1 // Copyright (C) 2007-2010 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 <SalomeApp_Module.h>
34 #include <GEOM_Client.hxx>
35 #include <SALOME_InteractiveObject.hxx>
36 #include <SALOMEDSClient.hxx>
45 #include <Graphic3d_HArray1OfBytes.hxx>
48 #include "SALOMEconfig.h"
49 #include CORBA_CLIENT_HEADER(SALOMEDS)
51 // minimum allowed value for deflection coefficient
52 #define DEFLECTION_MIN 1e-06
56 class GEOMGUI_OCCSelector;
57 class LightApp_VTKSelector;
58 class LightApp_Selection;
59 class SUIT_ViewManager;
60 class SalomeApp_Study;
62 //=================================================================================
63 // class : GeometryGUI
65 //=================================================================================
66 class GEOMGUI_EXPORT GeometryGUI : public SalomeApp_Module
77 virtual LightApp_Displayer* displayer();
78 virtual void initialize( CAM_Application* );
79 virtual QString engineIOR() const;
81 static Handle(Graphic3d_HArray1OfBytes) getTexture( SalomeApp_Study*, int, int&, int& );
83 static bool InitGeomGen();
85 static GEOM::GEOM_Gen_var GetGeomGen();
87 static CORBA::Object_var ClientSObjectToObject (_PTR(SObject) theSObject);
88 static SALOMEDS::Study_var ClientStudyToStudy (_PTR(Study) theStudy);
90 static void Modified( bool = true );
92 GEOM_Client& GetShapeReader() { static SHAPE_READER(myShapeReader);return myShapeReader; }
94 // Get active dialog box
95 QDialog* GetActiveDialogBox(){ return myActiveDialogBox; }
96 // Set active dialog box
97 void SetActiveDialogBox( QDialog* aDlg );
99 // Non modal dialog boxes management
100 void EmitSignalDeactivateDialog();
101 void EmitSignalCloseAllDialogs();
102 void EmitSignalDefaultStepValueChanged( double newVal );
105 void OnGUIEvent( int id );
107 // The Working Plane management
108 void SetWorkingPlane( gp_Ax3 wp ) { myWorkingPlane = wp; }
109 gp_Ax3 GetWorkingPlane() { return myWorkingPlane; }
110 void ActiveWorkingPlane();
112 virtual void windows( QMap<int, int>& ) const;
113 virtual void viewManagers( QStringList& ) const;
115 virtual void contextMenuPopup( const QString&, QMenu*, QString& );
116 virtual void createPreferences();
117 virtual void preferencesChanged( const QString&, const QString& );
118 int getLocalSelectionMode() const;
119 void setLocalSelectionMode(const int mode);
121 virtual void storeVisualParameters (int savePoint);
122 virtual void restoreVisualParameters(int savePoint);
125 virtual bool deactivateModule( SUIT_Study* );
126 virtual bool activateModule( SUIT_Study* );
127 virtual void OnKeyPress ( SUIT_ViewWindow*, QKeyEvent* );
128 virtual void OnMousePress( SUIT_ViewWindow*, QMouseEvent* );
129 virtual void OnMouseMove ( SUIT_ViewWindow*, QMouseEvent* );
132 virtual void onViewManagerAdded( SUIT_ViewManager* );
133 virtual void onViewManagerRemoved( SUIT_ViewManager* );
137 void onWindowActivated( SUIT_ViewWindow* );
138 void onViewAboutToShow();
141 void SignalDeactivateActiveDialog();
142 void SignalCloseAllDialogs();
143 void SignalDefaultStepValueChanged( double newVal );
146 virtual LightApp_Selection* createSelection() const;
149 GEOMGUI* getLibrary( const QString& libraryName );
150 void createGeomAction( const int id, const QString& po_id,
151 const QString& icon_id = QString(""),
152 const int key = 0, const bool toggle = false,
153 const QString& shortcutAction = QString() );
154 void createPopupItem( const int, const QString& clients, const QString& types,
155 const bool isSingle = false, const int isVisible = -1,
156 const bool isExpandAll = false, const bool isOCC = false,
157 const int parentId = -1 );
159 void createOriginAndBaseVectors();
162 static GEOM::GEOM_Gen_var myComponentGeom; // GEOM engine!!!
166 typedef QMap<long, Handle(Graphic3d_HArray1OfBytes)> TextureMap;
167 typedef QMap<long, TextureMap> StudyTextureMap;
168 typedef QMap<QString, GEOMGUI*> GUIMap;
170 GUIMap myGUIMap; // GUI libraries map
171 QDialog* myActiveDialogBox; // active dialog box
172 gp_Ax3 myWorkingPlane;
173 QMap<int,QString> myRules; // popup rules
174 static StudyTextureMap myTextureMap; // texture map
176 QList<GEOMGUI_OCCSelector*> myOCCSelectors;
177 QList<LightApp_VTKSelector*> myVTKSelectors;
179 LightApp_Displayer* myDisplayer;
180 int myLocalSelectionMode; //Select Only
182 friend class DisplayGUI;