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 // 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>
31 #include <HexVertex.hxx>
32 #include <HexQuad.hxx>
33 #include <HexEdge.hxx>
34 #include <HexHexa.hxx>
35 #include <HexDocument.hxx>
36 #include <vtkInteractorStyleTrackballCamera.h>
37 #include <SVTK_RenderWindowInteractor.h>
38 #include <vtkActor2D.h>
39 #include <SVTK_ViewWindow.h>
41 #include "HEXABLOCKGUI_DocumentModel.hxx"
42 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
44 class LightApp_Application;
47 class vtkUnstructuredGrid;
56 class HexaExport Document_Actor : public SALOME_Actor
59 Document_Actor(HEXA_NS::Document* doc, const QString& entry);
60 virtual ~Document_Actor();
63 virtual void highlight(bool theHighlight) {}
65 std::map<int,vtkIdType> vtkElemsId;
66 std::map<vtkIdType, int> hexaElemsId;
68 vtkUnstructuredGrid* getUnstructuredGrid();
70 HEXA_NS::Document* _doc;
74 class HexaExport Associate_Actor : public SALOME_Actor
77 Associate_Actor(HEXA_NS::Document* doc, const QString& entry);
78 virtual ~Associate_Actor() {}
81 virtual void highlight(bool theHighlight) {}
83 std::map<int,vtkIdType> vtkElemsId;
84 std::map<vtkIdType, int> hexaElemsId;
86 vtkUnstructuredGrid* getUnstructuredGrid();
88 HEXA_NS::Document* _doc;
91 /********************************************************************************
92 * VtkDocumentGraphicView
93 ********************************************************************************/
94 class HexaExport VtkDocumentGraphicView : public QAbstractItemView
99 VtkDocumentGraphicView(DocumentModel* docModel, SVTK_ViewWindow* view, QWidget* parent=NULL);
100 virtual ~VtkDocumentGraphicView();
102 void setModel ( QAbstractItemModel * model );
103 bool isEmpty() const { return getDocumentModel()->isEmpty(); }
104 void highlight( const QModelIndex& ielt );
105 void highlight( const QModelIndexList& elts );
106 void highlightGroups( const QModelIndex& eltIndex );
107 void highlightPropagation( const QModelIndex& eltIndex );
109 void setSelectionMode( const Selection_Mode theMode );
110 void setSelectionMode( const QModelIndex& eltIndex );
111 int getSelectionMode() const { return selectionMode; }
112 void getSelected(SALOME_ListIO& selectedObjects);
113 void clearSelection();
115 void loadDocument(const QString& file); //Loads a selected document
116 void loadDocument(); //Loads the current document
117 void saveDocument(const QString& file);
118 void update();//mise à jours de la vue : reconstruction complète
121 QModelIndex indexAt(const QPoint &point) const;
122 void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
123 QRect visualRect(const QModelIndex &index) const;
125 SVTK_ViewWindow* getViewWindow() const { return viewWindow; }
126 void setViewWindow(SVTK_ViewWindow* view) { viewWindow = view; }
127 Document_Actor* getDocumentActor() const { return documentActor; }
129 DocumentModel* getDocumentModel() const {
130 return dynamic_cast<DocumentModel*>(model());
132 PatternDataSelectionModel* getPatternDataSelectionModel() const
133 { return patternDataSelectionModel; }
135 PatternGeomSelectionModel* getPatternGeomSelectionModel() const
136 { return patternGeomSelectionModel;}
138 GroupsSelectionModel* getGroupsSelectionModel() const
139 { return groupsSelectionModel; }
141 MeshSelectionModel* getMeshSelectionModel() const
142 { return meshSelectionModel; }
144 PatternDataModel* getPatternDataModel() const {return patternDataModel;}
145 PatternGeomModel* getPatternGeomModel() const { return patternGeomModel;}
146 GroupsModel* getGroupsModel() const {return groupsModel;}
147 MeshModel* getMeshModel() const {return meshModel;}
150 void setWindowTitle(const QString& title);
151 void onPatternDatachanged();
152 void setVertexSelection();
153 void setEdgeSelection();
154 void setQuadSelection();
155 void setHexaSelection();
156 void setAllSelection();
159 virtual void closeEditor ( QWidget * editor, QAbstractItemDelegate::EndEditHint hint );
160 virtual void commitData ( QWidget * editor );
161 virtual void currentChanged ( const QModelIndex & current, const QModelIndex & previous );
162 virtual void dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight );
163 virtual void editorDestroyed ( QObject * editor );
164 virtual void rowsAboutToBeRemoved ( const QModelIndex & parent, int start, int end );
165 virtual void rowsInserted ( const QModelIndex & parent, int start, int end );
166 virtual void selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected );
167 virtual void updateGeometries ();
170 int horizontalOffset() const;
171 bool isIndexHidden(const QModelIndex &index) const;
172 QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction,
173 Qt::KeyboardModifiers modifiers);
174 void setSelection(const QRect&, QItemSelectionModel::SelectionFlags command);
175 int verticalOffset() const;
176 QRegion visualRegionForSelection(const QItemSelection &selection) const;
179 SVTK_ViewWindow* viewWindow;
183 Document_Actor* documentActor;
184 Associate_Actor* associateActor;
186 PatternDataSelectionModel* patternDataSelectionModel;
187 PatternGeomSelectionModel* patternGeomSelectionModel;
188 GroupsSelectionModel* groupsSelectionModel;
189 MeshSelectionModel* meshSelectionModel;
191 PatternDataModel* patternDataModel;
192 PatternGeomModel* patternGeomModel;
193 GroupsModel* groupsModel;
194 MeshModel* meshModel;
196 bool _currentChanged;