-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
1426 lines (1193 loc) · 41.1 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "mainwindow.h"
#include "globaldata.h"
MainWindow::MainWindow(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
setupUi(this);
mVideoExploreView = NULL;
mVideoLoopView = NULL;
mVideoTrackView = NULL;
mPreToolName = "";
mLabEqualBkThreshold = NULL;
mIconDetectorOpen = NULL;
mIconDetectorClose = NULL;
mToolBtDectorState = NULL;
mPlotWnd = NULL;
mSboxPlayStepSize = NULL;
mDockWndMat = NULL;
mDockWndBottom = NULL;
mToolBarLoop = NULL;
mToolBarVideoPlay = NULL;
mSbxCurrentID = NULL;
mStatusLeftWnd = NULL;
mStatusPositionWnd = NULL; // sub text showing position of mouse
mStatusToolNameWnd = NULL; // sub text showing position of mouse
//non-GUI
// set global data
//
globaldata::getInstance()->g_base_dir = QString("D:\\liye_360syn\\syn_develop\\tjems\\tjems2");
globaldata::getInstance()->g_mainwind = this;
mProgressDlg = new ProgressDlg( this );
mProgressDlg->hide();
createActions();
initGUI();
}
MainWindow::~MainWindow()
{
}
void MainWindow::createActions()
{
// file menu
//
connect( actionExit, SIGNAL(triggered()), this, SLOT(actExit()));
// view menu
//
// added after dock windows finished
// help menu
//
connect( actionWebsit, SIGNAL(triggered()), this, SLOT(actWebsit()));
connect( actionManual, SIGNAL(triggered()), this, SLOT( actManual()) );
connect( actionAbout, SIGNAL(triggered()), this, SLOT( actAbout()) );
// set up setting menu
//
mVideoModelActGroup = new QActionGroup( this );
mVideoModelActGroup->addAction( mActionExploringModel );
mVideoModelActGroup->addAction( mActionLoopDetector );
mVideoModelActGroup->addAction( mActionDetectionTrack );
connect( mVideoModelActGroup, SIGNAL(triggered(QAction*)), this, SLOT( actVideoModelChanged(QAction*)) );
// option menu
//
mActionSetting = new QAction("setting", this);
connect( mActionSetting, SIGNAL(triggered()), this, SLOT(actSetting()) );
}
void MainWindow::createToolbars()
{
// create top frame slider toolbar
createToolbarVideoSteps();
// create top frame scale view toolbar
createToolbarScale();
// controls for 3 views
createToolbarView3D();
createToolbarViewLoop();
createToolbarViewTrack();
}
void MainWindow::createDockWindows()
{
// right toolbar
createToolBoxRight();
//# view switch window
createWindSwitchTab();
//# bottom log window
createBottomWnd();
// create window showing matrix
createMatWnd();
// initialize main menu
//
// top
menuView->addAction( mToolBarVideoControl->toggleViewAction() );
menuView->addAction( mToolBarView->toggleViewAction() );
menuView->addAction( mPlotWnd->toggleViewAction() );
menuView->addSeparator();
// right
menuView->addAction( mToolBoxLoop->toggleViewAction() );
menuView->addAction( mToolBox3DRec->toggleViewAction() );
menuView->addAction( mToolBoxTrack->toggleViewAction() );
menuView->addAction( mDockWndMat->toggleViewAction() );
menuView->addSeparator();
// bottom
menuView->addAction( mDockWndBottom->toggleViewAction() );
}
void MainWindow::initGUI()
{
// set window title
this->setWindowTitle( globaldata::getInstance()->G_WINDOW_TITLE );
// create tool button group for all tool buttons
//
mBtGroupImgTool = new QButtonGroup();
mBtGroupImgTool->setExclusive( true );
connect(mBtGroupImgTool, SIGNAL(buttonPressed(QAbstractButton *)), this, SLOT(actToolChanged(QAbstractButton *)));
// add top toolbars
createToolbars();
createDockWindows();
// create 3 main views
createMainViews();
connectMenuToProcWnd();
// create image tools
createToolObject();
createStatusBar();
// set the initial GUI for video exploring model
actVideoModelChanged( mActionExploringModel );
}
void MainWindow::actToolChanged( QAbstractButton *button )
{
/*# scale tools
#
# pan tool
# */
if (mToolBtPanMap == button){
QString toolName = "PanMap";
setTool( toolName, mCurrentView );
}
// tools for 3d reconstruction
//
if (mBtDrawStudyArea == button){
QString toolName = "ToolStudyArea";
setTool( toolName, mCurrentView );
}
if (mBtSetControlLine == button){
QString toolName = "ToolCoordinateAxis";
setTool( toolName, mCurrentView );
}
if (mBtSetControlPoint == button){
QString toolName = "ToolControlPoint";
setTool( toolName, mCurrentView );
}
if (mBtSetEditControlPoint == button){
QString toolName = "ToolEditControlPoint";
setTool( toolName, mCurrentView );
}
//////////////////////////////////////////////////////
// tools for loop detector
//
if (mBtSetLoopArea == button){
QString toolName = "ToolLoopArea";
setTool( toolName, mCurrentView );
}
if (mBtSetLoopArea == button){
QString toolName = "ToolLoopArea";
setTool( toolName, mCurrentView );
}
if (mBtSetDeleteLoopDetector == button){
QString toolName = "ToolDeleteLoopDetector";
setTool( toolName, mCurrentView );
}
if (mBtSetBicycleHeadway == button){
QString toolName = "ToolBicycleHeadway";
setTool( toolName, mCurrentView );
}
/////////////////////////////////////////////////////////////////////
// tools for semi-tracking tools
//
if (mBtSemiTracking == button){
QString toolName = "ToolSemiTracking";
setTool( toolName, mCurrentView );
}
if (mBtMovePoint == button){
QString toolName = "ToolMoveTrackMark";
setTool( toolName, mCurrentView );
}
if (mBtDeletePoint == button){
QString toolName = "ToolDeleteTrackMark";
setTool( toolName, mCurrentView );
}
if (mBtEditTrackNode == button){
QString toolName = "ToolEditTrackMark";
setTool( toolName, mCurrentView );
}
if (mBtCopyTrackMark == button){
QString toolName = "ToolCopyTrackMark";
setTool( toolName, mCurrentView );
}
if (mBtTrackNewVehicle == button){
actNextID();
}
}
void MainWindow::createToolBoxRight()
{
// 1 create right toolbox for video explore
//
mToolBoxExplore = new QToolBar( "right video explore tool" );
mToolBoxExplore->setOrientation( Qt::Vertical );
mToolBoxExplore->addWidget ( mBtDrawStudyArea );
addToolBar(Qt::RightToolBarArea, mToolBoxExplore);
// 2 create right loop detector toolbox and add buttons
//
mToolBoxLoop = new QToolBar( "right loop detector tool" );
mToolBoxLoop->setOrientation( Qt::Vertical );
mToolBoxLoop->addWidget ( mBtSetLoopArea );
mToolBoxLoop->addWidget ( mBtSetDeleteLoopDetector );
mToolBoxLoop->addWidget ( mBtSetBicycleHeadway );
addToolBar(Qt::RightToolBarArea, mToolBoxLoop);
// 3 create right loop detector toolbox and add buttons
//
mToolBoxTrack = new QToolBar( "Bicycle track" );
mToolBoxTrack->setOrientation( Qt::Vertical );
mToolBoxTrack->addWidget ( mBtSemiTracking );
mToolBoxTrack->addWidget ( mBtDeletePoint );
mToolBoxTrack->addWidget ( mBtMovePoint );
mToolBoxTrack->addWidget ( mBtEditTrackNode );
////////////////////////////////////////////////////////////////////////
// track new vehicle button
//
QLabel* seperatorWnd = new QLabel();
mToolBoxTrack->addWidget ( seperatorWnd );
//
mToolBoxTrack->addWidget ( mBtCopyTrackMark );
mToolBoxTrack->addWidget ( mBtTrackNewVehicle );
// add line edit for current ID
//
mSbxCurrentID = new QSpinBox();
mToolBoxTrack->addWidget( mSbxCurrentID );
connect( mSbxCurrentID,SIGNAL(valueChanged(int)), this, SLOT(actVehicleIndexChanged(int)) );
// add combbox for bicycle type
//
mCmbBikeType = new QComboBox( );
mCmbBikeType->addItem( "Bicycle" );
mCmbBikeType->addItem( "E-bicycle" );
mToolBoxTrack->addWidget( mCmbBikeType );
addToolBar(Qt::RightToolBarArea, mToolBoxTrack);
// 4 create right 3D reconstruction toolbox and add buttons
//
mToolBox3DRec = new QToolBar( "3D reconstruction" );
mToolBox3DRec->addWidget ( mBtSetControlLine );
mToolBox3DRec->addWidget ( mBtSetControlPoint );
mToolBox3DRec->addWidget ( mBtSetEditControlPoint );
mToolBox3DRec->addWidget ( mBtCameraCalibration );
mToolBox3DRec->addWidget ( mBtCameraSpaceGrid );
addToolBar(Qt::RightToolBarArea, mToolBox3DRec);
}
void MainWindow::createWindSwitchTab()
{
//#add switch tab bar
//#
mSwithTool = new QToolBar( "window switch" );
mMainExchangeTab = new QTabBar();
mMainExchangeTab->setUsesScrollButtons( false );
mMainExchangeTab->setShape( QTabBar::TriangularWest );
mMainExchangeTab->addTab( "Video Processing" );
mMainExchangeTab->addTab( "3D reconstruciton" );
mMainExchangeTab->addTab( "Trajectory analysis" );
mSwithTool->addWidget( mMainExchangeTab );
addToolBar(Qt::LeftToolBarArea, mSwithTool);
connect( mMainExchangeTab, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)) );
}
void MainWindow::createBottomWnd()
{
// create dock area
//
mDockWndBottom = new QDockWidget("trajectory table");
mDockWndBottom->setAllowedAreas( Qt::LeftDockWidgetArea );
// create bottom window and add to doc area
//
mBottomWnd = new BottomWnd( this );
mDockWndBottom->setWidget( (QWidget*)mBottomWnd );
addDockWidget( Qt::BottomDockWidgetArea, mDockWndBottom);
}
void MainWindow::createMatWnd()
{
//////////////////////////////////////////////////////////////////////////
// create matrix plot window
//
// create dock area
//
mDockWndMat = new QDockWidget("Matrix window");
mDockWndMat->setAllowedAreas( Qt::RightDockWidgetArea );
// create matrix window for showing matrix
//
mMatWnd = new MatWnd( this );
mDockWndMat->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
mDockWndMat->setWidget( (QWidget*)mMatWnd );
addDockWidget( Qt::RightDockWidgetArea, mDockWndMat);
//////////////////////////////////////////////////////////////////////////
// create plot window
//
// create doc area
//
// create matrix window for showing matrix
//
mPlotWnd = new PlotWnd( this );
mPlotWnd->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
addDockWidget(Qt::TopDockWidgetArea, mPlotWnd);
}
void MainWindow::createToolbarVideoSteps()
{
// frame slider toolbar
//
mToolBarVideoControl = new QToolBar("top video processing toolbar");
//#############################################################################
//# create layout and added controls
//#
//# slider show progress
//#
QHBoxLayout *barLayout = new QHBoxLayout();
mFrameSlider = new QSlider( Qt::Horizontal );
mToolBarVideoControl->addWidget( mFrameSlider );
//# label show current frame number
//#
mLabFrameNum = new QLabel( "0/0" );
mLabFrameNum->setMinimumWidth( 80 );
mToolBarVideoControl->addWidget( mLabFrameNum );
//##############################################################################
//# start and pause buttons
//#
mToolGroupVideoPlay = new QButtonGroup(); //# buttons for playing video
mToolGroupVideoPlay->setExclusive( true );
//###################################################################
// set start frame editor
//
mToolBarVideoControl->addWidget( new QLabel("start frame:") );
mEdtStartFrame = new QLineEdit( "1" );
mToolBarVideoControl->addWidget( mEdtStartFrame );
// set start frame button
//
mBtSetStartFrame = new QPushButton( "set frame" );
connect(mBtSetStartFrame, SIGNAL(clicked()), this, SLOT(actSetStartFrame()));
mToolBarVideoControl->addWidget( mBtSetStartFrame );
// video sampling step length (key press)
//
mToolBarVideoControl->addWidget( new QLabel("sampling step(frame): ") );
mSboxStepSize = new QSpinBox();
mSboxStepSize->setRange( 1, 300);
connect(mSboxStepSize, SIGNAL(valueChanged(int)), this, SLOT(actStepsizeChanged(int))); //# step size changed action
mToolBarVideoControl->addWidget( mSboxStepSize );
// processing delay time
//
mToolBarVideoControl->addWidget( new QLabel("processing delay time(ms): ") );
mSboxProcessingDelay = new QSpinBox();
mSboxProcessingDelay->setRange( 1, 60*1000); // 1 minute
mSboxProcessingDelay->setSingleStep( 10 ); // 0.01 second
connect(mSboxProcessingDelay, SIGNAL(valueChanged(int)), this, SLOT(actProcessingDelayChanged(int))); //# step size changed action
mToolBarVideoControl->addWidget( mSboxProcessingDelay );
//////////////////////////////////////////////////////////////////////////
// video play step length (key press)
//
mToolBarVideoControl->addWidget( new QLabel(" play step(frame): ") );
mSboxPlayStepSize = new QSpinBox();
mSboxPlayStepSize->setRange( 1, 100);
connect(mSboxPlayStepSize, SIGNAL(valueChanged(int)), this, SLOT(actPlayStepSizeChanged(int))); //# step size changed action
mToolBarVideoControl->addWidget( mSboxPlayStepSize );
//########################################################
//# manual adjust step
//#
mLabManualStep = new QLabel( "single step size(frame): 5 " );
mToolBarVideoControl->addWidget( mLabManualStep );
addToolBar(Qt::TopToolBarArea, mToolBarVideoControl);
}
void MainWindow::createToolbarScale()
{
//# view scale tool buttons
//#
mToolBarView = new QToolBar("View scale toolbar");
mToolBarView->addWidget( new QLabel("View scale: ") );
//# add combox
//#
mCmbViewScale = new QComboBox();
QList<QString> strItmes;
strItmes.append( "None" );
strItmes.append( "25%" );
strItmes.append( "50%" );
strItmes.append( "75%" );
strItmes.append( "100%" );
strItmes.append( "150%" );
strItmes.append( "200%" );
strItmes.append( "250%" );
strItmes.append( "300%" );
strItmes.append( "400%" );
QStringList items( strItmes );
mCmbViewScale->addItems( items );
mCmbViewScale->setCurrentIndex( mCmbViewScale->findText("100%") );
mToolBarView->addWidget( mCmbViewScale );
//# combox signal link
//#
connect( mCmbViewScale, SIGNAL(currentIndexChanged(int)), this, SLOT(actViewScaleChanged(int)));
//# add pane map button
//#
QString g_base_dir = globaldata::getInstance()->g_base_dir;
QIcon *button_icon = new QIcon( g_base_dir + "/image/pan_map.PNG");
mToolBtPanMap = new QToolButton();
mToolBtPanMap->setIcon( *button_icon );
mToolBtPanMap->setCheckable( true );
mBtGroupImgTool->addButton(mToolBtPanMap);
mToolBarView->addWidget(mToolBtPanMap);
//#connect( action_scale_window, SIGNAL()
//# add scale window
//#
button_icon = new QIcon( g_base_dir + "/image/scale_window.PNG" );
mToolBtScaleMap = new QToolButton();
mToolBtScaleMap->setIcon( *button_icon );
mToolBtScaleMap->setCheckable( true );
mBtGroupImgTool->addButton( mToolBtScaleMap );
mToolBarView->addWidget(mToolBtScaleMap);
//#connect( action_scale_window, SIGNAL()
//# add scale full button
//#
button_icon = new QIcon( g_base_dir + "/image/zoom_full.PNG" );
mToolBtZoomFull = new QToolButton();
mToolBtZoomFull->setIcon( *button_icon );
mToolBtZoomFull->setCheckable( true );
mBtGroupImgTool->addButton( mToolBtZoomFull );
mToolBarView->addWidget(mToolBtZoomFull);
addToolBar( Qt::TopToolBarArea, mToolBarView );
}
void MainWindow::createToolbarView3D()
{
//////////////////////////////////////////////////////////////////////////
// buttons for video play
//
QButtonGroup *mToolGroupPlay = new QButtonGroup();
mToolGroupPlay->setExclusive( true );
QString g_base_dir = globaldata::getInstance()->g_base_dir;
QIcon *button_icon = new QIcon( g_base_dir + "/image/start.PNG");
mBtVideoStart = new QToolButton();
mBtVideoStart->setIcon( *button_icon );
mBtVideoStart->setCheckable( true );
mToolGroupPlay->addButton( mBtVideoStart );
// pause button
//
button_icon = new QIcon(g_base_dir + "/image/pause.PNG");
mBtVideoPause = new QToolButton();
mBtVideoPause->setIcon( *button_icon );
mBtVideoPause->setCheckable(true);
mToolGroupPlay->addButton( mBtVideoPause );
// end button
//
button_icon = new QIcon( g_base_dir + "/image/stop.PNG");
mBtVideoEnd = new QToolButton();
mBtVideoEnd->setIcon( *button_icon );
mBtVideoEnd->setCheckable(true);
mToolGroupPlay->addButton( mBtVideoEnd );
//////////////////////////////////////////////////////////////////////////
// video play
//
mToolBarVideoPlay = new QToolBar("video play toolbar");
mToolBarVideoPlay->addWidget( mBtVideoStart );
mToolBarVideoPlay->addWidget( mBtVideoPause );
mToolBarVideoPlay->addWidget( mBtVideoEnd );
addToolBar(Qt::TopToolBarArea, mToolBarVideoPlay);
}
void MainWindow::createToolbarViewLoop()
{
//////////////////////////////////////////////////////////////////////////
// buttons for loop detector start/pause/end/ bars / detector state
//
QButtonGroup *mToolGroupLoop = new QButtonGroup();
mToolGroupLoop->setExclusive( true );
QString g_base_dir = globaldata::getInstance()->g_base_dir;
QIcon *button_icon = new QIcon( g_base_dir + "/image/start.PNG");
mBtLoopStart = new QToolButton();
mBtLoopStart->setIcon( *button_icon );
mBtLoopStart->setCheckable( true );
mToolGroupLoop->addButton(mBtLoopStart);
// pause button
//
button_icon = new QIcon(g_base_dir + "/image/pause.PNG");
mBtLoopPause = new QToolButton();
mBtLoopPause->setIcon( *button_icon );
mBtLoopPause->setCheckable(true);
mToolGroupLoop->addButton( mBtLoopPause );
// end button
//
button_icon = new QIcon( g_base_dir + "/image/stop.PNG");
mBtLoopEnd = new QToolButton();
mBtLoopEnd->setIcon( *button_icon );
mBtLoopEnd->setCheckable(true);
mToolGroupLoop->addButton( mBtLoopEnd );
// detector state button on top toolbar
//
mIconDetectorOpen = new QIcon( g_base_dir + "/image/detector_open.PNG");
mIconDetectorClose = new QIcon( g_base_dir + "/image/detector_close.PNG");
mToolBtDectorState = new QToolButton();
mToolBtDectorState->setIcon( *mIconDetectorClose );
mToolBtDectorState->setCheckable(false);
//########################################################
//# loop detector video control toolbar
//#
mToolBarLoop = new QToolBar("loop parameter toolbar");
mToolBarLoop->addWidget( mBtLoopStart );
mToolBarLoop->addWidget( mBtLoopPause );
mToolBarLoop->addWidget( mBtLoopEnd );
mToolBarLoop->addWidget( mToolBtDectorState );
mCbxBikeStop = new QCheckBox("pause found bike", this);
mCbxBikeStop->setCheckState( Qt::Checked );
mToolBarLoop->addWidget( mCbxBikeStop );
// co-relation rate threshold, default 0.8
//
mLabEqualBkThreshold = new QLabel( "Co-relation threshold: 0.8" );
mToolBarLoop->addWidget( mLabEqualBkThreshold );
addToolBar(Qt::TopToolBarArea, mToolBarLoop);
}
void MainWindow::createToolbarViewTrack()
{
//////////////////////////////////////////////////////////////////////////
// buttons for video track
//
QButtonGroup *mGroupTrack = new QButtonGroup();
mGroupTrack->setExclusive( true );
QString g_base_dir = globaldata::getInstance()->g_base_dir;
QIcon *button_icon = new QIcon( g_base_dir + "/image/start.PNG");
mBtTrackStart = new QToolButton();
mBtTrackStart->setIcon( *button_icon );
mBtTrackStart->setCheckable( true );
mGroupTrack->addButton( mBtTrackStart );
// single step button
g_base_dir = globaldata::getInstance()->g_base_dir;
button_icon = new QIcon( g_base_dir + "/image/next_step.PNG");
mBtTrackSingleStep = new QToolButton();
mBtTrackSingleStep->setIcon( *button_icon );
mBtTrackSingleStep->setCheckable( true );
mGroupTrack->addButton( mBtTrackSingleStep );
// pause button
//
button_icon = new QIcon(g_base_dir + "/image/pause.PNG");
mBtTrackPause = new QToolButton();
mBtTrackPause->setIcon( *button_icon );
mBtTrackPause->setCheckable(true);
mGroupTrack->addButton( mBtTrackPause );
// end button
//
button_icon = new QIcon( g_base_dir + "/image/stop.PNG");
mBtTrackEnd = new QToolButton();
mBtTrackEnd->setIcon( *button_icon );
mBtTrackEnd->setCheckable(true);
mGroupTrack->addButton( mBtTrackEnd );
//////////////////////////////////////////////////////////////////////////
// create buttons needed for right toolbox
// buttons for loop detector
//
mBtDrawStudyArea = new QPushButton("&Set Study Area");
mBtDrawStudyArea->setCheckable( true );
mBtGroupImgTool->addButton( mBtDrawStudyArea );
mBtSetLoopArea = new QPushButton("&Drag loop detection area");
mBtSetLoopArea->setCheckable( true );
mBtGroupImgTool->addButton( mBtSetLoopArea );
mBtSetDeleteLoopDetector = new QPushButton("&Delete loop detector");
mBtSetDeleteLoopDetector->setCheckable( true );
mBtGroupImgTool->addButton( mBtSetDeleteLoopDetector );
mBtSetBicycleHeadway = new QPushButton("&Bicycle Headway");
mBtSetBicycleHeadway->setCheckable( true );
mBtGroupImgTool->addButton( mBtSetBicycleHeadway );
// buttons for bicycle tracking
//
mBtSemiTracking = new QPushButton("Semi-automatic track");
mBtGroupImgTool->addButton( mBtSemiTracking );
mBtDeletePoint = new QPushButton("delete point");
mBtGroupImgTool->addButton( mBtDeletePoint );
mBtMovePoint = new QPushButton("move point");
mBtGroupImgTool->addButton( mBtMovePoint );
mBtEditTrackNode = new QPushButton("edit track point");
mBtGroupImgTool->addButton( mBtEditTrackNode );
mBtTrackNewVehicle = new QPushButton("&track new vehicle");
mBtGroupImgTool->addButton( mBtTrackNewVehicle );
mBtCopyTrackMark = new QPushButton("© track vehicle");
mBtGroupImgTool->addButton( mBtCopyTrackMark );
// buttons for 3D reconstruction
//
mBtSetControlLine = new QPushButton("&set control line");
mBtGroupImgTool->addButton( mBtSetControlLine );
//connect( mBtSetControlLine, SIGNAL( "clicked()" ), this, SLOT(actSetControlLine()) );
mBtSetControlPoint = new QPushButton("&set control point");
mBtGroupImgTool->addButton( mBtSetControlPoint );
//connect( mBtSetControlPoint, SIGNAL( "clicked()" ), this, SLOT(actSetControlPoint()) );
mBtSetEditControlPoint = new QPushButton("&Edit control point");
mBtGroupImgTool->addButton( mBtSetEditControlPoint );
mBtCameraCalibration = new QPushButton("&camera calibration");
mBtGroupImgTool->addButton( mBtCameraCalibration );
connect( mBtCameraCalibration, SIGNAL( "clicked()" ), this, SLOT(actCalibrateCamera()) );
mBtCameraSpaceGrid = new QPushButton("&space grid");
mBtGroupImgTool->addButton( mBtCameraCalibration );
connect( mBtCameraSpaceGrid, SIGNAL( "clicked()" ), this, SLOT(actDrawSpaceGrid()) );
//////////////////////////////////////////////////////////////////////////
// video track toolbar
//
mToolBarTrack = new QToolBar("video track control toolbar");
mToolBarTrack->addWidget( mBtTrackStart );
mToolBarTrack->addWidget( mBtTrackSingleStep );
mToolBarTrack->addWidget( mBtTrackPause );
mToolBarTrack->addWidget( mBtTrackEnd );
addToolBar(Qt::TopToolBarArea, mToolBarTrack);
}
void MainWindow::actNextID()
{
ToolSemiTracking* semiTrackTool = (ToolSemiTracking*)( mToolMap["ToolSemiTracking"] );
semiTrackTool->actNextID();
}
void MainWindow::createToolObject()
{
///create tool object and save in maps
mToolMap.clear();
// scale tools
//
mToolMap["PanMap"] = new ToolPan( mVideoExploreView );
// 3D reconstruction tools
//
mToolMap["ToolCoordinateAxis"] = new ToolCoordinateAxis( mVideoExploreView );
mToolMap["ToolControlPoint"] = new ToolControlPoint( mVideoExploreView );
// video tools
//
mToolMap["ToolStudyArea"] = new ToolStudyArea( mVideoExploreView );
mToolMap["ToolLoopArea"] = new ToolLoopArea( mVideoLoopView );
mToolMap["ToolDeleteLoopDetector"] = new ToolDeleteLoopDetector( mVideoLoopView );
mToolMap["ToolBicycleHeadway"] = new ToolBicycleHeadway( mVideoLoopView );
// semi-track tools
//
mToolMap["ToolSemiTracking"] = new ToolSemiTracking( mVideoTrackView );
mToolMap["ToolMoveTrackMark"] = new ToolMoveTrackMark( mVideoTrackView );
mToolMap["ToolDeleteTrackMark"] = new ToolDeleteTrackMark( mVideoTrackView );
mToolMap["ToolEditTrackMark"] = new ToolEditTrackMark( mVideoTrackView );
mToolMap["ToolCopyTrackMark"] = new ToolCopyTrackMark( mVideoTrackView );
}
void MainWindow::setTool( const QString &tool_name, VideoViewBase *video_view )
{
//''' uninstall old tool, install new tool
//'''
//# uninstall old tool
//#
if ( mToolMap.contains( mPreToolName ) ){
mToolMap[ mPreToolName ]->uninstall( video_view );
QString msg = mPreToolName + " uninstalled";
log( msg );
}
//
//# install new tool
//#
if (mToolMap.contains( tool_name )){
mToolMap[ tool_name ]->install( video_view );
// change state and marker
//
if ( tool_name=="ToolBicycleHeadway" ) {
setDetectorState( true ); // show detector state on top bar
} else {
setDetectorState( false ); // show detector state on top bar
}
QString msg = tool_name + " installed";
log( msg );
mPreToolName = tool_name;
// show tool name in status bar
mStatusToolNameWnd->setText( QString("Tool: ")+tool_name );
}
}
void MainWindow::actRecognizeVehicle()
{
setCursor( Qt::CrossCursor );
}
void MainWindow::tabChanged( int index )
{
QMessageBox::information(NULL, "tabChanged", "" );
}
void MainWindow::connectMenuToProcWnd()
{
connect( mActionNewProject, SIGNAL(triggered()), this, SLOT(actNewProject()) );
connect( mActionOpenProject, SIGNAL(triggered()), this, SLOT(openProject()) );
connect( actionOpen_Video_Files, SIGNAL(triggered()), this, SLOT(actOpenNewFile()) );
connect( actionOpen_Current_Video, SIGNAL(triggered()), mVideoExploreView, SLOT(openVideo()) );
connect( actionNext_Frame, SIGNAL(triggered()), this, SLOT(actNextFrame()) );
connect( actionFinish_processing, SIGNAL(triggered()), this, SLOT(actEndProcessing()) );
connect( actionSetting, SIGNAL(triggered()), mVideoExploreView, SLOT(actSetting()) );
}
void MainWindow::actNextFrame()
{
if ( mCurrentView != NULL )
mCurrentView->actNextFrame();
}
void MainWindow::actWebsit()
{
QDesktopServices::openUrl( QUrl("http://opentrans.cn", QUrl::TolerantMode) );
}
void MainWindow::actManual()
{
QString docPath = "file:///" + globaldata::getInstance()->g_base_dir + "\\doc\\manual.pdf";
QDesktopServices::openUrl(QUrl( docPath ));
}
void MainWindow::actAbout()
{
QString message("");
message += "<p>This is an Trajectory extraction and management platform for traffic flow study</p>";
message += "<p>The first version is developed by Liye in University of Singapore (2013-2014)</p>";
message += "<p><a href= \"mailto:[email protected]\">Author email: [email protected]</a></p>";
QMessageBox::information( this, "About TJEMS", message);
}
//''' insert string message in first row of log window at bottom
// msg - string
// '''
void MainWindow::log( const QString &msg )
{
QString msg_show = QString("%1: %2").arg( mBottomWnd->mLstWidLog->count()+1 ).arg(msg);
mBottomWnd->mLstWidLog->insertItem( 0, msg_show );
QApplication::instance()->processEvents(); // make GUI active
}
void MainWindow::actSetting()
{
}
void MainWindow::actViewScaleChanged( int index )
{
QString scale_text = mCmbViewScale->itemText( index );
float rate = 1;
if (scale_text == "25%")
rate = 0.25;
else if (scale_text == "50%")
rate = 0.5;
else if (scale_text == "75%")
rate = 0.75;
else if (scale_text == "100%")
rate = 1.;
else if (scale_text == "150%")
rate = 1.5;
else if (scale_text == "200%")
rate = 2.;
else if (scale_text == "250%")
rate = 2.5;
else if (scale_text == "300%")
rate = 3.;
else if (scale_text == "400%")
rate = 4.;
QMatrix transM = QMatrix(rate, 0, 0, rate, 0, 0); //#qreal m11, qreal m12, qreal m21, qreal m22, qreal dx, qreal dy
mCurrentView->setMatrix( transM, false );
}
void MainWindow::actSetStartFrame()
{
//action, set starting frame of video
mCurrentView->pauseProcessing(); //# stop the auto play
int startFrame;
try{
startFrame = mEdtStartFrame->text().toInt();
} catch(...) {
startFrame = 1;
}
mVideoExploreView->readFrame( startFrame, true );
mVideoExploreView->showFrame( mVideoExploreView->mCurrentFrame );
}
void MainWindow::actStepsizeChanged( int step)
{
try{
if (mVideoExploreView!=NULL)
mCurrentView->mProStep = step;
} catch(...) {
;
}
}
void MainWindow::actProcessingDelayChanged( int step )
{
mVideoExploreView->mTimer->setInterval( step );
}
//
//
void MainWindow::actOpenNewFile()
{
//'''open new video file '''
QString videoFilePath = QFileDialog::getOpenFileName( this, "select UAV video file ", "", "UAV vidoe file ( *.avi )" );
try{
if(videoFilePath.isEmpty()) {
QMessageBox::information( this, "path error", "please select a valid UAV flight project file" );
return;
}
} catch(...) {
QMessageBox::information( this, "path error", "path contains not common characteristics" );
}
if ( QFile::exists(videoFilePath) )
{
mVideoExploreView->openNewFile( videoFilePath );
mCurrentVideoFile = videoFilePath;
mPrjFileObj.mVideoPath = mCurrentVideoFile;
}
}
void MainWindow::setDetectorState( bool isOpen )
{
if (isOpen) {
mToolBtDectorState->setIcon( *mIconDetectorOpen );
static_cast<VideoLoopTrackView*>(mCurrentView)->mDetectionModel = true;
} else {
mToolBtDectorState->setIcon( *mIconDetectorClose );
static_cast<VideoLoopTrackView*>(mCurrentView)->mDetectionModel = false;
}
}
void MainWindow::actPlayStepSizeChanged( int step )
{
mVideoExploreView->mPlayStep = step;
}
void MainWindow::closeEvent(QCloseEvent *event)
{
// Save project file
mPrjFileObj.saveProjectFile();
switch( QMessageBox::information( NULL, QString("close program"),
QString("Do you really want to close this program?"), QMessageBox::Yes|QMessageBox::No, QMessageBox::No ) )
{
case QMessageBox::Yes:
event->accept();
QMainWindow::closeEvent(event);
break;
case QMessageBox::No:
default:
event->ignore();
break;
}
}
void MainWindow::actExit()
{
this->close();
}
void MainWindow::actVideoModelChanged( QAction *action )
{
// verify if study exists
//
bool study_arae_ok = false;
if ( mToolMap.contains("ToolStudyArea") )
{
int pt_number = mInterestingArea.size();
study_arae_ok = static_cast<ToolStudyArea*>(mToolMap["ToolStudyArea"])->valid();
if ( pt_number>0 || study_arae_ok )
{
study_arae_ok = true;