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
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>
46 #include "HEXABLOCKGUI_SalomeTools.hxx"
47 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
48 #include "HEXABLOCKGUI_DocumentModel.hxx"
49 #include "HEXABLOCKGUI_DocumentGraphicView.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>
67 #include "MyGEOMBase_Helper.hxx"
69 #include <OCCViewer_ViewModel.h>
70 #include <SVTK_ViewModel.h>
71 #include <SalomeApp_Study.h>
72 #include <SalomeApp_Application.h>
73 #include <LightApp_SelectionMgr.h>
74 #include <SALOME_ListIteratorOfListIO.hxx>
76 #include <TopExp_Explorer.hxx>
77 #include <TopoDS_Iterator.hxx>
78 #include <TopTools_MapOfShape.hxx>
79 #include <TopTools_IndexedMapOfShape.hxx>
80 #include <TColStd_IndexedMapOfInteger.hxx>
85 using namespace HEXABLOCK::GUI;
89 PatternDataSelectionModel::PatternDataSelectionModel( QAbstractItemModel * model ):
90 QItemSelectionModel( model ),
91 MyGEOMBase_Helper( SUIT_Session::session()->activeApplication()->desktop() ),
92 _theModelSelectionChanged(false),
93 _theVtkSelectionChanged(false),
94 _theGeomSelectionChanged(false),
96 _salomeSelectionMgr(0)
98 connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
99 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
100 connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
101 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
106 PatternDataSelectionModel::~PatternDataSelectionModel()
108 disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
109 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
110 disconnect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
111 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
113 // if ( _salomeSelectionMgr )
114 // disconnect( _salomeSelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( salomeSelectionChanged() ) );
115 disconnect( HEXABLOCKGUI::selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( salomeSelectionChanged() ) );
119 void PatternDataSelectionModel::setVertexSelection()
121 MESSAGE("PatternDataSelectionModel::setVertexSelection(){");
122 SetSelectionMode(NodeSelection);
125 // // EdgeOfCellSelection,
128 // // VolumeSelection,
129 // // ActorSelection };
130 _selectionFilter = VERTEX_TREE;
134 void PatternDataSelectionModel::setEdgeSelection()
136 MESSAGE("PatternDataSelectionModel::setEdgeSelection(){");
137 SetSelectionMode(EdgeSelection);
138 _selectionFilter = EDGE_TREE;
142 void PatternDataSelectionModel::setQuadSelection()
144 MESSAGE("PatternDataSelectionModel::setQuadSelection(){");
145 SetSelectionMode(FaceSelection);
146 _selectionFilter = QUAD_TREE;
150 void PatternDataSelectionModel::setHexaSelection()
152 MESSAGE("PatternDataSelectionModel::setHexaSelection(){");
153 SetSelectionMode(VolumeSelection);
154 _selectionFilter = HEXA_TREE;
159 void PatternDataSelectionModel::setAllSelection()
161 MESSAGE("PatternDataSelectionModel::setAllSelection(){");
162 _selectionFilter = -1;
167 QModelIndex PatternDataSelectionModel::indexBy( int role, const QString& value )
169 QModelIndex eltIndex; // element (vertex, edge, quad) of model
170 const QAbstractItemModel* theModel = model();
171 if ( !theModel ) return eltIndex;
172 QModelIndexList theIndexes = theModel->match( theModel->index(0, 0),
176 Qt::MatchRecursive | Qt::MatchContains );//Qt::MatchFixedString );
177 if ( theIndexes.count()>0 )
178 eltIndex = theIndexes[0] ;
183 QModelIndex PatternDataSelectionModel::indexBy( int role, const QVariant& var )
185 QModelIndex eltIndex; // element (vertex, edge, quad) of model
186 const QAbstractItemModel* theModel = model();
187 if ( !theModel ) return eltIndex;
188 QModelIndexList theIndexes = theModel->match( theModel->index(0, 0),
192 Qt::MatchRecursive /*| Qt::MatchContains*/ );//Qt::MatchFixedString );
193 if ( theIndexes.count()>0 )
194 eltIndex = theIndexes[0] ;
199 void PatternDataSelectionModel::setSalomeSelectionMgr( LightApp_SelectionMgr* mgr )
201 _salomeSelectionMgr = mgr;
202 connect( _salomeSelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( salomeSelectionChanged() ) );
206 void PatternDataSelectionModel::SetSelectionMode(Selection_Mode theMode)
208 MESSAGE("PatternDataSelectionModel::SetSelectionMode(){");
209 SVTK_ViewWindow* aVTKViewWindow = _getVTKViewWindow();
210 // aViewWindow->clearFilters();
211 // _salomeSelectionMgr->clearFilters();
212 if ( aVTKViewWindow )
213 aVTKViewWindow->SetSelectionMode( theMode );
218 // A) De Salome(OCC, VTK) vers Hexablock(TreeView Data) :
220 // in: selection (vertex associé OCC).
221 // out: (vertex VTK) highlighté, (vertex TreeView) sélectionné.
223 // in : selection (vertex associé VTK).
224 // out: (vertex OCC) highlighté, (vertex TreeView) sélectionné.
227 // in: selection (edge associé OCC).
228 // out: (vertex VTK) highlighté, (vertex TreeView) sélectionné.
230 // in: selection (edge associé VTK).
231 // out: (toute la ligne OCC) highlighté + vertex sur (deb,fin) , (edge TreeView) sélectionné.
233 // -Face: idem vertex
234 void PatternDataSelectionModel::onCurrentChanged( const QModelIndex & current, const QModelIndex & previous )
236 MESSAGE("PatternDataSelectionModel::onCurrentChanged(){");
237 MESSAGE("* current : " << current.data().toString().toStdString());
238 MESSAGE("* previous : " << previous.data().toString().toStdString());
239 // _selectSalome( current, true );
240 // _selectSalome( previous, false );
246 void PatternDataSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
248 MESSAGE("PatternDataSelectionModel::onSelectionChanged(){");
249 foreach( const QModelIndex& isel, selected.indexes() ){
250 MESSAGE("* selected : " << isel.data().toString().toStdString());
252 foreach( const QModelIndex& iunsel, deselected.indexes() ){
253 MESSAGE("* unselected : " << iunsel.data().toString().toStdString());
256 _theModelSelectionChanged = true;
258 if ( _salomeSelectionMgr == NULL ) return;
259 // if ( !_theVtkSelectionChanged and !_theGeomSelectionChanged ) return;
261 _salomeSelectionMgr->clearSelected();
262 // erasePreview(true);
263 QModelIndexList indexes = selected.indexes();
264 for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){
265 // std::cout << "entry selected" << i_index->data( HEXA_ENTRY_ROLE ).toString().toStdString() << std::endl;
266 if ( !_theVtkSelectionChanged ) _selectVTK( *i_index );
267 if ( !_theGeomSelectionChanged ) _highlightGEOM( *i_index );
269 // CS_BP todo SALOMEGUI_Swig.cxx:370
270 // indexes = deselected.indexes();
271 // for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index )
272 // _unselectSalome( *i_index);
274 MESSAGE("Unknown exception was cought !!!");
276 _theModelSelectionChanged = false;
282 void PatternDataSelectionModel::salomeSelectionChanged()
284 MESSAGE("PatternDataSelectionModel::salomeSelectionChanged(){");
286 QModelIndex toSelect;
288 if ( _salomeSelectionMgr == NULL ) return;
289 SALOME_ListIO salomeSelected;
290 // _salomeSelectionMgr->selectedObjects( salomeSelected, SVTK_Viewer::Type() );//salomeSelected.Extent()
291 _salomeSelectionMgr->selectedObjects( salomeSelected, NULL, false );
292 if ( salomeSelected.IsEmpty() ){
293 MESSAGE("* salomeSelected.IsEmpty()");
298 Handle(SALOME_InteractiveObject) anIObject;
299 SALOME_ListIteratorOfListIO it(salomeSelected);
300 for( ; it.More(); it.Next()){
301 anIObject = it.Value(); //anIObject->getName()
302 toSelect = _geomSelectionChanged( anIObject );// is it comming from GEOM?
303 if ( !toSelect.isValid() ){
304 toSelect = _vtkSelectionChanged( anIObject ); ;// or VTK?...
305 if ( toSelect.isValid() )
306 MESSAGE("* OK : selection from VTK");
308 MESSAGE("* OK : selection from GEOM");
312 MESSAGE("* Unknown exception was cought !!!");
317 SVTK_ViewWindow* PatternDataSelectionModel::_getVTKViewWindow()
319 SVTK_ViewWindow* aVtkView = HEXABLOCKGUI::currentVtkView;
324 OCCViewer_ViewWindow* PatternDataSelectionModel::_getOCCViewWindow()
326 OCCViewer_ViewWindow* aOccView = HEXABLOCKGUI::currentOccView;
331 QModelIndex PatternDataSelectionModel::_indexOf( const QString& anEntry, int role )
333 QModelIndex eltIndex; // element (vertex, edge, quad) of model
334 const QAbstractItemModel* theModel = model();
335 if ( !theModel ) return eltIndex;
336 QModelIndexList theIndexes = theModel->match( theModel->index(0, 0),
340 Qt::MatchRecursive | Qt::MatchContains );//Qt::MatchFixedString );
341 if ( theIndexes.count()>0 )
342 eltIndex = theIndexes[0] ;
347 void PatternDataSelectionModel::_setVTKSelectionMode( const QModelIndex& eltIndex, SVTK_ViewWindow* vtkViewWindow )
349 MESSAGE("PatternDataSelectionModel::_setVTKSelectionMode( "<< eltIndex.data().toString().toStdString() << " ," << vtkViewWindow << " )");
350 QVariant treeVariant = eltIndex.data( HEXA_TREE_ROLE );
351 if ( !treeVariant.isValid() ) return;
352 int eltType = treeVariant.toInt();
354 if ( (_selectionFilter != -1) and ( _selectionFilter != eltType ) ) return;
358 case VERTEX_DIR_TREE : vtkViewWindow->SetSelectionMode(NodeSelection); MESSAGE("VERTEX"); break;
360 case EDGE_DIR_TREE : vtkViewWindow->SetSelectionMode(EdgeSelection); MESSAGE("EDGE"); break;
362 case QUAD_DIR_TREE : vtkViewWindow->SetSelectionMode(FaceSelection); MESSAGE("QUAD"); break;
364 case HEXA_DIR_TREE : vtkViewWindow->SetSelectionMode(VolumeSelection); MESSAGE("HEXA"); break;
365 case PROPAGATION_TREE :
366 case PROPAGATION_DIR_TREE : vtkViewWindow->SetSelectionMode(EdgeSelection); MESSAGE("PROPAGATION"); break;
368 // EdgeOfCellSelection,
376 void PatternDataSelectionModel::highlightVTKElts( const QModelIndexList& elts )
378 if (!elts.size()) return;
380 SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow();
381 if ( currentVTKViewWindow == NULL ) return;
382 SVTK_Selector* selector = currentVTKViewWindow->GetSelector();
383 if ( selector == NULL ) return;
385 // document selection
386 Document_Actor* docActor = NULL;
387 Handle(SALOME_InteractiveObject) docIO;
390 TColStd_MapOfInteger aMap;
391 QList<int>::const_iterator anIter;
396 QVariant docEntryVariant = elts[0].data( HEXA_DOC_ENTRY_ROLE );
398 if ( !docEntryVariant.isValid() ){
399 //INFOS("data from model not valid");
403 docEntry = docEntryVariant.toString();
405 // Select the document in Salome
406 docActor = dynamic_cast<Document_Actor*>( findActorByEntry( currentVTKViewWindow, docEntry.toLatin1() ) );
407 if ( docActor == NULL) return;
409 // // Set selection mode in VTK view
410 // currentVTKViewWindow->SetSelectionMode(EdgeSelection);
411 docIO = docActor->getIO();
413 // Highlight in vtk view the element from document
415 foreach( const QModelIndex& iElt, elts ){
416 edgeEntry = iElt.data( HEXA_ENTRY_ROLE ).toString();
417 vtkElemsId = docActor->vtkElemsId[ edgeEntry.toInt() ];
418 if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId );
421 selector->AddOrRemoveIndex( docIO, aMap, false );
422 currentVTKViewWindow->highlight( docIO, true, true );
425 // 1 vertex -> 1 point
426 // 1 edge -> n lines + points(deb,fin)
428 void PatternDataSelectionModel::_highlightGEOM( const QMultiMap<QString, int>& entrySubIDs )
430 MESSAGE("PatternDataSelectionModel::_highlightGEOM( const QMultiMap<QString, int>& entrySubIDs ){");
432 OCCViewer_ViewWindow* occView = _getOCCViewWindow();
433 if ( occView == NULL ) return;
434 SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>( occView->getViewManager()->getViewModel() );
435 if (!soccViewer) return;
436 _PTR(Study) aStudy = GetActiveStudyDocument();
439 CORBA::Object_var aCorbaObj = CORBA::Object::_nil();
440 GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_nil();
442 foreach ( QString entry, entrySubIDs.keys() ){
443 _PTR(SObject) aSChild = aStudy->FindObjectID( entry.toStdString() );
444 MESSAGE("* entry => "<< entry.toStdString());
445 aCorbaObj = corbaObj( aSChild );
446 aGeomObj = GEOM::GEOM_Object::_narrow( aCorbaObj );
447 if ( !CORBA::is_nil(aGeomObj) ){
448 MESSAGE("* !CORBA::is_nil(aGeomObj)");
449 QString objIOR = GEOMBase::GetIORFromObject( aGeomObj._retn() );
450 Handle(GEOM_AISShape) aSh = GEOMBase::ConvertIORinGEOMAISShape( objIOR );//, true );
451 if ( !aSh.IsNull() ){
452 MESSAGE("* !aSh.IsNull() ");
453 TColStd_IndexedMapOfInteger anIndexes;
454 foreach ( int subid, entrySubIDs.values(entry) ){
456 anIndexes.Add( subid );
458 if ( anIndexes.Extent() > 0 ){ // if it's a sub-shape
459 MESSAGE("* a sub-shape");
460 aSh->highlightSubShapes( anIndexes, true );
461 soccViewer->Repaint();
462 } else { // or a main shape
463 // std::cout << "aSh->getIO() => " << aSh->getIO() << std::endl;
464 // getDisplayer()->SetDisplayMode(0);
465 // soccViewer->setColor( aSh->getIO(), QColor( Qt::red ), true );
466 // soccViewer->switchRepresentation( aSh->getIO(), 2 );
467 MESSAGE("* a main shape");
468 // globalSelection();
469 soccViewer->highlight( aSh->getIO(), true, true );
479 void PatternDataSelectionModel::_highlightGEOM( const QModelIndex & anEltIndex )
481 MESSAGE("PatternDataSelectionModel::_highlightGEOM(" << anEltIndex.data().toString().toStdString() << ")");
482 // getting association(s) from model
483 QList<DocumentModel::GeomObj> assocs;
484 QMultiMap< QString, int > assocEntrySubIDs;
485 DocumentModel *docModel = NULL;
486 const QSortFilterProxyModel *pModel = dynamic_cast<const QSortFilterProxyModel *>( model() );
488 if ( !pModel ) return;
489 docModel = dynamic_cast<DocumentModel*>( pModel->sourceModel() );
490 if ( !docModel ) return;
491 assocs = docModel->getAssociations( pModel->mapToSource(anEltIndex) );
492 foreach( const DocumentModel::GeomObj& anAssoc, assocs )
493 assocEntrySubIDs.insert( anAssoc.entry, anAssoc.subid.toInt() );
495 _highlightGEOM( assocEntrySubIDs );
501 void PatternDataSelectionModel::_selectVTK( const QModelIndex& eltIndex )
503 MESSAGE("PatternDataSelectionModel::_selectVTK( "<< eltIndex.data().toString().toStdString() << ")");
504 SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow();
505 if ( currentVTKViewWindow == NULL ) return;
506 SVTK_Selector* selector = currentVTKViewWindow->GetSelector();
507 if ( selector == NULL ) return;
509 // document selection
510 Document_Actor* docActor = NULL;
511 Handle(SALOME_InteractiveObject) docIO;
515 TColStd_MapOfInteger aMap;
516 QList<int>::const_iterator anIter;
522 QVariant entryVariant = eltIndex.data( HEXA_ENTRY_ROLE );
523 QVariant docEntryVariant = eltIndex.data( HEXA_DOC_ENTRY_ROLE );
525 if ( !entryVariant.isValid() ){
526 //INFOS("entryVariant not valid");
529 if ( !docEntryVariant.isValid() ){
530 //INFOS("docEntryVariant not valid");
534 eltEntry = entryVariant.toString();
535 docEntry = docEntryVariant.toString();
537 // Select the document in Salome
538 docActor = dynamic_cast<Document_Actor*>( findActorByEntry( currentVTKViewWindow, docEntry.toLatin1() ) );
539 if ( docActor == NULL ) return;
541 // Set selection mode in VTK view
542 _setVTKSelectionMode( eltIndex, currentVTKViewWindow );
544 // if ( _salomeSelectionMgr == NULL ) return;
545 // _salomeSelectionMgr->selectedObjects( aList );
546 // std::cout<<"aList.Extent() => " << aList.Extent() << std::endl;
547 // aList.Append(docIO);
548 // _salomeSelectionMgr->setSelectedObjects( aList, true );//false );//true ); //CS_BP false?
549 docIO = docActor->getIO();
551 // Highlight in vtk view the element from document
552 vtkElemsId = docActor->vtkElemsId[ eltEntry.toInt() ];// get vtk ids from actor
553 if ( vtkElemsId > 0 ) // CS_BP ?: erreur si 1er elt == vertex (0,0,0)
554 aMap.Add( vtkElemsId );
555 // for (anIter = theIds.begin(); anIter != theIds.end(); ++anIter) {
556 // aMap.Add(*anIter);
558 selector->AddOrRemoveIndex( docIO, aMap, false );
559 currentVTKViewWindow->highlight( docIO, true, true );
564 QModelIndex PatternDataSelectionModel::_geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject )
566 MESSAGE("PatternDataSelectionModel::_geomSelectionChanged(){");
567 QModelIndex eltIndex;// the element of the model which is associated to the geom object and that is to be selected
569 bool fromGEOM = ( strcmp("GEOM", anIObject->getComponentDataType()) == 0 );
570 if ( !fromGEOM ) return eltIndex;
571 if (!_salomeSelectionMgr) return eltIndex;
574 GEOM::GEOM_Object_var aGeomObj = GEOMBase::ConvertIOinGEOMObject( anIObject );
577 if ( GEOMBase::IsShape(aGeomObj) ){
578 aName = GEOMBase::GetName(aGeomObj);
579 TColStd_IndexedMapOfInteger anIndexes;
580 _salomeSelectionMgr->GetIndexes(anIObject, anIndexes);
581 if ( anIndexes.Extent() == 1 )
582 anIndex = anIndexes(1);
583 QString aGeomObjStudyEntry = aGeomObj->GetStudyEntry();
584 QString aGeomObjModelEntry = aGeomObjStudyEntry + "," + QString::number(anIndex) + ";";
585 eltIndex = _indexOf( aGeomObjModelEntry, HEXA_ASSOC_ENTRY_ROLE );
586 if ( !_theModelSelectionChanged && eltIndex.isValid() ){ // select in model
587 _theGeomSelectionChanged = true;
588 // select( newIndex, QItemSelectionModel::ClearAndSelect );
589 // select( newIndex, QItemSelectionModel::SelectCurrent );
590 // setCurrentIndex( eltIndex, QItemSelectionModel::SelectCurrent );
591 setCurrentIndex( eltIndex, QItemSelectionModel::Clear ); //CS_TEST
592 setCurrentIndex( eltIndex, QItemSelectionModel::SelectCurrent );
593 _theGeomSelectionChanged = false;
604 QModelIndex PatternDataSelectionModel::_vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject )
606 MESSAGE("PatternDataSelectionModel::_vtkSelectionChanged(){");
607 QModelIndex anIOIndex;// // the element of the model which is associated to the Interactive object and that is to be selected
609 bool fromVTK = ( strcmp("HEXABLOCK", anIObject->getComponentDataType()) == 0 );
610 if ( !fromVTK ) return anIOIndex;
611 SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow();
612 if ( !currentVTKViewWindow ) return anIOIndex;
613 if ( !anIObject->hasEntry() ) return anIOIndex;
615 QString anIOEntry = anIObject->getEntry();
616 Document_Actor *anDocActor = NULL;
620 if ( GetNameOfSelectedElements( currentVTKViewWindow, anIObject, aText ) <= 0 ) return anIOIndex;
621 anDocActor = dynamic_cast<Document_Actor*>( findActorByEntry( currentVTKViewWindow, anIOEntry.toLatin1() ) );
622 if ( !anDocActor ) return anIOIndex;
623 anhexaElemsId = anDocActor->hexaElemsId[ aText.toInt() ];
624 anIOEntry = QString::number( anhexaElemsId );
625 anIOIndex = _indexOf( anIOEntry, HEXA_ENTRY_ROLE );
627 if ( !_theModelSelectionChanged && anIOIndex.isValid() ){ // select in model
628 _theVtkSelectionChanged = true;
629 // select( anIOIndex, QItemSelectionModel::Clear );
630 // select( anIOIndex, QItemSelectionModel::Select );
631 // select( anIOIndex, QItemSelectionModel::ClearAndSelect );
632 // select( anIOIndex, QItemSelectionModel::SelectCurrent );
633 // setCurrentIndex( anIOIndex, QItemSelectionModel::SelectCurrent );
634 // setCurrentIndex( anIOIndex, QItemSelectionModel::SelectCurrent );
635 // setCurrentIndex( anIOIndex, QItemSelectionModel::ClearAndSelect );
636 // setCurrentIndex( anIOIndex, QItemSelectionModel::ClearAndSelect );
637 setCurrentIndex( anIOIndex, QItemSelectionModel::Clear );
638 setCurrentIndex( anIOIndex, QItemSelectionModel::SelectCurrent );
639 _theVtkSelectionChanged = false;
644 // if (anIOIndex.isValid())
645 // _selectVTK(anIOIndex);
647 if (anIOIndex.isValid())
664 GroupsSelectionModel::GroupsSelectionModel( QAbstractItemModel * model ):
665 QItemSelectionModel( model )
667 connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
668 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
669 connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
670 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
674 GroupsSelectionModel::~GroupsSelectionModel()
676 disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
677 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
678 disconnect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
679 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
685 QModelIndex GroupsSelectionModel::indexBy( int role, const QVariant& var )
687 QModelIndex eltIndex; // element (vertex, edge, quad) of model
688 const QAbstractItemModel* theModel = model();
689 if ( !theModel ) return eltIndex;
690 QModelIndexList theIndexes = theModel->match( theModel->index(0, 0),
694 Qt::MatchRecursive /*| Qt::MatchContains*/ );//Qt::MatchFixedString );
695 if ( theIndexes.count()>0 )
696 eltIndex = theIndexes[0] ;
701 SVTK_ViewWindow* GroupsSelectionModel::_getVTKViewWindow()
703 SVTK_ViewWindow* aVtkView = HEXABLOCKGUI::currentVtkView;
708 void GroupsSelectionModel::_highlightGroups( const QModelIndex& eltIndex )
710 const GroupsModel* m = dynamic_cast<const GroupsModel *>( model() );
713 if ( m == NULL ) return;
714 SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow();
715 if ( currentVTKViewWindow == NULL ) return;
716 SVTK_Selector* selector = currentVTKViewWindow->GetSelector();
717 if ( selector == NULL ) return;
720 // document selection
721 Document_Actor* docActor = NULL;
722 Handle(SALOME_InteractiveObject) docIO;
726 TColStd_MapOfInteger aMap;
727 QList<int>::const_iterator anIter;
732 // debut ** data from model
736 QVariant treeVariant = eltIndex.data( HEXA_TREE_ROLE );
737 QVariant docEntryVariant = eltIndex.data( HEXA_DOC_ENTRY_ROLE );
739 if ( !treeVariant.isValid() || !docEntryVariant.isValid() ){
740 //INFOS("data from model not valid");
744 eltType = treeVariant.toInt();
745 docEntry = docEntryVariant.toString();
747 if ( eltType != GROUP_TREE ){
748 //INFOS("bad element type : not a group item" << eltType );
751 // fin ** data from model
753 // Select the document in Salome
754 docActor = dynamic_cast<Document_Actor*>( findActorByEntry( currentVTKViewWindow, docEntry.toLatin1() ) );
755 if ( docActor == NULL) return;
756 docIO = docActor->getIO();
758 // Highlight in vtk view the element from document
759 DocumentModel::Group kind;
760 QModelIndexList iElements = m->getGroupElements( eltIndex, kind );
762 // Set selection mode in VTK view
764 case HEXA_NS::HexaCell: case HEXA_NS::HexaNode: currentVTKViewWindow->SetSelectionMode(VolumeSelection); break;
765 case HEXA_NS::QuadCell: case HEXA_NS::QuadNode: currentVTKViewWindow->SetSelectionMode(FaceSelection); break;
766 case HEXA_NS::EdgeCell: case HEXA_NS::EdgeNode: currentVTKViewWindow->SetSelectionMode(EdgeSelection); break;
767 case HEXA_NS::VertexNode: currentVTKViewWindow->SetSelectionMode(NodeSelection); break;
771 foreach( const QModelIndex& iElt, iElements ){
772 eltEntry = iElt.data( HEXA_ENTRY_ROLE ).toString();
773 vtkElemsId = docActor->vtkElemsId[ eltEntry.toInt() ];
774 if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId );
777 selector->AddOrRemoveIndex( docIO, aMap, false );
778 currentVTKViewWindow->highlight( docIO, true, true );
783 void GroupsSelectionModel::_highlightAssoc( const QModelIndex& eltIndex )
785 const GroupsModel* m = dynamic_cast<const GroupsModel *>( model() );
788 if ( m == NULL ) return;
789 SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow();
790 if ( currentVTKViewWindow == NULL ) return;
791 SVTK_Selector* selector = currentVTKViewWindow->GetSelector();
792 if ( selector == NULL ) return;
795 // document selection
796 Document_Actor* docActor = NULL;
797 Handle(SALOME_InteractiveObject) docIO;
801 TColStd_MapOfInteger aMap;
802 QList<int>::const_iterator anIter;
807 // debut ** data from model
811 QVariant treeVariant = eltIndex.data( HEXA_TREE_ROLE );
812 QVariant docEntryVariant = eltIndex.data( HEXA_DOC_ENTRY_ROLE );
814 if ( !treeVariant.isValid() || !docEntryVariant.isValid() ){
815 //INFOS("data from model not valid");
819 eltType = treeVariant.toInt();
820 docEntry = docEntryVariant.toString();
822 //INFOS("bad element typ
823 if ( eltType != GROUP_TREE ){
824 //INFOS("bad element type : not a group item" << eltType );
827 // fin ** data from model
829 // Select the document in Salome
830 docActor = dynamic_cast<Document_Actor*>( findActorByEntry( currentVTKViewWindow, docEntry.toLatin1() ) );
831 if ( docActor == NULL) return;
832 docIO = docActor->getIO();
834 // Highlight in vtk view the element from document
835 DocumentModel::Group kind;
836 QModelIndexList iElements = m->getGroupElements( eltIndex, kind );
838 // Set selection mode in VTK view
841 case HEXA_NS::HexaCell: case HEXA_NS::HexaNode: currentVTKViewWindow->SetSelectionMode(VolumeSelection); break;
842 case HEXA_NS::QuadCell: case HEXA_NS::QuadNode: currentVTKViewWindow->SetSelectionMode(FaceSelection); break;
843 case HEXA_NS::EdgeCell: case HEXA_NS::EdgeNode: currentVTKViewWindow->SetSelectionMode(EdgeSelection); break;
844 case HEXA_NS::VertexNode: currentVTKViewWindow->SetSelectionMode(NodeSelection); break;
848 foreach( const QModelIndex& iElt, iElements ){
849 eltEntry = iElt.data( HEXA_ENTRY_ROLE ).toString();
850 vtkElemsId = docActor->vtkElemsId[ eltEntry.toInt() ];
852 if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId );
855 selector->AddOrRemoveIndex( docIO, aMap, false );
856 currentVTKViewWindow->highlight( docIO, true, true );
862 void GroupsSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
864 MESSAGE("GroupsSelectionModel::onSelectionChanged");
866 // if ( _salomeSelectionMgr == NULL ) return;
867 // _salomeSelectionMgr->clearSelected();
868 // erasePreview(true);
869 QModelIndexList indexes = selected.indexes();
870 for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){
871 MESSAGE( "entry selected" << i_index->data( HEXA_ENTRY_ROLE ).toString().toStdString() );
872 _highlightGroups( *i_index );
875 // CS_BP todo SALOMEGUI_Swig.cxx:370
876 // indexes = deselected.indexes();
877 // for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index )
878 // _unselectSalome( *i_index);
880 MESSAGE("Unknown exception was cought !!!");
891 MeshSelectionModel::MeshSelectionModel( QAbstractItemModel * model ):
892 QItemSelectionModel( model )
894 connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
895 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
896 connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
897 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
901 MeshSelectionModel::~MeshSelectionModel()
903 disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ),
904 this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) );
905 disconnect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ),
906 this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) );
910 QModelIndex MeshSelectionModel::indexBy( int role, const QVariant& var )
912 QModelIndex eltIndex; // element (vertex, edge, quad) of model
913 const QAbstractItemModel* theModel = model();
914 if ( !theModel ) return eltIndex;
915 QModelIndexList theIndexes = theModel->match( theModel->index(0, 0),
919 Qt::MatchRecursive /*| Qt::MatchContains*/ );//Qt::MatchFixedString );
920 if ( theIndexes.count()>0 )
921 eltIndex = theIndexes[0] ;
927 SVTK_ViewWindow* MeshSelectionModel::_getVTKViewWindow()
929 SVTK_ViewWindow* aVtkView = HEXABLOCKGUI::currentVtkView;
934 void MeshSelectionModel::_highlightPropagation( const QModelIndex& eltIndex )
936 const MeshModel* m = dynamic_cast<const MeshModel *>( model() );
937 if ( m == NULL ) return;
938 SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow();
939 if ( currentVTKViewWindow == NULL ) return;
940 SVTK_Selector* selector = currentVTKViewWindow->GetSelector();
941 if ( selector == NULL ) return;
943 // document selection
944 Document_Actor* docActor = NULL;
945 Handle(SALOME_InteractiveObject) docIO;
949 TColStd_MapOfInteger aMap;
950 QList<int>::const_iterator anIter;
957 QVariant treeVariant = eltIndex.data( HEXA_TREE_ROLE );
958 QVariant docEntryVariant = eltIndex.data( HEXA_DOC_ENTRY_ROLE );
960 if ( !treeVariant.isValid() || !docEntryVariant.isValid() ){
961 //INFOS("data from model not valid");
965 eltType = treeVariant.toInt();
966 docEntry = docEntryVariant.toString();
968 if ( eltType != PROPAGATION_TREE ){
969 //INFOS("bad element type : not a propagation item" << eltType );
973 // Select the document in Salome
974 docActor = dynamic_cast<Document_Actor*>( findActorByEntry( currentVTKViewWindow, docEntry.toLatin1() ) );
975 if ( docActor == NULL) return;
977 // // Set selection mode in VTK view
978 currentVTKViewWindow->SetSelectionMode(EdgeSelection);
979 docIO = docActor->getIO();
981 // Highlight in vtk view the element from document
982 QModelIndexList iEdges = m->getPropagation( eltIndex );
985 foreach( const QModelIndex& iEdge, iEdges ){
986 edgeEntry = iEdge.data( HEXA_ENTRY_ROLE ).toString();
987 vtkElemsId = docActor->vtkElemsId[ edgeEntry.toInt() ];
988 if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId );
991 selector->AddOrRemoveIndex( docIO, aMap, false );
992 currentVTKViewWindow->highlight( docIO, true, true );
997 void MeshSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected )
999 MESSAGE("MeshSelectionModel::onSelectionChanged");
1001 // if ( _salomeSelectionMgr == NULL ) return;
1002 // _salomeSelectionMgr->clearSelected();
1003 // erasePreview(true);
1004 QModelIndexList indexes = selected.indexes();
1005 for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){
1006 MESSAGE( "entry selected" << i_index->data( HEXA_ENTRY_ROLE ).toString().toStdString() );
1007 _highlightPropagation( *i_index );
1010 // CS_BP todo SALOMEGUI_Swig.cxx:370
1011 // indexes = deselected.indexes();
1012 // for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index )
1013 // _unselectSalome( *i_index);
1015 MESSAGE("Unknown exception was cought !!!");
1023 // //=================================================================================
1024 // // function : activateSelection
1025 // // purpose : Activate selection in accordance with myEditCurrentArgument
1026 // //=================================================================================
1027 // void PatternDataSelectionModel::activateSelection()
1029 // erasePreview(false);
1031 // // local selection
1032 // if (!myObject->_is_nil() && !isAllSubShapes())
1034 // GEOM_Displayer* aDisplayer = getDisplayer();
1035 // SALOME_View* view = GEOM_Displayer::GetActiveView();
1037 // CORBA::String_var aMainEntry = myObject->GetStudyEntry();
1038 // Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject (aMainEntry.in(), "GEOM", "TEMP_IO");
1039 // if (view->isVisible(io)) {
1040 // aDisplayer->Erase(myObject, false, false);
1041 // myIsHiddenMain = true;
1045 // int prevDisplayMode = aDisplayer->SetDisplayMode(0);
1047 // SUIT_ViewWindow* aViewWindow = 0;
1048 // SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
1050 // aViewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
1051 // if (aViewWindow == 0) return;
1053 // SUIT_ViewManager* aViewManager = aViewWindow->getViewManager();
1054 // if (aViewManager->getType() != OCCViewer_Viewer::Type() &&
1055 // aViewManager->getType() != SVTK_Viewer::Type())
1058 // SUIT_ViewModel* aViewModel = aViewManager->getViewModel();
1059 // SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
1060 // if (aView == 0) return;
1062 // //TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myObject);
1064 // TopTools_IndexedMapOfShape aSubShapesMap;
1065 // TopExp::MapShapes(myShape, aSubShapesMap);
1066 // CORBA::String_var aMainEntry = myObject->GetStudyEntry();
1067 // QString anEntryBase = aMainEntry.in();
1069 // TopExp_Explorer anExp (myShape, (TopAbs_ShapeEnum)shapeType());
1070 // for (; anExp.More(); anExp.Next())
1072 // TopoDS_Shape aSubShape = anExp.Current();
1073 // int index = aSubShapesMap.FindIndex(aSubShape);
1074 // QString anEntry = anEntryBase + QString("_%1").arg(index);
1076 // SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView);
1078 // displayPreview(aPrs, true, false); // append, do not update
1081 // aDisplayer->UpdateViewer();
1082 // aDisplayer->SetDisplayMode(prevDisplayMode);
1085 // globalSelection(GEOM_ALLSHAPES);
1091 // SUIT_DataOwnerPtrList aList;
1092 // ObjectList::iterator anIter;
1093 // for ( anIter = objects.begin(); anIter != objects.end(); ++anIter )
1095 // QString anEntry = getEntry( *anIter );
1096 // LightApp_DataOwner* anOwher = new LightApp_DataOwner( anEntry );
1097 // aList.append( anOwher );
1100 // SUIT_Session* session = SUIT_Session::session();
1101 // SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
1105 // LightApp_SelectionMgr* aMgr = app->selectionMgr();
1108 // _getVTKViewWindow()
1109 // aMgr->setSelecte_getVTKViewWindow()d( aList, false );
1115 // SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh);
1116 // if (!anActor || !anActor->hasIO())
1119 // Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
1120 // //mySelectionMgr->clearSelected();
1121 // //mySelectionMgr->AddIObject(anIO, false);
1122 // SALOME_ListIO aList;
1123 // aList.Append(anIO);
1124 // mySelectionMgr->setSelectedObjects(aList, false);
1126 // // Remove filter corresponding to the current type from viewer
1127 // int aType = myTable->GetType();
1128 // int aFilterId = SMESH::UnknownFilter;
1129 // if (aType == SMESH::EDGE ) aFilterId = SMESH::EdgeFilter;
1130 // else if (aType == SMESH::FACE ) aFilterId = SMESH::FaceFilter;
1131 // else if (aType == SMESH::VOLUME) aFilterId = SMESH::VolumeFilter;
1132 // Handle(VTKViewer_Filter) aFilter = SMESH::GetFilter(aFilterId);
1133 // SMESH::RemoveFilter(aFilterId);
1136 // TColStd_MapOfInteger aMap;
1137 // QList<int>::const_iterator anIter;
1138 // for (anIter = theIds.begin(); anIter != theIds.end(); ++anIter) {
1139 // aMap.Add(*anIter);
1142 // // Set new selection
1143 // activeViewWindow->AddOrRemoveIndex(anIO, aMap, false);
1144 // if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1145 // aViewWindow->highlight( anIO, true, true );
1147 // // insert previously stored filter in viewer if necessary
1148 // if (!aFilter.IsNull())
1149 // SMESH::SetFilter(aFilter);
1160 // if(SVTK_Selector* aSelector = aView->GetSelector()){
1161 // const SALOME_ListIO& aListIO = aSelector->StoredIObjects();
1162 // SALOME_ListIteratorOfListIO anIter(aListIO);
1163 // for(; anIter.More(); anIter.Next()){
1164 // Handle(SALOME_InteractiveObject) anIO = anIter.Value();
1165 // _PTR(Study) aStudy = HEXABLOCKGUI::activeStudy()->studyDS();
1166 // _PTR(SObject) aSObj = aStudy->FindObjectID( anEntry.toStdString().c_str() );
1167 // LightApp_DataObject* o = HEXABLOCKGUI::activeStudy()->findObjectByEntry(anEntry.toStdString().c_str());
1174 // void PatternDataSelectionModel::test()
1176 // if (myBusy) return;
1179 // SALOME_ListIO aList;
1180 // mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
1182 // if (aList.Extent() == 1) {
1183 // Handle(SALOME_InteractiveObject) anIO = aList.First();
1184 // myMeshActor = SMESH::FindActorByEntry(anIO->getEntry());
1187 // if (SMESH::GetNameOfSelectedNodes(activeViewWindow,anIO,aText) == 1) {
1188 // if(SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh()) {
1189 // if(const SMDS_MeshNode* aNode = aMesh->FindNode(aText.toInt())) {
1191 // myId->setText(aText);
1192 // myX->SetValue(aNode->X());
1193 // myY->SetValue(aNode->Y());
1194 // myZ->SetValue(aNode->Z());
1196 // erasePreview(); // avoid overlapping of a selection and a preview
1211 void PatternDataSelectionModel::setGeomEngine( GEOM::GEOM_Gen_var geomEngine )
1213 _geomEngine = geomEngine;
1216 GEOM::GEOM_IOperations_ptr PatternDataSelectionModel::createOperation()
1218 // return myGeomGUI->GetGeomGen()->GetIBasicOperations(getStudyId());
1219 return _geomEngine->GetIBasicOperations(getStudyId());
1222 bool PatternDataSelectionModel::execute(ObjectList& objects)
1226 _PTR(Study) aStudy = GetActiveStudyDocument();
1227 _PTR(SObject) aSChild;
1228 CORBA::Object_var aCorbaObj = CORBA::Object::_nil();
1229 GEOM::GEOM_Object_var assoc;
1231 foreach( const DocumentModel::GeomObj& anAssoc, _assocList ){
1232 std::cout << "FOUND=> " << anAssoc.entry.toStdString() << std::endl;
1233 aSChild = aStudy->FindObjectID( anAssoc.entry.toStdString() );
1234 aCorbaObj = corbaObj(aSChild);
1235 assoc = GEOM::GEOM_Object::_narrow(aCorbaObj);
1237 if ( !CORBA::is_nil(assoc) ){
1238 std::cout << "geom to highlight =>" << anAssoc.name.toStdString() << std::endl;
1239 objects.push_back( assoc._retn() );
1242 std::cout << "not a geom =>" << anAssoc.name.toStdString()<< std::endl;
1251 // SVTK_ViewWindow* PatternDataSelectionModel::GetViewWindow()
1253 // SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
1254 // (SUIT_Session::session()->activeApplication());
1256 // if (SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(anApp->desktop()->activeWindow()))
1259 // // SUIT_ViewManager* aViewManager =
1260 // // anApp->getViewManager(SVTK_Viewer::Type(), createIfNotFound);
1261 // // if (aViewManager) {
1262 // // if (SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()) {
1263 // // if (SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
1264 // // aViewWindow->raise();
1265 // // aViewWindow->setFocus();
1277 // void PatternDataSelectionModel::SetSelectionMode(Selection_Mode theMode)
1280 // QList<SUIT_Selector*> aSelectors;
1281 // _salomeSelectionMgr->selectors( SVTK_Viewer::Type(), aSelectors );
1282 // QListIterator<SUIT_Selector*> it( aSelectors );
1284 // std::cout << "PatternDataSelectionModel::SetSelectionMode()" << std::endl;
1285 // while ( it.hasNext() )
1287 // // SUIT_Selector* selector = it.next();
1288 // SVTK_Selector* selector = dynamic_cast<SVTK_Selector*>( it.next() );
1290 // std::cout << "PatternDataSelectionModel::SetSelectionMode()" << theMode << std::endl;
1291 // selector->SetSelectionMode(theMode);
1296 // LightApp_SelectionMgr* PatternDataSelectionModel::selectionMgr()
1298 // SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
1300 // return dynamic_cast<LightApp_SelectionMgr*>( anApp->selectionMgr() );
1306 // SUIT_DataOwnerPtrList aOList;
1307 // LightApp_DataOwner* anOwher = new LightApp_DataOwner( "0:1:1:1:2" );
1308 // aOList.append( anOwher );
1309 // _salomeSelectionMgr->setSelected( aOList, false );
1312 // void PatternDataSelectionModel::_highlightGEOM( const QModelIndex & anEltIndex )
1314 // std::cout << "PatternDataSelectionModel::_highlightGEOM go find ASSOCIATION for"<< anEltIndex.data().toString().toStdString()<<std::endl;
1315 // // HEXABLOCKGUI::currentVtkView
1317 // QList<DocumentModel::GeomObj> assocList;
1319 // DocumentModel *docModel = NULL;
1320 // const QSortFilterProxyModel *pModel = NULL;
1321 // // const QStandardItemModel *smodel
1322 // // const QAbstractItemModel *theModel = NULL;
1324 // pModel = dynamic_cast<const QSortFilterProxyModel *>( model() );
1326 // std::cout << "pModel "<< pModel << std::endl;
1328 // std::cout << "if ( pModel ){"<< std::endl;
1329 // docModel = dynamic_cast<DocumentModel*>( pModel->sourceModel() );
1331 // std::cout << "if ( docModel ){"<< std::endl;
1332 // assocList = docModel->getAssociations( pModel->mapToSource(anEltIndex) );
1337 // _PTR(Study) aStudy = GetActiveStudyDocument();
1338 // _PTR(SObject) aSChild;
1339 // CORBA::Object_var aCorbaObj = CORBA::Object::_nil();
1340 // GEOM::GEOM_Object_var assoc;
1341 // // foreach( const QString& entry, geomEntries ){
1342 // // struct GeomObj
1345 // // QString entry;
1351 // QVariant treeVariant = pModel->mapToSource(anEltIndex).data( HEXA_TREE_ROLE );
1353 // if ( !treeVariant.isValid() ) return;
1354 // eltType = treeVariant.toInt();
1356 // // GEOM::GeomObjPtr
1357 // // GEOM::GEOM_Object_ptr firstLine; //firstLine.nullify();//
1358 // GEOM::GEOM_Object_var firstLine = GEOM::GEOM_Object::_nil(); //GEOM::GeomObjPtr
1359 // GEOM::GEOM_Object_var lastLine = GEOM::GEOM_Object::_nil();
1360 // double firstParameter = 0.2; //CS_TODO
1361 // double lastParameter = 0.4; //CS_TODO
1363 // foreach( const DocumentModel::GeomObj& anAssoc, assocList ){
1364 // std::cout << "FOUND=> " << anAssoc.entry.toStdString() << std::endl;
1365 // aSChild = aStudy->FindObjectID( anAssoc.entry.toStdString() );
1366 // aCorbaObj = corbaObj(aSChild);
1367 // assoc = GEOM::GEOM_Object::_narrow(aCorbaObj);
1369 // if ( !CORBA::is_nil(assoc) ){
1370 // std::cout << "geom to highlight =>" << anAssoc.name.toStdString() << std::endl;
1371 // // objects.push_back(assoc._retn());
1372 // // if ( eltType == EDGE_TREE ){
1373 // // if ( CORBA::is_nil(firstLine) ){
1374 // // firstLine = GEOM::GEOM_Object::_duplicate( assoc._retn() );
1376 // // lastLine = GEOM::GEOM_Object::_duplicate( assoc._retn() );
1378 // displayPreview( assoc._retn(),
1379 // true, //false, //append,
1380 // false,//true, //false, //activate,
1381 // false,//true,//update,
1383 // 1,//-1,//displayMode,
1384 // Quantity_NOC_RED );
1386 // std::cout << "not a geom =>" << anAssoc.name.toStdString()<< std::endl;
1389 // // std::cout << "CORBA::is_nil(firstLine) =>" << CORBA::is_nil(firstLine) << std::endl;
1390 // // std::cout << "CORBA::is_nil(lastLine) =>" << CORBA::is_nil(lastLine) << std::endl;
1391 // // std::cout << "test" << ( !( CORBA::is_nil(firstLine) and !CORBA::is_nil(lastLine) ) ) << std::endl;
1393 // if ( !( CORBA::is_nil(firstLine) and !CORBA::is_nil(lastLine) ) ){
1394 // GEOM::GEOM_IBasicOperations_var anOper = _geomEngine->GetIBasicOperations( getStudyId() );
1395 // GEOM::GEOM_Object_var firstPoint = anOper->MakePointOnCurve( firstLine, firstParameter );
1396 // GEOM::GEOM_Object_var lastPoint = anOper->MakePointOnCurve( lastLine, lastParameter );
1398 // // std::cout << "firstPoint->_is_nil() =>" << firstPoint->_is_nil() << std::endl;
1399 // std::cout << "lastPoint->_is_nil() =>" << lastPoint->_is_nil() << std::endl;
1400 // if ( !( CORBA::is_nil(firstPoint) ) )// !firstPoint->_is_nil() )
1401 // displayPreview( firstPoint._retn(), true );
1402 // if ( !( CORBA::is_nil(lastPoint) ) )//if ( !lastPoint->_is_nil() )
1403 // displayPreview( lastPoint._retn(), true );