X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHEXABLOCKGUI%2FHEXABLOCKGUI_DocumentSelectionModel.cxx;h=7abc8b7fc6e933b666d8b4327a5e1ccea5638e9d;hb=dc9efa7dceb4fe9420be3640b0103dd599fbf164;hp=393c908c62fc4f7929f8da88ab6df211afb6f748;hpb=8681e72f844274a0c2fc2cd64bbf2451bd8db77b;p=modules%2Fhexablock.git diff --git a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentSelectionModel.cxx b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentSelectionModel.cxx index 393c908..7abc8b7 100755 --- a/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentSelectionModel.cxx +++ b/src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentSelectionModel.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2009-2012 CEA/DEN, EDF R&D +// Copyright (C) 2009-2013 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -41,12 +41,12 @@ #include #include #include +#include - +#include "HEXABLOCKGUI_VtkDocumentGraphicView.hxx" +#include "HEXABLOCKGUI_OccGraphicView.hxx" #include "HEXABLOCKGUI_SalomeTools.hxx" #include "HEXABLOCKGUI_DocumentSelectionModel.hxx" -#include "HEXABLOCKGUI_DocumentModel.hxx" -#include "HEXABLOCKGUI_DocumentGraphicView.hxx" #include "HEXABLOCKGUI_DocumentItem.hxx" #include "HEXABLOCKGUI.hxx" @@ -60,12 +60,10 @@ #include #include #include +#include #include -#include "GEOMBase.h" -#include "MyGEOMBase_Helper.hxx" - #include #include #include @@ -85,86 +83,25 @@ using namespace std; using namespace HEXABLOCK::GUI; +// //=========================================================================== +// SelectionModel +// //=========================================================================== -PatternDataSelectionModel::PatternDataSelectionModel( QAbstractItemModel * model ): -QItemSelectionModel( model ), -MyGEOMBase_Helper( SUIT_Session::session()->activeApplication()->desktop() ), -_theModelSelectionChanged(false), -_theVtkSelectionChanged(false), -_theGeomSelectionChanged(false), -_selectionFilter(-1), -_salomeSelectionMgr(0) -{ - connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), - this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) ); - connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ), - this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) ); - -} - - -PatternDataSelectionModel::~PatternDataSelectionModel() -{ - disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), - this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) ); - disconnect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ), - this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) ); - -// if ( _salomeSelectionMgr ) -// disconnect( _salomeSelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( salomeSelectionChanged() ) ); - disconnect( HEXABLOCKGUI::selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( salomeSelectionChanged() ) ); -} - - -void PatternDataSelectionModel::setVertexSelection() -{ - MESSAGE("PatternDataSelectionModel::setVertexSelection(){"); - SetSelectionMode(NodeSelection); -// // NodeSelection, -// // CellSelection, -// // EdgeOfCellSelection, -// // EdgeSelection, -// // FaceSelection, -// // VolumeSelection, -// // ActorSelection }; - _selectionFilter = VERTEX_TREE; - MESSAGE("}"); -} - -void PatternDataSelectionModel::setEdgeSelection() -{ - MESSAGE("PatternDataSelectionModel::setEdgeSelection(){"); - SetSelectionMode(EdgeSelection); - _selectionFilter = EDGE_TREE; - MESSAGE("}"); -} +bool SelectionModel::infoMode = true; -void PatternDataSelectionModel::setQuadSelection() +SelectionModel::SelectionModel( QAbstractItemModel * model ): +QItemSelectionModel( model ) { - MESSAGE("PatternDataSelectionModel::setQuadSelection(){"); - SetSelectionMode(FaceSelection); - _selectionFilter = QUAD_TREE; - MESSAGE("}"); -} -void PatternDataSelectionModel::setHexaSelection() -{ - MESSAGE("PatternDataSelectionModel::setHexaSelection(){"); - SetSelectionMode(VolumeSelection); - _selectionFilter = HEXA_TREE; - MESSAGE("}"); } - -void PatternDataSelectionModel::setAllSelection() +SelectionModel::~SelectionModel() { - MESSAGE("PatternDataSelectionModel::setAllSelection(){"); - _selectionFilter = -1; - MESSAGE("}"); + disconnect( HEXABLOCKGUI::selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( salomeSelectionChanged() ) ); } -QModelIndex PatternDataSelectionModel::indexBy( int role, const QString& value ) +QModelIndex SelectionModel::indexBy( int role, const QString& value ) { QModelIndex eltIndex; // element (vertex, edge, quad) of model const QAbstractItemModel* theModel = model(); @@ -180,7 +117,7 @@ QModelIndex PatternDataSelectionModel::indexBy( int role, const QString& value ) } -QModelIndex PatternDataSelectionModel::indexBy( int role, const QVariant& var ) +QModelIndex SelectionModel::indexBy( int role, const QVariant& var ) { QModelIndex eltIndex; // element (vertex, edge, quad) of model const QAbstractItemModel* theModel = model(); @@ -195,483 +132,359 @@ QModelIndex PatternDataSelectionModel::indexBy( int role, const QVariant& var ) return eltIndex; } - -void PatternDataSelectionModel::setSalomeSelectionMgr( LightApp_SelectionMgr* mgr ) +QModelIndex SelectionModel::indexOf( const QString& anEntry, int role ) { - _salomeSelectionMgr = mgr; - connect( _salomeSelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( salomeSelectionChanged() ) ); + QModelIndex eltIndex; // element (vertex, edge, quad) of model + const QAbstractItemModel* theModel = model(); + if ( !theModel ) return eltIndex; + + QModelIndexList theIndexes = theModel->match( theModel->index(0, 0), + role, + anEntry, + 1, + Qt::MatchRecursive | Qt::MatchContains );//Qt::MatchFixedString ); + if ( theIndexes.count()>0 ) + eltIndex = theIndexes[0] ; + return eltIndex; } -void PatternDataSelectionModel::SetSelectionMode(Selection_Mode theMode) +QModelIndexList SelectionModel::indexListOf( const QString& anEntry, int role ) { - MESSAGE("PatternDataSelectionModel::SetSelectionMode(){"); - SVTK_ViewWindow* aVTKViewWindow = _getVTKViewWindow(); -// aViewWindow->clearFilters(); -// _salomeSelectionMgr->clearFilters(); - if ( aVTKViewWindow ) - aVTKViewWindow->SetSelectionMode( theMode ); - MESSAGE("}"); + QModelIndexList theIndexes; // element (vertex, edge, quad) of model + const QAbstractItemModel* theModel = model(); + if ( !theModel ) return theIndexes; + theIndexes = theModel->match( theModel->index(0, 0), + role, + anEntry, + -1, + Qt::MatchRecursive | Qt::MatchContains );//Qt::MatchFixedString ); + return theIndexes; +} + +DocumentModel* SelectionModel::getDocModel() const +{ + DocumentModel* docModel = NULL; + const QSortFilterProxyModel *pModel = dynamic_cast( model() ); + if ( pModel != NULL) + docModel = dynamic_cast( pModel->sourceModel() ); + + return docModel; +} + +void SelectionModel::showEltInfo(QModelIndex& elt) +{ + DocumentModel* docModel = getDocModel(); + if (!elt.isValid() || docModel == NULL) + return; + + HEXA_NS::Vertex* vertex = docModel->getHexaPtr(elt); + HEXA_NS::Edge* edge = docModel->getHexaPtr(elt); + HEXA_NS::Quad* quad = docModel->getHexaPtr(elt); + HEXA_NS::Hexa* hexa = docModel->getHexaPtr(elt); + HEXA_NS::Vector* vector = docModel->getHexaPtr(elt); + HEXA_NS::Group* group = docModel->getHexaPtr(elt); + HEXA_NS::Law* law = docModel->getHexaPtr(elt); + HEXA_NS::Propagation* propagation = docModel->getHexaPtr(elt); + + HEXABLOCKGUI* hexagui = HEXABLOCKGUI::getInstance(); + if (vertex != NULL) + hexagui->showVertexInfoDialog(vertex); + else if (edge != NULL) + hexagui->showEdgeInfoDialog(edge); + else if (quad != NULL) + hexagui->showQuadInfoDialog(quad); + else if (hexa != NULL) + hexagui->showHexaInfoDialog(hexa); + else if (vector != NULL) + hexagui->showVectorInfoDialog(vector); + else if (group != NULL) + hexagui->showGroupInfoDialog(group); + else if (law != NULL) + hexagui->showLawInfoDialog(law); + else if (propagation != NULL) + hexagui->showPropagationInfoDialog(propagation); +} + +void SelectionModel::salomeSelectionChanged() +{ + // clear highlights and selections in the trees + PatternDataSelectionModel* pdsm = HEXABLOCKGUI::currentDocGView->getPatternDataSelectionModel(); +// PatternBuilderSelectionModel* pbsm = HEXABLOCKGUI::currentDocGView->getPatternBuilderSelectionModel(); + PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel(); + pdsm->clearSelection(); +// pbsm->clearSelection(); + pgsm->clearSelection(); + pdsm->unhighlightTreeItems(); + pgsm->unhighlightTreeItems(); + + try { + SALOME_ListIO selectedObjects; + Handle(SALOME_InteractiveObject) anIObject; + + switch (HEXABLOCKGUI::getActiveViewType()) + { + case HEXABLOCKGUI::VTK: + { + HEXABLOCKGUI::currentDocGView->getSelected(selectedObjects); + if ( selectedObjects.IsEmpty() ) + return; + anIObject = selectedObjects.First(); + vtkSelectionChanged( anIObject ); + break; + } + case HEXABLOCKGUI::OCC: + HEXABLOCKGUI::currentOccGView->getSelected(selectedObjects); + if ( selectedObjects.IsEmpty() ) + return; + anIObject = selectedObjects.First(); + geomSelectionChanged( anIObject ); + break; + } + } catch ( ... ) { + MESSAGE("* Unknown selection exception!"); + } } -// A) De Salome(OCC, VTK) vers Hexablock(TreeView Data) : -// -Vertex: -// in: selection (vertex associé OCC). -// out: (vertex VTK) highlighté, (vertex TreeView) sélectionné. -// -// in : selection (vertex associé VTK). -// out: (vertex OCC) highlighté, (vertex TreeView) sélectionné. -// -// -Edge: -// in: selection (edge associé OCC). -// out: (vertex VTK) highlighté, (vertex TreeView) sélectionné. -// -// in: selection (edge associé VTK). -// out: (toute la ligne OCC) highlighté + vertex sur (deb,fin) , (edge TreeView) sélectionné. -// -// -Face: idem vertex -void PatternDataSelectionModel::onCurrentChanged( const QModelIndex & current, const QModelIndex & previous ) +QModelIndexList SelectionModel::getSelectionFromModel(const Handle(SALOME_InteractiveObject)& anIObject) { - MESSAGE("PatternDataSelectionModel::onCurrentChanged(){"); - MESSAGE("* current : " << current.data().toString().toStdString()); - MESSAGE("* previous : " << previous.data().toString().toStdString()); -// _selectSalome( current, true ); -// _selectSalome( previous, false ); - MESSAGE("}"); -} + QModelIndexList selectedIndexes; + //verify if the IOBject is valid and from VTK selection + bool fromVTK = ( strcmp("HEXABLOCK", anIObject->getComponentDataType()) == 0 ); + if ( !fromVTK || !anIObject->hasEntry() || HEXABLOCKGUI::currentDocGView->getViewWindow() == NULL) + return selectedIndexes; + QString anIOEntry = anIObject->getEntry(); + int anhexaElemsId; + QString aText = ""; -void PatternDataSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected ) -{ - MESSAGE("PatternDataSelectionModel::onSelectionChanged(){"); - foreach( const QModelIndex& isel, selected.indexes() ){ - MESSAGE("* selected : " << isel.data().toString().toStdString()); - } - foreach( const QModelIndex& iunsel, deselected.indexes() ){ - MESSAGE("* unselected : " << iunsel.data().toString().toStdString()); - } - - _theModelSelectionChanged = true; - try { - if ( _salomeSelectionMgr == NULL ) return; -// if ( !_theVtkSelectionChanged and !_theGeomSelectionChanged ) return; - - _salomeSelectionMgr->clearSelected(); - // erasePreview(true); - QModelIndexList indexes = selected.indexes(); - for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){ - // std::cout << "entry selected" << i_index->data( HEXA_ENTRY_ROLE ).toString().toStdString() << std::endl; - if ( !_theVtkSelectionChanged ) _selectVTK( *i_index ); - if ( !_theGeomSelectionChanged ) _highlightGEOM( *i_index ); - } - // CS_BP todo SALOMEGUI_Swig.cxx:370 - // indexes = deselected.indexes(); - // for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ) - // _unselectSalome( *i_index); - } catch ( ... ) { - MESSAGE("Unknown exception was cought !!!"); - } - _theModelSelectionChanged = false; - - MESSAGE("}"); -} - + //extract vtk selection from the model ----------- + if ( GetNameOfSelectedElements( HEXABLOCKGUI::currentDocGView->getViewWindow(), anIObject, aText ) <= 0 ) + return selectedIndexes; -void PatternDataSelectionModel::salomeSelectionChanged() -{ - MESSAGE("PatternDataSelectionModel::salomeSelectionChanged(){"); - try { - QModelIndex toSelect; - - if ( _salomeSelectionMgr == NULL ) return; - SALOME_ListIO salomeSelected; - // _salomeSelectionMgr->selectedObjects( salomeSelected, SVTK_Viewer::Type() );//salomeSelected.Extent() - _salomeSelectionMgr->selectedObjects( salomeSelected, NULL, false ); - if ( salomeSelected.IsEmpty() ){ - MESSAGE("* salomeSelected.IsEmpty()"); - clearSelection(); - return; - } + Document_Actor* docActor = dynamic_cast( findActorByEntry( HEXABLOCKGUI::currentDocGView->getViewWindow(), + anIOEntry.toLatin1() ) ); + if ( !docActor ) return selectedIndexes; + QStringList idList = aText.split(" "); + foreach( const QString& id, idList ) + { + if (!id.isEmpty()) + { + //find selection in the model + anhexaElemsId = docActor->hexaElemsId[ id.toInt() ]; + anIOEntry = QString::number( anhexaElemsId ); - Handle(SALOME_InteractiveObject) anIObject; - SALOME_ListIteratorOfListIO it(salomeSelected); - for( ; it.More(); it.Next()){ - anIObject = it.Value(); //anIObject->getName() - toSelect = _geomSelectionChanged( anIObject );// is it comming from GEOM? - if ( !toSelect.isValid() ){ - toSelect = _vtkSelectionChanged( anIObject ); ;// or VTK?... - if ( toSelect.isValid() ) - MESSAGE("* OK : selection from VTK"); - } else { - MESSAGE("* OK : selection from GEOM"); - } - } - } catch ( ... ) { - MESSAGE("* Unknown exception was cought !!!"); - } - MESSAGE("}"); + selectedIndexes << indexOf( anIOEntry, HEXA_ENTRY_ROLE ); + } + } + return selectedIndexes; } -SVTK_ViewWindow* PatternDataSelectionModel::_getVTKViewWindow() +// //=========================================================================== +// PatternDataSelectionModel +// //=========================================================================== + +PatternDataSelectionModel::PatternDataSelectionModel( QAbstractItemModel * model ): +SelectionModel( model ) { - SVTK_ViewWindow* aVtkView = HEXABLOCKGUI::currentVtkView; - return aVtkView; -} + connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), + this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ), Qt::UniqueConnection ); + connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ), + this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ), Qt::UniqueConnection ); +} -OCCViewer_ViewWindow* PatternDataSelectionModel::_getOCCViewWindow() +PatternDataSelectionModel::~PatternDataSelectionModel() { - OCCViewer_ViewWindow* aOccView = HEXABLOCKGUI::currentOccView; - return aOccView; + disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), + this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) ); + disconnect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ), + this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) ); } -QModelIndex PatternDataSelectionModel::_indexOf( const QString& anEntry, int role ) +void PatternDataSelectionModel::onCurrentChanged( const QModelIndex & current, const QModelIndex & previous ) { - QModelIndex eltIndex; // element (vertex, edge, quad) of model - const QAbstractItemModel* theModel = model(); - if ( !theModel ) return eltIndex; - QModelIndexList theIndexes = theModel->match( theModel->index(0, 0), - role, - anEntry, - 1, - Qt::MatchRecursive | Qt::MatchContains );//Qt::MatchFixedString ); - if ( theIndexes.count()>0 ) - eltIndex = theIndexes[0] ; - return eltIndex; + //Setting the selection mode of the selected item from the treeview + HEXABLOCKGUI::currentDocGView->setSelectionMode( current ); + HEXABLOCKGUI::currentOccGView->setSelectionMode( current ); } - -void PatternDataSelectionModel::_setVTKSelectionMode( const QModelIndex& eltIndex, SVTK_ViewWindow* vtkViewWindow ) +void PatternDataSelectionModel::highlightTreeItems(QModelIndexList& indexes, + Qt::GlobalColor bgColor, + Qt::GlobalColor fgColor, bool only) { - MESSAGE("PatternDataSelectionModel::_setVTKSelectionMode( "<< eltIndex.data().toString().toStdString() << " ," << vtkViewWindow << " )"); - QVariant treeVariant = eltIndex.data( HEXA_TREE_ROLE ); - if ( !treeVariant.isValid() ) return; - int eltType = treeVariant.toInt(); - - if ( (_selectionFilter != -1) and ( _selectionFilter != eltType ) ) return; - - switch ( eltType ){ - case VERTEX_TREE : - case VERTEX_DIR_TREE : vtkViewWindow->SetSelectionMode(NodeSelection); MESSAGE("VERTEX"); break; - case EDGE_TREE : - case EDGE_DIR_TREE : vtkViewWindow->SetSelectionMode(EdgeSelection); MESSAGE("EDGE"); break; - case QUAD_TREE : - case QUAD_DIR_TREE : vtkViewWindow->SetSelectionMode(FaceSelection); MESSAGE("QUAD"); break; - case HEXA_TREE : - case HEXA_DIR_TREE : vtkViewWindow->SetSelectionMode(VolumeSelection); MESSAGE("HEXA"); break; - case PROPAGATION_TREE : - case PROPAGATION_DIR_TREE : vtkViewWindow->SetSelectionMode(EdgeSelection); MESSAGE("PROPAGATION"); break; -// CellSelection, -// EdgeOfCellSelection, -// VolumeSelection, -// ActorSelection - } -} + if (indexes.count() == 0) + return; + if (only) + unhighlightTreeItems(); + // * highlight item + QAbstractItemModel* theModel = (QAbstractItemModel*) model(); + foreach( const QModelIndex& anItemIndex, indexes ) + { + if (anItemIndex.isValid()) + { + theModel->setData(anItemIndex, fgColor, Qt::ForegroundRole); + theModel->setData(anItemIndex, bgColor, Qt::BackgroundRole); + currentHighlightedItems << anItemIndex; + } + } -void PatternDataSelectionModel::highlightVTKElts( const QModelIndexList& elts ) -{ - if (!elts.size()) return; - - SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow(); - if ( currentVTKViewWindow == NULL ) return; - SVTK_Selector* selector = currentVTKViewWindow->GetSelector(); - if ( selector == NULL ) return; - - // document selection - Document_Actor* docActor = NULL; - Handle(SALOME_InteractiveObject) docIO; - - // element highlight - TColStd_MapOfInteger aMap; - QList::const_iterator anIter; - int vtkElemsId; - - // data from model - QString docEntry; - QVariant docEntryVariant = elts[0].data( HEXA_DOC_ENTRY_ROLE ); - - if ( !docEntryVariant.isValid() ){ - //INFOS("data from model not valid"); - return; - } - - docEntry = docEntryVariant.toString(); - - // Select the document in Salome - docActor = dynamic_cast( findActorByEntry( currentVTKViewWindow, docEntry.toLatin1() ) ); - if ( docActor == NULL) return; - - // // Set selection mode in VTK view -// currentVTKViewWindow->SetSelectionMode(EdgeSelection); - docIO = docActor->getIO(); - - // Highlight in vtk view the element from document - QString edgeEntry; - foreach( const QModelIndex& iElt, elts ){ - edgeEntry = iElt.data( HEXA_ENTRY_ROLE ).toString(); - vtkElemsId = docActor->vtkElemsId[ edgeEntry.toInt() ]; - if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId ); - } - - selector->AddOrRemoveIndex( docIO, aMap, false ); - currentVTKViewWindow->highlight( docIO, true, true ); + // * scroll to the first highlighted item in the tree + HEXABLOCKGUI* module = HEXABLOCKGUI::getInstance(); + if (module != NULL && indexes[0].isValid()) + module->getPatternDataTreeView()->scrollTo(indexes[0]); } -// 1 vertex -> 1 point -// 1 edge -> n lines + points(deb,fin) -// 1 quad -> n faces -void PatternDataSelectionModel::_highlightGEOM( const QMultiMap& entrySubIDs ) +void PatternDataSelectionModel::unhighlightTreeItems(bool clearSelected) { - MESSAGE("PatternDataSelectionModel::_highlightGEOM( const QMultiMap& entrySubIDs ){"); - - OCCViewer_ViewWindow* occView = _getOCCViewWindow(); - if ( occView == NULL ) return; - SOCC_Viewer* soccViewer = dynamic_cast( occView->getViewManager()->getViewModel() ); - if (!soccViewer) return; - _PTR(Study) aStudy = GetActiveStudyDocument(); - if (!aStudy) return; - - CORBA::Object_var aCorbaObj = CORBA::Object::_nil(); - GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_nil(); - erasePreview(true); - foreach ( QString entry, entrySubIDs.keys() ){ - _PTR(SObject) aSChild = aStudy->FindObjectID( entry.toStdString() ); - MESSAGE("* entry => "<< entry.toStdString()); - aCorbaObj = corbaObj( aSChild ); - aGeomObj = GEOM::GEOM_Object::_narrow( aCorbaObj ); - if ( !CORBA::is_nil(aGeomObj) ){ - MESSAGE("* !CORBA::is_nil(aGeomObj)"); - QString objIOR = GEOMBase::GetIORFromObject( aGeomObj._retn() ); - Handle(GEOM_AISShape) aSh = GEOMBase::ConvertIORinGEOMAISShape( objIOR );//, true ); - if ( !aSh.IsNull() ){ - MESSAGE("* !aSh.IsNull() "); - TColStd_IndexedMapOfInteger anIndexes; - foreach ( int subid, entrySubIDs.values(entry) ){ - if ( subid != -1 ) - anIndexes.Add( subid ); - } - if ( anIndexes.Extent() > 0 ){ // if it's a sub-shape - MESSAGE("* a sub-shape"); - aSh->highlightSubShapes( anIndexes, true ); - soccViewer->Repaint(); - } else { // or a main shape -// std::cout << "aSh->getIO() => " << aSh->getIO() << std::endl; -// getDisplayer()->SetDisplayMode(0); -// soccViewer->setColor( aSh->getIO(), QColor( Qt::red ), true ); -// soccViewer->switchRepresentation( aSh->getIO(), 2 ); - MESSAGE("* a main shape"); -// globalSelection(); - soccViewer->highlight( aSh->getIO(), true, true ); + if (clearSelected) + clearSelection(); + if (currentHighlightedItems.count() == 0) + return; + + QAbstractItemModel* theModel = (QAbstractItemModel*) model(); + foreach( const QModelIndex& anItemIndex, currentHighlightedItems) + { + if (anItemIndex.isValid()) + { + theModel->setData(anItemIndex, Qt::darkGreen, Qt::ForegroundRole); + theModel->setData(anItemIndex, Qt::white, Qt::BackgroundRole); } - } } - } - - MESSAGE("}"); + currentHighlightedItems.clear(); } - -void PatternDataSelectionModel::_highlightGEOM( const QModelIndex & anEltIndex ) +QModelIndexList PatternDataSelectionModel::getGeomAssociations(const QModelIndex& dataIndex) { - MESSAGE("PatternDataSelectionModel::_highlightGEOM(" << anEltIndex.data().toString().toStdString() << ")"); - // getting association(s) from model - QList assocs; - QMultiMap< QString, int > assocEntrySubIDs; - DocumentModel *docModel = NULL; - const QSortFilterProxyModel *pModel = dynamic_cast( model() ); - - if ( !pModel ) return; - docModel = dynamic_cast( pModel->sourceModel() ); - if ( !docModel ) return; - assocs = docModel->getAssociations( pModel->mapToSource(anEltIndex) ); - foreach( const DocumentModel::GeomObj& anAssoc, assocs ) - assocEntrySubIDs.insert( anAssoc.entry, anAssoc.subid.toInt() ); - - _highlightGEOM( assocEntrySubIDs ); - MESSAGE("}"); -} + QModelIndexList geomIndexList; + DocumentModel* docModel = getDocModel(); + PatternGeomSelectionModel* pGSModel = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel(); + if (docModel == NULL || pGSModel == NULL) + return geomIndexList; + const QSortFilterProxyModel *pModel = dynamic_cast( model() ); + HEXA_NS::Vertex* vertex = docModel->getHexaPtr(dataIndex); + HEXA_NS::Edge* edge = docModel->getHexaPtr(dataIndex); + HEXA_NS::Quad* quad = docModel->getHexaPtr(dataIndex); + QModelIndex index = pModel->mapToSource(dataIndex); + if (vertex != NULL) + geomIndexList << docModel->getVertexAssociation( index ); + else if (edge != NULL) + geomIndexList = docModel->getEdgeAssociations( index ); + else if ( quad != NULL) + geomIndexList = docModel->getQuadAssociations( index ); -void PatternDataSelectionModel::_selectVTK( const QModelIndex& eltIndex ) -{ - MESSAGE("PatternDataSelectionModel::_selectVTK( "<< eltIndex.data().toString().toStdString() << ")"); - SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow(); - if ( currentVTKViewWindow == NULL ) return; - SVTK_Selector* selector = currentVTKViewWindow->GetSelector(); - if ( selector == NULL ) return; - - // document selection - Document_Actor* docActor = NULL; - Handle(SALOME_InteractiveObject) docIO; - SALOME_ListIO aList; - - // element highlight - TColStd_MapOfInteger aMap; - QList::const_iterator anIter; - int vtkElemsId; - - // data from model - QString eltEntry; - QString docEntry; - QVariant entryVariant = eltIndex.data( HEXA_ENTRY_ROLE ); - QVariant docEntryVariant = eltIndex.data( HEXA_DOC_ENTRY_ROLE ); - - if ( !entryVariant.isValid() ){ - //INFOS("entryVariant not valid"); - return; - } - if ( !docEntryVariant.isValid() ){ - //INFOS("docEntryVariant not valid"); - return; - } - - eltEntry = entryVariant.toString(); - docEntry = docEntryVariant.toString(); - - // Select the document in Salome - docActor = dynamic_cast( findActorByEntry( currentVTKViewWindow, docEntry.toLatin1() ) ); - if ( docActor == NULL ) return; - - // Set selection mode in VTK view - _setVTKSelectionMode( eltIndex, currentVTKViewWindow ); - -// if ( _salomeSelectionMgr == NULL ) return; -// _salomeSelectionMgr->selectedObjects( aList ); -// std::cout<<"aList.Extent() => " << aList.Extent() << std::endl; -// aList.Append(docIO); -// _salomeSelectionMgr->setSelectedObjects( aList, true );//false );//true ); //CS_BP false? - docIO = docActor->getIO(); - - // Highlight in vtk view the element from document - vtkElemsId = docActor->vtkElemsId[ eltEntry.toInt() ];// get vtk ids from actor - if ( vtkElemsId > 0 ) // CS_BP ?: erreur si 1er elt == vertex (0,0,0) - aMap.Add( vtkElemsId ); -// for (anIter = theIds.begin(); anIter != theIds.end(); ++anIter) { -// aMap.Add(*anIter); -// } - selector->AddOrRemoveIndex( docIO, aMap, false ); - currentVTKViewWindow->highlight( docIO, true, true ); - - MESSAGE("}"); + return geomIndexList; } -QModelIndex PatternDataSelectionModel::_geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ) +void PatternDataSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected ) { - MESSAGE("PatternDataSelectionModel::_geomSelectionChanged(){"); - QModelIndex eltIndex;// the element of the model which is associated to the geom object and that is to be selected + QModelIndexList indexes = selected.indexes(); + int nbSelected = indexes.count(); + if (nbSelected == 0) + return; - bool fromGEOM = ( strcmp("GEOM", anIObject->getComponentDataType()) == 0 ); - if ( !fromGEOM ) return eltIndex; - if (!_salomeSelectionMgr) return eltIndex; + // ** unhighlight current highlighted items in the trees + PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel(); + if (pgsm == NULL) + return; + unhighlightTreeItems(false); - QString aName; - GEOM::GEOM_Object_var aGeomObj = GEOMBase::ConvertIOinGEOMObject( anIObject ); + QModelIndexList associatedGeomIndexes = getGeomAssociations(indexes[0]); //Mono Selection + if (associatedGeomIndexes.count() == 0) + pgsm->unhighlightTreeItems(); - int anIndex = -1; - if ( GEOMBase::IsShape(aGeomObj) ){ - aName = GEOMBase::GetName(aGeomObj); - TColStd_IndexedMapOfInteger anIndexes; - _salomeSelectionMgr->GetIndexes(anIObject, anIndexes); - if ( anIndexes.Extent() == 1 ) - anIndex = anIndexes(1); - QString aGeomObjStudyEntry = aGeomObj->GetStudyEntry(); - QString aGeomObjModelEntry = aGeomObjStudyEntry + "," + QString::number(anIndex) + ";"; - eltIndex = _indexOf( aGeomObjModelEntry, HEXA_ASSOC_ENTRY_ROLE ); - if ( !_theModelSelectionChanged && eltIndex.isValid() ){ // select in model - _theGeomSelectionChanged = true; - // select( newIndex, QItemSelectionModel::ClearAndSelect ); - // select( newIndex, QItemSelectionModel::SelectCurrent ); -// setCurrentIndex( eltIndex, QItemSelectionModel::SelectCurrent ); - setCurrentIndex( eltIndex, QItemSelectionModel::Clear ); //CS_TEST - setCurrentIndex( eltIndex, QItemSelectionModel::SelectCurrent ); - _theGeomSelectionChanged = false; - - } else { - clearSelection(); - } - } + // ** highlight association in geometry tree + pgsm->highlightTreeItems(associatedGeomIndexes); - MESSAGE("}"); - return eltIndex; + // ** highlight association in the vtk view + HEXABLOCKGUI::currentDocGView->highlight(indexes); + + // ** highlight association in the occ view + HEXABLOCKGUI::currentOccGView->highlight(indexes); + + if (!infoMode || nbSelected > 1) + return; + + // ** Show informations of the selected element + QModelIndex elt = indexes[0]; + showEltInfo(elt); } -QModelIndex PatternDataSelectionModel::_vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ) +void PatternDataSelectionModel::geomSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ) { - MESSAGE("PatternDataSelectionModel::_vtkSelectionChanged(){"); - QModelIndex anIOIndex;// // the element of the model which is associated to the Interactive object and that is to be selected - - bool fromVTK = ( strcmp("HEXABLOCK", anIObject->getComponentDataType()) == 0 ); - if ( !fromVTK ) return anIOIndex; - SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow(); - if ( !currentVTKViewWindow ) return anIOIndex; - if ( !anIObject->hasEntry() ) return anIOIndex; - - QString anIOEntry = anIObject->getEntry(); - Document_Actor *anDocActor = NULL; - int anhexaElemsId; - - QString aText = ""; - if ( GetNameOfSelectedElements( currentVTKViewWindow, anIObject, aText ) <= 0 ) return anIOIndex; - anDocActor = dynamic_cast( findActorByEntry( currentVTKViewWindow, anIOEntry.toLatin1() ) ); - if ( !anDocActor ) return anIOIndex; - anhexaElemsId = anDocActor->hexaElemsId[ aText.toInt() ]; - anIOEntry = QString::number( anhexaElemsId ); - anIOIndex = _indexOf( anIOEntry, HEXA_ENTRY_ROLE ); - - if ( !_theModelSelectionChanged && anIOIndex.isValid() ){ // select in model - _theVtkSelectionChanged = true; -// select( anIOIndex, QItemSelectionModel::Clear ); -// select( anIOIndex, QItemSelectionModel::Select ); -// select( anIOIndex, QItemSelectionModel::ClearAndSelect ); -// select( anIOIndex, QItemSelectionModel::SelectCurrent ); -// setCurrentIndex( anIOIndex, QItemSelectionModel::SelectCurrent ); -// setCurrentIndex( anIOIndex, QItemSelectionModel::SelectCurrent ); -// setCurrentIndex( anIOIndex, QItemSelectionModel::ClearAndSelect ); -// setCurrentIndex( anIOIndex, QItemSelectionModel::ClearAndSelect ); - setCurrentIndex( anIOIndex, QItemSelectionModel::Clear ); - setCurrentIndex( anIOIndex, QItemSelectionModel::SelectCurrent ); - _theVtkSelectionChanged = false; - } else { - clearSelection(); - } - -// if (anIOIndex.isValid()) -// _selectVTK(anIOIndex); - - if (anIOIndex.isValid()) - { - QModelIndexList l; - l << anIOIndex; - highlightVTKElts(l); - } - - MESSAGE("}"); - return anIOIndex; -} +// if (HEXABLOCKGUI::assocInProgress) return; + PatternGeomSelectionModel* pgsm = HEXABLOCKGUI::currentDocGView->getPatternGeomSelectionModel(); + if (pgsm == NULL) return; + QModelIndex geomModelIndex = pgsm->getModelIndex(anIObject); + if (!geomModelIndex.isValid()) + return; + pgsm->select( geomModelIndex, QItemSelectionModel::SelectCurrent ); +} +void PatternDataSelectionModel::vtkSelectionChanged( const Handle(SALOME_InteractiveObject)& anIObject ) +{ + QModelIndexList selectedIndexes = getSelectionFromModel(anIObject); + if (selectedIndexes.count() == 0) + { + clearSelection(); + return; + } + QModelIndex anIOIndex = selectedIndexes[0]; //Monoselection + + //Temporary Debug for hexa selection ------------------------------ + if (HEXABLOCKGUI::currentDocGView->getSelectionMode() == HEXA_TREE) + { + DocumentModel* docModel = getDocModel(); + if ( docModel != NULL && anIOIndex.isValid()) + { + //get the selected quad + HEXA_NS::Quad* quad = docModel->getHexaPtr(anIOIndex); + + if (quad != NULL) + { + //get the hexa the quad belongs to + HEXA_NS::Hexa* hexa = docModel->getQuadHexa(quad); + if (hexa != NULL) //convert the hexa to a QModelIndex so we can select it in the model + anIOIndex = indexBy( HEXA_DATA_ROLE, QVariant::fromValue(hexa)); + else + { + SUIT_MessageBox::critical( 0, + tr("HexaBlock"), + tr("The Hexahedron this quad belongs to has been deleted!")); + return; + } + } + } + }//end if HEXA_TREE----------------------------------------------- + //select the element in the model + select( anIOIndex, QItemSelectionModel::SelectCurrent ); +} +// //=========================================================================== +// PatternGeomSelectionModel +// //=========================================================================== -GroupsSelectionModel::GroupsSelectionModel( QAbstractItemModel * model ): -QItemSelectionModel( model ) +PatternGeomSelectionModel::PatternGeomSelectionModel( QAbstractItemModel * model ): +SelectionModel( model ) { connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) ); connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ), - this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) ); + this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ), Qt::UniqueConnection ); } - -GroupsSelectionModel::~GroupsSelectionModel() +PatternGeomSelectionModel::~PatternGeomSelectionModel() { disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) ); @@ -679,226 +492,150 @@ GroupsSelectionModel::~GroupsSelectionModel() this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) ); } - - - -QModelIndex GroupsSelectionModel::indexBy( int role, const QVariant& var ) +void PatternGeomSelectionModel::onCurrentChanged( const QModelIndex & current, const QModelIndex & previous ) { - QModelIndex eltIndex; // element (vertex, edge, quad) of model - const QAbstractItemModel* theModel = model(); - if ( !theModel ) return eltIndex; - QModelIndexList theIndexes = theModel->match( theModel->index(0, 0), - role, - var, - 1, - Qt::MatchRecursive /*| Qt::MatchContains*/ );//Qt::MatchFixedString ); - if ( theIndexes.count()>0 ) - eltIndex = theIndexes[0] ; - return eltIndex; + //Setting the selection mode of the selected item from the treeview} + HEXABLOCKGUI::currentDocGView->setSelectionMode( current ); + HEXABLOCKGUI::currentOccGView->setSelectionMode( current ); } - -SVTK_ViewWindow* GroupsSelectionModel::_getVTKViewWindow() +void PatternGeomSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected ) { - SVTK_ViewWindow* aVtkView = HEXABLOCKGUI::currentVtkView; - return aVtkView; -} + DocumentModel* docModel = NULL; + const QSortFilterProxyModel *pModel = dynamic_cast( model() ); + if ( pModel != NULL) + docModel = dynamic_cast(pModel->sourceModel()); + QModelIndexList indexes = selected.indexes(); + if (indexes.count() == 0 || docModel == NULL) + return; -void GroupsSelectionModel::_highlightGroups( const QModelIndex& eltIndex ) -{ - const GroupsModel* m = dynamic_cast( model() ); - -// ---- VTK ---- - if ( m == NULL ) return; - SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow(); - if ( currentVTKViewWindow == NULL ) return; - SVTK_Selector* selector = currentVTKViewWindow->GetSelector(); - if ( selector == NULL ) return; - -// ---- vtkActor - // document selection - Document_Actor* docActor = NULL; - Handle(SALOME_InteractiveObject) docIO; - SALOME_ListIO aList; - - // element highlight - TColStd_MapOfInteger aMap; - QList::const_iterator anIter; - int vtkElemsId; - - - - // debut ** data from model - int eltType; - QString docEntry; - - QVariant treeVariant = eltIndex.data( HEXA_TREE_ROLE ); - QVariant docEntryVariant = eltIndex.data( HEXA_DOC_ENTRY_ROLE ); - - if ( !treeVariant.isValid() || !docEntryVariant.isValid() ){ - //INFOS("data from model not valid"); - return; - } - - eltType = treeVariant.toInt(); - docEntry = docEntryVariant.toString(); - - if ( eltType != GROUP_TREE ){ - //INFOS("bad element type : not a group item" << eltType ); - return; - } - // fin ** data from model - - // Select the document in Salome - docActor = dynamic_cast( findActorByEntry( currentVTKViewWindow, docEntry.toLatin1() ) ); - if ( docActor == NULL) return; - docIO = docActor->getIO(); - - // Highlight in vtk view the element from document - DocumentModel::Group kind; - QModelIndexList iElements = m->getGroupElements( eltIndex, kind ); - - // Set selection mode in VTK view - switch (kind){ - case HEXA_NS::HexaCell: case HEXA_NS::HexaNode: currentVTKViewWindow->SetSelectionMode(VolumeSelection); break; - case HEXA_NS::QuadCell: case HEXA_NS::QuadNode: currentVTKViewWindow->SetSelectionMode(FaceSelection); break; - case HEXA_NS::EdgeCell: case HEXA_NS::EdgeNode: currentVTKViewWindow->SetSelectionMode(EdgeSelection); break; - case HEXA_NS::VertexNode: currentVTKViewWindow->SetSelectionMode(NodeSelection); break; - } - - QString eltEntry; - foreach( const QModelIndex& iElt, iElements ){ - eltEntry = iElt.data( HEXA_ENTRY_ROLE ).toString(); - vtkElemsId = docActor->vtkElemsId[ eltEntry.toInt() ]; - if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId ); - } - - selector->AddOrRemoveIndex( docIO, aMap, false ); - currentVTKViewWindow->highlight( docIO, true, true ); + // ** unhighlight current highlighted items in the trees + PatternDataSelectionModel* pdsm = HEXABLOCKGUI::currentDocGView->getPatternDataSelectionModel(); + if (pdsm == NULL) + return; + unhighlightTreeItems(false); -} + //find the corresponding element in the model + HEXA_NS::SubShape* eltSubShape = dynamic_cast(docModel->getHexaPtr(indexes[0])); + if (eltSubShape == NULL) return; -/* -void GroupsSelectionModel::_highlightAssoc( const QModelIndex& eltIndex ) -{ - const GroupsModel* m = dynamic_cast( model() ); - -// ---- VTK ---- - if ( m == NULL ) return; - SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow(); - if ( currentVTKViewWindow == NULL ) return; - SVTK_Selector* selector = currentVTKViewWindow->GetSelector(); - if ( selector == NULL ) return; - -// ---- vtkActor - // document selection - Document_Actor* docActor = NULL; - Handle(SALOME_InteractiveObject) docIO; - SALOME_ListIO aList; - - // element highlight - TColStd_MapOfInteger aMap; - QList::const_iterator anIter; - int vtkElemsId; - - - - // debut ** data from model - int eltType; - QString docEntry; - - QVariant treeVariant = eltIndex.data( HEXA_TREE_ROLE ); - QVariant docEntryVariant = eltIndex.data( HEXA_DOC_ENTRY_ROLE ); - - if ( !treeVariant.isValid() || !docEntryVariant.isValid() ){ - //INFOS("data from model not valid"); - return; - } - - eltType = treeVariant.toInt(); - docEntry = docEntryVariant.toString(); - ){ - //INFOS("bad element typ - if ( eltType != GROUP_TREE ){ - //INFOS("bad element type : not a group item" << eltType ); - return; - } - // fin ** data from model - - // Select the document in Salome - docActor = dynamic_cast( findActorByEntry( currentVTKViewWindow, docEntry.toLatin1() ) ); - if ( docActor == NULL) return; - docIO = docActor->getIO(); - - // Highlight in vtk view the element from document - DocumentModel::Group kind; - QModelIndexList iElements = m->getGroupElements( eltIndex, kind ); - - // Set selection mode in VTK view -/* - switch (kind){ - case HEXA_NS::HexaCell: case HEXA_NS::HexaNode: currentVTKViewWindow->SetSelectionMode(VolumeSelection); break; - case HEXA_NS::QuadCell: case HEXA_NS::QuadNode: currentVTKViewWindow->SetSelectionMode(FaceSelection); break; - case HEXA_NS::EdgeCell: case HEXA_NS::EdgeNode: currentVTKViewWindow->SetSelectionMode(EdgeSelection); break; - case HEXA_NS::VertexNode: currentVTKViewWindow->SetSelectionMode(NodeSelection); break; - }---/ - - QString eltEntry; - foreach( const QModelIndex& iElt, iElements ){ - eltEntry = iElt.data( HEXA_ENTRY_ROLE ).toString(); - vtkElemsId = docActor->vtkElemsId[ eltEntry.toInt() ]; - if() - if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId ); - } - - selector->AddOrRemoveIndex( docIO, aMap, false ); - currentVTKViewWindow->highlight( docIO, true, true ); - -}*/ + HEXA_NS::NewShape* subShapeParent = eltSubShape->getParentShape(); + if (subShapeParent == NULL) return; + QString parentShapeName = subShapeParent->getName(); + QString subId = QString::number(eltSubShape->getIdent()); + QString aGeomObjModelEntry = parentShapeName + "," + subId + ";"; + QModelIndexList assocsIndexes = pdsm->indexListOf(aGeomObjModelEntry, HEXA_ASSOC_ENTRY_ROLE); + if (assocsIndexes.count() == 0) + pdsm->unhighlightTreeItems(); -void GroupsSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected ) -{ - MESSAGE("GroupsSelectionModel::onSelectionChanged"); - try { - // if ( _salomeSelectionMgr == NULL ) return; - // _salomeSelectionMgr->clearSelected(); - // erasePreview(true); - QModelIndexList indexes = selected.indexes(); - for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){ - MESSAGE( "entry selected" << i_index->data( HEXA_ENTRY_ROLE ).toString().toStdString() ); - _highlightGroups( *i_index ); - } + // ** highlight associations in the data tree + pdsm->highlightTreeItems(assocsIndexes); - // CS_BP todo SALOMEGUI_Swig.cxx:370 - // indexes = deselected.indexes(); - // for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ) - // _unselectSalome( *i_index); - } catch ( ... ) { - MESSAGE("Unknown exception was cought !!!"); - } + // ** highlight associations in the vtk view + HEXABLOCKGUI::currentDocGView->highlight(assocsIndexes); + // ** highlight the selected element in the occ view + QMultiMap entrySubIDs; + entrySubIDs.insert(parentShapeName, eltSubShape->getIdent()); + HEXABLOCKGUI::currentOccGView->highlight(entrySubIDs); } +QModelIndex PatternGeomSelectionModel::getModelIndex(const Handle(SALOME_InteractiveObject)& anIObject) +{ + QModelIndex result; + DocumentModel *docModel = NULL; + const QSortFilterProxyModel *pModel = dynamic_cast( model() ); + if ( pModel != NULL) + docModel = dynamic_cast( pModel->sourceModel()); + if ( docModel == NULL || HEXABLOCKGUI::selectionMgr() == NULL || + HEXABLOCKGUI::currentOccGView->getViewWindow() == NULL) + return result; + //extract associated elements in the model + TColStd_IndexedMapOfInteger anIndexes; + HEXABLOCKGUI::selectionMgr()->GetIndexes(anIObject, anIndexes); + if (anIndexes.Extent() == 0) return result; + QString aGeomObjStudyEntry = anIObject->getEntry(); + QString aGeomObjModelEntry = docModel->getGeomObjName(aGeomObjStudyEntry) + "," + QString::number(anIndexes(1)); + + HEXA_NS::SubShape* ssh = docModel->getGeomPtr(aGeomObjModelEntry); + HEXA_NS::VertexShape* vSh = dynamic_cast(ssh); + HEXA_NS::EdgeShape* eSh = dynamic_cast(ssh); + HEXA_NS::FaceShape* fSh = dynamic_cast(ssh); + + if (vSh != NULL) + result = indexBy( HEXA_DATA_ROLE, QVariant::fromValue(vSh)); + else if (eSh != NULL) + result = indexBy( HEXA_DATA_ROLE, QVariant::fromValue(eSh)); + else if (fSh != NULL) + result = indexBy( HEXA_DATA_ROLE, QVariant::fromValue(fSh)); + + return result; +} + +void PatternGeomSelectionModel::highlightTreeItems(QModelIndexList& indexes, + Qt::GlobalColor bgColor, + Qt::GlobalColor fgColor, bool only) +{ + if (indexes.count() == 0) + return; + + if (only) + unhighlightTreeItems(); + + // * highlight items + QAbstractItemModel* theModel = (QAbstractItemModel*) model(); + foreach( const QModelIndex& anItemIndex, indexes ) + { + if (anItemIndex.isValid()) + { + theModel->setData(anItemIndex, fgColor, Qt::ForegroundRole); + theModel->setData(anItemIndex, bgColor, Qt::BackgroundRole); + currentHighlightedItems << anItemIndex; + } + } + // * scroll to the first highlighted item in the tree + HEXABLOCKGUI* module = HEXABLOCKGUI::getInstance(); + if (module != NULL && indexes[0].isValid()) + module->getPatternGeomTreeView()->scrollTo(indexes[0]); +} +void PatternGeomSelectionModel::unhighlightTreeItems(bool clearSelected) +{ + if (clearSelected) + clearSelection(); + if (currentHighlightedItems.count() == 0) + return; + QAbstractItemModel* theModel = (QAbstractItemModel*) model(); + foreach( const QModelIndex& anItemIndex, currentHighlightedItems) + { + if (anItemIndex.isValid()) + { + theModel->setData(anItemIndex, Qt::darkGreen, Qt::ForegroundRole); + theModel->setData(anItemIndex, Qt::white, Qt::BackgroundRole); + } + } + currentHighlightedItems.clear(); +} - -MeshSelectionModel::MeshSelectionModel( QAbstractItemModel * model ): -QItemSelectionModel( model ) +// //=========================================================================== +// GroupsSelectionModel +// //=========================================================================== +GroupsSelectionModel::GroupsSelectionModel( QAbstractItemModel * model ): +SelectionModel( model ) { connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), - this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) ); + this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ), Qt::UniqueConnection ); connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ), - this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) ); + this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ), Qt::UniqueConnection ); } - -MeshSelectionModel::~MeshSelectionModel() +GroupsSelectionModel::~GroupsSelectionModel() { disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) ); @@ -906,501 +643,71 @@ MeshSelectionModel::~MeshSelectionModel() this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) ); } - -QModelIndex MeshSelectionModel::indexBy( int role, const QVariant& var ) +void GroupsSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected ) { - QModelIndex eltIndex; // element (vertex, edge, quad) of model - const QAbstractItemModel* theModel = model(); - if ( !theModel ) return eltIndex; - QModelIndexList theIndexes = theModel->match( theModel->index(0, 0), - role, - var, - 1, - Qt::MatchRecursive /*| Qt::MatchContains*/ );//Qt::MatchFixedString ); - if ( theIndexes.count()>0 ) - eltIndex = theIndexes[0] ; - return eltIndex; -} + QModelIndexList indexes = selected.indexes(); + int nbSelected = indexes.count(); + if (nbSelected == 0) + return; + + // ** Highlight the group in the vtk view **/ + try { + for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){ + HEXABLOCKGUI::currentDocGView->highlightGroups( *i_index ); + } + } catch ( ... ) { + MESSAGE("Unknown exception was cought !!!"); + } + if (!infoMode || nbSelected > 1) + return; + // ** Show informations of the selected element **/ + QModelIndex elt = indexes[0]; + showEltInfo(elt); +} -SVTK_ViewWindow* MeshSelectionModel::_getVTKViewWindow() +// //=========================================================================== +// MeshSelectionModel +// //=========================================================================== +MeshSelectionModel::MeshSelectionModel( QAbstractItemModel * model ): + SelectionModel( model ) { - SVTK_ViewWindow* aVtkView = HEXABLOCKGUI::currentVtkView; - return aVtkView; + connect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), + this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ), Qt::UniqueConnection ); + connect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ), + this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ), Qt::UniqueConnection ); } - -void MeshSelectionModel::_highlightPropagation( const QModelIndex& eltIndex ) +MeshSelectionModel::~MeshSelectionModel() { - const MeshModel* m = dynamic_cast( model() ); - if ( m == NULL ) return; - SVTK_ViewWindow* currentVTKViewWindow = _getVTKViewWindow(); - if ( currentVTKViewWindow == NULL ) return; - SVTK_Selector* selector = currentVTKViewWindow->GetSelector(); - if ( selector == NULL ) return; - - // document selection - Document_Actor* docActor = NULL; - Handle(SALOME_InteractiveObject) docIO; - SALOME_ListIO aList; - - // element highlight - TColStd_MapOfInteger aMap; - QList::const_iterator anIter; - int vtkElemsId; - - // data from model - int eltType; - QString docEntry; - - QVariant treeVariant = eltIndex.data( HEXA_TREE_ROLE ); - QVariant docEntryVariant = eltIndex.data( HEXA_DOC_ENTRY_ROLE ); - - if ( !treeVariant.isValid() || !docEntryVariant.isValid() ){ - //INFOS("data from model not valid"); - return; - } - - eltType = treeVariant.toInt(); - docEntry = docEntryVariant.toString(); - - if ( eltType != PROPAGATION_TREE ){ - //INFOS("bad element type : not a propagation item" << eltType ); - return; - } - - // Select the document in Salome - docActor = dynamic_cast( findActorByEntry( currentVTKViewWindow, docEntry.toLatin1() ) ); - if ( docActor == NULL) return; - -// // Set selection mode in VTK view - currentVTKViewWindow->SetSelectionMode(EdgeSelection); - docIO = docActor->getIO(); - - // Highlight in vtk view the element from document - QModelIndexList iEdges = m->getPropagation( eltIndex ); - - QString edgeEntry; - foreach( const QModelIndex& iEdge, iEdges ){ - edgeEntry = iEdge.data( HEXA_ENTRY_ROLE ).toString(); - vtkElemsId = docActor->vtkElemsId[ edgeEntry.toInt() ]; - if ( vtkElemsId > 0 ) aMap.Add( vtkElemsId ); - } - - selector->AddOrRemoveIndex( docIO, aMap, false ); - currentVTKViewWindow->highlight( docIO, true, true ); + disconnect( this, SIGNAL( currentChanged( const QModelIndex &, const QModelIndex & ) ), + this, SLOT( onCurrentChanged( const QModelIndex & , const QModelIndex & ) ) ); + disconnect( this, SIGNAL( selectionChanged( const QItemSelection & , const QItemSelection & ) ), + this, SLOT( onSelectionChanged( const QItemSelection & , const QItemSelection & ) ) ); } - void MeshSelectionModel::onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected ) { - MESSAGE("MeshSelectionModel::onSelectionChanged"); - try { - // if ( _salomeSelectionMgr == NULL ) return; - // _salomeSelectionMgr->clearSelected(); - // erasePreview(true); QModelIndexList indexes = selected.indexes(); - for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){ - MESSAGE( "entry selected" << i_index->data( HEXA_ENTRY_ROLE ).toString().toStdString() ); - _highlightPropagation( *i_index ); - } - - // CS_BP todo SALOMEGUI_Swig.cxx:370 - // indexes = deselected.indexes(); - // for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ) - // _unselectSalome( *i_index); - } catch ( ... ) { - MESSAGE("Unknown exception was cought !!!"); - } - -} - - + int nbSelected = indexes.count(); + if (nbSelected == 0) + return; + try { + for( QModelIndexList::const_iterator i_index = indexes.begin(); i_index != indexes.end(); ++i_index ){ + HEXABLOCKGUI::currentDocGView->highlightPropagation( *i_index ); + } + } catch ( ... ) { + MESSAGE("Unknown exception was cought !!!"); + } -// //================================================================================= -// // function : activateSelection -// // purpose : Activate selection in accordance with myEditCurrentArgument -// //================================================================================= -// void PatternDataSelectionModel::activateSelection() -// { -// erasePreview(false); -// -// // local selection -// if (!myObject->_is_nil() && !isAllSubShapes()) -// { -// GEOM_Displayer* aDisplayer = getDisplayer(); -// SALOME_View* view = GEOM_Displayer::GetActiveView(); -// if (view) { -// CORBA::String_var aMainEntry = myObject->GetStudyEntry(); -// Handle(SALOME_InteractiveObject) io = new SALOME_InteractiveObject (aMainEntry.in(), "GEOM", "TEMP_IO"); -// if (view->isVisible(io)) { -// aDisplayer->Erase(myObject, false, false); -// myIsHiddenMain = true; -// } -// } -// -// int prevDisplayMode = aDisplayer->SetDisplayMode(0); -// -// SUIT_ViewWindow* aViewWindow = 0; -// SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy(); -// if (activeStudy) -// aViewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); -// if (aViewWindow == 0) return; -// -// SUIT_ViewManager* aViewManager = aViewWindow->getViewManager(); -// if (aViewManager->getType() != OCCViewer_Viewer::Type() && -// aViewManager->getType() != SVTK_Viewer::Type()) -// return; -// -// SUIT_ViewModel* aViewModel = aViewManager->getViewModel(); -// SALOME_View* aView = dynamic_cast(aViewModel); -// if (aView == 0) return; -// -// //TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myObject); -// -// TopTools_IndexedMapOfShape aSubShapesMap; -// TopExp::MapShapes(myShape, aSubShapesMap); -// CORBA::String_var aMainEntry = myObject->GetStudyEntry(); -// QString anEntryBase = aMainEntry.in(); -// -// TopExp_Explorer anExp (myShape, (TopAbs_ShapeEnum)shapeType()); -// for (; anExp.More(); anExp.Next()) -// { -// TopoDS_Shape aSubShape = anExp.Current(); -// int index = aSubShapesMap.FindIndex(aSubShape); -// QString anEntry = anEntryBase + QString("_%1").arg(index); -// -// SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView); -// if (aPrs) { -// displayPreview(aPrs, true, false); // append, do not update -// } -// } -// aDisplayer->UpdateViewer(); -// aDisplayer->SetDisplayMode(prevDisplayMode); -// } -// -// globalSelection(GEOM_ALLSHAPES); -// } - - - - -// SUIT_DataOwnerPtrList aList; -// ObjectList::iterator anIter; -// for ( anIter = objects.begin(); anIter != objects.end(); ++anIter ) -// { -// QString anEntry = getEntry( *anIter ); -// LightApp_DataOwner* anOwher = new LightApp_DataOwner( anEntry ); -// aList.append( anOwher ); -// } -// -// SUIT_Session* session = SUIT_Session::session(); -// SalomeApp_Application* app = dynamic_cast( session->activeApplication() ); -// if ( !app ) -// return false; -// -// LightApp_SelectionMgr* aMgr = app->selectionMgr(); -// if ( !aMgr ) -// return false; -// _getVTKViewWindow() -// aMgr->setSelecte_getVTKViewWindow()d( aList, false ); - - - - - -// SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh); -// if (!anActor || !anActor->hasIO()) -// return; -// -// Handle(SALOME_InteractiveObject) anIO = anActor->getIO(); -// //mySelectionMgr->clearSelected(); -// //mySelectionMgr->AddIObject(anIO, false); -// SALOME_ListIO aList; -// aList.Append(anIO); -// mySelectionMgr->setSelectedObjects(aList, false); -// -// // Remove filter corresponding to the current type from viewer -// int aType = myTable->GetType(); -// int aFilterId = SMESH::UnknownFilter; -// if (aType == SMESH::EDGE ) aFilterId = SMESH::EdgeFilter; -// else if (aType == SMESH::FACE ) aFilterId = SMESH::FaceFilter; -// else if (aType == SMESH::VOLUME) aFilterId = SMESH::VolumeFilter; -// Handle(VTKViewer_Filter) aFilter = SMESH::GetFilter(aFilterId); -// SMESH::RemoveFilter(aFilterId); -// -// // get vtk ids -// TColStd_MapOfInteger aMap; -// QList::const_iterator anIter; -// for (anIter = theIds.begin(); anIter != theIds.end(); ++anIter) { -// aMap.Add(*anIter); -// } -// -// // Set new selection -// activeViewWindow->AddOrRemoveIndex(anIO, aMap, false); -// if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) -// aViewWindow->highlight( anIO, true, true ); -// -// // insert previously stored filter in viewer if necessary -// if (!aFilter.IsNull()) -// SMESH::SetFilter(aFilter); - - - - - - - - - -// //CS_TEST -// if(SVTK_Selector* aSelector = aView->GetSelector()){ -// const SALOME_ListIO& aListIO = aSelector->StoredIObjects(); -// SALOME_ListIteratorOfListIO anIter(aListIO); -// for(; anIter.More(); anIter.Next()){ -// Handle(SALOME_InteractiveObject) anIO = anIter.Value(); -// _PTR(Study) aStudy = HEXABLOCKGUI::activeStudy()->studyDS(); -// _PTR(SObject) aSObj = aStudy->FindObjectID( anEntry.toStdString().c_str() ); -// LightApp_DataObject* o = HEXABLOCKGUI::activeStudy()->findObjectByEntry(anEntry.toStdString().c_str()); -// //CS_TEST - - - - - -// void PatternDataSelectionModel::test() -// { -// if (myBusy) return; -// myMeshActor = 0; -// -// SALOME_ListIO aList; -// mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type()); -// -// if (aList.Extent() == 1) { -// Handle(SALOME_InteractiveObject) anIO = aList.First(); -// myMeshActor = SMESH::FindActorByEntry(anIO->getEntry()); -// if(myMeshActor){ -// QString aText; -// if (SMESH::GetNameOfSelectedNodes(activeViewWindow,anIO,aText) == 1) { -// if(SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh()) { -// if(const SMDS_MeshNode* aNode = aMesh->FindNode(aText.toInt())) { -// myBusy = true; -// myId->setText(aText); -// myX->SetValue(aNode->X()); -// myY->SetValue(aNode->Y()); -// myZ->SetValue(aNode->Z()); -// myBusy = false; -// erasePreview(); // avoid overlapping of a selection and a preview -// updateButtons(); -// return; -// } -// } -// } -// } -// } -// -// reset(); -// } - - -/* - -void PatternDataSelectionModel::setGeomEngine( GEOM::GEOM_Gen_var geomEngine ) -{gaumont parnasse - _geomEngine = geomEngine; -} + if (!infoMode || nbSelected > 1) + return; -GEOM::GEOM_IOperations_ptr PatternDataSelectionModel::createOperation() -{ -// return myGeomGUI->GetGeomGen()->GetIBasicOperations(getStudyId()); - return _geomEngine->GetIBasicOperations(getStudyId()); + // ** Show informations of the selected element **/ + QModelIndex elt = indexes[0]; + showEltInfo(elt); } -bool PatternDataSelectionModel::execute(ObjectList& objects) -{ - bool res = false; - - _PTR(Study) aStudy = GetActiveStudyDocument(); - _PTR(SObject) aSChild; - CORBA::Object_var aCorbaObj = CORBA::Object::_nil(); - GEOM::GEOM_Object_var assoc; - - foreach( const DocumentModel::GeomObj& anAssoc, _assocList ){ - std::cout << "FOUND=> " << anAssoc.entry.toStdString() << std::endl; - aSChild = aStudy->FindObjectID( anAssoc.entry.toStdString() ); - aCorbaObj = corbaObj(aSChild); - assoc = GEOM::GEOM_Object::_narrow(aCorbaObj); - - if ( !CORBA::is_nil(assoc) ){ - std::cout << "geom to highlight =>" << anAssoc.name.toStdString() << std::endl; - objects.push_back( assoc._retn() ); - res = true; - } else { - std::cout << "not a geom =>" << anAssoc.name.toStdString()<< std::endl; - } - } - - return res; -} -*/ - - -// SVTK_ViewWindow* PatternDataSelectionModel::GetViewWindow() -// { -// SalomeApp_Application* anApp = dynamic_cast -// (SUIT_Session::session()->activeApplication()); -// if (anApp) { -// if (SVTK_ViewWindow* aView = dynamic_cast(anApp->desktop()->activeWindow())) -// return aView; -// -// // SUIT_ViewManager* aViewManager = -// // anApp->getViewManager(SVTK_Viewer::Type(), createIfNotFound); -// // if (aViewManager) { -// // if (SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()) { -// // if (SVTK_ViewWindow* aView = dynamic_cast(aViewWindow)) { -// // aViewWindow->raise(); -// // aViewWindow->setFocus(); -// // return aView; -// // } -// // } -// // } -// } -// return NULL; -// } - - - - -// void PatternDataSelectionModel::SetSelectionMode(Selection_Mode theMode) -// { -// -// QList aSelectors; -// _salomeSelectionMgr->selectors( SVTK_Viewer::Type(), aSelectors ); -// QListIterator it( aSelectors ); -// -// std::cout << "PatternDataSelectionModel::SetSelectionMode()" << std::endl; -// while ( it.hasNext() ) -// { -// // SUIT_Selector* selector = it.next(); -// SVTK_Selector* selector = dynamic_cast( it.next() ); -// if ( selector ){ -// std::cout << "PatternDataSelectionModel::SetSelectionMode()" << theMode << std::endl; -// selector->SetSelectionMode(theMode); -// } -// } -// } - -// LightApp_SelectionMgr* PatternDataSelectionModel::selectionMgr() -// { -// SalomeApp_Application* anApp = dynamic_cast( SUIT_Session::session()->activeApplication() ); -// if( anApp ) -// return dynamic_cast( anApp->selectionMgr() ); -// else -// return 0; -// } - -// //CS_TEST -// SUIT_DataOwnerPtrList aOList; -// LightApp_DataOwner* anOwher = new LightApp_DataOwner( "0:1:1:1:2" ); -// aOList.append( anOwher ); -// _salomeSelectionMgr->setSelected( aOList, false ); -// //CS_TEST - -// void PatternDataSelectionModel::_highlightGEOM( const QModelIndex & anEltIndex ) -// { -// std::cout << "PatternDataSelectionModel::_highlightGEOM go find ASSOCIATION for"<< anEltIndex.data().toString().toStdString()< assocList; -// -// DocumentModel *docModel = NULL; -// const QSortFilterProxyModel *pModel = NULL; -// // const QStandardItemModel *smodel -// // const QAbstractItemModel *theModel = NULL; -// -// pModel = dynamic_cast( model() ); -// -// std::cout << "pModel "<< pModel << std::endl; -// if ( pModel ){ -// std::cout << "if ( pModel ){"<< std::endl; -// docModel = dynamic_cast( pModel->sourceModel() ); -// if ( docModel ){ -// std::cout << "if ( docModel ){"<< std::endl; -// assocList = docModel->getAssociations( pModel->mapToSource(anEltIndex) ); -// } -// } -// -// -// _PTR(Study) aStudy = GetActiveStudyDocument(); -// _PTR(SObject) aSChild; -// CORBA::Object_var aCorbaObj = CORBA::Object::_nil(); -// GEOM::GEOM_Object_var assoc; -// // foreach( const QString& entry, geomEntries ){ -// // struct GeomObj -// // { -// // QString name; -// // QString entry; -// // QString brep; -// // double start; -// // double end; -// // }; -// -// QVariant treeVariant = pModel->mapToSource(anEltIndex).data( HEXA_TREE_ROLE ); -// int eltType; -// if ( !treeVariant.isValid() ) return; -// eltType = treeVariant.toInt(); -// -// // GEOM::GeomObjPtr -// // GEOM::GEOM_Object_ptr firstLine; //firstLine.nullify();// -// GEOM::GEOM_Object_var firstLine = GEOM::GEOM_Object::_nil(); //GEOM::GeomObjPtr -// GEOM::GEOM_Object_var lastLine = GEOM::GEOM_Object::_nil(); -// double firstParameter = 0.2; //CS_TODO -// double lastParameter = 0.4; //CS_TODO -// -// foreach( const DocumentModel::GeomObj& anAssoc, assocList ){ -// std::cout << "FOUND=> " << anAssoc.entry.toStdString() << std::endl; -// aSChild = aStudy->FindObjectID( anAssoc.entry.toStdString() ); -// aCorbaObj = corbaObj(aSChild); -// assoc = GEOM::GEOM_Object::_narrow(aCorbaObj); -// -// if ( !CORBA::is_nil(assoc) ){ -// std::cout << "geom to highlight =>" << anAssoc.name.toStdString() << std::endl; -// // objects.push_back(assoc._retn()); -// // if ( eltType == EDGE_TREE ){ -// // if ( CORBA::is_nil(firstLine) ){ -// // firstLine = GEOM::GEOM_Object::_duplicate( assoc._retn() ); -// // } -// // lastLine = GEOM::GEOM_Object::_duplicate( assoc._retn() ); -// // } -// displayPreview( assoc._retn(), -// true, //false, //append, -// false,//true, //false, //activate, -// false,//true,//update, -// 4,//lineWidth, -// 1,//-1,//displayMode, -// Quantity_NOC_RED ); -// } else { -// std::cout << "not a geom =>" << anAssoc.name.toStdString()<< std::endl; -// } -// } -// // std::cout << "CORBA::is_nil(firstLine) =>" << CORBA::is_nil(firstLine) << std::endl; -// // std::cout << "CORBA::is_nil(lastLine) =>" << CORBA::is_nil(lastLine) << std::endl; -// // std::cout << "test" << ( !( CORBA::is_nil(firstLine) and !CORBA::is_nil(lastLine) ) ) << std::endl; -// /* -// if ( !( CORBA::is_nil(firstLine) and !CORBA::is_nil(lastLine) ) ){ -// GEOM::GEOM_IBasicOperations_var anOper = _geomEngine->GetIBasicOperations( getStudyId() ); -// GEOM::GEOM_Object_var firstPoint = anOper->MakePointOnCurve( firstLine, firstParameter ); -// GEOM::GEOM_Object_var lastPoint = anOper->MakePointOnCurve( lastLine, lastParameter ); -// -// // std::cout << "firstPoint->_is_nil() =>" << firstPoint->_is_nil() << std::endl; -// std::cout << "lastPoint->_is_nil() =>" << lastPoint->_is_nil() << std::endl; -// if ( !( CORBA::is_nil(firstPoint) ) )// !firstPoint->_is_nil() ) -// displayPreview( firstPoint._retn(), true ); -// if ( !( CORBA::is_nil(lastPoint) ) )//if ( !lastPoint->_is_nil() ) -// displayPreview( lastPoint._retn(), true ); -// }*/ -// } -//