Mercurial > hg > orthanc-stone
comparison Framework/Scene2DViewport/MeasureToolsToolbox.h @ 698:8b6adfb62a2f refactor-viewport-controller
Code is broken -- stashing ongoing work in a branch
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 15 May 2019 16:56:17 +0200 |
parents | |
children | c0fcb2757b0a 712ff6ff3c19 |
comparison
equal
deleted
inserted
replaced
660:cb3b76d16234 | 698:8b6adfb62a2f |
---|---|
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-2019 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 #include <Framework/Scene2D/PolylineSceneLayer.h> | |
22 #include <Framework/Scene2D/Scene2D.h> | |
23 | |
24 namespace OrthancStone | |
25 { | |
26 | |
27 /** | |
28 This function will create a square around the center point supplied in | |
29 scene coordinates, with a side length given in canvas coordinates. The | |
30 square sides are parallel to the canvas boundaries. | |
31 */ | |
32 void AddSquare(PolylineSceneLayer::Chain& chain, | |
33 const Scene2D& scene, | |
34 const ScenePoint2D& centerS, | |
35 const double& sideLength); | |
36 | |
37 | |
38 /** | |
39 Creates an arc centered on c that goes | |
40 - from a point r1: | |
41 - so that r1 belongs to the p1,c line | |
42 - so that the distance from c to r1 equals radius | |
43 - to a point r2: | |
44 - so that r2 belongs to the p2,c line | |
45 - so that the distance from c to r2 equals radius | |
46 - that follows the shortest among the two possible paths | |
47 | |
48 Warning: the existing chain content will be wiped out. | |
49 */ | |
50 void AddShortestArc( | |
51 PolylineSceneLayer::Chain& chain | |
52 , const Scene2D& scene | |
53 , const ScenePoint2D& p1 | |
54 , const ScenePoint2D& c | |
55 , const ScenePoint2D& p2 | |
56 , const double& radiusS | |
57 , const int subdivisionsCount = 63); | |
58 | |
59 /** | |
60 Creates an arc (open curve) with "numSubdivisions" (N + 1 points) from | |
61 start angle to end angle, by following the shortest arc. | |
62 | |
63 Warning: the existing chain content will be wiped out. | |
64 */ | |
65 void AddShortestArc( | |
66 PolylineSceneLayer::Chain& chain | |
67 , const Scene2D& scene | |
68 , const ScenePoint2D& centerS | |
69 , const double& radiusS | |
70 , const double startAngleRad | |
71 , const double endAngleRad | |
72 , const int subdivisionsCount = 63); | |
73 | |
74 #if 0 | |
75 /** | |
76 Creates an arc centered on c that goes | |
77 - from a point r1: | |
78 - so that r1 belongs to the p1,c line | |
79 - so that the distance from c to r1 equals radius | |
80 - to a point r2: | |
81 - so that r2 belongs to the p2,c line | |
82 - so that the distance from c to r2 equals radius | |
83 | |
84 if clockwise is true, the arc is drawn from r1 to r2 with increasing | |
85 angle values. Otherwise, the angle values decrease. | |
86 | |
87 Warning: the existing chain content will be wiped out. | |
88 */ | |
89 | |
90 void AddArc( | |
91 PolylineSceneLayer::Chain& chain | |
92 , const Scene2D& scene | |
93 , const ScenePoint2D& p1 | |
94 , const ScenePoint2D& c | |
95 , const ScenePoint2D& p2 | |
96 , const double& radiusS | |
97 , const bool clockwise | |
98 , const int subdivisionsCount = 63); | |
99 | |
100 /** | |
101 Creates an arc (open curve) with "numSubdivisions" (N + 1 points) from | |
102 start angle to end angle with the supplied radius. | |
103 | |
104 if clockwise is true, the arc is drawn from start to end by increasing the | |
105 angle values. | |
106 | |
107 Otherwise, the angle value decreases from start to end. | |
108 | |
109 Warning: the existing chain content will be wiped out. | |
110 */ | |
111 void AddArc( | |
112 PolylineSceneLayer::Chain& chain | |
113 , const Scene2D& scene | |
114 , const ScenePoint2D& centerS | |
115 , const double& radiusS | |
116 , const double startAngleRad | |
117 , const double endAngleRad | |
118 , const bool clockwise | |
119 , const int subdivisionsCount = 63); | |
120 #endif | |
121 /** | |
122 Creates a circle (closed curve) with "numSubdivisions" | |
123 (N points) | |
124 | |
125 Warning: the existing chain content will be wiped out. | |
126 */ | |
127 void AddCircle(PolylineSceneLayer::Chain& chain, | |
128 const Scene2D& scene, | |
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 | |
152 , const ScenePoint2D& c | |
153 , const ScenePoint2D& p2); | |
154 | |
155 /** | |
156 RadiansToDegrees | |
157 */ | |
158 double RadiansToDegrees(double angleRad); | |
159 | |
160 /** | |
161 This function will return the coordinates of a point that: | |
162 - belongs to the two bisecting lines of the p1 c p2 angle. | |
163 - is a distance d from c. | |
164 Among the four possible points, the one returned will be the one belonging | |
165 to the *smallest* half-plane defined by the [c,p1[ and [c,p2[ half-lines. | |
166 */ | |
167 void GetPositionOnBisectingLine( | |
168 ScenePoint2D& result | |
169 , const ScenePoint2D& p1 | |
170 , const ScenePoint2D& c | |
171 , const ScenePoint2D& p2 | |
172 , const double d); | |
173 | |
174 | |
175 /** | |
176 This helper is used when drawing text with an outline. | |
177 It set the properties for several text layers at once : first the | |
178 four outline layers, with a position shift and then the actual main text | |
179 layer. | |
180 | |
181 The five text layers are supposed to already exist in the scene, starting | |
182 from layerIndex, up to (and not including) layerIndex+5. | |
183 */ | |
184 void SetTextLayerOutlineProperties( | |
185 Scene2D& scene, int baseLayerIndex, const char* text, ScenePoint2D p); | |
186 | |
187 } |