1 // Copyright (C) 2009-2012 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 <SVTK_ViewWindow.h>
26 #include <SUIT_ViewWindow.h>
27 #include <SALOME_Actor.h>
28 #include <SVTK_InteractorStyle.h>
29 #include <QAbstractItemView>
32 // #include <QContextMenuEvent>
34 // #include <QGraphicsRectItem>
36 #include <HexVertex.hxx>
37 #include <HexQuad.hxx>
38 #include <HexEdge.hxx>
39 #include <HexHexa.hxx>
40 #include <HexDocument.hxx>
41 #include <vtkInteractorStyleTrackballCamera.h>
42 #include <SVTK_RenderWindowInteractor.h>
43 #include <vtkActor2D.h>
44 #include <SVTK_ViewWindow.h>
46 #include "HEXABLOCKGUI_DocumentModel.hxx"
47 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
49 // class LightApp_Displayer;
50 // class SalomeApp_Application;
51 class LightApp_Application;
54 // class vtkLookupTable ;
56 // class vtkCellArray ;
57 // class vtkFloatArray ;
62 class vtkUnstructuredGrid;
71 // class hexablockInteractorStyle : public SVTK_InteractorStyle
74 // hexablockInteractorStyle() {};
75 // virtual ~hexablockInteractorStyle() {};
78 // static hexablockInteractorStyle* New()
80 // return new hexablockInteractorStyle;
82 // virtual void HighlightActor2D(vtkActor2D* actor2D) {MESSAGE("% HIGHLIGHT PROP 2D %");}
83 // virtual void HighlightProp(vtkProp* prop) {MESSAGE("% HIGHLIGHT PROP %");}
84 // virtual void HighlightProp3D(vtkProp3D* prop3D) {MESSAGE("% HIGHLIGHT PROP 3D %");}
87 class Document_Actor : public SALOME_Actor
90 Document_Actor(HEXA_NS::Document* doc, const QString& entry);
91 virtual ~Document_Actor();
93 std::map<int,vtkIdType> vtkElemsId;
94 std::map<vtkIdType, int> hexaElemsId;
96 vtkUnstructuredGrid* getUnstructuredGrid();
98 HEXA_NS::Document* _doc;
102 class Associate_Actor : public SALOME_Actor
105 Associate_Actor(HEXA_NS::Document* doc, const QString& entry);
106 virtual ~Associate_Actor() {}
108 std::map<int,vtkIdType> vtkElemsId;
109 std::map<vtkIdType, int> hexaElemsId;
111 vtkUnstructuredGrid* getUnstructuredGrid();
113 HEXA_NS::Document* _doc;
117 /********************************************************************************
118 * VtkDocumentGraphicView
119 ********************************************************************************/
120 class VtkDocumentGraphicView : public QAbstractItemView
125 VtkDocumentGraphicView(DocumentModel* docModel, SVTK_ViewWindow* view, QWidget* parent=NULL);
126 virtual ~VtkDocumentGraphicView();
128 void setModel ( QAbstractItemModel * model );
129 bool isEmpty() const { return getDocumentModel()->isEmpty(); }
130 void highlight( const QModelIndex& ielt );
131 void highlight( const QModelIndexList& elts );
132 void highlightGroups( const QModelIndex& eltIndex );
133 void highlightPropagation( const QModelIndex& eltIndex );
135 void setSelectionMode( const Selection_Mode theMode );
136 void setSelectionMode( const QModelIndex& eltIndex );
137 int getSelectionMode() const { return selectionMode;}
138 void clearSelection();
140 void loadDocument(const QString& file); //Loads a selected document
141 void loadDocument(); //Loads the current document
142 void saveDocument(const QString& file);
143 void update();//mise à jours de la vue : reconstruction complète
146 QModelIndex indexAt(const QPoint &point) const;
147 void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
148 QRect visualRect(const QModelIndex &index) const;
150 SVTK_ViewWindow* getViewWindow() const { return viewWindow; }
151 void setViewWindow(SVTK_ViewWindow* view) { viewWindow = view; }
152 Document_Actor* getDocumentActor() const { return documentActor; }
154 DocumentModel* getDocumentModel() const {
155 return dynamic_cast<DocumentModel*>(model());
157 PatternDataSelectionModel* getPatternDataSelectionModel() const
158 { return patternDataSelectionModel; }
160 PatternBuilderSelectionModel* getPatternBuilderSelectionModel() const
161 { return patternBuilderSelectionModel; }
163 PatternGeomSelectionModel* getPatternGeomSelectionModel() const
164 { return patternGeomSelectionModel;}
166 GroupsSelectionModel* getGroupsSelectionModel() const
167 { return groupsSelectionModel; }
169 MeshSelectionModel* getMeshSelectionModel() const
170 { return meshSelectionModel; }
172 PatternDataModel* getPatternDataModel() const {return patternDataModel;}
173 PatternBuilderModel* getPatternBuilderModel() const {return patternBuilderModel;}
174 PatternGeomModel* getPatternGeomModel() const { return patternGeomModel;}
175 GroupsModel* getGroupsModel() const {return groupsModel;}
176 MeshModel* getMeshModel() const {return meshModel;}
179 void setWindowTitle(const QString& title);
180 void onPatternDatachanged();
181 void setVertexSelection();
182 void setEdgeSelection();
183 void setQuadSelection();
184 void setHexaSelection();
185 void setAllSelection();
188 virtual void closeEditor ( QWidget * editor, QAbstractItemDelegate::EndEditHint hint );
189 virtual void commitData ( QWidget * editor );
190 virtual void currentChanged ( const QModelIndex & current, const QModelIndex & previous );
191 virtual void dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight );
192 virtual void editorDestroyed ( QObject * editor );
193 virtual void rowsAboutToBeRemoved ( const QModelIndex & parent, int start, int end );
194 virtual void rowsInserted ( const QModelIndex & parent, int start, int end );
195 virtual void selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected );
196 virtual void updateGeometries ();
199 int horizontalOffset() const;
200 bool isIndexHidden(const QModelIndex &index) const;
201 QModelIndex moveCursor(QAbstractItemView::CursorAction cursorAction,
202 Qt::KeyboardModifiers modifiers);
203 void setSelection(const QRect&, QItemSelectionModel::SelectionFlags command);
204 int verticalOffset() const;
205 QRegion visualRegionForSelection(const QItemSelection &selection) const;
208 // virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 );
211 SVTK_ViewWindow* viewWindow;
215 Document_Actor* documentActor;
216 Associate_Actor* associateActor;
218 PatternDataSelectionModel* patternDataSelectionModel;
219 PatternBuilderSelectionModel* patternBuilderSelectionModel;
220 PatternGeomSelectionModel* patternGeomSelectionModel;
221 GroupsSelectionModel* groupsSelectionModel;
222 MeshSelectionModel* meshSelectionModel;
224 PatternDataModel* patternDataModel;
225 PatternBuilderModel* patternBuilderModel;
226 PatternGeomModel* patternGeomModel;
227 GroupsModel* groupsModel;
228 MeshModel* meshModel;
230 bool _currentChanged;