void FileLogger::timerEvent(QTimerEvent* event)
{
    if (!event)
    {
        return;
    }
    else if (event->timerId()==refreshTimer.timerId())
    {
        refreshSettings();
    }
    else if (event->timerId()==flushTimer.timerId() && file)
    {
        mutex.lock();

        // Flush the I/O buffer
        file->flush();

        // Rotate the file if it is too large
        if (maxSize>0 && file->size()>=maxSize)
        {
            close();
            rotate();
            open();
        }

        mutex.unlock();
    }
}
Пример #2
0
void highSpeed::setROI(int _x, int _y, int w, int h)
{
	unsigned long roiStep=0;
	XsGetCameraInfo(hCam,XSI_ROI_STEP,&roiStep,&nHi);
	XsGetCameraInfo(hCam,XSI_SNS_WIDTH,&maxWidth,&nHi);
	XsGetCameraInfo(hCam,XSI_SNS_HEIGHT,&maxHeight,&nHi);
	if(_x>=0&&_x+w<=maxWidth){
		if(_y>=0&&_y+h<=maxHeight){
			x=_x,y=_y;
			int found=w;
			int diff=2048;
			int num=0;
			for(int i=0; i<maxWidth/roiStep+1; i++){
				int k=i*roiStep;
				if(abs(w-(k))<diff) diff=abs(w-(k)),found=k;
			}
			width=found;
			height=h;
			XsSetParameter(hCam,&xsCfg,XSP_ROIX,x);
			XsSetParameter(hCam,&xsCfg,XSP_ROIY,y);
			XsSetParameter(hCam,&xsCfg,XSP_ROIWIDTH,width);
			XsSetParameter(hCam,&xsCfg,XSP_ROIHEIGHT,height);
			refreshSettings();
		}
	}
	updateFrameSize();
}
Пример #3
0
void highSpeed::setFPS(unsigned long fps)
{
	nFPS=fps;
	if(nFPS>1500) nFPS=1500;
	else if(nFPS<1) nFPS=1;
	nPeriod=1000000000/nFPS;
	XsSetParameter(hCam,&xsCfg,XSP_PERIOD,nPeriod);
	refreshSettings();
}
Пример #4
0
bool TrackControlWindow::eventFilter(QObject *obj, QEvent *evt) {
    if (evt->type() == QEvent::HoverEnter) {
        this->setWindowOpacity(1);
    }
    if (evt->type() == QEvent::HoverLeave) {
        refreshSettings();
    }
    return QWidget::eventFilter(obj, evt);
}
Пример #5
0
void highSpeed::setRotation(XS_ROT_ANGLE angle)
{
	if(angle == XS_ROT_90 || angle == XS_ROT_270){
		int tWid=width;
		width=height;
		height=tWid;
	}
	XsSetParameter(hCam,&xsCfg,XSP_ROT_ANGLE,angle);
	refreshSettings();
}
Пример #6
0
void highSpeed::setExposure(double timeInMillis)
{
	XsGetParameterAttribute(hCam,&xsCfg,XSP_EXPOSURE,XS_ATTR_MIN,&nMinExp);
	nExp=timeInMillis*1000000;
	if( nExp<nMinExp )
		nExp = nMinExp;
	else if( nExp>(nPeriod-3000) )
		nExp = nPeriod-3000;
	XsSetParameter(hCam,&xsCfg,XSP_EXPOSURE,nExp);
	refreshSettings();
}
Пример #7
0
bool Java::compile(const QString& filename, const QString& port)
{
	QFileInfo sourceInfo(filename);
	QStringList args;

	refreshSettings();

	m_outputFileName = sourceInfo.dir().absoluteFilePath(sourceInfo.baseName());
	QStringList files = QDir(m_outputFileName).entryList(QStringList() << "*.class");

	foreach(const QString& file, files) {
		QFile(m_outputFileName + "/" + file).remove();
	}
FileLogger::FileLogger(QSettings* settings, const int refreshInterval, QObject* parent)
    : Logger(parent)
{
    Q_ASSERT(settings!=0);
    Q_ASSERT(refreshInterval>=0);
    this->settings=settings;
    file=0;
    if (refreshInterval>0)
    {
        refreshTimer.start(refreshInterval,this);
    }
    flushTimer.start(1000,this);
    refreshSettings();
}
Пример #9
0
void MainWindow::on_actionSettings_triggered()
{
	if (state == STATE_RUNNING) mode_switch();
	SettingsDialog* dialog = new SettingsDialog(this);
	dialog->dropPreview = dropPreview;
	dialog->interval = interval;
	dialog->init_settings();
	dialog->setModal(true);
	dialog->exec();
	dropPreview = dialog->dropPreview;
	interval = dialog->interval;
	qDebug() << "dropPreview:" << dropPreview;
	qDebug() << "interval:" << interval;
	refreshSettings(true);
}
Пример #10
0
void MainWindow::addTab(TabbedWidget* tab)
{
	if(!tab->beginSetup()) return;
	addLookup(tab);
	setUpdatesEnabled(false);
	int tabNum = ui_tabWidget->addTab(tab->widget(), QString::fromAscii(""));
	ui_tabWidget->setCurrentIndex(tabNum);
	setUpdatesEnabled(true);
	tab->completeSetup();
	moveToTab(tab);
	
	QObject::connect(this, SIGNAL(settingsUpdated()), tab->widget(), SLOT(refreshSettings()));
	
	emit updateActivatable();
}
Пример #11
0
bool Gcc::compile(QString filename)
{
	QFileInfo sourceInfo(filename);
	QStringList args;

	refreshSettings();

#ifdef Q_OS_WIN32
	m_outputFileName = sourceInfo.dir().absoluteFilePath(sourceInfo.baseName() + ".exe");
#else
	m_outputFileName = sourceInfo.dir().absoluteFilePath(sourceInfo.baseName());
#endif
	QString objectName = sourceInfo.dir().absoluteFilePath(sourceInfo.baseName() + ".o");

	QFileInfo outputInfo(m_outputFileName);
	if(sourceInfo.lastModified() < outputInfo.lastModified())
		return true;

	args = m_cflags;
	m_defaultPort.replace("\\", "\\\\");
	args << "-DDEFAULT_SERIAL_PORT=\"" + m_defaultPort + "\"";
	args << "-c" << filename << "-o" << objectName;
	m_gcc.start(m_gccPath, args);
	m_gcc.waitForFinished();
	processCompilerOutput();
	m_linkerMessages.clear();

	if(m_gcc.exitCode() != 0)
		return false;

	args.clear();
	args << "-o" << m_outputFileName << objectName;
	args << m_lflags;
	m_gcc.start(m_gccPath, args);
	m_gcc.waitForFinished();
	processLinkerOutput();

	QFile objectFile(objectName);
	objectFile.remove();

	if(m_gcc.exitCode() == 0)
		return true;
	return false;
}
Пример #12
0
INT_PTR CALLBACK RenderControlDlg::dialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	char buf[20];

	switch(uMsg)
	{
	case WM_INITDIALOG:
		SetDlgItemInt(hwndDlg, IDC_WIDTH, mSettings.width, TRUE);
		SetDlgItemInt(hwndDlg, IDC_HEIGHT, mSettings.height, TRUE);
		CheckDlgButton(hwndDlg, IDC_LIGHTING, mSettings.lighting ? BST_CHECKED : BST_UNCHECKED);
		SetDlgItemInt(hwndDlg, IDC_MIN_SAMPLES, mSettings.minSamples, TRUE);
		SetDlgItemInt(hwndDlg, IDC_MAX_SAMPLES, mSettings.maxSamples, TRUE);
		sprintf_s(buf, sizeof(buf), "%.4f", mSettings.sampleThreshold);
		SetDlgItemText(hwndDlg, IDC_SAMPLE_THRESHOLD, buf);
		SendDlgItemMessage(hwndDlg, IDC_MAX_GEN_SPIN, UDM_SETRANGE, 0, MAKELPARAM(20, 1));
		CheckDlgButton(hwndDlg, IDC_RADIANT, mSettings.lighterSettings.radiantLighting ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwndDlg, IDC_SPECULAR, mSettings.lighterSettings.specularLighting ? BST_CHECKED : BST_UNCHECKED);
		SetDlgItemInt(hwndDlg, IDC_SPECULAR_MAX_GENERATION, mSettings.lighterSettings.specularMaxGeneration, TRUE);
		CheckDlgButton(hwndDlg, IDC_DIRECT, mSettings.lighterSettings.directLighting ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hwndDlg, IDC_INDIRECT, mSettings.lighterSettings.indirectLighting ? BST_CHECKED : BST_UNCHECKED);
		SetDlgItemInt(hwndDlg, IDC_INDIRECT_SAMPLES, mSettings.lighterSettings.indirectSamples, TRUE);
		CheckDlgButton(hwndDlg, IDC_IRRADIANCE_CACHING, mSettings.lighterSettings.irradianceCaching ? BST_CHECKED : BST_UNCHECKED);
		sprintf_s(buf, sizeof(buf), "%.3f", mSettings.lighterSettings.irradianceCacheThreshold);
		SetDlgItemText(hwndDlg, IDC_IRRADIANCE_CACHE_THRESHOLD, buf);
		return FALSE;

	case WM_COMMAND:
		switch(LOWORD(wParam))
		{
		case ID_RENDER:
			refreshSettings();
			mListener->onRenderButtonClicked();
			return TRUE;
		}
		break;

	case WM_CLOSE:
		ShowWindow(hwndDlg, SW_HIDE);
		return TRUE;
	}
	return FALSE;
}
Пример #13
0
void Minitel::moveCursorTo(byte location) {
  if (location == HOME || location == LINE_END || location == TOP_LEFT) {
    serialprint7(location);
  }
  else if (location == CENTER || location == TOP_RIGHT || location == BOTTOM_RIGHT || location == BOTTOM_LEFT) {
    if (location == CENTER) {
      moveCursorTo(20, 12);
    }
    else if (location == TOP_RIGHT) {
      moveCursorTo(40, 1);
    }
    else if (location == BOTTOM_RIGHT) {
      moveCursorTo(40, 24);
    }
    else if (location == BOTTOM_LEFT) {
      moveCursorTo(1, 24);
    }
    refreshSettings()  ;
  }
}
Пример #14
0
MainWindow::MainWindow (QWidget * parent):
QMainWindow (parent), ui (new Ui::MainWindow)
{
	ui->setupUi (this);
	scene = new QGraphicsScene (0, 0, BOARD_WIDTH * BOARD_TILE_SIZE,
		BOARD_HEIGHT * BOARD_TILE_SIZE);
	scene->setBackgroundBrush(QBrush(QColor(Qt::white)));
	ui->graphicsView->setScene (scene);
	nextScene = new QGraphicsScene (0, 0, 4*BOARD_TILE_SIZE, 4*BOARD_TILE_SIZE);
	nextScene->setBackgroundBrush(QBrush(QColor(Qt::black)));
	ui->nextView->setScene(nextScene);
	timer = new QTimer (this);
	connect(timer, SIGNAL(timeout()), this, SLOT(timer_timeout()));
	srand (std::time(NULL));
	game = new normal_game (BOARD_WIDTH, BOARD_HEIGHT);
	state = STATE_INIT;
	setWindowState(Qt::WindowMaximized);
	settings = new QSettings(SETTINGS_ORGNIZATION, SETTINGS_APPLICATION);
	refreshSettings();
}
Пример #15
0
void Messenger::reset()
{
    m_packetNo = 1;

    if (socket) {
        socket->close();
        delete socket;
        socket = NULL;
    }

    socket = new QUdpSocket(this);

    if (!socket->bind(UDP_PORT))
    {
        QMessageBox::critical(0, tr("Connection Error"), tr("Could not bind, perhaps port %1 is being used by another application.").arg(UDP_PORT));
        exit(1);
    }

    refreshSettings();
    connect(socket, SIGNAL(readyRead()), this, SLOT(receiveData()));
}
Пример #16
0
void Minitel::init() {
	Serial.begin(1200);
	begin(1200);
	useDefaultColors();
	refreshSettings();
}
Пример #17
0
void CSceneMenu::inputKey(char Key)
{
#ifdef _KINECT_
    if(iCurrentMenu == MENU_KINECT_INFO)
        sceneChange(SCENE_MATCH);
#endif

    switch(Key)
    {
    case KEY_ESC:

        switch(iCurrentMenu)
        {
        case MENU_MAIN:
            sceneChange(0);
            break;

        case MENU_PLAY:
            enterMenu(MENU_MAIN);
            break;

        case MENU_SETTINGS:
            enterMenu(MENU_MAIN);
            iSelectedOption = 1;
            break;

        case MENU_MULTIPLAYER:
            enterMenu(MENU_PLAY);
            iSelectedOption = 1;
            break;

        case MENU_MULTIPLAYER_SERVER:
            enterMenu(MENU_MULTIPLAYER);
            break;

        case MENU_MULTIPLAYER_CLIENT:
            enterMenu(MENU_MULTIPLAYER);
            iSelectedOption = 1;
            break;

        case MENU_SETTINGS_DIFFICULTY:
            enterMenu(MENU_SETTINGS);
            iSelectedOption = 5;
            break;

        case MENU_SETTINGS_KINECT:
            enterMenu(MENU_SETTINGS);
            iSelectedOption = 6;
            break;
        }

        break;
        
    case KEY_ENTER:

        selectOption(iSelectedOption);        

        break;

    case KEY_BACKSPACE:

        // port
        if((iCurrentMenu == MENU_MULTIPLAYER_SERVER && iSelectedOption == 0) ||
           (iCurrentMenu == MENU_MULTIPLAYER_CLIENT && iSelectedOption == 1))
        {
            if(strlen(sPort) > 0)
                sPort[strlen(sPort) - 1] = '\0';

            sGlobal->iPort = (strlen(sPort) > 0)? atoi(sPort): 0;

            refreshSettings();        
        }

        // server IP
        else if(iCurrentMenu == MENU_MULTIPLAYER_CLIENT && iSelectedOption == 0)
        {
            if(strlen(sGlobal->sIPServer) > 0)
            {
                sGlobal->sIPServer[strlen(sGlobal->sIPServer) - 1] = '\0';
                refreshSettings();
            }
        }

        break;

    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':

        // port
        if((iCurrentMenu == MENU_MULTIPLAYER_SERVER && iSelectedOption == 0) ||
           (iCurrentMenu == MENU_MULTIPLAYER_CLIENT && iSelectedOption == 1))
        {
            if(strlen(sPort) < 5)
            {
                sPort[strlen(sPort) + 1] = '\0';
                sPort[strlen(sPort)] = Key;
                sGlobal->iPort = atoi(sPort);
                refreshSettings();
            }
        }

        // server IP
        else if(iCurrentMenu == MENU_MULTIPLAYER_CLIENT && iSelectedOption == 0)
        {
            if(strlen(sGlobal->sIPServer) < 15)
            {
                sGlobal->sIPServer[strlen(sGlobal->sIPServer) + 1] = '\0';
                sGlobal->sIPServer[strlen(sGlobal->sIPServer)] = Key;
                refreshSettings();
            }
        }

        break;

    case -66:   // '.'
        
        // server IP
        if(iCurrentMenu == MENU_MULTIPLAYER_CLIENT && iSelectedOption == 0)
        {
            if(strlen(sGlobal->sIPServer) < 14)
            {
                sGlobal->sIPServer[strlen(sGlobal->sIPServer) + 1] = '\0';
                sGlobal->sIPServer[strlen(sGlobal->sIPServer)] = '.';
                refreshSettings();
            }
        }
        
        break;
        
    case KEY_UP:

        iSelectedOption--;

        if(iSelectedOption < 0)
            iSelectedOption = iNumOptions - 1;

        break;
        
    case KEY_DOWN:

        iSelectedOption++;

        if(iSelectedOption == iNumOptions)
            iSelectedOption = 0;

        break;

    case KEY_LEFT:

        switch(iCurrentMenu)
        {
        // settings
        case MENU_SETTINGS:

            switch(iSelectedOption)
            {
            // goals to win
            case 0:
                if(sGlobal->iGameMaxGoals > 1)
                    sGlobal->iGameMaxGoals--;
                break;

            // maximum time
            case 1:
                if(sGlobal->iGameMaxMinutes > 1)
                    sGlobal->iGameMaxMinutes--;
                break;

            // table air
            case 2:
                sGlobal->bTableAir = !sGlobal->bTableAir;
                break;

            // automatic replay
            case 3:
                sGlobal->bAutomaticReplay = !sGlobal->bAutomaticReplay;
                break;

            // split screen
            case 4:
                sGlobal->bSplit = !sGlobal->bSplit;
                break;
            }

            break;

        // multiplayer
        case MENU_MULTIPLAYER:

            // play with kinect
            if(iSelectedOption == 2)
                sGlobal->bKinect = !sGlobal->bKinect;

            break;

        // AI difficulty settings
        case MENU_SETTINGS_DIFFICULTY:

            switch(iSelectedOption)
            {
            // speed for shooting
            case 0:
                if(iPercentShooting > 0)
                    iPercentShooting--;
                break;

            // speed for defending
            case 1:
                if(iPercentDefending > 0)
                    iPercentDefending--;
                break;

            // speed for clearing
            case 2:
                if(iPercentClearing > 0)
                    iPercentClearing--;
                break;

            // attack/defense balance
            case 3:
                if(iPercentAttack > 0)
                    iPercentAttack--;
                break;
            }

            calculateDifficultyValues();

            break;

        // kinect settings
        case MENU_SETTINGS_KINECT:

            switch(iSelectedOption)
            {
            // table width
            case 0:
                if(sGlobal->fKinectWidth > (KINECT_WIDTH_MIN / 2))
                    sGlobal->fKinectWidth -= 5.0f;
                break;

            // minimum distance
            case 1:
                if(sGlobal->fKinectMinimumDistance > KINECT_MINDIST_MIN)
                    sGlobal->fKinectMinimumDistance -= 10.0f;
                break;

            // maximum distance
            case 2:
                if(sGlobal->fKinectMaximumDistance > KINECT_MAXDIST_MIN)
                {
                    sGlobal->fKinectMaximumDistance -= 10.0f;

                    if(sGlobal->fKinectMaximumDistance < sGlobal->fKinectMinimumDistance)
                        sGlobal->fKinectMinimumDistance = sGlobal->fKinectMaximumDistance;
                }
                break;

            // player 1 hand
            case 3:
                sGlobal->bPlayer1RightHanded = !sGlobal->bPlayer1RightHanded;
                break;

            // player 2 hand
            case 4:
                sGlobal->bPlayer2RightHanded = !sGlobal->bPlayer2RightHanded;
                break;
            }

            break;
        }

        refreshSettings();

        break;

    case KEY_RIGHT:

        switch(iCurrentMenu)
        {
        // settings
        case MENU_SETTINGS:

            switch(iSelectedOption)
            {
            // goals to win
            case 0:
                if(sGlobal->iGameMaxGoals < GAME_MAX_GOALS)
                    sGlobal->iGameMaxGoals++;
                break;

            // maximum time
            case 1:
                if(sGlobal->iGameMaxMinutes < GAME_MAX_MINUTES)
                    sGlobal->iGameMaxMinutes++;
                break;

            // table air
            case 2:
                sGlobal->bTableAir = !sGlobal->bTableAir;
                break;

            // automatic replay
            case 3:
                sGlobal->bAutomaticReplay = !sGlobal->bAutomaticReplay;
                break;

            // split screen
            case 4:
                sGlobal->bSplit = !sGlobal->bSplit;
                break;
            }

            break;

        // multiplayer
        case MENU_MULTIPLAYER:

            // play with kinect
            if(iSelectedOption == 2)
                sGlobal->bKinect = !sGlobal->bKinect;

            break;

        // AI difficulty settings
        case MENU_SETTINGS_DIFFICULTY:

            switch(iSelectedOption)
            {
            // speed for shooting
            case 0:
                if(iPercentShooting < 100)
                    iPercentShooting++;
                break;

            // speed for defending
            case 1:
                if(iPercentDefending < 100)
                    iPercentDefending++;
                break;

            // speed for clearing
            case 2:
                if(iPercentClearing < 100)
                    iPercentClearing++;
                break;

            // attack/defense balance
            case 3:
                if(iPercentAttack < 100)
                    iPercentAttack++;
                break;
            }

            calculateDifficultyValues();

            break;

        // kinect settings
        case MENU_SETTINGS_KINECT:

            switch(iSelectedOption)
            {
            // table width
            case 0:
                if(sGlobal->fKinectWidth < (KINECT_WIDTH_MAX / 2))
                    sGlobal->fKinectWidth += 5.0f;
                break;

            // minimum distance
            case 1:
                if(sGlobal->fKinectMinimumDistance < KINECT_MINDIST_MAX)
                {
                    sGlobal->fKinectMinimumDistance += 10.0f;

                    if(sGlobal->fKinectMinimumDistance > sGlobal->fKinectMaximumDistance)
                        sGlobal->fKinectMaximumDistance = sGlobal->fKinectMinimumDistance;
                }
                break;

            // maximum distance
            case 2:
                if(sGlobal->fKinectMaximumDistance < KINECT_MAXDIST_MAX)
                    sGlobal->fKinectMaximumDistance += 10.0f;
                break;

            // player 1 hand
            case 3:
                sGlobal->bPlayer1RightHanded = !sGlobal->bPlayer1RightHanded;
                break;

            // player 2 hand
            case 4:
                sGlobal->bPlayer2RightHanded = !sGlobal->bPlayer2RightHanded;
                break;
            }

            break;
        }

        refreshSettings();

        break;
    }
}
Пример #18
0
void CSceneMenu::enterMenu(int iMenu)
{
    iCurrentMenu = iMenu;
    iSelectedOption = 0;

    switch(iMenu)
    {
    case MENU_MAIN:
        iNumOptions = 3;
        strcpy(sOption[0], "Play");
        strcpy(sOption[1], "Settings");
        strcpy(sOption[2], "Exit");
        break;

    case MENU_PLAY:
        iNumOptions = 2;
        strcpy(sOption[0], "Player vs CPU");
        strcpy(sOption[1], "Multiplayer");
#ifdef _KINECT_
        iNumOptions = 4;
        strcpy(sOption[2], "Kinect: Player vs CPU");
        strcpy(sOption[3], "Kinect: Player vs Player");
#endif
        break;

    case MENU_SETTINGS:
        iNumOptions = 6;
        refreshSettings();
        strcpy(sOption[5], "CPU difficulty...");
#ifdef _KINECT_
        iNumOptions = 7;
        strcpy(sOption[6], "Kinect settings...");
#endif
        break;

    case MENU_MULTIPLAYER:
        iNumOptions = 2;
        strcpy(sOption[0], "Create game");
        strcpy(sOption[1], "Join game");
#ifdef _KINECT_
        iNumOptions = 3;
        refreshSettings();
#endif
        break;

    case MENU_MULTIPLAYER_CLIENT:
        iNumOptions = 3;
        strcpy(sOption[2], "Join game");
        refreshSettings();
        break;

    case MENU_MULTIPLAYER_SERVER:
        iNumOptions = 2;
        strcpy(sOption[1], "Create game");
        refreshSettings();
        break;

    case MENU_SETTINGS_DIFFICULTY:
        iNumOptions = 4;
        refreshSettings();
        break;

    case MENU_SETTINGS_KINECT:
        iNumOptions = 3;
#ifndef _KINECT_OPENNI_
        iNumOptions = 5;
#endif
        refreshSettings();
        break;

    case MENU_KINECT_INFO:
        iNumOptions = 0;
        break;
    }
}
Пример #19
0
Minitel::Minitel() {
	Serial2.begin(4800);
	useDefaultColors();
	refreshSettings();

}
Пример #20
0
void Minitel::moveCursorTo(byte x, byte y) {
  serialprint7(31); // Code positionnement de curseur
  serialprint7(64+y); // coordonnées x (x+64) (x de 1 à 40)
  serialprint7(64+x); // coordonnées y (y+64) (y de 1 à 24)
  refreshSettings();
}
Пример #21
0
void Minitel::clearScreen() {
  serialprint7(CLEARSCREEN);
  refreshSettings();
}
Пример #22
0
void Minitel::mode(byte mode) {
  if (mode == GRAPHIC_MODE || mode == TEXT_MODE) {
    _currentMode = mode;
    refreshSettings();
  } 
}