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
24 #include "utilities.h"
26 #include <QtxWorkstack.h>
27 #include <STD_TabDesktop.h>
28 #include <STD_MDIDesktop.h>
29 #include <STD_SDIDesktop.h>
31 #include <SalomeApp_Tools.h>
33 #include "SOCC_ViewModel.h"
34 #include <OCCViewer_ViewManager.h>
35 #include <OCCViewer_ViewModel.h>
36 #include <OCCViewer_ViewWindow.h>
38 #include <SUIT_OverrideCursor.h>
39 #include <SUIT_MessageBox.h>
40 #include <SUIT_Session.h>
41 #include <SUIT_Selector.h>
42 #include <SUIT_Desktop.h>
43 #include <SUIT_ViewManager.h>
44 #include <SVTK_View.h>
46 #include "HEXABLOCKGUI_VtkDocumentGraphicView.hxx"
47 #include "HEXABLOCKGUI_OccGraphicView.hxx"
48 #include "HEXABLOCKGUI_SalomeTools.hxx"
49 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
50 #include "HEXABLOCKGUI_DocumentItem.hxx"
51 #include "HEXABLOCKGUI.hxx"
54 #include <SVTK_Selector.h>
55 #include <SVTK_ViewModel.h>
58 #include <SalomeApp_Study.h>
59 #include <SalomeApp_Application.h>
60 #include <SALOME_Actor.h>
61 #include <SALOME_ListIO.hxx>
62 #include <SALOME_ListIteratorOfListIO.hxx>
63 #include <AIS_ListIteratorOfListOfInteractive.hxx>
67 #include <OCCViewer_ViewModel.h>
68 #include <SVTK_ViewModel.h>
69 #include <SalomeApp_Study.h>
70 #include <SalomeApp_Application.h>
71 #include <LightApp_SelectionMgr.h>
72 #include <SALOME_ListIteratorOfListIO.hxx>
74 #include <TopExp_Explorer.hxx>
75 #include <TopoDS_Iterator.hxx>
76 #include <TopTools_MapOfShape.hxx>
77 #include <TopTools_IndexedMapOfShape.hxx>
78 #include <TColStd_IndexedMapOfInteger.hxx>
83 using namespace HEXABLOCK::GUI;
86 // //===========================================================================
88 // //===========================================================================
90 bool SelectionModel::infoMode = true;
92 SelectionModel::SelectionModel( QAbstractItemModel * model ):
93 QItemSelectionModel( model )
98 SelectionModel::~SelectionModel()
100 disconnect( HEXABLOCKGUI::selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( salomeSelectionChanged() ) );
104 QModelIndex SelectionModel::indexBy( int role, const QString& value )
106 QModelIndex eltIndex; // element (vertex, edge, quad) of model
107 const QAbstractItemModel* theModel = model();
108 if ( !theModel ) return eltIndex;
109 QModelIndexList theIndexes = theModel->match( theModel->index(0, 0),
113 Qt::MatchRecursive | Qt::MatchContains );//Qt::MatchFixedString );
114 if ( theIndexes.count()>0 )
115 eltIndex = theIndexes[0] ;
120 QModelIndex SelectionModel::indexBy( int role, const QVariant& var )
122 QModelIndex eltIndex; // element (vertex, edge, quad) of model
123 const QAbstractItemModel* theModel = model();
124 if ( !theModel ) return eltIndex;
125 QModelIndexList theIndexes = theModel->match( theModel->index(0, 0),
129 Qt::MatchRecursive /*| Qt::MatchContains*/ );//Qt::MatchFixedString );
130 if ( theIndexes.count()>0 )
131 eltIndex = theIndexes[0] ;
135 QModelIndex SelectionModel::indexOf( const QString& anEntry, int role )
137 QModelIndex eltIndex; // element (vertex, edge, quad) of model
138 const QAbstractItemModel* theModel = model();
139 if ( !theModel ) return eltIndex;
141 QModelIndexList theIndexes = theModel->match( theModel->index(0, 0),
145 Qt::MatchRecursive | Qt::MatchContains );//Qt::MatchFixedString );
146 if ( theIndexes.count()>0 )
147 eltIndex = theIndexes[0] ;
152 QModelIndexList SelectionModel::indexListOf( const QString& anEntry, int role )
154 QModelIndexList theIndexes; // element (vertex, edge, quad) of model
155 const QAbstractItemModel* theModel = model();
156 if ( !theModel ) return theIndexes;
157 theIndexes = theModel->match( theModel->index(0, 0),
161 Qt::MatchRecursive | Qt::MatchContains );//Qt::MatchFixedString );
165 DocumentModel* SelectionModel::getDocModel() const
167 DocumentModel* docModel = NULL;
168 const QSortFilterProxyModel *pModel = dynamic_cast<const QSortFilterProxyModel *>( model() );
170 docModel = dynamic_cast<DocumentModel*>( pModel->sourceModel() );
175 void SelectionModel::showEltInfo(QModelIndex& elt)
177 DocumentModel* docModel = getDocModel();
178 if (!elt.isValid() || docModel == NULL)
181 HEXA_NS::Vertex* vertex = docModel->getHexaPtr<HEXA_NS::Vertex*>(elt);
182 HEXA_NS::Edge* edge = docModel->getHexaPtr<HEXA_NS::Edge*>(elt);
183 HEXA_NS::Quad* quad = docModel->getHexaPtr<HEXA_NS::Quad*>(elt);
184 HEXA_NS::Hexa* hexa = docModel->getHexaPtr<HEXA_NS::Hexa*>(elt);
185 HEXA_NS::Vector* vector = docModel->getHexaPtr<HEXA_NS::Vector*>(elt);
186 HEXA_NS::Group* group = docModel->getHexaPtr<HEXA_NS::Group*>(elt);
187 HEXA_NS::Law* law = docModel->getHexaPtr<HEXA_NS::Law*>(elt);
188 HEXA_NS::Propagation* propagation = docModel->getHexaPtr<HEXA_NS::Propagation*>(elt);
190 HEXABLOCKGUI* hexagui = HEXABLOCKGUI::getInstance();
192 hexagui->showVertexInfoDialog(vertex);
193 else if (edge != NULL)
194 hexagui->showEdgeInfoDialog(edge);
195 else if (quad != NULL)
196 hexagui->showQuadInfoDialog(quad);
197 else if (hexa != NULL)
198 hexagui->showHexaInfoDialog(hexa);
199 else if (vector != NULL)
200 hexagui->showVectorInfoDialog(vector);
201 else if (group != NULL)
202 hexagui->showGroupInfoDialog(group);
203 else if (law != NULL)
204 hexagui->showLawInfoDialog(law);
205 else if (propagation != NULL)
206 hexagui->showPropagationInfoDialog(propagation);
209 void SelectionModel::salomeSelectionChanged()
211 // clear highlights and selections in the trees
212 PatternDataSelectionModel* pdsm = HEXABLOCKGUI::currentDocGView->getPatternDataSelectionModel();
213 // PatternBuilderSelectionModel* pbsm = HEXABLOCKGUI::currentDocGView->getPatternBuilderSelectionModel();
214 PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
215 pdsm->clearSelection();
216 // pbsm->clearSelection();
217 pgsm->clearSelection();
218 pdsm->unhighlightTreeItems();
219 pgsm->unhighlightTreeItems();
222 SALOME_ListIO selectedObjects;
223 Handle(SALOME_InteractiveObject) anIObject;
225 switch (HEXABLOCKGUI::getActiveViewType())
227 case HEXABLOCKGUI::VTK:
229 HEXABLOCKGUI::currentDocGView->getSelected(selectedObjects);
230 if ( selectedObjects.IsEmpty() )
232 anIObject = selectedObjects.First();
233 vtkSelectionChanged( anIObject );
236 case HEXABLOCKGUI::OCC:
237 HEXABLOCKGUI::currentOccGView->getSelected(selectedObjects);
238 if ( selectedObjects.IsEmpty() )
240 anIObject = selectedObjects.First();
241 geomSelectionChanged( anIObject );
245 MESSAGE("* Unknown selection exception!");
250 QModelIndexList SelectionModel::getSelectionFromModel(const Handle(SALOME_InteractiveObject)& anIObject)
252 QModelIndexList selectedIndexes;
254 //verify if the IOBject is valid and from VTK selection
255 bool fromVTK = ( strcmp("HEXABLOCK", anIObject->getComponentDataType()) == 0 );
256 if ( !fromVTK || !anIObject->hasEntry() || HEXABLOCKGUI::currentDocGView->getViewWindow() == NULL)
257 return selectedIndexes;
259 QString anIOEntry = anIObject->getEntry();
263 //extract vtk selection from the model -----------
264 if ( GetNameOfSelectedElements( HEXABLOCKGUI::currentDocGView->getViewWindow(), anIObject, aText ) <= 0 )
265 return selectedIndexes;
267 Document_Actor* docActor = dynamic_cast<Document_Actor*>( findActorByEntry( HEXABLOCKGUI::currentDocGView->getViewWindow(),
268 anIOEntry.toLatin1() ) );
269 if ( !docActor ) return selectedIndexes;
270 QStringList idList = aText.split(" ");
271 foreach( const QString& id, idList )
275 //find selection in the model
276 anhexaElemsId = docActor->hexaElemsId[ id.toInt() ];
277 anIOEntry = QString::number( anhexaElemsId );
279 selectedIndexes << indexOf( anIOEntry, HEXA_ENTRY_ROLE );
282 return selectedIndexes;
285 // //===========================================================================
286 // PatternDataSelectionModel
287 // //===========================================================================
289 PatternDataSelectionModel::PatternDataSelectionModel( QAbstractItemModel * model ):
290 SelectionModel( model )
292 connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
293 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ), Qt::UniqueConnection );
294 connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
295 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ), Qt::UniqueConnection );
299 PatternDataSelectionModel::~PatternDataSelectionModel()
301 disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
302 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
303 disconnect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
304 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
308 void PatternDataSelectionModel::onCurrentChanged( const QModelIndex & current, const QModelIndex & previous )
310 //Setting the selection mode of the selected item from the treeview
311 HEXABLOCKGUI::currentDocGView->setSelectionMode( current );
312 HEXABLOCKGUI::currentOccGView->setSelectionMode( current );
315 void PatternDataSelectionModel::highlightTreeItems(QModelIndexList& indexes,
316 Qt::GlobalColor bgColor,
317 Qt::GlobalColor fgColor, bool only)
319 if (indexes.count() == 0)
323 unhighlightTreeItems();
326 QAbstractItemModel* theModel = (QAbstractItemModel*) model();
327 foreach( const QModelIndex& anItemIndex, indexes )
329 if (anItemIndex.isValid())
331 theModel->setData(anItemIndex, fgColor, Qt::ForegroundRole);
332 theModel->setData(anItemIndex, bgColor, Qt::BackgroundRole);
333 currentHighlightedItems << anItemIndex;
337 // * scroll to the first highlighted item in the tree
338 HEXABLOCKGUI* module = HEXABLOCKGUI::getInstance();
339 if (module != NULL && indexes[0].isValid())
340 module->getPatternDataTreeView()->scrollTo(indexes[0]);
343 void PatternDataSelectionModel::unhighlightTreeItems(bool clearSelected)
347 if (currentHighlightedItems.count() == 0)
350 QAbstractItemModel* theModel = (QAbstractItemModel*) model();
351 foreach( const QModelIndex& anItemIndex, currentHighlightedItems)
353 if (anItemIndex.isValid())
355 theModel->setData(anItemIndex, Qt::darkGreen, Qt::ForegroundRole);
356 theModel->setData(anItemIndex, Qt::white, Qt::BackgroundRole);
359 currentHighlightedItems.clear();
362 QModelIndexList PatternDataSelectionModel::getGeomAssociations(const QModelIndex& dataIndex)
364 QModelIndexList geomIndexList;
365 DocumentModel* docModel = getDocModel();
366 PatternGeomSelectionModel* pGSModel = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
367 if (docModel == NULL || pGSModel == NULL)
368 return geomIndexList;
370 const QSortFilterProxyModel *pModel = dynamic_cast<const QSortFilterProxyModel *>( model() );
371 HEXA_NS::Vertex* vertex = docModel->getHexaPtr<HEXA_NS::Vertex*>(dataIndex);
372 HEXA_NS::Edge* edge = docModel->getHexaPtr<HEXA_NS::Edge*>(dataIndex);
373 HEXA_NS::Quad* quad = docModel->getHexaPtr<HEXA_NS::Quad*>(dataIndex);
374 QModelIndex index = pModel->mapToSource(dataIndex);
377 geomIndexList << docModel->getVertexAssociation( index );
378 else if (edge != NULL)
379 geomIndexList = docModel->getEdgeAssociations( index );
380 else if ( quad != NULL)
381 geomIndexList = docModel->getQuadAssociations( index );
383 return geomIndexList;
386 void PatternDataSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
388 QModelIndexList indexes = selected.indexes();
389 int nbSelected = indexes.count();
393 // ** unhighlight current highlighted items in the trees
394 PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
397 unhighlightTreeItems(false);
399 QModelIndexList associatedGeomIndexes = getGeomAssociations(indexes[0]); //Mono Selection
400 if (associatedGeomIndexes.count() == 0)
401 pgsm->unhighlightTreeItems();
403 // ** highlight association in geometry tree
404 pgsm->highlightTreeItems(associatedGeomIndexes);
406 // ** highlight association in the vtk view
407 HEXABLOCKGUI::currentDocGView->highlight(indexes);
409 // ** highlight association in the occ view
410 HEXABLOCKGUI::currentOccGView->highlight(indexes);
412 if (!infoMode || nbSelected > 1)
415 // ** Show informations of the selected element
416 QModelIndex elt = indexes[0];
420 void PatternDataSelectionModel::geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject )
422 // if (HEXABLOCKGUI::assocInProgress) return;
424 PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel();
425 if (pgsm == NULL) return;
427 QModelIndex geomModelIndex = pgsm->getModelIndex(anIObject);
428 if (!geomModelIndex.isValid())
430 pgsm->select( geomModelIndex, QItemSelectionModel::SelectCurrent );
434 void PatternDataSelectionModel::vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject )
436 QModelIndexList selectedIndexes = getSelectionFromModel(anIObject);
437 if (selectedIndexes.count() == 0)
442 QModelIndex anIOIndex = selectedIndexes[0]; //Monoselection
444 //Temporary Debug for hexa selection ------------------------------
445 if (HEXABLOCKGUI::currentDocGView->getSelectionMode() == HEXA_TREE)
447 DocumentModel* docModel = getDocModel();
448 if ( docModel != NULL && anIOIndex.isValid())
450 //get the selected quad
451 HEXA_NS::Quad* quad = docModel->getHexaPtr<HEXA_NS::Quad*>(anIOIndex);
455 //get the hexa the quad belongs to
456 HEXA_NS::Hexa* hexa = docModel->getQuadHexa(quad);
457 if (hexa != NULL) //convert the hexa to a QModelIndex so we can select it in the model
458 anIOIndex = indexBy( HEXA_DATA_ROLE, QVariant::fromValue(hexa));
461 SUIT_MessageBox::critical( 0,
463 tr("The Hexahedron this quad belongs to has been deleted!"));
468 }//end if HEXA_TREE-----------------------------------------------
470 //select the element in the model
471 select( anIOIndex, QItemSelectionModel::SelectCurrent );
474 // //===========================================================================
475 // PatternGeomSelectionModel
476 // //===========================================================================
478 PatternGeomSelectionModel::PatternGeomSelectionModel( QAbstractItemModel * model ):
479 SelectionModel( model )
481 connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
482 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
483 connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
484 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ), Qt::UniqueConnection );
487 PatternGeomSelectionModel::~PatternGeomSelectionModel()
489 disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
490 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
491 disconnect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
492 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
495 void PatternGeomSelectionModel::onCurrentChanged( const QModelIndex & current, const QModelIndex & previous )
497 //Setting the selection mode of the selected item from the treeview}
498 HEXABLOCKGUI::currentDocGView->setSelectionMode( current );
499 HEXABLOCKGUI::currentOccGView->setSelectionMode( current );
502 void PatternGeomSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
504 DocumentModel* docModel = NULL;
505 const QSortFilterProxyModel *pModel = dynamic_cast<const QSortFilterProxyModel *>( model() );
507 docModel = dynamic_cast<DocumentModel*>(pModel->sourceModel());
509 QModelIndexList indexes = selected.indexes();
510 if (indexes.count() == 0 || docModel == NULL)
513 // ** unhighlight current highlighted items in the trees
514 PatternDataSelectionModel* pdsm = HEXABLOCKGUI::currentDocGView->getPatternDataSelectionModel();
517 unhighlightTreeItems(false);
519 //find the corresponding element in the model
520 HEXA_NS::SubShape* eltSubShape = dynamic_cast<HEXA_NS::SubShape*>(docModel->getHexaPtr(indexes[0]));
521 if (eltSubShape == NULL) return;
523 HEXA_NS::NewShape* subShapeParent = eltSubShape->getParentShape();
524 if (subShapeParent == NULL) return;
526 QString parentShapeName = subShapeParent->getName();
527 QString subId = QString::number(eltSubShape->getIdent());
528 QString aGeomObjModelEntry = parentShapeName + "," + subId + ";";
530 QModelIndexList assocsIndexes = pdsm->indexListOf(aGeomObjModelEntry, HEXA_ASSOC_ENTRY_ROLE);
531 if (assocsIndexes.count() == 0)
532 pdsm->unhighlightTreeItems();
534 // ** highlight associations in the data tree
535 pdsm->highlightTreeItems(assocsIndexes);
537 // ** highlight associations in the vtk view
538 HEXABLOCKGUI::currentDocGView->highlight(assocsIndexes);
540 // ** highlight the selected element in the occ view
541 QMultiMap<QString, int> entrySubIDs;
542 entrySubIDs.insert(parentShapeName, eltSubShape->getIdent());
543 HEXABLOCKGUI::currentOccGView->highlight(entrySubIDs);
546 QModelIndex PatternGeomSelectionModel::getModelIndex(const Handle(SALOME_InteractiveObject)& anIObject)
549 DocumentModel *docModel = NULL;
550 const QSortFilterProxyModel *pModel = dynamic_cast<const QSortFilterProxyModel *>( model() );
552 docModel = dynamic_cast<DocumentModel*>( pModel->sourceModel());
554 if ( docModel == NULL || HEXABLOCKGUI::selectionMgr() == NULL ||
555 HEXABLOCKGUI::currentOccGView->getViewWindow() == NULL)
558 //extract associated elements in the model
559 TColStd_IndexedMapOfInteger anIndexes;
560 HEXABLOCKGUI::selectionMgr()->GetIndexes(anIObject, anIndexes);
561 if (anIndexes.Extent() == 0) return result;
562 QString aGeomObjStudyEntry = anIObject->getEntry();
563 QString aGeomObjModelEntry = docModel->getGeomObjName(aGeomObjStudyEntry) + "," + QString::number(anIndexes(1));
565 HEXA_NS::SubShape* ssh = docModel->getGeomPtr(aGeomObjModelEntry);
566 HEXA_NS::VertexShape* vSh = dynamic_cast<HEXA_NS::VertexShape*>(ssh);
567 HEXA_NS::EdgeShape* eSh = dynamic_cast<HEXA_NS::EdgeShape*>(ssh);
568 HEXA_NS::FaceShape* fSh = dynamic_cast<HEXA_NS::FaceShape*>(ssh);
571 result = indexBy( HEXA_DATA_ROLE, QVariant::fromValue(vSh));
572 else if (eSh != NULL)
573 result = indexBy( HEXA_DATA_ROLE, QVariant::fromValue(eSh));
574 else if (fSh != NULL)
575 result = indexBy( HEXA_DATA_ROLE, QVariant::fromValue(fSh));
580 void PatternGeomSelectionModel::highlightTreeItems(QModelIndexList& indexes,
581 Qt::GlobalColor bgColor,
582 Qt::GlobalColor fgColor, bool only)
584 if (indexes.count() == 0)
588 unhighlightTreeItems();
591 QAbstractItemModel* theModel = (QAbstractItemModel*) model();
592 foreach( const QModelIndex& anItemIndex, indexes )
594 if (anItemIndex.isValid())
596 theModel->setData(anItemIndex, fgColor, Qt::ForegroundRole);
597 theModel->setData(anItemIndex, bgColor, Qt::BackgroundRole);
598 currentHighlightedItems << anItemIndex;
602 // * scroll to the first highlighted item in the tree
603 HEXABLOCKGUI* module = HEXABLOCKGUI::getInstance();
604 if (module != NULL && indexes[0].isValid())
605 module->getPatternGeomTreeView()->scrollTo(indexes[0]);
608 void PatternGeomSelectionModel::unhighlightTreeItems(bool clearSelected)
612 if (currentHighlightedItems.count() == 0)
614 QAbstractItemModel* theModel = (QAbstractItemModel*) model();
615 foreach( const QModelIndex& anItemIndex, currentHighlightedItems)
617 if (anItemIndex.isValid())
619 theModel->setData(anItemIndex, Qt::darkGreen, Qt::ForegroundRole);
620 theModel->setData(anItemIndex, Qt::white, Qt::BackgroundRole);
623 currentHighlightedItems.clear();
626 // //===========================================================================
627 // GroupsSelectionModel
628 // //===========================================================================
629 GroupsSelectionModel::GroupsSelectionModel( QAbstractItemModel * model ):
630 SelectionModel( model )
632 connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
633 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ), Qt::UniqueConnection );
634 connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
635 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ), Qt::UniqueConnection );
638 GroupsSelectionModel::~GroupsSelectionModel()
640 disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
641 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
642 disconnect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
643 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
646 void GroupsSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
648 QModelIndexList indexes = selected.indexes();
649 int nbSelected = indexes.count();
653 // ** Highlight the group in the vtk view **/
655 for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){
656 HEXABLOCKGUI::currentDocGView->highlightGroups( *i_index );
659 MESSAGE("Unknown exception was cought !!!");
662 if (!infoMode || nbSelected > 1)
665 // ** Show informations of the selected element **/
666 QModelIndex elt = indexes[0];
670 // //===========================================================================
671 // MeshSelectionModel
672 // //===========================================================================
673 MeshSelectionModel::MeshSelectionModel( QAbstractItemModel * model ):
674 SelectionModel( model )
676 connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
677 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ), Qt::UniqueConnection );
678 connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
679 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ), Qt::UniqueConnection );
682 MeshSelectionModel::~MeshSelectionModel()
684 disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
685 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
686 disconnect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
687 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
691 void MeshSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
693 QModelIndexList indexes = selected.indexes();
694 int nbSelected = indexes.count();
699 for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){
700 HEXABLOCKGUI::currentDocGView->highlightPropagation( *i_index );
703 MESSAGE("Unknown exception was cought !!!");
706 if (!infoMode || nbSelected > 1)
709 // ** Show informations of the selected element **/
710 QModelIndex elt = indexes[0];