Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Scene2DViewport/LineMeasureTool.cpp @ 1582:cdd1932c530c
fix cppcheck
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 16 Oct 2020 17:34:53 +0200 |
parents | 85e117739eca |
children | 8563ea5d8ae4 |
rev | line source |
---|---|
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1 /** |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
2 * Stone of Orthanc |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1048
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
6 * |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
11 * |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
16 * |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
19 **/ |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
20 |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
21 #include "LineMeasureTool.h" |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
22 #include "MeasureToolsToolbox.h" |
866
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
23 #include "EditLineMeasureTracker.h" |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
24 #include "LayerHolder.h" |
1048
f6be9412e42a
cleaning up IObservable.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1020
diff
changeset
|
25 #include "../StoneException.h" |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
26 |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1331
diff
changeset
|
27 #include <Logging.h> |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
28 |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
29 #include <boost/make_shared.hpp> |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
30 |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
31 namespace OrthancStone |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
32 { |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
33 LineMeasureTool::LineMeasureTool( |
1571 | 34 boost::shared_ptr<IViewport> viewport): |
35 MeasureTool(viewport), | |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
36 #if ORTHANC_STONE_ENABLE_OUTLINED_TEXT == 1 |
1571 | 37 layerHolder_(boost::shared_ptr<LayerHolder>(new LayerHolder(viewport,1,5))), |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
38 #else |
1571 | 39 layerHolder_(boost::shared_ptr<LayerHolder>(new LayerHolder(viewport,1,1))), |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
40 #endif |
1571 | 41 baseLayerIndex_(0), |
42 lineHighlightArea_(LineHighlightArea_None) | |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
43 { |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
44 |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
45 } |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
46 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1314
diff
changeset
|
47 boost::shared_ptr<LineMeasureTool> LineMeasureTool::Create(boost::shared_ptr<IViewport> viewport) |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1311
diff
changeset
|
48 { |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1311
diff
changeset
|
49 boost::shared_ptr<LineMeasureTool> obj(new LineMeasureTool(viewport)); |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1311
diff
changeset
|
50 obj->MeasureTool::PostConstructor(); |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1311
diff
changeset
|
51 obj->RefreshScene(); |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1311
diff
changeset
|
52 return obj; |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1311
diff
changeset
|
53 } |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1311
diff
changeset
|
54 |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
55 LineMeasureTool::~LineMeasureTool() |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
56 { |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
57 // this measuring tool is a RABI for the corresponding visual layers |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
58 // stored in the 2D scene |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
59 Disable(); |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
60 RemoveFromScene(); |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
61 } |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
62 |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
63 void LineMeasureTool::RemoveFromScene() |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
64 { |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
65 if (layerHolder_->AreLayersCreated() && IsSceneAlive()) |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
66 { |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
67 layerHolder_->DeleteLayers(); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
68 } |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
69 } |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
70 |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
71 void LineMeasureTool::SetStart(ScenePoint2D start) |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
72 { |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
73 start_ = start; |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
74 RefreshScene(); |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
75 } |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
76 |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
77 void LineMeasureTool::SetEnd(ScenePoint2D end) |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
78 { |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
79 end_ = end; |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
80 RefreshScene(); |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
81 } |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
82 |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
83 void LineMeasureTool::Set(ScenePoint2D start, ScenePoint2D end) |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
84 { |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
85 start_ = start; |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
86 end_ = end; |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
87 RefreshScene(); |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
88 } |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
89 |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
90 void LineMeasureTool::SetLineHighlightArea(LineHighlightArea area) |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
91 { |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
92 if (lineHighlightArea_ != area) |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
93 { |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
94 lineHighlightArea_ = area; |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
95 RefreshScene(); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
96 } |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
97 } |
774
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
98 |
1020
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
906
diff
changeset
|
99 std::string LineMeasureTool::GetDescription() |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
906
diff
changeset
|
100 { |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
906
diff
changeset
|
101 std::stringstream ss; |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
906
diff
changeset
|
102 ss << "LineMeasureTool. Start = " << start_ << " End = " << end_; |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
906
diff
changeset
|
103 return ss.str(); |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
906
diff
changeset
|
104 } |
ac88989817e3
TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents:
906
diff
changeset
|
105 |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
106 void LineMeasureTool::ResetHighlightState() |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
107 { |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
108 SetLineHighlightArea(LineHighlightArea_None); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
109 } |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
110 |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
111 void LineMeasureTool::Highlight(ScenePoint2D p) |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
112 { |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
113 LineHighlightArea lineHighlightArea = LineHitTest(p); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
114 SetLineHighlightArea(lineHighlightArea); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
115 } |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
116 |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
117 LineMeasureTool::LineHighlightArea LineMeasureTool::LineHitTest(ScenePoint2D p) |
774
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
118 { |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1314
diff
changeset
|
119 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
120 ViewportController& controller = lock->GetController(); |
1571 | 121 const Scene2D& scene = controller.GetScene(); |
774
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
122 |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
123 const double pixelToScene = scene.GetCanvasToSceneTransform().ComputeZoom(); |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
124 const double SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD = |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
125 pixelToScene * HIT_TEST_MAX_DISTANCE_CANVAS_COORD * |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
126 pixelToScene * HIT_TEST_MAX_DISTANCE_CANVAS_COORD; |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
127 |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
128 const double sqDistanceFromStart = |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
129 ScenePoint2D::SquaredDistancePtPt(p, start_); |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
130 |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
131 if (sqDistanceFromStart <= SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD) |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
132 return LineHighlightArea_Start; |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
133 |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
134 const double sqDistanceFromEnd = ScenePoint2D::SquaredDistancePtPt(p, end_); |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
135 |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
136 if (sqDistanceFromEnd <= SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD) |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
137 return LineHighlightArea_End; |
774
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
138 |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
139 const double sqDistanceFromPtSegment = |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
140 ScenePoint2D::SquaredDistancePtSegment(start_, end_, p); |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
141 |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
142 if (sqDistanceFromPtSegment <= SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD) |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
143 return LineHighlightArea_Segment; |
774
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
144 |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
145 return LineHighlightArea_None; |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
146 } |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
147 |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
148 bool LineMeasureTool::HitTest(ScenePoint2D p) |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
149 { |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
862
diff
changeset
|
150 return LineHitTest(p) != LineHighlightArea_None; |
774
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
151 } |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
152 |
866
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
153 boost::shared_ptr<IFlexiblePointerTracker> LineMeasureTool::CreateEditionTracker(const PointerEvent& e) |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
154 { |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1314
diff
changeset
|
155 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
156 ViewportController& controller = lock->GetController(); |
1571 | 157 const Scene2D& scene = controller.GetScene(); |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
158 |
866
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
159 ScenePoint2D scenePos = e.GetMainPosition().Apply( |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
160 scene.GetCanvasToSceneTransform()); |
866
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
161 |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
162 if (!HitTest(scenePos)) |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
163 return boost::shared_ptr<IFlexiblePointerTracker>(); |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
164 |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
165 boost::shared_ptr<EditLineMeasureTracker> editLineMeasureTracker( |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
166 new EditLineMeasureTracker(shared_from_this(), viewport_, e)); |
866
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
167 return editLineMeasureTracker; |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
168 } |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
169 |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
170 boost::shared_ptr<MeasureToolMemento> LineMeasureTool::GetMemento() const |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
171 { |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
172 boost::shared_ptr<LineMeasureToolMemento> memento(new LineMeasureToolMemento()); |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
173 memento->start_ = start_; |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
174 memento->end_ = end_; |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
175 return memento; |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
176 } |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
177 |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
178 void LineMeasureTool::SetMemento( |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
179 boost::shared_ptr<MeasureToolMemento> mementoBase) |
866
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
180 { |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
181 boost::shared_ptr<LineMeasureToolMemento> memento = |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
182 boost::dynamic_pointer_cast<LineMeasureToolMemento>(mementoBase); |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
183 |
866
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
184 ORTHANC_ASSERT(memento.get() != NULL, "Internal error: wrong (or bad) memento"); |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
185 |
866
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
186 start_ = memento->start_; |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
187 end_ = memento->end_; |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
188 RefreshScene(); |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
189 } |
c71ef52602a0
Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents:
865
diff
changeset
|
190 |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
191 void LineMeasureTool::RefreshScene() |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
192 { |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
193 if (IsSceneAlive()) |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
194 { |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
195 if (IsEnabled()) |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
196 { |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
197 |
1331
ab81ee8fce1f
- Viewport is not passed and stored as a shared_ptr instead
Benjamin Golinvaux <bgo@osimis.io>
parents:
1314
diff
changeset
|
198 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
199 ViewportController& controller = lock->GetController(); |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
200 Scene2D& scene = controller.GetScene(); |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
201 |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
202 layerHolder_->CreateLayersIfNeeded(); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
203 { |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
204 // Fill the polyline layer with the measurement line |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
205 |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
206 PolylineSceneLayer* polylineLayer = layerHolder_->GetPolylineLayer(0); |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
207 if (polylineLayer) |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
208 { |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
209 polylineLayer->ClearAllChains(); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
210 |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
211 const Color color(TOOL_LINES_COLOR_RED, |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
212 TOOL_LINES_COLOR_GREEN, |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
213 TOOL_LINES_COLOR_BLUE); |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
214 |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
215 const Color highlightColor(TOOL_LINES_HL_COLOR_RED, |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
216 TOOL_LINES_HL_COLOR_GREEN, |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
217 TOOL_LINES_HL_COLOR_BLUE); |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
218 |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
219 { |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
220 PolylineSceneLayer::Chain chain; |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
221 chain.push_back(start_); |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
222 chain.push_back(end_); |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
223 if(lineHighlightArea_ == LineHighlightArea_Segment) |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
224 polylineLayer->AddChain(chain, false, highlightColor); |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
225 else |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
226 polylineLayer->AddChain(chain, false, color); |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
227 } |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
228 |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
229 // handles |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
230 { |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
231 { |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
232 PolylineSceneLayer::Chain chain; |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
233 |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
234 //TODO: take DPI into account |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
235 AddSquare(chain, controller.GetScene(), start_, |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
236 controller.GetHandleSideLengthS()); |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
237 |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
238 if (lineHighlightArea_ == LineHighlightArea_Start) |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
239 polylineLayer->AddChain(chain, true, highlightColor); |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
240 else |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
241 polylineLayer->AddChain(chain, true, color); |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
242 } |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
243 |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
244 { |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
245 PolylineSceneLayer::Chain chain; |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
246 |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
247 //TODO: take DPI into account |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
248 AddSquare(chain, controller.GetScene(), end_, |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
249 controller.GetHandleSideLengthS()); |
1203
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
250 |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
251 if (lineHighlightArea_ == LineHighlightArea_End) |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
252 polylineLayer->AddChain(chain, true, highlightColor); |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
253 else |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
254 polylineLayer->AddChain(chain, true, color); |
f3bb9a6dd949
locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1060
diff
changeset
|
255 } |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
256 } |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
257 } |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
258 } |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
259 { |
774
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
260 // Set the text layer propreties |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
261 double deltaX = end_.GetX() - start_.GetX(); |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
262 double deltaY = end_.GetY() - start_.GetY(); |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
263 double squareDist = deltaX * deltaX + deltaY * deltaY; |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
264 double dist = sqrt(squareDist); |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
265 char buf[64]; |
862
ff3559c489c9
Fixed line displayed string
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
266 sprintf(buf, "%0.02f mm", dist); |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
267 |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
268 // TODO: for now we simply position the text overlay at the middle |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
269 // of the measuring segment |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
270 double midX = 0.5 * (end_.GetX() + start_.GetX()); |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
271 double midY = 0.5 * (end_.GetY() + start_.GetY()); |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
272 |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
273 { |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
274 |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
275 #if ORTHANC_STONE_ENABLE_OUTLINED_TEXT == 1 |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
276 SetTextLayerOutlineProperties( |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
277 scene, layerHolder_, buf, ScenePoint2D(midX, midY), 0); |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
278 #else |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
279 SetTextLayerProperties( |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
280 scene, layerHolder_, buf, ScenePoint2D(midX, midY), 0); |
906
52b1c6ff10c5
Disabled OpenGL in GuiAdapter to allow for Cairo-only workflows (THIS IS A TEMP CHANGE!!!) + disabled outlined text by default (build macro)
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
281 #endif |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
282 lock->Invalidate(); |
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
283 } |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
284 } |
1305
a5326ce4f24b
Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents:
1279
diff
changeset
|
285 lock->Invalidate(); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
286 } |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
287 else |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
288 { |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
289 RemoveFromScene(); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
290 } |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
291 } |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
292 } |
774
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
293 } |