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_ExportFormat.hxx>
33 #include <ViewerTest.hxx>
34 #include <ViewerTest_EventManager.hxx>
35 #include <Visual3d_View.hxx>
36 #include <Visual3d_ViewManager.hxx>
37 #include <V3d_LayerMgr.hxx>
38 #include <NIS_View.hxx>
39 #include <NIS_Triangulated.hxx>
40 #include <NIS_InteractiveContext.hxx>
41 #include <AIS_InteractiveContext.hxx>
42 #include <Draw_Interpretor.hxx>
44 #include <Draw_Appli.hxx>
45 #include <Aspect_PrintAlgo.hxx>
46 #include <Image_PixMap.hxx>
47 #include <TColStd_SequenceOfInteger.hxx>
48 #include <Visual3d_LayerItem.hxx>
49 #include <V3d_LayerMgr.hxx>
50 #include <V3d_LayerMgrPointer.hxx>
51 #include <Aspect_TypeOfLine.hxx>
57 #include <Visual3d_Layer.hxx>
60 #include <Graphic3d_GraphicDevice.hxx>
61 #include <Xw_GraphicDevice.hxx>
62 #include <Xw_WindowQuality.hxx>
63 #include <Xw_Window.hxx>
64 #include <X11/Xlib.h> /* contains some dangerous #defines such as Status, True etc. */
65 #include <X11/Xutil.h>
70 #include <Graphic3d_WNTGraphicDevice.hxx>
71 #include <WNT_WClass.hxx>
72 #include <WNT_Window.hxx>
74 #define _CRT_SECURE_NO_DEPRECATE
75 #pragma warning (disable:4996)
81 //==============================================================================
83 //==============================================================================
84 // VIEWER GLOBAL VARIABLES
85 //==============================================================================
87 Standard_IMPORT Standard_Boolean Draw_VirtualWindows;
89 Standard_EXPORT int ViewerMainLoop(Standard_Integer , const char** argv);
90 extern const Handle(NIS_InteractiveContext)& TheNISContext();
93 static Handle(Graphic3d_WNTGraphicDevice)& GetG3dDevice(){
94 static Handle(Graphic3d_WNTGraphicDevice) GD;
98 static Handle(WNT_Window)& VT_GetWindow() {
99 static Handle(WNT_Window) WNTWin;
104 static Handle(Graphic3d_GraphicDevice)& GetG3dDevice(){
105 static Handle(Graphic3d_GraphicDevice) GD;
108 static Handle(Xw_Window)& VT_GetWindow(){
109 static Handle(Xw_Window) XWWin;
112 static Display *display;
114 static void VProcessEvents(ClientData,int);
118 static Standard_Boolean DegenerateMode = Standard_True;
121 #define ZCLIPWIDTH 1.
123 static void OSWindowSetup();
125 //==============================================================================
126 // EVENT GLOBAL VARIABLES
127 //==============================================================================
129 static int Start_Rot = 0;
130 static int ZClipIsOn = 0;
131 static int X_Motion= 0,Y_Motion=0; // Current cursor position
132 static int X_ButtonPress = 0, Y_ButtonPress = 0; // Last ButtonPress position
135 //==============================================================================
138 static LRESULT WINAPI ViewerWindowProc(
143 static LRESULT WINAPI AdvViewerWindowProc(
151 //==============================================================================
154 //==============================================================================
156 const Handle(MMgt_TShared)& ViewerTest::WClass()
158 static Handle(MMgt_TShared) theWClass;
160 if (theWClass.IsNull()) {
161 theWClass = new WNT_WClass ("GW3D_Class", AdvViewerWindowProc,
162 CS_VREDRAW | CS_HREDRAW, 0, 0,
163 ::LoadCursor (NULL, IDC_ARROW));
169 //==============================================================================
170 //function : ViewerInit
171 //purpose : Create the window viewer and initialize all the global variable
172 //==============================================================================
174 void ViewerTest::ViewerInit (const Standard_Integer thePxLeft, const Standard_Integer thePxTop,
175 const Standard_Integer thePxWidth, const Standard_Integer thePxHeight)
177 static Standard_Boolean isFirst = Standard_True;
179 Standard_Integer aPxLeft = 0;
180 Standard_Integer aPxTop = 460;
181 Standard_Integer aPxWidth = 409;
182 Standard_Integer aPxHeight = 409;
183 if (thePxWidth != 0 && thePxHeight != 0)
187 aPxWidth = thePxWidth;
188 aPxHeight = thePxHeight;
193 // Create the Graphic device
195 if (GetG3dDevice().IsNull()) GetG3dDevice() = new Graphic3d_WNTGraphicDevice();
196 if (VT_GetWindow().IsNull())
198 // Create the Graphic device and the window
199 Handle(WNT_GraphicDevice) g_Device = new WNT_GraphicDevice();
201 VT_GetWindow() = new WNT_Window (g_Device, "Test3d",
202 Handle(WNT_WClass)::DownCast (WClass()),
207 VT_GetWindow()->SetVirtual (Draw_VirtualWindows);
210 if (GetG3dDevice().IsNull()) GetG3dDevice() =
211 new Graphic3d_GraphicDevice (getenv ("DISPLAY"), Xw_TOM_READONLY);
212 if (VT_GetWindow().IsNull())
214 VT_GetWindow() = new Xw_Window (GetG3dDevice(),
220 VT_GetWindow()->SetVirtual (Draw_VirtualWindows);
224 Handle(V3d_Viewer) a3DViewer, a3DCollector;
225 // Viewer and View creation
227 TCollection_ExtendedString NameOfWindow("Visu3D");
229 a3DViewer = new V3d_Viewer(GetG3dDevice(), NameOfWindow.ToExtString());
230 NameOfWindow = TCollection_ExtendedString("Collector");
231 a3DCollector = new V3d_Viewer(GetG3dDevice(), NameOfWindow.ToExtString());
232 a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK);
233 a3DCollector->SetDefaultBackgroundColor(Quantity_NOC_STEELBLUE);
234 Handle(NIS_View) aView =
235 Handle(NIS_View)::DownCast(ViewerTest::CurrentView());
236 if ( aView.IsNull() ) {
237 // Handle (V3d_View) V = a3DViewer->CreateView();
238 aView = new NIS_View (a3DViewer, VT_GetWindow());
239 ViewerTest::CurrentView(aView);
240 TheNISContext()->AttachView (aView);
242 Handle(V3d_View) a3DViewCol;
243 if ( a3DViewCol.IsNull() ) a3DViewCol = a3DViewer->CreateView();
246 if ( ViewerTest::GetAISContext().IsNull() ) {
247 Handle(AIS_InteractiveContext) C =
248 new AIS_InteractiveContext(a3DViewer,a3DCollector);
249 ViewerTest::SetAISContext(C);
252 // Setup for X11 or NT
254 // Viewer and View creation
256 a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK);
258 Handle (V3d_View) V = ViewerTest::CurrentView();
260 V->SetDegenerateModeOn();
262 DegenerateMode = V->DegenerateModeIsOn();
264 // V->SetWindow(VT_GetWindow(), NULL, MyViewProc, NULL);
266 V->SetZClippingDepth(0.5);
267 V->SetZClippingWidth(ZCLIPWIDTH/2.);
268 a3DViewer->SetDefaultLights();
269 a3DViewer->SetLightOn();
272 #if TCL_MAJOR_VERSION < 8
273 Tk_CreateFileHandler((void*)ConnectionNumber(display),
274 TK_READABLE, VProcessEvents, (ClientData) VT_GetWindow()->XWindow() );
276 Tk_CreateFileHandler(ConnectionNumber(display),
277 TK_READABLE, VProcessEvents, (ClientData) VT_GetWindow()->XWindow() );
281 isFirst = Standard_False;
283 VT_GetWindow()->Map();
286 //==============================================================================
288 //purpose : Create the window viewer and initialize all the global variable
289 // Use Tk_CreateFileHandler on UNIX to cath the X11 Viewer event
290 //==============================================================================
292 static int VInit (Draw_Interpretor& , Standard_Integer argc, const char** argv)
294 Standard_Integer aPxLeft = (argc > 1) ? atoi (argv[1]) : 0;
295 Standard_Integer aPxTop = (argc > 2) ? atoi (argv[2]) : 0;
296 Standard_Integer aPxWidth = (argc > 3) ? atoi (argv[3]) : 0;
297 Standard_Integer aPxHeight = (argc > 4) ? atoi (argv[4]) : 0;
298 ViewerTest::ViewerInit (aPxLeft, aPxTop, aPxWidth, aPxHeight);
302 //==============================================================================
303 //function : ProcessKeyPress
304 //purpose : Handle KeyPress event from a CString
305 //==============================================================================
307 static void ProcessKeyPress( char *buf_ret )
309 //cout << "KeyPress" << endl;
310 const Handle(V3d_View) aView = ViewerTest::CurrentView();
311 const Handle(NIS_View) aNisView = Handle(NIS_View)::DownCast (aView);
312 // Letter in alphabetic order
314 if ( !strcasecmp(buf_ret, "A") ) {
316 aView->SetProj(V3d_XposYnegZpos);
318 else if ( !strcasecmp(buf_ret, "D") ) {
322 else if ( !strcasecmp(buf_ret, "F") ) {
324 if (aNisView.IsNull())
327 aNisView->FitAll3d();
329 else if ( !strcasecmp(buf_ret, "H") ) {
331 cout << "HLR" << endl;
333 if (aView->DegenerateModeIsOn()) ViewerTest::CurrentView()->SetDegenerateModeOff();
334 else aView->SetDegenerateModeOn();
335 DegenerateMode = aView->DegenerateModeIsOn();
337 ViewerTest::CurrentView()->SetDegenerateModeOff();
340 else if ( !strcasecmp(buf_ret, "D") ) {
344 else if ( !strcasecmp(buf_ret, "S") ) {
346 cout << "passage en mode 1 (shading pour les shapes)" << endl;
348 ViewerTest::CurrentView()->SetDegenerateModeOn();
350 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
351 if(Ctx->NbCurrents()==0 ||
352 Ctx->NbSelected()==0)
353 Ctx->SetDisplayMode(AIS_Shaded);
355 if(Ctx->HasOpenedContext()){
356 for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
357 Ctx->SetDisplayMode(Ctx->Interactive(),1,Standard_False);
360 for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent())
361 Ctx->SetDisplayMode(Ctx->Current(),1,Standard_False);
363 Ctx->UpdateCurrentViewer();
366 else if ( !strcasecmp(buf_ret, "U") ) {
368 cout<<"passage au mode par defaut"<<endl;
370 ViewerTest::CurrentView()->SetDegenerateModeOn();
372 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
373 if(Ctx->NbCurrents()==0 ||
374 Ctx->NbSelected()==0)
375 Ctx->SetDisplayMode(AIS_WireFrame);
377 if(Ctx->HasOpenedContext()){
378 for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
379 Ctx->UnsetDisplayMode(Ctx->Interactive(),Standard_False);
382 for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent())
383 Ctx->UnsetDisplayMode(Ctx->Current(),Standard_False);
385 Ctx->UpdateCurrentViewer();
389 else if ( !strcasecmp(buf_ret, "T") ) {
391 aView->SetProj(V3d_Zpos);
393 else if ( !strcasecmp(buf_ret, "B") ) {
395 aView->SetProj(V3d_Zneg);
397 else if ( !strcasecmp(buf_ret, "L") ) {
399 aView->SetProj(V3d_Xneg);
401 else if ( !strcasecmp(buf_ret, "R") ) {
403 aView->SetProj(V3d_Xpos);
406 else if ( !strcasecmp(buf_ret, "W") ) {
409 ViewerTest::CurrentView()->SetDegenerateModeOn();
411 cout << "passage en mode 0 (filaire pour les shapes)" << endl;
413 ViewerTest::CurrentView()->SetDegenerateModeOn();
415 Handle(AIS_InteractiveContext) Ctx = ViewerTest::GetAISContext();
416 if(Ctx->NbCurrents()==0 ||
417 Ctx->NbSelected()==0)
418 Ctx->SetDisplayMode(AIS_WireFrame);
420 if(Ctx->HasOpenedContext()){
421 for(Ctx->InitSelected();Ctx->MoreSelected();Ctx->NextSelected())
422 Ctx->SetDisplayMode(Ctx->Interactive(),0,Standard_False);
425 for(Ctx->InitCurrent();Ctx->MoreCurrent();Ctx->NextCurrent())
426 Ctx->SetDisplayMode(Ctx->Current(),0,Standard_False);
428 Ctx->UpdateCurrentViewer();
431 else if ( !strcasecmp(buf_ret, "Z") ) {
435 cout << "ZClipping OFF" << endl;
438 aView->SetZClippingType(V3d_OFF);
442 cout << "ZClipping ON" << endl;
445 aView->SetZClippingType(V3d_FRONT);
449 else if ( !strcasecmp(buf_ret, ",") ) {
450 ViewerTest::GetAISContext()->HilightNextDetected(ViewerTest::CurrentView());
454 else if ( !strcasecmp(buf_ret, ".") ) {
455 ViewerTest::GetAISContext()->HilightPreviousDetected(ViewerTest::CurrentView());
459 Standard_Integer Num = atoi(buf_ret);
461 ViewerTest::StandardModeActivation(Num);
465 //==============================================================================
466 //function : ProcessExpose
467 //purpose : Redraw the View on an Expose Event
468 //==============================================================================
470 static void ProcessExpose( )
471 { //cout << "Expose" << endl;
472 ViewerTest::CurrentView()->Redraw();
475 //==============================================================================
476 //function : ProcessConfigure
477 //purpose : Resize the View on an Configure Event
478 //==============================================================================
480 static void ProcessConfigure()
482 Handle(V3d_View) V = ViewerTest::CurrentView();
488 //==============================================================================
489 //function : ProcessButton1Press
491 //==============================================================================
493 static Standard_Boolean ProcessButton1Press(
496 Standard_Boolean pick,
497 Standard_Boolean shift )
499 Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
501 Standard_Real X, Y, Z;
503 ViewerTest::CurrentView()->Convert(X_Motion, Y_Motion, X, Y, Z);
505 Draw::Set(argv[1], X);
506 Draw::Set(argv[2], Y);
507 Draw::Set(argv[3], Z);}
518 //==============================================================================
519 //function : ProcessButton3Press
520 //purpose : Start Rotation
521 //==============================================================================
523 static void ProcessButton3Press()
527 ViewerTest::CurrentView()->SetDegenerateModeOn();
528 ViewerTest::CurrentView()->StartRotation( X_ButtonPress, Y_ButtonPress );
531 //==============================================================================
532 //function : ProcessButtonRelease
533 //purpose : Start Rotation
534 //==============================================================================
536 static void ProcessButtonRelease()
542 if (!DegenerateMode) ViewerTest::CurrentView()->SetDegenerateModeOff();
546 ViewerTest::CurrentView()->SetDegenerateModeOff();
550 //==============================================================================
551 //function : ProcessZClipMotion
553 //==============================================================================
555 void ProcessZClipMotion()
557 Handle(V3d_View) a3DView = ViewerTest::CurrentView();
558 if ( Abs(X_Motion - X_ButtonPress) > 2 ) {
559 static Standard_Real CurZPos = 0.;
561 //Quantity_Length VDX, VDY;
562 //a3DView->Size(VDX,VDY);
563 //Standard_Real VDZ = a3DView->ZSize();
564 //printf("View size (%lf,%lf,%lf)\n", VDX, VDY, VDZ);
566 Quantity_Length dx = a3DView->Convert(X_Motion - X_ButtonPress);
568 // Front = Depth + width/2.
569 Standard_Real D = 0.5;
570 Standard_Real W = 0.1;
576 //printf("dx %lf Depth %lf Width %lf\n", dx, D, W);
578 a3DView->SetZClippingType(V3d_OFF);
579 a3DView->SetZClippingDepth(D);
580 a3DView->SetZClippingWidth(W);
581 a3DView->SetZClippingType(V3d_FRONT);
585 X_ButtonPress = X_Motion;
586 Y_ButtonPress = Y_Motion;
590 //==============================================================================
591 //function : ProcessControlButton1Motion
593 //==============================================================================
595 static void ProcessControlButton1Motion()
597 ViewerTest::CurrentView()->Zoom( X_ButtonPress, Y_ButtonPress, X_Motion, Y_Motion);
599 X_ButtonPress = X_Motion;
600 Y_ButtonPress = Y_Motion;
603 //==============================================================================
604 //function : ProcessControlButton2Motion
606 //==============================================================================
608 static void ProcessControlButton2Motion()
610 Quantity_Length dx = ViewerTest::CurrentView()->Convert(X_Motion - X_ButtonPress);
611 Quantity_Length dy = ViewerTest::CurrentView()->Convert(Y_Motion - Y_ButtonPress);
613 dy = -dy; // Xwindow Y axis is from top to Bottom
615 ViewerTest::CurrentView()->Panning( dx, dy );
617 X_ButtonPress = X_Motion;
618 Y_ButtonPress = Y_Motion;
621 //==============================================================================
622 //function : ProcessControlButton3Motion
624 //==============================================================================
626 static void ProcessControlButton3Motion()
628 if ( Start_Rot ) ViewerTest::CurrentView()->Rotation( X_Motion, Y_Motion);
631 //==============================================================================
632 //function : ProcessPointerMotion
634 //==============================================================================
636 static void ProcessMotion()
638 //pre-hilights detected objects at mouse position
640 Handle(ViewerTest_EventManager) EM = ViewerTest::CurrentEventManager();
641 EM->MoveTo(X_Motion, Y_Motion);
645 void ViewerTest::GetMousePosition(Standard_Integer& Xpix,Standard_Integer& Ypix)
647 Xpix = X_Motion;Ypix=Y_Motion;
650 //==============================================================================
652 //purpose : Switch to an Axonometric view
654 //==============================================================================
656 static int VAxo(Draw_Interpretor& di, Standard_Integer , const char** )
657 { if ( ViewerTest::CurrentView().IsNull() ) {
658 di<<"La commande vinit n'a pas ete appele avant"<<"\n";
659 // VInit(di, argc, argv);
662 ViewerTest::CurrentView()->SetProj(V3d_XposYnegZpos);
667 //==============================================================================
669 //purpose : Switch to a Top View
671 //==============================================================================
673 static int VTop(Draw_Interpretor& di, Standard_Integer , const char** )
676 if ( ViewerTest::CurrentView().IsNull() ) {
677 di<<"La commande vinit n'a pas ete appele avant"<<"\n";
679 // VInit(di, , argv);
682 ViewerTest::CurrentView()->SetProj(V3d_Zpos);
687 //==============================================================================
689 //purpose : Dsiplay help on viewer Keyboead and mouse commands
691 //==============================================================================
693 static int VHelp(Draw_Interpretor& di, Standard_Integer , const char** )
696 di << "Q : Quit the application" << "\n";
698 di << "========================="<<"\n";
699 di << "F : FitAll" << "\n";
700 di << "T : TopView" << "\n";
701 di << "A : AxonometricView" << "\n";
702 di << "R : ResetView" << "\n";
704 di << "========================="<<"\n";
705 di << "S : Shading" << "\n";
706 di << "W : Wireframe" << "\n";
707 di << "H : HidelLineRemoval" << "\n";
709 di << "========================="<<"\n";
710 di << "Selection mode "<<"\n";
711 di << "0 : Shape" <<"\n";
712 di << "1 : Vertex" <<"\n";
713 di << "2 : Edge" <<"\n";
714 di << "3 : Wire" <<"\n";
715 di << "4 : Face" <<"\n";
716 di << "5 : Shell" <<"\n";
717 di << "6 : Solid" <<"\n";
718 di << "7 : Compound" <<"\n";
720 di << "=========================="<<"\n";
721 di << "D : Remove Selected Object"<<"\n";
722 di << "=========================="<<"\n";
727 Standard_Boolean IsDragged = Standard_False;
729 Standard_Integer xx1, yy1, xx2, yy2;
730 //the first and last point in viewer co-ordinates
732 Standard_Boolean DragFirst;
737 static Standard_Boolean Ppick = 0;
738 static Standard_Integer Pargc = 0;
739 static const char** Pargv = NULL;
742 static LRESULT WINAPI AdvViewerWindowProc( HWND hwnd,
747 if ( !ViewerTest::CurrentView().IsNull() ) {
749 WPARAM fwKeys = wParam;
754 IsDragged = Standard_False;
757 HDC hdc = GetDC( hwnd );
758 HGDIOBJ anObj = SelectObject( hdc, GetStockObject( WHITE_PEN ) );
759 SelectObject( hdc, GetStockObject( HOLLOW_BRUSH ) );
760 SetROP2( hdc, R2_NOT );
761 Rectangle( hdc, xx1, yy1, xx2, yy2 );
762 ReleaseDC( hwnd, hdc );
764 const Handle(ViewerTest_EventManager) EM =
765 ViewerTest::CurrentEventManager();
766 if ( fwKeys & MK_SHIFT )
767 EM->ShiftSelect( min( xx1, xx2 ), max( yy1, yy2 ),
768 max( xx1, xx2 ), min( yy1, yy2 ));
770 EM->Select( min( xx1, xx2 ), max( yy1, yy2 ),
771 max( xx1, xx2 ), min( yy1, yy2 ));
773 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
776 if( fwKeys == MK_LBUTTON || fwKeys == ( MK_LBUTTON | MK_SHIFT ) )
778 IsDragged = Standard_True;
779 DragFirst = Standard_True;
780 xx1 = LOWORD(lParam);
781 yy1 = HIWORD(lParam);
783 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
790 HDC hdc = GetDC( hwnd );
792 HGDIOBJ anObj = SelectObject( hdc, GetStockObject( WHITE_PEN ) );
793 SelectObject( hdc, GetStockObject( HOLLOW_BRUSH ) );
794 SetROP2( hdc, R2_NOT );
797 Rectangle( hdc, xx1, yy1, xx2, yy2 );
799 DragFirst = Standard_False;
800 xx2 = LOWORD(lParam);
801 yy2 = HIWORD(lParam);
803 Rectangle( hdc, xx1, yy1, xx2, yy2 );
805 SelectObject( hdc, anObj );
807 ReleaseDC( hwnd, hdc );
810 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
814 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
818 return ViewerWindowProc( hwnd, Msg, wParam, lParam );
822 static LRESULT WINAPI ViewerWindowProc( HWND hwnd,
827 /*static Standard_Boolean Ppick = 0;
828 static Standard_Integer Pargc = 0;
829 static char** Pargv = NULL;*/
833 if ( !ViewerTest::CurrentView().IsNull() ) {
838 // do not destroy the window - just hide it!
839 VT_GetWindow()->Unmap();
842 //cout << "\t WM_PAINT" << endl;
843 BeginPaint(hwnd, &ps);
849 //cout << "\t WM_SIZE" << endl;
854 //cout << "\t WM_KEYDOWN " << (int) wParam << endl;
856 if ( (wParam != VK_SHIFT) && (wParam != VK_CONTROL) ) {
858 c[0] = (char) wParam;
867 //cout << "\t WM_xBUTTONUP" << endl;
869 ProcessButtonRelease();
876 //cout << "\t WM_xBUTTONDOWN" << endl;
877 WPARAM fwKeys = wParam;
881 X_ButtonPress = LOWORD(lParam);
882 Y_ButtonPress = HIWORD(lParam);
884 if ( Msg == WM_LBUTTONDOWN) {
885 if(fwKeys & MK_CONTROL) {
886 Ppick = ProcessButton1Press( Pargc, Pargv, Ppick, (fwKeys & MK_SHIFT) );
888 ProcessButton1Press( Pargc, Pargv, Ppick, (fwKeys & MK_SHIFT) );
890 else if ( Msg == WM_RBUTTONDOWN ) {
892 ProcessButton3Press( );
899 //cout << "\t WM_MOUSEMOVE" << endl;
900 WPARAM fwKeys = wParam;
901 X_Motion = LOWORD(lParam);
902 Y_Motion = HIWORD(lParam);
905 fwKeys & ( MK_LBUTTON|MK_MBUTTON|MK_RBUTTON ) ) {
907 X_ButtonPress = LOWORD(lParam);
908 Y_ButtonPress = HIWORD(lParam);
910 if ( fwKeys & MK_RBUTTON ) {
912 ProcessButton3Press();
916 if ( fwKeys & MK_CONTROL ) {
917 if ( fwKeys & MK_LBUTTON ) {
918 ProcessControlButton1Motion();
920 else if ( fwKeys & MK_MBUTTON ||
921 ((fwKeys&MK_LBUTTON) &&
922 (fwKeys&MK_RBUTTON) ) ){
923 ProcessControlButton2Motion();
925 else if ( fwKeys & MK_RBUTTON ) {
926 ProcessControlButton3Motion();
930 else if ( fwKeys & MK_SHIFT ) {
931 if ( fwKeys & MK_MBUTTON ||
932 ((fwKeys&MK_LBUTTON) &&
933 (fwKeys&MK_RBUTTON) ) ) {
934 cout << "ProcessZClipMotion()" << endl;
935 ProcessZClipMotion();
940 if (( fwKeys & MK_MBUTTON || ((fwKeys&MK_LBUTTON) && (fwKeys&MK_RBUTTON) ) )){
941 ProcessZClipMotion();
950 return( DefWindowProc( hwnd, Msg, wParam, lParam ));
955 return DefWindowProc( hwnd, Msg, wParam, lParam );
961 //==============================================================================
962 //function : ViewerMainLoop
963 //purpose : Get a Event on the view and dispatch it
964 //==============================================================================
967 static int ViewerMainLoop(Standard_Integer argc, const char** argv)
970 //cout << "No yet implemented on WNT" << endl;
971 /*static Standard_Boolean Ppick = 0;
972 static Standard_Integer Pargc = 0;
973 static char** Pargv = NULL;*/
975 //Ppick = (argc > 0)? -1 : 0;
976 Ppick = (argc > 0)? 1 : 0;
984 cout << "Start picking" << endl;
986 //while ( Ppick == -1 ) {
987 while ( Ppick == 1 ) {
988 // Wait for a ProcessButton1Press() to toggle pick to 1 or 0
989 if (GetMessage(&msg, NULL, 0, 0) ) {
990 TranslateMessage(&msg);
991 DispatchMessage(&msg);
995 cout << "Picking done" << endl;
1004 int min( int a, int b )
1012 int max( int a, int b )
1020 int ViewerMainLoop(Standard_Integer argc, const char** argv)
1022 { Standard_Boolean pick = argc > 0;
1026 static XEvent report;
1028 XNextEvent( display, &report );
1029 // cout << "rep type = " << report.type << endl;
1030 // cout << "rep button = " << report.xbutton.button << endl;
1032 switch ( report.type ) {
1038 case ConfigureNotify:
1049 XComposeStatus status_in_out;
1051 ret_len = XLookupString( ( XKeyEvent *)&report ,
1052 (char *) buf_ret , 10 ,
1053 &ks_ret , &status_in_out ) ;
1056 buf_ret[ret_len] = '\0' ;
1059 ProcessKeyPress( buf_ret);
1064 // cout << "ButtonPress" << endl;
1066 X_ButtonPress = report.xbutton.x;
1067 Y_ButtonPress = report.xbutton.y;
1069 if ( report.xbutton.button == Button1 )
1070 if( report.xbutton.state & ControlMask )
1071 pick = ProcessButton1Press( argc, argv, pick,
1072 ( report.xbutton.state & ShiftMask) );
1075 IsDragged = Standard_True;
1076 xx1 = X_ButtonPress;
1077 yy1 = Y_ButtonPress;
1078 DragFirst = Standard_True;
1080 else if ( report.xbutton.button == Button3 )
1082 ProcessButton3Press();
1087 // cout<<"relachement du bouton "<<(report.xbutton.button==3 ? "3": "on s'en fout") <<endl;
1088 // cout << IsDragged << endl;
1089 // cout << DragFirst << endl;
1095 Aspect_Handle aWindow = VT_GetWindow()->XWindow();
1096 GC gc = XCreateGC( display, aWindow, 0, 0 );
1097 // XSetFunction( display, gc, GXinvert );
1098 XDrawRectangle( display, aWindow, gc, min( xx1, xx2 ), min( yy1, yy2 ), abs( xx2-xx1 ), abs( yy2-yy1 ) );
1101 Handle( AIS_InteractiveContext ) aContext = ViewerTest::GetAISContext();
1102 if( aContext.IsNull() )
1104 cout << "The context is null. Please use vinit before createmesh" << endl;
1108 Standard_Boolean ShiftPressed = ( report.xbutton.state & ShiftMask );
1109 if( report.xbutton.button==1 )
1113 aContext->ShiftSelect();
1114 // cout << "shift select" << endl;
1119 // cout << "select" << endl;
1124 aContext->ShiftSelect( min( xx1, xx2 ), min( yy1, yy2 ),
1125 max( xx1, xx2 ), max( yy1, yy2 ),
1126 ViewerTest::CurrentView());
1127 // cout << "shift select" << endl;
1131 aContext->Select( min( xx1, xx2 ), min( yy1, yy2 ),
1132 max( xx1, xx2 ), max( yy1, yy2 ),
1133 ViewerTest::CurrentView() );
1134 // cout << "select" << endl;
1137 ProcessButtonRelease();
1139 IsDragged = Standard_False;
1142 ProcessButtonRelease();
1149 X_Motion = report.xmotion.x;
1150 Y_Motion = report.xmotion.y;
1154 Aspect_Handle aWindow = VT_GetWindow()->XWindow();
1155 GC gc = XCreateGC( display, aWindow, 0, 0 );
1156 XSetFunction( display, gc, GXinvert );
1159 XDrawRectangle( display, aWindow, gc, min( xx1, xx2 ), min( yy1, yy2 ), abs( xx2-xx1 ), abs( yy2-yy1 ) );
1163 DragFirst = Standard_False;
1165 //cout << "draw rect : " << xx2 << ", " << yy2 << endl;
1166 XDrawRectangle( display, aWindow, gc, min( xx1, xx2 ), min( yy1, yy2 ), abs( xx2-xx1 ), abs( yy2-yy1 ) );
1171 //cout << "MotionNotify " << X_Motion << "," << Y_Motion << endl;
1173 // remove all the ButtonMotionMask
1174 while( XCheckMaskEvent( display, ButtonMotionMask, &report) ) ;
1176 if ( ZClipIsOn && report.xmotion.state & ShiftMask ) {
1177 if ( Abs(X_Motion - X_ButtonPress) > 2 ) {
1179 Quantity_Length VDX, VDY;
1181 ViewerTest::CurrentView()->Size(VDX,VDY);
1182 Standard_Real VDZ =0 ;
1183 VDZ = ViewerTest::CurrentView()->ZSize();
1185 // printf("%lf,%lf,%lf\n", VDX, VDY, VDZ);
1186 printf("%f,%f,%f\n", VDX, VDY, VDZ);
1188 Quantity_Length dx = 0 ;
1189 dx = ViewerTest::CurrentView()->Convert(X_Motion - X_ButtonPress);
1193 dx = dx / VDX * VDZ;
1197 // Front = Depth + width/2.
1198 //ViewerTest::CurrentView()->SetZClippingDepth(dx);
1199 //ViewerTest::CurrentView()->SetZClippingWidth(0.);
1201 ViewerTest::CurrentView()->Redraw();
1205 if ( report.xmotion.state & ControlMask ) {
1206 if ( report.xmotion.state & Button1Mask ) {
1207 ProcessControlButton1Motion();
1209 else if ( report.xmotion.state & Button2Mask ) {
1210 ProcessControlButton2Motion();
1212 else if ( report.xmotion.state & Button3Mask ) {
1213 ProcessControlButton3Motion();
1228 //==============================================================================
1229 //function : VProcessEvents
1230 //purpose : call by Tk_CreateFileHandler() to be able to manage the
1231 // event in the Viewer window
1232 //==============================================================================
1234 static void VProcessEvents(ClientData,int)
1236 //cout << "VProcessEvents" << endl;
1239 while (XPending(display)) {
1240 ViewerMainLoop( 0, NULL);
1245 //==============================================================================
1246 //function : OSWindowSetup
1247 //purpose : Setup for the X11 window to be able to cath the event
1248 //==============================================================================
1251 static void OSWindowSetup()
1256 Window window = VT_GetWindow()->XWindow();
1258 Standard_Address theDisplay = GetG3dDevice()->XDisplay();
1259 display = (Display * ) theDisplay;
1260 // display = (Display *)GetG3dDevice()->XDisplay();
1262 XSynchronize(display, 1);
1264 VT_GetWindow()->Map();
1266 // X11 : For keyboard on SUN
1268 wmhints.flags = InputHint;
1271 XSetWMHints( display, window, &wmhints);
1273 XSelectInput( display, window, ExposureMask | KeyPressMask |
1274 ButtonPressMask | ButtonReleaseMask |
1275 StructureNotifyMask |
1277 Button1MotionMask | Button2MotionMask |
1281 XSynchronize(display, 0);
1290 //==============================================================================
1293 //purpose : Fitall, no DRAW arguments
1294 //Draw arg : No args
1295 //==============================================================================
1297 static int VFit(Draw_Interpretor& , Standard_Integer , const char** )
1299 const Handle(V3d_View) aView = ViewerTest::CurrentView();
1300 Handle(NIS_View) V = Handle(NIS_View)::DownCast(aView);
1301 if (V.IsNull() == Standard_False) {
1303 } else if (aView.IsNull() == Standard_False) {
1309 //==============================================================================
1311 //purpose : ZFitall, no DRAW arguments
1312 //Draw arg : No args
1313 //==============================================================================
1315 static int VZFit(Draw_Interpretor& , Standard_Integer , const char** )
1317 Handle(V3d_View) V = ViewerTest::CurrentView();
1318 if ( !V.IsNull() ) V->ZFitAll(); return 0; }
1321 static int VRepaint(Draw_Interpretor& , Standard_Integer , const char** )
1323 Handle(V3d_View) V = ViewerTest::CurrentView();
1324 if ( !V.IsNull() ) V->Redraw(); return 0;
1328 //==============================================================================
1330 //purpose : Remove all the object from the viewer
1331 //Draw arg : No args
1332 //==============================================================================
1334 static int VClear(Draw_Interpretor& , Standard_Integer , const char** )
1336 Handle(V3d_View) V = ViewerTest::CurrentView();
1338 ViewerTest::Clear();
1342 //==============================================================================
1345 //==============================================================================
1347 static int VPick(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1348 { if (ViewerTest::CurrentView().IsNull() ) return 1;
1351 di << argv[0] << "Invalid number of arguments" << "\n";
1355 while (ViewerMainLoop( argc, argv)) {
1363 //==============================================================================
1364 //function : InitViewerTest
1365 //purpose : initialisation de toutes les variables static de ViewerTest (dp)
1366 //==============================================================================
1368 void ViewerTest_InitViewerTest (const Handle(AIS_InteractiveContext)& context)
1370 Handle(V3d_Viewer) viewer = context->CurrentViewer();
1371 ViewerTest::SetAISContext(context);
1372 viewer->InitActiveViews();
1373 Handle(V3d_View) view = viewer->ActiveView();
1374 if (viewer->MoreActiveViews()) ViewerTest::CurrentView(view);
1375 ViewerTest::ResetEventManager();
1376 Handle(Aspect_GraphicDevice) device = viewer->Device();
1377 Handle(Aspect_Window) window = view->Window();
1380 VT_GetWindow() = Handle(Xw_Window)::DownCast(window);
1381 GetG3dDevice() = Handle(Graphic3d_GraphicDevice)::DownCast(device);
1383 static int first = 1;
1385 #if TCL_MAJOR_VERSION < 8
1386 Tk_CreateFileHandler((void*)ConnectionNumber(display),
1387 TK_READABLE, VProcessEvents, (ClientData) 0);
1389 Tk_CreateFileHandler(ConnectionNumber(display),
1390 TK_READABLE, VProcessEvents, (ClientData) 0);
1398 //==============================================================================
1400 //purpose : Load image as background
1401 //==============================================================================
1403 static int VSetBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1405 if (argc < 2 || argc > 3)
1407 di << "Usage : " << argv[0] << " imagefile [filltype] : Load image as background" << "\n";
1408 di << "filltype can be one of CENTERED, TILED, STRETCH, NONE" << "\n";
1412 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1413 if(AISContext.IsNull())
1415 di << "use 'vinit' command before " << argv[0] << "\n";
1419 Aspect_FillMethod aFillType = Aspect_FM_CENTERED;
1422 const char* szType = argv[2];
1423 if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE;
1424 else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED;
1425 else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED;
1426 else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH;
1429 di << "Wrong fill type : " << szType << "\n";
1430 di << "Must be one of CENTERED, TILED, STRETCH, NONE" << "\n";
1435 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1436 V3dView->SetBackgroundImage(argv[1], aFillType, Standard_True);
1441 //==============================================================================
1442 //function : VSetBgMode
1443 //purpose : Change background image fill type
1444 //==============================================================================
1446 static int VSetBgMode(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1450 di << "Usage : " << argv[0] << " filltype : Change background image mode" << "\n";
1451 di << "filltype must be one of CENTERED, TILED, STRETCH, NONE" << "\n";
1455 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1456 if(AISContext.IsNull())
1458 di << "use 'vinit' command before " << argv[0] << "\n";
1462 Aspect_FillMethod aFillType;
1465 const char* szType = argv[1];
1466 if (strcmp(szType, "NONE" ) == 0) aFillType = Aspect_FM_NONE;
1467 else if (strcmp(szType, "CENTERED") == 0) aFillType = Aspect_FM_CENTERED;
1468 else if (strcmp(szType, "TILED" ) == 0) aFillType = Aspect_FM_TILED;
1469 else if (strcmp(szType, "STRETCH" ) == 0) aFillType = Aspect_FM_STRETCH;
1472 di << "Wrong fill type : " << szType << "\n";
1473 di << "Must be one of CENTERED, TILED, STRETCH, NONE" << "\n";
1478 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1479 V3dView->SetBgImageStyle(aFillType, Standard_True);
1484 //==============================================================================
1485 //function : VSetGradientBg
1486 //purpose : Mount gradient background
1487 //==============================================================================
1488 static int VSetGradientBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1492 di << "Usage : " << argv[0] << " R1 G1 B1 R2 G2 B2 Type : Mount gradient background" << "\n";
1493 di << "R1,G1,B1,R2,G2,B2 = [0..255]" << "\n";
1494 di << "Type must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2" << "\n";
1495 di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4" << "\n";
1499 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1500 if(AISContext.IsNull())
1502 di << "use 'vinit' command before " << argv[0] << "\n";
1508 Standard_Real R1 = atof(argv[1])/255.;
1509 Standard_Real G1 = atof(argv[2])/255.;
1510 Standard_Real B1 = atof(argv[3])/255.;
1511 Quantity_Color aColor1(R1,G1,B1,Quantity_TOC_RGB);
1513 Standard_Real R2 = atof(argv[4])/255.;
1514 Standard_Real G2 = atof(argv[5])/255.;
1515 Standard_Real B2 = atof(argv[6])/255.;
1517 Quantity_Color aColor2(R2,G2,B2,Quantity_TOC_RGB);
1518 int aType = atoi(argv[7]);
1519 if( aType < 0 || aType > 8 )
1521 di << "Wrong fill type " << "\n";
1522 di << "Must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2" << "\n";
1523 di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4" << "\n";
1527 Aspect_GradientFillMethod aMethod = Aspect_GradientFillMethod(aType);
1529 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1530 V3dView->SetBgGradientColors( aColor1, aColor2, aMethod, 1);
1536 //==============================================================================
1537 //function : VSetGradientBgMode
1538 //purpose : Change gradient background fill style
1539 //==============================================================================
1540 static int VSetGradientBgMode(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1544 di << "Usage : " << argv[0] << " Type : Change gradient background fill type" << "\n";
1545 di << "Type must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2" << "\n";
1546 di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4" << "\n";
1550 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1551 if(AISContext.IsNull())
1553 di << "use 'vinit' command before " << argv[0] << "\n";
1558 int aType = atoi(argv[1]);
1559 if( aType < 0 || aType > 8 )
1561 di << "Wrong fill type " << "\n";
1562 di << "Must be one of 0 = NONE, 1 = HOR, 2 = VER, 3 = DIAG1, 4 = DIAG2" << "\n";
1563 di << " 5 = CORNER1, 6 = CORNER2, 7 = CORNER3, 8 = CORNER4" << "\n";
1567 Aspect_GradientFillMethod aMethod = Aspect_GradientFillMethod(aType);
1569 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1570 V3dView->SetBgGradientStyle( aMethod, 1 );
1576 //==============================================================================
1577 //function : VSetColorBg
1578 //purpose : Set color background
1579 //==============================================================================
1580 static int VSetColorBg(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1584 di << "Usage : " << argv[0] << " R G B : Set color background" << "\n";
1585 di << "R,G,B = [0..255]" << "\n";
1589 Handle(AIS_InteractiveContext) AISContext = ViewerTest::GetAISContext();
1590 if(AISContext.IsNull())
1592 di << "use 'vinit' command before " << argv[0] << "\n";
1598 Standard_Real R = atof(argv[1])/255.;
1599 Standard_Real G = atof(argv[2])/255.;
1600 Standard_Real B = atof(argv[3])/255.;
1601 Quantity_Color aColor(R,G,B,Quantity_TOC_RGB);
1603 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1604 V3dView->SetBackgroundColor( aColor );
1611 //==============================================================================
1613 //purpose : View Scaling
1614 //==============================================================================
1616 static int VScale(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1618 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1619 if ( V3dView.IsNull() ) return 1;
1622 di << argv[0] << "Invalid number of arguments" << "\n";
1625 V3dView->SetAxialScale( atof(argv[1]), atof(argv[2]), atof(argv[3]) );
1628 //==============================================================================
1629 //function : VTestZBuffTrihedron
1630 //purpose : Displays a V3d_ZBUFFER'ed trihedron at the bottom left corner of the view
1631 //==============================================================================
1633 static int VTestZBuffTrihedron(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1635 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1636 if ( V3dView.IsNull() ) return 1;
1638 // Set up default trihedron parameters
1639 V3dView->ZBufferTriedronSetup();
1640 V3dView->TriedronDisplay( Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.1, V3d_ZBUFFER );
1645 //==============================================================================
1646 //function : VRotate
1647 //purpose : Camera Rotating
1648 //==============================================================================
1650 static int VRotate( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) {
1651 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1652 if ( V3dView.IsNull() ) {
1657 V3dView->Rotate( atof(argv[1]), atof(argv[2]), atof(argv[3]) );
1659 } else if ( argc == 7 ) {
1660 V3dView->Rotate( atof(argv[1]), atof(argv[2]), atof(argv[3]), atof(argv[4]), atof(argv[5]), atof(argv[6]) );
1663 di << argv[0] << " Invalid number of arguments" << "\n";
1668 //==============================================================================
1670 //purpose : View zoom in / out (relative to current zoom)
1671 //==============================================================================
1673 static int VZoom( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) {
1674 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1675 if ( V3dView.IsNull() ) {
1680 Standard_Real coef = atof(argv[1]);
1681 if ( coef <= 0.0 ) {
1682 di << argv[1] << "Invalid value" << "\n";
1685 V3dView->SetZoom( atof(argv[1]) );
1688 di << argv[0] << " Invalid number of arguments" << "\n";
1693 //==============================================================================
1695 //purpose : View panning (in pixels)
1696 //==============================================================================
1698 static int VPan( Draw_Interpretor& di, Standard_Integer argc, const char** argv ) {
1699 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1700 if ( V3dView.IsNull() ) return 1;
1703 V3dView->Pan( atoi(argv[1]), atoi(argv[2]) );
1706 di << argv[0] << " Invalid number of arguments" << "\n";
1712 //==============================================================================
1713 //function : VExport
1714 //purpose : Export the view to a vector graphic format (PS, EMF, PDF)
1715 //==============================================================================
1717 static int VExport(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1719 Handle(V3d_View) V3dView = ViewerTest::CurrentView();
1720 if (V3dView.IsNull())
1725 std::cout << "Usage: " << argv[0] << " Filename [Format]\n";
1729 Graphic3d_ExportFormat anExpFormat = Graphic3d_EF_PDF;
1730 TCollection_AsciiString aFormatStr;
1732 TCollection_AsciiString aFileName (argv[1]);
1733 Standard_Integer aLen = aFileName.Length();
1737 aFormatStr = TCollection_AsciiString (argv[2]);
1741 if (aFileName.Value (aLen - 2) == '.')
1743 aFormatStr = aFileName.SubString (aLen - 1, aLen);
1745 else if (aFileName.Value (aLen - 3) == '.')
1747 aFormatStr = aFileName.SubString (aLen - 2, aLen);
1751 std::cout << "Export format couln't be detected from filename '" << argv[1] << "'\n";
1757 std::cout << "Export format couln't be detected from filename '" << argv[1] << "'\n";
1761 aFormatStr.UpperCase();
1762 if (aFormatStr == "PS")
1763 anExpFormat = Graphic3d_EF_PostScript;
1764 else if (aFormatStr == "EPS")
1765 anExpFormat = Graphic3d_EF_EnhPostScript;
1766 else if (aFormatStr == "TEX")
1767 anExpFormat = Graphic3d_EF_TEX;
1768 else if (aFormatStr == "PDF")
1769 anExpFormat = Graphic3d_EF_PDF;
1770 else if (aFormatStr == "SVG")
1771 anExpFormat = Graphic3d_EF_SVG;
1772 else if (aFormatStr == "PGF")
1773 anExpFormat = Graphic3d_EF_PGF;
1774 else if (aFormatStr == "EMF")
1775 anExpFormat = Graphic3d_EF_EMF;
1778 std::cout << "Invalid export format '" << aFormatStr << "'\n";
1782 if (!V3dView->View()->Export (argv[1], anExpFormat))
1784 std::cout << "Export failed!\n";
1790 //==============================================================================
1791 //function : VColorScale
1792 //purpose : representation color scale
1793 //==============================================================================
1794 #include <V3d_ColorScale.hxx>
1796 static int VColorScale (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
1798 if ( argc != 1 && argc != 4 && argc != 5 && argc != 6 && argc != 8 )
1800 di << "Usage : " << argv[0] << " [RangeMin = 0 RangeMax = 100 Intervals = 10 HeightFont = 16 Position = Right X = 0 Y = 0] " << "\n";
1804 Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
1805 if(aContext.IsNull()) {
1806 di << argv[0] << " ERROR : use 'vinit' command before " << "\n";
1810 Standard_Real minRange = 0. , maxRange = 100. ;
1812 Standard_Integer numIntervals = 10 ;
1813 Standard_Real textHeight = 16. ;
1814 Aspect_TypeOfColorScalePosition position = Aspect_TOCSP_RIGHT;
1815 Standard_Real X = 0., Y = 0. ;
1821 minRange = atof( argv[1] );
1822 maxRange = atof( argv[2] );
1823 numIntervals = atoi( argv[3] );
1826 textHeight = atof( argv[4] );
1828 position = (Aspect_TypeOfColorScalePosition)atoi( argv[5] );
1831 X = atof( argv[6] );
1832 Y = atof( argv[7] );
1835 Handle(V3d_View) curView = ViewerTest::CurrentView( );
1836 if ( curView.IsNull( ) )
1838 Handle(Aspect_ColorScale) aCSV = curView->ColorScale( );
1839 Handle(V3d_ColorScale) aCS = ( Handle( V3d_ColorScale )::DownCast( aCSV ) );
1840 if( ! aCS.IsNull( ) )
1842 aCS->SetPosition( X , Y );
1843 aCS->SetHeight( 0.95) ;
1844 aCS->SetTextHeight( textHeight );
1845 aCS->SetRange( minRange , maxRange );
1846 aCS->SetNumberOfIntervals( numIntervals );
1847 aCS->SetLabelPosition( position );
1848 if( !curView->ColorScaleIsDisplayed() )
1849 curView->ColorScaleDisplay( );
1854 //==============================================================================
1855 //function : VGraduatedTrihedron
1856 //purpose : Displays a graduated trihedron
1857 //==============================================================================
1859 static void AddMultibyteString (TCollection_ExtendedString &name, const char *arg)
1861 const char *str = arg;
1864 unsigned short c1 = *str++;
1865 unsigned short c2 = *str++;
1866 if (!c1 || !c2) break;
1867 name += (Standard_ExtCharacter)((c1 << 8) | c2);
1871 static int VGraduatedTrihedron(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
1874 if (argc != 2 && argc < 5)
1876 di<<"Error: "<<argv[0]<<" - invalid number of arguments\n";
1877 di<<"Usage: type help "<<argv[0]<<"\n";
1878 return 1; //TCL_ERROR
1881 Handle(V3d_View) aV3dView = ViewerTest::CurrentView();
1883 // Create 3D view if it doesn't exist
1884 if ( aV3dView.IsNull() )
1886 ViewerTest::ViewerInit();
1887 aV3dView = ViewerTest::CurrentView();
1888 if( aV3dView.IsNull() )
1890 di << "Error: Cannot create a 3D view\n";
1891 return 1; //TCL_ERROR
1895 // Erase (==0) or display (!=0)
1896 const int display = atoi(argv[1]);
1901 TCollection_AsciiString font;
1903 font.AssignCat("Courier");
1905 font.AssignCat(argv[5]);
1907 // Text is multibyte
1908 const Standard_Boolean isMultibyte = (argc < 7)? Standard_False : (atoi(argv[6]) != 0);
1911 TCollection_ExtendedString xname, yname, zname;
1916 AddMultibyteString(xname, argv[2]);
1917 AddMultibyteString(yname, argv[3]);
1918 AddMultibyteString(zname, argv[4]);
1934 aV3dView->GraduatedTrihedronDisplay(xname, yname, zname,
1935 Standard_True/*xdrawname*/, Standard_True/*ydrawname*/, Standard_True/*zdrawname*/,
1936 Standard_True/*xdrawvalues*/, Standard_True/*ydrawvalues*/, Standard_True/*zdrawvalues*/,
1937 Standard_True/*drawgrid*/,
1938 Standard_True/*drawaxes*/,
1939 5/*nbx*/, 5/*nby*/, 5/*nbz*/,
1940 10/*xoffset*/, 10/*yoffset*/, 10/*zoffset*/,
1941 30/*xaxisoffset*/, 30/*yaxisoffset*/, 30/*zaxisoffset*/,
1942 Standard_True/*xdrawtickmarks*/, Standard_True/*ydrawtickmarks*/, Standard_True/*zdrawtickmarks*/,
1943 10/*xtickmarklength*/, 10/*ytickmarklength*/, 10/*ztickmarklength*/,
1944 Quantity_NOC_WHITE/*gridcolor*/,
1945 Quantity_NOC_RED/*xnamecolor*/,Quantity_NOC_GREEN/*ynamecolor*/,Quantity_NOC_BLUE1/*znamecolor*/,
1946 Quantity_NOC_RED/*xcolor*/,Quantity_NOC_GREEN/*ycolor*/,Quantity_NOC_BLUE1/*zcolor*/,font);
1949 aV3dView->GraduatedTrihedronErase();
1951 ViewerTest::GetAISContext()->UpdateCurrentViewer();
1957 //==============================================================================
1958 //function : VPrintView
1959 //purpose : Test printing algorithm, print the view to image file with given
1960 // width and height. Printing implemented only for WNT.
1961 //==============================================================================
1962 static int VPrintView (Draw_Interpretor& di, Standard_Integer argc,
1966 di << "Printing implemented only for wnt!\n";
1970 Handle(AIS_InteractiveContext) aContextAIS = NULL;
1971 Handle(V3d_View) aView = NULL;
1972 aContextAIS = ViewerTest::GetAISContext();
1973 if (!aContextAIS.IsNull())
1975 const Handle(V3d_Viewer)& Vwr = aContextAIS->CurrentViewer();
1976 Vwr->InitActiveViews();
1977 if(Vwr->MoreActiveViews())
1978 aView = Vwr->ActiveView();
1984 di << "Call vinit before!\n";
1989 di << "Use: " << argv[0];
1990 di << " width height filename [print algo=0]\n";
1991 di << "width, height of the intermediate buffer for operation\n";
1992 di << "algo : {0|1}\n";
1993 di << " 0 - stretch algorithm\n";
1994 di << " 1 - tile algorithm\n";
1995 di << "test printing algorithms into an intermediate buffer\n";
1996 di << "with saving output to an image file\n";
2000 // get the input params
2001 Standard_Integer aWidth = atoi (argv[1]);
2002 Standard_Integer aHeight = atoi (argv[2]);
2003 Standard_Integer aMode = 0;
2004 TCollection_AsciiString aFileName = TCollection_AsciiString (argv[3]);
2006 aMode = atoi (argv[4]);
2008 // check the input parameters
2009 if (aWidth <= 0 || aHeight <= 0)
2011 di << "Width and height must be positive values!\n";
2014 if (aMode != 0 && aMode != 1)
2017 Image_CRawBufferData aRawBuffer;
2018 HDC anDC = CreateCompatibleDC(0);
2020 // define compatible bitmap
2021 BITMAPINFO aBitmapData;
2022 memset (&aBitmapData, 0, sizeof (BITMAPINFOHEADER));
2023 aBitmapData.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
2024 aBitmapData.bmiHeader.biWidth = aWidth ;
2025 aBitmapData.bmiHeader.biHeight = aHeight;
2026 aBitmapData.bmiHeader.biPlanes = 1;
2027 aBitmapData.bmiHeader.biBitCount = 24;
2028 aBitmapData.bmiHeader.biXPelsPerMeter = 0;
2029 aBitmapData.bmiHeader.biYPelsPerMeter = 0;
2030 aBitmapData.bmiHeader.biClrUsed = 0;
2031 aBitmapData.bmiHeader.biClrImportant = 0;
2032 aBitmapData.bmiHeader.biCompression = BI_RGB;
2033 aBitmapData.bmiHeader.biSizeImage = 0;
2035 // Create Device Independent Bitmap
2036 HBITMAP aMemoryBitmap = CreateDIBSection (anDC, &aBitmapData, DIB_RGB_COLORS,
2037 &aRawBuffer.dataPtr, NULL, 0);
2038 HGDIOBJ anOldBitmap = SelectObject(anDC, aMemoryBitmap);
2040 Standard_Boolean isSaved = Standard_False, isPrinted = Standard_False;
2041 if (aRawBuffer.dataPtr != 0)
2044 isPrinted = aView->Print(anDC,1,1,0,Aspect_PA_STRETCH);
2046 isPrinted = aView->Print(anDC,1,1,0,Aspect_PA_TILE);
2048 // succesfully printed into an intermediate buffer
2051 Handle(Image_PixMap) anImageBitmap =
2052 new Image_PixMap ((Standard_PByte)aRawBuffer.dataPtr,
2054 aWidth*3 + aWidth%4, 24, 0);
2055 isSaved = anImageBitmap->Dump(aFileName.ToCString());
2059 di << "Print operation failed due to printing errors or\n";
2060 di << "insufficient memory available\n";
2061 di << "Please, try to use smaller dimensions for this test\n";
2062 di << "command, as it allocates intermediate buffer for storing\n";
2063 di << "the result\n";
2068 di << "Can't allocate memory for intermediate buffer\n";
2069 di << "Please use smaller dimensions\n";
2074 SelectObject (anDC, anOldBitmap);
2075 DeleteObject (aMemoryBitmap);
2081 di << "Save to file operation failed. This operation may fail\n";
2082 di << "if you don't have enough available memory, then you can\n";
2083 di << "use smaller dimensions for the output file\n";
2092 //==============================================================================
2093 //function : VZLayer
2094 //purpose : Test z layer operations for v3d viewer
2095 //==============================================================================
2096 static int VZLayer (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2098 Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext ();
2099 if (aContextAIS.IsNull())
2101 di << "Call vinit before!\n";
2106 di << "Use: vzlayer " << argv[0];
2107 di << " add/del/get [id]\n";
2108 di << " add - add new z layer to viewer and print its id\n";
2109 di << " del - del z layer by its id\n";
2110 di << " get - print sequence of z layers in increasing order of their overlay level\n";
2111 di << "id - the layer identificator value defined when removing z layer\n";
2115 const Handle(V3d_Viewer)& aViewer = aContextAIS->CurrentViewer();
2116 if (aViewer.IsNull())
2118 di << "No active viewer!\n";
2122 // perform operation
2123 TCollection_AsciiString anOp = TCollection_AsciiString (argv[1]);
2126 Standard_Integer aNewId;
2127 if (!aViewer->AddZLayer (aNewId))
2129 di << "Impossible to add new z layer!\n";
2133 di << "New z layer added with index: " << aNewId << "\n";
2135 else if (anOp == "del")
2139 di << "Please also provide as argument id of z layer to remove\n";
2143 Standard_Integer aDelId = atoi (argv[2]);
2144 if (!aViewer->RemoveZLayer (aDelId))
2146 di << "Impossible to remove the z layer or invalid id!\n";
2150 di << "Z layer " << aDelId << " has been removed\n";
2152 else if (anOp == "get")
2154 TColStd_SequenceOfInteger anIds;
2155 aViewer->GetAllZLayers (anIds);
2156 for (Standard_Integer aSeqIdx = 1; aSeqIdx <= anIds.Length(); aSeqIdx++)
2158 di << anIds.Value (aSeqIdx) << " ";
2165 di << "Invalid operation, please use { add / del / get }\n";
2172 DEFINE_STANDARD_HANDLE(V3d_TextItem, Visual3d_LayerItem)
2174 // this class provides a presentation of text item in v3d view under-/overlayer
2175 class V3d_TextItem : public Visual3d_LayerItem
2180 DEFINE_STANDARD_RTTI(V3d_TextItem)
2183 Standard_EXPORT V3d_TextItem(const TCollection_AsciiString& theText,
2184 const Standard_Real theX1,
2185 const Standard_Real theY1,
2186 const Standard_Real theHeight,
2187 const TCollection_AsciiString& theFontName,
2188 const Quantity_Color& theColor,
2189 const Quantity_Color& theSubtitleColor,
2190 const Aspect_TypeOfDisplayText& theTypeOfDisplay,
2191 const Handle(Visual3d_Layer)& theLayer);
2194 Standard_EXPORT void RedrawLayerPrs();
2200 Standard_Real myHeight;
2201 TCollection_AsciiString myText;
2202 TCollection_AsciiString myFontName;
2203 Quantity_Color myColor;
2204 Quantity_Color mySubtitleColor;
2205 Aspect_TypeOfDisplayText myType;
2206 Handle(Visual3d_Layer) myLayer;
2210 IMPLEMENT_STANDARD_HANDLE(V3d_TextItem, Visual3d_LayerItem)
2211 IMPLEMENT_STANDARD_RTTIEXT(V3d_TextItem, Visual3d_LayerItem)
2213 // create and add to display the text item
2214 V3d_TextItem::V3d_TextItem (const TCollection_AsciiString& theText,
2215 const Standard_Real theX1,
2216 const Standard_Real theY1,
2217 const Standard_Real theHeight,
2218 const TCollection_AsciiString& theFontName,
2219 const Quantity_Color& theColor,
2220 const Quantity_Color& theSubtitleColor,
2221 const Aspect_TypeOfDisplayText& theTypeOfDisplay,
2222 const Handle(Visual3d_Layer)& theLayer)
2223 : myX1 (theX1), myY1 (theY1),
2225 myHeight (theHeight),
2228 mySubtitleColor (theSubtitleColor),
2229 myType (theTypeOfDisplay),
2230 myFontName (theFontName)
2232 if (!myLayer.IsNull ())
2233 myLayer->AddLayerItem (this);
2237 void V3d_TextItem::RedrawLayerPrs ()
2239 if (myLayer.IsNull ())
2242 myLayer->SetColor (myColor);
2243 myLayer->SetTextAttributes (myFontName.ToCString (), myType, mySubtitleColor);
2244 myLayer->DrawText (myText.ToCString (), myX1, myY1, myHeight);
2247 DEFINE_STANDARD_HANDLE(V3d_LineItem, Visual3d_LayerItem)
2249 // The Visual3d_LayerItem line item for "vlayerline" command
2250 // it provides a presentation of line with user-defined
2251 // linewidth, linetype and transparency.
2252 class V3d_LineItem : public Visual3d_LayerItem
2256 DEFINE_STANDARD_RTTI(V3d_LineItem)
2259 Standard_EXPORT V3d_LineItem(Standard_Real X1, Standard_Real Y1,
2260 Standard_Real X2, Standard_Real Y2,
2261 V3d_LayerMgrPointer theLayerMgr,
2262 Aspect_TypeOfLine theType = Aspect_TOL_SOLID,
2263 Standard_Real theWidth = 0.5,
2264 Standard_Real theTransp = 1.0);
2267 Standard_EXPORT void RedrawLayerPrs();
2271 Standard_Real myX1, myY1, myX2, myY2;
2272 Standard_Real myWidth;
2273 Standard_Real myTransparency;
2274 Aspect_TypeOfLine myType;
2275 V3d_LayerMgrPointer myLayerMgr;
2278 IMPLEMENT_STANDARD_HANDLE(V3d_LineItem, Visual3d_LayerItem)
2279 IMPLEMENT_STANDARD_RTTIEXT(V3d_LineItem, Visual3d_LayerItem)
2281 // default constructor for line item
2282 V3d_LineItem::V3d_LineItem(Standard_Real X1, Standard_Real Y1,
2283 Standard_Real X2, Standard_Real Y2,
2284 V3d_LayerMgrPointer theLayerMgr,
2285 Aspect_TypeOfLine theType,
2286 Standard_Real theWidth,
2287 Standard_Real theTransp) :
2288 myX1(X1), myY1(Y1), myX2(X2), myY2(Y2), myLayerMgr(theLayerMgr),
2289 myType(theType), myWidth(theWidth), myTransparency(theTransp)
2291 if (myLayerMgr && myLayerMgr->Overlay())
2292 myLayerMgr->Overlay()->AddLayerItem (this);
2296 void V3d_LineItem::RedrawLayerPrs ()
2298 Handle (Visual3d_Layer) aOverlay;
2301 aOverlay = myLayerMgr->Overlay();
2303 if (!aOverlay.IsNull())
2305 Quantity_Color aColor(1.0, 0, 0, Quantity_TOC_RGB);
2306 aOverlay->SetColor(aColor);
2307 aOverlay->SetTransparency((Standard_ShortReal)myTransparency);
2308 aOverlay->SetLineAttributes((Aspect_TypeOfLine)myType, myWidth);
2309 aOverlay->BeginPolyline();
2310 aOverlay->AddVertex(myX1, myY1);
2311 aOverlay->AddVertex(myX2, myY2);
2312 aOverlay->ClosePrimitive();
2316 //=============================================================================
2317 //function : VLayerLine
2318 //purpose : Draws line in the v3d view layer with given attributes: linetype,
2319 // : linewidth, transparency coefficient
2320 //============================================================================
2321 static int VLayerLine(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
2323 // get the active view
2324 Handle(V3d_View) aView = ViewerTest::CurrentView();
2327 di << "Call vinit before!\n";
2332 di << "Use: " << argv[0];
2333 di << " x1 y1 x2 y2 [linewidth = 0.5] [linetype = 0] [transparency = 1]\n";
2334 di << " linetype : { 0 | 1 | 2 | 3 } \n";
2335 di << " 0 - solid \n";
2336 di << " 1 - dashed \n";
2337 di << " 2 - dot \n";
2338 di << " 3 - dashdot\n";
2339 di << " transparency : { 0.0 - 1.0 } \n";
2340 di << " 0.0 - transparent\n";
2341 di << " 1.0 - visible \n";
2345 // get the input params
2346 Standard_Real X1 = atof(argv[1]);
2347 Standard_Real Y1 = atof(argv[2]);
2348 Standard_Real X2 = atof(argv[3]);
2349 Standard_Real Y2 = atof(argv[4]);
2351 Standard_Real aWidth = 0.5;
2352 Standard_Integer aType = 0;
2353 Standard_Real aTransparency = 1.0;
2357 aWidth = atof(argv[5]);
2361 aType = (Standard_Integer) atoi(argv[6]);
2366 aTransparency = atof(argv[7]);
2367 if (aTransparency < 0 || aTransparency > 1.0)
2368 aTransparency = 1.0;
2371 // select appropriate line type
2372 Aspect_TypeOfLine aLineType;
2376 aLineType = Aspect_TOL_DASH;
2380 aLineType = Aspect_TOL_DOT;
2384 aLineType = Aspect_TOL_DOTDASH;
2388 aLineType = Aspect_TOL_SOLID;
2391 // replace layer manager
2392 Handle(V3d_LayerMgr) aMgr = new V3d_LayerMgr(aView);
2393 aView->SetLayerMgr(aMgr);
2396 Handle (V3d_LineItem) anItem = new V3d_LineItem(X1, Y1, X2, Y2,
2402 aView->MustBeResized();
2408 //=======================================================================
2409 //function : VOverlayText
2410 //purpose : Test text displaying in view overlay
2411 //=======================================================================
2412 static int VOverlayText (Draw_Interpretor& di, Standard_Integer argc, const char**argv)
2414 // get the active view
2415 Handle(V3d_View) aView = ViewerTest::CurrentView();
2418 di << "No active view. Please call vinit.\n";
2421 else if (argc < 4 || argc > 13)
2423 di << "Use: " << argv[0];
2424 di << " text x y [height] [font_name] [text_color: R G B] [displayType]\n";
2425 di << "[background_color: R G B]\n";
2426 di << " height - pixel height of the text (default=10.0)\n";
2427 di << " font_name - name of font (default=courier)\n";
2428 di << " text_color - R G B values of text color (default=255.0 255.0 255.0)\n";
2429 di << " display_type = {normal/subtitle/decal/blend}, (default=normal)\n";
2430 di << " background_color- R G B values used for subtitle and decal text\n";
2431 di << "(default=255.0 255.0 255.0)\n";
2435 TCollection_AsciiString aText (argv[1]);
2436 Standard_Real aPosX = atof(argv[2]);
2437 Standard_Real aPosY = atof(argv[3]);
2438 Standard_Real aHeight = (argc >= 5) ? atof (argv[4]) : 10.0;
2441 TCollection_AsciiString aFontName = "Courier";
2443 aFontName = TCollection_AsciiString (argv[5]);
2446 Quantity_Parameter aColorRed = 1.0;
2447 Quantity_Parameter aColorGreen = 1.0;
2448 Quantity_Parameter aColorBlue = 1.0;
2451 aColorRed = atof (argv[6])/255.;
2452 aColorGreen = atof (argv[7])/255.;
2453 aColorBlue = atof (argv[8])/255.;
2457 TCollection_AsciiString aDispStr;
2459 aDispStr = TCollection_AsciiString (argv[9]);
2461 Aspect_TypeOfDisplayText aTextType = Aspect_TODT_NORMAL;
2462 if (aDispStr.IsEqual ("subtitle"))
2463 aTextType = Aspect_TODT_SUBTITLE;
2464 else if (aDispStr.IsEqual ("decal"))
2465 aTextType = Aspect_TODT_DEKALE;
2466 else if (aDispStr.IsEqual ("blend"))
2467 aTextType = Aspect_TODT_BLEND;
2470 Quantity_Parameter aSubRed = 1.0;
2471 Quantity_Parameter aSubGreen = 1.0;
2472 Quantity_Parameter aSubBlue = 1.0;
2475 aSubRed = atof (argv[10])/255.;
2476 aSubGreen = atof (argv[11])/255.;
2477 aSubBlue = atof (argv[12])/255.;
2480 // check fo current overlay
2481 Handle(Visual3d_Layer) anOverlay = aView->Viewer()->Viewer()->OverLayer ();
2482 if (anOverlay.IsNull ())
2484 Handle(V3d_LayerMgr) aMgr = new V3d_LayerMgr (aView);
2485 anOverlay = aMgr->Overlay ();
2486 aView->SetLayerMgr (aMgr);
2489 Quantity_Color aTextColor (aColorRed, aColorGreen,
2490 aColorBlue, Quantity_TOC_RGB);
2491 Quantity_Color aSubtColor (aSubRed, aSubGreen,
2492 aSubBlue, Quantity_TOC_RGB);
2495 Handle(V3d_TextItem) anItem = new V3d_TextItem (aText, aPosX, aPosY,
2496 aHeight, aFontName, aTextColor, aSubtColor, aTextType, anOverlay);
2499 aView->MustBeResized();
2505 //=======================================================================
2506 //function : ViewerCommands
2508 //=======================================================================
2510 void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
2513 const char *group = "ZeViewer";
2514 theCommands.Add("vinit" ,
2515 "vinit : vinit [leftPx topPx widthPx heightPx] : Create the Viewer window",
2516 __FILE__,VInit,group);
2517 theCommands.Add("vhelp" ,
2518 "vhelp : display help on the viewer commands",
2519 __FILE__,VHelp,group);
2520 theCommands.Add("vtop" ,
2521 "vtop or <T> : Top view" ,
2522 __FILE__,VTop,group);
2523 theCommands.Add("vaxo" ,
2524 " vaxo or <A> : Axonometric view ",
2525 __FILE__,VAxo,group);
2526 theCommands.Add("vpick" ,
2527 "vpick : vpick X Y Z [shape subshape] ( all variables as string )",
2529 theCommands.Add("vfit" ,
2530 "vfit or <F> : vfit",
2531 __FILE__,VFit,group);
2532 theCommands.Add("vzfit" ,
2534 __FILE__,VZFit,group);
2535 theCommands.Add("vrepaint",
2536 "vrepaint : vrepaint, force redraw",
2537 __FILE__,VRepaint,group);
2538 theCommands.Add("vclear",
2540 __FILE__,VClear,group);
2541 theCommands.Add("vsetbg",
2542 "vsetbg : vsetbg imagefile [filltype] : Load image as background",
2543 __FILE__,VSetBg,group);
2544 theCommands.Add("vsetbgmode",
2545 "vsetbgmode : vsetbgmode filltype : Change background image fill type",
2546 __FILE__,VSetBgMode,group);
2547 theCommands.Add("vsetgradientbg",
2548 "vsetgradientbg : vsetgradientbg r1 g1 b1 r2 g2 b2 filltype : Mount gradient background",
2549 __FILE__,VSetGradientBg,group);
2550 theCommands.Add("vsetgrbgmode",
2551 "vsetgrbgmode : vsetgrbgmode filltype : Change gradient background fill type",
2552 __FILE__,VSetGradientBgMode,group);
2553 theCommands.Add("vsetcolorbg",
2554 "vsetcolorbg : vsetcolorbg r g b : Set background color",
2555 __FILE__,VSetColorBg,group);
2556 theCommands.Add("vscale",
2557 "vscale : vscale X Y Z",
2558 __FILE__,VScale,group);
2559 theCommands.Add("vzbufftrihedron",
2560 "vzbufftrihedron : Displays a V3d_ZBUFFER'ed trihedron at the bottom left corner of the view",
2561 __FILE__,VTestZBuffTrihedron,group);
2562 theCommands.Add("vrotate",
2563 "vrotate : vrotate AX AY AZ [X Y Z]",
2564 __FILE__,VRotate,group);
2565 theCommands.Add("vzoom",
2566 "vzoom : vzoom coef",
2567 __FILE__,VZoom,group);
2568 theCommands.Add("vpan",
2569 "vpan : vpan dx dy",
2570 __FILE__,VPan,group);
2571 theCommands.Add("vexport",
2572 "vexport : vexport full_file_path {PS | EPS | TEX | PDF | SVG | PGF | EMF }"
2573 " : exports the view to a vector file of a given format"
2574 " : notice that EMF format requires patched gl2ps",
2575 __FILE__,VExport,group);
2576 theCommands.Add("vcolorscale",
2577 "vcolorscale : vcolorscale [RangeMin = 0 RangeMax = 100 Intervals = 10 HeightFont = 16 Position = 2 X = 0 Y = 0]: draw color scale",
2578 __FILE__,VColorScale,group);
2579 theCommands.Add("vgraduatedtrihedron",
2580 "vgraduatedtrihedron : 1/0 (display/erase) [Xname Yname Zname [Font [isMultibyte]]]",
2581 __FILE__,VGraduatedTrihedron,group);
2582 theCommands.Add("vprintview" ,
2583 "vprintview : width height filename [algo=0] : Test print algorithm: algo = 0 - stretch, algo = 1 - tile",
2584 __FILE__,VPrintView,group);
2585 theCommands.Add("vzlayer",
2586 "vzlayer : add/del/get [id] : Z layer operations in v3d viewer: add new z layer, delete z layer, get z layer ids",
2587 __FILE__,VZLayer,group);
2588 theCommands.Add("voverlaytext",
2589 "voverlaytext : text x y [height] [font_name] [text_color: R G B] [display_type] [background_color: R G B]"
2590 " : height - pixel height of the text (default=10.0)"
2591 " : font_name - name of font (default=courier)"
2592 " : text_color - three values: RedColor GreenColor BlueColor (default = 255.0 255.0 255.0) "
2593 " : display_type = {normal/subtitle/decal/blend}, (default=normal) "
2594 " : background_color - three values: RedColor GreenColor BlueColor (default = 255.0 255.0 255.0), the parameter is defined for subtitle and decal display types ",
2595 __FILE__,VOverlayText,group);
2596 theCommands.Add("vlayerline",
2597 "vlayerline : vlayerline x1 y1 x2 y2 [linewidth=0.5] [linetype=0] [transparency=1.0]",
2598 __FILE__,VLayerLine,group);