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/
19 /***********************************************************************
23 Classe OCCViewer_VService :
25 HISTORIQUE DES MODIFICATIONS :
26 --------------------------------
27 00-09-92 : GG ; Creation.
28 25-02-98 : FMN ; PERF.27: Optimisation de la création d'une vue à partir d'une vue existante
33 ************************************************************************/
35 /*----------------------------------------------------------------------*/
39 //just to load the OpenGl shared library
40 //#include <OpenGl_GraphicDriver.hxx>
42 #include "OCCViewer_VService.h"
43 #include <V3d_Viewer.hxx>
44 #include <V3d_View.hxx>
45 #include <Viewer_Viewer.hxx>
47 #include <V2d_Viewer.hxx>
48 #include <V2d_View.hxx>
49 #include <Viewer_Viewer.hxx>
52 #include <WNT_Window.hxx>
53 #include <Graphic3d_WNTGraphicDevice.hxx>
54 #include <WNT_GraphicDevice.hxx>
55 #include <WNT_GraphicDevice.hxx>
56 #include <WNT_WDriver.hxx>
58 #include <Xw_Window.hxx>
59 #include <Graphic3d_GraphicDevice.hxx>
60 #include <Xw_Driver.hxx>
61 #include <Xdps_Driver.hxx>
62 #include <Xw_TypeOfMapping.hxx>
69 static Handle(WNT_GraphicDevice) XServiceDefault2dDevice;
70 static Handle(WNT_GraphicDevice) XServiceImageDevice;
72 static Handle(WNT_GraphicDevice)& _XServiceDefault2dDevice() {
73 static Handle(WNT_GraphicDevice) XServiceDefault2dDevice;
74 return XServiceDefault2dDevice;
76 #define XServiceDefault2dDevice _XServiceDefault2dDevice()
78 static Handle(WNT_GraphicDevice)& _XServiceImageDevice() {
79 static Handle(WNT_GraphicDevice) XServiceImageDevice;
80 return XServiceImageDevice;
82 #define XServiceImageDevice _XServiceImageDevice()
86 static Handle(Xw_GraphicDevice) XServiceDefault2dDevice;
87 static Handle(Xw_GraphicDevice) XServiceImageDevice;
89 static Handle(Xw_GraphicDevice)& _XServiceDefault2dDevice() {
90 static Handle(Xw_GraphicDevice) XServiceDefault2dDevice;
91 return XServiceDefault2dDevice;
93 #define XServiceDefault2dDevice _XServiceImageDevice()
95 static Handle(Xw_GraphicDevice)& _XServiceImageDevice() {
96 static Handle(Xw_GraphicDevice) XServiceImageDevice;
97 return XServiceImageDevice;
99 #define XServiceImageDevice _XServiceImageDevice()
104 Maps CasCade view to the window [ static ]
106 void OCCViewer_VService::SetWindow( const Handle(V3d_View)& view,
107 const Standard_Integer hiwin,
108 const Standard_Integer lowin,
109 const Xw_WindowQuality quality )
112 Handle(WNT_Window) w =
113 new WNT_Window( Handle(Graphic3d_WNTGraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin );
115 Handle(Xw_Window) w =
116 new Xw_Window( Handle(Graphic3d_GraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin, quality );
118 view->SetWindow( w );
122 Magnifies 'view' based on previous view [ static ]
124 void OCCViewer_VService::SetMagnify( const Handle(V3d_View)& view,
125 const Standard_Integer hiwin,
126 const Standard_Integer lowin,
127 const Handle(V3d_View)& prevView,
128 const Standard_Integer x1,
129 const Standard_Integer y1,
130 const Standard_Integer x2,
131 const Standard_Integer y2,
132 const Xw_WindowQuality aQuality )
135 Handle(WNT_Window) w =
136 new WNT_Window( Handle(Graphic3d_WNTGraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin );
138 Handle(Xw_Window) w =
139 new Xw_Window( Handle(Graphic3d_GraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin, aQuality );
141 view->SetMagnify( w, prevView, x1, y1, x2, y2 );
145 Creates viewer 3d [ static ]
147 Handle(V3d_Viewer) OCCViewer_VService::Viewer3d( const Standard_CString aDisplay,
148 const Standard_ExtString aName,
149 const Standard_CString aDomain,
150 const Standard_Real ViewSize ,
151 const V3d_TypeOfOrientation ViewProj,
152 const Standard_Boolean ComputedMode,
153 const Standard_Boolean aDefaultComputedMode )
156 static Handle(Graphic3d_GraphicDevice) defaultdevice;
157 if ( defaultdevice.IsNull() )
158 defaultdevice = new Graphic3d_GraphicDevice( aDisplay );
159 return new V3d_Viewer( defaultdevice, aName, aDomain, ViewSize, ViewProj,
160 Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT,
161 ComputedMode, aDefaultComputedMode, V3d_TEX_NONE );
163 static Handle(Graphic3d_WNTGraphicDevice) defaultdevice;
164 if ( defaultdevice.IsNull() )
165 defaultdevice = new Graphic3d_WNTGraphicDevice();
166 return new V3d_Viewer( defaultdevice, aName, aDomain, ViewSize, ViewProj,
167 Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT,
168 ComputedMode, aDefaultComputedMode, V3d_TEX_NONE);
173 Creates view 2D and maps it to the window [ static ]
175 /*Handle(V2d_View) OCCViewer_VService::View2d( const Handle(V2d_Viewer)& aViewer,
176 const Standard_Integer hiwin,
177 const Standard_Integer lowin,
178 const Xw_WindowQuality aQuality,
179 const Standard_Boolean Update,
180 const Quantity_NameOfColor BackColor )
183 Handle(WNT_GraphicDevice) GD = Handle(WNT_GraphicDevice)::DownCast(aViewer->Device());
184 Handle(WNT_Window) W = new WNT_Window( GD, hiwin, lowin, BackColor );
185 Handle(WNT_WDriver) D = new WNT_WDriver( W );
187 Handle(Xw_GraphicDevice) GD = Handle(Xw_GraphicDevice)::DownCast(aViewer->Device());
188 Handle(Xw_Window) W = new Xw_Window( GD, hiwin, lowin, aQuality, BackColor );
189 Handle(Xw_Driver) D = new Xw_Driver( W );
191 Handle(V2d_View) V = new V2d_View( D, aViewer );
198 Creates view 2D and maps it to the window [ static ]
200 /*Handle(V2d_View) OCCViewer_VService::dpsView2d( const Handle(V2d_Viewer)& aViewer,
201 const Standard_Integer hiwin,
202 const Standard_Integer lowin,
203 const Xw_WindowQuality aQuality,
204 const Standard_Boolean Update,
205 const Quantity_NameOfColor BackColor )
208 Handle(WNT_GraphicDevice) GD = Handle(WNT_GraphicDevice)::DownCast(aViewer->Device());
209 Handle(WNT_Window) W = new WNT_Window( GD, hiwin, lowin, BackColor );
210 W->SetBackground( BackColor );
211 Handle(WNT_WDriver) D = new WNT_WDriver( W );
213 Handle(Xw_GraphicDevice) GD = Handle(Xw_GraphicDevice)::DownCast(aViewer->Device());
214 Handle(Xw_Window) W = new Xw_Window( GD, hiwin, lowin, aQuality, BackColor );
215 Handle(Xdps_Driver) D = new Xdps_Driver( W );
217 Handle(V2d_View) V = new V2d_View( D, aViewer );
224 Creates viewer 2D [ static ]
226 /*Handle(V2d_Viewer) OCCViewer_VService::Viewer2d( const Standard_CString aDisplay,
227 const Standard_ExtString aName,
228 const Standard_CString aDomain )
231 if ( XServiceDefault2dDevice.IsNull() )
232 XServiceDefault2dDevice = new WNT_GraphicDevice();
234 if ( XServiceDefault2dDevice.IsNull() )
235 XServiceDefault2dDevice = new Xw_GraphicDevice( aDisplay, Xw_TOM_READONLY );
237 return new V2d_Viewer( XServiceDefault2dDevice, aName, aDomain );
241 Creates viewer 2D [ static ]
243 /*Handle(V2d_Viewer) OCCViewer_VService::Viewer2d( const Standard_CString aDisplay,
244 const Handle(Graphic2d_View)& aView,
245 const Standard_ExtString aName,
246 const Standard_CString aDomain )
249 if ( XServiceDefault2dDevice.IsNull() )
250 XServiceDefault2dDevice = new WNT_GraphicDevice();
252 if ( XServiceDefault2dDevice.IsNull() )
253 XServiceDefault2dDevice = new Xw_GraphicDevice( aDisplay, Xw_TOM_READONLY );
255 return new V2d_Viewer( XServiceDefault2dDevice, aView, aName, aDomain );
259 Creates window driver [ static ]
261 Handle(Aspect_WindowDriver) OCCViewer_VService::WindowDriver( const Standard_CString aDisplay,
262 const Standard_Integer ahiwin,
263 const Standard_Integer alowin,
264 const Quantity_NameOfColor aColor )
267 if ( XServiceDefault2dDevice.IsNull() )
268 XServiceDefault2dDevice = new WNT_GraphicDevice();
269 Handle(WNT_Window) W = new WNT_Window( XServiceDefault2dDevice, ahiwin, alowin, aColor );
270 return new WNT_WDriver( W );
272 if ( XServiceDefault2dDevice.IsNull() )
273 XServiceDefault2dDevice = new Xw_GraphicDevice( aDisplay, Xw_TOM_READONLY );
274 Handle(Xw_Window) W = new Xw_Window( XServiceDefault2dDevice, ahiwin, alowin, Xw_WQ_DRAWINGQUALITY , aColor );
275 return new Xw_Driver( W );
280 Creates Xdps window driver [ static ]
281 On Win32 the same as OCCViewer_VService::WindowDriver()
283 Handle(Aspect_WindowDriver) OCCViewer_VService::XdpsDriver( const Standard_CString aDisplay,
284 const Standard_Integer ahiwin,
285 const Standard_Integer alowin,
286 const Quantity_NameOfColor aColor )
289 if ( XServiceDefault2dDevice.IsNull() )
290 XServiceDefault2dDevice = new WNT_GraphicDevice();
291 Handle(WNT_Window) W = new WNT_Window( XServiceDefault2dDevice, ahiwin, alowin, aColor );
292 return new WNT_WDriver( W );
294 if ( XServiceDefault2dDevice.IsNull() )
295 XServiceDefault2dDevice = new Xw_GraphicDevice( aDisplay, Xw_TOM_READONLY );
296 Handle(Xw_Window) W = new Xw_Window( XServiceDefault2dDevice, ahiwin, alowin,
297 Xw_WQ_DRAWINGQUALITY, aColor );
298 return new Xdps_Driver( W );
303 Creates Xw window driver [ static ]
304 On Win32 the same as OCCViewer_VService::WindowDriver()
306 Handle(Aspect_WindowDriver) OCCViewer_VService::ImageDriver( const Standard_CString aDisplay,
307 const Standard_Integer ahiwin,
308 const Standard_Integer alowin,
309 const Quantity_NameOfColor aColor )
312 if ( XServiceImageDevice.IsNull() )
313 XServiceImageDevice = new WNT_GraphicDevice();
314 Handle(WNT_Window) W = new WNT_Window( XServiceImageDevice, ahiwin, alowin, aColor );
315 return new WNT_WDriver( W );
317 if ( XServiceImageDevice.IsNull() )
318 XServiceImageDevice = new Xw_GraphicDevice( aDisplay, Xw_TOM_READONLY );
319 Handle(Xw_Window) W = new Xw_Window( XServiceImageDevice, ahiwin, alowin,
320 Xw_WQ_PICTUREQUALITY, aColor );
321 return new Xw_Driver( W );