void Viewportal::updatePixmap() { pixmap = QPixmap::grabWindow(QApplication::desktop()->winId (), 0, 51, screenX/2, screenY); setSimulation(false); QImage image = daltonize(pixmap.toImage(), getColorblindType()); pixmap = QPixmap::fromImage(image); setPixmap (pixmap); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , m_update_pending(false), m_animating(false) { m_oglviewer = new OGLViewer; ui.setupUi(this); ui.ogl_layout->addWidget(m_oglviewer); //connect(ui.actionAbout, SIGNAL(triggered()), this, SLOT(on_actionAbout_triggered())); setWindowTitle(tr("Spring")); m_oglviewer->setFocusPolicy(Qt::StrongFocus); connect(ui.play_button, SIGNAL(clicked()), this, SLOT(setSimulation())); connect(ui.init_button, &QPushButton::clicked, m_oglviewer, &OGLViewer::resetSim); connect(ui.init_button, &QPushButton::clicked, this, &MainWindow::setSpringProperty); connect(ui.scale_val, &QSlider::valueChanged, this, &MainWindow::setSpringProperty); connect(ui.ks_val, &QSlider::valueChanged, this, &MainWindow::setSpringProperty); connect(ui.kd_val, &QSlider::valueChanged, this, &MainWindow::setSpringProperty); connect(ui.spherex_val, &QSlider::valueChanged, this, &MainWindow::setSpringProperty); connect(ui.spherey_val, &QSlider::valueChanged, this, &MainWindow::setSpringProperty); connect(ui.spherez_val, &QSlider::valueChanged, this, &MainWindow::setSpringProperty); connect(ui.sphere_r_val, &QSlider::valueChanged, this, &MainWindow::setSpringProperty); connect(ui.ground_val, &QSlider::valueChanged, this, &MainWindow::setSpringProperty); }
void TPZNetworkSquareMidimew :: initialize() { if( isInitializated() ) return; /* Check consistency of parameters */ if(getSizeY()!=1 ||getSizeZ()!=1) { TPZString err; err.sprintf( ERR_TPZTONET_002, (char*)getRouterId() ); err.sprintf("\nSquare Midimew Network Ysize and Zsize must be 1. Al nodes in Xsize!"); EXIT_PROGRAM(err); } if((int)ceil(sqrt((float)getSizeX()))%2 || getSizeX() < 4 ) { TPZString err; err.sprintf( ERR_TPZTONET_002, (char*)getRouterId() ); err.sprintf("\n Square Midimew Network Xsize must be an even 2's power(4,16,64,256,1024,4096...)"); EXIT_PROGRAM(err); } if( !getSizeX() || !getSizeY() || !getSizeZ() ) { TPZString err; err.sprintf(ERR_TPZTONET_001, getSizeX(), getSizeY(), getSizeZ() ); EXIT_PROGRAM(err); } /* Create the routers for each node */ int i; for( i=0; i<getSizeX(); i++ ) { TPZPosition pos(i,0,0); TPZRouter* newRouter = (TPZRouter*) (TPZRouter::routerBuilder->createComponentWithId(getRouterId(),this)); if( ! newRouter ) { TPZString err; err.sprintf( ERR_TPZTONET_002, (char*)getRouterId() ); EXIT_PROGRAM(err); } newRouter->setPosition(pos); addRouter(newRouter); } /* Connect the routers together */ for( i=0; i<getSizeX(); i++ ) { initializeConnectionsFor(TPZPosition(i,0,0)); } /* Other initialization tasks */ generateRoutingTable(); setInitializated(true); setSimulation(getSimulation()); }
ViewSFML::ViewSFML(Simulation *sim) : window(sf::VideoMode::getDesktopMode(), window_name), logging(logLength) { setSimulation(std::shared_ptr<Simulation>(sim)); // Load resources if (!font.loadFromFile(selfpath() + "/" + fontName)) { throw std::runtime_error("unable to load font " + fontName); } }
void CANFestivalGui::initModule( ) { if( !driverLoaded ) { // load the driver. if allready loaded, a message to stdout occurs... system( "/sbin/insmod /home/rzullige/CanFestival/ArbraCan/arbracan.o can_silent=0 can_rate=125" ); driverLoaded = true; // open the canport (/dev/canx) if( ( fd = openDevice( ) ) < 0 ) { QMessageBox::information( this, "CANFestival GUI", "The CANport couln't be opened" ); return; } ui->initModuleButton->setText( "&De-Initialize CANPort" ); // set simulation mode to false, so real CAN message can be transmitted/received simulation = false; setSimulation( simulation ); // start log thread, which receives and shows all can messages (sniffer) mLogThread = new LogThread( ui->canReceiveLog, this ); mLogThread->start( ); } else { // unload driver module and close canport // stop logging thread (it would be useless in simulation mode) if(mLogThread) { mLogThread->stop( ); mLogThread = NULL; } // close device if( closeDevice( ) < 0 ) QMessageBox::information( this, "CANFestival GUI", "The CANport couln't be closed" ); // unload driver module for the can pci card (maybe not possible if the second port is opened by an other process) system( "/sbin/modprobe -r arbracan" ); // gui things ui->initModuleButton->setText( "&Initialize CANPort" ); driverLoaded = false; // set simulation mode to true setSimulation( simulation = true ); fd = -1; } }
/// Load a scene from a file Node::SPtr SceneLoaderXML::processXML(xml::BaseElement* xml, const char *filename) { loadSucceed = true; if ( xml==NULL ) { return NULL; } sofa::core::ExecParams* params = sofa::core::ExecParams::defaultInstance(); // We go the the current file's directory so that all relative path are correct helper::system::SetDirectory chdir ( filename ); // Temporarily set the numeric formatting locale to ensure that // floating-point values are interpreted correctly by tinyXML. (I.e. the // decimal separator is a dot '.'). helper::system::TemporaryLocale locale(LC_NUMERIC, "C"); sofa::simulation::xml::NodeElement* nodeElt = dynamic_cast<sofa::simulation::xml::NodeElement *>(xml); if( nodeElt==NULL ) { std::cerr << "LOAD ERROR: XML Root Node is not an Element."<<std::endl; loadSucceed = false; std::exit(EXIT_FAILURE); } else if( !(nodeElt->init()) ) { std::cerr << "LOAD ERROR: Node initialization failed."<<std::endl; loadSucceed = false; } core::objectmodel::BaseNode* baseroot = xml->getObject()->toBaseNode(); if ( baseroot == NULL ) { std::cerr << "LOAD ERROR: Objects initialization failed."<<std::endl; loadSucceed = false; return NULL; } Node::SPtr root = down_cast<Node> ( baseroot ); // Find the Simulation component in the scene FindByTypeVisitor<Simulation> findSimu(params); findSimu.execute(root.get()); if( !findSimu.found.empty() ) setSimulation( findSimu.found[0] ); return root; }