X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FDisplayGUI%2FDisplayGUI.cxx;h=edbeca37877ce70bf66a43cd56229def3f004feb;hb=57554854e0c045e0508bd1b2ab0fbb8cb439d90d;hp=61dc6bfca652e92a84180c9292e2cdadecd989cc;hpb=f505d638da4d75d3fe3daf6ce3bf7fab668bfad5;p=modules%2Fgeom.git diff --git a/src/DisplayGUI/DisplayGUI.cxx b/src/DisplayGUI/DisplayGUI.cxx index 61dc6bfca..edbeca378 100644 --- a/src/DisplayGUI/DisplayGUI.cxx +++ b/src/DisplayGUI/DisplayGUI.cxx @@ -1,45 +1,45 @@ -// GEOM GEOMGUI : GUI for Geometry component +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. // +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// File : DisplayGUI.cxx -// Author : Vadim SANDLER -// Module : GEOM -// $Header$ +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// GEOM GEOMGUI : GUI for Geometry component +// File : DisplayGUI.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) #include "DisplayGUI.h" -#include "GeometryGUI.h" -#include "GEOM_Displayer.h" +#include +#include "GeometryGUI_Operations.h" +#include +#include +#include +#include #include -#include #include #include #include #include -#include -#include +#include #include #include @@ -56,23 +56,10 @@ #include -#include - - -DisplayGUI* DisplayGUI::myGUIObject = 0; +#include +#include -//======================================================================= -// function : DisplayGUI::GetDisplayGUI() -// purpose : Get the only DisplayGUI object [ static ] -//======================================================================= -DisplayGUI* DisplayGUI::GetDisplayGUI( GeometryGUI* parent ) -{ - if ( myGUIObject == 0 ) { - // init DisplayGUI only once - myGUIObject = new DisplayGUI( parent ); - } - return myGUIObject; -} +#include //======================================================================= // function : DisplayGUI::DisplayGUI() @@ -82,7 +69,6 @@ DisplayGUI::DisplayGUI( GeometryGUI* parent ) : GEOMGUI( parent ) { } - //======================================================================= // function : DisplayGUI::~DisplayGUI() // purpose : Destructor @@ -98,67 +84,96 @@ DisplayGUI::~DisplayGUI() //======================================================================= bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) { - DisplayGUI* myDisplayGUI = GetDisplayGUI( getGeometryGUI() ); - LightApp_SelectionMgr *Sel = getGeometryGUI()->getApp()->selectionMgr(); + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if (!app) return false; + + SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); + if ( !appStudy ) return false; + + LightApp_SelectionMgr *Sel = app->selectionMgr(); SALOME_ListIO selected; Sel->selectedObjects( selected ); - switch (theCommandID) { - case 211: // MENU VIEW - WIREFRAME/SHADING - { - myDisplayGUI->InvertDisplayMode(); - int newMode = myDisplayGUI->GetDisplayMode(); - getGeometryGUI()->action( 211 )->setMenuText( newMode == 1 ? tr( "GEOM_MEN_WIREFRAME" ) : tr("GEOM_MEN_SHADING") ); - getGeometryGUI()->menuMgr()->update(); -// SUIT_Session::session()->activeApplication()->desktop()->menuBar()-> -// changeItem( 211, newMode == 1 ? tr( "GEOM_MEN_WIREFRAME" ) : tr("GEOM_MEN_SHADING") ); - break; - } - case 212: // MENU VIEW - DISPLAY ALL - { - getGeometryGUI()->EmitSignalDeactivateDialog(); - myDisplayGUI->DisplayAll(); - break; - } - case 213: // MENU VIEW - DISPLAY ONLY - { - getGeometryGUI()->EmitSignalDeactivateDialog(); - myDisplayGUI->DisplayOnly(); - break; - } - case 214: // MENU VIEW - ERASE ALL - { - myDisplayGUI->EraseAll(); - break; - } - case 215: // MENU VIEW - ERASE - { - myDisplayGUI->Erase(); - break; - } - case 216: // MENU VIEW - DISPLAY - { - getGeometryGUI()->EmitSignalDeactivateDialog(); - myDisplayGUI->Display(); - break; - } - case 80311: // POPUP VIEWER - WIREFRAME - { - myDisplayGUI->ChangeDisplayMode( 0 ); - break; - } - case 80312: // POPUP VIEWER - SHADING - { - myDisplayGUI->ChangeDisplayMode( 1 ); - break; - } + switch ( theCommandID ) { + case GEOMOp::OpDMWireframe: // MENU VIEW - DISPLAY MODE - WIREFRAME + SetDisplayMode( 0 ); + break; + case GEOMOp::OpDMShading: // MENU VIEW - DISPLAY MODE - SHADING + SetDisplayMode( 1 ); + break; + case GEOMOp::OpDMShadingWithEdges: // MENU VIEW - DISPLAY MODE - SHADING WITH EDGES + SetDisplayMode( 2 ); + break; + case GEOMOp::OpDMTexture: // MENU VIEW - DISPLAY MODE - TEXTURE + SetDisplayMode( 3 ); + break; + case GEOMOp::OpShowAll: // MENU VIEW - SHOW ALL + getGeometryGUI()->EmitSignalDeactivateDialog(); + DisplayAll(); + break; + case GEOMOp::OpShowOnly: // POPUP MENU - SHOW ONLY + getGeometryGUI()->EmitSignalDeactivateDialog(); + DisplayOnly(); + break; + case GEOMOp::OpShowOnlyChildren: // POPUP MENU - SHOW ONLY CHILDREN + getGeometryGUI()->EmitSignalDeactivateDialog(); + DisplayOnlyChildren(); + break; + case GEOMOp::OpHideAll: // MENU VIEW - HIDE ALL + EraseAll(); + break; + case GEOMOp::OpHide: // POPUP MENU - HIDE + Erase(); + break; + case GEOMOp::OpShow: // POPUP MENU - SHOW + getGeometryGUI()->EmitSignalDeactivateDialog(); + Display(); + break; + case GEOMOp::OpSwitchVectors: // MENU VIEW - DISPLAY MODE - SHOW EDGE DIRECTION + SetVectorMode(!GetVectorMode()); + getGeometryGUI()->action( GEOMOp::OpSwitchVectors )->setText + ( GetVectorMode() ? tr("MEN_VECTOR_MODE_ON") : tr( "MEN_VECTOR_MODE_OFF" ) ); + getGeometryGUI()->menuMgr()->update(); + break; + case GEOMOp::OpSwitchVertices: // MENU VIEW - DISPLAY MODE - SHOW/HIDE VERTICES + SetVerticesMode(!GetVerticesMode()); + getGeometryGUI()->action( GEOMOp::OpSwitchVertices )->setText + ( GetVerticesMode() ? tr("MEN_VERTICES_MODE_ON") : tr( "MEN_VERTICES_MODE_OFF" ) ); + getGeometryGUI()->menuMgr()->update(); + break; + case GEOMOp::OpSwitchName: // MENU VIEW - DISPLAY MODE - SHOW/HIDE NAME + SetNameMode(!GetNameMode()); + getGeometryGUI()->action( GEOMOp::OpSwitchName )->setText + ( GetNameMode() ? tr("MEN_NAME_MODE_ON") : tr( "MEN_NAME_MODE_OFF" ) ); + getGeometryGUI()->menuMgr()->update(); + break; + case GEOMOp::OpWireframe: // POPUP MENU - DISPLAY MODE - WIREFRAME + ChangeDisplayMode( 0 ); + break; + case GEOMOp::OpShading: // POPUP MENU - DISPLAY MODE - SHADING + ChangeDisplayMode( 1 ); + break; + case GEOMOp::OpShadingWithEdges: // POPUP MENU - DISPLAY MODE - SHADING WITH EDGES + ChangeDisplayMode( 2 ); + break; + case GEOMOp::OpTexture: // POPUP MENU - DISPLAY MODE - TEXTURE + ChangeDisplayMode( 3 ); + break; + case GEOMOp::OpVectors: // POPUP MENU - DISPLAY MODE - SHOW EDGE DIRECTION + ChangeDisplayMode( 4 ); + break; + case GEOMOp::OpVertices: // POPUP MENU - DISPLAY MODE - SHOW VERTICES + ChangeDisplayMode( 5 ); + break; + case GEOMOp::OpShowName: // POPUP MENU - DISPLAY MODE - SHOW NAME + ChangeDisplayMode( 6 ); + break; default: - { - SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); - break; - } + app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID)); + break; } Sel->setSelectedObjects( selected ); + GEOM_Displayer( appStudy ).UpdateColorScale(); return true; } @@ -168,7 +183,10 @@ bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) //===================================================================================== void DisplayGUI::DisplayAll() { - SalomeApp_Study* appStudy = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return; + + SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); if ( !appStudy ) return; _PTR(Study) aStudy = appStudy->studyDS(); if ( !aStudy ) return; @@ -180,13 +198,15 @@ void DisplayGUI::DisplayAll() _PTR(ChildIterator) anIter ( aStudy->NewChildIterator( SC ) ); anIter->InitEx( true ); - SUIT_OverrideCursor(); + SUIT_OverrideCursor wc; while( anIter->More() ) { _PTR(SObject) valSO ( anIter->Value() ); _PTR(SObject) refSO; if ( !valSO->ReferencedObject( refSO ) ) { - listIO.Append( new SALOME_InteractiveObject( valSO->GetID().c_str(), SC->ComponentDataType().c_str() ,valSO->GetName().c_str() ) ); + listIO.Append( new SALOME_InteractiveObject(valSO->GetID().c_str(), + SC->ComponentDataType().c_str(), + valSO->GetName().c_str()) ); } anIter->Next(); } @@ -199,17 +219,17 @@ void DisplayGUI::DisplayAll() //===================================================================================== void DisplayGUI::EraseAll() { - SUIT_OverrideCursor(); + SUIT_OverrideCursor wc; - SUIT_Application* app = SUIT_Session::session()->activeApplication(); + SUIT_Application* app = getGeometryGUI()->getApp(); if ( app ) { SUIT_ViewWindow* vw = app->desktop()->activeWindow(); if ( vw ) { SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); SUIT_ViewManager* vman = vw->getViewManager(); if ( vman->getType() == OCCViewer_Viewer::Type() || - vman->getType() == SVTK_Viewer::Type() ) { - GEOM_Displayer( appStudy ).EraseAll(); + vman->getType() == SVTK_Viewer::Type() ) { + GEOM_Displayer( appStudy ).EraseAll(true); } } } @@ -225,6 +245,62 @@ void DisplayGUI::DisplayOnly() Display(); } +//===================================================================================== +// function : DisplayGUI::DisplayOnlyChildren() +// purpose : Display only children of selected GEOM objects and erase other +//===================================================================================== +void DisplayGUI::DisplayOnlyChildren() +{ + EraseAll(); + + SALOME_ListIO listIO; + + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if (!app) return; + + SalomeApp_Study* anActiveStudy = dynamic_cast(app->activeStudy()); + if (!anActiveStudy) return; + + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + if (!aSelMgr) return; + + // get selection + SALOME_ListIO aList; + //aSelMgr->selectedObjects(aList); + aSelMgr->selectedObjects(aList, "ObjectBrowser", false); + SALOME_ListIteratorOfListIO It (aList); + + SUIT_OverrideCursor wc; + + for (; It.More(); It.Next()) { + Handle(SALOME_InteractiveObject) anIObject = It.Value(); + if (anIObject->hasEntry()) { + _PTR(SObject) SO (anActiveStudy->studyDS()->FindObjectID(anIObject->getEntry())); + if (SO) { + _PTR(SComponent) SC (SO->GetFatherComponent()); + if (QString(SO->GetID().c_str()) == QString(SO->GetFatherComponent()->GetID().c_str())) { + // if component is selected, pass it + } + else { + _PTR(ChildIterator) anIter (anActiveStudy->studyDS()->NewChildIterator(SO)); + anIter->InitEx(true); + while (anIter->More()) { + _PTR(SObject) valSO (anIter->Value()); + _PTR(SObject) refSO; + if (!valSO->ReferencedObject(refSO)) { + listIO.Append(new SALOME_InteractiveObject(valSO->GetID().c_str(), + SC->ComponentDataType().c_str(), + valSO->GetName().c_str())); + } + anIter->Next(); + } + } + } + } + } + GEOM_Displayer(anActiveStudy).Display(listIO, true); +} + //===================================================================================== // function : DisplayGUI::Display() // purpose : Display selected GEOM objects @@ -232,45 +308,47 @@ void DisplayGUI::DisplayOnly() void DisplayGUI::Display() { SALOME_ListIO listIO; - - SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + + SalomeApp_Application* app = getGeometryGUI()->getApp(); if ( !app ) return; SalomeApp_Study* anActiveStudy = dynamic_cast( app->activeStudy() ); if ( !anActiveStudy ) return; - + //get SalomeApp selection manager LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); if ( !aSelMgr ) return; - + SALOME_ListIO aList; aSelMgr->selectedObjects( aList ); SALOME_ListIteratorOfListIO It( aList ); - - SUIT_OverrideCursor(); + + SUIT_OverrideCursor wc; for( ;It.More();It.Next() ) { Handle(SALOME_InteractiveObject) anIObject = It.Value(); if ( anIObject->hasEntry() ) { _PTR(SObject) SO ( anActiveStudy->studyDS()->FindObjectID( anIObject->getEntry() ) ); - if ( SO && QString( SO->GetID().c_str() ) == QString( SO->GetFatherComponent()->GetID().c_str() ) ) { - _PTR(SComponent) SC ( SO->GetFatherComponent() ); - // if component is selected - listIO.Clear(); - _PTR(ChildIterator) anIter ( anActiveStudy->studyDS()->NewChildIterator( SO ) ); - anIter->InitEx( true ); - while( anIter->More() ) { - _PTR(SObject) valSO ( anIter->Value() ); - _PTR(SObject) refSO; - if ( !valSO->ReferencedObject( refSO ) ) { - listIO.Append( new SALOME_InteractiveObject( valSO->GetID().c_str(), SC->ComponentDataType().c_str() ,valSO->GetName().c_str() ) ); - } - anIter->Next(); - } - break; + if ( SO && QString(SO->GetID().c_str()) == QString(SO->GetFatherComponent()->GetID().c_str()) ) { + _PTR(SComponent) SC ( SO->GetFatherComponent() ); + // if component is selected + listIO.Clear(); + _PTR(ChildIterator) anIter ( anActiveStudy->studyDS()->NewChildIterator( SO ) ); + anIter->InitEx( true ); + while( anIter->More() ) { + _PTR(SObject) valSO ( anIter->Value() ); + _PTR(SObject) refSO; + if ( !valSO->ReferencedObject( refSO ) ) { + listIO.Append( new SALOME_InteractiveObject(valSO->GetID().c_str(), + SC->ComponentDataType().c_str(), + valSO->GetName().c_str()) ); + } + anIter->Next(); + } + break; } else { - listIO.Append( anIObject ); + listIO.Append( anIObject ); } } else { @@ -289,52 +367,60 @@ void DisplayGUI::Erase() { SALOME_ListIO listIO; - SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + SalomeApp_Application* app = getGeometryGUI()->getApp(); if ( !app ) return; SalomeApp_Study* anActiveStudy = dynamic_cast( app->activeStudy() ); if ( !anActiveStudy ) return; - + //get SalomeApp selection manager LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); if ( !aSelMgr ) return; - + SALOME_ListIO aList; aSelMgr->selectedObjects( aList ); SALOME_ListIteratorOfListIO It( aList ); - SUIT_OverrideCursor(); + SUIT_OverrideCursor wc; - for( ;It.More();It.Next() ) { + for( ; It.More(); It.Next() ) { Handle(SALOME_InteractiveObject) anIObject = It.Value(); if ( anIObject->hasEntry() ) { _PTR(SObject) SO ( anActiveStudy->studyDS()->FindObjectID( anIObject->getEntry() ) ); - if ( SO && QString( SO->GetID().c_str() ) == QString( SO->GetFatherComponent()->GetID().c_str() ) ) { - _PTR(SComponent) SC ( SO->GetFatherComponent() ); - // if component is selected - listIO.Clear(); - _PTR(ChildIterator) anIter ( anActiveStudy->studyDS()->NewChildIterator( SO ) ); - anIter->InitEx( true ); - while( anIter->More() ) { - _PTR(SObject) valSO ( anIter->Value() ); - _PTR(SObject) refSO; - if ( !valSO->ReferencedObject( refSO ) ) { - listIO.Append( new SALOME_InteractiveObject( valSO->GetID().c_str(), SC->ComponentDataType().c_str() ,valSO->GetName().c_str() ) ); - } - anIter->Next(); - } - break; + if ( SO && QString(SO->GetID().c_str()) == QString(SO->GetFatherComponent()->GetID().c_str()) ) { + _PTR(SComponent) SC ( SO->GetFatherComponent() ); + // if component is selected + listIO.Clear(); + _PTR(ChildIterator) anIter ( anActiveStudy->studyDS()->NewChildIterator( SO ) ); + anIter->InitEx( true ); + while( anIter->More() ) { + _PTR(SObject) valSO ( anIter->Value() ); + _PTR(SObject) refSO; + if ( !valSO->ReferencedObject( refSO ) ) { + listIO.Append( new SALOME_InteractiveObject(valSO->GetID().c_str(), + SC->ComponentDataType().c_str(), + valSO->GetName().c_str()) ); + } + anIter->Next(); + } + break; } else { - listIO.Append( anIObject ); + listIO.Append( anIObject ); } } else { listIO.Append( anIObject ); } } - GEOM_Displayer(anActiveStudy).Erase( listIO, true ); - ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->clearSelected(); + + SUIT_ViewWindow* viewWindow = app->desktop()->activeWindow(); + bool aIsForced = true; + if(viewWindow->getViewManager()->getType() == SVTK_Viewer::Type()) + aIsForced = false; + + GEOM_Displayer(anActiveStudy).Erase( listIO, aIsForced); + getGeometryGUI()->getApp()->selectionMgr()->clearSelected(); } //===================================================================================== @@ -343,67 +429,181 @@ void DisplayGUI::Erase() //===================================================================================== void DisplayGUI::SetDisplayMode( const int mode, SUIT_ViewWindow* viewWindow ) { - SUIT_OverrideCursor(); + SUIT_OverrideCursor wc; + + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return; if ( !viewWindow ) - viewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); - if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) { - SVTK_View* aView = ((SVTK_ViewWindow*)viewWindow)->getView(); - aView->SetDisplayMode( mode ); - } - else if ( viewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) { - OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(viewWindow->getViewManager()))->getOCCViewer(); - Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); - AIS_DisplayMode newmode = (mode == 1 ? AIS_Shaded : AIS_WireFrame); - AIS_ListOfInteractive List; - ic->DisplayedObjects( List ); - AIS_ListOfInteractive List1; - ic->ObjectsInCollector( List1 ); - List.Append( List1 ); - - AIS_ListIteratorOfListOfInteractive ite( List ); - while( ite.More() ) { - if( ite.Value()->IsInstance( STANDARD_TYPE(GEOM_AISShape) ) ) { - Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( ite.Value() ); - ic->SetDisplayMode( aSh, Standard_Integer( newmode ),true ); - } - ite.Next(); - } - - ic->SetDisplayMode( newmode, Standard_False ); + viewWindow = app->desktop()->activeWindow(); + + SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() ); + if ( !aStudy ) return; + + GEOM_Displayer displayer( aStudy ); + + int mgrId = viewWindow->getViewManager()->getGlobalId(); + + SALOME_View* window = displayer.GetActiveView(); + if ( !window ) return; + + SALOME_ListIO anIOlst; + window->GetVisible( anIOlst ); + + for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) { + Handle( SALOME_InteractiveObject ) io = It.Value(); + aStudy->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::DisplayMode ), mode ); + displayer.Redisplay( io, false ); + } + displayer.UpdateViewer(); + GeometryGUI::Modified(); +} + +//===================================================================================== +// function : DisplayGUI::SetVectorsMode() +// purpose : Set vector mode for the viewer +//===================================================================================== +void DisplayGUI::SetVectorMode( const bool mode, SUIT_ViewWindow* viewWindow ) +{ + SUIT_OverrideCursor wc; + + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return; + + SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() ); + if ( !aStudy ) return; + + if ( !viewWindow ) + viewWindow = app->desktop()->activeWindow(); + + GEOM_Displayer displayer( aStudy ); + + viewWindow->setProperty( "VectorsMode", mode ); + + int aMgrId = viewWindow->getViewManager()->getGlobalId(); + + SALOME_View* window = displayer.GetActiveView(); + if ( !window ) return; + + SALOME_ListIO anIOlst; + window->GetVisible( anIOlst ); + + for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) { + Handle( SALOME_InteractiveObject ) io = It.Value(); + aStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::EdgesDirection ), mode ); + displayer.Redisplay( io, false ); } + displayer.UpdateViewer(); + GeometryGUI::Modified(); } //===================================================================================== -// function : DisplayGUI::GetDisplayMode() -// purpose : Get display mode of the viewer (current viewer if - 0 ) +// function : DisplayGUI::GetVectorMode() +// purpose : Get the "show edge direction" mode of the viewer //===================================================================================== -int DisplayGUI::GetDisplayMode( SUIT_ViewWindow* viewWindow ) +int DisplayGUI::GetVectorMode( SUIT_ViewWindow* viewWindow ) { - int dispMode = 0; if ( !viewWindow ) - viewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); - if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) { - SVTK_View* aView = ((SVTK_ViewWindow*)viewWindow)->getView(); - dispMode = aView->GetDisplayMode(); - } - else if ( viewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) { - OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(viewWindow->getViewManager()))->getOCCViewer(); - Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); - AIS_DisplayMode mode = (AIS_DisplayMode)ic->DisplayMode(); - dispMode = (mode == AIS_WireFrame ? 0 : 1 ); + viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow(); + return viewWindow->property( "VectorsMode" ).toBool(); +} + +//===================================================================================== +// function : DisplayGUI::SetVerticesMode() +// purpose : Set vertices mode for the viewer +//===================================================================================== +void DisplayGUI::SetVerticesMode( const bool mode, SUIT_ViewWindow* viewWindow ) +{ + SUIT_OverrideCursor wc; + + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return; + + SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() ); + if ( !aStudy ) return; + + if ( !viewWindow ) + viewWindow = app->desktop()->activeWindow(); + + GEOM_Displayer displayer( aStudy ); + + viewWindow->setProperty( "VerticesMode", mode ); + + int aMgrId = viewWindow->getViewManager()->getGlobalId(); + + SALOME_View* window = displayer.GetActiveView(); + if ( !window ) return; + + SALOME_ListIO anIOlst; + window->GetVisible( anIOlst ); + + for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) { + Handle( SALOME_InteractiveObject ) io = It.Value(); + aStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::Vertices ), mode ); + displayer.Redisplay( io, false ); } - return dispMode; + displayer.UpdateViewer(); + GeometryGUI::Modified(); } //===================================================================================== -// function : DisplayGUI::InvertDisplayMode() -// purpose : Invert display mode ( shadin <-> wireframe ) for the viewer -// (current viewer if = 0 ) +// function : DisplayGUI::GetVerticesMode() +// purpose : Get the "show vertices" mode of the viewer +//===================================================================================== +int DisplayGUI::GetVerticesMode( SUIT_ViewWindow* viewWindow ) +{ + if ( !viewWindow ) + viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow(); + return viewWindow->property( "VerticesMode" ).toBool(); +} + +//===================================================================================== +// function : DisplayGUI::SetNameMode() +// purpose : Set name mode for the viewer //===================================================================================== -void DisplayGUI::InvertDisplayMode( SUIT_ViewWindow* viewWindow ) +void DisplayGUI::SetNameMode( const bool mode, SUIT_ViewWindow* viewWindow ) { - SetDisplayMode( 1 - GetDisplayMode( viewWindow ) ); + SUIT_OverrideCursor(); + + SalomeApp_Application* app = getGeometryGUI()->getApp(); + if ( !app ) return; + + SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() ); + if ( !aStudy ) return; + + if ( !viewWindow ) + viewWindow = app->desktop()->activeWindow(); + + viewWindow->setProperty( "NameMode", mode ); + + GEOM_Displayer displayer( aStudy ); + + int aMgrId = viewWindow->getViewManager()->getGlobalId(); + + SALOME_View* window = displayer.GetActiveView(); + if ( !window ) return; + + SALOME_ListIO anIOlst; + window->GetVisible( anIOlst ); + + for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) { + Handle( SALOME_InteractiveObject ) io = It.Value(); + aStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::ShowName ), mode ); + displayer.Redisplay( io, false ); + } + displayer.UpdateViewer(); + GeometryGUI::Modified(); +} + +//===================================================================================== +// function : DisplayGUI::GetNameMode() +// purpose : Get the "show name" mode of the viewer +//===================================================================================== +int DisplayGUI::GetNameMode( SUIT_ViewWindow* viewWindow ) +{ + if ( !viewWindow ) + viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow(); + return viewWindow->property( "NameMode" ).toBool(); } //===================================================================================== @@ -413,61 +613,53 @@ void DisplayGUI::InvertDisplayMode( SUIT_ViewWindow* viewWindow ) //===================================================================================== void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow ) { - if ( !viewWindow ) - viewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); - - SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + SalomeApp_Application* app = getGeometryGUI()->getApp(); if ( !app ) return; + if ( !viewWindow ) + viewWindow = app->desktop()->activeWindow(); + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); if ( !aSelMgr ) return; - - SUIT_OverrideCursor(); - SALOME_ListIO aList; - - if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) { - SVTK_ViewWindow* vw = dynamic_cast( viewWindow ); - SVTK_View* aView = vw->getView(); - - aSelMgr->selectedObjects( aList ); - SALOME_ListIteratorOfListIO It( aList ); - - for( ;It.More(); It.Next() ) { - SVTK_Viewer* stvkViewer = dynamic_cast(vw->getViewManager()->getViewModel()); - SVTK_Prs* vtkPrs = stvkViewer ? dynamic_cast( stvkViewer->CreatePrs( It.Value()->getEntry() ) ) : 0; - if ( vtkPrs && !vtkPrs->IsNull() ) { - if ( mode == 0 ) - aView->ChangeRepresentationToWireframe( vtkPrs->GetObjects() ); - else if ( mode == 1 ) - aView->ChangeRepresentationToSurface( vtkPrs->GetObjects() ); - } + SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() ); + if ( !aStudy ) return; + + SUIT_OverrideCursor wc; + + SALOME_ListIO selected; + aSelMgr->selectedObjects( selected ); + if ( selected.IsEmpty() ) return; + + GEOM_Displayer displayer( aStudy ); + + int mgrId = viewWindow->getViewManager()->getGlobalId(); + + QVariant v = aStudy->getObjectProperty( mgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::EdgesDirection ), QVariant() ); + bool vectorMode = v.isValid() ? !v.toBool() : false; + v = aStudy->getObjectProperty( mgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::Vertices ), QVariant() ); + bool verticesMode = v.isValid() ? !v.toBool() : false; + v = aStudy->getObjectProperty( mgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::ShowName ), QVariant() ); + bool nameMode = v.isValid() ? !v.toBool() : false; + + for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { + Handle( SALOME_InteractiveObject ) io = It.Value(); + if ( mode == 0 || mode == 1 || mode == 2 || mode == 3 ) { + aStudy->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::DisplayMode ), mode ); } - aView->Repaint(); - } - else if ( viewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) { - OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(viewWindow->getViewManager()))->getOCCViewer(); - Handle(AIS_InteractiveContext) ic = v3d->getAISContext(); - - aSelMgr->selectedObjects( aList ); - SALOME_ListIteratorOfListIO It( aList ); - - for( ;It.More(); It.Next() ) { - SOCC_Viewer* soccViewer = (SOCC_Viewer*)(viewWindow->getViewManager()->getViewModel()); - SOCC_Prs* occPrs = dynamic_cast( soccViewer->CreatePrs( It.Value()->getEntry() ) ); - if ( occPrs && !occPrs->IsNull() ) { - AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes ); - AIS_ListIteratorOfListOfInteractive interIter( shapes ); - for ( ; interIter.More(); interIter.Next() ) { - if ( mode == 0 ) - ic->SetDisplayMode( interIter.Value(), AIS_WireFrame, false ); - else if ( mode == 1 ) - ic->SetDisplayMode( interIter.Value(), AIS_Shaded, false ); - } - } + else if ( mode == 4 ) { + aStudy->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::EdgesDirection ), vectorMode ); + } + else if ( mode == 5 ) { + aStudy->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::Vertices ), verticesMode ); + } + else if ( mode == 6 ) { + aStudy->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::ShowName ), nameMode ); } - ic->UpdateCurrentViewer(); + displayer.Redisplay( io, false ); } + displayer.UpdateViewer(); + GeometryGUI::Modified(); } //===================================================================================== @@ -475,11 +667,11 @@ void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow //===================================================================================== extern "C" { -#ifdef WNT - __declspec( dllexport ) +#ifdef WIN32 + __declspec( dllexport ) #endif GEOMGUI* GetLibGUI( GeometryGUI* parent ) { - return DisplayGUI::GetDisplayGUI( parent ); + return new DisplayGUI( parent ); } }