Exemplo n.º 1
0
int
main(int , char **argv)
{
    // Initialize Inventor. This returns a main window to use.
    // If unsuccessful, exit.
    QWidget* myWindow = SoQt::init(argv[0]); // pass the app name
    if (myWindow == NULL) exit(1);

    // Make a scene containing a red cone
    SoSeparator *root = new SoSeparator;
    SoPerspectiveCamera *myCamera = new SoPerspectiveCamera;
    SoMaterial *myMaterial = new SoMaterial;
    root->ref();
    root->addChild(myCamera);
    root->addChild(new SoDirectionalLight);
    myMaterial->diffuseColor.setValue(1.0, 0.0, 0.0);   // Red
    root->addChild(myMaterial);


//   GsTL_SoNode::initClass();
    GsTL_SoNode* obj = new GsTL_SoNode;
    obj->addChild(new SoCone);
    root->addChild( obj );
    obj->visible = true;


    // Create a renderArea in which to see our scene graph.
    // The render area will appear within the main window.
    SoQtRenderArea *myRenderArea = new SoQtRenderArea(myWindow);

    // Make myCamera see everything.
    myCamera->viewAll(root, myRenderArea->getViewportRegion());

    // Put our scene in myRenderArea, change the title
    myRenderArea->setSceneGraph(root);
    myRenderArea->setTitle("Hello Cone");
    myRenderArea->show();

    SoQt::show(myWindow);  // Display main window
    SoQt::mainLoop();      // Main Inventor event loop
}
Exemplo n.º 2
0
//HandViewWindow:
//Set the HandViewWindow which contains he views themselves
HandViewWindow::HandViewWindow(QWidget * parent, Hand * h, const QRect & geom, SoNode * IVRoot, QWidget * stageFrame):currentPreviewIndex(-1),
maxViewSize(3), cloneHand(new Hand(h->getWorld(), "newHand")), geom_(geom), grid(NULL), stageFrame_(stageFrame)
{


  handViewWindow = new QFrame(NULL);
  handViewWindow->setWindowFlags(Qt::WindowStaysOnTopHint);
  viewHolder = new QFrame(NULL);
  handViewWindow->setGeometry(geom);
  hbox = new QHBoxLayout(handViewWindow);

    handViewWindow->show();
    viewHolder->setGeometry(0,0,2*geom_.width()/3,2*geom_.height()/3);
  viewHolder->setMinimumSize(2*geom_.width()/3,2*geom_.height()/3);
  viewHolder->setMaximumSize(2*geom_.width()/3,2*geom_.height()/3);
  viewHolder->setFrameStyle(QFrame::Box | QFrame::Raised);
 viewHolder->setLineWidth(2);
  if(IVRoot)
    {
      SoQtRenderArea * render = new SoQtRenderArea(viewHolder, " ",true);

      vbox1 = new QVBoxLayout();
      hbox->addLayout(vbox1);
      vbox1->addWidget(viewHolder);
      vbox1->addWidget(stageFrame);
      //render->setSceneGraph(IVRoot);
      SoSeparator * testRoot = new SoSeparator;
      //SoCone * testCone = new SoCone;
      //SoCamera * testCamera = new SoPerspectiveCamera;

      SoMaterial * testMaterial = new SoMaterial;

      testMaterial->diffuseColor.setValue(1,0,0);
      testRoot->addChild(graspItGUI->getIVmgr()->getViewer()->getCamera());
      SoTransformSeparator *lightSep = new SoTransformSeparator;
      SoRotation *lightDir = new SoRotation;
      lightDir->rotation.connectFrom(&graspItGUI->getIVmgr()->getViewer()->getCamera()->orientation);
      lightSep->addChild(lightDir);
      lightSep->addChild(graspItGUI->getIVmgr()->getViewer()->getHeadlight());
      SoLightModel * model = new SoLightModel;
      model->model=SoLightModel::PHONG;
      testRoot->addChild(lightSep);
      testRoot->addChild(model);
      testRoot->addChild(IVRoot);
      render->setSceneGraph(testRoot);
      render->setBackgroundColor(SbColor(1,1,1));
      render->scheduleRedraw();
      render->render();
      render->show();
    }
    vbox2 = new QVBoxLayout();
  vbox2->setGeometry(QRect(0,0,geom_.width()/3,geom_.height()));
  vbox2->setSizeConstraint(QLayout::SetMinimumSize);
  hbox->addLayout(vbox2);

 // vbox2->addWidget(new QWidget());
  //handViewWindow->setWindowFlags(Qt::WindowStaysOnTopHint);
  //handViewWindow->resize(QSize(900,100));
   //handViewFrame->setGeometry(geom_);
   handViewWindow->setFrameStyle(QFrame::Box | QFrame::Raised);
   handViewWindow->setLineWidth(4);


  cloneHand->cloneFrom(h);
  cloneHand->setTransparency(0.0);
  cloneHand->setRenderGeometry(false);
  cloneHand->showVirtualContacts(false);
  cloneHand->getWorld()->toggleCollisions(false, cloneHand);
}