1 // Copyright (C) 2007-2012 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>
29 #include <WNT_Window.hxx>
30 #include <Graphic3d_WNTGraphicDevice.hxx>
32 #include <Xw_Window.hxx>
33 #include <Graphic3d_GraphicDevice.hxx>
37 Create native view window for CasCade view [ static ]
39 Handle(Aspect_Window) OCCViewer_VService::CreateWindow( const Handle(V3d_View)& view,
40 const Standard_Integer hiwin,
41 const Standard_Integer lowin,
42 const Xw_WindowQuality quality )
45 Handle(WNT_Window) viewWindow = new WNT_Window( Handle(Graphic3d_WNTGraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin );
47 viewWindow->SetFlags( WDF_NOERASEBKGRND );
49 Handle(Xw_Window) viewWindow = new Xw_Window( Handle(Graphic3d_GraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin, quality );
55 Maps CasCade view to the window [ static ]
57 void OCCViewer_VService::SetWindow( const Handle(V3d_View)& view,
58 const Standard_Integer hiwin,
59 const Standard_Integer lowin,
60 const Xw_WindowQuality quality )
62 view->SetWindow( OCCViewer_VService::CreateWindow( view, hiwin, lowin, quality ) );
66 Magnifies 'view' based on previous view [ static ]
68 void OCCViewer_VService::SetMagnify( const Handle(V3d_View)& view,
69 const Standard_Integer hiwin,
70 const Standard_Integer lowin,
71 const Handle(V3d_View)& prevView,
72 const Standard_Integer x1,
73 const Standard_Integer y1,
74 const Standard_Integer x2,
75 const Standard_Integer y2,
76 const Xw_WindowQuality aQuality )
79 Handle(WNT_Window) w =
80 new WNT_Window( Handle(Graphic3d_WNTGraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin );
83 new Xw_Window( Handle(Graphic3d_GraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin, aQuality );
85 view->SetMagnify( w, prevView, x1, y1, x2, y2 );
89 Creates viewer 3d [ static ]
91 Handle(V3d_Viewer) OCCViewer_VService::Viewer3d( const Standard_CString aDisplay,
92 const Standard_ExtString aName,
93 const Standard_CString aDomain,
94 const Standard_Real ViewSize ,
95 const V3d_TypeOfOrientation ViewProj,
96 const Standard_Boolean ComputedMode,
97 const Standard_Boolean aDefaultComputedMode )
100 static Handle(Graphic3d_GraphicDevice) defaultdevice;
101 if ( defaultdevice.IsNull() )
102 defaultdevice = new Graphic3d_GraphicDevice( aDisplay );
103 return new V3d_Viewer( defaultdevice, aName, aDomain, ViewSize, ViewProj,
104 Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT,
105 ComputedMode, aDefaultComputedMode, V3d_TEX_NONE );
107 static Handle(Graphic3d_WNTGraphicDevice) defaultdevice;
108 if ( defaultdevice.IsNull() )
109 defaultdevice = new Graphic3d_WNTGraphicDevice();
110 return new V3d_Viewer( defaultdevice, aName, aDomain, ViewSize, ViewProj,
111 Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT,
112 ComputedMode, aDefaultComputedMode, V3d_TEX_NONE);