1 // Created on: 1996-12-05
2 // Created by: Jean-Pierre COMBE/Odile Olivier/Serguei Zaritchny
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
21 #include <AIS_RadiusDimension.hxx>
24 #include <AIS_Drawer.hxx>
26 #include <gce_MakeDir.hxx>
27 #include <Graphic3d_ArrayOfSegments.hxx>
28 #include <Graphic3d_Group.hxx>
29 #include <PrsMgr_PresentationManager3d.hxx>
30 #include <Prs3d_Root.hxx>
32 IMPLEMENT_STANDARD_HANDLE(AIS_RadiusDimension, AIS_Dimension)
33 IMPLEMENT_STANDARD_RTTIEXT(AIS_RadiusDimension, AIS_Dimension)
35 //=======================================================================
36 //function : Constructor
38 //=======================================================================
40 AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle)
44 myFirstPoint = ElCLib::Value(0, myCircle);
45 mySecondPoint = theCircle.Location();
46 myIsInitialized = Standard_True;
47 SetSpecialSymbol ('R');
48 SetDisplaySpecialSymbol (AIS_DSS_Before);
49 SetKindOfDimension (AIS_KOD_RADIUS);
53 //=======================================================================
54 //function : Constructor
56 //=======================================================================
58 AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle,
59 const gp_Pnt& theAttachPoint)
63 myFirstPoint = theAttachPoint;
64 mySecondPoint = theCircle.Location();
65 myIsInitialized = Standard_True;
66 SetSpecialSymbol ('R');
67 SetDisplaySpecialSymbol (AIS_DSS_Before);
68 SetKindOfDimension (AIS_KOD_RADIUS);
72 //=======================================================================
73 //function : Constructor
75 //=======================================================================
77 AIS_RadiusDimension::AIS_RadiusDimension (const TopoDS_Shape& theShape)
80 myFirstShape = theShape;
81 myIsInitialized = Standard_False;
82 SetSpecialSymbol ('R');
83 SetDisplaySpecialSymbol (AIS_DSS_Before);
84 SetKindOfDimension (AIS_KOD_RADIUS);
88 //=======================================================================
91 //=======================================================================
93 void AIS_RadiusDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePM*/,
94 const Handle(Prs3d_Presentation)& thePresentation,
95 const Standard_Integer theMode)
97 thePresentation->Clear();
99 Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
100 Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
102 if (!myIsInitialized)
105 if (!initCircularDimension (myFirstShape, myCircle,
106 myFirstPoint, aLastPoint))
110 mySecondPoint = myCircle.Location();
111 myIsInitialized = Standard_True;
115 if (!myIsWorkingPlaneCustom)
120 drawLinearDimension (thePresentation, (AIS_DimensionDisplayMode)theMode, Standard_True);
123 //=======================================================================
124 //function : computeValue
126 //=======================================================================
128 void AIS_RadiusDimension::computeValue ()
130 myValue = myFirstPoint.Distance (mySecondPoint);
131 AIS_Dimension::computeValue ();
134 //=======================================================================
135 //function : countDefaultPlane
137 //=======================================================================
139 void AIS_RadiusDimension::countDefaultPlane ()
141 // Compute normal of the default plane.
142 gp_Vec aVec1(mySecondPoint, myFirstPoint),
143 aVec2(mySecondPoint, ElCLib::Value(M_PI_2, myCircle));
144 myDefaultPlane = gp_Pln(myCircle.Location(), aVec1^aVec2);
145 // Set computed value to <myWorkingPlane>
146 ResetWorkingPlane ();