1 // Copyright (C) 2009-2013 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef _HEXABLOCKGUI_VTKDOCUMENTGRAPHICVIEW_HXX_
21 #define _HEXABLOCKGUI_VTKDOCUMENTGRAPHICVIEW_HXX_
23 #include "HEXABLOCKGUI_Export.hxx"
25 // SALOME GUI includes
26 #include <LightApp_Displayer.h>
27 #include <SUIT_ViewWindow.h>
28 #include <SALOME_Actor.h>
29 #include <SVTK_InteractorStyle.h>
30 #include <QAbstractItemView>
33 #include <HexVertex.hxx>
34 #include <HexQuad.hxx>
35 #include <HexEdge.hxx>
36 #include <HexHexa.hxx>
37 #include <HexDocument.hxx>
38 #include <vtkInteractorStyleTrackballCamera.h>
39 #include <SVTK_RenderWindowInteractor.h>
40 #include <vtkActor2D.h>
41 #include <SVTK_ViewWindow.h>
43 #include "HEXABLOCKGUI_DocumentModel.hxx"
44 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
46 class LightApp_Application;
49 class vtkUnstructuredGrid;
58 class HEXABLOCK_EXPORT Document_Actor : public SALOME_Actor
61 Document_Actor(HEXA_NS::Document* doc, const QString& entry);
62 virtual ~Document_Actor();
65 virtual void highlight(bool theHighlight) {}
67 std::map<int,vtkIdType> vtkElemsId;
68 std::map<vtkIdType, int> hexaElemsId;
70 vtkUnstructuredGrid* getUnstructuredGrid();
72 HEXA_NS::Document* _doc;
76 class Associate_Actor : public SALOME_Actor
79 Associate_Actor(HEXA_NS::Document* doc, const QString& entry);
80 virtual ~Associate_Actor() {}
83 virtual void highlight(bool theHighlight) {}
85 std::map<int,vtkIdType> vtkElemsId;
86 std::map<vtkIdType, int> hexaElemsId;
88 vtkUnstructuredGrid* getUnstructuredGrid();
90 HEXA_NS::Document* _doc;
94 /********************************************************************************
95 * VtkDocumentGraphicView
96 ********************************************************************************/
97 class HEXABLOCK_EXPORT VtkDocumentGraphicView : public QAbstractItemView
102 VtkDocumentGraphicView(DocumentModel* docModel, SVTK_ViewWindow* view, QWidget* parent=NULL);
103 virtual ~VtkDocumentGraphicView();
105 void setModel ( QAbstractItemModel * model );
106 bool isEmpty() const { return getDocumentModel()->isEmpty(); }
107 void highlight( const QModelIndex& ielt );
108 void highlight( const QModelIndexList& elts );
109 void highlightGroups( const QModelIndex& eltIndex );
110 void highlightPropagation( const QModelIndex& eltIndex );
112 void setSelectionMode( const Selection_Mode theMode );
113 void setSelectionMode( const QModelIndex& eltIndex );
114 int getSelectionMode() const { return selectionMode; }
115 void getSelected(SALOME_ListIO& selectedObjects);
116 void clearSelection();
118 void loadDocument(const QString& file); //Loads a selected document
119 void loadDocument(); //Loads the current document
120 void saveDocument(const QString& file);
121 void update();//mise à jours de la vue : reconstruction complète
124 QModelIndex indexAt(const QPoint &point) const;
125 void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
126 QRect visualRect(const QModelIndex &index) const;
128 SVTK_ViewWindow* getViewWindow() const { return viewWindow; }
129 void setViewWindow(SVTK_ViewWindow* view) { viewWindow = view; }
130 Document_Actor* getDocumentActor() const { return documentActor; }
132 DocumentModel* getDocumentModel() const {
133 return dynamic_cast<DocumentModel*>(model());
135 PatternDataSelectionModel* getPatternDataSelectionModel() const
136 { return patternDataSelectionModel; }
138 PatternBuilderSelectionModel* getPatternBuilderSelectionModel() const
139 { return patternBuilderSelectionModel; }
141 PatternGeomSelectionModel* getPatternGeomSelectionModel() const
142 { return patternGeomSelectionModel;}
144 GroupsSelectionModel* getGroupsSelectionModel() const
145 { return groupsSelectionModel; }
147 MeshSelectionModel* getMeshSelectionModel() const
148 { return meshSelectionModel; }
150 PatternDataModel* getPatternDataModel() const {return patternDataModel;}
151 PatternBuilderModel* getPatternBuilderModel() const {return patternBuilderModel;}
152 PatternGeomModel* getPatternGeomModel() const { return patternGeomModel;}
153 GroupsModel* getGroupsModel() const {return groupsModel;}
154 MeshModel* getMeshModel() const {return meshModel;}
157 void setWindowTitle(const QString& title);
158 void onPatternDatachanged();
159 void setVertexSelection();
160 void setEdgeSelection();
161 void setQuadSelection();
162 void setHexaSelection();
163 void setAllSelection();
166 virtual void closeEditor ( QWidget * editor, QAbstractItemDelegate::EndEditHint hint );
167 virtual void commitData ( QWidget * editor );
168 virtual void currentChanged ( const QModelIndex & current, const QModelIndex & previous );
169 virtual void dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight );
170 virtual void editorDestroyed ( QObject * editor );
171 virtual void rowsAboutToBeRemoved ( const QModelIndex & parent, int start, int end );
172 virtual void rowsInserted ( const QModelIndex & parent, int start, int end );
173 virtual void selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected );
174 virtual void updateGeometries ();
177 int horizontalOffset() const;
178 bool isIndexHidden(const QModelIndex &index) const;
179 QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction,
180 Qt::KeyboardModifiers modifiers);
181 void setSelection(const QRect&, QItemSelectionModel::SelectionFlags command);
182 int verticalOffset() const;
183 QRegion visualRegionForSelection(const QItemSelection &selection) const;
186 SVTK_ViewWindow* viewWindow;
190 Document_Actor* documentActor;
191 Associate_Actor* associateActor;
193 PatternDataSelectionModel* patternDataSelectionModel;
194 PatternBuilderSelectionModel* patternBuilderSelectionModel;
195 PatternGeomSelectionModel* patternGeomSelectionModel;
196 GroupsSelectionModel* groupsSelectionModel;
197 MeshSelectionModel* meshSelectionModel;
199 PatternDataModel* patternDataModel;
200 PatternBuilderModel* patternBuilderModel;
201 PatternGeomModel* patternGeomModel;
202 GroupsModel* groupsModel;
203 MeshModel* meshModel;
205 bool _currentChanged;