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 <Basics_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)
60 class GEOMGUI_OCCSelector;
61 class LightApp_VTKSelector;
62 class LightApp_Selection;
63 class SUIT_ViewManager;
64 class SalomeApp_Study;
66 //=================================================================================
67 // class : GeometryGUI
69 //=================================================================================
70 class GEOMGUI_EXPORT GeometryGUI : public SalomeApp_Module
81 virtual LightApp_Displayer* displayer();
82 virtual void initialize( CAM_Application* );
83 virtual QString engineIOR() const;
85 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
86 static Handle(TColStd_HArray1OfByte) getTexture (SalomeApp_Study*, int, int&, int&);
88 static Handle(Graphic3d_HArray1OfBytes) getTexture (SalomeApp_Study*, int, int&, int&);
91 static bool InitGeomGen();
93 static GEOM::GEOM_Gen_var GetGeomGen();
95 static CORBA::Object_var ClientSObjectToObject (_PTR(SObject) theSObject);
96 static SALOMEDS::Study_var ClientStudyToStudy (_PTR(Study) theStudy);
98 static void Modified( bool = true );
100 GEOM_Client& GetShapeReader() { static SHAPE_READER(myShapeReader);return myShapeReader; }
102 // Get active dialog box
103 QDialog* GetActiveDialogBox(){ return myActiveDialogBox; }
104 // Set active dialog box
105 void SetActiveDialogBox( QDialog* aDlg );
107 // Non modal dialog boxes management
108 void EmitSignalDeactivateDialog();
109 void EmitSignalCloseAllDialogs();
110 void EmitSignalDefaultStepValueChanged( double newVal );
113 void OnGUIEvent( int id );
115 // The Working Plane management
116 void SetWorkingPlane( gp_Ax3 wp ) { myWorkingPlane = wp; }
117 gp_Ax3 GetWorkingPlane() { return myWorkingPlane; }
118 void ActiveWorkingPlane();
120 virtual bool renameObject( const QString&, const QString& );
121 virtual bool renameAllowed( const QString& ) const;
123 virtual void windows( QMap<int, int>& ) const;
124 virtual void viewManagers( QStringList& ) const;
126 virtual void contextMenuPopup( const QString&, QMenu*, QString& );
127 virtual void createPreferences();
128 virtual void preferencesChanged( const QString&, const QString& );
129 int getLocalSelectionMode() const;
130 void setLocalSelectionMode(const int mode);
132 virtual void storeVisualParameters (int savePoint);
133 virtual void restoreVisualParameters(int savePoint);
135 QAction* getAction(const int id);
138 virtual bool deactivateModule( SUIT_Study* );
139 virtual bool activateModule( SUIT_Study* );
140 virtual void OnKeyPress ( SUIT_ViewWindow*, QKeyEvent* );
141 virtual void OnMousePress( SUIT_ViewWindow*, QMouseEvent* );
142 virtual void OnMouseMove ( SUIT_ViewWindow*, QMouseEvent* );
143 virtual void OnMouseRelease ( SUIT_ViewWindow*, QMouseEvent* );
146 virtual void onViewManagerAdded( SUIT_ViewManager* );
147 virtual void onViewManagerRemoved( SUIT_ViewManager* );
151 void onWindowActivated( SUIT_ViewWindow* );
152 void onViewAboutToShow();
155 void SignalDeactivateActiveDialog();
156 void SignalCloseAllDialogs();
157 void SignalDefaultStepValueChanged( double newVal );
160 virtual LightApp_Selection* createSelection() const;
163 GEOMGUI* getLibrary( const QString& libraryName );
164 void createGeomAction( const int id, const QString& po_id,
165 const QString& icon_id = QString(""),
166 const int key = 0, const bool toggle = false,
167 const QString& shortcutAction = QString() );
168 void createPopupItem( const int, const QString& clients, const QString& types,
169 const bool isSingle = false, const int isVisible = -1,
170 const bool isExpandAll = false, const bool isOCC = false,
171 const int parentId = -1 );
173 void createOriginAndBaseVectors();
176 static GEOM::GEOM_Gen_var myComponentGeom; // GEOM engine!!!
180 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
181 typedef QMap<long, Handle(TColStd_HArray1OfByte)> TextureMap;
183 typedef QMap<long, Handle(Graphic3d_HArray1OfBytes)> TextureMap;
186 typedef QMap<long, TextureMap> StudyTextureMap;
187 typedef QMap<QString, GEOMGUI*> GUIMap;
189 GUIMap myGUIMap; // GUI libraries map
190 QDialog* myActiveDialogBox; // active dialog box
191 gp_Ax3 myWorkingPlane;
192 QMap<int,QString> myRules; // popup rules
193 static StudyTextureMap myTextureMap; // texture map
195 QList<GEOMGUI_OCCSelector*> myOCCSelectors;
196 QList<LightApp_VTKSelector*> myVTKSelectors;
198 LightApp_Displayer* myDisplayer;
199 int myLocalSelectionMode; //Select Only
201 friend class DisplayGUI;