1 // Copyright (C) 2007-2013 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>
41 #include "GEOMPluginGUI.h"
50 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
51 #include <TColStd_HArray1OfByte.hxx>
53 #include <Graphic3d_HArray1OfBytes.hxx>
57 #include "SALOMEconfig.h"
58 #include CORBA_CLIENT_HEADER(SALOMEDS)
60 #include <SALOME_ListIO.hxx>
65 class GEOMGUI_OCCSelector;
66 class LightApp_VTKSelector;
67 class LightApp_Selection;
68 class SUIT_ViewManager;
69 class SalomeApp_Study;
70 class GEOMGUI_CreationInfoWdg;
72 //=================================================================================
73 // class : GeometryGUI
75 //=================================================================================
76 class GEOMGUI_EXPORT GeometryGUI : public SalomeApp_Module
87 virtual LightApp_Displayer* displayer();
88 virtual void initialize( CAM_Application* );
89 virtual QString engineIOR() const;
91 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
92 static Handle(TColStd_HArray1OfByte) getTexture (SalomeApp_Study*, int, int&, int&);
94 static Handle(Graphic3d_HArray1OfBytes) getTexture (SalomeApp_Study*, int, int&, int&);
97 static bool InitGeomGen();
99 static GEOM::GEOM_Gen_var GetGeomGen();
101 static CORBA::Object_var ClientSObjectToObject (_PTR(SObject) theSObject);
102 static SALOMEDS::Study_var ClientStudyToStudy (_PTR(Study) theStudy);
104 static void Modified( bool = true );
106 GEOM_Client& GetShapeReader() { static SHAPE_READER(myShapeReader);return myShapeReader; }
108 // Get active dialog box
109 QDialog* GetActiveDialogBox(){ return myActiveDialogBox; }
110 // Set active dialog box
111 void SetActiveDialogBox( QDialog* aDlg );
113 // Non modal dialog boxes management
114 void EmitSignalDeactivateDialog();
115 void EmitSignalCloseAllDialogs();
116 void EmitSignalDefaultStepValueChanged( double newVal );
119 void OnGUIEvent( int id, const QVariant& theParam = QVariant( QVariant::Invalid ) );
120 virtual bool activateOperation( int actionId );
121 virtual bool activateOperation( const QString& actionId );
122 virtual bool activateOperation( const QString& actionId, const QString& plugin );
124 // The Working Plane management
125 void SetWorkingPlane( gp_Ax3 wp ) { myWorkingPlane = wp; }
126 gp_Ax3 GetWorkingPlane() { return myWorkingPlane; }
127 void ActiveWorkingPlane();
129 virtual bool renameObject( const QString&, const QString& );
130 virtual bool renameAllowed( const QString& ) const;
132 virtual void windows( QMap<int, int>& ) const;
133 virtual void viewManagers( QStringList& ) const;
135 virtual void contextMenuPopup( const QString&, QMenu*, QString& );
136 virtual void createPreferences();
137 virtual void preferencesChanged( const QString&, const QString& );
138 int getLocalSelectionMode() const;
139 void setLocalSelectionMode(const int mode);
141 virtual void storeVisualParameters (int savePoint);
142 virtual void restoreVisualParameters(int savePoint);
144 QAction* getAction(const int id);
146 virtual void message( const QString& msg);
147 static void ClearShapeBuffer( GEOM::GEOM_Object_ptr );
148 static GEOM::GEOM_Object_ptr
149 GetObjectFromIOR( const QString& IOR );
151 static QString GetIORFromObject( GEOM::GEOM_Object_ptr object );
153 virtual bool isDraggable( const SUIT_DataObject* what ) const;
154 virtual bool isDropAccepted( const SUIT_DataObject* where ) const;
155 virtual void dropObjects( const DataObjectList& what,
156 SUIT_DataObject* where,
157 const int row, Qt::DropAction action );
160 virtual bool deactivateModule( SUIT_Study* );
161 virtual bool activateModule( SUIT_Study* );
162 virtual void OnKeyPress ( SUIT_ViewWindow*, QKeyEvent* );
163 virtual void OnMousePress( SUIT_ViewWindow*, QMouseEvent* );
164 virtual void OnMouseMove ( SUIT_ViewWindow*, QMouseEvent* );
165 virtual void OnMouseRelease ( SUIT_ViewWindow*, QMouseEvent* );
168 virtual void onViewManagerAdded( SUIT_ViewManager* );
169 virtual void onViewManagerRemoved( SUIT_ViewManager* );
173 void onWindowActivated( SUIT_ViewWindow* );
174 void onViewAboutToShow();
175 void OnSetMaterial( const QString& );
176 void updateMaterials();
177 void updateCreationInfo();
178 void onAutoBringToFront();
179 void updateFieldColorScale();
182 void SignalDeactivateActiveDialog();
183 void SignalCloseAllDialogs();
184 void SignalDefaultStepValueChanged( double newVal );
187 virtual LightApp_Selection* createSelection() const;
190 GEOMGUI* getLibrary( const QString& libraryName );
191 GEOMPluginGUI* getPluginLibrary( const QString& libraryName );
192 void createGeomAction( const int id, const QString& po_id,
193 const QString& icon_id = QString(""),
194 const int key = 0, const bool toggle = false,
195 const QString& shortcutAction = QString() );
196 void createPopupItem( const int, const QString& clients, const QString& types,
197 const bool isSingle = false, const int isVisible = -1,
198 const bool isExpandAll = false, const bool isOCC = false,
199 const int parentId = -1 );
200 void addPluginActions();
202 void createOriginAndBaseVectors();
205 static GEOM::GEOM_Gen_var myComponentGeom; // GEOM engine!!!
209 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
210 typedef QMap<long, Handle(TColStd_HArray1OfByte)> TextureMap;
212 typedef QMap<long, Handle(Graphic3d_HArray1OfBytes)> TextureMap;
215 typedef QMap<long, TextureMap> StudyTextureMap;
216 typedef QMap<QString, GEOMGUI*> GUIMap;
218 typedef QPair<QString, QString> PluginAction;
220 GUIMap myGUIMap; // GUI libraries map
221 QDialog* myActiveDialogBox; // active dialog box
222 gp_Ax3 myWorkingPlane;
223 //QMap<int,QString> myRules; // popup rules
224 static StudyTextureMap myTextureMap; // texture map
226 QMap<int, PluginAction> myPluginActions; // plugin actions
227 QMap<QString, QString> myPluginLibs; // plugin name to plugin client library
229 QList<GEOMGUI_OCCSelector*> myOCCSelectors;
230 QList<LightApp_VTKSelector*> myVTKSelectors;
232 LightApp_Displayer* myDisplayer;
233 int myLocalSelectionMode; //Select Only
235 GEOMGUI_CreationInfoWdg* myCreationInfoWdg;
237 SALOME_ListIO myTopLevelIOList;
239 friend class DisplayGUI;