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 // GEOM GEOMGUI : GUI for Geometry component
24 // File : GeometryGUI.h
25 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
30 #include "GEOM_GEOMGUI.hxx"
32 #include <Basics_OCCTVersion.hxx>
34 #include <SalomeApp_Module.h>
36 #include <GEOM_Client.hxx>
37 #include <SALOME_InteractiveObject.hxx>
38 #include <SALOMEDSClient.hxx>
48 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
49 #include <TColStd_HArray1OfByte.hxx>
51 #include <Graphic3d_HArray1OfBytes.hxx>
55 #include "SALOMEconfig.h"
56 #include CORBA_CLIENT_HEADER(SALOMEDS)
61 class GEOMGUI_OCCSelector;
62 class LightApp_VTKSelector;
63 class LightApp_Selection;
64 class SUIT_ViewManager;
65 class SalomeApp_Study;
67 //=================================================================================
68 // class : GeometryGUI
70 //=================================================================================
71 class GEOMGUI_EXPORT GeometryGUI : public SalomeApp_Module
82 virtual LightApp_Displayer* displayer();
83 virtual void initialize( CAM_Application* );
84 virtual QString engineIOR() const;
86 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
87 static Handle(TColStd_HArray1OfByte) getTexture (SalomeApp_Study*, int, int&, int&);
89 static Handle(Graphic3d_HArray1OfBytes) getTexture (SalomeApp_Study*, int, int&, int&);
92 static bool InitGeomGen();
94 static GEOM::GEOM_Gen_var GetGeomGen();
96 static CORBA::Object_var ClientSObjectToObject (_PTR(SObject) theSObject);
97 static SALOMEDS::Study_var ClientStudyToStudy (_PTR(Study) theStudy);
99 static void Modified( bool = true );
101 GEOM_Client& GetShapeReader() { static SHAPE_READER(myShapeReader);return myShapeReader; }
103 // Get active dialog box
104 QDialog* GetActiveDialogBox(){ return myActiveDialogBox; }
105 // Set active dialog box
106 void SetActiveDialogBox( QDialog* aDlg );
108 // Non modal dialog boxes management
109 void EmitSignalDeactivateDialog();
110 void EmitSignalCloseAllDialogs();
111 void EmitSignalDefaultStepValueChanged( double newVal );
114 void OnGUIEvent( int id, const QVariant& theParam = QVariant( QVariant::Invalid ) );
116 // The Working Plane management
117 void SetWorkingPlane( gp_Ax3 wp ) { myWorkingPlane = wp; }
118 gp_Ax3 GetWorkingPlane() { return myWorkingPlane; }
119 void ActiveWorkingPlane();
121 virtual bool renameObject( const QString&, const QString& );
122 virtual bool renameAllowed( const QString& ) const;
124 virtual void windows( QMap<int, int>& ) const;
125 virtual void viewManagers( QStringList& ) const;
127 virtual void contextMenuPopup( const QString&, QMenu*, QString& );
128 virtual void createPreferences();
129 virtual void preferencesChanged( const QString&, const QString& );
130 int getLocalSelectionMode() const;
131 void setLocalSelectionMode(const int mode);
133 virtual void storeVisualParameters (int savePoint);
134 virtual void restoreVisualParameters(int savePoint);
136 QAction* getAction(const int id);
139 virtual bool deactivateModule( SUIT_Study* );
140 virtual bool activateModule( SUIT_Study* );
141 virtual void OnKeyPress ( SUIT_ViewWindow*, QKeyEvent* );
142 virtual void OnMousePress( SUIT_ViewWindow*, QMouseEvent* );
143 virtual void OnMouseMove ( SUIT_ViewWindow*, QMouseEvent* );
144 virtual void OnMouseRelease ( SUIT_ViewWindow*, QMouseEvent* );
147 virtual void onViewManagerAdded( SUIT_ViewManager* );
148 virtual void onViewManagerRemoved( SUIT_ViewManager* );
152 void onWindowActivated( SUIT_ViewWindow* );
153 void onViewAboutToShow();
154 void OnSetMaterial( const QString& );
155 void updateMaterials();
158 void SignalDeactivateActiveDialog();
159 void SignalCloseAllDialogs();
160 void SignalDefaultStepValueChanged( double newVal );
163 virtual LightApp_Selection* createSelection() const;
166 GEOMGUI* getLibrary( const QString& libraryName );
167 void createGeomAction( const int id, const QString& po_id,
168 const QString& icon_id = QString(""),
169 const int key = 0, const bool toggle = false,
170 const QString& shortcutAction = QString() );
171 void createPopupItem( const int, const QString& clients, const QString& types,
172 const bool isSingle = false, const int isVisible = -1,
173 const bool isExpandAll = false, const bool isOCC = false,
174 const int parentId = -1 );
176 void createOriginAndBaseVectors();
179 static GEOM::GEOM_Gen_var myComponentGeom; // GEOM engine!!!
183 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
184 typedef QMap<long, Handle(TColStd_HArray1OfByte)> TextureMap;
186 typedef QMap<long, Handle(Graphic3d_HArray1OfBytes)> TextureMap;
189 typedef QMap<long, TextureMap> StudyTextureMap;
190 typedef QMap<QString, GEOMGUI*> GUIMap;
192 GUIMap myGUIMap; // GUI libraries map
193 QDialog* myActiveDialogBox; // active dialog box
194 gp_Ax3 myWorkingPlane;
195 QMap<int,QString> myRules; // popup rules
196 static StudyTextureMap myTextureMap; // texture map
198 QList<GEOMGUI_OCCSelector*> myOCCSelectors;
199 QList<LightApp_VTKSelector*> myVTKSelectors;
201 LightApp_Displayer* myDisplayer;
202 int myLocalSelectionMode; //Select Only
204 friend class DisplayGUI;