Salome HOME
Update copyrights
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_SubShapeSelectorWdg.h
1 // Copyright (C) 2007-2019  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // File   : StdMeshersGUI_SubShapeSelectorWdg.h
21 // Author : Open CASCADE S.A.S. (dmv)
22 //
23 #ifndef STDMESHERSGUI_SUBSHAPESELECTORWDG_H
24 #define STDMESHERSGUI_SUBSHAPESELECTORWDG_H
25
26 // SMESH includes
27 #include "SMESHGUI.h"
28 #include "SMESH_StdMeshersGUI.hxx"
29 #include "SMESH_SMESHGUI.hxx"
30
31 // Qt includes
32 #include <QWidget>
33 #include <QStringList>
34 #include <TopoDS_Shape.hxx>
35
36 #include <string>
37
38 class SMESHGUI;
39 class LightApp_SelectionMgr;
40 class SVTK_Selector;
41 class QPushButton;
42 class QLabel;
43 class QListWidget;
44 class SMESH_PreviewActorsCollection;
45 class vtkRenderer;
46 class SUIT_SelectionFilter;
47
48 class STDMESHERSGUI_EXPORT StdMeshersGUI_SubShapeSelectorWdg : public QWidget
49 {
50   Q_OBJECT
51
52 public:
53   StdMeshersGUI_SubShapeSelectorWdg( QWidget*         parent = 0,
54                                      TopAbs_ShapeEnum subShType = TopAbs_EDGE,
55                                      const bool       toShowList = true,
56                                      const bool       toShowActivateBtn = false);
57   ~StdMeshersGUI_SubShapeSelectorWdg();
58
59   SMESH::long_array_var          GetListOfIDs();
60   bool                           SetListOfIDs( SMESH::long_array_var );
61   const QList<int>&              GetSelectedIDs() const { return mySelectedIDs; }
62
63   void                           SetGeomShapeEntry( const QString& theEntry,
64                                                     const QString& theMainShapeEntry);
65   const char*                    GetMainShapeEntry();
66
67   TopoDS_Shape                   GetGeomShape() { return myGeomShape; }
68   TopoDS_Shape                   GetMainShape() { return myMainShape; }
69
70   static GEOM::GEOM_Object_var   GetGeomObjectByEntry( const QString& );
71   static TopoDS_Shape            GetTopoDSByEntry( const QString& );
72
73   QString                        GetValue() const { return myParamValue; }
74
75   void                           ShowPreview( bool );
76
77   int                            GetListSize() { return myListOfIDs.size(); }
78
79   void                           SetMaxSize(int aMaxSize) { myMaxSize = aMaxSize; }
80
81   vtkRenderer*                   GetRenderer() { return myRenderer; }
82   SMESH_PreviewActorsCollection* GetActorCollection() { return myPreviewActor; }
83   void                           ClearSelected();
84
85 public slots:
86   void                           ActivateSelection( bool );
87
88 signals:
89   void                           selectionChanged(); // in the list
90   void                           shapeSelected();    // globally
91
92 private:
93   void                           updateState();
94   void                           setFilter();
95   void                           updateButtons();
96
97 private slots:
98   void                           onAdd(); 
99   void                           onRemove(); 
100   void                           onPrevious(); 
101   void                           onNext(); 
102   void                           selectionIntoArgument();
103   void                           onListSelectionChanged();
104
105 private:
106   void                           init();
107
108 private:
109   SMESHGUI*                      mySMESHGUI;
110   LightApp_SelectionMgr*         mySelectionMgr;          /* User shape selection */
111   SVTK_Selector*                 mySelector;
112   SMESH::SMESH_Mesh_var          myMesh;
113   TopoDS_Shape                   myGeomShape; // shape whose sub-shapes are selected
114   TopoDS_Shape                   myMainShape; // main shape of the mesh
115   std::string                    myEntry;
116   std::string                    myMainEntry;
117   vtkRenderer*                   myRenderer;
118   
119   QListWidget*                   myListWidget;
120   QPushButton*                   myActivateButton;
121   QPushButton*                   myAddButton;
122   QPushButton*                   myRemoveButton;
123   QLabel*                        myInfoLabel;
124   QPushButton*                   myPrevButton;
125   QPushButton*                   myNextButton;
126   QList<int>                     mySelectedIDs;
127   QList<int>                     myListOfIDs;
128   
129   QString                        myParamValue;
130   bool                           myIsShown;
131
132   // for manage possible size of myListOfIDs
133   int                            myMaxSize;
134   // for manage type of selected subshape
135   TopAbs_ShapeEnum               mySubShType;
136   
137   SMESH_PreviewActorsCollection* myPreviewActor;
138   QList<SUIT_SelectionFilter*>   myGeomFilters;
139   SUIT_SelectionFilter*          myFilter;
140 };
141
142 #endif // STDMESHERSGUI_SUBSHAPESELECTORWDG_H