bool MgrStereoHand::init(){
	initWindows();

	drawingModule = new DrawingModule;

	fs = new FrameStorage;
	fs->initFrames();

	calibModule = new CalibrationModule;

	process = new ProcessingThread;
	process->init(fs, calibModule, calibDialog, statisticsDialog);

	calibDialog->init(calibModule);

	realProcessingThead = new QThread();
	process->moveToThread(realProcessingThead);

	connect(realProcessingThead, SIGNAL(started()), process, SLOT(process()));
	connect(process, SIGNAL(finished()), realProcessingThead, SLOT(quit()));
	connect(process, SIGNAL(finished()), process, SLOT(deleteLater()));
	connect(realProcessingThead, SIGNAL(finished()), realProcessingThead, SLOT(deleteLater()));
	
	connect(realProcessingThead, SIGNAL(finished()), this, SLOT(realExit()));
	
	connect(process, SIGNAL(showImages()), this, SLOT(showImages()));
	connect(process, SIGNAL(messageError(QString, QString)), this, SLOT(errorMessage(QString, QString)));
	connect(process, SIGNAL(startedProcess()), this, SLOT(startedProcess()));
	connect(process, SIGNAL(finishedProcess()), this, SLOT(finishedProcess()));
	connect(process, SIGNAL(calibrationNotSet()), this, SLOT(calibrationNotSet()));
	connect(process, SIGNAL(showOverlay(QString,int)), this, SLOT(showOverlay(QString,int)));
	connect(process, SIGNAL(getFilmFileName()), this, SLOT(getFilmFileName()));
	//connect(this, SIGNAL(showOverlay(QString,int)), this, SLOT(showOverlay(QString,int)));
	
	realProcessingThead->start();

	return true;
}
示例#2
0
文件: Menu.cpp 项目: AlIako/PSNBL
void Menu::clicOn(string name, bool leftClic)
{
    Gsounds::getInstance()->play("../data/sounds/hover.mp3");

    if(leftClic && name=="start")
    {
        curMenu="start";
        menuStart(&m_buttons);
    }
    if(leftClic && name=="single")
    {
        Config::getInstance()->mode="server";
        Online::getInstance()->setActive(false);
        command="play";

        mapSelected="";
        curMenu=name;
        menuSingle(&m_buttons);

        //fadingToLeave=true;
    }
    if(leftClic && curMenu=="single" && name!="single" && name!="linkocraftcom" && name!="back" && name!="title")
    {
        Config::getInstance()->mode="server";
        Online::getInstance()->setActive(false);
        command="play "+name;
        mapSelected=name;
        fadingToLeave=true;
    }
    if(leftClic && name=="join")
    {
        Config::getInstance()->mode="client";

        Online::getInstance()->setActive(true);
        Online::getInstance()->ini();
        Online::getInstance()->startThreads();

        if(!Online::getInstance()->m_server)
        {
            Online::getInstance()->setIncontrol(false);

            GTime start_try_connect;
            start_try_connect.reset();
            while(!Online::getInstance()->m_connectionEstablished && !start_try_connect.ecouler(2500))
            {
                start_try_connect.couler();
                Online::getInstance()->update();
                SDL_Delay(50);
            }
        }

        if(Online::getInstance()->m_connectionEstablished)
        {
            command="play";
            fadingToLeave=true;
        }
        else//fail connection
        {
            Online::getInstance()->closeOnline();
            messageError("Connection to server failed.");
        }

    }
    if(leftClic && name=="create")
    {
        Config::getInstance()->mode="server";

        Online::getInstance()->setActive(true);
        Online::getInstance()->ini();

        command="play";
        fadingToLeave=true;
    }
    if(leftClic && name=="multi")
    {
        curMenu=name;
        menuMultiplayer(&m_buttons);
    }
    if(leftClic && name=="editor")
    {
        mapSelected="";
        curMenu=name;
        menuEditor(&m_buttons,"../data/"+Config::getInstance()->editorpath+"/");
    }
    if(curMenu=="editor" && (name=="patterns" || name=="levels"))
    {
        mapSelected="";
        Config::getInstance()->editorpath=name;
        Config::getInstance()->save();
        menuEditor(&m_buttons,"../data/"+Config::getInstance()->editorpath+"/");
    }
    if(name.find("../data/patterns/")!=string::npos || name.find("../data/levels/")!=string::npos)
    {
        if(leftClic)
        {
            mapSelected=name;
            for(unsigned int i=0;i<m_buttons.size();i++)
            {
                if(m_buttons[i].getName()==name)
                    m_buttons[i].select(true);
                else m_buttons[i].select(false);
            }
        }
        else//right clic: open map with editor
        {
            command="editor "+name;
            fadingToLeave=true;
        }
    }
    if(leftClic && name=="open")
    {
        if(curMenu=="editor")
        {
            if(mapSelected!="")
            {
                command="editor "+mapSelected;
                cerr<<"going editor "<< command<<endl;
                fadingToLeave=true;
            }
        }
    }
    if(leftClic && name=="delete")
    {
        if(curMenu=="editor")
        {
            if(mapSelected!="")
            {
                if(messageSure())
                {
                    cerr<<"deleting "<< mapSelected<<endl;

                    char* tempChar=stringtochar(mapSelected);
                    remove(tempChar);
                    delete tempChar;

                    mapSelected="";

                    menuEditor(&m_buttons,"../data/"+Config::getInstance()->editorpath+"/");
                }
            }
        }
    }
    if(leftClic && name=="test")
    {
        if(curMenu=="editor")
        {
            if(mapSelected!="")
            {
                Config::getInstance()->mode="server";

                Online::getInstance()->setActive(false);

                command="play "+mapSelected;
                cerr<<"going play "<< command<<endl;
                fadingToLeave=true;
            }
        }
    }
    if(leftClic && name=="new")
    {
        if(curMenu=="editor")
        {
            string inputName=inputString("","Enter Name:");
            if(inputName!="")
            {
                inputName="../data/patterns/"+inputName+".txt";
                command="editor "+inputName;
                cerr<<"going editor "<< command<<endl;
                fadingToLeave=true;
            }
        }
    }

    if(leftClic && name=="options")
    {
        curMenu=name;
        menuOptions(&m_buttons);
    }
    if(leftClic && name=="audio")
    {
        curMenu=name;
        menuAudio(&m_buttons);
    }
    if(leftClic && name=="sound")
    {
        Config::getInstance()->toggleSound();
        Config::getInstance()->save();
        Gsounds::getInstance()->on=Config::getInstance()->sound;
        Gsounds::getInstance()->pauseSounds(Gsounds::getInstance()->on);
        menuAudio(&m_buttons);
    }
    if(leftClic && name=="music")
    {
        Config::getInstance()->toggleMusic();
        Config::getInstance()->save();
        Gsounds::getInstance()->music=Config::getInstance()->music;
        Gsounds::getInstance()->pauseMusic(Gsounds::getInstance()->music);
        menuAudio(&m_buttons);
    }
    if(leftClic && name=="video")
    {
        curMenu=name;
        menuVideo(&m_buttons);
    }
    if(leftClic && name=="fullscreen")
    {
        Config::getInstance()->toggleFullscreen();
        Config::getInstance()->save();
        menuVideo(&m_buttons);
    }
    if(name=="resolution")
    {
        Vector3D next=Vector3D(0,0,0);
        if(leftClic)
            next=Video::getInstance()->nextResolution(Config::getInstance()->width,Config::getInstance()->height);
        else next=Video::getInstance()->previousResolution(Config::getInstance()->width,Config::getInstance()->height);

        Config::getInstance()->width=next.X;
        Config::getInstance()->height=next.Y;
        Config::getInstance()->save();
        menuVideo(&m_buttons);
    }

    if(leftClic && name=="host")
    {
        curMenu=name;
        menuHost(&m_buttons);
    }
    if(leftClic && name=="joingame")
    {
        curMenu=name;
        menuJoin(&m_buttons);
    }
    if(leftClic && name=="name")
    {
        Config::getInstance()->name=inputString(Config::getInstance()->name,"Enter Name:");
        Config::getInstance()->save();
        menuMultiplayer(&m_buttons);
    }
    if(leftClic && name=="ip")
    {
        Config::getInstance()->ip=inputString(Config::getInstance()->ip,"Enter ip:");
        Config::getInstance()->save();
        menuJoin(&m_buttons);
    }
    if(leftClic && name=="port")
    {

        std::stringstream ss;
        ss << Config::getInstance()->port;

        istringstream buffer(inputString(ss.str(),"Enter Port:",true));
        int value;
        buffer >> value;

        Config::getInstance()->port=value;
        Config::getInstance()->save();


        if(curMenu=="joingame")
            menuJoin(&m_buttons);
        else if(curMenu=="host")
            menuHost(&m_buttons);
    }