0024448: Possible copy-paste bug in IGESGeom_SplineCurve.cxx
[occt.git] / src / AIS / AIS_RadiusDimension.cxx
CommitLineData
b311480e 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
5//
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.
10//
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.
13//
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.
20
a6eb515f 21#include <AIS_RadiusDimension.hxx>
7fd59977 22
a6eb515f 23#include <AIS.hxx>
24#include <AIS_Drawer.hxx>
a6eb515f 25#include <ElCLib.hxx>
a6eb515f 26#include <gce_MakeDir.hxx>
a6eb515f 27#include <Graphic3d_ArrayOfSegments.hxx>
28#include <Graphic3d_Group.hxx>
a6eb515f 29#include <PrsMgr_PresentationManager3d.hxx>
a6eb515f 30#include <Prs3d_Root.hxx>
7fd59977 31
a6eb515f 32IMPLEMENT_STANDARD_HANDLE(AIS_RadiusDimension, AIS_Dimension)
33IMPLEMENT_STANDARD_RTTIEXT(AIS_RadiusDimension, AIS_Dimension)
7fd59977 34
35//=======================================================================
36//function : Constructor
37//purpose :
38//=======================================================================
a6eb515f 39
40AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle)
41: AIS_Dimension(),
a6eb515f 42 myCircle (theCircle)
7fd59977 43{
a6eb515f 44 myFirstPoint = ElCLib::Value(0, myCircle);
45 mySecondPoint = theCircle.Location();
46 myIsInitialized = Standard_True;
47 SetSpecialSymbol ('R');
48 SetDisplaySpecialSymbol (AIS_DSS_Before);
d7bffd44 49 SetKindOfDimension (AIS_KOD_RADIUS);
50 SetFlyout (0.0);
a6eb515f 51}
52
d7bffd44 53//=======================================================================
54//function : Constructor
55//purpose :
56//=======================================================================
57
a6eb515f 58AIS_RadiusDimension::AIS_RadiusDimension (const gp_Circ& theCircle,
59 const gp_Pnt& theAttachPoint)
60: AIS_Dimension(),
a6eb515f 61 myCircle (theCircle)
62{
63 myFirstPoint = theAttachPoint;
64 mySecondPoint = theCircle.Location();
65 myIsInitialized = Standard_True;
66 SetSpecialSymbol ('R');
67 SetDisplaySpecialSymbol (AIS_DSS_Before);
68 SetKindOfDimension (AIS_KOD_RADIUS);
d7bffd44 69 SetFlyout (0.0);
7fd59977 70}
71
72//=======================================================================
73//function : Constructor
a6eb515f 74//purpose :
7fd59977 75//=======================================================================
a6eb515f 76
77AIS_RadiusDimension::AIS_RadiusDimension (const TopoDS_Shape& theShape)
62b6361a 78: AIS_Dimension ()
7fd59977 79{
a6eb515f 80 myFirstShape = theShape;
81 myIsInitialized = Standard_False;
82 SetSpecialSymbol ('R');
83 SetDisplaySpecialSymbol (AIS_DSS_Before);
84 SetKindOfDimension (AIS_KOD_RADIUS);
d7bffd44 85 SetFlyout (0.0);
7fd59977 86}
87
88//=======================================================================
89//function : Compute
90//purpose :
91//=======================================================================
7fd59977 92
62b6361a 93void AIS_RadiusDimension::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePM*/,
94 const Handle(Prs3d_Presentation)& thePresentation,
95 const Standard_Integer theMode)
a6eb515f 96{
97 thePresentation->Clear();
fe83e1ea 98 mySelectionGeom.Clear (theMode);
a6eb515f 99
100 Handle(Prs3d_DimensionAspect) aDimensionAspect = myDrawer->DimensionAspect();
101 Prs3d_Root::CurrentGroup (thePresentation)->SetPrimitivesAspect (aDimensionAspect->LineAspect()->Aspect());
102
103 if (!myIsInitialized)
104 {
105 gp_Pnt aLastPoint;
106 if (!initCircularDimension (myFirstShape, myCircle,
107 myFirstPoint, aLastPoint))
108 return;
109 else
110 {
111 mySecondPoint = myCircle.Location();
112 myIsInitialized = Standard_True;
113 }
114 }
a6eb515f 115
d7bffd44 116 if (!myIsWorkingPlaneCustom)
a6eb515f 117 {
d7bffd44 118 countDefaultPlane();
a6eb515f 119 }
120
fe83e1ea 121 drawLinearDimension (thePresentation, theMode, Standard_True);
7fd59977 122}
123
124//=======================================================================
a6eb515f 125//function : computeValue
126//purpose :
7fd59977 127//=======================================================================
a6eb515f 128
129void AIS_RadiusDimension::computeValue ()
7fd59977 130{
a6eb515f 131 myValue = myFirstPoint.Distance (mySecondPoint);
132 AIS_Dimension::computeValue ();
7fd59977 133}
134
135//=======================================================================
a6eb515f 136//function : countDefaultPlane
7fd59977 137//purpose :
138//=======================================================================
139
a6eb515f 140void AIS_RadiusDimension::countDefaultPlane ()
7fd59977 141{
a6eb515f 142 // Compute normal of the default plane.
143 gp_Vec aVec1(mySecondPoint, myFirstPoint),
144 aVec2(mySecondPoint, ElCLib::Value(M_PI_2, myCircle));
145 myDefaultPlane = gp_Pln(myCircle.Location(), aVec1^aVec2);
146 // Set computed value to <myWorkingPlane>
147 ResetWorkingPlane ();
7fd59977 148}