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
9 // under the terms of the GNU Lesser General Public 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.
22 #include <Standard_Stream.hxx>
23 #include <Standard_SStream.hxx>
25 #if defined(HAVE_IOS) || defined(WNT)
27 #elif defined(HAVE_IOS_H)
31 #include <Draw_Display.hxx>
32 #include <Draw_Appli.hxx>
33 #include <Draw_Number.hxx>
34 #include <Draw_Axis3D.hxx>
35 #include <Draw_Axis2D.hxx>
36 #include <Draw_Grid.hxx>
37 #include <Draw_Drawable3D.hxx>
38 #include <Draw_SequenceOfDrawable3D.hxx>
39 #include <Draw_VMap.hxx>
40 #include <Draw_ProgressIndicator.hxx>
43 extern Draw_Viewer dout;
52 #include <OSD_Environment.hxx>
54 Standard_Boolean Draw_ParseFailed;
56 static Standard_Boolean autodisp = Standard_True;
57 static Standard_Boolean repaint2d,repaint3d;
59 extern Draw_Interpretor theCommands;
61 //===============================================
62 // dictionnary of variables
63 // Variables are stored in a map Integer, Transient
64 // The Integer Value is the content of the TCl variable
65 //===============================================
67 static Draw_VMap theVariables;
69 //=======================================================================
70 //function : FindVariable
72 //=======================================================================
74 static Standard_Integer p_id;
75 static Standard_Integer p_X;
76 static Standard_Integer p_Y;
77 static Standard_Integer p_b;
78 static const char* p_Name = "";
81 static Draw_SaveAndRestore* Draw_First = NULL;
83 //=======================================================================
84 //function : Draw_SaveAndRestore
86 //=======================================================================
88 Draw_SaveAndRestore::Draw_SaveAndRestore
90 Standard_Boolean (*test)(const Handle(Draw_Drawable3D)&),
91 void (*save)(const Handle(Draw_Drawable3D)&, ostream&),
92 Handle(Draw_Drawable3D) (*restore) (istream&),
93 Standard_Boolean display) :
104 Standard_Boolean Draw_SaveAndRestore::Test(const Handle(Draw_Drawable3D)&d)
105 {return (*myTest) (d);}
107 void Draw_SaveAndRestore::Save(const Handle(Draw_Drawable3D)& d,
111 Handle(Draw_Drawable3D) Draw_SaveAndRestore::Restore(istream& is) const
112 {return (*myRestore) (is);}
114 //=======================================================================
115 // numeric save and restore
116 //=======================================================================
118 static Standard_Boolean numtest(const Handle(Draw_Drawable3D)& d)
120 return d->IsInstance(STANDARD_TYPE(Draw_Number));
123 static void numsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
125 Handle(Draw_Number) N = Handle(Draw_Number)::DownCast(d);
126 #if (defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)) || ( defined(WNT) && !defined(USE_OLD_STREAMS))
127 ios::fmtflags F = OS.flags();
128 OS.setf(ios::scientific);
132 long form = OS.setf(ios::scientific);
133 int prec = OS.precision(15);
134 int w = OS.width(30);
136 OS << N->Value()<<"\n";
137 #if (defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)) || (defined(WNT)&& !defined(USE_OLD_STREAMS))
146 static Handle(Draw_Drawable3D) numrestore (istream& is)
150 Handle(Draw_Number) N = new Draw_Number(val);
155 static Draw_SaveAndRestore numsr("Draw_Number",
156 numtest,numsave,numrestore,
159 //=======================================================================
161 //=======================================================================
163 static Standard_Integer save(Draw_Interpretor& di, Standard_Integer n, const char** a)
165 if (n <= 2) return 1;
168 const char* name = a[2];
172 if (!fic.open(name,ios::out)) {
173 di << "Cannot open file for writing "<<name;
177 Handle(Draw_Drawable3D) D = Draw::Get(a[1]);
180 Draw_SaveAndRestore* tool = Draw_First;
181 Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
182 progress->SetScale ( 0, 100, 1 );
183 progress->NewScope(100,"Writing");
187 if (tool->Test(D)) break;
191 os << tool->Name() << "\n";
192 Draw::SetProgressBar(progress);
197 di << "No method for saving " << a[1];
200 Draw::SetProgressBar( 0 );
201 progress->EndScope();
207 Standard_Boolean res = Standard_False;
212 res = os.good() && !errno;
215 di<<"File has not been written";
223 //=======================================================================
225 //=======================================================================
227 static Standard_Integer restore(Draw_Interpretor& di, Standard_Integer n, const char** a)
230 if (n <= 2) return 1;
232 const char* fname = a[1];
233 const char* name = a[2];
237 if (!fic.open(fname,ios::in)) {
238 di << "Cannot open file for reading : "<<fname;
246 Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
247 progress->NewScope(100,"Reading");
250 Draw_SaveAndRestore* tool = Draw_First;
252 if (!strcmp(typ,tool->Name())) break;
253 Draw::SetProgressBar(progress);
257 Handle(Draw_Drawable3D) D = tool->Restore(in);
258 Draw::Set(name,D,tool->Disp() && autodisp);
261 di << "Cannot restore a " << typ;
264 Draw::SetProgressBar( 0 );
265 progress->EndScope();
273 //=======================================================================
275 //=======================================================================
277 static Standard_Integer display(Draw_Interpretor& di, Standard_Integer n, const char** a)
279 if (n <= 1) return 1;
281 for (Standard_Integer i = 1; i < n; i++) {
282 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
294 //=======================================================================
295 // erase, clear, donly
296 //=======================================================================
298 static Standard_Integer erase(Draw_Interpretor& di, Standard_Integer n, const char** a)
300 static Standard_Boolean draw_erase_mute = Standard_False;
302 if (!strcasecmp(a[1],"-mute")) {
303 draw_erase_mute = Standard_True;
308 Standard_Boolean donly = !strcasecmp(a[0],"donly");
310 if (n <= 1 || donly) {
311 // clear, 2dclear, donly, erase (without arguments)
314 // solve the names for "." before erasing
316 for (i = 1; i < n; i++) {
317 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
319 if ((a[i][0] == '.') && (a[i][1] == '\0'))
320 cout << "Missed !!!" << endl;
326 // sauvegarde des proteges visibles
327 Draw_SequenceOfDrawable3D prot;
328 for (i = 1; i <= theVariables.Extent(); i++) {
329 const Handle(Draw_Drawable3D)& D = *((Handle(Draw_Drawable3D)*)&theVariables(i));
331 if (D->Protected() && D->Visible())
336 // effacement de toutes les variables
337 Standard_Integer erasemode = 1;
338 if (a[0][0] == '2') erasemode = 2;
339 if (a[0][0] == 'c') erasemode = 3;
341 // effacement des graphiques non variables
344 else if (erasemode == 3)
349 // affichage pour donly
351 for (i = 1; i < n; i++) {
352 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
356 if (!draw_erase_mute) di << a[i] << " ";
362 // afficahge des proteges
363 for (i = 1; i <= prot.Length(); i++)
369 for (Standard_Integer i = 1; i < n; i++) {
370 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
373 dout.RemoveDrawable(D);
374 if (!draw_erase_mute) di << D->Name() << " ";
381 draw_erase_mute = Standard_False;
382 repaint2d = Standard_False;
383 repaint3d = Standard_False;
390 //=======================================================================
392 //=======================================================================
394 static Standard_Integer draw(Draw_Interpretor& , Standard_Integer n, const char** a)
397 Standard_Integer id = Draw::Atoi(a[1]);
398 if (!dout.HasView(id)) {
399 cout << "bad view number in draw"<<endl;
402 Standard_Integer mo = Draw::Atoi(a[2]);
403 Draw_Display d = dout.MakeDisplay(id);
406 for (i = 3; i < n; i++) {
407 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
408 if (!D.IsNull()) D->DrawOn(d);
414 //=======================================================================
415 // protect, unprotect
416 //=======================================================================
418 static Standard_Integer protect(Draw_Interpretor& di, Standard_Integer n, const char** a)
420 if (n <= 1) return 1;
421 Standard_Boolean prot = *a[0] != 'u';
422 for (Standard_Integer i = 1; i < n; i++) {
423 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
432 //=======================================================================
434 //=======================================================================
436 static Standard_Integer autodisplay(Draw_Interpretor& di, Standard_Integer n, const char** a)
439 autodisp = !autodisp;
441 autodisp = !(!strcasecmp(a[1],"0"));
452 //=======================================================================
454 //=======================================================================
456 static Standard_Integer whatis(Draw_Interpretor& di, Standard_Integer n, const char** a)
458 if (n <= 1) return 1;
459 for (Standard_Integer i = 1; i < n; i++) {
460 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
469 //=======================================================================
471 //=======================================================================
473 static Standard_Integer value(Draw_Interpretor& di, Standard_Integer n, const char** a)
475 if (n != 2) return 1;
476 di << Draw::Atof(a[1]);
481 //=======================================================================
484 //=======================================================================
485 static Standard_Integer dname(Draw_Interpretor& di, Standard_Integer n, const char** a)
491 Standard_PCharacter pC;
493 Handle(Draw_Drawable3D) aD;
495 for (i = 1; i < n; ++i) {
496 aD = Draw::Get(a[i]);
498 //modified by NIZNHY-PKV Tue Jun 10 10:18:13 2008f
500 pC=(Standard_PCharacter)aD->Name();
502 //modified by NIZNHY-PKV Tue Jun 10 10:18:18 2008t
508 //=======================================================================
510 //=======================================================================
513 static Standard_Integer dump(Draw_Interpretor& DI, Standard_Integer n, const char** a)
517 for (i = 1; i < n; i++) {
518 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
520 Standard_SStream sss;
522 sss << "\n\n*********** Dump of " << a[i] << " *************\n";
530 //=======================================================================
532 //=======================================================================
534 static Standard_Integer copy(Draw_Interpretor& , Standard_Integer n, const char** a)
537 Standard_Boolean cop = !strcasecmp(a[0],"copy");
539 Handle(Draw_Drawable3D) D;
540 for (Standard_Integer i = 1; i < n; i += 2) {
541 if (i+1 >= n) return 0;
548 Draw::Set(a[i],Handle(Draw_Drawable3D()));
556 //=======================================================================
559 //=======================================================================
561 static Standard_Integer repaintall(Draw_Interpretor& , Standard_Integer , const char** )
563 if (repaint2d) dout.Repaint2D();
564 repaint2d = Standard_False;
565 if (repaint3d) dout.Repaint3D();
566 repaint3d = Standard_False;
571 //=======================================================================
574 //=======================================================================
576 static Standard_Integer set(Draw_Interpretor& di, Standard_Integer n, const char** a)
579 Standard_Integer i = 1;
581 for (i = 1; i < n; i += 2) {
583 if (i+1 < n) val = Draw::Atof(a[i+1]);
590 //=======================================================================
593 //=======================================================================
595 static Standard_Integer dsetenv(Draw_Interpretor& /*di*/, Standard_Integer argc, const char** argv)
598 cout << "Use: " << argv[0] << " {varname} [value]" << endl;
602 OSD_Environment env (argv[1]);
603 if (argc > 2 && argv[2][0] != '\0')
605 env.SetValue (argv[2]);
613 //=======================================================================
616 //=======================================================================
618 static Standard_Integer dgetenv(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
621 cout << "Use: " << argv[0] << " {varname}" << endl;
625 const char* val = getenv (argv[1]);
626 di << ( val ? val : "" );
630 //=======================================================================
633 //=======================================================================
635 static Standard_Integer isdraw(Draw_Interpretor& di, Standard_Integer n, const char** a)
637 if (n != 2) return 1;
638 Handle(Draw_Drawable3D) D = Draw::Get(a[1],Standard_False);
646 //=======================================================================
649 //=======================================================================
651 Standard_Integer isprot(Draw_Interpretor& di, Standard_Integer n, const char** a)
653 if (n != 2) return 1;
654 Handle(Draw_Drawable3D) D = Draw::Get(a[1],Standard_False);
667 //=======================================================================
670 //=======================================================================
672 static Standard_Integer pick(Draw_Interpretor& , Standard_Integer n, const char** a)
676 Standard_Integer X,Y,b;
677 Standard_Boolean wait = (n == 6);
678 if (!wait) id = Draw::Atoi(a[1]);
679 dout.Select(id,X,Y,b,wait);
680 Standard_Real z = dout.Zoom(id);
681 gp_Pnt P((Standard_Real)X /z,(Standard_Real)Y /z,0);
687 Draw::Set(a[2],P.X());
688 Draw::Set(a[3],P.Y());
689 Draw::Set(a[4],P.Z());
695 //=======================================================================
698 //=======================================================================
700 static Standard_Integer lastrep(Draw_Interpretor& di, Standard_Integer n, const char** a)
704 Draw::Set(a[1],p_id);
710 Standard_Real z = dout.Zoom(p_id);
711 gp_Pnt P((Standard_Real)p_X /z,(Standard_Real)p_Y /z,0);
713 dout.GetTrsf(p_id,T);
716 Draw::Set(a[2],P.X());
717 Draw::Set(a[3],P.Y());
718 Draw::Set(a[4],P.Z());
721 di << "Too many args";
724 Draw::Set(a[n-1],p_b);
730 //=======================================================================
733 //=======================================================================
734 void Draw::Set(const Standard_CString name,
735 const Handle(Draw_Drawable3D)& D)
737 Draw::Set(name,D,autodisp);
741 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
742 static char* tracevar(ClientData CD, Tcl_Interp*,const char*,const char*, Standard_Integer)
744 static char* tracevar(ClientData CD, Tcl_Interp*, char*, char*, Standard_Integer)
747 // protect if the map was destroyed before the interpretor
748 if (theVariables.IsEmpty()) return NULL;
751 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
752 Handle(Draw_Drawable3D)& D = *((Handle(Draw_Drawable3D)*)&theVariables((long)CD));
754 Standard_Integer index = (Standard_Integer) CD;
755 Handle(Draw_Drawable3D)& D = *((Handle(Draw_Drawable3D)*)&theVariables(index));
760 return (char*) "variable is protected";
763 dout.RemoveDrawable(D);
765 repaint3d = Standard_True;
767 repaint2d = Standard_True;
774 //=======================================================================
777 //=======================================================================
778 void Draw::Set(const Standard_CString name,
779 const Handle(Draw_Drawable3D)& D,
780 const Standard_Boolean displ)
782 if ((name[0] == '.') && (name[1] == '\0')) {
784 dout.RemoveDrawable(D);
785 if (displ) dout << D;
790 Tcl_UnsetVar(theCommands.Interp(),name,0);
792 Standard_Integer ival = theVariables.Extent() + 1;
793 theVariables.Bind(ival,D);
795 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
796 D->Name(Tcl_SetVar(theCommands.Interp(),name,name,0));
798 D->Name(Tcl_SetVar(theCommands.Interp(),(char*)name,(char*)name,0));
801 // set the trace function
802 Tcl_TraceVar(theCommands.Interp(),name,TCL_TRACE_UNSETS,
803 tracevar,(ClientData)ival);
809 else if (D->Visible())
810 dout.RemoveDrawable(D);
814 //=======================================================================
817 //=======================================================================
818 void Draw::Set(const Standard_CString Name, const Standard_Real val)
820 if ((Name[0] == '.') && (Name[1] == '\0')) return;
821 Standard_CString aName = Name;
822 Handle(Draw_Drawable3D) D = Draw::Get(aName,Standard_False);
823 Handle(Draw_Number) N;
825 N = Handle(Draw_Number)::DownCast(D);
828 N = new Draw_Number(val);
829 Draw::Set(aName,N,Standard_False);
834 //=======================================================================
837 //=======================================================================
838 Handle(Draw_Drawable3D) Draw::Get(Standard_CString& name,
839 const Standard_Boolean )
841 #if !((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) || defined(USE_NON_CONST)
842 Standard_PCharacter pName;
843 pName=(Standard_PCharacter)name;
846 Standard_Boolean pick = ((name[0] == '.') && (name[1] == '\0'));
847 Handle(Draw_Drawable3D) D;
849 cout << "Pick an object" << endl;
850 dout.Select(p_id,p_X,p_Y,p_b);
851 dout.Pick(p_id,p_X,p_Y,5,D,0);
854 name = p_Name = D->Name();
855 //p_Name = (char *)D->Name();
861 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
862 Standard_Address index =
863 Tcl_VarTraceInfo(theCommands.Interp(),name,TCL_TRACE_UNSETS,
866 D = Handle(Draw_Drawable3D)::DownCast(theVariables((long)index));
868 Standard_Integer index = (Standard_Integer)
869 Tcl_VarTraceInfo(theCommands.Interp(),
874 D = Handle(Draw_Drawable3D)::DownCast(theVariables(index));
877 if (D.IsNull() && complain)
878 cout <<name<<" does not exist"<<endl;
884 //=======================================================================
887 //=======================================================================
888 Standard_Boolean Draw::Get(const Standard_CString name,
891 if ((name[0] == '.') && (name[1] == '\0')) {
892 return Standard_False;
894 Standard_CString aName = name;
895 Handle(Draw_Drawable3D) D = Draw::Get(aName,Standard_False);
897 Handle(Draw_Number) N = Handle(Draw_Number)::DownCast(D);
900 return Standard_True;
903 return Standard_False;
906 //=======================================================================
907 //function : LastPick
909 //=======================================================================
910 void Draw::LastPick(Standard_Integer& view,
913 Standard_Integer& button)
920 //=======================================================================
923 //=======================================================================
926 repaint2d = Standard_True;
927 repaint3d = Standard_True;
930 //=======================================================================
931 //function : trigonometric functions
933 //=======================================================================
935 //static Standard_Integer trigo (Draw_Interpretor& di, Standard_Integer n, const char** a)
936 static Standard_Integer trigo (Draw_Interpretor& di, Standard_Integer , const char** a)
939 Standard_Real x = Draw::Atof(a[1]);
941 if (!strcasecmp(a[0],"cos"))
943 else if (!strcasecmp(a[0],"sin"))
945 else if (!strcasecmp(a[0],"tan"))
947 else if (!strcasecmp(a[0],"sqrt"))
949 else if (!strcasecmp(a[0],"acos"))
951 else if (!strcasecmp(a[0],"asin"))
953 else if (!strcasecmp(a[0],"atan2"))
954 di << ATan2(x,Draw::Atof(a[2]));
960 //=======================================================================
962 //=======================================================================
964 static Standard_Boolean Numeric(char c)
966 return (c == '.' || (c >= '0' && c <= '9'));
969 static Standard_Boolean Alphabetic(char c)
971 return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c == '_'));
974 static Standard_Real Parse(char*&);
976 static Standard_Real ParseValue(char*& name)
978 while (*name == ' ' || *name == '\t') name++;
989 cout << "Mismatched parenthesis" << endl;
995 x = ParseValue(name);
1000 x = - ParseValue(name);
1008 while (Numeric(*p)) p++;
1009 // process scientific notation
1010 if ((*p == 'e') || (*p == 'E')) {
1011 if (Numeric(*(p+1)) || *(p+1) == '+' || *(p+1) == '-')
1014 while (Numeric(*p) || Alphabetic(*p)) p++;
1018 if (Numeric(*name)) // numeric litteral
1020 else if (!Draw::Get((Standard_CString) name,x)) { // variable
1022 // search for a function ...
1025 Standard_Integer argc = 1;
1027 while ((*q == ' ') || (*q == '\t')) q++;
1029 Standard_Integer pc = 1;
1032 while ((pc > 0) && *q) {
1033 if (*q == '(') pc++;
1034 if (*q == ')') pc--;
1035 if ((pc == 1) && (*q == ',')) argc++;
1039 cout << "Unclosed parenthesis"<< endl;
1043 // build function call
1044 // replace , and first and last () by space
1046 Standard_Integer i = 2;
1047 while (*p != '(') p++;
1052 if (*p == '(') pc++;
1053 if (*p == ')') pc--;
1054 if ((pc == 1) && (*p == ',')) {
1065 // call the function, save the current result
1067 if (*theCommands.Result()) {
1068 sv = new char [strlen(theCommands.Result())];
1069 strcpy(sv,theCommands.Result());
1070 theCommands.Reset();
1072 if (theCommands.Eval(name) != 0) {
1073 cout << "Call of function " << name << " failed" << endl;
1077 x = Atof(theCommands.Result());
1078 theCommands.Reset();
1087 Draw_ParseFailed = Standard_True;
1095 while (*name == ' ' || *name == '\t') name++;
1100 static Standard_Real ParseFactor(char*& name)
1102 Standard_Real x = ParseValue(name);
1106 if (c == '\0') return x;
1111 x *= ParseValue(name);
1115 x /= ParseValue(name);
1126 static Standard_Real Parse(char*& name)
1128 Standard_Real x = ParseFactor(name);
1132 if (c == '\0') return x;
1137 x += ParseFactor(name);
1141 x -= ParseFactor(name);
1151 //=======================================================================
1154 //=======================================================================
1155 Standard_Real Draw::Atof(const Standard_CString name)
1158 char* n = new char[1+strlen(name)];
1161 Standard_Real x = Parse(n);
1162 while ((*n == ' ') || (*n == '\t')) n++;
1163 if (*n) Draw_ParseFailed = Standard_True;
1168 Standard_Integer Draw::Atoi(const Standard_CString name)
1170 return (Standard_Integer ) Draw::Atof(name);
1172 //=======================================================================
1174 //purpose : set a TCL var
1175 //=======================================================================
1176 void Draw::Set(const Standard_CString Name, const Standard_CString val)
1178 Standard_PCharacter pName, pVal;
1180 pName=(Standard_PCharacter)Name;
1181 pVal=(Standard_PCharacter)val;
1183 Tcl_SetVar(theCommands.Interp(), pName, pVal, 0);
1185 //=======================================================================
1186 // Command management
1187 // refresh the screen
1188 //=======================================================================
1190 static void before()
1192 repaint2d = Standard_False;
1193 repaint3d = Standard_False;
1196 void Draw_RepaintNowIfNecessary()
1198 if (repaint2d) dout.Repaint2D();
1199 if (repaint3d) dout.Repaint3D();
1200 repaint2d = Standard_False;
1201 repaint3d = Standard_False;
1204 static void after(Standard_Integer)
1206 Draw_RepaintNowIfNecessary();
1209 extern void (*Draw_BeforeCommand)();
1210 extern void (*Draw_AfterCommand)(Standard_Integer);
1213 //=======================================================================
1214 //function : Commands
1216 //=======================================================================
1217 void Draw::VariableCommands(Draw_Interpretor& theCommandsArg)
1219 static Standard_Boolean Done = Standard_False;
1221 Done = Standard_True;
1223 // set up start and stop command
1224 Draw_BeforeCommand = &before;
1225 Draw_AfterCommand = &after;
1227 // set up some variables
1230 Handle(Draw_Axis3D) theAxes3d = new Draw_Axis3D(gp_Pnt(0,0,0),Draw_bleu,20);
1232 Draw::Set(n,theAxes3d);
1233 theAxes3d->Protected(Standard_True);
1235 Handle(Draw_Axis2D) theAxes2d = new Draw_Axis2D(gp_Pnt2d(0,0),Draw_bleu,20);
1237 Draw::Set(n,theAxes2d);
1238 theAxes2d->Protected(Standard_True);
1242 Draw::Get(n)->Protected(Standard_True);
1245 Draw::Set(n,RealLast());
1246 Draw::Get(n)->Protected(Standard_True);
1249 Draw::Set(n,RealFirst());
1250 Draw::Get(n)->Protected(Standard_True);
1253 Handle(Draw_Grid) theGrid = new Draw_Grid();
1254 Draw::Set(n, theGrid);
1255 theGrid->Protected(Standard_True);
1260 g = "DRAW Numeric functions";
1262 theCommandsArg.Add("cos" ,"cos(x)" ,__FILE__,trigo,g);
1263 theCommandsArg.Add("sin" ,"sin(x)" ,__FILE__,trigo,g);
1264 theCommandsArg.Add("tan" ,"tan(x)" ,__FILE__,trigo,g);
1265 theCommandsArg.Add("acos" ,"acos(x)" ,__FILE__,trigo,g);
1266 theCommandsArg.Add("asin" ,"asin(x)" ,__FILE__,trigo,g);
1267 theCommandsArg.Add("atan2" ,"atan2(x,y)" ,__FILE__,trigo,g);
1268 theCommandsArg.Add("sqrt","sqrt(x)",__FILE__,trigo,g);
1270 g = "DRAW Variables management";
1272 theCommandsArg.Add("protect","protect name ...",__FILE__,protect,g);
1273 theCommandsArg.Add("unprotect","unprotect name ...",__FILE__,protect,g);
1275 theCommandsArg.Add("bsave","bsave name filename",__FILE__,save,g);
1276 theCommandsArg.Add("brestore","brestore filename name",__FILE__,restore,g);
1278 theCommandsArg.Add("isdraw","isdraw var, return 1 if Draw value",__FILE__,isdraw,g);
1279 theCommandsArg.Add("isprot","isprot var, return 1 if Draw var is protected",__FILE__,isprot,g);
1281 theCommandsArg.Add("autodisplay","toggle autodisplay [0/1]",__FILE__,autodisplay,g);
1282 theCommandsArg.Add("display","display [name1 name2 ...], no names display all",__FILE__,display,g);
1283 theCommandsArg.Add("donly","donly [name1 name2 ...], erase and display",__FILE__,erase,g);
1284 theCommandsArg.Add("erase","erase [name1 name2 ...], no names erase all",__FILE__,erase,g);
1285 theCommandsArg.Add("draw","draw view mode [name1 name2 ...], draw on view with mode",__FILE__,draw,g);
1286 theCommandsArg.Add("clear","clear display",__FILE__,erase,g);
1287 theCommandsArg.Add("2dclear","clear display (2d objects)",__FILE__,erase,g);
1288 theCommandsArg.Add("repaint","repaint, force redraw",__FILE__,repaintall,g);
1290 theCommandsArg.Add("dtyp", "dtyp name1 name2",__FILE__,whatis,g);
1291 theCommandsArg.Add("dval", "dval name, return value",__FILE__,value,g);
1292 theCommandsArg.Add("dname", "dname name, print name",__FILE__,dname,g);
1293 theCommandsArg.Add("dump", "dump name1 name2 ...",__FILE__,dump,g);
1294 theCommandsArg.Add("copy", "copy name1 toname1 name2 toname2 ...",__FILE__,copy,g);
1295 // san - 02/08/2002 - `rename` command changed to `renamevar` since it conflicts with
1296 // the built-in Tcl command `rename`
1297 //theCommands.Add("rename","rename name1 toname1 name2 toname2 ...",__FILE__,copy,g);
1298 theCommandsArg.Add("renamevar","renamevar name1 toname1 name2 toname2 ...",__FILE__,copy,g);
1299 theCommandsArg.Add("dset","var1 value1 vr2 value2 ...",__FILE__,set,g);
1301 // commands to access C environment variables; see Mantis issue #23197
1302 theCommandsArg.Add("dgetenv","var : get value of environment variable in C subsystem",__FILE__,dgetenv,g);
1303 theCommandsArg.Add("dsetenv","var [value] : set (unset if value is empty) environment variable in C subsystem",__FILE__,dsetenv,g);
1305 theCommandsArg.Add("pick","pick id X Y Z b [nowait]",__FILE__,pick,g);
1306 theCommandsArg.Add("lastrep","lastrep id X Y [Z] b, return name",__FILE__,lastrep,g);