1 // Created on: 2002-02-04
2 // Created by: QA Admin
3 // Copyright (c) 2002-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
26 #include <QADraw_DataMapOfAsciiStringOfAddress.hxx>
27 #include <Draw_Interpretor.hxx>
28 #include <Image_PixMap.hxx>
29 #include <V3d_View.hxx>
30 #include <ViewerTest.hxx>
31 #include <ViewerTest_EventManager.hxx>
32 #include <TColStd_StackOfInteger.hxx>
33 #include <TColStd_ListOfInteger.hxx>
34 #include <TColStd_ListIteratorOfListOfInteger.hxx>
35 #include <TColStd_HSequenceOfReal.hxx>
36 #include <AIS_InteractiveContext.hxx>
37 #include <Graphic3d_GraphicDevice.hxx>
38 #include <Draw_Window.hxx>
39 #include <Draw_Viewer.hxx>
40 #include <Aspect_WindowDriver.hxx>
43 #include <Viewer2dTest.hxx>
44 #include <V2d_View.hxx>
45 #include <Viewer2dTest_EventManager.hxx>
48 #include <Xw_Window.hxx>
51 #include <X11/Xutil.h>
52 #include <Xw_GraphicDevice.hxx>
53 #include <Xw_Cextern.hxx>
57 #include <WNT_GraphicDevice.hxx>
58 #include <WNT_Window.hxx>
64 #if ! defined(STDOUT_FILENO)
65 #define STDOUT_FILENO fileno(stdout)
69 #if ! defined(STDERR_FILENO)
70 #define STDERR_FILENO fileno(stderr)
73 Draw_Interpretor *thePCommands = NULL;
76 //extern Draw_Interpretor theCommands;
78 extern void (*Draw_BeforeCommand)();
79 extern void (*Draw_AfterCommand)(Standard_Integer);
81 //Standard_EXPORT Draw_Interpretor theCommands;
83 Standard_EXPORT void (*Draw_BeforeCommand)();
84 Standard_EXPORT void (*Draw_AfterCommand)(Standard_Integer);
88 #include <Draw_PluginMacro.hxx>
90 // avoid warnings on 'extern "C"' functions returning C++ classes
92 #pragma warning(4:4190)
98 void (*Draw_BeforeCommand_old)();
99 void (*Draw_AfterCommand_old)(Standard_Integer);
101 static Standard_Boolean should_be_printed = Standard_True;
103 static Standard_Boolean shouldDUP() {
105 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
106 const Standard_Character * adup = Tcl_GetVar(thePCommands->Interp(),
107 "QA_DUP",TCL_GLOBAL_ONLY);
109 Standard_Character * adup = Tcl_GetVar(thePCommands->Interp(),
110 "QA_DUP",TCL_GLOBAL_ONLY);
112 Standard_Integer aDUP=1;
113 if((adup != NULL) && (atof(adup) == 0)) {
120 static void before() {
121 should_be_printed = Standard_True;
122 if(Draw_BeforeCommand_old) (*Draw_BeforeCommand_old) ();
125 static void after(Standard_Integer a)
127 if(Draw_AfterCommand_old) (*Draw_AfterCommand_old) (a);
128 if(!should_be_printed) {
129 // Tcl_ResetResult(theCommands.Interp());
133 static QADraw_DataMapOfAsciiStringOfAddress stFuncMap;
136 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
137 static Standard_Integer (*CommandCmd_Old)
138 (ClientData clientData, Tcl_Interp *interp,
139 Standard_Integer argc, const char* argv[]) = NULL;
141 static Standard_Integer (*CommandCmd_Old)
142 (ClientData clientData, Tcl_Interp *interp,
143 Standard_Integer argc, char* argv[]) = NULL;
147 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
148 static Standard_Integer CommandCmd
149 (ClientData clientData, Tcl_Interp *interp,
150 Standard_Integer argc, const char* argv[])
152 static Standard_Integer CommandCmd
153 (ClientData clientData, Tcl_Interp *interp,
154 Standard_Integer argc, char* argv[])
157 Standard_Integer old_out = 0;
158 Standard_Integer old_err = 0;
159 Standard_Integer fd_out = 0;
160 Standard_Integer fd_err = 0;
162 FILE * aFile_out = NULL;
163 FILE * aFile_err = NULL;
168 if(strlen(getenv("TEMP")) == 0) {
169 cerr << "The TEMP variable is not set." << endl;
170 aFile_out = tmpfile();
171 aFile_err = tmpfile();
173 nameo = _tempnam(getenv("TEMP"),"tmpo");
174 namee = _tempnam(getenv("TEMP"),"tmpe");
175 aFile_out=fopen(nameo, "w+");
176 aFile_err=fopen(namee, "w+");
179 aFile_out = tmpfile();
180 aFile_err = tmpfile();
182 fd_out = fileno(aFile_out);
183 fd_err = fileno(aFile_err);
184 if(fd_out !=-1 && fd_err !=-1) {
185 old_err = dup(STDERR_FILENO);
186 old_out = dup(STDOUT_FILENO);
187 dup2(fd_err,STDERR_FILENO);
188 dup2(fd_out,STDOUT_FILENO);
190 cout << "Faulty : Can not create temporary file." << endl;
192 Standard_Integer clen = sizeof(Standard_Character);
194 Standard_Character * QA = getenv("QA_print_command");
195 if((QA != NULL) && (!strcmp(QA,"1"))) {
196 for(Standard_Integer i=0;i<argc;i++) {
197 write(st_err,argv[i],clen*strlen(argv[i]));
198 write(st_err," ",clen);
200 write(st_err,"\n",clen);
204 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
205 TCollection_AsciiString aName((char *) argv[0]);
207 TCollection_AsciiString aName(argv[0]);
210 Standard_Integer res = 0;
212 if(stFuncMap.IsBound(aName)) {
214 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
215 CommandCmd_Old = (int(*)(void*, Tcl_Interp*, int, const char**)) stFuncMap((char *) argv[0]);
217 CommandCmd_Old = (int(*)(void*, Tcl_Interp*, int, char**)) stFuncMap(argv[0]);
219 res = (*CommandCmd_Old) (clientData,interp,argc,argv);
224 close(STDERR_FILENO);
225 close(STDOUT_FILENO);
226 dup2(old_err,STDERR_FILENO);
227 dup2(old_out,STDOUT_FILENO);
231 Standard_Character buf[256];
232 Standard_Integer len = 0;
235 while((len = read(fd_err,buf,clen*255)/clen) > 0) {
238 (*thePCommands) << buf;
240 write(st_err,buf,clen*len);
248 while((len = read(fd_out,buf,clen*255)/clen) > 0) {
251 (*thePCommands) << buf;
253 write(st_err,buf,clen*len);
259 Standard_Character *Result = (Standard_Character *)thePCommands->Result();
260 if(Result[0] != '\0') {
261 Standard_Integer pos = 0;
262 Standard_Integer rlen = strlen(Result);
264 Standard_Integer nb = 256;
265 if((rlen - pos) <= 256) {
268 write(st_err,Result+pos,nb*clen);
271 write(st_err,"\n",clen);
272 should_be_printed = Standard_False ;
282 static Standard_Integer QARebuild (Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
285 Tcl_CmdInfo *infoPtr = new Tcl_CmdInfo;
287 if(!strcmp(a[0],a[1]))
290 char* var_a = (char*)a[1];
291 Standard_Integer res = Tcl_GetCommandInfo(di.Interp(),var_a,infoPtr);
292 if(res && (infoPtr->proc != &CommandCmd)) {
293 TCollection_AsciiString aName(var_a);
294 if (!stFuncMap.IsBound(aName)) {
295 stFuncMap.Bind(aName, (Standard_Address) infoPtr->proc);
297 infoPtr->proc = &CommandCmd;
298 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 3
299 infoPtr->isNativeObjectProc = 0;
300 infoPtr->objProc = NULL;
302 Tcl_SetCommandInfo(di.Interp(),var_a,infoPtr);
309 static Standard_Integer QAUpdateLights(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
312 di << "Usage : " << argv[0] << "\n";
316 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
317 if(myAIScontext.IsNull()) {
318 di << "use 'vinit' command before " << argv[0] << "\n";
321 ViewerTest::CurrentView()->UpdateLights();
322 ViewerTest::CurrentView()->Update();
326 static Standard_Integer QAxwd_3d(Draw_Interpretor& di, Standard_Integer argc, const char** argv )
329 di << "Usage : " << argv[0] << " filename" << "\n";
333 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
334 if(myAIScontext.IsNull()) {
335 di << "use 'vinit' command before " << argv[0] << "\n";
338 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
339 //cout << myV3dView->Dump(argv[1]) << endl;
340 myV3dView->Dump(argv[1]);
345 static Standard_Integer QAMoveTo(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
348 di << "Usage : " << argv[0] << " x y" << "\n";
352 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
353 if(myAIScontext.IsNull()) {
354 di << "use 'vinit' command before " << argv[0] << "\n";
357 ViewerTest::CurrentEventManager()->MoveTo(atoi(argv[1]),atoi(argv[2]));
361 static Standard_Integer QASelect(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
364 di << "Usage : " << argv[0] << " x y" << "\n";
368 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
369 if(myAIScontext.IsNull()) {
370 di << "use 'vinit' command before " << argv[0] << "\n";
373 ViewerTest::CurrentEventManager()->MoveTo(atoi(argv[1]),atoi(argv[2]));
374 ViewerTest::CurrentEventManager()->Select();
378 static Standard_Integer QAShiftSelect(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
381 di << "Usage : " << argv[0] << " x y" << "\n";
385 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
386 if(myAIScontext.IsNull()) {
387 di << "use 'vinit' command before " << argv[0] << "\n";
390 ViewerTest::CurrentEventManager()->MoveTo(atoi(argv[1]),atoi(argv[2]));
391 ViewerTest::CurrentEventManager()->ShiftSelect();
395 static Standard_Integer QASetAntialiasing(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
398 di << "Usage : " << argv[0] << " [1/0]" << "\n";
402 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
403 if(myAIScontext.IsNull()) {
404 di << "use 'vinit' command before " << argv[0] << "\n";
408 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
410 if((argc == 2) && (atof(argv[1]) == 0))
411 myV3dView->SetAntialiasingOff();
413 myV3dView->SetAntialiasingOn();
418 static Standard_Integer QAvzfit(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
420 Handle(V3d_View) V = ViewerTest::CurrentView();
422 di << "use 'vinit' command before " << argv[0] << "\n";
429 Handle(TColStd_HSequenceOfReal) GetColorOfPixel (const Handle(Aspect_PixMap) theImage,
430 const Standard_Integer theCoordinateX,
431 const Standard_Integer theCoordinateY,
432 const Standard_Integer theRadius)
434 Handle(TColStd_HSequenceOfReal) aSeq = new TColStd_HSequenceOfReal();
435 if (theImage.IsNull()) {
436 std::cerr << "The image is null.\n";
439 Standard_Integer aWidth = 0;
440 Standard_Integer anHeight = 0;
441 theImage->Size (aWidth, anHeight);
443 Quantity_Color aColorTmp;
444 for (Standard_Integer anXIter = theCoordinateX - theRadius;
445 anXIter <= theCoordinateX + theRadius; ++anXIter)
447 if (anXIter < 0 || anXIter >= aWidth)
451 for (Standard_Integer anYIter = theCoordinateY - theRadius;
452 anYIter <= theCoordinateY + theRadius; ++anYIter)
454 if (anYIter < 0 || anYIter >= anHeight)
458 // Image_PixMap stores image upside-down in memory!
459 aColorTmp = theImage->PixelColor (anXIter, anYIter);
460 aSeq->Append (aColorTmp.Red());
461 aSeq->Append (aColorTmp.Green());
462 aSeq->Append (aColorTmp.Blue());
468 static Standard_Integer QAAISGetPixelColor (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
472 di << "Usage : " << argv[0] << " coordinate_X coordinate_Y [color_R color_G color_B]" << "\n";
476 Handle (V3d_View) QAAISView = ViewerTest::CurrentView ();
477 if ( QAAISView.IsNull () ) {
478 di << "You must initialize AISViewer before this command." << "\n";
481 Handle (Aspect_Window) QAAISWindow = QAAISView->Window ();
482 Standard_Integer QAAISXWindowSize_X = 0;
483 Standard_Integer QAAISXWindowSize_Y = 0;
484 QAAISWindow->Size(QAAISXWindowSize_X, QAAISXWindowSize_Y);
485 Standard_ShortReal QAAISCoordinateX = atoi (argv [1]);
486 Standard_ShortReal QAAISCoordinateY = atoi (argv [2]);
488 Standard_ShortReal QAAISColorRED_V = 0;
489 Standard_ShortReal QAAISColorGRN_V = 0;
490 Standard_ShortReal QAAISColorBLU_V = 0;
493 QAAISColorRED_V = atof (argv [3]);
494 QAAISColorGRN_V = atof (argv [4]);
495 QAAISColorBLU_V = atof (argv [5]);
497 di << "Begin aColorRED_User = " << QAAISColorRED_V << "\n";
498 di << "Begin aColorGRN_User = " << QAAISColorRED_V << "\n";
499 di << "Begin aColorBLU_User = " << QAAISColorRED_V << "\n";
502 Standard_Integer aRadius = 1;
507 Handle(TColStd_HSequenceOfReal) aSeq = GetColorOfPixel (QAAISView->ToPixMap (QAAISXWindowSize_X, QAAISXWindowSize_Y, Image_TOI_RGB),
508 QAAISCoordinateX, QAAISCoordinateY,
510 cout << "Length = " << aSeq->Length() << endl;
512 Standard_Boolean IsNotEqual = Standard_True;
514 for(i=1; i<=aSeq->Length();i+=3) {
516 Standard_ShortReal QAAISColorRED_R = (((Standard_ShortReal) ((Standard_Integer) (aSeq->Value(i+0) * 1000000))) / 1000000.);
517 Standard_ShortReal QAAISColorGRN_R = (((Standard_ShortReal) ((Standard_Integer) (aSeq->Value(i+1) * 1000000))) / 1000000.);
518 Standard_ShortReal QAAISColorBLU_R = (((Standard_ShortReal) ((Standard_Integer) (aSeq->Value(i+2) * 1000000))) / 1000000.);
522 di << "RED : " << QAAISColorRED_R
523 << " GREEN : " << QAAISColorGRN_R
524 << " BLUE : " << QAAISColorBLU_R
526 IsNotEqual = Standard_False;
530 if ( QAAISColorRED_R == QAAISColorRED_V
531 && QAAISColorGRN_R == QAAISColorGRN_V
532 && QAAISColorBLU_R == QAAISColorBLU_V
534 IsNotEqual = Standard_False;
539 di << "Faulty : colors are not equal." << "\n";
545 static Standard_Boolean IsSelectionModeCurrentlyON (Standard_Integer theMode) {
546 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
547 if(!aContext->HasOpenedContext()) {
548 return Standard_False ;
550 const TColStd_ListOfInteger& List = aContext->ActivatedStandardModes();
551 TColStd_ListIteratorOfListOfInteger it;
552 Standard_Boolean Found=Standard_False;
553 for (it.Initialize(List); it.More()&&!Found; it.Next() ) {
554 if (it.Value()==theMode ) Found=Standard_True;
559 static Standard_Integer QAAISSetChoiceMode (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
562 di << "Usage : " << argv[0] << " mode switch" << "\n";
563 di << " mode: " << "\n";
564 // cout << " SHAPE " << endl;
565 di << " VERTEX " << "\n";
566 di << " EDGE " << "\n";
567 di << " WIRE " << "\n";
568 di << " FACE " << "\n";
569 di << " SHELL " << "\n";
570 di << " SOLID " << "\n";
571 di << " COMPOUND " << "\n";
572 di << " switch: " << "\n";
573 di << " ON " << "\n";
574 di << " OFF " << "\n";
577 Handle (V3d_View) QAAISView = ViewerTest::CurrentView ();
578 if ( QAAISView.IsNull () ) {
579 di << "You must initialize AISViewer before this command." << "\n";
582 Standard_Integer QAChoosingMode = -1;
583 // if ( strcmp (sc [1], "SHAPE") == 0 ) {
584 // QAChoosingMode = 0;
586 if ( strcmp (argv [1], "VERTEX") == 0 ) {
589 if ( strcmp (argv [1], "EDGE") == 0 ) {
592 if ( strcmp (argv [1], "WIRE") == 0 ) {
595 if ( strcmp (argv [1], "FACE") == 0 ) {
598 if ( strcmp (argv [1], "SHELL") == 0 ) {
601 if ( strcmp (argv [1], "SOLID") == 0 ) {
604 if ( strcmp (argv [1], "COMPOUND") == 0 ) {
607 if ( QAChoosingMode == -1 ) {
608 di << "Use - QAAISSetChoiceMode mode switch" << "\n";
612 if ( strcmp (argv [2], "ON") == 0 ) {
613 if ( IsSelectionModeCurrentlyON (QAChoosingMode)) {
614 di << "Mode already ON." << "\n";
617 ViewerTest::StandardModeActivation (QAChoosingMode);
620 if ( strcmp (argv [2], "OFF") == 0 ) {
621 if (!IsSelectionModeCurrentlyON (QAChoosingMode)) {
622 di << "Mode already OFF." << "\n";
625 ViewerTest::StandardModeActivation (QAChoosingMode);
628 di << "Usage : " << argv[0] << " mode switch" << "\n";
633 extern int ViewerMainLoop (Standard_Integer argc, const char ** argv);
635 Standard_EXPORT int ViewerMainLoop (Standard_Integer argc, const char ** argv);
638 extern int ViewerMainLoop2d (Standard_Integer argc, const char ** argv);
640 Standard_EXPORT int ViewerMainLoop2d (Standard_Integer argc, const char ** argv);
643 static Standard_Integer QAAISGetMousePoint (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
646 di << "Usage : " << argv[0] << "\n";
649 Handle (V3d_View) QAAISView = ViewerTest::CurrentView ();
650 if ( QAAISView.IsNull () ) {
651 di << "You must initialize AISViewer before this command." << "\n";
654 Standard_Integer QAAISMouseCoordinateX = 0;
655 Standard_Integer QAAISMouseCoordinateY = 0;
656 Standard_Integer argccc = 5;
657 const char *bufff[] = { "A", "B", "C", "D", "E" };
658 const char **argvvv = (const char **) bufff;
659 while ( ViewerMainLoop (argccc, argvvv) ) {
660 ViewerTest::GetMousePosition (QAAISMouseCoordinateX, QAAISMouseCoordinateY);
662 ViewerTest::GetMousePosition (QAAISMouseCoordinateX, QAAISMouseCoordinateY);
663 di << "X-coordinate: " << QAAISMouseCoordinateX << "; Y-coordinate: " << QAAISMouseCoordinateY << "\n";
667 static Standard_Integer QAAISGetViewCharac (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
670 di << "Usage : " << argv[0] << "\n";
673 Handle (V3d_View) QAAISView = ViewerTest::CurrentView ();
674 if ( QAAISView.IsNull () ) {
675 di << "You must initialize AISViewer before this command." << "\n";
678 Quantity_Factor QAAISViewScale = QAAISView -> V3d_View::Scale ();
679 Standard_Real QAAISViewCenterCoordinateX = 0.0;
680 Standard_Real QAAISViewCenterCoordinateY = 0.0;
681 QAAISView -> V3d_View::Center (QAAISViewCenterCoordinateX, QAAISViewCenterCoordinateY);
682 Standard_Real QAAISViewProjX = 0.0;
683 Standard_Real QAAISViewProjY = 0.0;
684 Standard_Real QAAISViewProjZ = 0.0;
685 QAAISView -> V3d_View::Proj (QAAISViewProjX, QAAISViewProjY, QAAISViewProjZ);
686 Standard_Real QAAISViewUpX = 0.0;
687 Standard_Real QAAISViewUpY = 0.0;
688 Standard_Real QAAISViewUpZ = 0.0;
689 QAAISView -> V3d_View::Up (QAAISViewUpX, QAAISViewUpY, QAAISViewUpZ);
690 Standard_Real QAAISViewAtX = 0.0;
691 Standard_Real QAAISViewAtY = 0.0;
692 Standard_Real QAAISViewAtZ = 0.0;
693 QAAISView -> V3d_View::At (QAAISViewAtX, QAAISViewAtY, QAAISViewAtZ);
694 di << "Scale of current view: " << QAAISViewScale << "\n";
695 di << "Center on X : "<< QAAISViewCenterCoordinateX << "; on Y: " << QAAISViewCenterCoordinateY << "\n";
696 di << "Proj on X : " << QAAISViewProjX << "; on Y: " << QAAISViewProjY << "; on Z: " << QAAISViewProjZ << "\n";
697 di << "Up on X : " << QAAISViewUpX << "; on Y: " << QAAISViewUpY << "; on Z: " << QAAISViewUpZ << "\n";
698 di << "At on X : " << QAAISViewAtX << "; on Y: " << QAAISViewAtY << "; on Z: " << QAAISViewAtZ << "\n";
701 static Standard_Integer QAAISSetViewCharac (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
704 di << "Usage : " << argv[0] << " scale center_X center_Y proj_X proj_Y proj_Z up_X up_Y up_Z at_X at_Y at_Z" << "\n";
707 Handle (V3d_View) QAAISView = ViewerTest::CurrentView ();
708 if ( QAAISView.IsNull () ) {
709 di << "You must initialize AISViewer before this command." << "\n";
712 Quantity_Factor QAAISViewScale = atof (argv [1]);
713 Standard_Real QAAISViewCenterCoordinateX = atof (argv [2]);
714 Standard_Real QAAISViewCenterCoordinateY = atof (argv [3]);
715 Standard_Real QAAISViewProjX = atof (argv [4]);
716 Standard_Real QAAISViewProjY = atof (argv [5]);
717 Standard_Real QAAISViewProjZ = atof (argv [6]);
718 Standard_Real QAAISViewUpX = atof (argv [7]);
719 Standard_Real QAAISViewUpY = atof (argv [8]);
720 Standard_Real QAAISViewUpZ = atof (argv [9]);
721 Standard_Real QAAISViewAtX = atof (argv [10]);
722 Standard_Real QAAISViewAtY = atof (argv [11]);
723 Standard_Real QAAISViewAtZ = atof (argv [12]);
724 QAAISView -> V3d_View::SetScale (QAAISViewScale);
725 QAAISView -> V3d_View::SetCenter (QAAISViewCenterCoordinateX, QAAISViewCenterCoordinateY);
726 QAAISView -> V3d_View::SetAt (QAAISViewAtX, QAAISViewAtY, QAAISViewAtZ);
727 QAAISView -> V3d_View::SetProj (QAAISViewProjX, QAAISViewProjY, QAAISViewProjZ);
728 QAAISView -> V3d_View::SetUp (QAAISViewUpX, QAAISViewUpY, QAAISViewUpZ);
729 QAAISView -> V3d_View::SetProj (QAAISViewProjX, QAAISViewProjY, QAAISViewProjZ);
733 static Standard_Integer QAAISGetColorCoord (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
737 di << "Usage : " << argv[0] << " [3d|2d]" << "\n";
740 Handle (Aspect_Window) QAAISWindow;
742 Standard_Boolean is3d = 1;
744 if(argc == 1 || !strcmp(argv[1],"3d")) {
746 Handle (V3d_View) QAAIS_MainView = ViewerTest::CurrentView ();
747 if ( QAAIS_MainView.IsNull () ) {
748 di << "You must initialize AISViewer before this command." << "\n";
751 QAAISWindow = QAAIS_MainView -> V3d_View::Window ();
755 if(argc == 2 && !strcmp(argv[1],"2d")) {
756 Handle(V2d_View) V = Viewer2dTest::CurrentView();
758 di << "You must initialize AIS 2D Viewer before this command." << "\n";
761 QAAISWindow = V->Driver()->Window();
765 Standard_Integer QAAIS_WindowSize_X = 0;
766 Standard_Integer QAAIS_WindowSize_Y = 0;
767 QAAISWindow->Size(QAAIS_WindowSize_X, QAAIS_WindowSize_Y);
768 Handle (Graphic3d_GraphicDevice) QAAIS_GraphicDevice = new Graphic3d_GraphicDevice (getenv ("DISPLAY"));
770 Draw_Window QAAIS_CoordWindow ("coordinate", 421, 205, 200, 60);
771 QAAIS_CoordWindow.DisplayWindow ();
772 QAAIS_CoordWindow.SetColor (12);
774 Handle (Xw_Window) QAAIS_ColorWindow = new Xw_Window (QAAIS_GraphicDevice, "color", 0.4074, 0.678, 0.1962, 0.06, Xw_WQ_3DQUALITY, Quantity_NOC_BLACK);
775 Handle (V3d_Viewer) QAAIS_ColorViewer = new V3d_Viewer (QAAIS_GraphicDevice, Standard_ExtString ("COLOR"));
776 Handle (V3d_View) QAAIS_ColorView = QAAIS_ColorViewer -> CreateView ();
777 QAAIS_ColorWindow -> Map ();
778 QAAIS_ColorView -> SetWindow (QAAIS_ColorWindow);
779 QAAIS_ColorView -> SetBackgroundColor (Quantity_NOC_BLACK);
780 QAAIS_ColorView -> Redraw ();
782 Standard_Integer QAAIS_MousePoint_X = 0;
783 Standard_Integer QAAIS_MousePoint_Y = 0;
784 Standard_Character QAAIS_MousePointX[32];
785 sprintf (QAAIS_MousePointX, "X : %d", QAAIS_MousePoint_X);
786 Standard_Character QAAIS_MousePointY[32];
787 sprintf (QAAIS_MousePointY, "Y : %d", QAAIS_MousePoint_Y);
788 Standard_ShortReal QAAIS_ColorRED = 0;
789 Standard_ShortReal QAAIS_ColorGRN = 0;
790 Standard_ShortReal QAAIS_ColorBLU = 0;
791 Quantity_Color QAAIS_ShowingColor;
792 QAAIS_ShowingColor.SetValues (QAAIS_ColorRED, QAAIS_ColorGRN, QAAIS_ColorBLU, Quantity_TOC_RGB);
793 Standard_Integer argccc = 5;
794 const char *bufff[] = { "A", "B", "C", "D", "E" };
795 const char **argvvv = (const char **) bufff;
796 while ( is3d ? ViewerMainLoop (argccc, argvvv) : ViewerMainLoop2d (argccc, argvvv)) {
797 Handle(TColStd_HSequenceOfReal) aSeq;
800 ViewerTest::GetMousePosition (QAAIS_MousePoint_X, QAAIS_MousePoint_Y);
801 Handle (V3d_View) QAAIS_MainView = ViewerTest::CurrentView();
802 aSeq = GetColorOfPixel (QAAIS_MainView->ToPixMap (QAAIS_WindowSize_X, QAAIS_WindowSize_Y, Image_TOI_RGB),
803 QAAIS_MousePoint_X, QAAIS_MousePoint_Y, 0);
807 Viewer2dTest::GetMousePosition (QAAIS_MousePoint_X, QAAIS_MousePoint_Y);
808 aSeq = GetColorOfPixel (QAAISWindow->ToPixMap(),
809 QAAIS_MousePoint_X, QAAIS_MousePoint_Y, 0);
811 QAAIS_ColorRED = aSeq->Value(1);
812 QAAIS_ColorGRN = aSeq->Value(2);
813 QAAIS_ColorBLU = aSeq->Value(3);
814 QAAIS_ShowingColor.SetValues (QAAIS_ColorRED, QAAIS_ColorGRN, QAAIS_ColorBLU, Quantity_TOC_RGB);
815 QAAIS_ColorView -> SetBackgroundColor (QAAIS_ShowingColor);
816 QAAIS_ColorView -> Redraw ();
817 QAAIS_CoordWindow.Clear();
818 sprintf (QAAIS_MousePointX, "X : %d", QAAIS_MousePoint_X);
819 sprintf (QAAIS_MousePointY, "Y : %d", QAAIS_MousePoint_Y);
820 QAAIS_CoordWindow.DrawString (30, 35, QAAIS_MousePointX);
821 QAAIS_CoordWindow.DrawString (125, 35, QAAIS_MousePointY);
823 QAAIS_CoordWindow.Destroy ();
828 //==============================================================================
830 //==============================================================================
832 extern int V2dPickGrid (Draw_Interpretor& , Standard_Integer argc, const char ** argv);
834 Standard_EXPORT int V2dPickGrid (Draw_Interpretor& , Standard_Integer argc, const char ** argv);
836 //==============================================================================
837 //function : V2dSetHighlightMode
838 //purpose : QAv2dSetHighlightMode mode
839 //==============================================================================
840 static int V2dSetHighlightMode (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
844 di << "Usage: QAv2dSetHighlightMode mode" << "\n";
848 Viewer2dTest::StandardModeActivation(atoi(argv[1]));
853 //==============================================================================
854 //function : QAAISGetPixelColor2d
855 //purpose : QAAISGetPixelColor2d coord_X coord_Y Red Green Blue
856 //==============================================================================
858 static int QAAISGetPixelColor2d (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
860 if (argc != 6 && argc != 3)
862 di << "Args: coord_X coord_Y [Red Green Blue]" << "\n";
866 Handle(V2d_View) V = Viewer2dTest::CurrentView();
869 di << "You must initialize AIS 2D Viewer before this command." << "\n";
873 Handle(Aspect_Window) QAAISWindow = V->Driver()->Window();
875 Standard_ShortReal aCoordinateX = atoi(argv[1]);
876 Standard_ShortReal aCoordinateY = atoi(argv[2]);
879 Standard_ShortReal aColorRED_V = 0;
880 Standard_ShortReal aColorGRN_V = 0;
881 Standard_ShortReal aColorBLU_V = 0;
884 aColorRED_V = atof (argv [3]);
885 aColorGRN_V = atof (argv [4]);
886 aColorBLU_V = atof (argv [5]);
888 di << "Begin aColorRED_User = " << aColorRED_V << "\n";
889 di << "Begin aColorGRN_User = " << aColorGRN_V << "\n";
890 di << "Begin aColorBLU_User = " << aColorBLU_V << "\n";
893 Standard_Integer aRadius = 1;
898 Handle(TColStd_HSequenceOfReal) aSeq = GetColorOfPixel (QAAISWindow->ToPixMap(),
899 aCoordinateX, aCoordinateY,
902 Standard_Boolean IsNotEqual = Standard_True;
904 for(i=1; i<=aSeq->Length();i+=3) {
906 Standard_ShortReal aColorRED_R = (((Standard_ShortReal) ((Standard_Integer) (aSeq->Value(i+0) * 1000000))) / 1000000.);
907 Standard_ShortReal aColorGRN_R = (((Standard_ShortReal) ((Standard_Integer) (aSeq->Value(i+1) * 1000000))) / 1000000.);
908 Standard_ShortReal aColorBLU_R = (((Standard_ShortReal) ((Standard_Integer) (aSeq->Value(i+2) * 1000000))) / 1000000.);
912 di << "RED : " << aColorRED_R << " GREEN : " << aColorGRN_R << " BLUE : " << aColorBLU_R << "\n";
913 IsNotEqual = Standard_False;
917 if ( aColorRED_R == aColorRED_V
918 && aColorGRN_R == aColorGRN_V
919 && aColorBLU_R == aColorBLU_V
921 IsNotEqual = Standard_False;
926 di << "Faulty : colors are not equal." << "\n";
933 //==============================================================================
934 //function : QAMoveTo2d
935 //purpose : QAMoveTo2d x y
936 //==============================================================================
937 static int QAMoveTo2d (Draw_Interpretor& di, int argc, const char ** argv)
941 di << "Usage : " << argv[0] << " x y" << "\n";
945 Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext();
946 if (myAIScontext.IsNull())
948 di << "use 'v2dinit' command before " << argv[0] << "\n";
951 Viewer2dTest::CurrentEventManager()->MoveTo
952 (atoi(argv[1]), atoi(argv[2]), Viewer2dTest::CurrentView());
956 //==============================================================================
957 //function : QASelect2d
958 //purpose : QASelect2d x y
959 //==============================================================================
960 static int QASelect2d (Draw_Interpretor& di, int argc, const char ** argv)
964 di << "Usage : " << argv[0] << " x y" << "\n";
968 Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext();
969 if (myAIScontext.IsNull())
971 di << "use 'v2dinit' command before " << argv[0] << "\n";
974 Viewer2dTest::CurrentEventManager()->MoveTo
975 (atoi(argv[1]), atoi(argv[2]), Viewer2dTest::CurrentView());
976 Viewer2dTest::CurrentEventManager()->Select();
980 //==============================================================================
981 //function : QAShiftSelect2d
982 //purpose : QAShiftSelect2d x y
983 //==============================================================================
984 static int QAShiftSelect2d (Draw_Interpretor& di, int argc, const char ** argv)
988 di << "Usage : " << argv[0] << " x y" << "\n";
992 Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext();
993 if (myAIScontext.IsNull())
995 di << "use 'v2dinit' command before " << argv[0] << "\n";
998 Viewer2dTest::CurrentEventManager()->MoveTo
999 (atoi(argv[1]), atoi(argv[2]), Viewer2dTest::CurrentView());
1000 Viewer2dTest::CurrentEventManager()->ShiftSelect();
1004 //==============================================================================
1005 //function : V2dZoom
1006 //purpose : QAv2dzoom zoom_factor
1007 //==============================================================================
1008 static int V2dZoom (Draw_Interpretor& di, int argc, const char ** argv)
1012 di << "Usage : " << argv[0] << " zoom_factor" << "\n";
1016 Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext();
1017 if (myAIScontext.IsNull())
1019 di << "use 'v2dinit' command before " << argv[0] << "\n";
1022 Viewer2dTest::CurrentView()->Zoom(atof(argv[1]));
1026 //==============================================================================
1028 //purpose : QAv2dpan dx dy
1029 //==============================================================================
1030 static int V2dPan (Draw_Interpretor& di, int argc, const char ** argv)
1034 di << "Usage : " << argv[0] << " dx dy" << "\n";
1038 Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext();
1039 if (myAIScontext.IsNull())
1041 di << "use 'v2dinit' command before " << argv[0] << "\n";
1044 Viewer2dTest::CurrentView()->Pan(atof(argv[1]), atof(argv[2]));
1048 //==============================================================================
1049 //function : V2dGetViewCharac
1050 //purpose : v2dGetViewCharac
1051 //==============================================================================
1052 static int V2dGetViewCharac (Draw_Interpretor& di, int si, const char ** /*sc*/)
1056 di << "Use - v2dGetViewCharac" << "\n";
1060 Handle(V2d_View) V = Viewer2dTest::CurrentView();
1063 di << "You must initialize AIS 2D Viewer before this command." << "\n";
1067 // Quantity_Factor aViewScale = V->Scale();
1069 Standard_Real aCenterCoordX = 0.0;
1070 Standard_Real aCenterCoordY = 0.0;
1071 V->Center(aCenterCoordX, aCenterCoordY);
1073 Standard_Real aViewProjX = 0.0;
1074 Standard_Real aViewProjY = 0.0;
1075 Standard_Real aViewProjZ = 0.0;
1076 // V->Proj(aViewProjX, aViewProjY, aViewProjZ);
1078 Standard_Real aViewUpX = 0.0;
1079 Standard_Real aViewUpY = 0.0;
1080 Standard_Real aViewUpZ = 0.0;
1081 // V->Up(aViewUpX, aViewUpY, aViewUpZ);
1083 Standard_Real aViewAtX = 0.0;
1084 Standard_Real aViewAtY = 0.0;
1085 Standard_Real aViewAtZ = 0.0;
1086 // V->At(aViewAtX, aViewAtY, aViewAtZ);
1088 // cout << "Scale of current view: " << aViewScale << endl;
1089 // cout << "Center on X : "<< aViewCenterCoordX << "; on Y: " << aViewCenterCoordY << endl;
1090 // cout << "Proj on X : " << aViewProjX << "; on Y: " << aViewProjY << "; on Z: " << aViewProjZ << endl;
1091 // cout << "Up on X : " << aViewUpX << "; on Y: " << aViewUpY << "; on Z: " << aViewUpZ << endl;
1092 // cout << "At on X : " << aViewAtX << "; on Y: " << aViewAtY << "; on Z: " << aViewAtZ << endl;
1094 // cout << aViewScale << " " << aViewCenterCoordX << " " << aViewCenterCoordY << " ";
1095 di << aViewProjX << " " << aViewProjY << " " << aViewProjZ << " ";
1096 di << aViewUpX << " " << aViewUpY << " " << aViewUpZ << " ";
1097 di << aViewAtX << " " << aViewAtY << " " << aViewAtZ << "\n";
1101 //==============================================================================
1102 //function : V2dSetViewCharac
1103 //purpose : v2dSetViewCharac
1104 //==============================================================================
1105 static int V2dSetViewCharac (Draw_Interpretor& di, int si, const char ** sc)
1109 di << "Use - v2dSetViewCharac scale center(X Y) proj(X Y Z) up(X Y Z) at(X Y Z)" << "\n";
1113 Handle(V2d_View) V = Viewer2dTest::CurrentView();
1116 di << "You must initialize AIS 2D Viewer before this command." << "\n";
1120 Quantity_Factor aViewScale = atof(sc[1]);
1122 Standard_Real aViewCenterCoordX = atof(sc[2]);
1123 Standard_Real aViewCenterCoordY = atof(sc[3]);
1125 Standard_Real aViewProjX = atof(sc[4]);
1126 Standard_Real aViewProjY = atof(sc[5]);
1127 Standard_Real aViewProjZ = atof(sc[6]);
1129 Standard_Real aViewUpX = atof(sc[7]);
1130 Standard_Real aViewUpY = atof(sc[8]);
1131 Standard_Real aViewUpZ = atof(sc[9]);
1133 Standard_Real aViewAtX = atof(sc[10]);
1134 Standard_Real aViewAtY = atof(sc[11]);
1135 Standard_Real aViewAtZ = atof(sc[12]);
1137 // V->SetScale(aViewScale);
1138 // V->SetCenter(aViewCenterCoordX, aViewCenterCoordY);
1139 // V->SetAt(aViewAtX, aViewAtY, aViewAtZ);
1140 // V->SetProj(aViewProjX, aViewProjY, aViewProjZ);
1141 // V->SetUp(aViewUpX, aViewUpY, aViewUpZ);
1142 // V->SetProj(aViewProjX, aViewProjY, aViewProjZ);
1146 //=======================================================================
1147 //function : QAxwd_2d
1149 //=======================================================================
1150 static int QAxwd_2d (Draw_Interpretor& di, int argc, const char ** argv)
1154 di << "Usage : " << argv[0] << " filename" << "\n";
1158 Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext();
1159 if (myAIScontext.IsNull())
1161 di << "use 'v2dinit' command before " << argv[0] << "\n";
1164 Handle(V2d_View) V = Viewer2dTest::CurrentView();
1170 extern Draw_Viewer dout;
1171 extern XW_STATUS Xw_save_image_adv (Display *aDisplay,Window aWindow,XWindowAttributes aWinAttr,XImage *aPximage,Colormap aColormap,int aNcolors,char *filename);
1172 extern Display* Draw_WindowDisplay;
1173 extern Colormap Draw_WindowColorMap;
1175 Standard_IMPORT Draw_Viewer dout;
1176 int __WNT_API SaveWindowToFile (Handle( WNT_GraphicDevice )& gDev,
1177 HWND hWnd, char* fName, int x, int y, int w, int h);
1180 //=======================================================================
1183 //=======================================================================
1184 static int QAxwd (Draw_Interpretor& di, int argc, const char ** argv)
1188 di << "Usage : " << argv[0] << " [id=1] filename" << "\n";
1192 // enforce repaint if necessary
1193 Standard_Integer id = 1;
1194 const char* file = argv[1];
1203 if(dout.HasView(id)) {
1205 Handle(WNT_GraphicDevice) aGd = new WNT_GraphicDevice(Standard_False);
1207 GetClientRect((HWND)dout.GetWindow(id), &rc);
1208 SaveWindowToFile(aGd,(HWND)dout.GetWindow(id),(char*)file,rc.left, rc.top,rc.right-rc.left, rc.bottom-rc.top);
1210 XSync(Draw_WindowDisplay,True);
1212 XWindowAttributes winAttr;
1213 XGetWindowAttributes (Draw_WindowDisplay, dout.GetWindow(id), &winAttr);
1215 XImage *pximage = XGetImage(Draw_WindowDisplay,dout.GetWindow(id),
1216 0,0,winAttr.width,winAttr.height,
1219 Xw_save_image_adv(Draw_WindowDisplay,dout.GetWindow(id),winAttr,pximage,Draw_WindowColorMap,256,(char*)file);
1226 //=======================================================================
1227 //function : QA2dGetIndexes
1229 //=======================================================================
1230 static int QA2dGetIndexes (Draw_Interpretor& di, int /*argc*/, const char ** argv)
1232 Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext();
1233 if (myAIScontext.IsNull())
1235 di << "use 'v2dinit' command before " << argv[0] << "\n";
1238 Handle(Aspect_WindowDriver) aWindowDriver = Viewer2dTest::CurrentView()->Driver();
1240 Standard_Integer aFontMin, aFontMax, aColorMin, aColorMax;
1241 aWindowDriver->FontBoundIndexs(aFontMin, aFontMax);
1242 di << "Available font indexes are " << aFontMin << " - " << aFontMax << "\n";
1243 aWindowDriver->ColorBoundIndexs(aColorMin, aColorMax);
1244 di << "Available color indexes are " << aColorMin << " - " << aColorMax << "\n";
1248 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
1249 extern Handle(AIS_InteractiveContext)& TheAISContext();
1251 Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
1252 Standard_EXPORT Handle(AIS_InteractiveContext)& TheAISContext();
1254 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
1255 #include <AIS_Trihedron.hxx>
1256 #include <AIS_Axis.hxx>
1257 #include <Geom_Line.hxx>
1258 #include <AIS_Line.hxx>
1260 //==============================================================================
1261 // function : VTrihedronOrigins
1263 // purpose : draws triheron axis origin lines.
1264 // Draw arg : vtri_orig trihedron_name
1265 //==============================================================================
1266 static int VTrihedronOrigins(Draw_Interpretor& di,
1267 Standard_Integer argc,
1271 di <<"Usage : vtri_orig tri_name"<<"\n";
1275 if(TheAISContext().IsNull()){
1276 di<<"Make 'vinit' before this method call"<<"\n";
1280 //get trihedron from AIS map.
1281 TCollection_AsciiString aName(argv[1]);
1282 if(!GetMapOfAIS().IsBound2(aName)){
1283 di<<"No object named '"<<argv[1]<<"'"<<"\n";
1287 Handle(AIS_Trihedron) aTrih =
1288 Handle(AIS_Trihedron)::DownCast(GetMapOfAIS().Find2(aName));
1290 di<<"Trihedron is not found, try another name"<<"\n";
1295 Handle(AIS_Axis) XAxis = aTrih->XAxis();
1296 Handle(AIS_Axis) YAxis = aTrih->YAxis();
1297 Handle(AIS_Axis) ZAxis = aTrih->Axis();
1299 //get geometrical lines
1300 Handle(Geom_Line) XGLine = XAxis->Component();
1301 Handle(Geom_Line) YGLine = YAxis->Component();
1302 Handle(Geom_Line) ZGLine = ZAxis->Component();
1305 Handle(AIS_Line) XLine = new AIS_Line(XGLine);
1306 Handle(AIS_Line) YLine = new AIS_Line(YGLine);
1307 Handle(AIS_Line) ZLine = new AIS_Line(ZGLine);
1309 //put them into AIS map:
1310 GetMapOfAIS().Bind(XLine,aName+"_X");
1311 GetMapOfAIS().Bind(YLine,aName+"_Y");
1312 GetMapOfAIS().Bind(ZLine,aName+"_Z");
1313 //print names of created objects:
1314 di<<argv[1]<<"_X "<<argv[1]<<"_Y "<<argv[1]<<"_Z"<<"\n";
1317 TheAISContext()->Display(XLine);
1318 TheAISContext()->Display(YLine);
1319 TheAISContext()->Display(ZLine);
1324 //=======================================================================
1325 //function : QAAddOrRemoveSelected
1327 //=======================================================================
1328 static Standard_Integer QAAddOrRemoveSelected (Draw_Interpretor& di, Standard_Integer n, const char ** a)
1332 di<<"Usage : QAAddOrRemoveSelected shape \n";
1336 Handle(AIS_InteractiveContext) anAISCtx = ViewerTest::GetAISContext();
1338 //ViewerTest_DoubleMapOfInteractiveAndName& aMap =
1339 // ViewerTest::GetDataMapOfAIS ();
1340 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
1342 TCollection_AsciiString aName(a[1]);
1343 Handle(AIS_InteractiveObject) AISObj;
1345 if(aMap.IsBound2(aName)){
1346 AISObj = Handle(AIS_InteractiveObject)::DownCast(aMap.Find2(aName));
1347 if(AISObj.IsNull()){
1348 di<<"No interactive object \n";
1352 if(anAISCtx->HasOpenedContext()){
1353 anAISCtx->InitSelected();
1354 anAISCtx->AddOrRemoveSelected(AISObj);
1357 anAISCtx->InitCurrent();
1358 anAISCtx->AddOrRemoveCurrentObject(AISObj);
1362 //select this shape:
1364 di<<"Use 'vdisplay' before";
1369 //=======================================================================
1370 //function : QASetZClippingMode
1372 //=======================================================================
1373 static Standard_Integer QASetZClippingMode (Draw_Interpretor& di, int argc, const char ** argv)
1376 di << "Usage : " << argv[0] << " mode(OFF/BACK/FRONT/SLICE)" << "\n";
1380 Handle(AIS_InteractiveContext) AIScontext = ViewerTest::GetAISContext();
1381 if(AIScontext.IsNull()) {
1382 di << "use 'vinit' command before " << argv[0] << "\n";
1386 Standard_Integer aStatus = 0;
1387 V3d_TypeOfZclipping ZClippingMode;
1388 if ( strcmp (argv [1], "OFF") == 0 ) {
1390 ZClippingMode = V3d_OFF;
1392 if ( strcmp (argv [1], "BACK") == 0 ) {
1394 ZClippingMode = V3d_BACK;
1396 if ( strcmp (argv [1], "FRONT") == 0 ) {
1398 ZClippingMode = V3d_FRONT;
1400 if ( strcmp (argv [1], "SLICE") == 0 ) {
1402 ZClippingMode = V3d_SLICE;
1406 di << "Bad mode; Usage : " << argv[0] << " mode(OFF/BACK/FRONT/SLICE)" << "\n";
1410 Handle(V3d_View) aView = ViewerTest::CurrentView();
1411 aView->SetZClippingType(ZClippingMode);
1417 //=======================================================================
1418 //function : QAGetZClippingMode
1420 //=======================================================================
1421 static Standard_Integer QAGetZClippingMode (Draw_Interpretor& di, int /*argc*/, const char ** argv)
1423 Handle(AIS_InteractiveContext) AIScontext = ViewerTest::GetAISContext();
1424 if(AIScontext.IsNull()) {
1425 di << "use 'vinit' command before " << argv[0] << "\n";
1429 Handle(V3d_View) aView = ViewerTest::CurrentView();
1430 TCollection_AsciiString ZClippingModeString;
1431 Quantity_Length Depth, Width;
1432 V3d_TypeOfZclipping ZClippingMode = aView->ZClipping(Depth, Width);
1433 switch (ZClippingMode)
1436 ZClippingModeString.Copy("OFF");
1439 ZClippingModeString.Copy("BACK");
1442 ZClippingModeString.Copy("FRONT");
1445 ZClippingModeString.Copy("SLICE");
1448 ZClippingModeString.Copy(TCollection_AsciiString(ZClippingMode));
1451 di << "ZClippingMode = " << ZClippingModeString.ToCString() << "\n";
1456 #include <V2d_View.hxx>
1457 #include <AIS2D_InteractiveObject.hxx>
1458 #include <Graphic2d_Circle.hxx>
1459 #include <Graphic2d_TypeOfPolygonFilling.hxx>
1460 #include <V2d_Viewer.hxx>
1461 #include <Viewer2dTest_DoubleMapOfInteractiveAndName.hxx>
1464 extern Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
1466 Standard_EXPORT Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
1469 //=======================================================================
1470 //function : QAv2dcircle
1472 //=======================================================================
1473 static Standard_Integer QAv2dcircle (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1475 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1476 if(aContext.IsNull()) {
1477 di << "ERROR: Use 'v2dinit' command before " << argv[0] << "\n";
1481 di<<"Usage : " << argv[0] << " CircleName X Y Radius Alpha Beta [Color_index]\n";
1484 Handle(V2d_View) V = Viewer2dTest::CurrentView();
1486 TCollection_AsciiString name = argv[1];
1487 Standard_Real x = atof(argv[2]);
1488 Standard_Real y = atof(argv[3]);
1489 Standard_Real radius = atof(argv[4]);
1490 Standard_Real alpha = atof(argv[5]);
1491 Standard_Real beta = atof(argv[6]);
1493 if (GetMapOfAIS2D().IsBound2(name)) {
1494 di << "There is already an object with name " << name.ToCString() << "\n";
1497 Handle(AIS2D_InteractiveObject) aisobj = new AIS2D_InteractiveObject();
1498 aisobj->SetView(V->View());
1499 Handle(Graphic2d_Circle) circle = new Graphic2d_Circle(aisobj,x,y,radius,alpha,beta);
1501 Standard_Integer color_index = atoi(argv[7]);
1502 circle->SetTypeOfPolygonFilling(Graphic2d_TOPF_FILLED);
1503 circle->SetInteriorColorIndex(color_index);
1505 GetMapOfAIS2D().Bind(aisobj, name);
1507 V->Viewer()->Update();
1511 #include <Draw_Viewer.hxx>
1515 extern Draw_Viewer dout;
1517 Standard_IMPORT Draw_Viewer dout;
1520 static Standard_Integer ViewId(const Standard_CString a)
1522 Standard_Integer id = atoi(a);
1523 if ((id < 0) || (id >= MAXVIEW)) {
1524 cout << "Incorrect view-id, must be in 0.."<<MAXVIEW-1<<endl;
1527 if (!dout.HasView(id)) {
1528 cout <<"View "<<id<<" does not exist."<<endl;
1534 //=======================================================================
1535 //function : QAwzoom
1537 //=======================================================================
1539 static Standard_Integer QAwzoom(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1541 di<<"Usage : " << argv[0] << " view-id X1 Y1 X2 Y2\n";
1545 Standard_Integer id = ViewId(argv [1]);
1550 Standard_Integer X1 = atoi (argv [2]);
1551 Standard_Integer Y1 = atoi (argv [3]);
1552 Standard_Integer X2 = atoi (argv [4]);
1553 Standard_Integer Y2 = atoi (argv [5]);
1555 Standard_Real zx,zy;
1557 Standard_Integer X,Y,W,H;
1558 dout.GetPosSize(id,X,Y,W,H);
1560 if ((X1 == X2) || (Y1 == Y2)) return 0;
1562 zx = (Standard_Real) Abs(X2-X1) / (Standard_Real) W;
1563 zy = (Standard_Real) Abs(Y2-Y1) / (Standard_Real) H;
1564 if (zy > zx) zx = zy;
1566 if (X2 < X1) X1 = X2;
1567 if (Y2 > Y1) Y1 = Y2;
1568 X1 = (Standard_Integer ) (X1*zx);
1569 Y1 = (Standard_Integer ) (Y1*zx);
1570 dout.SetZoom(id,zx*dout.Zoom(id));
1571 dout.SetPan(id,-X1,-Y1);
1572 dout.RepaintView(id);
1573 if (dout.HasView(id)) {
1575 sprintf(title,"%d : %s - Zoom %f",id,dout.GetType(id),dout.Zoom(id));
1576 dout.SetTitle(id,title);
1581 #include <Draw_Display.hxx>
1583 //=======================================================================
1584 //function : QAGetCoordinatesWzoom
1586 //=======================================================================
1588 static Standard_Integer QAGetCoordinatesWzoom(Draw_Interpretor& di, Standard_Integer, const char **)
1590 Standard_Integer id1,X1,Y1,b;
1591 Standard_Integer X2,Y2;
1592 Standard_Real dX1,dY1,dX2,dY2;
1593 di << "Pick first corner"<<"\n";
1594 dout.Select(id1,X1,Y1,b);
1598 dout.GetTrsf(id1,T);
1601 Standard_Real z = dout.Zoom(id1);
1604 dX1-=P0.X(); dY1-=P0.Y();
1607 if (b != 1) return 0;
1608 if (id1 < 0) return 0;
1609 Draw_Display d = dout.MakeDisplay(id1);
1610 d.SetColor(Draw_blanc);
1612 Standard_Real dOX2 = dX1;
1613 Standard_Real dOY2 = dY1;
1614 d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dOY2));
1615 d.Draw(gp_Pnt2d(dX1,dOY2),gp_Pnt2d(dOX2,dOY2));
1616 d.Draw(gp_Pnt2d(dOX2,dOY2),gp_Pnt2d(dOX2,dY1));
1617 d.Draw(gp_Pnt2d(dOX2,dY1),gp_Pnt2d(dX1,dY1));
1619 Standard_Real zx,zy;
1620 Standard_Integer X,Y,W,H;
1621 dout.GetPosSize(id1,X,Y,W,H);
1622 di << "Pick second corner"<<"\n";
1625 dout.Select(id1,X2,Y2,b,Standard_False);
1627 dX2-=P0.X(); dY2-=P0.Y();
1630 d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dOY2));
1631 d.Draw(gp_Pnt2d(dX1,dOY2),gp_Pnt2d(dOX2,dOY2));
1632 d.Draw(gp_Pnt2d(dOX2,dOY2),gp_Pnt2d(dOX2,dY1));
1633 d.Draw(gp_Pnt2d(dOX2,dY1),gp_Pnt2d(dX1,dY1));
1634 d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dY2));
1635 d.Draw(gp_Pnt2d(dX1,dY2),gp_Pnt2d(dX2,dY2));
1636 d.Draw(gp_Pnt2d(dX2,dY2),gp_Pnt2d(dX2,dY1));
1637 d.Draw(gp_Pnt2d(dX2,dY1),gp_Pnt2d(dX1,dY1));
1642 d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dOY2));
1643 d.Draw(gp_Pnt2d(dX1,dOY2),gp_Pnt2d(dOX2,dOY2));
1644 d.Draw(gp_Pnt2d(dOX2,dOY2),gp_Pnt2d(dOX2,dY1));
1645 d.Draw(gp_Pnt2d(dOX2,dY1),gp_Pnt2d(dX1,dY1));
1647 if (b != 1) return 0;
1649 if ((X1 == X2) || (Y1 == Y2)) return 0;
1651 di << "X1=" << X1 << " Y1=" << Y1 <<"\n";
1652 di << "X2=" << X2 << " Y2=" << Y2 <<"\n";
1654 zx = (Standard_Real) Abs(X2-X1) / (Standard_Real) W;
1655 zy = (Standard_Real) Abs(Y2-Y1) / (Standard_Real) H;
1656 if (zy > zx) zx = zy;
1658 if (X2 < X1) X1 = X2;
1659 if (Y2 > Y1) Y1 = Y2;
1660 X1 = (Standard_Integer ) (X1*zx);
1661 Y1 = (Standard_Integer ) (Y1*zx);
1662 dout.SetZoom(id1,zx*dout.Zoom(id1));
1663 dout.SetPan(id1,-X1,-Y1);
1664 dout.RepaintView(id1);
1667 sprintf(title,"%d : %s - Zoom %f",id1,dout.GetType(id1),dout.Zoom(id1));
1668 dout.SetTitle(id1,title);
1672 //=======================================================================
1674 //=======================================================================
1676 static Standard_Integer QArename(Draw_Interpretor& di, Standard_Integer n, const char** a)
1678 if (n < 3) return 1;
1679 Standard_Boolean cop = !strcasecmp(a[0],"copy");
1681 Handle(Draw_Drawable3D) D;
1682 for (Standard_Integer i = 1; i < n; i += 2) {
1683 if (i+1 >= n) return 0;
1684 D = Draw::Get(a[i]);
1690 Draw::Set(a[i],Handle(Draw_Drawable3D()));
1692 Draw::Set(a[i+1],D);
1698 static Standard_Integer QANbSelected (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1701 di << "Usage : " << argv[0] << "\n";
1704 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1705 if(aContext.IsNull()) {
1706 di << "use 'vinit' command before " << argv[0] << "\n";
1709 di << aContext->NbSelected() << "\n";
1714 //#include <AIS2D_InteractiveContext.hxx>
1715 //static Standard_Integer QANbSelected2d (Draw_Interpretor& /*di*/, Standard_Integer argc, char** argv)
1718 // cout << "Usage : " << argv[0] << endl;
1721 // Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1722 // if(aContext.IsNull()) {
1723 // cerr << "use 'v2dinit' command before " << argv[0] << endl;
1726 // cout << aContext->NbSelected() << endl;
1731 static Standard_Integer QAPurgeDisplay (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1734 di << "Usage : " << argv[0] << " [CollectorToo=0/1]" << "\n";
1737 Standard_Boolean CollectorTooBoolean = Standard_False;
1739 Standard_Integer CollectorTooInteger = atoi (argv [1]);
1740 if (CollectorTooInteger != 0)
1741 CollectorTooBoolean = Standard_True;
1743 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1744 if (aContext.IsNull()) {
1745 di << "use 'vinit' command before " << argv[0] << "\n";
1748 aContext->CloseAllContexts(Standard_False);
1749 di << aContext->PurgeDisplay(CollectorTooBoolean) << "\n";
1753 static Standard_Integer QACloseLocalContext (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1756 di << "Usage : " << argv[0] << " [Index [updateviewer=1/0]]" << "\n";
1759 Standard_Integer Index = -1;
1761 Index = atoi (argv [1]);
1763 //cout << "Index = " << Index << endl;
1764 Standard_Boolean updateviewerBoolean = Standard_True;
1766 Standard_Integer updateviewerInteger = atoi (argv [2]);
1767 if (updateviewerInteger == 0)
1768 updateviewerBoolean = Standard_False;
1770 //if (updateviewerBoolean)
1771 // cout << "updateviewer = Standard_True" << endl;
1773 // cout << "updateviewer = Standard_False" << endl;
1774 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1775 if (aContext.IsNull()) {
1776 di << "use 'vinit' command before " << argv[0] << "\n";
1779 aContext->CloseLocalContext(Index, updateviewerBoolean);
1783 static Standard_Integer QACloseAllContexts (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1786 di << "Usage : " << argv[0] << " [updateviewer=1/0]" << "\n";
1789 Standard_Boolean updateviewerBoolean = Standard_True;
1791 Standard_Integer updateviewerInteger = atoi (argv [1]);
1792 if (updateviewerInteger == 0)
1793 updateviewerBoolean = Standard_False;
1795 //if (updateviewerBoolean)
1796 // cout << "updateviewer = Standard_True" << endl;
1798 // cout << "updateviewer = Standard_False" << endl;
1799 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1800 if (aContext.IsNull()) {
1801 di << "use 'vinit' command before " << argv[0] << "\n";
1804 aContext->CloseAllContexts(updateviewerBoolean);
1808 static Standard_Integer QAIndexOfCurrentLocal (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1811 di << "Usage : " << argv[0] << "\n";
1814 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1815 if (aContext.IsNull()) {
1816 di << "use 'vinit' command before " << argv[0] << "\n";
1819 di << aContext->IndexOfCurrentLocal() << "\n";
1823 #include <AIS_ListOfInteractive.hxx>
1824 static Standard_Integer QADisplayedObjects (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1827 di << "Usage : " << argv[0] << " [OnlyFromNeutral=0/1]" << "\n";
1831 Standard_Boolean OnlyFromNeutralBoolean = Standard_False;
1833 Standard_Integer OnlyFromNeutralInteger = atoi (argv [1]);
1834 if (OnlyFromNeutralInteger != 0)
1835 OnlyFromNeutralBoolean = Standard_True;
1837 //if (OnlyFromNeutralBoolean)
1838 // cout << "OnlyFromNeutral = Standard_True" << endl;
1840 // cout << "OnlyFromNeutral = Standard_False" << endl;
1842 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1843 if (aContext.IsNull()) {
1844 di << "use 'vinit' command before " << argv[0] << "\n";
1847 Standard_Integer ListOfInteractiveExtent = 0;
1848 if(!aContext->HasOpenedContext()) {
1849 ListOfInteractiveExtent = 0;
1851 AIS_ListOfInteractive ListOfInteractive;
1852 aContext->DisplayedObjects(ListOfInteractive, OnlyFromNeutralBoolean);
1853 ListOfInteractiveExtent = ListOfInteractive.Extent();
1855 di << ListOfInteractiveExtent << "\n";
1859 static Standard_Integer QASelectRectangle(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
1862 di << "Usage : " << argv[0] << " x1 y1 x2 y2" << "\n";
1866 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
1867 if(myAIScontext.IsNull()) {
1868 di << "use 'vinit' command before " << argv[0] << "\n";
1872 Standard_Integer x1 = atoi(argv[1]);
1873 Standard_Integer y1 = atoi(argv[2]);
1874 Standard_Integer x2 = atoi(argv[3]);
1875 Standard_Integer y2 = atoi(argv[4]);
1877 Handle(ViewerTest_EventManager) aCurrentEventManager = ViewerTest::CurrentEventManager();
1878 // Handle(V3d_View) aCurrentView = ViewerTest::CurrentView();
1880 aCurrentEventManager->MoveTo(x1,y1);
1881 aCurrentEventManager->Select(x1,y1,x2,y2);
1882 aCurrentEventManager->MoveTo(x2,y2);
1887 static Standard_Integer QAShiftSelectRectangle(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
1890 di << "Usage : " << argv[0] << " x1 y1 x2 y2" << "\n";
1894 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
1895 if(myAIScontext.IsNull()) {
1896 di << "use 'vinit' command before " << argv[0] << "\n";
1899 Standard_Integer x1 = atoi(argv[1]);
1900 Standard_Integer y1 = atoi(argv[2]);
1901 Standard_Integer x2 = atoi(argv[3]);
1902 Standard_Integer y2 = atoi(argv[4]);
1904 Handle(ViewerTest_EventManager) aCurrentEventManager = ViewerTest::CurrentEventManager();
1905 // Handle(V3d_View) aCurrentView = ViewerTest::CurrentView();
1907 aCurrentEventManager->MoveTo(x1,y1);
1908 aCurrentEventManager->ShiftSelect(x1,y1,x2,y2);
1909 aCurrentEventManager->MoveTo(x2,y2);
1914 static int QASelect2dRectangle (Draw_Interpretor& di, int argc, const char ** argv)
1918 di << "Usage : " << argv[0] << " x1 y1 x2 y2" << "\n";
1922 Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext();
1923 if (myAIScontext.IsNull())
1925 di << "use 'v2dinit' command before " << argv[0] << "\n";
1929 Standard_Integer x1 = atoi(argv[1]);
1930 Standard_Integer y1 = atoi(argv[2]);
1931 Standard_Integer x2 = atoi(argv[3]);
1932 Standard_Integer y2 = atoi(argv[4]);
1934 Handle(Viewer2dTest_EventManager) aCurrentEventManager = Viewer2dTest::CurrentEventManager();
1935 Handle(V2d_View) aCurrentView = Viewer2dTest::CurrentView();
1937 aCurrentEventManager->MoveTo(x1,y1,aCurrentView);
1938 aCurrentEventManager->Select(x1,y1,x2,y2,aCurrentView);
1939 aCurrentEventManager->MoveTo(x2,y2,aCurrentView);
1944 static int QAShiftSelect2dRectangle (Draw_Interpretor& di, int argc, const char ** argv)
1948 di << "Usage : " << argv[0] << " x1 y1 x2 y2" << "\n";
1952 Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext();
1953 if (myAIScontext.IsNull())
1955 di << "use 'v2dinit' command before " << argv[0] << "\n";
1959 Standard_Integer x1 = atoi(argv[1]);
1960 Standard_Integer y1 = atoi(argv[2]);
1961 Standard_Integer x2 = atoi(argv[3]);
1962 Standard_Integer y2 = atoi(argv[4]);
1964 Handle(Viewer2dTest_EventManager) aCurrentEventManager = Viewer2dTest::CurrentEventManager();
1965 Handle(V2d_View) aCurrentView = Viewer2dTest::CurrentView();
1967 aCurrentEventManager->MoveTo(x1,y1,aCurrentView);
1968 aCurrentEventManager->ShiftSelect(x1,y1,x2,y2,aCurrentView);
1969 aCurrentEventManager->MoveTo(x2,y2,aCurrentView);
1974 //=======================================================================
1975 //function : QARotateV3dView
1977 //=======================================================================
1978 static Standard_Integer QARotateV3dView (Draw_Interpretor& di, int argc, const char ** argv)
1980 Handle(AIS_InteractiveContext) AIScontext = ViewerTest::GetAISContext();
1981 if(AIScontext.IsNull()) {
1982 di << "use 'vinit' command before " << argv[0] << "\n";
1985 if(argc < 4 || argc > 5){
1986 di<<"Usage : " << argv[0] << " Ax Ay Az [Start(1/0)]\n";
1989 Standard_Real Ax = atof(argv[1]);
1990 Standard_Real Ay = atof(argv[2]);
1991 Standard_Real Az = atof(argv[3]);
1992 Standard_Boolean Start = Standard_True;
1994 Standard_Integer StartInteger = atoi(argv[4]);
1995 if (StartInteger > 0) {
1996 Start = Standard_True;
1998 Start = Standard_False;
2002 Handle(V3d_View) aView = ViewerTest::CurrentView();
2003 aView->Rotate(Ax,Ay,Az,Start);
2007 //=======================================================================
2008 //function : QAMoveV3dView
2010 //=======================================================================
2011 static Standard_Integer QAMoveV3dView (Draw_Interpretor& di, int argc, const char ** argv)
2013 Handle(AIS_InteractiveContext) AIScontext = ViewerTest::GetAISContext();
2014 if(AIScontext.IsNull()) {
2015 di << "use 'vinit' command before " << argv[0] << "\n";
2018 if(argc < 4 || argc > 5){
2019 di<<"Usage : " << argv[0] << " Dx Dy Dz [Start(1/0)]\n";
2022 Standard_Real Dx = atof(argv[1]);
2023 Standard_Real Dy = atof(argv[2]);
2024 Standard_Real Dz = atof(argv[3]);
2025 Standard_Boolean Start = Standard_True;
2027 Standard_Integer StartInteger = atoi(argv[4]);
2028 if (StartInteger > 0) {
2029 Start = Standard_True;
2031 Start = Standard_False;
2035 Handle(V3d_View) aView = ViewerTest::CurrentView();
2036 aView->Move(Dx,Dy,Dz,Start);
2040 //=======================================================================
2041 //function : QATranslateV3dView
2043 //=======================================================================
2044 static Standard_Integer QATranslateV3dView (Draw_Interpretor& di, int argc, const char ** argv)
2046 Handle(AIS_InteractiveContext) AIScontext = ViewerTest::GetAISContext();
2047 if(AIScontext.IsNull()) {
2048 di << "use 'vinit' command before " << argv[0] << "\n";
2051 if(argc < 4 || argc > 5){
2052 di<<"Usage : " << argv[0] << " Dx Dy Dz [Start(1/0)]\n";
2055 Standard_Real Dx = atof(argv[1]);
2056 Standard_Real Dy = atof(argv[2]);
2057 Standard_Real Dz = atof(argv[3]);
2058 Standard_Boolean Start = Standard_True;
2060 Standard_Integer StartInteger = atoi(argv[4]);
2061 if (StartInteger > 0) {
2062 Start = Standard_True;
2064 Start = Standard_False;
2068 Handle(V3d_View) aView = ViewerTest::CurrentView();
2069 aView->Translate(Dx,Dy,Dz,Start);
2073 //=======================================================================
2074 //function : QATurnV3dView
2076 //=======================================================================
2077 static Standard_Integer QATurnV3dView (Draw_Interpretor& di, int argc, const char ** argv)
2079 Handle(AIS_InteractiveContext) AIScontext = ViewerTest::GetAISContext();
2080 if(AIScontext.IsNull()) {
2081 di << "use 'vinit' command before " << argv[0] << "\n";
2084 if(argc < 4 || argc > 5){
2085 di<<"Usage : " << argv[0] << " Ax Ay Az [Start(1/0)]\n";
2088 Standard_Real Ax = atof(argv[1]);
2089 Standard_Real Ay = atof(argv[2]);
2090 Standard_Real Az = atof(argv[3]);
2091 Standard_Boolean Start = Standard_True;
2093 Standard_Integer StartInteger = atoi(argv[4]);
2094 if (StartInteger > 0) {
2095 Start = Standard_True;
2097 Start = Standard_False;
2101 Handle(V3d_View) aView = ViewerTest::CurrentView();
2102 aView->Turn(Ax,Ay,Az,Start);
2106 //=======================================================================
2107 //function : QAPanningV3dView
2109 //=======================================================================
2110 static Standard_Integer QAPanningV3dView (Draw_Interpretor& di, int argc, const char ** argv)
2112 Handle(AIS_InteractiveContext) AIScontext = ViewerTest::GetAISContext();
2113 if(AIScontext.IsNull()) {
2114 di << "use 'vinit' command before " << argv[0] << "\n";
2117 if(argc < 3 || argc > 5){
2118 di<<"Usage : " << argv[0] << " Dx Dy [Zoom [Start(1/0)]]\n";
2121 Standard_Real Dx = atof(argv[1]);
2122 Standard_Real Dy = atof(argv[2]);
2123 Standard_Real Zoom = 1.;
2125 Zoom = atof(argv[3]);
2127 di<<"Bad Zoom value : " << Zoom << "\n";
2131 Standard_Boolean Start = Standard_True;
2133 Standard_Integer StartInteger = atoi(argv[4]);
2134 if (StartInteger > 0) {
2135 Start = Standard_True;
2137 Start = Standard_False;
2141 Handle(V3d_View) aView = ViewerTest::CurrentView();
2142 aView->Panning(Dx,Dy,Zoom,Start);
2146 //=======================================================================
2147 //function : QASetZoomV3dView
2149 //=======================================================================
2150 static Standard_Integer QASetZoomV3dView (Draw_Interpretor& di, int argc, const char ** argv)
2152 Handle(AIS_InteractiveContext) AIScontext = ViewerTest::GetAISContext();
2153 if(AIScontext.IsNull()) {
2154 di << "use 'vinit' command before " << argv[0] << "\n";
2157 if(argc < 2 || argc > 3){
2158 di<<"Usage : " << argv[0] << " Zoom [Start(1/0)]\n";
2161 Standard_Real Zoom = atof(argv[1]);
2163 di<<"Bad Zoom value : " << Zoom << "\n";
2166 Standard_Boolean Start = Standard_True;
2168 Standard_Integer StartInteger = atoi(argv[2]);
2169 if (StartInteger > 0) {
2170 Start = Standard_True;
2172 Start = Standard_False;
2176 Handle(V3d_View) aView = ViewerTest::CurrentView();
2177 aView->SetZoom(Zoom,Start);
2181 //=======================================================================
2182 //function : QASetSizeV3dView
2184 //=======================================================================
2185 static Standard_Integer QASetSizeV3dView (Draw_Interpretor& di, int argc, const char ** argv)
2187 Handle(AIS_InteractiveContext) AIScontext = ViewerTest::GetAISContext();
2188 if(AIScontext.IsNull()) {
2189 di << "use 'vinit' command before " << argv[0] << "\n";
2193 di<<"Usage : " << argv[0] << " Size\n";
2196 Standard_Real Size = atof(argv[1]);
2198 di<<"Bad Size value : " << Size << "\n";
2202 Handle(V3d_View) aView = ViewerTest::CurrentView();
2203 aView->SetSize(Size);
2207 void QADraw::CommonCommands(Draw_Interpretor& theCommands)
2209 ios::sync_with_stdio();
2211 st_err = dup(STDERR_FILENO);
2213 Draw_BeforeCommand_old = Draw_BeforeCommand;
2214 Draw_AfterCommand_old = Draw_AfterCommand;
2216 Draw_BeforeCommand = &before;
2217 Draw_AfterCommand = &after;
2219 const char* group = "QA_Commands";
2221 theCommands.Add("QARebuild","QARebuild command_name",__FILE__,QARebuild,group);
2222 theCommands.Add("QAxwd_3d","QAxwd_3d filename",__FILE__,QAxwd_3d,group);
2223 theCommands.Add("QAMoveTo","QAMoveTo x y",__FILE__,QAMoveTo,group);
2224 theCommands.Add("QASelect","QASelect x y",__FILE__,QASelect,group);
2225 theCommands.Add("QAShiftSelect","QAShiftSelect x y",__FILE__,QAShiftSelect,group);
2226 theCommands.Add("QAUpdateLights","QAUpdateLights",__FILE__,QAUpdateLights,group);
2227 theCommands.Add("QASetAntialiasing","QASetAntialiasing [1/0]",__FILE__,QASetAntialiasing,group);
2228 theCommands.Add("QAvzfit","QAvzfit",__FILE__,QAvzfit,group);
2229 theCommands.Add("QAGetPixelColor", "QAGetPixelColor coordinate_X coordinate_Y [color_R color_G color_B]", __FILE__,QAAISGetPixelColor, group);
2230 theCommands.Add("QASetChoiceMode", "QASetChoiceMode mode switch ; Use without params to see a help ", __FILE__,QAAISSetChoiceMode, group);
2231 theCommands.Add("QAGetMousePoint", "QAGetMousePoint", __FILE__,QAAISGetMousePoint, group);
2232 theCommands.Add("QAGetViewCharac", "QAGetViewCharac", __FILE__,QAAISGetViewCharac, group);
2233 theCommands.Add("QASetViewCharac", "QASetViewCharac scale center_X center_Y proj_X proj_Y proj_Z up_X up_Y up_Z at_X at_Y at_Z", __FILE__,QAAISSetViewCharac, group);
2234 theCommands.Add("QAGetColorCoord", "QAGetColorCoord [3d|2d]", __FILE__,QAAISGetColorCoord, group);
2236 theCommands.Add("QAAISGetPixelColor2d",
2237 "QAAISGetPixelColor2d coord_X coord_Y [Red Green Blue] : Check a color of pixel",
2238 __FILE__, QAAISGetPixelColor2d, group);
2241 theCommands.Add("v2dgetgrid",
2242 "v2dgetgrid coord_X coord_Y [grid_X grid_Y] : Get/print coordinates of a grid point near to (coord_X, coord_Y)",
2243 __FILE__, V2dPickGrid, group);
2245 theCommands.Add("QAv2dzoom",
2246 "QAv2dzoom zoom_factor : Set Scale Factor",
2247 __FILE__, V2dZoom, group);
2249 theCommands.Add("QAv2dpan",
2250 "QAv2dpan dx dy : script analog of Ctrl+MB2",
2251 __FILE__, V2dPan, group);
2253 // theCommands.Add("QAGetViewCharac2d",
2254 // "QAGetViewCharac2d - dumps viewer characteristics",
2255 // V2dGetViewCharac, group);
2257 // theCommands.Add("QASetViewCharac2d",
2258 // "QASetViewCharac2d scale center(X Y) proj(X Y Z) up(X Y Z) at(X Y Z)",
2259 // V2dSetViewCharac, group);
2261 theCommands.Add("QAMoveTo2d", "QAMoveTo2d x y", __FILE__, QAMoveTo2d, group);
2262 theCommands.Add("QASelect2d", "QASelect2d x y", __FILE__, QASelect2d, group);
2263 theCommands.Add("QAShiftSelect2d", "QAShiftSelect2d x y", __FILE__, QAShiftSelect2d, group);
2265 theCommands.Add("QAv2dSetHighlightMode",
2266 "QAv2dSetHighlightMode mode", __FILE__, V2dSetHighlightMode, group);
2268 theCommands.Add("QAxwd_2d", "QAxwd_2d filename", __FILE__, QAxwd_2d, group);
2270 theCommands.Add("QAxwd", "QAxwd [id=1] filename", __FILE__, QAxwd, group);
2272 theCommands.Add("QA2dGetIndexes", "QA2dGetIndexes", __FILE__, QA2dGetIndexes, group);
2274 theCommands.Add("vtri_orig",
2275 "vtri_orig : vtri_orig trihedron_name - draws axis origin lines",
2276 __FILE__,VTrihedronOrigins,group);
2278 theCommands.Add("QAAddOrRemoveSelected",
2279 "QAAddOrRemoveSelected shape : selects the shape by AddOrRemoveSelected method",
2280 __FILE__, QAAddOrRemoveSelected, group);
2282 theCommands.Add("QASetZClippingMode","QASetZClippingMode mode(OFF/BACK/FRONT/SLICE)",__FILE__,QASetZClippingMode,group);
2283 theCommands.Add("QAGetZClippingMode","QAGetZClippingMode",__FILE__,QAGetZClippingMode,group);
2284 theCommands.Add("QAv2dcircle", "QAv2dcircle CircleName X Y Radius Alpha Beta [Color_index]", __FILE__, QAv2dcircle, group);
2286 theCommands.Add("QAwzoom","QAwzoom view-id X1 Y1 X2 Y2; zoom on a window",__FILE__,QAwzoom,group);
2287 theCommands.Add("QAGetCoordinatesWzoom","QAGetCoordinatesWzoom ; Get coordinates for zoom on a window",__FILE__,QAGetCoordinatesWzoom,group);
2289 // adding commands "rename" leads to the fact that QA commands doesn't work properly OCC23410, use function "renamevar"
2290 // theCommands.Add("rename","rename name1 toname1 name2 toname2 ...",__FILE__,QArename,group);
2292 theCommands.Add ("QANbSelected", "QANbSelected", __FILE__, QANbSelected, group);
2294 // theCommands.Add ("QANbSelected2d", "QANbSelected2d", __FILE__, QANbSelected2d, group);
2297 theCommands.Add ("QAPurgeDisplay", "QAPurgeDisplay [CollectorToo=0/1]", __FILE__, QAPurgeDisplay, group);
2298 theCommands.Add ("QACloseLocalContext", "QACloseLocalContext [Index [updateviewer=1/0]]", __FILE__, QACloseLocalContext, group);
2299 theCommands.Add ("QACloseAllContexts", "QACloseAllContexts [updateviewer=1/0]", __FILE__, QACloseAllContexts, group);
2300 theCommands.Add ("QAIndexOfCurrentLocal", "QAIndexOfCurrentLocal", __FILE__, QAIndexOfCurrentLocal, group);
2301 theCommands.Add ("QADisplayedObjects", "QADisplayedObjects [OnlyFromNeutral=0/1]", __FILE__, QADisplayedObjects, group);
2303 theCommands.Add("QASelectRectangle","QASelectRectangle x1 y1 x2 y2",__FILE__,QASelectRectangle,group);
2304 theCommands.Add("QAShiftSelectRectangle","QAShiftSelectRectangle x1 y1 x2 y2",__FILE__,QAShiftSelectRectangle,group);
2305 theCommands.Add("QASelect2dRectangle","QASelect2dRectangle x1 y1 x2 y2",__FILE__,QASelect2dRectangle,group);
2306 theCommands.Add("QAShiftSelect2dRectangle","QAShiftSelect2dRectangle x1 y1 x2 y2",__FILE__,QAShiftSelect2dRectangle,group);
2308 theCommands.Add("QARotateV3dView","QARotateV3dView Ax Ay Az [Start(1/0)]",__FILE__,QARotateV3dView,group);
2309 theCommands.Add("QAMoveV3dView","QAMoveV3dView Dx Dy Dz [Start(1/0)]",__FILE__,QAMoveV3dView,group);
2310 theCommands.Add("QATranslateV3dView","QATranslateV3dView Dx Dy Dz [Start(1/0)]",__FILE__,QATranslateV3dView,group);
2311 theCommands.Add("QATurnV3dView","QATurnV3dView Ax Ay Az [Start(1/0)]",__FILE__,QATurnV3dView,group);
2312 theCommands.Add("QAPanningV3dView","QAPanningV3dView Dx Dy [Zoom [Start(1/0)]]",__FILE__,QAPanningV3dView,group);
2313 theCommands.Add("QASetZoomV3dView","QASetZoomV3dView Zoom [Start(1/0)]",__FILE__,QASetZoomV3dView,group);
2314 theCommands.Add("QASetSizeV3dView","QASetSizeV3dView Size",__FILE__,QASetSizeV3dView,group);
2317 extern "C" int Tkqadraw_Init(Tcl_Interp *);
2319 int Tkqadraw_Init(Tcl_Interp * ) {
2321 ios::sync_with_stdio();
2323 QADraw::CommonCommands(theCommands);
2324 QADraw::AdditionalCommands(theCommands);
2326 ViewerTest::Commands (theCommands);
2327 ViewerTest::ViewerCommands (theCommands);
2329 Viewer2dTest::Commands(theCommands);
2330 // if (Tcl_PkgProvide(theCommands.Interp(), "Qa", "1.0") != TCL_OK) {
2331 // return TCL_ERROR;
2337 //==============================================================================
2339 //==============================================================================
2340 void QADraw::Factory(Draw_Interpretor& theCommands)
2342 thePCommands = &theCommands;
2344 // definition of QA Command
2345 QADraw::CommonCommands(theCommands);
2346 QADraw::AdditionalCommands(theCommands);
2348 //ViewerTest::Commands (theCommands);
2349 //ViewerTest::ViewerCommands (theCommands);
2352 // Viewer2dTest::Commands(theCommands);
2356 // cout << "Draw Plugin : QA commands are loaded" << endl;
2360 // Declare entry point PLUGINFACTORY