void tst_QWidget_window::tst_recreateWindow_QTBUG40817() { QTabWidget tab; QWidget *w = new QWidget; tab.addTab(w, "Tab1"); QVBoxLayout *vl = new QVBoxLayout(w); QLabel *lbl = new QLabel("HELLO1"); lbl->setObjectName("label1"); vl->addWidget(lbl); w = new QWidget; tab.addTab(w, "Tab2"); vl = new QVBoxLayout(w); lbl = new QLabel("HELLO2"); lbl->setAttribute(Qt::WA_NativeWindow); lbl->setObjectName("label2"); vl->addWidget(lbl); tab.show(); QVERIFY(QTest::qWaitForWindowExposed(&tab)); QWindow *win = tab.windowHandle(); win->destroy(); QWindowPrivate *p = qt_window_private(win); p->create(true); win->show(); tab.setCurrentIndex(1); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); //#define ABC #ifdef ABC ParameterWidget *pw = new ParameterWidget(); pw->setProperties( "a", FloatParameterProperties() ); pw->setProperties( "b", FloatParameterProperties() ); pw->setProperties( "c", FloatParameterProperties() ); pw->setProperties( "d", FloatParameterProperties() ); pw->show(); #else QTabWidget *tw = new QTabWidget(); QScrollArea *sa = new QScrollArea( ); sa->setWidgetResizable( true ); QWidget *w = new QWidget( ); w->setLayout( new QVBoxLayout() ); w->layout()->addWidget( new CoordinateSystemWidget( "a", FloatParameterProperties(), "b", FloatParameterProperties(), w ) ); ( ( QVBoxLayout * ) w->layout() )->addStretch(); sa->setWidget( w ); tw->addTab( sa, "bla" ); tw->show(); app.processEvents(); w->layout()->addWidget( new CoordinateSystemWidget() ); #endif return app.exec(); }
int main ( int argc, char **argv ) { QApplication a( argc, argv ); QTabWidget tabWidget; SliderTab *sliderTab = new SliderTab(); sliderTab->setAutoFillBackground( true ); sliderTab->setPalette( QColor( "DimGray" ) ); WheelTab *wheelTab = new WheelTab(); wheelTab->setAutoFillBackground( true ); wheelTab->setPalette( QColor( "Silver" ) ); KnobTab *knobTab = new KnobTab(); knobTab->setAutoFillBackground( true ); knobTab->setPalette( Qt::darkGray ); DialTab *dialTab = new DialTab(); dialTab->setAutoFillBackground( true ); dialTab->setPalette( Qt::darkGray ); tabWidget.addTab( new SliderTab, "Slider" ); tabWidget.addTab( new WheelTab, "Wheel/Thermo" ); tabWidget.addTab( knobTab, "Knob" ); tabWidget.addTab( dialTab, "Dial" ); tabWidget.resize( 800, 600 ); tabWidget.show(); return a.exec(); }
void menuconfigproject::showsql() { QTabWidget *win = new QTabWidget(); win->addTab(new sqldatatable(QString("groupname, groupparent, type"), "project_" + this->name + "_groupe", 3), "groupe"); win->addTab(new sqldatatable(QString("lastname, firstname, email, groupid, refbool, questionbool"), "project_" + this->name + "_project", 6), "personne"); win->addTab(new sqldatatable(QString("question, groupid, type, note, sujet, qgroupid, typef, ref_only, splitchar"), "project_" + this->name + "_question", 9), "question"); win->setWindowModality(Qt::ApplicationModal); win->show(); }
int main (int argc, char **argv) { QApplication a(argc, argv); QTabWidget tabWidget; tabWidget.addTab(new CompassGrid, "Compass"); tabWidget.addTab(new CockpitGrid, "Cockpit"); tabWidget.show(); return a.exec(); }
int main(int argc,char **argv) { QApplication app(argc,argv); QLabel *label_first = new QLabel("first"); QLabel *label_second = new QLabel("second"); QTabWidget w; w.addTab(label_first,"first"); w.addTab(label_second,"second"); w.setWindowTitle("test for QTabWidget"); w.show(); return app.exec(); }
int main ( int argc, char **argv ) { QApplication a( argc, argv ); QTabWidget w; w.addTab( new PlotTab( false, &w ), "Non Parametric" ); w.addTab( new PlotTab( true, &w ), "Parametric" ); const QSize sz = 0.6 * QApplication::desktop()->size(); w.resize( sz.boundedTo( QSize( 800, 600 ) ) ); w.show(); return a.exec(); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); Widget w1; Widget w2; QTabWidget tabWidget; tabWidget.setTabPosition(QTabWidget::South); tabWidget.addTab(&w1, "Instance 1"); tabWidget.addTab(&w2, "Instance 2"); tabWidget.show(); return a.exec(); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QTabWidget *tab = new QTabWidget; QTextEdit *edit = new QTextEdit; Widget *w = new Widget; tab->addTab(w, "edit"); tab->addTab(edit, "recv"); QObject::connect(w, SIGNAL(message(QString)), edit, SLOT(append(QString))); edit->append("plain text"); tab->show(); // Widget w; // w.show(); return a.exec(); }
int main( int argc, char **argv ) { QApplication a( argc, argv ); QTabWidget tab; Scribble scribble(&tab, "scribble"); TabletStats tabStats( &tab, "tablet stats" ); scribble.setMinimumSize( 500, 350 ); tabStats.setMinimumSize( 500, 350 ); tab.addTab(&scribble, "Scribble" ); tab.addTab(&tabStats, "Tablet Stats" ); a.setMainWidget( &tab ); if ( QApplication::desktop()->width() > 550 && QApplication::desktop()->height() > 366 ) tab.show(); else tab.showMaximized(); return a.exec(); }
static int dynamicNormalizerGuiMain(int argc, char* argv[]) { uint32_t versionMajor, versionMinor, versionPatch; MDynamicAudioNormalizer::getVersionInfo(versionMajor, versionMinor, versionPatch); //initialize application QApplication app(argc, argv); app.setWindowIcon(QIcon(":/res/chart_curve.png")); app.setStyle(new QPlastiqueStyle()); //create basic tab widget QTabWidget window; window.setWindowTitle(QString("Dynamic Audio Normalizer - Log Viewer [%1]").arg(QString().sprintf("v%u.%02u-%u", versionMajor, versionMinor, versionPatch))); window.setMinimumSize(640, 480); window.show(); //get arguments const QStringList args = app.arguments(); //choose input file const QString logFileName = (args.size() < 2) ? QFileDialog::getOpenFileName(&window, "Open Log File", QString(), QString("Log File (*.log)")) : args.at(1); if(logFileName.isEmpty()) { return EXIT_FAILURE; } //check for existence if(!(QFileInfo(logFileName).exists() && QFileInfo(logFileName).isFile())) { QMessageBox::critical(&window, QString().sprintf("Dynamic Audio Normalizer"), QString("Error: The specified log file could not be found!")); return EXIT_FAILURE; } //open the input file QFile logFile(logFileName); if(!logFile.open(QIODevice::ReadOnly | QIODevice::Text)) { QMessageBox::critical(&window, QString().sprintf("Dynamic Audio Normalizer"), QString("Error: The selected log file could not opened for reading!")); return EXIT_FAILURE; } //wrap into text stream QTextStream textStream(&logFile); textStream.setCodec("UTF-8"); double minValue = DBL_MAX; double maxValue = 0.0; unsigned int channels = 0; //parse header if(!parseHeader(textStream, channels)) { QMessageBox::critical(&window, QString("Dynamic Audio Normalizer"), QString("Error: Failed to parse the header of the log file!\nProbably the file is of an unsupported type.")); return EXIT_FAILURE; } //allocate buffers LogFileData *data = new LogFileData[channels]; QCustomPlot *plot = new QCustomPlot[channels]; //load data parseData(textStream, channels, data, minValue, maxValue); logFile.close(); //check data if((data[0].original.size() < 1) || (data[0].minimal.size() < 1) || (data[0].smoothed.size() < 1)) { QMessageBox::critical(&window, QString("Dynamic Audio Normalizer"), QString("Error: Failed to load data. Log file countains no valid data!")); delete [] data; delete [] plot; return EXIT_FAILURE; } //determine length of data unsigned int length = UINT_MAX; for(unsigned int c = 0; c < channels; c++) { length = qMin(length, (unsigned int) data[c].original.count()); length = qMin(length, (unsigned int) data[c].minimal .count()); length = qMin(length, (unsigned int) data[c].smoothed.count()); } //create x-axis steps QVector<double> steps(length); for(unsigned int i = 0; i < length; i++) { steps[i] = double(i); } //now create the plots for(unsigned int c = 0; c < channels; c++) { //init the legend plot[c].legend->setVisible(true); plot[c].legend->setFont(QFont("Helvetica", 9)); //create graph and assign data to it: createGraph(&plot[c], steps, data[c].original, Qt::blue, Qt::SolidLine, 1); createGraph(&plot[c], steps, data[c].minimal, Qt::green, Qt::SolidLine, 1); createGraph(&plot[c], steps, data[c].smoothed, Qt::red, Qt::DashLine, 2); //set plot names plot[c].graph(0)->setName("Local Max. Gain"); plot[c].graph(1)->setName("Minimum Filtered"); plot[c].graph(2)->setName("Final Smoothed"); //set axes labels: plot[c].xAxis->setLabel("Frame #"); plot[c].yAxis->setLabel("Gain Factor"); makeAxisBold(plot[c].xAxis); makeAxisBold(plot[c].yAxis); //set axes ranges plot[c].xAxis->setRange(0.0, length); plot[c].yAxis->setRange(minValue - 0.25, maxValue + 0.25); plot[c].yAxis->setScaleType(QCPAxis::stLinear); plot[c].yAxis->setTickStep(1.0); plot[c].yAxis->setAutoTickStep(false); //add title plot[c].plotLayout()->insertRow(0); plot[c].plotLayout()->addElement(0, 0, new QCPPlotTitle(&plot[c], QString("%1 (Channel %2/%3)").arg(QFileInfo(logFile).fileName(), QString::number(c+1), QString::number(channels)))); //show the plot plot[c].replot(); window.addTab(&plot[c], QString().sprintf("Channel #%u", c + 1)); } //run application window.showMaximized(); app.exec(); //clean up delete [] data; delete [] plot; return EXIT_SUCCESS; }
int main(int argc, char ** argv) { // configuration const double periodIO = 0.5 * cmn_ms; const double periodKinematics = 1.0 * cmn_ms; const double periodTeleop = 1.0 * cmn_ms; const double periodUDP = 20.0 * cmn_ms; // log configuration cmnLogger::SetMask(CMN_LOG_ALLOW_ALL); cmnLogger::SetMaskDefaultLog(CMN_LOG_ALLOW_ALL); cmnLogger::SetMaskFunction(CMN_LOG_ALLOW_ALL); cmnLogger::SetMaskClassMatching("mtsIntuitiveResearchKit", CMN_LOG_ALLOW_ALL); cmnLogger::AddChannel(std::cerr, CMN_LOG_ALLOW_ERRORS_AND_WARNINGS); // parse options cmnCommandLineOptions options; int firewirePort = 0; std::string gcmip = "-1"; std::string jsonMainConfigFile; std::string jsonCollectionConfigFile; typedef std::map<std::string, std::string> ConfigFilesType; ConfigFilesType configFiles; std::string masterName, slaveName; options.AddOptionOneValue("j", "json-config", "json configuration file", cmnCommandLineOptions::REQUIRED_OPTION, &jsonMainConfigFile); options.AddOptionOneValue("f", "firewire", "firewire port number(s)", cmnCommandLineOptions::OPTIONAL_OPTION, &firewirePort); options.AddOptionOneValue("g", "gcmip", "global component manager IP address", cmnCommandLineOptions::OPTIONAL_OPTION, &gcmip); options.AddOptionOneValue("c", "collection-config", "json configuration file for data collection", cmnCommandLineOptions::OPTIONAL_OPTION, &jsonCollectionConfigFile); // check that all required options have been provided std::string errorMessage; if (!options.Parse(argc, argv, errorMessage)) { std::cerr << "Error: " << errorMessage << std::endl; options.PrintUsage(std::cerr); return -1; } std::string arguments; options.PrintParsedArguments(arguments); std::cout << "Options provided:" << std::endl << arguments << std::endl; // make sure the json config file exists and can be parsed fileExists("JSON configuration", jsonMainConfigFile); std::ifstream jsonStream; jsonStream.open(jsonMainConfigFile.c_str()); Json::Value jsonConfig; Json::Reader jsonReader; if (!jsonReader.parse(jsonStream, jsonConfig)) { std::cerr << "Error: failed to parse configuration\n" << jsonReader.getFormattedErrorMessages(); return -1; } // start initializing the cisstMultiTask manager std::cout << "FirewirePort: " << firewirePort << std::endl; std::string processname = "dvTeleop"; mtsManagerLocal * componentManager = 0; if (gcmip != "-1") { try { componentManager = mtsManagerLocal::GetInstance(gcmip, processname); } catch(...) { std::cerr << "Failed to get GCM instance." << std::endl; return -1; } } else { componentManager = mtsManagerLocal::GetInstance(); } // create a Qt application and tab to hold all widgets mtsQtApplication * qtAppTask = new mtsQtApplication("QtApplication", argc, argv); qtAppTask->Configure(); componentManager->AddComponent(qtAppTask); // console mtsIntuitiveResearchKitConsole * console = new mtsIntuitiveResearchKitConsole("console"); componentManager->AddComponent(console); mtsIntuitiveResearchKitConsoleQtWidget * consoleGUI = new mtsIntuitiveResearchKitConsoleQtWidget("consoleGUI"); componentManager->AddComponent(consoleGUI); // connect consoleGUI to console componentManager->Connect("console", "Main", "consoleGUI", "Main"); // organize all widgets in a tab widget QTabWidget * tabWidget = new QTabWidget; tabWidget->addTab(consoleGUI, "Main"); // IO is shared accross components mtsRobotIO1394 * io = new mtsRobotIO1394("io", periodIO, firewirePort); // find name of button event used to detect if operator is present std::string operatorPresentComponent = jsonConfig["operator-present"]["component"].asString(); std::string operatorPresentInterface = jsonConfig["operator-present"]["interface"].asString(); //set defaults if (operatorPresentComponent == "") { operatorPresentComponent = "io"; } if (operatorPresentInterface == "") { operatorPresentInterface = "COAG"; } std::cout << "Using \"" << operatorPresentComponent << "::" << operatorPresentInterface << "\" to detect if operator is present" << std::endl; // setup io defined in the json configuration file const Json::Value pairs = jsonConfig["pairs"]; for (unsigned int index = 0; index < pairs.size(); ++index) { // master Json::Value jsonMaster = pairs[index]["master"]; std::string armName = jsonMaster["name"].asString(); std::string ioFile = jsonMaster["io"].asString(); fileExists(armName + " IO", ioFile); io->Configure(ioFile); // slave Json::Value jsonSlave = pairs[index]["slave"]; armName = jsonSlave["name"].asString(); ioFile = jsonSlave["io"].asString(); fileExists(armName + " IO", ioFile); io->Configure(ioFile); } componentManager->AddComponent(io); // connect ioGUIMaster to io mtsRobotIO1394QtWidgetFactory * robotWidgetFactory = new mtsRobotIO1394QtWidgetFactory("robotWidgetFactory"); componentManager->AddComponent(robotWidgetFactory); componentManager->Connect("robotWidgetFactory", "RobotConfiguration", "io", "Configuration"); robotWidgetFactory->Configure(); // add all IO GUI to tab mtsRobotIO1394QtWidgetFactory::WidgetListType::const_iterator iterator; for (iterator = robotWidgetFactory->Widgets().begin(); iterator != robotWidgetFactory->Widgets().end(); ++iterator) { tabWidget->addTab(*iterator, (*iterator)->GetName().c_str()); } tabWidget->addTab(robotWidgetFactory->ButtonsWidget(), "Buttons"); // setup arms defined in the json configuration file for (unsigned int index = 0; index < pairs.size(); ++index) { Json::Value jsonMaster = pairs[index]["master"]; std::string masterName = jsonMaster["name"].asString(); std::string masterPIDFile = jsonMaster["pid"].asString(); std::string masterKinematicFile = jsonMaster["kinematic"].asString(); std::string masterUDPIP = jsonMaster["UDP-IP"].asString(); short masterUDPPort = jsonMaster["UDP-port"].asInt(); fileExists(masterName + " PID", masterPIDFile); fileExists(masterName + " kinematic", masterKinematicFile); mtsIntuitiveResearchKitConsole::Arm * mtm = new mtsIntuitiveResearchKitConsole::Arm(masterName, io->GetName()); mtm->ConfigurePID(masterPIDFile); mtm->ConfigureArm(mtsIntuitiveResearchKitConsole::Arm::ARM_MTM, masterKinematicFile, periodKinematics); console->AddArm(mtm); if (masterUDPIP != "" || masterUDPPort != 0) { if (masterUDPIP != "" && masterUDPPort != 0) { std::cout << "Adding UDPStream component for master " << masterName << " to " << masterUDPIP << ":" << masterUDPPort << std::endl; mtsIntuitiveResearchKitUDPStreamer * streamer = new mtsIntuitiveResearchKitUDPStreamer(masterName + "UDP", periodUDP, masterUDPIP, masterUDPPort); componentManager->AddComponent(streamer); // connect to mtm interface to get cartesian position componentManager->Connect(streamer->GetName(), "Robot", mtm->Name(), "Robot"); // connect to io to get clutch events componentManager->Connect(streamer->GetName(), "Clutch", "io", "CLUTCH"); // connect to io to get coag events componentManager->Connect(streamer->GetName(), "Coag", "io", "COAG"); } else { std::cerr << "Error for master arm " << masterName << ", you can provided UDP-IP w/o UDP-port" << std::endl; exit(-1); } } Json::Value jsonSlave = pairs[index]["slave"]; std::string slaveName = jsonSlave["name"].asString(); std::string slavePIDFile = jsonSlave["pid"].asString(); std::string slaveKinematicFile = jsonSlave["kinematic"].asString(); fileExists(slaveName + " PID", slavePIDFile); fileExists(slaveName + " kinematic", slaveKinematicFile); mtsIntuitiveResearchKitConsole::Arm * psm = new mtsIntuitiveResearchKitConsole::Arm(slaveName, io->GetName()); psm->ConfigurePID(slavePIDFile); psm->ConfigureArm(mtsIntuitiveResearchKitConsole::Arm::ARM_PSM, slaveKinematicFile, periodKinematics); console->AddArm(psm); // PID Master GUI std::string masterPIDName = masterName + " PID"; mtsPIDQtWidget * pidMasterGUI = new mtsPIDQtWidget(masterPIDName, 8); pidMasterGUI->Configure(); componentManager->AddComponent(pidMasterGUI); componentManager->Connect(pidMasterGUI->GetName(), "Controller", mtm->PIDComponentName(), "Controller"); tabWidget->addTab(pidMasterGUI, masterPIDName.c_str()); // PID Slave GUI std::string slavePIDName = slaveName + " PID"; mtsPIDQtWidget * pidSlaveGUI = new mtsPIDQtWidget(slavePIDName, 7); pidSlaveGUI->Configure(); componentManager->AddComponent(pidSlaveGUI); componentManager->Connect(pidSlaveGUI->GetName(), "Controller", psm->PIDComponentName(), "Controller"); tabWidget->addTab(pidSlaveGUI, slavePIDName.c_str()); // Master GUI mtsIntuitiveResearchKitArmQtWidget * masterGUI = new mtsIntuitiveResearchKitArmQtWidget(mtm->Name() + "GUI"); masterGUI->Configure(); componentManager->AddComponent(masterGUI); tabWidget->addTab(masterGUI, mtm->Name().c_str()); // connect masterGUI to master componentManager->Connect(masterGUI->GetName(), "Manipulator", mtm->Name(), "Robot"); // Slave GUI mtsIntuitiveResearchKitArmQtWidget * slaveGUI = new mtsIntuitiveResearchKitArmQtWidget(psm->Name() + "GUI"); slaveGUI->Configure(); componentManager->AddComponent(slaveGUI); tabWidget->addTab(slaveGUI, psm->Name().c_str()); // connect slaveGUI to slave componentManager->Connect(slaveGUI->GetName(), "Manipulator", psm->Name(), "Robot"); // Teleoperation std::string teleName = masterName + "-" + slaveName; mtsTeleOperationQtWidget * teleGUI = new mtsTeleOperationQtWidget(teleName + "GUI"); teleGUI->Configure(); componentManager->AddComponent(teleGUI); tabWidget->addTab(teleGUI, teleName.c_str()); mtsTeleOperation * tele = new mtsTeleOperation(teleName, periodTeleop); // Default orientation between master and slave vctMatRot3 master2slave; master2slave.From(vctAxAnRot3(vct3(0.0, 0.0, 1.0), 180.0 * cmnPI_180)); tele->SetRegistrationRotation(master2slave); componentManager->AddComponent(tele); // connect teleGUI to tele componentManager->Connect(teleGUI->GetName(), "TeleOperation", tele->GetName(), "Setting"); componentManager->Connect(tele->GetName(), "Master", mtm->Name(), "Robot"); componentManager->Connect(tele->GetName(), "Slave", psm->Name(), "Robot"); componentManager->Connect(tele->GetName(), "Clutch", "io", "CLUTCH"); componentManager->Connect(tele->GetName(), "OperatorPresent", operatorPresentComponent, operatorPresentInterface); console->AddTeleOperation(tele->GetName()); } // configure data collection if needed if (options.IsSet("collection-config")) { // make sure the json config file exists fileExists("JSON data collection configuration", jsonCollectionConfigFile); mtsCollectorFactory * collectorFactory = new mtsCollectorFactory("collectors"); collectorFactory->Configure(jsonCollectionConfigFile); componentManager->AddComponent(collectorFactory); collectorFactory->Connect(); mtsCollectorQtWidget * collectorQtWidget = new mtsCollectorQtWidget(); tabWidget->addTab(collectorQtWidget, "Collection"); mtsCollectorQtFactory * collectorQtFactory = new mtsCollectorQtFactory("collectorsQt"); collectorQtFactory->SetFactory("collectors"); componentManager->AddComponent(collectorQtFactory); collectorQtFactory->Connect(); collectorQtFactory->ConnectToWidget(collectorQtWidget); } // show all widgets tabWidget->show(); //-------------- create the components ------------------ io->CreateAndWait(2.0 * cmn_s); // this will also create the pids as they are in same thread io->StartAndWait(2.0 * cmn_s); // start all other components componentManager->CreateAllAndWait(2.0 * cmn_s); componentManager->StartAllAndWait(2.0 * cmn_s); // QtApplication will run in main thread and return control // when exited. componentManager->KillAllAndWait(2.0 * cmn_s); componentManager->Cleanup(); // delete dvgc robot delete io; delete robotWidgetFactory; // stop all logs cmnLogger::Kill(); return 0; }
int main(int argc, char** argv) { // program deprecated std::cout << "-----------------------------------------------------------" << std::endl << "- This program is deprecated: -" << std::endl << "- use dvrk_console_json instead -" << std::endl << "- examples can be found in share/jhu-dVRK/console*.json -" << std::endl << "-----------------------------------------------------------" << std::endl << std::endl; // desired frequencies const double ioPeriod = 0.5 * cmn_ms; const double armPeriod = 2.0 * cmn_ms; const double rosPeriod = 10.0 * cmn_ms; // log configuration cmnLogger::SetMask(CMN_LOG_ALLOW_ALL); cmnLogger::SetMaskDefaultLog(CMN_LOG_ALLOW_ALL); cmnLogger::SetMaskFunction(CMN_LOG_ALLOW_ALL); cmnLogger::AddChannel(std::cerr, CMN_LOG_ALLOW_ERRORS_AND_WARNINGS); // ---- WARNING: hack to remove ros args ---- ros::V_string argout; ros::removeROSArgs(argc, argv, argout); argc = argout.size(); // ------------------------------------------ // parse options int firewirePort = 0; std::string config_io; std::string config_pid; std::string config_kinematics; std::string config_name; cmnCommandLineOptions options; options.AddOptionOneValue("i", "io-master", "config file for master robot IO", cmnCommandLineOptions::REQUIRED_OPTION, &config_io); options.AddOptionOneValue("p", "pid-master", "config file for master PID controller", cmnCommandLineOptions::REQUIRED_OPTION, &config_pid); options.AddOptionOneValue("k", "kinematic-master", "config file for master robot kinematic", cmnCommandLineOptions::REQUIRED_OPTION, &config_kinematics); options.AddOptionOneValue("n", "name-master", "config file for master robot name", cmnCommandLineOptions::REQUIRED_OPTION, &config_name); options.AddOptionOneValue("f", "firewire", "firewire port number(s)", cmnCommandLineOptions::OPTIONAL_OPTION, &firewirePort); options.AddOptionNoValue("I", "io-ros", "add ROS bridge for IO level"); std::string errorMessage; if (!options.Parse(argc, argv, errorMessage)) { std::cerr << "Error: " << errorMessage << std::endl; options.PrintUsage(std::cerr); return -1; } // now components mtsManagerLocal * componentManager = mtsManagerLocal::GetInstance(); // create a Qt application and tab to hold all widgets mtsQtApplication * qtAppTask = new mtsQtApplication("QtApplication", argc, argv); qtAppTask->Configure(); componentManager->AddComponent(qtAppTask); // IO mtsRobotIO1394 * io = new mtsRobotIO1394("io", ioPeriod, firewirePort); io->Configure(config_io); componentManager->AddComponent(io); // connect ioGUIMaster to io mtsRobotIO1394QtWidgetFactory * robotWidgetFactory = new mtsRobotIO1394QtWidgetFactory("robotWidgetFactory"); componentManager->AddComponent(robotWidgetFactory); componentManager->Connect("robotWidgetFactory", "RobotConfiguration", "io", "Configuration"); robotWidgetFactory->Configure(); // mtsPID mtsPID* pid = new mtsPID("pid", ioPeriod); // periodicity will be ignore because ExecIn/Out are connected pid->Configure(config_pid); componentManager->AddComponent(pid); componentManager->Connect(pid->GetName(), "RobotJointTorqueInterface", "io", config_name); componentManager->Connect(pid->GetName(), "ExecIn", "io", "ExecOut"); // PID GUI mtsPIDQtWidget * pidMasterGUI = new mtsPIDQtWidget("pid master", 7); pidMasterGUI->Configure(); componentManager->AddComponent(pidMasterGUI); componentManager->Connect(pidMasterGUI->GetName(), "Controller", pid->GetName(), "Controller"); // psm mtsIntuitiveResearchKitPSM * psm = new mtsIntuitiveResearchKitPSM(config_name, armPeriod); psm->Configure(config_kinematics); componentManager->AddComponent(psm); componentManager->Connect(psm->GetName(), "PID", pid->GetName(), "Controller"); componentManager->Connect(psm->GetName(), "RobotIO", "io", config_name); componentManager->Connect(psm->GetName(), "Adapter", "io", psm->GetName() + "-Adapter"); componentManager->Connect(psm->GetName(), "Tool", "io", psm->GetName() + "-Tool"); componentManager->Connect(psm->GetName(), "ManipClutch", "io", psm->GetName() + "-ManipClutch"); // psm GUI mtsIntuitiveResearchKitArmQtWidget * psmGUI = new mtsIntuitiveResearchKitArmQtWidget(config_name + "GUI"); componentManager->AddComponent(psmGUI); componentManager->Connect(psmGUI->GetName(), "Manipulator", psm->GetName(), "Robot"); ROS_INFO("\n Name is :%s \n :%s \n :%s \n :%s \n ",config_name.c_str(),config_pid.c_str(),config_io.c_str() ,config_kinematics.c_str()); // ros wrapper mtsROSBridge robotBridge("RobotBridge", rosPeriod, true); // populate interfaces const dvrk_topics_version::version version = dvrk_topics_version::v1_3_0; dvrk::add_topics_psm(robotBridge, "/dvrk/" + config_name, psm->GetName(), version); if (options.IsSet("io-ros")) { dvrk::add_topics_io(robotBridge, "/dvrk/" + config_name + "/io", psm->GetName(), version); } // add component and connect componentManager->AddComponent(&robotBridge); dvrk::connect_bridge_psm(robotBridge, psm->GetName()); if (options.IsSet("io-ros")) { dvrk::connect_bridge_io(robotBridge, io->GetName(), psm->GetName()); } // organize all widgets in a tab widget QTabWidget * tabWidget = new QTabWidget; // io gui mtsRobotIO1394QtWidgetFactory::WidgetListType::const_iterator iterator; for (iterator = robotWidgetFactory->Widgets().begin(); iterator != robotWidgetFactory->Widgets().end(); ++iterator) { tabWidget->addTab(*iterator, (*iterator)->GetName().c_str()); } // pid gui tabWidget->addTab(pidMasterGUI, (config_name + " PID").c_str()); // psm gui tabWidget->addTab(psmGUI, psm->GetName().c_str()); // button gui tabWidget->addTab(robotWidgetFactory->ButtonsWidget(), "Buttons"); // show widget tabWidget->show(); //-------------- create the components ------------------ io->CreateAndWait(2.0 * cmn_s); // this will also create the pids as they are in same thread io->StartAndWait(2.0 * cmn_s); pid->StartAndWait(2.0 * cmn_s); // start all other components componentManager->CreateAllAndWait(2.0 * cmn_s); componentManager->StartAllAndWait(2.0 * cmn_s); // QtApp is now running componentManager->KillAllAndWait(2.0 * cmn_s); componentManager->Cleanup(); // delete dvgc robot delete pid; delete pidMasterGUI; delete psm; delete psmGUI; // stop all logs cmnLogger::Kill(); }
int main(int argc, char** argv) { // log configuration cmnLogger::SetMask(CMN_LOG_ALLOW_ALL); cmnLogger::SetMaskDefaultLog(CMN_LOG_ALLOW_ALL); cmnLogger::SetMaskFunction(CMN_LOG_ALLOW_ALL); cmnLogger::AddChannel(std::cerr, CMN_LOG_ALLOW_ERRORS_AND_WARNINGS); // ---- WARNING: hack to remove ros args ---- ros::V_string argout; ros::removeROSArgs(argc, argv, argout); argc = argout.size(); // ------------------------------------------ // parse options int firewirePort = 0; std::string config_io; std::string config_pid; std::string config_kinematics; std::string config_name; cmnCommandLineOptions options; options.AddOptionOneValue("i", "io-master", "config file for master robot IO", cmnCommandLineOptions::REQUIRED_OPTION, &config_io); options.AddOptionOneValue("p", "pid-master", "config file for master PID controller", cmnCommandLineOptions::REQUIRED_OPTION, &config_pid); options.AddOptionOneValue("k", "kinematic-master", "config file for master robot kinematic", cmnCommandLineOptions::REQUIRED_OPTION, &config_kinematics); options.AddOptionOneValue("n", "name-master", "config file for master robot name", cmnCommandLineOptions::REQUIRED_OPTION, &config_name); options.AddOptionOneValue("f", "firewire", "firewire port number(s)", cmnCommandLineOptions::OPTIONAL_OPTION, &firewirePort); std::string errorMessage; if (!options.Parse(argc, argv, errorMessage)) { std::cerr << "Error: " << errorMessage << std::endl; options.PrintUsage(std::cerr); return -1; } // now components mtsManagerLocal * componentManager = mtsManagerLocal::GetInstance(); // create a Qt application and tab to hold all widgets mtsQtApplication *qtAppTask = new mtsQtApplication("QtApplication", argc, argv); qtAppTask->Configure(); componentManager->AddComponent(qtAppTask); // console mtsIntuitiveResearchKitConsole * console = new mtsIntuitiveResearchKitConsole("console"); componentManager->AddComponent(console); mtsIntuitiveResearchKitConsoleQtWidget * consoleGUI = new mtsIntuitiveResearchKitConsoleQtWidget("consoleGUI"); componentManager->AddComponent(consoleGUI); // connect console GUI to console componentManager->Connect("console", "Main", "consoleGUI", "Main"); // IO mtsRobotIO1394 * io = new mtsRobotIO1394("io", 1.0 * cmn_ms, firewirePort); io->Configure(config_io); componentManager->AddComponent(io); // connect ioGUIMaster to io mtsRobotIO1394QtWidgetFactory * robotWidgetFactory = new mtsRobotIO1394QtWidgetFactory("robotWidgetFactory"); componentManager->AddComponent(robotWidgetFactory); componentManager->Connect("robotWidgetFactory", "RobotConfiguration", "io", "Configuration"); robotWidgetFactory->Configure(); // mtsPID mtsPID* pid = new mtsPID("pid", 5 * cmn_ms); pid->Configure(config_pid); componentManager->AddComponent(pid); componentManager->Connect(pid->GetName(), "RobotJointTorqueInterface", "io", config_name); componentManager->Connect(pid->GetName(), "ExecIn", "io", "ExecOut"); // PID Master GUI mtsPIDQtWidget * pidMasterGUI = new mtsPIDQtWidget("pid master",7); pidMasterGUI->Configure(); componentManager->AddComponent(pidMasterGUI); componentManager->Connect(pidMasterGUI->GetName(), "Controller", pid->GetName(), "Controller"); // psm mtsIntuitiveResearchKitConsole::Arm *psm = new mtsIntuitiveResearchKitConsole::Arm(config_name, io->GetName()); psm->ConfigurePID(config_pid); psm->ConfigureArm(mtsIntuitiveResearchKitConsole::Arm::ARM_PSM,config_kinematics, 5 * cmn_ms); console->AddArm(psm); console->Connect(); // psm GUI mtsIntuitiveResearchKitArmQtWidget* psmGUI = new mtsIntuitiveResearchKitArmQtWidget(config_name+"GUI"); psmGUI->Configure(); componentManager->AddComponent(psmGUI); componentManager->Connect(psmGUI->GetName(), "Manipulator", psm->Name(), "Robot"); //------------------------------------------------------- // Start ROS Bridge // ------------------------------------------------------ ROS_INFO("\n Name is :%s \n :%s \n :%s \n :%s \n ",config_name.c_str(),config_pid.c_str(),config_io.c_str() ,config_kinematics.c_str()); // ros wrapper mtsROSBridge robotBridge("RobotBridge", 20 * cmn_ms, true); // connect to psm robotBridge.AddPublisherFromReadCommand<prmPositionCartesianGet, geometry_msgs::Pose>( config_name, "GetPositionCartesian", "/dvrk_psm/cartesian_pose_current"); robotBridge.AddPublisherFromReadCommand<vctDoubleVec, cisst_msgs::vctDoubleVec>( pid->GetName(), "GetEffortJointDesired", "/dvrk_psm/joint_effort_current"); robotBridge.AddPublisherFromReadCommand<prmPositionJointGet, sensor_msgs::JointState>( pid->GetName(), "GetPositionJoint", "/dvrk_psm/joint_position_current"); robotBridge.AddPublisherFromEventWrite<prmEventButton, std_msgs::Bool>( "ManipClutch","Button","/dvrk_psm/manip_clutch_state"); robotBridge.AddPublisherFromReadCommand<std::string, std_msgs::String>( config_name,"GetRobotControlState","/dvrk_psm/robot_state_current"); // Finally Working Form; However it is still unsafe since there is no safety check. // Use with caution and with your hand on the E-Stop. robotBridge.AddSubscriberToWriteCommand<prmForceTorqueJointSet , sensor_msgs::JointState>( pid->GetName(), "SetTorqueJoint", "/dvrk_psm/set_joint_effort"); robotBridge.AddSubscriberToWriteCommand<std::string, std_msgs::String>( config_name, "SetRobotControlState", "/dvrk_psm/set_robot_state"); robotBridge.AddSubscriberToWriteCommand<bool, std_msgs::Bool>( pid->GetName(),"Enable","/dvrk_psm/enable_pid"); robotBridge.AddSubscriberToWriteCommand<prmPositionJointSet, sensor_msgs::JointState>( pid->GetName(),"SetPositionJoint","/dvrk_psm/set_position_joint"); robotBridge.AddSubscriberToWriteCommand<prmPositionCartesianSet, geometry_msgs::Pose>( config_name, "SetPositionCartesian", "/dvrk_psm/set_position_cartesian"); componentManager->AddComponent(&robotBridge); componentManager->Connect(robotBridge.GetName(), config_name, psm->Name(), "Robot"); componentManager->Connect(robotBridge.GetName(), pid->GetName(), pid->GetName(),"Controller"); componentManager->Connect(robotBridge.GetName(), "ManipClutch", "io", config_name + "-ManipClutch"); // componentManager->Connect(robotBridge.GetName(), "Clutch", "io", "CLUTCH"); //------------------------------------------------------- // End ROS Bridge // ------------------------------------------------------ // organize all widgets in a tab widget QTabWidget * tabWidget = new QTabWidget; // io gui mtsRobotIO1394QtWidgetFactory::WidgetListType::const_iterator iterator; for (iterator = robotWidgetFactory->Widgets().begin(); iterator != robotWidgetFactory->Widgets().end(); ++iterator) { tabWidget->addTab(*iterator, (*iterator)->GetName().c_str()); } tabWidget->addTab(consoleGUI, "Main"); // pid gui tabWidget->addTab(pidMasterGUI, (config_name + "PID").c_str()); // psm gui tabWidget->addTab(psmGUI, psm->Name().c_str()); // button gui tabWidget->addTab(robotWidgetFactory->ButtonsWidget(), "Buttons"); // show widget tabWidget->show(); //-------------- create the components ------------------ io->CreateAndWait(2.0 * cmn_s); // this will also create the pids as they are in same thread io->StartAndWait(2.0 * cmn_s); pid->StartAndWait(2.0 * cmn_s); // start all other components componentManager->CreateAllAndWait(2.0 * cmn_s); componentManager->StartAllAndWait(2.0 * cmn_s); // QtApp will run here componentManager->KillAllAndWait(2.0 * cmn_s); componentManager->Cleanup(); // delete dvgc robot delete pid; delete pidMasterGUI; delete psm; delete psmGUI; delete robotWidgetFactory; // stop all logs cmnLogger::Kill(); }
int main(int argc, char ** argv) { // log configuration cmnLogger::SetMask(CMN_LOG_ALLOW_ALL); cmnLogger::SetMaskDefaultLog(CMN_LOG_ALLOW_ALL); cmnLogger::SetMaskFunction(CMN_LOG_ALLOW_ALL); cmnLogger::SetMaskClass("mtsIntuitiveResearchKitPSM", CMN_LOG_ALLOW_ALL); cmnLogger::SetMaskClass("mtsPID", CMN_LOG_ALLOW_ALL); cmnLogger::AddChannel(std::cerr, CMN_LOG_ALLOW_ERRORS_AND_WARNINGS); // parse options cmnCommandLineOptions options; int firewirePort = 0; std::string gcmip = "-1"; typedef std::map<std::string, std::string> ConfigFilesType; ConfigFilesType configFiles; std::string masterName, slaveName; options.AddOptionOneValue("i", "io-master", "configuration file for master robot IO (see sawRobotIO1394)", cmnCommandLineOptions::REQUIRED, &configFiles["io-master"]); options.AddOptionOneValue("p", "pid-master", "configuration file for master PID controller (see sawControllers, mtsPID)", cmnCommandLineOptions::REQUIRED, &configFiles["pid-master"]); options.AddOptionOneValue("k", "kinematic-master", "configuration file for master kinematic (see cisstRobot, robManipulator)", cmnCommandLineOptions::REQUIRED, &configFiles["kinematic-master"]); options.AddOptionOneValue("I", "io-slave", "configuration file for slave robot IO (see sawRobotIO1394)", cmnCommandLineOptions::REQUIRED, &configFiles["io-slave"]); options.AddOptionOneValue("P", "pid-slave", "configuration file for slave PID controller (see sawControllers, mtsPID)", cmnCommandLineOptions::REQUIRED, &configFiles["pid-slave"]); options.AddOptionOneValue("K", "kinematic-slave", "configuration file for slave kinematic (see cisstRobot, robManipulator)", cmnCommandLineOptions::REQUIRED, &configFiles["kinematic-slave"]); options.AddOptionOneValue("n", "name-master", "MTML or MTMR", cmnCommandLineOptions::REQUIRED, &masterName); options.AddOptionOneValue("N", "name-slave", "PSM1 or PSM2", cmnCommandLineOptions::REQUIRED, &slaveName); options.AddOptionOneValue("f", "firewire", "firewire port number(s)", cmnCommandLineOptions::OPTIONAL, &firewirePort); options.AddOptionOneValue("g", "gcmip", "global component manager IP address", cmnCommandLineOptions::OPTIONAL, &gcmip); std::string errorMessage; if (!options.Parse(argc, argv, errorMessage)) { std::cerr << "Error: " << errorMessage << std::endl; options.PrintUsage(std::cerr); return -1; } for (ConfigFilesType::const_iterator iter = configFiles.begin(); iter != configFiles.end(); ++iter) { if (!cmnPath::Exists(iter->second)) { std::cerr << "File not found for " << iter->first << ": " << iter->second << std::endl; return -1; } else { std::cout << "Configuration file for " << iter->first << ": " << iter->second << std::endl; } } std::cout << "FirewirePort: " << firewirePort << std::endl; std::string processname = "dvTeleop"; mtsManagerLocal * componentManager = 0; if (gcmip != "-1") { try { componentManager = mtsManagerLocal::GetInstance(gcmip, processname); } catch(...) { std::cerr << "Failed to get GCM instance." << std::endl; return -1; } } else { componentManager = mtsManagerLocal::GetInstance(); } // create a Qt application and tab to hold all widgets QApplication qtAppTask(argc, argv); // console mtsIntuitiveResearchKitConsole * console = new mtsIntuitiveResearchKitConsole("console"); componentManager->AddComponent(console); mtsIntuitiveResearchKitConsoleQtWidget * consoleGUI = new mtsIntuitiveResearchKitConsoleQtWidget("consoleGUI"); componentManager->AddComponent(consoleGUI); // connect teleGUI to tele componentManager->Connect("console", "Main", "consoleGUI", "Main"); // IO mtsRobotIO1394 * io = new mtsRobotIO1394("io", 1.0 * cmn_ms, firewirePort); io->Configure("sawRobotIO1394-MTMR-28247.xml"); io->Configure("sawRobotIO1394-PSM1-28007.xml"); io->Configure("sawRobotIO1394-MTML-22723.xml"); io->Configure("sawRobotIO1394-PSM2-27374.xml"); componentManager->AddComponent(io); mtsIntuitiveResearchKitConsole::Arm * mtm = new mtsIntuitiveResearchKitConsole::Arm(masterName, io->GetName()); mtm->ConfigurePID("sawControllersPID-MTM.xml"); mtm->ConfigureArm(mtsIntuitiveResearchKitConsole::Arm::ARM_MTM, "dvmtm.rob", 3.0 * cmn_ms); console->AddArm(mtm); // MTML mtsIntuitiveResearchKitConsole::Arm * mtml = new mtsIntuitiveResearchKitConsole::Arm("MTML", io->GetName()); mtml->ConfigurePID("sawControllersPID-MTM.xml"); mtml->ConfigureArm(mtsIntuitiveResearchKitConsole::Arm::ARM_MTM, "dvmtm.rob", 3.0 * cmn_ms); console->AddArm(mtml); mtsIntuitiveResearchKitConsole::Arm * psm = new mtsIntuitiveResearchKitConsole::Arm("PSM1", io->GetName()); psm->ConfigurePID("sawControllersPID-PSM.xml"); psm->ConfigureArm(mtsIntuitiveResearchKitConsole::Arm::ARM_PSM, "dvpsm.rob", 3.0 * cmn_ms); console->AddArm(psm); mtsIntuitiveResearchKitConsole::Arm * psm2 = new mtsIntuitiveResearchKitConsole::Arm("PSM2", io->GetName()); psm2->ConfigurePID("sawControllersPID-PSM.xml"); psm2->ConfigureArm(mtsIntuitiveResearchKitConsole::Arm::ARM_PSM, "dvpsm.rob", 3.0 * cmn_ms); console->AddArm(psm2); // connect ioGUIMaster to io mtsRobotIO1394QtWidgetFactory * robotWidgetFactory = new mtsRobotIO1394QtWidgetFactory("robotWidgetFactory"); componentManager->AddComponent(robotWidgetFactory); componentManager->Connect("robotWidgetFactory", "RobotConfiguration", "io", "Configuration"); robotWidgetFactory->Configure(); // PID Master GUI mtsPIDQtWidget * pidMasterGUI = new mtsPIDQtWidget("PID Master", 8); pidMasterGUI->Configure(); componentManager->AddComponent(pidMasterGUI); componentManager->Connect(pidMasterGUI->GetName(), "Controller", mtm->PIDComponentName(), "Controller"); mtsPIDQtWidget * pidMasterGUI2 = new mtsPIDQtWidget("PID MTML", 8); pidMasterGUI2->Configure(); componentManager->AddComponent(pidMasterGUI2); componentManager->Connect(pidMasterGUI2->GetName(), "Controller", mtml->PIDComponentName(), "Controller"); // PID Slave GUI mtsPIDQtWidget * pidSlaveGUI = new mtsPIDQtWidget("PID Slave", 7); pidSlaveGUI->Configure(); componentManager->AddComponent(pidSlaveGUI); componentManager->Connect(pidSlaveGUI->GetName(), "Controller", psm->PIDComponentName(), "Controller"); mtsPIDQtWidget * pidSlaveGUI2 = new mtsPIDQtWidget("PID PSM2", 7); pidSlaveGUI2->Configure(); componentManager->AddComponent(pidSlaveGUI2); componentManager->Connect(pidSlaveGUI2->GetName(), "Controller", psm2->PIDComponentName(), "Controller"); // Teleoperation mtsTeleOperationQtWidget * teleGUI = new mtsTeleOperationQtWidget("teleGUI"); teleGUI->Configure(); componentManager->AddComponent(teleGUI); mtsTeleOperation * tele = new mtsTeleOperation("tele", 5.0 * cmn_ms); componentManager->AddComponent(tele); // connect teleGUI to tele componentManager->Connect("teleGUI", "TeleOperation", "tele", "Setting"); mtsTeleOperationQtWidget * teleGUI2 = new mtsTeleOperationQtWidget("teleGUI2"); teleGUI2->Configure(); componentManager->AddComponent(teleGUI2); mtsTeleOperation * tele2 = new mtsTeleOperation("tele2", 5.0 * cmn_ms); componentManager->AddComponent(tele2); // connect teleGUI to tele componentManager->Connect("teleGUI2", "TeleOperation", "tele2", "Setting"); // TextToSpeech mtsTextToSpeech* textToSpeech = new mtsTextToSpeech; textToSpeech->AddInterfaceRequiredForEventString("ErrorMsg", "RobotErrorMsg"); componentManager->AddComponent(textToSpeech); componentManager->Connect(textToSpeech->GetName(), "ErrorMsg", psm->Name(), "Robot"); // connect teleop to Master + Slave + Clutch componentManager->Connect("tele", "Master", mtm->Name(), "Robot"); componentManager->Connect("tele", "Slave", psm->Name(), "Robot"); componentManager->Connect("tele", "CLUTCH", "io", "CLUTCH"); componentManager->Connect("tele", "COAG", "io", "COAG"); componentManager->Connect("tele2", "Master", mtml->Name(), "Robot"); componentManager->Connect("tele2", "Slave", psm2->Name(), "Robot"); componentManager->Connect("tele2", "CLUTCH", "io", "CLUTCH"); componentManager->Connect("tele2", "COAG", "io", "COAG"); // organize all widgets in a tab widget QTabWidget * tabWidget = new QTabWidget; tabWidget->addTab(consoleGUI, "Main"); tabWidget->addTab(teleGUI, "Tele-op"); tabWidget->addTab(teleGUI2, "Tele-op2"); tabWidget->addTab(pidMasterGUI, "PID Master"); tabWidget->addTab(pidMasterGUI2, "PID MTML"); tabWidget->addTab(pidSlaveGUI, "PID Slave"); tabWidget->addTab(pidSlaveGUI2, "PID PSM2"); mtsRobotIO1394QtWidgetFactory::WidgetListType::const_iterator iterator; for (iterator = robotWidgetFactory->Widgets().begin(); iterator != robotWidgetFactory->Widgets().end(); ++iterator) { tabWidget->addTab(*iterator, (*iterator)->GetName().c_str()); } tabWidget->addTab(robotWidgetFactory->ButtonsWidget(), "Buttons"); tabWidget->show(); //-------------- create the components ------------------ io->CreateAndWait(2.0 * cmn_s); // this will also create the pids as they are in same thread // start all other components componentManager->CreateAllAndWait(2.0 * cmn_s); componentManager->StartAllAndWait(2.0 * cmn_s); // QtApplication will run in main thread and return control // when exited. qtAppTask.exec(); componentManager->KillAllAndWait(2.0 * cmn_s); componentManager->Cleanup(); // delete dvgc robot delete tele; delete tele2; delete pidMasterGUI; delete pidMasterGUI2; delete pidSlaveGUI; delete pidSlaveGUI2; delete io; delete robotWidgetFactory; // stop all logs cmnLogger::Kill(); return 0; }
int main(int argc, char ** argv) { // configuration const double periodIO = 0.5 * cmn_ms; const double periodKinematics = 2.0 * cmn_ms; const double periodTeleop = 2.0 * cmn_ms; const double periodUDP = 20.0 * cmn_ms; // log configuration cmnLogger::SetMask(CMN_LOG_ALLOW_ALL); cmnLogger::SetMaskDefaultLog(CMN_LOG_ALLOW_ALL); cmnLogger::SetMaskFunction(CMN_LOG_ALLOW_ALL); cmnLogger::SetMaskClass("mtsIntuitiveResearchKit", CMN_LOG_ALLOW_VERBOSE); cmnLogger::AddChannel(std::cerr, CMN_LOG_ALLOW_ERRORS_AND_WARNINGS); // ---- WARNING: hack to remove ros args ---- ros::V_string argout; ros::removeROSArgs(argc, argv, argout); argc = argout.size(); // ------------------------------------------ // parse options cmnCommandLineOptions options; int firewirePort = 0; std::string gcmip = "-1"; std::string jsonMainConfigFile; typedef std::map<std::string, std::string> ConfigFilesType; ConfigFilesType configFiles; std::string masterName, slaveName; options.AddOptionOneValue("j", "json-config", "json configuration file", cmnCommandLineOptions::REQUIRED_OPTION, &jsonMainConfigFile); options.AddOptionOneValue("f", "firewire", "firewire port number(s)", cmnCommandLineOptions::OPTIONAL_OPTION, &firewirePort); options.AddOptionOneValue("g", "gcmip", "global component manager IP address", cmnCommandLineOptions::OPTIONAL_OPTION, &gcmip); // check that all required options have been provided std::string errorMessage; if (!options.Parse(argc, argv, errorMessage)) { std::cerr << "Error: " << errorMessage << std::endl; options.PrintUsage(std::cerr); return -1; } // make sure the json config file exists and can be parsed fileExists("JSON configuration", jsonMainConfigFile); std::ifstream jsonStream; jsonStream.open(jsonMainConfigFile.c_str()); Json::Value jsonConfig; Json::Reader jsonReader; if (!jsonReader.parse(jsonStream, jsonConfig)) { std::cerr << "Error: failed to parse configuration\n" << jsonReader.getFormattedErrorMessages(); return -1; } // start initializing the cisstMultiTask manager std::cout << "FirewirePort: " << firewirePort << std::endl; std::string processname = "dvTeleop"; mtsManagerLocal * componentManager = 0; if (gcmip != "-1") { try { componentManager = mtsManagerLocal::GetInstance(gcmip, processname); } catch(...) { std::cerr << "Failed to get GCM instance." << std::endl; return -1; } } else { componentManager = mtsManagerLocal::GetInstance(); } // create a Qt application and tab to hold all widgets mtsQtApplication *qtAppTask = new mtsQtApplication("QtApplication", argc, argv); qtAppTask->Configure(); componentManager->AddComponent(qtAppTask); // console mtsIntuitiveResearchKitConsole * console = new mtsIntuitiveResearchKitConsole("console"); componentManager->AddComponent(console); mtsIntuitiveResearchKitConsoleQtWidget * consoleGUI = new mtsIntuitiveResearchKitConsoleQtWidget("consoleGUI"); componentManager->AddComponent(consoleGUI); // connect consoleGUI to console componentManager->Connect("console", "Main", "consoleGUI", "Main"); // organize all widgets in a tab widget QTabWidget * tabWidget = new QTabWidget; tabWidget->addTab(consoleGUI, "Main"); // IO is shared accross components mtsRobotIO1394 * io = new mtsRobotIO1394("io", periodIO, firewirePort); // setup io defined in the json configuration file const Json::Value pairs = jsonConfig["pairs"]; for (unsigned int index = 0; index < pairs.size(); ++index) { // master Json::Value jsonMaster = pairs[index]["master"]; std::string armName = jsonMaster["name"].asString(); std::string ioFile = jsonMaster["io"].asString(); fileExists(armName + " IO", ioFile); io->Configure(ioFile); // slave Json::Value jsonSlave = pairs[index]["slave"]; armName = jsonSlave["name"].asString(); ioFile = jsonSlave["io"].asString(); fileExists(armName + " IO", ioFile); io->Configure(ioFile); } componentManager->AddComponent(io); // connect ioGUIMaster to io mtsRobotIO1394QtWidgetFactory * robotWidgetFactory = new mtsRobotIO1394QtWidgetFactory("robotWidgetFactory"); componentManager->AddComponent(robotWidgetFactory); componentManager->Connect("robotWidgetFactory", "RobotConfiguration", "io", "Configuration"); robotWidgetFactory->Configure(); // add all IO GUI to tab mtsRobotIO1394QtWidgetFactory::WidgetListType::const_iterator iterator; for (iterator = robotWidgetFactory->Widgets().begin(); iterator != robotWidgetFactory->Widgets().end(); ++iterator) { tabWidget->addTab(*iterator, (*iterator)->GetName().c_str()); } tabWidget->addTab(robotWidgetFactory->ButtonsWidget(), "Buttons"); // setup arms defined in the json configuration file for (unsigned int index = 0; index < pairs.size(); ++index) { Json::Value jsonMaster = pairs[index]["master"]; std::string masterName = jsonMaster["name"].asString(); std::string masterPIDFile = jsonMaster["pid"].asString(); std::string masterKinematicFile = jsonMaster["kinematic"].asString(); std::string masterUDPIP = jsonMaster["UDP-IP"].asString(); short masterUDPPort = jsonMaster["UDP-port"].asInt(); fileExists(masterName + " PID", masterPIDFile); fileExists(masterName + " kinematic", masterKinematicFile); mtsIntuitiveResearchKitConsole::Arm * mtm = new mtsIntuitiveResearchKitConsole::Arm(masterName, io->GetName()); mtm->ConfigurePID(masterPIDFile); mtm->ConfigureArm(mtsIntuitiveResearchKitConsole::Arm::ARM_MTM, masterKinematicFile, periodKinematics); console->AddArm(mtm); if (masterUDPIP != "" || masterUDPPort != 0) { if (masterUDPIP != "" && masterUDPPort != 0) { std::cout << "Adding UDPStream component for master " << masterName << " to " << masterUDPIP << ":" << masterUDPPort << std::endl; mtsIntuitiveResearchKitUDPStreamer * streamer = new mtsIntuitiveResearchKitUDPStreamer(masterName + "UDP", periodUDP, masterUDPIP, masterUDPPort); componentManager->AddComponent(streamer); // connect to mtm interface to get cartesian position componentManager->Connect(streamer->GetName(), "Robot", mtm->Name(), "Robot"); // connect to io to get clutch events componentManager->Connect(streamer->GetName(), "Clutch", "io", "CLUTCH"); // connect to io to get coag events componentManager->Connect(streamer->GetName(), "Coag", "io", "COAG"); } else { std::cerr << "Error for master arm " << masterName << ", you can provided UDP-IP w/o UDP-port" << std::endl; exit(-1); } } Json::Value jsonSlave = pairs[index]["slave"]; std::string slaveName = jsonSlave["name"].asString(); std::string slavePIDFile = jsonSlave["pid"].asString(); std::string slaveKinematicFile = jsonSlave["kinematic"].asString(); fileExists(slaveName + " PID", slavePIDFile); fileExists(slaveName + " kinematic", slaveKinematicFile); mtsIntuitiveResearchKitConsole::Arm * psm = new mtsIntuitiveResearchKitConsole::Arm(slaveName, io->GetName()); psm->ConfigurePID(slavePIDFile); psm->ConfigureArm(mtsIntuitiveResearchKitConsole::Arm::ARM_PSM, slaveKinematicFile, periodKinematics); console->AddArm(psm); // PID Master GUI std::string masterPIDName = masterName + " PID"; mtsPIDQtWidget * pidMasterGUI = new mtsPIDQtWidget(masterPIDName, 8); pidMasterGUI->Configure(); componentManager->AddComponent(pidMasterGUI); componentManager->Connect(pidMasterGUI->GetName(), "Controller", mtm->PIDComponentName(), "Controller"); tabWidget->addTab(pidMasterGUI, masterPIDName.c_str()); // ROS_INFO("\n\n\n Name of :%s\n PID component :%s\n IO component :%s \\n\n",mtm->Name().c_str(), mtm->PIDComponentName().c_str() // , mtm->IOComponentName().c_str()); // std::vector<std::string> io_interface_provided = io->GetNamesOfInterfacesProvided(); // for (int i=0;i<io_interface_provided.size();i++) // { // ROS_INFO("Provided IO Interface %d is %s",i,io_interface_provided[i].c_str()); // } // std::vector<std::string> io_interface_required = io->GetNamesOfInterfacesRequired(); // for (int i=0;i<io_interface_required.size();i++) // { // ROS_INFO("Required IO Interface %d is %s",i,io_interface_required[i].c_str()); // } // PID Slave GUI std::string slavePIDName = slaveName + " PID"; mtsPIDQtWidget * pidSlaveGUI = new mtsPIDQtWidget(slavePIDName, 7); pidSlaveGUI->Configure(); componentManager->AddComponent(pidSlaveGUI); componentManager->Connect(pidSlaveGUI->GetName(), "Controller", psm->PIDComponentName(), "Controller"); tabWidget->addTab(pidSlaveGUI, slavePIDName.c_str()); // Master GUI mtsIntuitiveResearchKitArmQtWidget * masterGUI = new mtsIntuitiveResearchKitArmQtWidget(mtm->Name() + "GUI"); masterGUI->Configure(); componentManager->AddComponent(masterGUI); tabWidget->addTab(masterGUI, mtm->Name().c_str()); // connect masterGUI to master componentManager->Connect(masterGUI->GetName(), "Manipulator", mtm->Name(), "Robot"); // Slave GUI mtsIntuitiveResearchKitArmQtWidget * slaveGUI = new mtsIntuitiveResearchKitArmQtWidget(psm->Name() + "GUI"); slaveGUI->Configure(); componentManager->AddComponent(slaveGUI); tabWidget->addTab(slaveGUI, psm->Name().c_str()); // connect slaveGUI to slave componentManager->Connect(slaveGUI->GetName(), "Manipulator", psm->Name(), "Robot"); // Teleoperation std::string teleName = masterName + "-" + slaveName; mtsTeleOperationQtWidget * teleGUI = new mtsTeleOperationQtWidget(teleName + "GUI"); teleGUI->Configure(); componentManager->AddComponent(teleGUI); tabWidget->addTab(teleGUI, teleName.c_str()); mtsTeleOperation * tele = new mtsTeleOperation(teleName, periodTeleop); componentManager->AddComponent(tele); // connect teleGUI to tele componentManager->Connect(teleGUI->GetName(), "TeleOperation", tele->GetName(), "Setting"); componentManager->Connect(tele->GetName(), "Master", mtm->Name(), "Robot"); componentManager->Connect(tele->GetName(), "Slave", psm->Name(), "Robot"); componentManager->Connect(tele->GetName(), "CLUTCH", "io", "CLUTCH"); componentManager->Connect(tele->GetName(), "COAG", "io", "COAG"); } // Starting ROS-Bridge Here mtsROSBridge rosBridge("RobotBridge", 20 * cmn_ms, true); rosBridge.AddPublisherFromReadCommand<prmPositionJointGet, sensor_msgs::JointState>( "MTML", "GetPositionJoint", "/dvrk_mtml/joint_position_current"); rosBridge.AddPublisherFromReadCommand<prmPositionJointGet, sensor_msgs::JointState>( "MTMR", "GetPositionJoint", "/dvrk_mtmr/joint_position_current"); rosBridge.AddPublisherFromReadCommand<prmPositionJointGet, sensor_msgs::JointState>( "PSM1", "GetPositionJoint", "/dvrk_psm1/joint_position_current"); rosBridge.AddPublisherFromReadCommand<prmPositionJointGet, sensor_msgs::JointState>( "PSM2", "GetPositionJoint", "/dvrk_psm2/joint_position_current"); rosBridge.AddPublisherFromReadCommand<prmPositionCartesianGet, geometry_msgs::Pose>( "PSM1", "GetPositionCartesian", "/dvrk_psm1/joint_position_cartesian"); rosBridge.AddPublisherFromReadCommand<prmPositionCartesianGet, geometry_msgs::Pose>( "PSM2", "GetPositionCartesian", "/dvrk_psm2/joint_position_cartesian"); rosBridge.AddPublisherFromReadCommand<prmPositionCartesianGet, geometry_msgs::Pose>( "MTML", "GetPositionCartesian", "/dvrk_mtml/joint_position_cartesian"); rosBridge.AddPublisherFromReadCommand<prmPositionCartesianGet, geometry_msgs::Pose>( "MTMR", "GetPositionCartesian", "/dvrk_mtmr/joint_position_cartesian"); rosBridge.AddSubscriberToWriteCommand<std::string , std_msgs::String>( "PSM1", "SetRobotControlState", "/dvrk_psm1/set_robot_state"); rosBridge.AddSubscriberToWriteCommand<prmPositionCartesianSet, geometry_msgs::Pose>( "PSM1", "SetPositionCartesian", "/dvrk_psm1/set_cartesian_pose"); rosBridge.AddSubscriberToWriteCommand<std::string , std_msgs::String>( "PSM2", "SetRobotControlState", "/dvrk_psm2/set_robot_state"); rosBridge.AddSubscriberToWriteCommand<prmPositionCartesianSet, geometry_msgs::Pose>( "PSM2", "SetPositionCartesian", "/dvrk_psm2/set_cartesian_pose"); rosBridge.AddSubscriberToWriteCommand<std::string , std_msgs::String>( "MTML", "SetRobotControlState", "/dvrk_mtml/set_robot_state"); rosBridge.AddSubscriberToWriteCommand<prmPositionCartesianSet, geometry_msgs::Pose>( "MTML", "SetPositionCartesian", "/dvrk_mtml/set_cartesian_pose"); rosBridge.AddSubscriberToWriteCommand<std::string , std_msgs::String>( "MTMR", "SetRobotControlState", "/dvrk_mtmr/set_robot_state"); rosBridge.AddSubscriberToWriteCommand<prmPositionCartesianSet, geometry_msgs::Pose>( "MTMR", "SetPositionCartesian", "/dvrk_mtmr/set_cartesian_pose"); componentManager->AddComponent(&rosBridge); componentManager->Connect(rosBridge.GetName(), "MTML", "MTML", "Robot"); componentManager->Connect(rosBridge.GetName(), "MTMR", "MTMR", "Robot"); componentManager->Connect(rosBridge.GetName(), "PSM1", "PSM1", "Robot"); componentManager->Connect(rosBridge.GetName(), "PSM2", "PSM2", "Robot"); /////////////////////////////////////////////////////////////////// // show all widgets tabWidget->show(); //-------------- create the components ------------------ io->CreateAndWait(2.0 * cmn_s); // this will also create the pids as they are in same thread io->StartAndWait(2.0 * cmn_s); // start all other components componentManager->CreateAllAndWait(2.0 * cmn_s); componentManager->StartAllAndWait(2.0 * cmn_s); // QtApplication will run in main thread and return control // when exited. componentManager->KillAllAndWait(2.0 * cmn_s); componentManager->Cleanup(); // delete dvgc robot delete io; delete robotWidgetFactory; // stop all logs cmnLogger::Kill(); return 0; }
int main(int argc, char ** argv) { // program deprecated std::cout << "-----------------------------------------------------------" << std::endl << "- This program is deprecated: -" << std::endl << "- use dvrk_console_json instead -" << std::endl << "- examples can be found in share/jhu-dVRK/console*.json -" << std::endl << "-----------------------------------------------------------" << std::endl << std::endl; // desired frequencies const double ioPeriod = 0.5 * cmn_ms; const double armPeriod = 2.0 * cmn_ms; const double rosPeriod = 10.0 * cmn_ms; // log configuration cmnLogger::SetMask(CMN_LOG_ALLOW_ALL); cmnLogger::SetMaskDefaultLog(CMN_LOG_ALLOW_ALL); cmnLogger::SetMaskFunction(CMN_LOG_ALLOW_ALL); cmnLogger::SetMaskClass("mtsIntuitiveResearchKitECM", CMN_LOG_ALLOW_ALL); cmnLogger::AddChannel(std::cerr, CMN_LOG_ALLOW_ERRORS_AND_WARNINGS); // ---- WARNING: hack to remove ros args ---- ros::V_string argout; ros::removeROSArgs(argc, argv, argout); argc = argout.size(); // ------------------------------------------ // parse options cmnCommandLineOptions options; int firewirePort = 0; std::string gcmip = "-1"; typedef std::map<std::string, std::string> ConfigFilesType; ConfigFilesType configFiles; std::string armName; options.AddOptionOneValue("i", "io", "configuration file for robot IO (see sawRobotIO1394)", cmnCommandLineOptions::REQUIRED_OPTION, &configFiles["io"]); options.AddOptionOneValue("p", "pid", "configuration file for PID controller (see sawControllers, mtsPID)", cmnCommandLineOptions::REQUIRED_OPTION, &configFiles["pid"]); options.AddOptionOneValue("k", "kinematic", "configuration file for kinematic (see cisstRobot, robManipulator)", cmnCommandLineOptions::REQUIRED_OPTION, &configFiles["kinematic"]); options.AddOptionOneValue("n", "arm-name", "arm name, i.e. PSM1, ... as found in sawRobotIO configuration file", cmnCommandLineOptions::REQUIRED_OPTION, &armName); options.AddOptionOneValue("f", "firewire", "firewire port number(s)", cmnCommandLineOptions::OPTIONAL_OPTION, &firewirePort); options.AddOptionOneValue("g", "gcmip", "global component manager IP address", cmnCommandLineOptions::OPTIONAL_OPTION, &gcmip); std::string errorMessage; if (!options.Parse(argc, argv, errorMessage)) { std::cerr << "Error: " << errorMessage << std::endl; options.PrintUsage(std::cerr); return -1; } for (ConfigFilesType::const_iterator iter = configFiles.begin(); iter != configFiles.end(); ++iter) { if (!cmnPath::Exists(iter->second)) { std::cerr << "File not found for " << iter->first << ": " << iter->second << std::endl; return -1; } else { std::cout << "Configuration file for " << iter->first << ": " << iter->second << std::endl; } } std::cout << "FirewirePort: " << firewirePort << std::endl; std::string processname = "dv-arm"; mtsManagerLocal * componentManager = 0; if (gcmip != "-1") { try { componentManager = mtsManagerLocal::GetInstance(gcmip, processname); } catch(...) { std::cerr << "Failed to get GCM instance." << std::endl; return -1; } } else { componentManager = mtsManagerLocal::GetInstance(); } // create a Qt application and tab to hold all widgets mtsQtApplication * qtAppTask = new mtsQtApplication("QtApplication", argc, argv); qtAppTask->Configure(); componentManager->AddComponent(qtAppTask); // console mtsIntuitiveResearchKitConsole * console = new mtsIntuitiveResearchKitConsole("console"); componentManager->AddComponent(console); mtsIntuitiveResearchKitConsoleQtWidget * consoleGUI = new mtsIntuitiveResearchKitConsoleQtWidget("consoleGUI"); componentManager->AddComponent(consoleGUI); // connect console GUI to console componentManager->Connect("console", "Main", "consoleGUI", "Main"); // IO mtsRobotIO1394 * io = new mtsRobotIO1394("io", ioPeriod, firewirePort); io->Configure(configFiles["io"]); componentManager->AddComponent(io); // Create the arm unsigned int numberOfAxis = 0; mtsIntuitiveResearchKitConsole::Arm * arm = new mtsIntuitiveResearchKitConsole::Arm(armName, io->GetName()); arm->ConfigurePID(configFiles["pid"]); // Configure based on arm type assuming name if ((armName == "PSM1") || (armName == "PSM2") || (armName == "PSM3")) { arm->ConfigureArm(mtsIntuitiveResearchKitConsole::Arm::ARM_PSM, configFiles["kinematic"], armPeriod); numberOfAxis = 7; } else if ((armName == "MTML") || (armName == "MTMR")) { arm->ConfigureArm(mtsIntuitiveResearchKitConsole::Arm::ARM_MTM, configFiles["kinematic"], armPeriod); numberOfAxis = 8; } else if (armName == "ECM") { arm->ConfigureArm(mtsIntuitiveResearchKitConsole::Arm::ARM_ECM, configFiles["kinematic"], armPeriod); numberOfAxis = 4; } else { std::cerr << "Arm name should be either PSM1, PSM2, PSM3, MTML, MTMR or ECM, not " << armName << std::endl; return -1; } console->AddArm(arm); // connect ioGUIMaster to io mtsRobotIO1394QtWidgetFactory * robotWidgetFactory = new mtsRobotIO1394QtWidgetFactory("robotWidgetFactory"); componentManager->AddComponent(robotWidgetFactory); componentManager->Connect("robotWidgetFactory", "RobotConfiguration", "io", "Configuration"); robotWidgetFactory->Configure(); // PID GUI mtsPIDQtWidget * pidGUI = new mtsPIDQtWidget("PID", numberOfAxis); pidGUI->Configure(); componentManager->AddComponent(pidGUI); componentManager->Connect(pidGUI->GetName(), "Controller", arm->PIDComponentName(), "Controller"); // GUI mtsIntuitiveResearchKitArmQtWidget * armGUI = new mtsIntuitiveResearchKitArmQtWidget("Arm"); armGUI->Configure(); componentManager->AddComponent(armGUI); componentManager->Connect(armGUI->GetName(), "Manipulator", arm->Name(), "Robot"); // organize all widgets in a tab widget QTabWidget * tabWidget = new QTabWidget; tabWidget->addTab(consoleGUI, "Main"); tabWidget->addTab(armGUI, "Arm"); tabWidget->addTab(pidGUI, "PID"); mtsRobotIO1394QtWidgetFactory::WidgetListType::const_iterator iterator; for (iterator = robotWidgetFactory->Widgets().begin(); iterator != robotWidgetFactory->Widgets().end(); ++iterator) { tabWidget->addTab(*iterator, (*iterator)->GetName().c_str()); } tabWidget->addTab(robotWidgetFactory->ButtonsWidget(), "Buttons"); tabWidget->show(); // ros wrapper mtsROSBridge robotBridge("RobotBridge", rosPeriod, true); // populate interfaces const dvrk_topics_version::version version = dvrk_topics_version::v1_3_0; dvrk::add_topics_ecm(robotBridge, "/dvrk/" + armName, arm->Name(), version); // Connect componentManager->AddComponent(&robotBridge); dvrk::connect_bridge_ecm(robotBridge, arm->Name()); //-------------- create the components ------------------ io->CreateAndWait(2.0 * cmn_s); // this will also create the pids as they are in same thread io->StartAndWait(2.0 * cmn_s); componentManager->GetComponent(arm->PIDComponentName())->StartAndWait(2.0 * cmn_s); // start all other components componentManager->CreateAllAndWait(2.0 * cmn_s); componentManager->StartAllAndWait(2.0 * cmn_s); // QtApplication will run in main thread and return control // when exited. componentManager->KillAllAndWait(2.0 * cmn_s); componentManager->Cleanup(); // delete dvgc robot delete pidGUI; delete io; delete robotWidgetFactory; // stop all logs cmnLogger::Kill(); return 0; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { browser_ = new WebBrowser; browser_->loadSettings(); browser_->GoHome(); //setCentralWidget(browser_); // PESTAÑAS QTabWidget *tabWidgetMainWindow = new QTabWidget(this); tabWidgetMainWindow->setMinimumSize(800,600); tabWidgetMainWindow->addTab(browser_, "Pestaña 1"); tabWidgetMainWindow->addTab(new WebBrowser, "Pestaña 2"); tabWidgetMainWindow->setCurrentIndex(1); tabWidgetMainWindow->show(); setCentralWidget(tabWidgetMainWindow); zoomVar = 1; // inicialización del zoom // inicializamos los menus mainMenu_ = new QMenuBar(this); setMenuBar(mainMenu_); mnuArchivo_ = new QMenu(tr("&Archivo"), this); //mainMenu_ -> addMenu(mnuArchivo_); mnuEditar_ = new QMenu(tr("&Editar"), this); //mainMenu_ -> addMenu(mnuEditar_); mnuVer_ = new QMenu(tr("&Ver"), this); mainMenu_ -> addMenu(mnuVer_); actPlusZoom = new QAction(tr("&Aumentar zoom"), this); actPlusZoom -> setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Plus)); mnuVer_->addAction(actPlusZoom); connect(actPlusZoom, SIGNAL(triggered()), this, SLOT(setPlusZoom())); actMinusZoom_ = new QAction(tr("&Disminuir zoom"), this); actMinusZoom_ -> setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Minus)); mnuVer_->addAction(actMinusZoom_); connect(actMinusZoom_, SIGNAL(triggered()), this, SLOT(setMinusZoom())); mnuMarcadores_ = new QMenu(tr("&Marcadores"), this); mainMenu_ -> addMenu(mnuMarcadores_); actAddBookmark_ = new QAction(tr("&Añadir a marcadores"), this); actAddBookmark_ -> setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_O)); mnuMarcadores_->addAction(actAddBookmark_); connect(actAddBookmark_, SIGNAL(triggered()), this, SLOT(addMarcador())); mnuHerramientas_ = new QMenu(tr("&Herramientas"), this); mainMenu_ -> addMenu(mnuHerramientas_); actSetHomepage_ = new QAction(tr("Establecer como pagina principal"), this); mnuHerramientas_->addAction(actSetHomepage_); connect(actSetHomepage_, SIGNAL(triggered()), browser_, SLOT(setHomepage())); mnuHistorial_ = new QMenu(tr("&Historial"), this); mainMenu_ -> addMenu(mnuHistorial_); actDeleteHistory_ = new QAction(tr("&Borrar el historial"), this); actDeleteHistory_->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D)); mnuHistorial_->addAction(actDeleteHistory_); connect(actDeleteHistory_, SIGNAL(triggered()), this, SLOT(deleteHistory())); showHistory(); readBookmarkFile(); for (int i = 0; i < bookmarkList.size(); ++i) { QAction* tmp = new QAction(tr(bookmarkList.at(i).toLocal8Bit().constData()), this); mnuMarcadores_->addAction(tmp); connect(tmp,SIGNAL(triggered()),this,SLOT(PulsarMarcador())); } }