Salome HOME
Copyrights update 2015.
[modules/smesh.git] / src / StdMeshersGUI / StdMeshersGUI_SubShapeSelectorWdg.h
1 // Copyright (C) 2007-2015  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   bool                           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,
73                                                         bool* isOK=0);
74
75   static GEOM::GEOM_Object_var   GetGeomObjectByEntry( const QString& );
76   static TopoDS_Shape            GetTopoDSByEntry( const QString& );
77
78   QString                        GetValue() const { return myParamValue; }
79
80   void                           showPreview ( bool );
81
82   int                            GetListSize() { return myListOfIDs.size(); }
83
84   void SetMaxSize(int aMaxSize) { myMaxSize = aMaxSize; }
85   //void SetSubShType(TopAbs_ShapeEnum aSubShType) { mySubShType = aSubShType; }
86
87 private:
88   void                           updateState();
89   void                           setFilter();
90   void                           updateButtons();
91
92 private slots:
93   void                           onAdd(); 
94   void                           onRemove(); 
95   void                           onPrevious(); 
96   void                           onNext(); 
97   void                           SelectionIntoArgument();
98   void                           onListSelectionChanged();
99
100 private:
101   void                           init();
102
103 private:
104   SMESHGUI*                      mySMESHGUI;
105   LightApp_SelectionMgr*         mySelectionMgr;          /* User shape selection */
106   SVTK_Selector*                 mySelector;
107   SMESH::SMESH_Mesh_var          myMesh;
108   TopoDS_Shape                   myGeomShape; // shape whose sub-shapes are selected
109   TopoDS_Shape                   myMainShape; // main shape of the mesh
110   QString                        myEntry;
111   QString                        myMainEntry;
112   vtkRenderer*                   myRenderer;
113   
114   QListWidget*                   myListWidget;
115   QPushButton*                   myAddButton;
116   QPushButton*                   myRemoveButton;
117   QLabel*                        myInfoLabel;
118   QPushButton*                   myPrevButton;
119   QPushButton*                   myNextButton;
120   QList<int>                     mySelectedIDs;
121   QList<int>                     myListOfIDs;
122   
123   QString                        myParamValue;
124   bool                           myIsShown;
125   bool                           myIsNotCorrected;
126
127   // for manage possible size of myListOfIDs
128   int                            myMaxSize;
129   // for manage type of selected subshape
130   TopAbs_ShapeEnum               mySubShType;
131   
132   SMESH_PreviewActorsCollection* myPreviewActor;
133   QList<SUIT_SelectionFilter*>   myGeomFilters;
134   SUIT_SelectionFilter*          myFilter;
135 };
136
137 #endif // STDMESHERSGUI_SUBSHAPESELECTORWDG_H