Salome HOME
23076: [CEA 1499] Get in python all sub-shapes in error after Compute
[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 <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 aSubShType = TopAbs_EDGE );
55   ~StdMeshersGUI_SubShapeSelectorWdg();
56
57   SMESH::long_array_var          GetListOfIDs();
58   bool                           SetListOfIDs( SMESH::long_array_var );
59
60   void                           SetGeomShapeEntry( const QString& theEntry,
61                                                     const QString& theMainShapeEntry);
62   //QString                        GetGeomShapeEntry() { return myEntry; }
63
64   // void                           SetMainShapeEntry( const QString& theEntry );
65   const char*                    GetMainShapeEntry();
66
67   TopoDS_Shape                   GetGeomShape() { return myGeomShape; }
68   TopoDS_Shape                   GetMainShape() { return myMainShape; }
69
70   // QList<int>                     GetCorrectedListOfIDs( bool fromSubshapeToMainshape,
71   //                                                       bool* isOK=0);
72
73   static GEOM::GEOM_Object_var   GetGeomObjectByEntry( const QString& );
74   static TopoDS_Shape            GetTopoDSByEntry( const QString& );
75
76   QString                        GetValue() const { return myParamValue; }
77
78   void                           ShowPreview( bool );
79
80   int                            GetListSize() { return myListOfIDs.size(); }
81
82   void                           SetMaxSize(int aMaxSize) { myMaxSize = aMaxSize; }
83
84   vtkRenderer*                   GetRenderer() { return myRenderer; }
85   SMESH_PreviewActorsCollection* GetActorCollection() { return myPreviewActor; }
86   void                           ClearSelected();
87
88 signals:
89   void                           selectionChanged();
90
91 private:
92   void                           updateState();
93   void                           setFilter();
94   void                           updateButtons();
95
96 private slots:
97   void                           onAdd(); 
98   void                           onRemove(); 
99   void                           onPrevious(); 
100   void                           onNext(); 
101   void                           selectionIntoArgument();
102   void                           onListSelectionChanged();
103
104 private:
105   void                           init();
106
107 private:
108   SMESHGUI*                      mySMESHGUI;
109   LightApp_SelectionMgr*         mySelectionMgr;          /* User shape selection */
110   SVTK_Selector*                 mySelector;
111   SMESH::SMESH_Mesh_var          myMesh;
112   TopoDS_Shape                   myGeomShape; // shape whose sub-shapes are selected
113   TopoDS_Shape                   myMainShape; // main shape of the mesh
114   std::string                    myEntry;
115   std::string                    myMainEntry;
116   vtkRenderer*                   myRenderer;
117   
118   QListWidget*                   myListWidget;
119   QPushButton*                   myAddButton;
120   QPushButton*                   myRemoveButton;
121   QLabel*                        myInfoLabel;
122   QPushButton*                   myPrevButton;
123   QPushButton*                   myNextButton;
124   QList<int>                     mySelectedIDs;
125   QList<int>                     myListOfIDs;
126   
127   QString                        myParamValue;
128   bool                           myIsShown;
129   bool                           myIsNotCorrected;
130
131   // for manage possible size of myListOfIDs
132   int                            myMaxSize;
133   // for manage type of selected subshape
134   TopAbs_ShapeEnum               mySubShType;
135   
136   SMESH_PreviewActorsCollection* myPreviewActor;
137   QList<SUIT_SelectionFilter*>   myGeomFilters;
138   SUIT_SelectionFilter*          myFilter;
139 };
140
141 #endif // STDMESHERSGUI_SUBSHAPESELECTORWDG_H