Salome HOME
Merge branch V7_3_1_BR
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_SubShapeSelectorWdg.h
1 // Copyright (C) 2007-2014  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 <SMESHGUI_VTKUtils.h>
37
38 class SMESHGUI;
39 class LightApp_SelectionMgr;
40 class SVTK_Selector;
41 class QPushButton;
42 class QLabel;
43 class QLineEdit;
44 class QCheckBox;
45 class QListWidget;
46 class SMESH_Actor;
47 class SMESH_PreviewActorsCollection;
48 class vtkRenderer;
49 class SUIT_SelectionFilter;
50
51 class STDMESHERSGUI_EXPORT StdMeshersGUI_SubShapeSelectorWdg : public QWidget
52 {
53   Q_OBJECT
54
55 public:
56   StdMeshersGUI_SubShapeSelectorWdg( QWidget* parent = 0,
57                                      TopAbs_ShapeEnum aSubShType = TopAbs_EDGE );
58   ~StdMeshersGUI_SubShapeSelectorWdg();
59
60   SMESH::long_array_var          GetListOfIDs();
61   void                           SetListOfIDs( SMESH::long_array_var );
62
63   void                           SetGeomShapeEntry( const QString& theEntry );
64   const char*                    GetGeomShapeEntry() { return myEntry.toLatin1().data();}
65
66   void                           SetMainShapeEntry( const QString& theEntry );
67   const char*                    GetMainShapeEntry();
68
69   TopoDS_Shape                   GetGeomShape() { return myGeomShape; }
70   TopoDS_Shape                   GetMainShape() { return myMainShape; }
71
72   QList<int>                     GetCorrectedListOfIDs( bool fromSubshapeToMainshape = true );
73
74   static GEOM::GEOM_Object_var   GetGeomObjectByEntry( const QString& );
75   static TopoDS_Shape            GetTopoDSByEntry( const QString& );
76
77   QString                        GetValue() const { return myParamValue; }
78
79   void                           showPreview ( bool );
80
81   int                            GetListSize() { return myListOfIDs.size(); }
82
83   void SetMaxSize(int aMaxSize) { myMaxSize = aMaxSize; }
84   //void SetSubShType(TopAbs_ShapeEnum aSubShType) { mySubShType = aSubShType; }
85
86 private:
87   void                           updateState();
88   void                           setFilter();
89   void                           updateButtons();
90
91 private slots:
92   void                           onAdd(); 
93   void                           onRemove(); 
94   void                           onPrevious(); 
95   void                           onNext(); 
96   void                           SelectionIntoArgument();
97   void                           onListSelectionChanged();
98
99 private:
100   void                           init();
101
102 private:
103   SMESHGUI*                      mySMESHGUI;
104   LightApp_SelectionMgr*         mySelectionMgr;          /* User shape selection */
105   SVTK_Selector*                 mySelector;
106   SMESH::SMESH_Mesh_var          myMesh;
107   TopoDS_Shape                   myGeomShape; // shape whose sub-shapes are selected
108   TopoDS_Shape                   myMainShape; // main shape of the mesh
109   QString                        myEntry;
110   QString                        myMainEntry;
111   vtkRenderer*                   myRenderer;
112   
113   QListWidget*                   myListWidget;
114   QPushButton*                   myAddButton;
115   QPushButton*                   myRemoveButton;
116   QLabel*                        myInfoLabel;
117   QPushButton*                   myPrevButton;
118   QPushButton*                   myNextButton;
119   QList<int>                     mySelectedIDs;
120   QList<int>                     myListOfIDs;
121   
122   QString                        myParamValue;
123   bool                           myIsShown;
124   bool                           myIsNotCorrected;
125
126   // for manage possible size of myListOfIDs
127   int                            myMaxSize;
128   // for manage type of selected subshape
129   TopAbs_ShapeEnum               mySubShType;
130   
131   SMESH_PreviewActorsCollection* myPreviewActor;
132   QList<SUIT_SelectionFilter*>   myGeomFilters;
133   SUIT_SelectionFilter*          myFilter;
134 };
135
136 #endif // STDMESHERSGUI_SUBSHAPESELECTORWDG_H