Salome HOME
Porting to DEV version of OpenCASCADE: AIS_InteractiveContext : default value for...
[modules/gui.git] / src / OCCViewer / OCCViewer_VService.cxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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, or (at your option) any later version.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "OCCViewer_VService.h"
24
25 #include <V3d_Viewer.hxx>
26 #include <V3d_View.hxx>
27
28 #include <Basics_OCCTVersion.hxx>
29 #if OCC_VERSION_LARGE > 0x06070200 // for OCC-6.7.3 and higher version
30 #include <OpenGl_GraphicDriver.hxx>
31 #else
32 #include <Graphic3d.hxx>
33 #include <Graphic3d_GraphicDriver.hxx>
34 #endif
35 #include <Aspect_DisplayConnection.hxx>
36
37 #if defined(WIN32)
38 #include <WNT_Window.hxx>
39 #elif defined(__APPLE__)
40 #include <Cocoa_Window.hxx>
41 #else
42 #include <Xw_Window.hxx>
43 #endif
44
45 /*!
46     Create native view window for CasCade view [ static ]
47 */
48 Handle(Aspect_Window) OCCViewer_VService::CreateWindow( const Handle(V3d_View)& view,
49                                                         WId winId )
50 {
51   Aspect_Handle aWindowHandle = (Aspect_Handle)winId;
52 #if defined(WIN32)
53   Handle(WNT_Window) viewWindow = new WNT_Window( aWindowHandle );
54 #elif defined(__APPLE__)
55   Handle(Cocoa_Window) viewWindow = new Cocoa_Window( (NSView*)winId );
56 #else
57   Handle(Aspect_DisplayConnection) aDispConnection = view->Viewer()->Driver()->GetDisplayConnection();
58   Handle(Xw_Window) viewWindow = new Xw_Window( aDispConnection, aWindowHandle );
59 #endif
60   return viewWindow;
61 }
62
63 /*!
64     Creates viewer 3d [ static ]
65 */
66 Handle(V3d_Viewer) OCCViewer_VService::CreateViewer( const Standard_ExtString name,
67                                                      const Standard_CString displayName,
68                                                      const Standard_CString domain,
69                                                      const Standard_Real viewSize ,
70                                                      const V3d_TypeOfOrientation viewProjection,
71                                                      const Standard_Boolean computedMode,
72                                                      const Standard_Boolean defaultComputedMode )
73 {
74 #if OCC_VERSION_LARGE > 0x06070200 // for OCC-6.7.3 and higher version
75   static Handle(OpenGl_GraphicDriver) aGraphicDriver;
76 #else
77   static Handle(Graphic3d_GraphicDriver) aGraphicDriver;
78 #endif
79   if (aGraphicDriver.IsNull())
80   {
81     Handle(Aspect_DisplayConnection) aDisplayConnection;
82 #if !defined WIN32 && !defined __APPLE__
83     aDisplayConnection = new Aspect_DisplayConnection( displayName );
84 #else
85     aDisplayConnection = new Aspect_DisplayConnection();
86 #endif
87 #if OCC_VERSION_LARGE > 0x06070200 // for OCC-6.7.3 and higher version
88     aGraphicDriver = new OpenGl_GraphicDriver(aDisplayConnection);
89 #else
90     aGraphicDriver = Graphic3d::InitGraphicDriver( aDisplayConnection );
91 #endif
92   }
93
94 #if OCC_VERSION_LARGE > 0x07010000
95   return new V3d_Viewer( aGraphicDriver, name, domain, viewSize, viewProjection,
96                          Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD,
97                          computedMode, defaultComputedMode );
98   
99 #elif OCC_VERSION_LARGE > 0x07000000
100   return new V3d_Viewer( aGraphicDriver, name, domain, viewSize, viewProjection,
101                          Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT,
102                          computedMode, defaultComputedMode );  
103 #else
104   return new V3d_Viewer( aGraphicDriver, name, domain, viewSize, viewProjection,
105                          Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT,
106                          computedMode, defaultComputedMode, V3d_TEX_NONE );
107 #endif
108 }