summaryrefslogtreecommitdiff
path: root/src/DrawDim/DrawDim_Dimension.cxx
blob: 2a59ea7cf0306dd5c9a64e0dad96e4d04a9a1e7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// File:	DrawDim_Dimension.cxx
// Created:	Mon Apr 21 15:30:02 1997
// Author:	Denis PASCAL
//		<dp@dingox.paris1.matra-dtv.fr>


#include <DrawDim_Dimension.ixx>
#include <Standard_DomainError.hxx>
#include <Draw_Interpretor.hxx>
#include <TCollection_AsciiString.hxx>


//=======================================================================
//function : DrawDim_Dimension
//purpose  : 
//=======================================================================

DrawDim_Dimension::DrawDim_Dimension()
     : is_valued(Standard_False),
       myTextColor(Draw_blanc)
{
}

//=======================================================================
//function : SetValue
//purpose  : 
//=======================================================================

void DrawDim_Dimension::SetValue (const Standard_Real avalue)
{
  is_valued = Standard_True;
  myValue = avalue;
}

//=======================================================================
//function : GetValue
//purpose  : 
//=======================================================================

Standard_Real DrawDim_Dimension::GetValue() const 
{
  if (!is_valued) Standard_DomainError::Raise();
  return myValue;
}

//=======================================================================
//function : IsValued
//purpose  : 
//=======================================================================

Standard_Boolean DrawDim_Dimension::IsValued() const 
{
  return is_valued;
}

//=======================================================================
//function : TextColor
//purpose  : 
//=======================================================================

Draw_Color DrawDim_Dimension::TextColor() const
{
  return myTextColor;
}

//=======================================================================
//function : TextColor
//purpose  : 
//=======================================================================

void DrawDim_Dimension::TextColor(const Draw_Color& C)
{
   myTextColor = C;
}

//=======================================================================
//function : DrawText
//purpose  : 
//=======================================================================

void DrawDim_Dimension::DrawText(const gp_Pnt& P, Draw_Display& D) const
{
  TCollection_AsciiString t = Name();
  if (is_valued) {
    t+="=";
    Standard_Integer l = t.Length();
    t+= myValue;
    for (Standard_Integer i = l; i <= t.Length(); i++) {
      if (t.Value(i) == '.') { t.Trunc(i+2); break; }
    }
  }

  D.SetColor(myTextColor);
  D.DrawString(P,t.ToCString());
}