0023272: Image comparison algorithm
[occt.git] / src / QADraw / QADraw.cxx
CommitLineData
b311480e 1// Created on: 2002-02-04
2// Created by: QA Admin
3// Copyright (c) 2002-2012 OPEN CASCADE SAS
4//
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.
9//
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.
12//
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.
19
7fd59977 20
21
22#if defined(WNT)
23#include <windows.h>
24#endif
25#include <QADraw.hxx>
26#include <QADraw_DataMapOfAsciiStringOfAddress.hxx>
27#include <Draw_Interpretor.hxx>
692613e5 28#include <Image_AlienPixMap.hxx>
7fd59977 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>
41#include <stdio.h>
42
43#include <Viewer2dTest.hxx>
44#include <V2d_View.hxx>
45#include <Viewer2dTest_EventManager.hxx>
46
47#if ! defined(WNT)
48#include <Xw_Window.hxx>
49//#include <Xm/Xm.h>
50#include <X11/Xlib.h>
51#include <X11/Xutil.h>
52#include <Xw_GraphicDevice.hxx>
53#include <Xw_Cextern.hxx>
54#include <unistd.h>
55#else
56#include <WNT.h>
57#include <WNT_GraphicDevice.hxx>
58#include <WNT_Window.hxx>
59#include <io.h>
60#endif
61
62#include <tcl.h>
63
64#if ! defined(STDOUT_FILENO)
65#define STDOUT_FILENO fileno(stdout)
66#endif
67
68// mkv 15.07.03
69#if ! defined(STDERR_FILENO)
70#define STDERR_FILENO fileno(stderr)
71#endif
72
73Draw_Interpretor *thePCommands = NULL;
74
75#if ! defined(WNT)
76//extern Draw_Interpretor theCommands;
77
78extern void (*Draw_BeforeCommand)();
79extern void (*Draw_AfterCommand)(Standard_Integer);
80#else
81//Standard_EXPORT Draw_Interpretor theCommands;
82
83Standard_EXPORT void (*Draw_BeforeCommand)();
84Standard_EXPORT void (*Draw_AfterCommand)(Standard_Integer);
85#endif
86
87
88#include <Draw_PluginMacro.hxx>
89
90// avoid warnings on 'extern "C"' functions returning C++ classes
91#ifdef WNT
92#pragma warning(4:4190)
93#endif
94
95
96int st_err = 0;
97
98void (*Draw_BeforeCommand_old)();
99void (*Draw_AfterCommand_old)(Standard_Integer);
100
101static Standard_Boolean should_be_printed = Standard_True;
102
103static Standard_Boolean shouldDUP() {
104 // MKV 30.03.05
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);
108#else
109 Standard_Character * adup = Tcl_GetVar(thePCommands->Interp(),
110 "QA_DUP",TCL_GLOBAL_ONLY);
111#endif
112 Standard_Integer aDUP=1;
113 if((adup != NULL) && (atof(adup) == 0)) {
114 aDUP = 0;
115 }
116
117 return aDUP;
118}
119
120static void before() {
121 should_be_printed = Standard_True;
122 if(Draw_BeforeCommand_old) (*Draw_BeforeCommand_old) ();
123}
124
125static void after(Standard_Integer a)
126{
127 if(Draw_AfterCommand_old) (*Draw_AfterCommand_old) (a);
128 if(!should_be_printed) {
129// Tcl_ResetResult(theCommands.Interp());
130 }
131}
132
133static QADraw_DataMapOfAsciiStringOfAddress stFuncMap;
134
135 // MKV 30.03.05
136#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
137static Standard_Integer (*CommandCmd_Old)
138(ClientData clientData, Tcl_Interp *interp,
139 Standard_Integer argc, const char* argv[]) = NULL;
140#else
141static Standard_Integer (*CommandCmd_Old)
142(ClientData clientData, Tcl_Interp *interp,
143 Standard_Integer argc, char* argv[]) = NULL;
144#endif
145
146 // MKV 30.03.05
147#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
148static Standard_Integer CommandCmd
149(ClientData clientData, Tcl_Interp *interp,
150 Standard_Integer argc, const char* argv[])
151#else
152static Standard_Integer CommandCmd
153(ClientData clientData, Tcl_Interp *interp,
154 Standard_Integer argc, char* argv[])
155#endif
156{
157 Standard_Integer old_out = 0;
158 Standard_Integer old_err = 0;
159 Standard_Integer fd_out = 0;
160 Standard_Integer fd_err = 0;
161
162 FILE * aFile_out = NULL;
163 FILE * aFile_err = NULL;
164
165 char *nameo = NULL;
166 char *namee = NULL;
167#ifdef WNT
168 if(strlen(getenv("TEMP")) == 0) {
169 cerr << "The TEMP variable is not set." << endl;
170 aFile_out = tmpfile();
171 aFile_err = tmpfile();
172 } else {
173 nameo = _tempnam(getenv("TEMP"),"tmpo");
174 namee = _tempnam(getenv("TEMP"),"tmpe");
175 aFile_out=fopen(nameo, "w+");
176 aFile_err=fopen(namee, "w+");
177 }
178#else
179 aFile_out = tmpfile();
180 aFile_err = tmpfile();
181#endif
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);
189 } else
190 cout << "Faulty : Can not create temporary file." << endl;
191
192 Standard_Integer clen = sizeof(Standard_Character);
193
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);
199 }
200 write(st_err,"\n",clen);
201 }
202
203 // MKV 30.03.05
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]);
206#else
207 TCollection_AsciiString aName(argv[0]);
208#endif
209
210 Standard_Integer res = 0;
211
212 if(stFuncMap.IsBound(aName)) {
213 // MKV 30.03.05
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]);
216#else
217 CommandCmd_Old = (int(*)(void*, Tcl_Interp*, int, char**)) stFuncMap(argv[0]);
218#endif
219 res = (*CommandCmd_Old) (clientData,interp,argc,argv);
220 }
221
222 fflush(stderr);
223 fflush(stdout);
224 close(STDERR_FILENO);
225 close(STDOUT_FILENO);
226 dup2(old_err,STDERR_FILENO);
227 dup2(old_out,STDOUT_FILENO);
228 close(old_err);
229 close(old_out);
230
231 Standard_Character buf[256];
232 Standard_Integer len = 0;
233
234 rewind(aFile_err);
235 while((len = read(fd_err,buf,clen*255)/clen) > 0) {
236 buf[len]='\0';
237 if(shouldDUP()) {
238 (*thePCommands) << buf;
239 } else {
240 write(st_err,buf,clen*len);
241 }
242 }
243 close(fd_err);
244
245 rewind(aFile_out);
246 buf[0] = '\0';
247 len = 0;
248 while((len = read(fd_out,buf,clen*255)/clen) > 0) {
249 buf[len]='\0';
250 if(shouldDUP()) {
251 (*thePCommands) << buf;
252 } else {
253 write(st_err,buf,clen*len);
254 }
255 }
256 close(fd_out);
257
258 if(shouldDUP()) {
259 Standard_Character *Result = (Standard_Character *)thePCommands->Result();
260 if(Result[0] != '\0') {
261 Standard_Integer pos = 0;
262 Standard_Integer rlen = strlen(Result);
263 while(pos < rlen) {
264 Standard_Integer nb = 256;
265 if((rlen - pos) <= 256) {
266 nb = rlen - pos;
267 }
268 write(st_err,Result+pos,nb*clen);
269 pos += nb;
270 }
271 write(st_err,"\n",clen);
272 should_be_printed = Standard_False ;
273 }
274 } //else {
275 if(nameo)
276 free(nameo);
277 if(namee)
278 free(namee);
279 return res;
280}
281
282static Standard_Integer QARebuild (Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
283{
284
285 Tcl_CmdInfo *infoPtr = new Tcl_CmdInfo;
286
287 if(!strcmp(a[0],a[1]))
288 return 0;
289
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);
296
297 infoPtr->proc = &CommandCmd;
298#if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 3
299 infoPtr->isNativeObjectProc = 0;
300 infoPtr->objProc = NULL;
301#endif
302 Tcl_SetCommandInfo(di.Interp(),var_a,infoPtr);
303 }
304 }
305
306 return 0;
307}
308
309static Standard_Integer QAUpdateLights(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
310{
311 if(argc != 1) {
312 di << "Usage : " << argv[0] << "\n";
313 return -1;
314 }
315
316 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
317 if(myAIScontext.IsNull()) {
318 di << "use 'vinit' command before " << argv[0] << "\n";
319 return -1;
320 }
321 ViewerTest::CurrentView()->UpdateLights();
322 ViewerTest::CurrentView()->Update();
323 return 0;
324}
325
326static Standard_Integer QAxwd_3d(Draw_Interpretor& di, Standard_Integer argc, const char** argv )
327{
328 if(argc != 2) {
329 di << "Usage : " << argv[0] << " filename" << "\n";
330 return -1;
331 }
332
333 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
334 if(myAIScontext.IsNull()) {
335 di << "use 'vinit' command before " << argv[0] << "\n";
336 return -1;
337 }
338 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
339 //cout << myV3dView->Dump(argv[1]) << endl;
340 myV3dView->Dump(argv[1]);
341 return 0;
342}
343
344
345static Standard_Integer QAMoveTo(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
346{
347 if(argc != 3) {
348 di << "Usage : " << argv[0] << " x y" << "\n";
349 return -1;
350 }
351
352 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
353 if(myAIScontext.IsNull()) {
354 di << "use 'vinit' command before " << argv[0] << "\n";
355 return -1;
356 }
357 ViewerTest::CurrentEventManager()->MoveTo(atoi(argv[1]),atoi(argv[2]));
358 return 0;
359}
360
361static Standard_Integer QASelect(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
362{
363 if(argc != 3) {
364 di << "Usage : " << argv[0] << " x y" << "\n";
365 return -1;
366 }
367
368 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
369 if(myAIScontext.IsNull()) {
370 di << "use 'vinit' command before " << argv[0] << "\n";
371 return -1;
372 }
373 ViewerTest::CurrentEventManager()->MoveTo(atoi(argv[1]),atoi(argv[2]));
374 ViewerTest::CurrentEventManager()->Select();
375 return 0;
376}
377
378static Standard_Integer QAShiftSelect(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
379{
380 if(argc != 3) {
381 di << "Usage : " << argv[0] << " x y" << "\n";
382 return -1;
383 }
384
385 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
386 if(myAIScontext.IsNull()) {
387 di << "use 'vinit' command before " << argv[0] << "\n";
388 return -1;
389 }
390 ViewerTest::CurrentEventManager()->MoveTo(atoi(argv[1]),atoi(argv[2]));
391 ViewerTest::CurrentEventManager()->ShiftSelect();
392 return 0;
393}
394
395static Standard_Integer QASetAntialiasing(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
396{
397 if(argc > 2) {
398 di << "Usage : " << argv[0] << " [1/0]" << "\n";
399 return -1;
400 }
401
402 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
403 if(myAIScontext.IsNull()) {
404 di << "use 'vinit' command before " << argv[0] << "\n";
405 return -1;
406 }
407
408 Handle(V3d_View) myV3dView = ViewerTest::CurrentView();
409
410 if((argc == 2) && (atof(argv[1]) == 0))
411 myV3dView->SetAntialiasingOff();
412 else
413 myV3dView->SetAntialiasingOn();
414 myV3dView->Update();
415 return 0;
416}
417
418static Standard_Integer QAvzfit(Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv )
419{
420 Handle(V3d_View) V = ViewerTest::CurrentView();
421 if ( V.IsNull() ) {
422 di << "use 'vinit' command before " << argv[0] << "\n";
423 return -1;
424 }
425 V->ZFitAll();
426 return 0;
427}
428
692613e5 429Handle(TColStd_HSequenceOfReal) GetColorOfPixel (const Image_PixMap& theImage,
7fd59977 430 const Standard_Integer theCoordinateX,
431 const Standard_Integer theCoordinateY,
432 const Standard_Integer theRadius)
433{
434 Handle(TColStd_HSequenceOfReal) aSeq = new TColStd_HSequenceOfReal();
692613e5 435 if (theImage.IsEmpty()) {
7fd59977 436 std::cerr << "The image is null.\n";
437 return aSeq;
438 }
692613e5 439 Standard_Integer aWidth = (Standard_Integer )theImage.SizeX();
440 Standard_Integer anHeight = (Standard_Integer )theImage.SizeY();
7fd59977 441
442 Quantity_Color aColorTmp;
443 for (Standard_Integer anXIter = theCoordinateX - theRadius;
444 anXIter <= theCoordinateX + theRadius; ++anXIter)
445 {
446 if (anXIter < 0 || anXIter >= aWidth)
447 {
448 continue;
449 }
450 for (Standard_Integer anYIter = theCoordinateY - theRadius;
451 anYIter <= theCoordinateY + theRadius; ++anYIter)
452 {
453 if (anYIter < 0 || anYIter >= anHeight)
454 {
455 continue;
456 }
457 // Image_PixMap stores image upside-down in memory!
692613e5 458 aColorTmp = theImage.PixelColor (anXIter, anYIter);
7fd59977 459 aSeq->Append (aColorTmp.Red());
460 aSeq->Append (aColorTmp.Green());
461 aSeq->Append (aColorTmp.Blue());
462 }
463 }
464 return aSeq;
465}
466
467static Standard_Integer QAAISGetPixelColor (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
468{
469 if ( argc != 3 ) {
470 if ( argc != 6 ) {
471 di << "Usage : " << argv[0] << " coordinate_X coordinate_Y [color_R color_G color_B]" << "\n";
472 return 1;
473 }
474 }
475 Handle (V3d_View) QAAISView = ViewerTest::CurrentView ();
476 if ( QAAISView.IsNull () ) {
477 di << "You must initialize AISViewer before this command." << "\n";
478 return 1;
479 }
480 Handle (Aspect_Window) QAAISWindow = QAAISView->Window ();
481 Standard_Integer QAAISXWindowSize_X = 0;
482 Standard_Integer QAAISXWindowSize_Y = 0;
483 QAAISWindow->Size(QAAISXWindowSize_X, QAAISXWindowSize_Y);
692613e5 484 Standard_ShortReal QAAISCoordinateX = atof (argv [1]);
485 Standard_ShortReal QAAISCoordinateY = atof (argv [2]);
7fd59977 486
487 Standard_ShortReal QAAISColorRED_V = 0;
488 Standard_ShortReal QAAISColorGRN_V = 0;
489 Standard_ShortReal QAAISColorBLU_V = 0;
490
491 if ( argc == 6 ) {
492 QAAISColorRED_V = atof (argv [3]);
493 QAAISColorGRN_V = atof (argv [4]);
494 QAAISColorBLU_V = atof (argv [5]);
495
496 di << "Begin aColorRED_User = " << QAAISColorRED_V << "\n";
497 di << "Begin aColorGRN_User = " << QAAISColorRED_V << "\n";
498 di << "Begin aColorBLU_User = " << QAAISColorRED_V << "\n";
499 }
500
501 Standard_Integer aRadius = 1;
502 if ( argc == 3 ) {
503 aRadius=0;
504 }
505
692613e5 506 Image_PixMap anImage;
507 QAAISView->ToPixMap (anImage, QAAISXWindowSize_X, QAAISXWindowSize_Y);
508 Handle(TColStd_HSequenceOfReal) aSeq = GetColorOfPixel (anImage, QAAISCoordinateX, QAAISCoordinateY, aRadius);
7fd59977 509 cout << "Length = " << aSeq->Length() << endl;
510
511 Standard_Boolean IsNotEqual = Standard_True;
512 Standard_Integer i;
513 for(i=1; i<=aSeq->Length();i+=3) {
514 // mkv 29.04.03
515 Standard_ShortReal QAAISColorRED_R = (((Standard_ShortReal) ((Standard_Integer) (aSeq->Value(i+0) * 1000000))) / 1000000.);
516 Standard_ShortReal QAAISColorGRN_R = (((Standard_ShortReal) ((Standard_Integer) (aSeq->Value(i+1) * 1000000))) / 1000000.);
517 Standard_ShortReal QAAISColorBLU_R = (((Standard_ShortReal) ((Standard_Integer) (aSeq->Value(i+2) * 1000000))) / 1000000.);
518 // mkv 29.04.03
519
520 if ( argc == 3 ) {
521 di << "RED : " << QAAISColorRED_R
522 << " GREEN : " << QAAISColorGRN_R
523 << " BLUE : " << QAAISColorBLU_R
524 << "\n";
525 IsNotEqual = Standard_False;
526 break;
527 }
528
529 if ( QAAISColorRED_R == QAAISColorRED_V
530 && QAAISColorGRN_R == QAAISColorGRN_V
531 && QAAISColorBLU_R == QAAISColorBLU_V
532 ) {
533 IsNotEqual = Standard_False;
534 break;
535 }
536 }
537 if (IsNotEqual) {
538 di << "Faulty : colors are not equal." << "\n";
539 return 1;
540 }
541 return 0;
542}
543
544static Standard_Boolean IsSelectionModeCurrentlyON (Standard_Integer theMode) {
545 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
546 if(!aContext->HasOpenedContext()) {
547 return Standard_False ;
548 }
549 const TColStd_ListOfInteger& List = aContext->ActivatedStandardModes();
550 TColStd_ListIteratorOfListOfInteger it;
551 Standard_Boolean Found=Standard_False;
552 for (it.Initialize(List); it.More()&&!Found; it.Next() ) {
553 if (it.Value()==theMode ) Found=Standard_True;
554 }
555 return Found;
556}
557
558static Standard_Integer QAAISSetChoiceMode (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
559{
560 if ( argc != 3 ) {
561 di << "Usage : " << argv[0] << " mode switch" << "\n";
562 di << " mode: " << "\n";
563 // cout << " SHAPE " << endl;
564 di << " VERTEX " << "\n";
565 di << " EDGE " << "\n";
566 di << " WIRE " << "\n";
567 di << " FACE " << "\n";
568 di << " SHELL " << "\n";
569 di << " SOLID " << "\n";
570 di << " COMPOUND " << "\n";
571 di << " switch: " << "\n";
572 di << " ON " << "\n";
573 di << " OFF " << "\n";
574 return 1;
575 }
576 Handle (V3d_View) QAAISView = ViewerTest::CurrentView ();
577 if ( QAAISView.IsNull () ) {
578 di << "You must initialize AISViewer before this command." << "\n";
579 return 1;
580 }
581 Standard_Integer QAChoosingMode = -1;
582 // if ( strcmp (sc [1], "SHAPE") == 0 ) {
583 // QAChoosingMode = 0;
584 // }
585 if ( strcmp (argv [1], "VERTEX") == 0 ) {
586 QAChoosingMode = 1;
587 }
588 if ( strcmp (argv [1], "EDGE") == 0 ) {
589 QAChoosingMode = 2;
590 }
591 if ( strcmp (argv [1], "WIRE") == 0 ) {
592 QAChoosingMode = 3;
593 }
594 if ( strcmp (argv [1], "FACE") == 0 ) {
595 QAChoosingMode = 4;
596 }
597 if ( strcmp (argv [1], "SHELL") == 0 ) {
598 QAChoosingMode = 5;
599 }
600 if ( strcmp (argv [1], "SOLID") == 0 ) {
601 QAChoosingMode = 6;
602 }
603 if ( strcmp (argv [1], "COMPOUND") == 0 ) {
604 QAChoosingMode = 7;
605 }
606 if ( QAChoosingMode == -1 ) {
607 di << "Use - QAAISSetChoiceMode mode switch" << "\n";
608 return 1;
609 }
610
611 if ( strcmp (argv [2], "ON") == 0 ) {
612 if ( IsSelectionModeCurrentlyON (QAChoosingMode)) {
613 di << "Mode already ON." << "\n";
614 return 1;
615 }
616 ViewerTest::StandardModeActivation (QAChoosingMode);
617 return 0;
618 }
619 if ( strcmp (argv [2], "OFF") == 0 ) {
620 if (!IsSelectionModeCurrentlyON (QAChoosingMode)) {
621 di << "Mode already OFF." << "\n";
622 return 1;
623 }
624 ViewerTest::StandardModeActivation (QAChoosingMode);
625 return 0;
626 }
627 di << "Usage : " << argv[0] << " mode switch" << "\n";
628 return 1;
629}
630
631#if ! defined(WNT)
632extern int ViewerMainLoop (Standard_Integer argc, const char ** argv);
633#else
634Standard_EXPORT int ViewerMainLoop (Standard_Integer argc, const char ** argv);
635#endif
636#if ! defined(WNT)
637extern int ViewerMainLoop2d (Standard_Integer argc, const char ** argv);
638#else
639Standard_EXPORT int ViewerMainLoop2d (Standard_Integer argc, const char ** argv);
640#endif
641
642static Standard_Integer QAAISGetMousePoint (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
643{
644 if ( argc != 1 ) {
645 di << "Usage : " << argv[0] << "\n";
646 return 1;
647 }
648 Handle (V3d_View) QAAISView = ViewerTest::CurrentView ();
649 if ( QAAISView.IsNull () ) {
650 di << "You must initialize AISViewer before this command." << "\n";
651 return 1;
652 }
653 Standard_Integer QAAISMouseCoordinateX = 0;
654 Standard_Integer QAAISMouseCoordinateY = 0;
655 Standard_Integer argccc = 5;
656 const char *bufff[] = { "A", "B", "C", "D", "E" };
657 const char **argvvv = (const char **) bufff;
658 while ( ViewerMainLoop (argccc, argvvv) ) {
659 ViewerTest::GetMousePosition (QAAISMouseCoordinateX, QAAISMouseCoordinateY);
660 }
661 ViewerTest::GetMousePosition (QAAISMouseCoordinateX, QAAISMouseCoordinateY);
662 di << "X-coordinate: " << QAAISMouseCoordinateX << "; Y-coordinate: " << QAAISMouseCoordinateY << "\n";
663 return 0;
664}
665
666static Standard_Integer QAAISGetViewCharac (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
667{
668 if ( argc != 1 ) {
669 di << "Usage : " << argv[0] << "\n";
670 return 1;
671 }
672 Handle (V3d_View) QAAISView = ViewerTest::CurrentView ();
673 if ( QAAISView.IsNull () ) {
674 di << "You must initialize AISViewer before this command." << "\n";
675 return 1;
676 }
677 Quantity_Factor QAAISViewScale = QAAISView -> V3d_View::Scale ();
678 Standard_Real QAAISViewCenterCoordinateX = 0.0;
679 Standard_Real QAAISViewCenterCoordinateY = 0.0;
680 QAAISView -> V3d_View::Center (QAAISViewCenterCoordinateX, QAAISViewCenterCoordinateY);
681 Standard_Real QAAISViewProjX = 0.0;
682 Standard_Real QAAISViewProjY = 0.0;
683 Standard_Real QAAISViewProjZ = 0.0;
684 QAAISView -> V3d_View::Proj (QAAISViewProjX, QAAISViewProjY, QAAISViewProjZ);
685 Standard_Real QAAISViewUpX = 0.0;
686 Standard_Real QAAISViewUpY = 0.0;
687 Standard_Real QAAISViewUpZ = 0.0;
688 QAAISView -> V3d_View::Up (QAAISViewUpX, QAAISViewUpY, QAAISViewUpZ);
689 Standard_Real QAAISViewAtX = 0.0;
690 Standard_Real QAAISViewAtY = 0.0;
691 Standard_Real QAAISViewAtZ = 0.0;
692 QAAISView -> V3d_View::At (QAAISViewAtX, QAAISViewAtY, QAAISViewAtZ);
693 di << "Scale of current view: " << QAAISViewScale << "\n";
694 di << "Center on X : "<< QAAISViewCenterCoordinateX << "; on Y: " << QAAISViewCenterCoordinateY << "\n";
695 di << "Proj on X : " << QAAISViewProjX << "; on Y: " << QAAISViewProjY << "; on Z: " << QAAISViewProjZ << "\n";
696 di << "Up on X : " << QAAISViewUpX << "; on Y: " << QAAISViewUpY << "; on Z: " << QAAISViewUpZ << "\n";
697 di << "At on X : " << QAAISViewAtX << "; on Y: " << QAAISViewAtY << "; on Z: " << QAAISViewAtZ << "\n";
692613e5 698 return 0;
7fd59977 699}
700
701static Standard_Integer QAAISSetViewCharac (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
702{
703 if ( argc != 13 ) {
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";
705 return 1;
706 }
707 Handle (V3d_View) QAAISView = ViewerTest::CurrentView ();
708 if ( QAAISView.IsNull () ) {
709 di << "You must initialize AISViewer before this command." << "\n";
710 return 1;
711 }
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);
730 return 0;
731}
732
733static Standard_Integer QAAISGetColorCoord (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
734{
735#if ! defined(WNT)
736 if ( argc > 2 ) {
737 di << "Usage : " << argv[0] << " [3d|2d]" << "\n";
738 return 1;
739 }
692613e5 740 Handle(Xw_Window) QAAISWindow;
7fd59977 741
742 Standard_Boolean is3d = 1;
743
744 if(argc == 1 || !strcmp(argv[1],"3d")) {
745
746 Handle (V3d_View) QAAIS_MainView = ViewerTest::CurrentView ();
747 if ( QAAIS_MainView.IsNull () ) {
748 di << "You must initialize AISViewer before this command." << "\n";
749 return 1;
750 }
692613e5 751 QAAISWindow = Handle(Xw_Window)::DownCast (QAAIS_MainView->V3d_View::Window());
7fd59977 752 is3d = 1;
753 }
754
755 if(argc == 2 && !strcmp(argv[1],"2d")) {
756 Handle(V2d_View) V = Viewer2dTest::CurrentView();
757 if (V.IsNull()) {
758 di << "You must initialize AIS 2D Viewer before this command." << "\n";
759 return 1;
760 }
692613e5 761 QAAISWindow = Handle(Xw_Window)::DownCast (V->Driver()->Window());
7fd59977 762 is3d = 0;
763 }
764
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"));
769
770 Draw_Window QAAIS_CoordWindow ("coordinate", 421, 205, 200, 60);
771 QAAIS_CoordWindow.DisplayWindow ();
772 QAAIS_CoordWindow.SetColor (12);
773
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 ();
781
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;
692613e5 798 Image_PixMap anImage;
7fd59977 799 if(is3d)
800 {
801 ViewerTest::GetMousePosition (QAAIS_MousePoint_X, QAAIS_MousePoint_Y);
802 Handle (V3d_View) QAAIS_MainView = ViewerTest::CurrentView();
692613e5 803 QAAIS_MainView->ToPixMap (anImage, QAAIS_WindowSize_X, QAAIS_WindowSize_Y);
7fd59977 804 }
805 else
806 {
807 Viewer2dTest::GetMousePosition (QAAIS_MousePoint_X, QAAIS_MousePoint_Y);
692613e5 808 QAAISWindow->ToPixMap (anImage);
7fd59977 809 }
692613e5 810 aSeq = GetColorOfPixel (anImage, QAAIS_MousePoint_X, QAAIS_MousePoint_Y, 0);
811
7fd59977 812 QAAIS_ColorRED = aSeq->Value(1);
813 QAAIS_ColorGRN = aSeq->Value(2);
814 QAAIS_ColorBLU = aSeq->Value(3);
815 QAAIS_ShowingColor.SetValues (QAAIS_ColorRED, QAAIS_ColorGRN, QAAIS_ColorBLU, Quantity_TOC_RGB);
816 QAAIS_ColorView -> SetBackgroundColor (QAAIS_ShowingColor);
817 QAAIS_ColorView -> Redraw ();
818 QAAIS_CoordWindow.Clear();
819 sprintf (QAAIS_MousePointX, "X : %d", QAAIS_MousePoint_X);
820 sprintf (QAAIS_MousePointY, "Y : %d", QAAIS_MousePoint_Y);
821 QAAIS_CoordWindow.DrawString (30, 35, QAAIS_MousePointX);
822 QAAIS_CoordWindow.DrawString (125, 35, QAAIS_MousePointY);
823 }
824 QAAIS_CoordWindow.Destroy ();
825#endif //WNT
826 return 0;
827}
828
829//==============================================================================
830// VIEWER GLOBALs
831//==============================================================================
832#if ! defined(WNT)
833extern int V2dPickGrid (Draw_Interpretor& , Standard_Integer argc, const char ** argv);
834#else
835Standard_EXPORT int V2dPickGrid (Draw_Interpretor& , Standard_Integer argc, const char ** argv);
836#endif
837//==============================================================================
838//function : V2dSetHighlightMode
839//purpose : QAv2dSetHighlightMode mode
840//==============================================================================
841static int V2dSetHighlightMode (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
842{
843 if (argc != 2)
844 {
845 di << "Usage: QAv2dSetHighlightMode mode" << "\n";
846 return 1;
847 }
848
849 Viewer2dTest::StandardModeActivation(atoi(argv[1]));
850 return 0;
851}
852
853#ifndef WNT
854//==============================================================================
855//function : QAAISGetPixelColor2d
856//purpose : QAAISGetPixelColor2d coord_X coord_Y Red Green Blue
857//==============================================================================
858
859static int QAAISGetPixelColor2d (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
860{
861 if (argc != 6 && argc != 3)
862 {
863 di << "Args: coord_X coord_Y [Red Green Blue]" << "\n";
864 return 1;
865 }
866
867 Handle(V2d_View) V = Viewer2dTest::CurrentView();
868 if (V.IsNull())
869 {
870 di << "You must initialize AIS 2D Viewer before this command." << "\n";
871 return 1;
872 }
692613e5 873
7fd59977 874 // Get Color
692613e5 875 #if (defined(_WIN32) || defined(__WIN32__))
876 Handle(WNT_Window) QAAISWindow = Handle(WNT_Window)::DownCast (V->Driver()->Window());
877 #else
878 Handle(Xw_Window) QAAISWindow = Handle(Xw_Window )::DownCast (V->Driver()->Window());
879 #endif
7fd59977 880
881 Standard_ShortReal aCoordinateX = atoi(argv[1]);
882 Standard_ShortReal aCoordinateY = atoi(argv[2]);
883
884 // Get Color
885 Standard_ShortReal aColorRED_V = 0;
886 Standard_ShortReal aColorGRN_V = 0;
887 Standard_ShortReal aColorBLU_V = 0;
888
889 if ( argc == 6 ) {
890 aColorRED_V = atof (argv [3]);
891 aColorGRN_V = atof (argv [4]);
892 aColorBLU_V = atof (argv [5]);
893
894 di << "Begin aColorRED_User = " << aColorRED_V << "\n";
895 di << "Begin aColorGRN_User = " << aColorGRN_V << "\n";
896 di << "Begin aColorBLU_User = " << aColorBLU_V << "\n";
897 }
898
899 Standard_Integer aRadius = 1;
900 if ( argc == 3 ) {
901 aRadius=0;
902 }
903
692613e5 904 Image_PixMap anImage;
905 QAAISWindow->ToPixMap (anImage);
906 Handle(TColStd_HSequenceOfReal) aSeq = GetColorOfPixel (anImage, aCoordinateX, aCoordinateY, aRadius);
7fd59977 907
908 Standard_Boolean IsNotEqual = Standard_True;
909 Standard_Integer i;
910 for(i=1; i<=aSeq->Length();i+=3) {
911 // mkv 29.04.03
912 Standard_ShortReal aColorRED_R = (((Standard_ShortReal) ((Standard_Integer) (aSeq->Value(i+0) * 1000000))) / 1000000.);
913 Standard_ShortReal aColorGRN_R = (((Standard_ShortReal) ((Standard_Integer) (aSeq->Value(i+1) * 1000000))) / 1000000.);
914 Standard_ShortReal aColorBLU_R = (((Standard_ShortReal) ((Standard_Integer) (aSeq->Value(i+2) * 1000000))) / 1000000.);
915 // mkv 29.04.03
916
917 if ( argc == 3 ) {
918 di << "RED : " << aColorRED_R << " GREEN : " << aColorGRN_R << " BLUE : " << aColorBLU_R << "\n";
919 IsNotEqual = Standard_False;
920 break;
921 }
922
923 if ( aColorRED_R == aColorRED_V
924 && aColorGRN_R == aColorGRN_V
925 && aColorBLU_R == aColorBLU_V
926 ) {
927 IsNotEqual = Standard_False;
928 break;
929 }
930 }
931 if (IsNotEqual) {
932 di << "Faulty : colors are not equal." << "\n";
933 return 1;
934 }
935 return 0;
936}
937#endif // !WNT
938
939//==============================================================================
940//function : QAMoveTo2d
941//purpose : QAMoveTo2d x y
942//==============================================================================
943static int QAMoveTo2d (Draw_Interpretor& di, int argc, const char ** argv)
944{
945 if (argc != 3)
946 {
947 di << "Usage : " << argv[0] << " x y" << "\n";
948 return -1;
949 }
950
951 Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext();
952 if (myAIScontext.IsNull())
953 {
954 di << "use 'v2dinit' command before " << argv[0] << "\n";
955 return -1;
956 }
957 Viewer2dTest::CurrentEventManager()->MoveTo
958 (atoi(argv[1]), atoi(argv[2]), Viewer2dTest::CurrentView());
959 return 0;
960}
961
962//==============================================================================
963//function : QASelect2d
964//purpose : QASelect2d x y
965//==============================================================================
966static int QASelect2d (Draw_Interpretor& di, int argc, const char ** argv)
967{
968 if (argc != 3)
969 {
970 di << "Usage : " << argv[0] << " x y" << "\n";
971 return -1;
972 }
973
974 Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext();
975 if (myAIScontext.IsNull())
976 {
977 di << "use 'v2dinit' command before " << argv[0] << "\n";
978 return -1;
979 }
980 Viewer2dTest::CurrentEventManager()->MoveTo
981 (atoi(argv[1]), atoi(argv[2]), Viewer2dTest::CurrentView());
982 Viewer2dTest::CurrentEventManager()->Select();
983 return 0;
984}
985
986//==============================================================================
987//function : QAShiftSelect2d
988//purpose : QAShiftSelect2d x y
989//==============================================================================
990static int QAShiftSelect2d (Draw_Interpretor& di, int argc, const char ** argv)
991{
992 if (argc != 3)
993 {
994 di << "Usage : " << argv[0] << " x y" << "\n";
995 return -1;
996 }
997
998 Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext();
999 if (myAIScontext.IsNull())
1000 {
1001 di << "use 'v2dinit' command before " << argv[0] << "\n";
1002 return -1;
1003 }
1004 Viewer2dTest::CurrentEventManager()->MoveTo
1005 (atoi(argv[1]), atoi(argv[2]), Viewer2dTest::CurrentView());
1006 Viewer2dTest::CurrentEventManager()->ShiftSelect();
1007 return 0;
1008}
1009
1010//==============================================================================
1011//function : V2dZoom
1012//purpose : QAv2dzoom zoom_factor
1013//==============================================================================
1014static int V2dZoom (Draw_Interpretor& di, int argc, const char ** argv)
1015{
1016 if (argc != 2)
1017 {
1018 di << "Usage : " << argv[0] << " zoom_factor" << "\n";
1019 return -1;
1020 }
1021
1022 Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext();
1023 if (myAIScontext.IsNull())
1024 {
1025 di << "use 'v2dinit' command before " << argv[0] << "\n";
1026 return -1;
1027 }
1028 Viewer2dTest::CurrentView()->Zoom(atof(argv[1]));
1029 return 0;
1030}
1031
1032//==============================================================================
1033//function : V2dPan
1034//purpose : QAv2dpan dx dy
1035//==============================================================================
1036static int V2dPan (Draw_Interpretor& di, int argc, const char ** argv)
1037{
1038 if (argc != 3)
1039 {
1040 di << "Usage : " << argv[0] << " dx dy" << "\n";
1041 return -1;
1042 }
1043
1044 Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext();
1045 if (myAIScontext.IsNull())
1046 {
1047 di << "use 'v2dinit' command before " << argv[0] << "\n";
1048 return -1;
1049 }
692613e5 1050 Viewer2dTest::CurrentView()->Pan(atoi(argv[1]), atoi(argv[2]));
7fd59977 1051 return 0;
1052}
1053
1054//==============================================================================
1055//function : V2dGetViewCharac
1056//purpose : v2dGetViewCharac
1057//==============================================================================
1058static int V2dGetViewCharac (Draw_Interpretor& di, int si, const char ** /*sc*/)
1059{
1060 if (si != 1)
1061 {
1062 di << "Use - v2dGetViewCharac" << "\n";
1063 return 1;
1064 }
1065
1066 Handle(V2d_View) V = Viewer2dTest::CurrentView();
1067 if (V.IsNull())
1068 {
1069 di << "You must initialize AIS 2D Viewer before this command." << "\n";
1070 return 1;
1071 }
1072
1073// Quantity_Factor aViewScale = V->Scale();
1074
1075 Standard_Real aCenterCoordX = 0.0;
1076 Standard_Real aCenterCoordY = 0.0;
1077 V->Center(aCenterCoordX, aCenterCoordY);
1078
1079 Standard_Real aViewProjX = 0.0;
1080 Standard_Real aViewProjY = 0.0;
1081 Standard_Real aViewProjZ = 0.0;
1082// V->Proj(aViewProjX, aViewProjY, aViewProjZ);
1083
1084 Standard_Real aViewUpX = 0.0;
1085 Standard_Real aViewUpY = 0.0;
1086 Standard_Real aViewUpZ = 0.0;
1087// V->Up(aViewUpX, aViewUpY, aViewUpZ);
1088
1089 Standard_Real aViewAtX = 0.0;
1090 Standard_Real aViewAtY = 0.0;
1091 Standard_Real aViewAtZ = 0.0;
1092// V->At(aViewAtX, aViewAtY, aViewAtZ);
1093
1094// cout << "Scale of current view: " << aViewScale << endl;
1095// cout << "Center on X : "<< aViewCenterCoordX << "; on Y: " << aViewCenterCoordY << endl;
1096// cout << "Proj on X : " << aViewProjX << "; on Y: " << aViewProjY << "; on Z: " << aViewProjZ << endl;
1097// cout << "Up on X : " << aViewUpX << "; on Y: " << aViewUpY << "; on Z: " << aViewUpZ << endl;
1098// cout << "At on X : " << aViewAtX << "; on Y: " << aViewAtY << "; on Z: " << aViewAtZ << endl;
1099
1100// cout << aViewScale << " " << aViewCenterCoordX << " " << aViewCenterCoordY << " ";
1101 di << aViewProjX << " " << aViewProjY << " " << aViewProjZ << " ";
1102 di << aViewUpX << " " << aViewUpY << " " << aViewUpZ << " ";
1103 di << aViewAtX << " " << aViewAtY << " " << aViewAtZ << "\n";
1104 return 0;
1105}
1106
1107//==============================================================================
1108//function : V2dSetViewCharac
1109//purpose : v2dSetViewCharac
1110//==============================================================================
1111static int V2dSetViewCharac (Draw_Interpretor& di, int si, const char ** sc)
1112{
1113 if (si != 13)
1114 {
1115 di << "Use - v2dSetViewCharac scale center(X Y) proj(X Y Z) up(X Y Z) at(X Y Z)" << "\n";
1116 return 1;
1117 }
1118
1119 Handle(V2d_View) V = Viewer2dTest::CurrentView();
1120 if (V.IsNull())
1121 {
1122 di << "You must initialize AIS 2D Viewer before this command." << "\n";
1123 return 1;
1124 }
1125
1126 Quantity_Factor aViewScale = atof(sc[1]);
1127
1128 Standard_Real aViewCenterCoordX = atof(sc[2]);
1129 Standard_Real aViewCenterCoordY = atof(sc[3]);
1130
1131 Standard_Real aViewProjX = atof(sc[4]);
1132 Standard_Real aViewProjY = atof(sc[5]);
1133 Standard_Real aViewProjZ = atof(sc[6]);
1134
1135 Standard_Real aViewUpX = atof(sc[7]);
1136 Standard_Real aViewUpY = atof(sc[8]);
1137 Standard_Real aViewUpZ = atof(sc[9]);
1138
1139 Standard_Real aViewAtX = atof(sc[10]);
1140 Standard_Real aViewAtY = atof(sc[11]);
1141 Standard_Real aViewAtZ = atof(sc[12]);
1142
1143// V->SetScale(aViewScale);
1144// V->SetCenter(aViewCenterCoordX, aViewCenterCoordY);
1145// V->SetAt(aViewAtX, aViewAtY, aViewAtZ);
1146// V->SetProj(aViewProjX, aViewProjY, aViewProjZ);
1147// V->SetUp(aViewUpX, aViewUpY, aViewUpZ);
1148// V->SetProj(aViewProjX, aViewProjY, aViewProjZ);
1149 return 0;
1150}
1151
1152//=======================================================================
1153//function : QAxwd_2d
1154//purpose :
1155//=======================================================================
1156static int QAxwd_2d (Draw_Interpretor& di, int argc, const char ** argv)
1157{
1158 if (argc != 2)
1159 {
1160 di << "Usage : " << argv[0] << " filename" << "\n";
1161 return -1;
1162 }
1163
1164 Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext();
1165 if (myAIScontext.IsNull())
1166 {
1167 di << "use 'v2dinit' command before " << argv[0] << "\n";
1168 return -1;
1169 }
1170 Handle(V2d_View) V = Viewer2dTest::CurrentView();
1171 V->Dump(argv[1]);
1172 return 0;
1173}
1174
1175#ifndef WNT
1176extern Draw_Viewer dout;
1177extern XW_STATUS Xw_save_image_adv (Display *aDisplay,Window aWindow,XWindowAttributes aWinAttr,XImage *aPximage,Colormap aColormap,int aNcolors,char *filename);
1178extern Display* Draw_WindowDisplay;
1179extern Colormap Draw_WindowColorMap;
1180#else
1181Standard_IMPORT Draw_Viewer dout;
1182int __WNT_API SaveWindowToFile (Handle( WNT_GraphicDevice )& gDev,
1183 HWND hWnd, char* fName, int x, int y, int w, int h);
1184#endif
1185
1186//=======================================================================
1187//function : QAxwd
1188//purpose :
1189//=======================================================================
1190static int QAxwd (Draw_Interpretor& di, int argc, const char ** argv)
1191{
1192 if (argc < 2)
1193 {
1194 di << "Usage : " << argv[0] << " [id=1] filename" << "\n";
1195 return -1;
1196 }
1197
1198 // enforce repaint if necessary
1199 Standard_Integer id = 1;
1200 const char* file = argv[1];
1201 if (argc > 2) {
1202 id = atoi(argv[1]);
1203 file = argv[2];
1204 }
1205
1206 after(id);
1207
1208 dout.Flush();
1209 if(dout.HasView(id)) {
1210#if defined (WNT)
1211 Handle(WNT_GraphicDevice) aGd = new WNT_GraphicDevice(Standard_False);
1212 RECT rc;
1213 GetClientRect((HWND)dout.GetWindow(id), &rc);
1214 SaveWindowToFile(aGd,(HWND)dout.GetWindow(id),(char*)file,rc.left, rc.top,rc.right-rc.left, rc.bottom-rc.top);
1215#else
1216 XSync(Draw_WindowDisplay,True);
1217
1218 XWindowAttributes winAttr;
1219 XGetWindowAttributes (Draw_WindowDisplay, dout.GetWindow(id), &winAttr);
1220
1221 XImage *pximage = XGetImage(Draw_WindowDisplay,dout.GetWindow(id),
1222 0,0,winAttr.width,winAttr.height,
1223 AllPlanes,ZPixmap);
1224
1225 Xw_save_image_adv(Draw_WindowDisplay,dout.GetWindow(id),winAttr,pximage,Draw_WindowColorMap,256,(char*)file);
1226#endif
1227 }
1228
1229 return 0;
1230}
1231
1232//=======================================================================
1233//function : QA2dGetIndexes
1234//purpose :
1235//=======================================================================
1236static int QA2dGetIndexes (Draw_Interpretor& di, int /*argc*/, const char ** argv)
1237{
1238 Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext();
1239 if (myAIScontext.IsNull())
1240 {
1241 di << "use 'v2dinit' command before " << argv[0] << "\n";
1242 return -1;
1243 }
1244 Handle(Aspect_WindowDriver) aWindowDriver = Viewer2dTest::CurrentView()->Driver();
1245
1246 Standard_Integer aFontMin, aFontMax, aColorMin, aColorMax;
1247 aWindowDriver->FontBoundIndexs(aFontMin, aFontMax);
1248 di << "Available font indexes are " << aFontMin << " - " << aFontMax << "\n";
1249 aWindowDriver->ColorBoundIndexs(aColorMin, aColorMax);
1250 di << "Available color indexes are " << aColorMin << " - " << aColorMax << "\n";
692613e5 1251 return 0;
7fd59977 1252}
1253
1254#if ! defined(WNT)
1255extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
1256extern Handle(AIS_InteractiveContext)& TheAISContext();
1257#else
1258Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
1259Standard_EXPORT Handle(AIS_InteractiveContext)& TheAISContext();
1260#endif
1261#include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
1262#include <AIS_Trihedron.hxx>
1263#include <AIS_Axis.hxx>
1264#include <Geom_Line.hxx>
1265#include <AIS_Line.hxx>
1266
1267//==============================================================================
1268// function : VTrihedronOrigins
1269// author : ota
1270// purpose : draws triheron axis origin lines.
1271// Draw arg : vtri_orig trihedron_name
1272//==============================================================================
1273static int VTrihedronOrigins(Draw_Interpretor& di,
1274 Standard_Integer argc,
1275 const char ** argv)
1276{
1277 if(argc != 2){
1278 di <<"Usage : vtri_orig tri_name"<<"\n";
1279 return 1;
1280 }
1281
1282 if(TheAISContext().IsNull()){
1283 di<<"Make 'vinit' before this method call"<<"\n";
1284 return 1;
1285 }
1286
1287 //get trihedron from AIS map.
1288 TCollection_AsciiString aName(argv[1]);
1289 if(!GetMapOfAIS().IsBound2(aName)){
1290 di<<"No object named '"<<argv[1]<<"'"<<"\n";
1291 return 1;
1292 }
1293
1294 Handle(AIS_Trihedron) aTrih =
1295 Handle(AIS_Trihedron)::DownCast(GetMapOfAIS().Find2(aName));
1296 if(aTrih.IsNull()){
1297 di<<"Trihedron is not found, try another name"<<"\n";
1298 return 1;
1299 }
1300
1301 //get axis
1302 Handle(AIS_Axis) XAxis = aTrih->XAxis();
1303 Handle(AIS_Axis) YAxis = aTrih->YAxis();
1304 Handle(AIS_Axis) ZAxis = aTrih->Axis();
1305
1306 //get geometrical lines
1307 Handle(Geom_Line) XGLine = XAxis->Component();
1308 Handle(Geom_Line) YGLine = YAxis->Component();
1309 Handle(Geom_Line) ZGLine = ZAxis->Component();
1310
1311 //make AIS_Lines
1312 Handle(AIS_Line) XLine = new AIS_Line(XGLine);
1313 Handle(AIS_Line) YLine = new AIS_Line(YGLine);
1314 Handle(AIS_Line) ZLine = new AIS_Line(ZGLine);
1315
1316 //put them into AIS map:
1317 GetMapOfAIS().Bind(XLine,aName+"_X");
1318 GetMapOfAIS().Bind(YLine,aName+"_Y");
1319 GetMapOfAIS().Bind(ZLine,aName+"_Z");
1320 //print names of created objects:
1321 di<<argv[1]<<"_X "<<argv[1]<<"_Y "<<argv[1]<<"_Z"<<"\n";
1322
1323 //try to draw them:
1324 TheAISContext()->Display(XLine);
1325 TheAISContext()->Display(YLine);
1326 TheAISContext()->Display(ZLine);
1327
1328 return 0;
1329}
1330
1331//=======================================================================
1332//function : QAAddOrRemoveSelected
1333//purpose :
1334//=======================================================================
1335static Standard_Integer QAAddOrRemoveSelected (Draw_Interpretor& di, Standard_Integer n, const char ** a)
1336{
1337 if( n != 2)
1338 {
1339 di<<"Usage : QAAddOrRemoveSelected shape \n";
1340 return 1;
1341 }
1342 //get AIS_Shape:
1343 Handle(AIS_InteractiveContext) anAISCtx = ViewerTest::GetAISContext();
1344
1345 //ViewerTest_DoubleMapOfInteractiveAndName& aMap =
1346 // ViewerTest::GetDataMapOfAIS ();
1347 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
1348
1349 TCollection_AsciiString aName(a[1]);
1350 Handle(AIS_InteractiveObject) AISObj;
1351
1352 if(aMap.IsBound2(aName)){
1353 AISObj = Handle(AIS_InteractiveObject)::DownCast(aMap.Find2(aName));
1354 if(AISObj.IsNull()){
1355 di<<"No interactive object \n";
1356 return 1;
1357 }
1358
1359 if(anAISCtx->HasOpenedContext()){
1360 anAISCtx->InitSelected();
1361 anAISCtx->AddOrRemoveSelected(AISObj);
1362 }
1363 else {
1364 anAISCtx->InitCurrent();
1365 anAISCtx->AddOrRemoveCurrentObject(AISObj);
1366 }
1367 return 0;
1368 }
1369 //select this shape:
1370 else {
1371 di<<"Use 'vdisplay' before";
1372 return 1;
1373 }
1374}
1375
1376//=======================================================================
1377//function : QASetZClippingMode
1378//purpose :
1379//=======================================================================
1380static Standard_Integer QASetZClippingMode (Draw_Interpretor& di, int argc, const char ** argv)
1381{
1382 if (argc != 2) {
1383 di << "Usage : " << argv[0] << " mode(OFF/BACK/FRONT/SLICE)" << "\n";
1384 return -1;
1385 }
1386
1387 Handle(AIS_InteractiveContext) AIScontext = ViewerTest::GetAISContext();
1388 if(AIScontext.IsNull()) {
1389 di << "use 'vinit' command before " << argv[0] << "\n";
1390 return -1;
1391 }
1392
1393 Standard_Integer aStatus = 0;
1394 V3d_TypeOfZclipping ZClippingMode;
1395 if ( strcmp (argv [1], "OFF") == 0 ) {
1396 aStatus = 1;
1397 ZClippingMode = V3d_OFF;
1398 }
1399 if ( strcmp (argv [1], "BACK") == 0 ) {
1400 aStatus = 1;
1401 ZClippingMode = V3d_BACK;
1402 }
1403 if ( strcmp (argv [1], "FRONT") == 0 ) {
1404 aStatus = 1;
1405 ZClippingMode = V3d_FRONT;
1406 }
1407 if ( strcmp (argv [1], "SLICE") == 0 ) {
1408 aStatus = 1;
1409 ZClippingMode = V3d_SLICE;
1410 }
1411 if (aStatus != 1)
1412 {
1413 di << "Bad mode; Usage : " << argv[0] << " mode(OFF/BACK/FRONT/SLICE)" << "\n";
1414 return -1;
1415 }
1416
1417 Handle(V3d_View) aView = ViewerTest::CurrentView();
1418 aView->SetZClippingType(ZClippingMode);
1419 aView->Redraw();
1420
1421 return 0;
1422}
1423
1424//=======================================================================
1425//function : QAGetZClippingMode
1426//purpose :
1427//=======================================================================
1428static Standard_Integer QAGetZClippingMode (Draw_Interpretor& di, int /*argc*/, const char ** argv)
1429{
1430 Handle(AIS_InteractiveContext) AIScontext = ViewerTest::GetAISContext();
1431 if(AIScontext.IsNull()) {
1432 di << "use 'vinit' command before " << argv[0] << "\n";
1433 return -1;
1434 }
1435
1436 Handle(V3d_View) aView = ViewerTest::CurrentView();
1437 TCollection_AsciiString ZClippingModeString;
1438 Quantity_Length Depth, Width;
1439 V3d_TypeOfZclipping ZClippingMode = aView->ZClipping(Depth, Width);
1440 switch (ZClippingMode)
1441 {
1442 case V3d_OFF:
1443 ZClippingModeString.Copy("OFF");
1444 break;
1445 case V3d_BACK:
1446 ZClippingModeString.Copy("BACK");
1447 break;
1448 case V3d_FRONT:
1449 ZClippingModeString.Copy("FRONT");
1450 break;
1451 case V3d_SLICE:
1452 ZClippingModeString.Copy("SLICE");
1453 break;
1454 default:
1455 ZClippingModeString.Copy(TCollection_AsciiString(ZClippingMode));
1456 break;
1457 }
1458 di << "ZClippingMode = " << ZClippingModeString.ToCString() << "\n";
1459
1460 return 0;
1461}
1462
1463#include <V2d_View.hxx>
1464#include <AIS2D_InteractiveObject.hxx>
1465#include <Graphic2d_Circle.hxx>
1466#include <Graphic2d_TypeOfPolygonFilling.hxx>
1467#include <V2d_Viewer.hxx>
1468#include <Viewer2dTest_DoubleMapOfInteractiveAndName.hxx>
1469
1470#if ! defined(WNT)
1471extern Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
1472#else
1473Standard_EXPORT Viewer2dTest_DoubleMapOfInteractiveAndName& GetMapOfAIS2D();
1474#endif
1475
1476//=======================================================================
1477//function : QAv2dcircle
1478//purpose :
1479//=======================================================================
1480static Standard_Integer QAv2dcircle (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1481{
1482 Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1483 if(aContext.IsNull()) {
1484 di << "ERROR: Use 'v2dinit' command before " << argv[0] << "\n";
1485 return -1;
1486 }
1487 if(argc < 7){
1488 di<<"Usage : " << argv[0] << " CircleName X Y Radius Alpha Beta [Color_index]\n";
1489 return -1;
1490 }
1491 Handle(V2d_View) V = Viewer2dTest::CurrentView();
1492
1493 TCollection_AsciiString name = argv[1];
1494 Standard_Real x = atof(argv[2]);
1495 Standard_Real y = atof(argv[3]);
1496 Standard_Real radius = atof(argv[4]);
1497 Standard_Real alpha = atof(argv[5]);
1498 Standard_Real beta = atof(argv[6]);
1499
1500 if (GetMapOfAIS2D().IsBound2(name)) {
1501 di << "There is already an object with name " << name.ToCString() << "\n";
1502 return -1;
1503 }
1504 Handle(AIS2D_InteractiveObject) aisobj = new AIS2D_InteractiveObject();
1505 aisobj->SetView(V->View());
1506 Handle(Graphic2d_Circle) circle = new Graphic2d_Circle(aisobj,x,y,radius,alpha,beta);
1507 if(argc > 7){
1508 Standard_Integer color_index = atoi(argv[7]);
1509 circle->SetTypeOfPolygonFilling(Graphic2d_TOPF_FILLED);
1510 circle->SetInteriorColorIndex(color_index);
1511 }
1512 GetMapOfAIS2D().Bind(aisobj, name);
1513 aisobj->Display();
1514 V->Viewer()->Update();
1515 return 0;
1516}
1517
1518#include <Draw_Viewer.hxx>
1519#include <Draw.hxx>
1520
1521#ifndef WNT
1522extern Draw_Viewer dout;
1523#else
1524Standard_IMPORT Draw_Viewer dout;
1525#endif
1526
1527static Standard_Integer ViewId(const Standard_CString a)
1528{
1529 Standard_Integer id = atoi(a);
1530 if ((id < 0) || (id >= MAXVIEW)) {
1531 cout << "Incorrect view-id, must be in 0.."<<MAXVIEW-1<<endl;
1532 return -1;
1533 }
1534 if (!dout.HasView(id)) {
1535 cout <<"View "<<id<<" does not exist."<<endl;
1536 return -1;
1537 }
1538 return id;
1539}
1540
1541//=======================================================================
1542//function : QAwzoom
1543//purpose :
1544//=======================================================================
1545
1546static Standard_Integer QAwzoom(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) {
1547 if(argc < 6){
1548 di<<"Usage : " << argv[0] << " view-id X1 Y1 X2 Y2\n";
1549 return -1;
1550 }
1551
1552 Standard_Integer id = ViewId(argv [1]);
1553 if (id < 0) {
1554 return -1;
1555 }
1556
1557 Standard_Integer X1 = atoi (argv [2]);
1558 Standard_Integer Y1 = atoi (argv [3]);
1559 Standard_Integer X2 = atoi (argv [4]);
1560 Standard_Integer Y2 = atoi (argv [5]);
1561
1562 Standard_Real zx,zy;
1563
1564 Standard_Integer X,Y,W,H;
1565 dout.GetPosSize(id,X,Y,W,H);
1566
1567 if ((X1 == X2) || (Y1 == Y2)) return 0;
1568
1569 zx = (Standard_Real) Abs(X2-X1) / (Standard_Real) W;
1570 zy = (Standard_Real) Abs(Y2-Y1) / (Standard_Real) H;
1571 if (zy > zx) zx = zy;
1572 zx = 1/zx;
1573 if (X2 < X1) X1 = X2;
1574 if (Y2 > Y1) Y1 = Y2;
1575 X1 = (Standard_Integer ) (X1*zx);
1576 Y1 = (Standard_Integer ) (Y1*zx);
1577 dout.SetZoom(id,zx*dout.Zoom(id));
1578 dout.SetPan(id,-X1,-Y1);
1579 dout.RepaintView(id);
1580 if (dout.HasView(id)) {
1581 char title[255];
1582 sprintf(title,"%d : %s - Zoom %f",id,dout.GetType(id),dout.Zoom(id));
1583 dout.SetTitle(id,title);
1584 }
1585 return 0;
1586}
1587
1588#include <Draw_Display.hxx>
1589
1590//=======================================================================
1591//function : QAGetCoordinatesWzoom
1592//purpose :
1593//=======================================================================
1594
1595static Standard_Integer QAGetCoordinatesWzoom(Draw_Interpretor& di, Standard_Integer, const char **)
1596{
1597 Standard_Integer id1,X1,Y1,b;
1598 Standard_Integer X2,Y2;
1599 Standard_Real dX1,dY1,dX2,dY2;
1600 di << "Pick first corner"<<"\n";
1601 dout.Select(id1,X1,Y1,b);
1602
1603 gp_Trsf T;
1604 gp_Pnt P0(0,0,0);
1605 dout.GetTrsf(id1,T);
1606 T.Invert();
1607 P0.Transform(T);
1608 Standard_Real z = dout.Zoom(id1);
1609
1610 dX1=X1; dY1=Y1;
1611 dX1-=P0.X(); dY1-=P0.Y();
1612 dX1/=z; dY1/=z;
1613
1614 if (b != 1) return 0;
1615 if (id1 < 0) return 0;
1616 Draw_Display d = dout.MakeDisplay(id1);
1617 d.SetColor(Draw_blanc);
1618 d.SetMode(10);
1619 Standard_Real dOX2 = dX1;
1620 Standard_Real dOY2 = dY1;
1621 d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dOY2));
1622 d.Draw(gp_Pnt2d(dX1,dOY2),gp_Pnt2d(dOX2,dOY2));
1623 d.Draw(gp_Pnt2d(dOX2,dOY2),gp_Pnt2d(dOX2,dY1));
1624 d.Draw(gp_Pnt2d(dOX2,dY1),gp_Pnt2d(dX1,dY1));
1625 d.Flush();
1626 Standard_Real zx,zy;
1627 Standard_Integer X,Y,W,H;
1628 dout.GetPosSize(id1,X,Y,W,H);
1629 di << "Pick second corner"<<"\n";
1630 b = 0;
1631 while (b == 0) {
1632 dout.Select(id1,X2,Y2,b,Standard_False);
1633 dX2=X2; dY2=Y2;
1634 dX2-=P0.X(); dY2-=P0.Y();
1635 dX2/=z; dY2/=z;
1636
1637 d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dOY2));
1638 d.Draw(gp_Pnt2d(dX1,dOY2),gp_Pnt2d(dOX2,dOY2));
1639 d.Draw(gp_Pnt2d(dOX2,dOY2),gp_Pnt2d(dOX2,dY1));
1640 d.Draw(gp_Pnt2d(dOX2,dY1),gp_Pnt2d(dX1,dY1));
1641 d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dY2));
1642 d.Draw(gp_Pnt2d(dX1,dY2),gp_Pnt2d(dX2,dY2));
1643 d.Draw(gp_Pnt2d(dX2,dY2),gp_Pnt2d(dX2,dY1));
1644 d.Draw(gp_Pnt2d(dX2,dY1),gp_Pnt2d(dX1,dY1));
1645 d.Flush();
1646 dOX2 = dX2;
1647 dOY2 = dY2;
1648 }
1649 d.Draw(gp_Pnt2d(dX1,dY1),gp_Pnt2d(dX1,dOY2));
1650 d.Draw(gp_Pnt2d(dX1,dOY2),gp_Pnt2d(dOX2,dOY2));
1651 d.Draw(gp_Pnt2d(dOX2,dOY2),gp_Pnt2d(dOX2,dY1));
1652 d.Draw(gp_Pnt2d(dOX2,dY1),gp_Pnt2d(dX1,dY1));
1653 d.Flush();
1654 if (b != 1) return 0;
1655
1656 if ((X1 == X2) || (Y1 == Y2)) return 0;
1657
1658 di << "X1=" << X1 << " Y1=" << Y1 <<"\n";
1659 di << "X2=" << X2 << " Y2=" << Y2 <<"\n";
1660
1661 zx = (Standard_Real) Abs(X2-X1) / (Standard_Real) W;
1662 zy = (Standard_Real) Abs(Y2-Y1) / (Standard_Real) H;
1663 if (zy > zx) zx = zy;
1664 zx = 1/zx;
1665 if (X2 < X1) X1 = X2;
1666 if (Y2 > Y1) Y1 = Y2;
1667 X1 = (Standard_Integer ) (X1*zx);
1668 Y1 = (Standard_Integer ) (Y1*zx);
1669 dout.SetZoom(id1,zx*dout.Zoom(id1));
1670 dout.SetPan(id1,-X1,-Y1);
1671 dout.RepaintView(id1);
1672 //SetTitle(id1);
1673 char title[255];
1674 sprintf(title,"%d : %s - Zoom %f",id1,dout.GetType(id1),dout.Zoom(id1));
1675 dout.SetTitle(id1,title);
1676 return 0;
1677}
1678
1679//=======================================================================
1680// QArename
1681//=======================================================================
1682
1683static Standard_Integer QArename(Draw_Interpretor& di, Standard_Integer n, const char** a)
1684{
1685 if (n < 3) return 1;
1686 Standard_Boolean cop = !strcasecmp(a[0],"copy");
1687
1688 Handle(Draw_Drawable3D) D;
1689 for (Standard_Integer i = 1; i < n; i += 2) {
1690 if (i+1 >= n) return 0;
1691 D = Draw::Get(a[i]);
1692 if (!D.IsNull()) {
1693 if (cop)
1694 D = D->Copy();
1695 else
1696 // clear old name
1697 Draw::Set(a[i],Handle(Draw_Drawable3D()));
1698
1699 Draw::Set(a[i+1],D);
1700 }
1701 }
1702 return 0;
1703}
1704
1705static Standard_Integer QANbSelected (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1706{
1707 if(argc != 1) {
1708 di << "Usage : " << argv[0] << "\n";
1709 return 1;
1710 }
1711 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1712 if(aContext.IsNull()) {
1713 di << "use 'vinit' command before " << argv[0] << "\n";
1714 return 1;
1715 }
1716 di << aContext->NbSelected() << "\n";
1717 return 0;
1718}
1719
1720//#if defined(V2D)
1721//#include <AIS2D_InteractiveContext.hxx>
1722//static Standard_Integer QANbSelected2d (Draw_Interpretor& /*di*/, Standard_Integer argc, char** argv)
1723//{
1724// if(argc != 1) {
1725// cout << "Usage : " << argv[0] << endl;
1726// return 1;
1727// }
1728// Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
1729// if(aContext.IsNull()) {
1730// cerr << "use 'v2dinit' command before " << argv[0] << endl;
1731// return 1;
1732// }
1733// cout << aContext->NbSelected() << endl;
1734// return 0;
1735//}
1736//#endif
1737
1738static Standard_Integer QAPurgeDisplay (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1739{
1740 if (argc > 2) {
1741 di << "Usage : " << argv[0] << " [CollectorToo=0/1]" << "\n";
1742 return 1;
1743 }
1744 Standard_Boolean CollectorTooBoolean = Standard_False;
1745 if (argc == 2) {
1746 Standard_Integer CollectorTooInteger = atoi (argv [1]);
1747 if (CollectorTooInteger != 0)
1748 CollectorTooBoolean = Standard_True;
1749 }
1750 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1751 if (aContext.IsNull()) {
1752 di << "use 'vinit' command before " << argv[0] << "\n";
1753 return 1;
1754 }
1755 aContext->CloseAllContexts(Standard_False);
1756 di << aContext->PurgeDisplay(CollectorTooBoolean) << "\n";
1757 return 0;
1758}
1759
1760static Standard_Integer QACloseLocalContext (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1761{
1762 if (argc > 3) {
1763 di << "Usage : " << argv[0] << " [Index [updateviewer=1/0]]" << "\n";
1764 return 1;
1765 }
1766 Standard_Integer Index = -1;
1767 if (argc > 1) {
1768 Index = atoi (argv [1]);
1769 }
1770 //cout << "Index = " << Index << endl;
1771 Standard_Boolean updateviewerBoolean = Standard_True;
1772 if (argc == 3) {
1773 Standard_Integer updateviewerInteger = atoi (argv [2]);
1774 if (updateviewerInteger == 0)
1775 updateviewerBoolean = Standard_False;
1776 }
1777 //if (updateviewerBoolean)
1778 // cout << "updateviewer = Standard_True" << endl;
1779 //else
1780 // cout << "updateviewer = Standard_False" << endl;
1781 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1782 if (aContext.IsNull()) {
1783 di << "use 'vinit' command before " << argv[0] << "\n";
1784 return 1;
1785 }
1786 aContext->CloseLocalContext(Index, updateviewerBoolean);
1787 return 0;
1788}
1789
1790static Standard_Integer QACloseAllContexts (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1791{
1792 if (argc > 2) {
1793 di << "Usage : " << argv[0] << " [updateviewer=1/0]" << "\n";
1794 return 1;
1795 }
1796 Standard_Boolean updateviewerBoolean = Standard_True;
1797 if (argc == 2) {
1798 Standard_Integer updateviewerInteger = atoi (argv [1]);
1799 if (updateviewerInteger == 0)
1800 updateviewerBoolean = Standard_False;
1801 }
1802 //if (updateviewerBoolean)
1803 // cout << "updateviewer = Standard_True" << endl;
1804 //else
1805 // cout << "updateviewer = Standard_False" << endl;
1806 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1807 if (aContext.IsNull()) {
1808 di << "use 'vinit' command before " << argv[0] << "\n";
1809 return 1;
1810 }
1811 aContext->CloseAllContexts(updateviewerBoolean);
1812 return 0;
1813}
1814
1815static Standard_Integer QAIndexOfCurrentLocal (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1816{
1817 if (argc > 1) {
1818 di << "Usage : " << argv[0] << "\n";
1819 return 1;
1820 }
1821 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1822 if (aContext.IsNull()) {
1823 di << "use 'vinit' command before " << argv[0] << "\n";
1824 return 1;
1825 }
1826 di << aContext->IndexOfCurrentLocal() << "\n";
1827 return 0;
1828}
1829
1830#include <AIS_ListOfInteractive.hxx>
1831static Standard_Integer QADisplayedObjects (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1832{
1833 if (argc > 2) {
1834 di << "Usage : " << argv[0] << " [OnlyFromNeutral=0/1]" << "\n";
1835 return 1;
1836 }
1837
1838 Standard_Boolean OnlyFromNeutralBoolean = Standard_False;
1839 if (argc == 2) {
1840 Standard_Integer OnlyFromNeutralInteger = atoi (argv [1]);
1841 if (OnlyFromNeutralInteger != 0)
1842 OnlyFromNeutralBoolean = Standard_True;
1843 }
1844 //if (OnlyFromNeutralBoolean)
1845 // cout << "OnlyFromNeutral = Standard_True" << endl;
1846 //else
1847 // cout << "OnlyFromNeutral = Standard_False" << endl;
1848
1849 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1850 if (aContext.IsNull()) {
1851 di << "use 'vinit' command before " << argv[0] << "\n";
1852 return 1;
1853 }
1854 Standard_Integer ListOfInteractiveExtent = 0;
1855 if(!aContext->HasOpenedContext()) {
1856 ListOfInteractiveExtent = 0;
1857 } else {
1858 AIS_ListOfInteractive ListOfInteractive;
1859 aContext->DisplayedObjects(ListOfInteractive, OnlyFromNeutralBoolean);
1860 ListOfInteractiveExtent = ListOfInteractive.Extent();
1861 }
1862 di << ListOfInteractiveExtent << "\n";
1863 return 0;
1864}
1865
1866static Standard_Integer QASelectRectangle(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
1867{
1868 if(argc != 5) {
1869 di << "Usage : " << argv[0] << " x1 y1 x2 y2" << "\n";
1870 return -1;
1871 }
1872
1873 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
1874 if(myAIScontext.IsNull()) {
1875 di << "use 'vinit' command before " << argv[0] << "\n";
1876 return -1;
1877 }
1878
1879 Standard_Integer x1 = atoi(argv[1]);
1880 Standard_Integer y1 = atoi(argv[2]);
1881 Standard_Integer x2 = atoi(argv[3]);
1882 Standard_Integer y2 = atoi(argv[4]);
1883
1884 Handle(ViewerTest_EventManager) aCurrentEventManager = ViewerTest::CurrentEventManager();
1885// Handle(V3d_View) aCurrentView = ViewerTest::CurrentView();
1886
1887 aCurrentEventManager->MoveTo(x1,y1);
1888 aCurrentEventManager->Select(x1,y1,x2,y2);
1889 aCurrentEventManager->MoveTo(x2,y2);
1890
1891 return 0;
1892}
1893
1894static Standard_Integer QAShiftSelectRectangle(Draw_Interpretor& di, Standard_Integer argc, const char ** argv )
1895{
1896 if(argc != 5) {
1897 di << "Usage : " << argv[0] << " x1 y1 x2 y2" << "\n";
1898 return -1;
1899 }
1900
1901 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
1902 if(myAIScontext.IsNull()) {
1903 di << "use 'vinit' command before " << argv[0] << "\n";
1904 return -1;
1905 }
1906 Standard_Integer x1 = atoi(argv[1]);
1907 Standard_Integer y1 = atoi(argv[2]);
1908 Standard_Integer x2 = atoi(argv[3]);
1909 Standard_Integer y2 = atoi(argv[4]);
1910
1911 Handle(ViewerTest_EventManager) aCurrentEventManager = ViewerTest::CurrentEventManager();
1912// Handle(V3d_View) aCurrentView = ViewerTest::CurrentView();
1913
1914 aCurrentEventManager->MoveTo(x1,y1);
1915 aCurrentEventManager->ShiftSelect(x1,y1,x2,y2);
1916 aCurrentEventManager->MoveTo(x2,y2);
1917
1918 return 0;
1919}
1920
1921static int QASelect2dRectangle (Draw_Interpretor& di, int argc, const char ** argv)
1922{
1923 if (argc != 5)
1924 {
1925 di << "Usage : " << argv[0] << " x1 y1 x2 y2" << "\n";
1926 return -1;
1927 }
1928
1929 Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext();
1930 if (myAIScontext.IsNull())
1931 {
1932 di << "use 'v2dinit' command before " << argv[0] << "\n";
1933 return -1;
1934 }
1935
1936 Standard_Integer x1 = atoi(argv[1]);
1937 Standard_Integer y1 = atoi(argv[2]);
1938 Standard_Integer x2 = atoi(argv[3]);
1939 Standard_Integer y2 = atoi(argv[4]);
1940
1941 Handle(Viewer2dTest_EventManager) aCurrentEventManager = Viewer2dTest::CurrentEventManager();
1942 Handle(V2d_View) aCurrentView = Viewer2dTest::CurrentView();
1943
1944 aCurrentEventManager->MoveTo(x1,y1,aCurrentView);
1945 aCurrentEventManager->Select(x1,y1,x2,y2,aCurrentView);
1946 aCurrentEventManager->MoveTo(x2,y2,aCurrentView);
1947
1948 return 0;
1949}
1950
1951static int QAShiftSelect2dRectangle (Draw_Interpretor& di, int argc, const char ** argv)
1952{
1953 if (argc != 5)
1954 {
1955 di << "Usage : " << argv[0] << " x1 y1 x2 y2" << "\n";
1956 return -1;
1957 }
1958
1959 Handle(AIS2D_InteractiveContext) myAIScontext = Viewer2dTest::GetAIS2DContext();
1960 if (myAIScontext.IsNull())
1961 {
1962 di << "use 'v2dinit' command before " << argv[0] << "\n";
1963 return -1;
1964 }
1965
1966 Standard_Integer x1 = atoi(argv[1]);
1967 Standard_Integer y1 = atoi(argv[2]);
1968 Standard_Integer x2 = atoi(argv[3]);
1969 Standard_Integer y2 = atoi(argv[4]);
1970
1971 Handle(Viewer2dTest_EventManager) aCurrentEventManager = Viewer2dTest::CurrentEventManager();
1972 Handle(V2d_View) aCurrentView = Viewer2dTest::CurrentView();
1973
1974 aCurrentEventManager->MoveTo(x1,y1,aCurrentView);
1975 aCurrentEventManager->ShiftSelect(x1,y1,x2,y2,aCurrentView);
1976 aCurrentEventManager->MoveTo(x2,y2,aCurrentView);
1977
1978 return 0;
1979}
1980
1981//=======================================================================
1982//function : QARotateV3dView
1983//purpose :
1984//=======================================================================
1985static Standard_Integer QARotateV3dView (Draw_Interpretor& di, int argc, const char ** argv)
1986{
1987 Handle(AIS_InteractiveContext) AIScontext = ViewerTest::GetAISContext();
1988 if(AIScontext.IsNull()) {
1989 di << "use 'vinit' command before " << argv[0] << "\n";
1990 return -1;
1991 }
1992 if(argc < 4 || argc > 5){
1993 di<<"Usage : " << argv[0] << " Ax Ay Az [Start(1/0)]\n";
1994 return -1;
1995 }
1996 Standard_Real Ax = atof(argv[1]);
1997 Standard_Real Ay = atof(argv[2]);
1998 Standard_Real Az = atof(argv[3]);
1999 Standard_Boolean Start = Standard_True;
2000 if (argc == 5) {
2001 Standard_Integer StartInteger = atoi(argv[4]);
2002 if (StartInteger > 0) {
2003 Start = Standard_True;
2004 } else {
2005 Start = Standard_False;
2006 }
2007 }
2008
2009 Handle(V3d_View) aView = ViewerTest::CurrentView();
2010 aView->Rotate(Ax,Ay,Az,Start);
2011 return 0;
2012}
2013
2014//=======================================================================
2015//function : QAMoveV3dView
2016//purpose :
2017//=======================================================================
2018static Standard_Integer QAMoveV3dView (Draw_Interpretor& di, int argc, const char ** argv)
2019{
2020 Handle(AIS_InteractiveContext) AIScontext = ViewerTest::GetAISContext();
2021 if(AIScontext.IsNull()) {
2022 di << "use 'vinit' command before " << argv[0] << "\n";
2023 return -1;
2024 }
2025 if(argc < 4 || argc > 5){
2026 di<<"Usage : " << argv[0] << " Dx Dy Dz [Start(1/0)]\n";
2027 return -1;
2028 }
2029 Standard_Real Dx = atof(argv[1]);
2030 Standard_Real Dy = atof(argv[2]);
2031 Standard_Real Dz = atof(argv[3]);
2032 Standard_Boolean Start = Standard_True;
2033 if (argc == 5) {
2034 Standard_Integer StartInteger = atoi(argv[4]);
2035 if (StartInteger > 0) {
2036 Start = Standard_True;
2037 } else {
2038 Start = Standard_False;
2039 }
2040 }
2041
2042 Handle(V3d_View) aView = ViewerTest::CurrentView();
2043 aView->Move(Dx,Dy,Dz,Start);
2044 return 0;
2045}
2046
2047//=======================================================================
2048//function : QATranslateV3dView
2049//purpose :
2050//=======================================================================
2051static Standard_Integer QATranslateV3dView (Draw_Interpretor& di, int argc, const char ** argv)
2052{
2053 Handle(AIS_InteractiveContext) AIScontext = ViewerTest::GetAISContext();
2054 if(AIScontext.IsNull()) {
2055 di << "use 'vinit' command before " << argv[0] << "\n";
2056 return -1;
2057 }
2058 if(argc < 4 || argc > 5){
2059 di<<"Usage : " << argv[0] << " Dx Dy Dz [Start(1/0)]\n";
2060 return -1;
2061 }
2062 Standard_Real Dx = atof(argv[1]);
2063 Standard_Real Dy = atof(argv[2]);
2064 Standard_Real Dz = atof(argv[3]);
2065 Standard_Boolean Start = Standard_True;
2066 if (argc == 5) {
2067 Standard_Integer StartInteger = atoi(argv[4]);
2068 if (StartInteger > 0) {
2069 Start = Standard_True;
2070 } else {
2071 Start = Standard_False;
2072 }
2073 }
2074
2075 Handle(V3d_View) aView = ViewerTest::CurrentView();
2076 aView->Translate(Dx,Dy,Dz,Start);
2077 return 0;
2078}
2079
2080//=======================================================================
2081//function : QATurnV3dView
2082//purpose :
2083//=======================================================================
2084static Standard_Integer QATurnV3dView (Draw_Interpretor& di, int argc, const char ** argv)
2085{
2086 Handle(AIS_InteractiveContext) AIScontext = ViewerTest::GetAISContext();
2087 if(AIScontext.IsNull()) {
2088 di << "use 'vinit' command before " << argv[0] << "\n";
2089 return -1;
2090 }
2091 if(argc < 4 || argc > 5){
2092 di<<"Usage : " << argv[0] << " Ax Ay Az [Start(1/0)]\n";
2093 return -1;
2094 }
2095 Standard_Real Ax = atof(argv[1]);
2096 Standard_Real Ay = atof(argv[2]);
2097 Standard_Real Az = atof(argv[3]);
2098 Standard_Boolean Start = Standard_True;
2099 if (argc == 5) {
2100 Standard_Integer StartInteger = atoi(argv[4]);
2101 if (StartInteger > 0) {
2102 Start = Standard_True;
2103 } else {
2104 Start = Standard_False;
2105 }
2106 }
2107
2108 Handle(V3d_View) aView = ViewerTest::CurrentView();
2109 aView->Turn(Ax,Ay,Az,Start);
2110 return 0;
2111}
2112
2113//=======================================================================
2114//function : QAPanningV3dView
2115//purpose :
2116//=======================================================================
2117static Standard_Integer QAPanningV3dView (Draw_Interpretor& di, int argc, const char ** argv)
2118{
2119 Handle(AIS_InteractiveContext) AIScontext = ViewerTest::GetAISContext();
2120 if(AIScontext.IsNull()) {
2121 di << "use 'vinit' command before " << argv[0] << "\n";
2122 return -1;
2123 }
2124 if(argc < 3 || argc > 5){
2125 di<<"Usage : " << argv[0] << " Dx Dy [Zoom [Start(1/0)]]\n";
2126 return -1;
2127 }
2128 Standard_Real Dx = atof(argv[1]);
2129 Standard_Real Dy = atof(argv[2]);
2130 Standard_Real Zoom = 1.;
2131 if (argc > 3) {
2132 Zoom = atof(argv[3]);
2133 if (Zoom <= 0.) {
2134 di<<"Bad Zoom value : " << Zoom << "\n";
2135 return -1;
2136 }
2137 }
2138 Standard_Boolean Start = Standard_True;
2139 if (argc == 5) {
2140 Standard_Integer StartInteger = atoi(argv[4]);
2141 if (StartInteger > 0) {
2142 Start = Standard_True;
2143 } else {
2144 Start = Standard_False;
2145 }
2146 }
2147
2148 Handle(V3d_View) aView = ViewerTest::CurrentView();
2149 aView->Panning(Dx,Dy,Zoom,Start);
2150 return 0;
2151}
2152
2153//=======================================================================
2154//function : QASetZoomV3dView
2155//purpose :
2156//=======================================================================
2157static Standard_Integer QASetZoomV3dView (Draw_Interpretor& di, int argc, const char ** argv)
2158{
2159 Handle(AIS_InteractiveContext) AIScontext = ViewerTest::GetAISContext();
2160 if(AIScontext.IsNull()) {
2161 di << "use 'vinit' command before " << argv[0] << "\n";
2162 return -1;
2163 }
2164 if(argc < 2 || argc > 3){
2165 di<<"Usage : " << argv[0] << " Zoom [Start(1/0)]\n";
2166 return -1;
2167 }
2168 Standard_Real Zoom = atof(argv[1]);
2169 if (Zoom <= 0.) {
2170 di<<"Bad Zoom value : " << Zoom << "\n";
2171 return -1;
2172 }
2173 Standard_Boolean Start = Standard_True;
2174 if (argc == 3) {
2175 Standard_Integer StartInteger = atoi(argv[2]);
2176 if (StartInteger > 0) {
2177 Start = Standard_True;
2178 } else {
2179 Start = Standard_False;
2180 }
2181 }
2182
2183 Handle(V3d_View) aView = ViewerTest::CurrentView();
2184 aView->SetZoom(Zoom,Start);
2185 return 0;
2186}
2187
2188//=======================================================================
2189//function : QASetSizeV3dView
2190//purpose :
2191//=======================================================================
2192static Standard_Integer QASetSizeV3dView (Draw_Interpretor& di, int argc, const char ** argv)
2193{
2194 Handle(AIS_InteractiveContext) AIScontext = ViewerTest::GetAISContext();
2195 if(AIScontext.IsNull()) {
2196 di << "use 'vinit' command before " << argv[0] << "\n";
2197 return -1;
2198 }
2199 if(argc != 2){
2200 di<<"Usage : " << argv[0] << " Size\n";
2201 return -1;
2202 }
2203 Standard_Real Size = atof(argv[1]);
2204 if (Size <= 0.) {
2205 di<<"Bad Size value : " << Size << "\n";
2206 return -1;
2207 }
2208
2209 Handle(V3d_View) aView = ViewerTest::CurrentView();
2210 aView->SetSize(Size);
2211 return 0;
2212}
2213
2214void QADraw::CommonCommands(Draw_Interpretor& theCommands)
2215{
2216 ios::sync_with_stdio();
2217
2218 st_err = dup(STDERR_FILENO);
2219
2220 Draw_BeforeCommand_old = Draw_BeforeCommand;
2221 Draw_AfterCommand_old = Draw_AfterCommand;
2222
2223 Draw_BeforeCommand = &before;
2224 Draw_AfterCommand = &after;
2225
2226 const char* group = "QA_Commands";
2227
2228 theCommands.Add("QARebuild","QARebuild command_name",__FILE__,QARebuild,group);
2229 theCommands.Add("QAxwd_3d","QAxwd_3d filename",__FILE__,QAxwd_3d,group);
2230 theCommands.Add("QAMoveTo","QAMoveTo x y",__FILE__,QAMoveTo,group);
2231 theCommands.Add("QASelect","QASelect x y",__FILE__,QASelect,group);
2232 theCommands.Add("QAShiftSelect","QAShiftSelect x y",__FILE__,QAShiftSelect,group);
2233 theCommands.Add("QAUpdateLights","QAUpdateLights",__FILE__,QAUpdateLights,group);
2234 theCommands.Add("QASetAntialiasing","QASetAntialiasing [1/0]",__FILE__,QASetAntialiasing,group);
2235 theCommands.Add("QAvzfit","QAvzfit",__FILE__,QAvzfit,group);
2236 theCommands.Add("QAGetPixelColor", "QAGetPixelColor coordinate_X coordinate_Y [color_R color_G color_B]", __FILE__,QAAISGetPixelColor, group);
2237 theCommands.Add("QASetChoiceMode", "QASetChoiceMode mode switch ; Use without params to see a help ", __FILE__,QAAISSetChoiceMode, group);
2238 theCommands.Add("QAGetMousePoint", "QAGetMousePoint", __FILE__,QAAISGetMousePoint, group);
2239 theCommands.Add("QAGetViewCharac", "QAGetViewCharac", __FILE__,QAAISGetViewCharac, group);
2240 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);
2241 theCommands.Add("QAGetColorCoord", "QAGetColorCoord [3d|2d]", __FILE__,QAAISGetColorCoord, group);
2242#ifndef WNT
2243 theCommands.Add("QAAISGetPixelColor2d",
2244 "QAAISGetPixelColor2d coord_X coord_Y [Red Green Blue] : Check a color of pixel",
2245 __FILE__, QAAISGetPixelColor2d, group);
2246#endif
2247
2248 theCommands.Add("v2dgetgrid",
2249 "v2dgetgrid coord_X coord_Y [grid_X grid_Y] : Get/print coordinates of a grid point near to (coord_X, coord_Y)",
2250 __FILE__, V2dPickGrid, group);
2251
2252 theCommands.Add("QAv2dzoom",
2253 "QAv2dzoom zoom_factor : Set Scale Factor",
2254 __FILE__, V2dZoom, group);
2255
2256 theCommands.Add("QAv2dpan",
2257 "QAv2dpan dx dy : script analog of Ctrl+MB2",
2258 __FILE__, V2dPan, group);
2259
2260// theCommands.Add("QAGetViewCharac2d",
2261// "QAGetViewCharac2d - dumps viewer characteristics",
2262// V2dGetViewCharac, group);
2263
2264// theCommands.Add("QASetViewCharac2d",
2265// "QASetViewCharac2d scale center(X Y) proj(X Y Z) up(X Y Z) at(X Y Z)",
2266// V2dSetViewCharac, group);
2267
2268 theCommands.Add("QAMoveTo2d", "QAMoveTo2d x y", __FILE__, QAMoveTo2d, group);
2269 theCommands.Add("QASelect2d", "QASelect2d x y", __FILE__, QASelect2d, group);
2270 theCommands.Add("QAShiftSelect2d", "QAShiftSelect2d x y", __FILE__, QAShiftSelect2d, group);
2271
2272 theCommands.Add("QAv2dSetHighlightMode",
2273 "QAv2dSetHighlightMode mode", __FILE__, V2dSetHighlightMode, group);
2274
2275 theCommands.Add("QAxwd_2d", "QAxwd_2d filename", __FILE__, QAxwd_2d, group);
2276
2277 theCommands.Add("QAxwd", "QAxwd [id=1] filename", __FILE__, QAxwd, group);
2278
2279 theCommands.Add("QA2dGetIndexes", "QA2dGetIndexes", __FILE__, QA2dGetIndexes, group);
2280
2281 theCommands.Add("vtri_orig",
2282 "vtri_orig : vtri_orig trihedron_name - draws axis origin lines",
2283 __FILE__,VTrihedronOrigins,group);
2284
2285 theCommands.Add("QAAddOrRemoveSelected",
2286 "QAAddOrRemoveSelected shape : selects the shape by AddOrRemoveSelected method",
2287 __FILE__, QAAddOrRemoveSelected, group);
2288
2289 theCommands.Add("QASetZClippingMode","QASetZClippingMode mode(OFF/BACK/FRONT/SLICE)",__FILE__,QASetZClippingMode,group);
2290 theCommands.Add("QAGetZClippingMode","QAGetZClippingMode",__FILE__,QAGetZClippingMode,group);
2291 theCommands.Add("QAv2dcircle", "QAv2dcircle CircleName X Y Radius Alpha Beta [Color_index]", __FILE__, QAv2dcircle, group);
2292
2293 theCommands.Add("QAwzoom","QAwzoom view-id X1 Y1 X2 Y2; zoom on a window",__FILE__,QAwzoom,group);
2294 theCommands.Add("QAGetCoordinatesWzoom","QAGetCoordinatesWzoom ; Get coordinates for zoom on a window",__FILE__,QAGetCoordinatesWzoom,group);
2295
319e4241 2296// adding commands "rename" leads to the fact that QA commands doesn't work properly OCC23410, use function "renamevar"
2297// theCommands.Add("rename","rename name1 toname1 name2 toname2 ...",__FILE__,QArename,group);
7fd59977 2298
2299 theCommands.Add ("QANbSelected", "QANbSelected", __FILE__, QANbSelected, group);
2300//#if defined(V2D)
2301// theCommands.Add ("QANbSelected2d", "QANbSelected2d", __FILE__, QANbSelected2d, group);
2302//#endif
2303
2304 theCommands.Add ("QAPurgeDisplay", "QAPurgeDisplay [CollectorToo=0/1]", __FILE__, QAPurgeDisplay, group);
2305 theCommands.Add ("QACloseLocalContext", "QACloseLocalContext [Index [updateviewer=1/0]]", __FILE__, QACloseLocalContext, group);
2306 theCommands.Add ("QACloseAllContexts", "QACloseAllContexts [updateviewer=1/0]", __FILE__, QACloseAllContexts, group);
2307 theCommands.Add ("QAIndexOfCurrentLocal", "QAIndexOfCurrentLocal", __FILE__, QAIndexOfCurrentLocal, group);
2308 theCommands.Add ("QADisplayedObjects", "QADisplayedObjects [OnlyFromNeutral=0/1]", __FILE__, QADisplayedObjects, group);
2309
2310 theCommands.Add("QASelectRectangle","QASelectRectangle x1 y1 x2 y2",__FILE__,QASelectRectangle,group);
2311 theCommands.Add("QAShiftSelectRectangle","QAShiftSelectRectangle x1 y1 x2 y2",__FILE__,QAShiftSelectRectangle,group);
2312 theCommands.Add("QASelect2dRectangle","QASelect2dRectangle x1 y1 x2 y2",__FILE__,QASelect2dRectangle,group);
2313 theCommands.Add("QAShiftSelect2dRectangle","QAShiftSelect2dRectangle x1 y1 x2 y2",__FILE__,QAShiftSelect2dRectangle,group);
2314
2315 theCommands.Add("QARotateV3dView","QARotateV3dView Ax Ay Az [Start(1/0)]",__FILE__,QARotateV3dView,group);
2316 theCommands.Add("QAMoveV3dView","QAMoveV3dView Dx Dy Dz [Start(1/0)]",__FILE__,QAMoveV3dView,group);
2317 theCommands.Add("QATranslateV3dView","QATranslateV3dView Dx Dy Dz [Start(1/0)]",__FILE__,QATranslateV3dView,group);
2318 theCommands.Add("QATurnV3dView","QATurnV3dView Ax Ay Az [Start(1/0)]",__FILE__,QATurnV3dView,group);
2319 theCommands.Add("QAPanningV3dView","QAPanningV3dView Dx Dy [Zoom [Start(1/0)]]",__FILE__,QAPanningV3dView,group);
2320 theCommands.Add("QASetZoomV3dView","QASetZoomV3dView Zoom [Start(1/0)]",__FILE__,QASetZoomV3dView,group);
2321 theCommands.Add("QASetSizeV3dView","QASetSizeV3dView Size",__FILE__,QASetSizeV3dView,group);
2322}
2323/*
2324extern "C" int Tkqadraw_Init(Tcl_Interp *);
2325
2326int Tkqadraw_Init(Tcl_Interp * ) {
2327
2328 ios::sync_with_stdio();
2329
2330 QADraw::CommonCommands(theCommands);
2331 QADraw::AdditionalCommands(theCommands);
2332
2333 ViewerTest::Commands (theCommands);
2334 ViewerTest::ViewerCommands (theCommands);
2335
2336 Viewer2dTest::Commands(theCommands);
2337// if (Tcl_PkgProvide(theCommands.Interp(), "Qa", "1.0") != TCL_OK) {
2338// return TCL_ERROR;
2339// }
2340
2341 return TCL_OK;
2342}
2343*/
2344//==============================================================================
2345// QADraw::Factory
2346//==============================================================================
2347void QADraw::Factory(Draw_Interpretor& theCommands)
2348{
2349 thePCommands = &theCommands;
2350
2351 // definition of QA Command
2352 QADraw::CommonCommands(theCommands);
2353 QADraw::AdditionalCommands(theCommands);
2354
2355 //ViewerTest::Commands (theCommands);
2356 //ViewerTest::ViewerCommands (theCommands);
2357
2358//#if defined(V2D)
2359// Viewer2dTest::Commands(theCommands);
2360//#endif
2361
2362//#ifdef DEB
2363// cout << "Draw Plugin : QA commands are loaded" << endl;
2364//#endif
2365}
2366
2367// Declare entry point PLUGINFACTORY
2368DPLUGIN(QADraw)