Exemple #1
0
ViewportCore::ViewportCore(SoQtViewer *viewer)
	: viewer(viewer)
{
	manip = master->getViewportInstance();

	total = new SoSelection();
	total->policy = SoSelection::SINGLE;
	total->setPickFilterCallback(pickFilterCB);
	total->addSelectionCallback(selectCB, master);
	total->addDeselectionCallback(deselectCB, master);
	total->ref();

	camera = new SoPerspectiveCamera();
	total->addChild(camera);
	total->addChild(ViewportCore::sceneRoot);

	SoCallback *zClear = new SoCallback();
	zClear->setCallback(zClearCallback);
	total->addChild(zClear);

	camera->viewAll(total, viewer->getViewportRegion());

	total->addChild(manip->getRootNode());
	viewer->setSceneGraph(total);

	manip->setViewer(viewer);
}
Exemple #2
0
int
main(int argc, char ** argv)
{
  QWidget * win = SoQt::init("Debug Test");
  SoQtExaminerViewer * viewer = new SoQtExaminerViewer(win);
  viewer->show();
  SoQt::show(win);
  SoSeparator * sep = new SoSeparator;
  SoCallback * cb = new SoCallback;
  cb->setCallback(callback, sep);
  sep->addChild(cb);
  sep->addChild(new SoCube);
  viewer->setSceneGraph(sep);
  viewer->setViewing(FALSE);
  SoQt::mainLoop();
  viewer->hide();
  // delete viewer;
  return 0;
}
Exemple #3
0
SoSeparator *glowBranch(SoSeparator *geomHolder, SoMaterial *glowMat)
{
	SoSeparator *root = new SoSeparator();

	SoCallback *stFore = new SoCallback();
	stFore->setCallback(stencilCBfore);
	root->addChild(stFore);

	root->addChild(geomHolder); // 1st / normal instance

	// glow / background
	root->addChild(glowMat);

	SoDrawStyle *glowStyle = new SoDrawStyle();
	glowStyle->style = SoDrawStyle::LINES;
	glowStyle->lineWidth = 4;
	root->addChild(glowStyle);

	SoLightModel *lm = new SoLightModel();
	lm->model = SoLightModel::BASE_COLOR;
	root->addChild(lm);

	SoCallback *stBack = new SoCallback();
	stBack->setCallback(stencilCBback);
	root->addChild(stBack);

	root->addChild(geomHolder); // 2nd / glow instance

	SoCallback *stEnd = new SoCallback();
	stEnd->setCallback(stencilCBend);
	root->addChild(stEnd);

	return root;
}
  void init() {
    SoCallback* callbackNode = new SoCallback();
    callbackNode->setCallback( callbackCB, m_self );
    m_self->addChild( callbackNode );

  }
void BCIService::init(BCIControlWindow *bciControlWindow)
{
    ROS_INFO("Initing BCI Service");
    bciRenderArea = bciControlWindow->bciWorldView->renderArea;

    QPushButton * slowButton = new QPushButton("Flex Medium (Next)");
    QPushButton * fastButton = new QPushButton("Flex Hard (Select)");

    slowButton->setDefault(true);
    fastButton->setDefault(true);

    QDialogButtonBox *cursorControlBox = new QDialogButtonBox(Qt::Vertical);
    cursorControlBox->setCaption(QString("Cursor Control Box"));

    cursorControlBox->addButton(slowButton, QDialogButtonBox::ActionRole);
    cursorControlBox->addButton(fastButton, QDialogButtonBox::ActionRole);
    cursorControlBox->setWindowFlags(Qt::WindowStaysOnTopHint);
    cursorControlBox->resize(QSize(200,100));
    cursorControlBox->show();

    QObject::connect(slowButton, SIGNAL(clicked()), this, SLOT(updateControlSceneState1()));
    QObject::connect(fastButton, SIGNAL(clicked()), this, SLOT(updateControlSceneState2()));


    endOfExperimentFormat = new QFormLayout();

    successFailure = new QComboBox();
    successFailure->insertItem("Success");
    successFailure->insertItem("Failure");

    finalComments = new QTextEdit();

    finishedButton = new QPushButton("FINISHED");


    endOfExperimentFormat->addRow(tr("&Success or failure: "), successFailure);
    endOfExperimentFormat->addRow(tr("&Comments: "), finalComments);
    endOfExperimentFormat->addRow(tr(""), finishedButton);

    endOfExperiment = new QGroupBox();
    endOfExperiment->setLayout(endOfExperimentFormat);



    QObject::connect(finishedButton, SIGNAL(clicked()), this, SLOT(onFinishedFinalLog()));

    endOfExperiment->show();

    timer = new QTimer;
    QObject::connect(timer, SIGNAL(timeout()), this, SLOT(updateControlScene()));
    timer->start(1000 / 30);

    QObject::connect(this, SIGNAL(goToStateLow()), this, SLOT(updateControlSceneState0()));
    QObject::connect(this, SIGNAL(goToStateMedium()), this, SLOT(updateControlSceneState1()));
    QObject::connect(this, SIGNAL(goToStateHigh()), this, SLOT(updateControlSceneState2()));

    SoAnnotation *hudSeparator = new SoAnnotation;
    hudSeparator->renderCaching = SoSeparator::OFF;
    hudSeparator->setName("hud");
    graspitCore->getWorld()->getIVRoot()->addChild(hudSeparator);
    pcam = new SoOrthographicCamera;
    pcam->position = SbVec3f(0, 0, 10);
    pcam->nearDistance = 0.1;
    pcam->farDistance = 11;

    hudSeparator->addChild(pcam);
    SoLightModel * hudLightModel = new SoLightModel;
    hudLightModel->model=SoLightModel::BASE_COLOR;
    hudSeparator->addChild(hudLightModel);
    SoCallback * disableZTestNode = new SoCallback();
    disableZTestNode->setCallback(ui_tools::disableZCulling);
    hudSeparator->addChild(disableZTestNode);
    csm = new ControllerSceneManager(hudSeparator);

    BCIStateMachine *bciStateMachine = new BCIStateMachine(bciControlWindow,this);
    connect(this, SIGNAL(plannerUpdated()), bciControlWindow, SLOT(redraw()));
    connect(GraspManager::getInstance(), SIGNAL(render()), bciControlWindow, SLOT(redraw()));
    bciStateMachine->start();

    ROS_INFO("Finished initing BCI Service");
}