2004-01-07 20:46:21 +05:00
|
|
|
// GEOM GEOMGUI : GUI for Geometry component
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// File : DisplayGUI.cxx
|
2004-12-01 15:39:14 +05:00
|
|
|
// Author : Vadim SANDLER
|
2004-01-07 20:46:21 +05:00
|
|
|
// Module : GEOM
|
2004-12-01 15:39:14 +05:00
|
|
|
// $Header$
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
#include "DisplayGUI.h"
|
2004-12-01 15:39:14 +05:00
|
|
|
#include "GeometryGUI.h"
|
|
|
|
#include "GEOM_Displayer.h"
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
#include <SUIT_Desktop.h>
|
|
|
|
#include <SUIT_Session.h>
|
|
|
|
#include <SUIT_ViewWindow.h>
|
|
|
|
#include <SUIT_OverrideCursor.h>
|
|
|
|
|
|
|
|
#include <OCCViewer_ViewManager.h>
|
|
|
|
#include <OCCViewer_ViewModel.h>
|
|
|
|
#include <OCCViewer_ViewWindow.h>
|
|
|
|
|
|
|
|
#include <SALOME_ListIteratorOfListIO.hxx>
|
|
|
|
|
2005-06-14 18:38:09 +06:00
|
|
|
#include <SVTK_ViewWindow.h>
|
|
|
|
#include <SVTK_RenderWindowInteractor.h>
|
2005-06-02 13:17:09 +06:00
|
|
|
#include <SVTK_ViewModel.h>
|
|
|
|
#include <SOCC_ViewModel.h>
|
|
|
|
#include <SVTK_Prs.h>
|
|
|
|
#include <SOCC_Prs.h>
|
|
|
|
|
|
|
|
#include <SalomeApp_Application.h>
|
|
|
|
#include <SalomeApp_SelectionMgr.h>
|
|
|
|
#include <SalomeApp_Study.h>
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
#include <qmenubar.h>
|
|
|
|
|
2004-06-16 21:24:55 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
DisplayGUI* DisplayGUI::myGUIObject = 0;
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// function : DisplayGUI::GetDisplayGUI()
|
|
|
|
// purpose : Get the only DisplayGUI object [ static ]
|
2004-01-07 20:46:21 +05:00
|
|
|
//=======================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
DisplayGUI* DisplayGUI::GetDisplayGUI( GeometryGUI* parent )
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
|
|
|
if ( myGUIObject == 0 ) {
|
|
|
|
// init DisplayGUI only once
|
2005-06-02 13:17:09 +06:00
|
|
|
myGUIObject = new DisplayGUI( parent );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
return myGUIObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// function : DisplayGUI::DisplayGUI()
|
2004-01-07 20:46:21 +05:00
|
|
|
// purpose : Constructor
|
|
|
|
//=======================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
DisplayGUI::DisplayGUI( GeometryGUI* parent ) : GEOMGUI( parent )
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=======================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
// function : DisplayGUI::~DisplayGUI()
|
2004-01-07 20:46:21 +05:00
|
|
|
// purpose : Destructor
|
|
|
|
//=======================================================================
|
|
|
|
DisplayGUI::~DisplayGUI()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=======================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
// function : DisplayGUI::OnGUIEvent()
|
|
|
|
// purpose : Dispatch menu command
|
2004-01-07 20:46:21 +05:00
|
|
|
//=======================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
bool DisplayGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
DisplayGUI* myDisplayGUI = GetDisplayGUI( getGeometryGUI() );
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
switch (theCommandID) {
|
|
|
|
case 211: // MENU VIEW - WIREFRAME/SHADING
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
myDisplayGUI->InvertDisplayMode();
|
|
|
|
int newMode = myDisplayGUI->GetDisplayMode();
|
2005-09-30 13:00:00 +06:00
|
|
|
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") );
|
2004-12-01 15:39:14 +05:00
|
|
|
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();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 216: // MENU VIEW - DISPLAY
|
|
|
|
{
|
|
|
|
myDisplayGUI->Display();
|
|
|
|
break;
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
case 80311: // POPUP VIEWER - WIREFRAME
|
|
|
|
{
|
|
|
|
myDisplayGUI->ChangeDisplayMode( 0 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 80312: // POPUP VIEWER - SHADING
|
|
|
|
{
|
|
|
|
myDisplayGUI->ChangeDisplayMode( 1 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
|
2004-12-01 15:39:14 +05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-01-07 20:46:21 +05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
//=====================================================================================
|
|
|
|
// function : DisplayGUI::DisplayAll()
|
|
|
|
// purpose : Display all GEOM objects
|
|
|
|
//=====================================================================================
|
|
|
|
void DisplayGUI::DisplayAll()
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
|
|
|
|
if ( !appStudy ) return;
|
|
|
|
_PTR(Study) aStudy = appStudy->studyDS();
|
|
|
|
if ( !aStudy ) return;
|
|
|
|
_PTR(SComponent) SC ( aStudy->FindComponent( "GEOM" ) );
|
|
|
|
if ( !SC )
|
2004-06-16 21:24:55 +06:00
|
|
|
return;
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
SALOME_ListIO listIO;
|
2005-06-02 13:17:09 +06:00
|
|
|
_PTR(ChildIterator) anIter ( aStudy->NewChildIterator( SC ) );
|
2004-12-01 15:39:14 +05:00
|
|
|
anIter->InitEx( true );
|
2005-06-02 13:17:09 +06:00
|
|
|
|
|
|
|
SUIT_OverrideCursor();
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
while( anIter->More() ) {
|
2005-06-02 13:17:09 +06:00
|
|
|
_PTR(SObject) valSO ( anIter->Value() );
|
|
|
|
_PTR(SObject) refSO;
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( !valSO->ReferencedObject( refSO ) ) {
|
2005-06-02 13:17:09 +06:00
|
|
|
listIO.Append( new SALOME_InteractiveObject( valSO->GetID().c_str(), SC->ComponentDataType().c_str() ,valSO->GetName().c_str() ) );
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
anIter->Next();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
2005-06-02 13:17:09 +06:00
|
|
|
GEOM_Displayer( appStudy ).Display( listIO, true );
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=====================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
// function : DisplayGUI::EraseAll()
|
|
|
|
// purpose : Erase all GEOM objects
|
2004-01-07 20:46:21 +05:00
|
|
|
//=====================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
void DisplayGUI::EraseAll()
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
SUIT_OverrideCursor();
|
|
|
|
|
|
|
|
SUIT_Application* app = SUIT_Session::session()->activeApplication();
|
|
|
|
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() ||
|
2005-10-05 12:28:23 +06:00
|
|
|
vman->getType() == SVTK_Viewer::Type() ) {
|
2005-06-02 13:17:09 +06:00
|
|
|
GEOM_Displayer( appStudy ).EraseAll();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=====================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
// function : DisplayGUI::DisplayOnly()
|
|
|
|
// purpose : Display selected GEOM objects and erase other
|
2004-01-07 20:46:21 +05:00
|
|
|
//=====================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
void DisplayGUI::DisplayOnly()
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
EraseAll();
|
|
|
|
Display();
|
|
|
|
}
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
//=====================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
// function : DisplayGUI::Display()
|
|
|
|
// purpose : Display selected GEOM objects
|
2004-01-07 20:46:21 +05:00
|
|
|
//=====================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
void DisplayGUI::Display()
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
SALOME_ListIO listIO;
|
2005-06-02 13:17:09 +06:00
|
|
|
|
|
|
|
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
|
|
|
if ( !app ) return;
|
|
|
|
|
|
|
|
SalomeApp_Study* anActiveStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
|
|
|
|
if ( !anActiveStudy ) return;
|
|
|
|
|
|
|
|
//get SalomeApp selection manager
|
|
|
|
SalomeApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
|
|
|
if ( !aSelMgr ) return;
|
|
|
|
|
|
|
|
SALOME_ListIO aList;
|
|
|
|
aSelMgr->selectedObjects( aList );
|
|
|
|
SALOME_ListIteratorOfListIO It( aList );
|
|
|
|
|
|
|
|
SUIT_OverrideCursor();
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
for( ;It.More();It.Next() ) {
|
|
|
|
Handle(SALOME_InteractiveObject) anIObject = It.Value();
|
|
|
|
if ( anIObject->hasEntry() ) {
|
2005-06-02 13:17:09 +06:00
|
|
|
_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() );
|
2004-12-01 15:39:14 +05:00
|
|
|
// if component is selected
|
|
|
|
listIO.Clear();
|
2005-06-02 13:17:09 +06:00
|
|
|
_PTR(ChildIterator) anIter ( anActiveStudy->studyDS()->NewChildIterator( SO ) );
|
2004-12-01 15:39:14 +05:00
|
|
|
anIter->InitEx( true );
|
|
|
|
while( anIter->More() ) {
|
2005-06-02 13:17:09 +06:00
|
|
|
_PTR(SObject) valSO ( anIter->Value() );
|
|
|
|
_PTR(SObject) refSO;
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( !valSO->ReferencedObject( refSO ) ) {
|
2005-06-02 13:17:09 +06:00
|
|
|
listIO.Append( new SALOME_InteractiveObject( valSO->GetID().c_str(), SC->ComponentDataType().c_str() ,valSO->GetName().c_str() ) );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
anIter->Next();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
listIO.Append( anIObject );
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2004-12-01 15:39:14 +05:00
|
|
|
listIO.Append( anIObject );
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
}
|
2005-06-02 13:17:09 +06:00
|
|
|
GEOM_Displayer( anActiveStudy ).Display( listIO, true );
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=====================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
// function : DisplayGUI::Erase()
|
|
|
|
// purpose : Erase selected GEOM objects
|
2004-01-07 20:46:21 +05:00
|
|
|
//=====================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
void DisplayGUI::Erase()
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
SALOME_ListIO listIO;
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
|
|
|
if ( !app ) return;
|
|
|
|
|
|
|
|
SalomeApp_Study* anActiveStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
|
|
|
|
if ( !anActiveStudy ) return;
|
|
|
|
|
|
|
|
//get SalomeApp selection manager
|
|
|
|
SalomeApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
|
|
|
if ( !aSelMgr ) return;
|
|
|
|
|
|
|
|
SALOME_ListIO aList;
|
|
|
|
aSelMgr->selectedObjects( aList );
|
|
|
|
SALOME_ListIteratorOfListIO It( aList );
|
|
|
|
|
|
|
|
SUIT_OverrideCursor();
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
for( ;It.More();It.Next() ) {
|
|
|
|
Handle(SALOME_InteractiveObject) anIObject = It.Value();
|
|
|
|
if ( anIObject->hasEntry() ) {
|
2005-06-02 13:17:09 +06:00
|
|
|
_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() );
|
2004-12-01 15:39:14 +05:00
|
|
|
// if component is selected
|
|
|
|
listIO.Clear();
|
2005-06-02 13:17:09 +06:00
|
|
|
_PTR(ChildIterator) anIter ( anActiveStudy->studyDS()->NewChildIterator( SO ) );
|
2004-12-01 15:39:14 +05:00
|
|
|
anIter->InitEx( true );
|
|
|
|
while( anIter->More() ) {
|
2005-06-02 13:17:09 +06:00
|
|
|
_PTR(SObject) valSO ( anIter->Value() );
|
|
|
|
_PTR(SObject) refSO;
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( !valSO->ReferencedObject( refSO ) ) {
|
2005-06-02 13:17:09 +06:00
|
|
|
listIO.Append( new SALOME_InteractiveObject( valSO->GetID().c_str(), SC->ComponentDataType().c_str() ,valSO->GetName().c_str() ) );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
anIter->Next();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
break;
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
else {
|
2004-12-01 15:39:14 +05:00
|
|
|
listIO.Append( anIObject );
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
else {
|
|
|
|
listIO.Append( anIObject );
|
|
|
|
}
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
2005-06-02 13:17:09 +06:00
|
|
|
GEOM_Displayer(anActiveStudy).Erase( listIO, true );
|
|
|
|
((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr()->clearSelected();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=====================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
// function : DisplayGUI::SetDisplayMode()
|
2005-06-02 13:17:09 +06:00
|
|
|
// purpose : Set display mode for the viewer (current viewer if <viewWindow> - 0 )
|
2004-01-07 20:46:21 +05:00
|
|
|
//=====================================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
void DisplayGUI::SetDisplayMode( const int mode, SUIT_ViewWindow* viewWindow )
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
SUIT_OverrideCursor();
|
|
|
|
|
|
|
|
if ( !viewWindow )
|
|
|
|
viewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
|
2005-10-05 12:28:23 +06:00
|
|
|
if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) {
|
|
|
|
SVTK_ViewWindow* wnd = dynamic_cast<SVTK_ViewWindow*>( viewWindow );
|
|
|
|
SVTK_RenderWindowInteractor* myRenderInter = wnd ? wnd->getRWInteractor() : 0;
|
|
|
|
if( myRenderInter )
|
|
|
|
myRenderInter->SetDisplayMode( mode );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2005-06-02 13:17:09 +06:00
|
|
|
else if ( viewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
|
|
|
|
OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(viewWindow->getViewManager()))->getOCCViewer();
|
2004-12-01 15:39:14 +05:00
|
|
|
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();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
ic->SetDisplayMode( newmode, Standard_False );
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=====================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
// function : DisplayGUI::GetDisplayMode()
|
2005-06-02 13:17:09 +06:00
|
|
|
// purpose : Get display mode of the viewer (current viewer if <viewWindow> - 0 )
|
2004-01-07 20:46:21 +05:00
|
|
|
//=====================================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
int DisplayGUI::GetDisplayMode( SUIT_ViewWindow* viewWindow )
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
int dispMode = 0;
|
2005-06-02 13:17:09 +06:00
|
|
|
if ( !viewWindow )
|
|
|
|
viewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
|
2005-10-05 12:28:23 +06:00
|
|
|
if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) {
|
|
|
|
SVTK_ViewWindow* wnd = dynamic_cast<SVTK_ViewWindow*>( viewWindow );
|
|
|
|
SVTK_RenderWindowInteractor* myRenderInter = wnd ? wnd->getRWInteractor() : 0;
|
|
|
|
if( myRenderInter )
|
|
|
|
dispMode = myRenderInter->GetDisplayMode();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2005-06-02 13:17:09 +06:00
|
|
|
else if ( viewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
|
|
|
|
OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(viewWindow->getViewManager()))->getOCCViewer();
|
2004-12-01 15:39:14 +05:00
|
|
|
Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
|
|
|
|
AIS_DisplayMode mode = (AIS_DisplayMode)ic->DisplayMode();
|
|
|
|
dispMode = (mode == AIS_WireFrame ? 0 : 1 );
|
|
|
|
}
|
|
|
|
return dispMode;
|
|
|
|
}
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
//=====================================================================================
|
|
|
|
// function : DisplayGUI::InvertDisplayMode()
|
|
|
|
// purpose : Invert display mode ( shadin <-> wireframe ) for the viewer
|
2005-06-02 13:17:09 +06:00
|
|
|
// (current viewer if <viewWindow> = 0 )
|
2004-12-01 15:39:14 +05:00
|
|
|
//=====================================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
void DisplayGUI::InvertDisplayMode( SUIT_ViewWindow* viewWindow )
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
SetDisplayMode( 1 - GetDisplayMode( viewWindow ) );
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
//=====================================================================================
|
|
|
|
// function : DisplayGUI::ChangeDisplayMode()
|
|
|
|
// purpose : Set display mode for selected objects in the viewer given
|
2005-06-02 13:17:09 +06:00
|
|
|
// (current viewer if <viewWindow> = 0 )
|
2004-12-01 15:39:14 +05:00
|
|
|
//=====================================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
void DisplayGUI::ChangeDisplayMode( const int mode, SUIT_ViewWindow* viewWindow )
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
if ( !viewWindow )
|
|
|
|
viewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
|
|
|
|
|
|
|
|
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
|
|
|
if ( !app ) return;
|
|
|
|
|
|
|
|
SalomeApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
|
|
|
if ( !aSelMgr ) return;
|
|
|
|
|
|
|
|
SUIT_OverrideCursor();
|
|
|
|
|
|
|
|
SALOME_ListIO aList;
|
|
|
|
|
2005-10-05 12:28:23 +06:00
|
|
|
if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) {
|
2005-06-14 18:38:09 +06:00
|
|
|
SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( viewWindow );
|
2005-10-05 12:28:23 +06:00
|
|
|
SVTK_RenderWindowInteractor* rwi = vw ? vw->getRWInteractor() : 0;
|
|
|
|
|
|
|
|
if( !rwi )
|
|
|
|
return;
|
2005-06-02 13:17:09 +06:00
|
|
|
|
|
|
|
aSelMgr->selectedObjects( aList );
|
|
|
|
SALOME_ListIteratorOfListIO It( aList );
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
for( ;It.More(); It.Next() ) {
|
2005-10-05 12:28:23 +06:00
|
|
|
SVTK_Viewer* stvkViewer = dynamic_cast<SVTK_Viewer*>(vw->getViewManager()->getViewModel());
|
|
|
|
SVTK_Prs* vtkPrs = stvkViewer ? dynamic_cast<SVTK_Prs*>( stvkViewer->CreatePrs( It.Value()->getEntry() ) ) : 0;
|
2004-12-01 15:39:14 +05:00
|
|
|
if ( vtkPrs && !vtkPrs->IsNull() ) {
|
|
|
|
if ( mode == 0 )
|
2005-06-14 18:38:09 +06:00
|
|
|
rwi->ChangeRepresentationToWireframe( vtkPrs->GetObjects() );
|
2004-12-01 15:39:14 +05:00
|
|
|
else if ( mode == 1 )
|
2005-06-14 18:38:09 +06:00
|
|
|
rwi->ChangeRepresentationToSurface( vtkPrs->GetObjects() );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
}
|
2005-06-14 18:38:09 +06:00
|
|
|
rwi->Render();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2005-06-02 13:17:09 +06:00
|
|
|
else if ( viewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
|
|
|
|
OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(viewWindow->getViewManager()))->getOCCViewer();
|
2004-12-01 15:39:14 +05:00
|
|
|
Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
|
2005-06-02 13:17:09 +06:00
|
|
|
|
|
|
|
aSelMgr->selectedObjects( aList );
|
|
|
|
SALOME_ListIteratorOfListIO It( aList );
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
for( ;It.More(); It.Next() ) {
|
2005-06-02 13:17:09 +06:00
|
|
|
SOCC_Viewer* soccViewer = (SOCC_Viewer*)(viewWindow->getViewManager()->getViewModel());
|
|
|
|
SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( soccViewer->CreatePrs( It.Value()->getEntry() ) );
|
2004-12-01 15:39:14 +05:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ic->UpdateCurrentViewer();
|
|
|
|
}
|
|
|
|
}
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
//=====================================================================================
|
|
|
|
// EXPORTED METHODS
|
|
|
|
//=====================================================================================
|
|
|
|
extern "C"
|
|
|
|
{
|
2005-08-29 12:03:08 +06:00
|
|
|
#ifdef WNT
|
|
|
|
__declspec( dllexport )
|
|
|
|
#endif
|
2005-06-02 13:17:09 +06:00
|
|
|
GEOMGUI* GetLibGUI( GeometryGUI* parent )
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
return DisplayGUI::GetDisplayGUI( parent );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|