From: jfa Date: Mon, 13 Feb 2006 16:54:50 +0000 (+0000) Subject: Fix bug 11416: Post-Pro: Simplify display/erase. X-Git-Tag: mergeto_trunk_13Mar06~40 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c85bcbf42b27dbfaad30a565d53b8b6488a641bf;p=modules%2Fvisu.git Fix bug 11416: Post-Pro: Simplify display/erase. --- diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 8bff4218..508cc0b5 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -468,9 +468,10 @@ OnCreateMesh() return; // create a VTK view window if it does not exist - GetViewWindow( this, /*create=*/true ); + SVTK_ViewWindow* aViewWindow = GetViewWindow(this); - CreateMesh(this, anIO); + // create mesh presentation and display it in aViewWindow + CreateMesh(this, anIO, aViewWindow); } void @@ -482,7 +483,7 @@ OnCreateManyMesh() return; // create a VTK view window if it does not exist - GetViewWindow( this, /*create=*/true ); + SVTK_ViewWindow* aViewWindow = GetViewWindow(this); // Get selected SObject LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); @@ -494,7 +495,8 @@ OnCreateManyMesh() if (anIO.IsNull() || !anIO->hasEntry()) return; - CreateMesh(this, anIO); + // create mesh presentation and display it in aViewWindow + CreateMesh(this, anIO, aViewWindow); } } @@ -577,62 +579,65 @@ OnDisplayPrs() { if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs"); + LightApp_SelectionMgr* mgr = GetSelectionMgr(this); + if (!mgr) return; + QApplication::setOverrideCursor(Qt::waitCursor); + + SVTK_ViewWindow* vw = GetActiveViewWindow(this); + SALOME_ListIO aSel, aList; - LightApp_SelectionMgr* mgr = GetSelectionMgr(this); - mgr->selectedObjects( aSel ); + mgr->selectedObjects(aSel); + extractContainers(aSel, aList); - extractContainers( aSel, 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()); - Handle(SALOME_InteractiveObject) anIO; - for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) { - anIO = it.Value(); - CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() ); - if ( !CORBA::is_nil( anObject ) ) { + if (!CORBA::is_nil(anObject)) { // is it Prs3d object ? VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject).in()); - if(aPrsObject){ + if (aPrsObject) { if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Prs3d object"); //UpdateViewer( this, aPrsObject ); - SVTK_ViewWindow* vw = GetViewWindow( this, /*create=*/true ); - if ( vw ) - { - displayer()->Display( anIO->getEntry() ); + if (vw) { + displayer()->Display(anIO->getEntry()); vw->highlight(anIO, 1); } continue; } // is it Curve ? VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(anObject).in()); - if(aCurve){ + if (aCurve) { if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Curve object"); //PlotCurve( this, aCurve, VISU::eDisplay ); - displayer()->Display( anIO->getEntry() ); + displayer()->Display(anIO->getEntry()); continue; } // is it Container ? VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(anObject).in()); - if(aContainer){ + if (aContainer) { if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object"); //PlotContainer( this, aContainer, VISU::eDisplay ); - displayer()->Display( anIO->getEntry() ); + displayer()->Display(anIO->getEntry()); continue; } // is it Table ? VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(anObject).in()); - if(aTable){ + if (aTable) { if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object"); //PlotTable( this, aTable, VISU::eDisplay ); - displayer()->Display( anIO->getEntry() ); + displayer()->Display(anIO->getEntry()); continue; } } } - SVTK_ViewWindow* vw = GetViewWindow( this ); - if ( vw ) { + + if (vw) { vw->getRenderer()->ResetCameraClippingRange(); vw->Repaint(); } + QApplication::restoreOverrideCursor(); } @@ -652,27 +657,24 @@ OnErasePrs() QApplication::setOverrideCursor(Qt::waitCursor); - SVTK_ViewWindow* vw = GetViewWindow( this ); - if (vw) - vw->unHighlightAll(); + //SVTK_ViewWindow* vw = GetActiveViewWindow(this); + //if (vw) + // vw->unHighlightAll(); SALOME_ListIO aList, aSel; LightApp_SelectionMgr* mgr = GetSelectionMgr(this); - mgr->selectedObjects( aSel ); - - extractContainers( aSel, aList ); + mgr->selectedObjects(aSel); + extractContainers(aSel, aList); - Handle(SALOME_InteractiveObject) anIO; - for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) { - anIO = it.Value(); - CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() ); - if (!CORBA::is_nil(anObject)) - RemoveScalarBarPosition(this,anObject); - ErasePrs( this, anObject, false ); + for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) { + Handle(SALOME_InteractiveObject) anIO = it.Value(); + CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry()); + //ErasePrs(this, anObject, /*repaint_view_window = */false); + ErasePrs(this, anObject, /*repaint_view_window = */true); } - if (vw) - vw->Repaint(); + //if (vw) + // vw->Repaint(); QApplication::restoreOverrideCursor(); } @@ -682,7 +684,7 @@ VisuGUI:: OnEraseAll() { startOperation( myEraseAll ); - if (SVTK_ViewWindow* vw = GetViewWindow(this)) { + if (SVTK_ViewWindow* vw = GetActiveViewWindow(this)) { vw->unHighlightAll(); if (vtkRenderer *aRen = vw->getRenderer()) { vtkActor *anActor; @@ -690,7 +692,7 @@ OnEraseAll() for (anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ) { if (anActor->GetVisibility() > 0) if (VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)) { - RemoveScalarBarPosition(this,anVISUActor->GetPrs3d()); + RemoveScalarBarPosition(this, vw, anVISUActor->GetPrs3d()); anVISUActor->VisibilityOff(); } } @@ -707,26 +709,17 @@ VisuGUI:: OnEditScalarMap() { Handle(SALOME_InteractiveObject) anIO; - if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); - if(SVTK_ViewWindow* aViewWindow = GetViewWindow(this)){ - aViewWindow->highlight(anIO, 1); - } - } + if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) + EditPrs3d(this, anIO, aPrs3d); } - void VisuGUI:: OnEditDeformedShape() { Handle(SALOME_InteractiveObject) anIO; - if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); - if(SVTK_ViewWindow* aViewWindow = GetViewWindow(this)){ - aViewWindow->highlight(anIO, 1); - } - } + if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) + EditPrs3d(this, anIO, aPrs3d); } void @@ -734,12 +727,8 @@ VisuGUI:: OnEditScalarMapOnDeformedShape() { Handle(SALOME_InteractiveObject) anIO; - if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); - if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ - aViewWindow->highlight(anIO, 1); - } - } + if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) + EditPrs3d(this, anIO, aPrs3d); } void @@ -747,82 +736,53 @@ VisuGUI:: OnEditCutPlanes() { Handle(SALOME_InteractiveObject) anIO; - if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); - if(SVTK_ViewWindow* aViewWindow = GetViewWindow(this)){ - aViewWindow->highlight(anIO, 1); - } - } + if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) + EditPrs3d(this, anIO, aPrs3d); } - void VisuGUI:: OnEditCutLines() { Handle(SALOME_InteractiveObject) anIO; - if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); - if(SVTK_ViewWindow* aViewWindow = GetViewWindow(this)){ - aViewWindow->highlight(anIO, 1); - } - } + if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) + EditPrs3d(this, anIO, aPrs3d); } - void VisuGUI:: OnEditIsoSurfaces() { Handle(SALOME_InteractiveObject) anIO; - if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); - if(SVTK_ViewWindow* aViewWindow = GetViewWindow(this)){ - aViewWindow->highlight(anIO, 1); - } - } + if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) + EditPrs3d(this, anIO, aPrs3d); } - void VisuGUI:: OnEditVectors() { Handle(SALOME_InteractiveObject) anIO; - if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); - if(SVTK_ViewWindow* aViewWindow = GetViewWindow(this)){ - aViewWindow->highlight(anIO, 1); - } - } + if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) + EditPrs3d(this, anIO, aPrs3d); } - void VisuGUI:: OnEditStreamLines() { Handle(SALOME_InteractiveObject) anIO; - if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); - if(SVTK_ViewWindow* aViewWindow = GetViewWindow(this)){ - aViewWindow->highlight(anIO, 1); - } - } + if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) + EditPrs3d(this, anIO, aPrs3d); } - void VisuGUI:: OnEditPlot3D() { Handle(SALOME_InteractiveObject) anIO; - if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); - if(SVTK_ViewWindow* aViewWindow = GetViewWindow(this)){ - aViewWindow->highlight(anIO, 1); - } - } + if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) + EditPrs3d(this, anIO, aPrs3d); } @@ -895,7 +855,7 @@ OnChangeColor() VISU::Prs3d_i* aPrs3d = dynamic_cast(aServant.in()); if (!aPrs3d) return; - SVTK_ViewWindow* vw = GetViewWindow(this); + SVTK_ViewWindow* vw = GetActiveViewWindow(this); if (!vw) return; VISU_Actor* anActor = GetActor(aPrs3d, vw); @@ -967,7 +927,7 @@ OnChangeWireframeColor() VISU::Prs3d_i* aPrs3d = dynamic_cast(aServant.in()); if (!aPrs3d) return; - SVTK_ViewWindow* vw = GetViewWindow(this); + SVTK_ViewWindow* vw = GetActiveViewWindow(this); if (!vw) return; VISU_Actor* anActor = GetActor(aPrs3d, vw); @@ -1002,7 +962,7 @@ OnChangeOpacity() VISU::Prs3d_i* aPrsObject = dynamic_cast(aServant.in()); if (!aPrsObject) return; - SVTK_ViewWindow* vw = GetViewWindow(this); + SVTK_ViewWindow* vw = GetActiveViewWindow(this); if (!vw) return; VISU_Actor* anActor = GetActor(aPrsObject, vw); @@ -1025,7 +985,7 @@ OnChangeLines() VISU::Prs3d_i* aPrsObject = dynamic_cast(aServant.in()); if (!aPrsObject) return; - SVTK_ViewWindow* vw = GetViewWindow(this); + SVTK_ViewWindow* vw = GetActiveViewWindow(this); if (!vw) return; VISU_Actor* anActor = GetActor(aPrsObject, vw); @@ -1549,7 +1509,7 @@ OnSweep() VISU::ScalarMap_i* aPrsObject = dynamic_cast(aServant.in()); if (!aPrsObject) return; - SVTK_ViewWindow* vw = GetViewWindow(this); + SVTK_ViewWindow* vw = GetActiveViewWindow(this); if (!vw) return; VISU_Actor* aActor = GetActor(aPrsObject, vw); @@ -1592,7 +1552,7 @@ void VisuGUI:: OnTimeAnimation() { - if(!VISU::GetViewWindow(this)) + if (!VISU::GetActiveViewWindow(this)) return; _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this)); @@ -1631,7 +1591,7 @@ void VisuGUI:: OnShowAnimation() { - if(!VISU::GetViewWindow(this)) + if (!VISU::GetActiveViewWindow(this)) return; LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); @@ -1689,7 +1649,6 @@ OnCopyPresentation() VISU::Mesh_i* aMeshPrs = dynamic_cast(aPrsObject); VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult()); aSameMesh->SameAs(aMeshPrs); - UpdateViewer(this, aSameMesh); } break; case VISU::TSCALARMAP: @@ -1697,7 +1656,6 @@ OnCopyPresentation() VISU::ScalarMap_i* aScalarPrs = dynamic_cast(aPrsObject); VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult(),true); aSameScalar->SameAs(aScalarPrs); - UpdateViewer(this, aSameScalar); } break; case VISU::TDEFORMEDSHAPE: @@ -1705,15 +1663,15 @@ OnCopyPresentation() VISU::DeformedShape_i* aDefPrs = dynamic_cast(aPrsObject); VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult(),true); aSameDeformed->SameAs(aDefPrs); - UpdateViewer(this, aSameDeformed); } break; case VISU::TSCALARMAPONDEFORMEDSHAPE: { - VISU::ScalarMapOnDeformedShape_i* aDefPrs = dynamic_cast(aPrsObject); - VISU::ScalarMapOnDeformedShape_i* aSameScalarMapOnDeformed = new VISU::ScalarMapOnDeformedShape_i(aDefPrs->GetResult(),true); + VISU::ScalarMapOnDeformedShape_i* aDefPrs = + dynamic_cast(aPrsObject); + VISU::ScalarMapOnDeformedShape_i* aSameScalarMapOnDeformed = + new VISU::ScalarMapOnDeformedShape_i(aDefPrs->GetResult(),true); aSameScalarMapOnDeformed->SameAs(aDefPrs); - UpdateViewer(this, aSameScalarMapOnDeformed); } break; case VISU::TCUTPLANES: @@ -1721,7 +1679,6 @@ OnCopyPresentation() VISU::CutPlanes_i* aCutPrs = dynamic_cast(aPrsObject); VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult(),true); aSameCut->SameAs(aCutPrs); - UpdateViewer(this, aSameCut); } break; case VISU::TCUTLINES: @@ -1729,7 +1686,6 @@ OnCopyPresentation() VISU::CutLines_i* aCutPrs = dynamic_cast(aPrsObject); VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult(),true); aSameCut->SameAs(aCutPrs); - UpdateViewer(this, aSameCut); } break; case VISU::TISOSURFACE: @@ -1737,7 +1693,6 @@ OnCopyPresentation() VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast(aPrsObject); VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult(),true); aSameIso->SameAs(aIsoPrs); - UpdateViewer(this, aSameIso); } break; case VISU::TSTREAMLINES: @@ -1745,7 +1700,6 @@ OnCopyPresentation() VISU::StreamLines_i* aLinesPrs = dynamic_cast(aPrsObject); VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult(),true); aSameLines->SameAs(aLinesPrs); - UpdateViewer(this, aSameLines); } break; case VISU::TVECTORS: @@ -1753,7 +1707,6 @@ OnCopyPresentation() VISU::Vectors_i* aVectorsPrs = dynamic_cast(aPrsObject); VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult(),true); aSameVectors->SameAs(aVectorsPrs); - UpdateViewer(this, aSameVectors); } break; case VISU::TPLOT3D: @@ -1761,7 +1714,6 @@ OnCopyPresentation() VISU::Plot3D_i* aPlot3DPrs = dynamic_cast(aPrsObject); VISU::Plot3D_i* aSamePlot3D = new VISU::Plot3D_i(aPlot3DPrs->GetResult()); aSamePlot3D->SameAs(aPlot3DPrs); - UpdateViewer(this, aSamePlot3D); } break; } @@ -1772,7 +1724,7 @@ void VisuGUI:: OnSelectionInfo() { - if (GetViewWindow(this)) + if (GetActiveViewWindow(this)) (new VisuGUI_SelectionDlg(this))->show(); else SUIT_MessageBox::warn1(GetDesktop(this), @@ -1835,11 +1787,9 @@ OnMergeScalarBars() } } if (update) { - if (SVTK_ViewWindow* vw = GetViewWindow(this)) { -//if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) { - vw->getRenderer()->ResetCameraClippingRange(); - vw->Repaint(); -//} + if (SVTK_ViewWindow* vw = GetActiveViewWindow(this)) { + vw->getRenderer()->ResetCameraClippingRange(); + vw->Repaint(); } } } @@ -1874,11 +1824,9 @@ OnFreeScalarBars() } } if (update) { - if (SVTK_ViewWindow* vw = GetViewWindow(this)) { -//if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) { - vw->getRenderer()->ResetCameraClippingRange(); - vw->Repaint(); -//} + if (SVTK_ViewWindow* vw = GetActiveViewWindow(this)) { + vw->getRenderer()->ResetCameraClippingRange(); + vw->Repaint(); } } } @@ -1922,7 +1870,7 @@ void VisuGUI:: OnArrangeActors() { - SVTK_ViewWindow* vw = GetViewWindow(this); + SVTK_ViewWindow* vw = GetActiveViewWindow(this); if (vw) { ArrangeDlg* aDlg = new ArrangeDlg (GetDesktop(this), vw); aDlg->exec(); @@ -2235,13 +2183,11 @@ createActions() aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_GLOBAL_SELECTION")); createAction( VISU_GLOBAL_SELECTION, tr("MEN_GLOBAL_SELECTION"), QIconSet(aPixmap), tr("MEN_GLOBAL_SELECTION"), "", 0, aParent, false, - //this, SLOT(OnEraseAll())); this); aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PARTIAL_SELECTION")); createAction( VISU_PARTIAL_SELECTION, tr("MEN_PARTIAL_SELECTION"), QIconSet(aPixmap), tr("MEN_PARTIAL_SELECTION"), "", 0, aParent, false, - //this, SLOT(OnEraseAll())); this); createAction( VISU_SHOW_ANIMATION, tr("MEN_SHOW_ANIMATION"), QIconSet(), diff --git a/src/VISUGUI/VisuGUI_ClippingDlg.cxx b/src/VISUGUI/VisuGUI_ClippingDlg.cxx index 2c9f7f1b..1f35f980 100644 --- a/src/VISUGUI/VisuGUI_ClippingDlg.cxx +++ b/src/VISUGUI/VisuGUI_ClippingDlg.cxx @@ -22,6 +22,7 @@ #include "VisuGUI.h" #include "VisuGUI_Tools.h" +#include "VisuGUI_ViewTools.h" #include "VISU_Prs3d_i.hh" #include "VISU_Result_i.hh" @@ -389,7 +390,7 @@ VisuGUI_ClippingDlg::~VisuGUI_ClippingDlg() { // no need to delete child widgets, Qt does it all for us std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false)); - VISU::RenderViewWindow(VISU::GetViewWindow(myVisuGUI)); + VISU::RenderViewWindow(VISU::GetActiveViewWindow(myVisuGUI)); } //================================================================================= @@ -481,7 +482,7 @@ void VisuGUI_ClippingDlg::ClickOnApply() if (!myPrs3d) return; - if (SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myVisuGUI)) { + if (SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myVisuGUI)) { SUIT_OverrideCursor wc; // Save clipping planes, currently applied to the presentation @@ -565,7 +566,7 @@ void VisuGUI_ClippingDlg::ClickOnCancel() //================================================================================= void VisuGUI_ClippingDlg::onSelectionChanged() { - if (SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myVisuGUI)) { + if (SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myVisuGUI)) { Handle(SALOME_InteractiveObject) anIO; CORBA::Object_var anObject = VISU::GetSelectedObj(myVisuGUI, &anIO); myIO = anIO; @@ -653,7 +654,7 @@ void VisuGUI_ClippingDlg::ClickOnNew() if (!myPrs3d) return; - if (SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myVisuGUI)) { + if (SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myVisuGUI)) { OrientedPlane* aPlane = OrientedPlane::New(aViewWindow); VISU::TVTKPlane aTVTKPlane(aPlane); myPlanes.push_back(aTVTKPlane); @@ -689,7 +690,7 @@ void VisuGUI_ClippingDlg::ClickOnDelete() ClickOnApply(); Sinchronize(); - if (SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myVisuGUI)) + if (SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myVisuGUI)) VISU::RenderViewWindow(aViewWindow); } @@ -886,7 +887,7 @@ void VisuGUI_ClippingDlg::SetCurrentPlaneParam() if (AutoApplyCheckBox->isChecked()) ClickOnApply(); - if (SVTK_ViewWindow* vw = VISU::GetViewWindow(myVisuGUI)) + if (SVTK_ViewWindow* vw = VISU::GetActiveViewWindow(myVisuGUI)) VISU::RenderViewWindow(vw); } @@ -1094,6 +1095,6 @@ void VisuGUI_ClippingDlg::onIJKAxisChanged(int axisId) void VisuGUI_ClippingDlg::OnPreviewToggle (bool theIsToggled) { std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(theIsToggled)); - if (SVTK_ViewWindow* vw = VISU::GetViewWindow(myVisuGUI)) + if (SVTK_ViewWindow* vw = VISU::GetActiveViewWindow(myVisuGUI)) VISU::RenderViewWindow(vw); } diff --git a/src/VISUGUI/VisuGUI_CutLinesDlg.cxx b/src/VISUGUI/VisuGUI_CutLinesDlg.cxx index a9983bf3..545e8c81 100644 --- a/src/VISUGUI/VisuGUI_CutLinesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutLinesDlg.cxx @@ -12,6 +12,7 @@ #include "VisuGUI.h" #include "VisuGUI_Tools.h" +#include "VisuGUI_ViewTools.h" #include "VISU_Gen_i.hh" #include "VISU_CutLines_i.hh" @@ -105,7 +106,7 @@ VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule) QHBox* aPosBox = new QHBox (aPlanePane); aPosBox->setSpacing(5); - QLabel* aPosLbl = new QLabel (tr("LBL_POS"), aPosBox); + new QLabel (tr("LBL_POS"), aPosBox); myPosSpn = new QtxDblSpinBox (0, 1, 0.1, aPosBox); myPosSpn->setValue(0.5); aPlaneLayout->addWidget(aPosBox); @@ -166,7 +167,7 @@ VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule) QHBox* aNbBox = new QHBox(aLinesPane); aNbBox->setSpacing(5); - QLabel* aNbLbl = new QLabel( tr( "LBL_NB_PLANS" ), aNbBox ); + new QLabel( tr( "LBL_NB_PLANS" ), aNbBox ); myNbSpn = new QtxDblSpinBox( 1, 100, 1, aNbBox ); myNbSpn->setValue( 10 ); @@ -186,7 +187,7 @@ VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule) QHBox* aPosBox2 = new QHBox(aLinesPane); aPosBox2->setSpacing(5); - QLabel* aPosLbl2 = new QLabel( tr( "LBL_POS" ), aPosBox2 ); + new QLabel( tr( "LBL_POS" ), aPosBox2 ); myPosSpn2 = new QtxDblSpinBox( 0, 1, 0.1, aPosBox2 ); myPosSpn2->setValue( 0.5 ); aLinesLayout->addWidget( aPosBox2 ); @@ -258,7 +259,7 @@ VisuGUI_CutLinesDlg::~VisuGUI_CutLinesDlg() deletePlanes(); if (myCutLines) //delete myCutLines; myCutLines->Destroy(); - if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) + if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) vf->Repaint(); } @@ -327,7 +328,7 @@ int VisuGUI_CutLinesDlg::storeToPrsObject (VISU::CutLines_i* thePrs) //------------------------------------------------------------------------------ void VisuGUI_CutLinesDlg::createPlanes() { - SVTK_ViewWindow* aView = VISU::GetViewWindow(); + SVTK_ViewWindow* aView = VISU::GetActiveViewWindow(); if (aView == NULL) return; if (myCutLines == NULL) return; if (myPreviewActor != 0) return; @@ -357,7 +358,7 @@ void VisuGUI_CutLinesDlg::createPlanes() void VisuGUI_CutLinesDlg::deletePlanes() { if (myPreviewActor == 0) return; - if (SVTK_ViewWindow* aView = VISU::GetViewWindow()){ + if (SVTK_ViewWindow* aView = VISU::GetActiveViewWindow()){ aView->RemoveActor(myPreviewActor); aView->RemoveActor(myPreviewActorGlyphs); } @@ -414,7 +415,7 @@ void VisuGUI_CutLinesDlg::onCutSelect (int theId, bool theUpdate) myRotXLbl2->setText( tr("LBL_ROT_Z")); myRotYLbl2->setText( tr("LBL_ROT_X")); } - SVTK_ViewWindow* aView = VISU::GetViewWindow(); + SVTK_ViewWindow* aView = VISU::GetActiveViewWindow(); if (aView) { if (theUpdate && myPreviewCheck->isChecked() && (myCutLines != NULL)) { /*myCutLines->SetOrientation2(getOrientaion(false), @@ -443,7 +444,7 @@ void VisuGUI_CutLinesDlg::setBaseDefault (bool theUpdate) /* float aPos = myCutLines->GetBasePlanePosition(); myBasePlanePos->setText( QString::number(aPos) ); myBasePlanePos->setEnabled(false);*/ - SVTK_ViewWindow* aView = VISU::GetViewWindow(); + SVTK_ViewWindow* aView = VISU::GetActiveViewWindow(); if (aView) { if (theUpdate && myPreviewCheck->isChecked() && (myCutLines != NULL)) { //myCutLines->SetBasePlanePosition(aPos); @@ -515,7 +516,7 @@ void VisuGUI_CutLinesDlg::DrawTable() vh->setLabel( i, str.arg(i+1) ); } // Update preview - SVTK_ViewWindow* aView = VISU::GetViewWindow(); + SVTK_ViewWindow* aView = VISU::GetActiveViewWindow(); if (aView) { if (myPreviewCheck->isChecked()) { // myCutLines->GetPL()->Update(); @@ -593,7 +594,7 @@ void VisuGUI_CutLinesDlg::updateGlyphs(bool update){ source->Delete(); aPlaneMapper->Delete(); - if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) + if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) if (update) vf->Repaint(); } @@ -684,7 +685,7 @@ void VisuGUI_CutLinesDlg::onValueChanged (int theRow, int theCol) QString aTxt = myPosTable->text(theRow, 0); bool isChanged = !aTxt.isEmpty(); ((QCheckTableItem*)myPosTable->item(theRow, 1))->setChecked(!isChanged); - SVTK_ViewWindow* aView = VISU::GetViewWindow(); + SVTK_ViewWindow* aView = VISU::GetActiveViewWindow(); if (aView) { if (myPreviewCheck->isChecked()) { //Update Preview @@ -700,7 +701,7 @@ void VisuGUI_CutLinesDlg::onValueChanged (int theRow, int theCol) if (isDefault) { //myCutLines->SetDefaultPosition(theRow); // myPosTable->setText(theRow, 0, QString::number(myCutLines->GetLinePosition(theRow))); - SVTK_ViewWindow* aView = VISU::GetViewWindow(); + SVTK_ViewWindow* aView = VISU::GetActiveViewWindow(); if (aView) { if (myPreviewCheck->isChecked()) { //Update Preview @@ -820,7 +821,7 @@ void VisuGUI_CutLinesDlg::reject() void VisuGUI_CutLinesDlg::onPreviewCheck (bool thePreview) { - if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) { + if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) { if (thePreview) { //storeToPrsObject(myCutLines); // myCutLines->GetPL()->Update(); @@ -851,7 +852,7 @@ void VisuGUI_CutLinesDlg::onAllCurvesInvertedCheck(bool theInvert) void VisuGUI_CutLinesDlg::onRotation (double theValue) { if (myCutLines == NULL) return; - SVTK_ViewWindow* aView = VISU::GetViewWindow(); + SVTK_ViewWindow* aView = VISU::GetActiveViewWindow(); if (aView) { if (myPreviewCheck->isChecked()) { @@ -872,7 +873,7 @@ void VisuGUI_CutLinesDlg::onRotation (double theValue) void VisuGUI_CutLinesDlg::onPlanePos (const QString& theValue) { if (myCutLines == NULL) return; - SVTK_ViewWindow* aView = VISU::GetViewWindow(); + SVTK_ViewWindow* aView = VISU::GetActiveViewWindow(); if (aView) { if (myPreviewCheck->isChecked()) { //myCutLines->SetBasePlanePosition(theValue.toDouble()); diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx index c4072907..486a475d 100644 --- a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx @@ -30,6 +30,7 @@ #include "VisuGUI.h" #include "VisuGUI_Tools.h" +#include "VisuGUI_ViewTools.h" #include "VISU_CutPlanes_i.hh" #include "VISU_CutPlanesPL.hxx" @@ -166,11 +167,10 @@ VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane (QWidget* theParent) VisuGUI_CutPlanesPane::~VisuGUI_CutPlanesPane() { - cout<<"### VisuGUI_CutPlanesPane::~VisuGUI_CutPlanesPane"<Destroy(); - if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) + if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) vf->Repaint(); } @@ -194,7 +194,7 @@ void VisuGUI_CutPlanesPane::initFromPrsObject (VISU::CutPlanes_i* thePrs) void VisuGUI_CutPlanesPane::createPlanes() { - if (VISU::GetViewWindow() == NULL) return; + if (VISU::GetActiveViewWindow() == NULL) return; if (myCutPlanes == NULL) return; if (myPreviewActor != 0) return; @@ -211,7 +211,7 @@ void VisuGUI_CutPlanesPane::createPlanes() myPreviewActor->PickableOff(); myPreviewActor->SetMapper(aPlaneMapper); aPlaneMapper->Delete(); - VISU::GetViewWindow()->AddActor(myPreviewActor); + VISU::GetActiveViewWindow()->AddActor(myPreviewActor); } int VisuGUI_CutPlanesPane::storeToPrsObject (VISU::CutPlanes_i* thePrs) @@ -349,7 +349,7 @@ void VisuGUI_CutPlanesPane::DrawTable() // Update preview if (myPreviewCheck->isChecked()) { - if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) { + if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) { myCutPlanes->GetPL()->Update(); deletePlanes(); createPlanes(); @@ -386,7 +386,7 @@ void VisuGUI_CutPlanesPane::onValueChanged (int theRow, int theCol) if (myPreviewCheck->isChecked()) { //Update Preview - if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) { + if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) { myCutPlanes->SetPlanePosition( theRow, aTxt.toDouble()); myCutPlanes->GetPL()->Update(); deletePlanes(); @@ -401,7 +401,7 @@ void VisuGUI_CutPlanesPane::onValueChanged (int theRow, int theCol) myPosTable->setText(theRow, 0, QString::number(myCutPlanes->GetPlanePosition(theRow))); if (myPreviewCheck->isChecked()) { - if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) { + if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) { //Update Preview myCutPlanes->GetPL()->Update(); deletePlanes(); @@ -417,7 +417,7 @@ void VisuGUI_CutPlanesPane::onValueChanged (int theRow, int theCol) void VisuGUI_CutPlanesPane::deletePlanes() { if (myPreviewActor == 0) return; - if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) + if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) vf->RemoveActor(myPreviewActor); myPreviewActor->Delete(); myPreviewActor = 0; @@ -427,7 +427,7 @@ void VisuGUI_CutPlanesPane::onRotation (double theValue) { if (myCutPlanes == NULL) return; if (myPreviewCheck->isChecked()) { - if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) { + if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) { myCutPlanes->SetOrientation(getOrientaion(),getRotation1()*PI/180.,getRotation2()*PI/180.); myCutPlanes->GetPL()->Update(); deletePlanes(); @@ -439,7 +439,7 @@ void VisuGUI_CutPlanesPane::onRotation (double theValue) void VisuGUI_CutPlanesPane::onPreviewCheck (bool thePreview) { - if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) { + if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) { if (thePreview) { storeToPrsObject(myCutPlanes); myCutPlanes->GetPL()->Update(); diff --git a/src/VISUGUI/VisuGUI_Displayer.cxx b/src/VISUGUI/VisuGUI_Displayer.cxx index 1fa6f098..2939ca90 100644 --- a/src/VISUGUI/VisuGUI_Displayer.cxx +++ b/src/VISUGUI/VisuGUI_Displayer.cxx @@ -27,10 +27,13 @@ // $Header: /home/server/cvs/VISU/VISU_SRC/src/VISUGUI/VisuGUI_Displayer.cxx #include "VisuGUI_Displayer.h" -#include "VVTK_ViewModel.h" + #include "VisuGUI_Tools.h" +#include "VISU_ViewManager_i.hh" #include "VISU_Actor.h" +#include "VVTK_ViewModel.h" + #include #include @@ -41,7 +44,7 @@ #include #include -#include "VISU_ViewManager_i.hh" +#include VisuGUI_Displayer::VisuGUI_Displayer( SalomeApp_Application* app ) : LightApp_Displayer(), @@ -67,7 +70,9 @@ SALOME_Prs* VisuGUI_Displayer::buildPresentation( const QString& entry, SALOME_V if( CORBA::is_nil( anObj ) ) return 0; - SVTK_Viewer* vtk_viewer = dynamic_cast( aViewFrame ); + SVTK_Viewer* vtk_viewer = dynamic_cast( aViewFrame ); + if (!vtk_viewer) + vtk_viewer = dynamic_cast( aViewFrame ); if( vtk_viewer ) { SVTK_ViewWindow* wnd = @@ -116,14 +121,22 @@ SALOME_Prs* VisuGUI_Displayer::buildPresentation( const QString& entry, SALOME_V void VisuGUI_Displayer::buildPrs3d( SVTK_ViewWindow* wnd, VISU::Prs3d_i* thePrs ) const { - VISU_Actor* newAct = VISU::FindActor( wnd, thePrs ); - if( !newAct ) - { - newAct = thePrs->CreateActor(); + VISU_Actor* newAct = VISU::FindActor(wnd, thePrs); + if (!newAct) { + try { + newAct = thePrs->CreateActor(); + } catch (std::runtime_error& exc) { + thePrs->RemoveActors(); + + INFOS(exc.what()); + SUIT_MessageBox::warn1 + (myApp->desktop(), QObject::tr("WRN_VISU"), + QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(exc.what()), + QObject::tr("BUT_OK")); + } } - if( newAct ) - { - wnd->AddActor( newAct ); + if (newAct) { + wnd->AddActor(newAct); wnd->Repaint(); } } diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index f496c5dc..c9742837 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -1,4 +1,4 @@ - +// VISU VISUGUI : GUI of VISU component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -172,24 +172,24 @@ namespace VISU } //--------------------------------------------------------------- -VisuGUI_Module -::VisuGUI_Module() : +VisuGUI_Module:: +VisuGUI_Module() : VisuGUI() { } //--------------------------------------------------------------- -VisuGUI_Module -::~VisuGUI_Module() +VisuGUI_Module:: +~VisuGUI_Module() { } //--------------------------------------------------------------- void -VisuGUI_Module -::initialize( CAM_Application* theApp ) +VisuGUI_Module:: +initialize( CAM_Application* theApp ) { VisuGUI::initialize( theApp ); @@ -230,7 +230,8 @@ VisuGUI_Module accel->setActionKey( SVTK::PlusSpeedIncrementEvent, Key_Plus, aViewerType ); accel->setActionKey( SVTK::MinusSpeedIncrementEvent, Key_Minus, aViewerType ); - connect( getApp(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ), this, SLOT( OnViewManagerAdded (SUIT_ViewManager*) ) ); + connect( getApp(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ), + this, SLOT( OnViewManagerAdded (SUIT_ViewManager*) ) ); // Prepare popup menus QtxPopupMgr* mgr = popupMgr(); @@ -283,21 +284,21 @@ VisuGUI_Module this, SLOT(OnErasePrs())); mgr->insert( action( GAUSS_ERASE_PRS ), -1, -1, -1 ); // erase mgr->setRule( action( GAUSS_ERASE_PRS ), - aRule + " and (isVisible=true)", true ); + aRule + " and ({true} in $canBeDisplayed) and (isVisible=true)", true ); createAction( GAUSS_DISPLAY_PRS, VisuGUI::tr("MEN_DISPLAY"), QIconSet(), VisuGUI::tr("MEN_DISPLAY"), "", 0, this, false, this, SLOT(OnDisplayPrs())); mgr->insert( action( GAUSS_DISPLAY_PRS ), -1, -1, -1 ); // display mgr->setRule( action( GAUSS_DISPLAY_PRS ), - aRule + " and (isVisible=false)", true ); + aRule + " and ({true} in $canBeDisplayed) and (isVisible=false)", true ); createAction( GAUSS_DISPLAY_ONLY_PRS, VisuGUI::tr("MEN_DISPLAY_ONLY"), QIconSet(), VisuGUI::tr("MEN_DISPLAY_ONLY"), "", 0, this, false, this, SLOT(OnDisplayOnlyPrs())); mgr->insert( action( GAUSS_DISPLAY_ONLY_PRS ), -1, -1, -1 ); // display only mgr->setRule( action( GAUSS_DISPLAY_ONLY_PRS ), - aRule, true ); + aRule + " and ({true} in $canBeDisplayed)", true ); createAction( GAUSS_RENAME_CONFIGURATION, VisuGUI::tr("MEN_RENAME"), QIconSet(), VisuGUI::tr("MEN_RENAME"), "", 0, this, false, @@ -309,7 +310,8 @@ VisuGUI_Module tr("MEN_SAVE_CONFIGURATION"), "", 0, this, false, this, SLOT(OnSaveConfiguration())); mgr->insert( action( GAUSS_SAVE_CONFIGURATION ), -1, -1, -1 ); - mgr->setRule( action( GAUSS_SAVE_CONFIGURATION ), "selcount>=0 and client='VVTK' and activeView='VVTK'", true ); + mgr->setRule( action( GAUSS_SAVE_CONFIGURATION ), + "selcount>=0 and client='VVTK' and activeView='VVTK'", true ); createAction( GAUSS_OVERWRITE_CONFIGURATION, tr("MEN_OVERWRITE_CONFIGURATION"), QIconSet(), tr("MEN_OVERWRITE_CONFIGURATION"), "", 0, this, false, @@ -328,8 +330,8 @@ VisuGUI_Module //--------------------------------------------------------------- bool -VisuGUI_Module -::activateModule( SUIT_Study* theStudy ) +VisuGUI_Module:: +activateModule( SUIT_Study* theStudy ) { VisuGUI::activateModule( theStudy ); @@ -341,8 +343,8 @@ VisuGUI_Module //--------------------------------------------------------------- bool -VisuGUI_Module -::deactivateModule( SUIT_Study* theStudy ) +VisuGUI_Module:: +deactivateModule( SUIT_Study* theStudy ) { VisuGUI::deactivateModule( theStudy ); @@ -354,8 +356,8 @@ VisuGUI_Module //--------------------------------------------------------------- SUIT_ViewManager* -VisuGUI_Module -::onCreateViewManager() +VisuGUI_Module:: +onCreateViewManager() { Viewer* aViewer = new Viewer( this, myViewerMap ); return aViewer->getViewManager(); @@ -364,8 +366,8 @@ VisuGUI_Module //--------------------------------------------------------------- void -VisuGUI_Module -::onLastViewClosed(SUIT_ViewManager* theViewManager) +VisuGUI_Module:: +onLastViewClosed(SUIT_ViewManager* theViewManager) { myViewerMap.erase(theViewManager); } @@ -373,8 +375,8 @@ VisuGUI_Module //--------------------------------------------------------------- void -VisuGUI_Module -::createPreferences() +VisuGUI_Module:: +createPreferences() { VisuGUI::createPreferences(); @@ -389,15 +391,16 @@ VisuGUI_Module //--------------------------------------------------------------- void -VisuGUI_Module -::createGaussPointsPreferences() +VisuGUI_Module:: +createGaussPointsPreferences() { int gaussTab = addPreference( tr( "VISU_GAUSS_PREF_TAB_TTL" ) ); int primitiveGr = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_GROUP_TTL" ), gaussTab ); setPreferenceProperty( primitiveGr, "columns", 1 ); int primitiveTypePref = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_TYPE" ), primitiveGr, - LightApp_Preferences::Selector, "VISU", "point_sprite_primitive_type" ); + LightApp_Preferences::Selector, "VISU", + "point_sprite_primitive_type" ); QStringList values; values.append( tr( "VISU_GAUSS_PREF_POINTSPRITE" ) ); @@ -422,7 +425,8 @@ VisuGUI_Module LightApp_Preferences::File, "VISU", "point_sprite_alpha_texture" ); int alphaThresholdPref = addPreference( tr( "VISU_GAUSS_PREF_ALPHA_THRESHOLD" ), primitiveGr, - LightApp_Preferences::DblSpin, "VISU", "point_sprite_alpha_threshold" ); + LightApp_Preferences::DblSpin, "VISU", + "point_sprite_alpha_threshold" ); setPreferenceProperty( alphaThresholdPref, "min", 0.0 ); setPreferenceProperty( alphaThresholdPref, "max", 1.0 ); setPreferenceProperty( alphaThresholdPref, "step", 0.1 ); @@ -451,7 +455,8 @@ VisuGUI_Module setPreferenceProperty( maxSizePref, "max", 100 ); int magnificationPref = addPreference( tr( "VISU_GAUSS_PREF_MAGNIFICATION" ), sizeGr, - LightApp_Preferences::IntSpin, "VISU", "point_sprite_magnification" ); + LightApp_Preferences::IntSpin, "VISU", + "point_sprite_magnification" ); setPreferenceProperty( magnificationPref, "min", 10 ); setPreferenceProperty( magnificationPref, "max", 1000 ); @@ -513,8 +518,8 @@ VisuGUI_Module //--------------------------------------------------------------- void -VisuGUI_Module -::createInsideCursorPreferences() +VisuGUI_Module:: +createInsideCursorPreferences() { int insideCursorTab = addPreference( tr( "VISU_GAUSS_INSIDE_CURSOR_PREF_TAB_TTL" ) ); @@ -522,7 +527,8 @@ VisuGUI_Module setPreferenceProperty( primitiveGr, "columns", 1 ); int primitiveTypePref = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_TYPE" ), primitiveGr, - LightApp_Preferences::Selector, "VISU", "inside_point_sprite_primitive_type" ); + LightApp_Preferences::Selector, "VISU", + "inside_point_sprite_primitive_type" ); QStringList values; values.append( tr( "VISU_GAUSS_PREF_POINTSPRITE" ) ); @@ -547,18 +553,21 @@ VisuGUI_Module LightApp_Preferences::File, "VISU", "inside_point_sprite_alpha_texture" ); int alphaThresholdPref = addPreference( tr( "VISU_GAUSS_PREF_ALPHA_THRESHOLD" ), primitiveGr, - LightApp_Preferences::DblSpin, "VISU", "inside_point_sprite_alpha_threshold" ); + LightApp_Preferences::DblSpin, "VISU", + "inside_point_sprite_alpha_threshold" ); setPreferenceProperty( alphaThresholdPref, "min", 0.0 ); setPreferenceProperty( alphaThresholdPref, "max", 1.0 ); setPreferenceProperty( alphaThresholdPref, "step", 0.1 ); int resolutionPref = addPreference( tr( "VISU_GAUSS_PREF_RESOLUTION" ), primitiveGr, - LightApp_Preferences::IntSpin, "VISU", "inside_geom_sphere_resolution" ); + LightApp_Preferences::IntSpin, "VISU", + "inside_geom_sphere_resolution" ); setPreferenceProperty( resolutionPref, "min", 3 ); setPreferenceProperty( resolutionPref, "max", 100 ); int faceLimitPref = addPreference( tr( "VISU_GAUSS_PREF_FACE_LIMIT" ), primitiveGr, - LightApp_Preferences::IntSpin, "VISU", "inside_geom_sphere_face_limit" ); + LightApp_Preferences::IntSpin, "VISU", + "inside_geom_sphere_face_limit" ); setPreferenceProperty( faceLimitPref, "min", 10 ); setPreferenceProperty( faceLimitPref, "max", 1000000 ); @@ -566,12 +575,14 @@ VisuGUI_Module setPreferenceProperty( sizeGr, "columns", 2 ); int minSizePref = addPreference( tr( "VISU_GAUSS_PREF_MIN_SIZE" ), sizeGr, - LightApp_Preferences::IntSpin, "VISU", "inside_point_sprite_min_size" ); + LightApp_Preferences::IntSpin, "VISU", + "inside_point_sprite_min_size" ); setPreferenceProperty( minSizePref, "min", 1 ); setPreferenceProperty( minSizePref, "max", 100 ); int maxSizePref = addPreference( tr( "VISU_GAUSS_PREF_MAX_SIZE" ), sizeGr, - LightApp_Preferences::IntSpin, "VISU", "inside_point_sprite_max_size" ); + LightApp_Preferences::IntSpin, "VISU", + "inside_point_sprite_max_size" ); setPreferenceProperty( maxSizePref, "min", 1 ); setPreferenceProperty( maxSizePref, "max", 100 ); @@ -579,23 +590,24 @@ VisuGUI_Module setPreferenceProperty( magnificationGr, "columns", 2 ); int magnificationPref = addPreference( tr( "VISU_GAUSS_PREF_MAGNIFICATION" ), magnificationGr, - LightApp_Preferences::IntSpin, "VISU", "inside_point_sprite_magnification" ); + LightApp_Preferences::IntSpin, "VISU", + "inside_point_sprite_magnification" ); setPreferenceProperty( magnificationPref, "min", 10 ); setPreferenceProperty( magnificationPref, "max", 1000 ); int incrementPref = addPreference( tr( "VISU_GAUSS_PREF_INCREMENT" ), magnificationGr, - LightApp_Preferences::DblSpin, "VISU", "inside_point_sprite_increment" ); + LightApp_Preferences::DblSpin, "VISU", + "inside_point_sprite_increment" ); setPreferenceProperty( incrementPref, "min", 0.01 ); setPreferenceProperty( incrementPref, "max", 10 ); setPreferenceProperty( incrementPref, "step", 0.1 ); - } //--------------------------------------------------------------- void -VisuGUI_Module -::createOutsideCursorPreferences() +VisuGUI_Module:: +createOutsideCursorPreferences() { int outsideCursorTab = addPreference( tr( "VISU_GAUSS_OUTSIDE_CURSOR_PREF_TAB_TTL" ) ); @@ -603,7 +615,8 @@ VisuGUI_Module setPreferenceProperty( primitiveGr, "columns", 1 ); int primitiveTypePref = addPreference( tr( "VISU_GAUSS_PREF_PRIMITIVE_TYPE" ), primitiveGr, - LightApp_Preferences::Selector, "VISU", "outside_point_sprite_primitive_type" ); + LightApp_Preferences::Selector, "VISU", + "outside_point_sprite_primitive_type" ); QStringList values; values.append( tr( "VISU_GAUSS_PREF_POINTSPRITE" ) ); @@ -628,18 +641,21 @@ VisuGUI_Module LightApp_Preferences::File, "VISU", "outside_point_sprite_alpha_texture" ); int alphaThresholdPref = addPreference( tr( "VISU_GAUSS_PREF_ALPHA_THRESHOLD" ), primitiveGr, - LightApp_Preferences::DblSpin, "VISU", "outside_point_sprite_alpha_threshold" ); + LightApp_Preferences::DblSpin, "VISU", + "outside_point_sprite_alpha_threshold" ); setPreferenceProperty( alphaThresholdPref, "min", 0.0 ); setPreferenceProperty( alphaThresholdPref, "max", 1.0 ); setPreferenceProperty( alphaThresholdPref, "step", 0.1 ); int resolutionPref = addPreference( tr( "VISU_GAUSS_PREF_RESOLUTION" ), primitiveGr, - LightApp_Preferences::IntSpin, "VISU", "outside_geom_sphere_resolution" ); + LightApp_Preferences::IntSpin, "VISU", + "outside_geom_sphere_resolution" ); setPreferenceProperty( resolutionPref, "min", 3 ); setPreferenceProperty( resolutionPref, "max", 100 ); int faceLimitPref = addPreference( tr( "VISU_GAUSS_PREF_FACE_LIMIT" ), primitiveGr, - LightApp_Preferences::IntSpin, "VISU", "outside_geom_sphere_face_limit" ); + LightApp_Preferences::IntSpin, "VISU", + "outside_geom_sphere_face_limit" ); setPreferenceProperty( faceLimitPref, "min", 10 ); setPreferenceProperty( faceLimitPref, "max", 1000000 ); @@ -663,8 +679,8 @@ VisuGUI_Module //--------------------------------------------------------------- void -VisuGUI_Module -::createPickingPreferences() +VisuGUI_Module:: +createPickingPreferences() { int pickingTab = addPreference( tr( "VISU_PICKING_PREF_TAB_TTL" ) ); @@ -673,7 +689,7 @@ VisuGUI_Module setPreferenceProperty( cursorGr, "columns", 1 ); int cursorSizePref = addPreference( tr( "VISU_PICKING_PREF_CURSOR_SIZE" ), cursorGr, - LightApp_Preferences::DblSpin, "VISU", "picking_cursor_size" ); + LightApp_Preferences::DblSpin, "VISU", "picking_cursor_size" ); setPreferenceProperty( cursorSizePref, "min", 0 ); setPreferenceProperty( cursorSizePref, "max", 1.0 ); setPreferenceProperty( cursorSizePref, "step", 0.1 ); @@ -683,14 +699,15 @@ VisuGUI_Module setPreferenceProperty( pyramidHeightPref, "min", 1 ); setPreferenceProperty( pyramidHeightPref, "max", 100 ); - int selectionColorPref = addPreference( tr( "VISU_PICKING_PREF_SELECTION_COLOR" ), cursorGr, - LightApp_Preferences::Color, "VISU", "picking_selection_color" ); + /*int selectionColorPref = */ + addPreference( tr( "VISU_PICKING_PREF_SELECTION_COLOR" ), cursorGr, + LightApp_Preferences::Color, "VISU", "picking_selection_color" ); // Tolerance int toleranceGr = addPreference( tr( "VISU_PICKING_PREF_TOLERANCE_GROUP_TTL" ), pickingTab ); int pointTolerancePref = addPreference( tr( "VISU_PICKING_PREF_POINT_SELECTION_TOLERANCE" ), toleranceGr, - LightApp_Preferences::DblSpin, "VISU", "picking_point_tolerance" ); + LightApp_Preferences::DblSpin, "VISU", "picking_point_tolerance" ); setPreferenceProperty( pointTolerancePref, "min", 0.001 ); setPreferenceProperty( pointTolerancePref, "max", 10 ); setPreferenceProperty( pointTolerancePref, "step", 0.01 ); @@ -742,13 +759,14 @@ VisuGUI_Module //--------------------------------------------------------------- void -VisuGUI_Module -::createSpaceMousePreferences() +VisuGUI_Module:: +createSpaceMousePreferences() { int mouseTab = addPreference( tr( "VISU_MOUSE_PREF_TAB_TLT" ) ); int mouseGr = addPreference( tr( "VISU_MOUSE_PREF_GROUP_TLT" ), mouseTab ); - int mousePref = addPreference( tr( "VISU_MOUSE_PREF" ), mouseGr, LightApp_Preferences::Selector, "VISU", "mouse_behaviour" ); + int mousePref = addPreference( tr( "VISU_MOUSE_PREF" ), mouseGr, + LightApp_Preferences::Selector, "VISU", "mouse_behaviour" ); QStringList values; values.append( tr( "VISU_MOUSE_PREF_STANDARD" ) ); values.append( tr( "VISU_MOUSE_PREF_KEYBOARD_FREE" ) ); @@ -759,16 +777,27 @@ VisuGUI_Module setPreferenceProperty( mousePref, "indexes", indices ); int keybrdGr = addPreference( tr( "VISU_KEYBOARD_PREF_GROUP_TTL" ), mouseTab ); - int keybrdPref = addPreference( tr( "VISU_KEYBOARD_PREF" ), keybrdGr, LightApp_Preferences::IntSpin, "VISU", "speed_increment" ); + int keybrdPref = addPreference( tr( "VISU_KEYBOARD_PREF" ), keybrdGr, + LightApp_Preferences::IntSpin, "VISU", "speed_increment" ); setPreferenceProperty( keybrdPref, "max", 1000 ); int spacemouseGr = addPreference( tr( "VISU_SPACEMOUSE_PREF" ), mouseTab ); setPreferenceProperty( spacemouseGr, "columns", 1 ); - int spacemousePref1 = addPreference( tr( "VISU_SPACEMOUSE_PREF_1" ), spacemouseGr, LightApp_Preferences::Selector, "VISU", "spacemouse_func1_btn" ); //decrease_speed_increment - int spacemousePref2 = addPreference( tr( "VISU_SPACEMOUSE_PREF_2" ), spacemouseGr, LightApp_Preferences::Selector, "VISU", "spacemouse_func2_btn" ); //increase_speed_increment - int spacemousePref3 = addPreference( tr( "VISU_SPACEMOUSE_PREF_3" ), spacemouseGr, LightApp_Preferences::Selector, "VISU", "spacemouse_func3_btn" ); //decrease_gauss_point_magnification - int spacemousePref4 = addPreference( tr( "VISU_SPACEMOUSE_PREF_4" ), spacemouseGr, LightApp_Preferences::Selector, "VISU", "spacemouse_func4_btn" ); //increase_gauss_point_magnification - int spacemousePref5 = addPreference( tr( "VISU_SPACEMOUSE_PREF_5" ), spacemouseGr, LightApp_Preferences::Selector, "VISU", "spacemouse_func5_btn" ); //dominant_combined_switch + int spacemousePref1 = addPreference( tr( "VISU_SPACEMOUSE_PREF_1" ), spacemouseGr, + LightApp_Preferences::Selector, "VISU", + "spacemouse_func1_btn" ); //decrease_speed_increment + int spacemousePref2 = addPreference( tr( "VISU_SPACEMOUSE_PREF_2" ), spacemouseGr, + LightApp_Preferences::Selector, "VISU", + "spacemouse_func2_btn" ); //increase_speed_increment + int spacemousePref3 = addPreference( tr( "VISU_SPACEMOUSE_PREF_3" ), spacemouseGr, + LightApp_Preferences::Selector, "VISU", + "spacemouse_func3_btn" ); //decrease_gauss_point_magnification + int spacemousePref4 = addPreference( tr( "VISU_SPACEMOUSE_PREF_4" ), spacemouseGr, + LightApp_Preferences::Selector, "VISU", + "spacemouse_func4_btn" ); //increase_gauss_point_magnification + int spacemousePref5 = addPreference( tr( "VISU_SPACEMOUSE_PREF_5" ), spacemouseGr, + LightApp_Preferences::Selector, "VISU", + "spacemouse_func5_btn" ); //dominant_combined_switch values.clear(); values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_1" ) ); values.append( tr( "VISU_SPACEMOUSE_PREF_BTN_2" ) ); @@ -808,8 +837,8 @@ VisuGUI_Module //--------------------------------------------------------------- void -VisuGUI_Module -::createRecorderPreferences() +VisuGUI_Module:: +createRecorderPreferences() { int recorderTab = addPreference( tr( "VISU_RECORDER_PREF_TAB_TTL" ) ); @@ -844,27 +873,28 @@ VisuGUI_Module //--------------------------------------------------------------- void -VisuGUI_Module -::OnCreateGaussPoints() +VisuGUI_Module:: +OnCreateGaussPoints() { double initialTime = vtkTimerLog::GetCPUTime(); - CreatePrs3d(this,true); + CreatePrs3d(this); INFOS( "VisuGUI_Module::OnCreateGaussPoints() : Gauss Points created in " << vtkTimerLog::GetCPUTime() - initialTime << " seconds" ); } void -VisuGUI_Module -::OnViewManagerAdded(SUIT_ViewManager* viewMgr) +VisuGUI_Module:: +OnViewManagerAdded(SUIT_ViewManager* viewMgr) { QString type = viewMgr->getViewModel()->getType(); if ( type == VVTK_Viewer::Type() ) - connect( viewMgr, SIGNAL( viewCreated( SUIT_ViewWindow* ) ), this, SLOT( OnViewCreated( SUIT_ViewWindow* ) ) ); + connect( viewMgr, SIGNAL( viewCreated( SUIT_ViewWindow* ) ), + this, SLOT( OnViewCreated( SUIT_ViewWindow* ) ) ); } void -VisuGUI_Module -::OnViewCreated(SUIT_ViewWindow* view) +VisuGUI_Module:: +OnViewCreated(SUIT_ViewWindow* view) { SVTK_ViewWindow* viewWindow = dynamic_cast( view ); if ( viewWindow ) { @@ -878,8 +908,8 @@ VisuGUI_Module } void -VisuGUI_Module -::setProperty( SVTK_ViewWindow* viewWindow, const QString& pref ) +VisuGUI_Module:: +setProperty( SVTK_ViewWindow* viewWindow, const QString& pref ) { if ( !viewWindow ) return; @@ -914,8 +944,8 @@ VisuGUI_Module } void -VisuGUI_Module -::setProperty( SVTK_ViewManager* vm, const QString& prop ) +VisuGUI_Module:: +setProperty( SVTK_ViewManager* vm, const QString& prop ) { if ( !vm ) return; @@ -926,8 +956,8 @@ VisuGUI_Module } void -VisuGUI_Module -::preferencesChanged( const QString& group, const QString& pref ) +VisuGUI_Module:: +preferencesChanged( const QString& group, const QString& pref ) { VisuGUI::preferencesChanged(group,pref); @@ -945,14 +975,14 @@ VisuGUI_Module //--------------------------------------------------------------- SUIT_ViewManager* -VisuGUI_Module -::getViewManager(const QString& theType, - const bool theIsCreate) +VisuGUI_Module:: +getViewManager(const QString& theType, + const bool theIsCreate) { - if(SUIT_ViewManager* aViewManager = VisuGUI::getViewManager(theType,theIsCreate)) + if (SUIT_ViewManager* aViewManager = VisuGUI::getViewManager(theType,theIsCreate)) return aViewManager; - if(theIsCreate && VVTK_Viewer::Type() == theType) + if (theIsCreate && theType == VVTK_Viewer::Type()) return onCreateViewManager(); return NULL; @@ -960,131 +990,16 @@ VisuGUI_Module //--------------------------------------------------------------- void -VisuGUI_Module -::OnEditGaussPoints() +VisuGUI_Module:: +OnEditGaussPoints() { Handle(SALOME_InteractiveObject) anIO; - if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); - if(SVTK_ViewWindow* aViewWindow = GetViewWindow(this,true)){ - aViewWindow->highlight(anIO,1); - } - } -} - - -//--------------------------------------------------------------- -void -VisuGUI_Module -::OnDisplayPrs() -{ - if(MYDEBUG) MESSAGE("VisuGUI_Module::OnDisplayPrs"); - - QApplication::setOverrideCursor(Qt::waitCursor); - - if(LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this)){ - SALOME_ListIO aSel, aList; - aSelectionMgr->selectedObjects(aSel); - extractContainers(aSel, 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::GetServant(anObject).in())){ - if(MYDEBUG) MESSAGE("VisuGUI_Module::OnDisplayPrs : Prs3d object"); - if(aPrs3d->GetType() == VISU::TGAUSSPOINTS) - VISU::UpdateViewer(this,aPrs3d,false,true,true); - else if(SUIT_ViewManager* aViewManager = getApp()->activeViewManager()){ - QString aType = aViewManager->getType(); - if(aType == SVTK_Viewer::Type()) - VISU::UpdateViewer(this,aPrs3d,false,true,true); - else if(aType == VVTK_Viewer::Type()) - VISU::UpdateViewer(this,aPrs3d,false,true,true); - } - continue; - } - } - - // is it Curve ? - if(VISU::Curve_i* aCurve = dynamic_cast(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::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::GetServant(anObject).in())){ - if(MYDEBUG) MESSAGE("VisuGUI_Module::DisplayPrs : Table object"); - PlotTable( this, aTable, VISU::eDisplay ); - continue; - } + if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) { + // Create VVTK_ViewWindow, if it does not exist + if (VVTK_ViewWindow* aViewWindow = GetViewWindow(this)) { + EditPrs3d(this, anIO, aPrs3d, aViewWindow); } } - - QApplication::restoreOverrideCursor(); -} - - -//--------------------------------------------------------------- -void -VisuGUI_Module -::OnEraseAll() -{ - if(SUIT_ViewManager* aViewManager = getApp()->activeViewManager()){ - QString aType = aViewManager->getType(); - if(aType == SVTK_Viewer::Type()) - VISU::OnEraseAll(this); - else if(aType == VVTK_Viewer::Type()) - VISU::OnEraseAll(this); - else if(aType == SPlot2d_Viewer::Type()) - VISU::OnEraseAll(this); - } -} - - -//--------------------------------------------------------------- -void -VisuGUI_Module -::OnDisplayOnlyPrs() -{ - OnEraseAll(); - OnDisplayPrs(); -} - - -//--------------------------------------------------------------- -void -VisuGUI_Module -::OnErasePrs() -{ - QApplication::setOverrideCursor(Qt::waitCursor); - - LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); - SALOME_ListIO aSel, aList; - aSelectionMgr->selectedObjects(aSel); - extractContainers(aSel, 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(); } @@ -1375,7 +1290,7 @@ namespace PortableServer::ServantBase_var aServant = VISU::GetServant(anObject); if(VISU::Prs3d_i* aPrs3d = dynamic_cast(aServant.in())){ // To set visiblity - VISU::UpdateViewer(theModule,aPrs3d,anIsFirst,false,false); + VISU::UpdateViewer(theModule, aPrs3d, /*disp_only = */anIsFirst, /*highlight = */false); anIsFirst = false; // To update selection diff --git a/src/VISUGUI/VisuGUI_Module.h b/src/VISUGUI/VisuGUI_Module.h index c13c8235..88371a1b 100644 --- a/src/VISUGUI/VisuGUI_Module.h +++ b/src/VISUGUI/VisuGUI_Module.h @@ -24,7 +24,6 @@ // File : VisuGUI_Module.h // Author : // Module : VISU -// $Header$ #ifndef VisuGUI_Module_HeaderFile #define VisuGUI_Module_HeaderFile @@ -146,26 +145,6 @@ protected slots: void OnEditGaussPoints(); - //! Reimplemented method of the Gauss Points displaying. - virtual - void - OnDisplayPrs(); - - //! Reimplemented method of the Gauss Points displaying only. - virtual - void - OnDisplayOnlyPrs(); - - //! Reimplemented method of the Gauss Points full erasing. - virtual - void - OnEraseAll(); - - //! Reimplemented method of the Gauss Points erasing. - virtual - void - OnErasePrs(); - //! Virtual method of saving configuration. virtual void diff --git a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx index a7935632..04ba4334 100644 --- a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx +++ b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx @@ -30,12 +30,14 @@ #include "VisuGUI.h" #include "VisuGUI_Tools.h" +#include "VisuGUI_ViewTools.h" #include "VISU_ViewManager_i.hh" #include "VISU_Plot3DPL.hxx" -#include "SALOME_Actor.h" #include "SVTK_ViewWindow.h" + +#include "SALOME_Actor.h" #include "SUIT_Desktop.h" #include @@ -127,7 +129,7 @@ class TPlane : public SALOME_Actor //======================================================================= VisuGUI_Plot3DPane::VisuGUI_Plot3DPane (QWidget* parent) : QVBox(parent), myInitFromPrs(false), myPreviewActor(NULL), - myViewWindow(VISU::GetViewWindow()), myPrs(NULL), myPipeCopy(NULL) + myViewWindow(VISU::GetActiveViewWindow()), myPrs(NULL), myPipeCopy(NULL) { layout()->setAlignment(Qt::AlignTop); setSpacing(6); diff --git a/src/VISUGUI/VisuGUI_PopupTools.cxx b/src/VISUGUI/VisuGUI_PopupTools.cxx index b4ca7c20..68299777 100644 --- a/src/VISUGUI/VisuGUI_PopupTools.cxx +++ b/src/VISUGUI/VisuGUI_PopupTools.cxx @@ -26,15 +26,17 @@ // Module : VISU #include "VisuGUI_PopupTools.h" + #include "VisuGUI_ViewTools.h" #include "VisuGUI_Tools.h" -#include "SalomeApp_Study.h" -#include "LightApp_Study.h" + +#include "VISU_Result_i.hh" #include "VISU_Actor.h" #include "VISU_ScalarMapAct.h" -#include "VISU_Result_i.hh" + #include "SalomeApp_Study.h" +#include "LightApp_Study.h" using namespace VISU; @@ -211,10 +213,10 @@ QString VisuGUI_Selection::representation( const int ind ) const { QString aResStr; - if ( SVTK_ViewWindow* aView = GetViewWindow( myModule ) ){ - if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) ){ + if (SVTK_ViewWindow* aView = GetActiveViewWindow(myModule)) { + if (VISU_Actor* anVISUActor = FindActor(aView, entry(ind).latin1())) { int aRepresent = anVISUActor->GetRepresentation(); - switch ( aRepresent ){ + switch (aRepresent) { ENUM2STRING( aResStr, VISU::POINT ); ENUM2STRING( aResStr, VISU::WIREFRAME ); ENUM2STRING( aResStr, VISU::SHADED ); @@ -278,8 +280,8 @@ namespace const QString& theEntry) { typedef typename TViewer::TViewWindow TViewWindow; - if(TViewWindow* aViewWindow = GetViewWindow(theModule)) - if(VISU_Actor* anActor = FindActor(aViewWindow,theEntry.latin1())) + if (TViewWindow* aViewWindow = GetActiveViewWindow(theModule)) + if (VISU_Actor* anActor = FindActor(aViewWindow,theEntry.latin1())) return anActor->GetVisibility() ? "true" : "false"; return QString(); @@ -315,7 +317,7 @@ QString VisuGUI_Selection::isShrunk( const int ind ) const { QString aResStr; - if ( SVTK_ViewWindow* aView = GetViewWindow( myModule ) ) + if ( SVTK_ViewWindow* aView = GetActiveViewWindow(myModule) ) if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) ) if ( anVISUActor->IsShrunkable() ) aResStr = anVISUActor->IsShrunk() ? "1" : "0"; @@ -332,7 +334,7 @@ QString VisuGUI_Selection::isShading( const int ind ) const { QString aResStr; - if ( SVTK_ViewWindow* aView = GetViewWindow( myModule ) ) + if ( SVTK_ViewWindow* aView = GetActiveViewWindow(myModule) ) if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) ) if ( VISU_ScalarMapAct* anActor = dynamic_cast(anVISUActor) ) aResStr = anActor->IsShading() ? "1" : "0"; @@ -344,12 +346,12 @@ QString VisuGUI_Selection::isScalarMapAct( const int ind ) const { QString aResStr; - if ( SVTK_ViewWindow* aView = GetViewWindow( myModule ) ) + if ( SVTK_ViewWindow* aView = GetActiveViewWindow(myModule) ) if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) ) - { - VISU_ScalarMapAct* anActor = dynamic_cast(anVISUActor); - aResStr = anActor ? "1" : "0"; - } - + { + VISU_ScalarMapAct* anActor = dynamic_cast(anVISUActor); + aResStr = anActor ? "1" : "0"; + } + return aResStr; } diff --git a/src/VISUGUI/VisuGUI_Prs3dTools.h b/src/VISUGUI/VisuGUI_Prs3dTools.h index 7984a698..3fc626bb 100644 --- a/src/VISUGUI/VisuGUI_Prs3dTools.h +++ b/src/VISUGUI/VisuGUI_Prs3dTools.h @@ -24,7 +24,6 @@ // File : VisuGUI_Module.h // Author : // Module : VISU -// $Header$ #ifndef VisuGUI_Prs3dTools_HeaderFile #define VisuGUI_Prs3dTools_HeaderFile @@ -52,9 +51,10 @@ namespace VISU template void EditPrs3d(VisuGUI* theModule, - VISU::Prs3d_i* thePrs3d) + VISU::Prs3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow) { - if(TPrs3d_i* aPrs3d = dynamic_cast(thePrs3d)){ + if (TPrs3d_i* aPrs3d = dynamic_cast(thePrs3d)) { TDlg* aDlg = new TDlg (theModule); aDlg->initFromPrsObject(aPrs3d); if (runAndWait(aDlg,TIsDlgModal)) { @@ -65,18 +65,17 @@ namespace VISU try { aPrs3d->UpdateActors(); } catch (std::runtime_error& exc) { + aPrs3d->RemoveActors(); + INFOS(exc.what()); SUIT_MessageBox::warn1 (GetDesktop(theModule), QObject::tr("WRN_VISU"), QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(exc.what()), QObject::tr("BUT_OK")); - - aPrs3d->RemoveActors(); } - typedef typename TViewer::TViewWindow TViewWindow; - if(TViewWindow* aViewWindow = GetViewWindow(theModule)){ - aViewWindow->getRenderer()->ResetCameraClippingRange(); - aViewWindow->Repaint(); + if (theViewWindow) { + theViewWindow->getRenderer()->ResetCameraClippingRange(); + theViewWindow->Repaint(); } // Optionally, create table and curves for cut lines QApplication::setOverrideCursor(Qt::waitCursor); @@ -93,10 +92,19 @@ namespace VISU template inline void - EditPrs3d(VisuGUI* theModule, - VISU::Prs3d_i* thePrs3d) + EditPrs3d(VisuGUI* theModule, + Handle(SALOME_InteractiveObject)& theIO, + VISU::Prs3d_i* thePrs3d, + SVTK_ViewWindow* theViewWindow = NULL) { - EditPrs3d(theModule,thePrs3d); + SVTK_ViewWindow* aViewWindow = theViewWindow; + if (!aViewWindow) + // Create SVTK_ViewWindow, if it does not exist + aViewWindow = GetViewWindow(theModule); + if (aViewWindow) { + EditPrs3d(theModule, thePrs3d, aViewWindow); + aViewWindow->highlight(theIO, 1); + } } //--------------------------------------------------------------- @@ -134,26 +142,30 @@ namespace VISU bool CreatePrs3d(VisuGUI* theModule, _PTR(SObject) theTimeStamp, - const Handle(SALOME_InteractiveObject)& theIO, - const bool theIsCreateView = false) + const Handle(SALOME_InteractiveObject)& theIO) { Storable::TRestoringMap aMap = getMapOfValue(theTimeStamp); bool isExist; QString aType = Storable::FindValue(aMap,"myType",&isExist); - if(!isExist || aType.toInt() != TTIMESTAMP ) + if (!isExist || aType.toInt() != TTIMESTAMP ) return false; QString aMeshName = Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); QString anEntity = Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); QString aFieldName = Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); QString aTimeStampId = Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); - // - int aPos = GetFreePositionOfDefaultScalarBar(theModule); - GetResourceMgr()->setValue("VISU","scalar_bar_position_num",aPos); - // + + // Create new TViewWindow instance, if it does not exist. + typedef typename TViewer::TViewWindow TViewWindow; + TViewWindow* aViewWindow = GetViewWindow(theModule); + + // Define free position for scalar bar. + int aPos = GetFreePositionOfDefaultScalarBar(theModule, aViewWindow); + GetResourceMgr()->setValue("VISU", "scalar_bar_position_num", aPos); + QApplication::setOverrideCursor(Qt::waitCursor); - + TPrs3d_i* aPrs3d = CreatePrs3d(theModule, theTimeStamp, @@ -161,16 +173,16 @@ namespace VISU (Entity)anEntity.toInt(), aFieldName.latin1(), aTimeStampId.toInt()); - + QApplication::restoreOverrideCursor(); - if(aPrs3d){ + if (aPrs3d) { SUIT_ResourceMgr* aResourceMgr = GetResourceMgr(); int aValue = aResourceMgr->integerValue("VISU","BuildDefaultPrs3d",0); - if(!aValue){ - if(TDlg* aDlg = new TDlg(theModule)){ // dialog box in creation mode + if (!aValue) { + if (TDlg* aDlg = new TDlg(theModule)) { // dialog box in creation mode aDlg->initFromPrsObject(aPrs3d); - if(runAndWait(aDlg,IsDlgModal) && (aDlg->storeToPrsObject(aPrs3d))) { + if (runAndWait(aDlg,IsDlgModal) && (aDlg->storeToPrsObject(aPrs3d))) { // Optionally, create table and curves for cut lines QApplication::setOverrideCursor(Qt::waitCursor); CreateCurves( theModule, @@ -187,57 +199,60 @@ namespace VISU } } } - PublishInView(theModule,aPrs3d,true,theIsCreateView); - AddScalarBarPosition(theModule,aPrs3d,aPos); + // Display created presentation. + if (aViewWindow) { + PublishInView(theModule, aPrs3d, aViewWindow, /*highlight = */true); + aViewWindow->onFitAll(); + + AddScalarBarPosition(theModule, aViewWindow, aPrs3d, aPos); + } return true; } return false; } - + //--------------------------------------------------------------- template inline void - CreatePrs3d(VisuGUI* theModule, - const bool theIsCreateView = true) + CreatePrs3d(VisuGUI* theModule) { if (CheckLock(GetCStudy(GetAppStudy(theModule)),GetDesktop(theModule))) return; - + _PTR(SObject) aTimeStampSObj; Handle(SALOME_InteractiveObject) anIO; - if(!CheckTimeStamp(theModule,aTimeStampSObj,&anIO)) + if (!CheckTimeStamp(theModule,aTimeStampSObj,&anIO)) return; - - if(!CreatePrs3d(theModule,aTimeStampSObj,anIO,theIsCreateView)) + + // Create new TViewWindow instance, if it does not exist. + typedef typename TViewer::TViewWindow TViewWindow; + if (!GetViewWindow(theModule)) return; - + + if (!CreatePrs3d(theModule,aTimeStampSObj,anIO)) + return; + theModule->application()->putInfo(QObject::tr("INF_DONE")); - - typedef typename TViewer::TViewWindow TView; - if(TView* aView = GetViewWindow(theModule,theIsCreateView)) - aView->onFitAll(); } template inline void - CreatePrs3d(VisuGUI* theModule, - const bool theIsCreateView = true) + CreatePrs3d(VisuGUI* theModule) { - if(SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager()){ + if (SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager()) { QString aType = aViewManager->getType(); - if(aType == SVTK_Viewer::Type()) - CreatePrs3d(theModule,theIsCreateView); - else if(aType == VVTK_Viewer::Type()) - CreatePrs3d(theModule,theIsCreateView); + if (aType == VVTK_Viewer::Type()) + CreatePrs3d(theModule); + else + CreatePrs3d(theModule); } } - } #endif diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx index a00194ae..54c96b88 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -30,12 +30,10 @@ #include "VisuGUI.h" #include "VisuGUI_Tools.h" - -#include "SVTK_FontWidget.h" - -#include "SVTK_ViewWindow.h" +#include "VisuGUI_ViewTools.h" #include "SVTK_ViewWindow.h" +#include "SVTK_FontWidget.h" #include "VISUConfig.hh" #include "VISU_Convertor.hxx" @@ -634,7 +632,7 @@ void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ScalarMap_i* thePrs) { void VisuGUI_ScalarBarPane::updatePreview() { if (myPreviewCheck->isChecked()) { - if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) { + if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) { deleteScalarBar(); createScalarBar(); vf->Repaint(); @@ -646,11 +644,11 @@ void VisuGUI_ScalarBarPane::updatePreview() */ void VisuGUI_ScalarBarPane::createScalarBar() { - if (VISU::GetViewWindow() == NULL) return; + if (VISU::GetActiveViewWindow() == NULL) return; if (myPreviewActor != 0) return; if (myScalarMap == NULL) return; - if(!check()) return; + if (!check()) return; if ( myBusy ) return; @@ -737,7 +735,7 @@ void VisuGUI_ScalarBarPane::createScalarBar() aScalarBarActor->Modified(); - VISU::GetViewWindow()->AddActor(myPreviewActor); + VISU::GetActiveViewWindow()->AddActor(myPreviewActor); myBusy = false; } @@ -748,7 +746,7 @@ void VisuGUI_ScalarBarPane::deleteScalarBar() if ( myBusy ) return; if (myPreviewActor == 0) return; - if (SVTK_ViewWindow* vf = VISU::GetViewWindow()){ + if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()){ vf->RemoveActor(myPreviewActor); myPreviewActor->GetScalarBar()->VisibilityOff(); } @@ -1045,7 +1043,7 @@ void VisuGUI_ScalarBarPane::onTextPref() void VisuGUI_ScalarBarPane::onPreviewCheck (bool thePreview) { - if (SVTK_ViewWindow* vf = VISU::GetViewWindow()) { + if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) { if (thePreview) { createScalarBar(); } else { diff --git a/src/VISUGUI/VisuGUI_Selection.cxx b/src/VISUGUI/VisuGUI_Selection.cxx index 5bcf465f..371d50a5 100644 --- a/src/VISUGUI/VisuGUI_Selection.cxx +++ b/src/VISUGUI/VisuGUI_Selection.cxx @@ -30,6 +30,7 @@ #include "VisuGUI.h" #include "VisuGUI_Tools.h" +#include "VisuGUI_ViewTools.h" #include "VISU_Actor.h" #include "VISU_PrsObject_i.hh" @@ -49,7 +50,6 @@ #include "SALOME_ListIteratorOfListIO.hxx" #include "SVTK_ViewWindow.h" -#include "SVTK_ViewModel.h" #include "SVTK_Selector.h" #include "utilities.h" @@ -263,7 +263,7 @@ VisuGUI_SelectionDlg::VisuGUI_SelectionDlg (const SalomeApp_Module* theModule): // Activate Points pane myWidgetStack->raiseWidget(myPointsPane); - if(SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myModule)) + if (SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myModule)) aViewWindow->SetSelectionMode(NodeSelection); onSelectionEvent(); @@ -276,7 +276,7 @@ VisuGUI_SelectionDlg::~VisuGUI_SelectionDlg() void VisuGUI_SelectionDlg::onSelectionChange (int theId) { - SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myModule); + SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myModule); if (!aViewWindow) return; switch (theId) { @@ -300,11 +300,10 @@ void VisuGUI_SelectionDlg::onSelectionChange (int theId) void VisuGUI_SelectionDlg::closeEvent (QCloseEvent* theEvent) { - if( mySelectionDlg ) - { + if (mySelectionDlg) { mySelectionDlg = NULL; disconnect(mySelectionMgr,0,0,0); - if(SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myModule)){ + if (SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myModule)) { switch(aViewWindow->SelectionMode()){ case NodeSelection: case CellSelection: @@ -337,10 +336,10 @@ template QString getVector(TData* theData, int theId){ #define ABS(a) (a>=0)?a:-a void VisuGUI_SelectionDlg::onSelectionEvent() { - SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myModule); + SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(myModule); if (!aViewWindow) return; - switch(aViewWindow->SelectionMode()){ + switch (aViewWindow->SelectionMode()) { case NodeSelection: case CellSelection: case ActorSelection: @@ -538,7 +537,7 @@ bool onIdEdit (const QString& theText, QLabel* theFieldName) { SalomeApp_Application* anApp = theModule->getApp(); - SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(theModule); + SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow(theModule); if (!aViewWindow) return false; SVTK_Selector* aSelector = aViewWindow->GetSelector(); diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index 213b1ca3..acec9415 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -12,6 +12,7 @@ #include "VisuGUI.h" #include "VisuGUI_Tools.h" +#include "VisuGUI_ViewTools.h" #include "VisuGUI_DeformedShapeDlg.h" #include "VisuGUI_CutPlanesDlg.h" #include "VisuGUI_CutLinesDlg.h" @@ -68,8 +69,10 @@ #define MAXVAL 1e10 ArrangeDlg::ArrangeDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator) - : QDialog(theParent, "ArrangeDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), - myAnimator(theAnimator), myViewWindow(theAnimator->getViewer()) + : QDialog(theParent, "ArrangeDlg", true, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), + myAnimator(theAnimator), + myViewWindow(theAnimator->getViewer()) { myCurrent = 0; init(); @@ -970,7 +973,7 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (VisuGUI* theModule, _PTR(Stu myAnimator = new VISU_TimeAnimation (theStudy); myAnimator->setSpeed(1); - myAnimator->setViewer(VISU::GetViewWindow(theModule)); + myAnimator->setViewer(VISU::GetActiveViewWindow(theModule)); connect(myAnimator, SIGNAL(frameChanged(long, double)), this, SLOT(onExecution(long, double))); connect(myAnimator, SIGNAL(stopped()), this, SLOT(onStop())); diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 978a4c24..90f7dc2c 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -28,6 +28,9 @@ #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" @@ -42,15 +45,15 @@ #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" @@ -61,8 +64,6 @@ #include "SUIT_Session.h" #include "SUIT_MessageBox.h" -#include "VisuGUI.h" - #include #include @@ -421,49 +422,6 @@ namespace VISU 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::GetServant(aBase).in())) - PlotCurve(theModule, aCurve, VISU::eErase ); - break; - } - case VISU::TCONTAINER: - { - if (VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(aBase).in())) - PlotContainer(theModule, aContainer, VISU::eErase ); - break; - } - case VISU::TTABLE: - { - if (VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(aBase).in())) - PlotTable(theModule, aTable, VISU::eErase ); - break; - } - default: - { - if (VISU::Prs3d_i* aPrsObject = dynamic_cast(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, @@ -472,16 +430,13 @@ namespace VISU _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)) { @@ -506,19 +461,10 @@ namespace VISU if (CheckLock(GetCStudy(GetAppStudy(theModule)),GetDesktop(theModule))) return; - RemoveScalarBarPosition(theModule,thePrs); - thePrs->RemoveFromStudy(); - } + SVTK_ViewWindow* vw = GetActiveViewWindow(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 @@ -527,8 +473,8 @@ namespace VISU ChangeRepresentation (const SalomeApp_Module* theModule, VISU::PresentationType theType) { - SVTK_ViewWindow* vw = GetViewWindow( theModule, false ); - if( !vw ) + SVTK_ViewWindow* vw = GetActiveViewWindow(theModule); + if (!vw) return; Handle(SALOME_InteractiveObject) anIO; @@ -563,17 +509,15 @@ namespace VISU } } } - + void SetShading ( const SalomeApp_Module* theModule, bool theOn ) { - SUIT_ViewWindow* aView = GetActiveView(theModule, SVTK_Viewer::Type()); - if (!aView) return; - SVTK_ViewWindow* vw = dynamic_cast( aView ); - if( !vw ) + SVTK_ViewWindow* vw = GetActiveViewWindow(theModule); + if (!vw) return; - + Handle(SALOME_InteractiveObject) anIO; CORBA::Object_var anObject = GetSelectedObj(theModule, &anIO); if (CORBA::is_nil(anObject)) return; @@ -654,167 +598,30 @@ namespace VISU return dynamic_cast(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 anIter(aViewManagerList); - while(SUIT_ViewManager* aViewManager = anIter.current()){ - QPtrVector 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(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(anApp->desktop()->activeWindow()); - if( wnd ) - return wnd; - else - { - SUIT_ViewManager* aViewManager = anApp->getViewManager( SVTK_Viewer::Type(), theCreate ); - return aViewManager ? dynamic_cast( 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(anApp->desktop()->activeWindow()); - if( wnd ) - return wnd; - else - { - if(SUIT_ViewManager* aViewManager = anApp->getViewManager( SVTK_Viewer::Type(), theCreate )) - return dynamic_cast( aViewManager->getActiveView() ); - } - } - return NULL; - }*/ - - - SVTK_ViewWindow* - GetViewWindow() - { - SalomeApp_Application* anApp = dynamic_cast - (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(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 @@ -1196,7 +1003,8 @@ namespace VISU // 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)) @@ -1243,7 +1051,7 @@ namespace VISU timer.Show(); #endif - QApplication::restoreOverrideCursor(); + //QApplication::restoreOverrideCursor(); VISU::Mesh_i* pPresent = NULL; if (!CORBA::is_nil(aMesh)) pPresent = dynamic_cast(VISU::GetServant(aMesh).in()); @@ -1255,23 +1063,19 @@ namespace VISU 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 @@ -1280,6 +1084,10 @@ namespace VISU QObject::tr("BUT_OK")); } } + + theModule->application()->putInfo(QObject::tr("INF_DONE")); + // Make "Save" button active + theModule->getApp()->updateActions(); } // ======================================================================================== @@ -1411,58 +1219,45 @@ namespace VISU } return aList; } - - int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule){ + + int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow) + { int minIndx = 1; std::set 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::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::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::GetServant(aBase).in())){ - RemoveScalarBarPosition(theModule,aPrsObject); - } - } - } } diff --git a/src/VISUGUI/VisuGUI_Tools.h b/src/VISUGUI/VisuGUI_Tools.h index d514b4b3..af166ad6 100644 --- a/src/VISUGUI/VisuGUI_Tools.h +++ b/src/VISUGUI/VisuGUI_Tools.h @@ -98,18 +98,12 @@ namespace VISU { bool IsRemovableSelected(const SalomeApp_Module* theModule); - // Display/Erase - void ErasePrs(const SalomeApp_Module* theModule, - CORBA::Object_ptr theObject, - bool theUpdate = true); void DeleteSObject(VisuGUI* theModule, _PTR(Study) theStudy, _PTR(SObject) theSObject); void DeletePrs3d(VisuGUI* theModule, VISU::Prs3d_i* thePrs, const Handle(SALOME_InteractiveObject)& theIO); - void ErasePrs3d(const SalomeApp_Module* theModule, - VISU::Prs3d_i* thePrs); // Presentation management void ChangeRepresentation (const SalomeApp_Module* theModule, @@ -126,21 +120,11 @@ namespace VISU { VISU::Result_var& theResult); bool IsSObjectTable(_PTR(SObject) theSObject); - // Views - SUIT_ViewWindow* GetActiveView(const SalomeApp_Module* theModule, - QString theType = QString::null); - - // VTK View - TViewWindows GetViews(const SalomeApp_Module* theModule); - SVTK_ViewWindow* GetViewWindow(const SalomeApp_Module* theModule, - const bool theCreate = false ); - SVTK_ViewWindow* GetViewWindow(); - - VISU_Actor* PublishInView(const SalomeApp_Module* theModule, - VISU::Prs3d_i* thePrs); - VISU_Actor* UpdateViewer(const SalomeApp_Module* theModule, - VISU::Prs3d_i* thePrs, - bool theDispOnly = false); + /*! Display mesh presentation in given VTK view window + */ + VISU_Actor* PublishMeshInView(const SalomeApp_Module* theModule, + VISU::Prs3d_i* thePrs, + SVTK_ViewWindow* theViewWindow); /*! * \brief Repaint all SVTK view windows, where the given object is displayed. @@ -183,26 +167,32 @@ namespace VISU { void CreatePlot( SalomeApp_Module* theModule, _PTR(SObject) theSobj ); + /*! Display/Erase/Update a curve presentation. + * Parameter \a frame may be NULL, in this case there is only update without display/erase + */ void UpdateCurve( VISU::Curve_i*, Plot2d_ViewFrame* frame, SPlot2d_Curve*, int theDisplaying ); - //parameter frame may be 0, in this case there is only update without display/erase - // Others + /*! Create mesh presentation and display it in \a theViewWindow. + * If \a theViewWindow is NULL, no displaying will be done. + */ void CreateMesh (const SalomeApp_Module* theModule, - const Handle(SALOME_InteractiveObject)& theIO); + const Handle(SALOME_InteractiveObject)& theIO, + SVTK_ViewWindow* theViewWindow = NULL); + // Others std::vector GetPrs3dList (const SalomeApp_Module* theModule, const Handle(SALOME_InteractiveObject)& theIO); std::vector GetPrs3dList (const SalomeApp_Module* theModule, _PTR(SObject) theObject); - int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule); - void AddScalarBarPosition(VisuGUI* theModule,VISU::Prs3d_i* thePrs3d, int pos); - void RemoveScalarBarPosition(VisuGUI* theModule,VISU::Prs3d_i* thePrs3d); - void RemoveScalarBarPosition(VisuGUI* theModule,SVTK_ViewWindow* vw,VISU::Prs3d_i* thePrs3d); - void RemoveScalarBarPosition(VisuGUI* theModule,CORBA::Object_ptr theObject); + int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow); + void AddScalarBarPosition(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow, + VISU::Prs3d_i* thePrs3d, int pos); + void RemoveScalarBarPosition(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow, + VISU::Prs3d_i* thePrs3d); } #endif diff --git a/src/VISUGUI/VisuGUI_TransparencyDlg.cxx b/src/VISUGUI/VisuGUI_TransparencyDlg.cxx index bf893f50..b9556c4c 100644 --- a/src/VISUGUI/VisuGUI_TransparencyDlg.cxx +++ b/src/VISUGUI/VisuGUI_TransparencyDlg.cxx @@ -66,7 +66,7 @@ VisuGUI_TransparencyDlg::VisuGUI_TransparencyDlg( VisuGUI* theModule, : QDialog( VISU::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ), mySelectionMgr( VISU::GetSelectionMgr( theModule ) ), - myViewWindow( VISU::GetViewWindow( theModule ) ) + myViewWindow( VISU::GetActiveViewWindow(theModule) ) { if (!name) setName("VisuGUI_TransparencyDlg"); diff --git a/src/VISUGUI/VisuGUI_ViewTools.cxx b/src/VISUGUI/VisuGUI_ViewTools.cxx index 868ab606..601e2a17 100644 --- a/src/VISUGUI/VisuGUI_ViewTools.cxx +++ b/src/VISUGUI/VisuGUI_ViewTools.cxx @@ -37,37 +37,35 @@ namespace VISU { void ErasePrs(VisuGUI* theModule, - VISU::Base_ptr theBase, - bool thIsUpdate) + CORBA::Object_ptr theObject, + bool theDoRepaintVW) { - VISU::VISUType aType = theBase->GetType(); + if (CORBA::is_nil(theObject)) return; + 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::GetServant(theBase).in())) + if (VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(aBase).in())) PlotCurve(theModule, aCurve, VISU::eErase ); break; } case VISU::TCONTAINER: { - if (VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(theBase).in())) + if (VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(aBase).in())) PlotContainer(theModule, aContainer, VISU::eErase ); break; } case VISU::TTABLE: { - if (VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(theBase).in())) + if (VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(aBase).in())) PlotTable(theModule, aTable, VISU::eErase ); break; } default: { - if(VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(theBase).in())){ - if(aType == VISU::TGAUSSPOINTS) - ErasePrs3d(theModule,aPrsObject,thIsUpdate); - else if(SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager()){ - QString aType = aViewManager->getType(); - if(aType == SVTK_Viewer::Type()) - ErasePrs3d(theModule,aPrsObject,thIsUpdate); - else if(aType == VVTK_Viewer::Type()) - ErasePrs3d(theModule,aPrsObject,thIsUpdate); - } + if (VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(aBase).in())) { + SVTK_ViewWindow* vw = GetActiveViewWindow(theModule); + RemoveScalarBarPosition(theModule, vw, aPrsObject); + ErasePrs3d(theModule, aPrsObject, theDoRepaintVW); } }} // switch (aType) } diff --git a/src/VISUGUI/VisuGUI_ViewTools.h b/src/VISUGUI/VisuGUI_ViewTools.h index f10bf63e..bb28861a 100644 --- a/src/VISUGUI/VisuGUI_ViewTools.h +++ b/src/VISUGUI/VisuGUI_ViewTools.h @@ -30,34 +30,36 @@ #include "VisuGUI.h" -#include "SUIT_MessageBox.h" -#include "SUIT_ViewManager.h" -#include "SUIT_ViewWindow.h" +#include "VisuGUI_Tools.h" + +#include "VISU_Prs3d_i.hh" +#include "VISU_Table_i.hh" +#include "VISU_ViewManager_i.hh" + +#include "VISU_Actor.h" #include "SalomeApp_Module.h" #include "SalomeApp_Application.h" -#include "VISU_Prs3d_i.hh" - #include "VVTK_ViewModel.h" #include "VVTK_ViewWindow.h" +#include "SVTK_Functor.h" #include "SVTK_ViewModel.h" #include "SVTK_ViewWindow.h" -#include "VisuGUI_Tools.h" +#include "SPlot2d_ViewModel.h" + #include "VTKViewer_Algorithm.h" -#include "SVTK_Functor.h" -#include "VISU_Table_i.hh" -#include "VISU_ViewManager_i.hh" +#include "SUIT_Session.h" +#include "SUIT_MessageBox.h" +#include "SUIT_ViewManager.h" +#include "SUIT_ViewWindow.h" + #include "SALOME_ListIO.hxx" #include "SALOME_ListIteratorOfListIO.hxx" -#include "SPlot2d_ViewModel.h" - -#include "VISU_Actor.h" - #include #include @@ -65,17 +67,26 @@ class VVTK_Viewer; namespace VISU { - //--------------------------------------------------------------- + /*! Return active view window, if it instantiates TViewer::TViewWindow class, + * overwise find or create corresponding view window, make it active and return it. + * \note Active VVTK_ViewWindow can be returned by request GetViewWindow(), + * because VVTK_ViewWindow inherits SVTK_ViewWindow. + */ template inline typename TViewer::TViewWindow* - GetViewWindow(VisuGUI* theModule, - const bool theIsViewCreate = false) + GetViewWindow(VisuGUI* theModule) { - typedef typename TViewer::TViewWindow TView; - if(SUIT_ViewManager* aViewManager = theModule->getViewManager(TViewer::Type(),theIsViewCreate)){ - if(SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()){ - if(TView* aView = dynamic_cast(aViewWindow)){ + typedef typename TViewer::TViewWindow TViewWindow; + if (SalomeApp_Application* anApp = theModule->getApp()) { + if (TViewWindow* aView = dynamic_cast(anApp->desktop()->activeWindow())) + return aView; + } + SUIT_ViewManager* aViewManager = + theModule->getViewManager(TViewer::Type(), /*create = */true); + if (aViewManager) { + if (SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()) { + if (TViewWindow* aView = dynamic_cast(aViewWindow)) { aViewWindow->raise(); aViewWindow->setFocus(); return aView; @@ -85,30 +96,54 @@ namespace VISU return NULL; } + /*! Return active view window, if it instantiates TViewWindow class, overwise return NULL. + * \note Active VVTK_ViewWindow can be returned by request GetActiveViewWindow(), + * because VVTK_ViewWindow inherits SVTK_ViewWindow. + */ + template + inline + TViewWindow* + GetActiveViewWindow(const SalomeApp_Module* theModule = NULL) + { + SalomeApp_Application* anApp = NULL; + if (theModule) + anApp = theModule->getApp(); + else + anApp = dynamic_cast + (SUIT_Session::session()->activeApplication()); + + if (anApp) + if (SUIT_ViewManager* aViewManager = anApp->activeViewManager()) + if (SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()) + return dynamic_cast(aViewWindow); + + return NULL; + } + //--------------------------------------------------------------- - template inline VISU_Actor* PublishInView(VisuGUI* theModule, Prs3d_i* thePrs, - const bool theIsHighlight = false, - const bool theIsCreateView = false) + SVTK_ViewWindow* theViewWindow, + const bool theIsHighlight = false) { - typedef typename TViewer::TViewWindow TView; - if(TView* aView = GetViewWindow(theModule,theIsCreateView)){ + if (theViewWindow) { QApplication::setOverrideCursor( Qt::waitCursor ); try { - if(VISU_Actor* anActor = thePrs->CreateActor()){ - aView->AddActor(anActor); - if(theIsHighlight) - aView->highlight(anActor->getIO(),true); - aView->getRenderer()->ResetCameraClippingRange(); - aView->Repaint(); + if (VISU_Actor* anActor = thePrs->CreateActor()) { + theViewWindow->AddActor(anActor); + if (theIsHighlight) + theViewWindow->highlight(anActor->getIO(),true); + theViewWindow->getRenderer()->ResetCameraClippingRange(); + theViewWindow->Repaint(); QApplication::restoreOverrideCursor(); return anActor; } } catch(std::exception& exc) { + thePrs->RemoveActors(); + QApplication::restoreOverrideCursor(); INFOS(exc.what()); SUIT_MessageBox::warn1 @@ -122,56 +157,53 @@ namespace VISU //--------------------------------------------------------------- - template inline VISU_Actor* UpdateViewer(VisuGUI* theModule, VISU::Prs3d_i* thePrs, bool theDispOnly = false, - const bool theIsHighlight = false, - const bool theIsViewCreate = false) + const bool theIsHighlight = false) { - typedef typename TViewer::TViewWindow TView; - if(TView* aView = GetViewWindow(theModule,theIsViewCreate)){ - vtkRenderer *aRen = aView->getRenderer(); + if (SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(theModule)) { + vtkRenderer *aRen = aViewWindow->getRenderer(); vtkActorCollection *anActColl = aRen->GetActors(); anActColl->InitTraversal(); VISU_Actor* aResActor = NULL; - while(vtkActor *anAct = anActColl->GetNextActor()){ - if(VISU_Actor* anActor = dynamic_cast(anAct)){ - if(VISU::Prs3d_i* aPrs3d = anActor->GetPrs3d()){ - if(thePrs == aPrs3d){ + bool isOk = true; + while (vtkActor *anAct = anActColl->GetNextActor()) { + if (VISU_Actor* anActor = dynamic_cast(anAct)) { + if (VISU::Prs3d_i* aPrs3d = anActor->GetPrs3d()) { + if (thePrs == aPrs3d) { try { + aResActor = anActor; thePrs->UpdateActors(); + aResActor->VisibilityOn(); } catch (std::runtime_error& exc) { + thePrs->RemoveActors(); + isOk = false; + INFOS(exc.what()); - QApplication::restoreOverrideCursor(); SUIT_MessageBox::warn1 (GetDesktop(theModule), QObject::tr("WRN_VISU"), QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(exc.what()), QObject::tr("BUT_OK")); - - thePrs->RemoveActors(); - return NULL; } - aResActor = anActor; - aResActor->VisibilityOn(); - }else if(theDispOnly){ + } else if (theDispOnly) { anActor->VisibilityOff(); } - }else if(theDispOnly && anActor->GetVisibility()){ + } else if (theDispOnly && anActor->GetVisibility()) { anActor->VisibilityOff(); } } } - if(aResActor){ - if(theIsHighlight) - aView->highlight(aResActor->getIO(),true); - aView->getRenderer()->ResetCameraClippingRange(); - aView->Repaint(); + if (aResActor) { + if (theIsHighlight && isOk) + aViewWindow->highlight(aResActor->getIO(), true); + aViewWindow->getRenderer()->ResetCameraClippingRange(); + aViewWindow->Repaint(); return aResActor; } - return PublishInView(theModule,thePrs,theIsHighlight,theIsViewCreate); + return PublishInView(theModule, thePrs, aViewWindow, theIsHighlight); } return NULL; } @@ -184,14 +216,14 @@ namespace VISU OnEraseAll(VisuGUI* theModule) { typedef typename TViewer::TViewWindow TViewWindow; - if(TViewWindow* aViewWindow = GetViewWindow(theModule)){ + if (TViewWindow* aViewWindow = GetActiveViewWindow(theModule)) { aViewWindow->unHighlightAll(); - if(vtkRenderer *aRen = aViewWindow->getRenderer()){ + if (vtkRenderer *aRen = aViewWindow->getRenderer()) { vtkActorCollection *aCollection = aRen->GetActors(); aCollection->InitTraversal(); - while(vtkActor *anAct = aCollection->GetNextActor()){ - if(anAct->GetVisibility() > 0) - if(SALOME_Actor* anActor = dynamic_cast(anAct)){ + while (vtkActor *anAct = aCollection->GetNextActor()) { + if (anAct->GetVisibility() > 0) + if (SALOME_Actor* anActor = dynamic_cast(anAct)) { anActor->VisibilityOff(); } } @@ -199,57 +231,37 @@ namespace VISU } } } - + template<> inline void OnEraseAll(VisuGUI* theModule) { - if(SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(theModule,false)) + if (SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(theModule, false)) aPlot2d->EraseAll(); } //--------------------------------------------------------------- - template - inline - VISU_Actor* - FindActor(TVieweWindow* theViewWindow, - const char* theEntry) - { - using namespace SVTK; - if(vtkRenderer* aRenderer = theViewWindow->getRenderer()){ - if(vtkActorCollection* aCollection = aRenderer->GetActors()){ - if(VISU_Actor* anActor = Find(aCollection,TIsSameEntry(theEntry))){ - return anActor; - } - } - } - return NULL; - } - - template inline void ErasePrs3d(VisuGUI* theModule, VISU::Prs3d_i* thePrs, - const bool thIsUpdate = true) + const bool theDoRepaintVW = true) { - typedef typename TViewer::TViewWindow TViewWindow; - if(TViewWindow* aViewWindow = GetViewWindow(theModule)){ - if(VISU_Actor* anActor = FindActor(aViewWindow,thePrs)){ + if (SVTK_ViewWindow* aViewWindow = GetActiveViewWindow(theModule)) { + if (VISU_Actor* anActor = FindActor(aViewWindow, thePrs)) { anActor->VisibilityOff(); - if(thIsUpdate) + if (theDoRepaintVW) aViewWindow->Repaint(); } } } - void ErasePrs(VisuGUI* theModule, - VISU::Base_ptr theBase, - bool thIsUpdate); + CORBA::Object_ptr theObject, + bool theDoRepaintVW); } #endif diff --git a/src/VISU_I/VISU_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index 64bb0bb9..1bdd88b8 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -265,8 +265,8 @@ VISU::Prs3d_i }catch(std::bad_alloc& ex){ throw std::runtime_error("CreateActor >> No enough memory"); throw ex; - } catch(std::exception& ex){ - throw ex; + } catch(std::exception&){ + throw; }catch(...) { throw std::runtime_error("CreateActor >> unexpected exception was caught!!!"); } diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index c1db8093..cf92735e 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -64,7 +64,7 @@ VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy, if (!CORBA::is_nil(theView3D)) { VISU::View3D_i* pView = dynamic_cast(GetServant(theView3D).in()); SUIT_ViewWindow* aVW = pView->GetViewWindow(); - myView = VISU::GetViewWindow(aVW); + myView = dynamic_cast(aVW); connect( myView, SIGNAL( destroyed() ), this, SLOT( onViewDeleted() ) ); } diff --git a/src/VISU_I/VISU_ViewManager_i.cc b/src/VISU_I/VISU_ViewManager_i.cc index c86ac5d8..7168bb99 100644 --- a/src/VISU_I/VISU_ViewManager_i.cc +++ b/src/VISU_I/VISU_ViewManager_i.cc @@ -257,31 +257,29 @@ namespace VISU { //=========================================================================== // VISU namespace functions //=========================================================================== - SVTK_ViewWindow* GetViewWindow (SUIT_ViewWindow* theStudyFrame) + vtkRenderer* GetRenderer (SUIT_ViewWindow* theViewWindow) { - return dynamic_cast(theStudyFrame); - } - - vtkRenderer* GetRenderer (SUIT_ViewWindow* theStudyFrame) - { - return GetViewWindow(theStudyFrame)->getRenderer(); + if (SVTK_ViewWindow* vw = dynamic_cast(theViewWindow)) + return vw->getRenderer(); + return NULL; } - vtkCamera* GetCamera (SUIT_ViewWindow* theStudyFrame) + vtkCamera* GetCamera (SUIT_ViewWindow* theViewWindow) { - return GetRenderer(theStudyFrame)->GetActiveCamera(); + return GetRenderer(theViewWindow)->GetActiveCamera(); } void RepaintView (SUIT_ViewWindow* theViewWindow) { - SVTK_ViewWindow* vf = GetViewWindow(theViewWindow); - vf->getRenderer()->ResetCameraClippingRange(); - vf->getRenderWindow()->Render(); + if (SVTK_ViewWindow* vf = dynamic_cast(theViewWindow)) { + vf->getRenderer()->ResetCameraClippingRange(); + vf->getRenderWindow()->Render(); + } } - VISU_Actor* UpdateViewer (SUIT_ViewWindow* theStudyFrame, int theDisplaing, Prs3d_i* thePrs) + VISU_Actor* UpdateViewer (SUIT_ViewWindow* theViewWindow, int theDisplaing, Prs3d_i* thePrs) { - SVTK_ViewWindow* vf = GetViewWindow(theStudyFrame); + SVTK_ViewWindow* vf = dynamic_cast(theViewWindow); if (!vf) return NULL; if(MYDEBUG) MESSAGE("UpdateViewer - theDisplaing = "<GetScale(aScaleFactor); + (dynamic_cast(theViewWindow))->GetScale(aScaleFactor); Storable::DataToStream(theStr,"myScaleFactor[0]",aScaleFactor[0]); Storable::DataToStream(theStr,"myScaleFactor[1]",aScaleFactor[1]); Storable::DataToStream(theStr,"myScaleFactor[2]",aScaleFactor[2]); @@ -1841,7 +1841,7 @@ namespace VISU { aColor[1] = int(255.0*theColor.G); aColor[2] = int(255.0*theColor.B); QColor aNewColor (aColor[0],aColor[1],aColor[2]); - VISU::GetViewWindow(theViewWindow)->setBackgroundColor(aNewColor); + (dynamic_cast(theViewWindow))->setBackgroundColor(aNewColor); } SALOMEDS::Color View3D_i::GetBackground (SUIT_ViewWindow* theViewWindow) @@ -1922,7 +1922,7 @@ namespace VISU { SUIT_ViewWindow* aVW = GetViewWindow(); if (aVW) { ProcessVoidEvent(new TVoidMemFunEvent - (VISU::GetViewWindow(aVW), &SVTK_ViewWindow::onFitAll)); + (dynamic_cast(aVW), &SVTK_ViewWindow::onFitAll)); Update(); } } @@ -1936,27 +1936,27 @@ namespace VISU { switch (theType) { case VISU::View3D::FRONT : ProcessVoidEvent(new TVoidMemFunEvent - (VISU::GetViewWindow(aVW), &SVTK_ViewWindow::onFrontView)); + (dynamic_cast(aVW), &SVTK_ViewWindow::onFrontView)); break; case VISU::View3D::BACK : ProcessVoidEvent(new TVoidMemFunEvent - (VISU::GetViewWindow(aVW), &SVTK_ViewWindow::onBackView)); + (dynamic_cast(aVW), &SVTK_ViewWindow::onBackView)); break; case VISU::View3D::LEFT : ProcessVoidEvent(new TVoidMemFunEvent - (VISU::GetViewWindow(aVW),&SVTK_ViewWindow::onLeftView)); + (dynamic_cast(aVW),&SVTK_ViewWindow::onLeftView)); break; case VISU::View3D::RIGHT : ProcessVoidEvent(new TVoidMemFunEvent - (VISU::GetViewWindow(aVW),&SVTK_ViewWindow::onRightView)); + (dynamic_cast(aVW),&SVTK_ViewWindow::onRightView)); break; case VISU::View3D::TOP : ProcessVoidEvent(new TVoidMemFunEvent - (VISU::GetViewWindow(aVW),&SVTK_ViewWindow::onTopView)); + (dynamic_cast(aVW),&SVTK_ViewWindow::onTopView)); break; case VISU::View3D::BOTTOM : ProcessVoidEvent(new TVoidMemFunEvent - (VISU::GetViewWindow(aVW),&SVTK_ViewWindow::onBottomView)); + (dynamic_cast(aVW),&SVTK_ViewWindow::onBottomView)); break; } Update(); @@ -2126,7 +2126,7 @@ namespace VISU { void View3D_i::ScaleView (SUIT_ViewWindow* theViewWindow, VISU::View3D::Axis theAxis, CORBA::Double theParam) { - SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(theViewWindow); + SVTK_ViewWindow* aViewWindow = dynamic_cast(theViewWindow); double aScaleFactor[3]; aViewWindow->GetScale(aScaleFactor); aScaleFactor[theAxis] = theParam; @@ -2136,7 +2136,7 @@ namespace VISU { void SetScaleView (SUIT_ViewWindow* theViewWindow, const CORBA::Double theScale[3]) { double aScale[3] = {theScale[0], theScale[1], theScale[2]}; - VISU::GetViewWindow(theViewWindow)->SetScale(aScale); + (dynamic_cast(theViewWindow))->SetScale(aScale); } void View3D_i::ScaleView(VISU::View3D::Axis theAxis, CORBA::Double theParam) @@ -2145,7 +2145,7 @@ namespace VISU { SUIT_ViewWindow* aVW = GetViewWindow(); if (aVW) { double aScale[3]; - VISU::GetViewWindow(aVW)->GetScale(aScale); + (dynamic_cast(aVW))->GetScale(aScale); aScale[theAxis] = theParam; ProcessVoidEvent(new TSet3DViewParamEvent(&SetScaleView,aVW,aScale)); } diff --git a/src/VVTK/VVTK_ViewModel.cxx b/src/VVTK/VVTK_ViewModel.cxx index e3778816..5fcc06f9 100644 --- a/src/VVTK/VVTK_ViewModel.cxx +++ b/src/VVTK/VVTK_ViewModel.cxx @@ -1,208 +1,27 @@ -#include -#include - #include "VVTK_ViewModel.h" -#include "VVTK_ViewWindow.h" - -#include "SVTK_View.h" -#include "SVTK_MainWindow.h" -#include "SVTK_RenderWindowInteractor.h" -#include "VTKViewer_ViewModel.h" +#include "VVTK_ViewWindow.h" -//========================================================== -VVTK_Viewer -::VVTK_Viewer() +VVTK_Viewer:: +VVTK_Viewer() { - myTrihedronSize = 105; } -VVTK_Viewer -::~VVTK_Viewer() -{} - - -//========================================================== -void -VVTK_Viewer -::setViewManager(SUIT_ViewManager* theViewManager) +VVTK_Viewer:: +~VVTK_Viewer() { - SUIT_ViewModel::setViewManager(theViewManager); - - if ( !theViewManager ) - return; - - connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), - this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); - - connect(theViewManager, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)), - this, SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*))); - - connect(theViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), - this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*))); } - //========================================================== -SUIT_ViewWindow* -VVTK_Viewer -::createView( SUIT_Desktop* theDesktop ) +SUIT_ViewWindow* +VVTK_Viewer:: +createView( SUIT_Desktop* theDesktop ) { - TViewWindow* aViewWindow = new TViewWindow(theDesktop); + TViewWindow* aViewWindow = new TViewWindow (theDesktop); aViewWindow->Initialize(this); - + aViewWindow->setBackgroundColor( backgroundColor() ); aViewWindow->SetTrihedronSize( trihedronSize() ); return aViewWindow; } - - -//========================================================== -void -VVTK_Viewer -::contextMenuPopup( QPopupMenu* thePopup ) -{ - thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) ); - thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_CHANGE_BACKGROUD" ), this, SLOT( onChangeBgColor() ) ); - - thePopup->insertSeparator(); - - if(TViewWindow* aView = dynamic_cast(myViewManager->getActiveView())){ - if ( !aView->getMainWindow()->getToolBar()->isVisible() ){ - thePopup->insertItem( VTKViewer_Viewer::tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) ); - } - } -} - - -//========================================================== -void -VVTK_Viewer -::Repaint() -{ - QPtrVector aViews = myViewManager->getViews(); - for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ - if(TViewWindow* aView = dynamic_cast(aViews.at(i))){ - aView->getMainWindow()->Repaint(); - } - } -} - - -//========================================================== -bool -VVTK_Viewer -::isVisible( const Handle(SALOME_InteractiveObject)& io ) -{ - QPtrVector aViews = myViewManager->getViews(); - for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) - if(SUIT_ViewWindow* aViewWindow = aViews.at(i)) - if(TViewWindow* aView = dynamic_cast(aViewWindow)) - if(!aView->getView()->isVisible( io )) - return false; - - return true; -} - - -//========================================================== -void -VVTK_Viewer -::onMousePress(SUIT_ViewWindow* vw, QMouseEvent* event) -{} - -void -VVTK_Viewer -::onMouseMove(SUIT_ViewWindow* vw, QMouseEvent* event) -{} - -void -VVTK_Viewer -::onMouseRelease(SUIT_ViewWindow* vw, QMouseEvent* event) -{} - - -//========================================================== -QColor -VVTK_Viewer -::backgroundColor() const -{ - return myBgColor; -} - -void -VVTK_Viewer -::setBackgroundColor( const QColor& theColor ) -{ - if ( !theColor.isValid() ) - return; - - QPtrVector aViews = myViewManager->getViews(); - for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ - if(SUIT_ViewWindow* aViewWindow = aViews.at(i)){ - if(TViewWindow* aView = dynamic_cast(aViewWindow)){ - aView->setBackgroundColor(theColor); - } - } - } - - myBgColor = theColor; -} - -//========================================================== -int -VVTK_Viewer -::trihedronSize() const -{ - return myTrihedronSize; -} - -void -VVTK_Viewer -::setTrihedronSize( const int theSize ) -{ - myTrihedronSize = theSize; - if(SUIT_ViewManager* aViewManager = getViewManager()){ - QPtrVector aViews = aViewManager->getViews(); - for ( int i = 0; i < aViews.count(); i++ ){ - if(TViewWindow* aView = dynamic_cast(aViews.at( i ))){ - aView->getMainWindow()->SetTrihedronSize( theSize ); - } - } - } -} - -//========================================================== -void -VVTK_Viewer -::onDumpView() -{ - if(SUIT_ViewWindow* aView = myViewManager->getActiveView()) - aView->onDumpView(); -} - -//========================================================== -void -VVTK_Viewer -::onChangeBgColor() -{ - if(SUIT_ViewWindow* aView = myViewManager->getActiveView()){ - QColor aColor = QColorDialog::getColor( backgroundColor(), aView); - setBackgroundColor(aColor); - } -} - -//========================================================== -void -VVTK_Viewer -::onShowToolbar() -{ - QPtrVector aViews = myViewManager->getViews(); - for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ - if(TViewWindow* aView = dynamic_cast(aViews.at(i))){ - aView->getMainWindow()->getToolBar()->show(); - } - } -} - diff --git a/src/VVTK/VVTK_ViewModel.h b/src/VVTK/VVTK_ViewModel.h index 0846edcd..5f343dc9 100644 --- a/src/VVTK/VVTK_ViewModel.h +++ b/src/VVTK/VVTK_ViewModel.h @@ -4,15 +4,12 @@ #include #include "VVTK.h" -#include "SVTK_ViewModelBase.h" - -#include "SALOME_Prs.h" -#include "SALOME_InteractiveObject.hxx" +#include "SVTK_ViewModel.h" class VVTK_ViewWindow; -//! Extends two interfaces #SVTK_ViewModelBase and #SALOME_View -class VVTK_EXPORT VVTK_Viewer : public SVTK_ViewModelBase, public SALOME_View +//! VVTK View Model +class VVTK_EXPORT VVTK_Viewer : public SVTK_Viewer { Q_OBJECT; @@ -23,48 +20,11 @@ public: VVTK_Viewer(); virtual ~VVTK_Viewer(); - //! Redefine SUIT_ViewModel::createView + //! See #SUIT_ViewModel::createView virtual SUIT_ViewWindow* createView(SUIT_Desktop*); - //! Redefine SUIT_ViewModel::setViewManager - virtual void setViewManager(SUIT_ViewManager* theViewManager); - //! Redefine SUIT_ViewModel::contextMenuPopup - virtual void contextMenuPopup( QPopupMenu* ); //! See SUIT_ViewModel::getType virtual QString getType() const { return Type(); } - - //! Redefine SALOME_View::Repaint - virtual void Repaint(); - - //! Redefine SALOME_View::isVisible - virtual bool isVisible( const Handle(SALOME_InteractiveObject)& ); - - //! Get background color of the viewer - QColor backgroundColor() const; - - //! Set background color to the viewer - void setBackgroundColor( const QColor& ); - - //! Get size of trihedron of the viewer (see SVTK_Renderer::SetTrihedronSize) - int trihedronSize() const; - - //! Set size of trihedron of the viewer (see SVTK_Renderer::SetTrihedronSize) - void setTrihedronSize( const int ); - -protected slots: - void onMousePress(SUIT_ViewWindow*, QMouseEvent*); - void onMouseMove(SUIT_ViewWindow*, QMouseEvent*); - void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*); - - void onDumpView(); - void onShowToolbar(); - void onChangeBgColor(); - -private: - QColor myBgColor; - int myTrihedronSize; - bool mySelectionEnabled; - bool myMultiSelectionEnabled; }; #endif