-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtooldeleteloopdetector.cpp
41 lines (30 loc) · 1.09 KB
/
tooldeleteloopdetector.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
#include "tooldeleteloopdetector.h"
#include "videolooptrackview.h"
ToolDeleteLoopDetector::ToolDeleteLoopDetector(VideoViewBase *parent)
: ToolImage(parent)
{
}
ToolDeleteLoopDetector::~ToolDeleteLoopDetector()
{
}
void ToolDeleteLoopDetector::mousePress( QMouseEvent *mouseEvent )
{
VideoLoopTrackView *view = static_cast<VideoLoopTrackView*>( mView );
//# get point in scene coordinate system
//#
QPoint ptMouse = QPoint( mouseEvent->x(), mouseEvent->y() );
QPointF pt = view->mapToScene( ptMouse ); //# convert from view to scene coordinate
//# iterate all detector to check if point is contained
//#
for (int i=0; i<view->mLoopDetectors.count(); ++i)
{
LoopDetector *detector = view->mLoopDetectors.at(i);
if ( detector->mPolygon->contains( pt ) ){
QMessageBox::StandardButton reply = QMessageBox::question(NULL, "delete detector", "want to delete this detector?", QMessageBox::Yes|QMessageBox::No );
if (reply == QMessageBox::Yes){
detector->removeShape(); //# delete shape from scene
view->mLoopDetectors.removeOne( detector ); //# delete object
}
}
}
}