QXipIvWidget::QXipIvWidget(QWidget* parent, QGLWidget* shareWidget) : QWidget(parent) { m_cursorField = 0; m_sceneObject = 0; m_mouseDownPos = QPoint(-1, -1); m_width = 0; m_height = 0; m_root = 0; m_mouseMode = RESIZE_NONE; m_sceneManager = 0; m_isSceneManagerActive = false; setMouseTracking(true); setAutoFillBackground(false); m_sceneManager = new SoSceneManager; m_sceneManager->setGLRenderAction(new SoGLRenderAction(SbViewportRegion(512, 512))); m_sceneManager->setRenderCallback(renderSceneCbFunc_, this); m_sceneManager->setSceneGraph(ViewerCore::get()->getRootNode()); m_sceneManager->activate(); m_isSceneManagerActive = true; m_GLWidget = new QXipIvGLWidget(m_sceneManager, this, shareWidget); m_GLWidget->show(); m_GLWidget->setMouseTracking(true); QTimer* mIdleTimer = new QTimer(this); connect(mIdleTimer, SIGNAL(timeout()), this, SLOT(doIdleProcessing())); mIdleTimer->start(40); }
// -------------------------------------------------------------------------------------- int main(void) { WindowRef window; initialize(); // initialization gDone = false; while (!gDone) // application event loop { EventRecord event; if (WaitNextEvent(everyEvent, &event, ULONG_MAX, NULL)) { if (IsDialogEvent(&event)) HandleDialogEvents(&event); else handleEvents(&event); } else doIdleProcessing(); } // finalization for (window = FrontNonFloatingWindow(); window != NULL; window = FrontNonFloatingWindow()) { if (GetWindowKind(window) == kDialogWindowKind) ClosePrefsDialog(GetDialogFromWindow(window)); else // kApplicationWindowKind ClosePrefsWindow(window); } DisposeAEEventHandlerUPP(gOpenAppAEHandler); DisposeAEEventHandlerUPP(gQuitAppAEHandler); DisposeAEEventHandlerUPP(gViewsFontChangedAEHandler); return 0; }
rsRetVal wtiWorker(wti_t *pThis) { wtp_t *pWtp; /* our worker thread pool */ int bInactivityTOOccured = 0; rsRetVal localRet; rsRetVal terminateRet; int iCancelStateSave; DEFiRet; ISOBJ_TYPE_assert(pThis, wti); pWtp = pThis->pWtp; /* shortcut */ ISOBJ_TYPE_assert(pWtp, wtp); dbgSetThrdName(pThis->pszDbgHdr); pthread_cleanup_push(wtiWorkerCancelCleanup, pThis); pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &iCancelStateSave); /* now we have our identity, on to real processing */ while(1) { /* loop will be broken below - need to do mutex locks */ if(pWtp->pfRateLimiter != NULL) { /* call rate-limiter, if defined */ pWtp->pfRateLimiter(pWtp->pUsr); } d_pthread_mutex_lock(pWtp->pmutUsr); /* first check if we are in shutdown process (but evaluate a bit later) */ terminateRet = wtpChkStopWrkr(pWtp, MUTEX_ALREADY_LOCKED); if(terminateRet == RS_RET_TERMINATE_NOW) { /* we now need to free the old batch */ localRet = pWtp->pfObjProcessed(pWtp->pUsr, pThis); dbgoprint((obj_t*) pThis, "terminating worker because of TERMINATE_NOW mode, del iRet %d\n", localRet); d_pthread_mutex_unlock(pWtp->pmutUsr); break; } /* try to execute and process whatever we have */ /* Note that this function releases and re-aquires the mutex. The returned * information on idle state must be processed before releasing the mutex again. */ localRet = pWtp->pfDoWork(pWtp->pUsr, pThis); if(localRet == RS_RET_IDLE) { if(terminateRet == RS_RET_TERMINATE_WHEN_IDLE || bInactivityTOOccured) { d_pthread_mutex_unlock(pWtp->pmutUsr); dbgoprint((obj_t*) pThis, "terminating worker terminateRet=%d, bInactivityTOOccured=%d\n", terminateRet, bInactivityTOOccured); break; /* end of loop */ } doIdleProcessing(pThis, pWtp, &bInactivityTOOccured); d_pthread_mutex_unlock(pWtp->pmutUsr); continue; /* request next iteration */ } d_pthread_mutex_unlock(pWtp->pmutUsr); bInactivityTOOccured = 0; /* reset for next run */ } /* indicate termination */ pthread_cleanup_pop(0); /* remove cleanup handler */ pthread_setcancelstate(iCancelStateSave, NULL); RETiRet; }
QCtkXipSGWidget::QCtkXipSGWidget(QWidget *parent, QGLWidget * shareWidget) : QGLWidget(QGLFormat(QGL::AlphaChannel|QGL::StencilBuffer|QGL::DepthBuffer|QGL::Rgba), parent, shareWidget) { setAutoBufferSwap(false); setMouseTracking(true); mIdleTimer = new QTimer(this); connect(mIdleTimer, SIGNAL(timeout()), this, SLOT(doIdleProcessing())); mIdleTimer->start(40); mCursorField = 0; mSceneObject = 0; mMouseDownPos = QPoint(-1, -1); mWidth = 0; mHeight = 0; mSceneManager = 0; mRoot = 0; mIsSceneManagerActive = false; mQtInventorKeyMap[Qt::Key_0] = SoKeyboardEvent::NUMBER_0; mQtInventorKeyMap[Qt::Key_1] = SoKeyboardEvent::NUMBER_1; mQtInventorKeyMap[Qt::Key_2] = SoKeyboardEvent::NUMBER_2; mQtInventorKeyMap[Qt::Key_3] = SoKeyboardEvent::NUMBER_3; mQtInventorKeyMap[Qt::Key_4] = SoKeyboardEvent::NUMBER_4; mQtInventorKeyMap[Qt::Key_5] = SoKeyboardEvent::NUMBER_5; mQtInventorKeyMap[Qt::Key_6] = SoKeyboardEvent::NUMBER_6; mQtInventorKeyMap[Qt::Key_7] = SoKeyboardEvent::NUMBER_7; mQtInventorKeyMap[Qt::Key_8] = SoKeyboardEvent::NUMBER_8; mQtInventorKeyMap[Qt::Key_9] = SoKeyboardEvent::NUMBER_9; mQtInventorKeyMap[Qt::Key_A] = SoKeyboardEvent::A; mQtInventorKeyMap[Qt::Key_B] = SoKeyboardEvent::B; mQtInventorKeyMap[Qt::Key_C] = SoKeyboardEvent::C; mQtInventorKeyMap[Qt::Key_D] = SoKeyboardEvent::D; mQtInventorKeyMap[Qt::Key_E] = SoKeyboardEvent::E; mQtInventorKeyMap[Qt::Key_F] = SoKeyboardEvent::F; mQtInventorKeyMap[Qt::Key_G] = SoKeyboardEvent::G; mQtInventorKeyMap[Qt::Key_H] = SoKeyboardEvent::H; mQtInventorKeyMap[Qt::Key_I] = SoKeyboardEvent::I; mQtInventorKeyMap[Qt::Key_J] = SoKeyboardEvent::J; mQtInventorKeyMap[Qt::Key_K] = SoKeyboardEvent::K; mQtInventorKeyMap[Qt::Key_L] = SoKeyboardEvent::L; mQtInventorKeyMap[Qt::Key_M] = SoKeyboardEvent::M; mQtInventorKeyMap[Qt::Key_N] = SoKeyboardEvent::N; mQtInventorKeyMap[Qt::Key_O] = SoKeyboardEvent::O; mQtInventorKeyMap[Qt::Key_P] = SoKeyboardEvent::P; mQtInventorKeyMap[Qt::Key_Q] = SoKeyboardEvent::Q; mQtInventorKeyMap[Qt::Key_R] = SoKeyboardEvent::R; mQtInventorKeyMap[Qt::Key_S] = SoKeyboardEvent::S; mQtInventorKeyMap[Qt::Key_T] = SoKeyboardEvent::T; mQtInventorKeyMap[Qt::Key_U] = SoKeyboardEvent::U; mQtInventorKeyMap[Qt::Key_V] = SoKeyboardEvent::V; mQtInventorKeyMap[Qt::Key_W] = SoKeyboardEvent::W; mQtInventorKeyMap[Qt::Key_X] = SoKeyboardEvent::X; mQtInventorKeyMap[Qt::Key_Y] = SoKeyboardEvent::Y; mQtInventorKeyMap[Qt::Key_Z] = SoKeyboardEvent::Z; mQtInventorKeyMap[Qt::Key_Return] = SoKeyboardEvent::RETURN; mQtInventorKeyMap[Qt::Key_Enter] = SoKeyboardEvent::ENTER; mQtInventorKeyMap[Qt::Key_Insert] = SoKeyboardEvent::INSERT; mQtInventorKeyMap[Qt::Key_Delete] = SoKeyboardEvent::KEY_DELETE; mQtInventorKeyMap[Qt::Key_Pause] = SoKeyboardEvent::PAUSE; mQtInventorKeyMap[Qt::Key_Print] = SoKeyboardEvent::PRINT; mQtInventorKeyMap[Qt::Key_Home] = SoKeyboardEvent::HOME; mQtInventorKeyMap[Qt::Key_End] = SoKeyboardEvent::END; mQtInventorKeyMap[Qt::Key_Left] = SoKeyboardEvent::LEFT_ARROW; mQtInventorKeyMap[Qt::Key_Up] = SoKeyboardEvent::UP_ARROW; mQtInventorKeyMap[Qt::Key_Right] = SoKeyboardEvent::RIGHT_ARROW; mQtInventorKeyMap[Qt::Key_Down] = SoKeyboardEvent::DOWN_ARROW; mQtInventorKeyMap[Qt::Key_Escape] = SoKeyboardEvent::ESCAPE; mQtInventorKeyMap[Qt::Key_Tab] = SoKeyboardEvent::TAB; mQtInventorKeyMap[Qt::Key_Backspace] = SoKeyboardEvent::BACKSPACE; mQtInventorKeyMap[Qt::Key_PageUp] = SoKeyboardEvent::PAGE_UP; mQtInventorKeyMap[Qt::Key_PageDown] = SoKeyboardEvent::PAGE_DOWN; mQtInventorKeyMap[Qt::Key_Alt] = SoKeyboardEvent::LEFT_ALT; mQtInventorKeyMap[Qt::Key_CapsLock] = SoKeyboardEvent::CAPS_LOCK; mQtInventorKeyMap[Qt::Key_NumLock] = SoKeyboardEvent::NUM_LOCK; mQtInventorKeyMap[Qt::Key_ScrollLock] = SoKeyboardEvent::SCROLL_LOCK; mQtInventorKeyMap[Qt::Key_F1] = SoKeyboardEvent::F1; mQtInventorKeyMap[Qt::Key_F2] = SoKeyboardEvent::F2; mQtInventorKeyMap[Qt::Key_F3] = SoKeyboardEvent::F3; mQtInventorKeyMap[Qt::Key_F4] = SoKeyboardEvent::F4; mQtInventorKeyMap[Qt::Key_F5] = SoKeyboardEvent::F5; mQtInventorKeyMap[Qt::Key_F6] = SoKeyboardEvent::F6; mQtInventorKeyMap[Qt::Key_F7] = SoKeyboardEvent::F7; mQtInventorKeyMap[Qt::Key_F8] = SoKeyboardEvent::F8; mQtInventorKeyMap[Qt::Key_F9] = SoKeyboardEvent::F9; mQtInventorKeyMap[Qt::Key_F10] = SoKeyboardEvent::F10; mQtInventorKeyMap[Qt::Key_F11] = SoKeyboardEvent::F11; mQtInventorKeyMap[Qt::Key_F12] = SoKeyboardEvent::F12; mQtInventorKeyMap[Qt::Key_Space] = SoKeyboardEvent::SPACE; mQtInventorKeyMap[Qt::Key_Apostrophe] = SoKeyboardEvent::APOSTROPHE; mQtInventorKeyMap[Qt::Key_Asterisk] = SoKeyboardEvent::PAD_MULTIPLY; mQtInventorKeyMap[Qt::Key_Plus] = SoKeyboardEvent::PAD_ADD; mQtInventorKeyMap[Qt::Key_Comma] = SoKeyboardEvent::COMMA; mQtInventorKeyMap[Qt::Key_Minus] = SoKeyboardEvent::MINUS; mQtInventorKeyMap[Qt::Key_Period] = SoKeyboardEvent::PERIOD; mQtInventorKeyMap[Qt::Key_Slash] = SoKeyboardEvent::SLASH; mQtInventorKeyMap[Qt::Key_Semicolon] = SoKeyboardEvent::SEMICOLON; mQtInventorKeyMap[Qt::Key_BracketLeft] = SoKeyboardEvent::BRACKETLEFT; mQtInventorKeyMap[Qt::Key_BracketRight] = SoKeyboardEvent::BRACKETRIGHT; mQtInventorKeyMap[Qt::Key_Backslash] = SoKeyboardEvent::BACKSLASH; mQtInventorKeyMap[Qt::Key_BraceRight] = SoKeyboardEvent::BRACKETRIGHT; mQtInventorKeyMap[Qt::Key_BraceLeft] = SoKeyboardEvent::BRACKETLEFT; mQtInventorKeyMap[Qt::Key_Equal] = SoKeyboardEvent::EQUAL; mQtInventorKeyMap[Qt::Key_division] = SoKeyboardEvent::PAD_DIVIDE; mQtInventorKeyMap[Qt::Key_Agrave] = SoKeyboardEvent::GRAVE; }