annotate OrthancStone/Sources/Scene2DViewport/LineMeasureTool.cpp @ 1794:fe5c7311a7fd

fix for msvc 2008
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 17 May 2021 18:03:47 +0200
parents 9b650ab68d4c
children 3889ae96d2e9
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
1739
9ac2a65d4172 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1606
diff changeset
5 * Copyright (C) 2017-2021 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
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1571
diff changeset
8 * modify it under the terms of the GNU Lesser General Public License
698
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
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1571
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1571
diff changeset
15 * Lesser General Public License for more details.
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
16 *
1598
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1571
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1571
diff changeset
18 * License along with this program. If not, see
8563ea5d8ae4 relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1571
diff changeset
19 * <http://www.gnu.org/licenses/>.
698
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
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
22 #include "LineMeasureTool.h"
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
23 #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
24 #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
25 #include "LayerHolder.h"
1048
f6be9412e42a cleaning up IObservable.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1020
diff changeset
26 #include "../StoneException.h"
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
27
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1331
diff changeset
28 #include <Logging.h>
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
29
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
30 #include <boost/make_shared.hpp>
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
31
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
32 namespace OrthancStone
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
33 {
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
34 LineMeasureTool::LineMeasureTool(
1606
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
35 boost::weak_ptr<IViewport> viewport):
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
36 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
37 #if ORTHANC_STONE_ENABLE_OUTLINED_TEXT == 1
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
38 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
39 #else
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
40 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
41 #endif
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
42 baseLayerIndex_(0),
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
43 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
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 }
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
47
1606
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
48 boost::shared_ptr<LineMeasureTool> LineMeasureTool::Create(boost::weak_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
49 {
9b126de2cde2 Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents: 1311
diff changeset
50 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
51 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
52 obj->RefreshScene();
9b126de2cde2 Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents: 1311
diff changeset
53 return obj;
9b126de2cde2 Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents: 1311
diff changeset
54 }
9b126de2cde2 Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents: 1311
diff changeset
55
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
56 LineMeasureTool::~LineMeasureTool()
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58 // 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
59 // stored in the 2D scene
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
60 Disable();
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
61 RemoveFromScene();
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
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64 void LineMeasureTool::RemoveFromScene()
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
65 {
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
66 if (layerHolder_->AreLayersCreated() && IsSceneAlive())
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
67 {
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
68 layerHolder_->DeleteLayers();
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70 }
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
71
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
72 void LineMeasureTool::SetStart(ScenePoint2D start)
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 start_ = start;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 RefreshScene();
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
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
78 void LineMeasureTool::SetEnd(ScenePoint2D end)
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
79 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
80 end_ = end;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
81 RefreshScene();
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
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
84 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
85 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
86 start_ = start;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
87 end_ = end;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
88 RefreshScene();
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
89 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
90
865
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
91 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
92 {
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
93 if (lineHighlightArea_ != area)
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
94 {
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
95 lineHighlightArea_ = area;
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
96 RefreshScene();
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
97 }
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
98 }
774
66ac7a2d1e3a A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
99
1020
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
100 std::string LineMeasureTool::GetDescription()
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
101 {
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
102 std::stringstream ss;
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
103 ss << "LineMeasureTool. Start = " << start_ << " End = " << end_;
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
104 return ss.str();
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
105 }
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
106
865
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
107 void LineMeasureTool::ResetHighlightState()
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 SetLineHighlightArea(LineHighlightArea_None);
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
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
112 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
113 {
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
114 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
115 SetLineHighlightArea(lineHighlightArea);
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
116 }
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
117
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
118 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
119 {
1606
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
120 std::unique_ptr<IViewport::ILock> lock(GetViewportLock());
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
121 if (lock.get() != NULL)
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
122 {
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
123 ViewportController& controller = lock->GetController();
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
124 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
125
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
126 const double pixelToScene = scene.GetCanvasToSceneTransform().ComputeZoom();
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
127 const double SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD =
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
128 pixelToScene * HIT_TEST_MAX_DISTANCE_CANVAS_COORD *
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
129 pixelToScene * HIT_TEST_MAX_DISTANCE_CANVAS_COORD;
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
130
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
131 const double sqDistanceFromStart =
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
132 ScenePoint2D::SquaredDistancePtPt(p, start_);
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
133
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
134 if (sqDistanceFromStart <= SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD)
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
135 return LineHighlightArea_Start;
865
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
136
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
137 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
138
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
139 if (sqDistanceFromEnd <= SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD)
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
140 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
141
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
142 const double sqDistanceFromPtSegment =
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
143 ScenePoint2D::SquaredDistancePtSegment(start_, end_, p);
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
144
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
145 if (sqDistanceFromPtSegment <= SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD)
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
146 return LineHighlightArea_Segment;
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
147 }
774
66ac7a2d1e3a A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
148
865
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
149 return LineHighlightArea_None;
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
150 }
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
151
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
152 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
153 {
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
154 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
155 }
66ac7a2d1e3a A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
156
866
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
157 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
158 {
1606
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
159 std::unique_ptr<IViewport::ILock> lock(GetViewportLock());
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
160 if (lock.get() != NULL)
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
161 {
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
162 ViewportController& controller = lock->GetController();
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
163 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
164
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
165 ScenePoint2D scenePos = e.GetMainPosition().Apply(
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
166 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
167
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
168 if (!HitTest(scenePos))
1794
fe5c7311a7fd fix for msvc 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1791
diff changeset
169 {
fe5c7311a7fd fix for msvc 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1791
diff changeset
170 return boost::shared_ptr<IFlexiblePointerTracker>(); // NULL
fe5c7311a7fd fix for msvc 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1791
diff changeset
171 }
fe5c7311a7fd fix for msvc 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1791
diff changeset
172 else
fe5c7311a7fd fix for msvc 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1791
diff changeset
173 {
fe5c7311a7fd fix for msvc 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1791
diff changeset
174 boost::shared_ptr<EditLineMeasureTracker> editLineMeasureTracker(
fe5c7311a7fd fix for msvc 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1791
diff changeset
175 new EditLineMeasureTracker(shared_from_this(), viewport_, e));
fe5c7311a7fd fix for msvc 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1791
diff changeset
176 return editLineMeasureTracker;
fe5c7311a7fd fix for msvc 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1791
diff changeset
177 }
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
178 }
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
179 else
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
180 {
1794
fe5c7311a7fd fix for msvc 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1791
diff changeset
181 return boost::shared_ptr<IFlexiblePointerTracker>(); // NULL
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
182 }
866
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
183 }
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
184
1791
9b650ab68d4c replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
185 MeasureToolMemento* LineMeasureTool::CreateMemento() const
866
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
186 {
1791
9b650ab68d4c replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
187 std::unique_ptr<LineMeasureToolMemento> memento(new LineMeasureToolMemento());
866
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
188 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
189 memento->end_ = end_;
1791
9b650ab68d4c replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
190 return memento.release();
866
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
191 }
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
192
1791
9b650ab68d4c replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
193 void LineMeasureTool::SetMemento(const 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
194 {
1791
9b650ab68d4c replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
195 const LineMeasureToolMemento& memento = dynamic_cast<const LineMeasureToolMemento&>(mementoBase);
9b650ab68d4c replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
196 start_ = memento.start_;
9b650ab68d4c replaced unneeded use of boost::share_ptr for MeasureCommand mementos by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1789
diff changeset
197 end_ = memento.end_;
866
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
198 RefreshScene();
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
199 }
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
200
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
201 void LineMeasureTool::RefreshScene()
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
202 {
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
203 if (IsSceneAlive())
698
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 if (IsEnabled())
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
206 {
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
207
1606
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
208 std::unique_ptr<IViewport::ILock> lock(GetViewportLock());
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
209 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
210 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
211
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
212 layerHolder_->CreateLayersIfNeeded();
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
213 {
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
214 // 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
215
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
216 PolylineSceneLayer* polylineLayer = layerHolder_->GetPolylineLayer(0);
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
217 if (polylineLayer)
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
218 {
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
219 polylineLayer->ClearAllChains();
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
220
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
221 const Color color(TOOL_LINES_COLOR_RED,
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
222 TOOL_LINES_COLOR_GREEN,
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
223 TOOL_LINES_COLOR_BLUE);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
224
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
225 const Color highlightColor(TOOL_LINES_HL_COLOR_RED,
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
226 TOOL_LINES_HL_COLOR_GREEN,
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
227 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
228
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
229 {
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
230 PolylineSceneLayer::Chain chain;
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
231 chain.push_back(start_);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
232 chain.push_back(end_);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
233 if(lineHighlightArea_ == LineHighlightArea_Segment)
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
234 polylineLayer->AddChain(chain, false, highlightColor);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
235 else
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
236 polylineLayer->AddChain(chain, false, color);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
237 }
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
238
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
239 // handles
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
240 {
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
241 {
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
242 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
243
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
244 //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
245 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
246 controller.GetHandleSideLengthS());
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
247
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
248 if (lineHighlightArea_ == LineHighlightArea_Start)
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
249 polylineLayer->AddChain(chain, true, highlightColor);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
250 else
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
251 polylineLayer->AddChain(chain, true, color);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
252 }
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
253
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
254 {
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
255 PolylineSceneLayer::Chain chain;
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
256
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
257 //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
258 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
259 controller.GetHandleSideLengthS());
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
260
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
261 if (lineHighlightArea_ == LineHighlightArea_End)
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
262 polylineLayer->AddChain(chain, true, highlightColor);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
263 else
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
264 polylineLayer->AddChain(chain, true, color);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
265 }
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
266 }
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 }
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
269 {
774
66ac7a2d1e3a A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
270 // 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
271 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
272 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
273 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
274 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
275 char buf[64];
862
ff3559c489c9 Fixed line displayed string
Benjamin Golinvaux <bgo@osimis.io>
parents: 818
diff changeset
276 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
277
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
278 // 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
279 // 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
280 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
281 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
282
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
283 {
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
284
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
285 #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
286 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
287 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
288 #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
289 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
290 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
291 #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
292 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
293 }
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
294 }
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
295 lock->Invalidate();
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
296 }
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
297 else
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
298 {
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
299 RemoveFromScene();
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
300 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
301 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
302 }
774
66ac7a2d1e3a A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
303 }