Back to index

salome-gui  6.5.0
OCCViewer_VService.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include "OCCViewer_VService.h"
00024 #include <V3d_Viewer.hxx>
00025 #include <V3d_View.hxx>
00026 #include <Viewer_Viewer.hxx>
00027 
00028 #include <V2d_Viewer.hxx>
00029 #include <V2d_View.hxx>
00030 #include <Viewer_Viewer.hxx>
00031 
00032 #ifdef WNT
00033 #include <WNT_Window.hxx>
00034 #include <Graphic3d_WNTGraphicDevice.hxx>
00035 #include <WNT_GraphicDevice.hxx>
00036 #include <WNT_WDriver.hxx>
00037 #include <InterfaceGraphic_WNT.hxx>
00038 #else
00039 #include <Xw_Window.hxx>
00040 #include <Graphic3d_GraphicDevice.hxx>
00041 #include <Xw_Driver.hxx>
00042 //#include <Xdps_Driver.hxx>
00043 #include <Xw_TypeOfMapping.hxx>
00044 #endif
00045 
00046 // For 2d
00047 #define LOPTIM
00048 #ifdef WNT
00049 #ifndef LOPTIM
00050 static Handle(WNT_GraphicDevice) XServiceDefault2dDevice;
00051 static Handle(WNT_GraphicDevice) XServiceImageDevice;
00052 #else
00053 static Handle(WNT_GraphicDevice)& _XServiceDefault2dDevice() {
00054 static Handle(WNT_GraphicDevice) XServiceDefault2dDevice;
00055 return XServiceDefault2dDevice;
00056 }
00057 #define XServiceDefault2dDevice _XServiceDefault2dDevice()
00058 
00059 static Handle(WNT_GraphicDevice)& _XServiceImageDevice() {
00060 static Handle(WNT_GraphicDevice) XServiceImageDevice;
00061 return XServiceImageDevice;
00062 }
00063 #define XServiceImageDevice _XServiceImageDevice()
00064 #endif // LOPTIM
00065 #else
00066 #ifndef LOPTIM
00067 static Handle(Xw_GraphicDevice) XServiceDefault2dDevice;
00068 static Handle(Xw_GraphicDevice) XServiceImageDevice;
00069 #else
00070 static Handle(Xw_GraphicDevice)& _XServiceDefault2dDevice() {
00071 static Handle(Xw_GraphicDevice) XServiceDefault2dDevice;
00072 return XServiceDefault2dDevice;
00073 }
00074 #define XServiceDefault2dDevice _XServiceImageDevice()
00075 
00076 static Handle(Xw_GraphicDevice)& _XServiceImageDevice() {
00077 static Handle(Xw_GraphicDevice) XServiceImageDevice;
00078 return XServiceImageDevice;
00079 }
00080 #define XServiceImageDevice _XServiceImageDevice()
00081 #endif // LOPTIM
00082 #endif // WNT
00083 
00087 Handle(Aspect_Window) OCCViewer_VService::CreateWindow( const Handle(V3d_View)& view,
00088                                                         const Standard_Integer hiwin,
00089                                                         const Standard_Integer lowin,
00090                                                         const Xw_WindowQuality quality )
00091 {
00092 #ifdef WNT
00093   Handle(WNT_Window) viewWindow = new WNT_Window( Handle(Graphic3d_WNTGraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin );
00094   // Prevent flickering
00095   viewWindow->SetFlags( WDF_NOERASEBKGRND );
00096 #else
00097   Handle(Xw_Window) viewWindow = new Xw_Window( Handle(Graphic3d_GraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin, quality );
00098 #endif
00099   return viewWindow;
00100 }
00101 
00105 void OCCViewer_VService::SetWindow( const Handle(V3d_View)& view,
00106                                     const Standard_Integer hiwin,
00107                                     const Standard_Integer lowin,
00108                                     const Xw_WindowQuality quality )
00109 {
00110   view->SetWindow( OCCViewer_VService::CreateWindow( view, hiwin, lowin, quality ) );
00111 }
00112 
00116 void OCCViewer_VService::SetMagnify( const Handle(V3d_View)& view,
00117                                    const Standard_Integer hiwin,
00118                                    const Standard_Integer lowin,
00119                                    const Handle(V3d_View)& prevView,
00120                                    const Standard_Integer x1,
00121                                    const Standard_Integer y1,
00122                                    const Standard_Integer x2,
00123                                    const Standard_Integer y2,
00124                                const Xw_WindowQuality aQuality )
00125 {
00126 #ifdef WNT
00127   Handle(WNT_Window) w =
00128       new WNT_Window( Handle(Graphic3d_WNTGraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin );
00129 #else
00130   Handle(Xw_Window) w =
00131       new Xw_Window( Handle(Graphic3d_GraphicDevice)::DownCast(view->Viewer()->Device()), hiwin, lowin, aQuality );
00132 #endif
00133   view->SetMagnify( w, prevView, x1, y1, x2, y2 );
00134 }
00135 
00139 Handle(V3d_Viewer) OCCViewer_VService::Viewer3d( const Standard_CString aDisplay,
00140                                            const Standard_ExtString aName,
00141                                            const Standard_CString aDomain,
00142                                            const Standard_Real ViewSize ,
00143                                            const V3d_TypeOfOrientation ViewProj,
00144                                            const Standard_Boolean ComputedMode,
00145                                            const Standard_Boolean aDefaultComputedMode )
00146 {
00147 #ifndef WNT
00148     static Handle(Graphic3d_GraphicDevice) defaultdevice;
00149     if ( defaultdevice.IsNull() )
00150         defaultdevice = new Graphic3d_GraphicDevice( aDisplay );
00151     return new V3d_Viewer( defaultdevice, aName, aDomain, ViewSize, ViewProj,
00152                            Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT,
00153                            ComputedMode, aDefaultComputedMode, V3d_TEX_NONE );
00154 #else
00155     static Handle(Graphic3d_WNTGraphicDevice) defaultdevice;
00156     if ( defaultdevice.IsNull() )
00157         defaultdevice = new Graphic3d_WNTGraphicDevice();
00158     return new V3d_Viewer( defaultdevice, aName, aDomain, ViewSize, ViewProj,
00159                            Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT,
00160                            ComputedMode, aDefaultComputedMode, V3d_TEX_NONE);
00161 #endif  // WNT
00162 }
00163 
00167 /*Handle(V2d_View) OCCViewer_VService::View2d( const Handle(V2d_Viewer)& aViewer,
00168                                                            const Standard_Integer hiwin,
00169                                                            const Standard_Integer lowin,
00170                                                            const Xw_WindowQuality aQuality,
00171                                                            const Standard_Boolean Update,
00172                                                            const Quantity_NameOfColor BackColor )
00173 {
00174 #ifdef WNT
00175     Handle(WNT_GraphicDevice) GD = Handle(WNT_GraphicDevice)::DownCast(aViewer->Device());
00176     Handle(WNT_Window) W = new WNT_Window( GD, hiwin, lowin, BackColor );
00177     Handle(WNT_WDriver) D = new WNT_WDriver( W );
00178 #else
00179     Handle(Xw_GraphicDevice) GD = Handle(Xw_GraphicDevice)::DownCast(aViewer->Device());
00180     Handle(Xw_Window) W = new Xw_Window( GD, hiwin, lowin, aQuality, BackColor );
00181     Handle(Xw_Driver) D = new Xw_Driver( W );
00182 #endif
00183     Handle(V2d_View)  V = new V2d_View( D, aViewer );
00184     if ( Update )
00185         V->Update();
00186     return V;
00187 }*/
00188 
00192 /*Handle(V2d_View) OCCViewer_VService::dpsView2d( const Handle(V2d_Viewer)& aViewer,
00193                                                               const Standard_Integer hiwin,
00194                                                               const Standard_Integer lowin,
00195                                                               const Xw_WindowQuality aQuality,
00196                                                               const Standard_Boolean Update,
00197                                                               const Quantity_NameOfColor BackColor )
00198 {
00199 #ifdef WNT
00200     Handle(WNT_GraphicDevice) GD = Handle(WNT_GraphicDevice)::DownCast(aViewer->Device());
00201     Handle(WNT_Window) W = new WNT_Window( GD, hiwin, lowin, BackColor );
00202     W->SetBackground( BackColor );
00203     Handle(WNT_WDriver) D = new WNT_WDriver( W );
00204 #else
00205     Handle(Xw_GraphicDevice) GD = Handle(Xw_GraphicDevice)::DownCast(aViewer->Device());
00206     Handle(Xw_Window) W = new Xw_Window( GD,  hiwin, lowin, aQuality, BackColor );
00207     Handle(Xdps_Driver) D = new Xdps_Driver( W );
00208 #endif
00209     Handle(V2d_View)  V = new V2d_View( D, aViewer );
00210     if ( Update )
00211         V->Update();
00212     return V;
00213 }*/
00214 
00218 /*Handle(V2d_Viewer) OCCViewer_VService::Viewer2d( const Standard_CString aDisplay,
00219                                                            const Standard_ExtString aName,
00220                                                            const Standard_CString aDomain )
00221 {
00222 #ifdef WNT
00223     if ( XServiceDefault2dDevice.IsNull() )
00224         XServiceDefault2dDevice = new WNT_GraphicDevice();
00225 #else
00226     if ( XServiceDefault2dDevice.IsNull() )
00227         XServiceDefault2dDevice = new Xw_GraphicDevice( aDisplay, Xw_TOM_READONLY );
00228 #endif
00229     return new V2d_Viewer( XServiceDefault2dDevice, aName, aDomain );
00230 }*/
00231 
00235 /*Handle(V2d_Viewer) OCCViewer_VService::Viewer2d( const Standard_CString aDisplay,
00236                                                            const Handle(Graphic2d_View)& aView,
00237                                                            const Standard_ExtString aName,
00238                                                            const Standard_CString aDomain )
00239 {
00240 #ifdef WNT
00241     if ( XServiceDefault2dDevice.IsNull() )
00242         XServiceDefault2dDevice = new WNT_GraphicDevice();
00243 #else
00244     if ( XServiceDefault2dDevice.IsNull() )
00245         XServiceDefault2dDevice = new Xw_GraphicDevice( aDisplay, Xw_TOM_READONLY );
00246 #endif
00247     return new V2d_Viewer( XServiceDefault2dDevice, aView, aName, aDomain );
00248 }*/
00249 
00253 Handle(Aspect_WindowDriver) OCCViewer_VService::WindowDriver( const Standard_CString aDisplay,
00254                                                         const Standard_Integer ahiwin,
00255                                                         const Standard_Integer alowin,
00256                                                         const Quantity_NameOfColor aColor )
00257 {
00258 #ifdef WNT
00259     if ( XServiceDefault2dDevice.IsNull() )
00260         XServiceDefault2dDevice = new WNT_GraphicDevice();
00261     Handle(WNT_Window) W = new WNT_Window( XServiceDefault2dDevice, ahiwin, alowin, aColor );
00262     return new WNT_WDriver( W );
00263 #else
00264     if ( XServiceDefault2dDevice.IsNull() )
00265         XServiceDefault2dDevice = new Xw_GraphicDevice( aDisplay, Xw_TOM_READONLY );
00266     Handle(Xw_Window) W = new Xw_Window( XServiceDefault2dDevice, ahiwin, alowin, Xw_WQ_DRAWINGQUALITY , aColor );
00267     return new Xw_Driver( W );
00268 #endif
00269 }
00270 
00275 /*
00276 Handle(Aspect_WindowDriver) OCCViewer_VService::XdpsDriver( const Standard_CString aDisplay,
00277                                                       const Standard_Integer ahiwin,
00278                                                       const Standard_Integer alowin,
00279                                                       const Quantity_NameOfColor aColor )
00280 {
00281 #ifdef WNT
00282     if ( XServiceDefault2dDevice.IsNull() )
00283         XServiceDefault2dDevice = new WNT_GraphicDevice();
00284     Handle(WNT_Window) W = new WNT_Window( XServiceDefault2dDevice, ahiwin, alowin, aColor );
00285     return new WNT_WDriver( W );
00286 #else
00287     if ( XServiceDefault2dDevice.IsNull() )
00288         XServiceDefault2dDevice = new Xw_GraphicDevice( aDisplay, Xw_TOM_READONLY );
00289     Handle(Xw_Window) W = new Xw_Window( XServiceDefault2dDevice, ahiwin, alowin,
00290                                          Xw_WQ_DRAWINGQUALITY, aColor );
00291     return new Xdps_Driver( W );
00292 #endif
00293 }
00294 */
00299 Handle(Aspect_WindowDriver) OCCViewer_VService::ImageDriver( const Standard_CString aDisplay,
00300                                                        const Standard_Integer ahiwin,
00301                                                        const Standard_Integer alowin,
00302                                                        const Quantity_NameOfColor aColor )
00303 {
00304 #ifdef WNT
00305     if ( XServiceImageDevice.IsNull() )
00306         XServiceImageDevice = new WNT_GraphicDevice();
00307     Handle(WNT_Window) W = new WNT_Window( XServiceImageDevice, ahiwin, alowin, aColor );
00308     return new WNT_WDriver( W );
00309 #else
00310     if ( XServiceImageDevice.IsNull() )
00311         XServiceImageDevice = new Xw_GraphicDevice( aDisplay, Xw_TOM_READONLY );
00312     Handle(Xw_Window) W = new Xw_Window( XServiceImageDevice, ahiwin, alowin,
00313                                          Xw_WQ_PICTUREQUALITY, aColor );
00314     return new Xw_Driver( W );
00315 #endif
00316 }