Mercurial > hg > orthanc-stone
annotate Samples/Common/MeasureCommands.cpp @ 654:462a5074f914
Turned the scene into an observable to be able to dynamically react to
scene to canvas transform changes --> now the handles and angle measure
adornments are immune to zoom changes
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 14 May 2019 13:51:00 +0200 |
parents | 1e9ed656318e |
children |
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( |
654
462a5074f914
Turned the scene into an observable to be able to dynamically react to
Benjamin Golinvaux <bgo@osimis.io>
parents:
645
diff
changeset
|
51 MessageBroker& broker, |
462a5074f914
Turned the scene into an observable to be able to dynamically react to
Benjamin Golinvaux <bgo@osimis.io>
parents:
645
diff
changeset
|
52 Scene2D& scene, |
462a5074f914
Turned the scene into an observable to be able to dynamically react to
Benjamin Golinvaux <bgo@osimis.io>
parents:
645
diff
changeset
|
53 MeasureToolList& measureTools, |
462a5074f914
Turned the scene into an observable to be able to dynamically react to
Benjamin Golinvaux <bgo@osimis.io>
parents:
645
diff
changeset
|
54 ScenePoint2D point) |
632
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
55 : CreateMeasureCommand(scene, measureTools) |
654
462a5074f914
Turned the scene into an observable to be able to dynamically react to
Benjamin Golinvaux <bgo@osimis.io>
parents:
645
diff
changeset
|
56 , measureTool_(new LineMeasureTool(broker,scene)) |
632
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 measureTools_.push_back(measureTool_); |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
59 measureTool_->Set(point, point); |
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 |
645
1e9ed656318e
Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents:
644
diff
changeset
|
62 void CreateLineMeasureCommand::SetEnd(ScenePoint2D scenePos) |
632
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
63 { |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
64 measureTool_->SetEnd(scenePos); |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
65 } |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
66 |
645
1e9ed656318e
Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents:
644
diff
changeset
|
67 CreateAngleMeasureCommand::CreateAngleMeasureCommand( |
654
462a5074f914
Turned the scene into an observable to be able to dynamically react to
Benjamin Golinvaux <bgo@osimis.io>
parents:
645
diff
changeset
|
68 MessageBroker& broker, |
462a5074f914
Turned the scene into an observable to be able to dynamically react to
Benjamin Golinvaux <bgo@osimis.io>
parents:
645
diff
changeset
|
69 Scene2D& scene, |
462a5074f914
Turned the scene into an observable to be able to dynamically react to
Benjamin Golinvaux <bgo@osimis.io>
parents:
645
diff
changeset
|
70 MeasureToolList& measureTools, |
462a5074f914
Turned the scene into an observable to be able to dynamically react to
Benjamin Golinvaux <bgo@osimis.io>
parents:
645
diff
changeset
|
71 ScenePoint2D point) |
645
1e9ed656318e
Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents:
644
diff
changeset
|
72 : CreateMeasureCommand(scene, measureTools) |
654
462a5074f914
Turned the scene into an observable to be able to dynamically react to
Benjamin Golinvaux <bgo@osimis.io>
parents:
645
diff
changeset
|
73 , measureTool_(new AngleMeasureTool(broker,scene)) |
645
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 measureTools_.push_back(measureTool_); |
1e9ed656318e
Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents:
644
diff
changeset
|
76 measureTool_->SetSide1End(point); |
1e9ed656318e
Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents:
644
diff
changeset
|
77 measureTool_->SetCenter(point); |
1e9ed656318e
Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents:
644
diff
changeset
|
78 measureTool_->SetSide2End(point); |
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 center*/ |
1e9ed656318e
Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents:
644
diff
changeset
|
82 void CreateAngleMeasureCommand::SetCenter(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_->SetCenter(scenePos); |
1e9ed656318e
Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents:
644
diff
changeset
|
85 } |
1e9ed656318e
Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents:
644
diff
changeset
|
86 |
1e9ed656318e
Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents:
644
diff
changeset
|
87 /** This method sets end of side 2*/ |
1e9ed656318e
Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents:
644
diff
changeset
|
88 void CreateAngleMeasureCommand::SetSide2End(ScenePoint2D scenePos) |
1e9ed656318e
Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents:
644
diff
changeset
|
89 { |
1e9ed656318e
Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents:
644
diff
changeset
|
90 measureTool_->SetSide2End(scenePos); |
1e9ed656318e
Merge + ongoing measure work
Benjamin Golinvaux <bgo@osimis.io>
parents:
644
diff
changeset
|
91 } |
644 | 92 |
632
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
93 } |