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.
21 // **************************************************************
24 // Modif : DFO 05/11/96
30 #include <Draw_Appli.hxx>
32 #include <Draw_Drawable3D.hxx>
33 #include <Draw_Grid.hxx>
34 #include <Draw_Display.hxx>
35 #include <Draw_Text3D.hxx>
36 #include <Draw_Text2D.hxx>
38 #include <Standard_Stream.hxx>
42 extern Draw_Viewer dout;
43 extern Standard_Boolean Draw_Batch;
49 extern Standard_Boolean Draw_BlackBackGround;
52 #define DEFROTATE (5 * M_PI/ 180.)
53 #define DEFMAGNIFY 1.1
54 #define DEFPANNING 0.1
57 #define DEFGRIDSTEP 100.0
58 static Standard_Real steprot = DEFROTATE;
59 static Standard_Real steppan = DEFPANNING;
60 static Standard_Real stepmagnify = DEFMAGNIFY;
61 static Standard_Real stepfocal = DEFFOCAL;
62 static Standard_Real frame = DEFFRAME;
63 static Standard_Real DefaultGridStep = DEFGRIDSTEP ;
66 static char Draw_fontname[FONTLENGTH]="Helvetica";
67 static char Draw_fontsize[FONTLENGTH]="150";
68 static char Draw_fontnamedefault[FONTLENGTH]="Helvetica";
69 static char Draw_fontsizedefault[FONTLENGTH]="150";
71 // *******************************************************************
73 // *******************************************************************
75 static Standard_Integer ViewId(const Standard_CString a)
77 Standard_Integer id = Draw::Atoi(a);
78 if ((id < 0) || (id >= MAXVIEW)) {
79 cout << "Incorrect view-id, must be in 0.."<<MAXVIEW-1<<endl;
82 if (!dout.HasView(id)) {
83 cout <<"View "<<id<<" does not exist."<<endl;
89 static void SetTitle(const Standard_Integer id)
91 if (dout.HasView(id)) {
93 Sprintf(title,"%d : %s - Zoom %f",id,dout.GetType(id),dout.Zoom(id));
94 dout.SetTitle(id,title);
98 //=======================================================================
101 //=======================================================================
103 static Standard_Integer zoom(Draw_Interpretor& , Standard_Integer n, const char** a)
105 // one argument -> All Views
106 // two argument -> First is the view
107 Standard_Boolean z2d = !strcasecmp(a[0],"2dzoom");
109 Standard_Real z = Draw::Atof(a[1]);
110 for (Standard_Integer id = 0; id < MAXVIEW; id++) {
111 if (dout.HasView(id)) {
112 if ((z2d && !dout.Is3D(id)) || (!z2d && dout.Is3D(id))) {
115 dout.RepaintView(id);
122 Standard_Integer id = ViewId(a[1]);
123 if (id < 0) return 1;
124 Standard_Real z = Draw::Atof(a[2]);
126 dout.RepaintView(id);
134 //=======================================================================
137 //=======================================================================
139 static Standard_Integer wzoom(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
141 Standard_Integer id,X,Y,W,H,X1,Y1,X2,Y2,b;
142 Standard_Real dX1,dY1,dX2,dY2,zx,zy;
143 if(argc != 1 && argc != 6)
145 di<<"Usage : " << argv[0] << " [view-id X1 Y1 X2 Y2]\n";
150 di << "Pick first corner"<<"\n";
151 dout.Select(id,X1,Y1,b);
158 Standard_Real z = dout.Zoom(id);
161 dX1-=P0.X(); dY1-=P0.Y();
164 if (b != 1) return 0;
165 if (id < 0) return 0;
166 Draw_Display d = dout.MakeDisplay(id);
167 d.SetColor(Draw_blanc);
169 Standard_Real dOX2 = dX1;
170 Standard_Real dOY2 = dY1;
171 d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dOY2));
172 d.Draw(gp_Pnt2d(dX1,dOY2),gp_Pnt2d(dOX2,dOY2));
173 d.Draw(gp_Pnt2d(dOX2,dOY2),gp_Pnt2d(dOX2,dY1));
174 d.Draw(gp_Pnt2d(dOX2,dY1),gp_Pnt2d(dX1,dY1));
176 dout.GetPosSize(id,X,Y,W,H);
177 di << "Pick second corner"<<"\n";
180 dout.Select(id,X2,Y2,b,Standard_False);
182 dX2-=P0.X(); dY2-=P0.Y();
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));
189 d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dY2));
190 d.Draw(gp_Pnt2d(dX1,dY2),gp_Pnt2d(dX2,dY2));
191 d.Draw(gp_Pnt2d(dX2,dY2),gp_Pnt2d(dX2,dY1));
192 d.Draw(gp_Pnt2d(dX2,dY1),gp_Pnt2d(dX1,dY1));
197 d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dOY2));
198 d.Draw(gp_Pnt2d(dX1,dOY2),gp_Pnt2d(dOX2,dOY2));
199 d.Draw(gp_Pnt2d(dOX2,dOY2),gp_Pnt2d(dOX2,dY1));
200 d.Draw(gp_Pnt2d(dOX2,dY1),gp_Pnt2d(dX1,dY1));
202 if (b != 1) return 0;
208 if ((id < 0) || (id >= MAXVIEW))
210 cout << "Incorrect view-id, must be in 0.."<<MAXVIEW-1<<endl;
213 if (!dout.HasView(id))
215 cout <<"View "<<id<<" does not exist."<<endl;
218 X1 = atoi (argv [2]);
219 Y1 = atoi (argv [3]);
220 X2 = atoi (argv [4]);
221 Y2 = atoi (argv [5]);
223 dout.GetPosSize(id,X,Y,W,H);
226 if ((X1 == X2) || (Y1 == Y2)) return 0;
227 zx = (Standard_Real) Abs(X2-X1) / (Standard_Real) W;
228 zy = (Standard_Real) Abs(Y2-Y1) / (Standard_Real) H;
229 if (zy > zx) zx = zy;
231 if (X2 < X1) X1 = X2;
232 if (Y2 > Y1) Y1 = Y2;
233 X1 = (Standard_Integer ) (X1*zx);
234 Y1 = (Standard_Integer ) (Y1*zx);
235 dout.SetZoom(id,zx*dout.Zoom(id));
236 dout.SetPan(id,-X1,-Y1);
237 dout.RepaintView(id);
242 //=======================================================================
245 //=======================================================================
247 static Standard_Integer wclick(Draw_Interpretor& di, Standard_Integer, const char**)
249 Standard_Integer id1,X1,Y1,b;
251 di << "Just click."<<"\n";
252 dout.Select(id1,X1,Y1,b);
256 //=======================================================================
259 //=======================================================================
261 static Standard_Integer view(Draw_Interpretor& di, Standard_Integer n, const char** a)
263 if (Draw_Batch) return 1;
265 if ((n >= 3) && (n != 4)) {
266 Standard_Integer id = Draw::Atoi(a[1]);
267 if ((id < 0) || (id >= MAXVIEW)) {
268 di <<"View-id must be in 0.."<<MAXVIEW-1<<"\n";
271 Standard_Integer X = 0;
272 Standard_Integer Y = 0;
273 Standard_Integer W = 500;
274 Standard_Integer H = 500;
275 // if view exist, get old values
276 if (dout.HasView(id))
277 dout.GetPosSize(id,X,Y,W,H);
279 X = Draw::Atoi(a[3]);
281 Y = Draw::Atoi(a[4]);
283 W = Draw::Atoi(a[5]);
285 H = Draw::Atoi(a[6]);
286 dout.MakeView(id,a[2],X,Y,W,H);
287 if (!dout.HasView(id)) {
288 di << "View creation failed"<<"\n";
292 dout.DisplayView(id);
296 // create a view on a given window
297 Standard_Integer id = Draw::Atoi(a[1]);
298 if ((id < 0) || (id >= MAXVIEW)) {
299 di <<"View-id must be in 0.."<<MAXVIEW-1<<"\n";
302 dout.MakeView(id,a[2],a[3]);
303 if (!dout.HasView(id)) {
304 di << "View creation failed"<<"\n";
308 dout.DisplayView(id);
315 //=======================================================================
318 //=======================================================================
320 static Standard_Integer delview(Draw_Interpretor& , Standard_Integer n, const char** a)
323 for (Standard_Integer id = 0; id < MAXVIEW; id++)
328 Standard_Integer id = ViewId(a[1]);
329 if (id < 0) return 1;
337 //=======================================================================
340 //=======================================================================
342 static Standard_Integer fit(Draw_Interpretor& , Standard_Integer n, const char** a)
344 Standard_Boolean f2d = !strcasecmp(a[0],"2dfit");
346 Standard_Real zoom = RealLast();
348 for ( id = 0; id < MAXVIEW; id++) {
349 if (dout.HasView(id)) {
350 if ((f2d && !dout.Is3D(id)) || (!f2d && dout.Is3D(id))) {
351 // dout.FitView(id,frame);
352 dout.FitView(id,(Standard_Integer ) frame);
353 if (dout.Zoom(id) < zoom) zoom = dout.Zoom(id);
357 for (id = 0; id < MAXVIEW; id++) {
358 if (dout.HasView(id)) {
359 if ((f2d && !dout.Is3D(id)) || (!f2d && dout.Is3D(id))) {
360 dout.SetZoom(id,zoom);
361 dout.RepaintView(id);
369 Standard_Integer id = ViewId(a[1]);
370 if (id < 0) return 1;
371 // dout.FitView(id,frame);
372 dout.FitView(id,(Standard_Integer ) frame);
373 dout.RepaintView(id);
381 //=======================================================================
384 //=======================================================================
386 static Standard_Integer focal(Draw_Interpretor& , Standard_Integer n, const char** a)
388 Standard_Integer start = 0;
389 Standard_Integer end = MAXVIEW-1;
391 Standard_Integer anid = ViewId(a[1]);
392 if (anid < 0) return 1;
395 Standard_Real df = 1.;
396 if (!strcasecmp(a[0],"fu"))
398 if (!strcasecmp(a[0],"fd"))
401 for (Standard_Integer id = start; id <= end; id++) {
402 if (!strcasecmp(dout.GetType(id),"PERS")) {
403 dout.SetFocal(id,dout.Focal(id) * df);
404 dout.RepaintView(id);
410 //=======================================================================
411 //function : setfocal
413 //=======================================================================
415 static Standard_Integer setfocal(Draw_Interpretor& di, Standard_Integer n, const char** a)
418 for (Standard_Integer id = 0; id < MAXVIEW; id++) {
419 if (!strcasecmp(dout.GetType(id),"PERS"))
420 di << "Focal view "<<id<<" is "<<dout.Focal(id)<<"\n";
424 Standard_Real f = Draw::Atof(a[1]);
425 for (Standard_Integer id = 0; id < MAXVIEW; id++) {
426 if (!strcasecmp(dout.GetType(id),"PERS"))
434 //=======================================================================
437 //=======================================================================
439 //static Standard_Integer magnify(Draw_Interpretor& di, Standard_Integer n, const char** a)
440 static Standard_Integer magnify(Draw_Interpretor& , Standard_Integer n, const char** a)
442 Standard_Integer start = 0;
443 Standard_Integer end = MAXVIEW-1;
445 Standard_Integer anid = ViewId(a[1]);
446 if (anid < 0) return 1;
449 Standard_Boolean v2d = (a[0][0] == '2'); // 2dmu, 2dmd
450 const char* com = a[0];
452 Standard_Real dz = 1.;
453 if (!strcasecmp(com,"mu")) // mu, 2dmu
458 for (Standard_Integer id = start; id <= end; id++) {
459 if (dout.HasView(id)) {
460 if ((v2d && !dout.Is3D(id)) || (!v2d && dout.Is3D(id))) {
461 dout.SetZoom(id,dout.Zoom(id) * dz);
463 dout.RepaintView(id);
470 Standard_EXPORT Standard_Integer Draw_magnify(Draw_Interpretor& di, Standard_Integer n, const char** a)
472 return magnify(di,n,a);
475 //=======================================================================
478 //=======================================================================
480 static Standard_Integer rotate(Draw_Interpretor& , Standard_Integer n, const char** a)
482 Standard_Integer start = 0;
483 Standard_Integer end = MAXVIEW-1;
485 Standard_Integer anid = ViewId(a[1]);
486 if (anid < 0) return 1;
492 if (!strcasecmp(a[0],"u")) {
496 if (!strcasecmp(a[0],"d")) {
500 if (!strcasecmp(a[0],"l")) {
504 if (!strcasecmp(a[0],"r")) {
509 for (Standard_Integer id = start; id <= end; id++) {
510 if ((!strcasecmp(dout.GetType(id),"AXON")) ||
511 (!strcasecmp(dout.GetType(id),"PERS"))) {
512 dout.RotateView(id,D,ang);
513 dout.RepaintView(id);
519 //=======================================================================
522 //=======================================================================
524 static Standard_Integer panning(Draw_Interpretor& , Standard_Integer n, const char** a)
526 Standard_Integer start = 0;
527 Standard_Integer end = MAXVIEW-1;
529 Standard_Integer anid = ViewId(a[1]);
530 if (anid < 0) return 1;
533 Standard_Integer DX = 0;
534 Standard_Integer DY = 0;
535 Standard_Integer X,Y,W,H;
537 Standard_Boolean v2d = (a[0][0] == '2'); // pu2d, pd2d, pr2d, pl2d
538 const char* com = a[0];
541 if (!strcasecmp(com,"pu")) // pu , 2dpu
543 if (!strcasecmp(com,"pd")) // pd , 2dpd
545 if (!strcasecmp(com,"pl")) // pl , 2dpl
547 if (!strcasecmp(com,"pr")) // pr , 2dpr
550 for (Standard_Integer id = start; id <= end; id++) {
551 if (dout.HasView(id)) {
552 if ((v2d && !dout.Is3D(id)) || (!v2d && dout.Is3D(id))) {
553 dout.GetPosSize(id,X,Y,W,H);
554 // dout.PanView(id,W * DX * steppan, H * DY * steppan);
555 dout.PanView(id,(Standard_Integer )( W * DX * steppan),(Standard_Integer )( H * DY * steppan));
556 dout.RepaintView(id);
563 //=======================================================================
566 //=======================================================================
568 static Standard_Integer ptv(Draw_Interpretor& , Standard_Integer n, const char** a)
571 Standard_Integer start = 0;
572 Standard_Integer end = MAXVIEW-1;
575 Standard_Integer anid = ViewId(a[1]);
576 if (anid < 0) return 1;
578 X = Draw::Atof(a[2]);
579 Y = Draw::Atof(a[3]);
580 Z = Draw::Atof(a[4]);
583 X = Draw::Atof(a[1]);
584 Y = Draw::Atof(a[2]);
585 Z = Draw::Atof(a[3]);
588 for (Standard_Integer id = start; id <= end; id++) {
591 T.SetTranslationPart(gp_Vec(0,0,0));
593 T1.SetTranslationPart(gp_Vec(-X,-Y,-Z));
594 gp_Trsf aLocalTrsf(T*T1);
595 dout.SetTrsf(id,aLocalTrsf);
596 // dout.SetTrsf(id,T*T1);
597 dout.RepaintView(id);
602 //=======================================================================
605 //=======================================================================
607 static Standard_Integer dptv(Draw_Interpretor& , Standard_Integer n, const char** a)
609 Standard_Real DX,DY,DZ;
610 Standard_Integer start = 0;
611 Standard_Integer end = MAXVIEW-1;
614 Standard_Integer anid = ViewId(a[1]);
615 if (anid < 0) return 1;
617 DX = Draw::Atof(a[2]);
618 DY = Draw::Atof(a[3]);
619 DZ = Draw::Atof(a[4]);
622 DX = Draw::Atof(a[1]);
623 DY = Draw::Atof(a[2]);
624 DZ = Draw::Atof(a[3]);
627 for (Standard_Integer id = start; id <= end; id++) {
631 T1.SetTranslationPart(gp_Vec(-DX,-DY,-DZ));
634 dout.RepaintView(id);
640 //=======================================================================
643 //=======================================================================
645 static Standard_Integer color(Draw_Interpretor& di, Standard_Integer n, const char** a)
648 Draw_BlackBackGround = !Draw_BlackBackGround;
650 else if (!dout.DefineColor(Draw::Atoi(a[1]),a[2])) {
651 di << "Could not allocate color "<<a[2]<<"\n";
659 //=======================================================================
660 //function : hardcopy
661 //purpose : hardcopy --> hardcopy of view 1
664 // hardcopy name view --> hardcopy of view <view>
667 // hardcopy name view format --> hardcopy of view <view>
669 // in format <a4,a3,a2,a1,a0>
670 //=======================================================================
672 static Standard_Integer hardcopy(Draw_Interpretor& ,
673 Standard_Integer n, const char** a)
675 // Inch = 25.40001969 mm.
677 // format par default papier a4 210 297 mm avec marge de 3 mm.
679 Standard_Real rap = 28.4;
680 Standard_Real cad = 3;
681 Standard_Real dx = 210;
682 Standard_Real dy = 210 * Sqrt(2.);
684 Standard_Integer iview = 1;
685 const char* file = "a4.ps";
689 iview = ViewId(a[2]);
690 if (iview < 0) return 1;
692 if (!strcmp(a[3],"a7")) {
693 cad = cad / (2 * Sqrt(2));
694 dx = dx / (2 * Sqrt(2));
695 dy = dy / (2 * Sqrt(2));
697 else if (!strcmp(a[3],"a6")) {
702 else if (!strcmp(a[3],"a5")) {
707 else if (!strcmp(a[3],"a4")) {
712 else if (!strcmp(a[3],"a3")) {
717 else if (!strcmp(a[3],"a2")) {
722 else if (!strcmp(a[3],"a1")) {
723 cad = cad * 2 * Sqrt(2);
724 dx = dx * 2 * Sqrt(2);
725 dy = dy * 2 * Sqrt(2);
727 else if (!strcmp(a[3],"a0")) {
736 Standard_Integer pxmin = (Standard_Integer)(cad * rap);
737 Standard_Integer pymin = (Standard_Integer)(cad * rap);
738 Standard_Integer pxmax = (Standard_Integer)((dx - cad) * rap);
739 Standard_Integer pymax = (Standard_Integer)((dy - cad) * rap);
743 Standard_Integer vxmin,vymin,vxmax,vymax;
744 if (dout.HasView(iview)) {
745 dout.GetFrame(iview,vxmin,vymin,vxmax,vymax);
746 Standard_Real kx = (Standard_Real) (pxmax - pxmin) / (vxmax - vxmin);
747 Standard_Real ky = (Standard_Real) (pymax - pymin) / (vymax - vymin);
748 Standard_Real k = Min(Abs(kx),Abs(ky));
749 kx = (kx > 0) ? k : -k;
750 ky = (ky > 0) ? k : -k;
751 pxmax = (Standard_Integer )( pxmin + kx * (vxmax - vxmin));
752 pymax = (Standard_Integer )( pymin + ky * (vymax - vymin));
754 // si on veut choisir l'orientation : 90 rotate
756 // ecriture du header
758 os << "%!PS-Adobe-3.0 EPSF-3.0\n";
759 os << "%%BoundingBox: " << pxmin << " " << pymin << " "
760 << pxmax << " " << pymax << "\n";
761 os << "%%Pages: 1\n";
762 os << "%%DocumentFonts: "<<Draw_fontname<<"\n";
763 os << "%%EndComments\n";
765 os << "/"<<Draw_fontname<<" findfont\n"<<Draw_fontsize<<" scalefont\nsetfont\n";
766 os << "/m {moveto} bind def\n";
767 os << "/l {lineto} bind def\n";
768 os <<".1 .1 scale\n";
772 os <<"3 setlinewidth\n0 setgray\nnewpath\n";
773 os << pxmin << " " << pymin << " m\n";
774 os << pxmax << " " << pymin << " l\n";
775 os << pxmax << " " << pymax << " l\n";
776 os << pxmin << " " << pymax << " l\n";
777 os << "closepath\nstroke\n";
782 os << pxmin << " " << pymin << " m\n";
783 os << pxmax << " " << pymin << " l\n";
784 os << pxmax << " " << pymax << " l\n";
785 os << pxmin << " " << pymax << " l\n";
786 os << "closepath\nclip\n";
788 dout.PostScriptView(iview,
789 vxmin,vymin,vxmax,vymax,
790 pxmin,pymin,pxmax,pymax,os);
798 static Standard_Integer dfont(Draw_Interpretor& di,
799 Standard_Integer n, const char** a)
802 strcpy(Draw_fontname, Draw_fontnamedefault);
803 strcpy(Draw_fontsize, Draw_fontsizedefault);
804 } else if ( n == 2 ) {
805 strcpy(Draw_fontname, a[1]);
806 } else if ( n == 3 ) {
807 strcpy(Draw_fontname, a[1]);
808 strcpy(Draw_fontsize, a[2]);
810 di<<Draw_fontname<<" "<<Draw_fontsize<<"\n";
814 //=======================================================================
817 //=======================================================================
819 static Standard_Integer hcolor(Draw_Interpretor& di, Standard_Integer n, const char** a)
822 di << "code de couleur (Draw.cxx) : " << "\n" ;
823 di << "0 = White,\t 1 = Red,\t 2 = Green,\t 3 = Blue" << "\n" ;
824 di << "4 = Cyan,\t 5 = Gold,\t 6 = Magenta,\t 7 = Maroon" << "\n" ;
825 di << "8 = Orange,\t 9 = Pink,\t 10 = Salmon,\t 11 = Violet" << "\n" ;
826 di << "12 = Yellow,\t 13 = Khaki,\t 14 = Coral" << "\n" ;
827 di << "1 <= width <= 11, 0 (noir) <= gray <= 1 (blanc)" << "\n" ;
829 dout.PostColor(Draw::Atoi(a[1]),Draw::Atoi(a[2]),Draw::Atof(a[3]));
834 //=======================================================================
836 //purpose : xwd file from a view
837 //=======================================================================
839 extern void Draw_RepaintNowIfNecessary();
841 static Standard_Integer xwd(Draw_Interpretor& , Standard_Integer n, const char** a)
845 // enforce repaint if necessary
846 Draw_RepaintNowIfNecessary();
848 Standard_Integer id = 1;
849 const char* file = a[1];
851 id = Draw::Atoi(a[1]);
854 if (!dout.SaveView(id,file))
860 //=======================================================================
862 //purpose : Creation/Suppression d'une grille.
863 //=======================================================================
865 static Standard_Integer grid (Draw_Interpretor& , Standard_Integer NbArg, const char **Arg)
867 Standard_Real StepX, StepY, StepZ ;
871 StepX = DefaultGridStep ;
872 StepY = DefaultGridStep ;
873 StepZ = DefaultGridStep ;
876 StepX = Abs (Draw::Atof (Arg[1])) ;
877 StepY = Abs (Draw::Atof (Arg[1])) ;
878 StepZ = Abs (Draw::Atof (Arg[1])) ;
881 StepX = Abs (Draw::Atof (Arg[1])) ;
882 StepY = Abs (Draw::Atof (Arg[2])) ;
883 StepZ = Abs (Draw::Atof (Arg[2])) ;
886 StepX = Abs (Draw::Atof (Arg[1])) ;
887 StepY = Abs (Draw::Atof (Arg[2])) ;
888 StepZ = Abs (Draw::Atof (Arg[3])) ;
895 const char *temp = "grid";
897 char temp1[] = "grid";
898 const char *temp = temp1;
900 Handle (Draw_Grid) Grille = Handle(Draw_Grid)::DownCast (Draw::Get(temp)) ;
902 Grille->Steps (StepX, StepY, StepZ) ;
908 //=======================================================================
911 //=======================================================================
913 static Standard_Integer dflush (Draw_Interpretor& , Standard_Integer, const char **)
919 //=======================================================================
922 //=======================================================================
924 static Standard_Integer dtext(Draw_Interpretor& di, Standard_Integer n, const char** a)
927 Standard_Boolean is3d;
929 Standard_Integer id,X,Y,b;
930 di << "Pick position with button 1, other button escape"<<"\n";
931 dout.Select(id,X,Y,b);
934 Standard_Real z = dout.Zoom(id);
935 P.SetCoord((Standard_Real)X /z,(Standard_Real)Y /z,0);
940 is3d = dout.Is3D(id);
944 P.SetCoord(Draw::Atof(a[1]),Draw::Atof(a[2]),is3d ? Draw::Atof(a[3]) : 0);
950 Handle(Draw_Text3D) D = new Draw_Text3D(P,a[n-1],Draw_vert);
954 Handle(Draw_Text2D) D = new Draw_Text2D(gp_Pnt2d(P.X(),P.Y()),
961 void Draw::GraphicCommands(Draw_Interpretor& theCommands)
963 static Standard_Boolean Done = Standard_False;
965 Done = Standard_True;
967 const char* g = "DRAW Graphic Commands";
968 theCommands.Add("wclick","wait for a mouse click",
970 theCommands.Add("zoom","zoom [view-id] z, or zoom z for all 3d views",
972 theCommands.Add("2dzoom","2dzoom [view-id] z, or zoom2d z for all 2d views",
974 theCommands.Add("wzoom","wzoom [view-id X1 Y1 X2 Y2]\n"
975 "- fits the contents of a given rectangle into a view window.\n"
976 "- The view window and rectangle corners are specified through the arguments\n"
977 "- or selected interactively by the user if no arguments are given",
979 theCommands.Add("view","view view-id type X(0) Y(0) W(500) H(500)",
981 theCommands.Add("delete","delete [view-id]",
983 theCommands.Add("fit","fit [view-id]",
985 theCommands.Add("2dfit","2dfit [view-id]",
987 theCommands.Add("fu","fu [view-id], focal up",
989 theCommands.Add("fd","fd [view-id], focal down",
991 theCommands.Add("focal","focal [f]",
992 __FILE__,setfocal,g);
993 theCommands.Add("mu","mu [view-id], magnify up",
995 theCommands.Add("2dmu","2dmu [view-id], magnify up",
997 theCommands.Add("md","md [view-id], magnify down",
999 theCommands.Add("2dmd","2dmd [view-id], magnify down",
1000 __FILE__,magnify,g);
1001 theCommands.Add("u","u [view-id], rotate up",
1003 theCommands.Add("d","d [view-id], rotate down",
1005 theCommands.Add("l","l [view-id], rotate left",__FILE__,rotate,g);
1006 theCommands.Add("r","r [view-id], rotate right",__FILE__,rotate,g);
1007 theCommands.Add("pu","pu [view-id], panning up",__FILE__,panning,g);
1008 theCommands.Add("pd","pd [view-id], panning down",__FILE__,panning,g);
1009 theCommands.Add("pl","pl [view-id], panning left",__FILE__,panning,g);
1010 theCommands.Add("pr","pr [view-id], panning right",__FILE__,panning,g);
1011 theCommands.Add("2dpu","2dpu [view-id], panning up",__FILE__,panning,g);
1012 theCommands.Add("2dpd","2dpd [view-id], panning down",__FILE__,panning,g);
1013 theCommands.Add("2dpl","2dpl [view-id], panning left",__FILE__,panning,g);
1014 theCommands.Add("2dpr","2dpr [view-id], panning right",__FILE__,panning,g);
1015 theCommands.Add("ptv","ptv [view-id], X , Y , Z",
1017 theCommands.Add("dptv","dptv [view-id], dX , dY , dZ",
1019 theCommands.Add("color","color i colorname, define color i",
1021 theCommands.Add("hardcopy","hardcopy [file = a4.ps] [view-id = 1] [format = a4]", __FILE__,hardcopy,g);
1022 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",
1024 theCommands.Add("hcolor","hcolor icol width gray (< 1, 0 black)",
1026 theCommands.Add("grid", "grid [stepX(100) [stepY [stepZ]]] / 0",
1028 theCommands.Add("dflush","dflush, flush the viewer",
1030 theCommands.Add("dtext","dtext [x y [z]] string",
1032 theCommands.Add("dfont","dfont [name size] : set name and size of Draw font, or reset to default",