int SoXipSegmentationOverlayManager::SetupOverlayAction ( SoHandleEventAction* action, SoXipShape *pshape ) { // Maximal distance between two consecutive mouse down positions // allowed to generate a double-click. int DoubleClickMaxJump = 2; // Maximal time between two mouse clicks to be considered as a // double-click. SbTime DoubleClickTime = SbTime(0.5); // Time corresponding to a click SbTime ClickTime = SbTime(0.1); if (pshape == NULL) return ( 0 ) ; const SbString& classname = shapeClassName.getValue(); char *szName = (char*)classname.getString () ; if (szName == NULL) return ( 0 ) ; SoDebugError::postInfo ( szName, "test" ) ; SbVec3f pos; const SbVec2s& mousePosition = action->getEvent()->getPosition() ; //if( SO_MOUSE_RELEASE_EVENT( action->getEvent(), BUTTON1 ) && action->getGrabber() == this ) if( SO_MOUSE_RELEASE_EVENT( action->getEvent(), BUTTON1 )) { SoDebugError::postInfo ( szName, "test" ) ; mMouseUpTime = action->getEvent()->getTime(); { } } else if( SO_MOUSE_PRESS_EVENT( action->getEvent(), BUTTON1 ) ) { SbTime tim = action->getEvent()->getTime(); // Compute the distance between the last mouse press event and this one SbVec2s v = (mMouseDownPos - mousePosition); float mouseJump = sqrtf( v.dot(v) ); // Do not perform a double-click if the time between two mouse press // events is higher than the default time set for double-clicks, or if // the mouse jumped further than the tolerance set (without tolerance // it is more difficult to get a double-click. if ( (tim - mMouseDownTime) < DoubleClickTime && mouseJump < DoubleClickMaxJump ) { mMouseDownTime = SbTime::zero(); mMouseDownPos = SbVec2s(-1, -1); } else { mMouseDownTime = action->getEvent()->getTime() ; } } return ( 1 ) ; }
/*! Default constructor. */ SoOneShot::SoOneShot(void) { SO_ENGINE_INTERNAL_CONSTRUCTOR(SoOneShot); SO_ENGINE_ADD_INPUT(timeIn, (SbTime::zero())); SO_ENGINE_ADD_INPUT(duration, (SbTime(1.0))); SO_ENGINE_ADD_INPUT(trigger, ()); SO_ENGINE_ADD_INPUT(flags, (0)); SO_ENGINE_ADD_INPUT(disable, (FALSE)); SO_ENGINE_ADD_OUTPUT(timeOut, SoSFTime); SO_ENGINE_ADD_OUTPUT(isActive, SoSFBool); SO_ENGINE_ADD_OUTPUT(ramp, SoSFFloat); SO_ENGINE_DEFINE_ENUM_VALUE(Flags, RETRIGGERABLE); SO_ENGINE_DEFINE_ENUM_VALUE(Flags, HOLD_FINAL); SO_ENGINE_SET_SF_ENUM_TYPE(flags, Flags); SoField * realtime = SoDB::getGlobalField("realTime"); this->timeIn.connectFrom(realtime); this->running = FALSE; this->starttime = SbTime::zero(); this->holdramp = 0.0f; this->holdduration = SbTime::zero(); }
//! Constructor SoUMDViewerTrigger::SoUMDViewerTrigger() { // Execute inventor internal stuff for node construction. SO_NODE_CONSTRUCTOR(SoUMDViewerTrigger); //SO_NODE_ADD_FIELD(ViewerNameFld, ("UndefindedName")); SO_NODE_ADD_FIELD(StatusFld, ("Ready")); //SO_NODE_ADD_FIELD(PongFld, ("Ready")); //SO_NODE_ADD_FIELD(PositionFld, (0,0,0)); //SO_NODE_ADD_FIELD(OrientationFld, (0,0,0,0)); //SO_NODE_ADD_FIELD(ForceRedrawFld, ()); timerSensor = new SoTimerSensor((SoSensorCB*)SoUMDViewerTrigger::timerEvent, this); timerSensor->setInterval(SbTime(1.0/50.0)); //timerSensor->setInterval(SbTime(1.0/1.0)); //!!!!ACHTUNG NUR ZUM VERLANGSAMEN FÜR EUROVISPAPER timerSensor->unschedule(); currentlyLeft = false; frameRendered = true; // Create a sensor calling nodeChangedCB if any field changes. //_nodeSensor = new SoNodeSensor((SoSensorCB*)SoUMDViewerTrigger::_nodeChangedCB, this); //_nodeSensor->attach(this); // Set priority of sensor. Priority 0 forces direct call which is needed for correct field detection. //_nodeSensor->setPriority(0); }
void DBaseBatchPlanner::plannerComplete() { if (mPlanner->isActive()) { DBGAF(mLogStream,"Planner is not finished!"); return; } //this prints the remainins solutions plannerUpdate(); DBGAF(mLogStream,"Planner completed; starting shutdown"); if (mType == GRIPPER) { graspitCore->getWorld()->destroyElement(mHand,false); fprintf(stderr,"Taking scans...\n"); takeScans(); } if (mResultFile!=stderr && mResultFile!=stdout) fclose(mResultFile); //schedule the sensor to give us the exit signal in 3 seconds //this should give the planner time to finish mTimerSensor = new SoTimerSensor(sensorCB, this); mTimerSensor->setInterval( SbTime( 3.0 )); mTimerSensor->schedule(); }
SbTime operator *(const SbTime &tm, double s) // //////////////////////////////////////////////////////////////////////// { return SbTime(tm.getValue() * s); }
/*! Acts as a contructor. Sets the default Flock mode (RELATIVE) and default master bird (1). */ void SensorInputDlg::init(World *w) { mWorld = w; mGloveRunning = false; mFlockRunning = false; mPcbirdRunning = false; mFlock = NULL; mPcbird = NULL; mGlove = NULL; mTimerSensor = new SoTimerSensor(timerStaticCB, this); //timer interval, in seconds mTimerSensor->setInterval( SbTime(0.05) ); mNumBirds = 1; flockModeBox->insertItem("Relative"); flockModeBox->insertItem("Camera"); flockModeBox->insertItem("Absolute"); pcbirdModeBox->insertItem("Camera"); pcbirdModeBox->insertItem("Absolute"); pcbirdModeBox->setCurrentIndex(1); masterFlockBox->setMinimum(1); masterFlockBox->setMaximum(9); masterFlockBox->setValue(1); mMasterBird = 1; mFlockMode = FLOCK_RELATIVE; }
void EmptyTask::start() { mSensor = new SoTimerSensor(sensorCB, this); mSensor->setInterval( SbTime( 4.0 )); mSensor->schedule(); mStatus = RUNNING; DBGA("Empty task has started"); }
TaskDispatcher::TaskDispatcher() : mDBMgr(NULL) , mCurrentTask(NULL), mStatus(READY) { //note that we do not also schedule this guy mSensor = new SoTimerSensor(sensorCB, this); mSensor->setInterval( SbTime( 3.0 )); //hard-coded for now mMaxTasks = -1; mCompletedTasks = 0; }
SbTime::SbTime(double sec) // //////////////////////////////////////////////////////////////////////// { if (sec >= 0) { t.tv_sec = int(sec); t.tv_usec = (time_t) (0.5 + (sec - t.tv_sec) * 1000000.0); } else *this = -SbTime(-sec); }
const SoEvent * SoSimpleMouse::translateEvent(MSG * msg) { SoEvent * soevent = (SoEvent *) NULL; SoButtonEvent::State state = SoButtonEvent::UNKNOWN; switch (msg->message) { case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MOUSEWHEEL: if (!(eventmask & SoSimpleMouse::BUTTON_PRESS)) break; state = SoButtonEvent::DOWN; soevent = makeButtonEvent(msg, state); break; case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: if (!(eventmask & SoSimpleMouse::BUTTON_RELEASE)) break; state = SoButtonEvent::UP; soevent = makeButtonEvent(msg, state); break; case WM_MOUSEMOVE: if (!(eventmask & SoSimpleMouse::POINTER_MOTION)) break; soevent = makeLocationEvent(msg); break; case WM_SETFOCUS: case WM_KILLFOCUS: default: break; } if(soevent) { long msec = ::GetTickCount(); soevent->setTime(SbTime((msec / 1000), (msec % 1000) * 1000)); } return (SoEvent*) soevent; }
//---------------------------------------------------------------------------------- //! Constructor //---------------------------------------------------------------------------------- METKAutoFading::METKAutoFading (void) : inherited(0,0,ObjMgrClient::EVENTS_SELECTED) { ML_TRACE_IN("METKAutoFading::METKAutoFading()") myObjMgr = new ObjMgrCommunicator(); myCamera = new kCamera(); FieldContainer *fields = getFieldContainer(); // Suppress calls of handleNotification on field changes. handleNotificationOff(); _outScene = getFieldContainer()->addSoNode("outScene"); (_EnableFading = fields->addBool("EnableFading"))->setBoolValue(FALSE); (_UseMETKValues = fields->addBool("UseMETKValues"))->setBoolValue(FALSE); (_CurrentObject = fields->addString("CurrentObject"))->setStringValue(""); (_ViewerName = fields->addString("ViewerName"))->setStringValue("METKViewer3D"); _init = fields->addNotify("init"); _calc = fields->addNotify("calc"); (_dataPath = fields->addString("dataPath"))->setStringValue(""); _similarPosition = fields->addVec3f("similarPosition"); _camPosition = fields->addVec3f("camPosition"); _camOrientation = fields->addVec4f("camOrientation"); setAcceptedEvents(); m_soViewer = new SoVisDataViewer(); _outScene->setSoNodeValue(m_soViewer); oReceiver = new METKMsgReceiver(); oReceiver->messageFld->setStringValue("fading"); /*_message = (StringField*) getFieldContainer()->addField(oReceiver->getFieldContainer()->getField("message")); _messageData = (StringField*) getFieldContainer()->addField(oReceiver->getFieldContainer()->getField("data"));*/ _message = getFieldContainer()->addString("message"); oReceiver->messageFld->attachField(_message,0); _messageData = getFieldContainer()->addString("data"); oReceiver->getFieldContainer()->getField("data")->attachField(_messageData,0); timerSensor = new SoTimerSensor((SoSensorCB*)METKAutoFading::timerEvent, this); timerSensor->setInterval(SbTime(1.0/1000.0)); timerSensor->unschedule(); // Reactivate calls of handleNotification on field changes. handleNotificationOn(); }
SbTime operator -(const SbTime &t0, const SbTime &t1) // //////////////////////////////////////////////////////////////////////// { int32_t sec; long usec; // System long sec = t0.t.tv_sec - t1.t.tv_sec; usec = t0.t.tv_usec - t1.t.tv_usec; while (usec < 0 && sec > 0) { usec += 1000000; sec -= 1; } return SbTime(sec, usec); }