annotate OrthancStone/Sources/Scene2DViewport/LineMeasureTool.cpp @ 1870:3889ae96d2e9

added copyright UCLouvain
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Jan 2022 11:04:09 +0100
parents fe5c7311a7fd
children 7053b8a0aaec
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
1870
3889ae96d2e9 added copyright UCLouvain
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1794
diff changeset
6 * Copyright (C) 2021-2021 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
7 *
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
8 * 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
9 * 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
10 * 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
11 * 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
12 *
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
13 * 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
14 * 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
15 * 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
16 * 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
17 *
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
18 * 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
19 * 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
20 * <http://www.gnu.org/licenses/>.
698
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
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
23 #include "LineMeasureTool.h"
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
24 #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
25 #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
26 #include "LayerHolder.h"
1048
f6be9412e42a cleaning up IObservable.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1020
diff changeset
27 #include "../StoneException.h"
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
28
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1331
diff changeset
29 #include <Logging.h>
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
30
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
31 #include <boost/make_shared.hpp>
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
32
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
33 namespace OrthancStone
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
34 {
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
35 LineMeasureTool::LineMeasureTool(
1606
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
36 boost::weak_ptr<IViewport> viewport):
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
37 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
38 #if ORTHANC_STONE_ENABLE_OUTLINED_TEXT == 1
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
39 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
40 #else
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
41 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
42 #endif
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
43 baseLayerIndex_(0),
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
44 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
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 }
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
48
1606
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
49 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
50 {
9b126de2cde2 Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents: 1311
diff changeset
51 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
52 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
53 obj->RefreshScene();
9b126de2cde2 Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents: 1311
diff changeset
54 return obj;
9b126de2cde2 Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents: 1311
diff changeset
55 }
9b126de2cde2 Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents: 1311
diff changeset
56
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
57 LineMeasureTool::~LineMeasureTool()
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
58 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
59 // 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
60 // stored in the 2D scene
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
61 Disable();
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
62 RemoveFromScene();
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
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
65 void LineMeasureTool::RemoveFromScene()
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
66 {
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
67 if (layerHolder_->AreLayersCreated() && IsSceneAlive())
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68 {
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
69 layerHolder_->DeleteLayers();
698
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 }
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
72
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73 void LineMeasureTool::SetStart(ScenePoint2D start)
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 start_ = start;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
76 RefreshScene();
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
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
79 void LineMeasureTool::SetEnd(ScenePoint2D end)
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 end_ = end;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
82 RefreshScene();
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
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
85 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
86 {
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
87 start_ = start;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
88 end_ = end;
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
89 RefreshScene();
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
90 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
91
865
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
92 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
93 {
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
94 if (lineHighlightArea_ != area)
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
95 {
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
96 lineHighlightArea_ = area;
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
97 RefreshScene();
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
98 }
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
99 }
774
66ac7a2d1e3a A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
100
1020
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
101 std::string LineMeasureTool::GetDescription()
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
102 {
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
103 std::stringstream ss;
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
104 ss << "LineMeasureTool. Start = " << start_ << " End = " << end_;
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
105 return ss.str();
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
106 }
ac88989817e3 TrackerCommand --> MeasureCommand + fuse against exception in MeasureTool dtor
Benjamin Golinvaux <bgo@osimis.io>
parents: 906
diff changeset
107
865
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
108 void LineMeasureTool::ResetHighlightState()
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
109 {
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
110 SetLineHighlightArea(LineHighlightArea_None);
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
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
113 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
114 {
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
115 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
116 SetLineHighlightArea(lineHighlightArea);
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
117 }
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
118
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
119 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
120 {
1606
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
121 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
122 if (lock.get() != NULL)
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
123 {
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
124 ViewportController& controller = lock->GetController();
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
125 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
126
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
127 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
128 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
129 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
130 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
131
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
132 const double sqDistanceFromStart =
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
133 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
134
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
135 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
136 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
137
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
138 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
139
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
140 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
141 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
142
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
143 const double sqDistanceFromPtSegment =
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
144 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
145
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
146 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
147 return LineHighlightArea_Segment;
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
148 }
774
66ac7a2d1e3a A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
149
865
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
150 return LineHighlightArea_None;
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
151 }
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
152
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
153 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
154 {
a29c13497557 Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents: 862
diff changeset
155 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
156 }
66ac7a2d1e3a A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
157
866
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<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
159 {
1606
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
160 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
161 if (lock.get() != NULL)
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
162 {
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
163 ViewportController& controller = lock->GetController();
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
164 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
165
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
166 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
167 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
168
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
169 if (!HitTest(scenePos))
1794
fe5c7311a7fd fix for msvc 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1791
diff changeset
170 {
fe5c7311a7fd fix for msvc 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1791
diff changeset
171 return boost::shared_ptr<IFlexiblePointerTracker>(); // NULL
fe5c7311a7fd fix for msvc 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1791
diff changeset
172 }
fe5c7311a7fd fix for msvc 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1791
diff changeset
173 else
fe5c7311a7fd fix for msvc 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1791
diff changeset
174 {
fe5c7311a7fd fix for msvc 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1791
diff changeset
175 boost::shared_ptr<EditLineMeasureTracker> editLineMeasureTracker(
fe5c7311a7fd fix for msvc 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1791
diff changeset
176 new EditLineMeasureTracker(shared_from_this(), viewport_, e));
fe5c7311a7fd fix for msvc 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1791
diff changeset
177 return editLineMeasureTracker;
fe5c7311a7fd fix for msvc 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1791
diff changeset
178 }
1789
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
179 }
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
180 else
462d7a0e064e added line measures to sdl single frame viewer sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
181 {
1794
fe5c7311a7fd fix for msvc 2008
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1791
diff changeset
182 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
183 }
866
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
184 }
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
185
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
186 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
187 {
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
188 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
189 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
190 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
191 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
192 }
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
193
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
194 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
195 {
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
196 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
197 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
198 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
199 RefreshScene();
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
200 }
c71ef52602a0 Added the ability to edit existing measuring tools (demo not updated yet)
Benjamin Golinvaux <bgo@osimis.io>
parents: 865
diff changeset
201
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
202 void LineMeasureTool::RefreshScene()
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
203 {
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
204 if (IsSceneAlive())
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
205 {
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
206 if (IsEnabled())
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
207 {
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
208
1606
874e178f34e9 - ViewportController now has weak ptr to Viewport
Benjamin Golinvaux <bgo@osimis.io>
parents: 1598
diff changeset
209 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
210 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
211 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
212
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
213 layerHolder_->CreateLayersIfNeeded();
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
214 {
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
215 // 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
216
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
217 PolylineSceneLayer* polylineLayer = layerHolder_->GetPolylineLayer(0);
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
218 if (polylineLayer)
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
219 {
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
220 polylineLayer->ClearAllChains();
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
221
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
222 const Color color(TOOL_LINES_COLOR_RED,
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
223 TOOL_LINES_COLOR_GREEN,
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
224 TOOL_LINES_COLOR_BLUE);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
225
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
226 const Color highlightColor(TOOL_LINES_HL_COLOR_RED,
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
227 TOOL_LINES_HL_COLOR_GREEN,
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
228 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
229
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
230 {
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
231 PolylineSceneLayer::Chain chain;
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
232 chain.push_back(start_);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
233 chain.push_back(end_);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
234 if(lineHighlightArea_ == LineHighlightArea_Segment)
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
235 polylineLayer->AddChain(chain, false, highlightColor);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
236 else
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
237 polylineLayer->AddChain(chain, false, color);
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
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
240 // handles
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 {
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
243 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
244
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
245 //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
246 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
247 controller.GetHandleSideLengthS());
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
248
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
249 if (lineHighlightArea_ == LineHighlightArea_Start)
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
250 polylineLayer->AddChain(chain, true, highlightColor);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
251 else
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
252 polylineLayer->AddChain(chain, true, color);
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 {
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
256 PolylineSceneLayer::Chain chain;
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
257
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
258 //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
259 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
260 controller.GetHandleSideLengthS());
1203
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
261
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
262 if (lineHighlightArea_ == LineHighlightArea_End)
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
263 polylineLayer->AddChain(chain, true, highlightColor);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
264 else
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
265 polylineLayer->AddChain(chain, true, color);
f3bb9a6dd949 locking abstraction in IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1060
diff changeset
266 }
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
267 }
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
268 }
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
269 }
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
270 {
774
66ac7a2d1e3a A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
271 // 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
272 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
273 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
274 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
275 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
276 char buf[64];
862
ff3559c489c9 Fixed line displayed string
Benjamin Golinvaux <bgo@osimis.io>
parents: 818
diff changeset
277 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
278
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
279 // 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
280 // 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
281 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
282 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
283
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
284 {
a5326ce4f24b Trackers and measuring tools now use the viewport instead of ViewportController, so that proper locks can be used
Benjamin Golinvaux <bgo@osimis.io>
parents: 1279
diff changeset
285
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
286 #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
287 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
288 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
289 #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
290 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
291 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
292 #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
293 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
294 }
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
295 }
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
296 lock->Invalidate();
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
297 }
722
28b9e3a54200 Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents: 698
diff changeset
298 else
698
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
299 {
751
712ff6ff3c19 - undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents: 722
diff changeset
300 RemoveFromScene();
698
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 }
8b6adfb62a2f Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
303 }
774
66ac7a2d1e3a A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents: 751
diff changeset
304 }