1 // Created on: 1995-02-23
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
28 #include <Standard_Stream.hxx>
29 #include <Standard_SStream.hxx>
31 #if defined(HAVE_IOS) || defined(WNT)
33 #elif defined(HAVE_IOS_H)
37 #include <Draw_Display.hxx>
38 #include <Draw_Appli.hxx>
39 #include <Draw_Number.hxx>
40 #include <Draw_Axis3D.hxx>
41 #include <Draw_Axis2D.hxx>
42 #include <Draw_Grid.hxx>
43 #include <Draw_Drawable3D.hxx>
44 #include <Draw_SequenceOfDrawable3D.hxx>
45 #include <Draw_VMap.hxx>
46 #include <Draw_ProgressIndicator.hxx>
49 extern Draw_Viewer dout;
58 #include <OSD_Environment.hxx>
60 Standard_Boolean Draw_ParseFailed;
62 static Standard_Boolean autodisp = Standard_True;
63 static Standard_Boolean repaint2d,repaint3d;
65 extern Draw_Interpretor theCommands;
67 //===============================================
68 // dictionnary of variables
69 // Variables are stored in a map Integer, Transient
70 // The Integer Value is the content of the TCl variable
71 //===============================================
73 static Draw_VMap theVariables;
75 //=======================================================================
76 //function : FindVariable
78 //=======================================================================
80 static Standard_Integer p_id;
81 static Standard_Integer p_X;
82 static Standard_Integer p_Y;
83 static Standard_Integer p_b;
84 static const char* p_Name = "";
87 static Draw_SaveAndRestore* Draw_First = NULL;
89 //=======================================================================
90 //function : Draw_SaveAndRestore
92 //=======================================================================
94 Draw_SaveAndRestore::Draw_SaveAndRestore
96 Standard_Boolean (*test)(const Handle(Draw_Drawable3D)&),
97 void (*save)(const Handle(Draw_Drawable3D)&, ostream&),
98 Handle(Draw_Drawable3D) (*restore) (istream&),
99 Standard_Boolean display) :
110 Standard_Boolean Draw_SaveAndRestore::Test(const Handle(Draw_Drawable3D)&d)
111 {return (*myTest) (d);}
113 void Draw_SaveAndRestore::Save(const Handle(Draw_Drawable3D)& d,
117 Handle(Draw_Drawable3D) Draw_SaveAndRestore::Restore(istream& is) const
118 {return (*myRestore) (is);}
120 //=======================================================================
121 // numeric save and restore
122 //=======================================================================
124 static Standard_Boolean numtest(const Handle(Draw_Drawable3D)& d)
126 return d->IsInstance(STANDARD_TYPE(Draw_Number));
129 static void numsave(const Handle(Draw_Drawable3D)&d, ostream& OS)
131 Handle(Draw_Number) N = Handle(Draw_Number)::DownCast(d);
132 #if (defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)) || ( defined(WNT) && !defined(USE_OLD_STREAMS))
133 ios::fmtflags F = OS.flags();
134 OS.setf(ios::scientific);
138 long form = OS.setf(ios::scientific);
139 int prec = OS.precision(15);
140 int w = OS.width(30);
142 OS << N->Value()<<"\n";
143 #if (defined(HAVE_IOS) && !defined(__sgi) && !defined(IRIX)) || (defined(WNT)&& !defined(USE_OLD_STREAMS))
152 static Handle(Draw_Drawable3D) numrestore (istream& is)
156 Handle(Draw_Number) N = new Draw_Number(val);
161 static Draw_SaveAndRestore numsr("Draw_Number",
162 numtest,numsave,numrestore,
165 //=======================================================================
167 //=======================================================================
169 static Standard_Integer save(Draw_Interpretor& di, Standard_Integer n, const char** a)
171 if (n <= 2) return 1;
174 const char* name = a[2];
178 if (!fic.open(name,ios::out)) {
179 di << "Cannot open file for writing "<<name;
183 Handle(Draw_Drawable3D) D = Draw::Get(a[1]);
186 Draw_SaveAndRestore* tool = Draw_First;
187 Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
188 progress->SetScale ( 0, 100, 1 );
189 progress->NewScope(100,"Writing");
193 if (tool->Test(D)) break;
197 os << tool->Name() << "\n";
198 Draw::SetProgressBar(progress);
203 di << "No method for saving " << a[1];
206 Draw::SetProgressBar( 0 );
207 progress->EndScope();
213 Standard_Boolean res = Standard_False;
218 res = os.good() && !errno;
221 di<<"File has not been written";
229 //=======================================================================
231 //=======================================================================
233 static Standard_Integer restore(Draw_Interpretor& di, Standard_Integer n, const char** a)
236 if (n <= 2) return 1;
238 const char* fname = a[1];
239 const char* name = a[2];
243 if (!fic.open(fname,ios::in)) {
244 di << "Cannot open file for reading : "<<fname;
252 Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
253 progress->NewScope(100,"Reading");
256 Draw_SaveAndRestore* tool = Draw_First;
258 if (!strcmp(typ,tool->Name())) break;
259 Draw::SetProgressBar(progress);
263 Handle(Draw_Drawable3D) D = tool->Restore(in);
264 Draw::Set(name,D,tool->Disp() && autodisp);
267 di << "Cannot restore a " << typ;
270 Draw::SetProgressBar( 0 );
271 progress->EndScope();
279 //=======================================================================
281 //=======================================================================
283 static Standard_Integer display(Draw_Interpretor& di, Standard_Integer n, const char** a)
285 if (n <= 1) return 1;
287 for (Standard_Integer i = 1; i < n; i++) {
288 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
300 //=======================================================================
301 // erase, clear, donly
302 //=======================================================================
304 static Standard_Integer erase(Draw_Interpretor& di, Standard_Integer n, const char** a)
306 static Standard_Boolean draw_erase_mute = Standard_False;
308 if (!strcasecmp(a[1],"-mute")) {
309 draw_erase_mute = Standard_True;
314 Standard_Boolean donly = !strcasecmp(a[0],"donly");
316 if (n <= 1 || donly) {
317 // clear, 2dclear, donly, erase (without arguments)
320 // solve the names for "." before erasing
322 for (i = 1; i < n; i++) {
323 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
325 if ((a[i][0] == '.') && (a[i][1] == '\0'))
326 cout << "Missed !!!" << endl;
332 // sauvegarde des proteges visibles
333 Draw_SequenceOfDrawable3D prot;
334 for (i = 1; i <= theVariables.Extent(); i++) {
335 const Handle(Draw_Drawable3D)& D = *((Handle(Draw_Drawable3D)*)&theVariables(i));
337 if (D->Protected() && D->Visible())
342 // effacement de toutes les variables
343 Standard_Integer erasemode = 1;
344 if (a[0][0] == '2') erasemode = 2;
345 if (a[0][0] == 'c') erasemode = 3;
347 // effacement des graphiques non variables
350 else if (erasemode == 3)
355 // affichage pour donly
357 for (i = 1; i < n; i++) {
358 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
362 if (!draw_erase_mute) di << a[i] << " ";
368 // afficahge des proteges
369 for (i = 1; i <= prot.Length(); i++)
375 for (Standard_Integer i = 1; i < n; i++) {
376 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
379 dout.RemoveDrawable(D);
380 if (!draw_erase_mute) di << D->Name() << " ";
387 draw_erase_mute = Standard_False;
388 repaint2d = Standard_False;
389 repaint3d = Standard_False;
396 //=======================================================================
398 //=======================================================================
400 static Standard_Integer draw(Draw_Interpretor& , Standard_Integer n, const char** a)
403 Standard_Integer id = Draw::Atoi(a[1]);
404 if (!dout.HasView(id)) {
405 cout << "bad view number in draw"<<endl;
408 Standard_Integer mo = Draw::Atoi(a[2]);
409 Draw_Display d = dout.MakeDisplay(id);
412 for (i = 3; i < n; i++) {
413 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
414 if (!D.IsNull()) D->DrawOn(d);
420 //=======================================================================
421 // protect, unprotect
422 //=======================================================================
424 static Standard_Integer protect(Draw_Interpretor& di, Standard_Integer n, const char** a)
426 if (n <= 1) return 1;
427 Standard_Boolean prot = *a[0] != 'u';
428 for (Standard_Integer i = 1; i < n; i++) {
429 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
438 //=======================================================================
440 //=======================================================================
442 static Standard_Integer autodisplay(Draw_Interpretor& di, Standard_Integer n, const char** a)
445 autodisp = !autodisp;
447 autodisp = !(!strcasecmp(a[1],"0"));
458 //=======================================================================
460 //=======================================================================
462 static Standard_Integer whatis(Draw_Interpretor& di, Standard_Integer n, const char** a)
464 if (n <= 1) return 1;
465 for (Standard_Integer i = 1; i < n; i++) {
466 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
475 //=======================================================================
477 //=======================================================================
479 static Standard_Integer value(Draw_Interpretor& di, Standard_Integer n, const char** a)
481 if (n != 2) return 1;
482 di << Draw::Atof(a[1]);
487 //=======================================================================
490 //=======================================================================
491 static Standard_Integer dname(Draw_Interpretor& di, Standard_Integer n, const char** a)
497 Standard_PCharacter pC;
499 Handle(Draw_Drawable3D) aD;
501 for (i = 1; i < n; ++i) {
502 aD = Draw::Get(a[i]);
504 //modified by NIZNHY-PKV Tue Jun 10 10:18:13 2008f
506 pC=(Standard_PCharacter)aD->Name();
508 //modified by NIZNHY-PKV Tue Jun 10 10:18:18 2008t
514 //=======================================================================
516 //=======================================================================
519 static Standard_Integer dump(Draw_Interpretor& DI, Standard_Integer n, const char** a)
523 for (i = 1; i < n; i++) {
524 Handle(Draw_Drawable3D) D = Draw::Get(a[i]);
526 Standard_SStream sss;
528 sss << "\n\n*********** Dump of " << a[i] << " *************\n";
536 //=======================================================================
538 //=======================================================================
540 static Standard_Integer copy(Draw_Interpretor& , Standard_Integer n, const char** a)
543 Standard_Boolean cop = !strcasecmp(a[0],"copy");
545 Handle(Draw_Drawable3D) D;
546 for (Standard_Integer i = 1; i < n; i += 2) {
547 if (i+1 >= n) return 0;
554 Draw::Set(a[i],Handle(Draw_Drawable3D()));
562 //=======================================================================
565 //=======================================================================
567 static Standard_Integer repaintall(Draw_Interpretor& , Standard_Integer , const char** )
569 if (repaint2d) dout.Repaint2D();
570 repaint2d = Standard_False;
571 if (repaint3d) dout.Repaint3D();
572 repaint3d = Standard_False;
577 //=======================================================================
580 //=======================================================================
582 static Standard_Integer set(Draw_Interpretor& di, Standard_Integer n, const char** a)
585 Standard_Integer i = 1;
587 for (i = 1; i < n; i += 2) {
589 if (i+1 < n) val = Draw::Atof(a[i+1]);
596 //=======================================================================
599 //=======================================================================
601 static Standard_Integer dsetenv(Draw_Interpretor& /*di*/, Standard_Integer argc, const char** argv)
604 cout << "Use: " << argv[0] << " {varname} [value]" << endl;
608 OSD_Environment env (argv[1]);
609 if (argc > 2 && argv[2][0] != '\0')
611 env.SetValue (argv[2]);
619 //=======================================================================
622 //=======================================================================
624 static Standard_Integer dgetenv(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
627 cout << "Use: " << argv[0] << " {varname}" << endl;
631 const char* val = getenv (argv[1]);
632 di << ( val ? val : "" );
636 //=======================================================================
639 //=======================================================================
641 static Standard_Integer isdraw(Draw_Interpretor& di, Standard_Integer n, const char** a)
643 if (n != 2) return 1;
644 Handle(Draw_Drawable3D) D = Draw::Get(a[1],Standard_False);
652 //=======================================================================
655 //=======================================================================
657 Standard_Integer isprot(Draw_Interpretor& di, Standard_Integer n, const char** a)
659 if (n != 2) return 1;
660 Handle(Draw_Drawable3D) D = Draw::Get(a[1],Standard_False);
673 //=======================================================================
676 //=======================================================================
678 static Standard_Integer pick(Draw_Interpretor& , Standard_Integer n, const char** a)
682 Standard_Integer X,Y,b;
683 Standard_Boolean wait = (n == 6);
684 if (!wait) id = Draw::Atoi(a[1]);
685 dout.Select(id,X,Y,b,wait);
686 Standard_Real z = dout.Zoom(id);
687 gp_Pnt P((Standard_Real)X /z,(Standard_Real)Y /z,0);
693 Draw::Set(a[2],P.X());
694 Draw::Set(a[3],P.Y());
695 Draw::Set(a[4],P.Z());
701 //=======================================================================
704 //=======================================================================
706 static Standard_Integer lastrep(Draw_Interpretor& di, Standard_Integer n, const char** a)
710 Draw::Set(a[1],p_id);
716 Standard_Real z = dout.Zoom(p_id);
717 gp_Pnt P((Standard_Real)p_X /z,(Standard_Real)p_Y /z,0);
719 dout.GetTrsf(p_id,T);
722 Draw::Set(a[2],P.X());
723 Draw::Set(a[3],P.Y());
724 Draw::Set(a[4],P.Z());
727 di << "Too many args";
730 Draw::Set(a[n-1],p_b);
736 //=======================================================================
739 //=======================================================================
740 void Draw::Set(const Standard_CString name,
741 const Handle(Draw_Drawable3D)& D)
743 Draw::Set(name,D,autodisp);
747 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
748 static char* tracevar(ClientData CD, Tcl_Interp*,const char*,const char*, Standard_Integer)
750 static char* tracevar(ClientData CD, Tcl_Interp*, char*, char*, Standard_Integer)
753 // protect if the map was destroyed before the interpretor
754 if (theVariables.IsEmpty()) return NULL;
757 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
758 Handle(Draw_Drawable3D)& D = *((Handle(Draw_Drawable3D)*)&theVariables((long)CD));
760 Standard_Integer index = (Standard_Integer) CD;
761 Handle(Draw_Drawable3D)& D = *((Handle(Draw_Drawable3D)*)&theVariables(index));
766 return (char*) "variable is protected";
769 dout.RemoveDrawable(D);
771 repaint3d = Standard_True;
773 repaint2d = Standard_True;
780 //=======================================================================
783 //=======================================================================
784 void Draw::Set(const Standard_CString name,
785 const Handle(Draw_Drawable3D)& D,
786 const Standard_Boolean displ)
788 Standard_PCharacter pName;
790 pName=(Standard_PCharacter)name;
792 if ((name[0] == '.') && (name[1] == '\0')) {
794 dout.RemoveDrawable(D);
795 if (displ) dout << D;
800 Tcl_UnsetVar(theCommands.Interp(),pName,0);
802 Standard_Integer ival = theVariables.Extent() + 1;
803 theVariables.Bind(ival,D);
805 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
806 D->Name((const Standard_CString)Tcl_SetVar(theCommands.Interp(),name,name,0));
808 D->Name(Tcl_SetVar(theCommands.Interp(),pName,pName,0));
811 // set the trace function
812 Tcl_TraceVar(theCommands.Interp(),pName,TCL_TRACE_UNSETS,
813 tracevar,(ClientData)ival);
819 else if (D->Visible())
820 dout.RemoveDrawable(D);
824 //=======================================================================
827 //=======================================================================
828 void Draw::Set(const Standard_CString Name, const Standard_Real val)
830 if ((Name[0] == '.') && (Name[1] == '\0')) return;
831 Standard_CString aName = Name;
832 Handle(Draw_Drawable3D) D = Draw::Get(aName,Standard_False);
833 Handle(Draw_Number) N;
835 N = Handle(Draw_Number)::DownCast(D);
838 N = new Draw_Number(val);
839 Draw::Set(aName,N,Standard_False);
844 //=======================================================================
847 //=======================================================================
848 Handle(Draw_Drawable3D) Draw::Get(Standard_CString& name,
849 const Standard_Boolean )
851 Standard_PCharacter pName;
853 pName=(Standard_PCharacter)name;
855 Standard_Boolean pick = ((name[0] == '.') && (name[1] == '\0'));
856 Handle(Draw_Drawable3D) D;
858 cout << "Pick an object" << endl;
859 dout.Select(p_id,p_X,p_Y,p_b);
860 dout.Pick(p_id,p_X,p_Y,5,D,0);
863 name = p_Name = D->Name();
864 //p_Name = (char *)D->Name();
870 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
871 Standard_Address index =
872 Tcl_VarTraceInfo(theCommands.Interp(),name,TCL_TRACE_UNSETS,
875 D = Handle(Draw_Drawable3D)::DownCast(theVariables((long)index));
877 Standard_Integer index = (Standard_Integer)
878 Tcl_VarTraceInfo(theCommands.Interp(),
883 D = Handle(Draw_Drawable3D)::DownCast(theVariables(index));
886 if (D.IsNull() && complain)
887 cout <<name<<" does not exist"<<endl;
893 //=======================================================================
896 //=======================================================================
897 Standard_Boolean Draw::Get(const Standard_CString name,
900 if ((name[0] == '.') && (name[1] == '\0')) {
901 return Standard_False;
903 Standard_CString aName = name;
904 Handle(Draw_Drawable3D) D = Draw::Get(aName,Standard_False);
906 Handle(Draw_Number) N = Handle(Draw_Number)::DownCast(D);
909 return Standard_True;
912 return Standard_False;
915 //=======================================================================
916 //function : LastPick
918 //=======================================================================
919 void Draw::LastPick(Standard_Integer& view,
922 Standard_Integer& button)
929 //=======================================================================
932 //=======================================================================
935 repaint2d = Standard_True;
936 repaint3d = Standard_True;
939 //=======================================================================
940 //function : trigonometric functions
942 //=======================================================================
944 //static Standard_Integer trigo (Draw_Interpretor& di, Standard_Integer n, const char** a)
945 static Standard_Integer trigo (Draw_Interpretor& di, Standard_Integer , const char** a)
948 Standard_Real x = Draw::Atof(a[1]);
950 if (!strcasecmp(a[0],"cos"))
952 else if (!strcasecmp(a[0],"sin"))
954 else if (!strcasecmp(a[0],"tan"))
956 else if (!strcasecmp(a[0],"sqrt"))
958 else if (!strcasecmp(a[0],"acos"))
960 else if (!strcasecmp(a[0],"asin"))
962 else if (!strcasecmp(a[0],"atan2"))
963 di << ATan2(x,Draw::Atof(a[2]));
969 //=======================================================================
971 //=======================================================================
973 static Standard_Boolean Numeric(char c)
975 return (c == '.' || (c >= '0' && c <= '9'));
978 static Standard_Boolean Alphabetic(char c)
980 return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c == '_'));
983 static Standard_Real Parse(char*&);
985 static Standard_Real ParseValue(char*& name)
987 while (*name == ' ' || *name == '\t') name++;
998 cout << "Mismatched parenthesis" << endl;
1004 x = ParseValue(name);
1009 x = - ParseValue(name);
1017 while (Numeric(*p)) p++;
1018 // process scientific notation
1019 if ((*p == 'e') || (*p == 'E')) {
1020 if (Numeric(*(p+1)) || *(p+1) == '+' || *(p+1) == '-')
1023 while (Numeric(*p) || Alphabetic(*p)) p++;
1027 if (Numeric(*name)) // numeric litteral
1029 else if (!Draw::Get((Standard_CString) name,x)) { // variable
1031 // search for a function ...
1034 Standard_Integer argc = 1;
1036 while ((*q == ' ') || (*q == '\t')) q++;
1038 Standard_Integer pc = 1;
1041 while ((pc > 0) && *q) {
1042 if (*q == '(') pc++;
1043 if (*q == ')') pc--;
1044 if ((pc == 1) && (*q == ',')) argc++;
1048 cout << "Unclosed parenthesis"<< endl;
1052 // build function call
1053 // replace , and first and last () by space
1055 Standard_Integer i = 2;
1056 while (*p != '(') p++;
1061 if (*p == '(') pc++;
1062 if (*p == ')') pc--;
1063 if ((pc == 1) && (*p == ',')) {
1074 // call the function, save the current result
1076 if (*theCommands.Result()) {
1077 sv = new char [strlen(theCommands.Result())];
1078 strcpy(sv,theCommands.Result());
1079 theCommands.Reset();
1081 if (theCommands.Eval(name) != 0) {
1082 cout << "Call of function " << name << " failed" << endl;
1086 x = Atof(theCommands.Result());
1087 theCommands.Reset();
1096 Draw_ParseFailed = Standard_True;
1104 while (*name == ' ' || *name == '\t') name++;
1109 static Standard_Real ParseFactor(char*& name)
1111 Standard_Real x = ParseValue(name);
1115 if (c == '\0') return x;
1120 x *= ParseValue(name);
1124 x /= ParseValue(name);
1135 static Standard_Real Parse(char*& name)
1137 Standard_Real x = ParseFactor(name);
1141 if (c == '\0') return x;
1146 x += ParseFactor(name);
1150 x -= ParseFactor(name);
1160 //=======================================================================
1163 //=======================================================================
1164 Standard_Real Draw::Atof(const Standard_CString name)
1167 char* n = new char[1+strlen(name)];
1170 Standard_Real x = Parse(n);
1171 while ((*n == ' ') || (*n == '\t')) n++;
1172 if (*n) Draw_ParseFailed = Standard_True;
1177 Standard_Integer Draw::Atoi(const Standard_CString name)
1179 return (Standard_Integer ) Draw::Atof(name);
1181 //=======================================================================
1183 //purpose : set a TCL var
1184 //=======================================================================
1185 void Draw::Set(const Standard_CString Name, const Standard_CString val)
1187 Standard_PCharacter pName, pVal;
1189 pName=(Standard_PCharacter)Name;
1190 pVal=(Standard_PCharacter)val;
1192 Tcl_SetVar(theCommands.Interp(), pName, pVal, 0);
1194 //=======================================================================
1195 // Command management
1196 // refresh the screen
1197 //=======================================================================
1199 static void before()
1201 repaint2d = Standard_False;
1202 repaint3d = Standard_False;
1205 void Draw_RepaintNowIfNecessary()
1207 if (repaint2d) dout.Repaint2D();
1208 if (repaint3d) dout.Repaint3D();
1209 repaint2d = Standard_False;
1210 repaint3d = Standard_False;
1213 static void after(Standard_Integer)
1215 Draw_RepaintNowIfNecessary();
1218 extern void (*Draw_BeforeCommand)();
1219 extern void (*Draw_AfterCommand)(Standard_Integer);
1222 //=======================================================================
1223 //function : Commands
1225 //=======================================================================
1226 void Draw::VariableCommands(Draw_Interpretor& theCommandsArg)
1228 static Standard_Boolean Done = Standard_False;
1230 Done = Standard_True;
1232 // set up start and stop command
1233 Draw_BeforeCommand = &before;
1234 Draw_AfterCommand = &after;
1236 // set up some variables
1239 Handle(Draw_Axis3D) theAxes3d = new Draw_Axis3D(gp_Pnt(0,0,0),Draw_bleu,20);
1241 Draw::Set(n,theAxes3d);
1242 theAxes3d->Protected(Standard_True);
1244 Handle(Draw_Axis2D) theAxes2d = new Draw_Axis2D(gp_Pnt2d(0,0),Draw_bleu,20);
1246 Draw::Set(n,theAxes2d);
1247 theAxes2d->Protected(Standard_True);
1251 Draw::Get(n)->Protected(Standard_True);
1254 Draw::Set(n,RealLast());
1255 Draw::Get(n)->Protected(Standard_True);
1258 Draw::Set(n,RealFirst());
1259 Draw::Get(n)->Protected(Standard_True);
1262 Handle(Draw_Grid) theGrid = new Draw_Grid();
1263 Draw::Set(n, theGrid);
1264 theGrid->Protected(Standard_True);
1269 g = "DRAW Numeric functions";
1271 theCommandsArg.Add("cos" ,"cos(x)" ,__FILE__,trigo,g);
1272 theCommandsArg.Add("sin" ,"sin(x)" ,__FILE__,trigo,g);
1273 theCommandsArg.Add("tan" ,"tan(x)" ,__FILE__,trigo,g);
1274 theCommandsArg.Add("acos" ,"acos(x)" ,__FILE__,trigo,g);
1275 theCommandsArg.Add("asin" ,"asin(x)" ,__FILE__,trigo,g);
1276 theCommandsArg.Add("atan2" ,"atan2(x,y)" ,__FILE__,trigo,g);
1277 theCommandsArg.Add("sqrt","sqrt(x)",__FILE__,trigo,g);
1279 g = "DRAW Variables management";
1281 theCommandsArg.Add("protect","protect name ...",__FILE__,protect,g);
1282 theCommandsArg.Add("unprotect","unprotect name ...",__FILE__,protect,g);
1284 theCommandsArg.Add("bsave","bsave name filename",__FILE__,save,g);
1285 theCommandsArg.Add("brestore","brestore filename name",__FILE__,restore,g);
1287 theCommandsArg.Add("isdraw","isdraw var, return 1 if Draw value",__FILE__,isdraw,g);
1288 theCommandsArg.Add("isprot","isprot var, return 1 if Draw var is protected",__FILE__,isprot,g);
1290 theCommandsArg.Add("autodisplay","toggle autodisplay [0/1]",__FILE__,autodisplay,g);
1291 theCommandsArg.Add("display","display [name1 name2 ...], no names display all",__FILE__,display,g);
1292 theCommandsArg.Add("donly","donly [name1 name2 ...], erase and display",__FILE__,erase,g);
1293 theCommandsArg.Add("erase","erase [name1 name2 ...], no names erase all",__FILE__,erase,g);
1294 theCommandsArg.Add("draw","draw view mode [name1 name2 ...], draw on view with mode",__FILE__,draw,g);
1295 theCommandsArg.Add("clear","clear display",__FILE__,erase,g);
1296 theCommandsArg.Add("2dclear","clear display (2d objects)",__FILE__,erase,g);
1297 theCommandsArg.Add("repaint","repaint, force redraw",__FILE__,repaintall,g);
1299 theCommandsArg.Add("dtyp", "dtyp name1 name2",__FILE__,whatis,g);
1300 theCommandsArg.Add("dval", "dval name, return value",__FILE__,value,g);
1301 theCommandsArg.Add("dname", "dname name, print name",__FILE__,dname,g);
1302 theCommandsArg.Add("dump", "dump name1 name2 ...",__FILE__,dump,g);
1303 theCommandsArg.Add("copy", "copy name1 toname1 name2 toname2 ...",__FILE__,copy,g);
1304 // san - 02/08/2002 - `rename` command changed to `renamevar` since it conflicts with
1305 // the built-in Tcl command `rename`
1306 //theCommands.Add("rename","rename name1 toname1 name2 toname2 ...",__FILE__,copy,g);
1307 theCommandsArg.Add("renamevar","renamevar name1 toname1 name2 toname2 ...",__FILE__,copy,g);
1308 theCommandsArg.Add("dset","var1 value1 vr2 value2 ...",__FILE__,set,g);
1310 // commands to access C environment variables; see Mantis issue #23197
1311 theCommandsArg.Add("dgetenv","var : get value of environment variable in C subsystem",__FILE__,dgetenv,g);
1312 theCommandsArg.Add("dsetenv","var [value] : set (unset if value is empty) environment variable in C subsystem",__FILE__,dsetenv,g);
1314 theCommandsArg.Add("pick","pick id X Y Z b [nowait]",__FILE__,pick,g);
1315 theCommandsArg.Add("lastrep","lastrep id X Y [Z] b, return name",__FILE__,lastrep,g);