Salome HOME
Abu : Correction export/import dll
[modules/hexablock.git] / src / HEXABLOCKGUI / HEXABLOCKGUI_VtkDocumentGraphicView.hxx
1 // Copyright (C) 2009-2013  CEA/DEN, EDF R&D
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.
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 #ifndef _HEXABLOCKGUI_VTKDOCUMENTGRAPHICVIEW_HXX_
21 #define _HEXABLOCKGUI_VTKDOCUMENTGRAPHICVIEW_HXX_
22
23 // SALOME GUI includes
24 #include <LightApp_Displayer.h>
25 #include <SUIT_ViewWindow.h>
26 #include <SALOME_Actor.h>
27 #include <SVTK_InteractorStyle.h>
28 #include <QAbstractItemView>
29 #include <QMap>
30
31 #include "HEXABLOCKGUI_Export.hxx"
32 #include <HexVertex.hxx>
33 #include <HexQuad.hxx>
34 #include <HexEdge.hxx>
35 #include <HexHexa.hxx>
36 #include <HexDocument.hxx>
37 #include <vtkInteractorStyleTrackballCamera.h>
38 #include <SVTK_RenderWindowInteractor.h>
39 #include <vtkActor2D.h>
40 #include <SVTK_ViewWindow.h>
41
42 #include "HEXABLOCKGUI_DocumentModel.hxx"
43 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
44
45 class LightApp_Application;
46 class SALOME_Actor;
47
48 class vtkUnstructuredGrid;
49
50
51
52 namespace HEXABLOCK
53 {
54
55     namespace GUI
56     {
57         class HEXABLOCK_EXPORT Document_Actor : public SALOME_Actor
58         {
59           public:
60             Document_Actor(HEXA_NS::Document* doc, const QString& entry);
61             virtual ~Document_Actor();
62
63             // Highlight
64             virtual void highlight(bool theHighlight) {}
65
66             std::map<int,vtkIdType>   vtkElemsId;
67             std::map<vtkIdType, int>  hexaElemsId;
68
69             vtkUnstructuredGrid* getUnstructuredGrid();
70           private:
71             HEXA_NS::Document* _doc;
72
73         };
74                    // Abu
75         class HEXABLOCK_EXPORT Associate_Actor : public SALOME_Actor
76         {
77           public:
78             Associate_Actor(HEXA_NS::Document* doc, const QString& entry);
79             virtual ~Associate_Actor() {}
80
81             // Highlight
82             virtual void highlight(bool theHighlight) {}
83
84             std::map<int,vtkIdType>   vtkElemsId;
85             std::map<vtkIdType, int>  hexaElemsId;
86
87             vtkUnstructuredGrid* getUnstructuredGrid();
88           private:
89             HEXA_NS::Document* _doc;
90         };
91
92         /********************************************************************************
93          *                          VtkDocumentGraphicView
94          ********************************************************************************/
95         class HEXABLOCK_EXPORT VtkDocumentGraphicView : public QAbstractItemView
96         {
97             Q_OBJECT
98
99             public:
100             VtkDocumentGraphicView(DocumentModel* docModel, SVTK_ViewWindow* view, QWidget* parent=NULL);
101             virtual ~VtkDocumentGraphicView();
102             
103                 void setModel ( QAbstractItemModel * model );
104                 bool isEmpty() const { return getDocumentModel()->isEmpty(); }
105                 void highlight( const QModelIndex& ielt );
106                 void highlight( const QModelIndexList& elts );
107                 void highlightGroups( const QModelIndex& eltIndex );
108                 void highlightPropagation( const QModelIndex& eltIndex );
109
110             void setSelectionMode( const Selection_Mode theMode );
111             void setSelectionMode( const QModelIndex& eltIndex );
112             int getSelectionMode() const { return selectionMode; }
113             void getSelected(SALOME_ListIO& selectedObjects);
114             void clearSelection();
115
116                 void loadDocument(const QString& file); //Loads a selected document
117                 void loadDocument(); //Loads the current document
118                 void saveDocument(const QString& file);
119                 void update();//mise à jours de la vue : reconstruction complète
120                 void removeActor();
121
122                 QModelIndex indexAt(const QPoint &point) const;
123                 void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
124                 QRect visualRect(const QModelIndex &index) const;
125
126                 SVTK_ViewWindow* getViewWindow() const { return viewWindow; }
127                 void setViewWindow(SVTK_ViewWindow* view) { viewWindow = view; }
128                 Document_Actor* getDocumentActor() const { return documentActor; }
129
130                 DocumentModel*      getDocumentModel() const {
131                     return dynamic_cast<DocumentModel*>(model());
132                 }
133                 PatternDataSelectionModel* getPatternDataSelectionModel() const
134                 { return patternDataSelectionModel; }
135
136                 PatternGeomSelectionModel* getPatternGeomSelectionModel() const
137             { return patternGeomSelectionModel;}
138
139                 GroupsSelectionModel* getGroupsSelectionModel() const
140                 { return groupsSelectionModel; }
141
142                 MeshSelectionModel* getMeshSelectionModel() const
143                 { return meshSelectionModel; }
144
145                 PatternDataModel*    getPatternDataModel() const {return patternDataModel;}
146                 PatternGeomModel*    getPatternGeomModel() const { return patternGeomModel;}
147                 GroupsModel*         getGroupsModel() const {return groupsModel;}
148                 MeshModel*           getMeshModel() const {return meshModel;}
149
150         public slots:
151           void setWindowTitle(const QString& title);
152           void onPatternDatachanged();
153           void setVertexSelection();
154           void setEdgeSelection();
155           void setQuadSelection();
156           void setHexaSelection();
157           void setAllSelection();
158
159         protected slots:
160           virtual void  closeEditor ( QWidget * editor, QAbstractItemDelegate::EndEditHint hint );
161           virtual void  commitData ( QWidget * editor );
162           virtual void  currentChanged ( const QModelIndex & current, const QModelIndex & previous );
163           virtual void  dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight );
164           virtual void  editorDestroyed ( QObject * editor );
165           virtual void  rowsAboutToBeRemoved ( const QModelIndex & parent, int start, int end );
166           virtual void  rowsInserted ( const QModelIndex & parent, int start, int end );
167           virtual void  selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected );
168           virtual void  updateGeometries ();
169
170         protected:
171             int horizontalOffset() const;
172             bool isIndexHidden(const QModelIndex &index) const;
173             QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction,
174                                    Qt::KeyboardModifiers modifiers);
175             void setSelection(const QRect&, QItemSelectionModel::SelectionFlags command);
176             int verticalOffset() const;
177             QRegion visualRegionForSelection(const QItemSelection &selection) const;
178
179         private:
180             SVTK_ViewWindow*  viewWindow;
181             int selectionMode;
182             bool state;
183
184             Document_Actor*   documentActor;
185             Associate_Actor*  associateActor;
186
187             PatternDataSelectionModel*     patternDataSelectionModel;
188             PatternGeomSelectionModel*     patternGeomSelectionModel;
189             GroupsSelectionModel*          groupsSelectionModel;
190             MeshSelectionModel*            meshSelectionModel;
191
192             PatternDataModel*              patternDataModel;
193             PatternGeomModel*              patternGeomModel;
194             GroupsModel*                   groupsModel;
195             MeshModel*                     meshModel;
196
197             bool _currentChanged;
198             bool firstUpdate;
199         };
200     }
201 }
202
203
204
205
206 #endif