-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoolcopytrackmark.cpp
61 lines (50 loc) · 1.81 KB
/
toolcopytrackmark.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
#include "toolcopytrackmark.h"
#include "videolooptrackview.h"
ToolCopyTrackMark::ToolCopyTrackMark(VideoViewBase *parent)
: ToolImage(parent)
{
mBaseView = parent;
mSourcePt.first = NULL;
mSourcePt.second = NULL;
mDestPt.first = NULL;
mDestPt.second = NULL;
}
ToolCopyTrackMark::~ToolCopyTrackMark()
{
}
void ToolCopyTrackMark::mousePress( QMouseEvent *mouseEvent )
{
if (Qt::LeftButton == mouseEvent->button()) // left mouse button, add point and line
{ // add one point
// save point to list
QPointF pt = mView->mapToScene( QPoint(mouseEvent->x(), mouseEvent->y()) );
int cur_time = mView->mCurrentFrameIndex;
if ( mSourcePt.first==NULL ){ // this finding source point
mSourcePt = mBaseView->mMainWind->mPrjFileObj.nearestPoint(pt.x(), pt.y(), cur_time);
mSourcePt.first->setSelected();
// set ID and type to left tool button
//
mView->mMainWind->setBikeType( mSourcePt.first->bikeType() );
mView->mMainWind->mSbxCurrentID->setValue( mSourcePt.first->bikeID() );
} else { // finding the destination point
mDestPt = mBaseView->mMainWind->mPrjFileObj.nearestPoint(pt.x(), pt.y(), cur_time);
// copy bike id and type, from source point to destination point
//
mDestPt.first->bikeID( mSourcePt.first->bikeID() );
mDestPt.first->bikeType( mSourcePt.first->bikeType() );
mDestPt.first->setSelected();
// change label
// set source point's pointers to NULL, clear old ones
mSourcePt.first->clearSelected();
mSourcePt.first = NULL;
mSourcePt.second = NULL;
}
} else if ( Qt::RightButton == mouseEvent->button() ) // right button, clear copyed data to start new round
{
// set source point's pointers to NULL, clear old ones
if(mSourcePt.first!= NULL)
mSourcePt.first->clearSelected();
mSourcePt.first = NULL;
mSourcePt.second = NULL;
}
}