60bf98ae |
1 | // Created on: 2013-11-11 |
2 | // Created by: Anastasia BORISOVA |
3 | // Copyright (c) 2013 OPEN CASCADE SAS |
a6eb515f |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
a6eb515f |
6 | // |
973c2be1 |
7 | // This library is free software; you can redistribute it and / or modify it |
8 | // under the terms of the GNU Lesser General Public version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
a6eb515f |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
a6eb515f |
15 | |
60bf98ae |
16 | #ifndef _AIS_Dimension_HeaderFile |
17 | #define _AIS_Dimension_HeaderFile |
a6eb515f |
18 | |
fe83e1ea |
19 | #include <AIS_DimensionSelectionMode.hxx> |
62b6361a |
20 | #include <AIS_DimensionOwner.hxx> |
a6eb515f |
21 | #include <AIS_DisplaySpecialSymbol.hxx> |
22 | #include <AIS_InteractiveObject.hxx> |
23 | #include <AIS_KindOfInteractive.hxx> |
24 | #include <AIS_KindOfDimension.hxx> |
25 | #include <AIS_KindOfSurface.hxx> |
60bf98ae |
26 | #include <AIS_Drawer.hxx> |
a6eb515f |
27 | #include <Geom_Curve.hxx> |
28 | #include <gp_Pln.hxx> |
29 | #include <Prs3d_ArrowAspect.hxx> |
30 | #include <Prs3d_DimensionAspect.hxx> |
60bf98ae |
31 | #include <Prs3d_DimensionUnits.hxx> |
a6eb515f |
32 | #include <Prs3d_LineAspect.hxx> |
33 | #include <Prs3d_Presentation.hxx> |
34 | #include <Prs3d_TextAspect.hxx> |
a6eb515f |
35 | #include <Select3D_ListOfSensitive.hxx> |
36 | #include <SelectMgr_EntityOwner.hxx> |
37 | #include <Standard.hxx> |
38 | #include <TCollection_ExtendedString.hxx> |
fe83e1ea |
39 | #include <TColgp_HSequenceOfPnt.hxx> |
a6eb515f |
40 | #include <TopoDS_Face.hxx> |
41 | #include <TopoDS_Shape.hxx> |
fe83e1ea |
42 | #include <NCollection_Sequence.hxx> |
43 | #include <NCollection_Handle.hxx> |
a6eb515f |
44 | |
45 | DEFINE_STANDARD_HANDLE(AIS_Dimension, AIS_InteractiveObject) |
46 | |
60bf98ae |
47 | //! AIS_Dimension is a base class for 2D presentations of linear (length, diameter, radius) |
48 | //! and angular dimensions. |
49 | //! |
50 | //! The dimensions provide measurement of quantities, such as lengths or plane angles. |
51 | //! The measurement of dimension "value" is done in model space "as is". |
52 | //! These "value" are said to be represented in "model units", which can be specified by user. |
53 | //! During the display the measured value converted from "model units" to "display units". |
54 | //! The display and model units are stored in common Prs3d_Drawer (drawer of the context) |
55 | //! to share it between all dimensions. |
56 | //! The specified by user units are stored in the dimension's drawer. |
57 | //! |
58 | //! As a drawing, the dimension is composed from the following components: |
59 | //! - Attachement (binding) points. The points where the dimension lines attaches to, for |
60 | //! length dimensions the distances are measured between these points. |
61 | //! - Main dimension line. The which extends from the attachement points in "up" direction, |
62 | //! and which contains text label on it with value string. |
63 | //! - Flyouts. The lines connecting the attachement points with main dimension line. |
64 | //! - Extension. The lines used to extend the main dimension line in the cases when text |
65 | //! or arrows do not fit into the main dimension line due to their size. |
66 | //! - Arrows. |
67 | //! |
68 | //! <pre> |
69 | //! Linear dimensions: |
70 | //! |
71 | //! extension |
72 | //! line arrow |
73 | //! -->|------- main dimension line -------|<-- |
74 | //! | | |
75 | //! |flyout flyout| |
76 | //! | | |
77 | //! +-----------------------------------+ |
78 | //! attachement attachement |
79 | //! point point |
80 | //! |
81 | //! Angular dimensions: |
82 | //! |
83 | //! extension |
84 | //! line |
85 | //! -->|+++++ |
86 | //! arrow | +++ |
87 | //! | 90(deg) - main dimension line |
88 | //! flyout | +++ |
89 | //! | + |
90 | //! o---flyout--- |
91 | //! center ^ |
92 | //! point | extension |
93 | //! line |
94 | //! </pre> |
95 | //! |
96 | //! Being a 2D drawings, the dimensions are created on imaginary plane, called "dimension plane", |
97 | //! which can be thought of as reference system of axes (X,Y,N) for constructing the presentation. |
98 | //! |
99 | //! The role of axes of the dimension plane is to guide you through the encapsualted automations |
100 | //! of presentation building to help you understand how is the presentation will look and how it |
101 | //! will be oriented in model space during construction. |
102 | //! |
103 | //! Orientation of dimension line in model space relatively to the base shapes is defined |
104 | //! with the flyouts. Flyouts specify length of flyout lines and their orientation relatively |
105 | //! to the attachment points on the working plane. |
106 | //! For linear dimensions: |
107 | //! Direction of flyouts is specified with direction of main dimension line |
108 | //! (vector from the first attachment to the second attachment) and the normal of the dimension plane. |
109 | //! Positive direction of flyouts is defined by vector multiplication: AttachVector * PlaneNormal. |
110 | //! For angular dimensions: |
111 | //! Flyouts are defined by vectors from the center point to the attachment points. |
112 | //! These vectors directions are supposed to be the positive directions of flyouts. |
113 | //! Negative flyouts directions means that these vectors should be reversed |
114 | //! (and dimension will be built out of the angle constructed with center and two attach points). |
115 | //! |
116 | //! The dimension plane can be constructed automatically by application (where possible, |
117 | //! it depends on the measured geometry). |
118 | //! It can be also set by user. However, if the user-defined plane does not fit the |
119 | //! geometry of the dimension (attach points do not belong to it), the dimension could not |
120 | //! be built. |
121 | //! If it is not possible to compute automatic plane (for example, in case of length between |
122 | //! two points) the user is supposed to specify the custom plane. |
123 | //! |
124 | //! Since the dimensions feature automated construction procedures from an arbitrary shapes, |
125 | //! the interfaces to check the validness are also implemented. Once the measured geometry is |
126 | //! specified, the one can inquire the validness status by calling "IsValid()" method. If the result |
127 | //! is TRUE, then all of public parameters should be pre-computed and ready. The presentation |
128 | //! should be also computable. Otherwise, the parameters may return invalid values. In this case, |
129 | //! the presentation will not be computed and displayed. |
130 | //! |
131 | //! The dimension support two local selection modes: main dimension line selection and text label |
132 | //! selection. These modes can be used to develop interactive modification of dimension presentations. |
133 | //! The component hilighting in these selection modes is provided by AIS_DimensionOwner class. |
134 | //! Please note that selection is unavailable until the presentation is computed. |
135 | //! |
136 | //! The specific drawing attributes are controlled through Prs3d_DimensionAspect. The one can change |
137 | //! color, arrows, text and arrow style and specify positioning of value label by setting corresponding |
138 | //! values to the aspect. |
139 | //! |
a6eb515f |
140 | class AIS_Dimension : public AIS_InteractiveObject |
141 | { |
d7bffd44 |
142 | protected: |
143 | |
60bf98ae |
144 | //! Geometry type defines type of shapes on which the dimension is to be built. |
145 | //! Some type of geometry allows automatical plane computing and |
146 | //! can be built without user-defined plane |
147 | //! Another types can't be built without user-defined plane. |
148 | enum GeometryType |
149 | { |
150 | GeometryType_UndefShapes, |
151 | GeometryType_Edge, |
152 | GeometryType_Face, |
153 | GeometryType_Points, |
154 | GeometryType_Edges, |
155 | GeometryType_Faces, |
156 | GeometryType_EdgeFace, |
157 | GeometryType_EdgeVertex |
158 | }; |
159 | |
160 | //! Specifies supported at base level horizontal and vertical |
161 | //! label positions for drawing extension lines and centered text. |
d7bffd44 |
162 | enum LabelPosition |
163 | { |
164 | LabelPosition_None = 0x00, |
165 | |
166 | LabelPosition_Left = 0x01, |
167 | LabelPosition_Right = 0x02, |
168 | LabelPosition_HCenter = 0x04, |
60bf98ae |
169 | LabelPosition_HMask = LabelPosition_Left | LabelPosition_Right | LabelPosition_HCenter, |
d7bffd44 |
170 | |
171 | LabelPosition_Above = 0x10, |
172 | LabelPosition_Below = 0x20, |
173 | LabelPosition_VCenter = 0x40, |
60bf98ae |
174 | LabelPosition_VMask = LabelPosition_Above | LabelPosition_Below | LabelPosition_VCenter |
d7bffd44 |
175 | }; |
176 | |
fe83e1ea |
177 | public: |
178 | |
179 | //! Specifies supported presentation compute modes. |
180 | //! Used to compute only parts of presentation for |
181 | //! advanced highlighting. |
182 | enum ComputeMode |
183 | { |
184 | ComputeMode_All = 0, //!< "0" is reserved as neutral mode |
185 | ComputeMode_Line = 1, //!< corresponds to selection mode |
186 | ComputeMode_Text = 2 //!< corresponds to selection mode |
187 | }; |
188 | |
a6eb515f |
189 | public: |
d7bffd44 |
190 | |
60bf98ae |
191 | //! Constructor with default parameters values. |
192 | //! @param theType [in] the type of dimension. |
193 | Standard_EXPORT AIS_Dimension (const AIS_KindOfDimension theType); |
a6eb515f |
194 | |
60bf98ae |
195 | //! Gets dimension measurement value. If the value to display is not |
196 | //! specified by user, then the dimension object is responsible to |
197 | //! compute it on its own in model space coordinates. |
198 | //! @return the dimension value (in model units) which is used |
199 | //! during display of the presentation. |
200 | Standard_Real GetValue() const |
201 | { |
202 | return myIsValueCustom ? myCustomValue : ComputeValue(); |
203 | } |
a6eb515f |
204 | |
60bf98ae |
205 | //! Sets user-defined dimension value. |
206 | //! The user-defined dimension value is specified in model space, |
207 | //! and affect by unit conversion during the display. |
208 | //! @param theValue [in] the user-defined value to display. |
209 | Standard_EXPORT void SetCustomValue (const Standard_Real theValue); |
210 | |
211 | //! Get the dimension plane in which the 2D dimension presentation is computed. |
212 | //! By default, if plane is not defined by user, it is computed automatically |
213 | //! after dimension geometry is computed. |
214 | //! If computed dimension geometry (points) can't be placed on the user-defined |
215 | //! plane, dimension geometry was set as unvalid (validity flag is set to false) |
216 | //! and dimension presentation wil not be computed. |
217 | //! If user-defined plane allow geometry placement on it, it will be used for |
218 | //! computing of the dimension presentation. |
219 | //! @return dimension plane used for presentation computing. |
220 | Standard_EXPORT const gp_Pln& GetPlane() const; |
221 | |
222 | //! Geometry type defines type of shapes on which the dimension is to be built. |
223 | //! @return type of geometry on which the dimension will be built. |
224 | Standard_EXPORT const Standard_Integer GetGeometryType () const; |
225 | |
226 | //! Sets user-defined plane where the 2D dimension presentation will be placed. |
227 | //! Checks validity of this plane if geometry has been set already. |
228 | //! Validity of the plane is checked according to the geometry set |
229 | //! and has different criteria for different kinds of dimensions. |
230 | Standard_EXPORT virtual void SetCustomPlane (const gp_Pln& thePlane); |
231 | |
232 | //! Unsets user-defined plane. Therefore the plane for dimension will be |
233 | //! computed automatically. |
234 | Standard_EXPORT void UnsetCustomPlane() { myIsPlaneCustom = Standard_False; } |
a6eb515f |
235 | |
60bf98ae |
236 | public: |
a6eb515f |
237 | |
238 | //! Gets the dimension aspect from AIS object drawer. |
239 | //! Dimension aspect contains aspects of line, text and arrows for dimension presentation. |
60bf98ae |
240 | Handle(Prs3d_DimensionAspect) DimensionAspect() const |
241 | { |
242 | return myDrawer->DimensionAspect(); |
243 | } |
a6eb515f |
244 | |
60bf98ae |
245 | //! Sets new dimension aspect for the interactive object drawer. |
246 | //! The dimension aspect provides dynamic properties which are generally |
247 | //! used during computation of dimension presentations. |
248 | Standard_EXPORT void SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theDimensionAspect); |
a6eb515f |
249 | |
60bf98ae |
250 | //! @return the kind of dimension. |
251 | AIS_KindOfDimension KindOfDimension() const |
252 | { |
253 | return myKindOfDimension; |
254 | } |
a6eb515f |
255 | |
60bf98ae |
256 | //! @return the kind of interactive. |
257 | virtual AIS_KindOfInteractive Type() const |
258 | { |
259 | return AIS_KOI_Relation; |
260 | } |
a6eb515f |
261 | |
262 | //! Returns true if the class of objects accepts the display mode theMode. |
60bf98ae |
263 | //! The interactive context can have a default mode of representation for |
264 | //! the set of Interactive Objects. This mode may not be accepted by object. |
265 | virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const |
266 | { |
267 | return theMode == ComputeMode_All; |
268 | } |
d7bffd44 |
269 | |
60bf98ae |
270 | public: |
d7bffd44 |
271 | |
60bf98ae |
272 | //! @return dimension special symbol display options. |
273 | AIS_DisplaySpecialSymbol DisplaySpecialSymbol() const |
274 | { |
275 | return myDisplaySpecialSymbol; |
276 | } |
d7bffd44 |
277 | |
60bf98ae |
278 | //! Specifies whether to display special symbol or not. |
279 | Standard_EXPORT void SetDisplaySpecialSymbol (const AIS_DisplaySpecialSymbol theDisplaySpecSymbol); |
d7bffd44 |
280 | |
60bf98ae |
281 | //! @return special symbol. |
282 | Standard_ExtCharacter SpecialSymbol() const |
283 | { |
284 | return mySpecialSymbol; |
285 | } |
d7bffd44 |
286 | |
60bf98ae |
287 | //! Specifies special symbol. |
288 | Standard_EXPORT void SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymbol); |
d7bffd44 |
289 | |
60bf98ae |
290 | Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits() const; |
d7bffd44 |
291 | |
60bf98ae |
292 | Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const; |
d7bffd44 |
293 | |
60bf98ae |
294 | Standard_EXPORT virtual void SetDisplayUnits (const TCollection_AsciiString& /*theUnits*/) { } |
d7bffd44 |
295 | |
60bf98ae |
296 | Standard_EXPORT virtual void SetModelUnits (const TCollection_AsciiString& /*theUnits*/) { } |
d7bffd44 |
297 | |
60bf98ae |
298 | public: |
d7bffd44 |
299 | |
60bf98ae |
300 | //! Returns selection tolerance for text2d: |
301 | //! For 2d text selection detection sensitive point with tolerance is used |
302 | //! Important! Only for 2d text. |
303 | Standard_Real SelToleranceForText2d() const |
304 | { |
305 | return mySelToleranceForText2d; |
306 | } |
d7bffd44 |
307 | |
a6eb515f |
308 | //! Sets selection tolerance for text2d: |
309 | //! For 2d text selection detection sensitive point with tolerance is used |
310 | //! to change this tolerance use this method |
60bf98ae |
311 | //! Important! Only for 2d text. |
312 | Standard_EXPORT void SetSelToleranceForText2d (const Standard_Real theTol); |
d7bffd44 |
313 | |
60bf98ae |
314 | //! @return flyout value for dimension. |
315 | Standard_Real GetFlyout() const |
316 | { |
317 | return myFlyout; |
318 | } |
d7bffd44 |
319 | |
60bf98ae |
320 | //! Sets flyout value for dimension. |
62b6361a |
321 | Standard_EXPORT void SetFlyout (const Standard_Real theFlyout); |
d7bffd44 |
322 | |
60bf98ae |
323 | //! Check that the input geometry for dimension is valid and the |
324 | //! presentation can be succesfully computed. |
325 | //! @return TRUE if dimension geometry is ok. |
326 | Standard_Boolean IsValid() const |
d7bffd44 |
327 | { |
60bf98ae |
328 | return myIsValid; |
d7bffd44 |
329 | } |
330 | |
331 | public: |
a6eb515f |
332 | |
333 | DEFINE_STANDARD_RTTI(AIS_Dimension) |
334 | |
335 | protected: |
d7bffd44 |
336 | |
60bf98ae |
337 | Standard_EXPORT Standard_Real ValueToDisplayUnits() const; |
a6eb515f |
338 | |
60bf98ae |
339 | //! Get formatted value string and its model space width. |
340 | //! @param theWidth [out] the model space with of the string. |
341 | //! @return formatted dimension value string. |
342 | Standard_EXPORT TCollection_ExtendedString GetValueString (Standard_Real& theWidth) const; |
a6eb515f |
343 | |
344 | //! Performs drawing of 2d or 3d arrows on the working plane |
60bf98ae |
345 | //! @param theLocation [in] the location of the arrow tip. |
346 | //! @param theDirection [in] the direction from the tip to the bottom of the arrow. |
347 | Standard_EXPORT void DrawArrow (const Handle(Prs3d_Presentation)& thePresentation, |
a6eb515f |
348 | const gp_Pnt& theLocation, |
349 | const gp_Dir& theDirection); |
350 | |
351 | //! Performs drawing of 2d or 3d text on the working plane |
60bf98ae |
352 | //! @param theTextPos [in] the position of the text label. |
353 | //! @param theTestDir [in] the direction of the text label. |
354 | //! @param theText [in] the text label string. |
355 | //! @param theLabelPosition [in] the text label vertical and horizontal positioning option |
356 | //! respectively to the main dimension line. |
a6eb515f |
357 | //! @return text width relative to the dimension working plane. For 2d text this value will be zero. |
60bf98ae |
358 | Standard_EXPORT void DrawText (const Handle(Prs3d_Presentation)& thePresentation, |
fe83e1ea |
359 | const gp_Pnt& theTextPos, |
360 | const gp_Dir& theTextDir, |
361 | const TCollection_ExtendedString& theText, |
362 | const Standard_Integer theLabelPosition); |
a6eb515f |
363 | |
364 | //! Performs computing of dimension linear extension with text |
d7bffd44 |
365 | //! @param thePresentation [in] the presentation to fill with graphical primitives. |
366 | //! @param theExtensionSize [in] the size of extension line. |
367 | //! @param theExtensionStart [in] the point where extension line connects to dimension. |
368 | //! @param theExtensionDir [in] the direction of extension line. |
fe83e1ea |
369 | //! @param theLabelString [in] the string with value. |
370 | //! @param theLabelWidth [in] the geometrical width computed for value string. |
d7bffd44 |
371 | //! @param theMode [in] the display mode. |
372 | //! @param theLabelPosition [in] position flags for the text label. |
60bf98ae |
373 | Standard_EXPORT void DrawExtension (const Handle(Prs3d_Presentation)& thePresentation, |
d7bffd44 |
374 | const Standard_Real theExtensionSize, |
375 | const gp_Pnt& theExtensionStart, |
376 | const gp_Dir& theExtensionDir, |
fe83e1ea |
377 | const TCollection_ExtendedString& theLabelString, |
378 | const Standard_Real theLabelWidth, |
379 | const Standard_Integer theMode, |
d7bffd44 |
380 | const Standard_Integer theLabelPosition); |
a6eb515f |
381 | |
60bf98ae |
382 | //! Performs computing of linear dimension (for length, diameter, radius and so on). |
383 | //! Please note that this method uses base dimension properties, like working plane |
384 | //! flyout length, drawer attributes. |
385 | //! @param thePresentation [in] the presentation to fill with primitives. |
386 | //! @param theMode [in] the presentation compute mode. |
387 | //! @param theFirstPoint [in] the first attach point of linear dimension. |
388 | //! @param theSecondPoint [in] the second attach point of linear dimension. |
389 | //! @param theIsOneSide [in] specifies whether the dimension has only one flyout line. |
390 | Standard_EXPORT void DrawLinearDimension (const Handle(Prs3d_Presentation)& thePresentation, |
fe83e1ea |
391 | const Standard_Integer theMode, |
60bf98ae |
392 | const gp_Pnt& theFirstPoint, |
393 | const gp_Pnt& theSecondPoint, |
394 | const Standard_Boolean theIsOneSide = Standard_False); |
395 | |
396 | //! Compute selection sensitives for linear dimension flyout lines (length, diameter, radius). |
397 | //! Please note that this method uses base dimension properties: working plane and flyout length. |
398 | //! @param theSelection [in] the selection structure to fill with selection primitives. |
399 | //! @param theOwner [in] the selection entity owner. |
400 | //! @param theFirstPoint [in] the first attach point of linear dimension. |
401 | //! @param theSecondPoint [in] the second attach point of linear dimension. |
402 | Standard_EXPORT void ComputeLinearFlyouts (const Handle(SelectMgr_Selection)& theSelection, |
403 | const Handle(SelectMgr_EntityOwner)& theOwner, |
404 | const gp_Pnt& theFirstPoint, |
405 | const gp_Pnt& theSecondPoint); |
406 | |
407 | //! If it is possible extracts circle from planar face. |
408 | //! @param theFace [in] the planar face. |
409 | //! @param theCurve [out] the circular curve. |
410 | //! @param theFirstPoint [out] the point of the first parameter of the circlular curve. |
411 | //! @param theSecondPoint [out] the point of the last parameter of the circlular curve. |
412 | //! @return TRUE in case of successful circle extraction. |
413 | Standard_EXPORT Standard_Boolean CircleFromPlanarFace (const TopoDS_Face& theFace, |
a6eb515f |
414 | Handle(Geom_Curve)& theCurve, |
60bf98ae |
415 | gp_Pnt& theFirstPoint, |
416 | gp_Pnt& theLastPoint); |
417 | |
418 | //! Performs initialization of circle and middle arc point from the passed |
419 | //! shape which is assumed to contain circular geometry. |
420 | //! @param theShape [in] the shape to explore. |
421 | //! @param theCircle [out] the circle geometry. |
422 | //! @param theMiddleArcPoint [out] the middle point of the arc. |
423 | //! @param theIsClosed [out] returns TRUE if the geometry is closed circle. |
424 | //! @return TRUE if the the circle is successfully got from the input shape. |
425 | Standard_EXPORT Standard_Boolean InitCircularDimension (const TopoDS_Shape& theShape, |
426 | gp_Circ& theCircle, |
427 | gp_Pnt& theMiddleArcPoint, |
428 | Standard_Boolean& theIsClosed); |
429 | |
430 | protected: //! @name Behavior to implement |
431 | |
432 | //! Override this method to compute automatically dimension plane |
433 | //! in which the dimension presentation is built. |
434 | virtual void ComputePlane() { } |
435 | |
436 | //! Override this method to check if user-defined plane |
437 | //! is valid for the dimension geometry. |
438 | //! @param thePlane [in] the working plane for positioning every |
439 | //! dimension in the application. |
440 | //! @return true is the plane is suitable for building dimension |
441 | //! with computed dimension geometry. |
442 | virtual Standard_Boolean CheckPlane (const gp_Pln& /*thePlane*/) const { return Standard_True; } |
443 | |
444 | //! Override this method to computed value of dimension. |
445 | //! @return value from the measured geometry. |
446 | virtual Standard_Real ComputeValue() const |
447 | { |
448 | return 0.0; |
449 | } |
a6eb515f |
450 | |
60bf98ae |
451 | //! Override this method to compute selection primitives for |
452 | //! flyout lines (if the dimension provides it). |
453 | //! This callback is a only a part of base selection |
454 | //! computation routine. |
455 | virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)&, |
456 | const Handle(SelectMgr_EntityOwner)&) {} |
fe83e1ea |
457 | |
458 | //! Produce points for triangular arrow face. |
459 | //! @param thePeakPnt [in] the arrow peak position. |
460 | //! @param theDirection [in] the arrow direction. |
461 | //! @param thePlane [in] the face plane. |
462 | //! @param theArrowLength [in] the length of arrow. |
463 | //! @param theArrowAngle [in] the angle of arrow. |
464 | //! @param thePeakPnt [in] the arrow peak point. |
465 | //! @param theSidePnt1 [in] the first side point. |
466 | //! @param theSidePnt2 [in] the second side point. |
467 | Standard_EXPORT void PointsForArrow (const gp_Pnt& thePeakPnt, |
468 | const gp_Dir& theDirection, |
469 | const gp_Dir& thePlane, |
470 | const Standard_Real theArrowLength, |
471 | const Standard_Real theArrowAngle, |
472 | gp_Pnt& theSidePnt1, |
473 | gp_Pnt& theSidePnt2); |
a6eb515f |
474 | |
60bf98ae |
475 | //! Base procedure of computing selection (based on selection geometry data). |
476 | //! @param theSelection [in] the selection structure to will with primitives. |
477 | //! @param theMode [in] the selection mode. |
478 | Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, |
479 | const Standard_Integer theMode); |
a6eb515f |
480 | |
fe83e1ea |
481 | protected: //! @name Selection geometry |
a6eb515f |
482 | |
fe83e1ea |
483 | //! Selection geometry of dimension presentation. The structure is filled with data |
484 | //! during compute of presentation, then this data is used to generate selection |
485 | //! sensitives when computing selection. |
486 | struct SelectionGeometry |
a6eb515f |
487 | { |
fe83e1ea |
488 | //! Arrows are represented by directed triangles. |
489 | struct Arrow |
490 | { |
491 | gp_Pnt Position; |
492 | gp_Dir Direction; |
493 | }; |
494 | typedef NCollection_Sequence<gp_Pnt> Curve; |
495 | typedef NCollection_Handle<Curve> HCurve; |
496 | typedef NCollection_Handle<Arrow> HArrow; |
497 | typedef NCollection_Sequence<HCurve> SeqOfCurves; |
498 | typedef NCollection_Sequence<HArrow> SeqOfArrows; |
499 | |
500 | gp_Pnt TextPos; //!< Center of text label. |
501 | gp_Dir TextDir; //!< Direction of text label. |
502 | Standard_Real TextWidth; //!< Width of text label. |
503 | Standard_Real TextHeight; //!< Height of text label. |
504 | SeqOfCurves DimensionLine; //!< Sequence of points for composing the segments of dimension line. |
505 | SeqOfArrows Arrows; //!< Sequence of arrow geometries. |
506 | |
507 | public: |
508 | |
509 | //! Clear geometry of sensitives for the specified compute mode. |
510 | //! @param theMode [in] the compute mode to clear. |
511 | void Clear (const Standard_Integer theMode) |
512 | { |
513 | if (theMode == ComputeMode_All || theMode == ComputeMode_Line) |
514 | { |
515 | DimensionLine.Clear(); |
516 | Arrows.Clear(); |
517 | } |
518 | |
519 | if (theMode == ComputeMode_All || theMode == ComputeMode_Text) |
520 | { |
521 | TextPos = gp::Origin(); |
522 | TextDir = gp::DX(); |
523 | TextWidth = 0.0; |
524 | TextHeight = 0.0; |
525 | } |
526 | } |
527 | |
528 | //! Add new curve entry and return the referenece to populate it. |
529 | Curve& NewCurve() |
530 | { |
531 | DimensionLine.Append( new Curve ); |
532 | HCurve& aLastCurve = DimensionLine.ChangeLast(); |
533 | return *aLastCurve; |
534 | } |
535 | |
536 | //! Add new arrow entry and return the referenece to populate it. |
537 | Arrow& NewArrow() |
538 | { |
539 | Arrows.Append( new Arrow ); |
540 | HArrow& aLastArrow = Arrows.ChangeLast(); |
541 | return *aLastArrow; |
542 | } |
543 | } mySelectionGeom; |
544 | |
545 | Standard_Real mySelToleranceForText2d; //!< Sensitive point tolerance for 2d text selection. |
546 | Standard_Boolean myIsComputed; //!< Shows if the presentation and selection was computed. |
d7bffd44 |
547 | |
60bf98ae |
548 | protected: //! @name Value properties |
d7bffd44 |
549 | |
60bf98ae |
550 | Standard_Real myCustomValue; //!< Value of the dimension (computed or user-defined). |
551 | Standard_Boolean myIsValueCustom; //!< Is user-defined value. |
d7bffd44 |
552 | |
60bf98ae |
553 | protected: //! @name Units properties |
d7bffd44 |
554 | |
60bf98ae |
555 | Standard_ExtCharacter mySpecialSymbol; //!< Special symbol. |
556 | AIS_DisplaySpecialSymbol myDisplaySpecialSymbol; //!< Special symbol display options. |
d7bffd44 |
557 | |
60bf98ae |
558 | protected: //! @name Geometrical properties |
d7bffd44 |
559 | |
60bf98ae |
560 | GeometryType myGeometryType; //!< defines type of shapes on which the dimension is to be built. |
d7bffd44 |
561 | |
60bf98ae |
562 | gp_Pln myPlane; //!< Plane where dimension will be built (computed or user defined). |
563 | Standard_Boolean myIsPlaneCustom; //!< Is plane defined by user (otherwise it will be computed automatically). |
564 | Standard_Real myFlyout; //!< Flyout distance. |
565 | Standard_Boolean myIsValid; //!< Is dimension geometry properly defined. |
d7bffd44 |
566 | |
a6eb515f |
567 | private: |
d7bffd44 |
568 | |
a6eb515f |
569 | AIS_KindOfDimension myKindOfDimension; |
a6eb515f |
570 | }; |
60bf98ae |
571 | |
572 | #endif // _AIS_Dimension_HeaderFile |