1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/
20 #include "OCCViewer_VService.h"
21 #include <V3d_Viewer.hxx>
22 #include <V3d_View.hxx>
23 #include <Viewer_Viewer.hxx>
25 #include <V2d_Viewer.hxx>
26 #include <V2d_View.hxx>
27 #include <Viewer_Viewer.hxx>
30 #include <WNT_Window.hxx>
31 #include <Graphic3d_WNTGraphicDevice.hxx>
32 #include <WNT_GraphicDevice.hxx>
33 #include <WNT_GraphicDevice.hxx>
34 #include <WNT_WDriver.hxx>
36 #include <Xw_Window.hxx>
37 #include <Graphic3d_GraphicDevice.hxx>
38 #include <Xw_Driver.hxx>
39 //#include <Xdps_Driver.hxx>
40 #include <Xw_TypeOfMapping.hxx>
47 static Handle(WNT_GraphicDevice) XServiceDefault2dDevice;
48 static Handle(WNT_GraphicDevice) XServiceImageDevice;
50 static Handle(WNT_GraphicDevice)& _XServiceDefault2dDevice() {
51 static Handle(WNT_GraphicDevice) XServiceDefault2dDevice;
52 return XServiceDefault2dDevice;
54 #define XServiceDefault2dDevice _XServiceDefault2dDevice()
56 static Handle(WNT_GraphicDevice)& _XServiceImageDevice() {
57 static Handle(WNT_GraphicDevice) XServiceImageDevice;
58 return XServiceImageDevice;
60 #define XServiceImageDevice _XServiceImageDevice()
64 static Handle(Xw_GraphicDevice) XServiceDefault2dDevice;
65 static Handle(Xw_GraphicDevice) XServiceImageDevice;
67 static Handle(Xw_GraphicDevice)& _XServiceDefault2dDevice() {
68 static Handle(Xw_GraphicDevice) XServiceDefault2dDevice;
69 return XServiceDefault2dDevice;
71 #define XServiceDefault2dDevice _XServiceImageDevice()
73 static Handle(Xw_GraphicDevice)& _XServiceImageDevice() {
74 static Handle(Xw_GraphicDevice) XServiceImageDevice;
75 return XServiceImageDevice;
77 #define XServiceImageDevice _XServiceImageDevice()
82 Maps CasCade view to the window [ static ]
84 void OCCViewer_VService::SetWindow( const Handle(V3d_View)& view,
85 const Standard_Integer hiwin,
86 const Standard_Integer lowin,
87 const Xw_WindowQuality quality )
90 Handle(WNT_Window) w =
91 new WNT_Window( Handle(Graphic3d_WNTGraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin );
94 new Xw_Window( Handle(Graphic3d_GraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin, quality );
100 Magnifies 'view' based on previous view [ static ]
102 void OCCViewer_VService::SetMagnify( const Handle(V3d_View)& view,
103 const Standard_Integer hiwin,
104 const Standard_Integer lowin,
105 const Handle(V3d_View)& prevView,
106 const Standard_Integer x1,
107 const Standard_Integer y1,
108 const Standard_Integer x2,
109 const Standard_Integer y2,
110 const Xw_WindowQuality aQuality )
113 Handle(WNT_Window) w =
114 new WNT_Window( Handle(Graphic3d_WNTGraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin );
116 Handle(Xw_Window) w =
117 new Xw_Window( Handle(Graphic3d_GraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin, aQuality );
119 view->SetMagnify( w, prevView, x1, y1, x2, y2 );
123 Creates viewer 3d [ static ]
125 Handle(V3d_Viewer) OCCViewer_VService::Viewer3d( const Standard_CString aDisplay,
126 const Standard_ExtString aName,
127 const Standard_CString aDomain,
128 const Standard_Real ViewSize ,
129 const V3d_TypeOfOrientation ViewProj,
130 const Standard_Boolean ComputedMode,
131 const Standard_Boolean aDefaultComputedMode )
134 static Handle(Graphic3d_GraphicDevice) defaultdevice;
135 if ( defaultdevice.IsNull() )
136 defaultdevice = new Graphic3d_GraphicDevice( aDisplay );
137 return new V3d_Viewer( defaultdevice, aName, aDomain, ViewSize, ViewProj,
138 Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT,
139 ComputedMode, aDefaultComputedMode, V3d_TEX_NONE );
141 static Handle(Graphic3d_WNTGraphicDevice) defaultdevice;
142 if ( defaultdevice.IsNull() )
143 defaultdevice = new Graphic3d_WNTGraphicDevice();
144 return new V3d_Viewer( defaultdevice, aName, aDomain, ViewSize, ViewProj,
145 Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT,
146 ComputedMode, aDefaultComputedMode, V3d_TEX_NONE);
151 Creates view 2D and maps it to the window [ static ]
153 /*Handle(V2d_View) OCCViewer_VService::View2d( const Handle(V2d_Viewer)& aViewer,
154 const Standard_Integer hiwin,
155 const Standard_Integer lowin,
156 const Xw_WindowQuality aQuality,
157 const Standard_Boolean Update,
158 const Quantity_NameOfColor BackColor )
161 Handle(WNT_GraphicDevice) GD = Handle(WNT_GraphicDevice)::DownCast(aViewer->Device());
162 Handle(WNT_Window) W = new WNT_Window( GD, hiwin, lowin, BackColor );
163 Handle(WNT_WDriver) D = new WNT_WDriver( W );
165 Handle(Xw_GraphicDevice) GD = Handle(Xw_GraphicDevice)::DownCast(aViewer->Device());
166 Handle(Xw_Window) W = new Xw_Window( GD, hiwin, lowin, aQuality, BackColor );
167 Handle(Xw_Driver) D = new Xw_Driver( W );
169 Handle(V2d_View) V = new V2d_View( D, aViewer );
176 Creates view 2D and maps it to the window [ static ]
178 /*Handle(V2d_View) OCCViewer_VService::dpsView2d( const Handle(V2d_Viewer)& aViewer,
179 const Standard_Integer hiwin,
180 const Standard_Integer lowin,
181 const Xw_WindowQuality aQuality,
182 const Standard_Boolean Update,
183 const Quantity_NameOfColor BackColor )
186 Handle(WNT_GraphicDevice) GD = Handle(WNT_GraphicDevice)::DownCast(aViewer->Device());
187 Handle(WNT_Window) W = new WNT_Window( GD, hiwin, lowin, BackColor );
188 W->SetBackground( BackColor );
189 Handle(WNT_WDriver) D = new WNT_WDriver( W );
191 Handle(Xw_GraphicDevice) GD = Handle(Xw_GraphicDevice)::DownCast(aViewer->Device());
192 Handle(Xw_Window) W = new Xw_Window( GD, hiwin, lowin, aQuality, BackColor );
193 Handle(Xdps_Driver) D = new Xdps_Driver( W );
195 Handle(V2d_View) V = new V2d_View( D, aViewer );
202 Creates viewer 2D [ static ]
204 /*Handle(V2d_Viewer) OCCViewer_VService::Viewer2d( const Standard_CString aDisplay,
205 const Standard_ExtString aName,
206 const Standard_CString aDomain )
209 if ( XServiceDefault2dDevice.IsNull() )
210 XServiceDefault2dDevice = new WNT_GraphicDevice();
212 if ( XServiceDefault2dDevice.IsNull() )
213 XServiceDefault2dDevice = new Xw_GraphicDevice( aDisplay, Xw_TOM_READONLY );
215 return new V2d_Viewer( XServiceDefault2dDevice, aName, aDomain );
219 Creates viewer 2D [ static ]
221 /*Handle(V2d_Viewer) OCCViewer_VService::Viewer2d( const Standard_CString aDisplay,
222 const Handle(Graphic2d_View)& aView,
223 const Standard_ExtString aName,
224 const Standard_CString aDomain )
227 if ( XServiceDefault2dDevice.IsNull() )
228 XServiceDefault2dDevice = new WNT_GraphicDevice();
230 if ( XServiceDefault2dDevice.IsNull() )
231 XServiceDefault2dDevice = new Xw_GraphicDevice( aDisplay, Xw_TOM_READONLY );
233 return new V2d_Viewer( XServiceDefault2dDevice, aView, aName, aDomain );
237 Creates window driver [ static ]
239 Handle(Aspect_WindowDriver) OCCViewer_VService::WindowDriver( const Standard_CString aDisplay,
240 const Standard_Integer ahiwin,
241 const Standard_Integer alowin,
242 const Quantity_NameOfColor aColor )
245 if ( XServiceDefault2dDevice.IsNull() )
246 XServiceDefault2dDevice = new WNT_GraphicDevice();
247 Handle(WNT_Window) W = new WNT_Window( XServiceDefault2dDevice, ahiwin, alowin, aColor );
248 return new WNT_WDriver( W );
250 if ( XServiceDefault2dDevice.IsNull() )
251 XServiceDefault2dDevice = new Xw_GraphicDevice( aDisplay, Xw_TOM_READONLY );
252 Handle(Xw_Window) W = new Xw_Window( XServiceDefault2dDevice, ahiwin, alowin, Xw_WQ_DRAWINGQUALITY , aColor );
253 return new Xw_Driver( W );
258 Creates Xdps window driver [ static ]
259 On Win32 the same as OCCViewer_VService::WindowDriver()
262 Handle(Aspect_WindowDriver) OCCViewer_VService::XdpsDriver( const Standard_CString aDisplay,
263 const Standard_Integer ahiwin,
264 const Standard_Integer alowin,
265 const Quantity_NameOfColor aColor )
268 if ( XServiceDefault2dDevice.IsNull() )
269 XServiceDefault2dDevice = new WNT_GraphicDevice();
270 Handle(WNT_Window) W = new WNT_Window( XServiceDefault2dDevice, ahiwin, alowin, aColor );
271 return new WNT_WDriver( W );
273 if ( XServiceDefault2dDevice.IsNull() )
274 XServiceDefault2dDevice = new Xw_GraphicDevice( aDisplay, Xw_TOM_READONLY );
275 Handle(Xw_Window) W = new Xw_Window( XServiceDefault2dDevice, ahiwin, alowin,
276 Xw_WQ_DRAWINGQUALITY, aColor );
277 return new Xdps_Driver( W );
282 Creates Xw window driver [ static ]
283 On Win32 the same as OCCViewer_VService::WindowDriver()
285 Handle(Aspect_WindowDriver) OCCViewer_VService::ImageDriver( const Standard_CString aDisplay,
286 const Standard_Integer ahiwin,
287 const Standard_Integer alowin,
288 const Quantity_NameOfColor aColor )
291 if ( XServiceImageDevice.IsNull() )
292 XServiceImageDevice = new WNT_GraphicDevice();
293 Handle(WNT_Window) W = new WNT_Window( XServiceImageDevice, ahiwin, alowin, aColor );
294 return new WNT_WDriver( W );
296 if ( XServiceImageDevice.IsNull() )
297 XServiceImageDevice = new Xw_GraphicDevice( aDisplay, Xw_TOM_READONLY );
298 Handle(Xw_Window) W = new Xw_Window( XServiceImageDevice, ahiwin, alowin,
299 Xw_WQ_PICTUREQUALITY, aColor );
300 return new Xw_Driver( W );