|
||||
File indexing completed on 2025-01-18 10:03:24
0001 // Created on: 1991-04-24 0002 // Created by: Arnaud BOUZY 0003 // Copyright (c) 1991-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _Draw_HeaderFile 0018 #define _Draw_HeaderFile 0019 0020 #include <Draw_Interpretor.hxx> 0021 #include <NCollection_Map.hxx> 0022 #include <Quantity_ColorRGBA.hxx> 0023 #include <Standard_Handle.hxx> 0024 0025 class Draw_Drawable3D; 0026 class Draw_ProgressIndicator; 0027 0028 //! MAQUETTE DESSIN MODELISATION 0029 class Draw 0030 { 0031 public: 0032 0033 DEFINE_STANDARD_ALLOC 0034 0035 //! (Re)Load a Draw Harness plugin. 0036 //! @param theDI [in] [out] Tcl interpretor to append loaded commands 0037 //! @param theKey [in] plugin code name to be resolved in resource file 0038 //! @param theResourceFileName [in] description file name 0039 //! @param theDefaultsDirectory [in] default folder for looking description file 0040 //! @param theUserDefaultsDirectory [in] user folder for looking description file 0041 //! @param theIsVerbose [in] print verbose messages 0042 Standard_EXPORT static void Load (Draw_Interpretor& theDI, 0043 const TCollection_AsciiString& theKey, 0044 const TCollection_AsciiString& theResourceFileName, 0045 const TCollection_AsciiString& theDefaultsDirectory, 0046 const TCollection_AsciiString& theUserDefaultsDirectory, 0047 const Standard_Boolean theIsVerbose = Standard_False); 0048 0049 public: //! @name Tcl variables management tools 0050 0051 //! Sets a variable. Display it if <Disp> is true. 0052 Standard_EXPORT static void Set (const Standard_CString Name, const Handle(Draw_Drawable3D)& D, const Standard_Boolean Disp); 0053 0054 //! Sets a variable, a null handle clear the 0055 //! vartiable. Automatic display is context driven. 0056 Standard_EXPORT static void Set (const Standard_CString Name, const Handle(Draw_Drawable3D)& D); 0057 0058 //! Sets a numeric variable. 0059 Standard_EXPORT static void Set (const Standard_CString Name, const Standard_Real val); 0060 0061 //! Returns main DRAW interpretor. 0062 Standard_EXPORT static Draw_Interpretor& GetInterpretor(); 0063 0064 //! Returns a variable value. 0065 //! The name "." does a graphic selection; in this case theName will be is overwritten with the name of the variable. 0066 static Handle(Draw_Drawable3D) Get (Standard_CString& theName) { return getDrawable (theName, Standard_True); } 0067 0068 //! Returns a variable value. 0069 static Handle(Draw_Drawable3D) GetExisting (const Standard_CString& theName) 0070 { 0071 Standard_CString aName = theName; 0072 return getDrawable (aName, Standard_False); 0073 } 0074 0075 //! Gets a numeric variable. Returns True if the 0076 //! variable exist. 0077 Standard_EXPORT static Standard_Boolean Get (const Standard_CString Name, Standard_Real& val); 0078 0079 //! Sets a TCL string variable 0080 Standard_EXPORT static void Set (const Standard_CString Name, const Standard_CString val); 0081 0082 //! Returns a map of Draw_Drawable3D variables. 0083 Standard_EXPORT static const NCollection_Map<Handle(Draw_Drawable3D)>& Drawables(); 0084 0085 public: //! @name argument parsing tools 0086 0087 //! Converts numeric expression, that can involve DRAW 0088 //! variables, to real value. 0089 Standard_EXPORT static Standard_Real Atof (const Standard_CString Name); 0090 0091 //! Converts the numeric expression, that can involve DRAW variables, to a real value 0092 //! @param theExpressionString the strings that contains the expression involving DRAW variables to be parsed 0093 //! @param theParsedRealValue a real value that is a result of parsing 0094 //! @return true if parsing was successful, or false otherwise 0095 Standard_EXPORT static bool ParseReal (const Standard_CString theExpressionString, Standard_Real& theParsedRealValue); 0096 0097 //! Converts numeric expression, that can involve DRAW 0098 //! variables, to integer value. 0099 //! Implemented as cast of Atof() to integer. 0100 Standard_EXPORT static Standard_Integer Atoi (const Standard_CString Name); 0101 0102 //! Converts the numeric expression, that can involve DRAW variables, to an integer value 0103 //! @param theExpressionString the strings that contains the expression involving DRAW variables to be parsed 0104 //! @param theParsedIntegerValue an integer value that is a result of parsing 0105 //! @return true if parsing was successful, or false otherwise 0106 Standard_EXPORT static bool ParseInteger (const Standard_CString theExpressionString, 0107 Standard_Integer& theParsedIntegerValue); 0108 0109 //! Parses RGB(A) color argument(s) specified within theArgVec[0], theArgVec[1], theArgVec[2] and theArgVec[3]. 0110 //! Handles either color specified by name (single argument) or by RGB(A) components (3-4 arguments) in range 0..1. 0111 //! The result is stored in theColor on success. 0112 //! 0113 //! Usage code sample for command argument in form "cmd -color {ColorName|R G B [A]|ColorHex}": 0114 //! @code 0115 //! for (int anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) 0116 //! { 0117 //! TCollection_AsciiString aParam (theArgVec[anArgIter]); 0118 //! aParam.LowerCase(); 0119 //! if (aParam == "-color") 0120 //! { 0121 //! Quantity_ColorRGBA aColor; 0122 //! Standard_Integer aNbParsed = Draw::ParseColor (theArgNb - anArgIter - 1, 0123 //! theArgVec + anArgIter + 1, aColor); 0124 //! anArgIter += aNbParsed; 0125 //! if (aNbParsed == 0) { std::cerr << "Syntax error at '" << aParam << "'"; return 1; } 0126 //! // process color 0127 //! } 0128 //! } 0129 //! @endcode 0130 //! 0131 //! @param theArgNb [in] number of available arguments in theArgVec (array limits) 0132 //! @param theArgVec [in] argument list 0133 //! @param theColor [out] retrieved color 0134 //! @return number of handled arguments (1, 2, 3 or 4) or 0 on syntax error 0135 static Standard_Integer ParseColor (const Standard_Integer theArgNb, 0136 const char* const* const theArgVec, 0137 Quantity_ColorRGBA& theColor) 0138 { 0139 return parseColor (theArgNb, theArgVec, theColor, true); 0140 } 0141 0142 //! Parses RGB color argument(s). 0143 //! @param theArgNb [in] number of available arguments in theArgVec (array limits) 0144 //! @param theArgVec [in] argument list 0145 //! @param theColor [out] retrieved color 0146 //! @return number of handled arguments (1 or 3) or 0 on syntax error. 0147 static Standard_Integer ParseColor (const Standard_Integer theArgNb, 0148 const char* const* const theArgVec, 0149 Quantity_Color& theColor) 0150 { 0151 Quantity_ColorRGBA anRgba; 0152 const Standard_Integer aNbParsed = parseColor (theArgNb, theArgVec, anRgba, false); 0153 if (aNbParsed != 0) 0154 { 0155 theColor = anRgba.GetRGB(); 0156 } 0157 return aNbParsed; 0158 } 0159 0160 //! Parses boolean argument. Handles either flag specified by 0|1 or on|off. 0161 //! 0162 //! Usage code sample for command argument in form "cmd -usefeature [on|off|1|0]=on": 0163 //! @code 0164 //! for (int anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) 0165 //! { 0166 //! TCollection_AsciiString aParam (theArgVec[anArgIter]); 0167 //! aParam.LowerCase(); 0168 //! if (aParam == "-usefeature") 0169 //! { 0170 //! bool toUseFeature = true; 0171 //! if (anArgIter + 1 < theNbArgs && Draw::ParseOnOff (theArgVec[anArgIter + 1])) 0172 //! { 0173 //! ++anArgIter; 0174 //! } 0175 //! // process feature 0176 //! } 0177 //! } 0178 //! @endcode 0179 //! 0180 //! @param theArg [in] argument value 0181 //! @param theIsOn [out] decoded Boolean flag 0182 //! @return FALSE on syntax error 0183 Standard_EXPORT static Standard_Boolean ParseOnOff (Standard_CString theArg, 0184 Standard_Boolean& theIsOn); 0185 0186 //! Parses boolean argument at specified iterator position with optional on/off coming next. 0187 //! 0188 //! Usage code sample for command argument in form "cmd -usefeature [on|off|1|0]=on": 0189 //! @code 0190 //! for (int anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) 0191 //! { 0192 //! if (strcasecmp (theArgVec[anArgIter], "-usefeature") == 0) 0193 //! { 0194 //! bool toUseFeature = Draw::ParseOnOffIterator (theNbArgs, theArgVec, anArgIter); 0195 //! // process feature 0196 //! } 0197 //! } 0198 //! @endcode 0199 //! 0200 //! @param theArgsNb [in] overall number of arguments 0201 //! @param theArgVec [in] vector of arguments 0202 //! @param theArgIter [in] [out] argument position to parse 0203 //! @return flag value 0204 Standard_EXPORT static Standard_Boolean ParseOnOffIterator (Standard_Integer theArgsNb, 0205 const char** theArgVec, 0206 Standard_Integer& theArgIter); 0207 0208 //! Parses boolean argument at specified iterator position with optional on/off coming next. 0209 //! Similar to ParseOnOffIterator() but also reverses returned value if argument name starts with "no" prefix. 0210 //! E.g. if nominal argument is "cmd -usefeature [on|off|1|0]=on", then "-nousefeature" argument will return FALSE. 0211 //! @param theArgsNb [in] overall number of arguments 0212 //! @param theArgVec [in] vector of arguments 0213 //! @param theArgIter [in] [out] argument position to parse 0214 //! @return flag value 0215 Standard_EXPORT static Standard_Boolean ParseOnOffNoIterator (Standard_Integer theArgsNb, 0216 const char** theArgVec, 0217 Standard_Integer& theArgIter); 0218 0219 public: 0220 0221 //! Returns last graphic selection description. 0222 Standard_EXPORT static void LastPick (Standard_Integer& view, Standard_Integer& X, Standard_Integer& Y, Standard_Integer& button); 0223 0224 //! Asks to repaint the screen after the current command. 0225 Standard_EXPORT static void Repaint(); 0226 0227 //! sets progress indicator 0228 Standard_EXPORT static void SetProgressBar (const Handle(Draw_ProgressIndicator)& theProgress); 0229 0230 //! gets progress indicator 0231 Standard_EXPORT static Handle(Draw_ProgressIndicator) GetProgressBar(); 0232 0233 public: //! @name methods loading standard command sets 0234 0235 //! Defines all Draw commands 0236 Standard_EXPORT static void Commands (Draw_Interpretor& I); 0237 0238 //! Defines Draw basic commands 0239 Standard_EXPORT static void BasicCommands (Draw_Interpretor& I); 0240 0241 //! Defines Draw message commands 0242 Standard_EXPORT static void MessageCommands (Draw_Interpretor& I); 0243 0244 //! Defines Draw variables handling commands. 0245 Standard_EXPORT static void VariableCommands (Draw_Interpretor& I); 0246 0247 //! Defines Draw variables handling commands. 0248 Standard_EXPORT static void GraphicCommands (Draw_Interpretor& I); 0249 0250 //! Defines Loads Draw plugins commands. 0251 Standard_EXPORT static void PloadCommands (Draw_Interpretor& I); 0252 0253 //! Defines Draw unit commands 0254 Standard_EXPORT static void UnitCommands (Draw_Interpretor& I); 0255 0256 protected: 0257 0258 //! Returns a variable value. 0259 //! @param theName [in] [out] variable name, or "." to activate picking 0260 //! @param theToAllowPick [in] when TRUE, "." name will activate picking 0261 Standard_EXPORT static Handle(Draw_Drawable3D) getDrawable (Standard_CString& theName, 0262 Standard_Boolean theToAllowPick); 0263 0264 //! Parses RGB(A) color argument(s) specified within theArgVec[0], theArgVec[1], theArgVec[2] and theArgVec[3]. 0265 //! Handles either color specified by name (single argument) 0266 //! or by RGB(A) components (3-4 arguments) in range 0..1. 0267 //! The result is stored in theColor on success. 0268 //! Returns number of handled arguments (1, 2, 3 or 4) or 0 on syntax error. 0269 Standard_EXPORT static Standard_Integer parseColor (Standard_Integer theArgNb, 0270 const char* const* theArgVec, 0271 Quantity_ColorRGBA& theColor, 0272 bool theToParseAlpha); 0273 0274 }; 0275 0276 #endif // _Draw_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |