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"
\r
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 HEXABLOCK_EXPORT 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;
93 /********************************************************************************
94 * VtkDocumentGraphicView
95 ********************************************************************************/
96 class HEXABLOCK_EXPORT VtkDocumentGraphicView : public QAbstractItemView
101 VtkDocumentGraphicView(DocumentModel* docModel, SVTK_ViewWindow* view, QWidget* parent=NULL);
102 virtual ~VtkDocumentGraphicView();
104 void setModel ( QAbstractItemModel * model );
105 bool isEmpty() const { return getDocumentModel()->isEmpty(); }
106 void highlight( const QModelIndex& ielt );
107 void highlight( const QModelIndexList& elts );
108 void highlightGroups( const QModelIndex& eltIndex );
109 void highlightPropagation( const QModelIndex& eltIndex );
111 void setSelectionMode( const Selection_Mode theMode );
112 void setSelectionMode( const QModelIndex& eltIndex );
113 int getSelectionMode() const { return selectionMode; }
114 void getSelected(SALOME_ListIO& selectedObjects);
115 void clearSelection();
117 void loadDocument(const QString& file); //Loads a selected document
118 void loadDocument(); //Loads the current document
119 void saveDocument(const QString& file);
120 void update();//mise à jours de la vue : reconstruction complète
123 QModelIndex indexAt(const QPoint &point) const;
124 void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
125 QRect visualRect(const QModelIndex &index) const;
127 SVTK_ViewWindow* getViewWindow() const { return viewWindow; }
128 void setViewWindow(SVTK_ViewWindow* view) { viewWindow = view; }
129 Document_Actor* getDocumentActor() const { return documentActor; }
131 DocumentModel* getDocumentModel() const {
132 return dynamic_cast<DocumentModel*>(model());
134 PatternDataSelectionModel* getPatternDataSelectionModel() const
135 { return patternDataSelectionModel; }
137 PatternGeomSelectionModel* getPatternGeomSelectionModel() const
138 { return patternGeomSelectionModel;}
140 GroupsSelectionModel* getGroupsSelectionModel() const
141 { return groupsSelectionModel; }
143 MeshSelectionModel* getMeshSelectionModel() const
144 { return meshSelectionModel; }
146 PatternDataModel* getPatternDataModel() const {return patternDataModel;}
147 PatternGeomModel* getPatternGeomModel() const { return patternGeomModel;}
148 GroupsModel* getGroupsModel() const {return groupsModel;}
149 MeshModel* getMeshModel() const {return meshModel;}
152 void setWindowTitle(const QString& title);
153 void onPatternDatachanged();
154 void setVertexSelection();
155 void setEdgeSelection();
156 void setQuadSelection();
157 void setHexaSelection();
158 void setAllSelection();
161 virtual void closeEditor ( QWidget * editor, QAbstractItemDelegate::EndEditHint hint );
162 virtual void commitData ( QWidget * editor );
163 virtual void currentChanged ( const QModelIndex & current, const QModelIndex & previous );
164 virtual void dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight );
165 virtual void editorDestroyed ( QObject * editor );
166 virtual void rowsAboutToBeRemoved ( const QModelIndex & parent, int start, int end );
167 virtual void rowsInserted ( const QModelIndex & parent, int start, int end );
168 virtual void selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected );
169 virtual void updateGeometries ();
172 int horizontalOffset() const;
173 bool isIndexHidden(const QModelIndex &index) const;
174 QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction,
175 Qt::KeyboardModifiers modifiers);
176 void setSelection(const QRect&, QItemSelectionModel::SelectionFlags command);
177 int verticalOffset() const;
178 QRegion visualRegionForSelection(const QItemSelection &selection) const;
181 SVTK_ViewWindow* viewWindow;
185 Document_Actor* documentActor;
186 Associate_Actor* associateActor;
188 PatternDataSelectionModel* patternDataSelectionModel;
189 PatternGeomSelectionModel* patternGeomSelectionModel;
190 GroupsSelectionModel* groupsSelectionModel;
191 MeshSelectionModel* meshSelectionModel;
193 PatternDataModel* patternDataModel;
194 PatternGeomModel* patternGeomModel;
195 GroupsModel* groupsModel;
196 MeshModel* meshModel;
198 bool _currentChanged;