Mercurial > hg > orthanc-stone
comparison Framework/Scene2DViewport/MeasureToolsToolbox.h @ 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 | e42b491f1fb2 |
children | 0aff28f15ea2 |
comparison
equal
deleted
inserted
replaced
864:ae3eccd0f545 | 865:a29c13497557 |
---|---|
31 square sides are parallel to the canvas boundaries. | 31 square sides are parallel to the canvas boundaries. |
32 */ | 32 */ |
33 void AddSquare(PolylineSceneLayer::Chain& chain, | 33 void AddSquare(PolylineSceneLayer::Chain& chain, |
34 boost::shared_ptr<const Scene2D> scene, | 34 boost::shared_ptr<const Scene2D> scene, |
35 const ScenePoint2D& centerS, | 35 const ScenePoint2D& centerS, |
36 const double& sideLengthS); | 36 const double& sideLengthS); |
37 | 37 |
38 /** | 38 /** |
39 Creates an arc centered on c that goes | 39 Creates an arc centered on c that goes |
40 - from a point r1: | 40 - from a point r1: |
41 - so that r1 belongs to the p1,c line | 41 - so that r1 belongs to the p1,c line |
46 - that follows the shortest among the two possible paths | 46 - that follows the shortest among the two possible paths |
47 | 47 |
48 Warning: the existing chain content will be wiped out. | 48 Warning: the existing chain content will be wiped out. |
49 */ | 49 */ |
50 void AddShortestArc( | 50 void AddShortestArc( |
51 PolylineSceneLayer::Chain& chain | 51 PolylineSceneLayer::Chain& chain |
52 , const ScenePoint2D& p1 | 52 , const ScenePoint2D& p1 |
53 , const ScenePoint2D& c | 53 , const ScenePoint2D& c |
54 , const ScenePoint2D& p2 | 54 , const ScenePoint2D& p2 |
55 , const double& radiusS | 55 , const double& radiusS |
56 , const int subdivisionsCount = 63); | 56 , const int subdivisionsCount = 63); |
57 | 57 |
58 /** | 58 /** |
59 Creates an arc (open curve) with "numSubdivisions" (N + 1 points) from | 59 Creates an arc (open curve) with "numSubdivisions" (N + 1 points) from |
60 start angle to end angle, by following the shortest arc. | 60 start angle to end angle, by following the shortest arc. |
61 | 61 |
62 Warning: the existing chain content will be wiped out. | 62 Warning: the existing chain content will be wiped out. |
63 */ | 63 */ |
64 void AddShortestArc( | 64 void AddShortestArc( |
65 PolylineSceneLayer::Chain& chain | 65 PolylineSceneLayer::Chain& chain |
66 , const ScenePoint2D& centerS | 66 , const ScenePoint2D& centerS |
67 , const double& radiusS | 67 , const double& radiusS |
68 , const double startAngleRad | 68 , const double startAngleRad |
69 , const double endAngleRad | 69 , const double endAngleRad |
70 , const int subdivisionsCount = 63); | 70 , const int subdivisionsCount = 63); |
71 | 71 |
72 #if 0 | 72 #if 0 |
77 - so that the distance from c to r1 equals radius | 77 - so that the distance from c to r1 equals radius |
78 - to a point r2: | 78 - to a point r2: |
79 - so that r2 belongs to the p2,c line | 79 - so that r2 belongs to the p2,c line |
80 - so that the distance from c to r2 equals radius | 80 - so that the distance from c to r2 equals radius |
81 | 81 |
82 if clockwise is true, the arc is drawn from r1 to r2 with increasing | 82 if clockwise is true, the arc is drawn from r1 to r2 with increasing |
83 angle values. Otherwise, the angle values decrease. | 83 angle values. Otherwise, the angle values decrease. |
84 | 84 |
85 Warning: the existing chain content will be wiped out. | 85 Warning: the existing chain content will be wiped out. |
86 */ | 86 */ |
87 | 87 |
88 void AddArc( | 88 void AddArc( |
89 PolylineSceneLayer::Chain& chain | 89 PolylineSceneLayer::Chain & chain |
90 , const Scene2D& scene | 90 , const Scene2D & scene |
91 , const ScenePoint2D& p1 | 91 , const ScenePoint2D & p1 |
92 , const ScenePoint2D& c | 92 , const ScenePoint2D & c |
93 , const ScenePoint2D& p2 | 93 , const ScenePoint2D & p2 |
94 , const double& radiusS | 94 , const double& radiusS |
95 , const bool clockwise | 95 , const bool clockwise |
96 , const int subdivisionsCount = 63); | 96 , const int subdivisionsCount = 63); |
97 | 97 |
98 /** | 98 /** |
99 Creates an arc (open curve) with "numSubdivisions" (N + 1 points) from | 99 Creates an arc (open curve) with "numSubdivisions" (N + 1 points) from |
100 start angle to end angle with the supplied radius. | 100 start angle to end angle with the supplied radius. |
101 | 101 |
102 if clockwise is true, the arc is drawn from start to end by increasing the | 102 if clockwise is true, the arc is drawn from start to end by increasing the |
103 angle values. | 103 angle values. |
104 | 104 |
105 Otherwise, the angle value decreases from start to end. | 105 Otherwise, the angle value decreases from start to end. |
106 | 106 |
107 Warning: the existing chain content will be wiped out. | 107 Warning: the existing chain content will be wiped out. |
108 */ | 108 */ |
109 void AddArc( | 109 void AddArc( |
110 PolylineSceneLayer::Chain& chain | 110 PolylineSceneLayer::Chain& chain |
111 , const Scene2D& scene | 111 , const Scene2D& scene |
112 , const ScenePoint2D& centerS | 112 , const ScenePoint2D& centerS |
113 , const double& radiusS | 113 , const double& radiusS |
114 , const double startAngleRad | 114 , const double startAngleRad |
115 , const double endAngleRad | 115 , const double endAngleRad |
116 , const bool clockwise | 116 , const bool clockwise |
117 , const int subdivisionsCount = 63); | 117 , const int subdivisionsCount = 63); |
118 #endif | 118 #endif |
121 (N points) | 121 (N points) |
122 | 122 |
123 Warning: the existing chain content will be wiped out. | 123 Warning: the existing chain content will be wiped out. |
124 */ | 124 */ |
125 void AddCircle(PolylineSceneLayer::Chain& chain, | 125 void AddCircle(PolylineSceneLayer::Chain& chain, |
126 const Scene2D& scene, | 126 const Scene2D& scene, |
127 const ScenePoint2D& centerS, | 127 const ScenePoint2D& centerS, |
128 const double& radiusS, | 128 const double& radiusS, |
129 const int numSubdivisions = 63); | 129 const int numSubdivisions = 63); |
130 | 130 |
131 /** | 131 /** |
132 Adds or subtracts 2*pi as many times as need to shift the specified | 132 Adds or subtracts 2*pi as many times as need to shift the specified |
133 angle to a value such as: -pi <= value < pi | 133 angle to a value such as: -pi <= value < pi |
134 */ | 134 */ |
135 double NormalizeAngle(double angle); | 135 double NormalizeAngle(double angle); |
136 | 136 |
137 /** | 137 /** |
138 Returns the angle magnitude between the p1,c and p2,c lines. | 138 Returns the angle magnitude between the p1,c and p2,c lines. |
139 The returned angle is between 0 and 2*pi | 139 The returned angle is between 0 and 2*pi |
140 | 140 |
141 If the angle is between 0 and pi, this means that the shortest arc | 141 If the angle is between 0 and pi, this means that the shortest arc |
142 from p1 to p2 is clockwise. | 142 from p1 to p2 is clockwise. |
143 | 143 |
144 If the angle is between pi and 2*pi, this means that the shortest arc | 144 If the angle is between pi and 2*pi, this means that the shortest arc |
145 from p1 to p2 is COUNTERclockwise. | 145 from p1 to p2 is COUNTERclockwise. |
146 | 146 |
147 */ | 147 */ |
148 double MeasureAngle( | 148 double MeasureAngle( |
149 const ScenePoint2D& p1 | 149 const ScenePoint2D& p1 |
150 , const ScenePoint2D& c | 150 , const ScenePoint2D& c |
151 , const ScenePoint2D& p2); | 151 , const ScenePoint2D& p2); |
152 | 152 |
153 /** | 153 /** |
154 RadiansToDegrees | 154 RadiansToDegrees |
161 - is a distance d from c. | 161 - is a distance d from c. |
162 Among the four possible points, the one returned will be the one belonging | 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. | 163 to the *smallest* half-plane defined by the [c,p1[ and [c,p2[ half-lines. |
164 */ | 164 */ |
165 void GetPositionOnBisectingLine( | 165 void GetPositionOnBisectingLine( |
166 ScenePoint2D& result | 166 ScenePoint2D& result |
167 , const ScenePoint2D& p1 | 167 , const ScenePoint2D& p1 |
168 , const ScenePoint2D& c | 168 , const ScenePoint2D& c |
169 , const ScenePoint2D& p2 | 169 , const ScenePoint2D& p2 |
170 , const double d); | 170 , const double d); |
171 | 171 |
172 | 172 |
173 /** | 173 /** |
174 This helper is used when drawing text with an outline. | 174 This helper is used when drawing text with an outline. |
175 It set the properties for several text layers at once : first the | 175 It set the properties for several text layers at once : first the |
176 four outline layers, with a position shift and then the actual main text | 176 four outline layers, with a position shift and then the actual main text |
177 layer. | 177 layer. |
178 | 178 |
179 The five text layers are supposed to already exist in the scene, starting | 179 The five text layers are supposed to already exist in the scene, starting |
180 from layerIndex, up to (and not including) layerIndex+5. | 180 from layerIndex, up to (and not including) layerIndex+5. |
181 */ | 181 */ |
182 void SetTextLayerOutlineProperties( | 182 void SetTextLayerOutlineProperties( |
183 boost::shared_ptr<Scene2D> scene, boost::shared_ptr<LayerHolder> layerHolder, | 183 boost::shared_ptr<Scene2D> scene, boost::shared_ptr<LayerHolder> layerHolder, |
184 const char* text, ScenePoint2D p); | 184 const char* text, ScenePoint2D p); |
185 | |
186 | |
187 std::ostream& operator<<(std::ostream& os, const ScenePoint2D& p); | |
185 } | 188 } |
189 |