Mercurial > hg > orthanc-stone
annotate Framework/Scene2DViewport/AngleMeasureTool.cpp @ 865:a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 25 Jun 2019 15:24:13 +0200 |
parents | 2fd96a637a59 |
children | c71ef52602a0 |
rev | line source |
---|---|
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1 /** |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
2 * Stone of Orthanc |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
6 * |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
11 * |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
16 * |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
19 **/ |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
20 |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
21 #include "AngleMeasureTool.h" |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
22 #include "MeasureToolsToolbox.h" |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
23 #include "LayerHolder.h" |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
24 |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
25 #include <Core/Logging.h> |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
26 |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
27 #include <boost/math/constants/constants.hpp> |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
28 #include <boost/make_shared.hpp> |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
29 |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
30 //// <HACK> |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
31 //// REMOVE THIS |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
32 //#ifndef NDEBUG |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
33 //extern void |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
34 //TrackerSample_SetInfoDisplayMessage(std::string key, std::string value); |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
35 //#endif |
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
36 //// </HACK> |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
37 |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
38 namespace OrthancStone |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
39 { |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
40 // the params in the LayerHolder ctor specify the number of polyline and text |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
41 // layers |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
42 AngleMeasureTool::AngleMeasureTool( |
818
e42b491f1fb2
Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
43 MessageBroker& broker, boost::weak_ptr<ViewportController> controllerW) |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
44 : MeasureTool(broker, controllerW) |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
45 , layerHolder_(boost::make_shared<LayerHolder>(controllerW,1,5)) |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
46 , angleHighlightArea_(AngleHighlightArea_None) |
751
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 |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
49 } |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
50 |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
51 AngleMeasureTool::~AngleMeasureTool() |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
52 { |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
53 // 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
|
54 // stored in the 2D scene |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
55 Disable(); |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
56 RemoveFromScene(); |
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 |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
59 void AngleMeasureTool::RemoveFromScene() |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
60 { |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
61 if (layerHolder_->AreLayersCreated() && IsSceneAlive()) |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
62 { |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
63 layerHolder_->DeleteLayers(); |
698
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 } |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
66 |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
67 void AngleMeasureTool::SetSide1End(ScenePoint2D pt) |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
68 { |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
69 side1End_ = pt; |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
70 RefreshScene(); |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
71 } |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
72 |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
73 void AngleMeasureTool::SetSide2End(ScenePoint2D pt) |
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 side2End_ = pt; |
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 |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
79 void AngleMeasureTool::SetAngleHighlightArea(AngleHighlightArea area) |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
80 { |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
81 if (angleHighlightArea_ != area) |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
82 { |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
83 angleHighlightArea_ = area; |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
84 RefreshScene(); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
85 } |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
86 } |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
87 |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
88 void AngleMeasureTool::ResetHighlightState() |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
89 { |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
90 SetAngleHighlightArea(AngleHighlightArea_None); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
91 } |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
92 |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
93 void AngleMeasureTool::Highlight(ScenePoint2D p) |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
94 { |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
95 AngleHighlightArea angleHighlightArea = AngleHitTest(p); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
96 SetAngleHighlightArea(angleHighlightArea); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
97 } |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
98 |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
99 AngleMeasureTool::AngleHighlightArea AngleMeasureTool::AngleHitTest(ScenePoint2D p) const |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
100 { |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
101 const double pixelToScene = |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
102 GetScene()->GetCanvasToSceneTransform().ComputeZoom(); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
103 const double SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD = pixelToScene * HIT_TEST_MAX_DISTANCE_CANVAS_COORD * pixelToScene * HIT_TEST_MAX_DISTANCE_CANVAS_COORD; |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
104 |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
105 { |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
106 const double sqDistanceFromSide1End = ScenePoint2D::SquaredDistancePtPt(p, side1End_); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
107 if (sqDistanceFromSide1End <= SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD) |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
108 return AngleHighlightArea_Side1End; |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
109 } |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
110 |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
111 { |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
112 const double sqDistanceFromSide2End = ScenePoint2D::SquaredDistancePtPt(p, side2End_); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
113 if (sqDistanceFromSide2End <= SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD) |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
114 return AngleHighlightArea_Side2End; |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
115 } |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
116 |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
117 { |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
118 const double sqDistanceFromCenter = ScenePoint2D::SquaredDistancePtPt(p, center_); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
119 if (sqDistanceFromCenter <= SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD) |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
120 return AngleHighlightArea_Center; |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
121 } |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
122 |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
123 { |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
124 const double sqDistanceFromSide1 = ScenePoint2D::SquaredDistancePtSegment(center_, side1End_, p); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
125 if (sqDistanceFromSide1 <= SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD) |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
126 return AngleHighlightArea_Side1; |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
127 } |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
128 |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
129 { |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
130 const double sqDistanceFromSide2 = ScenePoint2D::SquaredDistancePtSegment(center_, side2End_, p); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
131 if (sqDistanceFromSide2 <= SQUARED_HIT_TEST_MAX_DISTANCE_SCENE_COORD) |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
132 return AngleHighlightArea_Side2; |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
133 } |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
134 |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
135 return AngleHighlightArea_None; |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
136 } |
774
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
137 |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
138 bool AngleMeasureTool::HitTest(ScenePoint2D p) const |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
139 { |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
140 return AngleHitTest(p) != AngleHighlightArea_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
|
141 } |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
142 |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
143 void AngleMeasureTool::SetCenter(ScenePoint2D pt) |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
144 { |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
145 center_ = pt; |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
146 RefreshScene(); |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
147 } |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
148 |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
149 void AngleMeasureTool::RefreshScene() |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
150 { |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
151 if (IsSceneAlive()) |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
152 { |
818
e42b491f1fb2
Removed typedefs to shared_ptr by making them explicit. Removed using namespace
Benjamin Golinvaux <bgo@osimis.io>
parents:
804
diff
changeset
|
153 boost::shared_ptr<ViewportController> controller = GetController(); |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
154 if (IsEnabled()) |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
155 { |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
156 layerHolder_->CreateLayersIfNeeded(); |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
157 |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
158 { |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
159 // Fill the polyline layer with the measurement lines |
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
160 PolylineSceneLayer* polylineLayer = layerHolder_->GetPolylineLayer(0); |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
161 polylineLayer->ClearAllChains(); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
162 |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
163 const Color color(TOOL_ANGLE_LINES_COLOR_RED, TOOL_ANGLE_LINES_COLOR_GREEN, TOOL_ANGLE_LINES_COLOR_BLUE); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
164 const Color highlightColor(TOOL_ANGLE_LINES_HL_COLOR_RED, TOOL_ANGLE_LINES_HL_COLOR_GREEN, TOOL_ANGLE_LINES_HL_COLOR_BLUE); |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
165 |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
166 // sides |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
167 { |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
168 { |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
169 PolylineSceneLayer::Chain chain; |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
170 chain.push_back(side1End_); |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
171 chain.push_back(center_); |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
172 |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
173 if ((angleHighlightArea_ == AngleHighlightArea_Side1) || (angleHighlightArea_ == AngleHighlightArea_Side2)) |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
174 polylineLayer->AddChain(chain, false, highlightColor); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
175 else |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
176 polylineLayer->AddChain(chain, false, color); |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
177 } |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
178 { |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
179 PolylineSceneLayer::Chain chain; |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
180 chain.push_back(side2End_); |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
181 chain.push_back(center_); |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
182 if ((angleHighlightArea_ == AngleHighlightArea_Side1) || (angleHighlightArea_ == AngleHighlightArea_Side2)) |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
183 polylineLayer->AddChain(chain, false, highlightColor); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
184 else |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
185 polylineLayer->AddChain(chain, false, color); |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
186 } |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
187 } |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
188 |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
189 // Create the handles |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
190 { |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
191 { |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
192 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
|
193 //TODO: take DPI into account |
774
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
194 AddSquare(chain, GetScene(), side1End_, |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
195 GetController()->GetHandleSideLengthS()); |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
196 |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
197 if (angleHighlightArea_ == AngleHighlightArea_Side1End) |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
198 polylineLayer->AddChain(chain, true, highlightColor); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
199 else |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
200 polylineLayer->AddChain(chain, true, color); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
201 |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
202 } |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
203 { |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
204 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
|
205 //TODO: take DPI into account |
774
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
206 AddSquare(chain, GetScene(), side2End_, |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
207 GetController()->GetHandleSideLengthS()); |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
208 |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
209 if (angleHighlightArea_ == AngleHighlightArea_Side2End) |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
210 polylineLayer->AddChain(chain, true, highlightColor); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
211 else |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
212 polylineLayer->AddChain(chain, true, color); |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
213 } |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
214 } |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
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 // Create the arc |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
217 { |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
218 PolylineSceneLayer::Chain chain; |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
219 |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
220 AddShortestArc(chain, side1End_, center_, side2End_, |
774
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
221 controller->GetAngleToolArcRadiusS()); |
865
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
222 if (angleHighlightArea_ == AngleHighlightArea_Center) |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
223 polylineLayer->AddChain(chain, false, highlightColor); |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
224 else |
a29c13497557
Added operators to ScenePoint2D + highlight support on MouseOver for measuring tools
Benjamin Golinvaux <bgo@osimis.io>
parents:
827
diff
changeset
|
225 polylineLayer->AddChain(chain, false, color); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
226 } |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
227 } |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
228 { |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
229 // Set the text layer |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
230 |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
231 double p1cAngle = atan2( |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
232 side1End_.GetY() - center_.GetY(), |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
233 side1End_.GetX() - center_.GetX()); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
234 |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
235 double p2cAngle = atan2( |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
236 side2End_.GetY() - center_.GetY(), |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
237 side2End_.GetX() - center_.GetX()); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
238 |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
239 double delta = NormalizeAngle(p2cAngle - p1cAngle); |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
240 double theta = p1cAngle + delta / 2; |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
241 |
774
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
242 double ox = controller->GetAngleTopTextLabelDistanceS() * cos(theta); |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
243 double oy = controller->GetAngleTopTextLabelDistanceS() * sin(theta); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
244 |
774
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
245 double pointX = center_.GetX() + ox; |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
246 double pointY = center_.GetY() + oy; |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
247 |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
248 char buf[64]; |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
249 double angleDeg = RadiansToDegrees(delta); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
250 |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
251 // http://www.ltg.ed.ac.uk/~richard/utf-8.cgi?input=00B0&mode=hex |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
252 sprintf(buf, "%0.02f\xc2\xb0", angleDeg); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
253 |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
254 SetTextLayerOutlineProperties( |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
255 GetScene(), layerHolder_, buf, ScenePoint2D(pointX, pointY)); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
256 |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
257 #if 0 |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
258 // TODO:make it togglable |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
259 bool enableInfoDisplay = false; |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
260 if (enableInfoDisplay) |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
261 { |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
262 TrackerSample_SetInfoDisplayMessage("center_.GetX()", |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
263 boost::lexical_cast<std::string>(center_.GetX())); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
264 |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
265 TrackerSample_SetInfoDisplayMessage("center_.GetY()", |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
266 boost::lexical_cast<std::string>(center_.GetY())); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
267 |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
268 TrackerSample_SetInfoDisplayMessage("side1End_.GetX()", |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
269 boost::lexical_cast<std::string>(side1End_.GetX())); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
270 |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
271 TrackerSample_SetInfoDisplayMessage("side1End_.GetY()", |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
272 boost::lexical_cast<std::string>(side1End_.GetY())); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
273 |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
274 TrackerSample_SetInfoDisplayMessage("side2End_.GetX()", |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
275 boost::lexical_cast<std::string>(side2End_.GetX())); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
276 |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
277 TrackerSample_SetInfoDisplayMessage("side2End_.GetY()", |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
278 boost::lexical_cast<std::string>(side2End_.GetY())); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
279 |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
280 TrackerSample_SetInfoDisplayMessage("p1cAngle (deg)", |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
281 boost::lexical_cast<std::string>(RadiansToDegrees(p1cAngle))); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
282 |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
283 TrackerSample_SetInfoDisplayMessage("delta (deg)", |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
284 boost::lexical_cast<std::string>(RadiansToDegrees(delta))); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
285 |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
286 TrackerSample_SetInfoDisplayMessage("theta (deg)", |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
287 boost::lexical_cast<std::string>(RadiansToDegrees(theta))); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
288 |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
289 TrackerSample_SetInfoDisplayMessage("p2cAngle (deg)", |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
290 boost::lexical_cast<std::string>(RadiansToDegrees(p2cAngle))); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
291 |
774
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
292 TrackerSample_SetInfoDisplayMessage("ox (scene)", |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
293 boost::lexical_cast<std::string>(ox)); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
294 |
774
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
295 TrackerSample_SetInfoDisplayMessage("offsetY (scene)", |
66ac7a2d1e3a
A few renames and cleanups + moved GUI constants to controller + start work on
Benjamin Golinvaux <bgo@osimis.io>
parents:
751
diff
changeset
|
296 boost::lexical_cast<std::string>(oy)); |
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 TrackerSample_SetInfoDisplayMessage("pointX", |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
299 boost::lexical_cast<std::string>(pointX)); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
300 |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
301 TrackerSample_SetInfoDisplayMessage("pointY", |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
302 boost::lexical_cast<std::string>(pointY)); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
303 |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
304 TrackerSample_SetInfoDisplayMessage("angleDeg", |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
305 boost::lexical_cast<std::string>(angleDeg)); |
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
306 } |
827
2fd96a637a59
Added FusioMpr sample + small dumb changes
Benjamin Golinvaux <bgo@osimis.io>
parents:
818
diff
changeset
|
307 #endif |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
308 } |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
309 } |
722
28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
Benjamin Golinvaux <bgo@osimis.io>
parents:
698
diff
changeset
|
310 else |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
311 { |
751
712ff6ff3c19
- undo redo now works fine for both measure tool creation commands
Benjamin Golinvaux <bgo@osimis.io>
parents:
722
diff
changeset
|
312 RemoveFromScene(); |
698
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
313 } |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
314 } |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
315 } |
8b6adfb62a2f
Code is broken -- stashing ongoing work in a branch
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
316 } |