annotate Samples/Common/MeasureCommands.cpp @ 651:62f6ff016085

Iteration in angle measuring tool. Text label is not ok and handles and arcs (and maybe angle sides) should not scale with zoom.
author Benjamin Golinvaux <bgo@osimis.io>
date Tue, 14 May 2019 09:48:14 +0200
parents 1e9ed656318e
children 462a5074f914
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
632
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
1 /**
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
2 * Stone of Orthanc
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
6 *
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
10 * the License, or (at your option) any later version.
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
11 *
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
15 * Affero General Public License for more details.
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
16 *
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
19 **/
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
20
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
21 #include "MeasureCommands.h"
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
22
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
23 namespace OrthancStone
634
6a144a45b2d8 Converted C++11 code to C++03
Benjamin Golinvaux <bgo@osimis.io>
parents: 632
diff changeset
24 {
632
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
25 void CreateMeasureCommand::Undo()
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
26 {
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
27 // simply disable the measure tool upon undo
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
28 GetMeasureTool()->Disable();
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
29 }
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
30
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
31 void CreateMeasureCommand::Redo()
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
32 {
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
33 GetMeasureTool()->Enable();
634
6a144a45b2d8 Converted C++11 code to C++03
Benjamin Golinvaux <bgo@osimis.io>
parents: 632
diff changeset
34 }
632
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
35
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
36 CreateMeasureCommand::CreateMeasureCommand(
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
37 Scene2D& scene, MeasureToolList& measureTools)
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
38 : TrackerCommand(scene)
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
39 , measureTools_(measureTools)
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
40 {
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
41
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
42 }
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
43
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
44 CreateMeasureCommand::~CreateMeasureCommand()
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
45 {
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
46 // deleting the command should not change the model state
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
47 // we thus leave it as is
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
48 }
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
49
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
50 CreateLineMeasureCommand::CreateLineMeasureCommand(
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
51 Scene2D& scene, MeasureToolList& measureTools, ScenePoint2D point)
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
52 : CreateMeasureCommand(scene, measureTools)
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
53 , measureTool_(new LineMeasureTool(scene))
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54 {
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55 measureTools_.push_back(measureTool_);
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56 measureTool_->Set(point, point);
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57 }
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58
645
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
59 void CreateLineMeasureCommand::SetEnd(ScenePoint2D scenePos)
632
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60 {
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
61 measureTool_->SetEnd(scenePos);
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
62 }
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63
645
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
64 CreateAngleMeasureCommand::CreateAngleMeasureCommand(
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
65 Scene2D& scene, MeasureToolList& measureTools, ScenePoint2D point)
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
66 : CreateMeasureCommand(scene, measureTools)
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
67 , measureTool_(new AngleMeasureTool(scene))
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
68 {
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
69 measureTools_.push_back(measureTool_);
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
70 measureTool_->SetSide1End(point);
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
71 measureTool_->SetCenter(point);
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
72 measureTool_->SetSide2End(point);
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
73 }
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
74
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
75 /** This method sets center*/
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
76 void CreateAngleMeasureCommand::SetCenter(ScenePoint2D scenePos)
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
77 {
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
78 measureTool_->SetCenter(scenePos);
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
79 }
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
80
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
81 /** This method sets end of side 2*/
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
82 void CreateAngleMeasureCommand::SetSide2End(ScenePoint2D scenePos)
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
83 {
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
84 measureTool_->SetSide2End(scenePos);
1e9ed656318e Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents: 644
diff changeset
85 }
644
f939f449482c Ongoing tracker work.
Benjamin Golinvaux <bgo@osimis.io>
parents: 634
diff changeset
86
632
500c3f70b6c2 - Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
87 }