From 892670dfa63e3a10989e348fee2df55929bf12a5 Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 18 Apr 2006 09:16:47 +0000 Subject: [PATCH] Plot3d on CutPlane --- src/VISUGUI/VISU_msg_en.po | 3 + src/VISUGUI/VisuGUI.cxx | 139 ++++++++++++++++++++++++++++--- src/VISUGUI/VisuGUI.h | 1 + src/VISUGUI/VisuGUI_ActionsDef.h | 2 + 4 files changed, 135 insertions(+), 10 deletions(-) diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index 4ba765cb..0511fa4f 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -385,6 +385,9 @@ msgstr "Use Field Range" msgid "VisuGUI::MEN_ARRANGE_ACTORS" msgstr "Arrange Actors" +msgid "VisuGUI::MEN_PLOT3D_FROM_CUTPLANE" +msgstr "Plot3d" + msgid "VisuGUI::ERR_ERROR_DURING_EXPORT" msgstr "Error has been occured during exporting to file" diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 3c2ad867..46a5fef9 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -2213,6 +2213,11 @@ createActions() createAction( VISU_SHOW_ANIMATION, tr("MEN_SHOW_ANIMATION"), QIconSet(), 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())); } void @@ -2602,22 +2607,15 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q } } } - if (nbPrs > 1) { theMenu->insertSeparator(); action( VISU_MERGE_SCALAR_BARS )->addTo(theMenu); action( VISU_FREE_SCALAR_BARS )->addTo(theMenu); } - theMenu->insertSeparator(); - - // Check if some (nb > 0) removable objects selected - if (isOBClient && IsRemovableSelected(this)) { - action( VISU_DELETE_OBJS )->addTo(theMenu); - } - // Check if some curves selected (for bug PAL10611) bool isCurves = false; + bool isOneCutPlane = false; SALOME_ListIteratorOfListIO It1 (aListIO); for (; It1.More() && !isCurves; It1.Next()) { Handle(SALOME_InteractiveObject)& anIO = It1.Value(); @@ -2635,12 +2633,33 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q VISU::Storable::StrToMap(strIn, pMap); bool isExist; VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt(); - if (isExist && aType == VISU::TCURVE) { + 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; + } + } + } + } } } } + + if (isOneCutPlane) + action( VISU_PLOT3D_FROM_CUTPLANE )->addTo(theMenu); + + theMenu->insertSeparator(); + + // Check if some (nb > 0) removable objects selected + if (isOBClient && IsRemovableSelected(this)) { + action( VISU_DELETE_OBJS )->addTo(theMenu); + } if (isCurves) { action( myDisplay )->removeFrom(theMenu); action( myErase )->removeFrom(theMenu); @@ -3043,3 +3062,103 @@ LightApp_Displayer* VisuGUI::displayer() return myDisplayer; } + + +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")); + } +} diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index cec1e4c2..32dc989b 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -154,6 +154,7 @@ protected slots: void OnTranslatePrs(); void OnArrangeActors(); + void OnPlot3dFromCutPlane(); protected: virtual LightApp_Selection* createSelection() const; diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index 681a9d13..58abbd06 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -112,4 +112,6 @@ #define VISU_FREE_SCALAR_BARS 4081 #define VISU_SHOW_ANIMATION 4082 +#define VISU_PLOT3D_FROM_CUTPLANE 4083 + #endif -- 2.39.2