0023022: This is desirable to access OpenGl extensions and core API (1.2+) in one...
[occt.git] / src / ViewerTest / ViewerTest_Tool.cxx
CommitLineData
7fd59977 1// File: ViewerTest_Tool.cxx
2// Created: Thu Oct 15 10:24:56 1998
3// Author: Denis PASCAL
4// <dp@dingox.paris1.matra-dtv.fr>
5
6#ifdef WNT
7#include <windows.h>
8#endif
9
10#include <ViewerTest_Tool.ixx>
11
12#include <V3d_View.hxx>
13#include <AIS_InteractiveContext.hxx>
14#include <ViewerTest.hxx>
15#include <string.h>
16#include <Draw_Interpretor.hxx>
17#include <Draw.hxx>
18#include <Draw_Appli.hxx>
19#include <DBRep.hxx>
20#include <Graphic3d_GraphicDevice.hxx>
21#include <Xw_GraphicDevice.hxx>
22#include <Xw_WindowQuality.hxx>
23#include <Xw_Window.hxx>
24#include <Graphic3d_GraphicDevice.hxx>
25#include <Xw_GraphicDevice.hxx>
26#include <Xw_WindowQuality.hxx>
27#include <Xw_Window.hxx>
28#include <TCollection_AsciiString.hxx>
29#include <V3d_Viewer.hxx>
30#include <V3d_View.hxx>
31#include <V3d.hxx>
32#include <AIS_DisplayMode.hxx>
33#include <TColStd_MapOfInteger.hxx>
34#include <AIS_MapOfInteractive.hxx>
35#include <ViewerTest_DoubleMapOfInteractiveAndName.hxx>
36#include <ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName.hxx>
37#include <ViewerTest_EventManager.hxx>
38#include <Draw_Window.hxx>
39#include <AIS_ListIteratorOfListOfInteractive.hxx>
40#include <AIS_ListOfInteractive.hxx>
41#include <Aspect_Window.hxx>
42
43
44#ifndef WNT
45#include <X11/Xlib.h>
46#include <X11/Xutil.h>
47#else
48#include <WNT_WClass.hxx>
49#include <WNT_Window.hxx>
50#include <Graphic3d_WNTGraphicDevice.hxx>
51#endif
52
53
54
55
56
57//==============================================================================
58// GLOBAL VARIABLES
59//==============================================================================
60#define ZCLIPWIDTH 1.
61
62#ifdef WNT
63
64static Handle(Graphic3d_WNTGraphicDevice) GetDevice() {
65 static Handle(Graphic3d_WNTGraphicDevice) myDevice;
66 static int first = 1;
67 if ( first ) myDevice = new Graphic3d_WNTGraphicDevice();
68 first = 0;
69 return myDevice;
70}
71
72#else
73
74static Handle(Graphic3d_GraphicDevice)& GetDevice() {
75 static Handle(Graphic3d_GraphicDevice) myDevice;
76 static int first = 1;
77 if ( first ) myDevice = new Graphic3d_GraphicDevice (getenv("DISPLAY"),Xw_TOM_READONLY);
78 first = 0;
79 return myDevice;
80}
81
82//static Display *display;
83
84#endif
85
86
4b9ac1ce
V
87Standard_IMPORT Standard_Boolean Draw_VirtualWindows;
88
7fd59977 89//=======================================================================
90//function : MakeViewer
91//purpose :
92//=======================================================================
93
94Handle(V3d_Viewer) ViewerTest_Tool::MakeViewer (const Standard_CString title)
95{
96
97 Handle(Aspect_Window) window;
98
99#ifdef WNT
100
101 window = new WNT_Window (GetDevice(),
102 title,
103 Handle(WNT_WClass)::DownCast (ViewerTest::WClass()),
104 WS_OVERLAPPEDWINDOW,
4b9ac1ce 105 0,460,409,409,
7fd59977 106 Quantity_NOC_BLACK);
107 window->Map();
108
109#else
110 window = new Xw_Window(GetDevice(),
111 title,
4b9ac1ce 112 0,460,409,409,
7fd59977 113 Xw_WQ_3DQUALITY,
114 Quantity_NOC_BLACK);
115#endif
4b9ac1ce 116 window->SetVirtual (Draw_VirtualWindows);
7fd59977 117
118 // Viewer
119
120 Handle(Aspect_GraphicDevice) theDevice = GetDevice();
121 TCollection_ExtendedString NameOfWindow("Visu3D");
122 Handle(V3d_Viewer) a3DViewer = new V3d_Viewer(theDevice,NameOfWindow.ToExtString());
123
124
125 a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK);
126 a3DViewer->SetDefaultLights();
127 a3DViewer->SetLightOn();
128
129 // View
130 Handle (V3d_View) V = a3DViewer->CreateView();
131 V->SetDegenerateModeOn();
132 V->SetWindow(window);
133 V->SetZClippingDepth(0.5);
134 V->SetZClippingWidth(ZCLIPWIDTH/2.);
135
136 return a3DViewer;
137}
138
139//=======================================================================
140//function : MakeContext
141//purpose :
142//=======================================================================
143
144Handle(AIS_InteractiveContext) ViewerTest_Tool::MakeContext (const Standard_CString title)
145{
146 return new AIS_InteractiveContext (MakeViewer(title));
147}
148
149
150
151//=======================================================================
152//function : InitViewerTest
153//purpose :
154//=======================================================================
155
156// ********* next method is defined in ViewerTest_ViewerCommands.hxx ****
157extern void ViewerTest_InitViewerTest (const Handle(AIS_InteractiveContext)&);
158// **********************************************************************
159
160void ViewerTest_Tool::InitViewerTest (const Handle(AIS_InteractiveContext)& context)
161{
162 ViewerTest_InitViewerTest (context);
163}
164