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.
17 // **************************************************************
20 // Modif : DFO 05/11/96
26 #include <Draw_Appli.hxx>
28 #include <Draw_Drawable3D.hxx>
29 #include <Draw_Grid.hxx>
30 #include <Draw_Display.hxx>
31 #include <Draw_Text3D.hxx>
32 #include <Draw_Text2D.hxx>
34 #include <Standard_Stream.hxx>
38 extern Draw_Viewer dout;
39 extern Standard_Boolean Draw_Batch;
45 extern Standard_Boolean Draw_BlackBackGround;
48 #define DEFROTATE (5 * M_PI/ 180.)
49 #define DEFMAGNIFY 1.1
50 #define DEFPANNING 0.1
53 #define DEFGRIDSTEP 100.0
54 static Standard_Real steprot = DEFROTATE;
55 static Standard_Real steppan = DEFPANNING;
56 static Standard_Real stepmagnify = DEFMAGNIFY;
57 static Standard_Real stepfocal = DEFFOCAL;
58 static Standard_Real frame = DEFFRAME;
59 static Standard_Real DefaultGridStep = DEFGRIDSTEP ;
62 static char Draw_fontname[FONTLENGTH]="Helvetica";
63 static char Draw_fontsize[FONTLENGTH]="150";
64 static char Draw_fontnamedefault[FONTLENGTH]="Helvetica";
65 static char Draw_fontsizedefault[FONTLENGTH]="150";
67 // *******************************************************************
69 // *******************************************************************
71 static Standard_Integer ViewId(const Standard_CString a)
73 Standard_Integer id = Draw::Atoi(a);
74 if ((id < 0) || (id >= MAXVIEW)) {
75 cout << "Incorrect view-id, must be in 0.."<<MAXVIEW-1<<endl;
78 if (!dout.HasView(id)) {
79 cout <<"View "<<id<<" does not exist."<<endl;
85 static void SetTitle(const Standard_Integer id)
87 if (dout.HasView(id)) {
89 Sprintf(title,"%d : %s - Zoom %f",id,dout.GetType(id),dout.Zoom(id));
90 dout.SetTitle(id,title);
94 //=======================================================================
97 //=======================================================================
99 static Standard_Integer zoom(Draw_Interpretor& , Standard_Integer n, const char** a)
101 // one argument -> All Views
102 // two argument -> First is the view
103 Standard_Boolean z2d = !strcasecmp(a[0],"2dzoom");
105 Standard_Real z = Draw::Atof(a[1]);
106 for (Standard_Integer id = 0; id < MAXVIEW; id++) {
107 if (dout.HasView(id)) {
108 if ((z2d && !dout.Is3D(id)) || (!z2d && dout.Is3D(id))) {
111 dout.RepaintView(id);
118 Standard_Integer id = ViewId(a[1]);
119 if (id < 0) return 1;
120 Standard_Real z = Draw::Atof(a[2]);
122 dout.RepaintView(id);
130 //=======================================================================
133 //=======================================================================
135 static Standard_Integer wzoom(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
137 Standard_Integer id,X,Y,W,H,X1,Y1,X2 = 0,Y2 = 0,b;
138 Standard_Real dX1,dY1,dX2,dY2,zx,zy;
139 if(argc != 1 && argc != 6)
141 di<<"Usage : " << argv[0] << " [view-id X1 Y1 X2 Y2]\n";
146 di << "Pick first corner"<<"\n";
147 dout.Select(id,X1,Y1,b);
154 Standard_Real z = dout.Zoom(id);
157 dX1-=P0.X(); dY1-=P0.Y();
160 if (b != 1) return 0;
161 if (id < 0) return 0;
162 Draw_Display d = dout.MakeDisplay(id);
163 d.SetColor(Draw_blanc);
165 Standard_Real dOX2 = dX1;
166 Standard_Real dOY2 = dY1;
167 d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dOY2));
168 d.Draw(gp_Pnt2d(dX1,dOY2),gp_Pnt2d(dOX2,dOY2));
169 d.Draw(gp_Pnt2d(dOX2,dOY2),gp_Pnt2d(dOX2,dY1));
170 d.Draw(gp_Pnt2d(dOX2,dY1),gp_Pnt2d(dX1,dY1));
172 dout.GetPosSize(id,X,Y,W,H);
173 di << "Pick second corner"<<"\n";
176 dout.Select(id,X2,Y2,b,Standard_False);
178 dX2-=P0.X(); dY2-=P0.Y();
181 d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dOY2));
182 d.Draw(gp_Pnt2d(dX1,dOY2),gp_Pnt2d(dOX2,dOY2));
183 d.Draw(gp_Pnt2d(dOX2,dOY2),gp_Pnt2d(dOX2,dY1));
184 d.Draw(gp_Pnt2d(dOX2,dY1),gp_Pnt2d(dX1,dY1));
185 d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dY2));
186 d.Draw(gp_Pnt2d(dX1,dY2),gp_Pnt2d(dX2,dY2));
187 d.Draw(gp_Pnt2d(dX2,dY2),gp_Pnt2d(dX2,dY1));
188 d.Draw(gp_Pnt2d(dX2,dY1),gp_Pnt2d(dX1,dY1));
193 d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dOY2));
194 d.Draw(gp_Pnt2d(dX1,dOY2),gp_Pnt2d(dOX2,dOY2));
195 d.Draw(gp_Pnt2d(dOX2,dOY2),gp_Pnt2d(dOX2,dY1));
196 d.Draw(gp_Pnt2d(dOX2,dY1),gp_Pnt2d(dX1,dY1));
198 if (b != 1) return 0;
204 if ((id < 0) || (id >= MAXVIEW))
206 cout << "Incorrect view-id, must be in 0.."<<MAXVIEW-1<<endl;
209 if (!dout.HasView(id))
211 cout <<"View "<<id<<" does not exist."<<endl;
214 X1 = atoi (argv [2]);
215 Y1 = atoi (argv [3]);
216 X2 = atoi (argv [4]);
217 Y2 = atoi (argv [5]);
219 dout.GetPosSize(id,X,Y,W,H);
222 if ((X1 == X2) || (Y1 == Y2)) return 0;
223 zx = (Standard_Real) Abs(X2-X1) / (Standard_Real) W;
224 zy = (Standard_Real) Abs(Y2-Y1) / (Standard_Real) H;
225 if (zy > zx) zx = zy;
227 if (X2 < X1) X1 = X2;
228 if (Y2 > Y1) Y1 = Y2;
229 X1 = (Standard_Integer ) (X1*zx);
230 Y1 = (Standard_Integer ) (Y1*zx);
231 dout.SetZoom(id,zx*dout.Zoom(id));
232 dout.SetPan(id,-X1,-Y1);
233 dout.RepaintView(id);
238 //=======================================================================
241 //=======================================================================
243 static Standard_Integer wclick(Draw_Interpretor& di, Standard_Integer, const char**)
245 Standard_Integer id1,X1,Y1,b;
247 di << "Just click."<<"\n";
248 dout.Select(id1,X1,Y1,b);
252 //=======================================================================
255 //=======================================================================
257 static Standard_Integer view(Draw_Interpretor& di, Standard_Integer n, const char** a)
259 if (Draw_Batch) return 1;
261 if ((n >= 3) && (n != 4)) {
262 Standard_Integer id = Draw::Atoi(a[1]);
263 if ((id < 0) || (id >= MAXVIEW)) {
264 di <<"View-id must be in 0.."<<MAXVIEW-1<<"\n";
267 Standard_Integer X = 0;
268 Standard_Integer Y = 0;
269 Standard_Integer W = 500;
270 Standard_Integer H = 500;
271 // if view exist, get old values
272 if (dout.HasView(id))
273 dout.GetPosSize(id,X,Y,W,H);
275 X = Draw::Atoi(a[3]);
277 Y = Draw::Atoi(a[4]);
279 W = Draw::Atoi(a[5]);
281 H = Draw::Atoi(a[6]);
282 dout.MakeView(id,a[2],X,Y,W,H);
283 if (!dout.HasView(id)) {
284 di << "View creation failed"<<"\n";
288 dout.DisplayView(id);
292 // create a view on a given window
293 Standard_Integer id = Draw::Atoi(a[1]);
294 if ((id < 0) || (id >= MAXVIEW)) {
295 di <<"View-id must be in 0.."<<MAXVIEW-1<<"\n";
298 dout.MakeView(id,a[2],a[3]);
299 if (!dout.HasView(id)) {
300 di << "View creation failed"<<"\n";
304 dout.DisplayView(id);
311 //=======================================================================
314 //=======================================================================
316 static Standard_Integer delview(Draw_Interpretor& , Standard_Integer n, const char** a)
319 for (Standard_Integer id = 0; id < MAXVIEW; id++)
324 Standard_Integer id = ViewId(a[1]);
325 if (id < 0) return 1;
333 //=======================================================================
336 //=======================================================================
338 static Standard_Integer fit(Draw_Interpretor& , Standard_Integer n, const char** a)
340 Standard_Boolean f2d = !strcasecmp(a[0],"2dfit");
342 Standard_Real zoom = RealLast();
344 for ( id = 0; id < MAXVIEW; id++) {
345 if (dout.HasView(id)) {
346 if ((f2d && !dout.Is3D(id)) || (!f2d && dout.Is3D(id))) {
347 // dout.FitView(id,frame);
348 dout.FitView(id,(Standard_Integer ) frame);
349 if (dout.Zoom(id) < zoom) zoom = dout.Zoom(id);
353 for (id = 0; id < MAXVIEW; id++) {
354 if (dout.HasView(id)) {
355 if ((f2d && !dout.Is3D(id)) || (!f2d && dout.Is3D(id))) {
356 dout.SetZoom(id,zoom);
357 dout.RepaintView(id);
365 Standard_Integer id = ViewId(a[1]);
366 if (id < 0) return 1;
367 // dout.FitView(id,frame);
368 dout.FitView(id,(Standard_Integer ) frame);
369 dout.RepaintView(id);
377 //=======================================================================
380 //=======================================================================
382 static Standard_Integer focal(Draw_Interpretor& , Standard_Integer n, const char** a)
384 Standard_Integer start = 0;
385 Standard_Integer end = MAXVIEW-1;
387 Standard_Integer anid = ViewId(a[1]);
388 if (anid < 0) return 1;
391 Standard_Real df = 1.;
392 if (!strcasecmp(a[0],"fu"))
394 if (!strcasecmp(a[0],"fd"))
397 for (Standard_Integer id = start; id <= end; id++) {
398 if (!strcasecmp(dout.GetType(id),"PERS")) {
399 dout.SetFocal(id,dout.Focal(id) * df);
400 dout.RepaintView(id);
406 //=======================================================================
407 //function : setfocal
409 //=======================================================================
411 static Standard_Integer setfocal(Draw_Interpretor& di, Standard_Integer n, const char** a)
414 for (Standard_Integer id = 0; id < MAXVIEW; id++) {
415 if (!strcasecmp(dout.GetType(id),"PERS"))
416 di << "Focal view "<<id<<" is "<<dout.Focal(id)<<"\n";
420 Standard_Real f = Draw::Atof(a[1]);
421 for (Standard_Integer id = 0; id < MAXVIEW; id++) {
422 if (!strcasecmp(dout.GetType(id),"PERS"))
430 //=======================================================================
433 //=======================================================================
435 //static Standard_Integer magnify(Draw_Interpretor& di, Standard_Integer n, const char** a)
436 static Standard_Integer magnify(Draw_Interpretor& , Standard_Integer n, const char** a)
438 Standard_Integer start = 0;
439 Standard_Integer end = MAXVIEW-1;
441 Standard_Integer anid = ViewId(a[1]);
442 if (anid < 0) return 1;
445 Standard_Boolean v2d = (a[0][0] == '2'); // 2dmu, 2dmd
446 const char* com = a[0];
448 Standard_Real dz = 1.;
449 if (!strcasecmp(com,"mu")) // mu, 2dmu
454 for (Standard_Integer id = start; id <= end; id++) {
455 if (dout.HasView(id)) {
456 if ((v2d && !dout.Is3D(id)) || (!v2d && dout.Is3D(id))) {
457 dout.SetZoom(id,dout.Zoom(id) * dz);
459 dout.RepaintView(id);
466 Standard_EXPORT Standard_Integer Draw_magnify(Draw_Interpretor& di, Standard_Integer n, const char** a)
468 return magnify(di,n,a);
471 //=======================================================================
474 //=======================================================================
476 static Standard_Integer rotate(Draw_Interpretor& , Standard_Integer n, const char** a)
478 Standard_Integer start = 0;
479 Standard_Integer end = MAXVIEW-1;
481 Standard_Integer anid = ViewId(a[1]);
482 if (anid < 0) return 1;
488 if (!strcasecmp(a[0],"u")) {
492 if (!strcasecmp(a[0],"d")) {
496 if (!strcasecmp(a[0],"l")) {
500 if (!strcasecmp(a[0],"r")) {
505 for (Standard_Integer id = start; id <= end; id++) {
506 if ((!strcasecmp(dout.GetType(id),"AXON")) ||
507 (!strcasecmp(dout.GetType(id),"PERS"))) {
508 dout.RotateView(id,D,ang);
509 dout.RepaintView(id);
515 //=======================================================================
518 //=======================================================================
520 static Standard_Integer panning(Draw_Interpretor& , Standard_Integer n, const char** a)
522 Standard_Integer start = 0;
523 Standard_Integer end = MAXVIEW-1;
525 Standard_Integer anid = ViewId(a[1]);
526 if (anid < 0) return 1;
529 Standard_Integer DX = 0;
530 Standard_Integer DY = 0;
531 Standard_Integer X,Y,W,H;
533 Standard_Boolean v2d = (a[0][0] == '2'); // pu2d, pd2d, pr2d, pl2d
534 const char* com = a[0];
537 if (!strcasecmp(com,"pu")) // pu , 2dpu
539 if (!strcasecmp(com,"pd")) // pd , 2dpd
541 if (!strcasecmp(com,"pl")) // pl , 2dpl
543 if (!strcasecmp(com,"pr")) // pr , 2dpr
546 for (Standard_Integer id = start; id <= end; id++) {
547 if (dout.HasView(id)) {
548 if ((v2d && !dout.Is3D(id)) || (!v2d && dout.Is3D(id))) {
549 dout.GetPosSize(id,X,Y,W,H);
550 // dout.PanView(id,W * DX * steppan, H * DY * steppan);
551 dout.PanView(id,(Standard_Integer )( W * DX * steppan),(Standard_Integer )( H * DY * steppan));
552 dout.RepaintView(id);
559 //=======================================================================
562 //=======================================================================
564 static Standard_Integer ptv(Draw_Interpretor& , Standard_Integer n, const char** a)
567 Standard_Integer start = 0;
568 Standard_Integer end = MAXVIEW-1;
571 Standard_Integer anid = ViewId(a[1]);
572 if (anid < 0) return 1;
574 X = Draw::Atof(a[2]);
575 Y = Draw::Atof(a[3]);
576 Z = Draw::Atof(a[4]);
579 X = Draw::Atof(a[1]);
580 Y = Draw::Atof(a[2]);
581 Z = Draw::Atof(a[3]);
584 for (Standard_Integer id = start; id <= end; id++) {
587 T.SetTranslationPart(gp_Vec(0,0,0));
589 T1.SetTranslationPart(gp_Vec(-X,-Y,-Z));
590 gp_Trsf aLocalTrsf(T*T1);
591 dout.SetTrsf(id,aLocalTrsf);
592 // dout.SetTrsf(id,T*T1);
593 dout.RepaintView(id);
598 //=======================================================================
601 //=======================================================================
603 static Standard_Integer dptv(Draw_Interpretor& , Standard_Integer n, const char** a)
605 Standard_Real DX,DY,DZ;
606 Standard_Integer start = 0;
607 Standard_Integer end = MAXVIEW-1;
610 Standard_Integer anid = ViewId(a[1]);
611 if (anid < 0) return 1;
613 DX = Draw::Atof(a[2]);
614 DY = Draw::Atof(a[3]);
615 DZ = Draw::Atof(a[4]);
618 DX = Draw::Atof(a[1]);
619 DY = Draw::Atof(a[2]);
620 DZ = Draw::Atof(a[3]);
623 for (Standard_Integer id = start; id <= end; id++) {
627 T1.SetTranslationPart(gp_Vec(-DX,-DY,-DZ));
630 dout.RepaintView(id);
636 //=======================================================================
639 //=======================================================================
641 static Standard_Integer color(Draw_Interpretor& di, Standard_Integer n, const char** a)
644 Draw_BlackBackGround = !Draw_BlackBackGround;
646 else if (!dout.DefineColor(Draw::Atoi(a[1]),a[2])) {
647 di << "Could not allocate color "<<a[2]<<"\n";
655 //=======================================================================
656 //function : hardcopy
657 //purpose : hardcopy --> hardcopy of view 1
660 // hardcopy name view --> hardcopy of view <view>
663 // hardcopy name view format --> hardcopy of view <view>
665 // in format <a4,a3,a2,a1,a0>
666 //=======================================================================
668 static Standard_Integer hardcopy(Draw_Interpretor& ,
669 Standard_Integer n, const char** a)
671 // Inch = 25.40001969 mm.
673 // format par default papier a4 210 297 mm avec marge de 3 mm.
675 Standard_Real rap = 28.4;
676 Standard_Real cad = 3;
677 Standard_Real dx = 210;
678 Standard_Real dy = 210 * Sqrt(2.);
680 Standard_Integer iview = 1;
681 const char* file = "a4.ps";
685 iview = ViewId(a[2]);
686 if (iview < 0) return 1;
688 if (!strcmp(a[3],"a7")) {
689 cad = cad / (2 * Sqrt(2));
690 dx = dx / (2 * Sqrt(2));
691 dy = dy / (2 * Sqrt(2));
693 else if (!strcmp(a[3],"a6")) {
698 else if (!strcmp(a[3],"a5")) {
703 else if (!strcmp(a[3],"a4")) {
709 else if (!strcmp(a[3],"a3")) {
714 else if (!strcmp(a[3],"a2")) {
719 else if (!strcmp(a[3],"a1")) {
720 cad = cad * 2 * Sqrt(2);
721 dx = dx * 2 * Sqrt(2);
722 dy = dy * 2 * Sqrt(2);
724 else if (!strcmp(a[3],"a0")) {
733 Standard_Integer pxmin = (Standard_Integer)(cad * rap);
734 Standard_Integer pymin = (Standard_Integer)(cad * rap);
735 Standard_Integer pxmax = (Standard_Integer)((dx - cad) * rap);
736 Standard_Integer pymax = (Standard_Integer)((dy - cad) * rap);
740 Standard_Integer vxmin,vymin,vxmax,vymax;
741 if (dout.HasView(iview)) {
742 dout.GetFrame(iview,vxmin,vymin,vxmax,vymax);
743 Standard_Real kx = (Standard_Real) (pxmax - pxmin) / (vxmax - vxmin);
744 Standard_Real ky = (Standard_Real) (pymax - pymin) / (vymax - vymin);
745 Standard_Real k = Min(Abs(kx),Abs(ky));
746 kx = (kx > 0) ? k : -k;
747 ky = (ky > 0) ? k : -k;
748 pxmax = (Standard_Integer )( pxmin + kx * (vxmax - vxmin));
749 pymax = (Standard_Integer )( pymin + ky * (vymax - vymin));
751 // si on veut choisir l'orientation : 90 rotate
753 // ecriture du header
755 os << "%!PS-Adobe-3.0 EPSF-3.0\n";
756 os << "%%BoundingBox: " << pxmin << " " << pymin << " "
757 << pxmax << " " << pymax << "\n";
758 os << "%%Pages: 1\n";
759 os << "%%DocumentFonts: "<<Draw_fontname<<"\n";
760 os << "%%EndComments\n";
762 os << "/"<<Draw_fontname<<" findfont\n"<<Draw_fontsize<<" scalefont\nsetfont\n";
763 os << "/m {moveto} bind def\n";
764 os << "/l {lineto} bind def\n";
765 os <<".1 .1 scale\n";
769 os <<"3 setlinewidth\n0 setgray\nnewpath\n";
770 os << pxmin << " " << pymin << " m\n";
771 os << pxmax << " " << pymin << " l\n";
772 os << pxmax << " " << pymax << " l\n";
773 os << pxmin << " " << pymax << " l\n";
774 os << "closepath\nstroke\n";
779 os << pxmin << " " << pymin << " m\n";
780 os << pxmax << " " << pymin << " l\n";
781 os << pxmax << " " << pymax << " l\n";
782 os << pxmin << " " << pymax << " l\n";
783 os << "closepath\nclip\n";
785 dout.PostScriptView(iview,
786 vxmin,vymin,vxmax,vymax,
787 pxmin,pymin,pxmax,pymax,os);
795 static Standard_Integer dfont(Draw_Interpretor& di,
796 Standard_Integer n, const char** a)
799 strcpy(Draw_fontname, Draw_fontnamedefault);
800 strcpy(Draw_fontsize, Draw_fontsizedefault);
801 } else if ( n == 2 ) {
802 strcpy(Draw_fontname, a[1]);
803 } else if ( n == 3 ) {
804 strcpy(Draw_fontname, a[1]);
805 strcpy(Draw_fontsize, a[2]);
807 di<<Draw_fontname<<" "<<Draw_fontsize<<"\n";
811 //=======================================================================
814 //=======================================================================
816 static Standard_Integer hcolor(Draw_Interpretor& di, Standard_Integer n, const char** a)
819 di << "code de couleur (Draw.cxx) : " << "\n" ;
820 di << "0 = White,\t 1 = Red,\t 2 = Green,\t 3 = Blue" << "\n" ;
821 di << "4 = Cyan,\t 5 = Gold,\t 6 = Magenta,\t 7 = Maroon" << "\n" ;
822 di << "8 = Orange,\t 9 = Pink,\t 10 = Salmon,\t 11 = Violet" << "\n" ;
823 di << "12 = Yellow,\t 13 = Khaki,\t 14 = Coral" << "\n" ;
824 di << "1 <= width <= 11, 0 (noir) <= gray <= 1 (blanc)" << "\n" ;
826 dout.PostColor(Draw::Atoi(a[1]),Draw::Atoi(a[2]),Draw::Atof(a[3]));
831 //=======================================================================
833 //purpose : xwd file from a view
834 //=======================================================================
836 extern void Draw_RepaintNowIfNecessary();
838 static Standard_Integer xwd(Draw_Interpretor& , Standard_Integer n, const char** a)
842 // enforce repaint if necessary
843 Draw_RepaintNowIfNecessary();
845 Standard_Integer id = 1;
846 const char* file = a[1];
848 id = Draw::Atoi(a[1]);
851 if (!dout.SaveView(id,file))
857 //=======================================================================
859 //purpose : Creation/Suppression d'une grille.
860 //=======================================================================
862 static Standard_Integer grid (Draw_Interpretor& , Standard_Integer NbArg, const char **Arg)
864 Standard_Real StepX, StepY, StepZ ;
868 StepX = DefaultGridStep ;
869 StepY = DefaultGridStep ;
870 StepZ = DefaultGridStep ;
873 StepX = Abs (Draw::Atof (Arg[1])) ;
874 StepY = Abs (Draw::Atof (Arg[1])) ;
875 StepZ = Abs (Draw::Atof (Arg[1])) ;
878 StepX = Abs (Draw::Atof (Arg[1])) ;
879 StepY = Abs (Draw::Atof (Arg[2])) ;
880 StepZ = Abs (Draw::Atof (Arg[2])) ;
883 StepX = Abs (Draw::Atof (Arg[1])) ;
884 StepY = Abs (Draw::Atof (Arg[2])) ;
885 StepZ = Abs (Draw::Atof (Arg[3])) ;
892 const char *temp = "grid";
894 char temp1[] = "grid";
895 const char *temp = temp1;
897 Handle (Draw_Grid) Grille = Handle(Draw_Grid)::DownCast (Draw::Get(temp)) ;
899 Grille->Steps (StepX, StepY, StepZ) ;
905 //=======================================================================
908 //=======================================================================
910 static Standard_Integer dflush (Draw_Interpretor& , Standard_Integer, const char **)
916 //=======================================================================
919 //=======================================================================
921 static Standard_Integer dtext(Draw_Interpretor& di, Standard_Integer n, const char** a)
924 Standard_Boolean is3d;
926 Standard_Integer id,X,Y,b;
927 di << "Pick position with button 1, other button escape"<<"\n";
928 dout.Select(id,X,Y,b);
931 Standard_Real z = dout.Zoom(id);
932 P.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0);
937 is3d = dout.Is3D(id);
941 P.SetCoord(Draw::Atof(a[1]),Draw::Atof(a[2]),is3d ? Draw::Atof(a[3]) : 0);
947 Handle(Draw_Text3D) D = new Draw_Text3D(P,a[n-1],Draw_vert);
951 Handle(Draw_Text2D) D = new Draw_Text2D(gp_Pnt2d(P.X(),P.Y()),
958 void Draw::GraphicCommands(Draw_Interpretor& theCommands)
960 static Standard_Boolean Done = Standard_False;
962 Done = Standard_True;
964 const char* g = "DRAW Graphic Commands";
965 theCommands.Add("wclick","wait for a mouse click",
967 theCommands.Add("zoom","zoom [view-id] z, or zoom z for all 3d views",
969 theCommands.Add("2dzoom","2dzoom [view-id] z, or zoom2d z for all 2d views",
971 theCommands.Add("wzoom","wzoom [view-id X1 Y1 X2 Y2]\n"
972 "- fits the contents of a given rectangle into a view window.\n"
973 "- The view window and rectangle corners are specified through the arguments\n"
974 "- or selected interactively by the user if no arguments are given",
976 theCommands.Add("view","view view-id type X(0) Y(0) W(500) H(500)",
978 theCommands.Add("delete","delete [view-id]",
980 theCommands.Add("fit","fit [view-id]",
982 theCommands.Add("2dfit","2dfit [view-id]",
984 theCommands.Add("fu","fu [view-id], focal up",
986 theCommands.Add("fd","fd [view-id], focal down",
988 theCommands.Add("focal","focal [f]",
989 __FILE__,setfocal,g);
990 theCommands.Add("mu","mu [view-id], magnify up",
992 theCommands.Add("2dmu","2dmu [view-id], magnify up",
994 theCommands.Add("md","md [view-id], magnify down",
996 theCommands.Add("2dmd","2dmd [view-id], magnify down",
998 theCommands.Add("u","u [view-id], rotate up",
1000 theCommands.Add("d","d [view-id], rotate down",
1002 theCommands.Add("l","l [view-id], rotate left",__FILE__,rotate,g);
1003 theCommands.Add("r","r [view-id], rotate right",__FILE__,rotate,g);
1004 theCommands.Add("pu","pu [view-id], panning up",__FILE__,panning,g);
1005 theCommands.Add("pd","pd [view-id], panning down",__FILE__,panning,g);
1006 theCommands.Add("pl","pl [view-id], panning left",__FILE__,panning,g);
1007 theCommands.Add("pr","pr [view-id], panning right",__FILE__,panning,g);
1008 theCommands.Add("2dpu","2dpu [view-id], panning up",__FILE__,panning,g);
1009 theCommands.Add("2dpd","2dpd [view-id], panning down",__FILE__,panning,g);
1010 theCommands.Add("2dpl","2dpl [view-id], panning left",__FILE__,panning,g);
1011 theCommands.Add("2dpr","2dpr [view-id], panning right",__FILE__,panning,g);
1012 theCommands.Add("ptv","ptv [view-id], X , Y , Z",
1014 theCommands.Add("dptv","dptv [view-id], dX , dY , dZ",
1016 theCommands.Add("color","color i colorname, define color i",
1018 theCommands.Add("hardcopy","hardcopy [file = a4.ps] [view-id = 1] [format = a4]", __FILE__,hardcopy,g);
1019 theCommands.Add("xwd","xwd [id = 1] <filename>.{png|bmp|jpg|gif}\n\t\t: Dump contents of viewer window to PNG, BMP, JPEG or GIF file",
1021 theCommands.Add("hcolor","hcolor icol width gray (< 1, 0 black)",
1023 theCommands.Add("grid", "grid [stepX(100) [stepY [stepZ]]] / 0",
1025 theCommands.Add("dflush","dflush, flush the viewer",
1027 theCommands.Add("dtext","dtext [x y [z]] string",
1029 theCommands.Add("dfont","dfont [name size] : set name and size of Draw font, or reset to default",