From ff27b39c6c0065d48be174c59a9b4cb164a334b9 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 18 May 2006 08:46:10 +0000 Subject: [PATCH] New functionality: creation of Plot3d using a CutPlanes presentation with a one plane --- src/VISUGUI/VisuGUI.cxx | 224 +++++++++++++++--------------- src/VISUGUI/VisuGUI_Plot3DDlg.cxx | 38 +++++ src/VISUGUI/VisuGUI_Plot3DDlg.h | 4 + 3 files changed, 155 insertions(+), 111 deletions(-) diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 98bb59d6..9bd0664f 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -2279,10 +2279,10 @@ createActions() tr("MEN_SHOW_ANIMATION"), "", 0, aParent, false, this, SLOT(OnShowAnimation())); - //aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT_3D")); - //createAction( VISU_PLOT3D_FROM_CUTPLANE, tr("MEN_PLOT3D_FROM_CUTPLANE"), QIconSet(aPixmap), - // tr("MEN_PLOT3D_FROM_CUTPLANE"), "", 0, aParent, false, - // this, SLOT(OnPlot3dFromCutPlane())); + aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT_3D")); + createAction( VISU_PLOT3D_FROM_CUTPLANE, tr("MEN_PLOT3D_FROM_CUTPLANE"), QIconSet(aPixmap), + tr("MEN_PLOT3D_FROM_CUTPLANE"), "", 0, aParent, false, + this, SLOT(OnPlot3dFromCutPlane())); } void @@ -2706,23 +2706,25 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q if (isExist && aType == VISU::TCURVE) { isCurves = true; } else { - //CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry()); - //if (!CORBA::is_nil(anObject)) { - // VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject).in()); - // if (aPrsObject->GetType() == VISU::TCUTPLANES) { - // VISU::CutPlanes_i* aCutPrs = dynamic_cast(aPrsObject); - // if (aCutPrs) { - // isOneCutPlane = aCutPrs->GetNbPlanes() == 1; - // } - // } - //} + CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry()); + if (!CORBA::is_nil(anObject)) { + VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject).in()); + if (aPrsObject) { + if (aPrsObject->GetType() == VISU::TCUTPLANES) { + VISU::CutPlanes_i* aCutPrs = dynamic_cast(aPrsObject); + if (aCutPrs) { + isOneCutPlane = aCutPrs->GetNbPlanes() == 1; + } + } + } + } } } } } - //if (isOneCutPlane) - // action( VISU_PLOT3D_FROM_CUTPLANE )->addTo(theMenu); + if (isOneCutPlane) + action( VISU_PLOT3D_FROM_CUTPLANE )->addTo(theMenu); theMenu->insertSeparator(); @@ -3222,99 +3224,99 @@ LightApp_Displayer* VisuGUI::displayer() void VisuGUI::OnPlot3dFromCutPlane() { -// _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this)); -// if (CheckLock(aCStudy, GetDesktop(this))) -// return; -// -// LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); -// SALOME_ListIO aListIO; -// aSelectionMgr->selectedObjects(aListIO); -// -// if (aListIO.Extent() < 1) return; -// -// -// VISU::CutPlanes_i* aCutPrs = 0; -// Handle(SALOME_InteractiveObject) anIO; -// _PTR(SObject) aSObject; -// SALOME_ListIteratorOfListIO It (aListIO); -// for (; It.More(); It.Next()) { -// anIO = It.Value(); -// -// if (!anIO.IsNull() && anIO->hasEntry()) { -// aSObject = aCStudy->FindObjectID(anIO->getEntry()); -// if ( !aSObject ) -// continue; -// CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry()); -// if (!CORBA::is_nil(anObject)) { -// VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject).in()); -// if (aPrsObject->GetType() == VISU::TCUTPLANES) { -// aCutPrs = dynamic_cast(aPrsObject); -// if (aCutPrs) -// break; -// } -// } -// } -// } -// -// if (aCutPrs) { -// _PTR(SObject) aTimeStampSObj = aSObject->GetFather(); -// if (SUIT_ViewManager* aViewManager = getApp()->activeViewManager()) { -// QString aType = aViewManager->getType(); -// bool isVVTK = aType == VVTK_Viewer::Type(); -// -// Storable::TRestoringMap aMap = getMapOfValue(aTimeStampSObj); -// bool isExist; -// aType = Storable::FindValue(aMap,"myType",&isExist); -// if (!isExist || aType.toInt() != TTIMESTAMP ) -// return; -// -// 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; -// SUIT_ViewWindow* aViewWindow = 0; -// if (isVVTK) { -// aViewWindow = GetViewWindow(this); -// aPos = GetFreePositionOfDefaultScalarBar(this, dynamic_cast(aViewWindow)); -// } else { -// aViewWindow = GetViewWindow(this); -// aPos = GetFreePositionOfDefaultScalarBar(this, dynamic_cast(GetViewWindow(this))); -// } -// GetResourceMgr()->setValue("VISU", "scalar_bar_position_num", aPos); -// -// VISU::Plot3D_i* aPrs3d = CreatePrs3d(this, aTimeStampSObj, aMeshName.latin1(), (Entity)anEntity.toInt(), -// aFieldName.latin1(), aTimeStampId.toInt()); -// if (aPrs3d) { -// SUIT_ResourceMgr* aResourceMgr = GetResourceMgr(); -// int aValue = aResourceMgr->integerValue("VISU","BuildDefaultPrs3d",0); -// if (!aValue) { -// VisuGUI_Plot3DDlg* aDlg = new VisuGUI_Plot3DDlg(this); -// aDlg->initFromPrsObject(aPrs3d); -// int aOrient = aCutPrs->GetOrientationType(); // Plot3d has the same orientation type -// double aRotX = aCutPrs->GetRotateX(); -// double aRotY = aCutPrs->GetRotateY(); -// double aPlanePos = aCutPrs->GetPlanePosition(0); -// aDlg->setPlane(aOrient, aRotX, aRotY, aPlanePos); -// -// if (!(runAndWait(aDlg, 0) && (aDlg->storeToPrsObject(aPrs3d)))) { -// DeletePrs3d(this, aPrs3d, anIO); -// delete aDlg; -// return; -// } -// delete aDlg; -// UpdateObjBrowser(this, true, aTimeStampSObj); -// } -// SVTK_ViewWindow* aSVtkWindow = dynamic_cast(aViewWindow); -// if ( aSVtkWindow ) { -// PublishInView(this, aPrs3d, aSVtkWindow, /*highlight = */true); -// aSVtkWindow->onFitAll(); -// -// AddScalarBarPosition(this, aSVtkWindow, aPrs3d, aPos); -// } -// } -// } -// application()->putInfo(QObject::tr("INF_DONE")); -// } + _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this)); + if (CheckLock(aCStudy, GetDesktop(this))) + return; + + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + SALOME_ListIO aListIO; + aSelectionMgr->selectedObjects(aListIO); + + if (aListIO.Extent() < 1) return; + + + VISU::CutPlanes_i* aCutPrs = 0; + Handle(SALOME_InteractiveObject) anIO; + _PTR(SObject) aSObject; + SALOME_ListIteratorOfListIO It (aListIO); + for (; It.More(); It.Next()) { + anIO = It.Value(); + + if (!anIO.IsNull() && anIO->hasEntry()) { + aSObject = aCStudy->FindObjectID(anIO->getEntry()); + if ( !aSObject ) + continue; + CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry()); + if (!CORBA::is_nil(anObject)) { + VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject).in()); + if (aPrsObject->GetType() == VISU::TCUTPLANES) { + aCutPrs = dynamic_cast(aPrsObject); + if (aCutPrs) + break; + } + } + } + } + + if (aCutPrs) { + _PTR(SObject) aTimeStampSObj = aSObject->GetFather(); + if (SUIT_ViewManager* aViewManager = getApp()->activeViewManager()) { + QString aType = aViewManager->getType(); + bool isVVTK = aType == VVTK_Viewer::Type(); + + Storable::TRestoringMap aMap = getMapOfValue(aTimeStampSObj); + bool isExist; + aType = Storable::FindValue(aMap,"myType",&isExist); + if (!isExist || aType.toInt() != TTIMESTAMP ) + return; + + 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; + SUIT_ViewWindow* aViewWindow = 0; + if (isVVTK) { + aViewWindow = GetViewWindow(this); + aPos = GetFreePositionOfDefaultScalarBar(this, dynamic_cast(aViewWindow)); + } else { + aViewWindow = GetViewWindow(this); + aPos = GetFreePositionOfDefaultScalarBar(this, dynamic_cast(GetViewWindow(this))); + } + GetResourceMgr()->setValue("VISU", "scalar_bar_position_num", aPos); + + VISU::Plot3D_i* aPrs3d = CreatePrs3d(this, aTimeStampSObj, aMeshName.latin1(), (Entity)anEntity.toInt(), + aFieldName.latin1(), aTimeStampId.toInt()); + if (aPrs3d) { + SUIT_ResourceMgr* aResourceMgr = GetResourceMgr(); + int aValue = aResourceMgr->integerValue("VISU","BuildDefaultPrs3d",0); + if (!aValue) { + VisuGUI_Plot3DDlg* aDlg = new VisuGUI_Plot3DDlg(this); + aDlg->initFromPrsObject(aPrs3d); + int aOrient = aCutPrs->GetOrientationType(); // Plot3d has the same orientation type + double aRotX = aCutPrs->GetRotateX(); + double aRotY = aCutPrs->GetRotateY(); + double aPlanePos = aCutPrs->GetPlanePosition(0); + aDlg->setPlane(aOrient, aRotX, aRotY, aPlanePos); + + if (!(runAndWait(aDlg, 0) && (aDlg->storeToPrsObject(aPrs3d)))) { + DeletePrs3d(this, aPrs3d, anIO); + delete aDlg; + return; + } + delete aDlg; + UpdateObjBrowser(this, true, aTimeStampSObj); + } + SVTK_ViewWindow* aSVtkWindow = dynamic_cast(aViewWindow); + if ( aSVtkWindow ) { + PublishInView(this, aPrs3d, aSVtkWindow, /*highlight = */true); + aSVtkWindow->onFitAll(); + + AddScalarBarPosition(this, aSVtkWindow, aPrs3d, aPos); + } + } + } + application()->putInfo(QObject::tr("INF_DONE")); + } } diff --git a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx index b80b5417..2662f9ff 100644 --- a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx +++ b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx @@ -500,6 +500,35 @@ bool VisuGUI_Plot3DPane::check() return true; } +void VisuGUI_Plot3DPane::setPlane(int theOrientation, double theXRotation, double theYRotation, double thePlanePos) +{ + // Set plane + int id; + switch (theOrientation) { + case VISU::Plot3D::XY: id = 0; break; + case VISU::Plot3D::YZ: id = 1; break; + default: id = 2; + } + GBOrientation->setButton(id); + orientationChanged(id); + GBOrientation->setEnabled(false); + + + // Set rotation + Rot1->setValue(theXRotation * 180./PI); + Rot1->setEnabled(false); + Rot2->setValue(theYRotation * 180./PI); + Rot2->setEnabled(false); + + // Set position + RelativeChkB->setChecked(false); + onRelativePos(false); // update range + PositionSpn->setValue(thePlanePos); + RelativeChkB->setEnabled(false); + PositionSpn->setEnabled(false); +} + + //======================================================================= //function : Constructor //purpose : @@ -599,3 +628,12 @@ void VisuGUI_Plot3DDlg::onHelp() QObject::tr("BUT_OK")); } } + +//======================================================================= +//function : setPlane +//purpose : +//======================================================================= +void VisuGUI_Plot3DDlg::setPlane(int theOrientation, double theXRotation, double theYRotation, double thePlanePos) +{ + myIsoPane->setPlane(theOrientation, theXRotation, theYRotation, thePlanePos); +} diff --git a/src/VISUGUI/VisuGUI_Plot3DDlg.h b/src/VISUGUI/VisuGUI_Plot3DDlg.h index 325441f5..04065b26 100644 --- a/src/VISUGUI/VisuGUI_Plot3DDlg.h +++ b/src/VISUGUI/VisuGUI_Plot3DDlg.h @@ -61,6 +61,8 @@ class VisuGUI_Plot3DPane : public QVBox VISU::Plot3D_i* GetPrs() { return myPrs; } + void setPlane(int theOrientation, double theXRotation, double theYRotation, double thePlanePos); + private: bool myInitFromPrs; SALOME_Actor* myPreviewActor; @@ -107,6 +109,8 @@ class VisuGUI_Plot3DDlg : public QDialog int storeToPrsObject (VISU::Plot3D_i* thePrs) { return myScalarPane->storeToPrsObject(thePrs) && myIsoPane->storeToPrsObject(thePrs); } + void setPlane(int theOrientation, double theXRotation, double theYRotation, double thePlanePos); + protected slots: void accept(); void reject(); -- 2.39.2