0030623: Draw Harness - support hex color codes within ViewerTest::ParseColor()
[occt.git] / src / Draw / Draw.hxx
1 // Created on: 1991-04-24
2 // Created by: Arnaud BOUZY
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _Draw_HeaderFile
18 #define _Draw_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
23
24 #include <Draw_Interpretor.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <Standard_CString.hxx>
27 #include <Standard_Real.hxx>
28 #include <Standard_Integer.hxx>
29 class TCollection_AsciiString;
30 class Draw_Drawable3D;
31 class Draw_ProgressIndicator;
32 class Draw_Drawable3D;
33 class Draw_Drawable2D;
34 class Draw_Color;
35 class Draw_Display;
36 class Draw_Segment3D;
37 class Draw_Segment2D;
38 class Draw_Marker3D;
39 class Draw_Marker2D;
40 class Draw_Axis3D;
41 class Draw_Axis2D;
42 class Draw_Text3D;
43 class Draw_Text2D;
44 class Draw_Circle3D;
45 class Draw_Circle2D;
46 class Draw_Number;
47 class Draw_Chronometer;
48 class Draw_Grid;
49 class Draw_Box;
50 class Draw_ProgressIndicator;
51 class Draw_Printer;
52
53
54 //! MAQUETTE DESSIN MODELISATION
55 class Draw 
56 {
57 public:
58
59   DEFINE_STANDARD_ALLOC
60
61   
62   Standard_EXPORT static void Load (Draw_Interpretor& theDI, const TCollection_AsciiString& theKey, const TCollection_AsciiString& theResourceFileName, TCollection_AsciiString& theDefaultsDirectory, TCollection_AsciiString& theUserDefaultsDirectory, const Standard_Boolean Verbose = Standard_False);
63   
64   //! Sets a variable. Display it if <Disp> is true.
65   Standard_EXPORT static void Set (const Standard_CString Name, const Handle(Draw_Drawable3D)& D, const Standard_Boolean Disp);
66   
67   //! Sets a    variable,  a  null   handle    clear the
68   //! vartiable. Automatic display is context driven.
69   Standard_EXPORT static void Set (const Standard_CString Name, const Handle(Draw_Drawable3D)& D);
70   
71   //! Sets a numeric variable.
72   Standard_EXPORT static void Set (const Standard_CString Name, const Standard_Real val);
73
74   //! Returns main DRAW interpretor.
75   Standard_EXPORT static Draw_Interpretor& GetInterpretor();
76
77   //! Returns a variable value.
78   //! The name "." does a graphic selection; in this case theName will be is overwritten with the name of the variable.
79   static Handle(Draw_Drawable3D) Get (Standard_CString& theName) { return getDrawable (theName, Standard_True); }
80
81   //! Returns a variable value.
82   static Handle(Draw_Drawable3D) GetExisting (const Standard_CString& theName)
83   {
84     Standard_CString aName = theName;
85     return getDrawable (aName, Standard_False);
86   }
87
88   //! Gets a   numeric  variable. Returns  True   if the
89   //! variable exist.
90   Standard_EXPORT static Standard_Boolean Get (const Standard_CString Name, Standard_Real& val);
91   
92   //! Sets a TCL sting variable
93   Standard_EXPORT static void Set (const Standard_CString Name, const Standard_CString val);
94   
95   //! Converts numeric expression, that can involve DRAW
96   //! variables, to real value.
97   Standard_EXPORT static Standard_Real Atof (const Standard_CString Name);
98
99   //! Converts the numeric expression, that can involve DRAW variables, to a real value
100   //! @param theExpressionString the strings that containes the expression involving DRAW variables to be parsed
101   //! @param theParsedRealValue a real value that is a result of parsing
102   //! @return true if parsing was successfull, or false otherwise
103   Standard_EXPORT static bool ParseReal (const Standard_CString theExpressionString, Standard_Real& theParsedRealValue);
104
105   //! Converts numeric expression, that can involve DRAW
106   //! variables, to integer value.
107   //! Implemented as cast of Atof() to integer.
108   Standard_EXPORT static Standard_Integer Atoi (const Standard_CString Name);
109
110   //! Converts the numeric expression, that can involve DRAW variables, to an integer value
111   //! @param theExpressionString the strings that containes the expression involving DRAW variables to be parsed
112   //! @param theParsedIntegerValue an integer value that is a result of parsing
113   //! @return true if parsing was successfull, or false otherwise
114   Standard_EXPORT static bool ParseInteger (const Standard_CString theExpressionString,
115                                             Standard_Integer&      theParsedIntegerValue);
116
117   //! Returns last graphic selection description.
118   Standard_EXPORT static void LastPick (Standard_Integer& view, Standard_Integer& X, Standard_Integer& Y, Standard_Integer& button);
119   
120   //! Asks to repaint the screen after the current command.
121   Standard_EXPORT static void Repaint();
122   
123   //! sets progress indicator
124   Standard_EXPORT static void SetProgressBar (const Handle(Draw_ProgressIndicator)& thePI);
125   
126   //! gets progress indicator
127   Standard_EXPORT static Handle(Draw_ProgressIndicator) GetProgressBar();
128   
129   //! Defines all Draw commands
130   Standard_EXPORT static void Commands (Draw_Interpretor& I);
131   
132   //! Defines Draw basic commands
133   Standard_EXPORT static void BasicCommands (Draw_Interpretor& I);
134   
135   //! Defines Draw variables handling commands.
136   Standard_EXPORT static void VariableCommands (Draw_Interpretor& I);
137   
138   //! Defines Draw variables handling commands.
139   Standard_EXPORT static void GraphicCommands (Draw_Interpretor& I);
140   
141   //! Defines Loads Draw plugins commands.
142   Standard_EXPORT static void PloadCommands (Draw_Interpretor& I);
143   
144   //! Defines Draw unit commands
145   Standard_EXPORT static void UnitCommands (Draw_Interpretor& I);
146
147 protected:
148
149   //! Returns a variable value.
150   //! @param theName [in] [out] variable name, or "." to activate picking
151   //! @param theToAllowPick [in] when TRUE, "." name will activate picking
152   Standard_EXPORT static Handle(Draw_Drawable3D) getDrawable (Standard_CString& theName,
153                                                               Standard_Boolean theToAllowPick);
154
155 private:
156
157 friend class Draw_Drawable3D;
158 friend class Draw_Drawable2D;
159 friend class Draw_Color;
160 friend class Draw_Display;
161 friend class Draw_Segment3D;
162 friend class Draw_Segment2D;
163 friend class Draw_Marker3D;
164 friend class Draw_Marker2D;
165 friend class Draw_Axis3D;
166 friend class Draw_Axis2D;
167 friend class Draw_Text3D;
168 friend class Draw_Text2D;
169 friend class Draw_Circle3D;
170 friend class Draw_Circle2D;
171 friend class Draw_Number;
172 friend class Draw_Chronometer;
173 friend class Draw_Grid;
174 friend class Draw_Box;
175 friend class Draw_ProgressIndicator;
176 friend class Draw_Printer;
177
178 };
179
180
181
182
183
184
185
186 #endif // _Draw_HeaderFile