-// GEOM GEOMGUI : GUI for Geometry component
+// Copyright (C) 2007-2011 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.
//
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// File : DisplayGUI.cxx
-// Author : Vadim SANDLER
-// Module : GEOM
-// $Header$
+// 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 "QAD_RightFrame.h"
-#include "QAD_WaitCursor.h"
-#include "QAD_Desktop.h"
-#include "VTKViewer_ViewFrame.h"
-#include "VTKViewer_RenderWindowInteractor.h"
-#include "OCCViewer_ViewFrame.h"
-#include "OCCViewer_Viewer3d.h"
-#include "SALOME_ListIteratorOfListIO.hxx"
-#include "VTKViewer_Prs.h"
-#include "OCCViewer_Prs.h"
+#include <GeometryGUI.h>
+#include "GeometryGUI_Operations.h"
+#include <GEOM_Constants.h>
+#include <GEOM_Displayer.h>
+#include <GEOM_AISShape.hxx>
+#include <GEOM_Actor.h>
-#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <SUIT_Desktop.h>
+#include <SUIT_ViewWindow.h>
+#include <SUIT_OverrideCursor.h>
-using namespace std;
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewModel.h>
-DisplayGUI* DisplayGUI::myGUIObject = 0;
+#include <SALOME_ListIO.hxx>
+#include <SALOME_ListIteratorOfListIO.hxx>
-//=======================================================================
-// function : DisplayGUI::GetDisplayGUI()
-// purpose : Get the only DisplayGUI object [ static ]
-//=======================================================================
-DisplayGUI* DisplayGUI::GetDisplayGUI()
-{
- if ( myGUIObject == 0 ) {
- // init DisplayGUI only once
- myGUIObject = new DisplayGUI();
- }
- return myGUIObject;
-}
+#include <SVTK_ViewWindow.h>
+#include <SVTK_View.h>
+#include <SVTK_ViewModel.h>
+#include <SOCC_ViewModel.h>
+#include <SVTK_Prs.h>
+#include <SOCC_Prs.h>
+
+#include <QtxActionMenuMgr.h>
+
+#include <SalomeApp_Application.h>
+#include <LightApp_SelectionMgr.h>
+#include <SalomeApp_Study.h>
+
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+
+#include <vtkActorCollection.h>
+#include <vtkRenderer.h>
+
+#include <QAction>
//=======================================================================
// function : DisplayGUI::DisplayGUI()
// purpose : Constructor
//=======================================================================
-DisplayGUI::DisplayGUI() : GEOMGUI()
+DisplayGUI::DisplayGUI( GeometryGUI* parent ) : GEOMGUI( parent )
{
}
-
//=======================================================================
// function : DisplayGUI::~DisplayGUI()
// purpose : Destructor
// function : DisplayGUI::OnGUIEvent()
// purpose : Dispatch menu command
//=======================================================================
-bool DisplayGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
+bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
{
- DisplayGUI* myDisplayGUI = GetDisplayGUI();
-
- switch (theCommandID) {
- case 211: // MENU VIEW - WIREFRAME/SHADING
- {
- myDisplayGUI->InvertDisplayMode();
- int newMode = myDisplayGUI->GetDisplayMode();
- QAD_Application::getDesktop()->menuBar()->changeItem( 211, newMode == 1 ? tr( "GEOM_MEN_WIREFRAME" ) : tr("GEOM_MEN_SHADING") );
- break;
- }
- case 212: // MENU VIEW - DISPLAY ALL
- {
- myDisplayGUI->DisplayAll();
- break;
- }
- case 213: // MENU VIEW - DISPLAY ONLY
- {
- myDisplayGUI->DisplayOnly();
- break;
- }
- case 214: // MENU VIEW - ERASE ALL
- {
- myDisplayGUI->EraseAll();
- break;
- }
- case 215: // MENU VIEW - ERASE
- {
- myDisplayGUI->Erase();
+ SalomeApp_Application* app = getGeometryGUI()->getApp();
+ if (!app) return false;
+
+ LightApp_SelectionMgr *Sel = app->selectionMgr();
+ SALOME_ListIO selected;
+ Sel->selectedObjects( selected );
+
+ QString aDispModeName;
+ int aDispMode;
+ if ( theCommandID == GEOMOp::OpDisplayMode )
+ aDispMode = GetDisplayMode();
+
+ switch ( theCommandID ) {
+ case GEOMOp::OpDisplayMode: // MENU VIEW - DISPLAY MODE - WIREFRAME/SHADING/SHADING WITH EDGES
+ //InvertDisplayMode();
+ switch ( aDispMode) {
+ case 0:
+ aDispModeName = tr( "GEOM_MEN_WIREFRAME" );
break;
- }
- case 216: // MENU VIEW - DISPLAY
- {
- myDisplayGUI->Display();
+ case 1:
+ aDispModeName = tr("GEOM_MEN_SHADING");
break;
- }
- case 80311: // POPUP VIEWER - WIREFRAME
- {
- myDisplayGUI->ChangeDisplayMode( 0 );
+ case 2:
+ aDispModeName = tr("GEOM_MEN_SHADING_WITH_EDGES");
break;
- }
- case 80312: // POPUP VIEWER - SHADING
- {
- myDisplayGUI->ChangeDisplayMode( 1 );
+ default:
break;
}
+ getGeometryGUI()->action( GEOMOp::OpDisplayMode )->setText( aDispModeName );
+ getGeometryGUI()->menuMgr()->update();
+ 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::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::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;
default:
- {
- parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
- break;
- }
+ app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
+ break;
}
+ Sel->setSelectedObjects( selected );
return true;
}
//=====================================================================================
void DisplayGUI::DisplayAll()
{
- QAD_WaitCursor wc;
- SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
- SALOMEDS::SComponent_var SC = aStudy->FindComponent( "GEOM" );
- if ( SC->_is_nil() )
+ SalomeApp_Application* app = getGeometryGUI()->getApp();
+ if ( !app ) return;
+
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ if ( !appStudy ) return;
+ _PTR(Study) aStudy = appStudy->studyDS();
+ if ( !aStudy ) return;
+ _PTR(SComponent) SC ( aStudy->FindComponent( "GEOM" ) );
+ if ( !SC )
return;
SALOME_ListIO listIO;
- SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( SC );
+ _PTR(ChildIterator) anIter ( aStudy->NewChildIterator( SC ) );
anIter->InitEx( true );
+
+ SUIT_OverrideCursor();
+
while( anIter->More() ) {
- SALOMEDS::SObject_var valSO = anIter->Value();
- SALOMEDS::SObject_var refSO;
+ _PTR(SObject) valSO ( anIter->Value() );
+ _PTR(SObject) refSO;
if ( !valSO->ReferencedObject( refSO ) ) {
- listIO.Append( new SALOME_InteractiveObject( valSO->GetID(), SC->ComponentDataType() ,valSO->GetName()) );
+ listIO.Append( new SALOME_InteractiveObject(valSO->GetID().c_str(),
+ SC->ComponentDataType().c_str(),
+ valSO->GetName().c_str()) );
}
anIter->Next();
}
- GEOM_Displayer().Display( listIO, true );
+ GEOM_Displayer( appStudy ).Display( listIO, true );
}
//=====================================================================================
//=====================================================================================
void DisplayGUI::EraseAll()
{
- QAD_WaitCursor wc;
- QAD_ViewFrame* vf = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
- if ( vf->getTypeView() == VIEW_OCC || vf->getTypeView() == VIEW_VTK )
- vf->EraseAll();
+ SUIT_OverrideCursor();
+
+ SUIT_Application* app = getGeometryGUI()->getApp();
+ if ( app ) {
+ SUIT_ViewWindow* vw = app->desktop()->activeWindow();
+ if ( vw ) {
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ SUIT_ViewManager* vman = vw->getViewManager();
+ if ( vman->getType() == OCCViewer_Viewer::Type() ||
+ vman->getType() == SVTK_Viewer::Type() ) {
+ GEOM_Displayer( appStudy ).EraseAll();
+ }
+ }
+ }
}
//=====================================================================================
//=====================================================================================
void DisplayGUI::Display()
{
- QAD_WaitCursor wc;
SALOME_ListIO listIO;
- QAD_Study* anActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
- SALOME_Selection* Sel = SALOME_Selection::Selection( anActiveStudy->getSelection() );
- SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ SalomeApp_Application* app = getGeometryGUI()->getApp();
+ if ( !app ) return;
+
+ SalomeApp_Study* anActiveStudy = dynamic_cast<SalomeApp_Study*>( 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();
+
for( ;It.More();It.Next() ) {
Handle(SALOME_InteractiveObject) anIObject = It.Value();
if ( anIObject->hasEntry() ) {
- SALOMEDS::SObject_var SO = anActiveStudy->getStudyDocument()->FindObjectID( anIObject->getEntry() );
- if ( !SO->_is_nil() && QString( SO->GetID() ) == QString( SO->GetFatherComponent()->GetID() ) ) {
- SALOMEDS::SComponent_var SC = SO->GetFatherComponent();
- // if component is selected
- listIO.Clear();
- SALOMEDS::ChildIterator_var anIter = anActiveStudy->getStudyDocument()->NewChildIterator( SO );
- anIter->InitEx( true );
- while( anIter->More() ) {
- SALOMEDS::SObject_var valSO = anIter->Value();
- SALOMEDS::SObject_var refSO;
- if ( !valSO->ReferencedObject( refSO ) ) {
- listIO.Append( new SALOME_InteractiveObject( valSO->GetID(), SC->ComponentDataType() ,valSO->GetName()) );
- }
- anIter->Next();
- }
- break;
+ _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;
}
else {
- listIO.Append( anIObject );
+ listIO.Append( anIObject );
}
}
else {
listIO.Append( anIObject );
}
}
- GEOM_Displayer().Display( listIO, true );
+ GEOM_Displayer( anActiveStudy ).Display( listIO, true );
}
//=====================================================================================
void DisplayGUI::Erase()
{
- QAD_WaitCursor wc;
SALOME_ListIO listIO;
- QAD_Study* anActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
- SALOME_Selection* Sel = SALOME_Selection::Selection( anActiveStudy->getSelection() );
- SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
- for( ;It.More();It.Next() ) {
+ SalomeApp_Application* app = getGeometryGUI()->getApp();
+ if ( !app ) return;
+
+ SalomeApp_Study* anActiveStudy = dynamic_cast<SalomeApp_Study*>( 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();
+
+ for( ; It.More(); It.Next() ) {
Handle(SALOME_InteractiveObject) anIObject = It.Value();
if ( anIObject->hasEntry() ) {
- SALOMEDS::SObject_var SO = anActiveStudy->getStudyDocument()->FindObjectID( anIObject->getEntry() );
- if ( !SO->_is_nil() && QString( SO->GetID() ) == QString( SO->GetFatherComponent()->GetID() ) ) {
- SALOMEDS::SComponent_var SC = SO->GetFatherComponent();
- // if component is selected
- listIO.Clear();
- SALOMEDS::ChildIterator_var anIter = anActiveStudy->getStudyDocument()->NewChildIterator( SO );
- anIter->InitEx( true );
- while( anIter->More() ) {
- SALOMEDS::SObject_var valSO = anIter->Value();
- SALOMEDS::SObject_var refSO;
- if ( !valSO->ReferencedObject( refSO ) ) {
- listIO.Append( new SALOME_InteractiveObject( valSO->GetID(), SC->ComponentDataType() ,valSO->GetName()) );
- }
- anIter->Next();
- }
- break;
+ _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;
}
else {
- listIO.Append( anIObject );
+ listIO.Append( anIObject );
}
}
else {
listIO.Append( anIObject );
}
}
- GEOM_Displayer().Erase( listIO, true );
- Sel->ClearIObjects();
+
+ 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();
}
//=====================================================================================
// function : DisplayGUI::SetDisplayMode()
-// purpose : Set display mode for the viewer (current viewer if <viewFrame> - 0 )
+// purpose : Set display mode for the viewer (current viewer if <viewWindow> - 0 )
//=====================================================================================
-void DisplayGUI::SetDisplayMode( const int mode, QAD_ViewFrame* viewFrame )
+void DisplayGUI::SetDisplayMode( const int mode, SUIT_ViewWindow* viewWindow )
{
- QAD_WaitCursor wc;
- if ( !viewFrame )
- viewFrame = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
- if( viewFrame->getTypeView() == VIEW_VTK ) {
- VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)viewFrame)->getRWInteractor();
- myRenderInter->SetDisplayMode( mode );
+ SUIT_OverrideCursor();
+
+ if ( !viewWindow )
+ viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow();
+ if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) {
+ SVTK_View* aView = ((SVTK_ViewWindow*)viewWindow)->getView();
+ aView->SetDisplayMode( mode );
+ GeometryGUI::Modified();
}
- else if( viewFrame->getTypeView() == VIEW_OCC ) {
- OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)viewFrame)->getViewer();
+ 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_DisplayMode newmode;
+ switch (mode) {
+ case 0:
+ newmode = AIS_WireFrame;
+ break;
+ case 1:
+ newmode = AIS_Shaded;
+ break;
+ case 2:
+ newmode = AIS_DisplayMode( GEOM_AISShape::ShadingWithEdges );
+ break;
+ case 3:
+ newmode = AIS_DisplayMode( GEOM_AISShape::TexturedShape );
+ break;
+ default:
+ break;
+ }
+
AIS_ListOfInteractive List;
ic->DisplayedObjects( List );
AIS_ListOfInteractive List1;
}
ite.Next();
}
-
+
ic->SetDisplayMode( newmode, Standard_False );
+
+ GeometryGUI::Modified();
}
}
//=====================================================================================
// function : DisplayGUI::GetDisplayMode()
-// purpose : Get display mode of the viewer (current viewer if <viewFrame> - 0 )
+// purpose : Get display mode of the viewer (current viewer if <viewWindow> - 0 )
//=====================================================================================
-int DisplayGUI::GetDisplayMode( QAD_ViewFrame* viewFrame )
+int DisplayGUI::GetDisplayMode( SUIT_ViewWindow* viewWindow )
{
int dispMode = 0;
- if ( !viewFrame )
- viewFrame = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
- if( viewFrame->getTypeView() == VIEW_VTK) {
- VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)viewFrame)->getRWInteractor();
- dispMode = myRenderInter->GetDisplayMode();
+ if ( !viewWindow )
+ viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow();
+ if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) {
+ SVTK_View* aView = ((SVTK_ViewWindow*)viewWindow)->getView();
+ dispMode = aView->GetDisplayMode();
}
- else if( viewFrame->getTypeView() == VIEW_OCC) {
- OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)viewFrame)->getViewer();
- Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
- AIS_DisplayMode mode = (AIS_DisplayMode)ic->DisplayMode();
- dispMode = (mode == AIS_WireFrame ? 0 : 1 );
+ else if ( viewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
+ OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(viewWindow->getViewManager()))->getOCCViewer();
+ Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
+ dispMode = ic->DisplayMode();
}
return dispMode;
}
+//=====================================================================================
+// function : DisplayGUI::SetVectorsMode()
+// purpose : Set vector mode for the viewer
+//=====================================================================================
+void DisplayGUI::SetVectorMode( const bool mode, SUIT_ViewWindow* viewWindow )
+{
+ SUIT_OverrideCursor();
+
+ if ( !viewWindow )
+ viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow();
+ if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) {
+ viewWindow->setProperty( "VectorsMode", mode );
+ SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( viewWindow );
+ vtkActorCollection* allActors = vw->getRenderer()->GetActors();
+ allActors->InitTraversal();
+ while (vtkActor* actor = allActors->GetNextActor()) {
+ if (actor->GetVisibility()) { // only for visible actors
+ GEOM_Actor* aGeomActor = 0;
+ if ( actor->IsA( "GEOM_Actor" ) ) {
+ aGeomActor = GEOM_Actor::SafeDownCast( actor );
+ if ( aGeomActor )
+ aGeomActor->SetVectorMode( mode );
+ }
+ }
+ }
+ GeometryGUI::Modified();
+ }
+ else if ( viewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
+ viewWindow->setProperty( "VectorsMode", mode );
+ OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(viewWindow->getViewManager()))->getOCCViewer();
+ Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
+ 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() );
+ aSh->SetDisplayVectors(mode);
+ ic->RecomputePrsOnly(ite.Value());
+ }
+ ite.Next();
+ }
+ GeometryGUI::Modified();
+ }
+}
+
+//=====================================================================================
+// function : DisplayGUI::GetVectorMode()
+// purpose : Get the "show edge direction" mode of the viewer
+//=====================================================================================
+int DisplayGUI::GetVectorMode( SUIT_ViewWindow* viewWindow )
+{
+ if ( !viewWindow )
+ viewWindow = getGeometryGUI()->getApp()->desktop()->activeWindow();
+ return viewWindow->property( "VectorsMode" ).toBool();
+}
+
//=====================================================================================
// function : DisplayGUI::InvertDisplayMode()
-// purpose : Invert display mode ( shadin <-> wireframe ) for the viewer
-// (current viewer if <viewFrame> = 0 )
+// purpose : Invert display mode ( shading <-> wireframe ) for the viewer
+// (current viewer if <viewWindow> = 0 )
//=====================================================================================
-void DisplayGUI::InvertDisplayMode( QAD_ViewFrame* viewFrame )
+void DisplayGUI::InvertDisplayMode( SUIT_ViewWindow* viewWindow )
{
- SetDisplayMode( 1 - GetDisplayMode( viewFrame ) );
+ SetDisplayMode( 1 - GetDisplayMode( viewWindow ) );
}
//=====================================================================================
// function : DisplayGUI::ChangeDisplayMode()
// purpose : Set display mode for selected objects in the viewer given
-// (current viewer if <viewFrame> = 0 )
+// (current viewer if <viewWindow> = 0 )
//=====================================================================================
-void DisplayGUI::ChangeDisplayMode( const int mode, QAD_ViewFrame* viewFrame )
+void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow )
{
- QAD_WaitCursor wc;
- if ( !viewFrame )
- viewFrame = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
- SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
- if ( viewFrame->getTypeView() == VIEW_VTK ) {
- VTKViewer_RenderWindowInteractor* myRenderInter = ((VTKViewer_ViewFrame*)viewFrame)->getRWInteractor();
- SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ SalomeApp_Application* app = getGeometryGUI()->getApp();
+ if ( !app ) return;
+
+ if ( !viewWindow )
+ viewWindow = app->desktop()->activeWindow();
+
+ LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+ if ( !aSelMgr ) return;
+
+ SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
+
+ if(!aStudy)
+ return;
+
+ SUIT_OverrideCursor();
+
+ SALOME_ListIO aList;
+
+ if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) {
+ SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( viewWindow );
+ SVTK_View* aView = vw->getView();
+ int mgrId = viewWindow->getViewManager()->getGlobalId();
+ bool vectorMode = false;
+
+ aSelMgr->selectedObjects( aList );
+ SALOME_ListIteratorOfListIO It( aList );
+
for( ;It.More(); It.Next() ) {
- VTKViewer_Prs* vtkPrs = dynamic_cast<VTKViewer_Prs*>( viewFrame->CreatePrs( It.Value()->getEntry() ) );
+ SVTK_Viewer* stvkViewer = dynamic_cast<SVTK_Viewer*>(vw->getViewManager()->getViewModel());
+ SVTK_Prs* vtkPrs =
+ stvkViewer ? dynamic_cast<SVTK_Prs*>( stvkViewer->CreatePrs( It.Value()->getEntry() ) ) : 0;
if ( vtkPrs && !vtkPrs->IsNull() ) {
- if ( mode == 0 )
- myRenderInter->ChangeRepresentationToWireframe( vtkPrs->GetObjects() );
+ if (mode == 0 )
+ aView->ChangeRepresentationToWireframe( vtkPrs->GetObjects() );
else if ( mode == 1 )
- myRenderInter->ChangeRepresentationToSurface( vtkPrs->GetObjects() );
+ aView->ChangeRepresentationToSurface( vtkPrs->GetObjects() );
+ else if ( mode == 2 )
+ aView->ChangeRepresentationToSurfaceWithEdges( vtkPrs->GetObjects() );
+ else if ( mode == 4 ) {
+ vtkActorCollection* anActors = vtkPrs->GetObjects();
+ anActors->InitTraversal();
+ while (vtkActor* anAct = anActors->GetNextActor()) {
+ GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(anAct);
+ vectorMode = !aGeomActor->GetVectorMode();
+ aGeomActor->SetVectorMode(vectorMode);
+ }
+ }
+ if(mode == 0 || mode == 1 || mode == 2) {
+ aStudy->setObjectProperty(mgrId,It.Value()->getEntry(),DISPLAY_MODE_PROP, mode);
+ }
+ else if (mode == 4) {
+ aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),VECTOR_MODE_PROP, vectorMode);
+ }
}
}
- myRenderInter->Render();
+ aView->Repaint();
+ GeometryGUI::Modified();
}
- else if ( viewFrame->getTypeView() == VIEW_OCC ) {
- OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)viewFrame)->getViewer();
+ else if ( viewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
+ OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(viewWindow->getViewManager()))->getOCCViewer();
Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
- SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+
+ aSelMgr->selectedObjects( aList );
+ SALOME_ListIteratorOfListIO It( aList );
+ int mgrId = viewWindow->getViewManager()->getGlobalId();
+ bool vectorMode = 0;
+
for( ;It.More(); It.Next() ) {
- OCCViewer_Prs* occPrs = dynamic_cast<OCCViewer_Prs*>( viewFrame->CreatePrs( It.Value()->getEntry() ) );
+ SOCC_Viewer* soccViewer = (SOCC_Viewer*)(viewWindow->getViewManager()->getViewModel());
+ SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( soccViewer->CreatePrs( It.Value()->getEntry() ) );
if ( occPrs && !occPrs->IsNull() ) {
- AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes );
- AIS_ListIteratorOfListOfInteractive interIter( shapes );
- for ( ; interIter.More(); interIter.Next() ) {
+ 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 );
+ ic->SetDisplayMode( interIter.Value(), AIS_WireFrame, false );
else if ( mode == 1 )
- ic->SetDisplayMode( interIter.Value(), AIS_Shaded, false );
+ ic->SetDisplayMode( interIter.Value(), AIS_Shaded, false );
+ else if ( mode == 2 )
+ ic->SetDisplayMode( interIter.Value(), GEOM_AISShape::ShadingWithEdges, false );
+ else if ( mode == 3 )
+ ic->SetDisplayMode( interIter.Value(), AIS_ExactHLR, false );
+ else if (mode == 4 ) {
+ Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() );
+ if ( !aSh.IsNull() ) {
+ vectorMode = !aSh->isShowVectors();
+ aSh->SetDisplayVectors(vectorMode);
+ ic->RecomputePrsOnly(interIter.Value());
+ }
+ }
+ }
+ if(mode == 0 || mode == 1 || mode == 2 || mode == 3) {
+ aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),DISPLAY_MODE_PROP, mode);
+ }
+ else if (mode == 4) {
+ aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),VECTOR_MODE_PROP, vectorMode);
}
}
}
ic->UpdateCurrentViewer();
+ GeometryGUI::Modified();
}
}
//=====================================================================================
extern "C"
{
- GEOMGUI* GetLibGUI()
+#ifdef WIN32
+ __declspec( dllexport )
+#endif
+ GEOMGUI* GetLibGUI( GeometryGUI* parent )
{
- return DisplayGUI::GetDisplayGUI();
+ return new DisplayGUI( parent );
}
}