1 // Copyright (C) 2007-2011 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
22 // GEOM GEOMGUI : GUI for Geometry component
23 // File : GeometryGUI.h
24 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
29 #include "GEOM_GEOMGUI.hxx"
31 #include <CASCatch_OCCTVersion.hxx>
33 #include <SalomeApp_Module.h>
35 #include <GEOM_Client.hxx>
36 #include <SALOME_InteractiveObject.hxx>
37 #include <SALOMEDSClient.hxx>
47 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
48 #include <TColStd_HArray1OfByte.hxx>
50 #include <Graphic3d_HArray1OfBytes.hxx>
54 #include "SALOMEconfig.h"
55 #include CORBA_CLIENT_HEADER(SALOMEDS)
57 // minimum allowed value for deflection coefficient
58 #define DEFLECTION_MIN 1e-06
61 #define NAME_SEPARATOR '_' // character used to separate parameter names
62 #define DIGIT_SEPARATOR ':' // character used to separate numeric parameter values (color = r:g:b)
64 #define VISIBILITY_PROP "Visibility" //Object visibility property
65 #define OPACITY_PROP "Opacity" //Object opacity property
66 #define TRANSPARENCY_PROP "Transparency" //Object transparency property
67 #define DISPLAY_MODE_PROP "DisplayMode" //Object display mode property
68 #define ISOS_PROP "Isos" //Number of the Isos property of the object
69 #define COLOR_PROP "Color" //Color of the object
70 #define VECTOR_MODE_PROP "VectorMode" //Vector mode property
71 #define DEFLECTION_COEFF_PROP "DeflectionCoeff" //Deflection coeff property
72 #define MARKER_TYPE_PROP "MarkerType" // Marker type property
77 class GEOMGUI_OCCSelector;
78 class LightApp_VTKSelector;
79 class LightApp_Selection;
80 class SUIT_ViewManager;
81 class SalomeApp_Study;
83 //=================================================================================
84 // class : GeometryGUI
86 //=================================================================================
87 class GEOMGUI_EXPORT GeometryGUI : public SalomeApp_Module
98 virtual LightApp_Displayer* displayer();
99 virtual void initialize( CAM_Application* );
100 virtual QString engineIOR() const;
102 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
103 static Handle(TColStd_HArray1OfByte) getTexture (SalomeApp_Study*, int, int&, int&);
105 static Handle(Graphic3d_HArray1OfBytes) getTexture (SalomeApp_Study*, int, int&, int&);
108 static bool InitGeomGen();
110 static GEOM::GEOM_Gen_var GetGeomGen();
112 static CORBA::Object_var ClientSObjectToObject (_PTR(SObject) theSObject);
113 static SALOMEDS::Study_var ClientStudyToStudy (_PTR(Study) theStudy);
115 static void Modified( bool = true );
117 GEOM_Client& GetShapeReader() { static SHAPE_READER(myShapeReader);return myShapeReader; }
119 // Get active dialog box
120 QDialog* GetActiveDialogBox(){ return myActiveDialogBox; }
121 // Set active dialog box
122 void SetActiveDialogBox( QDialog* aDlg );
124 // Non modal dialog boxes management
125 void EmitSignalDeactivateDialog();
126 void EmitSignalCloseAllDialogs();
127 void EmitSignalDefaultStepValueChanged( double newVal );
130 void OnGUIEvent( int id );
132 // The Working Plane management
133 void SetWorkingPlane( gp_Ax3 wp ) { myWorkingPlane = wp; }
134 gp_Ax3 GetWorkingPlane() { return myWorkingPlane; }
135 void ActiveWorkingPlane();
137 virtual bool renameObject( const QString&, const QString& );
139 virtual void windows( QMap<int, int>& ) const;
140 virtual void viewManagers( QStringList& ) const;
142 virtual void contextMenuPopup( const QString&, QMenu*, QString& );
143 virtual void createPreferences();
144 virtual void preferencesChanged( const QString&, const QString& );
145 int getLocalSelectionMode() const;
146 void setLocalSelectionMode(const int mode);
148 virtual void storeVisualParameters (int savePoint);
149 virtual void restoreVisualParameters(int savePoint);
152 virtual bool deactivateModule( SUIT_Study* );
153 virtual bool activateModule( SUIT_Study* );
154 virtual void OnKeyPress ( SUIT_ViewWindow*, QKeyEvent* );
155 virtual void OnMousePress( SUIT_ViewWindow*, QMouseEvent* );
156 virtual void OnMouseMove ( SUIT_ViewWindow*, QMouseEvent* );
159 virtual void onViewManagerAdded( SUIT_ViewManager* );
160 virtual void onViewManagerRemoved( SUIT_ViewManager* );
164 void onWindowActivated( SUIT_ViewWindow* );
165 void onViewAboutToShow();
168 void SignalDeactivateActiveDialog();
169 void SignalCloseAllDialogs();
170 void SignalDefaultStepValueChanged( double newVal );
173 virtual LightApp_Selection* createSelection() const;
176 GEOMGUI* getLibrary( const QString& libraryName );
177 void createGeomAction( const int id, const QString& po_id,
178 const QString& icon_id = QString(""),
179 const int key = 0, const bool toggle = false,
180 const QString& shortcutAction = QString() );
181 void createPopupItem( const int, const QString& clients, const QString& types,
182 const bool isSingle = false, const int isVisible = -1,
183 const bool isExpandAll = false, const bool isOCC = false,
184 const int parentId = -1 );
186 void createOriginAndBaseVectors();
189 static GEOM::GEOM_Gen_var myComponentGeom; // GEOM engine!!!
193 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
194 typedef QMap<long, Handle(TColStd_HArray1OfByte)> TextureMap;
196 typedef QMap<long, Handle(Graphic3d_HArray1OfBytes)> TextureMap;
199 typedef QMap<long, TextureMap> StudyTextureMap;
200 typedef QMap<QString, GEOMGUI*> GUIMap;
202 GUIMap myGUIMap; // GUI libraries map
203 QDialog* myActiveDialogBox; // active dialog box
204 gp_Ax3 myWorkingPlane;
205 QMap<int,QString> myRules; // popup rules
206 static StudyTextureMap myTextureMap; // texture map
208 QList<GEOMGUI_OCCSelector*> myOCCSelectors;
209 QList<LightApp_VTKSelector*> myVTKSelectors;
211 LightApp_Displayer* myDisplayer;
212 int myLocalSelectionMode; //Select Only
214 friend class DisplayGUI;