annotate Framework/Scene2DViewport/LineMeasureTool.cpp @ 1048:f6be9412e42a

cleaning up IObservable.h
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 10 Oct 2019 14:11:52 +0200
parents ac88989817e3
children e713f1a99861 2d8ab34c8c91
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
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
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
27 #include <Core/Logging.h>
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
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
34 LineMeasureTool::LineMeasureTool(
818
e42b491f1fb2 Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents: 804
diff changeset
35 MessageBroker& broker, boost::weak_ptr<ViewportController> controllerW)
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
36 : MeasureTool(broker, controllerW)
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
37 #if ORTHANC_STONE_ENABLE_OUTLINED_TEXT == 1
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
38 , layerHolder_(boost::make_shared<LayerHolder>(controllerW, 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
39 #else
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 , layerHolder_(boost::make_shared<LayerHolder>(controllerW, 1, 1))
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
41 #endif
865
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
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
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
47 LineMeasureTool::~LineMeasureTool()
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
48 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
49 // 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
50 // stored in the 2D scene
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
51 Disable();
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
52 RemoveFromScene();
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
53 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
54
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
55 void LineMeasureTool::RemoveFromScene()
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56 {
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
57 if (layerHolder_->AreLayersCreated() && IsSceneAlive())
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58 {
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
59 layerHolder_->DeleteLayers();
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
61 }
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
62
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
63 void LineMeasureTool::SetStart(ScenePoint2D start)
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
65 start_ = start;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
66 RefreshScene();
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
67 }
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 void LineMeasureTool::SetEnd(ScenePoint2D end)
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
71 end_ = end;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
72 RefreshScene();
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
74
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 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
76 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
77 start_ = start;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
78 end_ = end;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
79 RefreshScene();
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
80 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
81
865
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
82 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
83 {
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
84 if (lineHighlightArea_ != area)
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
85 {
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
86 lineHighlightArea_ = area;
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
87 RefreshScene();
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
88 }
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
89 }
774
66ac7a2d1e3a A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
90
1020
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
91 std::string LineMeasureTool::GetDescription()
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
92 {
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
93 std::stringstream ss;
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
94 ss << "LineMeasureTool. Start = " << start_ << " End = " << end_;
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
95 return ss.str();
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
96 }
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
97
865
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
98 void LineMeasureTool::ResetHighlightState()
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
99 {
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
100 SetLineHighlightArea(LineHighlightArea_None);
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
101 }
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
102
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
103 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
104 {
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
105 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
106 SetLineHighlightArea(lineHighlightArea);
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
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
109 LineMeasureTool::LineHighlightArea LineMeasureTool::LineHitTest(ScenePoint2D p) const
774
66ac7a2d1e3a A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
110 {
66ac7a2d1e3a A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
111 const double pixelToScene =
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 866
diff changeset
112 GetController()->GetScene().GetCanvasToSceneTransform().ComputeZoom();
865
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
113 const double SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD = pixelToScene * HIT_TEST_MAX_DISTANCE_CANVAS_COORD * pixelToScene * HIT_TEST_MAX_DISTANCE_CANVAS_COORD;
774
66ac7a2d1e3a A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
114
865
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
115 const double sqDistanceFromStart = ScenePoint2D::SquaredDistancePtPt(p, start_);
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
116 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
117 return LineHighlightArea_Start;
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
118
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
119 const double sqDistanceFromEnd = ScenePoint2D::SquaredDistancePtPt(p, end_);
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
120 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
121 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
122
865
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
123 const double sqDistanceFromPtSegment = ScenePoint2D::SquaredDistancePtSegment(start_, end_, p);
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
124 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
125 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
126
865
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
127 return LineHighlightArea_None;
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
128 }
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
129
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
130 bool LineMeasureTool::HitTest(ScenePoint2D p) const
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
131 {
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
132 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
133 }
66ac7a2d1e3a A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
134
866
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
135 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
136 {
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
137 ScenePoint2D scenePos = e.GetMainPosition().Apply(
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 866
diff changeset
138 GetController()->GetScene().GetCanvasToSceneTransform());
866
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
139
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
140 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
141 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
142
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
143 /**
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
144 new EditLineMeasureTracker(
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
145 boost::shared_ptr<LineMeasureTool> measureTool;
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
146 MessageBroker & broker,
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
147 boost::weak_ptr<ViewportController> controllerW,
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
148 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
149 */
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
150 boost::shared_ptr<EditLineMeasureTracker> editLineMeasureTracker(
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
151 new EditLineMeasureTracker(shared_from_this(), GetBroker(), GetController(), e));
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
152 return editLineMeasureTracker;
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
153 }
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
154
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
155
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
156 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
157 {
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
158 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
159 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
160 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
161 return memento;
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
162 }
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
163
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
164 void LineMeasureTool::SetMemento(boost::shared_ptr<MeasureToolMemento> mementoBase)
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
165 {
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
166 boost::shared_ptr<LineMeasureToolMemento> memento = boost::dynamic_pointer_cast<LineMeasureToolMemento>(mementoBase);
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
167 ORTHANC_ASSERT(memento.get() != NULL, "Internal error: wrong (or bad) memento");
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
168 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
169 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
170 RefreshScene();
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
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
173 void LineMeasureTool::RefreshScene()
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
174 {
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
175 if (IsSceneAlive())
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
176 {
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
177 if (IsEnabled())
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
178 {
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
179 layerHolder_->CreateLayersIfNeeded();
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
180
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
181 {
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
182 // 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
183
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
184 PolylineSceneLayer* polylineLayer = layerHolder_->GetPolylineLayer(0);
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
185 polylineLayer->ClearAllChains();
804
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 774
diff changeset
186
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 774
diff changeset
187 const Color color(TOOL_LINES_COLOR_RED,
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 774
diff changeset
188 TOOL_LINES_COLOR_GREEN,
61ba4b504e9a PolylineSceneLayer now has one color per chain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 774
diff changeset
189 TOOL_LINES_COLOR_BLUE);
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
190
865
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
191 const Color highlightColor(TOOL_LINES_HL_COLOR_RED,
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
192 TOOL_LINES_HL_COLOR_GREEN,
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
193 TOOL_LINES_HL_COLOR_BLUE);
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
194
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
195 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
196 PolylineSceneLayer::Chain chain;
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
197 chain.push_back(start_);
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
198 chain.push_back(end_);
865
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
199 if(lineHighlightArea_ == LineHighlightArea_Segment)
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
200 polylineLayer->AddChain(chain, false, highlightColor);
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
201 else
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
202 polylineLayer->AddChain(chain, false, color);
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
203 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
204
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
205 // handles
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
206 {
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
207 {
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
208 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
209
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
210 //TODO: take DPI into account
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 866
diff changeset
211 AddSquare(chain, GetController()->GetScene(), start_,
774
66ac7a2d1e3a A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
212 GetController()->GetHandleSideLengthS());
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
213
865
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
214 if (lineHighlightArea_ == LineHighlightArea_Start)
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
215 polylineLayer->AddChain(chain, true, highlightColor);
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
216 else
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
217 polylineLayer->AddChain(chain, true, color);
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 {
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
221 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
222
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
223 //TODO: take DPI into account
891
0aff28f15ea2 new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 866
diff changeset
224 AddSquare(chain, GetController()->GetScene(), 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
225 GetController()->GetHandleSideLengthS());
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
226
865
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
227 if (lineHighlightArea_ == LineHighlightArea_End)
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
228 polylineLayer->AddChain(chain, true, highlightColor);
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
229 else
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
230 polylineLayer->AddChain(chain, true, color);
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
231 }
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
232 }
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
233
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
234 }
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
235 {
774
66ac7a2d1e3a A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
236 // 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
237 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
238 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
239 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
240 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
241 char buf[64];
862
ff3559c489c9 Fixed line displayed string
Benjamin Golinvaux <bgo@osimis.io>
parents: 818
diff changeset
242 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
243
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
244 // 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
245 // 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
246 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
247 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
248
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
249 #if ORTHANC_STONE_ENABLE_OUTLINED_TEXT == 1
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
250 SetTextLayerOutlineProperties(
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
251 GetController()->GetScene(), layerHolder_, buf, ScenePoint2D(midX, midY), 0);
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
252 #else
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
253 SetTextLayerProperties(
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
254 GetController()->GetScene(), layerHolder_, buf, ScenePoint2D(midX, midY), 0);
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
255 #endif
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
256 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
257 }
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
258 else
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
259 {
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
260 RemoveFromScene();
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
261 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
262 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
263 }
774
66ac7a2d1e3a A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
264 }