1 // Created on: 1998-09-01
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
22 // Robert Boehne 30 May 2000 : Dec Osf
32 #include <Graphic3d_AspectMarker3d.hxx>
33 #include <Graphic3d_GraphicDriver.hxx>
34 #include <Graphic3d_ExportFormat.hxx>
35 #include <Graphic3d_NameOfTextureEnv.hxx>
36 #include <Graphic3d_TextureEnv.hxx>
37 #include <Graphic3d_TextureParams.hxx>
38 #include <Graphic3d_TypeOfTextureFilter.hxx>
39 #include <ViewerTest.hxx>
40 #include <ViewerTest_EventManager.hxx>
41 #include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
42 #include <Visual3d_View.hxx>
43 #include <Visual3d_ViewManager.hxx>
44 #include <V3d_LayerMgr.hxx>
45 #include <NIS_View.hxx>
46 #include <NIS_Triangulated.hxx>
47 #include <NIS_InteractiveContext.hxx>
48 #include <AIS_InteractiveContext.hxx>
49 #include <Draw_Interpretor.hxx>
51 #include <Draw_Appli.hxx>
52 #include <Aspect_PrintAlgo.hxx>
53 #include <Image_AlienPixMap.hxx>
54 #include <OSD_Timer.hxx>
55 #include <TColStd_SequenceOfInteger.hxx>
56 #include <TColStd_HSequenceOfReal.hxx>
57 #include <TColgp_Array1OfPnt2d.hxx>
58 #include <Visual3d_LayerItem.hxx>
59 #include <V3d_LayerMgr.hxx>
60 #include <V3d_LayerMgrPointer.hxx>
61 #include <Aspect_TypeOfLine.hxx>
62 #include <Image_Diff.hxx>
63 #include <Aspect_DisplayConnection.hxx>
64 #include <Graphic3d.hxx>
70 #include <Visual3d_Layer.hxx>
73 #if defined(_WIN32) || defined(__WIN32__)
74 #include <WNT_WClass.hxx>
75 #include <WNT_Window.hxx>
78 #define _CRT_SECURE_NO_DEPRECATE
79 #pragma warning (disable:4996)
81 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
82 #include <Cocoa_Window.hxx>
85 #include <Xw_WindowQuality.hxx>
86 #include <Xw_Window.hxx>
87 #include <X11/Xlib.h> /* contains some dangerous #defines such as Status, True etc. */
88 #include <X11/Xutil.h>
92 //==============================================================================
94 //==============================================================================
95 // VIEWER GLOBAL VARIABLES
96 //==============================================================================
98 Standard_IMPORT Standard_Boolean Draw_VirtualWindows;
100 Standard_EXPORT int ViewerMainLoop(Standard_Integer , const char** argv);
101 extern const Handle(NIS_InteractiveContext)& TheNISContext();
102 extern ViewerTest_DoubleMapOfInteractiveAndName& GetMapOfAIS();
104 #if defined(_WIN32) || defined(__WIN32__)
105 static Handle(WNT_Window)& VT_GetWindow() {
106 static Handle(WNT_Window) WNTWin;
109 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
110 static Handle(Cocoa_Window)& VT_GetWindow()
112 static Handle(Cocoa_Window) aWindow;
115 extern void ViewerTest_SetCocoaEventManagerView (const Handle(Cocoa_Window)& theWindow);
117 static Handle(Xw_Window)& VT_GetWindow(){
118 static Handle(Xw_Window) XWWin;
121 static Display *display;
123 static void VProcessEvents(ClientData,int);
126 static Handle(Graphic3d_GraphicDriver)& GetGraphicDriver()
128 static Handle(Graphic3d_GraphicDriver) aGraphicDriver;
129 return aGraphicDriver;
132 static Standard_Boolean DegenerateMode = Standard_True;
134 #define ZCLIPWIDTH 1.
136 static void OSWindowSetup();
138 //==============================================================================
139 // EVENT GLOBAL VARIABLES
140 //==============================================================================
142 static int Start_Rot = 0;
143 static int ZClipIsOn = 0;
144 int X_Motion = 0; // Current cursor position
146 int X_ButtonPress = 0; // Last ButtonPress position
147 int Y_ButtonPress = 0;
148 Standard_Boolean IsDragged = Standard_False;
149 Standard_Boolean DragFirst;
151 //==============================================================================
154 static LRESULT WINAPI ViewerWindowProc(
159 static LRESULT WINAPI AdvViewerWindowProc(
167 //==============================================================================
170 //==============================================================================
172 const Handle(MMgt_TShared)& ViewerTest::WClass()
174 static Handle(MMgt_TShared) theWClass;
175 #if defined(_WIN32) || defined(__WIN32__)
176 if (theWClass.IsNull())
178 theWClass = new WNT_WClass ("GW3D_Class", AdvViewerWindowProc,
179 CS_VREDRAW | CS_HREDRAW, 0, 0,
180 ::LoadCursor (NULL, IDC_ARROW));
186 //==============================================================================
187 //function : ViewerInit
188 //purpose : Create the window viewer and initialize all the global variable
189 //==============================================================================
191 void ViewerTest::ViewerInit (const Standard_Integer thePxLeft, const Standard_Integer thePxTop,
192 const Standard_Integer thePxWidth, const Standard_Integer thePxHeight)
194 static Standard_Boolean isFirst = Standard_True;
196 // Default position and dimension of the viewer window.
197 // Note that left top corner is set to be sufficiently small to have
198 // window fit in the small screens (actual for remote desktops, see #23003).
199 // The position corresponds to the window's client area, thus some
200 // gap is added for window frame to be visible.
201 Standard_Integer aPxLeft = 20;
202 Standard_Integer aPxTop = 40;
203 Standard_Integer aPxWidth = 409;
204 Standard_Integer aPxHeight = 409;
205 if (thePxWidth != 0 && thePxHeight != 0)
209 aPxWidth = thePxWidth;
210 aPxHeight = thePxHeight;
215 Handle(Aspect_DisplayConnection) aDisplayConnection = new Aspect_DisplayConnection();
216 if (GetGraphicDriver().IsNull())
218 GetGraphicDriver() = Graphic3d::InitGraphicDriver (aDisplayConnection);
220 #if defined(_WIN32) || defined(__WIN32__)
221 if (VT_GetWindow().IsNull())
223 VT_GetWindow() = new WNT_Window ("Test3d",
224 Handle(WNT_WClass)::DownCast (WClass()),
230 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
231 if (VT_GetWindow().IsNull())
233 VT_GetWindow() = new Cocoa_Window ("Test3d",
235 aPxWidth, aPxHeight);
236 ViewerTest_SetCocoaEventManagerView (VT_GetWindow());
239 if (VT_GetWindow().IsNull())
241 VT_GetWindow() = new Xw_Window (aDisplayConnection,
248 VT_GetWindow()->SetVirtual (Draw_VirtualWindows);
250 Handle(V3d_Viewer) a3DViewer, a3DCollector;
251 // Viewer and View creation
253 TCollection_ExtendedString NameOfWindow("Visu3D");
255 a3DViewer = new V3d_Viewer(GetGraphicDriver(), NameOfWindow.ToExtString());
256 NameOfWindow = TCollection_ExtendedString("Collector");
257 a3DCollector = new V3d_Viewer(GetGraphicDriver(), NameOfWindow.ToExtString());
258 a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK);
259 a3DCollector->SetDefaultBackgroundColor(Quantity_NOC_STEELBLUE);
260 Handle(NIS_View) aView = Handle(NIS_View)::DownCast(ViewerTest::CurrentView());
263 //Handle(V3d_View) a3DViewCol = a3DViewer->CreateView();
264 aView = new NIS_View (a3DViewer, VT_GetWindow());
265 ViewerTest::CurrentView(aView);
266 TheNISContext()->AttachView (aView);
270 if ( ViewerTest::GetAISContext().IsNull() ) {
271 Handle(AIS_InteractiveContext) C =
272 new AIS_InteractiveContext(a3DViewer,a3DCollector);
273 ViewerTest::SetAISContext(C);
276 // Setup for X11 or NT
278 // Viewer and View creation
280 a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK);
282 Handle (V3d_View) V = ViewerTest::CurrentView();
284 V->SetDegenerateModeOn();
285 DegenerateMode = V->DegenerateModeIsOn();
286 // V->SetWindow(VT_GetWindow(), NULL, MyViewProc, NULL);
288 V->SetZClippingDepth(0.5);
289 V->SetZClippingWidth(ZCLIPWIDTH/2.);
290 a3DViewer->SetDefaultLights();
291 a3DViewer->SetLightOn();
293 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
294 #if TCL_MAJOR_VERSION < 8
295 Tk_CreateFileHandler((void*)ConnectionNumber(display),
296 TK_READABLE, VProcessEvents, (ClientData) VT_GetWindow()->XWindow() );
298 Tk_CreateFileHandler(ConnectionNumber(display),
299 TK_READABLE, VProcessEvents, (ClientData) VT_GetWindow()->XWindow() );
303 isFirst = Standard_False;
306 VT_GetWindow()->Map();
307 ViewerTest::CurrentView()->Redraw();
310 //==============================================================================
312 //purpose : Create the window viewer and initialize all the global variable
313 // Use Tk_CreateFileHandler on UNIX to cath the X11 Viewer event
314 //==============================================================================
316 static int VInit (Draw_Interpretor& , Standard_Integer argc, const char** argv)
318 Standard_Integer aPxLeft = (argc > 1) ? Draw::Atoi (argv[1]) : 0;
319 Standard_Integer aPxTop = (argc > 2) ? Draw::Atoi (argv[2]) : 0;
320 Standard_Integer aPxWidth = (argc > 3) ? Draw::Atoi (argv[3]) : 0;
321 Standard_Integer aPxHeight = (argc > 4) ? Draw::Atoi (argv[4]) : 0;
322 ViewerTest::ViewerInit (aPxLeft, aPxTop, aPxWidth, aPxHeight);
326 //==============================================================================
327 //function : VT_ProcessKeyPress
328 //purpose : Handle KeyPress event from a CString
329 //==============================================================================
330 void VT_ProcessKeyPress (const char* buf_ret)
332 //cout << "KeyPress" << endl;
333 const Handle(V3d_View) aView = ViewerTest::CurrentView();
334 const Handle(NIS_View) aNisView = Handle(NIS_View)::DownCast (aView);
335 // Letter in alphabetic order
337 if ( !strcasecmp(buf_ret, "A") ) {
339 aView->SetProj(V3d_XposYnegZpos);
341 else if ( !strcasecmp(buf_ret, "D") ) {
345 else if ( !strcasecmp(buf_ret, "F") ) {
347 if (aNisView.IsNull())
350 aNisView->FitAll3d();
352 else if ( !strcasecmp(buf_ret, "H") ) {
354 cout << "HLR" << endl;
356 if (aView->DegenerateModeIsOn()) ViewerTest::CurrentView()->SetDegenerateModeOff();
357 else aView->SetDegenerateModeOn();
358 DegenerateMode = aView->DegenerateModeIsOn();
360 else if ( !strcasecmp(buf_ret, "S") ) {
362 cout << "passage en mode 1 (shading pour les shapes)" << endl;
364 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
365 if(Ctx->NbCurrents()==0 ||
366 Ctx->NbSelected()==0)
367 Ctx->SetDisplayMode(AIS_Shaded);
369 if(Ctx->HasOpenedContext()){
370 for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
371 Ctx->SetDisplayMode(Ctx->Interactive(),1,Standard_False);
374 for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent())
375 Ctx->SetDisplayMode(Ctx->Current(),1,Standard_False);
377 Ctx->UpdateCurrentViewer();
380 else if ( !strcasecmp(buf_ret, "U") ) {
381 // Unset display mode
382 cout<<"passage au mode par defaut"<<endl;
384 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
385 if(Ctx->NbCurrents()==0 ||
386 Ctx->NbSelected()==0)
387 Ctx->SetDisplayMode(AIS_WireFrame);
389 if(Ctx->HasOpenedContext()){
390 for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
391 Ctx->UnsetDisplayMode(Ctx->Interactive(),Standard_False);
394 for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent())
395 Ctx->UnsetDisplayMode(Ctx->Current(),Standard_False);
397 Ctx->UpdateCurrentViewer();
401 else if ( !strcasecmp(buf_ret, "T") ) {
403 aView->SetProj(V3d_Zpos);
405 else if ( !strcasecmp(buf_ret, "B") ) {
407 aView->SetProj(V3d_Zneg);
409 else if ( !strcasecmp(buf_ret, "L") ) {
411 aView->SetProj(V3d_Xneg);
413 else if ( !strcasecmp(buf_ret, "R") ) {
415 aView->SetProj(V3d_Xpos);
418 else if ( !strcasecmp(buf_ret, "W") ) {
420 cout << "passage en mode 0 (filaire pour les shapes)" << endl;
421 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
422 if(Ctx->NbCurrents()==0 ||
423 Ctx->NbSelected()==0)
424 Ctx->SetDisplayMode(AIS_WireFrame);
426 if(Ctx->HasOpenedContext()){
427 for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
428 Ctx->SetDisplayMode(Ctx->Interactive(),0,Standard_False);
431 for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent())
432 Ctx->SetDisplayMode(Ctx->Current(),0,Standard_False);
434 Ctx->UpdateCurrentViewer();
437 else if ( !strcasecmp(buf_ret, "Z") ) {
441 cout << "ZClipping OFF" << endl;
444 aView->SetZClippingType(V3d_OFF);
448 cout << "ZClipping ON" << endl;
451 aView->SetZClippingType(V3d_FRONT);
455 else if ( !strcasecmp(buf_ret, ",") ) {
456 ViewerTest::GetAISContext()->HilightNextDetected(ViewerTest::CurrentView());
460 else if ( !strcasecmp(buf_ret, ".") ) {
461 ViewerTest::GetAISContext()->HilightPreviousDetected(ViewerTest::CurrentView());
465 Standard_Integer Num = Draw::Atoi(buf_ret);
467 ViewerTest::StandardModeActivation(Num);
471 //==============================================================================
472 //function : VT_ProcessExpose
473 //purpose : Redraw the View on an Expose Event
474 //==============================================================================
475 void VT_ProcessExpose()
477 Handle(V3d_View) aView3d = ViewerTest::CurrentView();
478 if (!aView3d.IsNull())
484 //==============================================================================
485 //function : VT_ProcessConfigure
486 //purpose : Resize the View on an Configure Event
487 //==============================================================================
488 void VT_ProcessConfigure()
490 Handle(V3d_View) aView3d = ViewerTest::CurrentView();
491 if (aView3d.IsNull())
496 aView3d->MustBeResized();
501 //==============================================================================
502 //function : VT_ProcessButton1Press
504 //==============================================================================
505 Standard_Boolean VT_ProcessButton1Press(
508 Standard_Boolean pick,
509 Standard_Boolean shift)
511 Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
513 Standard_Real X, Y, Z;
515 ViewerTest::CurrentView()->Convert(X_Motion, Y_Motion, X, Y, Z);
517 Draw::Set(argv[1], X);
518 Draw::Set(argv[2], Y);
519 Draw::Set(argv[3], Z);}
530 //==============================================================================
531 //function : VT_ProcessButton1Release
532 //purpose : End selecting
533 //==============================================================================
534 void VT_ProcessButton1Release (Standard_Boolean theIsShift)
538 IsDragged = Standard_False;
539 Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
542 EM->ShiftSelect (Min (X_ButtonPress, X_Motion), Max (Y_ButtonPress, Y_Motion),
543 Max (X_ButtonPress, X_Motion), Min (Y_ButtonPress, Y_Motion));
547 EM->Select (Min (X_ButtonPress, X_Motion), Max (Y_ButtonPress, Y_Motion),
548 Max (X_ButtonPress, X_Motion), Min (Y_ButtonPress, Y_Motion));
553 //==============================================================================
554 //function : VT_ProcessButton3Press
555 //purpose : Start Rotation
556 //==============================================================================
557 void VT_ProcessButton3Press()
560 ViewerTest::CurrentView()->SetDegenerateModeOn();
561 ViewerTest::CurrentView()->StartRotation( X_ButtonPress, Y_ButtonPress );
564 //==============================================================================
565 //function : VT_ProcessButton3Release
566 //purpose : End rotation
567 //==============================================================================
568 void VT_ProcessButton3Release()
573 if (!DegenerateMode) ViewerTest::CurrentView()->SetDegenerateModeOff();
577 //==============================================================================
578 //function : ProcessZClipMotion
580 //==============================================================================
582 void ProcessZClipMotion()
584 Handle(V3d_View) a3DView = ViewerTest::CurrentView();
585 if ( Abs(X_Motion - X_ButtonPress) > 2 ) {
586 static Standard_Real CurZPos = 0.;
588 //Quantity_Length VDX, VDY;
589 //a3DView->Size(VDX,VDY);
590 //Standard_Real VDZ = a3DView->ZSize();
591 //printf("View size (%lf,%lf,%lf)\n", VDX, VDY, VDZ);
593 Quantity_Length dx = a3DView->Convert(X_Motion - X_ButtonPress);
595 // Front = Depth + width/2.
596 Standard_Real D = 0.5;
597 Standard_Real W = 0.1;
603 //printf("dx %lf Depth %lf Width %lf\n", dx, D, W);
605 a3DView->SetZClippingType(V3d_OFF);
606 a3DView->SetZClippingDepth(D);
607 a3DView->SetZClippingWidth(W);
608 a3DView->SetZClippingType(V3d_FRONT);
612 X_ButtonPress = X_Motion;
613 Y_ButtonPress = Y_Motion;
617 //==============================================================================
618 //function : ProcessControlButton1Motion
620 //==============================================================================
622 static void ProcessControlButton1Motion()
624 ViewerTest::CurrentView()->Zoom( X_ButtonPress, Y_ButtonPress, X_Motion, Y_Motion);
626 X_ButtonPress = X_Motion;
627 Y_ButtonPress = Y_Motion;
630 //==============================================================================
631 //function : VT_ProcessControlButton2Motion
633 //==============================================================================
634 void VT_ProcessControlButton2Motion()
636 Quantity_Length dx = ViewerTest::CurrentView()->Convert(X_Motion - X_ButtonPress);
637 Quantity_Length dy = ViewerTest::CurrentView()->Convert(Y_Motion - Y_ButtonPress);
639 dy = -dy; // Xwindow Y axis is from top to Bottom
641 ViewerTest::CurrentView()->Panning( dx, dy );
643 X_ButtonPress = X_Motion;
644 Y_ButtonPress = Y_Motion;
647 //==============================================================================
648 //function : VT_ProcessControlButton3Motion
650 //==============================================================================
651 void VT_ProcessControlButton3Motion()
655 ViewerTest::CurrentView()->Rotation (X_Motion, Y_Motion);
659 //==============================================================================
660 //function : VT_ProcessMotion
662 //==============================================================================
663 void VT_ProcessMotion()
665 //pre-hilights detected objects at mouse position
667 Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
668 EM->MoveTo(X_Motion, Y_Motion);
672 void ViewerTest::GetMousePosition(Standard_Integer& Xpix,Standard_Integer& Ypix)
674 Xpix = X_Motion;Ypix=Y_Motion;
677 //==============================================================================
678 //function : ViewProject: implements VAxo, VTop, VLeft, ...
679 //purpose : Switches to an axonometric, top, left and other views
680 //==============================================================================
682 static int ViewProject(Draw_Interpretor& di, const V3d_TypeOfOrientation ori)
684 if ( ViewerTest::CurrentView().IsNull() )
686 di<<"Call vinit before this command, please"<<"\n";
690 ViewerTest::CurrentView()->SetProj(ori);
694 //==============================================================================
696 //purpose : Switch to an Axonometric view
698 //==============================================================================
700 static int VAxo(Draw_Interpretor& di, Standard_Integer , const char** )
702 return ViewProject(di, V3d_XposYnegZpos);
705 //==============================================================================
707 //purpose : Switch to a Top View
709 //==============================================================================
711 static int VTop(Draw_Interpretor& di, Standard_Integer , const char** )
713 return ViewProject(di, V3d_Zpos);
716 //==============================================================================
718 //purpose : Switch to a Bottom View
720 //==============================================================================
722 static int VBottom(Draw_Interpretor& di, Standard_Integer , const char** )
724 return ViewProject(di, V3d_Zneg);
727 //==============================================================================
729 //purpose : Switch to a Left View
731 //==============================================================================
733 static int VLeft(Draw_Interpretor& di, Standard_Integer , const char** )
735 return ViewProject(di, V3d_Ypos);
738 //==============================================================================
740 //purpose : Switch to a Right View
742 //==============================================================================
744 static int VRight(Draw_Interpretor& di, Standard_Integer , const char** )
746 return ViewProject(di, V3d_Yneg);
749 //==============================================================================
751 //purpose : Switch to a Front View
753 //==============================================================================
755 static int VFront(Draw_Interpretor& di, Standard_Integer , const char** )
757 return ViewProject(di, V3d_Xpos);
760 //==============================================================================
762 //purpose : Switch to a Back View
764 //==============================================================================
766 static int VBack(Draw_Interpretor& di, Standard_Integer , const char** )
768 return ViewProject(di, V3d_Xneg);
771 //==============================================================================
773 //purpose : Dsiplay help on viewer Keyboead and mouse commands
775 //==============================================================================
777 static int VHelp(Draw_Interpretor& di, Standard_Integer , const char** )
780 di << "Q : Quit the application" << "\n";
782 di << "========================="<<"\n";
783 di << "F : FitAll" << "\n";
784 di << "T : TopView" << "\n";
785 di << "B : BottomView" << "\n";
786 di << "R : RightView" << "\n";
787 di << "L : LeftView" << "\n";
788 di << "A : AxonometricView" << "\n";
789 di << "D : ResetView" << "\n";
791 di << "========================="<<"\n";
792 di << "S : Shading" << "\n";
793 di << "W : Wireframe" << "\n";
794 di << "H : HidelLineRemoval" << "\n";
795 di << "U : Unset display mode" << "\n";
797 di << "========================="<<"\n";
798 di << "Selection mode "<<"\n";
799 di << "0 : Shape" <<"\n";
800 di << "1 : Vertex" <<"\n";
801 di << "2 : Edge" <<"\n";
802 di << "3 : Wire" <<"\n";
803 di << "4 : Face" <<"\n";
804 di << "5 : Shell" <<"\n";
805 di << "6 : Solid" <<"\n";
806 di << "7 : Compound" <<"\n";
808 di << "========================="<<"\n";
809 di << "Z : Switch Z clipping On/Off" << "\n";
810 di << ", : Hilight next detected" << "\n";
811 di << ". : Hilight previous detected" << "\n";
818 static Standard_Boolean Ppick = 0;
819 static Standard_Integer Pargc = 0;
820 static const char** Pargv = NULL;
823 static LRESULT WINAPI AdvViewerWindowProc( HWND hwnd,
828 if ( !ViewerTest::CurrentView().IsNull() ) {
830 WPARAM fwKeys = wParam;
835 IsDragged = Standard_False;
838 HDC hdc = GetDC( hwnd );
839 HGDIOBJ anObj = SelectObject( hdc, GetStockObject( WHITE_PEN ) );
840 SelectObject( hdc, GetStockObject( HOLLOW_BRUSH ) );
841 SetROP2( hdc, R2_NOT );
842 Rectangle( hdc, X_ButtonPress, Y_ButtonPress, X_Motion, Y_Motion );
843 ReleaseDC( hwnd, hdc );
845 const Handle(ViewerTest_EventManager) EM =
846 ViewerTest::CurrentEventManager();
847 if ( fwKeys & MK_SHIFT )
848 EM->ShiftSelect( min( X_ButtonPress, X_Motion ), max( Y_ButtonPress, Y_Motion ),
849 max( X_ButtonPress, X_Motion ), min( Y_ButtonPress, Y_Motion ));
851 EM->Select( min( X_ButtonPress, X_Motion ), max( Y_ButtonPress, Y_Motion ),
852 max( X_ButtonPress, X_Motion ), min( Y_ButtonPress, Y_Motion ));
854 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
857 if( fwKeys == MK_LBUTTON || fwKeys == ( MK_LBUTTON | MK_SHIFT ) )
859 IsDragged = Standard_True;
860 DragFirst = Standard_True;
861 X_ButtonPress = LOWORD(lParam);
862 Y_ButtonPress = HIWORD(lParam);
864 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
871 HDC hdc = GetDC( hwnd );
873 HGDIOBJ anObj = SelectObject( hdc, GetStockObject( WHITE_PEN ) );
874 SelectObject( hdc, GetStockObject( HOLLOW_BRUSH ) );
875 SetROP2( hdc, R2_NOT );
878 Rectangle( hdc, X_ButtonPress, Y_ButtonPress, X_Motion, Y_Motion );
880 DragFirst = Standard_False;
881 X_Motion = LOWORD(lParam);
882 Y_Motion = HIWORD(lParam);
884 Rectangle( hdc, X_ButtonPress, Y_ButtonPress, X_Motion, Y_Motion );
886 SelectObject( hdc, anObj );
888 ReleaseDC( hwnd, hdc );
891 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
895 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
899 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
903 static LRESULT WINAPI ViewerWindowProc( HWND hwnd,
908 /*static Standard_Boolean Ppick = 0;
909 static Standard_Integer Pargc = 0;
910 static char** Pargv = NULL;*/
914 if ( !ViewerTest::CurrentView().IsNull() ) {
919 // do not destroy the window - just hide it!
920 VT_GetWindow()->Unmap();
923 BeginPaint(hwnd, &ps);
929 VT_ProcessConfigure();
933 if ((wParam != VK_SHIFT) && (wParam != VK_CONTROL))
936 c[0] = (char) wParam;
938 VT_ProcessKeyPress (c);
946 VT_ProcessButton3Release();
953 WPARAM fwKeys = wParam;
957 X_ButtonPress = LOWORD(lParam);
958 Y_ButtonPress = HIWORD(lParam);
960 if (Msg == WM_LBUTTONDOWN)
962 if (fwKeys & MK_CONTROL)
964 Ppick = VT_ProcessButton1Press (Pargc, Pargv, Ppick, (fwKeys & MK_SHIFT));
968 VT_ProcessButton1Press (Pargc, Pargv, Ppick, (fwKeys & MK_SHIFT));
971 else if (Msg == WM_RBUTTONDOWN)
974 VT_ProcessButton3Press();
981 //cout << "\t WM_MOUSEMOVE" << endl;
982 WPARAM fwKeys = wParam;
983 X_Motion = LOWORD(lParam);
984 Y_Motion = HIWORD(lParam);
987 fwKeys & ( MK_LBUTTON|MK_MBUTTON|MK_RBUTTON ) ) {
989 X_ButtonPress = LOWORD(lParam);
990 Y_ButtonPress = HIWORD(lParam);
992 if ( fwKeys & MK_RBUTTON ) {
994 VT_ProcessButton3Press();
998 if ( fwKeys & MK_CONTROL ) {
999 if ( fwKeys & MK_LBUTTON ) {
1000 ProcessControlButton1Motion();
1002 else if ( fwKeys & MK_MBUTTON ||
1003 ((fwKeys&MK_LBUTTON) &&
1004 (fwKeys&MK_RBUTTON) ) ){
1005 VT_ProcessControlButton2Motion();
1007 else if ( fwKeys & MK_RBUTTON ) {
1008 VT_ProcessControlButton3Motion();
1012 else if ( fwKeys & MK_SHIFT ) {
1013 if ( fwKeys & MK_MBUTTON ||
1014 ((fwKeys&MK_LBUTTON) &&
1015 (fwKeys&MK_RBUTTON) ) ) {
1016 cout << "ProcessZClipMotion()" << endl;
1017 ProcessZClipMotion();
1022 if ((fwKeys & MK_MBUTTON
1023 || ((fwKeys & MK_LBUTTON) && (fwKeys & MK_RBUTTON))))
1025 ProcessZClipMotion();
1035 return( DefWindowProc( hwnd, Msg, wParam, lParam ));
1040 return DefWindowProc( hwnd, Msg, wParam, lParam );
1046 //==============================================================================
1047 //function : ViewerMainLoop
1048 //purpose : Get a Event on the view and dispatch it
1049 //==============================================================================
1052 static int ViewerMainLoop(Standard_Integer argc, const char** argv)
1055 //cout << "No yet implemented on WNT" << endl;
1056 /*static Standard_Boolean Ppick = 0;
1057 static Standard_Integer Pargc = 0;
1058 static char** Pargv = NULL;*/
1060 //Ppick = (argc > 0)? -1 : 0;
1061 Ppick = (argc > 0)? 1 : 0;
1069 cout << "Start picking" << endl;
1071 //while ( Ppick == -1 ) {
1072 while ( Ppick == 1 ) {
1073 // Wait for a VT_ProcessButton1Press() to toggle pick to 1 or 0
1074 if (GetMessage(&msg, NULL, 0, 0) ) {
1075 TranslateMessage(&msg);
1076 DispatchMessage(&msg);
1080 cout << "Picking done" << endl;
1086 #elif !defined(__APPLE__) || defined(MACOSX_USE_GLX)
1088 int min( int a, int b )
1096 int max( int a, int b )
1104 int ViewerMainLoop(Standard_Integer argc, const char** argv)
1106 { Standard_Boolean pick = argc > 0;
1110 static XEvent report;
1112 XNextEvent( display, &report );
1113 // cout << "rep type = " << report.type << endl;
1114 // cout << "rep button = " << report.xbutton.button << endl;
1116 switch ( report.type ) {
1122 case ConfigureNotify:
1124 VT_ProcessConfigure();
1133 XComposeStatus status_in_out;
1135 ret_len = XLookupString( ( XKeyEvent *)&report ,
1136 (char *) buf_ret , 10 ,
1137 &ks_ret , &status_in_out ) ;
1140 buf_ret[ret_len] = '\0' ;
1144 VT_ProcessKeyPress (buf_ret);
1149 // cout << "ButtonPress" << endl;
1151 X_ButtonPress = report.xbutton.x;
1152 Y_ButtonPress = report.xbutton.y;
1154 if (report.xbutton.button == Button1)
1156 if (report.xbutton.state & ControlMask)
1158 pick = VT_ProcessButton1Press (argc, argv, pick, (report.xbutton.state & ShiftMask));
1162 IsDragged = Standard_True;
1163 X_ButtonPress = X_ButtonPress;
1164 Y_ButtonPress = Y_ButtonPress;
1165 DragFirst = Standard_True;
1168 else if (report.xbutton.button == Button3)
1171 VT_ProcessButton3Press();
1177 // cout<<"relachement du bouton "<<(report.xbutton.button==3 ? "3": "on s'en fout") <<endl;
1178 // cout << IsDragged << endl;
1179 // cout << DragFirst << endl;
1185 Aspect_Handle aWindow = VT_GetWindow()->XWindow();
1186 GC gc = XCreateGC( display, aWindow, 0, 0 );
1187 // XSetFunction( display, gc, GXinvert );
1188 XDrawRectangle( display, aWindow, gc, min( X_ButtonPress, X_Motion ), min( Y_ButtonPress, Y_Motion ), abs( X_Motion-X_ButtonPress ), abs( Y_Motion-Y_ButtonPress ) );
1191 Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
1192 if( aContext.IsNull() )
1194 cout << "The context is null. Please use vinit before createmesh" << endl;
1198 Standard_Boolean ShiftPressed = ( report.xbutton.state & ShiftMask );
1199 if( report.xbutton.button==1 )
1203 aContext->ShiftSelect();
1204 // cout << "shift select" << endl;
1209 // cout << "select" << endl;
1214 aContext->ShiftSelect( min( X_ButtonPress, X_Motion ), min( Y_ButtonPress, Y_Motion ),
1215 max( X_ButtonPress, X_Motion ), max( Y_ButtonPress, Y_Motion ),
1216 ViewerTest::CurrentView());
1217 // cout << "shift select" << endl;
1221 aContext->Select( min( X_ButtonPress, X_Motion ), min( Y_ButtonPress, Y_Motion ),
1222 max( X_ButtonPress, X_Motion ), max( Y_ButtonPress, Y_Motion ),
1223 ViewerTest::CurrentView() );
1224 // cout << "select" << endl;
1227 VT_ProcessButton3Release();
1229 IsDragged = Standard_False;
1232 VT_ProcessButton3Release();
1239 X_Motion = report.xmotion.x;
1240 Y_Motion = report.xmotion.y;
1244 Aspect_Handle aWindow = VT_GetWindow()->XWindow();
1245 GC gc = XCreateGC( display, aWindow, 0, 0 );
1246 XSetFunction( display, gc, GXinvert );
1249 XDrawRectangle( display, aWindow, gc, min( X_ButtonPress, X_Motion ), min( Y_ButtonPress, Y_Motion ), abs( X_Motion-X_ButtonPress ), abs( Y_Motion-Y_ButtonPress ) );
1251 X_Motion = X_Motion;
1252 Y_Motion = Y_Motion;
1253 DragFirst = Standard_False;
1255 //cout << "draw rect : " << X_Motion << ", " << Y_Motion << endl;
1256 XDrawRectangle( display, aWindow, gc, min( X_ButtonPress, X_Motion ), min( Y_ButtonPress, Y_Motion ), abs( X_Motion-X_ButtonPress ), abs( Y_Motion-Y_ButtonPress ) );
1261 //cout << "MotionNotify " << X_Motion << "," << Y_Motion << endl;
1263 // remove all the ButtonMotionMask
1264 while( XCheckMaskEvent( display, ButtonMotionMask, &report) ) ;
1266 if ( ZClipIsOn && report.xmotion.state & ShiftMask ) {
1267 if ( Abs(X_Motion - X_ButtonPress) > 2 ) {
1269 Quantity_Length VDX, VDY;
1271 ViewerTest::CurrentView()->Size(VDX,VDY);
1272 Standard_Real VDZ =0 ;
1273 VDZ = ViewerTest::CurrentView()->ZSize();
1275 // printf("%lf,%lf,%lf\n", VDX, VDY, VDZ);
1276 printf("%f,%f,%f\n", VDX, VDY, VDZ);
1278 Quantity_Length dx = 0 ;
1279 dx = ViewerTest::CurrentView()->Convert(X_Motion - X_ButtonPress);
1283 dx = dx / VDX * VDZ;
1287 // Front = Depth + width/2.
1288 //ViewerTest::CurrentView()->SetZClippingDepth(dx);
1289 //ViewerTest::CurrentView()->SetZClippingWidth(0.);
1291 ViewerTest::CurrentView()->Redraw();
1295 if ( report.xmotion.state & ControlMask ) {
1296 if ( report.xmotion.state & Button1Mask ) {
1297 ProcessControlButton1Motion();
1299 else if ( report.xmotion.state & Button2Mask ) {
1300 VT_ProcessControlButton2Motion();
1302 else if ( report.xmotion.state & Button3Mask ) {
1303 VT_ProcessControlButton3Motion();
1319 //==============================================================================
1320 //function : VProcessEvents
1321 //purpose : call by Tk_CreateFileHandler() to be able to manage the
1322 // event in the Viewer window
1323 //==============================================================================
1325 static void VProcessEvents(ClientData,int)
1327 //cout << "VProcessEvents" << endl;
1330 while (XPending(display)) {
1331 ViewerMainLoop( 0, NULL);
1336 //==============================================================================
1337 //function : OSWindowSetup
1338 //purpose : Setup for the X11 window to be able to cath the event
1339 //==============================================================================
1342 static void OSWindowSetup()
1344 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
1347 Window window = VT_GetWindow()->XWindow();
1349 display = GetGraphicDriver()->GetDisplayConnection()->GetDisplay();
1350 // display = (Display *)GetG3dDevice()->XDisplay();
1352 XSynchronize(display, 1);
1354 VT_GetWindow()->Map();
1356 // X11 : For keyboard on SUN
1358 wmhints.flags = InputHint;
1361 XSetWMHints( display, window, &wmhints);
1363 XSelectInput( display, window, ExposureMask | KeyPressMask |
1364 ButtonPressMask | ButtonReleaseMask |
1365 StructureNotifyMask |
1367 Button1MotionMask | Button2MotionMask |
1371 XSynchronize(display, 0);
1380 //==============================================================================
1383 //purpose : Fitall, no DRAW arguments
1384 //Draw arg : No args
1385 //==============================================================================
1387 static int VFit(Draw_Interpretor& , Standard_Integer , const char** )
1389 const Handle(V3d_View) aView = ViewerTest::CurrentView();
1390 Handle(NIS_View) V = Handle(NIS_View)::DownCast(aView);
1391 if (V.IsNull() == Standard_False) {
1393 } else if (aView.IsNull() == Standard_False) {
1399 //==============================================================================
1401 //purpose : ZFitall, no DRAW arguments
1402 //Draw arg : No args
1403 //==============================================================================
1405 static int VZFit(Draw_Interpretor& , Standard_Integer , const char** )
1407 Handle(V3d_View) V = ViewerTest::CurrentView();
1408 if ( !V.IsNull() ) V->ZFitAll(); return 0; }
1411 static int VRepaint(Draw_Interpretor& , Standard_Integer , const char** )
1413 Handle(V3d_View) V = ViewerTest::CurrentView();
1414 if ( !V.IsNull() ) V->Redraw(); return 0;
1418 //==============================================================================
1420 //purpose : Remove all the object from the viewer
1421 //Draw arg : No args
1422 //==============================================================================
1424 static int VClear(Draw_Interpretor& , Standard_Integer , const char** )
1426 Handle(V3d_View) V = ViewerTest::CurrentView();
1428 ViewerTest::Clear();
1432 //==============================================================================
1435 //==============================================================================
1437 static int VPick(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1438 { if (ViewerTest::CurrentView().IsNull() ) return 1;
1441 di << argv[0] << "Invalid number of arguments" << "\n";
1445 while (ViewerMainLoop( argc, argv)) {
1451 //==============================================================================
1452 //function : InitViewerTest
1453 //purpose : initialisation de toutes les variables static de ViewerTest (dp)
1454 //==============================================================================
1456 void ViewerTest_InitViewerTest (const Handle(AIS_InteractiveContext)& context)
1458 Handle(V3d_Viewer) viewer = context->CurrentViewer();
1459 ViewerTest::SetAISContext(context);
1460 viewer->InitActiveViews();
1461 Handle(V3d_View) view = viewer->ActiveView();
1462 if (viewer->MoreActiveViews()) ViewerTest::CurrentView(view);
1463 ViewerTest::ResetEventManager();
1464 Handle(Aspect_Window) window = view->Window();
1465 #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
1467 VT_GetWindow() = Handle(Xw_Window)::DownCast(window);
1468 GetGraphicDriver() = viewer->Driver();
1470 static int first = 1;
1472 #if TCL_MAJOR_VERSION < 8
1473 Tk_CreateFileHandler((void*)ConnectionNumber(display),
1474 TK_READABLE, VProcessEvents, (ClientData) 0);
1476 Tk_CreateFileHandler(ConnectionNumber(display),
1477 TK_READABLE, VProcessEvents, (ClientData) 0);
1484 //==============================================================================
1486 //purpose : Load image as background
1487 //==============================================================================
1489 static int VSetBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1491 if (argc < 2 || argc > 3)
1493 di << "Usage : " << argv[0] << " imagefile [filltype] : Load image as background" << "\n";
1494 di << "filltype can be one of CENTERED, TILED, STRETCH, NONE" << "\n";
1498 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1499 if(AISContext.IsNull())
1501 di << "use 'vinit' command before " << argv[0] << "\n";
1505 Aspect_FillMethod aFillType = Aspect_FM_CENTERED;
1508 const char* szType = argv[2];
1509 if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE;
1510 else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED;
1511 else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED;
1512 else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH;
1515 di << "Wrong fill type : " << szType << "\n";
1516 di << "Must be one of CENTERED, TILED, STRETCH, NONE" << "\n";
1521 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1522 V3dView->SetBackgroundImage(argv[1], aFillType, Standard_True);
1527 //==============================================================================
1528 //function : VSetBgMode
1529 //purpose : Change background image fill type
1530 //==============================================================================
1532 static int VSetBgMode(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1536 di << "Usage : " << argv[0] << " filltype : Change background image mode" << "\n";
1537 di << "filltype must be one of CENTERED, TILED, STRETCH, NONE" << "\n";
1541 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1542 if(AISContext.IsNull())
1544 di << "use 'vinit' command before " << argv[0] << "\n";
1548 Aspect_FillMethod aFillType;
1551 const char* szType = argv[1];
1552 if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE;
1553 else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED;
1554 else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED;
1555 else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH;
1558 di << "Wrong fill type : " << szType << "\n";
1559 di << "Must be one of CENTERED, TILED, STRETCH, NONE" << "\n";
1564 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1565 V3dView->SetBgImageStyle(aFillType, Standard_True);
1570 //==============================================================================
1571 //function : VSetGradientBg
1572 //purpose : Mount gradient background
1573 //==============================================================================
1574 static int VSetGradientBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1578 di << "Usage : " << argv[0] << " R1 G1 B1 R2 G2 B2 Type : Mount gradient background" << "\n";
1579 di << "R1,G1,B1,R2,G2,B2 = [0..255]" << "\n";
1580 di << "Type must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2" << "\n";
1581 di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4" << "\n";
1585 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1586 if(AISContext.IsNull())
1588 di << "use 'vinit' command before " << argv[0] << "\n";
1594 Standard_Real R1 = Draw::Atof(argv[1])/255.;
1595 Standard_Real G1 = Draw::Atof(argv[2])/255.;
1596 Standard_Real B1 = Draw::Atof(argv[3])/255.;
1597 Quantity_Color aColor1(R1,G1,B1,Quantity_TOC_RGB);
1599 Standard_Real R2 = Draw::Atof(argv[4])/255.;
1600 Standard_Real G2 = Draw::Atof(argv[5])/255.;
1601 Standard_Real B2 = Draw::Atof(argv[6])/255.;
1603 Quantity_Color aColor2(R2,G2,B2,Quantity_TOC_RGB);
1604 int aType = Draw::Atoi(argv[7]);
1605 if( aType < 0 || aType > 8 )
1607 di << "Wrong fill type " << "\n";
1608 di << "Must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2" << "\n";
1609 di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4" << "\n";
1613 Aspect_GradientFillMethod aMethod = Aspect_GradientFillMethod(aType);
1615 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1616 V3dView->SetBgGradientColors( aColor1, aColor2, aMethod, 1);
1622 //==============================================================================
1623 //function : VSetGradientBgMode
1624 //purpose : Change gradient background fill style
1625 //==============================================================================
1626 static int VSetGradientBgMode(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1630 di << "Usage : " << argv[0] << " Type : Change gradient background fill type" << "\n";
1631 di << "Type must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2" << "\n";
1632 di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4" << "\n";
1636 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1637 if(AISContext.IsNull())
1639 di << "use 'vinit' command before " << argv[0] << "\n";
1644 int aType = Draw::Atoi(argv[1]);
1645 if( aType < 0 || aType > 8 )
1647 di << "Wrong fill type " << "\n";
1648 di << "Must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2" << "\n";
1649 di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4" << "\n";
1653 Aspect_GradientFillMethod aMethod = Aspect_GradientFillMethod(aType);
1655 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1656 V3dView->SetBgGradientStyle( aMethod, 1 );
1662 //==============================================================================
1663 //function : VSetColorBg
1664 //purpose : Set color background
1665 //==============================================================================
1666 static int VSetColorBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1670 di << "Usage : " << argv[0] << " R G B : Set color background" << "\n";
1671 di << "R,G,B = [0..255]" << "\n";
1675 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1676 if(AISContext.IsNull())
1678 di << "use 'vinit' command before " << argv[0] << "\n";
1684 Standard_Real R = Draw::Atof(argv[1])/255.;
1685 Standard_Real G = Draw::Atof(argv[2])/255.;
1686 Standard_Real B = Draw::Atof(argv[3])/255.;
1687 Quantity_Color aColor(R,G,B,Quantity_TOC_RGB);
1689 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1690 V3dView->SetBackgroundColor( aColor );
1697 //==============================================================================
1699 //purpose : View Scaling
1700 //==============================================================================
1702 static int VScale(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1704 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1705 if ( V3dView.IsNull() ) return 1;
1708 di << argv[0] << "Invalid number of arguments" << "\n";
1711 V3dView->SetAxialScale( Draw::Atof(argv[1]), Draw::Atof(argv[2]), Draw::Atof(argv[3]) );
1714 //==============================================================================
1715 //function : VTestZBuffTrihedron
1716 //purpose : Displays a V3d_ZBUFFER'ed or V3d_WIREFRAME'd trihedron
1717 //==============================================================================
1719 static int VTestZBuffTrihedron(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1721 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1722 if ( V3dView.IsNull() ) return 1;
1724 V3dView->ZBufferTriedronSetup();
1727 // Set up default trihedron parameters
1728 V3dView->TriedronDisplay( Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.1, V3d_ZBUFFER );
1732 Aspect_TypeOfTriedronPosition aPosition = Aspect_TOTP_LEFT_LOWER;
1733 const char* aPosType = argv[1];
1735 if ( strcmp(aPosType, "center") == 0 )
1737 aPosition = Aspect_TOTP_CENTER;
1739 if (strcmp(aPosType, "left_lower") == 0)
1741 aPosition = Aspect_TOTP_LEFT_LOWER;
1743 if (strcmp(aPosType, "left_upper") == 0)
1745 aPosition = Aspect_TOTP_LEFT_UPPER;
1747 if (strcmp(aPosType, "right_lower") == 0)
1749 aPosition = Aspect_TOTP_RIGHT_LOWER;
1751 if (strcmp(aPosType, "right_upper") == 0)
1753 aPosition = Aspect_TOTP_RIGHT_UPPER;
1756 di << argv[1] << " Invalid type of alignment" << "\n";
1757 di << "Must be one of [ center, left_lower," << "\n";
1758 di << "left_upper, right_lower, right_upper ]" << "\n";
1762 Standard_Real R = Draw::Atof(argv[2])/255.;
1763 Standard_Real G = Draw::Atof(argv[3])/255.;
1764 Standard_Real B = Draw::Atof(argv[4])/255.;
1765 Quantity_Color aColor(R, G, B, Quantity_TOC_RGB);
1767 Standard_Real aScale = Draw::Atof(argv[5]);
1771 di << argv[5] << " Invalid value. Must be > 0" << "\n";
1775 V3d_TypeOfVisualization aPresentation = V3d_ZBUFFER;
1776 const char* aPresType = argv[6];
1778 if ( strcmp(aPresType, "wireframe") == 0 )
1780 aPresentation = V3d_WIREFRAME;
1782 if (strcmp(aPresType, "zbuffer") == 0)
1784 aPresentation = V3d_ZBUFFER;
1787 di << argv[6] << " Invalid type of visualization" << "\n";
1788 di << "Must be one of [ wireframe, zbuffer ]" << "\n";
1792 V3dView->TriedronDisplay( aPosition, aColor.Name(), aScale, aPresentation );
1796 di << argv[0] << " Invalid number of arguments" << "\n";
1805 //==============================================================================
1806 //function : VRotate
1807 //purpose : Camera Rotating
1808 //==============================================================================
1810 static int VRotate( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) {
1811 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1812 if ( V3dView.IsNull() ) {
1817 V3dView->Rotate( Draw::Atof(argv[1]), Draw::Atof(argv[2]), Draw::Atof(argv[3]) );
1819 } else if ( argc == 7 ) {
1820 V3dView->Rotate( Draw::Atof(argv[1]), Draw::Atof(argv[2]), Draw::Atof(argv[3]), Draw::Atof(argv[4]), Draw::Atof(argv[5]), Draw::Atof(argv[6]) );
1823 di << argv[0] << " Invalid number of arguments" << "\n";
1828 //==============================================================================
1830 //purpose : View zoom in / out (relative to current zoom)
1831 //==============================================================================
1833 static int VZoom( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) {
1834 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1835 if ( V3dView.IsNull() ) {
1840 Standard_Real coef = Draw::Atof(argv[1]);
1841 if ( coef <= 0.0 ) {
1842 di << argv[1] << "Invalid value" << "\n";
1845 V3dView->SetZoom( Draw::Atof(argv[1]) );
1848 di << argv[0] << " Invalid number of arguments" << "\n";
1853 //==============================================================================
1855 //purpose : View panning (in pixels)
1856 //==============================================================================
1858 static int VPan( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) {
1859 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1860 if ( V3dView.IsNull() ) return 1;
1863 V3dView->Pan( Draw::Atoi(argv[1]), Draw::Atoi(argv[2]) );
1866 di << argv[0] << " Invalid number of arguments" << "\n";
1872 //==============================================================================
1873 //function : VExport
1874 //purpose : Export the view to a vector graphic format (PS, EMF, PDF)
1875 //==============================================================================
1877 static int VExport(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1879 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1880 if (V3dView.IsNull())
1885 std::cout << "Usage: " << argv[0] << " Filename [Format]\n";
1889 Graphic3d_ExportFormat anExpFormat = Graphic3d_EF_PDF;
1890 TCollection_AsciiString aFormatStr;
1892 TCollection_AsciiString aFileName (argv[1]);
1893 Standard_Integer aLen = aFileName.Length();
1897 aFormatStr = TCollection_AsciiString (argv[2]);
1901 if (aFileName.Value (aLen - 2) == '.')
1903 aFormatStr = aFileName.SubString (aLen - 1, aLen);
1905 else if (aFileName.Value (aLen - 3) == '.')
1907 aFormatStr = aFileName.SubString (aLen - 2, aLen);
1911 std::cout << "Export format couln't be detected from filename '" << argv[1] << "'\n";
1917 std::cout << "Export format couln't be detected from filename '" << argv[1] << "'\n";
1921 aFormatStr.UpperCase();
1922 if (aFormatStr == "PS")
1923 anExpFormat = Graphic3d_EF_PostScript;
1924 else if (aFormatStr == "EPS")
1925 anExpFormat = Graphic3d_EF_EnhPostScript;
1926 else if (aFormatStr == "TEX")
1927 anExpFormat = Graphic3d_EF_TEX;
1928 else if (aFormatStr == "PDF")
1929 anExpFormat = Graphic3d_EF_PDF;
1930 else if (aFormatStr == "SVG")
1931 anExpFormat = Graphic3d_EF_SVG;
1932 else if (aFormatStr == "PGF")
1933 anExpFormat = Graphic3d_EF_PGF;
1934 else if (aFormatStr == "EMF")
1935 anExpFormat = Graphic3d_EF_EMF;
1938 std::cout << "Invalid export format '" << aFormatStr << "'\n";
1942 if (!V3dView->View()->Export (argv[1], anExpFormat))
1944 std::cout << "Export failed!\n";
1950 //==============================================================================
1951 //function : VColorScale
1952 //purpose : representation color scale
1953 //==============================================================================
1954 #include <V3d_ColorScale.hxx>
1956 static int VColorScale (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1958 if ( argc != 1 && argc != 4 && argc != 5 && argc != 6 && argc != 8 )
1960 di << "Usage : " << argv[0] << " [RangeMin = 0 RangeMax = 100 Intervals = 10 HeightFont = 16 Position = Right X = 0 Y = 0] " << "\n";
1964 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1965 if(aContext.IsNull()) {
1966 di << argv[0] << " ERROR : use 'vinit' command before " << "\n";
1970 Standard_Real minRange = 0. , maxRange = 100. ;
1972 Standard_Integer numIntervals = 10 ;
1973 Standard_Integer textHeight = 16;
1974 Aspect_TypeOfColorScalePosition position = Aspect_TOCSP_RIGHT;
1975 Standard_Real X = 0., Y = 0. ;
1981 minRange = Draw::Atof( argv[1] );
1982 maxRange = Draw::Atof( argv[2] );
1983 numIntervals = Draw::Atoi( argv[3] );
1986 textHeight = Draw::Atoi( argv[4] );
1988 position = (Aspect_TypeOfColorScalePosition)Draw::Atoi( argv[5] );
1991 X = Draw::Atof( argv[6] );
1992 Y = Draw::Atof( argv[7] );
1995 Handle(V3d_View) curView = ViewerTest::CurrentView( );
1996 if ( curView.IsNull( ) )
1998 Handle(Aspect_ColorScale) aCSV = curView->ColorScale( );
1999 Handle(V3d_ColorScale) aCS = ( Handle( V3d_ColorScale )::DownCast( aCSV ) );
2000 if( ! aCS.IsNull( ) )
2002 aCS->SetPosition( X , Y );
2003 aCS->SetHeight( 0.95) ;
2004 aCS->SetTextHeight( textHeight );
2005 aCS->SetRange( minRange , maxRange );
2006 aCS->SetNumberOfIntervals( numIntervals );
2007 aCS->SetLabelPosition( position );
2008 if( !curView->ColorScaleIsDisplayed() )
2009 curView->ColorScaleDisplay( );
2014 //==============================================================================
2015 //function : VGraduatedTrihedron
2016 //purpose : Displays a graduated trihedron
2017 //==============================================================================
2019 static void AddMultibyteString (TCollection_ExtendedString &name, const char *arg)
2021 const char *str = arg;
2024 unsigned short c1 = *str++;
2025 unsigned short c2 = *str++;
2026 if (!c1 || !c2) break;
2027 name += (Standard_ExtCharacter)((c1 << 8) | c2);
2031 static int VGraduatedTrihedron(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2034 if (argc != 2 && argc < 5)
2036 di<<"Error: "<<argv[0]<<" - invalid number of arguments\n";
2037 di<<"Usage: type help "<<argv[0]<<"\n";
2038 return 1; //TCL_ERROR
2041 Handle(V3d_View) aV3dView = ViewerTest::CurrentView();
2043 // Create 3D view if it doesn't exist
2044 if ( aV3dView.IsNull() )
2046 ViewerTest::ViewerInit();
2047 aV3dView = ViewerTest::CurrentView();
2048 if( aV3dView.IsNull() )
2050 di << "Error: Cannot create a 3D view\n";
2051 return 1; //TCL_ERROR
2055 // Erase (==0) or display (!=0)
2056 const int display = Draw::Atoi(argv[1]);
2061 TCollection_AsciiString font;
2063 font.AssignCat("Courier");
2065 font.AssignCat(argv[5]);
2067 // Text is multibyte
2068 const Standard_Boolean isMultibyte = (argc < 7)? Standard_False : (Draw::Atoi(argv[6]) != 0);
2071 TCollection_ExtendedString xname, yname, zname;
2076 AddMultibyteString(xname, argv[2]);
2077 AddMultibyteString(yname, argv[3]);
2078 AddMultibyteString(zname, argv[4]);
2094 aV3dView->GraduatedTrihedronDisplay(xname, yname, zname,
2095 Standard_True/*xdrawname*/, Standard_True/*ydrawname*/, Standard_True/*zdrawname*/,
2096 Standard_True/*xdrawvalues*/, Standard_True/*ydrawvalues*/, Standard_True/*zdrawvalues*/,
2097 Standard_True/*drawgrid*/,
2098 Standard_True/*drawaxes*/,
2099 5/*nbx*/, 5/*nby*/, 5/*nbz*/,
2100 10/*xoffset*/, 10/*yoffset*/, 10/*zoffset*/,
2101 30/*xaxisoffset*/, 30/*yaxisoffset*/, 30/*zaxisoffset*/,
2102 Standard_True/*xdrawtickmarks*/, Standard_True/*ydrawtickmarks*/, Standard_True/*zdrawtickmarks*/,
2103 10/*xtickmarklength*/, 10/*ytickmarklength*/, 10/*ztickmarklength*/,
2104 Quantity_NOC_WHITE/*gridcolor*/,
2105 Quantity_NOC_RED/*xnamecolor*/,Quantity_NOC_GREEN/*ynamecolor*/,Quantity_NOC_BLUE1/*znamecolor*/,
2106 Quantity_NOC_RED/*xcolor*/,Quantity_NOC_GREEN/*ycolor*/,Quantity_NOC_BLUE1/*zcolor*/,font);
2109 aV3dView->GraduatedTrihedronErase();
2111 ViewerTest::GetAISContext()->UpdateCurrentViewer();
2117 //==============================================================================
2118 //function : VPrintView
2119 //purpose : Test printing algorithm, print the view to image file with given
2120 // width and height. Printing implemented only for WNT.
2121 //==============================================================================
2122 static int VPrintView (Draw_Interpretor& di, Standard_Integer argc,
2126 di << "Printing implemented only for wnt!\n";
2130 Handle(AIS_InteractiveContext) aContextAIS = NULL;
2131 Handle(V3d_View) aView = NULL;
2132 aContextAIS = ViewerTest::GetAISContext();
2133 if (!aContextAIS.IsNull())
2135 const Handle(V3d_Viewer)& Vwr = aContextAIS->CurrentViewer();
2136 Vwr->InitActiveViews();
2137 if(Vwr->MoreActiveViews())
2138 aView = Vwr->ActiveView();
2144 di << "Call vinit before!\n";
2149 di << "Use: " << argv[0];
2150 di << " width height filename [print algo=0]\n";
2151 di << "width, height of the intermediate buffer for operation\n";
2152 di << "algo : {0|1}\n";
2153 di << " 0 - stretch algorithm\n";
2154 di << " 1 - tile algorithm\n";
2155 di << "test printing algorithms into an intermediate buffer\n";
2156 di << "with saving output to an image file\n";
2160 // get the input params
2161 Standard_Integer aWidth = Draw::Atoi (argv[1]);
2162 Standard_Integer aHeight = Draw::Atoi (argv[2]);
2163 Standard_Integer aMode = 0;
2164 TCollection_AsciiString aFileName = TCollection_AsciiString (argv[3]);
2166 aMode = Draw::Atoi (argv[4]);
2168 // check the input parameters
2169 if (aWidth <= 0 || aHeight <= 0)
2171 di << "Width and height must be positive values!\n";
2174 if (aMode != 0 && aMode != 1)
2177 // define compatible bitmap
2178 HDC anDC = CreateCompatibleDC(0);
2179 BITMAPINFO aBitmapData;
2180 memset (&aBitmapData, 0, sizeof (BITMAPINFOHEADER));
2181 aBitmapData.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
2182 aBitmapData.bmiHeader.biWidth = aWidth ;
2183 aBitmapData.bmiHeader.biHeight = aHeight;
2184 aBitmapData.bmiHeader.biPlanes = 1;
2185 aBitmapData.bmiHeader.biBitCount = 24;
2186 aBitmapData.bmiHeader.biXPelsPerMeter = 0;
2187 aBitmapData.bmiHeader.biYPelsPerMeter = 0;
2188 aBitmapData.bmiHeader.biClrUsed = 0;
2189 aBitmapData.bmiHeader.biClrImportant = 0;
2190 aBitmapData.bmiHeader.biCompression = BI_RGB;
2191 aBitmapData.bmiHeader.biSizeImage = 0;
2193 // Create Device Independent Bitmap
2194 void* aBitsOut = NULL;
2195 HBITMAP aMemoryBitmap = CreateDIBSection (anDC, &aBitmapData, DIB_RGB_COLORS,
2196 &aBitsOut, NULL, 0);
2197 HGDIOBJ anOldBitmap = SelectObject(anDC, aMemoryBitmap);
2199 Standard_Boolean isSaved = Standard_False, isPrinted = Standard_False;
2200 if (aBitsOut != NULL)
2203 isPrinted = aView->Print(anDC,1,1,0,Aspect_PA_STRETCH);
2205 isPrinted = aView->Print(anDC,1,1,0,Aspect_PA_TILE);
2207 // succesfully printed into an intermediate buffer
2210 Image_PixMap aWrapper;
2211 aWrapper.InitWrapper (Image_PixMap::ImgBGR, (Standard_Byte* )aBitsOut, aWidth, aHeight, aWidth * 3 + aWidth % 4);
2212 aWrapper.SetTopDown (false);
2214 Image_AlienPixMap anImageBitmap;
2215 anImageBitmap.InitCopy (aWrapper);
2216 isSaved = anImageBitmap.Save (aFileName);
2220 di << "Print operation failed due to printing errors or\n";
2221 di << "insufficient memory available\n";
2222 di << "Please, try to use smaller dimensions for this test\n";
2223 di << "command, as it allocates intermediate buffer for storing\n";
2224 di << "the result\n";
2229 di << "Can't allocate memory for intermediate buffer\n";
2230 di << "Please use smaller dimensions\n";
2235 SelectObject (anDC, anOldBitmap);
2236 DeleteObject (aMemoryBitmap);
2242 di << "Save to file operation failed. This operation may fail\n";
2243 di << "if you don't have enough available memory, then you can\n";
2244 di << "use smaller dimensions for the output file\n";
2253 //==============================================================================
2254 //function : VZLayer
2255 //purpose : Test z layer operations for v3d viewer
2256 //==============================================================================
2257 static int VZLayer (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2259 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext ();
2260 if (aContextAIS.IsNull())
2262 di << "Call vinit before!\n";
2267 di << "Use: vzlayer " << argv[0];
2268 di << " add/del/get [id]\n";
2269 di << " add - add new z layer to viewer and print its id\n";
2270 di << " del - del z layer by its id\n";
2271 di << " get - print sequence of z layers in increasing order of their overlay level\n";
2272 di << "id - the layer identificator value defined when removing z layer\n";
2276 const Handle(V3d_Viewer)& aViewer = aContextAIS->CurrentViewer();
2277 if (aViewer.IsNull())
2279 di << "No active viewer!\n";
2283 // perform operation
2284 TCollection_AsciiString anOp = TCollection_AsciiString (argv[1]);
2287 Standard_Integer aNewId;
2288 if (!aViewer->AddZLayer (aNewId))
2290 di << "Impossible to add new z layer!\n";
2294 di << "New z layer added with index: " << aNewId << "\n";
2296 else if (anOp == "del")
2300 di << "Please also provide as argument id of z layer to remove\n";
2304 Standard_Integer aDelId = Draw::Atoi (argv[2]);
2305 if (!aViewer->RemoveZLayer (aDelId))
2307 di << "Impossible to remove the z layer or invalid id!\n";
2311 di << "Z layer " << aDelId << " has been removed\n";
2313 else if (anOp == "get")
2315 TColStd_SequenceOfInteger anIds;
2316 aViewer->GetAllZLayers (anIds);
2317 for (Standard_Integer aSeqIdx = 1; aSeqIdx <= anIds.Length(); aSeqIdx++)
2319 di << anIds.Value (aSeqIdx) << " ";
2326 di << "Invalid operation, please use { add / del / get }\n";
2333 DEFINE_STANDARD_HANDLE(V3d_TextItem, Visual3d_LayerItem)
2335 // this class provides a presentation of text item in v3d view under-/overlayer
2336 class V3d_TextItem : public Visual3d_LayerItem
2341 DEFINE_STANDARD_RTTI(V3d_TextItem)
2344 Standard_EXPORT V3d_TextItem(const TCollection_AsciiString& theText,
2345 const Standard_Real theX1,
2346 const Standard_Real theY1,
2347 const Standard_Real theHeight,
2348 const TCollection_AsciiString& theFontName,
2349 const Quantity_Color& theColor,
2350 const Quantity_Color& theSubtitleColor,
2351 const Aspect_TypeOfDisplayText& theTypeOfDisplay,
2352 const Handle(Visual3d_Layer)& theLayer);
2355 Standard_EXPORT void RedrawLayerPrs();
2361 Standard_Real myHeight;
2362 TCollection_AsciiString myText;
2363 TCollection_AsciiString myFontName;
2364 Quantity_Color myColor;
2365 Quantity_Color mySubtitleColor;
2366 Aspect_TypeOfDisplayText myType;
2367 Handle(Visual3d_Layer) myLayer;
2371 IMPLEMENT_STANDARD_HANDLE(V3d_TextItem, Visual3d_LayerItem)
2372 IMPLEMENT_STANDARD_RTTIEXT(V3d_TextItem, Visual3d_LayerItem)
2374 // create and add to display the text item
2375 V3d_TextItem::V3d_TextItem (const TCollection_AsciiString& theText,
2376 const Standard_Real theX1,
2377 const Standard_Real theY1,
2378 const Standard_Real theHeight,
2379 const TCollection_AsciiString& theFontName,
2380 const Quantity_Color& theColor,
2381 const Quantity_Color& theSubtitleColor,
2382 const Aspect_TypeOfDisplayText& theTypeOfDisplay,
2383 const Handle(Visual3d_Layer)& theLayer)
2384 : myX1 (theX1), myY1 (theY1),
2386 myHeight (theHeight),
2389 mySubtitleColor (theSubtitleColor),
2390 myType (theTypeOfDisplay),
2391 myFontName (theFontName)
2393 if (!myLayer.IsNull ())
2394 myLayer->AddLayerItem (this);
2398 void V3d_TextItem::RedrawLayerPrs ()
2400 if (myLayer.IsNull ())
2403 myLayer->SetColor (myColor);
2404 myLayer->SetTextAttributes (myFontName.ToCString (), myType, mySubtitleColor);
2405 myLayer->DrawText (myText.ToCString (), myX1, myY1, myHeight);
2408 DEFINE_STANDARD_HANDLE(V3d_LineItem, Visual3d_LayerItem)
2410 // The Visual3d_LayerItem line item for "vlayerline" command
2411 // it provides a presentation of line with user-defined
2412 // linewidth, linetype and transparency.
2413 class V3d_LineItem : public Visual3d_LayerItem
2417 DEFINE_STANDARD_RTTI(V3d_LineItem)
2420 Standard_EXPORT V3d_LineItem(Standard_Real X1, Standard_Real Y1,
2421 Standard_Real X2, Standard_Real Y2,
2422 V3d_LayerMgrPointer theLayerMgr,
2423 Aspect_TypeOfLine theType = Aspect_TOL_SOLID,
2424 Standard_Real theWidth = 0.5,
2425 Standard_Real theTransp = 1.0);
2428 Standard_EXPORT void RedrawLayerPrs();
2432 Standard_Real myX1, myY1, myX2, myY2;
2433 Standard_Real myWidth;
2434 Standard_Real myTransparency;
2435 Aspect_TypeOfLine myType;
2436 V3d_LayerMgrPointer myLayerMgr;
2439 IMPLEMENT_STANDARD_HANDLE(V3d_LineItem, Visual3d_LayerItem)
2440 IMPLEMENT_STANDARD_RTTIEXT(V3d_LineItem, Visual3d_LayerItem)
2442 // default constructor for line item
2443 V3d_LineItem::V3d_LineItem(Standard_Real X1, Standard_Real Y1,
2444 Standard_Real X2, Standard_Real Y2,
2445 V3d_LayerMgrPointer theLayerMgr,
2446 Aspect_TypeOfLine theType,
2447 Standard_Real theWidth,
2448 Standard_Real theTransp) :
2449 myX1(X1), myY1(Y1), myX2(X2), myY2(Y2), myLayerMgr(theLayerMgr),
2450 myType(theType), myWidth(theWidth), myTransparency(theTransp)
2452 if (myLayerMgr && !myLayerMgr->Overlay().IsNull())
2453 myLayerMgr->Overlay()->AddLayerItem (this);
2457 void V3d_LineItem::RedrawLayerPrs ()
2459 Handle (Visual3d_Layer) aOverlay;
2462 aOverlay = myLayerMgr->Overlay();
2464 if (!aOverlay.IsNull())
2466 Quantity_Color aColor(1.0, 0, 0, Quantity_TOC_RGB);
2467 aOverlay->SetColor(aColor);
2468 aOverlay->SetTransparency((Standard_ShortReal)myTransparency);
2469 aOverlay->SetLineAttributes((Aspect_TypeOfLine)myType, myWidth);
2470 aOverlay->BeginPolyline();
2471 aOverlay->AddVertex(myX1, myY1);
2472 aOverlay->AddVertex(myX2, myY2);
2473 aOverlay->ClosePrimitive();
2477 //=============================================================================
2478 //function : VLayerLine
2479 //purpose : Draws line in the v3d view layer with given attributes: linetype,
2480 // : linewidth, transparency coefficient
2481 //============================================================================
2482 static int VLayerLine(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2484 // get the active view
2485 Handle(V3d_View) aView = ViewerTest::CurrentView();
2488 di << "Call vinit before!\n";
2493 di << "Use: " << argv[0];
2494 di << " x1 y1 x2 y2 [linewidth = 0.5] [linetype = 0] [transparency = 1]\n";
2495 di << " linetype : { 0 | 1 | 2 | 3 } \n";
2496 di << " 0 - solid \n";
2497 di << " 1 - dashed \n";
2498 di << " 2 - dot \n";
2499 di << " 3 - dashdot\n";
2500 di << " transparency : { 0.0 - 1.0 } \n";
2501 di << " 0.0 - transparent\n";
2502 di << " 1.0 - visible \n";
2506 // get the input params
2507 Standard_Real X1 = Draw::Atof(argv[1]);
2508 Standard_Real Y1 = Draw::Atof(argv[2]);
2509 Standard_Real X2 = Draw::Atof(argv[3]);
2510 Standard_Real Y2 = Draw::Atof(argv[4]);
2512 Standard_Real aWidth = 0.5;
2513 Standard_Integer aType = 0;
2514 Standard_Real aTransparency = 1.0;
2518 aWidth = Draw::Atof(argv[5]);
2522 aType = (Standard_Integer) Draw::Atoi(argv[6]);
2527 aTransparency = Draw::Atof(argv[7]);
2528 if (aTransparency < 0 || aTransparency > 1.0)
2529 aTransparency = 1.0;
2532 // select appropriate line type
2533 Aspect_TypeOfLine aLineType;
2537 aLineType = Aspect_TOL_DASH;
2541 aLineType = Aspect_TOL_DOT;
2545 aLineType = Aspect_TOL_DOTDASH;
2549 aLineType = Aspect_TOL_SOLID;
2552 // replace layer manager
2553 Handle(V3d_LayerMgr) aMgr = new V3d_LayerMgr(aView);
2554 aView->SetLayerMgr(aMgr);
2557 Handle (V3d_LineItem) anItem = new V3d_LineItem(X1, Y1, X2, Y2,
2563 aView->MustBeResized();
2569 //=======================================================================
2570 //function : VOverlayText
2571 //purpose : Test text displaying in view overlay
2572 //=======================================================================
2573 static int VOverlayText (Draw_Interpretor& di, Standard_Integer argc, const char**argv)
2575 // get the active view
2576 Handle(V3d_View) aView = ViewerTest::CurrentView();
2579 di << "No active view. Please call vinit.\n";
2582 else if (argc < 4 || argc > 13)
2584 di << "Use: " << argv[0];
2585 di << " text x y [height] [font_name] [text_color: R G B] [displayType]\n";
2586 di << "[background_color: R G B]\n";
2587 di << " height - pixel height of the text (default=10.0)\n";
2588 di << " font_name - name of font (default=courier)\n";
2589 di << " text_color - R G B values of text color (default=255.0 255.0 255.0)\n";
2590 di << " display_type = {normal/subtitle/decal/blend}, (default=normal)\n";
2591 di << " background_color- R G B values used for subtitle and decal text\n";
2592 di << "(default=255.0 255.0 255.0)\n";
2596 TCollection_AsciiString aText (argv[1]);
2597 Standard_Real aPosX = Draw::Atof(argv[2]);
2598 Standard_Real aPosY = Draw::Atof(argv[3]);
2599 Standard_Real aHeight = (argc >= 5) ? Draw::Atof (argv[4]) : 10.0;
2602 TCollection_AsciiString aFontName = "Courier";
2604 aFontName = TCollection_AsciiString (argv[5]);
2607 Quantity_Parameter aColorRed = 1.0;
2608 Quantity_Parameter aColorGreen = 1.0;
2609 Quantity_Parameter aColorBlue = 1.0;
2612 aColorRed = Draw::Atof (argv[6])/255.;
2613 aColorGreen = Draw::Atof (argv[7])/255.;
2614 aColorBlue = Draw::Atof (argv[8])/255.;
2618 TCollection_AsciiString aDispStr;
2620 aDispStr = TCollection_AsciiString (argv[9]);
2622 Aspect_TypeOfDisplayText aTextType = Aspect_TODT_NORMAL;
2623 if (aDispStr.IsEqual ("subtitle"))
2624 aTextType = Aspect_TODT_SUBTITLE;
2625 else if (aDispStr.IsEqual ("decal"))
2626 aTextType = Aspect_TODT_DEKALE;
2627 else if (aDispStr.IsEqual ("blend"))
2628 aTextType = Aspect_TODT_BLEND;
2631 Quantity_Parameter aSubRed = 1.0;
2632 Quantity_Parameter aSubGreen = 1.0;
2633 Quantity_Parameter aSubBlue = 1.0;
2636 aSubRed = Draw::Atof (argv[10])/255.;
2637 aSubGreen = Draw::Atof (argv[11])/255.;
2638 aSubBlue = Draw::Atof (argv[12])/255.;
2641 // check fo current overlay
2642 Handle(Visual3d_Layer) anOverlay = aView->Viewer()->Viewer()->OverLayer ();
2643 if (anOverlay.IsNull ())
2645 Handle(V3d_LayerMgr) aMgr = new V3d_LayerMgr (aView);
2646 anOverlay = aMgr->Overlay ();
2647 aView->SetLayerMgr (aMgr);
2650 Quantity_Color aTextColor (aColorRed, aColorGreen,
2651 aColorBlue, Quantity_TOC_RGB);
2652 Quantity_Color aSubtColor (aSubRed, aSubGreen,
2653 aSubBlue, Quantity_TOC_RGB);
2656 Handle(V3d_TextItem) anItem = new V3d_TextItem (aText, aPosX, aPosY,
2657 aHeight, aFontName, aTextColor, aSubtColor, aTextType, anOverlay);
2660 aView->MustBeResized();
2666 //==============================================================================
2669 //==============================================================================
2671 static int VGrid (Draw_Interpretor& theDI,
2672 Standard_Integer theArgNb,
2673 const char** theArgVec)
2675 // get the active view
2676 Handle(V3d_View) aView = ViewerTest::CurrentView();
2677 Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
2678 if (aView.IsNull() || aViewer.IsNull())
2680 std::cerr << "No active view. Please call vinit.\n";
2684 Aspect_GridType aType = aViewer->GridType();
2685 Aspect_GridDrawMode aMode = aViewer->GridDrawMode();
2687 Standard_Integer anIter = 1;
2688 for (; anIter < theArgNb; ++anIter)
2690 const char* aValue = theArgVec[anIter];
2693 aType = Aspect_GT_Rectangular;
2695 else if (*aValue == 'c')
2697 aType = Aspect_GT_Circular;
2699 else if (*aValue == 'l')
2701 aMode = Aspect_GDM_Lines;
2703 else if (*aValue == 'p')
2705 aMode = Aspect_GDM_Points;
2707 else if (strcmp (aValue, "off" ) == 0)
2709 aViewer->DeactivateGrid();
2718 Standard_Integer aTail = (theArgNb - anIter);
2721 aViewer->ActivateGrid (aType, aMode);
2724 else if (aTail != 2 && aTail != 5)
2726 std::cerr << "Incorrect arguments number! Usage:\n"
2727 << "vgrid [off] [Mode={r|c}] [Type={l|p}] [OriginX OriginY [StepX/StepRadius StepY/DivNb RotAngle]]\n";
2731 Quantity_Length anOriginX, anOriginY;
2732 Quantity_PlaneAngle aRotAngle;
2733 if (aType == Aspect_GT_Rectangular)
2735 Quantity_Length aRStepX, aRStepY;
2736 aViewer->RectangularGridValues (anOriginX, anOriginY, aRStepX, aRStepY, aRotAngle);
2738 anOriginX = Draw::Atof (theArgVec[anIter++]);
2739 anOriginY = Draw::Atof (theArgVec[anIter++]);
2742 aRStepX = Draw::Atof (theArgVec[anIter++]);
2743 aRStepY = Draw::Atof (theArgVec[anIter++]);
2744 aRotAngle = Draw::Atof (theArgVec[anIter++]);
2746 aViewer->SetRectangularGridValues (anOriginX, anOriginY, aRStepX, aRStepY, aRotAngle);
2747 aViewer->ActivateGrid (aType, aMode);
2749 else if (aType == Aspect_GT_Circular)
2751 Quantity_Length aRadiusStep;
2752 Standard_Integer aDivisionNumber;
2753 aViewer->CircularGridValues (anOriginX, anOriginY, aRadiusStep, aDivisionNumber, aRotAngle);
2755 anOriginX = Draw::Atof (theArgVec[anIter++]);
2756 anOriginY = Draw::Atof (theArgVec[anIter++]);
2759 aRadiusStep = Draw::Atof (theArgVec[anIter++]);
2760 aDivisionNumber = Draw::Atoi (theArgVec[anIter++]);
2761 aRotAngle = Draw::Atof (theArgVec[anIter++]);
2764 aViewer->SetCircularGridValues (anOriginX, anOriginY, aRadiusStep, aDivisionNumber, aRotAngle);
2765 aViewer->ActivateGrid (aType, aMode);
2771 //==============================================================================
2774 //==============================================================================
2776 static int VFps (Draw_Interpretor& theDI,
2777 Standard_Integer theArgNb,
2778 const char** theArgVec)
2780 // get the active view
2781 Handle(V3d_View) aView = ViewerTest::CurrentView();
2784 std::cerr << "No active view. Please call vinit.\n";
2788 Standard_Integer aFramesNb = (theArgNb > 1) ? Draw::Atoi(theArgVec[1]) : 100;
2791 std::cerr << "Incorrect arguments!\n";
2795 // the time is meaningless for first call
2796 // due to async OpenGl rendering
2799 // redraw view in loop to estimate average values
2802 for (Standard_Integer anInter = 0; anInter < aFramesNb; ++anInter)
2808 const Standard_Real aTime = aTimer.ElapsedTime();
2809 aTimer.OSD_Chronometer::Show (aCpu);
2811 const Standard_Real aFpsAver = Standard_Real(aFramesNb) / aTime;
2812 const Standard_Real aCpuAver = aCpu / Standard_Real(aFramesNb);
2814 // return statistics
2815 theDI << "FPS: " << aFpsAver << "\n"
2816 << "CPU: " << (1000.0 * aCpuAver) << " msec\n";
2822 //==============================================================================
2825 //==============================================================================
2827 static int VVbo (Draw_Interpretor& theDI,
2828 Standard_Integer theArgNb,
2829 const char** theArgVec)
2832 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
2833 if (aContextAIS.IsNull())
2835 std::cerr << "No active view. Please call vinit.\n";
2839 Handle(Graphic3d_GraphicDriver) aDriver = aContextAIS->CurrentViewer()->Driver();
2841 if (aDriver.IsNull())
2843 std::cerr << "Graphic driver not available.\n";
2849 //theDI << "VBO: " << aDriver->ToUseVBO() << "\n";
2851 std::cerr << "Wrong number of arguments.\n";
2855 aDriver->EnableVBO (Draw::Atoi(theArgVec[1]) != 0);
2859 //==============================================================================
2860 //function : VMemGpu
2862 //==============================================================================
2864 static int VMemGpu (Draw_Interpretor& theDI,
2865 Standard_Integer theArgNb,
2866 const char** theArgVec)
2869 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
2870 if (aContextAIS.IsNull())
2872 std::cerr << "No active view. Please call vinit.\n";
2876 Handle(Graphic3d_GraphicDriver) aDriver = aContextAIS->CurrentViewer()->Driver();
2878 if (aDriver.IsNull())
2880 std::cerr << "Graphic driver not available.\n";
2884 Standard_Size aFreeBytes = 0;
2885 TCollection_AsciiString anInfo;
2886 if (!aDriver->MemoryInfo (aFreeBytes, anInfo))
2888 std::cerr << "Information not available.\n";
2892 if (theArgNb > 1 && *theArgVec[1] == 'f')
2894 theDI << Standard_Real (aFreeBytes);
2904 // ==============================================================================
2905 // function : VReadPixel
2907 // ==============================================================================
2908 static int VReadPixel (Draw_Interpretor& theDI,
2909 Standard_Integer theArgNb,
2910 const char** theArgVec)
2912 // get the active view
2913 Handle(V3d_View) aView = ViewerTest::CurrentView();
2916 std::cerr << "No active view. Please call vinit.\n";
2919 else if (theArgNb < 3)
2921 std::cerr << "Usage : " << theArgVec[0] << " xPixel yPixel [{rgb|rgba|depth|hls|rgbf|rgbaf}=rgba] [name]\n";
2925 Image_PixMap::ImgFormat aFormat = Image_PixMap::IsBigEndianHost() ? Image_PixMap::ImgRGBA : Image_PixMap::ImgBGRA;
2926 Graphic3d_BufferType aBufferType = Graphic3d_BT_RGBA;
2928 Standard_Integer aWidth, aHeight;
2929 aView->Window()->Size (aWidth, aHeight);
2930 const Standard_Integer anX = Draw::Atoi (theArgVec[1]);
2931 const Standard_Integer anY = Draw::Atoi (theArgVec[2]);
2932 if (anX < 0 || anX >= aWidth || anY < 0 || anY > aHeight)
2934 std::cerr << "Pixel coordinates (" << anX << "; " << anY << ") are out of view (" << aWidth << " x " << aHeight << ")\n";
2938 Standard_Boolean toShowName = Standard_False;
2939 Standard_Boolean toShowHls = Standard_False;
2940 for (Standard_Integer anIter = 3; anIter < theArgNb; ++anIter)
2942 TCollection_AsciiString aParam (theArgVec[anIter]);
2943 if (TCollection_AsciiString::ISSIMILAR (aParam, TCollection_AsciiString ("rgb")))
2945 aFormat = Image_PixMap::IsBigEndianHost() ? Image_PixMap::ImgRGB : Image_PixMap::ImgBGR;
2946 aBufferType = Graphic3d_BT_RGB;
2948 else if (TCollection_AsciiString::ISSIMILAR (aParam, TCollection_AsciiString ("hls")))
2950 aFormat = Image_PixMap::IsBigEndianHost() ? Image_PixMap::ImgRGB : Image_PixMap::ImgBGR;
2951 aBufferType = Graphic3d_BT_RGB;
2952 toShowHls = Standard_True;
2954 else if (TCollection_AsciiString::ISSIMILAR (aParam, TCollection_AsciiString ("rgbf")))
2956 aFormat = Image_PixMap::ImgRGBF;
2957 aBufferType = Graphic3d_BT_RGB;
2959 else if (TCollection_AsciiString::ISSIMILAR (aParam, TCollection_AsciiString ("rgba")))
2961 aFormat = Image_PixMap::IsBigEndianHost() ? Image_PixMap::ImgRGBA : Image_PixMap::ImgBGRA;
2962 aBufferType = Graphic3d_BT_RGBA;
2964 else if (TCollection_AsciiString::ISSIMILAR (aParam, TCollection_AsciiString ("rgbaf")))
2966 aFormat = Image_PixMap::ImgRGBAF;
2967 aBufferType = Graphic3d_BT_RGBA;
2969 else if (TCollection_AsciiString::ISSIMILAR (aParam, TCollection_AsciiString ("depth")))
2971 aFormat = Image_PixMap::ImgGrayF;
2972 aBufferType = Graphic3d_BT_Depth;
2974 else if (TCollection_AsciiString::ISSIMILAR (aParam, TCollection_AsciiString ("name")))
2976 toShowName = Standard_True;
2980 Image_PixMap anImage;
2981 if (!anImage.InitTrash (aFormat, aWidth, aHeight))
2983 std::cerr << "Image allocation failed\n";
2986 else if (!aView->ToPixMap (anImage, aWidth, aHeight, aBufferType))
2988 std::cerr << "Image dump failed\n";
2992 Quantity_Parameter anAlpha;
2993 Quantity_Color aColor = anImage.PixelColor (anX, anY, anAlpha);
2996 if (aBufferType == Graphic3d_BT_RGBA)
2998 theDI << Quantity_Color::StringName (aColor.Name()) << " " << anAlpha << "\n";
3002 theDI << Quantity_Color::StringName (aColor.Name()) << "\n";
3007 switch (aBufferType)
3010 case Graphic3d_BT_RGB:
3014 theDI << aColor.Hue() << " " << aColor.Light() << " " << aColor.Saturation() << "\n";
3018 theDI << aColor.Red() << " " << aColor.Green() << " " << aColor.Blue() << "\n";
3022 case Graphic3d_BT_RGBA:
3024 theDI << aColor.Red() << " " << aColor.Green() << " " << aColor.Blue() << " " << anAlpha << "\n";
3027 case Graphic3d_BT_Depth:
3029 theDI << aColor.Red() << "\n";
3038 //==============================================================================
3039 //function : VDiffImage
3040 //purpose : The draw-command compares two images.
3041 //==============================================================================
3043 static int VDiffImage (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3047 theDI << "Not enough arguments.\n";
3052 const char* anImgPathRef = theArgVec[1];
3053 const char* anImgPathNew = theArgVec[2];
3055 // get string tolerance and check its validity
3056 Standard_Real aTolColor = Draw::Atof (theArgVec[3]);
3057 if (aTolColor < 0.0)
3059 if (aTolColor > 1.0)
3062 Standard_Boolean toBlackWhite = (Draw::Atoi (theArgVec[4]) == 1);
3063 Standard_Boolean isBorderFilterOn = (Draw::Atoi (theArgVec[5]) == 1);
3065 // image file of difference
3066 const char* aDiffImagePath = (theArgNb >= 7) ? theArgVec[6] : NULL;
3068 // compare the images
3069 Image_Diff aComparer;
3070 if (!aComparer.Init (anImgPathRef, anImgPathNew, toBlackWhite))
3075 aComparer.SetColorTolerance (aTolColor);
3076 aComparer.SetBorderFilterOn (isBorderFilterOn);
3077 Standard_Integer aDiffColorsNb = aComparer.Compare();
3078 theDI << aDiffColorsNb << "\n";
3080 // save image of difference
3081 if (aDiffImagePath != NULL)
3083 aComparer.SaveDiffImage (aDiffImagePath);
3089 //=======================================================================
3090 //function : VSelect
3091 //purpose : Emulates different types of selection by mouse:
3092 // 1) single click selection
3093 // 2) selection with rectangle having corners at pixel positions (x1,y1) and (x2,y2)
3094 // 3) selection with polygon having corners at
3095 // pixel positions (x1,y1),...,(xn,yn)
3096 // 4) any of these selections with shift button pressed
3097 //=======================================================================
3098 static Standard_Integer VSelect (Draw_Interpretor& di,
3099 Standard_Integer argc,
3104 di << "Usage : " << argv[0] << " x1 y1 [x2 y2 [... xn yn]] [shift_selection = 1|0]" << "\n";
3108 Handle(AIS_InteractiveContext) myAIScontext = ViewerTest::GetAISContext();
3109 if(myAIScontext.IsNull())
3111 di << "use 'vinit' command before " << argv[0] << "\n";
3114 const Standard_Boolean isShiftSelection = (argc>3 && !(argc%2) && (atoi(argv[argc-1])==1));
3115 Handle(ViewerTest_EventManager) aCurrentEventManager = ViewerTest::CurrentEventManager();
3116 aCurrentEventManager->MoveTo(atoi(argv[1]),atoi(argv[2]));
3119 if(isShiftSelection)
3120 aCurrentEventManager->ShiftSelect();
3122 aCurrentEventManager->Select();
3126 if(isShiftSelection)
3127 aCurrentEventManager->ShiftSelect(atoi(argv[1]),atoi(argv[2]),atoi(argv[3]),atoi(argv[4]));
3129 aCurrentEventManager->Select(atoi(argv[1]),atoi(argv[2]),atoi(argv[3]),atoi(argv[4]));
3133 Standard_Integer anUpper = 0;
3135 if(isShiftSelection)
3136 anUpper = (argc-1)/2;
3139 TColgp_Array1OfPnt2d aPolyline(1,anUpper);
3141 for(Standard_Integer i=1;i<=anUpper;++i)
3142 aPolyline.SetValue(i,gp_Pnt2d(atoi(argv[2*i-1]),atoi(argv[2*i])));
3144 if(isShiftSelection)
3145 aCurrentEventManager->ShiftSelect(aPolyline);
3147 aCurrentEventManager->Select(aPolyline);
3152 //=======================================================================
3153 //function : VMoveTo
3154 //purpose : Emulates cursor movement to defined pixel position
3155 //=======================================================================
3156 static Standard_Integer VMoveTo (Draw_Interpretor& di,
3157 Standard_Integer argc,
3162 di << "Usage : " << argv[0] << " x y" << "\n";
3166 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
3167 if(aContext.IsNull())
3169 di << "use 'vinit' command before " << argv[0] << "\n";
3172 ViewerTest::CurrentEventManager()->MoveTo(atoi(argv[1]),atoi(argv[2]));
3176 //=======================================================================
3177 //function : VViewParams
3178 //purpose : Gets or sets AIS View characteristics
3179 //=======================================================================
3180 static Standard_Integer VViewParams (Draw_Interpretor& di,
3181 Standard_Integer argc,
3184 if ( argc != 1 && argc != 13)
3186 di << "Usage : " << argv[0] << "\n";
3189 Handle (V3d_View) anAISView = ViewerTest::CurrentView ();
3190 if ( anAISView.IsNull () )
3192 di << "use 'vinit' command before " << argv[0] << "\n";
3196 Quantity_Factor anAISViewScale = anAISView -> V3d_View::Scale ();
3197 Standard_Real anAISViewCenterCoordinateX = 0.0;
3198 Standard_Real anAISViewCenterCoordinateY = 0.0;
3199 anAISView -> V3d_View::Center (anAISViewCenterCoordinateX, anAISViewCenterCoordinateY);
3200 Standard_Real anAISViewProjX = 0.0;
3201 Standard_Real anAISViewProjY = 0.0;
3202 Standard_Real anAISViewProjZ = 0.0;
3203 anAISView -> V3d_View::Proj (anAISViewProjX, anAISViewProjY, anAISViewProjZ);
3204 Standard_Real anAISViewUpX = 0.0;
3205 Standard_Real anAISViewUpY = 0.0;
3206 Standard_Real anAISViewUpZ = 0.0;
3207 anAISView -> V3d_View::Up (anAISViewUpX, anAISViewUpY, anAISViewUpZ);
3208 Standard_Real anAISViewAtX = 0.0;
3209 Standard_Real anAISViewAtY = 0.0;
3210 Standard_Real anAISViewAtZ = 0.0;
3211 anAISView -> V3d_View::At (anAISViewAtX, anAISViewAtY, anAISViewAtZ);
3212 di << "Scale of current view: " << anAISViewScale << "\n";
3213 di << "Center on X : "<< anAISViewCenterCoordinateX << "; on Y: " << anAISViewCenterCoordinateY << "\n";
3214 di << "Proj on X : " << anAISViewProjX << "; on Y: " << anAISViewProjY << "; on Z: " << anAISViewProjZ << "\n";
3215 di << "Up on X : " << anAISViewUpX << "; on Y: " << anAISViewUpY << "; on Z: " << anAISViewUpZ << "\n";
3216 di << "At on X : " << anAISViewAtX << "; on Y: " << anAISViewAtY << "; on Z: " << anAISViewAtZ << "\n";
3220 Quantity_Factor anAISViewScale = atof (argv [1]);
3221 Standard_Real anAISViewCenterCoordinateX = atof (argv [2]);
3222 Standard_Real anAISViewCenterCoordinateY = atof (argv [3]);
3223 Standard_Real anAISViewProjX = atof (argv [4]);
3224 Standard_Real anAISViewProjY = atof (argv [5]);
3225 Standard_Real anAISViewProjZ = atof (argv [6]);
3226 Standard_Real anAISViewUpX = atof (argv [7]);
3227 Standard_Real anAISViewUpY = atof (argv [8]);
3228 Standard_Real anAISViewUpZ = atof (argv [9]);
3229 Standard_Real anAISViewAtX = atof (argv [10]);
3230 Standard_Real anAISViewAtY = atof (argv [11]);
3231 Standard_Real anAISViewAtZ = atof (argv [12]);
3232 anAISView -> V3d_View::SetScale (anAISViewScale);
3233 anAISView -> V3d_View::SetCenter (anAISViewCenterCoordinateX, anAISViewCenterCoordinateY);
3234 anAISView -> V3d_View::SetAt (anAISViewAtX, anAISViewAtY, anAISViewAtZ);
3235 anAISView -> V3d_View::SetProj (anAISViewProjX, anAISViewProjY, anAISViewProjZ);
3236 anAISView -> V3d_View::SetUp (anAISViewUpX, anAISViewUpY, anAISViewUpZ);
3241 //=======================================================================
3242 //function : VChangeSelected
3243 //purpose : Adds the shape to selection or remove one from it
3244 //=======================================================================
3245 static Standard_Integer VChangeSelected (Draw_Interpretor& di,
3246 Standard_Integer argc,
3251 di<<"Usage : " << argv[0] << " shape \n";
3255 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
3256 ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS();
3257 TCollection_AsciiString aName(argv[1]);
3258 Handle(AIS_InteractiveObject) anAISObject;
3260 if(!aMap.IsBound2(aName))
3262 di<<"Use 'vdisplay' before";
3267 anAISObject = Handle(AIS_InteractiveObject)::DownCast(aMap.Find2(aName));
3268 if(anAISObject.IsNull()){
3269 di<<"No interactive object \n";
3273 if(aContext->HasOpenedContext())
3275 aContext->AddOrRemoveSelected(anAISObject);
3279 aContext->AddOrRemoveCurrentObject(anAISObject);
3285 //=======================================================================
3286 //function : VZClipping
3287 //purpose : Gets or sets ZClipping mode, width and depth
3288 //=======================================================================
3289 static Standard_Integer VZClipping (Draw_Interpretor& di,
3290 Standard_Integer argc,
3295 di << "Usage : " << argv[0] << " [mode] [depth width]" << "\n"
3296 <<"mode = OFF|BACK|FRONT|SLICE depth = [0..1] width = [0..1]" << "\n";
3299 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
3300 if(aContext.IsNull())
3302 di << "use 'vinit' command before " << argv[0] << "\n";
3305 Handle(V3d_View) aView = ViewerTest::CurrentView();
3306 V3d_TypeOfZclipping aZClippingMode;
3309 TCollection_AsciiString aZClippingModeString;
3310 Quantity_Length aDepth, aWidth;
3311 aZClippingMode = aView->ZClipping(aDepth, aWidth);
3312 switch (aZClippingMode)
3315 aZClippingModeString.Copy("OFF");
3318 aZClippingModeString.Copy("BACK");
3321 aZClippingModeString.Copy("FRONT");
3324 aZClippingModeString.Copy("SLICE");
3327 aZClippingModeString.Copy(TCollection_AsciiString(aZClippingMode));
3330 di << "ZClippingMode = " << aZClippingModeString.ToCString() << "\n"
3331 << "ZClipping depth = " << aDepth << "\n"
3332 << "ZClipping width = " << aWidth << "\n";
3338 Standard_Integer aStatus = 0;
3339 if ( strcmp (argv [1], "OFF") == 0 ) {
3341 aZClippingMode = V3d_OFF;
3343 if ( strcmp (argv [1], "BACK") == 0 ) {
3345 aZClippingMode = V3d_BACK;
3347 if ( strcmp (argv [1], "FRONT") == 0 ) {
3349 aZClippingMode = V3d_FRONT;
3351 if ( strcmp (argv [1], "SLICE") == 0 ) {
3353 aZClippingMode = V3d_SLICE;
3357 di << "Bad mode; Usage : " << argv[0] << " [mode] [depth width]" << "\n"
3358 << "mode = OFF|BACK|FRONT|SLICE depth = [0..1] width = [0..1]" << "\n";
3361 aView->SetZClippingType(aZClippingMode);
3365 Quantity_Length aDepth = 0., aWidth = 1.;
3368 aDepth = atof(argv[1]);
3369 aWidth = atof(argv[2]);
3373 aDepth = atof(argv[2]);
3374 aWidth = atof(argv[3]);
3377 if(aDepth<0. || aDepth>1.)
3379 di << "Bad depth; Usage : " << argv[0] << " [mode] [depth width]" << "\n"
3380 << "mode = OFF|BACK|FRONT|SLICE depth = [0..1] width = [0..1]" << "\n";
3383 if(aWidth<0. || aWidth>1.)
3385 di << "Bad width; Usage : " << argv[0] << " [mode] [depth width]" << "\n"
3386 << "mode = OFF|BACK|FRONT|SLICE depth = [0..1] width = [0..1]" << "\n";
3390 aView->SetZClippingDepth(aDepth);
3391 aView->SetZClippingWidth(aWidth);
3398 //=======================================================================
3399 //function : VNbSelected
3400 //purpose : Returns number of selected objects
3401 //=======================================================================
3402 static Standard_Integer VNbSelected (Draw_Interpretor& di,
3403 Standard_Integer argc,
3408 di << "Usage : " << argv[0] << "\n";
3411 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
3412 if(aContext.IsNull())
3414 di << "use 'vinit' command before " << argv[0] << "\n";
3417 di << aContext->NbSelected() << "\n";
3421 //=======================================================================
3422 //function : VAntialiasing
3423 //purpose : Switches altialiasing on or off
3424 //=======================================================================
3425 static Standard_Integer VAntialiasing (Draw_Interpretor& di,
3426 Standard_Integer argc,
3431 di << "Usage : " << argv[0] << " [1|0]" << "\n";
3435 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
3436 if(aContext.IsNull())
3438 di << "use 'vinit' command before " << argv[0] << "\n";
3442 Handle(V3d_View) aView = ViewerTest::CurrentView();
3444 if((argc == 2) && (atof(argv[1]) == 0))
3445 aView->SetAntialiasingOff();
3447 aView->SetAntialiasingOn();
3452 //=======================================================================
3453 //function : VPurgeDisplay
3454 //purpose : Switches altialiasing on or off
3455 //=======================================================================
3456 static Standard_Integer VPurgeDisplay (Draw_Interpretor& di,
3457 Standard_Integer argc,
3462 di << "Usage : " << argv[0] << " [CollectorToo = 0|1]" << "\n";
3465 Standard_Boolean isCollectorToo = Standard_False;
3468 isCollectorToo = (atoi(argv [1]) != 0);
3470 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
3471 if (aContext.IsNull())
3473 di << "use 'vinit' command before " << argv[0] << "\n";
3476 aContext->CloseAllContexts(Standard_False);
3477 di << aContext->PurgeDisplay(isCollectorToo) << "\n";
3481 //=======================================================================
3482 //function : VSetViewSize
3484 //=======================================================================
3485 static Standard_Integer VSetViewSize (Draw_Interpretor& di,
3486 Standard_Integer argc,
3489 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
3490 if(aContext.IsNull())
3492 di << "use 'vinit' command before " << argv[0] << "\n";
3497 di<<"Usage : " << argv[0] << " Size\n";
3500 Standard_Real aSize = atof(argv[1]);
3503 di<<"Bad Size value : " << aSize << "\n";
3507 Handle(V3d_View) aView = ViewerTest::CurrentView();
3508 aView->SetSize(aSize);
3512 //=======================================================================
3513 //function : VMoveView
3515 //=======================================================================
3516 static Standard_Integer VMoveView (Draw_Interpretor& di,
3517 Standard_Integer argc,
3520 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
3521 if(aContext.IsNull())
3523 di << "use 'vinit' command before " << argv[0] << "\n";
3526 if(argc < 4 || argc > 5)
3528 di<<"Usage : " << argv[0] << " Dx Dy Dz [Start = 1|0]\n";
3531 Standard_Real Dx = atof(argv[1]);
3532 Standard_Real Dy = atof(argv[2]);
3533 Standard_Real Dz = atof(argv[3]);
3534 Standard_Boolean aStart = Standard_True;
3537 aStart = (atoi(argv[4]) > 0);
3540 Handle(V3d_View) aView = ViewerTest::CurrentView();
3541 aView->Move(Dx,Dy,Dz,aStart);
3545 //=======================================================================
3546 //function : VTranslateView
3548 //=======================================================================
3549 static Standard_Integer VTranslateView (Draw_Interpretor& di,
3550 Standard_Integer argc,
3553 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
3554 if(aContext.IsNull())
3556 di << "use 'vinit' command before " << argv[0] << "\n";
3559 if(argc < 4 || argc > 5)
3561 di<<"Usage : " << argv[0] << " Dx Dy Dz [Start = 1|0]\n";
3564 Standard_Real Dx = atof(argv[1]);
3565 Standard_Real Dy = atof(argv[2]);
3566 Standard_Real Dz = atof(argv[3]);
3567 Standard_Boolean aStart = Standard_True;
3570 aStart = (atoi(argv[4]) > 0);
3573 Handle(V3d_View) aView = ViewerTest::CurrentView();
3574 aView->Translate(Dx,Dy,Dz,aStart);
3578 //=======================================================================
3579 //function : VTurnView
3581 //=======================================================================
3582 static Standard_Integer VTurnView (Draw_Interpretor& di,
3583 Standard_Integer argc,
3586 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
3587 if(aContext.IsNull()) {
3588 di << "use 'vinit' command before " << argv[0] << "\n";
3591 if(argc < 4 || argc > 5){
3592 di<<"Usage : " << argv[0] << " Ax Ay Az [Start = 1|0]\n";
3595 Standard_Real Ax = atof(argv[1]);
3596 Standard_Real Ay = atof(argv[2]);
3597 Standard_Real Az = atof(argv[3]);
3598 Standard_Boolean aStart = Standard_True;
3601 aStart = (atoi(argv[4]) > 0);
3604 Handle(V3d_View) aView = ViewerTest::CurrentView();
3605 aView->Turn(Ax,Ay,Az,aStart);
3609 //==============================================================================
3610 //function : VTextureEnv
3611 //purpose : ENables or disables environment mapping
3612 //==============================================================================
3613 class OCC_TextureEnv : public Graphic3d_TextureEnv
3616 OCC_TextureEnv(const Standard_CString FileName);
3617 OCC_TextureEnv(const Graphic3d_NameOfTextureEnv aName);
3618 void SetTextureParameters(const Standard_Boolean theRepeatFlag,
3619 const Standard_Boolean theModulateFlag,
3620 const Graphic3d_TypeOfTextureFilter theFilter,
3621 const Standard_ShortReal theXScale,
3622 const Standard_ShortReal theYScale,
3623 const Standard_ShortReal theXShift,
3624 const Standard_ShortReal theYShift,
3625 const Standard_ShortReal theAngle);
3626 DEFINE_STANDARD_RTTI(OCC_TextureEnv);
3628 DEFINE_STANDARD_HANDLE(OCC_TextureEnv, Graphic3d_TextureEnv);
3629 IMPLEMENT_STANDARD_HANDLE(OCC_TextureEnv, Graphic3d_TextureEnv);
3630 IMPLEMENT_STANDARD_RTTIEXT(OCC_TextureEnv, Graphic3d_TextureEnv);
3632 OCC_TextureEnv::OCC_TextureEnv(const Standard_CString theFileName)
3633 : Graphic3d_TextureEnv(theFileName)
3637 OCC_TextureEnv::OCC_TextureEnv(const Graphic3d_NameOfTextureEnv theTexId)
3638 : Graphic3d_TextureEnv(theTexId)
3642 void OCC_TextureEnv::SetTextureParameters(const Standard_Boolean theRepeatFlag,
3643 const Standard_Boolean theModulateFlag,
3644 const Graphic3d_TypeOfTextureFilter theFilter,
3645 const Standard_ShortReal theXScale,
3646 const Standard_ShortReal theYScale,
3647 const Standard_ShortReal theXShift,
3648 const Standard_ShortReal theYShift,
3649 const Standard_ShortReal theAngle)
3651 myParams->SetRepeat (theRepeatFlag);
3652 myParams->SetModulate (theModulateFlag);
3653 myParams->SetFilter (theFilter);
3654 myParams->SetScale (Graphic3d_Vec2(theXScale, theYScale));
3655 myParams->SetTranslation(Graphic3d_Vec2(theXShift, theYShift));
3656 myParams->SetRotation (theAngle);
3659 static int VTextureEnv (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
3661 // get the active view
3662 Handle(V3d_View) aView = ViewerTest::CurrentView();
3665 std::cerr << "No active view. Please call vinit.\n";
3669 // Checking the input arguments
3670 Standard_Boolean anEnableFlag = Standard_False;
3671 Standard_Boolean isOk = theArgNb >= 2;
3674 TCollection_AsciiString anEnableOpt(theArgVec[1]);
3675 anEnableFlag = anEnableOpt.IsEqual("on");
3676 isOk = anEnableFlag || anEnableOpt.IsEqual("off");
3680 isOk = (theArgNb == 3 || theArgNb == 11);
3683 TCollection_AsciiString aTextureOpt(theArgVec[2]);
3684 isOk = (!aTextureOpt.IsIntegerValue() ||
3685 (aTextureOpt.IntegerValue() >= 0 && aTextureOpt.IntegerValue() < Graphic3d_NOT_ENV_UNKNOWN));
3687 if (isOk && theArgNb == 11)
3689 TCollection_AsciiString aRepeatOpt (theArgVec[3]),
3690 aModulateOpt(theArgVec[4]),
3691 aFilterOpt (theArgVec[5]),
3692 aSScaleOpt (theArgVec[6]),
3693 aTScaleOpt (theArgVec[7]),
3694 aSTransOpt (theArgVec[8]),
3695 aTTransOpt (theArgVec[9]),
3696 anAngleOpt (theArgVec[10]);
3697 isOk = ((aRepeatOpt. IsEqual("repeat") || aRepeatOpt. IsEqual("clamp")) &&
3698 (aModulateOpt.IsEqual("modulate") || aModulateOpt.IsEqual("decal")) &&
3699 (aFilterOpt. IsEqual("nearest") || aFilterOpt. IsEqual("bilinear") || aFilterOpt.IsEqual("trilinear")) &&
3700 aSScaleOpt.IsRealValue() && aTScaleOpt.IsRealValue() &&
3701 aSTransOpt.IsRealValue() && aTTransOpt.IsRealValue() &&
3702 anAngleOpt.IsRealValue());
3709 std::cerr << "Usage :" << std::endl;
3710 std::cerr << theArgVec[0] << " off" << std::endl;
3711 std::cerr << theArgVec[0] << " on {index_of_std_texture(0..7)|texture_file_name} [{clamp|repeat} {decal|modulate} {nearest|bilinear|trilinear} scale_s scale_t translation_s translation_t rotation_degrees]" << std::endl;
3717 TCollection_AsciiString aTextureOpt(theArgVec[2]);
3718 Handle(OCC_TextureEnv) aTexEnv = aTextureOpt.IsIntegerValue() ?
3719 new OCC_TextureEnv((Graphic3d_NameOfTextureEnv)aTextureOpt.IntegerValue()) :
3720 new OCC_TextureEnv(theArgVec[2]);
3724 TCollection_AsciiString aRepeatOpt(theArgVec[3]), aModulateOpt(theArgVec[4]), aFilterOpt(theArgVec[5]);
3725 aTexEnv->SetTextureParameters(
3726 aRepeatOpt. IsEqual("repeat"),
3727 aModulateOpt.IsEqual("modulate"),
3728 aFilterOpt. IsEqual("nearest") ? Graphic3d_TOTF_NEAREST :
3729 aFilterOpt.IsEqual("bilinear") ? Graphic3d_TOTF_BILINEAR :
3730 Graphic3d_TOTF_TRILINEAR,
3731 (Standard_ShortReal)Draw::Atof(theArgVec[6]),
3732 (Standard_ShortReal)Draw::Atof(theArgVec[7]),
3733 (Standard_ShortReal)Draw::Atof(theArgVec[8]),
3734 (Standard_ShortReal)Draw::Atof(theArgVec[9]),
3735 (Standard_ShortReal)Draw::Atof(theArgVec[10])
3738 aView->SetTextureEnv(aTexEnv);
3739 aView->SetSurfaceDetail(V3d_TEX_ENVIRONMENT);
3741 else // Disabling environment mapping
3743 aView->SetSurfaceDetail(V3d_TEX_NONE);
3744 Handle(Graphic3d_TextureEnv) aTexture;
3745 aView->SetTextureEnv(aTexture); // Passing null handle to clear the texture data
3752 //=======================================================================
3753 //function : ViewerCommands
3755 //=======================================================================
3757 void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
3760 const char *group = "ZeViewer";
3761 theCommands.Add("vinit" ,
3762 "vinit : vinit [leftPx topPx widthPx heightPx] : Create the Viewer window",
3763 __FILE__,VInit,group);
3764 theCommands.Add("vhelp" ,
3765 "vhelp : display help on the viewer commands",
3766 __FILE__,VHelp,group);
3767 theCommands.Add("vtop" ,
3768 "vtop or <T> : Top view" ,
3769 __FILE__,VTop,group);
3770 theCommands.Add("vbottom" ,
3771 "vbottom : Bottom view" ,
3772 __FILE__,VBottom,group);
3773 theCommands.Add("vleft" ,
3774 "vleft : Left view" ,
3775 __FILE__,VLeft,group);
3776 theCommands.Add("vright" ,
3777 "vright : Right view" ,
3778 __FILE__,VRight,group);
3779 theCommands.Add("vaxo" ,
3780 " vaxo or <A> : Axonometric view ",
3781 __FILE__,VAxo,group);
3782 theCommands.Add("vfront" ,
3783 "vfront : Front view" ,
3784 __FILE__,VFront,group);
3785 theCommands.Add("vback" ,
3786 "vback : Back view" ,
3787 __FILE__,VBack,group);
3788 theCommands.Add("vpick" ,
3789 "vpick : vpick X Y Z [shape subshape] ( all variables as string )",
3791 theCommands.Add("vfit" ,
3792 "vfit or <F> : vfit",
3793 __FILE__,VFit,group);
3794 theCommands.Add("vzfit" ,
3796 __FILE__,VZFit,group);
3797 theCommands.Add("vrepaint",
3798 "vrepaint : vrepaint, force redraw",
3799 __FILE__,VRepaint,group);
3800 theCommands.Add("vclear",
3802 __FILE__,VClear,group);
3803 theCommands.Add("vsetbg",
3804 "vsetbg : vsetbg imagefile [filltype] : Load image as background",
3805 __FILE__,VSetBg,group);
3806 theCommands.Add("vsetbgmode",
3807 "vsetbgmode : vsetbgmode filltype : Change background image fill type",
3808 __FILE__,VSetBgMode,group);
3809 theCommands.Add("vsetgradientbg",
3810 "vsetgradientbg : vsetgradientbg r1 g1 b1 r2 g2 b2 filltype : Mount gradient background",
3811 __FILE__,VSetGradientBg,group);
3812 theCommands.Add("vsetgrbgmode",
3813 "vsetgrbgmode : vsetgrbgmode filltype : Change gradient background fill type",
3814 __FILE__,VSetGradientBgMode,group);
3815 theCommands.Add("vsetcolorbg",
3816 "vsetcolorbg : vsetcolorbg r g b : Set background color",
3817 __FILE__,VSetColorBg,group);
3818 theCommands.Add("vscale",
3819 "vscale : vscale X Y Z",
3820 __FILE__,VScale,group);
3821 theCommands.Add("vzbufftrihedron",
3822 "vzbufftrihedron [center|left_lower|left_upper|right_lower|right_upper"
3823 " textR=255 textG=255 textB=255 scale=0.1 wireframe|zbuffer]"
3824 " : Displays a V3d_ZBUFFER'ed or V3d_WIREFRAME'd trihedron",
3825 __FILE__,VTestZBuffTrihedron,group);
3826 theCommands.Add("vrotate",
3827 "vrotate : vrotate AX AY AZ [X Y Z]",
3828 __FILE__,VRotate,group);
3829 theCommands.Add("vzoom",
3830 "vzoom : vzoom coef",
3831 __FILE__,VZoom,group);
3832 theCommands.Add("vpan",
3833 "vpan : vpan dx dy",
3834 __FILE__,VPan,group);
3835 theCommands.Add("vexport",
3836 "vexport : vexport full_file_path {PS | EPS | TEX | PDF | SVG | PGF | EMF }"
3837 " : exports the view to a vector file of a given format"
3838 " : notice that EMF format requires patched gl2ps",
3839 __FILE__,VExport,group);
3840 theCommands.Add("vcolorscale",
3841 "vcolorscale : vcolorscale [RangeMin = 0 RangeMax = 100 Intervals = 10 HeightFont = 16 Position = 2 X = 0 Y = 0]: draw color scale",
3842 __FILE__,VColorScale,group);
3843 theCommands.Add("vgraduatedtrihedron",
3844 "vgraduatedtrihedron : 1/0 (display/erase) [Xname Yname Zname [Font [isMultibyte]]]",
3845 __FILE__,VGraduatedTrihedron,group);
3846 theCommands.Add("vprintview" ,
3847 "vprintview : width height filename [algo=0] : Test print algorithm: algo = 0 - stretch, algo = 1 - tile",
3848 __FILE__,VPrintView,group);
3849 theCommands.Add("vzlayer",
3850 "vzlayer : add/del/get [id] : Z layer operations in v3d viewer: add new z layer, delete z layer, get z layer ids",
3851 __FILE__,VZLayer,group);
3852 theCommands.Add("voverlaytext",
3853 "voverlaytext : text x y [height] [font_name] [text_color: R G B] [display_type] [background_color: R G B]"
3854 " : height - pixel height of the text (default=10.0)"
3855 " : font_name - name of font (default=courier)"
3856 " : text_color - three values: RedColor GreenColor BlueColor (default = 255.0 255.0 255.0) "
3857 " : display_type = {normal/subtitle/decal/blend}, (default=normal) "
3858 " : background_color - three values: RedColor GreenColor BlueColor (default = 255.0 255.0 255.0), the parameter is defined for subtitle and decal display types ",
3859 __FILE__,VOverlayText,group);
3860 theCommands.Add("vlayerline",
3861 "vlayerline : vlayerline x1 y1 x2 y2 [linewidth=0.5] [linetype=0] [transparency=1.0]",
3862 __FILE__,VLayerLine,group);
3863 theCommands.Add ("vgrid",
3864 "vgrid [off] [Mode={r|c}] [Type={l|p}] [OriginX OriginY [StepX/StepRadius StepY/DivNb RotAngle]]"
3865 " : Mode - rectangular or circular"
3866 " : Type - lines or points",
3867 __FILE__, VGrid, group);
3868 theCommands.Add ("vfps",
3869 "vfps [framesNb=100] : estimate average frame rate for active view",
3870 __FILE__, VFps, group);
3871 theCommands.Add ("vvbo",
3872 "vvbo {0|1} : turn VBO usage On/Off; affects only newly displayed objects",
3873 __FILE__, VVbo, group);
3874 theCommands.Add ("vmemgpu",
3875 "vmemgpu [f]: print system-dependent GPU memory information if available;"
3876 " with f option returns free memory in bytes",
3877 __FILE__, VMemGpu, group);
3878 theCommands.Add ("vreadpixel",
3879 "vreadpixel xPixel yPixel [{rgb|rgba|depth|hls|rgbf|rgbaf}=rgba] [name]"
3880 " : Read pixel value for active view",
3881 __FILE__, VReadPixel, group);
3882 theCommands.Add("diffimage",
3883 "diffimage : diffimage imageFile1 imageFile2 toleranceOfColor(0..1) blackWhite(1|0) borderFilter(1|0) [diffImageFile]",
3884 __FILE__, VDiffImage, group);
3885 theCommands.Add ("vselect",
3886 "vselect x1 y1 [x2 y2 [x3 y3 ... xn yn]] [shift_selection = 0|1]\n"
3887 "- emulates different types of selection:\n"
3888 "- 1) single click selection\n"
3889 "- 2) selection with rectangle having corners at pixel positions (x1,y1) and (x2,y2)\n"
3890 "- 3) selection with polygon having corners in pixel positions (x1,y1), (x2,y2),...,(xn,yn)\n"
3891 "- 4) any of these selections with shift button pressed",
3892 __FILE__, VSelect, group);
3893 theCommands.Add ("vmoveto",
3895 "- emulates cursor movement to pixel postion (x,y)",
3896 __FILE__, VMoveTo, group);
3897 theCommands.Add("vviewparams",
3898 "vviewparams [scale center_X center_Y proj_X proj_Y proj_Z up_X up_Y up_Z at_X at_Y at_Z]"
3899 "- gets or sets current view characteristics",
3900 __FILE__,VViewParams, group);
3901 theCommands.Add("vchangeselected",
3902 "vchangeselected shape"
3903 "- adds to shape to selection or remove one from it",
3904 __FILE__, VChangeSelected, group);
3905 theCommands.Add("vzclipping",
3906 "vzclipping [mode] [depth width]\n"
3907 "- mode = OFF|BACK|FRONT|SLICE depth = [0..1] width = [0..1]\n"
3908 "- gets or sets ZClipping mode, width and depth",
3909 __FILE__,VZClipping,group);
3910 theCommands.Add ("vnbselected",
3911 "vnbselected", __FILE__, VNbSelected, group);
3912 theCommands.Add("vantialiasing",
3913 "vantialiasing 1|0",
3914 __FILE__,VAntialiasing,group);
3915 theCommands.Add ("vpurgedisplay",
3916 "vpurgedisplay [CollectorToo = 0|1]"
3917 "- removes structures which don't belong to objects displayed in neutral point",
3918 __FILE__, VPurgeDisplay, group);
3919 theCommands.Add("vsetviewsize",
3920 "vsetviewsize size",
3921 __FILE__,VSetViewSize,group);
3922 theCommands.Add("vmoveview",
3923 "vmoveview Dx Dy Dz [Start = 1|0]",
3924 __FILE__,VMoveView,group);
3925 theCommands.Add("vtranslateview",
3926 "vtranslateview Dx Dy Dz [Start = 1|0)]",
3927 __FILE__,VTranslateView,group);
3928 theCommands.Add("vturnview",
3929 "vturnview Ax Ay Az [Start = 1|0]",
3930 __FILE__,VTurnView,group);
3931 theCommands.Add("vtextureenv",
3932 "Enables or disables environment mapping in the 3D view, loading the texture from the given standard "
3933 "or user-defined file and optionally applying texture mapping parameters\n"
3935 " vtextureenv off - disables environment mapping\n"
3936 " vtextureenv on {std_texture|texture_file_name} [rep mod flt ss st ts tt rot] - enables environment mapping\n"
3937 " std_texture = (0..7)\n"
3938 " rep = {clamp|repeat}\n"
3939 " mod = {decal|modulate}\n"
3940 " flt = {nearest|bilinear|trilinear}\n"
3941 " ss, st - scale factors for s and t texture coordinates\n"
3942 " ts, tt - translation for s and t texture coordinates\n"
3943 " rot - texture rotation angle in degrees",
3944 __FILE__, VTextureEnv, group);