From: apo Date: Mon, 10 Oct 2005 14:48:55 +0000 (+0000) Subject: Merge with V3_1_0a X-Git-Tag: BR-D5-38-2003_D2005-12-10~16 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=794143c49ef9da963d0de0eda543316efbc7d75c;p=modules%2Fvisu.git Merge with V3_1_0a --- diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 3b629381..275e4523 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -561,14 +561,14 @@ void VisuGUI:: OnCreateCutPlanes() { - CreatePrs3d(this); + CreatePrs3d(this); } void VisuGUI:: OnCreateCutLines() { - CreatePrs3d(this); + CreatePrs3d(this); } void @@ -582,7 +582,7 @@ void VisuGUI:: OnCreatePlot3D() { - CreatePrs3d(this); + CreatePrs3d(this); } void @@ -696,7 +696,7 @@ OnEditScalarMap() { Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); + EditPrs3d(this, aPrs3d); if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ aViewWindow->highlight(anIO, 1); } @@ -710,7 +710,7 @@ OnEditDeformedShape() { Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); + EditPrs3d(this, aPrs3d); if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ aViewWindow->highlight(anIO, 1); } @@ -724,7 +724,7 @@ OnEditCutPlanes() { Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); + EditPrs3d(this, aPrs3d); if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ aViewWindow->highlight(anIO, 1); } @@ -738,7 +738,7 @@ OnEditCutLines() { Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); + EditPrs3d(this, aPrs3d); if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ aViewWindow->highlight(anIO, 1); } @@ -752,7 +752,7 @@ OnEditIsoSurfaces() { Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); + EditPrs3d(this, aPrs3d); if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ aViewWindow->highlight(anIO, 1); } @@ -766,7 +766,7 @@ OnEditVectors() { Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); + EditPrs3d(this, aPrs3d); if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ aViewWindow->highlight(anIO, 1); } @@ -780,7 +780,7 @@ OnEditStreamLines() { Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); + EditPrs3d(this, aPrs3d); if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ aViewWindow->highlight(anIO, 1); } @@ -794,7 +794,7 @@ OnEditPlot3D() { Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); + EditPrs3d(this, aPrs3d); if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ aViewWindow->highlight(anIO, 1); } @@ -2892,3 +2892,7 @@ VisuGUI return getApp()->getViewManager(theType,theIsCreate); } +SalomeApp_Displayer* VisuGUI::displayer() +{ + return 0; +} diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index 5b76de10..d0b5c1a5 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -42,6 +42,7 @@ public: VisuGUI(); virtual ~VisuGUI(); + virtual SalomeApp_Displayer* displayer(); virtual void initialize( CAM_Application* ); virtual void windows( QMap& ) const; virtual void viewManagers( QStringList& ) const; @@ -147,6 +148,9 @@ private: void createMenus(); void createToolBars(); void createPopupMenus(); + +private: + SalomeApp_Displayer* myDisplayer; }; #endif diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index 6dc6997d..73ed5300 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -737,7 +737,7 @@ VisuGUI_Module { Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); + EditPrs3d(this, aPrs3d); if(SVTK_ViewWindow* aViewWindow = GetViewWindow(this,true)){ aViewWindow->highlight(anIO,1); } diff --git a/src/VISUGUI/VisuGUI_Prs3dTools.h b/src/VISUGUI/VisuGUI_Prs3dTools.h index b13975c8..4287a9ab 100644 --- a/src/VISUGUI/VisuGUI_Prs3dTools.h +++ b/src/VISUGUI/VisuGUI_Prs3dTools.h @@ -29,8 +29,9 @@ #ifndef VisuGUI_Prs3dTools_HeaderFile #define VisuGUI_Prs3dTools_HeaderFile -#include "VisuGUI_ViewTools.h" #include "VISU_Gen_i.hh" +#include "VisuGUI_ViewTools.h" +#include "VisuGUI_DialogRunner.h" #include @@ -39,8 +40,16 @@ namespace VISU class CutLines_i; //--------------------------------------------------------------- - template inline + int + runAndWait( QDialog* dlg, const bool modal ) + { + VisuGUI_DialogRunner r( dlg ); + return r.run( modal ); + } + + //--------------------------------------------------------------- + template void EditPrs3d(VisuGUI* theModule, VISU::Prs3d_i* thePrs3d) @@ -48,7 +57,7 @@ namespace VISU if(TPrs3d_i* aPrs3d = dynamic_cast(thePrs3d)){ TDlg* aDlg = new TDlg (theModule); aDlg->initFromPrsObject(aPrs3d); - if (aDlg->exec()) { + if (runAndWait(aDlg,TIsDlgModal)) { if (!(aDlg->storeToPrsObject(aPrs3d))) { delete aDlg; return; @@ -71,13 +80,13 @@ namespace VISU } } - template + template inline void EditPrs3d(VisuGUI* theModule, VISU::Prs3d_i* thePrs3d) { - EditPrs3d(theModule,thePrs3d); + EditPrs3d(theModule,thePrs3d); } //--------------------------------------------------------------- @@ -146,8 +155,8 @@ namespace VISU if(!aValue){ if(TDlg* aDlg = new TDlg(theModule)){ // dialog box in creation mode aDlg->initFromPrsObject(aPrs3d); - if(IsDlgModal) - if(aDlg->exec() && (aDlg->storeToPrsObject(aPrs3d))){ + + if(runAndWait(aDlg,IsDlgModal) && (aDlg->storeToPrsObject(aPrs3d))) { // Optionally, create table and curves for cut lines QApplication::setOverrideCursor(Qt::waitCursor); CreateCurves( theModule, @@ -161,10 +170,6 @@ namespace VISU delete aDlg; return false; } - else{ - aDlg->show(); - return true; - } } } PublishInView(theModule,aPrs3d,true,theIsCreateView); diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 6db5b293..5593929b 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -213,15 +213,15 @@ namespace VISU { if (CheckLock(GetCStudy(GetAppStudy(theModule)))) return NULL; - + CORBA::Object_var anObject = GetSelectedObj(theModule, theIO); - if (CORBA::is_nil(anObject)) + if (CORBA::is_nil(anObject)) return NULL; PortableServer::ServantBase_var aServant = VISU::GetServant(anObject); - if (!aServant.in()) + if (!aServant.in()) return NULL; - + return dynamic_cast(aServant.in()); } @@ -391,9 +391,13 @@ namespace VISU _PTR(Study) theStudy, _PTR(SObject) theSObject) { + SalomeApp_Study* study = GetAppStudy( theModule ); + study->deleteReferencesTo( theSObject ); + _PTR(ChildIterator) aChildIter = theStudy->NewChildIterator(theSObject); for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) { _PTR(SObject) aChildSObject = aChildIter->Value(); + study->deleteReferencesTo( aChildSObject ); CORBA::Object_var aChildObj = VISU::ClientSObjectToObject(aChildSObject); ErasePrs(theModule, aChildObj); } @@ -408,6 +412,7 @@ namespace VISU } } else { // Remove aSObject together with all its sub-objects + VISU::RemoveFromStudy(theSObject, false, // remove not only IOR attribute, but Object With Children false); // not Destroy() sub-objects @@ -457,13 +462,19 @@ namespace VISU ChangeRepresentation (const SalomeApp_Module* theModule, VISU::PresentationType theType) { - SUIT_ViewWindow* aView = GetActiveView(theModule, VTKViewer_Viewer::Type()); + SUIT_ViewWindow* aView = GetActiveView(theModule, SVTK_Viewer::Type()); if (!aView) return; - SVTK_ViewWindow* vw = (SVTK_ViewWindow*) aView; + SVTK_ViewWindow* vw = dynamic_cast( aView ); + if( !vw ) + return; Handle(SALOME_InteractiveObject) anIO; CORBA::Object_var anObject = GetSelectedObj(theModule, &anIO); if (CORBA::is_nil(anObject)) return; + + VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); + if (CORBA::is_nil(aVisuObj)) return; + PortableServer::ServantBase_var aServant = VISU::GetServant(anObject); if (!aServant.in()) return; @@ -778,6 +789,89 @@ namespace VISU QApplication::restoreOverrideCursor(); } + static bool ComputeVisiblePropBounds(SVTK_ViewWindow* theViewWindow, + float allBounds[6], + const char* theActorClassName = "VISU_Actor") + { + vtkRenderer *aRen = theViewWindow->getRenderer(); + vtkActorCollection *anActColl = aRen->GetActors(); + vtkProp *prop; + float *bounds; + int somethingVisible = false; + + allBounds[0] = allBounds[2] = allBounds[4] = VTK_LARGE_FLOAT; + allBounds[1] = allBounds[3] = allBounds[5] = -VTK_LARGE_FLOAT; + // loop through all props + for (anActColl->InitTraversal(); (prop = anActColl->GetNextProp()); ) { + // if it's invisible, or has no geometry, we can skip the rest + if (prop->GetVisibility() && prop->IsA(theActorClassName)) { + bounds = prop->GetBounds(); + // make sure we haven't got bogus bounds + if (bounds != NULL && + bounds[0] > -VTK_LARGE_FLOAT && bounds[1] < VTK_LARGE_FLOAT && + bounds[2] > -VTK_LARGE_FLOAT && bounds[3] < VTK_LARGE_FLOAT && + bounds[4] > -VTK_LARGE_FLOAT && bounds[5] < VTK_LARGE_FLOAT) + { + somethingVisible = true; + if (bounds[0] < allBounds[0]) allBounds[0] = bounds[0]; + if (bounds[1] > allBounds[1]) allBounds[1] = bounds[1]; + if (bounds[2] < allBounds[2]) allBounds[2] = bounds[2]; + if (bounds[3] > allBounds[3]) allBounds[3] = bounds[3]; + if (bounds[4] < allBounds[4]) allBounds[4] = bounds[4]; + if (bounds[5] > allBounds[5]) allBounds[5] = bounds[5]; + }//not bogus + } + } + return somethingVisible; + } + + void SetFitAll(SVTK_ViewWindow* theViewWindow) + { + static float PRECISION = 0.000001; + static float DEVIATION = 600; + float XYZ_Bnd[6]; + if (!ComputeVisiblePropBounds(theViewWindow, XYZ_Bnd)) return; + + float absX = XYZ_Bnd[1] - XYZ_Bnd[0]; + float absY = XYZ_Bnd[3] - XYZ_Bnd[2]; + float absZ = XYZ_Bnd[5] - XYZ_Bnd[4]; + + enum CameraOrient {e3D, eFront, eLeft, eTop}; + CameraOrient aCameraOrient = e3D; + if (absX <= PRECISION) aCameraOrient = eFront; + else { + if (absY <= PRECISION) aCameraOrient = eLeft; + else { + if (absZ <= PRECISION) aCameraOrient = eTop; + else { + // all the three dimensions exceeds precision + float dev_abs_XY = absX / absY; + float dev_abs_YZ = absY / absZ; + float dev_abs_XZ = absX / absZ; + if (dev_abs_XY >= DEVIATION || 1./dev_abs_YZ >= DEVIATION) + aCameraOrient = eLeft; + else { + if (1./dev_abs_XY >= DEVIATION || 1./dev_abs_XZ >= DEVIATION) + aCameraOrient = eFront; + else { + if (dev_abs_XZ >= DEVIATION || dev_abs_YZ >= DEVIATION) + aCameraOrient = eTop; + } + } + } + } + } + + switch (aCameraOrient) { + case eFront: theViewWindow->onFrontView(); break; + case eLeft: theViewWindow->onLeftView(); break; + case eTop: theViewWindow->onTopView(); break; + case e3D: theViewWindow->onResetView(); break; + } + theViewWindow->getRenderer()->ResetCameraClippingRange(); + theViewWindow->onFitAll(); + } + //************************************************************ // Plot2d View @@ -1056,7 +1150,8 @@ namespace VISU timer.Start(); #endif PublishInView(theModule, pPresent); - aView->onFitAll(); + //aView->onFitAll(); + SetFitAll(aView); #ifdef CHECKTIME timer.Stop(); MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH"); diff --git a/src/VISUGUI/VisuGUI_Tools.h b/src/VISUGUI/VisuGUI_Tools.h index 63a767f4..3d6fd0e5 100644 --- a/src/VISUGUI/VisuGUI_Tools.h +++ b/src/VISUGUI/VisuGUI_Tools.h @@ -150,6 +150,17 @@ namespace VISU { void RecreateActor(const SalomeApp_Module* theModule, VISU::Prs3d_i* thePrs); + /*! + * \brief Advanced FitAll, sets view projection in accordance with current view contents + * + * If common bounding box of all actors in \a theViewWindow has + * at least one small side, then corresponding projection will be set + * (Top, Left or Front), else 3D projection will be used. + * + * \param theViewWindow - the view to perform FitAll in. + */ + void SetFitAll(SVTK_ViewWindow* theViewWindow); + // Plot2d View SPlot2d_Viewer* GetPlot2dViewer(const SalomeApp_Module* theModule, const bool theCreate = false); diff --git a/src/VISU_I/VISU_View_i.cc b/src/VISU_I/VISU_View_i.cc index 54c64623..92e46a57 100644 --- a/src/VISU_I/VISU_View_i.cc +++ b/src/VISU_I/VISU_View_i.cc @@ -926,7 +926,11 @@ namespace VISU { void Execute() { - myResult = myApplication->getViewManager(TViewer::Type(), true); + myResult = myApplication->getViewManager(TViewer::Type(), false); + if (!myResult) { + myResult = myApplication->getViewManager(TViewer::Type(), true); + myResult->closeAllViews(); + } } };