VisuGUI_Module.cxx \
VisuGUI_Selection.cxx \
VisuGUI_Tools.cxx \
+ VisuGUI_ViewTools.cxx \
VisuGUI_PopupTools.cxx \
VisuGUI_NameDlg.cxx \
VisuGUI_FileDlg.cxx \
this, SLOT(OnDisplayPrs()));
mgr->insert( action( GAUSS_DISPLAY_PRS ), -1, -1, -1 ); // display
mgr->setRule( action( GAUSS_DISPLAY_PRS ),
- aRule + " and ((isVisible=false and isActiveView=true) or (isActiveView=false))", true );
+ aRule + " and (isVisible=false)", true );
createAction( GAUSS_DISPLAY_ONLY_PRS, VisuGUI::tr("MEN_DISPLAY_ONLY"), QIconSet(),
VisuGUI::tr("MEN_DISPLAY_ONLY"), "", 0, this, false,
mgr->insert( action( GAUSS_DISPLAY_ONLY_PRS ), -1, -1, -1 ); // display only
mgr->setRule( action( GAUSS_DISPLAY_ONLY_PRS ),
aRule, true );
+
+ QString aSVTKCompatiblePrs;
+ aSVTKCompatiblePrs =
+ "'VISU::TSCALARMAP' "
+ "'VISU::TISOSURFACE' "
+ "'VISU::TDEFORMEDSHAPE' "
+ "'VISU::TCUTPLANES' "
+ "'VISU::TCUTLINES' "
+ "'VISU::TVECTORS' "
+ "'VISU::TSTREAMLINES' "
+ "'VISU::TPLOT3D'";
+
+ aRule =
+ "(client='ObjectBrowser' and selcount>0 and ("
+ "(type='VISU::TTABLE' and nbChildren>0) or "
+ "($type in {'VISU::TCURVE' 'VISU::TCONTAINER'}) or "
+ "$type in {" + aSVTKCompatiblePrs +"} or "
+ "$type='VISU::TGAUSSPOINTS' "
+ ")) and (isVisible=false)";
+
+ mgr->setRule( action( VISU_DISPLAY ), aRule, true );
}
//---------------------------------------------------------------
//---------------------------------------------------------------
-void
+SUIT_ViewManager*
VisuGUI_Module
::onCreateViewManager()
{
- new Viewer( this, myViewerMap );
+ Viewer* aViewer = new Viewer( this, myViewerMap );
+ return aViewer->getViewManager();
}
VisuGUI_Module
::OnCreateGaussPoints()
{
- CreatePrs3d<VISU::GaussPoints_i,VVTK_Viewer,VisuGUI_GaussPointsDlg,1>(this);
+ CreatePrs3d<VISU::GaussPoints_i,VVTK_Viewer,VisuGUI_GaussPointsDlg,1>(this,true);
}
void
}
}
+
+//---------------------------------------------------------------
+SUIT_ViewManager*
+VisuGUI_Module
+::getViewManager(const QString& theType,
+ const bool theIsCreate)
+{
+ if(SUIT_ViewManager* aViewManager = VisuGUI::getViewManager(theType,theIsCreate))
+ return aViewManager;
+
+ if(theIsCreate && VVTK_Viewer::Type() == theType)
+ return onCreateViewManager();
+
+ return NULL;
+}
+
+//---------------------------------------------------------------
void
VisuGUI_Module::
OnEditGaussPoints()
Handle(SALOME_InteractiveObject) anIO;
if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
EditPrs3d<VISU::GaussPoints_i, VisuGUI_GaussPointsDlg>(this, aPrs3d);
- if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
- aViewWindow->highlight(anIO, 1);
+ if(SVTK_ViewWindow* aViewWindow = GetViewWindow<VVTK_Viewer>(this,true)){
+ aViewWindow->highlight(anIO,1);
}
}
}
+
+
+//---------------------------------------------------------------
+void
+VisuGUI_Module::
+OnDisplayPrs()
+{
+ if(MYDEBUG) MESSAGE("VisuGUI_Module::OnDisplayPrs");
+
+ QApplication::setOverrideCursor(Qt::waitCursor);
+
+ if(SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this)){
+ SALOME_ListIO aList;
+ aSelectionMgr->selectedObjects(aList);
+ for(SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next()){
+ Handle(SALOME_InteractiveObject) anIO = it.Value();
+ CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
+
+ // is it a Prs3d object ?
+ if(!CORBA::is_nil(anObject)){
+ if(VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in())){
+ if(MYDEBUG) MESSAGE("VisuGUI_Module::OnDisplayPrs : Prs3d object");
+ if(aPrs3d->GetType() != VISU::TGAUSSPOINTS)
+ VISU::UpdateViewer<SVTK_Viewer>(this,aPrs3d,false,true,true);
+ else
+ VISU::UpdateViewer<VVTK_Viewer>(this,aPrs3d,false,true,true);
+ continue;
+ }
+ }
+
+ // is it Curve ?
+ if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in())){
+ if(MYDEBUG) MESSAGE("VisuGUI_Module::OnDisplayPrs : Curve object");
+ PlotCurve( this, aCurve, VISU::eDisplay );
+ continue;
+ }
+
+ // is it Container ?
+ if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in())){
+ if(MYDEBUG) MESSAGE("VisuGUI_Module::DisplayPrs : Container object");
+ PlotContainer( this, aContainer, VISU::eDisplay );
+ continue;
+ }
+
+ // is it Table ?
+ if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in())){
+ if(MYDEBUG) MESSAGE("VisuGUI_Module::DisplayPrs : Table object");
+ PlotTable( this, aTable, VISU::eDisplay );
+ continue;
+ }
+ }
+ }
+
+ QApplication::restoreOverrideCursor();
+}
+
+
+//---------------------------------------------------------------
+void
+VisuGUI_Module
+::OnEraseAll()
+{
+ if(SUIT_ViewManager* aViewManager = getApp()->activeViewManager()){
+ QString aType = aViewManager->getType();
+ if(aType == SVTK_Viewer::Type())
+ VISU::OnEraseAll<SVTK_Viewer>(this);
+ else if(aType == VVTK_Viewer::Type())
+ VISU::OnEraseAll<VVTK_Viewer>(this);
+ else if(aType == SPlot2d_Viewer::Type())
+ VISU::OnEraseAll<SPlot2d_Viewer>(this);
+ }
+}
+
+
+//---------------------------------------------------------------
+void
+VisuGUI_Module::
+OnErasePrs()
+{
+ QApplication::setOverrideCursor(Qt::waitCursor);
+
+ SALOME_ListIO aList;
+ SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+ aSelectionMgr->selectedObjects(aList);
+
+ for(SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next()){
+ Handle(SALOME_InteractiveObject) anIO = it.Value();
+ CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this),anIO->getEntry());
+ if(!CORBA::is_nil(anObject)){
+ VISU::Base_var aBase = VISU::Base::_narrow(anObject);
+ if(!CORBA::is_nil(aBase))
+ VISU::ErasePrs(this,aBase,true);
+ }
+ }
+
+ QApplication::restoreOverrideCursor();
+}
void
preferencesChanged( const QString&, const QString& );
+ virtual
+ SUIT_ViewManager*
+ getViewManager(const QString& theType,
+ const bool theIsCreate);
public slots:
virtual
activateModule( SUIT_Study* );
protected slots:
- void
+ SUIT_ViewManager*
onCreateViewManager();
void
void
OnEditGaussPoints();
+ virtual
+ void
+ OnDisplayPrs();
+
+ virtual
+ void
+ OnEraseAll();
+
+ virtual
+ void
+ OnErasePrs();
+
protected:
VISU::TViewerMap myViewerMap;
// Module : VISU
#include "VisuGUI_PopupTools.h"
+#include "VisuGUI_ViewTools.h"
#include "VisuGUI_Tools.h"
-#include "VISU_Actor.h"
-
using namespace VISU;
//////////////////////////////////////////////////
return aResStr;
}
-QString VisuGUI_Selection::isVisible( const int ind ) const
+namespace
{
- QString aResStr;
-
- if ( SVTK_ViewWindow* aView = GetViewWindow( myModule ) )
- if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) )
- aResStr = anVISUActor->GetVisibility() ? "1" : "0";
+ struct TIsVisibleFunctor
+ {
+ template<class TViewer>
+ QString
+ Get(VisuGUI* theModule,
+ const QString& theEntry)
+ {
+ typedef typename TViewer::TViewWindow TViewWindow;
+ if(TViewWindow* aViewWindow = GetViewWindow<TViewer>(theModule))
+ if(VISU_Actor* anActor = FindActor(aViewWindow,theEntry.latin1()))
+ return anActor->GetVisibility() ? "1" : "0";
+
+ return QString();
+ }
+ };
+
+ template<class TPopupFunctor>
+ struct TPopupDispatcher
+ {
+ QString
+ operator()(VisuGUI* theModule,
+ const QString& theEntry)
+ {
+ if(SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager()){
+ QString aType = aViewManager->getType();
+ TPopupFunctor aFunctor;
+ if(aType == SVTK_Viewer::Type())
+ return aFunctor.template Get<SVTK_Viewer>(theModule,theEntry);
+ else if(aType == VVTK_Viewer::Type())
+ return aFunctor.template Get<VVTK_Viewer>(theModule,theEntry);
+ }
+ return QString();
+ }
+ };
+}
- return aResStr;
+QString VisuGUI_Selection::isVisible( const int ind ) const
+{
+ return TPopupDispatcher<TIsVisibleFunctor>()((VisuGUI*)myModule,entry(ind));
}
QString VisuGUI_Selection::isShrunk( const int ind ) const
//---------------------------------------------------------------
template<class TPrs3d_i, class TDlg>
void
- EditPrs3d (SalomeApp_Module* theModule, VISU::Prs3d_i* thePrs3d)
+ EditPrs3d(VisuGUI* theModule,
+ VISU::Prs3d_i* thePrs3d)
{
TPrs3d_i* aPrsObject = dynamic_cast<TPrs3d_i*>(thePrs3d);
if (aPrsObject) {
//---------------------------------------------------------------
template<class TPrs3d_i>
TPrs3d_i*
- CreatePrs3d(SalomeApp_Module* theModule,
+ CreatePrs3d(VisuGUI* theModule,
_PTR(SObject) theTimeStamp,
const char* theMeshName,
VISU::Entity theEntity,
//---------------------------------------------------------------
template<class TPrs3d_i, class TViewer, class TDlg, int IsDlgModal>
bool
- CreatePrs3d(SalomeApp_Module* theModule,
+ CreatePrs3d(VisuGUI* theModule,
_PTR(SObject) theTimeStamp,
- const Handle(SALOME_InteractiveObject)& theIO)
+ const Handle(SALOME_InteractiveObject)& theIO,
+ const bool theIsCreateView = false)
{
Storable::TRestoringMap aMap = getMapOfValue(theTimeStamp);
}
}
}
- PublishInView<TViewer>(theModule,aPrs3d);
+ PublishInView<TViewer>(theModule,aPrs3d,true,theIsCreateView);
return true;
}
//---------------------------------------------------------------
template<class TPrs3d_i, class TViewer, class TDlg, int IsDlgModal>
void
- CreatePrs3d(SalomeApp_Module* theModule)
+ CreatePrs3d(VisuGUI* theModule,
+ const bool theIsCreateView = false)
{
if (CheckLock(GetCStudy(GetAppStudy(theModule))))
return;
if(!CheckTimeStamp(theModule,aTimeStampSObj,&anIO))
return;
- if(!CreatePrs3d<TPrs3d_i,TViewer,TDlg,IsDlgModal>(theModule,aTimeStampSObj,anIO))
+ if(!CreatePrs3d<TPrs3d_i,TViewer,TDlg,IsDlgModal>(theModule,aTimeStampSObj,anIO,theIsCreateView))
return;
theModule->application()->putInfo(QObject::tr("INF_DONE"));
UpdateObjBrowser(theModule);
typedef typename TViewer::TViewWindow TView;
- if(TView* aView = GetViewWindow<TViewer>(theModule))
+ if(TView* aView = GetViewWindow<TViewer>(theModule,theIsCreateView))
aView->onFitAll();
}
template<class TPrs3d_i, class TDlg, int IsDlgModal>
void
- CreatePrs3d(SalomeApp_Module* theModule)
+ CreatePrs3d(VisuGUI* theModule,
+ const bool theIsCreateView = false)
{
- CreatePrs3d<TPrs3d_i,SVTK_Viewer,TDlg,IsDlgModal>(theModule);
+ CreatePrs3d<TPrs3d_i,SVTK_Viewer,TDlg,IsDlgModal>(theModule,theIsCreateView);
}
}
--- /dev/null
+// VISU VISUGUI : GUI of VISU component
+//
+// Copyright (C) 2005 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 : VisuGUI_Tools.cxx
+// Author : Sergey Anikin
+// Module : VISU
+
+
+#include "VisuGUI_ViewTools.h"
+
+#include "VISU_Actor.h"
+
+#include "SVTK_ViewModel.h"
+#include "SVTK_ViewWindow.h"
+
+namespace VISU
+{
+ void
+ ErasePrs(VisuGUI* theModule,
+ VISU::Base_ptr theBase,
+ bool thIsUpdate)
+ {
+ VISU::VISUType aType = theBase->GetType();
+ switch (aType) {
+ case VISU::TCURVE: {
+ if (VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(theBase).in()))
+ PlotCurve(theModule, aCurve, VISU::eErase );
+ break;
+ }
+ case VISU::TCONTAINER: {
+ if (VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(theBase).in()))
+ PlotContainer(theModule, aContainer, VISU::eErase );
+ break;
+ }
+ case VISU::TTABLE: {
+ if (VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(theBase).in()))
+ PlotTable(theModule, aTable, VISU::eErase );
+ break;
+ }
+ default: {
+ if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(theBase).in())){
+ if(aType == VISU::TGAUSSPOINTS)
+ ErasePrs3d<VVTK_Viewer>(theModule,aPrsObject,thIsUpdate);
+ else
+ ErasePrs3d<SVTK_Viewer>(theModule,aPrsObject,thIsUpdate);
+ }
+ }} // switch (aType)
+ }
+}
#ifndef VisuGUI_ViewTools_HeaderFile
#define VisuGUI_ViewTools_HeaderFile
+#include "VisuGUI.h"
+
#include "SUIT_MessageBox.h"
#include "SUIT_ViewManager.h"
#include "SUIT_ViewWindow.h"
#include "VISU_Prs3d_i.hh"
+#include "VVTK_ViewModel.h"
+#include "VVTK_ViewWindow.h"
+
+#include "SVTK_ViewModel.h"
+#include "SVTK_ViewWindow.h"
+
+#include "VisuGUI_Tools.h"
+#include "VTKViewer_Algorithm.h"
+#include "SVTK_Functor.h"
+
+#include "VISU_Table_i.hh"
+#include "VISU_ViewManager_i.hh"
+#include "SALOME_ListIO.hxx"
+#include "SALOME_ListIteratorOfListIO.hxx"
+
+#include "SPlot2d_ViewModel.h"
+
+#include "VISU_Actor.h"
+
+#include <vtkActorCollection.h>
+#include <vtkRenderer.h>
+
+class VVTK_Viewer;
+
namespace VISU
{
//---------------------------------------------------------------
template<class TViewer>
+ inline
typename TViewer::TViewWindow*
- GetViewWindow(const SalomeApp_Module* theModule,
- const bool theCreate = false)
+ GetViewWindow(VisuGUI* theModule,
+ const bool theIsViewCreate = false)
{
typedef typename TViewer::TViewWindow TView;
- if(SalomeApp_Application* anApp = theModule->getApp()){
- if(SUIT_ViewManager* aViewManager = anApp->getViewManager( TViewer::Type(), theCreate )){
- if(SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()){
- return dynamic_cast<TView*>(aViewWindow);
- }
+ if(SUIT_ViewManager* aViewManager = theModule->getViewManager(TViewer::Type(),theIsViewCreate)){
+ if(SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()){
+ if(TView* aView = dynamic_cast<TView*>(aViewWindow)){
+ aViewWindow->raise();
+ aViewWindow->setFocus();
+ return aView;
+ }
}
}
return NULL;
//---------------------------------------------------------------
template<class TViewer>
+ inline
VISU_Actor*
- PublishInView(const SalomeApp_Module* theModule,
- Prs3d_i* thePrs)
+ PublishInView(VisuGUI* theModule,
+ Prs3d_i* thePrs,
+ const bool theIsHighlight = false,
+ const bool theIsCreateView = false)
{
- VISU_Actor* aActor = NULL;
-
- if(!thePrs)
- return aActor;
-
typedef typename TViewer::TViewWindow TView;
- if(TView* aView = GetViewWindow<TViewer>(theModule)){
+ if(TView* aView = GetViewWindow<TViewer>(theModule,theIsCreateView)){
QApplication::setOverrideCursor( Qt::waitCursor );
try{
- if(aActor = thePrs->CreateActor())
- aView->AddActor(aActor);
+ if(VISU_Actor* anActor = thePrs->CreateActor()){
+ aView->AddActor(anActor);
+ if(theIsHighlight)
+ aView->highlight(anActor->getIO(),true);
+ aView->getRenderer()->ResetCameraClippingRange();
+ aView->Repaint();
+ QApplication::restoreOverrideCursor();
+ return anActor;
+ }
}catch(std::exception& exc){
SUIT_MessageBox::warn1(GetDesktop(theModule),
QObject::tr("WRN_VISU"),
QObject::tr("ERR_CANT_CREATE_ACTOR"),
QObject::tr("BUT_OK"));
}
- QApplication::restoreOverrideCursor();
}
- return aActor;
+ return NULL;
}
+
+
+ //---------------------------------------------------------------
+ template<class TViewer>
+ inline
+ VISU_Actor*
+ UpdateViewer(VisuGUI* theModule,
+ VISU::Prs3d_i* thePrs,
+ bool theDispOnly = false,
+ const bool theIsHighlight = false,
+ const bool theIsViewCreate = false)
+ {
+ typedef typename TViewer::TViewWindow TView;
+ if(TView* aView = GetViewWindow<TViewer>(theModule,theIsViewCreate)){
+ vtkRenderer *aRen = aView->getRenderer();
+ vtkActorCollection *anActColl = aRen->GetActors();
+ anActColl->InitTraversal();
+ VISU_Actor* aResActor = NULL;
+ while(vtkActor *anAct = anActColl->GetNextActor()){
+ if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anAct)){
+ if(VISU::Prs3d_i* aPrs3d = anActor->GetPrs3d()){
+ if(thePrs == aPrs3d){
+ aResActor = anActor->GetParent();
+ thePrs->UpdateActor(aResActor);
+ aResActor->VisibilityOn();
+ }else if(theDispOnly){
+ anActor->GetParent()->VisibilityOff();
+ }
+ }else if(theDispOnly && anActor->GetVisibility()){
+ anActor->VisibilityOff();
+ }
+ }
+ }
+ if(aResActor){
+ if(theIsHighlight)
+ aView->highlight(aResActor->getIO(),true);
+ aView->getRenderer()->ResetCameraClippingRange();
+ aView->Repaint();
+ return aResActor;
+ }
+ return PublishInView<TViewer>(theModule,thePrs,theIsHighlight,theIsViewCreate);
+ }
+ return NULL;
+ }
+
+
+ //---------------------------------------------------------------
+ template<class TViewer>
+ inline
+ void
+ OnEraseAll(VisuGUI* theModule)
+ {
+ typedef typename TViewer::TViewWindow TViewWindow;
+ if(TViewWindow* aViewWindow = GetViewWindow<TViewer>(theModule)){
+ aViewWindow->unHighlightAll();
+ if(vtkRenderer *aRen = aViewWindow->getRenderer()){
+ vtkActorCollection *aCollection = aRen->GetActors();
+ aCollection->InitTraversal();
+ while(vtkActor *anAct = aCollection->GetNextActor()){
+ if(anAct->GetVisibility() > 0)
+ if(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(anAct)){
+ anActor = anActor->GetParent();
+ anActor->VisibilityOff();
+ }
+ }
+ aViewWindow->Repaint();
+ }
+ }
+ }
+
+ template<>
+ inline
+ void
+ OnEraseAll<SPlot2d_Viewer>(VisuGUI* theModule)
+ {
+ if(SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(theModule,false))
+ aPlot2d->EraseAll();
+ }
+
+
+ //---------------------------------------------------------------
+ template<class TVieweWindow>
+ inline
+ VISU_Actor*
+ FindActor(TVieweWindow* theViewWindow,
+ const char* theEntry)
+ {
+ using namespace VTK;
+ if(vtkRenderer* aRenderer = theViewWindow->getRenderer()){
+ if(vtkActorCollection* aCollection = aRenderer->GetActors()){
+ if(VISU_Actor* anActor = Find<VISU_Actor>(aCollection,TIsSameEntry<VISU_Actor>(theEntry))){
+ return anActor->GetParent();
+ }
+ }
+ }
+ return NULL;
+ }
+
+ template<class TViewer>
+ inline
+ void
+ ErasePrs3d(VisuGUI* theModule,
+ VISU::Prs3d_i* thePrs,
+ const bool thIsUpdate = true)
+ {
+ typedef typename TViewer::TViewWindow TViewWindow;
+ if(TViewWindow* aViewWindow = GetViewWindow<TViewer>(theModule)){
+ if(VISU_Actor* anActor = FindActor(aViewWindow,thePrs)){
+ anActor->VisibilityOff();
+ if(thIsUpdate)
+ aViewWindow->Repaint();
+ }
+ }
+ }
+
+
+ void
+ ErasePrs(VisuGUI* theModule,
+ VISU::Base_ptr theBase,
+ bool thIsUpdate);
}
#endif