1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
19 #include <Prs3d_Drawer.ixx>
21 // =======================================================================
22 // function : Prs3d_Drawer
24 // =======================================================================
25 Prs3d_Drawer::Prs3d_Drawer()
27 myIsoOnPlane (Standard_False),
28 myFreeBoundaryDraw (Standard_True),
29 myUnFreeBoundaryDraw (Standard_True),
30 myWireDraw (Standard_True),
31 myShadingAspect (new Prs3d_ShadingAspect()),
32 myShadingAspectGlobal (Standard_True),
33 myChordialDeviation (0.0001),
34 myTypeOfDeflection (Aspect_TOD_RELATIVE),
35 myMaximalParameterValue (500000.),
36 myDeviationCoefficient (0.001),
37 myHLRDeviationCoefficient (0.02),
38 myDeviationAngle (12.0 * M_PI / 180.0),
39 myHLRAngle (20.0 * M_PI / 180.0),
40 myLineDrawArrow (Standard_False),
41 myDrawHiddenLine (Standard_False),
42 myFaceBoundaryDraw (Standard_False),
43 myTypeOfHLR (Prs3d_TOH_PolyAlgo)
45 myDimensionModelUnits.SetLengthUnits ("m");
46 myDimensionModelUnits.SetAngleUnits ("rad");
47 myDimensionDisplayUnits.SetLengthUnits ("m");
48 myDimensionDisplayUnits.SetAngleUnits ("deg");
51 void Prs3d_Drawer::SetTypeOfDeflection(const Aspect_TypeOfDeflection aTypeOfDeflection){
53 myTypeOfDeflection = aTypeOfDeflection;}
55 Aspect_TypeOfDeflection Prs3d_Drawer::TypeOfDeflection() const {
57 return myTypeOfDeflection;
62 void Prs3d_Drawer::SetIsoOnPlane(const Standard_Boolean OnOff)
68 Standard_Boolean Prs3d_Drawer::IsoOnPlane()const
74 Standard_Integer Prs3d_Drawer::Discretisation() const
80 void Prs3d_Drawer::SetDiscretisation(const Standard_Integer d)
86 void Prs3d_Drawer::SetMaximalChordialDeviation(
87 const Quantity_Length aChordialDeviation) {
88 myChordialDeviation = aChordialDeviation;
91 Quantity_Length Prs3d_Drawer::MaximalChordialDeviation() const {
92 return myChordialDeviation;
96 //=======================================================================
97 //function : SetDeviationCoefficient
99 //=======================================================================
101 void Prs3d_Drawer::SetDeviationCoefficient (const Standard_Real aCoefficient) {
103 myDeviationCoefficient = aCoefficient;
106 //=======================================================================
107 //function : DeviationCoefficient
109 //=======================================================================
111 Standard_Real Prs3d_Drawer::DeviationCoefficient () const {
113 return myDeviationCoefficient;
116 //=======================================================================
117 //function : SetHLRDeviationCoefficient
119 //=======================================================================
121 void Prs3d_Drawer::SetHLRDeviationCoefficient (const Standard_Real aCoefficient) {
123 myHLRDeviationCoefficient = aCoefficient;
126 //=======================================================================
127 //function : HLRDeviationCoefficient
129 //=======================================================================
131 Standard_Real Prs3d_Drawer::HLRDeviationCoefficient () const {
133 return myHLRDeviationCoefficient;
136 //=======================================================================
137 //function : SetHLRAngle
139 //=======================================================================
141 void Prs3d_Drawer::SetHLRAngle (const Standard_Real anAngle) {
143 myHLRAngle = anAngle;
146 //=======================================================================
147 //function : HLRAngle
149 //=======================================================================
151 Standard_Real Prs3d_Drawer::HLRAngle () const {
156 //=======================================================================
157 //function : SetDeviationAngle
159 //=======================================================================
161 void Prs3d_Drawer::SetDeviationAngle (const Standard_Real anAngle)
163 myDeviationAngle = anAngle;
166 //=======================================================================
167 //function : DeviationAngle
169 //=======================================================================
171 Standard_Real Prs3d_Drawer::DeviationAngle () const
173 return myDeviationAngle;
177 void Prs3d_Drawer::SetMaximalParameterValue (const Standard_Real Value) {
178 myMaximalParameterValue = Value;
181 Standard_Real Prs3d_Drawer::MaximalParameterValue () const {
182 return myMaximalParameterValue;
185 Handle (Prs3d_IsoAspect) Prs3d_Drawer::UIsoAspect (){
187 if (myUIsoAspect.IsNull())
188 myUIsoAspect = new Prs3d_IsoAspect
189 (Quantity_NOC_GRAY75,Aspect_TOL_SOLID,0.5,1);
194 void Prs3d_Drawer::SetUIsoAspect ( const Handle(Prs3d_IsoAspect)& anAspect) {
195 myUIsoAspect = anAspect;
198 Handle (Prs3d_IsoAspect) Prs3d_Drawer::VIsoAspect () {
199 if (myVIsoAspect.IsNull())
200 myVIsoAspect = new Prs3d_IsoAspect
201 (Quantity_NOC_GRAY75,Aspect_TOL_SOLID,0.5,1);
206 void Prs3d_Drawer::SetVIsoAspect ( const Handle(Prs3d_IsoAspect)& anAspect) {
207 myVIsoAspect = anAspect;
210 Handle (Prs3d_LineAspect) Prs3d_Drawer::FreeBoundaryAspect () {
211 if (myFreeBoundaryAspect.IsNull())
212 myFreeBoundaryAspect = new Prs3d_LineAspect
213 (Quantity_NOC_GREEN,Aspect_TOL_SOLID,1.);
215 return myFreeBoundaryAspect;
218 void Prs3d_Drawer::SetFreeBoundaryAspect (const Handle(Prs3d_LineAspect)& anAspect) {
219 myFreeBoundaryAspect = anAspect;
222 void Prs3d_Drawer::SetFreeBoundaryDraw ( const Standard_Boolean OnOff ) {
223 myFreeBoundaryDraw = OnOff;
226 Standard_Boolean Prs3d_Drawer::FreeBoundaryDraw () const {
227 return myFreeBoundaryDraw;
230 Handle (Prs3d_LineAspect) Prs3d_Drawer::UnFreeBoundaryAspect (){
231 if (myUnFreeBoundaryAspect.IsNull())
232 myUnFreeBoundaryAspect = new Prs3d_LineAspect
233 (Quantity_NOC_YELLOW,Aspect_TOL_SOLID,1.);
234 return myUnFreeBoundaryAspect;
237 void Prs3d_Drawer::SetUnFreeBoundaryAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
238 myUnFreeBoundaryAspect = anAspect;
241 void Prs3d_Drawer::SetUnFreeBoundaryDraw ( const Standard_Boolean OnOff ) {
242 myUnFreeBoundaryDraw = OnOff;
245 Standard_Boolean Prs3d_Drawer::UnFreeBoundaryDraw () const {
246 return myUnFreeBoundaryDraw;
249 Handle (Prs3d_LineAspect) Prs3d_Drawer::WireAspect () {
250 if (myWireAspect.IsNull())
251 myWireAspect = new Prs3d_LineAspect(Quantity_NOC_RED,Aspect_TOL_SOLID,1.);
256 void Prs3d_Drawer::SetWireAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
257 myWireAspect = anAspect;
259 void Prs3d_Drawer::SetWireDraw ( const Standard_Boolean OnOff ) {
263 Standard_Boolean Prs3d_Drawer::WireDraw () const {
268 Handle (Prs3d_LineAspect) Prs3d_Drawer::LineAspect () {
269 if (myLineAspect.IsNull())
270 myLineAspect = new Prs3d_LineAspect
271 (Quantity_NOC_YELLOW,Aspect_TOL_SOLID,1.);
275 void Prs3d_Drawer::SetLineAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
276 myLineAspect = anAspect;
279 Handle (Prs3d_TextAspect) Prs3d_Drawer::TextAspect () {
280 if (myTextAspect.IsNull())
281 myTextAspect = new Prs3d_TextAspect();
286 void Prs3d_Drawer::SetTextAspect ( const Handle(Prs3d_TextAspect)& anAspect) {
287 myTextAspect = anAspect;
290 Handle (Prs3d_ShadingAspect) Prs3d_Drawer::ShadingAspect () {
291 if (myShadingAspect.IsNull())
292 myShadingAspect = new Prs3d_ShadingAspect();
294 return myShadingAspect;
297 void Prs3d_Drawer::SetShadingAspect ( const Handle(Prs3d_ShadingAspect)& anAspect) {
298 myShadingAspect = anAspect;
301 void Prs3d_Drawer::SetShadingAspectGlobal(const Standard_Boolean aValue) {
302 myShadingAspectGlobal = aValue;
305 Standard_Boolean Prs3d_Drawer::ShadingAspectGlobal() const {
307 return myShadingAspectGlobal;
311 void Prs3d_Drawer::SetLineArrowDraw ( const Standard_Boolean OnOff ) {
312 myLineDrawArrow = OnOff;
315 Standard_Boolean Prs3d_Drawer::LineArrowDraw () const {
316 return myLineDrawArrow;
319 Handle (Prs3d_ArrowAspect) Prs3d_Drawer::ArrowAspect() {
320 if (myArrowAspect.IsNull())
321 myArrowAspect = new Prs3d_ArrowAspect;
323 return myArrowAspect;
326 void Prs3d_Drawer::SetArrowAspect ( const Handle(Prs3d_ArrowAspect)& anAspect) {
327 myArrowAspect = anAspect;
330 Handle (Prs3d_PointAspect) Prs3d_Drawer::PointAspect() {
331 if (myPointAspect.IsNull())
332 myPointAspect = new Prs3d_PointAspect
333 (Aspect_TOM_PLUS,Quantity_NOC_YELLOW,1.);
335 return myPointAspect;
338 void Prs3d_Drawer::SetPointAspect ( const Handle(Prs3d_PointAspect)& anAspect) {
339 myPointAspect = anAspect;
342 Standard_Boolean Prs3d_Drawer::DrawHiddenLine () const {return myDrawHiddenLine;}
344 void Prs3d_Drawer::EnableDrawHiddenLine () {myDrawHiddenLine=Standard_True;}
346 void Prs3d_Drawer::DisableDrawHiddenLine () {myDrawHiddenLine=Standard_False;}
348 Handle (Prs3d_LineAspect) Prs3d_Drawer::HiddenLineAspect () {
349 if (myHiddenLineAspect.IsNull())
350 myHiddenLineAspect = new Prs3d_LineAspect
351 (Quantity_NOC_YELLOW,Aspect_TOL_DASH,0.5);
353 return myHiddenLineAspect;
356 void Prs3d_Drawer::SetHiddenLineAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
357 myHiddenLineAspect = anAspect;
360 Handle (Prs3d_LineAspect) Prs3d_Drawer::SeenLineAspect () {
361 if (mySeenLineAspect.IsNull())
362 mySeenLineAspect = new Prs3d_LineAspect
363 (Quantity_NOC_YELLOW,Aspect_TOL_SOLID,1.);
365 return mySeenLineAspect;
368 void Prs3d_Drawer::SetSeenLineAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
369 mySeenLineAspect = anAspect;
372 Handle (Prs3d_LineAspect) Prs3d_Drawer::VectorAspect () {
373 if (myVectorAspect.IsNull())
374 myVectorAspect = new Prs3d_LineAspect
375 (Quantity_NOC_SKYBLUE,Aspect_TOL_SOLID,1.);
377 return myVectorAspect;
380 void Prs3d_Drawer::SetVectorAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
381 myVectorAspect = anAspect;
384 Handle (Prs3d_DatumAspect) Prs3d_Drawer::DatumAspect () {
385 if (myDatumAspect.IsNull())
386 myDatumAspect = new Prs3d_DatumAspect;
388 return myDatumAspect;
391 void Prs3d_Drawer::SetDatumAspect ( const Handle(Prs3d_DatumAspect)& anAspect) {
392 myDatumAspect = anAspect;
395 Handle (Prs3d_PlaneAspect) Prs3d_Drawer::PlaneAspect () {
396 if (myPlaneAspect.IsNull())
397 myPlaneAspect = new Prs3d_PlaneAspect;
399 return myPlaneAspect;
402 void Prs3d_Drawer::SetPlaneAspect ( const Handle(Prs3d_PlaneAspect)& anAspect) {
403 myPlaneAspect = anAspect;
406 // =======================================================================
407 // function : DimensionAspect
409 // =======================================================================
410 Handle(Prs3d_DimensionAspect) Prs3d_Drawer::DimensionAspect()
412 if (myDimensionAspect.IsNull())
414 myDimensionAspect = new Prs3d_DimensionAspect;
417 return myDimensionAspect;
420 // =======================================================================
421 // function : SetDimensionAspect
423 // =======================================================================
424 void Prs3d_Drawer::SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theAspect)
426 myDimensionAspect = theAspect;
429 // =======================================================================
430 // function : SetDimLengthModelUnits
432 // =======================================================================
433 void Prs3d_Drawer::SetDimLengthModelUnits (const TCollection_AsciiString& theUnits)
435 myDimensionModelUnits.SetLengthUnits (theUnits);
438 // =======================================================================
439 // function : SetDimAngleModelUnits
441 // =======================================================================
442 void Prs3d_Drawer::SetDimAngleModelUnits (const TCollection_AsciiString& theUnits)
444 myDimensionModelUnits.SetAngleUnits (theUnits);
447 // =======================================================================
448 // function : DimLengthModelUnits
450 // =======================================================================
451 const TCollection_AsciiString& Prs3d_Drawer::DimLengthModelUnits() const
453 return myDimensionModelUnits.GetLengthUnits();
456 // =======================================================================
457 // function : DimAngleModelUnits
459 // =======================================================================
460 const TCollection_AsciiString& Prs3d_Drawer::DimAngleModelUnits() const
462 return myDimensionModelUnits.GetAngleUnits();
465 // =======================================================================
466 // function : SetDimLengthDisplayUnits
468 // =======================================================================
469 void Prs3d_Drawer::SetDimLengthDisplayUnits (const TCollection_AsciiString& theUnits)
471 myDimensionDisplayUnits.SetLengthUnits (theUnits);
474 // =======================================================================
475 // function : SetDimAngleDisplayUnits
477 // =======================================================================
478 void Prs3d_Drawer::SetDimAngleDisplayUnits (const TCollection_AsciiString& theUnits)
480 myDimensionDisplayUnits.SetAngleUnits (theUnits);
483 // =======================================================================
484 // function : DimLengthDisplayUnits
486 // =======================================================================
487 const TCollection_AsciiString& Prs3d_Drawer::DimLengthDisplayUnits() const
489 return myDimensionDisplayUnits.GetLengthUnits();
492 // =======================================================================
493 // function : DimAngleDisplayUnits
495 // =======================================================================
496 const TCollection_AsciiString& Prs3d_Drawer::DimAngleDisplayUnits() const
498 return myDimensionDisplayUnits.GetAngleUnits();
501 // =======================================================================
502 // function : SectionAspect
504 // =======================================================================
505 Handle (Prs3d_LineAspect) Prs3d_Drawer::SectionAspect()
507 if (mySectionAspect.IsNull())
509 mySectionAspect = new Prs3d_LineAspect (Quantity_NOC_ORANGE, Aspect_TOL_SOLID, 1.0);
512 return mySectionAspect;
515 // =======================================================================
516 // function : SetSectionAspect
518 // =======================================================================
519 void Prs3d_Drawer::SetSectionAspect (const Handle(Prs3d_LineAspect)& theAspect)
521 mySectionAspect = theAspect;
524 // =======================================================================
525 // function : SetFaceBoundaryDraw
527 // =======================================================================
528 void Prs3d_Drawer::SetFaceBoundaryDraw (const Standard_Boolean theIsEnabled)
530 myFaceBoundaryDraw = theIsEnabled;
533 // =======================================================================
534 // function : IsFaceBoundaryDraw
536 // =======================================================================
537 Standard_Boolean Prs3d_Drawer::IsFaceBoundaryDraw () const
539 return myFaceBoundaryDraw;
542 // =======================================================================
543 // function : SetFaceBoundaryAspect
545 // =======================================================================
546 void Prs3d_Drawer::SetFaceBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
548 myFaceBoundaryAspect = theAspect;
551 // =======================================================================
552 // function : FaceBoundaryAspect
554 // =======================================================================
555 Handle_Prs3d_LineAspect Prs3d_Drawer::FaceBoundaryAspect ()
557 if (myFaceBoundaryAspect.IsNull ())
559 myFaceBoundaryAspect =
560 new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0);
563 return myFaceBoundaryAspect;
566 // =======================================================================
567 // function : SetTypeOfHLR
568 // purpose : set type of HLR algorithm
569 // =======================================================================
570 void Prs3d_Drawer::SetTypeOfHLR ( const Prs3d_TypeOfHLR theTypeOfHLR)
572 myTypeOfHLR = theTypeOfHLR;
575 // =======================================================================
576 // function : TypeOfHLR
577 // purpose : gets type of HLR algorithm
578 // =======================================================================
579 Prs3d_TypeOfHLR Prs3d_Drawer::TypeOfHLR ( ) const