VisuGUI::
OnCreateCutPlanes()
{
- CreatePrs3d<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg,1>(this);
+ CreatePrs3d<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg,0>(this);
}
void
VisuGUI::
OnCreateCutLines()
{
- CreatePrs3d<VISU::CutLines_i,VisuGUI_CutLinesDlg,1>(this);
+ CreatePrs3d<VISU::CutLines_i,VisuGUI_CutLinesDlg,0>(this);
}
void
VisuGUI::
OnCreatePlot3D()
{
- CreatePrs3d<VISU::Plot3D_i,VisuGUI_Plot3DDlg,1>(this);
+ CreatePrs3d<VISU::Plot3D_i,VisuGUI_Plot3DDlg,0>(this);
}
void
{
Handle(SALOME_InteractiveObject) anIO;
if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
- EditPrs3d<VISU::ScalarMap_i, VisuGUI_ScalarBarDlg>(this, aPrs3d);
+ EditPrs3d<VISU::ScalarMap_i, VisuGUI_ScalarBarDlg,1>(this, aPrs3d);
if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
aViewWindow->highlight(anIO, 1);
}
{
Handle(SALOME_InteractiveObject) anIO;
if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
- EditPrs3d<VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg>(this, aPrs3d);
+ EditPrs3d<VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg,1>(this, aPrs3d);
if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
aViewWindow->highlight(anIO, 1);
}
{
Handle(SALOME_InteractiveObject) anIO;
if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
- EditPrs3d<VISU::CutPlanes_i, VisuGUI_CutPlanesDlg>(this, aPrs3d);
+ EditPrs3d<VISU::CutPlanes_i, VisuGUI_CutPlanesDlg,0>(this, aPrs3d);
if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
aViewWindow->highlight(anIO, 1);
}
{
Handle(SALOME_InteractiveObject) anIO;
if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
- EditPrs3d<VISU::CutLines_i, VisuGUI_CutLinesDlg>(this, aPrs3d);
+ EditPrs3d<VISU::CutLines_i, VisuGUI_CutLinesDlg,0>(this, aPrs3d);
if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
aViewWindow->highlight(anIO, 1);
}
{
Handle(SALOME_InteractiveObject) anIO;
if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
- EditPrs3d<VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg>(this, aPrs3d);
+ EditPrs3d<VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg,1>(this, aPrs3d);
if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
aViewWindow->highlight(anIO, 1);
}
{
Handle(SALOME_InteractiveObject) anIO;
if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
- EditPrs3d<VISU::Vectors_i, VisuGUI_VectorsDlg>(this, aPrs3d);
+ EditPrs3d<VISU::Vectors_i, VisuGUI_VectorsDlg,1>(this, aPrs3d);
if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
aViewWindow->highlight(anIO, 1);
}
{
Handle(SALOME_InteractiveObject) anIO;
if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
- EditPrs3d<VISU::StreamLines_i, VisuGUI_StreamLinesDlg>(this, aPrs3d);
+ EditPrs3d<VISU::StreamLines_i, VisuGUI_StreamLinesDlg,1>(this, aPrs3d);
if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
aViewWindow->highlight(anIO, 1);
}
{
Handle(SALOME_InteractiveObject) anIO;
if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
- EditPrs3d<VISU::Plot3D_i, VisuGUI_Plot3DDlg>(this, aPrs3d);
+ EditPrs3d<VISU::Plot3D_i, VisuGUI_Plot3DDlg,0>(this, aPrs3d);
if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
aViewWindow->highlight(anIO, 1);
}
return getApp()->getViewManager(theType,theIsCreate);
}
+SalomeApp_Displayer* VisuGUI::displayer()
+{
+ return 0;
+}
VisuGUI();
virtual ~VisuGUI();
+ virtual SalomeApp_Displayer* displayer();
virtual void initialize( CAM_Application* );
virtual void windows( QMap<int, int>& ) const;
virtual void viewManagers( QStringList& ) const;
void createMenus();
void createToolBars();
void createPopupMenus();
+
+private:
+ SalomeApp_Displayer* myDisplayer;
};
#endif
{
Handle(SALOME_InteractiveObject) anIO;
if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
- EditPrs3d<VISU::GaussPoints_i, VisuGUI_GaussPointsDlg>(this, aPrs3d);
+ EditPrs3d<VISU::GaussPoints_i,VisuGUI_GaussPointsDlg,1>(this, aPrs3d);
if(SVTK_ViewWindow* aViewWindow = GetViewWindow<VVTK_Viewer>(this,true)){
aViewWindow->highlight(anIO,1);
}
#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 <vtkRenderer.h>
class CutLines_i;
//---------------------------------------------------------------
- template<class TPrs3d_i, class TViewer, class TDlg>
inline
+ int
+ runAndWait( QDialog* dlg, const bool modal )
+ {
+ VisuGUI_DialogRunner r( dlg );
+ return r.run( modal );
+ }
+
+ //---------------------------------------------------------------
+ template<class TPrs3d_i, class TViewer, class TDlg, int TIsDlgModal>
void
EditPrs3d(VisuGUI* theModule,
VISU::Prs3d_i* thePrs3d)
if(TPrs3d_i* aPrs3d = dynamic_cast<TPrs3d_i*>(thePrs3d)){
TDlg* aDlg = new TDlg (theModule);
aDlg->initFromPrsObject(aPrs3d);
- if (aDlg->exec()) {
+ if (runAndWait(aDlg,TIsDlgModal)) {
if (!(aDlg->storeToPrsObject(aPrs3d))) {
delete aDlg;
return;
}
}
- template<class TPrs3d_i, class TDlg>
+ template<class TPrs3d_i, class TDlg, int TIsDlgModal>
inline
void
EditPrs3d(VisuGUI* theModule,
VISU::Prs3d_i* thePrs3d)
{
- EditPrs3d<TPrs3d_i,SVTK_Viewer,TDlg>(theModule,thePrs3d);
+ EditPrs3d<TPrs3d_i,SVTK_Viewer,TDlg,TIsDlgModal>(theModule,thePrs3d);
}
//---------------------------------------------------------------
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,
delete aDlg;
return false;
}
- else{
- aDlg->show();
- return true;
- }
}
}
PublishInView<TViewer>(theModule,aPrs3d,true,theIsCreateView);
{
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<VISU::Prs3d_i*>(aServant.in());
}
_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);
}
}
} 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
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<SVTK_ViewWindow*>( 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;
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
timer.Start();
#endif
PublishInView(theModule, pPresent);
- aView->onFitAll();
+ //aView->onFitAll();
+ SetFitAll(aView);
#ifdef CHECKTIME
timer.Stop();
MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
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);
void
Execute()
{
- myResult = myApplication->getViewManager(TViewer::Type(), true);
+ myResult = myApplication->getViewManager(TViewer::Type(), false);
+ if (!myResult) {
+ myResult = myApplication->getViewManager(TViewer::Type(), true);
+ myResult->closeAllViews();
+ }
}
};