7fd59977 |
1 | // File: DrawDim_Dimension.cxx |
2 | // Created: Mon Apr 21 15:30:02 1997 |
3 | // Author: Denis PASCAL |
4 | // <dp@dingox.paris1.matra-dtv.fr> |
5 | |
6 | |
7 | #include <DrawDim_Dimension.ixx> |
8 | #include <Standard_DomainError.hxx> |
9 | #include <Draw_Interpretor.hxx> |
10 | #include <TCollection_AsciiString.hxx> |
11 | |
12 | |
13 | //======================================================================= |
14 | //function : DrawDim_Dimension |
15 | //purpose : |
16 | //======================================================================= |
17 | |
18 | DrawDim_Dimension::DrawDim_Dimension() |
19 | : is_valued(Standard_False), |
20 | myTextColor(Draw_blanc) |
21 | { |
22 | } |
23 | |
24 | //======================================================================= |
25 | //function : SetValue |
26 | //purpose : |
27 | //======================================================================= |
28 | |
29 | void DrawDim_Dimension::SetValue (const Standard_Real avalue) |
30 | { |
31 | is_valued = Standard_True; |
32 | myValue = avalue; |
33 | } |
34 | |
35 | //======================================================================= |
36 | //function : GetValue |
37 | //purpose : |
38 | //======================================================================= |
39 | |
40 | Standard_Real DrawDim_Dimension::GetValue() const |
41 | { |
42 | if (!is_valued) Standard_DomainError::Raise(); |
43 | return myValue; |
44 | } |
45 | |
46 | //======================================================================= |
47 | //function : IsValued |
48 | //purpose : |
49 | //======================================================================= |
50 | |
51 | Standard_Boolean DrawDim_Dimension::IsValued() const |
52 | { |
53 | return is_valued; |
54 | } |
55 | |
56 | //======================================================================= |
57 | //function : TextColor |
58 | //purpose : |
59 | //======================================================================= |
60 | |
61 | Draw_Color DrawDim_Dimension::TextColor() const |
62 | { |
63 | return myTextColor; |
64 | } |
65 | |
66 | //======================================================================= |
67 | //function : TextColor |
68 | //purpose : |
69 | //======================================================================= |
70 | |
71 | void DrawDim_Dimension::TextColor(const Draw_Color& C) |
72 | { |
73 | myTextColor = C; |
74 | } |
75 | |
76 | //======================================================================= |
77 | //function : DrawText |
78 | //purpose : |
79 | //======================================================================= |
80 | |
81 | void DrawDim_Dimension::DrawText(const gp_Pnt& P, Draw_Display& D) const |
82 | { |
83 | TCollection_AsciiString t = Name(); |
84 | if (is_valued) { |
85 | t+="="; |
86 | Standard_Integer l = t.Length(); |
87 | t+= myValue; |
88 | for (Standard_Integer i = l; i <= t.Length(); i++) { |
89 | if (t.Value(i) == '.') { t.Trunc(i+2); break; } |
90 | } |
91 | } |
92 | |
93 | D.SetColor(myTextColor); |
94 | D.DrawString(P,t.ToCString()); |
95 | } |