コード例 #1
0
ファイル: browsepicture.cpp プロジェクト: qhw/deal_bmp
void BrowsePicture::AutoMergeButtonClicked()
{
  pic_path = ui.dir_edit->text();
  if(!ReadFile(pic_path))
  {
    return;
  }
  clearDir(pic_path);
  MyAutoMergeThread *automerge = new MyAutoMergeThread;
  automerge->setArg(arg);
  automerge->setPath(pic_path);
  connect(automerge,SIGNAL(done()),this,SLOT(doneSuccess()));
  connect(automerge,SIGNAL(fail()),this,SLOT(doneFail()));
  connect(automerge,SIGNAL(showpic(QString)),this,SLOT(ShowDonePicture(QString)));
  connect(automerge,SIGNAL(showDoingPic(QString)),this,SLOT(ShowThumbnail(QString)));

  Progress *dlg = new Progress;
  dlg->setFlag(1);
  dlg->setPathName(pic_path);
  dlg->setArg(arg);
  dlg->setProgressMax();
  dlg->setAutoMergeThread(automerge);
  dlg->show();
  connect(automerge,SIGNAL(done()),dlg,SLOT(closeDlg()));
  automergethread_list.append(automerge);
  automergeprogress_list.append(dlg);
  automerge->start();
}
コード例 #2
0
ファイル: browsepicture.cpp プロジェクト: qhw/deal_bmp
void BrowsePicture::ShowPicButtonClicked()
{
  pic_path = ui.dir_edit->text();
  if(!ReadFile(pic_path))
  {
    return;
  }
  clearDir(pic_path);
  ShowImage();
}
コード例 #3
0
void Segmentation::on_rgbFileAction_triggered() {
    QString curPath = QFileDialog::getExistingDirectory(this, tr("Select RGB Image Path"), "E:\\Image\\NJU-DS400\\image", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);

    if (rgbPath.isEmpty() && curPath.isEmpty()) {
        QMessageBox::warning(this, tr("Path"), tr("You did not select any path."));
    }
    else {
        if (!rgbPath.isEmpty()) {
            clearDir();
            depthPath.clear();
            rgbPath.clear();
            curDepthName.clear();
            curRGBName.clear();
        }
        setDir(curPath);
        rgbPath = curPath + "/";
        //cout << rgbPath.toStdString() << endl;
    }
}
コード例 #4
0
ファイル: SFile.cpp プロジェクト: song-kang/Qt_RMS601-2
////////////////////////////////////////////////////////////////////////
// 描    述:  清除指定目录下的全部内容,同时递归清除全部子目录,不清除指定的目录自身
// 作    者:  邵凯田
// 创建时间:  2011-11-18 11:40
// 参数说明:  @dir为指定的目录
// 返 回 值:  true清除成功,false表示清除失败
//////////////////////////////////////////////////////////////////////////
bool SDir::clearDir(SString sPath)//清除指定目录下的全部内容
{
	if(sPath.Right(1) != "\\" && sPath.Right(1) != "/")
	{
#ifdef WIN32
		sPath += "\\";
#else
		sPath += "/";
#endif
	}
	SDir dir(sPath,"*");
	bool err = false;
	int i,cnt = dir.count();
	for(i=0;i<cnt;i++)
	{
		SString sFile = dir[i];
		if(sFile == "." || sFile == "..")
			continue;
		SString attr = dir.attribute(i);
		if(SString::GetAttributeValueI(attr,"isdir") == 1)
		{
			if(!clearDir(sPath+sFile))
				err = true;
			if(!SDir::removeDir(sPath+sFile))
				err = true;
		}
		else
		{
			if(!SFile::remove(sPath+sFile))
				err = true;
		}
	}
	if(err)
		return false;
	return true;
}
コード例 #5
0
int main(void) {

    //setup USART recive
    UCSR0B = (1<<RXEN0);
    UCSR0C = (1<<UCSZ00) | (1<<UCSZ01);
    UBRR0 = 25; // 25 = 2400 baud; 6 = 9600 baud


    /* Set pins as output, high->output, low->input */
    DDRA = 0xFF;          /* Pin for LED out */
    DDRB = 0xFF;          /* Pin for LED out */

    DDRC = 0xFF;          /* Pin for LED out */
    DDRD = 0xFE;          /* Pin for LED out */

    unsigned char input;
    unsigned char value;
    unsigned char control;

    PORTA = 0xFF;
    PORTB = 0xFF;
    PORTC = 0xFF;
    PORTD = 0xFF;
    _delay_ms(1000);

    /*
    while (1){
    	clearStates();
    	lightDisplay();
    }*/
    /*
    int i = 0;
    unsigned int states[4] = {0x27, 0xA0, 0x56, 0xD4};  */
    /*
    while (1) {
    	unsigned char in = USART_Receive();

    	for (int i = 0; i < 8; i++) {
    		dir[i] = (in>>(7-i))&0x1;
    	}
    	displayDirection();
    }
    */

    while(1) {
        //clearStates();
        input = USART_Receive();

        //input = 0x27;
        /*  _delay_ms(2000);
          input = states[i];
          i++;
          i = i%4;*/

        control = input & CTRL_MSK;
        if (input & CMD_BIT) {
            ctrl[LONG_SIP]  = control == LONG_SIP                ? ON : OFF;
            ctrl[LONG_PUFF] = control == LONG_PUFF               ? ON : OFF;
            ctrl[SIP]       = control == SIP  || ctrl[LONG_SIP]  ? ON : OFF;
            ctrl[PUFF]      = control == PUFF || ctrl[LONG_PUFF] ? ON : OFF;
        } else {
            clearCtrl();
        }

        value = (input&VAL_MSK) >> 3;
        if (input & SPD_BIT) { //SPEED
            clearSpeed();
            if (input & NEG_BIT) { //REVERSE
                spd[0] = ON;
            }
            else { //FORWARD
                switch (value) {
                default:
                case 4:
                    spd[4+SPD_OFFSET] = ON;
                case 3:
                    spd[3+SPD_OFFSET] = ON;
                case 2:
                    spd[2+SPD_OFFSET] = ON;
                case 1:
                    spd[1+SPD_OFFSET] = ON;
                    break;
                case 0:
                    spd[0+SPD_OFFSET] = ON;
                    break;
                }
            }
            displaySpeed();
        }
        else { //DIRECTION
            clearDir();
            if (input & NEG_BIT) { //LEFT
                switch (value) {
                default:
                case 4:
                    dir[DIR_OFFSET+1-4] = ON;
                case 3:
                    dir[DIR_OFFSET+1-3] = ON;
                case 2:
                    dir[DIR_OFFSET+1-2] = ON;
                case 1:
                    dir[DIR_OFFSET+1-1] = ON;
                    break;
                case 0:
                    break;
                }
            }
            else { //RIGHT
                switch (value) {
                default:
                case 4:
                    dir[4+DIR_OFFSET] = ON;
                case 3:
                    dir[3+DIR_OFFSET] = ON;
                case 2:
                    dir[2+DIR_OFFSET] = ON;
                case 1:
                    dir[1+DIR_OFFSET] = ON;
                    break;
                case 0:
                    break;
                }
            }
            displayDirection();
        }
    }

    return 0;

}
コード例 #6
0
ファイル: Main.cpp プロジェクト: Entro-yuhim/nwchecker
void checkProgram(ParticipantTask &task, string participantName)
{
	addLog("Cheking task number "+to_str(task.taskNumber+1)+". Participant "
			+participantName);
	if (skipCheckedPrograms)
	{
		unsigned int newTime=getFileTime(task.path.c_str());
		if (saving.find(task.path)!=saving.end())

		{
			SaveInformation sinfo=saving[task.path];

			if (newTime==sinfo.checkFileTime)
			{
				addLog("Task "+task.path+" was skipped");
				task.result = sinfo.result;
				task.score = sinfo.score;
				task.checkFileTime=newTime;
				return;
			}
		}
		task.checkFileTime=newTime;
	}
	CompilerInfo compiler=compilers[task.compilerNumber];
	Task tsk=tasks[task.taskNumber];
	clearDir(runDir, "");
	CopyFile(task.path.c_str(),(runDir+compiler.inFile).c_str(),0);
	SetCurrentDirectory(runDir.c_str());
	runProgram(compiler.exeFile + " " + compiler.params, 1);
	string exename=runDir+compiler.outFile;
	if (!fileExists(exename))
	{
		task.result="Compile failed";
		addLog("Compile Failed...");
		task.score=0;
		return;
	}
	clearDir(runDir, compiler.outFile);
	task.score=0;
	for (unsigned int i=0; i<tsk.tests.size(); i++)
	{
		CopyFile(tsk.tests[i].testFile.c_str(),(runDir+tsk.inFile).c_str(),0);
		addLog(participantName+": task "+to_str(task.taskNumber+1)+" test "
				+to_str(i+1)+" ", 0);
		char res=runProgramTimer(exename, tsk.tests[i].maxTime, 1);
		if (res!='+')
		{
			task.result+=res;
			continue;
		}
		if (!fileExists(runDir+tsk.outFile))
		{
			task.result+="F";
			addLog("No output File...");
			continue;
		}
		CopyFile(tsk.tests[i].judgeFile.c_str(),(runDir+"judge.sol1").c_str(),0);
		if (!tsk.checkProgram.empty())
		{
			CopyFile(tsk.checkProgram.c_str(),(runDir+"check.exe").c_str(),0);
			res=validatingTask(tsk.inFile, tsk.outFile, "judge.sol1",
					"check.exe");
		}
		else
			res=validatingTask(tsk.inFile, tsk.outFile, "judge.sol1");
		task.result+=res;
		if (res=='+')
			task.score+=tsk.tests[i].maxScore, addLog("Right answer!!! ");
		else if (res=='P')
			task.score+=tsk.tests[i].maxScore*tsk.wrongFormat,
					addLog("Presentation error.");
		else
			addLog("Wrong answer...");
		clearDir(runDir, compiler.outFile);
	}
	addLog("Task "+task.path+" Result: "+task.result+" score "
			+to_str(task.score));
	addLog("***********************************************************************");
}