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 // **************************************************************
18 // Modif : DFO 05/11/96
21 #include <Draw_Appli.hxx>
22 #include <Draw_Display.hxx>
23 #include <Draw_Drawable3D.hxx>
24 #include <Draw_Grid.hxx>
25 #include <Draw_ProgressIndicator.hxx>
26 #include <Draw_Text2D.hxx>
27 #include <Draw_Text3D.hxx>
28 #include <Standard_Stream.hxx>
29 #include <TCollection_AsciiString.hxx>
33 extern Draw_Viewer dout;
34 extern Standard_Boolean Draw_Batch;
37 extern Standard_Boolean Draw_BlackBackGround;
40 #define DEFROTATE (5 * M_PI/ 180.)
41 #define DEFMAGNIFY 1.1
42 #define DEFPANNING 0.1
45 #define DEFGRIDSTEP 100.0
46 static Standard_Real steprot = DEFROTATE;
47 static Standard_Real steppan = DEFPANNING;
48 static Standard_Real stepmagnify = DEFMAGNIFY;
49 static Standard_Real stepfocal = DEFFOCAL;
50 static Standard_Real frame = DEFFRAME;
51 static Standard_Real DefaultGridStep = DEFGRIDSTEP ;
54 static char Draw_fontname[FONTLENGTH]="Helvetica";
55 static char Draw_fontsize[FONTLENGTH]="150";
56 static char Draw_fontnamedefault[FONTLENGTH]="Helvetica";
57 static char Draw_fontsizedefault[FONTLENGTH]="150";
59 // *******************************************************************
61 // *******************************************************************
63 static Standard_Integer ViewId(const Standard_CString a)
65 Standard_Integer id = Draw::Atoi(a);
66 if ((id < 0) || (id >= MAXVIEW)) {
67 cout << "Incorrect view-id, must be in 0.."<<MAXVIEW-1<<endl;
70 if (!dout.HasView(id)) {
71 cout <<"View "<<id<<" does not exist."<<endl;
77 static void SetTitle(const Standard_Integer id)
79 if (dout.HasView(id)) {
81 Sprintf(title,"%d : %s - Zoom %f",id,dout.GetType(id),dout.Zoom(id));
82 dout.SetTitle(id,title);
86 //=======================================================================
89 //=======================================================================
91 static Standard_Integer zoom(Draw_Interpretor& , Standard_Integer n, const char** a)
93 // one argument -> All Views
94 // two argument -> First is the view
95 Standard_Boolean z2d = !strcasecmp(a[0],"2dzoom");
97 Standard_Real z = Draw::Atof(a[1]);
98 for (Standard_Integer id = 0; id < MAXVIEW; id++) {
99 if (dout.HasView(id)) {
100 if ((z2d && !dout.Is3D(id)) || (!z2d && dout.Is3D(id))) {
103 dout.RepaintView(id);
110 Standard_Integer id = ViewId(a[1]);
111 if (id < 0) return 1;
112 Standard_Real z = Draw::Atof(a[2]);
114 dout.RepaintView(id);
122 //=======================================================================
125 //=======================================================================
127 static Standard_Integer wzoom(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
129 Standard_Integer id,X,Y,W,H,X1,Y1,X2 = 0,Y2 = 0,b;
130 Standard_Real dX1,dY1,dX2,dY2,zx,zy;
131 if(argc != 1 && argc != 6)
133 di<<"Usage : " << argv[0] << " [view-id X1 Y1 X2 Y2]\n";
138 di << "Pick first corner\n";
139 dout.Select(id,X1,Y1,b);
146 Standard_Real z = dout.Zoom(id);
149 dX1-=P0.X(); dY1-=P0.Y();
152 if (b != 1) return 0;
153 if (id < 0) return 0;
154 Draw_Display d = dout.MakeDisplay(id);
155 d.SetColor(Draw_blanc);
157 Standard_Real dOX2 = dX1;
158 Standard_Real dOY2 = dY1;
159 d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dOY2));
160 d.Draw(gp_Pnt2d(dX1,dOY2),gp_Pnt2d(dOX2,dOY2));
161 d.Draw(gp_Pnt2d(dOX2,dOY2),gp_Pnt2d(dOX2,dY1));
162 d.Draw(gp_Pnt2d(dOX2,dY1),gp_Pnt2d(dX1,dY1));
164 dout.GetPosSize(id,X,Y,W,H);
165 di << "Pick second corner\n";
168 dout.Select(id,X2,Y2,b,Standard_False);
170 dX2-=P0.X(); dY2-=P0.Y();
173 d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dOY2));
174 d.Draw(gp_Pnt2d(dX1,dOY2),gp_Pnt2d(dOX2,dOY2));
175 d.Draw(gp_Pnt2d(dOX2,dOY2),gp_Pnt2d(dOX2,dY1));
176 d.Draw(gp_Pnt2d(dOX2,dY1),gp_Pnt2d(dX1,dY1));
177 d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dY2));
178 d.Draw(gp_Pnt2d(dX1,dY2),gp_Pnt2d(dX2,dY2));
179 d.Draw(gp_Pnt2d(dX2,dY2),gp_Pnt2d(dX2,dY1));
180 d.Draw(gp_Pnt2d(dX2,dY1),gp_Pnt2d(dX1,dY1));
185 d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dOY2));
186 d.Draw(gp_Pnt2d(dX1,dOY2),gp_Pnt2d(dOX2,dOY2));
187 d.Draw(gp_Pnt2d(dOX2,dOY2),gp_Pnt2d(dOX2,dY1));
188 d.Draw(gp_Pnt2d(dOX2,dY1),gp_Pnt2d(dX1,dY1));
190 if (b != 1) return 0;
196 if ((id < 0) || (id >= MAXVIEW))
198 cout << "Incorrect view-id, must be in 0.."<<MAXVIEW-1<<endl;
201 if (!dout.HasView(id))
203 cout <<"View "<<id<<" does not exist."<<endl;
206 X1 = atoi (argv [2]);
207 Y1 = atoi (argv [3]);
208 X2 = atoi (argv [4]);
209 Y2 = atoi (argv [5]);
211 dout.GetPosSize(id,X,Y,W,H);
214 if ((X1 == X2) || (Y1 == Y2)) return 0;
215 zx = (Standard_Real) Abs(X2-X1) / (Standard_Real) W;
216 zy = (Standard_Real) Abs(Y2-Y1) / (Standard_Real) H;
217 if (zy > zx) zx = zy;
219 if (X2 < X1) X1 = X2;
220 if (Y2 > Y1) Y1 = Y2;
221 X1 = (Standard_Integer ) (X1*zx);
222 Y1 = (Standard_Integer ) (Y1*zx);
223 dout.SetZoom(id,zx*dout.Zoom(id));
224 dout.SetPan(id,-X1,-Y1);
225 dout.RepaintView(id);
230 //=======================================================================
233 //=======================================================================
235 static Standard_Integer wclick(Draw_Interpretor& di, Standard_Integer, const char**)
237 Standard_Integer id1,X1,Y1,b;
239 di << "Just click.\n";
240 dout.Select(id1,X1,Y1,b);
244 //=======================================================================
247 //=======================================================================
249 static Standard_Integer view(Draw_Interpretor& di, Standard_Integer n, const char** a)
251 if (Draw_Batch) return 1;
253 if ((n >= 3) && (n != 4)) {
254 Standard_Integer id = Draw::Atoi(a[1]);
255 if ((id < 0) || (id >= MAXVIEW)) {
256 di <<"View-id must be in 0.."<<MAXVIEW-1<<"\n";
259 Standard_Integer X = 0;
260 Standard_Integer Y = 0;
261 Standard_Integer W = 500;
262 Standard_Integer H = 500;
263 // if view exist, get old values
264 if (dout.HasView(id))
265 dout.GetPosSize(id,X,Y,W,H);
267 X = Draw::Atoi(a[3]);
269 Y = Draw::Atoi(a[4]);
271 W = Draw::Atoi(a[5]);
273 H = Draw::Atoi(a[6]);
274 dout.MakeView(id,a[2],X,Y,W,H);
275 if (!dout.HasView(id)) {
276 di << "View creation failed\n";
280 dout.DisplayView(id);
284 // create a view on a given window
285 Standard_Integer id = Draw::Atoi(a[1]);
286 if ((id < 0) || (id >= MAXVIEW)) {
287 di <<"View-id must be in 0.."<<MAXVIEW-1<<"\n";
290 dout.MakeView(id,a[2],a[3]);
291 if (!dout.HasView(id)) {
292 di << "View creation failed\n";
296 dout.DisplayView(id);
303 //=======================================================================
306 //=======================================================================
308 static Standard_Integer delview(Draw_Interpretor& , Standard_Integer n, const char** a)
311 for (Standard_Integer id = 0; id < MAXVIEW; id++)
316 Standard_Integer id = ViewId(a[1]);
317 if (id < 0) return 1;
325 //=======================================================================
328 //=======================================================================
330 static Standard_Integer fit(Draw_Interpretor& , Standard_Integer n, const char** a)
332 Standard_Boolean f2d = !strcasecmp(a[0],"2dfit");
334 Standard_Real zoom = RealLast();
336 for ( id = 0; id < MAXVIEW; id++) {
337 if (dout.HasView(id)) {
338 if ((f2d && !dout.Is3D(id)) || (!f2d && dout.Is3D(id))) {
339 // dout.FitView(id,frame);
340 dout.FitView(id,(Standard_Integer ) frame);
341 if (dout.Zoom(id) < zoom) zoom = dout.Zoom(id);
345 for (id = 0; id < MAXVIEW; id++) {
346 if (dout.HasView(id)) {
347 if ((f2d && !dout.Is3D(id)) || (!f2d && dout.Is3D(id))) {
348 dout.SetZoom(id,zoom);
349 dout.RepaintView(id);
357 Standard_Integer id = ViewId(a[1]);
358 if (id < 0) return 1;
359 // dout.FitView(id,frame);
360 dout.FitView(id,(Standard_Integer ) frame);
361 dout.RepaintView(id);
369 //=======================================================================
372 //=======================================================================
374 static Standard_Integer focal(Draw_Interpretor& , Standard_Integer n, const char** a)
376 Standard_Integer start = 0;
377 Standard_Integer end = MAXVIEW-1;
379 Standard_Integer anid = ViewId(a[1]);
380 if (anid < 0) return 1;
383 Standard_Real df = 1.;
384 if (!strcasecmp(a[0],"fu"))
386 if (!strcasecmp(a[0],"fd"))
389 for (Standard_Integer id = start; id <= end; id++) {
390 if (!strcasecmp(dout.GetType(id),"PERS")) {
391 dout.SetFocal(id,dout.Focal(id) * df);
392 dout.RepaintView(id);
398 //=======================================================================
399 //function : setfocal
401 //=======================================================================
403 static Standard_Integer setfocal(Draw_Interpretor& di, Standard_Integer n, const char** a)
406 for (Standard_Integer id = 0; id < MAXVIEW; id++) {
407 if (!strcasecmp(dout.GetType(id),"PERS"))
408 di << "Focal view "<<id<<" is "<<dout.Focal(id)<<"\n";
412 Standard_Real f = Draw::Atof(a[1]);
413 for (Standard_Integer id = 0; id < MAXVIEW; id++) {
414 if (!strcasecmp(dout.GetType(id),"PERS"))
422 //=======================================================================
425 //=======================================================================
427 //static Standard_Integer magnify(Draw_Interpretor& di, Standard_Integer n, const char** a)
428 static Standard_Integer magnify(Draw_Interpretor& , Standard_Integer n, const char** a)
430 Standard_Integer start = 0;
431 Standard_Integer end = MAXVIEW-1;
433 Standard_Integer anid = ViewId(a[1]);
434 if (anid < 0) return 1;
437 Standard_Boolean v2d = (a[0][0] == '2'); // 2dmu, 2dmd
438 const char* com = a[0];
440 Standard_Real dz = 1.;
441 if (!strcasecmp(com,"mu")) // mu, 2dmu
446 for (Standard_Integer id = start; id <= end; id++) {
447 if (dout.HasView(id)) {
448 if ((v2d && !dout.Is3D(id)) || (!v2d && dout.Is3D(id))) {
449 dout.SetZoom(id,dout.Zoom(id) * dz);
451 dout.RepaintView(id);
458 Standard_EXPORT Standard_Integer Draw_magnify(Draw_Interpretor& di, Standard_Integer n, const char** a)
460 return magnify(di,n,a);
463 //=======================================================================
466 //=======================================================================
468 static Standard_Integer rotate(Draw_Interpretor& , Standard_Integer n, const char** a)
470 Standard_Integer start = 0;
471 Standard_Integer end = MAXVIEW-1;
473 Standard_Integer anid = ViewId(a[1]);
474 if (anid < 0) return 1;
480 if (!strcasecmp(a[0],"u")) {
484 if (!strcasecmp(a[0],"d")) {
488 if (!strcasecmp(a[0],"l")) {
492 if (!strcasecmp(a[0],"r")) {
497 for (Standard_Integer id = start; id <= end; id++) {
498 if ((!strcasecmp(dout.GetType(id),"AXON")) ||
499 (!strcasecmp(dout.GetType(id),"PERS"))) {
500 dout.RotateView(id,D,ang);
501 dout.RepaintView(id);
507 //=======================================================================
510 //=======================================================================
512 static Standard_Integer panning(Draw_Interpretor& , Standard_Integer n, const char** a)
514 Standard_Integer start = 0;
515 Standard_Integer end = MAXVIEW-1;
517 Standard_Integer anid = ViewId(a[1]);
518 if (anid < 0) return 1;
521 Standard_Integer DX = 0;
522 Standard_Integer DY = 0;
523 Standard_Integer X,Y,W,H;
525 Standard_Boolean v2d = (a[0][0] == '2'); // pu2d, pd2d, pr2d, pl2d
526 const char* com = a[0];
529 if (!strcasecmp(com,"pu")) // pu , 2dpu
531 if (!strcasecmp(com,"pd")) // pd , 2dpd
533 if (!strcasecmp(com,"pl")) // pl , 2dpl
535 if (!strcasecmp(com,"pr")) // pr , 2dpr
538 for (Standard_Integer id = start; id <= end; id++) {
539 if (dout.HasView(id)) {
540 if ((v2d && !dout.Is3D(id)) || (!v2d && dout.Is3D(id))) {
541 dout.GetPosSize(id,X,Y,W,H);
542 // dout.PanView(id,W * DX * steppan, H * DY * steppan);
543 dout.PanView(id,(Standard_Integer )( W * DX * steppan),(Standard_Integer )( H * DY * steppan));
544 dout.RepaintView(id);
551 //=======================================================================
554 //=======================================================================
556 static Standard_Integer ptv(Draw_Interpretor& , Standard_Integer n, const char** a)
559 Standard_Integer start = 0;
560 Standard_Integer end = MAXVIEW-1;
563 Standard_Integer anid = ViewId(a[1]);
564 if (anid < 0) return 1;
566 X = Draw::Atof(a[2]);
567 Y = Draw::Atof(a[3]);
568 Z = Draw::Atof(a[4]);
571 X = Draw::Atof(a[1]);
572 Y = Draw::Atof(a[2]);
573 Z = Draw::Atof(a[3]);
576 for (Standard_Integer id = start; id <= end; id++) {
579 T.SetTranslationPart(gp_Vec(0,0,0));
581 T1.SetTranslationPart(gp_Vec(-X,-Y,-Z));
582 gp_Trsf aLocalTrsf(T*T1);
583 dout.SetTrsf(id,aLocalTrsf);
584 // dout.SetTrsf(id,T*T1);
585 dout.RepaintView(id);
590 //=======================================================================
593 //=======================================================================
595 static Standard_Integer dptv(Draw_Interpretor& , Standard_Integer n, const char** a)
597 Standard_Real DX,DY,DZ;
598 Standard_Integer start = 0;
599 Standard_Integer end = MAXVIEW-1;
602 Standard_Integer anid = ViewId(a[1]);
603 if (anid < 0) return 1;
605 DX = Draw::Atof(a[2]);
606 DY = Draw::Atof(a[3]);
607 DZ = Draw::Atof(a[4]);
610 DX = Draw::Atof(a[1]);
611 DY = Draw::Atof(a[2]);
612 DZ = Draw::Atof(a[3]);
615 for (Standard_Integer id = start; id <= end; id++) {
619 T1.SetTranslationPart(gp_Vec(-DX,-DY,-DZ));
622 dout.RepaintView(id);
628 //=======================================================================
631 //=======================================================================
633 static Standard_Integer color(Draw_Interpretor& di, Standard_Integer n, const char** a)
636 Draw_BlackBackGround = !Draw_BlackBackGround;
638 else if (!dout.DefineColor(Draw::Atoi(a[1]),a[2])) {
639 di << "Could not allocate color "<<a[2]<<"\n";
647 //=======================================================================
648 //function : hardcopy
649 //purpose : hardcopy --> hardcopy of view 1
652 // hardcopy name view --> hardcopy of view <view>
655 // hardcopy name view format --> hardcopy of view <view>
657 // in format <a4,a3,a2,a1,a0>
658 //=======================================================================
660 static Standard_Integer hardcopy(Draw_Interpretor& ,
661 Standard_Integer n, const char** a)
663 // Inch = 25.40001969 mm.
665 // format par default papier a4 210 297 mm avec marge de 3 mm.
667 Standard_Real rap = 28.4;
668 Standard_Real cad = 3;
669 Standard_Real dx = 210;
670 Standard_Real dy = 210 * Sqrt(2.);
672 Standard_Integer iview = 1;
673 const char* file = "a4.ps";
677 iview = ViewId(a[2]);
678 if (iview < 0) return 1;
680 if (!strcmp(a[3],"a7")) {
681 cad = cad / (2 * Sqrt(2));
682 dx = dx / (2 * Sqrt(2));
683 dy = dy / (2 * Sqrt(2));
685 else if (!strcmp(a[3],"a6")) {
690 else if (!strcmp(a[3],"a5")) {
695 else if (!strcmp(a[3],"a4")) {
701 else if (!strcmp(a[3],"a3")) {
706 else if (!strcmp(a[3],"a2")) {
711 else if (!strcmp(a[3],"a1")) {
712 cad = cad * 2 * Sqrt(2);
713 dx = dx * 2 * Sqrt(2);
714 dy = dy * 2 * Sqrt(2);
716 else if (!strcmp(a[3],"a0")) {
725 Standard_Integer pxmin = (Standard_Integer)(cad * rap);
726 Standard_Integer pymin = (Standard_Integer)(cad * rap);
727 Standard_Integer pxmax = (Standard_Integer)((dx - cad) * rap);
728 Standard_Integer pymax = (Standard_Integer)((dy - cad) * rap);
732 Standard_Integer vxmin,vymin,vxmax,vymax;
733 if (dout.HasView(iview)) {
734 dout.GetFrame(iview,vxmin,vymin,vxmax,vymax);
735 Standard_Real kx = (Standard_Real) (pxmax - pxmin) / (vxmax - vxmin);
736 Standard_Real ky = (Standard_Real) (pymax - pymin) / (vymax - vymin);
737 Standard_Real k = Min(Abs(kx),Abs(ky));
738 kx = (kx > 0) ? k : -k;
739 ky = (ky > 0) ? k : -k;
740 pxmax = (Standard_Integer )( pxmin + kx * (vxmax - vxmin));
741 pymax = (Standard_Integer )( pymin + ky * (vymax - vymin));
743 // si on veut choisir l'orientation : 90 rotate
745 // ecriture du header
747 os << "%!PS-Adobe-3.0 EPSF-3.0\n";
748 os << "%%BoundingBox: " << pxmin << " " << pymin << " "
749 << pxmax << " " << pymax << "\n";
750 os << "%%Pages: 1\n";
751 os << "%%DocumentFonts: "<<Draw_fontname<<"\n";
752 os << "%%EndComments\n";
754 os << "/"<<Draw_fontname<<" findfont\n"<<Draw_fontsize<<" scalefont\nsetfont\n";
755 os << "/m {moveto} bind def\n";
756 os << "/l {lineto} bind def\n";
757 os <<".1 .1 scale\n";
761 os <<"3 setlinewidth\n0 setgray\nnewpath\n";
762 os << pxmin << " " << pymin << " m\n";
763 os << pxmax << " " << pymin << " l\n";
764 os << pxmax << " " << pymax << " l\n";
765 os << pxmin << " " << pymax << " l\n";
766 os << "closepath\nstroke\n";
771 os << pxmin << " " << pymin << " m\n";
772 os << pxmax << " " << pymin << " l\n";
773 os << pxmax << " " << pymax << " l\n";
774 os << pxmin << " " << pymax << " l\n";
775 os << "closepath\nclip\n";
777 dout.PostScriptView(iview,
778 vxmin,vymin,vxmax,vymax,
779 pxmin,pymin,pxmax,pymax,os);
787 static Standard_Integer dfont(Draw_Interpretor& di,
788 Standard_Integer n, const char** a)
791 strcpy(Draw_fontname, Draw_fontnamedefault);
792 strcpy(Draw_fontsize, Draw_fontsizedefault);
793 } else if ( n == 2 ) {
794 strcpy(Draw_fontname, a[1]);
795 } else if ( n == 3 ) {
796 strcpy(Draw_fontname, a[1]);
797 strcpy(Draw_fontsize, a[2]);
799 di<<Draw_fontname<<" "<<Draw_fontsize<<"\n";
803 //=======================================================================
806 //=======================================================================
808 static Standard_Integer hcolor(Draw_Interpretor& di, Standard_Integer n, const char** a)
811 di << "code de couleur (Draw.cxx) : \n" ;
812 di << "0 = White,\t 1 = Red,\t 2 = Green,\t 3 = Blue\n" ;
813 di << "4 = Cyan,\t 5 = Gold,\t 6 = Magenta,\t 7 = Maroon" << "\n" ;
814 di << "8 = Orange,\t 9 = Pink,\t 10 = Salmon,\t 11 = Violet\n" ;
815 di << "12 = Yellow,\t 13 = Khaki,\t 14 = Coral\n" ;
816 di << "1 <= width <= 11, 0 (noir) <= gray <= 1 (blanc)\n" ;
818 dout.PostColor(Draw::Atoi(a[1]),Draw::Atoi(a[2]),Draw::Atof(a[3]));
823 //=======================================================================
825 //purpose : xwd file from a view
826 //=======================================================================
828 extern void Draw_RepaintNowIfNecessary();
830 static Standard_Integer xwd(Draw_Interpretor& , Standard_Integer n, const char** a)
834 // enforce repaint if necessary
835 Draw_RepaintNowIfNecessary();
837 Standard_Integer id = 1;
838 const char* file = a[1];
840 id = Draw::Atoi(a[1]);
843 if (!dout.SaveView(id,file))
849 //=======================================================================
851 //purpose : Creation/Suppression d'une grille.
852 //=======================================================================
854 static Standard_Integer grid (Draw_Interpretor& , Standard_Integer NbArg, const char **Arg)
856 Standard_Real StepX, StepY, StepZ ;
860 StepX = DefaultGridStep ;
861 StepY = DefaultGridStep ;
862 StepZ = DefaultGridStep ;
865 StepX = Abs (Draw::Atof (Arg[1])) ;
866 StepY = Abs (Draw::Atof (Arg[1])) ;
867 StepZ = Abs (Draw::Atof (Arg[1])) ;
870 StepX = Abs (Draw::Atof (Arg[1])) ;
871 StepY = Abs (Draw::Atof (Arg[2])) ;
872 StepZ = Abs (Draw::Atof (Arg[2])) ;
875 StepX = Abs (Draw::Atof (Arg[1])) ;
876 StepY = Abs (Draw::Atof (Arg[2])) ;
877 StepZ = Abs (Draw::Atof (Arg[3])) ;
884 const char *temp = "grid";
886 char temp1[] = "grid";
887 const char *temp = temp1;
889 Handle (Draw_Grid) Grille = Handle(Draw_Grid)::DownCast (Draw::Get(temp)) ;
891 Grille->Steps (StepX, StepY, StepZ) ;
897 //=======================================================================
900 //=======================================================================
902 static Standard_Integer dflush (Draw_Interpretor& , Standard_Integer, const char **)
908 //=======================================================================
911 //=======================================================================
913 static Standard_Integer dtext(Draw_Interpretor& di, Standard_Integer n, const char** a)
916 Standard_Boolean is3d;
918 Standard_Integer id,X,Y,b;
919 di << "Pick position with button 1, other button escape\n";
920 dout.Select(id,X,Y,b);
923 Standard_Real z = dout.Zoom(id);
924 P.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0);
929 is3d = dout.Is3D(id);
933 P.SetCoord(Draw::Atof(a[1]),Draw::Atof(a[2]),is3d ? Draw::Atof(a[3]) : 0);
939 Handle(Draw_Text3D) D = new Draw_Text3D(P,a[n-1],Draw_vert);
943 Handle(Draw_Text2D) D = new Draw_Text2D(gp_Pnt2d(P.X(),P.Y()),
950 void Draw::GraphicCommands(Draw_Interpretor& theCommands)
952 static Standard_Boolean Done = Standard_False;
954 Done = Standard_True;
956 const char* g = "DRAW Graphic Commands";
957 theCommands.Add("wclick","wait for a mouse click",
959 theCommands.Add("zoom","zoom [view-id] z, or zoom z for all 3d views",
961 theCommands.Add("2dzoom","2dzoom [view-id] z, or zoom2d z for all 2d views",
963 theCommands.Add("wzoom","wzoom [view-id X1 Y1 X2 Y2]\n"
964 "- fits the contents of a given rectangle into a view window.\n"
965 "- The view window and rectangle corners are specified through the arguments\n"
966 "- or selected interactively by the user if no arguments are given",
968 theCommands.Add("view","view view-id type X(0) Y(0) W(500) H(500)",
970 theCommands.Add("delete","delete [view-id]",
972 theCommands.Add("fit","fit [view-id]",
974 theCommands.Add("2dfit","2dfit [view-id]",
976 theCommands.Add("fu","fu [view-id], focal up",
978 theCommands.Add("fd","fd [view-id], focal down",
980 theCommands.Add("focal","focal [f]",
981 __FILE__,setfocal,g);
982 theCommands.Add("mu","mu [view-id], magnify up",
984 theCommands.Add("2dmu","2dmu [view-id], magnify up",
986 theCommands.Add("md","md [view-id], magnify down",
988 theCommands.Add("2dmd","2dmd [view-id], magnify down",
990 theCommands.Add("u","u [view-id], rotate up",
992 theCommands.Add("d","d [view-id], rotate down",
994 theCommands.Add("l","l [view-id], rotate left",__FILE__,rotate,g);
995 theCommands.Add("r","r [view-id], rotate right",__FILE__,rotate,g);
996 theCommands.Add("pu","pu [view-id], panning up",__FILE__,panning,g);
997 theCommands.Add("pd","pd [view-id], panning down",__FILE__,panning,g);
998 theCommands.Add("pl","pl [view-id], panning left",__FILE__,panning,g);
999 theCommands.Add("pr","pr [view-id], panning right",__FILE__,panning,g);
1000 theCommands.Add("2dpu","2dpu [view-id], panning up",__FILE__,panning,g);
1001 theCommands.Add("2dpd","2dpd [view-id], panning down",__FILE__,panning,g);
1002 theCommands.Add("2dpl","2dpl [view-id], panning left",__FILE__,panning,g);
1003 theCommands.Add("2dpr","2dpr [view-id], panning right",__FILE__,panning,g);
1004 theCommands.Add("ptv","ptv [view-id], X , Y , Z",
1006 theCommands.Add("dptv","dptv [view-id], dX , dY , dZ",
1008 theCommands.Add("color","color i colorname, define color i",
1010 theCommands.Add("hardcopy","hardcopy [file = a4.ps] [view-id = 1] [format = a4]", __FILE__,hardcopy,g);
1011 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",
1013 theCommands.Add("hcolor","hcolor icol width gray (< 1, 0 black)",
1015 theCommands.Add("grid", "grid [stepX(100) [stepY [stepZ]]] / 0",
1017 theCommands.Add("dflush","dflush, flush the viewer",
1019 theCommands.Add("dtext","dtext [x y [z]] string",
1021 theCommands.Add("dfont","dfont [name size] : set name and size of Draw font, or reset to default",