1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #include <Prs3d_DimensionAspect.hxx>
17 #include <Aspect_TypeOfLine.hxx>
18 #include <Graphic3d_AspectText3d.hxx>
19 #include <Standard_Dump.hxx>
21 IMPLEMENT_STANDARD_RTTIEXT(Prs3d_DimensionAspect, Prs3d_BasicAspect)
23 //=======================================================================
24 //function : Constructor
26 //=======================================================================
27 Prs3d_DimensionAspect::Prs3d_DimensionAspect()
28 : myLineAspect (new Prs3d_LineAspect (Quantity_NOC_LAWNGREEN, Aspect_TOL_SOLID, 1.0)),
29 myTextAspect (new Prs3d_TextAspect()),
30 myArrowAspect (new Prs3d_ArrowAspect()),
31 myValueStringFormat ("%g"),
32 myExtensionSize (6.0),
33 myArrowTailSize (6.0),
34 myArrowOrientation (Prs3d_DAO_Fit),
35 myTextHPosition (Prs3d_DTHP_Fit),
36 myTextVPosition (Prs3d_DTVP_Center),
37 myToDisplayUnits (Standard_False),
38 myIsText3d (Standard_False),
39 myIsTextShaded (Standard_False),
40 myIsArrows3d (Standard_False)
42 myTextAspect->Aspect()->SetTextZoomable (Standard_False);
43 myTextAspect->SetColor (Quantity_NOC_LAWNGREEN);
44 myTextAspect->SetHorizontalJustification (Graphic3d_HTA_CENTER);
45 myTextAspect->SetVerticalJustification (Graphic3d_VTA_CENTER);
47 myArrowAspect->SetColor (Quantity_NOC_LAWNGREEN);
48 myArrowAspect->SetAngle (M_PI * 12.0 / 180.0);
49 myArrowAspect->SetLength (6.0);
52 //=======================================================================
53 //function : SetCommonColor
54 //purpose : Sets the same color for all parts of dimension:
55 // lines, arrows and text.
56 //=======================================================================
57 void Prs3d_DimensionAspect::SetCommonColor (const Quantity_Color& theColor)
59 myLineAspect->SetColor (theColor);
60 myTextAspect->SetColor (theColor);
61 myArrowAspect->SetColor (theColor);
64 // =======================================================================
65 // function : DumpJson
67 // =======================================================================
68 void Prs3d_DimensionAspect::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
70 OCCT_DUMP_CLASS_BEGIN (theOStream, Prs3d_DimensionAspect);
72 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myLineAspect.get());
73 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTextAspect.get());
74 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myArrowAspect.get());
76 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myValueStringFormat);
77 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myExtensionSize);
78 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myArrowTailSize);
79 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myArrowOrientation);
80 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTextHPosition);
81 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myTextVPosition);
82 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myToDisplayUnits);
83 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsText3d);
84 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsTextShaded);
85 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsArrows3d);