#include "VisuGUI_Tools.h"
+#include "VisuGUI.h"
+#include "VisuGUI_ViewTools.h"
+
#include "VISU_Gen_i.hh"
#include "VISU_Prs3d_i.hh"
#include "VISU_Result_i.hh"
#include "SalomeApp_Study.h"
#include "SalomeApp_Application.h"
-#include "OB_Browser.h"
#include "LightApp_DataObject.h"
#include "LightApp_SelectionMgr.h"
+#include "OB_Browser.h"
+
#include "SALOME_ListIO.hxx"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "SVTK_ViewWindow.h"
-#include "SVTK_ViewModel.h"
#include "SVTK_Functor.h"
#include "VTKViewer_Algorithm.h"
#include "SUIT_Session.h"
#include "SUIT_MessageBox.h"
-#include "VisuGUI.h"
-
#include <vtkRenderer.h>
#include <vtkActorCollection.h>
for (; anIter.More(); anIter.Next()) {
Handle(SALOME_InteractiveObject) anIO = anIter.Value();
if (anIO->hasEntry()) {
+
+ // asv : if selected object is a Save Point object selected in object browser - return false
+ if ( QString( anIO->getEntry() ).startsWith( QObject::tr( "SAVE_POINT_DEF_NAME" ) ) )
+ return false;
+
_PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
VISU::Storable::TRestoringMap pMap;
if (aSObject) {
return true;
}
- // Display/Erase
-
- void
- ErasePrs (const SalomeApp_Module* theModule,
- CORBA::Object_ptr theObject, bool theUpdate)
- {
- if (!CORBA::is_nil(theObject)) {
- VISU::Base_var aBase = VISU::Base::_narrow(theObject);
- if (CORBA::is_nil(aBase)) return;
- VISU::VISUType aType = aBase->GetType();
- switch (aType) {
- case VISU::TCURVE:
- {
- if (VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aBase).in()))
- PlotCurve(theModule, aCurve, VISU::eErase );
- break;
- }
- case VISU::TCONTAINER:
- {
- if (VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aBase).in()))
- PlotContainer(theModule, aContainer, VISU::eErase );
- break;
- }
- case VISU::TTABLE:
- {
- if (VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aBase).in()))
- PlotTable(theModule, aTable, VISU::eErase );
- break;
- }
- default:
- {
- if (VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aBase).in())) {
- ErasePrs3d(theModule, aPrsObject);
- if (theUpdate) {
- if (SVTK_ViewWindow* vw = GetViewWindow(theModule))
- vw->Repaint();
- }
- }
- }
- } // switch (aType)
- }
- }
-
void
DeleteSObject(VisuGUI* theModule,
_PTR(Study) theStudy,
_PTR(ChildIterator) aChildIter = theStudy->NewChildIterator(theSObject);
for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
_PTR(SObject) aChildSObject = aChildIter->Value();
-
CORBA::Object_var aChildObj = VISU::ClientSObjectToObject(aChildSObject);
- RemoveScalarBarPosition(theModule,aChildObj);
- ErasePrs(theModule, aChildObj);
+ ErasePrs(theModule, aChildObj, /*repaint_view_window = */false);
}
CORBA::Object_var anObj = VISU::ClientSObjectToObject(theSObject);
if (!CORBA::is_nil(anObj)) {
- RemoveScalarBarPosition(theModule,anObj);
- ErasePrs(theModule, anObj);
+ ErasePrs(theModule, anObj, /*repaint_view_window = */true);
VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(anObj);
if (!CORBA::is_nil(aRemovableObject)) {
if (CheckLock(GetCStudy(GetAppStudy(theModule)),GetDesktop(theModule)))
return;
- RemoveScalarBarPosition(theModule,thePrs);
- thePrs->RemoveFromStudy();
- }
+ SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
+ RemoveScalarBarPosition(theModule, vw, thePrs);
- void
- ErasePrs3d(const SalomeApp_Module* theModule,
- VISU::Prs3d_i* thePrs)
- {
- if ( SVTK_ViewWindow* vw = GetViewWindow( theModule ) ){
- if (VISU_Actor* anVISUActor = FindActor( vw, thePrs )) {
- anVISUActor->VisibilityOff();
- }
- }
+ thePrs->RemoveFromStudy();
}
// Presentation management
ChangeRepresentation (const SalomeApp_Module* theModule,
VISU::PresentationType theType)
{
- SVTK_ViewWindow* vw = GetViewWindow( theModule, false );
- if( !vw )
+ SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
+ if (!vw)
return;
Handle(SALOME_InteractiveObject) anIO;
}
}
}
-
+
void
SetShading ( const SalomeApp_Module* theModule,
bool theOn )
{
- SUIT_ViewWindow* aView = GetActiveView(theModule, SVTK_Viewer::Type());
- if (!aView) return;
- SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( aView );
- if( !vw )
+ SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
+ if (!vw)
return;
-
+
Handle(SALOME_InteractiveObject) anIO;
CORBA::Object_var anObject = GetSelectedObj(theModule, &anIO);
if (CORBA::is_nil(anObject)) return;
return dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
}
- // Views
-
- SUIT_ViewWindow* GetActiveView(const SalomeApp_Module* theModule, QString theType)
- {
- if(SalomeApp_Application* anApp = theModule->getApp()){
- if(SUIT_ViewManager* aViewManager = anApp->activeViewManager()){
- if (!theType.isNull()) {
- if (aViewManager->getType() != theType)
- return 0;
- }
- return aViewManager->getActiveView();
- }
- }
- return 0;
- }
-
// VTK View
- TViewWindows
- GetViews(const SalomeApp_Module* theModule)
- {
- TViewWindows aViewWindows;
- if(SalomeApp_Application* anApp = theModule->getApp()){
- ViewManagerList aViewManagerList;
- anApp->viewManagers(SVTK_Viewer::Type(),aViewManagerList);
- QPtrListIterator<SUIT_ViewManager> anIter(aViewManagerList);
- while(SUIT_ViewManager* aViewManager = anIter.current()){
- QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
- for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
- if(SUIT_ViewWindow* aViewWindow = aViews.at(i))
- if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow))
- aViewWindows.push_back(aView);
- }
- ++anIter;
- }
- }
- return aViewWindows;
- }
-
- SVTK_ViewWindow*
- GetViewWindow( const SalomeApp_Module* theModule, const bool theCreate )
- {
- if (SalomeApp_Application* anApp = theModule->getApp())
- {
- SVTK_ViewWindow* wnd = dynamic_cast<SVTK_ViewWindow*>(anApp->desktop()->activeWindow());
- if( wnd )
- return wnd;
- else
- {
- SUIT_ViewManager* aViewManager = anApp->getViewManager( SVTK_Viewer::Type(), theCreate );
- return aViewManager ? dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() ) : 0;
- }
- }
- return NULL;
- }
-
- /*SVTK_ViewWindow*
- GetViewWindow(const SalomeApp_Module* theModule, const bool theCreate )
- {
- if (SalomeApp_Application* anApp = theModule->getApp())
- {
- SVTK_ViewWindow* wnd = dynamic_cast<SVTK_ViewWindow*>(anApp->desktop()->activeWindow());
- if( wnd )
- return wnd;
- else
- {
- if(SUIT_ViewManager* aViewManager = anApp->getViewManager( SVTK_Viewer::Type(), theCreate ))
- return dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
- }
- }
- return NULL;
- }*/
-
-
- SVTK_ViewWindow*
- GetViewWindow()
- {
- SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
- (SUIT_Session::session()->activeApplication());
- if (anApp) {
- if (SUIT_ViewManager* aViewManager = anApp->activeViewManager()) {
- if (aViewManager->getType() == SVTK_Viewer::Type()) {
- if (SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()) {
- return dynamic_cast<SVTK_ViewWindow*>(aViewWindow);
- }
- }
- }
- }
- return NULL;
- }
-
VISU_Actor*
- PublishInView(const SalomeApp_Module* theModule,
- VISU::Prs3d_i* thePrs)
+ PublishMeshInView(const SalomeApp_Module* theModule,
+ VISU::Prs3d_i* thePrs,
+ SVTK_ViewWindow* theViewWindow)
{
VISU_Actor* aActor = NULL;
- if(!thePrs)
+ if (!thePrs || !theViewWindow)
return aActor;
- if(SVTK_ViewWindow* aView = GetViewWindow(theModule)){
- QApplication::setOverrideCursor( Qt::waitCursor );
- try{
- if(aActor = thePrs->CreateActor())
- aView->AddActor(aActor);
- }catch(std::exception& exc){
- SUIT_MessageBox::warn1
- (GetDesktop(theModule), QObject::tr("WRN_VISU"),
- QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()),
- QObject::tr("BUT_OK"));
- }
- QApplication::restoreOverrideCursor();
- }
- return aActor;
- }
- VISU_Actor*
- UpdateViewer(const SalomeApp_Module* theModule,
- VISU::Prs3d_i* thePrs,
- bool theDispOnly)
- {
- SVTK_ViewWindow* vw = GetViewWindow( theModule );
- if (!vw) return NULL;
-
- vtkRenderer *aRen = vw->getRenderer();
- vtkActorCollection *anActColl = aRen->GetActors();
- anActColl->InitTraversal();
-
- vtkActor *anActor;
- VISU_Actor* anVISUActor = NULL;
- VISU_Actor* aResActor = NULL;
- while(vtkActor *anActor = anActColl->GetNextActor()){
- anVISUActor = VISU_Actor::SafeDownCast(anActor);
- if(anVISUActor){
- VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d();
- if(aPrs == NULL) continue;
- if (thePrs == aPrs) {
- try {
- aResActor = anVISUActor;
- thePrs->UpdateActor(aResActor);
- aResActor->VisibilityOn();
- } catch (std::runtime_error& exc) {
- aResActor->VisibilityOff();
- INFOS(exc.what());
- SUIT_MessageBox::warn1
- (GetDesktop(theModule), QObject::tr("WRN_VISU"),
- QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()),
- QObject::tr("BUT_OK"));
- }
- } else if (theDispOnly) {
- anVISUActor->VisibilityOff();
- } else {
- }
- } else if (theDispOnly && anActor->GetVisibility()) {
- anActor->VisibilityOff();
- } else {
- }
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ try {
+ if (aActor = thePrs->CreateActor())
+ theViewWindow->AddActor(aActor);
+ } catch(std::exception& exc) {
+ SUIT_MessageBox::warn1
+ (GetDesktop(theModule), QObject::tr("WRN_VISU"),
+ QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()),
+ QObject::tr("BUT_OK"));
}
- if (aResActor)
- return aResActor;
+ QApplication::restoreOverrideCursor();
- //anVISUActor = PublishInView( theModule, thePrs );
- return anVISUActor;
+ return aActor;
}
void
// Others
void CreateMesh (const SalomeApp_Module* theModule,
- const Handle(SALOME_InteractiveObject)& theIO)
+ const Handle(SALOME_InteractiveObject)& theIO,
+ SVTK_ViewWindow* theViewWindow)
{
_PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
//if (CheckLock(aStudy))
timer.Show();
#endif
- QApplication::restoreOverrideCursor();
+ //QApplication::restoreOverrideCursor();
VISU::Mesh_i* pPresent = NULL;
if (!CORBA::is_nil(aMesh))
pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
return;
}
- if (SVTK_ViewWindow* aView = GetViewWindow(theModule)) {
+ if (theViewWindow) {
try {
#ifdef CHECKTIME
Utils_Timer timer;
timer.Start();
#endif
- PublishInView(theModule, pPresent);
- //aView->onFitAll();
- SetFitAll(aView);
+ PublishMeshInView(theModule, pPresent, theViewWindow);
+ SetFitAll(theViewWindow);
#ifdef CHECKTIME
timer.Stop();
MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
timer.Show();
#endif
- theModule->application()->putInfo(QObject::tr("INF_DONE"));
- // Make "Save" button active
- theModule->getApp()->updateActions();
} catch (std::runtime_error& exc) {
INFOS(exc.what());
SUIT_MessageBox::warn1
QObject::tr("BUT_OK"));
}
}
+
+ theModule->application()->putInfo(QObject::tr("INF_DONE"));
+ // Make "Save" button active
+ theModule->getApp()->updateActions();
}
// ========================================================================================
}
return aList;
}
-
- int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule){
+
+ int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow)
+ {
int minIndx = 1;
std::set<int> aIndexes;
- SVTK_ViewWindow* vw = GetViewWindow(theModule);
TViewToPrs3d aMap = theModule->getScalarBarsMap();
- TViewToPrs3d::const_iterator aViewToPrsIter = aMap.find(vw);
- if (aViewToPrsIter != aMap.end()){
+ TViewToPrs3d::const_iterator aViewToPrsIter = aMap.find(theViewWindow);
+ if (aViewToPrsIter != aMap.end()) {
TSetPrs3d::const_iterator aPrsIter = (aViewToPrsIter->second).begin();
- for(;aPrsIter!=(aViewToPrsIter->second).end();aPrsIter++){
+ for (; aPrsIter != (aViewToPrsIter->second).end(); aPrsIter++) {
aIndexes.insert((*aPrsIter).second);
}
}
std::set<int>::const_iterator aIter = aIndexes.begin();
- for (int i=1,length=aIndexes.size(); i <= length; i++){
+ for (int i = 1,length = aIndexes.size(); i <= length; i++) {
std::set<int>::const_iterator aIter = aIndexes.find(i);
- if(aIter==aIndexes.end()){minIndx = i;break;}
+ if (aIter == aIndexes.end()) { minIndx = i; break; }
else minIndx = i + 1;
-
}
return minIndx;
}
-
- void AddScalarBarPosition(VisuGUI* theModule,VISU::Prs3d_i* thePrs3d, int pos){
- SVTK_ViewWindow* vw = GetViewWindow(theModule);
+
+ void AddScalarBarPosition (VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
+ VISU::Prs3d_i* thePrs3d, int pos)
+ {
TViewToPrs3d& aMap = theModule->myScalarBarsMap;
- TPrs3dToInd aPair; aPair.first=thePrs3d; aPair.second=pos;
- aMap[vw].insert(aPair);
+ TPrs3dToInd aPair; aPair.first = thePrs3d; aPair.second = pos;
+ aMap[theViewWindow].insert(aPair);
}
-
- void RemoveScalarBarPosition(VisuGUI* theModule,SVTK_ViewWindow* vw,VISU::Prs3d_i* thePrs3d){
+
+ void RemoveScalarBarPosition(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
+ VISU::Prs3d_i* thePrs3d)
+ {
TViewToPrs3d& aMap = theModule->myScalarBarsMap;
- TSetPrs3d::iterator aIter = aMap[vw].begin();
- for(;aIter!=aMap[vw].end();aIter++)
- if((*aIter).first == thePrs3d){
- aMap[vw].erase(*aIter);
+ TSetPrs3d::iterator aIter = aMap[theViewWindow].begin();
+ for (; aIter != aMap[theViewWindow].end(); aIter++)
+ if ((*aIter).first == thePrs3d) {
+ aMap[theViewWindow].erase(*aIter);
return;
}
}
-
- void RemoveScalarBarPosition(VisuGUI* theModule,VISU::Prs3d_i* thePrs3d){
- SVTK_ViewWindow* vw = GetViewWindow(theModule);
- RemoveScalarBarPosition(theModule,vw,thePrs3d);
- }
-
- void RemoveScalarBarPosition(VisuGUI* theModule,CORBA::Object_ptr theObject){
- if (!CORBA::is_nil(theObject)) {
- Base_var aBase = Base::_narrow(theObject);
- if (CORBA::is_nil(aBase)) return;
- if (VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aBase).in())){
- RemoveScalarBarPosition(theModule,aPrsObject);
- }
- }
- }
}