|
||||
File indexing completed on 2025-01-18 10:04:40
0001 // Created on: 2013-11-11 0002 // Created by: Anastasia BORISOVA 0003 // Copyright (c) 2013-2014 OPEN CASCADE SAS 0004 // 0005 // This file is part of Open CASCADE Technology software library. 0006 // 0007 // This library is free software; you can redistribute it and/or modify it under 0008 // the terms of the GNU Lesser General Public License version 2.1 as published 0009 // by the Free Software Foundation, with special exception defined in the file 0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0011 // distribution for complete text of the license and disclaimer of any warranty. 0012 // 0013 // Alternatively, this file may be used under the terms of Open CASCADE 0014 // commercial license or contractual agreement. 0015 0016 #ifndef _PrsDim_Dimension_HeaderFile 0017 #define _PrsDim_Dimension_HeaderFile 0018 0019 #include <PrsDim_DimensionOwner.hxx> 0020 #include <PrsDim_DisplaySpecialSymbol.hxx> 0021 #include <AIS_InteractiveObject.hxx> 0022 #include <AIS_KindOfInteractive.hxx> 0023 #include <PrsDim_KindOfDimension.hxx> 0024 #include <Geom_Curve.hxx> 0025 #include <gp_Circ.hxx> 0026 #include <gp_Pln.hxx> 0027 #include <Prs3d_DimensionAspect.hxx> 0028 #include <Prs3d_Drawer.hxx> 0029 #include <Prs3d_LineAspect.hxx> 0030 #include <Prs3d_Presentation.hxx> 0031 #include <SelectMgr_EntityOwner.hxx> 0032 #include <Standard.hxx> 0033 #include <TCollection_ExtendedString.hxx> 0034 #include <TopoDS_Edge.hxx> 0035 #include <TopoDS_Face.hxx> 0036 #include <TopoDS_Shape.hxx> 0037 #include <NCollection_Sequence.hxx> 0038 #include <NCollection_Handle.hxx> 0039 0040 DEFINE_STANDARD_HANDLE(PrsDim_Dimension, AIS_InteractiveObject) 0041 0042 //! PrsDim_Dimension is a base class for 2D presentations of linear (length, diameter, radius) 0043 //! and angular dimensions. 0044 //! 0045 //! The dimensions provide measurement of quantities, such as lengths or plane angles. 0046 //! The measurement of dimension "value" is done in model space "as is". 0047 //! These "value" are said to be represented in "model units", which can be specified by user. 0048 //! During the display the measured value converted from "model units" to "display units". 0049 //! The display and model units are stored in common Prs3d_Drawer (drawer of the context) 0050 //! to share it between all dimensions. 0051 //! The specified by user units are stored in the dimension's drawer. 0052 //! 0053 //! As a drawing, the dimension is composed from the following components: 0054 //! - Attachment (binding) points. The points where the dimension lines attaches to, for 0055 //! length dimensions the distances are measured between these points. 0056 //! - Main dimension line. The which extends from the attachment points in "up" direction, 0057 //! and which contains text label on it with value string. 0058 //! - Flyouts. The lines connecting the attachment points with main dimension line. 0059 //! - Extension. The lines used to extend the main dimension line in the cases when text 0060 //! or arrows do not fit into the main dimension line due to their size. 0061 //! - Arrows. 0062 //! 0063 //! <pre> 0064 //! Linear dimensions: 0065 //! 0066 //! extension 0067 //! line arrow 0068 //! -->|------- main dimension line -------|<-- 0069 //! | | 0070 //! |flyout flyout| 0071 //! | | 0072 //! +-----------------------------------+ 0073 //! attachment attachment 0074 //! point point 0075 //! 0076 //! Angular dimensions: 0077 //! 0078 //! extension 0079 //! line 0080 //! -->|+++++ 0081 //! arrow | +++ 0082 //! | 90(deg) - main dimension line 0083 //! flyout | +++ 0084 //! | + 0085 //! o---flyout--- 0086 //! center ^ 0087 //! point | extension 0088 //! line 0089 //! </pre> 0090 //! 0091 //! Being a 2D drawings, the dimensions are created on imaginary plane, called "dimension plane", 0092 //! which can be thought of as reference system of axes (X,Y,N) for constructing the presentation. 0093 //! 0094 //! The role of axes of the dimension plane is to guide you through the encapsualted automations 0095 //! of presentation building to help you understand how is the presentation will look and how it 0096 //! will be oriented in model space during construction. 0097 //! 0098 //! Orientation of dimension line in model space relatively to the base shapes is defined 0099 //! with the flyouts. Flyouts specify length of flyout lines and their orientation relatively 0100 //! to the attachment points on the working plane. 0101 //! For linear dimensions: 0102 //! Direction of flyouts is specified with direction of main dimension line 0103 //! (vector from the first attachment to the second attachment) and the normal of the dimension plane. 0104 //! Positive direction of flyouts is defined by vector multiplication: AttachVector * PlaneNormal. 0105 //! For angular dimensions: 0106 //! Flyouts are defined by vectors from the center point to the attachment points. 0107 //! These vectors directions are supposed to be the positive directions of flyouts. 0108 //! Negative flyouts directions means that these vectors should be reversed 0109 //! (and dimension will be built out of the angle constructed with center and two attach points). 0110 //! 0111 //! The dimension plane can be constructed automatically by application (where possible, 0112 //! it depends on the measured geometry). 0113 //! It can be also set by user. However, if the user-defined plane does not fit the 0114 //! geometry of the dimension (attach points do not belong to it), the dimension could not 0115 //! be built. 0116 //! If it is not possible to compute automatic plane (for example, in case of length between 0117 //! two points) the user is supposed to specify the custom plane. 0118 //! 0119 //! Since the dimensions feature automated construction procedures from an arbitrary shapes, 0120 //! the interfaces to check the validness are also implemented. Once the measured geometry is 0121 //! specified, the one can inquire the validness status by calling "IsValid()" method. If the result 0122 //! is TRUE, then all of public parameters should be pre-computed and ready. The presentation 0123 //! should be also computable. Otherwise, the parameters may return invalid values. In this case, 0124 //! the presentation will not be computed and displayed. 0125 //! 0126 //! The dimension support two local selection modes: main dimension line selection and text label 0127 //! selection. These modes can be used to develop interactive modification of dimension presentations. 0128 //! The component highlighting in these selection modes is provided by PrsDim_DimensionOwner class. 0129 //! Please note that selection is unavailable until the presentation is computed. 0130 //! 0131 //! The specific drawing attributes are controlled through Prs3d_DimensionAspect. The one can change 0132 //! color, arrows, text and arrow style and specify positioning of value label by setting corresponding 0133 //! values to the aspect. 0134 //! 0135 //! Such set of parameters that consists of: 0136 //! - flyout size and direction, 0137 //! - user-defined dimension plane, 0138 //! - horizontal and vertical text alignment 0139 //! can be uniquely replaced with text position in 3d space. Therefore, there are methods to convert 0140 //! this set of parameters to the text position and vice versa: 0141 //! 0142 //! - If the fixed text position is defined by user, called SetTextPosition (theTextPos) method converts 0143 //! this 3d point to the set of parameters including adjusting of the dimension plane (this plane will be 0144 //! automatic plane, NOT user-defined one). 0145 //! If the fixed text position is set, the flag myIsFixedTextPosition is set to TRUE. 0146 //! ATTENTION! myIsFixedTextPosition fixes all parameters of the set from recomputing inside 0147 //! SetMeasureGeometry() methods. Parameters in dimension aspect (they are horizontal text position 0148 //! and extension size) are adjusted on presentation computing step, user-defined values in 0149 //! dimension aspect are not changed. 0150 //! But plane and flyout as dimension position parameters are changed by SetTextPosition() method 0151 //! according with user-defined text position. 0152 //! If parameters from the set are changed by user with calls of setters, it leads to disabling of 0153 //! fixed text position (myIsFixedTextPosition is set to FALSE). 0154 //! If the fixed text position is set and geometry is changed by user (SetMeasureGeometry() method 0155 //! is called) and the geometry doesn't satisfy computed dimension plane, the dimension is not valid. 0156 //! 0157 //! - If the set of parameters was set by user (may be without the user-defined plane or with it), 0158 //! it can be converted to the text position by calling the method GetTextPosition(). In this case 0159 //! the text position is NOT fixed, and SetMeasureGeometry() without user-defined plane adjusts 0160 //! the automatic plane according input geometry (if it is possible). 0161 class PrsDim_Dimension : public AIS_InteractiveObject 0162 { 0163 DEFINE_STANDARD_RTTIEXT(PrsDim_Dimension, AIS_InteractiveObject) 0164 protected: 0165 0166 //! Geometry type defines type of shapes on which the dimension is to be built. 0167 //! Some type of geometry allows automatic plane computing and 0168 //! can be built without user-defined plane 0169 //! Another types can't be built without user-defined plane. 0170 enum GeometryType 0171 { 0172 GeometryType_UndefShapes, 0173 GeometryType_Edge, 0174 GeometryType_Face, 0175 GeometryType_Points, 0176 GeometryType_Edges, 0177 GeometryType_Faces, 0178 GeometryType_EdgeFace, 0179 GeometryType_EdgeVertex 0180 }; 0181 0182 //! Specifies supported at base level horizontal and vertical 0183 //! label positions for drawing extension lines and centered text. 0184 enum LabelPosition 0185 { 0186 LabelPosition_None = 0x00, 0187 0188 LabelPosition_Left = 0x01, 0189 LabelPosition_Right = 0x02, 0190 LabelPosition_HCenter = 0x04, 0191 LabelPosition_HMask = LabelPosition_Left | LabelPosition_Right | LabelPosition_HCenter, 0192 0193 LabelPosition_Above = 0x10, 0194 LabelPosition_Below = 0x20, 0195 LabelPosition_VCenter = 0x40, 0196 LabelPosition_VMask = LabelPosition_Above | LabelPosition_Below | LabelPosition_VCenter 0197 }; 0198 0199 enum ValueType 0200 { 0201 ValueType_Computed, 0202 ValueType_CustomReal, 0203 ValueType_CustomText 0204 }; 0205 0206 public: 0207 0208 //! Specifies supported presentation compute modes. 0209 //! Used to compute only parts of presentation for 0210 //! advanced highlighting. 0211 enum ComputeMode 0212 { 0213 ComputeMode_All = 0, //!< "0" is reserved as neutral mode 0214 ComputeMode_Line = 1, //!< corresponds to selection mode 0215 ComputeMode_Text = 2 //!< corresponds to selection mode 0216 }; 0217 0218 public: 0219 0220 //! Constructor with default parameters values. 0221 //! @param theType [in] the type of dimension. 0222 Standard_EXPORT PrsDim_Dimension (const PrsDim_KindOfDimension theType); 0223 0224 //! Gets dimension measurement value. If the value to display is not 0225 //! specified by user, then the dimension object is responsible to 0226 //! compute it on its own in model space coordinates. 0227 //! @return the dimension value (in model units) which is used 0228 //! during display of the presentation. 0229 Standard_Real GetValue() const 0230 { 0231 return myValueType == ValueType_CustomReal ? myCustomValue : ComputeValue(); 0232 } 0233 0234 //! Sets computed dimension value. Resets custom value mode if it was set. 0235 void SetComputedValue () 0236 { 0237 myValueType = ValueType_Computed; 0238 } 0239 0240 //! Sets user-defined dimension value. 0241 //! The user-defined dimension value is specified in model space, 0242 //! and affect by unit conversion during the display. 0243 //! @param theValue [in] the user-defined value to display. 0244 Standard_EXPORT void SetCustomValue (const Standard_Real theValue); 0245 0246 //! Sets user-defined dimension value. 0247 //! Unit conversion during the display is not applied. 0248 //! @param theValue [in] the user-defined value to display. 0249 Standard_EXPORT void SetCustomValue (const TCollection_ExtendedString& theValue); 0250 0251 //! Gets user-defined dimension value. 0252 //! @return dimension value string. 0253 const TCollection_ExtendedString& GetCustomValue() const { return myCustomStringValue; } 0254 0255 //! Get the dimension plane in which the 2D dimension presentation is computed. 0256 //! By default, if plane is not defined by user, it is computed automatically 0257 //! after dimension geometry is computed. 0258 //! If computed dimension geometry (points) can't be placed on the user-defined 0259 //! plane, dimension geometry was set as invalid (validity flag is set to false) 0260 //! and dimension presentation will not be computed. 0261 //! If user-defined plane allow geometry placement on it, it will be used for 0262 //! computing of the dimension presentation. 0263 //! @return dimension plane used for presentation computing. 0264 const gp_Pln& GetPlane() const { return myPlane; } 0265 0266 //! Geometry type defines type of shapes on which the dimension is to be built. 0267 //! @return type of geometry on which the dimension will be built. 0268 Standard_Integer GetGeometryType () const { return myGeometryType; } 0269 0270 //! Sets user-defined plane where the 2D dimension presentation will be placed. 0271 //! Checks validity of this plane if geometry has been set already. 0272 //! Validity of the plane is checked according to the geometry set 0273 //! and has different criteria for different kinds of dimensions. 0274 Standard_EXPORT virtual void SetCustomPlane (const gp_Pln& thePlane); 0275 0276 //! Unsets user-defined plane. Therefore the plane for dimension will be 0277 //! computed automatically. 0278 void UnsetCustomPlane() { myIsPlaneCustom = Standard_False; } 0279 0280 //! @return TRUE if text position is set by user with method SetTextPosition(). 0281 Standard_Boolean IsTextPositionCustom() const 0282 { 0283 return myIsTextPositionFixed; 0284 } 0285 0286 //! Fixes the absolute text position and adjusts flyout, plane and text alignment 0287 //! according to it. Updates presentation if the text position is valid. 0288 //! ATTENTION! It does not change vertical text alignment. 0289 //! @param theTextPos [in] the point of text position. 0290 virtual void SetTextPosition (const gp_Pnt& /*theTextPos*/) { } 0291 0292 //! Computes absolute text position from dimension parameters 0293 //! (flyout, plane and text alignment). 0294 virtual gp_Pnt GetTextPosition () const { return gp_Pnt(); } 0295 0296 public: 0297 0298 //! Gets the dimension aspect from AIS object drawer. 0299 //! Dimension aspect contains aspects of line, text and arrows for dimension presentation. 0300 Handle(Prs3d_DimensionAspect) DimensionAspect() const 0301 { 0302 return myDrawer->DimensionAspect(); 0303 } 0304 0305 //! Sets new dimension aspect for the interactive object drawer. 0306 //! The dimension aspect provides dynamic properties which are generally 0307 //! used during computation of dimension presentations. 0308 Standard_EXPORT void SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theDimensionAspect); 0309 0310 //! @return the kind of dimension. 0311 PrsDim_KindOfDimension KindOfDimension() const { return myKindOfDimension; } 0312 0313 //! @return the kind of interactive. 0314 virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Dimension; } 0315 0316 //! Returns true if the class of objects accepts the display mode theMode. 0317 //! The interactive context can have a default mode of representation for 0318 //! the set of Interactive Objects. This mode may not be accepted by object. 0319 virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE 0320 { 0321 return theMode == ComputeMode_All; 0322 } 0323 0324 public: 0325 0326 //! @return dimension special symbol display options. 0327 PrsDim_DisplaySpecialSymbol DisplaySpecialSymbol() const { return myDisplaySpecialSymbol; } 0328 0329 //! Specifies whether to display special symbol or not. 0330 Standard_EXPORT void SetDisplaySpecialSymbol (const PrsDim_DisplaySpecialSymbol theDisplaySpecSymbol); 0331 0332 //! @return special symbol. 0333 Standard_ExtCharacter SpecialSymbol() const 0334 { 0335 return mySpecialSymbol; 0336 } 0337 0338 //! Specifies special symbol. 0339 Standard_EXPORT void SetSpecialSymbol (const Standard_ExtCharacter theSpecialSymbol); 0340 0341 Standard_EXPORT virtual const TCollection_AsciiString& GetDisplayUnits() const; 0342 0343 Standard_EXPORT virtual const TCollection_AsciiString& GetModelUnits() const; 0344 0345 virtual void SetDisplayUnits (const TCollection_AsciiString& /*theUnits*/) { } 0346 0347 virtual void SetModelUnits (const TCollection_AsciiString& /*theUnits*/) { } 0348 0349 //! Unsets user defined text positioning and enables text positioning 0350 //! by other parameters: text alignment, extension size, flyout and custom plane. 0351 Standard_EXPORT void UnsetFixedTextPosition(); 0352 0353 public: 0354 0355 //! Returns selection tolerance for text2d: 0356 //! For 2d text selection detection sensitive point with tolerance is used 0357 //! Important! Only for 2d text. 0358 Standard_Real SelToleranceForText2d() const 0359 { 0360 return mySelToleranceForText2d; 0361 } 0362 0363 //! Sets selection tolerance for text2d: 0364 //! For 2d text selection detection sensitive point with tolerance is used 0365 //! to change this tolerance use this method 0366 //! Important! Only for 2d text. 0367 Standard_EXPORT void SetSelToleranceForText2d (const Standard_Real theTol); 0368 0369 //! @return flyout value for dimension. 0370 Standard_Real GetFlyout() const 0371 { 0372 return myFlyout; 0373 } 0374 0375 //! Sets flyout value for dimension. 0376 Standard_EXPORT void SetFlyout (const Standard_Real theFlyout); 0377 0378 //! Check that the input geometry for dimension is valid and the 0379 //! presentation can be successfully computed. 0380 //! @return TRUE if dimension geometry is ok. 0381 virtual Standard_Boolean IsValid() const 0382 { 0383 return myIsGeometryValid && CheckPlane (GetPlane()); 0384 } 0385 0386 protected: 0387 0388 Standard_EXPORT Standard_Real ValueToDisplayUnits() const; 0389 0390 //! Get formatted value string and its model space width. 0391 //! @param theWidth [out] the model space with of the string. 0392 //! @return formatted dimension value string. 0393 Standard_EXPORT TCollection_ExtendedString GetValueString (Standard_Real& theWidth) const; 0394 0395 //! Performs drawing of 2d or 3d arrows on the working plane 0396 //! @param theLocation [in] the location of the arrow tip. 0397 //! @param theDirection [in] the direction from the tip to the bottom of the arrow. 0398 Standard_EXPORT void DrawArrow (const Handle(Prs3d_Presentation)& thePresentation, 0399 const gp_Pnt& theLocation, 0400 const gp_Dir& theDirection); 0401 0402 //! Performs drawing of 2d or 3d text on the working plane 0403 //! @param theTextPos [in] the position of the text label. 0404 //! @param theTestDir [in] the direction of the text label. 0405 //! @param theText [in] the text label string. 0406 //! @param theLabelPosition [in] the text label vertical and horizontal positioning option 0407 //! respectively to the main dimension line. 0408 //! @return text width relative to the dimension working plane. For 2d text this value will be zero. 0409 Standard_EXPORT void drawText (const Handle(Prs3d_Presentation)& thePresentation, 0410 const gp_Pnt& theTextPos, 0411 const gp_Dir& theTextDir, 0412 const TCollection_ExtendedString& theText, 0413 const Standard_Integer theLabelPosition); 0414 0415 //! Performs computing of dimension linear extension with text 0416 //! @param thePresentation [in] the presentation to fill with graphical primitives. 0417 //! @param theExtensionSize [in] the size of extension line. 0418 //! @param theExtensionStart [in] the point where extension line connects to dimension. 0419 //! @param theExtensionDir [in] the direction of extension line. 0420 //! @param theLabelString [in] the string with value. 0421 //! @param theLabelWidth [in] the geometrical width computed for value string. 0422 //! @param theMode [in] the display mode. 0423 //! @param theLabelPosition [in] position flags for the text label. 0424 Standard_EXPORT void DrawExtension (const Handle(Prs3d_Presentation)& thePresentation, 0425 const Standard_Real theExtensionSize, 0426 const gp_Pnt& theExtensionStart, 0427 const gp_Dir& theExtensionDir, 0428 const TCollection_ExtendedString& theLabelString, 0429 const Standard_Real theLabelWidth, 0430 const Standard_Integer theMode, 0431 const Standard_Integer theLabelPosition); 0432 0433 //! Performs computing of linear dimension (for length, diameter, radius and so on). 0434 //! Please note that this method uses base dimension properties, like working plane 0435 //! flyout length, drawer attributes. 0436 //! @param thePresentation [in] the presentation to fill with primitives. 0437 //! @param theMode [in] the presentation compute mode. 0438 //! @param theFirstPoint [in] the first attach point of linear dimension. 0439 //! @param theSecondPoint [in] the second attach point of linear dimension. 0440 //! @param theIsOneSide [in] specifies whether the dimension has only one flyout line. 0441 Standard_EXPORT void DrawLinearDimension (const Handle(Prs3d_Presentation)& thePresentation, 0442 const Standard_Integer theMode, 0443 const gp_Pnt& theFirstPoint, 0444 const gp_Pnt& theSecondPoint, 0445 const Standard_Boolean theIsOneSide = Standard_False); 0446 0447 //! Computes points bounded the flyout line for linear dimension. 0448 //! @param theFirstPoint [in] the first attach point of linear dimension. 0449 //! @param theSecondPoint [in] the second attach point of linear dimension. 0450 //! @param theLineBegPoint [out] the first attach point of linear dimension. 0451 //! @param theLineEndPoint [out] the second attach point of linear dimension. 0452 Standard_EXPORT virtual void ComputeFlyoutLinePoints (const gp_Pnt& theFirstPoint, const gp_Pnt& theSecondPoint, 0453 gp_Pnt& theLineBegPoint, gp_Pnt& theLineEndPoint); 0454 0455 //! Compute selection sensitives for linear dimension flyout lines (length, diameter, radius). 0456 //! Please note that this method uses base dimension properties: working plane and flyout length. 0457 //! @param theSelection [in] the selection structure to fill with selection primitives. 0458 //! @param theOwner [in] the selection entity owner. 0459 //! @param theFirstPoint [in] the first attach point of linear dimension. 0460 //! @param theSecondPoint [in] the second attach point of linear dimension. 0461 Standard_EXPORT void ComputeLinearFlyouts (const Handle(SelectMgr_Selection)& theSelection, 0462 const Handle(SelectMgr_EntityOwner)& theOwner, 0463 const gp_Pnt& theFirstPoint, 0464 const gp_Pnt& theSecondPoint); 0465 0466 0467 //! Performs initialization of circle and middle arc point from the passed 0468 //! shape which is assumed to contain circular geometry. 0469 //! @param theShape [in] the shape to explore. 0470 //! @param theCircle [out] the circle geometry. 0471 //! @param theMiddleArcPoint [out] the middle point of the arc. 0472 //! @param theIsClosed [out] returns TRUE if the geometry is closed circle. 0473 //! @return TRUE if the circle is successfully returned from the input shape. 0474 Standard_EXPORT Standard_Boolean InitCircularDimension (const TopoDS_Shape& theShape, 0475 gp_Circ& theCircle, 0476 gp_Pnt& theMiddleArcPoint, 0477 Standard_Boolean& theIsClosed); 0478 0479 //! Produce points for triangular arrow face. 0480 //! @param thePeakPnt [in] the arrow peak position. 0481 //! @param theDirection [in] the arrow direction. 0482 //! @param thePlane [in] the face plane. 0483 //! @param theArrowLength [in] the length of arrow. 0484 //! @param theArrowAngle [in] the angle of arrow. 0485 //! @param theSidePnt1 [out] the first side point. 0486 //! @param theSidePnt2 [out] the second side point. 0487 Standard_EXPORT void PointsForArrow (const gp_Pnt& thePeakPnt, 0488 const gp_Dir& theDirection, 0489 const gp_Dir& thePlane, 0490 const Standard_Real theArrowLength, 0491 const Standard_Real theArrowAngle, 0492 gp_Pnt& theSidePnt1, 0493 gp_Pnt& theSidePnt2); 0494 0495 //! Compute point of text position for dimension parameters 0496 //! for linear kinds of dimensions (length, radius, diameter). 0497 Standard_EXPORT gp_Pnt GetTextPositionForLinear (const gp_Pnt& theFirstPoint, 0498 const gp_Pnt& theSecondPoint, 0499 const Standard_Boolean theIsOneSide = Standard_False) const; 0500 0501 //! Fits text alignment relatively to the dimension line. 0502 //! @param theFirstPoint [in] the first attachment point. 0503 //! @param theSecondPoint [in] the second attachment point. 0504 //! @param theIsOneSide [in] is the arrow displayed only on the one side of the dimension. 0505 //! @param theHorizontalTextPos [in] the text horizontal position (alignment). 0506 //! @param theLabelPosition [out] the label position, contains bits that defines 0507 //! vertical and horizontal alignment. (for internal usage in count text position) 0508 //! @param theIsArrowExternal [out] is the arrows external, 0509 //! if arrow orientation in the dimension aspect is Prs3d_DAO_Fit, it fits arrow 0510 //! orientation automatically. 0511 Standard_EXPORT void FitTextAlignmentForLinear (const gp_Pnt& theFirstPoint, 0512 const gp_Pnt& theSecondPoint, 0513 const Standard_Boolean theIsOneSide, 0514 const Prs3d_DimensionTextHorizontalPosition& theHorizontalTextPos, 0515 Standard_Integer& theLabelPosition, 0516 Standard_Boolean& theIsArrowsExternal) const; 0517 0518 //! Adjusts aspect parameters according the text position: 0519 //! extension size, vertical text alignment and flyout. 0520 //! @param theTextPos [in] the user defined 3d point of text position 0521 //! @param theFirstPoint [in] the first point of linear measurement. 0522 //! @param theSecondPoint [in] the second point of linear measurement. 0523 //! @param theExtensionSize [out] the adjusted extension size 0524 //! @param theAlignment [out] the horizontal label alignment. 0525 //! @param theFlyout [out] the adjusted value of flyout. 0526 //! @param thePlane [out] the new plane that contains theTextPos and attachment points. 0527 //! @param theIsPlaneOld [out] shows if new plane is computed. 0528 Standard_EXPORT Standard_Boolean AdjustParametersForLinear (const gp_Pnt& theTextPos, 0529 const gp_Pnt& theFirstPoint, 0530 const gp_Pnt& theSecondPoint, 0531 Standard_Real& theExtensionSize, 0532 Prs3d_DimensionTextHorizontalPosition& theAlignment, 0533 Standard_Real& theFlyout, 0534 gp_Pln& thePlane, 0535 Standard_Boolean& theIsPlaneOld) const; 0536 0537 protected: //! @name Static auxilliary methods for geometry extraction 0538 0539 //! If it is possible extracts circle from planar face. 0540 //! @param theFace [in] the planar face 0541 //! @param theCurve [out] the circular curve 0542 //! @param theFirstPoint [out] the point of the first parameter of the circlular curve 0543 //! @param theSecondPoint [out] the point of the last parameter of the circlular curve 0544 //! @return TRUE in case of successful circle extraction 0545 static Standard_Boolean CircleFromPlanarFace (const TopoDS_Face& theFace, 0546 Handle(Geom_Curve)& theCurve, 0547 gp_Pnt& theFirstPoint, 0548 gp_Pnt& theLastPoint); 0549 0550 //! If it is possible extracts circle from the edge. 0551 //! @param theEdge [in] input edge to extract circle from 0552 //! @param theCircle [out] circle 0553 //! @param theFirstPoint [out] the point of the first parameter of the circlular curve 0554 //! @param theSecondPoint [out] the point of the last parameter of the circlular curve 0555 //! @return TRUE in case of successful circle extraction. 0556 static Standard_Boolean CircleFromEdge (const TopoDS_Edge& theEdge, 0557 gp_Circ& theCircle, 0558 gp_Pnt& theFirstPoint, 0559 gp_Pnt& theLastPoint); 0560 0561 protected: //! @name Behavior to implement 0562 0563 //! Override this method to check if user-defined plane 0564 //! is valid for the dimension geometry. 0565 //! @param thePlane [in] the working plane for positioning every 0566 //! dimension in the application. 0567 //! @return true is the plane is suitable for building dimension 0568 //! with computed dimension geometry. 0569 virtual Standard_Boolean CheckPlane (const gp_Pln& /*thePlane*/) const { return Standard_True; } 0570 0571 //! Override this method to computed value of dimension. 0572 //! @return value from the measured geometry. 0573 virtual Standard_Real ComputeValue() const 0574 { 0575 return 0.0; 0576 } 0577 0578 //! Override this method to compute selection primitives for 0579 //! flyout lines (if the dimension provides it). 0580 //! This callback is a only a part of base selection 0581 //! computation routine. 0582 virtual void ComputeFlyoutSelection (const Handle(SelectMgr_Selection)&, 0583 const Handle(SelectMgr_EntityOwner)&) {} 0584 0585 0586 //! Base procedure of computing selection (based on selection geometry data). 0587 //! @param theSelection [in] the selection structure to will with primitives. 0588 //! @param theMode [in] the selection mode. 0589 Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, 0590 const Standard_Integer theMode) Standard_OVERRIDE; 0591 0592 protected: //! @name Selection geometry 0593 0594 //! Selection geometry of dimension presentation. The structure is filled with data 0595 //! during compute of presentation, then this data is used to generate selection 0596 //! sensitives when computing selection. 0597 struct SelectionGeometry 0598 { 0599 //! Arrows are represented by directed triangles. 0600 struct Arrow 0601 { 0602 gp_Pnt Position; 0603 gp_Dir Direction; 0604 }; 0605 typedef NCollection_Sequence<gp_Pnt> Curve; 0606 typedef NCollection_Handle<Curve> HCurve; 0607 typedef NCollection_Handle<Arrow> HArrow; 0608 typedef NCollection_Sequence<HCurve> SeqOfCurves; 0609 typedef NCollection_Sequence<HArrow> SeqOfArrows; 0610 0611 gp_Pnt TextPos; //!< Center of text label. 0612 gp_Dir TextDir; //!< Direction of text label. 0613 Standard_Real TextWidth; //!< Width of text label. 0614 Standard_Real TextHeight; //!< Height of text label. 0615 SeqOfCurves DimensionLine; //!< Sequence of points for composing the segments of dimension line. 0616 SeqOfArrows Arrows; //!< Sequence of arrow geometries. 0617 Standard_Boolean IsComputed; //!< Shows if the selection geometry was filled. 0618 0619 public: 0620 0621 //! Clear geometry of sensitives for the specified compute mode. 0622 //! @param theMode [in] the compute mode to clear. 0623 void Clear (const Standard_Integer theMode) 0624 { 0625 if (theMode == ComputeMode_All || theMode == ComputeMode_Line) 0626 { 0627 DimensionLine.Clear(); 0628 Arrows.Clear(); 0629 } 0630 0631 if (theMode == ComputeMode_All || theMode == ComputeMode_Text) 0632 { 0633 TextPos = gp::Origin(); 0634 TextDir = gp::DX(); 0635 TextWidth = 0.0; 0636 TextHeight = 0.0; 0637 } 0638 0639 IsComputed = Standard_False; 0640 } 0641 0642 //! Add new curve entry and return the reference to populate it. 0643 Curve& NewCurve() 0644 { 0645 DimensionLine.Append( new Curve ); 0646 HCurve& aLastCurve = DimensionLine.ChangeLast(); 0647 return *aLastCurve; 0648 } 0649 0650 //! Add new arrow entry and return the reference to populate it. 0651 Arrow& NewArrow() 0652 { 0653 Arrows.Append( new Arrow ); 0654 HArrow& aLastArrow = Arrows.ChangeLast(); 0655 return *aLastArrow; 0656 } 0657 } mySelectionGeom; 0658 0659 Standard_Real mySelToleranceForText2d; //!< Sensitive point tolerance for 2d text selection. 0660 0661 protected: //! @name Value properties 0662 0663 ValueType myValueType; //! type of value (computed or user-defined) 0664 Standard_Real myCustomValue; //!< Value of the dimension (computed or user-defined). 0665 0666 TCollection_ExtendedString myCustomStringValue; //!< Value of the dimension (computed or user-defined). 0667 0668 protected: //! @name Fixed text position properties 0669 0670 gp_Pnt myFixedTextPosition; //!< Stores text position fixed by user. 0671 Standard_Boolean myIsTextPositionFixed; //!< Is the text label position fixed by user. 0672 0673 protected: //! @name Units properties 0674 0675 Standard_ExtCharacter mySpecialSymbol; //!< Special symbol. 0676 PrsDim_DisplaySpecialSymbol myDisplaySpecialSymbol; //!< Special symbol display options. 0677 0678 protected: //! @name Geometrical properties 0679 0680 GeometryType myGeometryType; //!< defines type of shapes on which the dimension is to be built. 0681 0682 gp_Pln myPlane; //!< Plane where dimension will be built (computed or user defined). 0683 Standard_Boolean myIsPlaneCustom; //!< Is plane defined by user (otherwise it will be computed automatically). 0684 Standard_Real myFlyout; //!< Flyout distance. 0685 Standard_Boolean myIsGeometryValid; //!< Is dimension geometry properly defined. 0686 0687 private: 0688 0689 PrsDim_KindOfDimension myKindOfDimension; 0690 }; 0691 0692 #endif // _PrsDim_Dimension_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |