From: dmv Date: Wed, 21 Nov 2007 08:07:00 +0000 (+0000) Subject: NPAL 16841 X-Git-Tag: V3_2_9rc2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f8544097f233093118dd710a68999866a6d8c675;p=modules%2Fvisu.git NPAL 16841 --- diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index 56c4ca5b..c34c1188 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -275,6 +275,9 @@ msgstr "Color..." msgid "VisuGUI::MEN_CREATE_CURVES" msgstr "Create Curves" +msgid "VisuGUI::MEN_CREATE_PLOT3D_PRESENTATION" +msgstr "Create Plot3D Presentation" + msgid "VisuGUI::MEN_CREATE_MANY_PRS" msgstr "Create Presentations" diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index fc85a142..83868456 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -647,7 +647,7 @@ void VisuGUI:: OnCreateDeformedShape() { - CreatePrs3d(this); + VisuGUI_DeformedShapeDlg::CreatePrs3d(this); } void @@ -854,7 +854,8 @@ OnEditDeformedShape() { Handle(SALOME_InteractiveObject) anIO; if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO)) - EditPrs3d(this, anIO, aPrs3d); + VisuGUI_DeformedShapeDlg::EditPrs3d(this, aPrs3d, anIO); + // EditPrs3d(this, anIO, aPrs3d); } void diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index 12ffe377..0da54c95 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -47,6 +47,7 @@ #define VISU_SHOW_TABLE 4023 #define VISU_CREATE_CURVES 4024 #define VISU_EXPORT_TABLE 4025 +#define VISU_CREATE_PLOT3D_PRESENTATION 4034 #define VISU_CREATE_PRS 4026 #define VISU_CREATE_MANY_PRS 4027 diff --git a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx index 2eddd716..2a6be696 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx @@ -30,9 +30,13 @@ #include "VisuGUI.h" #include "VisuGUI_Tools.h" - +#include "VisuGUI_ViewTools.h" +#include "VISU_Gen_i.hh" +#include "VISU_Result_i.hh" +#include "VisuGUI_Prs3dTools.h" +#include "SVTK_ViewWindow.h" #include "VISU_DeformedShape_i.hh" - +#include "VisuGUI_Module.h" #include "SalomeApp_Module.h" #include "LightApp_Application.h" #include "SUIT_Desktop.h" @@ -48,12 +52,13 @@ using namespace std; /*! * Constructor */ -VisuGUI_DeformedShapeDlg::VisuGUI_DeformedShapeDlg (SalomeApp_Module* theModule) - : QDialog(VISU::GetDesktop(theModule), "VisuGUI_DeformedShapeDlg", true, +VisuGUI_DeformedShapeDlg::VisuGUI_DeformedShapeDlg (VisuGUI* theModule) + : QDialog(VISU::GetDesktop(theModule), "VisuGUI_DeformedShapeDlg", false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { setCaption(tr("DLG_TITLE")); setSizeGripEnabled(TRUE); + myModule = theModule; QVBoxLayout* TopLayout = new QVBoxLayout (this); TopLayout->setSpacing(6); @@ -92,6 +97,7 @@ VisuGUI_DeformedShapeDlg::VisuGUI_DeformedShapeDlg (SalomeApp_Module* theModule) // Scalar bar pane myScalarPane = new VisuGUI_ScalarBarPane (this, false); myScalarPane->setMargin(5); + myScalarPane->removePreview(); aTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB")); @@ -111,8 +117,10 @@ VisuGUI_DeformedShapeDlg::VisuGUI_DeformedShapeDlg (SalomeApp_Module* theModule) buttonOk->setDefault(TRUE); GroupButtonsLayout->addWidget(buttonOk, 0, 0); - GroupButtonsLayout->addItem(new QSpacerItem (5, 5, QSizePolicy::Expanding, - QSizePolicy::Minimum), 0, 1); + QPushButton* buttonApply = new QPushButton (tr("&Apply"), GroupButtons, "buttonApply"); + buttonApply->setAutoDefault(TRUE); + buttonApply->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonApply, 0, 1); QPushButton* buttonCancel = new QPushButton (tr("&Cancel") , GroupButtons, "buttonCancel"); buttonCancel->setAutoDefault(TRUE); @@ -128,6 +136,7 @@ VisuGUI_DeformedShapeDlg::VisuGUI_DeformedShapeDlg (SalomeApp_Module* theModule) // signals and slots connections connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept())); + connect(buttonApply, SIGNAL(clicked()), this, SLOT(onApply())); connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())); } @@ -137,6 +146,7 @@ void VisuGUI_DeformedShapeDlg::initFromPrsObject (VISU::DeformedShape_i* thePrs) myScalarPane->initFromPrsObject(thePrs); setFactor(thePrs->GetScale()); UseMagn->setChecked(thePrs->IsColored()); + myPrs = thePrs; } int VisuGUI_DeformedShapeDlg::storeToPrsObject(VISU::DeformedShape_i* thePrs) { @@ -147,16 +157,43 @@ int VisuGUI_DeformedShapeDlg::storeToPrsObject(VISU::DeformedShape_i* thePrs) { } void VisuGUI_DeformedShapeDlg::accept() { - if (myScalarPane->check()) - { - myScalarPane->deletePreview(); - QDialog::accept(); + if ( onApply() ) + QDialog::accept(); +} + +bool VisuGUI_DeformedShapeDlg::onApply() +{ + if ( myScalarPane->check() && storeToPrsObject(myPrs) ) + { + //myScalarPane->deletePreview(); + + if ( myPrs->GetNumberOfActors() == 0 ) { + SVTK_ViewWindow* aViewWindow = VISU::GetViewWindow(myModule); + PublishInView(myModule, myPrs, aViewWindow, true); + aViewWindow->onFitAll(); + int aPos = VISU::GetFreePositionOfDefaultScalarBar(myModule, aViewWindow); + VISU::AddScalarBarPosition(myModule, aViewWindow, myPrs, aPos); + } else { + try { + myPrs->UpdateActors(); + } catch (std::runtime_error& exc) { + myPrs->RemoveActors(); + + INFOS(exc.what()); + SUIT_MessageBox::warn1 + (VISU::GetDesktop(myModule), QObject::tr("WRN_VISU"), + QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(exc.what()), + QObject::tr("BUT_OK")); + } } + return true; + } + return false; } void VisuGUI_DeformedShapeDlg::reject() { - myScalarPane->deletePreview(); + // myScalarPane->deletePreview(); QDialog::reject(); } @@ -188,3 +225,76 @@ void VisuGUI_DeformedShapeDlg::keyPressEvent( QKeyEvent* e ) onHelp(); } } + +//////////////////////////////////////////////////////////////////////////////// +// Create and Edit +//////////////////////////////////////////////////////////////////////////////// + +void VisuGUI_DeformedShapeDlg::CreatePrs3d(VisuGUI* theModule) +{ + _PTR(SObject) aTimeStamp; + Handle(SALOME_InteractiveObject) anIO; + + if (VISU::CheckTimeStamp(theModule,aTimeStamp,&anIO)) + { + VISU::Storable::TRestoringMap aMap = VISU::getMapOfValue(aTimeStamp); + bool isExist; + QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); + if ( isExist && aType.toInt() == VISU::TTIMESTAMP ) + { + QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); + QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); + QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); + QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); + + typedef VISU::DeformedShape_i TPrs3d_i; + + TPrs3d_i* aPrs3d = VISU::CreatePrs3d(theModule, aTimeStamp, + aMeshName.latin1(), (VISU::Entity)anEntity.toInt(), + aFieldName.latin1(), aTimeStampId.toInt()); + + VisuGUI_DeformedShapeDlg* aDlg = new VisuGUI_DeformedShapeDlg (theModule); + aDlg->initFromPrsObject(aPrs3d); + VisuGUI_DialogRunner r(aDlg); + int dlgResult = r.run( false ); + + if ( dlgResult == 0 && aPrs3d->GetNumberOfActors() == 0 ) + aPrs3d->RemoveFromStudy(); + + VISU::UpdateObjBrowser(theModule,true, aTimeStamp); + delete aDlg; + } + } +} + +//////////////////////////////////////////////////////////////////////////////// + +void VisuGUI_DeformedShapeDlg::EditPrs3d(VisuGUI* theModule, VISU::Prs3d_i* thePrs3d, Handle(SALOME_InteractiveObject)& theIO) +{ + typedef VISU::DeformedShape_i TPrs3d_i; + + if (TPrs3d_i* aPrs3d = dynamic_cast(thePrs3d)) + { + VisuGUI_DeformedShapeDlg* aDlg = new VisuGUI_DeformedShapeDlg (theModule); + aDlg->initFromPrsObject(aPrs3d); + VisuGUI_DialogRunner r(aDlg); + r.run( false ); + + delete aDlg; + return; + } + try + { + thePrs3d->UpdateActors(); + } + catch (std::runtime_error& exc) + { + thePrs3d->RemoveActors(); + + INFOS(exc.what()); + SUIT_MessageBox::warn1 + (VISU::GetDesktop(theModule), QObject::tr("WRN_VISU"), + QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(exc.what()), + QObject::tr("BUT_OK")); + } +} diff --git a/src/VISUGUI/VisuGUI_DeformedShapeDlg.h b/src/VISUGUI/VisuGUI_DeformedShapeDlg.h index 32c10f4c..3ed55d38 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeDlg.h +++ b/src/VISUGUI/VisuGUI_DeformedShapeDlg.h @@ -30,9 +30,7 @@ #define VISUGUI_DEFORMEDSHAPEDLS_H #include "VisuGUI_ScalarBarDlg.h" - #include "QtxDblSpinBox.h" - #include #include #include @@ -40,9 +38,12 @@ #include class SalomeApp_Module; +class VisuGUI; namespace VISU{ class DeformedShape_i; + class Prs3d_i; + class CutLines_i; } class VisuGUI_DeformedShapeDlg : public QDialog @@ -50,7 +51,7 @@ class VisuGUI_DeformedShapeDlg : public QDialog Q_OBJECT public: - VisuGUI_DeformedShapeDlg (SalomeApp_Module* theModule); + VisuGUI_DeformedShapeDlg (VisuGUI* theModule); ~VisuGUI_DeformedShapeDlg() {}; double getFactor() @@ -64,6 +65,9 @@ public: void initFromPrsObject(VISU::DeformedShape_i* thePrs); int storeToPrsObject(VISU::DeformedShape_i* thePrs); + static void CreatePrs3d(VisuGUI* theModule); + static void EditPrs3d(VisuGUI* theModule, VISU::Prs3d_i* thePrs3d, Handle(SALOME_InteractiveObject)& theIO); + private: void keyPressEvent( QKeyEvent* e ); @@ -71,11 +75,15 @@ protected slots: void accept(); void reject(); void onHelp(); + bool onApply(); - private: +private: QtxDblSpinBox* ScalFact; QCheckBox* UseMagn; VisuGUI_ScalarBarPane* myScalarPane; + VISU::DeformedShape_i* myPrs; + VisuGUI* myModule; + _PTR(SObject)* myTimeStamp; }; #endif // VISUGUI_DEFORMEDSHAPEDLS_H diff --git a/src/VISUGUI/VisuGUI_Plot3DDlg.h b/src/VISUGUI/VisuGUI_Plot3DDlg.h index 230df000..84eb3ffc 100644 --- a/src/VISUGUI/VisuGUI_Plot3DDlg.h +++ b/src/VISUGUI/VisuGUI_Plot3DDlg.h @@ -108,7 +108,7 @@ 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); private: diff --git a/src/VISUGUI/VisuGUI_Prs3dTools.h b/src/VISUGUI/VisuGUI_Prs3dTools.h index fd1fa76b..61180fb1 100644 --- a/src/VISUGUI/VisuGUI_Prs3dTools.h +++ b/src/VISUGUI/VisuGUI_Prs3dTools.h @@ -197,12 +197,11 @@ namespace VISU if(aResourceMgr->booleanValue("VISU","display_only",false)){ theModule->OnEraseAll(); } - 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))) { if(aResourceMgr->booleanValue("VISU","display_only",false)){ if(SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(theModule, false)) aPlot2d->EraseAll(); } @@ -215,7 +214,8 @@ namespace VISU UpdateObjBrowser(theModule,true,theTimeStamp); QApplication::restoreOverrideCursor(); delete aDlg; - } else { + } else + { DeletePrs3d(theModule,aPrs3d,theIO); QApplication::restoreOverrideCursor(); delete aDlg; @@ -275,6 +275,7 @@ namespace VISU CreatePrs3d(theModule); } + } #endif diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx index 3060c851..8f4ac0a6 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -730,6 +730,11 @@ void VisuGUI_ScalarBarPane::updatePreview() } } +void VisuGUI_ScalarBarPane::removePreview() +{ + myPreviewCheck->hide(); +} + /*! Creating preview scalar bar */ void VisuGUI_ScalarBarPane::createScalarBar() diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.h b/src/VISUGUI/VisuGUI_ScalarBarDlg.h index 9426ba2d..839faab1 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.h +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.h @@ -148,6 +148,7 @@ class VisuGUI_ScalarBarPane : public QVBox bool check(); void deletePreview(); + void removePreview(); //remove preview button from dialog bool eventFilter (QObject* object, QEvent* event); diff --git a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx index a2b33129..865ece30 100644 --- a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx @@ -137,7 +137,7 @@ VisuGUI_ScalarMapOnDeformedShapeDlg::VisuGUI_ScalarMapOnDeformedShapeDlg (Salome GroupButtonsLayout->addWidget(buttonOk, 0, 0); GroupButtonsLayout->addItem(new QSpacerItem (5, 5, QSizePolicy::Expanding, - QSizePolicy::Minimum), 0, 1); + QSizePolicy::Minimum), 0, 1); QPushButton* buttonCancel = new QPushButton (tr("&Cancel") , GroupButtons, "buttonCancel"); buttonCancel->setAutoDefault(TRUE); @@ -155,6 +155,7 @@ VisuGUI_ScalarMapOnDeformedShapeDlg::VisuGUI_ScalarMapOnDeformedShapeDlg (Salome connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept())); connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())); + connect(myFieldsCombo, SIGNAL(activated(int)), this, SLOT(onFieldChanged(int))); connect(myTimeStampsCombo, SIGNAL(activated(int)), this, SLOT(onTimeStampChanged(int))); } diff --git a/src/VISU_I/VISU_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index 461b04f4..0e7ac28c 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -444,3 +444,10 @@ VISU::GetResult(SALOMEDS::SObject_ptr theSObject) return NULL; } +int +VISU::Prs3d_i +::GetNumberOfActors() +{ + return myActorCollection->GetNumberOfItems(); +} + diff --git a/src/VISU_I/VISU_Prs3d_i.hh b/src/VISU_I/VISU_Prs3d_i.hh index d7bf7628..df4c15db 100644 --- a/src/VISU_I/VISU_Prs3d_i.hh +++ b/src/VISU_I/VISU_Prs3d_i.hh @@ -194,6 +194,9 @@ namespace VISU void GetBounds(vtkFloatingPointType aBounds[6]); + int + GetNumberOfActors (); + void SetOffset(const CORBA::Float* theOffsets);