1 // Copyright (C) 2009-2014 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, or (at your option) any later version.
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
23 #include <vtkRenderer.h>
24 #include <vtkUnstructuredGrid.h>
25 #include <vtkDataSetMapper.h>
26 #include "vtkCellArray.h"
27 #include "vtkPolyData.h"
29 #include <VTKViewer_CellLocationsArray.h>
30 #include <SVTK_ViewModel.h>
32 #include "HEXABLOCKGUI_Trace.hxx"
33 #include "HEXABLOCKGUI_VtkDocumentGraphicView.hxx"
34 #include "HEXABLOCKGUI.hxx"
37 #define M_PI 3.1415927
41 using namespace HEXABLOCK::GUI;
42 using namespace HEXA_NS;
44 Document_Actor::Document_Actor( Document* doc, const QString& entry ):
48 DEBTRACE("Document_Actor::Document_Actor " << entry.toLatin1() );
49 const char* docName = ((doc != NULL) ? doc->getName() : "");
50 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject( entry.toLatin1(), "HEXABLOCK", docName );//,theName); CS_TODO
52 vtkUnstructuredGrid* aGrid = getUnstructuredGrid();
53 vtkDataSetMapper* aMapper = vtkDataSetMapper::New();
54 aMapper->SetInputData(aGrid); // saclay
55 // aMapper->SetInput(aGrid);
58 SetVisibility( true );//VisibilityOff();
59 SetPickable( true ); //PickableOff();//
63 vtkProperty* aProp = vtkProperty::New();
65 // aProp->SetRepresentationToSurface();
66 aProp->SetRepresentationToWireframe();
67 // aProp->SetRepresentationToPoints();
68 aProp->EdgeVisibilityOn ();
69 aProp->SetPointSize(5);
72 // SetPointRepresentation(true);
75 Document_Actor::~Document_Actor()
81 vtkUnstructuredGrid* Document_Actor::getUnstructuredGrid()
83 vtkUnstructuredGrid* theGrid = vtkUnstructuredGrid::New();
85 _doc->reorderFaces(); //CS_TEST
87 map <int,vtkIdType> vtkNodeId;
88 map <vtkIdType, int> hexaNodeId;
91 vtkPoints* aPoints = vtkPoints::New();
92 int nbVertex = _doc->countVertex();
93 aPoints->SetNumberOfPoints( nbVertex );
97 for ( int i=0; i <nbVertex; ++i ){
98 v = _doc->getVertex(i);
99 aPoints->SetPoint( i, v->getX(), v->getY(), v->getZ() );
100 vertexId = reinterpret_cast<intptr_t>(v); //v->getId();
101 vtkNodeId [ vertexId ] = i;
102 hexaNodeId[ i ] = vertexId ;
103 // vtkNodeId [ vertexId ] = i+1;
104 // hexaNodeId[ i+1 ] = vertexId ;
107 theGrid->SetPoints( aPoints );
109 // theGrid->SetCells( 0, 0, 0, 0, 0 );
112 // Calculate cells size
113 int nb0DElement = _doc->countVertex();
114 int nbEdge = _doc->countEdge();
115 int nbFace = _doc->countQuad();
116 int nbVolume = _doc->countHexa();
118 vtkIdType aCellsSize = 2*nb0DElement + 3*nbEdge + ( 4 + 1 )*nbFace + ( 8 + 1 )*nbVolume;
119 vtkIdType aNbCells = nb0DElement + nbEdge + nbFace + nbVolume;
122 vtkCellArray* aConnectivity = vtkCellArray::New();
123 aConnectivity->Allocate( aCellsSize, 0 );
125 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
126 aCellTypesArray->SetNumberOfComponents( 1 );
127 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
129 vtkIdList *anIdList = vtkIdList::New();
130 vtkIdType iVtkElem = 0;
131 // vtkIdType iVtkElem = 1; //CS_TEST
135 for ( int i=0; i<nb0DElement; ++i ){
136 anIdList->SetNumberOfIds( 1 );
137 v = _doc->getVertex(i);
138 iHexaElem = reinterpret_cast<intptr_t>(v);//v->getId();
139 vtkElemsId[iHexaElem] = iVtkElem;
140 hexaElemsId[iVtkElem] = iHexaElem;
141 anIdList->SetId(0, vtkNodeId[iHexaElem]);
142 aConnectivity->InsertNextCell( anIdList );
143 aCellTypesArray->InsertNextValue( VTK_VERTEX );//getCellType( aType, anElem->IsPoly(), aNbNodes ) );
149 Vertex* vertexElem = NULL;
150 for ( int i=0; i<nbEdge; ++i ){
151 anIdList->SetNumberOfIds( 2 );
152 e = _doc->getEdge(i);
153 iHexaElem = reinterpret_cast<intptr_t>(e); //e->getId();
154 vtkElemsId[iHexaElem] = iVtkElem;
155 hexaElemsId[iVtkElem] = iHexaElem;
157 for( vtkIdType j = 0; j< 2; ++j ){ //j< e->countVertex(); ++j ){
158 vertexElem = e->getVertex( j );
159 anIdList->SetId( j, vtkNodeId[ reinterpret_cast<intptr_t>(vertexElem) ] );//vertexElem->getId() ]);
161 aConnectivity->InsertNextCell( anIdList );
162 aCellTypesArray->InsertNextValue( VTK_LINE );//getCellType( aType, anElem->IsPoly(), aNbNodes ) );
168 for ( int i=0; i<nbFace; ++i ){
169 anIdList->SetNumberOfIds( 4 );
170 q = _doc->getQuad(i);
171 iHexaElem = reinterpret_cast<intptr_t>(q); //q->getId();
172 vtkElemsId[iHexaElem] = iVtkElem;
173 hexaElemsId[iVtkElem] = iHexaElem;
175 for( vtkIdType j = 0; j< 4; ++j ){
176 vertexElem = q->getVertex( j );
177 anIdList->SetId( j, vtkNodeId[ reinterpret_cast<intptr_t>(vertexElem) ] );//vertexElem->getId() ]);
179 aConnectivity->InsertNextCell( anIdList );
180 aCellTypesArray->InsertNextValue( VTK_QUAD );//getCellType( aType, anElem->IsPoly(), aNbNodes ) );
186 std::map<int, int> connectivity;
195 for ( int i=0; i<nbVolume; ++i ){
196 anIdList->SetNumberOfIds( 8 );
197 h = _doc->getHexa(i);
198 iHexaElem = reinterpret_cast<intptr_t>(h); //q->getId();
199 vtkElemsId[iHexaElem] = iVtkElem;
200 hexaElemsId[iVtkElem] = iHexaElem;
202 for( vtkIdType j = 0; j< 8; ++j ){
203 vertexElem = h->getVertex( j );// );
204 anIdList->SetId( connectivity[j], vtkNodeId[ reinterpret_cast<intptr_t>(vertexElem) ]);//vertexElem->getId() ]);
206 aConnectivity->InsertNextCell( anIdList );
207 aCellTypesArray->InsertNextValue( VTK_HEXAHEDRON );
213 // V_ACE, V_ACF, V_ADE, V_ADF, V_BCE, V_BCF, V_BDE, V_BDF,
217 // Insert cells in grid
218 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
219 aCellLocationsArray->SetNumberOfComponents( 1 );
220 aCellLocationsArray->SetNumberOfTuples( aNbCells );
221 // std::cout << "aNbCells =>" << aNbCells << std::endl;
223 aConnectivity->InitTraversal();
224 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ ){
225 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
227 theGrid->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
229 aCellLocationsArray->Delete();
230 aCellTypesArray->Delete();
231 aConnectivity->Delete();
233 //std::cout << "theGrid->GetNumberOfCells()" << theGrid->GetNumberOfCells() << std::endl;
238 // =============================================================== Abu : debut
239 // ===================================================== Constructeur
240 Associate_Actor::Associate_Actor( Document* doc, const QString& entry)
241 : SALOME_Actor(), _doc( doc )
243 DEBTRACE("Associate_Actor::Associate_Actor " << entry.toLatin1() );
244 const char* docName = ((doc != NULL) ? doc->getName() : "");
245 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject( entry.toLatin1(), "HEXABLOCK", docName );//,theName); CS_TODO
247 vtkUnstructuredGrid* aGrid = getUnstructuredGrid();
249 vtkDataSetMapper* aMapper = vtkDataSetMapper::New();
250 aMapper->SetInputData(aGrid); // saclay
251 // aMapper->SetInput (aGrid);
254 SetVisibility( true );//VisibilityOff();
255 SetPickable( true ); //PickableOff();//
256 SetMapper( aMapper );
259 vtkProperty* aProp = vtkProperty::New();
260 aProp->SetColor(0,255,0);
261 // aProp->SetRepresentationToSurface();
262 aProp->SetRepresentationToWireframe();
263 // aProp->SetRepresentationToPoints();
264 aProp->EdgeVisibilityOn ();
265 aProp->SetPointSize(5);
266 SetProperty( aProp );
268 // SetPointRepresentation(true);
270 // ===================================================== getUnstructuredGrid
272 vtkUnstructuredGrid* Associate_Actor::getUnstructuredGrid()
274 vtkUnstructuredGrid* theGrid = vtkUnstructuredGrid::New();
276 _doc->reorderFaces(); //CS_TEST
278 std::map<int,vtkIdType> vtkNodeId;
279 std::map<vtkIdType, int> hexaNodeId;
282 vtkPoints* aPoints = vtkPoints::New();
283 int nbVertex = _doc->countVertex();
284 aPoints->SetNumberOfPoints( nbVertex );
288 for ( int i=0; i <nbVertex; ++i ){
289 v = _doc->getVertex(i);
290 aPoints->SetPoint( i, v->getX()+6, v->getY()+6, v->getZ() );
291 vertexId = reinterpret_cast<intptr_t>(v); //v->getId();
292 vtkNodeId [ vertexId ] = i;
293 hexaNodeId[ i ] = vertexId ;
294 // vtkNodeId [ vertexId ] = i+1;
295 // hexaNodeId[ i+1 ] = vertexId ;
298 theGrid->SetPoints( aPoints );
300 // theGrid->SetCells( 0, 0, 0, 0, 0 );
302 // Calculate cells size
303 int nb0DElement = _doc->countVertex();
304 int nbEdge = _doc->countEdge();
305 int nbFace = _doc->countQuad();
306 int nbVolume = _doc->countHexa();
308 vtkIdType aCellsSize = 2*nb0DElement + 3*nbEdge + ( 4 + 1 )*nbFace + ( 8 + 1 )*nbVolume;
309 vtkIdType aNbCells = nb0DElement + nbEdge + nbFace + nbVolume;
312 vtkCellArray* aConnectivity = vtkCellArray::New();
313 aConnectivity->Allocate( aCellsSize, 0 );
315 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
316 aCellTypesArray->SetNumberOfComponents( 1 );
317 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
319 vtkIdList *anIdList = vtkIdList::New();
320 vtkIdType iVtkElem = 0;
321 // vtkIdType iVtkElem = 1; //CS_TEST
325 for ( int i=0; i<nb0DElement; ++i ){
326 anIdList->SetNumberOfIds( 1 );
327 v = _doc->getVertex(i);
328 iHexaElem = reinterpret_cast<intptr_t>(v);//v->getId();
329 vtkElemsId[iHexaElem] = iVtkElem;
330 hexaElemsId[iVtkElem] = iHexaElem;
331 anIdList->SetId(0, vtkNodeId[iHexaElem]);
332 aConnectivity->InsertNextCell( anIdList );
333 aCellTypesArray->InsertNextValue( VTK_VERTEX );//getCellType( aType, anElem->IsPoly(), aNbNodes ) );
339 Vertex* vertexElem = NULL;
340 for ( int i=0; i<nbEdge; ++i ){
341 anIdList->SetNumberOfIds( 2 );
342 e = _doc->getEdge(i);
343 iHexaElem = reinterpret_cast<intptr_t>(e); //e->getId();
344 vtkElemsId[iHexaElem] = iVtkElem;
345 hexaElemsId[iVtkElem] = iHexaElem;
347 for( vtkIdType j = 0; j< 2; ++j ){ //j< e->countVertex(); ++j ){
348 vertexElem = e->getVertex( j );
349 anIdList->SetId( j, vtkNodeId[ reinterpret_cast<intptr_t>(vertexElem) ] );//vertexElem->getId() ]);
351 aConnectivity->InsertNextCell( anIdList );
352 aCellTypesArray->InsertNextValue( VTK_LINE );//getCellType( aType, anElem->IsPoly(), aNbNodes ) );
358 for ( int i=0; i<nbFace; ++i ){
359 anIdList->SetNumberOfIds( 4 );
360 q = _doc->getQuad(i);
361 iHexaElem = reinterpret_cast<intptr_t>(q); //q->getId();
362 vtkElemsId[iHexaElem] = iVtkElem;
363 hexaElemsId[iVtkElem] = iHexaElem;
365 for( vtkIdType j = 0; j< 4; ++j ){
366 vertexElem = q->getVertex( j );
367 anIdList->SetId( j, vtkNodeId[ reinterpret_cast<intptr_t>(vertexElem) ] );//vertexElem->getId() ]);
369 aConnectivity->InsertNextCell( anIdList );
370 aCellTypesArray->InsertNextValue( VTK_QUAD );//getCellType( aType, anElem->IsPoly(), aNbNodes ) );
376 std::map<int, int> connectivity;
385 for ( int i=0; i<nbVolume; ++i ){
386 anIdList->SetNumberOfIds( 8 );
387 h = _doc->getHexa(i);
388 iHexaElem = reinterpret_cast<intptr_t>(h); //q->getId();
389 vtkElemsId[iHexaElem] = iVtkElem;
390 hexaElemsId[iVtkElem] = iHexaElem;
392 for( vtkIdType j = 0; j< 8; ++j ){
393 vertexElem = h->getVertex( j );// );
394 anIdList->SetId( connectivity[j], vtkNodeId[ reinterpret_cast<intptr_t>(vertexElem) ]);//vertexElem->getId() ]);
396 aConnectivity->InsertNextCell( anIdList );
397 aCellTypesArray->InsertNextValue( VTK_HEXAHEDRON );
403 // V_ACE, V_ACF, V_ADE, V_ADF, V_BCE, V_BCF, V_BDE, V_BDF,
407 // Insert cells in grid
408 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
409 aCellLocationsArray->SetNumberOfComponents( 1 );
410 aCellLocationsArray->SetNumberOfTuples( aNbCells );
411 // std::cout << "aNbCells =>" << aNbCells << std::endl;
413 aConnectivity->InitTraversal();
414 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ ){
415 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
417 theGrid->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
419 aCellLocationsArray->Delete();
420 aCellTypesArray->Delete();
421 aConnectivity->Delete();
428 // -----------------------------------------------------------------------
429 // VtkDocumentGraphicView implementation
430 // -----------------------------------------------------------------------
431 VtkDocumentGraphicView::VtkDocumentGraphicView( DocumentModel* documentModel,
432 SVTK_ViewWindow* view, QWidget* parent ):
433 QAbstractItemView(parent),
435 documentActor( NULL ),
436 associateActor (NULL), // Abu
437 _currentChanged( false ),
443 setModel(documentModel);
444 patternDataModel = new PatternDataModel(parent);
445 patternGeomModel = new PatternGeomModel(parent);
446 groupsModel = new GroupsModel(parent);
447 meshModel = new MeshModel(parent);
449 patternDataModel->setSourceModel(documentModel);
450 patternGeomModel->setSourceModel(documentModel);
451 groupsModel->setSourceModel(documentModel);
452 meshModel->setSourceModel(documentModel);
455 patternDataSelectionModel = new PatternDataSelectionModel(patternDataModel);
456 patternGeomSelectionModel = new PatternGeomSelectionModel(patternGeomModel);
457 groupsSelectionModel = new GroupsSelectionModel(groupsModel);
458 meshSelectionModel = new MeshSelectionModel(meshModel );
460 setSelectionModel(patternDataSelectionModel);
463 //Loads the graphic view document
464 void VtkDocumentGraphicView::loadDocument()
466 DocumentModel* docModel = getDocumentModel();
467 if (docModel == NULL) return;
472 //Loads the document from the file in this graphic view
473 void VtkDocumentGraphicView::loadDocument(const QString& file)
475 if ( file.isEmpty() ) return;
476 getDocumentModel()->load(file);
479 //Saves the graphic view's document in the file
480 void VtkDocumentGraphicView::saveDocument(const QString& file)
482 if (file.isEmpty()) return;
483 getDocumentModel()->save(file);
487 VtkDocumentGraphicView::~VtkDocumentGraphicView()
491 delete patternDataModel;
495 //Delete Selection Model/ Disconnect signals on delete (Qt)
496 // delete patternDataSelectionModel;
497 // delete groupsSelectionModel;
498 // delete meshSelectionModel;
501 void VtkDocumentGraphicView::setWindowTitle(const QString& title)
503 viewWindow->setWindowTitle( QString("hexablock : ") + title );
506 void VtkDocumentGraphicView::onPatternDatachanged()
511 void VtkDocumentGraphicView::removeActor()
513 if ( documentActor != NULL && viewWindow != NULL){
514 viewWindow->RemoveActor( documentActor );
515 documentActor->Delete();
519 void VtkDocumentGraphicView::update()
521 DocumentModel* theModel = dynamic_cast<DocumentModel*>( model() );
522 if (theModel == NULL || viewWindow == NULL) return;
524 Document* theDocumentImpl = theModel->documentImpl();
525 QString theDocumentEntry = theModel->documentEntry();
527 if ( documentActor ){
528 viewWindow->RemoveActor( documentActor );
529 documentActor->Delete();
531 documentActor = new Document_Actor( theDocumentImpl, theDocumentEntry );
532 viewWindow->AddActor( documentActor );
534 viewWindow->getRenderer()->Render();
535 viewWindow->Repaint();
538 viewWindow->onFitAll();
543 void VtkDocumentGraphicView::setVertexSelection()
545 setSelectionMode(NodeSelection);
548 void VtkDocumentGraphicView::setEdgeSelection()
550 setSelectionMode(EdgeSelection);
553 void VtkDocumentGraphicView::setQuadSelection()
555 setSelectionMode(FaceSelection);
558 void VtkDocumentGraphicView::setHexaSelection()
560 // SetSelectionMode(VolumeSelection);
561 setSelectionMode(FaceSelection); //temporary for hexa selection debug
562 selectionMode = HEXA_TREE;
563 // aProp->FaceVisibilityOff (); //would debug hexa preselection, selection???
566 void VtkDocumentGraphicView::setAllSelection()
568 setSelectionMode(ActorSelection);
572 void VtkDocumentGraphicView::setSelectionMode(Selection_Mode theMode)
574 if (viewWindow == NULL || selectionMode == theMode)
577 HEXABLOCKGUI::selectionMgr()->clearSelected();
578 viewWindow->SetSelectionMode( theMode );
579 selectionMode = theMode;
582 void VtkDocumentGraphicView::setSelectionMode( const QModelIndex& eltIndex )
584 QVariant treeVariant = eltIndex.data( HEXA_TREE_ROLE );
585 if ( !treeVariant.isValid() ) return;
586 int eltType = treeVariant.toInt();
588 if ( selectionMode == eltType ) return;
593 case GEOMPOINT_DIR_TREE:
594 case VERTEX_DIR_TREE : setVertexSelection(); break;
597 case GEOMEDGE_DIR_TREE:
598 case EDGE_DIR_TREE : setEdgeSelection(); break;
601 case GEOMFACE_DIR_TREE:
602 case QUAD_DIR_TREE : setQuadSelection(); break;
605 case GEOMSHAPE_DIR_TREE:
606 case HEXA_DIR_TREE : setHexaSelection(); break;
607 case PROPAGATION_TREE :
608 case PROPAGATION_DIR_TREE : setEdgeSelection(); break;
609 default: setAllSelection();
613 void VtkDocumentGraphicView::getSelected(SALOME_ListIO& selectedObjects)
615 HEXABLOCKGUI::selectionMgr()->selectedObjects( selectedObjects, SVTK_Viewer::Type());
618 void VtkDocumentGraphicView::clearSelection()
620 if (viewWindow != NULL)
622 // viewWindow->unHighlightAll();
623 setSelectionMode(ActorSelection);
627 void VtkDocumentGraphicView::highlight( const QModelIndex& ielt )
630 QModelIndexList indexList;
632 highlight(indexList);
636 void VtkDocumentGraphicView::highlight( const QModelIndexList& elts )
639 if (elts.size() == 0 || viewWindow == NULL || documentActor == NULL)
641 SVTK_Selector* selector = viewWindow->GetSelector();
642 if ( selector == NULL )
644 // Set selection mode in VTK view
645 // viewWindow->SetSelectionMode(VolumeSelection);
647 // --- elements highlight ---
648 TColStd_IndexedMapOfInteger aMap;
652 foreach( const QModelIndex& iElt, elts ){
655 eltEntry = iElt.data( HEXA_ENTRY_ROLE ).toString();
656 vtkElemsId = documentActor->vtkElemsId[ eltEntry.toInt() ];
657 if ( vtkElemsId > 0 )
658 aMap.Add( vtkElemsId );
661 selector->AddOrRemoveIndex( documentActor->getIO(), aMap, false );
662 viewWindow->highlight( documentActor->getIO(), true, true );
666 void VtkDocumentGraphicView::highlightGroups( const QModelIndex& eltIndex )
668 if ( groupsModel == NULL || viewWindow == NULL || documentActor == NULL) return;
669 SVTK_Selector* selector = viewWindow->GetSelector();
670 if ( selector == NULL ) return;
672 QVariant treeVariant = eltIndex.data( HEXA_TREE_ROLE );
673 if ( !treeVariant.isValid())
676 int eltType = treeVariant.toInt();
677 if ( eltType != GROUP_TREE )
680 //Get elements to highlight
681 DocumentModel::Group kind;
682 QModelIndexList iElements = groupsModel->getGroupElements( eltIndex, kind );
683 if (iElements.count() == 0) return;
685 // ---------- elements highlight --------------
687 // Set selection mode in VTK view
689 case HexaCell: case HexaNode: viewWindow->SetSelectionMode(VolumeSelection); break;
690 case QuadCell: case QuadNode: viewWindow->SetSelectionMode(FaceSelection); break;
691 case EdgeCell: case EdgeNode: viewWindow->SetSelectionMode(EdgeSelection); break;
692 case VertexNode: viewWindow->SetSelectionMode(NodeSelection); break;
695 TColStd_MapOfInteger aMap;
699 foreach( const QModelIndex& iElt, iElements ){
702 eltEntry = iElt.data( HEXA_ENTRY_ROLE ).toString();
703 vtkElemsId = documentActor->vtkElemsId[ eltEntry.toInt() ];
704 if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId );
708 selector->AddOrRemoveIndex( documentActor->getIO(), aMap, false );
709 viewWindow->highlight( documentActor->getIO(), true, true );
710 documentActor->highlight( false );
715 void VtkDocumentGraphicView::highlightPropagation( const QModelIndex& eltIndex )
717 if ( meshModel == NULL || viewWindow == NULL || documentActor == NULL) return;
718 SVTK_Selector* selector = viewWindow->GetSelector();
719 if ( selector == NULL ) return;
721 QVariant treeVariant = eltIndex.data( HEXA_TREE_ROLE );
722 if ( !treeVariant.isValid())
725 int eltType = treeVariant.toInt();
726 if ( eltType != PROPAGATION_TREE )
729 // Get elements to highlight
730 QModelIndexList iEdges = meshModel->getPropagation( eltIndex );
731 if (iEdges.count() == 0) return;
733 // ---------- elements highlight --------------
735 // Set selection mode in VTK view
736 viewWindow->SetSelectionMode(EdgeSelection);
738 TColStd_MapOfInteger aMap;
742 foreach( const QModelIndex& iEdge, iEdges ){
745 edgeEntry = iEdge.data( HEXA_ENTRY_ROLE ).toString();
746 vtkElemsId = documentActor->vtkElemsId[ edgeEntry.toInt() ];
747 if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId );
751 selector->AddOrRemoveIndex( documentActor->getIO(), aMap, false );
752 viewWindow->highlight( documentActor->getIO(), true, true );
753 documentActor->highlight( false );
760 /********************************************************************************
761 * ABSTRACT METHOD ( MUST BE IMPLEMENTED )
762 ********************************************************************************/
764 Returns the item that covers the coordinate given in the view.
766 QModelIndex VtkDocumentGraphicView::indexAt(const QPoint &point) const
768 return QModelIndex();
771 void VtkDocumentGraphicView::scrollTo(const QModelIndex &index, ScrollHint)
776 Returns the position of the item in viewport coordinates.
778 QRect VtkDocumentGraphicView::visualRect(const QModelIndex &index) const
784 int VtkDocumentGraphicView::horizontalOffset() const
786 return horizontalScrollBar()->value();
789 bool VtkDocumentGraphicView::isIndexHidden(const QModelIndex &index) const
794 QModelIndex VtkDocumentGraphicView::moveCursor(QAbstractItemView::CursorAction cursorAction,
795 Qt::KeyboardModifiers /*modifiers*/)
797 QModelIndex current = currentIndex();
802 Find the indices corresponding to the extent of the selection.
804 void VtkDocumentGraphicView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command)
809 int VtkDocumentGraphicView::verticalOffset() const
811 return verticalScrollBar()->value();
815 Returns a region corresponding to the selection in viewport coordinates.
817 QRegion VtkDocumentGraphicView::visualRegionForSelection(const QItemSelection &selection) const
823 /********************************************************************************
825 ********************************************************************************/
826 void VtkDocumentGraphicView::closeEditor ( QWidget * editor, QAbstractItemDelegate::EndEditHint hint )
830 void VtkDocumentGraphicView::commitData ( QWidget * editor )
834 void VtkDocumentGraphicView::currentChanged( const QModelIndex & current, const QModelIndex & previous )
836 _currentChanged = true;
839 void VtkDocumentGraphicView::dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight )
842 _currentChanged = false;
845 void VtkDocumentGraphicView::editorDestroyed ( QObject * editor )
849 void VtkDocumentGraphicView::rowsAboutToBeRemoved ( const QModelIndex & parent, int start, int end )
853 void VtkDocumentGraphicView::rowsInserted ( const QModelIndex & parent, int start, int end )
857 void VtkDocumentGraphicView::selectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
861 void VtkDocumentGraphicView::updateGeometries ()
866 void VtkDocumentGraphicView::setModel ( QAbstractItemModel * model )
868 QAbstractItemView::setModel( model );
870 // PatternDataModel* pdm = dynamic_cast<PatternDataModel*>(model);
872 // connect( pdm, SIGNAL(patternDataChanged() ), this, SLOT ( onPatternDatachanged() ) );
874 DocumentModel* dm = dynamic_cast<DocumentModel*>(model);
876 // setWindowTitle( dm->getName() );
877 connect( dm, SIGNAL(patternDataChanged() ), this, SLOT ( onPatternDatachanged() ) );
878 // connect( dm, SIGNAL( nameChanged(const QString&) ), this, SLOT ( setWindowTitle(const QString&) ) );