void UMDSoMeasureTool::getObject() { // EventCallback fuer die Mousebutton-Ereignisse SoEventCallback* eventCB = new SoEventCallback; _root->addChild(eventCB); eventCB->addEventCallback(SoMouseButtonEvent::getClassTypeId(), mousePressedCB, this); eventCB->addEventCallback(SoKeyboardEvent::getClassTypeId(), cursorPressCB, this); // hier wird ein LevelOfDetail-Knoten angehaengt, // der fuer die Font-Groesse verantwortlich ist SoLevelOfDetail* lod = (SoLevelOfDetail*) getLOD(); _root->addChild(lod); // Das Material und die Linienstaerke _objectMaterial = new SoMaterial; _root->addChild(_objectMaterial); _objectMaterial->diffuseColor.connectFrom(&color); // Switch-Knoten, der die Dragger enthaelt _switchDragger = new SoSwitch; _root->addChild(_switchDragger); // der Inhaber aller LocateHighlight-Knoten _highlightSep = new SoSeparator; _root->addChild(_highlightSep); _textSep = new SoAnnotation; _root->addChild(_textSep); // der Text soll zwar sichtbar, aber nicht // selektierbar sein SoPickStyle* pickstyle = new SoPickStyle; _textSep->addChild(pickstyle); pickstyle->style.setValue(SoPickStyle::UNPICKABLE); } //getObject
void InventorViewer::init(const char * windowName, float bck_r, float bck_g, float bck_b) { if (viewWindow) { ROS_ERROR("InventorViewer already initialized"); return; } viewWindow = SoQt::init(windowName); viewer = new SoQtExaminerViewer(viewWindow); viewer->setBackgroundColor(SbColor(bck_r,bck_g,bck_b)); root = new SoSelection(); root->ref(); SoEventCallback * ecb = new SoEventCallback(); ecb->addEventCallback(SoMouseButtonEvent::getClassTypeId(), InventorViewer::mouseBtnCB, this); root->addChild(ecb); initialized = true; }
ManipWidget::ManipWidget(ManipViewportInstance *inst, char *name) { this->name = name; this->inst = inst; this->xform = inst->getTransform(); this->viewer = NULL; this->affected = NULL; this->root = new SoSeparator(); SoEventCallback *eventCB = new SoEventCallback(); eventCB->addEventCallback(SoLocation2Event::getClassTypeId(), ManipWidget::mouseMoveCB, this); eventCB->addEventCallback(SoMouseButtonEvent::getClassTypeId(), ManipWidget::mouseButtonCB, this); root->addChild(eventCB); this->highlighted = NULL; this->isDragging = false; this->isActive = false; }
// Forward Declarations SoSeparator* startUpScene(SoNode* avatar) { //************************************************************** // ================ STARTING WORLD STRUCTURE ================== // Separator (root0) // | // Selection Node (root)__ ----> selection_callback // |______________ ----> un_select_callback // | // Camera Node // | // World Skeleton & Floor // from external files // | // Avatar ( Separator ) // | // Event Callback Node (for keyboard) -->kbd_callback function // | // One Shot sensor ( repeat keyboard status check ) // _____________________|_________________________________ // | | | | // Separator Separator Separator Separator //(sciences area) (bioSciences) (Arts Area) (Unassigned area) // | | | | // Translation Translation Translation Translation // //************************************************************** // callbacks for selecting objects SoSelection* root = new SoSelection; selection = root; root->ref(); root->addSelectionCallback( made_selection, (void *)1L ); root->addDeselectionCallback( made_selection, (void *)0L ); root->policy = SoSelection::TOGGLE; //CAMERA camera = new SoPerspectiveCamera(); camera->nearDistance = 4; camera->farDistance = 4096; root->addChild( camera ); root->addChild( get_scene_graph_from_file("/usr/local/share/l3dclient/world.wrl") ); root->addChild( get_scene_graph_from_file("/usr/local/share/l3dclient/grass.wrl") ); root->addChild( avatar ); ////////// move camera and avatar with directional keys // keyboard handling SoEventCallback *cb = new SoEventCallback; cb->addEventCallback(SoKeyboardEvent::getClassTypeId(), keyboardEvent_cb, NULL); root->insertChild(cb, 0); // sensor for infinite processing of simulationStep SoOneShotSensor *sensor = new SoOneShotSensor(simulationStep, NULL); sensor->schedule(); SoSeparator* scienceArea = new SoSeparator; SoTranslation* sciTransl = new SoTranslation; sciTransl->translation.setValue(150, 0 ,150 ); scienceArea->setName(VRML_UTILS_SCIENCES_AREA_NAME); root->addChild( scienceArea ); scienceArea->addChild( sciTransl ); scienceArea->addChild( get_scene_graph_from_file("/usr/local/share/l3dclient/flag_sci.wrl") ); SoSeparator* bioArea = new SoSeparator; SoTranslation* bioTransl = new SoTranslation; bioTransl->translation.setValue(-150, 0 ,150 ); bioArea->setName(VRML_UTILS_BIO_AREA_NAME); root->addChild( bioArea ); bioArea->addChild( bioTransl ); bioArea->addChild( get_scene_graph_from_file("/usr/local/share/l3dclient/flag_bio.wrl") ); SoSeparator* artsArea = new SoSeparator; SoTranslation* artsTransl = new SoTranslation; artsTransl->translation.setValue(150, 0 ,-150 ); artsArea->setName(VRML_UTILS_ARTS_AREA_NAME); root->addChild( artsArea ); artsArea->addChild( artsTransl ); artsArea->addChild( get_scene_graph_from_file("/usr/local/share/l3dclient/flag_arts.wrl") ); SoSeparator* freeArea = new SoSeparator; SoTranslation* freeTransl = new SoTranslation; freeTransl->translation.setValue(-150, 0 ,-150 ); freeArea->setName(VRML_UTILS_FREE_AREA_NAME); root->addChild( freeArea ); freeArea->addChild( freeTransl ); freeArea->addChild( get_scene_graph_from_file("/usr/local/share/l3dclient/flag_free.wrl") ); // load resources from server root->unrefNoDelete(); return root; }
int main(int argc, char** argv) { // init Inventor HWND w = SoWin::init(argv[0]); SoWinExaminerViewer * v = new SoWinExaminerViewer(w); //Preguntar donde iria SoViewportRegion::initClass(); // Iniciamos la escena SoSeparator *root = new SoSeparator; root->ref(); root->addChild(new SoUnits); Pointers * mypointers= new Pointers(); //De este separador colgará la escena que se carga de //fichero, así como las cámaras y luces encargadas de //mostrarla SoSeparator *ojo_izq= new SoSeparator; //Partimos la pantalla SoViewportRegion *vp1 = new SoViewportRegion(); vp1->height=0.4f; vp1->width=0.2f; vp1->y_pos=0.6f; vp1->x_pos=0.0f; vp1->onTop=TRUE; ojo_izq->addChild(vp1); //Introducimos una nueva cámara. Esta cámara pintará //los draggers siempre en la misma posición SoFrustumCamera *cam = new SoFrustumCamera(); ojo_izq->addChild(cam); SoSeparator * escena = new SoSeparator; LightControl * luces; luces = new LightControl(escena); CheckStick * mystickcontrol; mypointers->lights=luces; mypointers->viewer=v; SoSeparator *habitacion=new SoSeparator; SoTransform * centrar = new SoTransform; //centrar->translation.setValue(60.0f,-60.0f,60.0f); centrar->translation.setValue(0,-1.f,0.5f); //centrar->scaleFactor.setValue(0.0001f,0.0001f,0.0001f);//bateria wena //centrar->scaleFactor.setValue(3.f,3.f,3.f); habitacion->addChild(centrar); //Desplazamiento de la pantalla // model SoFile *model = new SoFile; if (argc > 1) model->name.setValue(argv[1]); else model->name.setValue("drumconparedes.wrl"); habitacion->addChild(model); escena->addChild(habitacion); SoSeparator * esqueleto= new SoSeparator; DrawCoin::CrearEsqueleto(esqueleto); mystickcontrol=new CheckStick(DrawCoin::t_cabeza,DrawCoin::t_mano_izq,DrawCoin::t_mano_der); mypointers->sticks=mystickcontrol; escena->addChild(esqueleto); ojo_izq->addChild (escena); //Colocamos la camara de modo que pueda ver toda la escena cam->viewAll(escena,vp1->getViewportRegion()); //cam->position.setValue(0.0f,10.0f,-10.f); //cam->orientation.setValue(SbVec3f(0.0f,-1.f,1.f),0); //De este separador colgará la escena que se carga de //fichero, así como las cámaras y luces encargadas de //mostrarla SoSeparator *ojo_der= new SoSeparator; root->addChild (ojo_der); root->addChild (ojo_izq); //Partimos la pantalla SoViewportRegion *vp2 = new SoViewportRegion(); vp2->height=1.0f; vp2->width=1.0f; vp2->x_pos=0.0f; vp2->onTop=FALSE; ojo_der->addChild(vp2); //Introducimos una nueva cámara. Esta cámara pintará //los draggers siempre en la misma posición SoFrustumCamera * cam2; cam2 = new SoFrustumCamera(); mypointers->camera2=cam2; //cam2->farDistance = 3.f; ojo_der->addChild(cam2); SoTransform * cabeza; SoRotation * rotacion; cabeza=DrawCoin::Get_Cabeza_Pos(); rotacion=DrawCoin::Get_Cabeza_Rot(); cam2->position.connectFrom(&cabeza->translation); cam2->orientation.connectFrom(&rotacion->rotation); ojo_der->addChild (escena); //Colocamos la camara de modo que pueda ver toda la escena cam2->viewAll(escena,vp2->getViewportRegion()); cam2->viewportMapping = SoCamera::LEAVE_ALONE; cam2->position.setValue(0.0f,0.0f,0.0f); int Data_Of_Thread = 1; HANDLE Handle_Of_Thread; Handle_Of_Thread = CreateThread( NULL, 0, Thread, &Data_Of_Thread, 0, NULL); if ( Handle_Of_Thread == NULL) ExitProcess(Data_Of_Thread); //Creamos un sensor encargado del render SoTimerSensor* rendertimer = new SoTimerSensor(renderCallback,(void *)mypointers); rendertimer->setInterval(FPS); rendertimer->schedule(); SoEventCallback *eventCB = new SoEventCallback; eventCB->addEventCallback(SoKeyboardEvent::getClassTypeId(),handle_keyboard,(void*)mypointers); root->addChild(eventCB); v->setBackgroundColor(SbColor(0.0f, 0.2f, 0.3f)); v->setFeedbackVisibility(TRUE); v->setSceneGraph(root); //v->setViewing(FALSE); v->setTitle("Kinect Tracking"); v->setAutoRedraw(FALSE); ///v->setDecoration(FALSE); SoWin::show(w); SoWin::mainLoop(); root->unref(); delete v; return 0; }
ObjectSimpleViewer:: ObjectSimpleViewer( bool is3D, bool isBlending): QWidget( 0, Qt::SubWindow | Qt::Window), root(NULL), views_root_s(NULL), views_root_t(NULL), blinker_root(NULL), m_clipPlaneManip(NULL), m_clipPlane(NULL), m_clipManipulatorButtonBi(NULL), m_obliqueSliceButton(NULL), m_clipLandmarkButton(NULL), m_blinkButton(NULL), m_mixSlider(NULL), m_viewAll(true) { QLayout *mix = NULL; if(isBlending) { QGridLayout * l2 = new QGridLayout; m_mixSlider = new QSlider(Qt::Vertical, NULL);; l2->addWidget(m_mixSlider, 0, 0, Qt::AlignBottom | Qt::AlignHCenter); m_mixSlider->setRange(0, 100); m_mixSlider->setSingleStep(1); m_mixSlider->setPageStep(10); m_mixSlider->setValue(100); QLabel * label = new QLabel("Mix", NULL); label->setAlignment(Qt::AlignLeft | Qt::AlignTop); label->setMargin(0); l2->addWidget(label, 1, 0, Qt::AlignTop | Qt::AlignHCenter); mix = l2; QWidget::connect(m_mixSlider, SIGNAL(valueChanged(int)), this, SLOT(transparencyChanged(int))); } QList <QWidget*> *buttons=new QList <QWidget*>; QIcon icon; //blink button on/off icon.addPixmap(QPixmap(QString::fromUtf8(":/icons/images/blink.png")), QIcon::Normal); m_blinkButton=new QPushButton(this); m_blinkButton->setCheckable(true); m_blinkButton->setChecked(false); m_blinkButton->setIcon(icon); m_blinkButton->setToolTip("Flash source on/off"); m_blinkButton->setVisible(false); connect(m_blinkButton, SIGNAL(clicked(bool)), this, SLOT(setFlashSourceTarget(bool))); if(is3D) { m_clipManipulatorButtonBi=new ClipPlaneButtonBiDirection(this); m_clipManipulatorButtonBi->setCheckable(false); m_clipManipulatorButtonBi->setToolTip("Clip manipulator on/clip/off"); buttons->append(m_clipManipulatorButtonBi); icon.addPixmap(QPixmap( QString::fromUtf8(":/icons/images/orthosliceon.png")), QIcon::Normal, QIcon::Off); icon.addPixmap(QPixmap( QString::fromUtf8(":/icons/images/orthosliceoff.png")), QIcon::Normal, QIcon::On); m_obliqueSliceButton=new QPushButton(this); m_obliqueSliceButton->setCheckable(true); m_obliqueSliceButton->setIcon(icon); m_obliqueSliceButton->setToolTip("Oblique slice on/off"); buttons->append(m_obliqueSliceButton); //landmark clip on/off icon.addPixmap(QPixmap( QString::fromUtf8(":/icons/images/cuttinglandmarksoff.png")), QIcon::Normal, QIcon::Off); icon.addPixmap( QPixmap(QString::fromUtf8(":/icons/images/cuttinglandmarkson.png")), QIcon::Normal, QIcon::On); m_clipLandmarkButton=new QPushButton(this); m_clipLandmarkButton->setCheckable(true); m_clipLandmarkButton->setChecked(true); m_clipLandmarkButton->setIcon(icon); m_clipLandmarkButton->setToolTip("Clip landmarks on/off"); m_clipLandmarkButton->setVisible(false); buttons->append(m_clipLandmarkButton); buttons->append(m_blinkButton); m_viewer = (Viewer2D3D*) new Viewer3D(this, mix, buttons); connect(m_clipManipulatorButtonBi, SIGNAL(stateChanged(ClipPlaneButton::statetype)), this, SLOT(stateChanged(ClipPlaneButton::statetype))); } else { buttons->append(m_blinkButton); m_viewer = (Viewer2D3D *)new Viewer2D(this, mix, buttons); } Q_ASSERT(m_viewer); root = new SoSeparator; Q_ASSERT(root); root->ref(); SoEventCallback * cb = new SoEventCallback; cb->addEventCallback(SoMouseButtonEvent::getClassTypeId(), mouseEventCB, this); root->insertChild(cb, 0); blinker_root = new SoSwitch; Q_ASSERT(blinker_root); blinker_root->ref(); blinker_root->whichChild = 0; // select non blinking SoSeparator* noblinker = new SoSeparator; Q_ASSERT(noblinker); blinker_root->addChild(noblinker); SoBlinker* blinker = new SoBlinker; Q_ASSERT(blinker); blinker->on = true; blinker_root->addChild(blinker); views_root_s = new SoSeparator; Q_ASSERT(views_root_s); blinker->addChild(views_root_s); noblinker->addChild(views_root_s); views_root_t = new SoSeparator; Q_ASSERT(views_root_t); blinker->addChild(views_root_t); noblinker->addChild(views_root_t); root->addChild(blinker_root); m_viewer ->setSceneGraph(root); //this has to go in the Editor m_activateAction = new QAction (this); m_activateAction -> setCheckable(true); connect(m_activateAction, SIGNAL(triggered()), this, SLOT(show())); connect(m_activateAction, SIGNAL(triggered()), this, SLOT(raise())); connect(m_activateAction, SIGNAL(triggered()), this, SLOT(setFocus())); this->setSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding ); }