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_AlienPixMap.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>
39 #include <Draw_Window.hxx>
40 #include <Draw_Viewer.hxx>
41 #include <Aspect_WindowDriver.hxx>
45 #include <Xw_Window.hxx>
48 #include <X11/Xutil.h>
49 #include <Xw_GraphicDevice.hxx>
50 #include <Xw_Cextern.hxx>
54 #include <WNT_GraphicDevice.hxx>
55 #include <WNT_Window.hxx>
61 #if ! defined(STDOUT_FILENO)
62 #define STDOUT_FILENO fileno(stdout)
66 #if ! defined(STDERR_FILENO)
67 #define STDERR_FILENO fileno(stderr)
70 Draw_Interpretor *thePCommands = NULL;
73 //extern Draw_Interpretor theCommands;
75 extern void (*Draw_BeforeCommand)();
76 extern void (*Draw_AfterCommand)(Standard_Integer);
78 //Standard_EXPORT Draw_Interpretor theCommands;
80 Standard_EXPORT void (*Draw_BeforeCommand)();
81 Standard_EXPORT void (*Draw_AfterCommand)(Standard_Integer);
85 #include <Draw_PluginMacro.hxx>
87 // avoid warnings on 'extern "C"' functions returning C++ classes
89 #pragma warning(4:4190)
95 void (*Draw_BeforeCommand_old)();
96 void (*Draw_AfterCommand_old)(Standard_Integer);
98 static Standard_Boolean should_be_printed = Standard_True;
100 static Standard_Boolean shouldDUP() {
102 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
103 const Standard_Character * adup = Tcl_GetVar(thePCommands->Interp(),
104 "QA_DUP",TCL_GLOBAL_ONLY);
106 Standard_Character * adup = Tcl_GetVar(thePCommands->Interp(),
107 "QA_DUP",TCL_GLOBAL_ONLY);
109 Standard_Integer aDUP=1;
110 if((adup != NULL) && (Draw::Atof(adup) == 0)) {
117 static void before() {
118 should_be_printed = Standard_True;
119 if(Draw_BeforeCommand_old) (*Draw_BeforeCommand_old) ();
122 static void after(Standard_Integer a)
124 if(Draw_AfterCommand_old) (*Draw_AfterCommand_old) (a);
125 if(!should_be_printed) {
126 // Tcl_ResetResult(theCommands.Interp());
130 static QADraw_DataMapOfAsciiStringOfAddress stFuncMap;
133 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
134 static Standard_Integer (*CommandCmd_Old)
135 (ClientData clientData, Tcl_Interp *interp,
136 Standard_Integer argc, const char* argv[]) = NULL;
138 static Standard_Integer (*CommandCmd_Old)
139 (ClientData clientData, Tcl_Interp *interp,
140 Standard_Integer argc, char* argv[]) = NULL;
144 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
145 static Standard_Integer CommandCmd
146 (ClientData clientData, Tcl_Interp *interp,
147 Standard_Integer argc, const char* argv[])
149 static Standard_Integer CommandCmd
150 (ClientData clientData, Tcl_Interp *interp,
151 Standard_Integer argc, char* argv[])
154 Standard_Integer old_out = 0;
155 Standard_Integer old_err = 0;
156 Standard_Integer fd_out = 0;
157 Standard_Integer fd_err = 0;
159 FILE * aFile_out = NULL;
160 FILE * aFile_err = NULL;
165 if(strlen(getenv("TEMP")) == 0) {
166 cerr << "The TEMP variable is not set." << endl;
167 aFile_out = tmpfile();
168 aFile_err = tmpfile();
170 nameo = _tempnam(getenv("TEMP"),"tmpo");
171 namee = _tempnam(getenv("TEMP"),"tmpe");
172 aFile_out=fopen(nameo, "w+");
173 aFile_err=fopen(namee, "w+");
176 aFile_out = tmpfile();
177 aFile_err = tmpfile();
179 fd_out = fileno(aFile_out);
180 fd_err = fileno(aFile_err);
181 if(fd_out !=-1 && fd_err !=-1) {
182 old_err = dup(STDERR_FILENO);
183 old_out = dup(STDOUT_FILENO);
184 dup2(fd_err,STDERR_FILENO);
185 dup2(fd_out,STDOUT_FILENO);
187 cout << "Faulty : Can not create temporary file." << endl;
189 Standard_Integer clen = sizeof(Standard_Character);
191 Standard_Character * QA = getenv("QA_print_command");
192 if((QA != NULL) && (!strcmp(QA,"1"))) {
193 for(Standard_Integer i=0;i<argc;i++) {
194 write(st_err,argv[i],clen*strlen(argv[i]));
195 write(st_err," ",clen);
197 write(st_err,"\n",clen);
201 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
202 TCollection_AsciiString aName((char *) argv[0]);
204 TCollection_AsciiString aName(argv[0]);
207 Standard_Integer res = 0;
209 if(stFuncMap.IsBound(aName)) {
211 #if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4))) && !defined(USE_NON_CONST)
212 CommandCmd_Old = (int(*)(void*, Tcl_Interp*, int, const char**)) stFuncMap((char *) argv[0]);
214 CommandCmd_Old = (int(*)(void*, Tcl_Interp*, int, char**)) stFuncMap(argv[0]);
216 res = (*CommandCmd_Old) (clientData,interp,argc,argv);
221 close(STDERR_FILENO);
222 close(STDOUT_FILENO);
223 dup2(old_err,STDERR_FILENO);
224 dup2(old_out,STDOUT_FILENO);
228 Standard_Character buf[256];
229 Standard_Integer len = 0;
232 while((len = read(fd_err,buf,clen*255)/clen) > 0) {
235 (*thePCommands) << buf;
237 write(st_err,buf,clen*len);
245 while((len = read(fd_out,buf,clen*255)/clen) > 0) {
248 (*thePCommands) << buf;
250 write(st_err,buf,clen*len);
256 Standard_Character *Result = (Standard_Character *)thePCommands->Result();
257 if(Result[0] != '\0') {
258 Standard_Integer pos = 0;
259 Standard_Integer rlen = strlen(Result);
261 Standard_Integer nb = 256;
262 if((rlen - pos) <= 256) {
265 write(st_err,Result+pos,nb*clen);
268 write(st_err,"\n",clen);
269 should_be_printed = Standard_False ;
279 static Standard_Integer QARebuild (Draw_Interpretor& di, Standard_Integer /*n*/, const char ** a)
282 Tcl_CmdInfo *infoPtr = new Tcl_CmdInfo;
284 if(!strcmp(a[0],a[1]))
287 char* var_a = (char*)a[1];
288 Standard_Integer res = Tcl_GetCommandInfo(di.Interp(),var_a,infoPtr);
289 if(res && (infoPtr->proc != &CommandCmd)) {
290 TCollection_AsciiString aName(var_a);
291 if (!stFuncMap.IsBound(aName)) {
292 stFuncMap.Bind(aName, (Standard_Address) infoPtr->proc);
294 infoPtr->proc = &CommandCmd;
295 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 3
296 infoPtr->isNativeObjectProc = 0;
297 infoPtr->objProc = NULL;
299 Tcl_SetCommandInfo(di.Interp(),var_a,infoPtr);
306 Handle(TColStd_HSequenceOfReal) GetColorOfPixel (const Image_PixMap& theImage,
307 const Standard_Integer theCoordinateX,
308 const Standard_Integer theCoordinateY,
309 const Standard_Integer theRadius)
311 Handle(TColStd_HSequenceOfReal) aSeq = new TColStd_HSequenceOfReal();
312 if (theImage.IsEmpty()) {
313 std::cerr << "The image is null.\n";
316 Standard_Integer aWidth = (Standard_Integer )theImage.SizeX();
317 Standard_Integer anHeight = (Standard_Integer )theImage.SizeY();
319 Quantity_Color aColorTmp;
320 for (Standard_Integer anXIter = theCoordinateX - theRadius;
321 anXIter <= theCoordinateX + theRadius; ++anXIter)
323 if (anXIter < 0 || anXIter >= aWidth)
327 for (Standard_Integer anYIter = theCoordinateY - theRadius;
328 anYIter <= theCoordinateY + theRadius; ++anYIter)
330 if (anYIter < 0 || anYIter >= anHeight)
334 // Image_PixMap stores image upside-down in memory!
335 aColorTmp = theImage.PixelColor (anXIter, anYIter);
336 aSeq->Append (aColorTmp.Red());
337 aSeq->Append (aColorTmp.Green());
338 aSeq->Append (aColorTmp.Blue());
344 static Standard_Integer QAAISGetPixelColor (Draw_Interpretor& theDi,
345 Standard_Integer theArgsNb,
346 const char** theArgs)
348 if (theArgsNb != 3 && theArgsNb != 6)
350 theDi << "Usage : " << theArgs[0] << " coordinate_X coordinate_Y [color_R color_G color_B]" << "\n";
351 return 1; // TCL_ERROR
354 Handle(V3d_View) aView3d = ViewerTest::CurrentView();
355 if (aView3d.IsNull())
357 theDi << "You must initialize AISViewer before this command.\n";
358 return 1; // TCL_ERROR
361 const Handle(Aspect_Window) anAISWindow = aView3d->Window();
362 Standard_Integer aWindowSizeX = 0;
363 Standard_Integer aWindowSizeY = 0;
364 anAISWindow->Size (aWindowSizeX, aWindowSizeY);
366 Standard_Integer anArgIter = 1;
367 const Standard_Integer aPickCoordX = Draw::Atoi (theArgs[anArgIter++]);
368 const Standard_Integer aPickCoordY = Draw::Atoi (theArgs[anArgIter++]);
369 const Standard_Integer aRadius = (theArgsNb == 3) ? 0 : 1;
371 Image_ColorRGBF aColorInput = {{ 0.0f, 0.0f, 0.0f }};
374 aColorInput.r() = (Standard_ShortReal )Draw::Atof (theArgs[anArgIter++]);
375 aColorInput.g() = (Standard_ShortReal )Draw::Atof (theArgs[anArgIter++]);
376 aColorInput.b() = (Standard_ShortReal )Draw::Atof (theArgs[anArgIter++]);
379 Image_PixMap anImage;
380 aView3d->ToPixMap (anImage, aWindowSizeX, aWindowSizeY);
381 const Handle(TColStd_HSequenceOfReal) aSeq = GetColorOfPixel (anImage, aPickCoordX, aPickCoordY, aRadius);
382 cout << "Length = " << aSeq->Length() << endl;
384 Image_ColorRGBF aColorPicked = {{ 0.0f, 0.0f, 0.0f }};
385 Standard_Boolean isNotEqual = Standard_True;
386 for (Standard_Integer i = 1; i <= aSeq->Length(); i += 3)
388 aColorPicked.r() = (Standard_ShortReal )aSeq->Value (i + 0);
389 aColorPicked.g() = (Standard_ShortReal )aSeq->Value (i + 1);
390 aColorPicked.b() = (Standard_ShortReal )aSeq->Value (i + 2);
392 if (theArgsNb == 3 ||
393 ((Abs (aColorPicked.r() - aColorInput.r()) <= Precision::Confusion())
394 && (Abs (aColorPicked.g() - aColorInput.g()) <= Precision::Confusion())
395 && (Abs (aColorPicked.b() - aColorInput.b()) <= Precision::Confusion())))
397 isNotEqual = Standard_False;
402 theDi << "RED : " << aColorPicked.r() << " "
403 << "GREEN : " << aColorPicked.g() << " "
404 << "BLUE : " << aColorPicked.b() << "\n";
408 theDi << "User color: \n"
409 << "RED : " << aColorInput.r() << " "
410 << "GREEN : " << aColorInput.g() << " "
411 << "BLUE : " << aColorInput.b() << "\n";
416 theDi << "Faulty : colors are not equal.\n";
417 return 1; // TCL_ERROR
423 extern int ViewerMainLoop (Standard_Integer argc, const char ** argv);
425 Standard_EXPORT int ViewerMainLoop (Standard_Integer argc, const char ** argv);
428 extern int ViewerMainLoop2d (Standard_Integer argc, const char ** argv);
430 Standard_EXPORT int ViewerMainLoop2d (Standard_Integer argc, const char ** argv);
433 static Standard_Integer QAAISGetMousePoint (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
436 di << "Usage : " << argv[0] << "\n";
439 Handle (V3d_View) QAAISView = ViewerTest::CurrentView ();
440 if ( QAAISView.IsNull () ) {
441 di << "You must initialize AISViewer before this command." << "\n";
444 Standard_Integer QAAISMouseCoordinateX = 0;
445 Standard_Integer QAAISMouseCoordinateY = 0;
446 Standard_Integer argccc = 5;
447 const char *bufff[] = { "A", "B", "C", "D", "E" };
448 const char **argvvv = (const char **) bufff;
449 while ( ViewerMainLoop (argccc, argvvv) ) {
450 ViewerTest::GetMousePosition (QAAISMouseCoordinateX, QAAISMouseCoordinateY);
452 ViewerTest::GetMousePosition (QAAISMouseCoordinateX, QAAISMouseCoordinateY);
453 di << "X-coordinate: " << QAAISMouseCoordinateX << "; Y-coordinate: " << QAAISMouseCoordinateY << "\n";
457 static Standard_Integer QAAISGetColorCoord (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
461 di << "Usage : " << argv[0] << " [3d|2d]" << "\n";
464 Handle(Xw_Window) QAAISWindow;
466 Standard_Boolean is3d = 1;
468 if(argc == 1 || !strcmp(argv[1],"3d")) {
470 Handle (V3d_View) QAAIS_MainView = ViewerTest::CurrentView ();
471 if ( QAAIS_MainView.IsNull () ) {
472 di << "You must initialize AISViewer before this command." << "\n";
475 QAAISWindow = Handle(Xw_Window)::DownCast (QAAIS_MainView->V3d_View::Window());
479 Standard_Integer QAAIS_WindowSize_X = 0;
480 Standard_Integer QAAIS_WindowSize_Y = 0;
481 QAAISWindow->Size(QAAIS_WindowSize_X, QAAIS_WindowSize_Y);
482 Handle (Graphic3d_GraphicDevice) QAAIS_GraphicDevice = new Graphic3d_GraphicDevice (getenv ("DISPLAY"));
484 Draw_Window QAAIS_CoordWindow ("coordinate", 421, 205, 200, 60);
485 QAAIS_CoordWindow.DisplayWindow ();
486 QAAIS_CoordWindow.SetColor (12);
488 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);
489 Handle (V3d_Viewer) QAAIS_ColorViewer = new V3d_Viewer (QAAIS_GraphicDevice, Standard_ExtString ("COLOR"));
490 Handle (V3d_View) QAAIS_ColorView = QAAIS_ColorViewer -> CreateView ();
491 QAAIS_ColorWindow -> Map ();
492 QAAIS_ColorView -> SetWindow (QAAIS_ColorWindow);
493 QAAIS_ColorView -> SetBackgroundColor (Quantity_NOC_BLACK);
494 QAAIS_ColorView -> Redraw ();
496 Standard_Integer QAAIS_MousePoint_X = 0;
497 Standard_Integer QAAIS_MousePoint_Y = 0;
498 Standard_Character QAAIS_MousePointX[32];
499 Sprintf (QAAIS_MousePointX, "X : %d", QAAIS_MousePoint_X);
500 Standard_Character QAAIS_MousePointY[32];
501 Sprintf (QAAIS_MousePointY, "Y : %d", QAAIS_MousePoint_Y);
502 Standard_ShortReal QAAIS_ColorRED = 0;
503 Standard_ShortReal QAAIS_ColorGRN = 0;
504 Standard_ShortReal QAAIS_ColorBLU = 0;
505 Quantity_Color QAAIS_ShowingColor;
506 QAAIS_ShowingColor.SetValues (QAAIS_ColorRED, QAAIS_ColorGRN, QAAIS_ColorBLU, Quantity_TOC_RGB);
507 Standard_Integer argccc = 5;
508 const char *bufff[] = { "A", "B", "C", "D", "E" };
509 const char **argvvv = (const char **) bufff;
510 while ( is3d ? ViewerMainLoop (argccc, argvvv) : ViewerMainLoop2d (argccc, argvvv)) {
511 Handle(TColStd_HSequenceOfReal) aSeq;
512 Image_PixMap anImage;
515 ViewerTest::GetMousePosition (QAAIS_MousePoint_X, QAAIS_MousePoint_Y);
516 Handle (V3d_View) QAAIS_MainView = ViewerTest::CurrentView();
517 QAAIS_MainView->ToPixMap (anImage, QAAIS_WindowSize_X, QAAIS_WindowSize_Y);
519 aSeq = GetColorOfPixel (anImage, QAAIS_MousePoint_X, QAAIS_MousePoint_Y, 0);
521 QAAIS_ColorRED = aSeq->Value(1);
522 QAAIS_ColorGRN = aSeq->Value(2);
523 QAAIS_ColorBLU = aSeq->Value(3);
524 QAAIS_ShowingColor.SetValues (QAAIS_ColorRED, QAAIS_ColorGRN, QAAIS_ColorBLU, Quantity_TOC_RGB);
525 QAAIS_ColorView -> SetBackgroundColor (QAAIS_ShowingColor);
526 QAAIS_ColorView -> Redraw ();
527 QAAIS_CoordWindow.Clear();
528 Sprintf (QAAIS_MousePointX, "X : %d", QAAIS_MousePoint_X);
529 Sprintf (QAAIS_MousePointY, "Y : %d", QAAIS_MousePoint_Y);
530 QAAIS_CoordWindow.DrawString (30, 35, QAAIS_MousePointX);
531 QAAIS_CoordWindow.DrawString (125, 35, QAAIS_MousePointY);
533 QAAIS_CoordWindow.Destroy ();
538 //==============================================================================
540 //==============================================================================
542 extern Draw_Viewer dout;
543 extern Display* Draw_WindowDisplay;
544 extern Colormap Draw_WindowColorMap;
546 Standard_IMPORT Draw_Viewer dout;
549 //=======================================================================
551 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
552 extern Handle(AIS_InteractiveContext)& TheAISContext();
554 Standard_EXPORT ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
555 Standard_EXPORT Handle(AIS_InteractiveContext)& TheAISContext();
557 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
558 #include <AIS_Trihedron.hxx>
559 #include <AIS_Axis.hxx>
560 #include <Geom_Line.hxx>
561 #include <AIS_Line.hxx>
563 //==============================================================================
564 // function : VTrihedronOrigins
566 // purpose : draws triheron axis origin lines.
567 // Draw arg : vtri_orig trihedron_name
568 //==============================================================================
569 static int VTrihedronOrigins(Draw_Interpretor& di,
570 Standard_Integer argc,
574 di <<"Usage : vtri_orig tri_name"<<"\n";
578 if(TheAISContext().IsNull()){
579 di<<"Make 'vinit' before this method call"<<"\n";
583 //get trihedron from AIS map.
584 TCollection_AsciiString aName(argv[1]);
585 if(!GetMapOfAIS().IsBound2(aName)){
586 di<<"No object named '"<<argv[1]<<"'"<<"\n";
590 Handle(AIS_Trihedron) aTrih =
591 Handle(AIS_Trihedron)::DownCast(GetMapOfAIS().Find2(aName));
593 di<<"Trihedron is not found, try another name"<<"\n";
598 Handle(AIS_Axis) XAxis = aTrih->XAxis();
599 Handle(AIS_Axis) YAxis = aTrih->YAxis();
600 Handle(AIS_Axis) ZAxis = aTrih->Axis();
602 //get geometrical lines
603 Handle(Geom_Line) XGLine = XAxis->Component();
604 Handle(Geom_Line) YGLine = YAxis->Component();
605 Handle(Geom_Line) ZGLine = ZAxis->Component();
608 Handle(AIS_Line) XLine = new AIS_Line(XGLine);
609 Handle(AIS_Line) YLine = new AIS_Line(YGLine);
610 Handle(AIS_Line) ZLine = new AIS_Line(ZGLine);
612 //put them into AIS map:
613 GetMapOfAIS().Bind(XLine,aName+"_X");
614 GetMapOfAIS().Bind(YLine,aName+"_Y");
615 GetMapOfAIS().Bind(ZLine,aName+"_Z");
616 //print names of created objects:
617 di<<argv[1]<<"_X "<<argv[1]<<"_Y "<<argv[1]<<"_Z"<<"\n";
620 TheAISContext()->Display(XLine);
621 TheAISContext()->Display(YLine);
622 TheAISContext()->Display(ZLine);
627 #include <Draw_Viewer.hxx>
630 static Standard_Integer ViewId(const Standard_CString a)
632 Standard_Integer id = Draw::Atoi(a);
633 if ((id < 0) || (id >= MAXVIEW)) {
634 cout << "Incorrect view-id, must be in 0.."<<MAXVIEW-1<<endl;
637 if (!dout.HasView(id)) {
638 cout <<"View "<<id<<" does not exist."<<endl;
644 #include <Draw_Display.hxx>
646 //=======================================================================
648 //=======================================================================
650 static Standard_Integer QArename(Draw_Interpretor& di, Standard_Integer n, const char** a)
653 Standard_Boolean cop = !strcasecmp(a[0],"copy");
655 Handle(Draw_Drawable3D) D;
656 for (Standard_Integer i = 1; i < n; i += 2) {
657 if (i+1 >= n) return 0;
664 Draw::Set(a[i],Handle(Draw_Drawable3D()));
673 //#include <AIS2D_InteractiveContext.hxx>
674 //static Standard_Integer QANbSelected2d (Draw_Interpretor& /*di*/, Standard_Integer argc, char** argv)
677 // cout << "Usage : " << argv[0] << endl;
680 // Handle(AIS2D_InteractiveContext) aContext = Viewer2dTest::GetAIS2DContext();
681 // if(aContext.IsNull()) {
682 // cerr << "use 'v2dinit' command before " << argv[0] << endl;
685 // cout << aContext->NbSelected() << endl;
690 void QADraw::CommonCommands(Draw_Interpretor& theCommands)
692 ios::sync_with_stdio();
694 st_err = dup(STDERR_FILENO);
696 Draw_BeforeCommand_old = Draw_BeforeCommand;
697 Draw_AfterCommand_old = Draw_AfterCommand;
699 Draw_BeforeCommand = &before;
700 Draw_AfterCommand = &after;
702 const char* group = "QA_Commands";
704 theCommands.Add("QARebuild","QARebuild command_name",__FILE__,QARebuild,group);
705 theCommands.Add("QAGetPixelColor", "QAGetPixelColor coordinate_X coordinate_Y [color_R color_G color_B]", __FILE__,QAAISGetPixelColor, group);
706 theCommands.Add("QAGetMousePoint", "QAGetMousePoint", __FILE__,QAAISGetMousePoint, group);
707 theCommands.Add("QAGetColorCoord", "QAGetColorCoord [3d|2d]", __FILE__,QAAISGetColorCoord, group);
708 theCommands.Add("vtri_orig",
709 "vtri_orig : vtri_orig trihedron_name - draws axis origin lines",
710 __FILE__,VTrihedronOrigins,group);
712 // adding commands "rename" leads to the fact that QA commands doesn't work properly OCC23410, use function "renamevar"
713 // theCommands.Add("rename","rename name1 toname1 name2 toname2 ...",__FILE__,QArename,group);
716 extern "C" int Tkqadraw_Init(Tcl_Interp *);
718 int Tkqadraw_Init(Tcl_Interp * ) {
720 ios::sync_with_stdio();
722 QADraw::CommonCommands(theCommands);
723 QADraw::AdditionalCommands(theCommands);
725 ViewerTest::Commands (theCommands);
726 ViewerTest::ViewerCommands (theCommands);
728 Viewer2dTest::Commands(theCommands);
729 // if (Tcl_PkgProvide(theCommands.Interp(), "Qa", "1.0") != TCL_OK) {
736 //==============================================================================
738 //==============================================================================
739 void QADraw::Factory(Draw_Interpretor& theCommands)
741 thePCommands = &theCommands;
743 // definition of QA Command
744 QADraw::CommonCommands(theCommands);
745 QADraw::AdditionalCommands(theCommands);
747 //ViewerTest::Commands (theCommands);
748 //ViewerTest::ViewerCommands (theCommands);
751 // Viewer2dTest::Commands(theCommands);
755 // cout << "Draw Plugin : QA commands are loaded" << endl;
759 // Declare entry point PLUGINFACTORY