1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "OCCViewer_VService.h"
25 #include <V3d_Viewer.hxx>
26 #include <V3d_View.hxx>
28 #include <Basics_OCCTVersion.hxx>
30 #if OCC_VERSION_LARGE > 0x06050500
33 // new code, changed in OCCT v6.6.0
36 #include <Aspect_DisplayConnection.hxx>
37 #include <Graphic3d.hxx>
38 #include <Graphic3d_GraphicDriver.hxx>
40 #include <WNT_Window.hxx>
42 #include <Xw_Window.hxx>
45 #else // #if OCC_VERSION_LARGE > 0x06050500
48 // obsolete code (before OCCT v6.6.0); to be removed
52 #include <WNT_Window.hxx>
53 #include <Graphic3d_WNTGraphicDevice.hxx>
55 #include <Xw_Window.hxx>
56 #include <Graphic3d_GraphicDevice.hxx>
59 #endif // #if OCC_VERSION_LARGE > 0x06050500
62 Create native view window for CasCade view [ static ]
64 Handle(Aspect_Window) OCCViewer_VService::CreateWindow( const Handle(V3d_View)& view,
67 #if OCC_VERSION_LARGE > 0x06050500
70 // new code, changed in OCCT v6.6.0
72 Aspect_Handle aWindowHandle = (Aspect_Handle)winId;
74 Handle(WNT_Window) viewWindow = new WNT_Window( aWindowHandle );
76 Handle(Aspect_DisplayConnection) aDispConnection = view->Viewer()->Driver()->GetDisplayConnection();
77 Handle(Xw_Window) viewWindow = new Xw_Window( aDispConnection, aWindowHandle );
81 #else // #if OCC_VERSION_LARGE > 0x06050500
84 // obsolete code (before OCCT v6.6.0); to be removed
86 int hwnd = (int)winId;
87 short lowin = (short)hwnd;
88 short hiwin = (short)( hwnd >> 16 );
91 Handle(WNT_Window) viewWindow = new WNT_Window( Handle(Graphic3d_WNTGraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin );
93 viewWindow->SetFlags( WDF_NOERASEBKGRND );
95 Handle(Xw_Window) viewWindow = new Xw_Window( Handle(Graphic3d_GraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin, Xw_WQ_SAMEQUALITY );
99 #endif // #if OCC_VERSION_LARGE > 0x06050500
103 Maps CasCade view to the window [ static ]
105 // void OCCViewer_VService::SetWindow( const Handle(V3d_View)& view,
106 // const Standard_Integer hiwin,
107 // const Standard_Integer lowin,
108 // const Xw_WindowQuality quality )
110 // view->SetWindow( OCCViewer_VService::CreateWindow( view, hiwin, lowin, quality ) );
114 Magnifies 'view' based on previous view [ static ]
116 // void OCCViewer_VService::SetMagnify( const Handle(V3d_View)& view,
117 // const Standard_Integer hiwin,
118 // const Standard_Integer lowin,
119 // const Handle(V3d_View)& prevView,
120 // const Standard_Integer x1,
121 // const Standard_Integer y1,
122 // const Standard_Integer x2,
123 // const Standard_Integer y2,
124 // const Xw_WindowQuality aQuality )
127 // Handle(WNT_Window) w =
128 // new WNT_Window( Handle(Graphic3d_WNTGraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin );
130 // Handle(Xw_Window) w =
131 // new Xw_Window( Handle(Graphic3d_GraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin, aQuality );
133 // view->SetMagnify( w, prevView, x1, y1, x2, y2 );
137 Creates viewer 3d [ static ]
139 Handle(V3d_Viewer) OCCViewer_VService::Viewer3d( const Standard_CString aDisplay,
140 const Standard_ExtString aName,
141 const Standard_CString aDomain,
142 const Standard_Real ViewSize ,
143 const V3d_TypeOfOrientation ViewProj,
144 const Standard_Boolean ComputedMode,
145 const Standard_Boolean aDefaultComputedMode )
147 #if OCC_VERSION_LARGE > 0x06050500
150 // new code, changed in OCCT v6.6.0
153 static Handle(Graphic3d_GraphicDriver) aGraphicDriver;
154 if (aGraphicDriver.IsNull())
156 Handle(Aspect_DisplayConnection) aDisplayConnection;
158 aDisplayConnection = new Aspect_DisplayConnection( aDisplay );
160 aGraphicDriver = Graphic3d::InitGraphicDriver( aDisplayConnection );
163 return new V3d_Viewer( aGraphicDriver, aName, aDomain, ViewSize, ViewProj,
164 Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT,
165 ComputedMode, aDefaultComputedMode, V3d_TEX_NONE );
167 #else // #if OCC_VERSION_LARGE > 0x06050500
170 // obsolete code (before OCCT v6.6.0); to be removed
174 static Handle(Graphic3d_GraphicDevice) defaultdevice;
175 if ( defaultdevice.IsNull() )
176 defaultdevice = new Graphic3d_GraphicDevice( aDisplay );
177 return new V3d_Viewer( defaultdevice, aName, aDomain, ViewSize, ViewProj,
178 Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT,
179 ComputedMode, aDefaultComputedMode, V3d_TEX_NONE );
181 static Handle(Graphic3d_WNTGraphicDevice) defaultdevice;
182 if ( defaultdevice.IsNull() )
183 defaultdevice = new Graphic3d_WNTGraphicDevice();
184 return new V3d_Viewer( defaultdevice, aName, aDomain, ViewSize, ViewProj,
185 Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT,
186 ComputedMode, aDefaultComputedMode, V3d_TEX_NONE);
189 #endif // #if OCC_VERSION_LARGE > 0x06050500