X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSOCC%2FSOCC_ViewModel.cxx;h=aa9ed64b2ae762a1e6ff5c917690352d20bc55fa;hb=331294345d3e1716fbf79ae25a2851011729be79;hp=25fdb6547d146cb9301f7e8666a8154838f63033;hpb=d26f738c9c427a45409bacf3848fd8c224edf6ed;p=modules%2Fgui.git diff --git a/src/SOCC/SOCC_ViewModel.cxx b/src/SOCC/SOCC_ViewModel.cxx index 25fdb6547..aa9ed64b2 100755 --- a/src/SOCC/SOCC_ViewModel.cxx +++ b/src/SOCC/SOCC_ViewModel.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -25,8 +25,6 @@ #include "SOCC_Prs.h" #include "SOCC_ViewWindow.h" -#include "OCCViewer_Trihedron.h" - #include "SUIT_Session.h" #include "SUIT_ResourceMgr.h" //#include "SUIT_Application.h" @@ -40,50 +38,16 @@ //#include CORBA_CLIENT_HEADER(SALOMEDS) #include -#include #include #include #include #include -// Temporarily commented to avoid awful dependecy on SALOMEDS -// TODO: better mechanism of storing display/erse status in a study -// should be provided... -//#include -//#include -//#include -//#include - -//#include "SALOMEDSClient.hxx" -//#include "SALOMEDS_StudyManager.hxx" -#include - #include #include -// in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study. -// SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from -// SALOMEDS::StudyManager - no linkage with SalomeApp. - -// Temporarily commented to avoid awful dependecy on SALOMEDS -// TODO: better mechanism of storing display/erse status in a study -// should be provided... -//static _PTR(Study) getStudyDS() -//{ -// SALOMEDSClient_Study* aStudy = NULL; -// _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() ); - - // get id of SUIT_Study, if it's a SalomeApp_Study, it will return - // id of its underlying SALOMEDS::Study -// SUIT_Application* app = SUIT_Session::session()->activeApplication(); -// if ( !app ) return _PTR(Study)(aStudy); -// SUIT_Study* stud = app->activeStudy(); -// if ( !stud ) return _PTR(Study)(aStudy); -// const int id = stud->id(); // virtual method, must return SALOMEDS_Study id - // get SALOMEDS_Study with this id from StudyMgr -// return aMgr->GetStudyByID( id ); -//} +#include /*! Constructor @@ -158,16 +122,6 @@ bool SOCC_Viewer::isInViewer( const Handle(SALOME_InteractiveObject)& obj, { AIS_ListOfInteractive List; getAISContext()->DisplayedObjects(List); - -#if OCC_VERSION_LARGE <= 0x06060000 - if( !onlyInViewer ) { - AIS_ListOfInteractive List1; - getAISContext()->ObjectsInCollector(List1); - List.Append(List1); -} -#endif - - AIS_ListIteratorOfListOfInteractive ite(List); for ( ; ite.More(); ite.Next() ) { @@ -305,7 +259,7 @@ void SOCC_Viewer::rename( const Handle(SALOME_InteractiveObject)& obj, Handle(SALOME_InteractiveObject) IO = aSh->getIO(); if ( IO->isSame( obj ) ) { - aSh->setName( name.toLatin1().data() ); + aSh->setName( name.toUtf8().data() ); break; } } @@ -332,12 +286,6 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) if ( !anOCCPrs || anOCCPrs->IsNull() ) return; - // get SALOMEDS Study - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - // _PTR(Study) study(getStudyDS()); - // get context Handle (AIS_InteractiveContext) ic = getAISContext(); @@ -362,29 +310,6 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) continue; } -#if OCC_VERSION_LARGE <= 0x06060000 - // then try to find presentation in the collector - if(ic->IsInCollector(anAIS)) - { - ic->DisplayFromCollector( anAIS, false ); - // Deactivate object if necessary - if ( !anOCCPrs->ToActivate() ) - ic->Deactivate( anAIS ); - - // Set visibility flag - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - //Handle(SALOME_InteractiveObject) anObj = - // Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); - //if ( !anObj.IsNull() && anObj->hasEntry() ) - //{ - // if ( study ) - // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); - //} - continue; - } -#endif // if object is not displayed and not found in the collector - display it if ( anAIS->IsKind( STANDARD_TYPE(AIS_Trihedron) ) ) { @@ -400,14 +325,12 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) { aSh->SetClippable (prs->IsClippable()); applyExistingClipPlanesToObject (anAIS); -#if OCC_VERSION_LARGE > 0x06050200 bool top = (aSh->isTopLevel() && aSh->switchTopLevel()); ic->SetZLayer( aSh, top ? getTopLayerId() : 0 ); if(!aSh->toActivate()) { ic->Deactivate( aSh ); } -#endif } //Register anAIS (if it has an entry) in entry2aisobjects map @@ -438,8 +361,7 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) // Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); //if ( !anObj.IsNull() && anObj->hasEntry() ) //{ - // if ( study ) - // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); + // ToolsGUI::SetVisibility( anObj->getEntry(), true, this ); //} // Deactivate object if necessary @@ -463,12 +385,6 @@ void SOCC_Viewer::Erase( const SALOME_OCCPrs* prs, const bool forced ) if ( !anOCCPrs || anOCCPrs->IsNull() ) return; - // get SALOMEDS Study - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - // _PTR(Study) study(getStudyDS()); - // get context Handle(AIS_InteractiveContext) ic = getAISContext(); @@ -481,11 +397,7 @@ void SOCC_Viewer::Erase( const SALOME_OCCPrs* prs, const bool forced ) Handle(AIS_InteractiveObject) anAIS = aIter.Value(); if ( !anAIS.IsNull() ) { // erase the object from context : move it to collector -#if OCC_VERSION_LARGE <= 0x06060000 - ic->Erase( anAIS, false, forced ? false : true ); -#else ic->Erase( anAIS, false ); -#endif // Set visibility flag if necessary // Temporarily commented to avoid awful dependecy on SALOMEDS // TODO: better mechanism of storing display/erse status in a study @@ -496,8 +408,7 @@ void SOCC_Viewer::Erase( const SALOME_OCCPrs* prs, const bool forced ) // Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); // if ( !anObj.IsNull() && anObj->hasEntry() ) // { - // if ( study ) - // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); + // ToolsGUI::SetVisibility( anObj->getEntry(), true, this ); // } //} } @@ -510,14 +421,8 @@ void SOCC_Viewer::Erase( const SALOME_OCCPrs* prs, const bool forced ) Erase all presentations \param forced - removes all objects from context */ -void SOCC_Viewer::EraseAll( const bool forced ) +void SOCC_Viewer::EraseAll( SALOME_Displayer* d, const bool forced ) { - // get SALOMEDS Study - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - // _PTR(Study) study(getStudyDS()); - // get context Handle(AIS_InteractiveContext) ic = getAISContext(); @@ -529,17 +434,12 @@ void SOCC_Viewer::EraseAll( const bool forced ) ic->DisplayedObjects( aList ); AIS_ListIteratorOfListOfInteractive anIter( aList ); for ( ; anIter.More(); anIter.Next() ) { - if ( (isTrihedronDisplayed && anIter.Value()->DynamicType() == STANDARD_TYPE( AIS_Trihedron )) || - anIter.Value()->DynamicType() == STANDARD_TYPE( OCCViewer_Trihedron )) + if ( (isTrihedronDisplayed && anIter.Value()->DynamicType() == STANDARD_TYPE( AIS_Trihedron ) ) ) continue; // erase an object Handle(AIS_InteractiveObject) anIO = anIter.Value(); -#if OCC_VERSION_LARGE <= 0x06060000 - ic->Erase( anIO, false, forced ? false : true ); -#else ic->Erase( anIO, false ); -#endif // Set visibility flag if necessary // Temporarily commented to avoid awful dependecy on SALOMEDS @@ -550,12 +450,13 @@ void SOCC_Viewer::EraseAll( const bool forced ) // Handle(SALOME_InteractiveObject)::DownCast( anIO->GetOwner() ); // if ( !anObj.IsNull() && anObj->hasEntry() ) { - // if ( study ) - // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); + // ToolsGUI::SetVisibility( anObj->getEntry(), true, this ); // } //} } + SALOME_View::EraseAll( d, forced ); + Repaint(); updateTrihedron(); } @@ -566,7 +467,7 @@ void SOCC_Viewer::EraseAll( const bool forced ) */ SALOME_Prs* SOCC_Viewer::CreatePrs( const char* entry ) { - SOCC_Prs* prs = new SOCC_Prs(); + SOCC_Prs* prs = new SOCC_Prs(entry); if ( entry ) { if(entry2aisobjects.count(entry)>0) @@ -579,11 +480,7 @@ SALOME_Prs* SOCC_Viewer::CreatePrs( const char* entry ) for ( unsigned int ind = 0; ind < List.size(); ind++ ) { Handle(AIS_InteractiveObject) anAIS=List[ind]; - if(ic->IsDisplayed(anAIS) -#if OCC_VERSION_LARGE <= 0x06060000 - || ic->IsInCollector(anAIS) -#endif - ) + if(ic->IsDisplayed(anAIS)) { prs->AddObject( anAIS ); } @@ -596,7 +493,7 @@ SALOME_Prs* SOCC_Viewer::CreatePrs( const char* entry ) /*! Activates selection of sub-shapes */ -void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const int theMode ) +void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const std::list modes ) { Handle(AIS_InteractiveContext) ic = getAISContext(); @@ -608,7 +505,7 @@ void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const int theMode bool allObjects = thePrs == 0 || thePrs->IsNull(); if ( !ic->HasOpenedContext() ) { ic->ClearCurrents( false ); - ic->OpenLocalContext( allObjects, true, true ); + ic->OpenLocalContext( Standard_False, Standard_True, Standard_True ); } AIS_ListOfInteractive anObjs; @@ -618,26 +515,44 @@ void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const int theMode else anOCCPrs->GetObjects( anObjs ); + std::list sel_modes; + for ( int i = TopAbs_COMPOUND; i < TopAbs_SHAPE; i++ ) + if ( std::find(modes.begin(), modes.end(), (int)TopAbs_SHAPE) != modes.end() || std::find(modes.begin(), modes.end(), i) != modes.end()) + sel_modes.push_back(i); + // Activate selection of objects from prs AIS_ListIteratorOfListOfInteractive aIter( anObjs ); for ( ; aIter.More(); aIter.Next() ) { Handle(AIS_InteractiveObject) anAIS = aIter.Value(); if ( !anAIS.IsNull() ) { + std::list::const_iterator it; if ( anAIS->IsKind( STANDARD_TYPE( AIS_Shape ) ) ) { ic->Load( anAIS, -1, false ); - ic->Activate( anAIS, AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)theMode ) ); + for( it = sel_modes.begin(); it != sel_modes.end(); ++it ) + ic->Activate( anAIS, AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)*it ) ); } else if ( anAIS->DynamicType() != STANDARD_TYPE(AIS_Trihedron) ) { ic->Load( anAIS, -1, false ); - ic->Activate( anAIS, theMode ); + for( it = sel_modes.begin(); it != sel_modes.end(); ++it ) + ic->Activate( anAIS, *it ); } } } } +/*! + Activates selection of sub-shapes +*/ +void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const int theMode ) +{ + std::list modes; + modes.push_back( theMode ); + LocalSelection( thePrs, modes ); +} + /*! Deactivates selection of sub-shapes */