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
55 #define NAME_SEPARATOR '_' // character used to separate parameter names
56 #define DIGIT_SEPARATOR ':' // character used to separate numeric parameter values (color = r:g:b)
58 #define VISIBILITY_PROP "Visibility" //Object visibility property
59 #define OPACITY_PROP "Opacity" //Object opacity property
60 #define TRANSPARENCY_PROP "Transparency" //Object transparency property
61 #define DISPLAY_MODE_PROP "DisplayMode" //Object display mode property
62 #define ISOS_PROP "Isos" //Number of the Isos property of the object
63 #define COLOR_PROP "Color" //Color of the object
64 #define VECTOR_MODE_PROP "VectorMode" //Vector mode property
65 #define DEFLECTION_COEFF_PROP "DeflectionCoeff" //Deflection coeff property
66 #define MARKER_TYPE_PROP "MarkerType" // Marker type property
71 class GEOMGUI_OCCSelector;
72 class LightApp_VTKSelector;
73 class LightApp_Selection;
74 class SUIT_ViewManager;
75 class SalomeApp_Study;
77 //=================================================================================
78 // class : GeometryGUI
80 //=================================================================================
81 class GEOMGUI_EXPORT GeometryGUI : public SalomeApp_Module
92 virtual LightApp_Displayer* displayer();
93 virtual void initialize( CAM_Application* );
94 virtual QString engineIOR() const;
96 static Handle(Graphic3d_HArray1OfBytes) getTexture( SalomeApp_Study*, int, int&, int& );
98 static bool InitGeomGen();
100 static GEOM::GEOM_Gen_var GetGeomGen();
102 static CORBA::Object_var ClientSObjectToObject (_PTR(SObject) theSObject);
103 static SALOMEDS::Study_var ClientStudyToStudy (_PTR(Study) theStudy);
105 static void Modified( bool = true );
107 GEOM_Client& GetShapeReader() { static SHAPE_READER(myShapeReader);return myShapeReader; }
109 // Get active dialog box
110 QDialog* GetActiveDialogBox(){ return myActiveDialogBox; }
111 // Set active dialog box
112 void SetActiveDialogBox( QDialog* aDlg );
114 // Non modal dialog boxes management
115 void EmitSignalDeactivateDialog();
116 void EmitSignalCloseAllDialogs();
117 void EmitSignalDefaultStepValueChanged( double newVal );
120 void OnGUIEvent( int id );
122 // The Working Plane management
123 void SetWorkingPlane( gp_Ax3 wp ) { myWorkingPlane = wp; }
124 gp_Ax3 GetWorkingPlane() { return myWorkingPlane; }
125 void ActiveWorkingPlane();
127 virtual bool renameObject( const QString&, const QString& );
129 virtual void windows( QMap<int, int>& ) const;
130 virtual void viewManagers( QStringList& ) const;
132 virtual void contextMenuPopup( const QString&, QMenu*, QString& );
133 virtual void createPreferences();
134 virtual void preferencesChanged( const QString&, const QString& );
135 int getLocalSelectionMode() const;
136 void setLocalSelectionMode(const int mode);
138 virtual void storeVisualParameters (int savePoint);
139 virtual void restoreVisualParameters(int savePoint);
142 virtual bool deactivateModule( SUIT_Study* );
143 virtual bool activateModule( SUIT_Study* );
144 virtual void OnKeyPress ( SUIT_ViewWindow*, QKeyEvent* );
145 virtual void OnMousePress( SUIT_ViewWindow*, QMouseEvent* );
146 virtual void OnMouseMove ( SUIT_ViewWindow*, QMouseEvent* );
149 virtual void onViewManagerAdded( SUIT_ViewManager* );
150 virtual void onViewManagerRemoved( SUIT_ViewManager* );
154 void onWindowActivated( SUIT_ViewWindow* );
155 void onViewAboutToShow();
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 typedef QMap<long, Handle(Graphic3d_HArray1OfBytes)> TextureMap;
184 typedef QMap<long, TextureMap> StudyTextureMap;
185 typedef QMap<QString, GEOMGUI*> GUIMap;
187 GUIMap myGUIMap; // GUI libraries map
188 QDialog* myActiveDialogBox; // active dialog box
189 gp_Ax3 myWorkingPlane;
190 QMap<int,QString> myRules; // popup rules
191 static StudyTextureMap myTextureMap; // texture map
193 QList<GEOMGUI_OCCSelector*> myOCCSelectors;
194 QList<LightApp_VTKSelector*> myVTKSelectors;
196 LightApp_Displayer* myDisplayer;
197 int myLocalSelectionMode; //Select Only
199 friend class DisplayGUI;