MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWindow) { ui->setupUi(this); setWindowTitle("基于OpenCV单目标运动物体检测与识别系统设计"); setWindowIcon(QIcon("F:/qt_test/videoDisplay/videoDisplay/cat.jpg")); //capture = new CvCapture(); //capture = cvCaptureFromFile(fileName); //divog = new DIVoG(); //DIVoG divog; //this->cap.open(0); findFlag = 0; //初始化识别标志位 sendFlag = 0; receiveFlag = 0; learnRate = 0; if (capture) { time1.setInterval(1); algorithmFlag = 0; } else { qDebug()<<"not open!"; } //connect(&time1, &QTimer::timeout, this, &MainWindow::updateImage); //connect(this,SIGNAL(startUpdate()),this,SLOT(updateImage())); connect(&time1, &QTimer::timeout, this, &MainWindow::updateFPS); //connect(&time1, &QTimer::timeout, &newTransport,SLOT(revData())); connect(ui->actionOpen,SIGNAL(triggered()),this,SLOT(openFile())); connect(this,SIGNAL(detectSuccess()),this,SLOT(showAns())); connect(this,SIGNAL(detectFailed()),this,SLOT(showAns())); connect(this,SIGNAL(startSend(Mat &)),&newTransport,SLOT(sendData(Mat &))); //connect(this,SIGNAL(startRecv(Mat &)),&newTransport,SLOT(revData(Mat &))); //connect(newTransport.tcpSocket,SIGNAL(readyRead()),this,SLOT(revData())); //connect(&time1,SIGNAL(timeout()),this,SLOT(revData())); datasize = 0; }
void MainWindow::refreshText() { if(qstep==0 || qstep==3){ showQes(); }else if(qstep==1){ showAns(0); //####引数0は仮 }else if(qstep==2){ showGood(0); //####引数0は仮 edtAns[0]->setText(RecordVisitor(m_allList.getTotalAt(qindex), m_turned).getA()); }else if(qstep==4){ showCongratulation(); }else if(qstep==-1){ ; } }
LRESULT MainWindow::onCommand(UINT msg,WPARAM wParam,LPARAM lParam) { int cmd_id=LOWORD(wParam); int cmd_notify=HIWORD(wParam); if(cmd_notify==0 || cmd_notify==1)switch(cmd_id){ case IDM_FILE_OPEN: if(static_cast<Paracka*>(g_app)->fs->showOpen(L"開く",this->getHWND())){ std::vector<std::wstring> paths; paths.push_back(static_cast<Paracka*>(g_app)->fs->GetPath().GetFullPath()); fileLoad(paths); } break; case IDM_FILE_RELOAD: fileReload(false); break; case IDM_FILE_RELOAD_RESTART: fileReload(true); break; case IDM_FILE_QUIT: close(); break; case IDM_FUNC_MARKING: const_cast<Record&>(m_allList.getTotalAt(qindex)).toggleMarking(); m_allList.saveFile(); refreshText(); break; case IDM_FUNC_FILTER_MARKING: // フィルタリング切り替え m_allList.toggleFilter(); // 乱数テーブル構築しなおし rndtable.generateTable(m_allList); // 問題の表示 if(rndtable.getCurrentSize()>0){ qindex=rndtable.getNext(); showQes(); }else{ showNone(); } updateCaption(); break; case IDM_FUNC_START: //乱数リストの作成 rndtable.generateTable(m_allList); // if(rndtable.getCurrentSize()>0){ qindex=rndtable.getNext(); showQes(); }else{ showNone(); } updateCaption(); break; case IDM_FUNC_ENTER: if(isGood()){ //次の問題へ rndtable.clear(qindex); updateCaption(); if(rndtable.getCurrentSize()>0){ sendMenuClick(IDM_FUNC_PASS); }else{ sndClear->play(); showCongratulation(); } }else{ for(int i=0;i<n_edtAns;i++){ if(GetFocus()==edtAns[i]->getHWND()){ //sendMenuClick(IDM_FUNC_ENTER); if(rndtable.getCurrentSize()>0){ //解答チェック wchar_t *p=edtAns[i]->getTextTemp(); bool result = RecordVisitor(m_allList.getTotalAt(qindex), m_turned).checkAnswer(p); if(result){ sndOk->play(); showGood(i); if(!mark_is_all_good()){ edtAns[(i+1+n_edtAns)%n_edtAns]->setFocus(); } break; }else{ sndNg->play(); showBad(); } } return 0L; } } } break; case IDM_FUNC_PASS: if(rndtable.getCurrentSize()>0){ qindex=rndtable.getNext(); showQes(); } break; case IDM_FUNC_VIEW: if(rndtable.getCurrentSize()>0){ int f=0; //フォーカスのあるエディットボックスについて適用 for(int i=0;i<n_edtAns;i++){ if(GetFocus()==edtAns[i]->getHWND()){ if(!visibleAns(i)){ showAns(i); }else{ hideAns(i); } f=1; break; } } //フォーカスがどれでもない場合は、すべてに適用 if(f==0){ for(int i=0;i<n_edtAns;i++){ if(!visibleAns(i)){ showAns(i); }else{ hideAns(i); } } } } break; case IDM_FUNC_TURN: if(rndtable.getCurrentSize()>0){ turnQesAns(); } break; case IDM_VOLUME_LOW: WaveSound::globalVolume(0.2f); break; case IDM_VOLUME_MIDDLE: WaveSound::globalVolume(0.6f); break; case IDM_VOLUME_HIGH: WaveSound::globalVolume(1.0f); break; case IDM_HELP_TOPIC: g_app->shellOpen(L"Paracka.txt",this); break; case IDM_HELP_VER: g_app->showVersion(this); break; } return 0L; }