Exemplo n.º 1
0
ControlPanel *PanelScrollView::addControlPanel(MetaGear *metaGear)
{
  ControlPanel *controlPanel = new ControlPanel(_mainVBox, metaGear);
  metaGear->associateControlPanel(controlPanel);
  
  controlPanel->show();
    
  return controlPanel;
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    ControlPanel w;

    // Make sure ROS shuts down correctly
    //QObject::connect(&a, SIGNAL(aboutToQuit()), &w.ros_interface, SLOT(shutdown()));

    w.show();

    return a.exec();
}
bool SetPanelNameDialog::saveText(const char *s)
{
    if (IsBlankString(s)) {
        ModalErrorMessage(
            "The name string cannot be blank.");
        return false;
    } else {
        ControlPanel *panel = this->controlPanel;
        panel->setPanelName(s);
        panel->getNetwork()->setFileDirty();
    }

    return true;
}
Exemplo n.º 4
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);


    printf("start\n");

    int port = 1000;

    if (argc > 1)
        port = atoi(argv[1]);
    boost::asio::io_service io_service;
    boost::asio::ip::tcp::endpoint endp(boost::asio::ip::address::from_string("127.0.0.1"), port);
    boost::shared_ptr<rc::DataBuffer> buf(new rc::DataBuffer(50 * 1024 * 1024));

    boost::shared_ptr<rc::Decode> decode(new rc::Decode(buf));

    boost::shared_ptr<ScreenClient> client(new ScreenClient(io_service, endp, buf));
    client->on_recved_init_info = [decode](InitInfo& info)
    {
            printf("client set init info\n");
        decode->init(info);
    };

    printf("starting client\n");
    boost::thread([client]{client->start(); });

    ControlPanel* panel = new ControlPanel(QRect(50, 50, 1000, 700));
    panel->show();

    printf("starting decode\n");
    decode->set_panel(panel);
    boost::thread([decode]{decode->start(); });

    printf("starting io_service\n");
    boost::thread([&io_service]{io_service.run(); });

    return a.exec();
}
extern "C" void ControlPanelAccessDialog_OpenPanelCB(Widget widget, 
					   XtPointer clientData, 
					   XtPointer callData)
{
    Boolean  set;
    ControlPanelAccessDialog *pad = (ControlPanelAccessDialog*)clientData;
    ControlPanel *cp;
    int  cpCount2, cpCount1 = pad->panelManager->getNetwork()->getPanelCount();

    XtVaGetValues(widget, 
		  XmNset, &set,
		  XmNuserData, &cp, 
		  NULL);

    set ? cp->manage() : cp->unmanage(); 

    cpCount2 = pad->panelManager->getNetwork()->getPanelCount();

    if (cpCount2 == 0)
         pad->unmanage();
    else if (cpCount2 < cpCount1)
         pad->makeToggles();
}
void ControlPanelGroupDialog::setToggles()
{
     Widget   	widget;
     List	plist;
     int	i, size = this->toggleList[0].getSize(); 
     boolean	state=false, set = this->lastIndex;
     ControlPanel *cp;

     if(set)
     	this->panelManager->getPanelGroup(this->lastIndex, &plist);

     for(i = 1; i <= size; i++)
     {
        widget = (Widget)this->toggleList[1].getElement(i);
        XtVaGetValues(widget, XmNuserData, &cp, NULL);
        XtVaSetValues(widget, XmNset, cp->isManaged(), NULL);
        if(set)
            state = plist.isMember((void*)cp->getInstanceNumber());
        widget = (Widget)this->toggleList[0].getElement(i);
        XtVaSetValues(widget, XmNset, set AND state, NULL);
     }

}
void ControlPanelAccessDialog::makeToggles()
{
     int i, inst;
     Boolean set;
     Widget widget, lastwidget = NULL; // NULL stops scary cc warnings 
     ControlPanel *cp;
     Network      *network = this->panelManager->getNetwork();
     PanelGroupManager * pgm = network->getPanelGroupManager();
     char   *gname, *pname;

     XtUnmanageChild(this->sform);

     ListIterator  li(this->toggleList[0]);
     int size = network->getPanelCount();

     if(this->toggleList[0].getSize() > 0)
     {
        while( (widget = (Widget)li.getNext()) )
             XtDestroyWidget(widget);

	li.setList(this->toggleList[1]);
        while( (widget = (Widget)li.getNext()) )
             XtDestroyWidget(widget);

        this->toggleList[0].clear();
        this->toggleList[1].clear();
     }

     if(this->separator)
     {
	XtDestroyWidget(this->separator);
	this->separator = NULL;
     }

     if(this->toggleList[2].getSize() > 0)
     {
	li.setList(this->toggleList[2]);
        while( (widget = (Widget)li.getNext()) )
             XtDestroyWidget(widget);

        this->toggleList[2].clear();
     }

     if(size == 0)
        return;

     for(i = 0; i < size; i++)
     {
        cp = network->getPanelByIndex(i+1);
	inst = cp->getInstanceNumber();
	set  = this->panelManager->isAccessiblePanel(inst);

        pname = (char*)cp->getPanelNameString();
        if(IsBlankString(pname))
            pname = "Control Panel";

        widget = XmCreateToggleButton(this->sform,
                                     pname, 
                                     NULL,
                                     0);
        XtVaSetValues(widget,
		      XmNset,		 set,
		      XmNindicatorType,	 XmN_OF_MANY,
		      XmNalignment,	 XmALIGNMENT_BEGINNING,
		      XmNshadowThickness,0,
		      XmNleftAttachment, XmATTACH_FORM,
		      XmNrightAttachment,XmATTACH_POSITION,
		      XmNrightPosition,  80,
		      XmNtopOffset,      2,
		      XmNleftOffset,     2,
                      NULL);
	if(i == 0)
            XtVaSetValues(widget, XmNtopAttachment,XmATTACH_FORM,NULL);
	else
            XtVaSetValues(widget,
		          XmNtopAttachment,XmATTACH_WIDGET,
		          XmNtopWidget,    lastwidget,
                          NULL);

	if(this->panelManager->getControlPanel() == cp)
            XtVaSetValues(widget, 
			  XmNsensitive, False,
			  XmNset,	False, 
			  NULL);

        this->toggleList[0].appendElement((void*)widget);
        XtManageChild(widget);

	set = cp->isManaged();
        widget = XmCreateToggleButton(this->sform,
                                     "...",
                                     NULL,
                                     0);
        XtVaSetValues(widget,
		      XmNuserData,      cp,
		      XmNset,		set,
		      XmNindicatorOn,	False,
    		      XmNfillOnSelect,  False,
		      XmNrightAttachment,XmATTACH_FORM,
		      XmNleftAttachment,XmATTACH_POSITION,
		      XmNleftPosition,  80,
		      XmNtopOffset,     2,
		      XmNleftOffset,    5,
		      XmNindicatorSize, 1,
		      XmNspacing,	0,
                      NULL);
	if(i == 0)
            XtVaSetValues(widget, XmNtopAttachment,XmATTACH_FORM,NULL);
	else
            XtVaSetValues(widget,
		          XmNtopAttachment,XmATTACH_WIDGET,
		          XmNtopWidget,    lastwidget,
                          NULL);

	if(this->panelManager->getControlPanel() == cp)
            XtVaSetValues(widget, XmNsensitive, False, NULL);

        XtAddCallback(widget,
                      XmNvalueChangedCallback,
                      (XtCallbackProc)ControlPanelAccessDialog_OpenPanelCB,
                      (XtPointer)this);

        this->toggleList[1].appendElement((void*)widget);
        XtManageChild(widget);

	lastwidget = widget;
     }

    size = pgm->getGroupCount();

    if(size == 0)
    {
     	XtManageChild(this->sform);
	return;
    }

    this->separator = XtVaCreateManagedWidget("separator",
	xmSeparatorGadgetClass, this->sform,
        XmNleftAttachment,    XmATTACH_FORM,
        XmNleftOffset,        2,
        XmNrightAttachment,   XmATTACH_FORM,
        XmNrightOffset,       2,
        XmNtopAttachment,     XmATTACH_WIDGET,
        XmNtopWidget,         lastwidget,
        XmNtopOffset,         5,
        NULL);
   
     for(i = 1; i <= size; i++)
     {
	gname = (char*)pgm->getPanelGroup(i, NULL);
	set  = this->panelManager->isAccessibleGroup(gname);

        widget = XmCreateToggleButton(this->sform, gname, NULL, 0);
        XtVaSetValues(widget,
                      XmNset,            set,
                      XmNindicatorType,  XmN_OF_MANY,
                      XmNalignment,      XmALIGNMENT_BEGINNING,
                      XmNshadowThickness,0,
                      XmNleftAttachment, XmATTACH_FORM,
                      XmNtopAttachment,  XmATTACH_WIDGET,
                      XmNtopOffset,      2,
                      XmNleftOffset,     2,
                      NULL);
        if(i == 1)
            XtVaSetValues(widget, 
			  XmNtopWidget,    this->separator,
                          XmNtopOffset,    5,
			  NULL);
        else
            XtVaSetValues(widget,
                          XmNtopWidget,    lastwidget,
                          NULL);

        this->toggleList[2].appendElement((void*)widget);
        XtManageChild(widget);

	lastwidget = widget;
    }

     XtManageChild(this->sform);
}
Exemplo n.º 8
0
Arquivo: main.cpp Projeto: goeb/ji3
int main(int argc, char **argv)
{
    Logger::init(".");
    SoundManager::init();



    LOG_INFO("Starting...");
    QApplication app(argc, argv);
    QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));

    QString scenario;

    // set default values
    float period = 1; // seconds
    int numberOfItems = 10;
    int ratioOfExceptions = 10; // percent
    TestMode modeInhibition = MODE_ATTENTION;
    bool commandLine = false;
    const char * codec = 0;

    QStringList args = QCoreApplication::arguments();
    int n = args.size();
    int i = 1;

    while (i<n) {
        QString arg = args.at(i);
        //LOG_DEBUG("arg=" << arg.toLocal8Bit().constData());
        if (arg == "-p") { // period
            i++; if (i >= n) usage();
            period = args.at(i).toFloat();
        } else if (arg == "-n") {
            i++; if (i >= n) usage();
            numberOfItems = args.at(i).toInt();
        } else if (arg == "--codec") {
            i++; if (i >= n) usage();
            codec = args.at(i).toAscii().constData();
        } else if (arg == "-x") {
            i++; if (i >= n) usage();
            ratioOfExceptions = args.at(i).toInt();
        } else if (arg == "-a") {
            modeInhibition = MODE_ATTENTION;
        } else if (arg == "-i") {
            modeInhibition = MODE_INHIBITION;
        } else if (arg == "-ads") {
            modeInhibition = MODE_DIVIDED_ATTENTION_SOUND;
        } else if (arg == "-adv") {
            modeInhibition = MODE_DIVIDED_ATTENTION_VISUAL;
        } else if (arg == "-h") {
            usage();
        } else {
            // scenario
            scenario = args.at(i);
            commandLine = true;
        }
        i++;
    }

    if (codec) {
        QTextCodec::setCodecForCStrings(QTextCodec::codecForName(codec));
        QTextCodec::setCodecForLocale(QTextCodec::codecForName(codec));
    }

    ControlPanel *c = 0;
    QString player = "";
    bool playGame = false;
    bool showGraph = false;
    bool withSound = true;
    while (1) {
        showGraph = false;
        playGame = false;

        if (commandLine) {
            // command line mode:
            // start immediately test with values given on the command line.

            LOG_DEBUG("scenario=" << scenario.toLocal8Bit().constData() << ", period=" << period <<
                      ", numberOfItems=" << numberOfItems << ", ratioOfExceptions=" << ratioOfExceptions <<
                      ", modeInhibition=" << modeInhibition);

            playGame = true;
        } else {

            // show control panel
            LOG_INFO("Show Contol Panel");
            if (!c) c = new ControlPanel();

            c->updateTable();
            c->show();
            int r = app.exec();
            LOG_DEBUG("after app.exec(), r=" << r);

            if (0 == r) { // ctrl-Q, or closed window
                // really quit
                exit(0);
            } else {
                if (2 == r) {
                    // show graph
                    showGraph = true;

                } else {
                    // play game
                    playGame = true;
                }

                // retrieve values from object 'c'.
                LOG_DEBUG("player=" << c->getPlayer().toLocal8Bit().constData() <<
                          ", scenario=" << c->getScenario().toLocal8Bit().constData() <<
                          ", sound=" <<  c->getSound());
                ratioOfExceptions = c->getRatio();
                period = c->getPeriod()/1000;
                numberOfItems = c->getNumber();
                modeInhibition = c->getType();
                scenario = c->getScenario();
                player = c->getPlayer();
                withSound = c->getSound();
            }
        }

        Scenario s(scenario.toLocal8Bit().constData(), period*1000, numberOfItems, ratioOfExceptions, modeInhibition, withSound);
        QString filename = User::getUserfile(player);

        if (playGame) {
            if (c) c->hide();

            s.load();
            s.generateItemList();
            s.generateDistractors();

            Viewer imageViewer(s);
            //imageViewer.showFullScreen();
            imageViewer.show();
            imageViewer.resize(800,600);
            int r = app.exec();

            LOG_DEBUG("Return from Viewer: r=" << r);

            if (commandLine) exit(0);

            if (r == 0) { // closed window, of 'q' pressed
                // else 'q' pressed, do not store result into file
            } else {
                // nominal case
                if (!player.isEmpty()) {
                    // store to file
                    s.store(filename);

                    // go to curve diagram
                    showGraph = true;
                }
            }

        }

        if (showGraph) {
            if (c) c->hide();

            // from user name, get list of scenarios
            // from these scenarii, only keep those matching the last one
            // (so that the curve compares things comparable)
            GraphPanel x(filename, s);
            x.show();
            int r = app.exec();
        }
    }

}
extern "C" void ControlPanelGroupDialog_AddCB(Widget widget,
                                           XtPointer clientData,
                                           XtPointer callData)
{
    ControlPanelGroupDialog* pgd = (ControlPanelGroupDialog*)clientData;
    char* oldname = NULL;
    char* name = XmTextGetString(pgd->text); 
    Boolean setting;

    if(widget == pgd->changebtn)
    {
    	oldname = (char*)pgd->panelManager->getPanelGroup(pgd->lastIndex, NULL);
	if(EqualString(oldname, name))
	{
    	    pgd->panelManager->removePanelGroup(name);
	    oldname = NULL;
        }
    }	

    if(IsBlankString(name))
    {
	ModalErrorMessage(pgd->getRootWidget(), "No name is given.");
	goto error;
    }
    else
    if(NOT pgd->panelManager->createPanelGroup(name))
    {
	ModalErrorMessage(pgd->getRootWidget(), "%s already exists.", name);
	goto error;
    }
    else
    {
	int     i, size = pgd->toggleList[0].getSize();	
	Widget  widget;
	ControlPanel *cp;	

	for(i = 1; i <= size; i++)	
	{
	     widget = (Widget)pgd->toggleList[0].getElement(i);
	     XtVaGetValues(widget, XmNset, &setting, NULL);
	     if(setting)
	     {
	     	widget = (Widget)pgd->toggleList[1].getElement(i);
	     	XtVaGetValues(widget, XmNuserData, &cp, NULL);
		pgd->panelManager->addGroupMember(name,cp->getInstanceNumber()); 
	     }
	}

	if(oldname)	
    	    pgd->panelManager->removePanelGroup(oldname);
	pgd->makeGroupList(-1);
    }


    //
    // Let the application know that the panels have changed (generally,
    // this means notifying the DXWindows which may have panelAccessDialogs
    // open).
    //
    theDXApplication->notifyPanelChanged();

error:
    if(name)  XtFree(name);   //	AJ
}
void ControlPanelGroupDialog::makeToggles()
{
     int i;
     Boolean set = FALSE, state = FALSE;
     Widget widget, lastwidget = NULL; // NULL stops scary cc warnings
     ControlPanel *cp;
     List    glist;
     char    *pname;
     Network      *network = this->panelManager->getNetwork();

     ListIterator  li(this->toggleList[0]);
     int size = network->getPanelCount();

     XtUnmanageChild(this->sform);

     if(this->toggleList[0].getSize() > 0)
     {
        while( (widget = (Widget)li.getNext()) )
             XtDestroyWidget(widget);

	li.setList(this->toggleList[1]);
        while( (widget = (Widget)li.getNext()) )
             XtDestroyWidget(widget);

        this->toggleList[0].clear();
        this->toggleList[1].clear();
     }

     if(size == 0)
     {
        this->unmanage();
        return;
     }

     set = this->lastIndex 
	   AND this->panelManager->getGroupCount()
     	   AND this->panelManager->getPanelGroup(this->lastIndex, &glist);

     for(i = 0; i < size; i++)
     {
        cp = network->getPanelByIndex(i+1);
	/*inst = cp->getInstanceNumber();*/
	if(set)
	     state = glist.isMember((void*)cp->getInstanceNumber());
	else
	     state = FALSE;

        pname = (char*)cp->getPanelNameString();
        if(IsBlankString(pname))
            pname = "Control Panel";

        widget = XmCreateToggleButton(this->sform,
                                     pname, 
                                     NULL,
                                     0);
        XtVaSetValues(widget,
		      XmNset,		 state,
		      XmNindicatorType,	 XmN_OF_MANY,
		      XmNalignment,	 XmALIGNMENT_BEGINNING,
		      XmNshadowThickness,0,
		      XmNleftAttachment, XmATTACH_FORM,
		      XmNrightAttachment,XmATTACH_POSITION,
		      XmNrightPosition,  70,
		      XmNtopOffset,      2,
		      XmNleftOffset,     2,
                      NULL);
	if(i == 0)
            XtVaSetValues(widget, XmNtopAttachment,XmATTACH_FORM,NULL);
	else
            XtVaSetValues(widget,
		          XmNtopAttachment,XmATTACH_WIDGET,
		          XmNtopWidget,    lastwidget,
                          NULL);

        this->toggleList[0].appendElement((void*)widget);
        XtManageChild(widget);

	state = cp->isManaged();
        widget = XmCreateToggleButton(this->sform,
                                     "...",
                                     NULL,
                                     0);
        XtVaSetValues(widget,
		      XmNuserData,      cp,
		      XmNset,		state,
		      XmNindicatorOn,	False,
		      XmNfillOnSelect,	False,
		      XmNrightAttachment,XmATTACH_FORM,
		      XmNleftAttachment,XmATTACH_POSITION,
		      XmNleftPosition,  70,
		      XmNindicatorSize, 1,
		      XmNtopOffset,     2,
		      XmNleftOffset,    5,
                      NULL);
	if(i == 0)
            XtVaSetValues(widget, XmNtopAttachment,XmATTACH_FORM,NULL);
	else
            XtVaSetValues(widget,
		          XmNtopAttachment,XmATTACH_WIDGET,
		          XmNtopWidget,    lastwidget,
                          NULL);

        XtAddCallback(widget,
                      XmNvalueChangedCallback,
                      (XtCallbackProc)ControlPanelGroupDialog_OpenPanelCB,
                      (XtPointer)this);

        this->toggleList[1].appendElement((void*)widget);
        XtManageChild(widget);

	lastwidget = widget;
     }

     XtManageChild(this->sform);
}