void SofaHAPIHapticsDevice::setForceFeedbacks(vector<ForceFeedback*> ffs) { bool xfer = false; for (int i=feedbackEffects.size()-1; i>=0; --i) { SofaHAPIForceFeedbackEffect::SPtr ffe = feedbackEffects[i]; removeSlave(ffe.get()); if (device.get() && ffe->getEffect()) { device->removeEffect(ffe->getEffect()); xfer = true; } feedbackEffects.remove(ffe); } //feedbackEffects.clear(); if (xfer) device->transferObjects(); for (unsigned int i=0; i<ffs.size(); ++i) { SofaHAPIForceFeedbackEffect::SPtr ffe = sofa::core::objectmodel::New<SofaHAPIForceFeedbackEffect>(); ffe->setForceFeedback(ffs[i]); std::ostringstream name; name << "Tool"<<ffs[i]->indice.getValue() <<"-" << ffs[i]->getName(); ffe->setName(name.str()); ForceFeedbackEffect* e = ffe->getEffect(); e->setTransform(data); e->permanent_feedback = permanent.getValue(); addSlave(ffe.get()); feedbackEffects.add(ffe); } }
void VlcWidget::setAudioTrack (QAction *action) { if (action->data ().isNull ()) addSlave (); else { int track = action->data ().toInt (); VlcPlayer_->setAudioTrack (track); } }
ViewerQT::ViewerQT(QWidget * parent, const char * name, const QGLWidget * shareWidget, WindowFlags f): AdapterWidget( parent, name, shareWidget, f) { setCamera(this->getCamera()); // Camera getCamera()->setViewport(new osg::Viewport(0,0,width(),height())); getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(width())/static_cast<double>(height()), 1.0f, 10000.0f); getCamera()->setGraphicsContext(getGraphicsWindow()); getCamera()->setClearColor(osg::Vec4d(51/255.0, 51/255.0, 102/255.0, 0)); getCamera()->setViewMatrix(osg::Matrix::identity()); // // getCamera()->setProjectionMatrixAsOrtho2D(0,1280,0,1024); // // getCamera()->setClearColor(osg::Vec4d(1, 1, 1, 0)); // getCamera()->setReferenceFrame(osg::Transform::ABSOLUTE_RF); // getCamera()->setClearMask(GL_DEPTH_BUFFER_BIT); // getCamera()->setRenderOrder(osg::Camera::POST_RENDER); // getCamera()->setUpdateCallback(new AxisCameraUpdateCallback()); // QString axespath = QCoreApplication::applicationDirPath() + "/axes.osg"; // osg::Node* axes = osgDB::readNodeFile(axespath.toLatin1().data()); // qDebug()<<axes->asGroup()->getNumChildren(); // qDebug()<<axespath; // getCamera()->addChild(axes); // Trackball m_rpTrackball = new osgGA::TrackballManipulator; // setCameraManipulator(m_rpTrackball.get()); addEventHandler(new osgGA::StateSetManipulator(getCamera()->getOrCreateStateSet())); // addEventHandler(new osgViewer::WindowSizeHandler); addEventHandler(new osgViewer::StatsHandler); // Scene root m_rpSceneGroupRoot = new osg::Group; setSceneData(m_rpSceneGroupRoot.get()); osg::Camera* camera = createHUD(); addSlave(camera, false); m_rpSceneGroupRoot->addChild(camera); osgText::Text* text = new osgText::Text; m_rpSceneGroupRoot->addChild( createHUD_viewPoint( text));//加入HUD文字 // pickHandler = new PickHandler; // addEventHandler(pickHandler); addEventHandler(new PickDragHandler(text)); osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator; keyswitchManipulator->addMatrixManipulator(1,"Trackball",new osgGA::TrackballManipulator()); keyswitchManipulator->addMatrixManipulator(2,"Flight",new osgGA::FlightManipulator()); keyswitchManipulator->addMatrixManipulator(3,"Drive",new osgGA::DriveManipulator()); keyswitchManipulator->addMatrixManipulator(4,"Terrain",new osgGA::TerrainManipulator()); setCameraManipulator(keyswitchManipulator.get()); setThreadingModel(osgViewer::Viewer::SingleThreaded); connect(&_timer, SIGNAL(timeout()), this, SLOT(updateGL())); _timer.start(10); }
void ossimPlanetViewer::addEphemeris(ossim_uint32 memberBitMask) { if(!theEphemerisLayer.valid()) { if(getLight()) { theSavedLight = (osg::Light*)getLight()->clone(osg::CopyOp::DEEP_COPY_ALL); } ossimPlanet* tempPlanet = new ossimPlanet; tempPlanet->setComputeIntersectionFlag(false); theEphemerisRoot = tempPlanet; theEphemerisLayer = new ossimPlanetEphemeris(); theEphemerisLayer->setRoot(theRootNode.get()); theEphemerisLayer->setMembers(memberBitMask); // planet()->addChild(theEphemerisLayer.get()); tempPlanet->addChild(theEphemerisLayer.get()); theRootNode->addChild(tempPlanet); theEphemerisCamera = new osg::Camera; theEphemerisCamera->setProjectionResizePolicy(getCamera()->getProjectionResizePolicy()); theEphemerisCamera->setClearColor(getCamera()->getClearColor()); theEphemerisCamera->setRenderOrder(osg::Camera::PRE_RENDER); theEphemerisCamera->setRenderTargetImplementation( getCamera()->getRenderTargetImplementation() ); // theEphemerisCamera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); // getCamera()->setClearMask(getCamera()->getClearMask() & ~GL_COLOR_BUFFER_BIT & ~GL_DEPTH_BUFFER_BIT); theEphemerisCamera->setClearMask(GL_COLOR_BUFFER_BIT); getCamera()->setClearMask(getCamera()->getClearMask() & ~GL_COLOR_BUFFER_BIT); if(getCamera()->getViewport()) { theEphemerisCamera->setViewport(new osg::Viewport(*getCamera()->getViewport())); } else { theEphemerisCamera->setViewport(new osg::Viewport()); } addSlave(theEphemerisCamera.get(), false); theEphemerisLayer->setCamera(theEphemerisCamera.get()); theEphemerisCamera->setEventCallback(new ossimPlanetTraverseCallback()); theEphemerisCamera->setUpdateCallback(new ossimPlanetTraverseCallback()); theEphemerisCamera->setCullCallback(new ossimPlanetTraverseCallback()); //theEphemerisCamera->addChild(theRootNode.get()); //getCamera()->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); //theEphemerisCamera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); //double fov, aspectRatio, near, far; //osg::Matrixd& m = getCamera()->getProjectionMatrix(); //m.getPerspective(fov, aspectRatio, near, far); //theEphemerisCamera->setProjectionMatrixAsPerspective(fov, aspectRatio, .2, 5.0); //getCamera()->setProjectionMatrixAsPerspective(fov, aspectRatio, .0000001, .2); } }
// Actual allocation is done by an instance of real allocator, // which is specified by the template parameter. TestAllocator() : real(createAllocator<T>()) { // We use 'ON_CALL' and 'WillByDefault' here to specify the // default actions (call in to the real allocator). This allows // the tests to leverage the 'DoDefault' action. // However, 'ON_CALL' results in a "Uninteresting mock function // call" warning unless each test puts expectations in place. // As a result, we also use 'EXPECT_CALL' and 'WillRepeatedly' // to get the best of both worlds: the ability to use 'DoDefault' // and no warnings when expectations are not explicit. ON_CALL(*this, initialize(_, _, _)) .WillByDefault(InvokeInitialize(this)); EXPECT_CALL(*this, initialize(_, _, _)) .WillRepeatedly(DoDefault()); ON_CALL(*this, recover(_, _)) .WillByDefault(InvokeRecover(this)); EXPECT_CALL(*this, recover(_, _)) .WillRepeatedly(DoDefault()); ON_CALL(*this, addFramework(_, _, _, _, _)) .WillByDefault(InvokeAddFramework(this)); EXPECT_CALL(*this, addFramework(_, _, _, _, _)) .WillRepeatedly(DoDefault()); ON_CALL(*this, removeFramework(_)) .WillByDefault(InvokeRemoveFramework(this)); EXPECT_CALL(*this, removeFramework(_)) .WillRepeatedly(DoDefault()); ON_CALL(*this, activateFramework(_)) .WillByDefault(InvokeActivateFramework(this)); EXPECT_CALL(*this, activateFramework(_)) .WillRepeatedly(DoDefault()); ON_CALL(*this, deactivateFramework(_)) .WillByDefault(InvokeDeactivateFramework(this)); EXPECT_CALL(*this, deactivateFramework(_)) .WillRepeatedly(DoDefault()); ON_CALL(*this, updateFramework(_, _, _)) .WillByDefault(InvokeUpdateFramework(this)); EXPECT_CALL(*this, updateFramework(_, _, _)) .WillRepeatedly(DoDefault()); ON_CALL(*this, addSlave(_, _, _, _, _, _)) .WillByDefault(InvokeAddSlave(this)); EXPECT_CALL(*this, addSlave(_, _, _, _, _, _)) .WillRepeatedly(DoDefault()); ON_CALL(*this, removeSlave(_)) .WillByDefault(InvokeRemoveSlave(this)); EXPECT_CALL(*this, removeSlave(_)) .WillRepeatedly(DoDefault()); ON_CALL(*this, updateSlave(_, _, _, _)) .WillByDefault(InvokeUpdateSlave(this)); EXPECT_CALL(*this, updateSlave(_, _, _, _)) .WillRepeatedly(DoDefault()); ON_CALL(*this, addResourceProvider(_, _, _)) .WillByDefault(InvokeAddResourceProvider(this)); EXPECT_CALL(*this, addResourceProvider(_, _, _)) .WillRepeatedly(DoDefault()); ON_CALL(*this, activateSlave(_)) .WillByDefault(InvokeActivateSlave(this)); EXPECT_CALL(*this, activateSlave(_)) .WillRepeatedly(DoDefault()); ON_CALL(*this, deactivateSlave(_)) .WillByDefault(InvokeDeactivateSlave(this)); EXPECT_CALL(*this, deactivateSlave(_)) .WillRepeatedly(DoDefault()); ON_CALL(*this, updateWhitelist(_)) .WillByDefault(InvokeUpdateWhitelist(this)); EXPECT_CALL(*this, updateWhitelist(_)) .WillRepeatedly(DoDefault()); ON_CALL(*this, requestResources(_, _)) .WillByDefault(InvokeRequestResources(this)); EXPECT_CALL(*this, requestResources(_, _)) .WillRepeatedly(DoDefault()); ON_CALL(*this, updateAllocation(_, _, _, _)) .WillByDefault(InvokeUpdateAllocation(this)); EXPECT_CALL(*this, updateAllocation(_, _, _, _)) .WillRepeatedly(DoDefault()); ON_CALL(*this, updateAvailable(_, _)) .WillByDefault(InvokeUpdateAvailable(this)); EXPECT_CALL(*this, updateAvailable(_, _)) .WillRepeatedly(DoDefault()); ON_CALL(*this, updateUnavailability(_, _)) .WillByDefault(InvokeUpdateUnavailability(this)); EXPECT_CALL(*this, updateUnavailability(_, _)) .WillRepeatedly(DoDefault()); ON_CALL(*this, updateInverseOffer(_, _, _, _, _)) .WillByDefault(InvokeUpdateInverseOffer(this)); EXPECT_CALL(*this, updateInverseOffer(_, _, _, _, _)) .WillRepeatedly(DoDefault()); ON_CALL(*this, getInverseOfferStatuses()) .WillByDefault(InvokeGetInverseOfferStatuses(this)); EXPECT_CALL(*this, getInverseOfferStatuses()) .WillRepeatedly(DoDefault()); ON_CALL(*this, recoverResources(_, _, _, _)) .WillByDefault(InvokeRecoverResources(this)); EXPECT_CALL(*this, recoverResources(_, _, _, _)) .WillRepeatedly(DoDefault()); ON_CALL(*this, suppressOffers(_, _)) .WillByDefault(InvokeSuppressOffers(this)); EXPECT_CALL(*this, suppressOffers(_, _)) .WillRepeatedly(DoDefault()); ON_CALL(*this, reviveOffers(_, _)) .WillByDefault(InvokeReviveOffers(this)); EXPECT_CALL(*this, reviveOffers(_, _)) .WillRepeatedly(DoDefault()); ON_CALL(*this, setQuota(_, _)) .WillByDefault(InvokeSetQuota(this)); EXPECT_CALL(*this, setQuota(_, _)) .WillRepeatedly(DoDefault()); ON_CALL(*this, removeQuota(_)) .WillByDefault(InvokeRemoveQuota(this)); EXPECT_CALL(*this, removeQuota(_)) .WillRepeatedly(DoDefault()); ON_CALL(*this, updateWeights(_)) .WillByDefault(InvokeUpdateWeights(this)); EXPECT_CALL(*this, updateWeights(_)) .WillRepeatedly(DoDefault()); ON_CALL(*this, pause()) .WillByDefault(InvokePause(this)); EXPECT_CALL(*this, pause()) .WillRepeatedly(DoDefault()); ON_CALL(*this, resume()) .WillByDefault(InvokeResume(this)); EXPECT_CALL(*this, resume()) .WillRepeatedly(DoDefault()); }
osaOSGStereo::osaOSGStereo( osaOSGWorld* world, int x, int y, int width, int height, const vctFixedSizeMatrix<double,3,3>& Kl, const vctFixedSizeMatrix<double,3,3>& Kr, const vctFrame4x4<double>& vctRt, double zNear, double zFar, bool trackball, const vctFrame4x4<double>& Rtoffset ) : osaOSGCamera( world, trackball, Rtoffset ), x( x ), // x position y( y ), // y position width( width ), // width of images height( height ), baseline( baseline ){ double x0 = 0; double y0 = 0; // Set the intrinsic paramters getCamera()->setProjectionMatrix( osg::Matrixd() ); // Setup the left camera { osg::Matrixd K; double K00 = Kl[0][0]; // 526.0554; double K11 = Kl[1][1]; // 525.0756; double K02 = Kl[0][2]; // 313.2596; double K12 = Kl[1][2]; // 233.6962; K( 0, 0 ) = 2*K00/width; K( 1, 0 ) = 0.0; K( 2, 0 ) = (width - 2*K02 + 2*x0)/width; K( 3, 0 ) = 0; K( 0, 1 ) = 0.0; K( 1, 1 ) = 2*K11/height; K( 2, 1 ) = (-height + 2*K12 + 2*y0)/height; K( 3, 1 ) = 0; K( 0, 2 ) = 0.0; K( 1, 2 ) = 0.0; K( 2, 2 ) = (-zFar - zNear)/(zFar - zNear); K( 3, 2 ) = -2*zFar*zNear/(zFar - zNear); K( 0, 3 ) = 0.0; K( 1, 3 ) = 0.0; K( 2, 3 ) = -1; K( 3, 3 ) = 0.0; // Create a new (slave) camera osg::ref_ptr<osg::Camera> camera = new osg::Camera; // Create the view port. Again, the reason why the viewport is created // here is because the SVL stuff in the final draw callback needs to be // created during the constructor camera->setViewport( new osg::Viewport( 0, 0, width, height) ); // add this slave camera to the viewer, with a shift left of the // projection matrix addSlave( camera.get(), K, osg::Matrixd() ); } // setup the right camera { osg::Matrixd K; double K00 = Kr[0][0]; // 534.6877; double K11 = Kr[1][1]; // 533.5979; double K02 = Kr[0][2]; // 327.7359; double K12 = Kr[1][2]; // 249.4243; K( 0, 0 ) = 2*K00/width; K( 1, 0 ) = 0.0; K( 2, 0 ) = (width - 2*K02 + 2*x0)/width; K( 3, 0 ) = 0; K( 0, 1 ) = 0.0; K( 1, 1 ) = 2*K11/height; K( 2, 1 ) = (-height + 2*K12 + 2*y0)/height; K( 3, 1 ) = 0; K( 0, 2 ) = 0.0; K( 1, 2 ) = 0.0; K( 2, 2 ) = -(zFar + zNear)/(zFar - zNear); K( 3, 2 ) = -2*zFar*zNear/(zFar - zNear); K( 0, 3 ) = 0.0; K( 1, 3 ) = 0.0; K( 2, 3 ) = -1; K( 3, 3 ) = 0.0; osg::Matrixd osgRt( vctRt[0][0], vctRt[1][0], vctRt[2][0], 0.0, vctRt[0][1], vctRt[1][1], vctRt[2][1], 0.0, vctRt[0][2], vctRt[1][2], vctRt[2][2], 0.0, vctRt[0][3], vctRt[1][3], vctRt[2][3], 1.0 ); // Create a new (slave) camera osg::ref_ptr<osg::Camera> camera = new osg::Camera; // Create the view port. Again, the reason why the viewport is created // here is because the SVL stuff in the final draw callback needs to be // created during the constructor camera->setViewport( new osg::Viewport( 0, 0, width, height) ); // add this slave camera to the viewer, with a shift right of the // projection matrix addSlave( camera.get(), K, osgRt ); } }
osaOSGStereo::osaOSGStereo( osaOSGWorld* world, int x, int y, int width, int height, double fovy, double aspectRatio, double zNear, double zFar, double baseline, bool trackball, const vctFrame4x4<double>& Rtoffset ) : osaOSGCamera( world, trackball, Rtoffset ), x( x ), // x position y( y ), // y position width( width ), // width of images height( height ), baseline( baseline ){ double K00 = 533.401729541061854; double K11 = 532.351481757753163; double K02 = 327.972320586762351/1000.0; double K12 = 247.901576976705911/1000.0; double x0 = 0; double y0 = 0; osg::Matrixd K; K( 0, 0 ) = 2*K00/width; K( 1, 0 ) = 0.0; K( 2, 0 ) = (2*K02 + 2*x0)/width - 1.0; K( 3, 0 ) = 0; K( 0, 1 ) = 0.0; K( 1, 1 ) = 2*K11/height; K( 2, 1 ) = (2*K12 + 2*y0)/height -1.0; K( 3, 1 ) = 0; K( 0, 2 ) = 0.0; K( 1, 2 ) = 0.0; K( 2, 2 ) = -(zFar + zNear)/(zFar - zNear); K( 3, 2 ) = -2*zFar*zNear/(zFar - zNear); K( 0, 3 ) = 0.0; K( 1, 3 ) = 0.0; K( 2, 3 ) = -1; K( 3, 3 ) = 0; // Set the intrinsic paramters getCamera()->setProjectionMatrixAsPerspective(fovy,aspectRatio,zNear,zFar); K = getCamera()->getProjectionMatrix( ); // Setup the left camera { // Create a new (slave) camera osg::ref_ptr<osg::Camera> camera = new osg::Camera; // Create the view port. Again, the reason why the viewport is created // here is because the SVL stuff in the final draw callback needs to be // created during the constructor camera->setViewport( new osg::Viewport( 0, 0, width, height) ); // add this slave camera to the viewer, with a shift left of the // projection matrix addSlave( camera.get(), osg::Matrixd(), osg::Matrixd() ); // Only do drawing callback if OpenCV is enabled #ifdef SAW_OPENSCENEGRAPH_SUPPORTS_OPENCV // Create a drawing callback. This callback is set to capture // depth+color buffer (true, true) osg::ref_ptr<osaOSGCamera::FinalDrawCallback> finaldrawcallback; try{ finaldrawcallback = new FinalDrawCallback( camera ); } catch( std::bad_alloc& ){ CMN_LOG_RUN_ERROR << CMN_LOG_DETAILS << "Failed to allocate FinalDrawCallback." << std::endl; } CMN_ASSERT( finaldrawcallback ); camera->setFinalDrawCallback( finaldrawcallback ); #endif //SAW_OPENSCENEGRAPH_SUPPORTS_OPENCV } // setup the right camera { // Create a new (slave) camera osg::ref_ptr<osg::Camera> camera = new osg::Camera; // Create the view port. Again, the reason why the viewport is created // here is because the SVL stuff in the final draw callback needs to be // created during the constructor camera->setViewport( new osg::Viewport( 0, 0, width, height) ); // add this slave camera to the viewer, with a shift right of the // projection matrix addSlave( camera.get(), osg::Matrixd(), osg::Matrixd() ); // Only do drawing callback if OpenCV is enabled #ifdef SAW_OPENSCENEGRAPH_SUPPORTS_OPENCV // Create a drawing callback. This callback is set to capture // depth+color buffer (true, true) osg::ref_ptr<osaOSGCamera::FinalDrawCallback> finaldrawcallback; try{ finaldrawcallback = new FinalDrawCallback( camera ); } catch( std::bad_alloc& ){ CMN_LOG_RUN_ERROR << CMN_LOG_DETAILS << "Failed to allocate FinalDrawCallback." << std::endl; } CMN_ASSERT( finaldrawcallback ); camera->setFinalDrawCallback( finaldrawcallback ); #endif // SAW_OPENSCENEGRAPH_SUPPORTS_OPENCV } }
int main(int argc, char** argv) { printf("i2c c test.\n"); int fd[2]; unsigned char buf[10]; char *fileName = "/dev/i2c-1"; int addr[2] = {0x29, 0x39}; // Adressen der Chips openPort(&fd[0]); openPort(&fd[1]); addSlave(addr[0], &fd[0]); addSlave(addr[1], &fd[1]); int i; int readcount[2] = {0, 1}; double maxlux = 0.0; int maxCh0 = 0; //Variablen zur Berechnung des Lichteinfalls int cLow[2] = {65536, 65536}; int cHigh[2] = {0, 0}; double cc[2] = {0.0, 0.0}; double maxcc[2] = {0.0, 0.0}; double lastcc[2] = {0.0, 0.0}; double epsilon = 0.01; //Variablen zur Aktivierung der Dosen: int active[2] = {0, 0}; double actThr = 0.1; //Schwellenwert um Verdunklung zu erkennen //initialisiere OSC: lo_address oscaddr = initOSC("192.168.1.8", "7777"); while(1) { for(i = 0; i < 2; i++) { cc[i] = readLight(&fd[i], &cLow[i], &cHigh[i]); readcount[i]++; if(cc[i] > maxcc[i]) { maxcc[i] = cc[i]; } if(readcount[i] >= 3) { if(active[i]) { if((lastcc[i] > maxcc[i] + epsilon) || (lastcc[i] < maxcc[i] - epsilon)) { //Lichtintensitaet hat sich signifikant geaendert -> Ausgabe! printf("%d Licht: %f\n", i, maxcc[i]); if(i == 0) sendOSC(&oscaddr, "/licht0", maxcc[i]); else if(i == 1) sendOSC(&oscaddr, "/licht1", maxcc[i]); lastcc[i] = maxcc[i]; } } else { if(maxcc[i] > (1.0 - actThr)) { printf("Dose %d ist jetzt aktiv.\n", i); active[i] = 1; } } readcount[i] = 0; maxcc[i] = 0.0; } } /* lo_address t = lo_address_new("192.168.1.8", "7777"); if(lo_send(t, "/light", "f", cc) == -1) { printf("OSC Fehler: %s\n", lo_address_errstr(t)); }*/ usleep(13 * 1000); } return 0; }