예제 #1
0
void mySpaces::openNewTab(QUrl url)
{
    for(int i = 0; i < tabs->count(); i++)
    {
        tabPage * tab = static_cast<tabPage*>(tabs->widget(i));
        if(tab->url().toString() == url.toString())
        {
            tabs->setCurrentIndex(i);
            return;
        }
    }
    tabPage * tab = new tabPage(tabs);
    tab->load(url);
    tabs->addTab(tab,QIcon(":/myspaces/t_icon_home.png"),"mySpaces");
    connect(tab, SIGNAL(OpenLinkInNewTab(QUrl)),SLOT(openNewTab(QUrl)));
    connect(tab, SIGNAL(changeTitle(QString)),
            this, SLOT(refreshTitles(QString)));
    connect(tab, SIGNAL(exitApplication()), SLOT(exitApp()));
    if(url.toString().startsWith("myspaces://"))
        tabs->setCurrentWidget(tab);
    if(tabs->count()>1)
        tabs->setMovable(true);
    else
        tabs->setMovable(false);
    resizeTabs();
}
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    central = new QWidget(this);
    central->setContextMenuPolicy(Qt::NoContextMenu); // explicitly forbid usage of context menu so actions item is not shown menu
    setCentralWidget(central);

    // Create text editor and set softkeys to it
    textEditor= new QTextEdit(tr("Navigate in UI to see context sensitive softkeys in action"), this);
    QAction* clear = new QAction(tr("Clear"), this);
    clear->setSoftKeyRole(QAction::NegativeSoftKey);

    textEditor->addAction(clear);

    ok = new QAction(tr("Ok"), this);
    ok->setSoftKeyRole(QAction::PositiveSoftKey);
    connect(ok, SIGNAL(triggered()), this, SLOT(okPressed()));

    cancel = new QAction(tr("Cancel"), this);
    cancel->setSoftKeyRole(QAction::NegativeSoftKey);
    connect(cancel, SIGNAL(triggered()), this, SLOT(cancelPressed()));

    infoLabel = new QLabel(tr(""), this);
    infoLabel->setContextMenuPolicy(Qt::NoContextMenu);

    toggleButton = new QPushButton(tr("Custom"), this);
    toggleButton->setContextMenuPolicy(Qt::NoContextMenu);
    toggleButton->setCheckable(true);

    pushButton = new QPushButton(tr("File Dialog"), this);
    pushButton->setContextMenuPolicy(Qt::NoContextMenu);

    QComboBox* comboBox = new QComboBox(this);
    comboBox->setContextMenuPolicy(Qt::NoContextMenu);
    comboBox->insertItems(0, QStringList()
     << QApplication::translate("MainWindow", "Selection1", 0, QApplication::UnicodeUTF8)
     << QApplication::translate("MainWindow", "Selection2", 0, QApplication::UnicodeUTF8)
     << QApplication::translate("MainWindow", "Selection3", 0, QApplication::UnicodeUTF8)
    );

    layout = new QGridLayout;
    layout->addWidget(textEditor, 0, 0, 1, 2);
    layout->addWidget(infoLabel, 1, 0, 1, 2);
    layout->addWidget(toggleButton, 2, 0);
    layout->addWidget(pushButton, 2, 1);
    layout->addWidget(comboBox, 3, 0, 1, 2);
    central->setLayout(layout);

    fileMenu = menuBar()->addMenu(tr("&File"));
    exit = new QAction(tr("&Exit"), this);
    fileMenu->addAction(exit);

    connect(clear, SIGNAL(triggered()), this, SLOT(clearTextEditor()));
    connect(pushButton, SIGNAL(clicked()), this, SLOT(openDialog()));
    connect(exit, SIGNAL(triggered()), this, SLOT(exitApplication()));
    connect(toggleButton, SIGNAL(clicked()), this, SLOT(setCustomSoftKeys()));
    pushButton->setFocus();
}
예제 #3
0
void keyDown(char character, int virtualKey)
{
	_pressedChar = character;

	repaintWindow();

	if(virtualKey == VK_END)
		exitApplication();
}
예제 #4
0
/* signalHandler
**
** Purpose:
**	Handle any kill interrupts i.e. pressing control-C
**
** Parameter Dictionary:
**	None
**
** Return Values:
**	None
**
** Notes:
**
** Algorithm:
**	Description of the algorithm (optional) and any other notes.
*/
static void
signalHandler()
{
    CONDITION
    cond;

    fprintf(stderr, "\nProcess Killed\n");
    cond = COND_PushCondition(APP_ERROR(APP_OPERATIONINTERRUPTED));
    exitApplication(cond);
}
//-----------------------------------------------------------------------------
void CloseFileGuiCommand::init ()
{
    getQAction(CLOSE_FILE_)->setShortcut (QKeySequence::Close);
    getQAction(CLOSE_FILE_)->setIcon (QIcon(":/images/icons/fileclose.png"));
    getQAction(EXIT_APPLICATION_)->setShortcut (QKeySequence::Quit);
    getQAction(EXIT_APPLICATION_)->setIcon (QIcon(":/images/icons/exit.png"));

    resetActionTriggerSlot(CLOSE_FILE_, SLOT(closeFile()));
    resetActionTriggerSlot(EXIT_APPLICATION_, SLOT(exitApplication()));
}
예제 #6
0
void StandardActions::createStandardActions()
{
    QAction *newAction = new QAction(tr("New"), mainWindow);
    newAction->setShortcut(QKeySequence("Ctrl+N"));
    mainWindow->getActionCollection()->addAction("new", newAction);
    connect(newAction, SIGNAL(triggered()), this, SLOT(newFile()));

    QAction *openAction = new QAction(tr("Open"), mainWindow);
    openAction->setShortcut(QKeySequence("Ctrl+O"));
    mainWindow->getActionCollection()->addAction("open", openAction);
    connect(openAction, SIGNAL(triggered()), this, SLOT(openFile()));

    QAction *saveAction = new QAction(tr("Save"), mainWindow);
    saveAction->setShortcut(QKeySequence("Ctrl+S"));
    mainWindow->getActionCollection()->addAction("save", saveAction);
    connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));

    QAction *saveAsAction = new QAction(tr("Save As"), mainWindow);
    mainWindow->getActionCollection()->addAction("saveas", saveAsAction);
    connect(saveAsAction, SIGNAL(triggered()), this, SLOT(saveFileAs()));

    QAction *exportAction = new QAction(tr("Export"), mainWindow);
    mainWindow->getActionCollection()->addAction("export", exportAction);
    connect(exportAction, SIGNAL(triggered()), this, SLOT(exportFile()));

    QAction *exitAction = new QAction(tr("Exit"), mainWindow);
    exitAction->setShortcut(QKeySequence("Ctrl+Q"));
    mainWindow->getActionCollection()->addAction("exit", exitAction);
    connect(exitAction, SIGNAL(triggered()), this, SLOT(exitApplication()));

    QAction* cutAction = new QAction(tr("Cut"), mainWindow);
    cutAction->setShortcut(QKeySequence("Ctrl+X"));
    mainWindow->getActionCollection()->addAction("cut", cutAction);
    connect(cutAction, SIGNAL(triggered()), this, SLOT(cut()));

    QAction* copyAction = new QAction(tr("Copy"), mainWindow);
    copyAction->setShortcut(QKeySequence("Ctrl+C"));
    mainWindow->getActionCollection()->addAction("copy", copyAction);
    connect(copyAction, SIGNAL(triggered()), this , SLOT(copy()));

    QAction* pasteAction = new QAction(tr("Paste"), mainWindow);
    pasteAction->setShortcut(QKeySequence("Ctrl+V"));
    mainWindow->getActionCollection()->addAction("paste", pasteAction);
    connect(pasteAction, SIGNAL(triggered()), this, SLOT(paste()));

    QAction* undoAction = new QAction(tr("Undo"), mainWindow);
    undoAction->setShortcut(QKeySequence("Ctrl+Z"));
    mainWindow->getActionCollection()->addAction("undo", undoAction);
    connect(undoAction, SIGNAL(triggered()), this, SLOT(undo()));

    QAction* redoAction = new QAction(tr("Redo"), mainWindow);
    redoAction->setShortcut(QKeySequence("Ctrl+R"));
    mainWindow->getActionCollection()->addAction("redo", redoAction);
    connect(redoAction, SIGNAL(triggered(bool)), this, SLOT(redo()));
}
예제 #7
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setListFile();
    model = new TableModel(this);
    model->setSettings(&settings);
    model->readFromFile(listfile);
    ui->tableView->setModel(model);
    readSettings();

    if (settings.trayicon)
    {
        trayicon = new QSystemTrayIcon(this->windowIcon(), this);
        connect(trayicon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
                    this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));

        traymenu = new QMenu(this);
        traymenu->addAction(ui->actionStart);
        traymenu->addAction(ui->actionStop);
        traymenu->addAction(ui->actionExit);

        trayicon->setContextMenu(traymenu);
        trayicon->setToolTip(tr("Upcoder"));
        trayicon->show();
    } else
    {
        trayicon = 0;
        traymenu = 0;
    }

    time = new QTime();

    settingsdialog = 0;
    resdialog = 0;

    connect(ui->actionSettings, SIGNAL(triggered()), this, SLOT(settingsPressed()));
    connect(ui->actionAdd, SIGNAL(triggered()), this, SLOT(addPressed()));
    connect(ui->actionDelete, SIGNAL(triggered()), this, SLOT(deletePressed()));
    connect(ui->actionClear, SIGNAL(triggered()), model, SLOT(clear()));
    connect(ui->actionStart, SIGNAL(triggered()), model, SLOT(startUploading()));
    connect(ui->actionStop, SIGNAL(triggered()), model, SLOT(stopUploading()));
    connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(exitApplication()));
    connect(ui->actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    connect(ui->actionShow_links_to_files, SIGNAL(triggered()), this, SLOT(showLinks()));
    connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(aboutPressed()));
    connect(ui->tableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(showLinks()));

    connect(model, SIGNAL(statusChanged(QString)), ui->statusBar, SLOT(showMessage(QString)));
    connect(model, SIGNAL(progress(qint64,qint64)), this, SLOT(uploadProgress(qint64,qint64)));
    connect(model, SIGNAL(uploadingStarted()), this, SLOT(uploadingStarted()));
    connect(model, SIGNAL(allUploadsStarted()), this, SLOT(allUploadsStarted()));
    connect(model, SIGNAL(allUploadsFinished()), this, SLOT(allUploadsFinished()));
}
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: getBitPlane((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 1: getDisplayOption((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 2: getEdgeFilter((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 3: getImpulseNoise((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 4: getKLTQuality((*reinterpret_cast< double(*)>(_a[1]))); break;
        case 5: getKLTMinDist((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 6: getKLTWindowSize((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 7: getKLTNumLevels((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 8: getLogarithmConstant((*reinterpret_cast< double(*)>(_a[1]))); break;
        case 9: getOFAlgorithm((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 10: getPowerLawConstant((*reinterpret_cast< double(*)>(_a[1]))); break;
        case 11: getPowerLawGamma((*reinterpret_cast< double(*)>(_a[1]))); break;
        case 12: getR1((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 13: getK((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 14: getMinSize((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 15: getSharpeningAlgorithm((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 16: getSigma((*reinterpret_cast< double(*)>(_a[1]))); break;
        case 17: getSmoothingFilter((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 18: getSmoothingMask((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 19: exitApplication(); break;
        case 20: openImageDirectory(); break;
        case 21: toggleAddGaussianNoise(); break;
        case 22: toggleAddGammaNoise(); break;
        case 23: toggleAddImpulseNoise(); break;
        case 24: toggleBitPlaneSlicing(); break;
        case 25: toggleContrastStretching(); break;
        case 26: toggleFilter(); break;
        case 27: toggleFitToWindow(); break;
        case 28: toggleHistogramEqualization(); break;
        case 29: toggleLogarithm(); break;
        case 30: toggleNegative(); break;
        case 31: toggleOpticalFlow(); break;
        case 32: togglePowerLaw(); break;
        case 33: toggleSegmentation(); break;
        case 34: toggleSharpeningAlgorithm(); break;
        case 35: toggleSmoothing(); break;
        case 36: toggleSwapRedBlue(); break;
        case 37: updateImageNumber((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 38: timerEvent((*reinterpret_cast< QTimerEvent*(*)>(_a[1]))); break;
        case 39: on_pushButtonTrack_clicked(); break;
        default: ;
        }
        _id -= 40;
    }
    return _id;
}
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    a.setWindowIcon(QPixmap(":icons/icons/picture.png"));

    MainWindow w;
    w.show();

    QObject::connect(&w, SIGNAL(exitApplication()), &a, SLOT(closeAllWindows()));

    return a.exec();
}
예제 #10
0
int main(int argc, char** argv){


	killed=false;
	struct sigaction sigIntHandler;

   sigIntHandler.sa_handler = exitApplication;
   sigemptyset(&sigIntHandler.sa_mask);
   sigIntHandler.sa_flags = 0;

   sigaction(SIGINT, &sigIntHandler, NULL);

	Ice::PropertiesPtr prop;
	std::string componentPrefix("myComponent");

	
	

	try{
			ic = Ice::initialize(argc,argv);
			prop = ic->getProperties();
	}
	catch (const Ice::Exception& ex) {
			std::cerr << ex << std::endl;
			return 1;
	}
	catch (const char* msg) {
			std::cerr <<"Error :" << msg << std::endl;
			return 1;
	}

	std::string Endpoints = prop->getProperty(componentPrefix + ".Endpoints");
	Ice::ObjectAdapterPtr adapter =ic->createObjectAdapterWithEndpoints(componentPrefix, Endpoints);

	// for each interface:

	std::string objPrefix="myInterface";
	std::string Name = "pointcloud1";
	std::cout << "Creating pointcloud1 " << Name << std::endl;
	interface1 = new myClassI();
	adapter->add(interface1, ic->stringToIdentity(Name));

	//starting the adapter
	adapter->activate();
	ic->waitForShutdown();

	if (!killed)
		exitApplication(1);
   
   return 0;

}
예제 #11
0
/*!
    Ask from view that is it ok to pop view. This kind of 2-phase popView is
    needed because view may show query dialog for user response.
 */
void NmApplication::prepareForPopView()
{
    if (mViewStack && mViewStack->size() > 0) {
        // Get view pointer.
        NmBaseView *view = mViewStack->top();
        if (view){
			NmUiViewId topViewId = view->nmailViewId();
			
			// We must know in popView, are we coming with back button from
			// message view to prevent the send animation.
			if (topViewId == NmUiViewMessageEditor) {
				mBackButtonPressed = true;
			}
            
            // View will call/signal popView if exitting is ok.
            view->okToExitView();        
        }
    }
    // If the view stack is now empty quit the app. This happens also when
    // the app has been started as a service
    else if (mViewStack && mViewStack->size() == 0) {
        exitApplication();
    }
}
예제 #12
0
int main(int argc, char** argv){



	struct sigaction sigIntHandler;

   sigIntHandler.sa_handler = exitApplication;
   sigemptyset(&sigIntHandler.sa_mask);
   sigIntHandler.sa_flags = 0;

   sigaction(SIGINT, &sigIntHandler, NULL);

	int accion=0;
	int sentido=10;

	int status;

	struct timeval a, b, t2;
	int cycle = 100;
	long totalb,totala;
	long diff;

	// INTERFACE
	std::vector<jderobot::LaserPrx> lprx;
	std::vector<jderobot::CameraPrx> cprx;
	std::vector<jderobot::Pose3DEncodersPrx> pose3dencoders;
	std::vector<jderobot::Pose3DPrx> pose3dprx;
	std::vector<jderobot::EncodersPrx> encoders;
	std::vector <jderobot::pointCloudPrx> prx;


	//INTERFACE DATA
	jderobot::EncodersDataPtr ed;
	jderobot::LaserDataPtr ld;
	
	jderobot::ImageDataPtr imageData;

	//pools

	pthread_attr_t attr;
	//images
	std::vector<recorder::poolWriteImages*> poolImages;
	int nConsumidores;
	int poolSize;
	//lasers
	std::vector<recorder::poolWriteLasers*> poolLasers;
	//pose3dencoders
	std::vector<recorder::poolWritePose3dEncoders*> poolPose3dEncoders;
	//pose3d
	std::vector<recorder::poolWritePose3d*> poolPose3d;
	//encoders
	std::vector<recorder::poolWriteEncoders*> poolEncoders;
	//pointClouds
	std::vector<recorder::poolWritePointCloud*> poolPointClouds;

	//numero de lasers

	int Hz = 10;
	int muestrasLaser = 180;
	int pngCompressRatio;
	int jpgQuality;
    std::string fileFormat;
	std::vector<int> compression_params;
    
   
	//---------------- INPUT ARGUMENTS ---------------//

	if (argc<2){
		std::cout << std::endl << "USE: ./mycomponent --Ice.Config=mycomponent.cfg" << std::endl;
	}

	//---------------- INPUT ARGUMENTS -----------------//

	try{
		//creamos el directorio principal
		struct stat buf;
		char dire[]="./data/";
		if( stat( dire, &buf ) == -1 )
		{
			system("mkdir data");
		}
   
		Ice::PropertiesPtr prop;

		ic = Ice::initialize(argc,argv);

		prop = ic->getProperties();

		Hz = prop->getPropertyAsInt("Recorder.Hz");
		cycle = 1000.0/Hz;
      
		pthread_attr_init(&attr);
		pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
      

		nCameras = prop->getPropertyAsIntWithDefault("Recorder.nCameras",0);
		if (nCameras > 0 ){
			struct stat buf;
			char dire[]="./data/images/";
			if( stat( dire, &buf ) == -1 )
			{
				system("mkdir ./data/images/");
			}
            fileFormat=prop->getProperty("Recorder.FileFormat");
            if (fileFormat.compare(std::string("png"))==0){
				pngCompressRatio=prop->getPropertyAsIntWithDefault("Recorder.PngCompression",3);
				compression_params.push_back(CV_IMWRITE_PNG_COMPRESSION);
				compression_params.push_back(pngCompressRatio);
			}
            else if (fileFormat.compare(std::string("jpg"))==0){
				jpgQuality=prop->getPropertyAsIntWithDefault("Recorder.JpgQuality",95);
				compression_params.push_back(CV_IMWRITE_JPEG_QUALITY);
				compression_params.push_back(jpgQuality);
			}
			else{
                throw "File format is not valid";
			}
			nConsumidores=prop->getPropertyAsIntWithDefault("Recorder.nConsumers",2);
			poolSize=prop->getPropertyAsIntWithDefault("Recorder.poolSize",10);


		}

		for (int i=0; i< nCameras; i++){
			struct stat buf;
			std::stringstream cameraPath;
			cameraPath << "./data/images/camera" << i+1;
			if( stat( cameraPath.str().c_str(), &buf ) == -1 )
			{
				std::stringstream instruction;
				instruction << "mkdir " << cameraPath.str();
				system(instruction.str().c_str());
			}


            std::stringstream sProxy;

			// Get driver camera
			sProxy << "Recorder.Camera" << i+1 << ".Proxy";

			Ice::ObjectPrx camara = ic->propertyToProxy(sProxy.str());
			if (0==camara)
				throw "Could not create proxy to camera1 server";
			// cast to CameraPrx
			jderobot::CameraPrx cprxAux = jderobot::CameraPrx::checkedCast(camara);
			if (0== cprxAux)
				throw "Invalid proxy";
			else
				cprx.push_back(cprxAux);

            std::stringstream sFormat;
            std::string imageFormat;

            sFormat << "Recorder.Camera" << i+1 << ".Format";

            imageFormat = prop->getProperty(sFormat.str());

			//pool
            recorder::poolWriteImages *temp = new recorder::poolWriteImages(cprxAux, Hz,poolSize,i+1,imageFormat ,fileFormat ,compression_params);
			poolImages.push_back(temp);


			for (int j=i*nConsumidores; j< i*nConsumidores+nConsumidores; j++){
				pthread_create(&consumerThreads[j], &attr, camera_pool_consumer_thread,temp);
				totalConsumers++;
			}
			pthread_create(&producerThreads[i], &attr, camera_pool_producer_thread,temp);
			totalProducers++;
		}



		nLasers= prop->getPropertyAsInt("Recorder.nLasers");
		if (nLasers > 0){
			struct stat buf;
			char dire[]="./data/lasers/";
			if( stat( dire, &buf ) == -1 )
			{
				system("mkdir data/lasers/");
			}
		}
		for (int i=0; i< nLasers; i++){
			struct stat buf;
			std::stringstream claserPath;
			claserPath << "./data/lasers/laser" << i+1;
			if( stat( claserPath.str().c_str(), &buf ) == -1 )
			{
				std::stringstream instruction;
				instruction << "mkdir " << claserPath.str();
				system(instruction.str().c_str());
			}

			// Contact to LASER interface
			std::stringstream sProxy;
			sProxy << "Recorder.Laser" << i+1 << ".Proxy";

			Ice::ObjectPrx baseLaser = ic->propertyToProxy(sProxy.str());
			if (0==baseLaser)
				throw "Could not create proxy with laser";

			// Cast to laser
			jderobot::LaserPrx laserPrx = jderobot::LaserPrx::checkedCast(baseLaser);
			if (0== laserPrx)
				throw "Invalid proxy Mycomponent.Laser.Proxy";
			lprx.push_back(laserPrx);
			recorder::poolWriteLasers *temp = new recorder::poolWriteLasers(laserPrx, Hz,poolSize,i+1);

			poolLasers.push_back(temp);
			pthread_create(&consumerThreads[totalConsumers], &attr, laser_pool_consumer_thread,temp);
			totalConsumers++;
			pthread_create(&producerThreads[totalProducers], &attr, laser_pool_producer_thread,temp);
			totalProducers++;
		}


		nPose3dEncoders= prop->getPropertyAsInt("Recorder.nPose3dEncoders");
		if (nPose3dEncoders > 0){
			struct stat buf;
			char dire[]="./data/pose3dencoders/";
			if( stat( dire, &buf ) == -1 )
			{
				system("mkdir data/pose3dencoders/");
			}
		}
		for (int i=0; i< nPose3dEncoders; i++){
			struct stat buf;
			std::stringstream claserPath;
			claserPath << "./data/pose3dencoders/pose3dencoder" << i+1;
			if( stat( claserPath.str().c_str(), &buf ) == -1 )
			{
				std::stringstream instruction;
				instruction << "mkdir " << claserPath.str();
				system(instruction.str().c_str());
			}

			// Contact to POSE3DENCODERS interface
			std::stringstream sProxy;
			sProxy << "Recorder.Pose3DEncoders" << i+1 << ".Proxy";

			Ice::ObjectPrx base = ic->propertyToProxy(sProxy.str());
			if (0==base)
				throw "Could not create proxy with pose3dencoders";

			// Cast to Pose3DEncodersPrx
			jderobot::Pose3DEncodersPrx prx = jderobot::Pose3DEncodersPrx::checkedCast(base);
			if (0== prx)
				throw "Invalid proxy Mycomponent.pose3dencoders.Proxy";
			pose3dencoders.push_back(prx);
			recorder::poolWritePose3dEncoders*temp = new recorder::poolWritePose3dEncoders(prx, Hz,poolSize,i+1);

			poolPose3dEncoders.push_back(temp);
			pthread_create(&consumerThreads[totalConsumers], &attr, pose3dencoders_pool_consumer_thread,temp);
			totalConsumers++;
			pthread_create(&producerThreads[totalProducers], &attr, pose3dencoders_pool_producer_thread,temp);
			totalProducers++;
		}

		nPose3d= prop->getPropertyAsInt("Recorder.nPose3d");
		if (nPose3d > 0){
			struct stat buf;
			char dire[]="./data/pose3d/";
			if( stat( dire, &buf ) == -1 )
			{
				system("mkdir data/pose3d/");
			}
		}
		for (int i=0; i< nPose3d; i++){
			struct stat buf;
			std::stringstream claserPath;
			claserPath << "./data/pose3d/pose3d" << i+1;
			if( stat( claserPath.str().c_str(), &buf ) == -1 )
			{
				std::stringstream instruction;
				instruction << "mkdir " << claserPath.str();
				system(instruction.str().c_str());
			}

			// Contact to POSE3D interface
			std::stringstream sProxy;
			sProxy << "Recorder.Pose3D" << i+1 << ".Proxy";

			Ice::ObjectPrx base = ic->propertyToProxy(sProxy.str());
			if (0==base)
				throw "Could not create proxy with pose3d";

			// Cast to Pose3DPrx
			jderobot::Pose3DPrx prx = jderobot::Pose3DPrx::checkedCast(base);
			if (0== prx)
				throw "Invalid proxy Mycomponent.pose3d.Proxy";
			pose3dprx.push_back(prx);
			recorder::poolWritePose3d*temp = new recorder::poolWritePose3d(prx, Hz,poolSize,i+1);

			poolPose3d.push_back(temp);
			pthread_create(&consumerThreads[totalConsumers], &attr, pose3d_pool_consumer_thread,temp);
			totalConsumers++;
			pthread_create(&producerThreads[totalProducers], &attr, pose3d_pool_producer_thread,temp);
			totalProducers++;
		}

		nEncoders= prop->getPropertyAsInt("Recorder.nEncoders");
		if (nEncoders > 0){
			struct stat buf;
			char dire[]="./data/encoders/";
			if( stat( dire, &buf ) == -1 )
			{
				system("mkdir data/encoders/");
			}
		}
		for (int i=0; i< nEncoders; i++){
			struct stat buf;
			std::stringstream claserPath;
			claserPath << "./data/encoders/encoder" << i+1;
			if( stat( claserPath.str().c_str(), &buf ) == -1 )
			{
				std::stringstream instruction;
				instruction << "mkdir " << claserPath.str();
				system(instruction.str().c_str());
			}

			// Contact to ENCODERS interface
			std::stringstream sProxy;
			sProxy << "Recorder.Encoders" << i+1 << ".Proxy";

			Ice::ObjectPrx base = ic->propertyToProxy(sProxy.str());
			if (0==base)
				throw "Could not create proxy with encoders";

			// Cast to EncodersPrx
			jderobot::EncodersPrx prx = jderobot::EncodersPrx::checkedCast(base);
			if (0== prx)
				throw "Invalid proxy Mycomponent.encoders.Proxy";
			encoders.push_back(prx);
			recorder::poolWriteEncoders*temp = new recorder::poolWriteEncoders(prx, Hz,poolSize,i+1);

			poolEncoders.push_back(temp);
			pthread_create(&consumerThreads[totalConsumers], &attr, encoders_pool_consumer_thread,temp);
			totalConsumers++;
			pthread_create(&producerThreads[totalProducers], &attr, encoders_pool_producer_thread,temp);
			totalProducers++;
		}

		nDepthSensors = prop->getPropertyAsIntWithDefault("Recorder.nDethSensors",0);
		if (nDepthSensors){
			struct stat buf;
			char dire[]="./data/pointClouds/";
			if( stat( dire, &buf ) == -1 )
			{
				system("mkdir data/pointClouds/");
			}
		}
		for (int i=0; i< nDepthSensors; i++){
			struct stat buf;
			std::stringstream claserPath;
			claserPath << "./data/pointClouds/pointCloud" << i+1;
			if( stat( claserPath.str().c_str(), &buf ) == -1 )
			{
				std::stringstream instruction;
				instruction << "mkdir " << claserPath.str();
				system(instruction.str().c_str());
			}


			std::stringstream sProxy;
			// Get driver camera
			sProxy << "Recorder.DepthSensor" << i+1 << ".Proxy";

			Ice::ObjectPrx kinect = ic->propertyToProxy(sProxy.str());
			if (0==kinect){
				throw "Could not create proxy with Kinect1";
			}
			// Cast to KINECT
			jderobot::pointCloudPrx prxAux = jderobot::pointCloudPrx::checkedCast(kinect);
			if (0== prxAux){
				throw std::string("Invalid proxy Recorder.Kinect1.Proxy");
			}
			prx.push_back(prxAux);
			recorder::poolWritePointCloud* temp = new recorder::poolWritePointCloud(prxAux, Hz,poolSize,i+1);
			poolPointClouds.push_back(temp);
			pthread_create(&consumerThreads[totalConsumers], &attr, pointcloud_pool_consumer_thread,temp);
			totalConsumers++;
			pthread_create(&producerThreads[totalProducers], &attr, pointcloud_pool_producer_thread,temp);
			totalProducers++;
		}

		//****************************** Processing the Control ******************************///


		//---------------- ITERATIONS CONTROL -----------//
		//muestreo para el laser
		muestrasLaser = prop->getPropertyAsInt("Recorder.Laser.Samples");
		std::string robotName = prop->getPropertyWithDefault("Recorder.Hostname","localhost");
		std::string robotPort = prop->getPropertyWithDefault("Recorder.Port","9999");
      
		long timeRelative = 0;


		int guiActive=prop->getPropertyAsIntWithDefault("Recorder.GUI",0);
		recorder::recordergui *gui;

		if (guiActive){
	      gui = new recorder::recordergui();
		}
		long long int iteration=0;
		
            
		while(globalActive){
			//gui activado
			if (guiActive){
				gui->set_iteration(iteration);
				gui->update();
				globalActive=gui->get_active();
				recording=gui->get_recording();
			}
			else{
				recording=true;
			}

			if (recording){
				if (iteration==0){
					gettimeofday(&inicio,NULL);
				}
				iteration++;
				gettimeofday(&b,NULL);
				totalb=b.tv_sec*1000000+b.tv_usec;
				//calculamos la velocidad de grabación actual
				float myfps=1000000./((float)totalb-(float)totala);
				if (guiActive){
					gui->set_fps((int)myfps);
				}
				gettimeofday(&a,NULL);
				totala=a.tv_sec*1000000+a.tv_usec;

				gettimeofday(&b,NULL);
				totalb=b.tv_sec*1000000+b.tv_usec;
				std::cout << "Recorder takes " << (totalb-totala)/1000 << " ms" << std::endl;

				diff = (totalb-totala)/1000;
				if(diff < 0 || diff > cycle)
					diff = cycle;
				else
					diff = cycle-diff;

				//Sleep Algorithm
				usleep(diff*1000);
				if(diff < 10)
					usleep(10*1000);

				// std::cout << cycle <<" ->" << diff  << " ->" << timeRelative<< std::endl;
				timeRelative+= diff + (totalb-totala)/1000;
				// std::cout << "->" << diff  << " ->" << timeRelative<< std::endl;
			}
			else{
				usleep(10*1000);
			}

		}

	//--------------ITERATIONS CONTROL-------------//
	}
	catch (const Ice::Exception& ex) {
		std::cerr << ex << std::endl;
		status = 1;
   } 
	catch (const char* msg) {
		std::cerr << msg << std::endl;
		status = 1;
	}

	if (!killed)
		exitApplication(1);
   
   return 0;
}
예제 #13
0
void AtsMainWindow::exitActionTriggered() {
    exitApplication();
}
예제 #14
0
int
main(int argc, char **argv)
{
    CONDITION
    cond = APP_NORMAL;		/* condition code returned by various
				 * facilities */
    DUL_NETWORKKEY
	* network;		/* The handle to the network */
    DUL_ASSOCIATIONKEY
	* association = NULL;	/* The handle to the Association */
    DUL_ASSOCIATESERVICEPARAMETERS
	service;		/* Presentation parameters */
    int
        pid,			/* process id */
        port;			/* port number on which the server listens */
    char
        node[MAXHOSTNAMELEN + 1] = "";	/* name of node */
    CTNBOOLEAN
	singleUserMode = FALSE;	/* indicates if the server will run in single
				 * user mode i.e. iterative */
    LST_HEAD
	* processList = NULL;	/* maintains a list of children processes */
    CTNBOOLEAN paramsFlag = FALSE;	/* Dump association parameters? */

    (void) gethostname(node, MAXHOSTNAMELEN);
    /* Parse the command line arguments. First process all the switches */
    while (--argc > 0 && *(++argv)[0] == '-') {
	switch ((*argv)[1]) {
	case 'd':		/* option to put a specific facility in debug
				 * mode */
	    argc--;
	    argv++;
	    if (!argc)
		usageError();
	    if (strcmp(*argv, "DCM") == 0)
		verboseDCM = TRUE;
	    else if (strcmp(*argv, "DUL") == 0)
		verboseDUL = TRUE;
	    else if (strcmp(*argv, "SRV") == 0)
		verboseSRV = TRUE;
	    else
		usageError();
	    break;
	case 'f':		/* database selection option */
	    argc--;
	    argv++;
	    if (!argc)
		usageError();
	    controlDatabase = *argv;
	    break;
	case 'i':		/* set the forgive option */
	    forgiveFlag = TRUE;
	    break;
	case 'n':		/* use node as name rather than hostname */
	    if (argc < 1)
		usageError();
	    argc--;
	    argv++;
	    strcpy(node, *argv);
	    break;
	case 'p':
	    paramsFlag = TRUE;	/* Dump the association parameters to stdout */
	    break;
	case 'r':
	    sendBack = TRUE;	/* send optional attributes back in the
				 * response messages */
	    break;
	case 's':		/* set single user mode. Useful for debugging */
	    singleUserMode = TRUE;
	    break;
	case 't':
	    traceFlag = TRUE;	/* tracing ON (non silent operation) */
	    break;
	case 'v':		/* set verbose mode ON */
	    verboseDUL = TRUE;
	    verboseSRV = TRUE;
	    verboseDCM = TRUE;
	    break;
	case 'x':		/* for maintaining a Generalized Queue. This
				 * option is useful for terminals having X
				 * capability */
	    gqueueFlag = TRUE;
#ifdef ASG
	    argc--;
	    argv++;
	    if (sscanf(*argv, "%d", &gqID) != 1)
		usageError();
#endif
	    break;
	default:
	    printf("Unrecognized option: %s\n", *argv);
	    break;
	}
    }

    if (argc < 1)
	usageError();

    if (sscanf(*argv++, "%d", &port) != 1)
	usageError();

#ifdef _MSC_VER
    singleUserMode = TRUE;
#endif

    THR_Init();
    DCM_Debug(verboseDCM);
    DUL_Debug(verboseDUL);
    SRV_Debug(verboseSRV);

    /* Handle interrupts */
    (void) signal(SIGINT, signalHandler);

    /* Initialize a network connection and listen on the specified port */
    cond = DUL_InitializeNetwork(DUL_NETWORK_TCP, DUL_AEBOTH,
		 (void *) &port, DUL_TIMEOUT, DUL_ORDERBIGENDIAN, &network);
    if (cond != DUL_NORMAL) {
	exitApplication(cond);
    }
    appHandles.network = network;	/* set the network key field */
    if (!singleUserMode) {
	/*
	 * initialize a list that will hold information about all the
	 * children processes that are active
	 */
	if ((processList = LST_Create()) == NULL) {
	    cond = COND_PushCondition(APP_ERROR(APP_FAILURE), "LST_Create",
				      "main");
	    exitApplication(cond);
	}
	appHandles.processList = processList;	/* set the process list field */
    }
    /* The server loops forever accepting new requests */
    while (1) {
	/* get the next Association request */
	cond = nextAssociationRequest(node, &network, &service, maxPDU,
				      forgiveFlag, &gqID, &association);
	if (cond == APP_NORMAL) {
	    appHandles.association = association;
	    appHandles.service = &service;
	    if (!singleUserMode) {
		/*
		 * remove all those child processes that have exited so that
		 * zombie processes are not created
		 */
		(void) harvestChildrenProcesses(&processList);
		/*
		 * server continues to accept new requests, whereas the child
		 * services the requests on that association. To create a
		 * child process, we fork
		 */
		pid = fork();
	    } else
		pid = 0;	/* setting pid to 0 in this else clause is
				 * essential due to the manner in which the
				 * following if condition is coded */

	    if (pid < 0) {
		/* fork failed */
		printf("Cannot spawn child process. Request rejected\n");
		clearAssociationKeyAndServiceParameters(APP_FAILURE);
		continue;
	    } else if (pid == 0) {	/* This is the child process unless
					 * the single user mode is ON in
					 * which case this is the parent
					 * process itself. For this part of
					 * the code to be activated when the
					 * singleUserMode is TRUE, we need to
					 * set pid = 0 as done above */
		if (!singleUserMode)
		    printf("Forked child\n");
		cond = DUL_AcknowledgeAssociationRQ(&association, &service);
		if (cond != DUL_NORMAL) {
		    if (!singleUserMode) {
			/* child process exits with a status of -1 */
			exitApplication(cond);
		    } else {
			/*
			 * In the single user mode, the parent just discards
			 * the current association and service parameters and
			 * continues to listen to new requests
			 */
			clearAssociationKeyAndServiceParameters(cond);
			continue;	/* go to next iteration of main loop */
		    }
		}
		/*
		 * open a GQ queue, if the GQ facility is to be used
		 */
		if (gqueueFlag) {
		    if (gqID == -1) {	/* we were unsuccessful retrieving
					 * the GQ ID info from the database.
					 * Hence we decide to ignore the
					 * display */
			fprintf(stderr,
				"Failure to retrieve GQ ID information\n");
			fprintf(stderr,
				"GQ facility ignored\n");
			gqueueFlag = FALSE;
		    } else {
			/* open a GQ */
			cond = openGQ(gqID);
			if (cond != APP_NORMAL) {
			    if (!singleUserMode) {
				/* child process exits with a status of -1 */
				exitApplication(cond);
			    } else {
				clearAssociationKeyAndServiceParameters(cond);
				continue;	/* go to next iteration of
						 * main loop */
			    }
			}
		    }
		}
		if (paramsFlag)
		    DUL_DumpParams(&service);
		cond = serviceRequests(&network, &association, &service);
		if (cond == SRV_PEERREQUESTEDRELEASE)
		    cond = SRV_NORMAL;
		if (CTN_ERROR(cond)) {
		    if (!singleUserMode) {
			fprintf(stderr, "child failed to service request\n");
			COND_DumpConditions();
			exitApplication(cond);
		    } else {
			/*
			 * In the single user mode, the parent just discards
			 * the current association and service parameters and
			 * continues to listen to new requests
			 */
			fprintf(stderr,
			      "Iterative server failed to serve request\n");
			clearAssociationKeyAndServiceParameters(cond);
			continue;	/* go to next iteration of main loop */
		    }
		}
		if (!singleUserMode) {
		    /* graceful exit by the child process (return status 0) */
		    exitApplication(SRV_NORMAL);
		}
	    } else {
		/*
		 * Parent has to drop the Association that was created for
		 * the child when an Association request arrived from the
		 * client. If this is not done, both the parent and the child
		 * are capable of receiving on the same association
		 */
		cond = DUL_DropAssociation(&association);
		if (cond != DUL_NORMAL) {
		    exitApplication(cond);
		}
		/*
		 * Add information of the process to the list maintained by
		 * the parent
		 */
		(void) addChildProcess(&service, pid, &processList);
		/*
		 * Now clear the service parameters so as to accept a new set
		 * of parameters on the association
		 */
		(void) DUL_ClearServiceParameters(&service);
		printf("Parent ready to accept new request\n");
	    }
	} else {
	    /*
	     * something went wrong accepting the next Association request
	     * Parent server issues an error message and continues to serve
	     * the next request
	     */
	    fprintf(stderr, "!!!! Error getting next Request.\n");
	    fprintf(stderr, "Discarding this request\n");
	    COND_DumpConditions();
	}
    }
#ifdef MALLOC_DEBUG
    malloc_verify(0);
    malloc_shutdown();
#endif
    return 0;
}
예제 #15
0
void QtSystray::setTrayMenu() {
	_trayMenu->clear();

	//openAction
#if defined(OS_MACOSX)
	// On Mac OS X, clicking the Dock icon should show the application thus the
	// 'Open WengoPhone' entry is not necessary. We get the Dock Icon click event
	// from our QtMacApplication class.
	QtMacApplication * qMacApp = dynamic_cast<QtMacApplication *>(QApplication::instance());
	SAFE_CONNECT_RECEIVER(qMacApp, SIGNAL(applicationMustShow()), _qtWengoPhone->getWidget(), SLOT(show()));
#endif
	_startNew = new QMenu(tr("Start New"));
	
	_newCall = new QAction(tr("Call"), _startNew);
	_newConference = new QAction(tr("Conference Call"), _startNew);
	//_newInstantMessage = new QMenu(tr("Instant Message"));
	_newInstantMessage = new QAction(tr("Instant Message"), _startNew);
	_newGroupChat = new QAction(tr("Group Chat"), _startNew);
	_newTextMessage = new QAction(tr("Text Message"), _startNew);
	_newGroupTextMessage = new QAction(tr("Group Text Message"), _startNew);
	_newEmail = new QAction(tr("Email"), _startNew);
	_newGroupEmail = new QAction(tr("Group Email"), _startNew);
	_newSendFile = new QAction(tr("Send File"), _startNew);
	_newSendFax = new QAction(tr("Send Fax"), _startNew);

	SAFE_CONNECT_RECEIVER(_newCall, SIGNAL(triggered()), _qtToolBar, SLOT(showKeyTab()));
	SAFE_CONNECT_RECEIVER(_newConference, SIGNAL(triggered()), _qtToolBar, SLOT(createConferenceCall()));
	/*_newInstantMessage->clear();
	SAFE_CONNECT(_newInstantMessage, SIGNAL(triggered(QAction *)), SLOT(startChat(QAction *)));
	QtContactMenu::populateChatMenu(_newInstantMessage, _qtWengoPhone->getCWengoPhone());*/
	_newInstantMessage->setDisabled(true);
	_newGroupChat->setDisabled(true);
	_newTextMessage->setDisabled(true);
	_newGroupTextMessage->setDisabled(true);
	_newEmail->setDisabled(true);
	_newGroupEmail->setDisabled(true);
	_newSendFile->setDisabled(true);
	_newSendFax->setDisabled(true);
	
	_startNew->addAction(_newCall);
	_startNew->addAction(_newConference);
	_startNew->addAction(_newInstantMessage);
	//_startNew->addMenu(_newInstantMessage);
	_startNew->addAction(_newGroupChat);
	_startNew->addAction(_newTextMessage);
	_startNew->addAction(_newGroupTextMessage);
	_startNew->addAction(_newEmail);
	_startNew->addAction(_newGroupEmail);
	_startNew->addAction(_newSendFile);
	_startNew->addAction(_newSendFax);	

	_recentContacts = new QMenu(tr("Recent Contacts"));
	_viewConversations = new QAction(tr("View Conversations"), _trayMenu);
	_showContactList = new QAction(tr("Show Contact List"), _trayMenu);
	_settings = new QAction(tr("Settings"), _trayMenu);
	_signOut = new QAction(tr("Sign Out"), _trayMenu);
	_quit = new QAction(tr("Quit @product@"), _trayMenu);
	
	_recentContacts->setDisabled(true);
	SAFE_CONNECT_RECEIVER(_viewConversations, SIGNAL(triggered()), _qtToolBar, SLOT(showHistory()));
	SAFE_CONNECT_RECEIVER(_showContactList, SIGNAL(triggered()), _qtToolBar, SLOT(showContactsTab()));
	SAFE_CONNECT_RECEIVER(_settings, SIGNAL(triggered()), _qtToolBar, SLOT(showConfig()));
//	SAFE_CONNECT_RECEIVER(_signOut, SIGNAL(triggered()), _qtToolBar, SLOT(logOff()));
//	SAFE_CONNECT_RECEIVER(_quit, SIGNAL(triggered()), _qtWengoPhone, SLOT(prepareToExitApplication()));	
	SAFE_CONNECT_RECEIVER(_signOut, SIGNAL(triggered()), _qtWengoPhone, SLOT(logOff()));					//VOXOX - JRT - 2009.07.13 
	SAFE_CONNECT_RECEIVER(_quit,	SIGNAL(triggered()), _qtWengoPhone, SLOT(exitApplication()));			//VOXOX - JRT - 2009.07.13 
	
	if(!_qtToolBar->getUserIsLogged()){
		_startNew->setDisabled(true);
		_viewConversations->setDisabled(true);
		_showContactList->setDisabled(true);
		_settings->setDisabled(true);
		_signOut->setDisabled(true);
	}

	_trayMenu->addMenu(_startNew);
	_trayMenu->addMenu(_recentContacts);
	_trayMenu->addAction(_viewConversations);
	_trayMenu->addAction(_showContactList);
	if ( getCUserProfile() ) {
		_trayMenu->addMenu(createStatusMenu());
	}
	_trayMenu->addAction(_settings);
	_trayMenu->addAction(_signOut);
	_trayMenu->addAction(_quit);

	_trayIcon->setPopup(_trayMenu);
}
void MainWindow::on_actionExit_triggered()
{
    emit exitApplication();
}
예제 #17
0
/*!
    Pop view from view stack. View object is deleted.
*/
void NmApplication::popView()
{
    if (mViewStack && mViewStack->size() > 0) {
        NmBaseView *view = mViewStack->top();    
        if (view) {
            // Get top view id.
            NmUiViewId topViewId = view->nmailViewId();
            
            // Prepare for send animation if returing from editor and message
            // has been sent.
            if (topViewId == NmUiViewMessageEditor && mUiEngine->isSendingMessage()) {
				// If we are coming from message editor with back button.
				// do not prepare the send animation.
				if (!mBackButtonPressed) {
					mEffects->prepareEffect(NmUiEffects::NmEditorSendMessageAnimation);
				}
	        }
            mBackButtonPressed = false;

            // Move the application to background if closing the message list view
            if (topViewId == NmUiViewMessageList && mViewStack->size() == 1) {
                
                // if the application has been started as embedded service,
                // we must close it. Otherwise we cannot return back to the calling application.
                if (!XQServiceUtil::isEmbedded()) {
                    hideApplication();
                    return;
                }
            }

            mViewStack->pop();
            // Call custom exit function.
            view->aboutToExitView();
            // Remove view from stack.
            mMainWindow->removeView(view);
            
            // If we were in editor and sent a message, pop viewer from stack
            // first so we can go straight to mail list.
            if (!mViewStack->isEmpty() && topViewId == NmUiViewMessageEditor &&
                mUiEngine->isSendingMessage() &&
                mViewStack->top()->nmailViewId() == NmUiViewMessageViewer) {
                NmBaseView *tmpView = mViewStack->pop();
                mMainWindow->removeView(tmpView);
                delete tmpView;
                tmpView = NULL;
            }
            
            if (!mViewStack->isEmpty()) {
                // Activate next view in stack.
                NmBaseView *showView = mViewStack->top();
                mMainWindow->addView(showView);
                mMainWindow->setCurrentView(showView);
                // Store activated view id.
                mActiveViewId=showView->nmailViewId();
                // Perform send animation if requested.
                mEffects->startEffect(NmUiEffects::NmEditorSendMessageAnimation);
            }
            
            delete view;
            view = NULL;
            
            // If view was started as service, move the app now to the
            // background, unless it was started when the app was already in
            // foreground.
            if (mServiceViewId == topViewId) {
                mServiceViewId = NmUiViewNone;
                NM_COMMENT("NmApplication::popView() : returned from service view.");
                // If started as embedded or while the app was in foreground,
                // do not hide the app.
                if (!XQServiceUtil::isEmbedded() &&
                    !mForegroundService) {
                    XQServiceUtil::toBackground(true);
                }
            }
        }
    }
    
    // If the view stack is now empty quit the app. This happens also when
    // the app has been started as a service.
    if (mViewStack && mViewStack->size() == 0) {
        exitApplication();
    }
}