1 // Copyright (C) 2007-2008 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 <SalomeApp_Module.h>
33 #include <GEOM_Client.hxx>
34 #include <SALOME_InteractiveObject.hxx>
35 #include <SALOMEDSClient.hxx>
44 #include <Graphic3d_HArray1OfBytes.hxx>
47 #include "SALOMEconfig.h"
48 #include CORBA_CLIENT_HEADER(SALOMEDS)
50 // minimum allowed value for deflection coefficient
51 #define DEFLECTION_MIN 1e-06
53 typedef QMap<QString, GEOMGUI*> GUIMap;
57 class GEOMGUI_OCCSelector;
58 class LightApp_VTKSelector;
59 class LightApp_Selection;
60 class SUIT_ViewManager;
61 class SalomeApp_Study;
63 //=================================================================================
64 // class : GeometryGUI
66 //=================================================================================
67 class GEOMGUI_EXPORT GeometryGUI : public SalomeApp_Module
78 virtual LightApp_Displayer* displayer();
79 virtual void initialize( CAM_Application* );
80 virtual QString engineIOR() const;
82 static Handle(Graphic3d_HArray1OfBytes) getTexture( SalomeApp_Study*, int, int&, int& );
84 static bool InitGeomGen(); //BugID IPAL9186: SRN: To be called by Python scripts
86 static GEOM::GEOM_Gen_var GetGeomGen();// { return GeometryGUI::myComponentGeom; }
88 static CORBA::Object_var ClientSObjectToObject (_PTR(SObject) theSObject);
89 static SALOMEDS::Study_var ClientStudyToStudy (_PTR(Study) theStudy);
91 GEOM_Client& GetShapeReader() { return myShapeReader; }
92 Standard_CString& GetFatherior() { return myFatherior; }
93 //void SetState( const int state ) { myState = state; }
94 //int GetState() const { return myState; }
96 // Get active dialog box
97 QDialog* GetActiveDialogBox(){ return myActiveDialogBox; }
98 // Set active dialog box
99 void SetActiveDialogBox( QDialog* aDlg );
101 // Non modal dialog boxes management
102 void EmitSignalDeactivateDialog();
103 void EmitSignalCloseAllDialogs();
104 void EmitSignalDefaultStepValueChanged( double newVal );
106 void OnGUIEvent( int id );
108 // virtual bool SetSettings();
109 // virtual void SupportedViewType ( int* buffer, int bufferSize );
110 virtual void BuildPresentation( const Handle(SALOME_InteractiveObject)&, SUIT_ViewWindow* = 0 );
112 // virtual void DefinePopup( QString & theContext, QString & theParent, QString & theObject);
113 // virtual bool CustomPopup( QAD_Desktop* parent, QMenu* popup, const QString& theContext,
114 // const QString& theParent, const QString& theObject );
116 // The Working Plane management
117 void SetWorkingPlane( gp_Ax3 wp ) { myWorkingPlane = wp; }
118 gp_Ax3 GetWorkingPlane() { return myWorkingPlane; }
119 void ActiveWorkingPlane();
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* );
141 virtual void onViewManagerAdded( SUIT_ViewManager* );
142 virtual void onViewManagerRemoved( SUIT_ViewManager* );
146 void onWindowActivated( SUIT_ViewWindow* );
147 void onViewAboutToShow();
150 void SignalDeactivateActiveDialog();
151 void SignalCloseAllDialogs();
152 void SignalDefaultStepValueChanged( double newVal );
155 virtual LightApp_Selection* createSelection() const;
158 GEOMGUI* getLibrary( const QString& libraryName );
159 void createGeomAction( const int id, const QString& po_id,
160 const QString& icon_id = QString(""),
161 const int key = 0, const bool toggle = false );
162 void createPopupItem( const int, const QString& clients, const QString& types,
163 const bool isSingle = false, const int isVisible = -1,
164 const bool isExpandAll = false, const bool isOCC = false,
165 const int parentId = -1 );
168 static GEOM::GEOM_Gen_var myComponentGeom; // GEOM engine!!!
172 typedef QMap<long, Handle(Graphic3d_HArray1OfBytes)> TextureMap;
173 typedef QMap<long, TextureMap> StudyTextureMap;
175 GUIMap myGUIMap; // GUI libraries map
176 QDialog* myActiveDialogBox; // active dialog box
177 GEOM_Client myShapeReader; // geom shape reader
178 Standard_CString myFatherior;
179 int myState; // identify a method
180 gp_Ax3 myWorkingPlane;
181 QMap<int,QString> myRules; // popup rules
182 static StudyTextureMap myTextureMap; // texture map
184 QList<GEOMGUI_OCCSelector*> myOCCSelectors;
185 QList<LightApp_VTKSelector*> myVTKSelectors;
187 LightApp_Displayer* myDisplayer;
188 int myLocalSelectionMode; //Select Only
190 friend class DisplayGUI;