1 // Created on: 1995-02-23
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
19 #include <Standard_Stream.hxx>
20 #include <Standard_SStream.hxx>
22 #include <Draw_Display.hxx>
23 #include <Draw_Appli.hxx>
24 #include <Draw_Number.hxx>
25 #include <Draw_Axis3D.hxx>
26 #include <Draw_Axis2D.hxx>
27 #include <Draw_Grid.hxx>
28 #include <Draw_Drawable3D.hxx>
29 #include <Draw_SequenceOfDrawable3D.hxx>
30 #include <Draw_ProgressIndicator.hxx>
32 #include <NCollection_Map.hxx>
37 extern Draw_Viewer dout;
43 #include <OSD_Environment.hxx>
44 #include <OSD_OpenFile.hxx>
46 Standard_Boolean Draw_ParseFailed;
48 static Standard_Boolean autodisp = Standard_True;
49 static Standard_Boolean repaint2d,repaint3d;
51 extern Draw_Interpretor theCommands;
53 //===============================================
54 // dictionnary of variables
55 // Variables are stored in a map Integer, Transient
56 // The Integer Value is the content of the TCl variable
57 //===============================================
59 static NCollection_Map<Handle(Draw_Drawable3D)> theVariables;
61 //=======================================================================
62 //function : FindVariable
64 //=======================================================================
66 static Standard_Integer p_id;
67 static Standard_Integer p_X;
68 static Standard_Integer p_Y;
69 static Standard_Integer p_b;
70 static const char* p_Name = "";
73 static Draw_SaveAndRestore* Draw_First = NULL;
75 //=======================================================================
76 //function : Draw_SaveAndRestore
78 //=======================================================================
80 Draw_SaveAndRestore::Draw_SaveAndRestore
82 Standard_Boolean (*test)(const Handle(Draw_Drawable3D)&),
83 void (*save)(const Handle(Draw_Drawable3D)&, ostream&),
84 Handle(Draw_Drawable3D) (*restore) (istream&),
85 Standard_Boolean display) :
96 Standard_Boolean Draw_SaveAndRestore::Test(const Handle(Draw_Drawable3D)&d)
97 {return (*myTest) (d);}
99 void Draw_SaveAndRestore::Save(const Handle(Draw_Drawable3D)& d,
103 Handle(Draw_Drawable3D) Draw_SaveAndRestore::Restore(istream& is) const
104 {return (*myRestore) (is);}
106 //=======================================================================
107 // numeric save and restore
108 //=======================================================================
110 static Standard_Boolean numtest(const Handle(Draw_Drawable3D)& d)
112 return d->IsInstance(STANDARD_TYPE(Draw_Number));
115 static void numsave (const Handle(Draw_Drawable3D)& theDrawable,
118 Handle(Draw_Number) aNum = Handle(Draw_Number)::DownCast (theDrawable);
119 ios::fmtflags aFlags = theStream.flags();
120 theStream.setf (ios::scientific);
121 theStream.precision (15);
122 theStream.width (30);
123 theStream << aNum->Value() << "\n";
124 theStream.setf (aFlags);
127 static Handle(Draw_Drawable3D) numrestore (istream& is)
131 Handle(Draw_Number) N = new Draw_Number(val);
136 static Draw_SaveAndRestore numsr("Draw_Number",
137 numtest,numsave,numrestore,
140 //=======================================================================
142 //=======================================================================
144 static Standard_Integer save(Draw_Interpretor& di, Standard_Integer n, const char** a)
146 if (n <= 2) return 1;
149 const char* name = a[2];
152 OSD_OpenStream(os, name, ios::out);
153 if (!os.rdbuf()->is_open()) {
154 di << "Cannot open file for writing "<<name;
158 Handle(Draw_Drawable3D) D = Draw::Get(a[1]);
161 Draw_SaveAndRestore* tool = Draw_First;
162 Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
163 progress->SetScale ( 0, 100, 1 );
164 progress->NewScope(100,"Writing");
168 if (tool->Test(D)) break;
172 os << tool->Name() << "\n";
173 Draw::SetProgressBar(progress);
178 di << "No method for saving " << a[1];
181 Draw::SetProgressBar( 0 );
182 progress->EndScope();
188 Standard_Boolean res = Standard_False;
192 res = os.good() && !errno;
195 di<<"File has not been written";
203 //=======================================================================
205 //=======================================================================
207 static Standard_Integer restore(Draw_Interpretor& di, Standard_Integer n, const char** a)
210 if (n <= 2) return 1;
212 const char* fname = a[1];
213 const char* name = a[2];
217 OSD_OpenFileBuf(fic,fname,ios::in);
218 if (!fic.is_open()) {
219 di << "Cannot open file for reading : "<<fname;
227 Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
228 progress->NewScope(100,"Reading");
231 Draw_SaveAndRestore* tool = Draw_First;
233 if (!strcmp(typ,tool->Name())) break;
234 Draw::SetProgressBar(progress);
238 Handle(Draw_Drawable3D) D = tool->Restore(in);
239 Draw::Set(name,D,tool->Disp() && autodisp);
242 di << "Cannot restore a " << typ;
245 Draw::SetProgressBar( 0 );
246 progress->EndScope();
254 //=======================================================================
256 //=======================================================================
258 static Standard_Integer display(Draw_Interpretor& di, Standard_Integer n, const char** a)
260 if (n <= 1) return 1;
262 for (Standard_Integer i = 1; i < n; i++) {
263 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
275 //=======================================================================
276 // erase, clear, donly
277 //=======================================================================
279 static Standard_Integer erase(Draw_Interpretor& di, Standard_Integer n, const char** a)
281 static Standard_Boolean draw_erase_mute = Standard_False;
283 if (!strcasecmp(a[1],"-mute")) {
284 draw_erase_mute = Standard_True;
289 Standard_Boolean donly = !strcasecmp(a[0],"donly");
291 if (n <= 1 || donly) {
292 // clear, 2dclear, donly, erase (without arguments)
295 // solve the names for "." before erasing
297 for (i = 1; i < n; i++) {
298 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
300 if ((a[i][0] == '.') && (a[i][1] == '\0'))
301 cout << "Missed !!!" << endl;
307 // sauvegarde des proteges visibles
308 Draw_SequenceOfDrawable3D prot;
309 NCollection_Map<Handle(Draw_Drawable3D)>::Iterator aMapIt (theVariables);
310 for (; aMapIt.More(); aMapIt.Next()) {
311 const Handle(Draw_Drawable3D)& D = aMapIt.Key();
313 if (D->Protected() && D->Visible())
318 // effacement de toutes les variables
319 Standard_Integer erasemode = 1;
320 if (a[0][0] == '2') erasemode = 2;
321 if (a[0][0] == 'c') erasemode = 3;
323 // effacement des graphiques non variables
326 else if (erasemode == 3)
331 // affichage pour donly
333 for (i = 1; i < n; i++) {
334 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
338 if (!draw_erase_mute) di << a[i] << " ";
344 // afficahge des proteges
345 for (i = 1; i <= prot.Length(); i++)
351 for (Standard_Integer i = 1; i < n; i++) {
352 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
355 dout.RemoveDrawable(D);
356 if (!draw_erase_mute) di << D->Name() << " ";
363 draw_erase_mute = Standard_False;
364 repaint2d = Standard_False;
365 repaint3d = Standard_False;
372 //=======================================================================
374 //=======================================================================
376 static Standard_Integer draw(Draw_Interpretor& , Standard_Integer n, const char** a)
379 Standard_Integer id = Draw::Atoi(a[1]);
380 if (!dout.HasView(id)) {
381 cout << "bad view number in draw"<<endl;
384 Standard_Integer mo = Draw::Atoi(a[2]);
385 Draw_Display d = dout.MakeDisplay(id);
388 for (i = 3; i < n; i++) {
389 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
390 if (!D.IsNull()) D->DrawOn(d);
396 //=======================================================================
397 // protect, unprotect
398 //=======================================================================
400 static Standard_Integer protect(Draw_Interpretor& di, Standard_Integer n, const char** a)
402 if (n <= 1) return 1;
403 Standard_Boolean prot = *a[0] != 'u';
404 for (Standard_Integer i = 1; i < n; i++) {
405 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
414 //=======================================================================
416 //=======================================================================
418 static Standard_Integer autodisplay(Draw_Interpretor& di, Standard_Integer n, const char** a)
421 autodisp = !autodisp;
423 autodisp = !(!strcasecmp(a[1],"0"));
434 //=======================================================================
436 //=======================================================================
438 static Standard_Integer whatis(Draw_Interpretor& di, Standard_Integer n, const char** a)
440 if (n <= 1) return 1;
441 for (Standard_Integer i = 1; i < n; i++) {
442 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
451 //=======================================================================
453 //=======================================================================
455 static Standard_Integer value(Draw_Interpretor& di, Standard_Integer n, const char** a)
457 if (n != 2) return 1;
458 di << Draw::Atof(a[1]);
463 //=======================================================================
466 //=======================================================================
467 static Standard_Integer dname(Draw_Interpretor& di, Standard_Integer n, const char** a)
473 Standard_PCharacter pC;
475 Handle(Draw_Drawable3D) aD;
477 for (i = 1; i < n; ++i) {
478 aD = Draw::Get(a[i]);
480 //modified by NIZNHY-PKV Tue Jun 10 10:18:13 2008f
482 pC=(Standard_PCharacter)aD->Name();
484 //modified by NIZNHY-PKV Tue Jun 10 10:18:18 2008t
490 //=======================================================================
492 //=======================================================================
495 static Standard_Integer dump(Draw_Interpretor& DI, Standard_Integer n, const char** a)
499 for (i = 1; i < n; i++) {
500 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
502 Standard_SStream sss;
504 sss << "\n\n*********** Dump of " << a[i] << " *************\n";
512 //=======================================================================
514 //=======================================================================
516 static Standard_Integer copy(Draw_Interpretor& , Standard_Integer n, const char** a)
519 Standard_Boolean cop = !strcasecmp(a[0],"copy");
521 Handle(Draw_Drawable3D) D;
522 for (Standard_Integer i = 1; i < n; i += 2) {
523 if (i+1 >= n) return 0;
530 Draw::Set(a[i],Handle(Draw_Drawable3D()));
538 //=======================================================================
541 //=======================================================================
543 static Standard_Integer repaintall(Draw_Interpretor& , Standard_Integer , const char** )
545 if (repaint2d) dout.Repaint2D();
546 repaint2d = Standard_False;
547 if (repaint3d) dout.Repaint3D();
548 repaint3d = Standard_False;
553 //=======================================================================
556 //=======================================================================
558 static Standard_Integer set(Draw_Interpretor& di, Standard_Integer n, const char** a)
561 Standard_Integer i = 1;
563 for (i = 1; i < n; i += 2) {
565 if (i+1 < n) val = Draw::Atof(a[i+1]);
572 //=======================================================================
575 //=======================================================================
577 static Standard_Integer dsetenv(Draw_Interpretor& /*di*/, Standard_Integer argc, const char** argv)
580 cout << "Use: " << argv[0] << " {varname} [value]" << endl;
584 OSD_Environment env (argv[1]);
585 if (argc > 2 && argv[2][0] != '\0')
587 env.SetValue (argv[2]);
595 //=======================================================================
598 //=======================================================================
600 static Standard_Integer dgetenv(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
603 cout << "Use: " << argv[0] << " {varname}" << endl;
607 const char* val = getenv (argv[1]);
608 di << ( val ? val : "" );
612 //=======================================================================
615 //=======================================================================
617 static Standard_Integer isdraw(Draw_Interpretor& di, Standard_Integer n, const char** a)
619 if (n != 2) return 1;
620 Handle(Draw_Drawable3D) D = Draw::Get(a[1],Standard_False);
628 //=======================================================================
631 //=======================================================================
633 Standard_Integer isprot(Draw_Interpretor& di, Standard_Integer n, const char** a)
635 if (n != 2) return 1;
636 Handle(Draw_Drawable3D) D = Draw::Get(a[1],Standard_False);
649 //=======================================================================
652 //=======================================================================
654 static Standard_Integer pick(Draw_Interpretor& , Standard_Integer n, const char** a)
658 Standard_Integer X,Y,b;
659 Standard_Boolean wait = (n == 6);
660 if (!wait) id = Draw::Atoi(a[1]);
661 dout.Select(id,X,Y,b,wait);
662 Standard_Real z = dout.Zoom(id);
663 gp_Pnt P((Standard_Real)X /z,(Standard_Real)Y /z,0);
669 Draw::Set(a[2],P.X());
670 Draw::Set(a[3],P.Y());
671 Draw::Set(a[4],P.Z());
677 //=======================================================================
680 //=======================================================================
682 static Standard_Integer lastrep(Draw_Interpretor& di, Standard_Integer n, const char** a)
686 Draw::Set(a[1],p_id);
692 Standard_Real z = dout.Zoom(p_id);
693 gp_Pnt P((Standard_Real)p_X /z,(Standard_Real)p_Y /z,0);
695 dout.GetTrsf(p_id,T);
698 Draw::Set(a[2],P.X());
699 Draw::Set(a[3],P.Y());
700 Draw::Set(a[4],P.Z());
703 di << "Too many args";
706 Draw::Set(a[n-1],p_b);
712 //=======================================================================
715 //=======================================================================
716 void Draw::Set(const Standard_CString name,
717 const Handle(Draw_Drawable3D)& D)
719 Draw::Set(name,D,autodisp);
723 static char* tracevar(ClientData CD, Tcl_Interp*,const char* name,const char*, int)
725 // protect if the map was destroyed before the interpretor
726 if (theVariables.IsEmpty()) return NULL;
728 // MSV 9.10.14 CR25344
729 Handle(Draw_Drawable3D) D(reinterpret_cast<Draw_Drawable3D*>(CD));
731 Tcl_UntraceVar(theCommands.Interp(),name,TCL_TRACE_UNSETS | TCL_TRACE_WRITES,
735 if (D->Protected()) {
736 D->Name(Tcl_SetVar(theCommands.Interp(),name,name,0));
737 return (char*) "variable is protected";
740 dout.RemoveDrawable(D);
742 repaint3d = Standard_True;
744 repaint2d = Standard_True;
746 Tcl_UntraceVar(theCommands.Interp(),name,TCL_TRACE_UNSETS | TCL_TRACE_WRITES,
748 theVariables.Remove(D);
753 //=======================================================================
756 //=======================================================================
757 void Draw::Set(const Standard_CString name,
758 const Handle(Draw_Drawable3D)& D,
759 const Standard_Boolean displ)
761 if ((name[0] == '.') && (name[1] == '\0')) {
763 dout.RemoveDrawable(D);
764 if (displ) dout << D;
768 // Check if the variable with the same name exists
770 Tcl_VarTraceInfo(theCommands.Interp(),name,TCL_TRACE_UNSETS | TCL_TRACE_WRITES,
772 Handle(Draw_Drawable3D) anOldD(reinterpret_cast<Draw_Drawable3D*>(aCD));
773 if (!anOldD.IsNull()) {
774 if (theVariables.Contains(anOldD) && anOldD->Protected()) {
775 cout << "variable is protected" << endl;
781 Tcl_UnsetVar(theCommands.Interp(),name,0);
785 D->Name(Tcl_SetVar(theCommands.Interp(),name,name,0));
787 // set the trace function
788 Tcl_TraceVar(theCommands.Interp(),name,TCL_TRACE_UNSETS | TCL_TRACE_WRITES,
789 tracevar,reinterpret_cast<ClientData>(D.operator->()));
794 else if (D->Visible())
795 dout.RemoveDrawable(D);
799 //=======================================================================
802 //=======================================================================
803 void Draw::Set(const Standard_CString Name, const Standard_Real val)
805 if ((Name[0] == '.') && (Name[1] == '\0')) return;
806 Standard_CString aName = Name;
807 Handle(Draw_Drawable3D) D = Draw::Get(aName,Standard_False);
808 Handle(Draw_Number) N;
810 N = Handle(Draw_Number)::DownCast(D);
813 N = new Draw_Number(val);
814 Draw::Set(aName,N,Standard_False);
819 //=======================================================================
822 //=======================================================================
823 Handle(Draw_Drawable3D) Draw::Get(Standard_CString& name,
824 const Standard_Boolean )
826 Standard_Boolean pick = ((name[0] == '.') && (name[1] == '\0'));
827 Handle(Draw_Drawable3D) D;
829 cout << "Pick an object" << endl;
830 dout.Select(p_id,p_X,p_Y,p_b);
831 dout.Pick(p_id,p_X,p_Y,5,D,0);
834 name = p_Name = D->Name();
835 //p_Name = (char *)D->Name();
841 Tcl_VarTraceInfo(theCommands.Interp(),name,TCL_TRACE_UNSETS | TCL_TRACE_WRITES,
843 D = reinterpret_cast<Draw_Drawable3D*>(aCD);
844 if (!theVariables.Contains(D))
847 if (D.IsNull() && complain)
848 cout <<name<<" does not exist"<<endl;
854 //=======================================================================
857 //=======================================================================
858 Standard_Boolean Draw::Get(const Standard_CString name,
861 if ((name[0] == '.') && (name[1] == '\0')) {
862 return Standard_False;
864 Standard_CString aName = name;
865 Handle(Draw_Drawable3D) D = Draw::Get(aName,Standard_False);
867 Handle(Draw_Number) N = Handle(Draw_Number)::DownCast(D);
870 return Standard_True;
873 return Standard_False;
876 //=======================================================================
877 //function : LastPick
879 //=======================================================================
880 void Draw::LastPick(Standard_Integer& view,
883 Standard_Integer& button)
890 //=======================================================================
893 //=======================================================================
896 repaint2d = Standard_True;
897 repaint3d = Standard_True;
900 //=======================================================================
901 //function : trigonometric functions
903 //=======================================================================
905 //static Standard_Integer trigo (Draw_Interpretor& di, Standard_Integer n, const char** a)
906 static Standard_Integer trigo (Draw_Interpretor& di, Standard_Integer , const char** a)
909 Standard_Real x = Draw::Atof(a[1]);
911 if (!strcasecmp(a[0],"cos"))
913 else if (!strcasecmp(a[0],"sin"))
915 else if (!strcasecmp(a[0],"tan"))
917 else if (!strcasecmp(a[0],"sqrt"))
919 else if (!strcasecmp(a[0],"acos"))
921 else if (!strcasecmp(a[0],"asin"))
923 else if (!strcasecmp(a[0],"atan2"))
924 di << ATan2(x,Draw::Atof(a[2]));
930 //=======================================================================
932 //=======================================================================
934 static Standard_Boolean Numeric(char c)
936 return (c == '.' || (c >= '0' && c <= '9'));
939 static Standard_Boolean Alphabetic(char c)
941 return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c == '_'));
944 static Standard_Real Parse(char*&);
946 static Standard_Real ParseValue(char*& name)
948 while (*name == ' ' || *name == '\t') name++;
959 cout << "Mismatched parenthesis" << endl;
965 x = ParseValue(name);
970 x = - ParseValue(name);
978 while (Numeric(*p)) p++;
979 // process scientific notation
980 if ((*p == 'e') || (*p == 'E')) {
981 if (Numeric(*(p+1)) || *(p+1) == '+' || *(p+1) == '-')
984 while (Numeric(*p) || Alphabetic(*p)) p++;
988 if (Numeric(*name)) // numeric litteral
990 else if (!Draw::Get((Standard_CString) name,x)) { // variable
992 // search for a function ...
995 Standard_Integer argc = 1;
997 while ((*q == ' ') || (*q == '\t')) q++;
999 Standard_Integer pc = 1;
1002 while ((pc > 0) && *q) {
1003 if (*q == '(') pc++;
1004 if (*q == ')') pc--;
1005 if ((pc == 1) && (*q == ',')) argc++;
1009 cout << "Unclosed parenthesis"<< endl;
1013 // build function call
1014 // replace , and first and last () by space
1016 Standard_Integer i = 2;
1017 while (*p != '(') p++;
1022 if (*p == '(') pc++;
1023 if (*p == ')') pc--;
1024 if ((pc == 1) && (*p == ',')) {
1035 // call the function, save the current result
1037 if (*theCommands.Result()) {
1038 sv = new char [strlen(theCommands.Result())];
1039 strcpy(sv,theCommands.Result());
1040 theCommands.Reset();
1042 if (theCommands.Eval(name) != 0) {
1043 cout << "Call of function " << name << " failed" << endl;
1047 x = Atof(theCommands.Result());
1048 theCommands.Reset();
1057 Draw_ParseFailed = Standard_True;
1065 while (*name == ' ' || *name == '\t') name++;
1070 static Standard_Real ParseFactor(char*& name)
1072 Standard_Real x = ParseValue(name);
1076 if (c == '\0') return x;
1081 x *= ParseValue(name);
1085 x /= ParseValue(name);
1096 static Standard_Real Parse(char*& name)
1098 Standard_Real x = ParseFactor(name);
1102 if (c == '\0') return x;
1107 x += ParseFactor(name);
1111 x -= ParseFactor(name);
1121 //=======================================================================
1124 //=======================================================================
1125 Standard_Real Draw::Atof(const Standard_CString name)
1128 char* n = new char[1+strlen(name)];
1131 Standard_Real x = Parse(n);
1132 while ((*n == ' ') || (*n == '\t')) n++;
1133 if (*n) Draw_ParseFailed = Standard_True;
1138 Standard_Integer Draw::Atoi(const Standard_CString name)
1140 return (Standard_Integer ) Draw::Atof(name);
1142 //=======================================================================
1144 //purpose : set a TCL var
1145 //=======================================================================
1146 void Draw::Set(const Standard_CString Name, const Standard_CString val)
1148 Standard_PCharacter pName, pVal;
1150 pName=(Standard_PCharacter)Name;
1151 pVal=(Standard_PCharacter)val;
1153 Tcl_SetVar(theCommands.Interp(), pName, pVal, 0);
1155 //=======================================================================
1156 // Command management
1157 // refresh the screen
1158 //=======================================================================
1160 static void before()
1162 repaint2d = Standard_False;
1163 repaint3d = Standard_False;
1166 void Draw_RepaintNowIfNecessary()
1168 if (repaint2d) dout.Repaint2D();
1169 if (repaint3d) dout.Repaint3D();
1170 repaint2d = Standard_False;
1171 repaint3d = Standard_False;
1174 static void after(Standard_Integer)
1176 Draw_RepaintNowIfNecessary();
1179 extern void (*Draw_BeforeCommand)();
1180 extern void (*Draw_AfterCommand)(Standard_Integer);
1183 //=======================================================================
1184 //function : Commands
1186 //=======================================================================
1187 void Draw::VariableCommands(Draw_Interpretor& theCommandsArg)
1189 static Standard_Boolean Done = Standard_False;
1191 Done = Standard_True;
1193 // set up start and stop command
1194 Draw_BeforeCommand = &before;
1195 Draw_AfterCommand = &after;
1197 // set up some variables
1200 Handle(Draw_Axis3D) theAxes3d = new Draw_Axis3D(gp_Pnt(0,0,0),Draw_bleu,20);
1202 Draw::Set(n,theAxes3d);
1203 theAxes3d->Protected(Standard_True);
1205 Handle(Draw_Axis2D) theAxes2d = new Draw_Axis2D(gp_Pnt2d(0,0),Draw_bleu,20);
1207 Draw::Set(n,theAxes2d);
1208 theAxes2d->Protected(Standard_True);
1212 Draw::Get(n)->Protected(Standard_True);
1215 Draw::Set(n,RealLast());
1216 Draw::Get(n)->Protected(Standard_True);
1219 Draw::Set(n,RealFirst());
1220 Draw::Get(n)->Protected(Standard_True);
1223 Handle(Draw_Grid) theGrid = new Draw_Grid();
1224 Draw::Set(n, theGrid);
1225 theGrid->Protected(Standard_True);
1230 g = "DRAW Numeric functions";
1232 theCommandsArg.Add("cos" ,"cos(x)" ,__FILE__,trigo,g);
1233 theCommandsArg.Add("sin" ,"sin(x)" ,__FILE__,trigo,g);
1234 theCommandsArg.Add("tan" ,"tan(x)" ,__FILE__,trigo,g);
1235 theCommandsArg.Add("acos" ,"acos(x)" ,__FILE__,trigo,g);
1236 theCommandsArg.Add("asin" ,"asin(x)" ,__FILE__,trigo,g);
1237 theCommandsArg.Add("atan2" ,"atan2(x,y)" ,__FILE__,trigo,g);
1238 theCommandsArg.Add("sqrt","sqrt(x)",__FILE__,trigo,g);
1240 g = "DRAW Variables management";
1242 theCommandsArg.Add("protect","protect name ...",__FILE__,protect,g);
1243 theCommandsArg.Add("unprotect","unprotect name ...",__FILE__,protect,g);
1245 theCommandsArg.Add("bsave","bsave name filename",__FILE__,save,g);
1246 theCommandsArg.Add("brestore","brestore filename name",__FILE__,restore,g);
1248 theCommandsArg.Add("isdraw","isdraw var, return 1 if Draw value",__FILE__,isdraw,g);
1249 theCommandsArg.Add("isprot","isprot var, return 1 if Draw var is protected",__FILE__,isprot,g);
1251 theCommandsArg.Add("autodisplay","toggle autodisplay [0/1]",__FILE__,autodisplay,g);
1252 theCommandsArg.Add("display","display [name1 name2 ...], no names display all",__FILE__,display,g);
1253 theCommandsArg.Add("donly","donly [name1 name2 ...], erase and display",__FILE__,erase,g);
1254 theCommandsArg.Add("erase","erase [name1 name2 ...], no names erase all",__FILE__,erase,g);
1255 theCommandsArg.Add("draw","draw view mode [name1 name2 ...], draw on view with mode",__FILE__,draw,g);
1256 theCommandsArg.Add("clear","clear display",__FILE__,erase,g);
1257 theCommandsArg.Add("2dclear","clear display (2d objects)",__FILE__,erase,g);
1258 theCommandsArg.Add("repaint","repaint, force redraw",__FILE__,repaintall,g);
1260 theCommandsArg.Add("dtyp", "dtyp name1 name2",__FILE__,whatis,g);
1261 theCommandsArg.Add("dval", "dval name, return value",__FILE__,value,g);
1262 theCommandsArg.Add("dname", "dname name, print name",__FILE__,dname,g);
1263 theCommandsArg.Add("dump", "dump name1 name2 ...",__FILE__,dump,g);
1264 theCommandsArg.Add("copy", "copy name1 toname1 name2 toname2 ...",__FILE__,copy,g);
1265 // san - 02/08/2002 - `rename` command changed to `renamevar` since it conflicts with
1266 // the built-in Tcl command `rename`
1267 //theCommands.Add("rename","rename name1 toname1 name2 toname2 ...",__FILE__,copy,g);
1268 theCommandsArg.Add("renamevar","renamevar name1 toname1 name2 toname2 ...",__FILE__,copy,g);
1269 theCommandsArg.Add("dset","var1 value1 vr2 value2 ...",__FILE__,set,g);
1271 // commands to access C environment variables; see Mantis issue #23197
1272 theCommandsArg.Add("dgetenv","var : get value of environment variable in C subsystem",__FILE__,dgetenv,g);
1273 theCommandsArg.Add("dsetenv","var [value] : set (unset if value is empty) environment variable in C subsystem",__FILE__,dsetenv,g);
1275 theCommandsArg.Add("pick","pick id X Y Z b [nowait]",__FILE__,pick,g);
1276 theCommandsArg.Add("lastrep","lastrep id X Y [Z] b, return name",__FILE__,lastrep,g);