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)
59 class GEOMGUI_OCCSelector;
60 class LightApp_VTKSelector;
61 class LightApp_Selection;
62 class SUIT_ViewManager;
63 class SalomeApp_Study;
65 //=================================================================================
66 // class : GeometryGUI
68 //=================================================================================
69 class GEOMGUI_EXPORT GeometryGUI : public SalomeApp_Module
80 virtual LightApp_Displayer* displayer();
81 virtual void initialize( CAM_Application* );
82 virtual QString engineIOR() const;
84 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
85 static Handle(TColStd_HArray1OfByte) getTexture (SalomeApp_Study*, int, int&, int&);
87 static Handle(Graphic3d_HArray1OfBytes) getTexture (SalomeApp_Study*, int, int&, int&);
90 static bool InitGeomGen();
92 static GEOM::GEOM_Gen_var GetGeomGen();
94 static CORBA::Object_var ClientSObjectToObject (_PTR(SObject) theSObject);
95 static SALOMEDS::Study_var ClientStudyToStudy (_PTR(Study) theStudy);
97 static void Modified( bool = true );
99 GEOM_Client& GetShapeReader() { static SHAPE_READER(myShapeReader);return myShapeReader; }
101 // Get active dialog box
102 QDialog* GetActiveDialogBox(){ return myActiveDialogBox; }
103 // Set active dialog box
104 void SetActiveDialogBox( QDialog* aDlg );
106 // Non modal dialog boxes management
107 void EmitSignalDeactivateDialog();
108 void EmitSignalCloseAllDialogs();
109 void EmitSignalDefaultStepValueChanged( double newVal );
112 void OnGUIEvent( int id );
114 // The Working Plane management
115 void SetWorkingPlane( gp_Ax3 wp ) { myWorkingPlane = wp; }
116 gp_Ax3 GetWorkingPlane() { return myWorkingPlane; }
117 void ActiveWorkingPlane();
119 virtual bool renameObject( const QString&, const QString& );
121 virtual void windows( QMap<int, int>& ) const;
122 virtual void viewManagers( QStringList& ) const;
124 virtual void contextMenuPopup( const QString&, QMenu*, QString& );
125 virtual void createPreferences();
126 virtual void preferencesChanged( const QString&, const QString& );
127 int getLocalSelectionMode() const;
128 void setLocalSelectionMode(const int mode);
130 virtual void storeVisualParameters (int savePoint);
131 virtual void restoreVisualParameters(int savePoint);
134 virtual bool deactivateModule( SUIT_Study* );
135 virtual bool activateModule( SUIT_Study* );
136 virtual void OnKeyPress ( SUIT_ViewWindow*, QKeyEvent* );
137 virtual void OnMousePress( SUIT_ViewWindow*, QMouseEvent* );
138 virtual void OnMouseMove ( SUIT_ViewWindow*, QMouseEvent* );
139 virtual void OnMouseRelease ( SUIT_ViewWindow*, QMouseEvent* );
142 virtual void onViewManagerAdded( SUIT_ViewManager* );
143 virtual void onViewManagerRemoved( SUIT_ViewManager* );
147 void onWindowActivated( SUIT_ViewWindow* );
148 void onViewAboutToShow();
151 void SignalDeactivateActiveDialog();
152 void SignalCloseAllDialogs();
153 void SignalDefaultStepValueChanged( double newVal );
156 virtual LightApp_Selection* createSelection() const;
159 GEOMGUI* getLibrary( const QString& libraryName );
160 void createGeomAction( const int id, const QString& po_id,
161 const QString& icon_id = QString(""),
162 const int key = 0, const bool toggle = false,
163 const QString& shortcutAction = QString() );
164 void createPopupItem( const int, const QString& clients, const QString& types,
165 const bool isSingle = false, const int isVisible = -1,
166 const bool isExpandAll = false, const bool isOCC = false,
167 const int parentId = -1 );
169 void createOriginAndBaseVectors();
172 static GEOM::GEOM_Gen_var myComponentGeom; // GEOM engine!!!
176 #if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
177 typedef QMap<long, Handle(TColStd_HArray1OfByte)> TextureMap;
179 typedef QMap<long, Handle(Graphic3d_HArray1OfBytes)> TextureMap;
182 typedef QMap<long, TextureMap> StudyTextureMap;
183 typedef QMap<QString, GEOMGUI*> GUIMap;
185 GUIMap myGUIMap; // GUI libraries map
186 QDialog* myActiveDialogBox; // active dialog box
187 gp_Ax3 myWorkingPlane;
188 QMap<int,QString> myRules; // popup rules
189 static StudyTextureMap myTextureMap; // texture map
191 QList<GEOMGUI_OCCSelector*> myOCCSelectors;
192 QList<LightApp_VTKSelector*> myVTKSelectors;
194 LightApp_Displayer* myDisplayer;
195 int myLocalSelectionMode; //Select Only
197 friend class DisplayGUI;