comparison OrthancStone/Sources/Scene2DViewport/MeasureToolsToolbox.h @ 1512:244ad1e4e76a

reorganization of folders
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Jul 2020 16:21:02 +0200
parents Framework/Scene2DViewport/MeasureToolsToolbox.h@828a9b4ee1b7
children 8563ea5d8ae4
comparison
equal deleted inserted replaced
1511:9dfeee74c1e6 1512:244ad1e4e76a
1 /**
2 * Stone of Orthanc
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
6 *
7 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Affero General Public License
9 * as published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/
20
21
22 #pragma once
23
24 #include "PredeclaredTypes.h"
25 #include "../Scene2D/PolylineSceneLayer.h"
26 #include "../Scene2D/Scene2D.h"
27
28 namespace OrthancStone
29 {
30
31 /**
32 This function will create a square around the center point supplied in
33 scene coordinates, with a side length given in canvas coordinates. The
34 square sides are parallel to the canvas boundaries.
35 */
36 void AddSquare(PolylineSceneLayer::Chain& chain,
37 const Scene2D& scene,
38 const ScenePoint2D& centerS,
39 const double& sideLengthS);
40
41 /**
42 Creates an arc centered on c that goes
43 - from a point r1:
44 - so that r1 belongs to the p1,c line
45 - so that the distance from c to r1 equals radius
46 - to a point r2:
47 - so that r2 belongs to the p2,c line
48 - so that the distance from c to r2 equals radius
49 - that follows the shortest among the two possible paths
50
51 Warning: the existing chain content will be wiped out.
52 */
53 void AddShortestArc(
54 PolylineSceneLayer::Chain& chain
55 , const ScenePoint2D& p1
56 , const ScenePoint2D& c
57 , const ScenePoint2D& p2
58 , const double& radiusS
59 , const int subdivisionsCount = 63);
60
61 /**
62 Creates an arc (open curve) with "numSubdivisions" (N + 1 points) from
63 start angle to end angle, by following the shortest arc.
64
65 Warning: the existing chain content will be wiped out.
66 */
67 void AddShortestArc(
68 PolylineSceneLayer::Chain& chain
69 , const ScenePoint2D& centerS
70 , const double& radiusS
71 , const double startAngleRad
72 , const double endAngleRad
73 , const int subdivisionsCount = 63);
74
75 #if 0
76 /**
77 Creates an arc centered on c that goes
78 - from a point r1:
79 - so that r1 belongs to the p1,c line
80 - so that the distance from c to r1 equals radius
81 - to a point r2:
82 - so that r2 belongs to the p2,c line
83 - so that the distance from c to r2 equals radius
84
85 if clockwise is true, the arc is drawn from r1 to r2 with increasing
86 angle values. Otherwise, the angle values decrease.
87
88 Warning: the existing chain content will be wiped out.
89 */
90
91 void AddArc(
92 PolylineSceneLayer::Chain & chain
93 , const Scene2D & scene
94 , const ScenePoint2D & p1
95 , const ScenePoint2D & c
96 , const ScenePoint2D & p2
97 , const double& radiusS
98 , const bool clockwise
99 , const int subdivisionsCount = 63);
100
101 /**
102 Creates an arc (open curve) with "numSubdivisions" (N + 1 points) from
103 start angle to end angle with the supplied radius.
104
105 if clockwise is true, the arc is drawn from start to end by increasing the
106 angle values.
107
108 Otherwise, the angle value decreases from start to end.
109
110 Warning: the existing chain content will be wiped out.
111 */
112 void AddArc(
113 PolylineSceneLayer::Chain& chain
114 , const Scene2D& scene
115 , const ScenePoint2D& centerS
116 , const double& radiusS
117 , const double startAngleRad
118 , const double endAngleRad
119 , const bool clockwise
120 , const int subdivisionsCount = 63);
121 #endif
122 /**
123 Creates a circle (closed curve) with "numSubdivisions"
124 (N points)
125
126 Warning: the existing chain content will be wiped out.
127 */
128 void AddCircle(PolylineSceneLayer::Chain& chain,
129 const ScenePoint2D& centerS,
130 const double& radiusS,
131 const int numSubdivisions = 63);
132
133 /**
134 Adds or subtracts 2*pi as many times as need to shift the specified
135 angle to a value such as: -pi <= value < pi
136 */
137 double NormalizeAngle(double angle);
138
139 /**
140 Returns the angle magnitude between the p1,c and p2,c lines.
141 The returned angle is between 0 and 2*pi
142
143 If the angle is between 0 and pi, this means that the shortest arc
144 from p1 to p2 is clockwise.
145
146 If the angle is between pi and 2*pi, this means that the shortest arc
147 from p1 to p2 is COUNTERclockwise.
148
149 */
150 double MeasureAngle(
151 const ScenePoint2D& p1, const ScenePoint2D& c, const ScenePoint2D& p2);
152
153 /**
154 RadiansToDegrees
155 */
156 double RadiansToDegrees(double angleRad);
157
158 /**
159 This function will return the coordinates of a point that:
160 - belongs to the two bisecting lines of the p1 c p2 angle.
161 - is a distance d from c.
162 Among the four possible points, the one returned will be the one belonging
163 to the *smallest* half-plane defined by the [c,p1[ and [c,p2[ half-lines.
164 */
165 void GetPositionOnBisectingLine(
166 ScenePoint2D& result
167 , const ScenePoint2D& p1
168 , const ScenePoint2D& c
169 , const ScenePoint2D& p2
170 , const double d);
171
172
173 #if ORTHANC_STONE_ENABLE_OUTLINED_TEXT == 1
174 /**
175 This helper is used when drawing text with an outline.
176 It set the properties for several text layers at once : first the
177 four outline layers, with a position shift and then the actual main text
178 layer.
179
180 The five text layers are supposed to already exist in the scene, starting
181 from startingLayerIndex, up to (and not including) startingLayerIndex+5.
182 */
183 void SetTextLayerOutlineProperties(
184 Scene2D& scene
185 , boost::shared_ptr<LayerHolder> layerHolder
186 , const char* text
187 , ScenePoint2D p
188 , int startingLayerIndex);
189 #else
190 void SetTextLayerProperties(
191 Scene2D& scene
192 , boost::shared_ptr<LayerHolder> layerHolder
193 , const char* text
194 , ScenePoint2D p
195 , int layerIndex);
196 #endif
197
198 std::ostream& operator<<(std::ostream& os, const ScenePoint2D& p);
199 }
200