-// SMESH SMESHGUI : GUI for SMESH component
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// File : SMESHGUI.h
-// Author : Nicolas REJNERI
-// Module : SMESH
-// $Header$
-
-#ifndef SMESHGUI_HeaderFile
-#define SMESHGUI_HeaderFile
-
-#include "TColStd_MapOfInteger.hxx"
-#include <map>
-#include "SMESHDS_Document.hxx"
+// SMESH SMESHGUI : GUI for SMESH component
+// File : SMESHGUI.h
+// Author : Nicolas REJNERI, Open CASCADE S.A.S.
+//
+#ifndef SMESHGUI_H
+#define SMESHGUI_H
-// SALOME Includes
-#include "SALOMEGUI.h"
-#include "QAD_Desktop.h"
-#include "SALOME_Selection.h"
-#include "SALOME_InteractiveObject.hxx"
+// SMESH includes
+#include "SMESH_SMESHGUI.hxx"
-#include "SMESHGUI_StudyAPI.h"
-#include "SMESHGUI_Hypotheses.h"
+// SALOME GUI includes
+#include <SalomeApp_Module.h>
+#include <VTKViewer_MarkerDef.h>
+#include <SALOME_InteractiveObject.hxx>
-// IDL Headers
+// IDL includes
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Gen)
-#include CORBA_SERVER_HEADER(SMESH_Mesh)
-#include CORBA_SERVER_HEADER(SMESH_Group)
-#include CORBA_SERVER_HEADER(SMESH_Hypothesis)
-#include CORBA_SERVER_HEADER(GEOM_Gen)
-#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-#include CORBA_SERVER_HEADER(SMESH_Filter)
-
-// QT Includes
-#include <qstringlist.h>
-// VTK Inlcludes
+// VTK includes
+#include <vtkSmartPointer.h>
+#include <vtkType.h>
-class vtkActorCollection;
-class vtkActor2DCollection;
-class vtkScalarBarActor;
class vtkActor;
+class vtkCallbackCommand;
+class vtkObject;
-class SMESH_Actor;
-
-//=================================================================================
-// class : SMESHGUI
-// purpose :
-//=================================================================================
-class SMESHGUI : public SALOMEGUI
-{
- Q_OBJECT
-
-private :
-
- QAD_Desktop* myDesktop;
- QAD_Study* myActiveStudy;
- SMESH::SMESH_Gen_var myComponentMesh;
- GEOM::GEOM_Gen_var myComponentGeom;
-
- QDialog* myActiveDialogBox;
- int myNbMesh ;
- int myState ;
-
- vtkActorCollection* mySimulationActors;
- vtkActor2DCollection* mySimulationActors2D;
+class QDialog;
- SMESH_Actor* myCurrentMesh;
+class SUIT_Desktop;
+class SUIT_Study;
+class SUIT_ViewWindow;
+class SUIT_ResourceMgr;
+class SUIT_ViewManager;
- SALOMEDS::Study_var myStudy;
- int myStudyId;
+class LightApp_Operation;
+class SalomeApp_Study;
+class LightApp_Selection;
+class LightApp_SelectionMgr;
- SMESHGUI_StudyAPI myStudyAPI;
-
- // vtkScalarBarActor* myScalarBar;
+class SMESH_Actor;
+class SMESHGUI_FilterLibraryDlg;
- SMESHDS_Document * myDocument;//NBU
+typedef std::map<int, VTK::MarkerMap> SMESHGUI_StudyId2MarkerMap;
- bool myAutomaticUpdate;
+namespace SMESH
+{
+ class OrientedPlane;
+ struct ClippingPlaneInfo
+ {
+ OrientedPlane* Plane;
+ std::list<vtkActor*> ActorList;
+ };
+}
- SMESH::FilterManager_var myFilterMgr;
+typedef std::list<SMESH::ClippingPlaneInfo> SMESHGUI_ClippingPlaneInfoList;
+typedef std::map<SUIT_ViewManager*, SMESHGUI_ClippingPlaneInfoList> SMESHGUI_ClippingPlaneInfoMap;
- // Hypotheses/algorithms from plugin libraries
- map<string, HypothesisData*> myHypothesesMap;
- map<string, HypothesisData*> myAlgorithmsMap;
- map<string, SMESHGUI_GenericHypothesisCreator*> myHypCreatorMap;
+//=================================================================================
+// class : SMESHGUI
+// purpose :
+//=================================================================================
+class SMESHGUI_EXPORT SMESHGUI : public SalomeApp_Module
+{
+ Q_OBJECT;
public :
-
- SMESHGUI( const QString& name = "", QObject* parent = 0 );
+ SMESHGUI();
~SMESHGUI();
- static SMESHGUI* GetOrCreateSMESHGUI( QAD_Desktop* desktop );
- static SMESHGUI* GetSMESHGUI() ;
+ static SMESH::SMESH_Gen_var GetSMESHGen();
+ static SMESHGUI* GetSMESHGUI();
+ static LightApp_SelectionMgr* selectionMgr();
+ static SUIT_ResourceMgr* resourceMgr();
+ static SUIT_Desktop* desktop();
+ static SalomeApp_Study* activeStudy();
+
+ bool isActiveStudyLocked();
- QAD_Study* GetActiveStudy() ;
- QAD_Desktop* GetDesktop() ;
- SALOMEDS::Study_ptr GetStudy();
- SMESHGUI_StudyAPI GetStudyAPI();
+ static bool automaticUpdate(unsigned int requestedSize = 0, bool* limitExceeded = 0);
+ static bool automaticUpdate( SMESH::SMESH_Mesh_ptr, int*, bool*, int* );
- QDialog* GetActiveDialogBox() ;
- void SetActiveDialogBox(QDialog* aDlg) ;
+ static void Modified( bool = true );
- void SetState(int aState) ;
- void ResetState() ;
- bool DefineDlgPosition(QWidget* aDlg, int& x, int& y) ;
+ virtual LightApp_Displayer* displayer();
+ virtual QString engineIOR() const;
+ virtual void initialize( CAM_Application* );
+ virtual void windows( QMap<int, int>& ) const;
+ virtual void viewManagers( QStringList& ) const;
+ QDialog* GetActiveDialogBox();
+ void SetActiveDialogBox( QDialog* );
- virtual bool OnGUIEvent (int theCommandID, QAD_Desktop* parent);
- virtual bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame);
- virtual bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame);
- virtual bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame);
- virtual bool ActiveStudyChanged( QAD_Desktop* parent );
- virtual bool SetSettings ( QAD_Desktop* parent );
- virtual void DefinePopup ( QString & theContext, QString & theParent, QString & theObject );
- virtual bool CustomPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext,
- const QString & theParent, const QString & theObject );
- virtual void BuildPresentation ( const Handle(SALOME_InteractiveObject)& theIO );
- virtual void SupportedViewType (int* buffer, int bufferSize);
- virtual void Deactivate ();
+ void ResetState();
+ void SetState( int );
+ bool DefineDlgPosition( QWidget*, int&, int& );
+ void switchToOperation( int );
- void OnEditDelete();
+ virtual bool OnGUIEvent( int );
+ virtual bool OnMousePress( QMouseEvent*, SUIT_ViewWindow* );
+ virtual bool OnMouseMove( QMouseEvent*, SUIT_ViewWindow* );
+ virtual bool OnKeyPress( QKeyEvent*, SUIT_ViewWindow* );
- /* Mesh Management */
- SMESH::SMESH_Mesh_ptr InitMesh( GEOM::GEOM_Shape_ptr aShape, QString NameMesh );
- SMESH::SMESH_subMesh_ptr AddSubMesh( SMESH::SMESH_Mesh_ptr aMesh, GEOM::GEOM_Shape_ptr aShape, QString NameMesh );
- SMESH::SMESH_Group_ptr AddGroup( SMESH::SMESH_Mesh_ptr aMesh, SMESH::ElementType aType, QString aName );
+ virtual LightApp_Selection* createSelection() const;
- /* Hypotheses and Algorithms Management */
- void InitAvailableHypotheses ();
- QStringList GetAvailableHypotheses (const bool isAlgo);
- HypothesisData* GetHypothesisData (const char* aHypType);
- SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator (const QString& aHypType);
+ virtual void BuildPresentation ( const Handle(SALOME_InteractiveObject)&,
+ SUIT_ViewWindow* = 0 );
- SMESH::SMESH_Hypothesis_ptr CreateHypothesis (const QString& aHypType,
- const QString& aHypName,
- const bool isAlgo = false);
+ /* Non modal dialog boxes management */
+ void EmitSignalDeactivateDialog();
+ void EmitSignalStudyFrameChanged();
+ void EmitSignalCloseAllDialogs();
+ void EmitSignalVisibilityChanged();
- bool AddHypothesisOnMesh (SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp);
- bool AddAlgorithmOnMesh (SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp);
+ virtual void contextMenuPopup( const QString&, QMenu*, QString& );
+ virtual void createPreferences();
+ virtual void preferencesChanged( const QString&, const QString& );
- bool AddHypothesisOnSubMesh (SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp);
- bool AddAlgorithmOnSubMesh (SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp);
+ virtual void message( const QString& );
- bool RemoveHypothesisOrAlgorithmOnMesh (const Handle(SALOME_InteractiveObject)& IObject);
- bool RemoveHypothesisOrAlgorithmOnMesh (SALOMEDS::SObject_ptr MorSM,
- SMESH::SMESH_Hypothesis_ptr anHyp);
+ virtual void update( const int );
- void SetPickable(SMESH_Actor* theActor = NULL);
+ static SALOMEDS::Color getUniqueColor( const QList<SALOMEDS::Color>& );
+ static SALOMEDS::Color getPredefinedUniqueColor();
- /* NODES */
- void ViewNodes();
- vtkActor* SimulationMoveNode(SMESH_Actor* Mactor, int idnode);
- void MoveNode( SMESH::SMESH_Mesh_ptr aMesh, int idnode, float x, float y, float z);
+ virtual void storeVisualParameters (int savePoint);
+ virtual void restoreVisualParameters(int savePoint);
- void DisplaySimulationNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z);
- void DisplaySimulationMoveNode( vtkActor* ac, int idnode, float x, float y, float z);
+ virtual void addActorAsObserver( SMESH_Actor* theActor );
+
+ virtual bool renameAllowed( const QString& ) const;
+ virtual bool renameObject( const QString&, const QString& );
- void RemoveNodes(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) ;
- /* EDGES */
- void DisplayEdges(SMESH_Actor* ac, bool visibility = true);
- void DisplayEdgesConnectivityLegendBox(vtkActor *ac);
- void DisplaySimulationEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
+ SMESHGUI_ClippingPlaneInfoMap& getClippingPlaneInfoMap() { return myClippingPlaneInfoMap; }
- /* TRIANGLES */
- void DisplaySimulationTriangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
+public slots:
+ virtual bool deactivateModule( SUIT_Study* );
+ virtual bool activateModule( SUIT_Study* );
+ virtual void studyClosed( SUIT_Study* );
+ void onViewClosed( SUIT_ViewWindow* );
- /* QUADRANGLES */
- void DisplaySimulationQuadrangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
+private slots:
+ void OnGUIEvent();
+ void onViewManagerActivated( SUIT_ViewManager* );
+ void onViewManagerRemoved( SUIT_ViewManager* );
+ void onOperationCommited( SUIT_Operation* );
+ void onOperationAborted( SUIT_Operation* );
+ void onHypothesisEdit( int result );
- /* VOLUMES */
- void DisplaySimulationTetra( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
- void DisplaySimulationHexa( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
-
- /* ELEMENTS */
- void RemoveElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) ;
- void OrientationElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex);
- void DiagonalInversion(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex);
-
- void AddFace( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse );
- void AddEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
- void AddVolume( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex );
- void AddNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z);
-
- /* Simulation management */
- void EraseSimulationActors() ;
-
- /* Non modal dialog boxes magement */
- void EmitSignalDeactivateDialog() ;
- void EmitSignalCloseAllDialogs() ;
-
- /* Selection management */
- int GetNameOfSelectedIObjects( SALOME_Selection* Sel, QString& aName ) ;
- int GetNameOfSelectedNodes( SALOME_Selection* Sel, QString& aName ) ;
- int GetNameOfSelectedElements( SALOME_Selection* Sel, QString& aName ) ;
- int GetNameOfSelectedEdges( SALOME_Selection* Sel, QString& aName ) ;
-
- SMESH::SMESH_Hypothesis_ptr ConvertIOinSMESHHypothesis( const Handle(SALOME_InteractiveObject)& IO,
- Standard_Boolean& testResult ) ;
-
- SMESH::SMESH_Mesh_ptr ConvertIOinMesh(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ;
- SMESH::SMESH_subMesh_ptr ConvertIOinSubMesh(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ;
- SMESH::SMESH_Group_ptr ConvertIOinSMESHGroup(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ;
-
- /* Geometry Client */
- GEOM::GEOM_Shape_ptr ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO,
- Standard_Boolean& testResult ) ;
-
- /* Popup management */
- QString CheckTypeObject(const Handle(SALOME_InteractiveObject)& IO);
- QString CheckHomogeneousSelection();
-
- /* Scripts management */
- SMESH_Actor* ReadScript(SMESH::SMESH_Mesh_ptr aMesh);
-
- /* Actors management */
- void Dump(SMESH_Actor* Mactor);
-
- void SetViewMode(int commandId);
- void ChangeRepresentation( SMESH_Actor* ac, int type );
-
- SMESH_Actor* FindActor(CORBA::Object_ptr theObj,
- Standard_Boolean& testResult,
- bool onlyInActiveView);
- SMESH_Actor* FindActorByEntry(QString entry,
- Standard_Boolean& testResult,
- bool onlyInActiveView);
-
- void InitActor(SMESH::SMESH_Mesh_ptr aMesh);
- void DisplayActor(SMESH_Actor* ac, bool visibility = true);
- void EraseActor(SMESH_Actor* ac);
- bool AddActorInSelection(SMESH_Actor* ac);
-
- void UpdateView();
-
- void Update();
- void Update(const Handle(SALOME_InteractiveObject)& IO);
-
- void ScalarVisibilityOff();
-
-
- /* Settings management */
- void SetSettingsScalarBar(vtkScalarBarActor* theScalarBar,
- QString Bold, QString Italic, QString Shadow, QString Font,
- QString Orientation, float Width, float Height,
- int NbColors, int NbLabels);
- void SetDisplaySettings();
-
- SALOMEDS::Study::ListOfSObject* GetMeshesUsingAlgoOrHypothesis( SMESH::SMESH_Hypothesis_ptr AlgoOrHyp ) ;
-
- /* Control management */
- void Control(int theCommandID);
-
- /* Parameter functions */
- double Parameter( Standard_Boolean& res, const double aValue,
- const char* aLabel, const char* aTitle,
- const double bottom, const double top, const int decimals ) ;
- int Parameter( Standard_Boolean& res, const int aValue,
- const char* aLabel, const char* aTitle,
- const int bottom, const int top ) ;
+signals:
+ void SignalDeactivateActiveDialog();
+ void SignalStudyFrameChanged();
+ void SignalCloseAllDialogs();
+ void SignalVisibilityChanged();
+
+protected:
+ void createSMESHAction( const int,
+ const QString&,
+ const QString& = QString(),
+ const int = 0,
+ const bool = false,
+ const QString& = QString() );
+ void createPopupItem( const int,
+ const QString&,
+ const QString&,
+ const QString& = QString(),
+ const int = -1 );
+
+ virtual LightApp_Operation* createOperation( const int ) const;
+
+ virtual bool isSelectionCompatible();
+
+ virtual bool reusableOperation( const int id );
+
+ static void ProcessEvents( vtkObject* theObject,
+ unsigned long theEvent,
+ void* theClientData,
+ void* theCallData );
+
+private:
+ void OnEditDelete();
+ int addVtkFontPref( const QString&,
+ const int,
+ const QString&,
+ const bool = false);
+
+ void connectView( const SUIT_ViewWindow* );
+
- static void setOrb();
+private :
+ static SMESH::SMESH_Gen_var myComponentSMESH;
+ QDialog* myActiveDialogBox;
+ int myState;
+ QMap<int, QString> myRules;
+ LightApp_Displayer* myDisplayer;
- /* Import/Export */ //NBU
- static void Import_Mesh(QAD_Desktop* parent, int theCommandID);
- static void Export_Mesh(QAD_Desktop* parent, int theCommandID);
+ SMESHGUI_FilterLibraryDlg* myFilterLibraryDlg;
- /* Filter manager */
- SMESH::FilterManager_ptr GetFilterMgr();
+ SMESHGUI_StudyId2MarkerMap myMarkerMap;
+ SMESHGUI_ClippingPlaneInfoMap myClippingPlaneInfoMap;
-signals:
- void SignalDeactivateActiveDialog() ;
- void SignalCloseAllDialogs() ;
+ vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
+ double myPriority;
};
-#endif
+#endif // SMESHGUI_H