#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"
/*!
* 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);
// Scalar bar pane
myScalarPane = new VisuGUI_ScalarBarPane (this, false);
myScalarPane->setMargin(5);
+ myScalarPane->removePreview();
aTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB"));
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);
// 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()));
}
myScalarPane->initFromPrsObject(thePrs);
setFactor(thePrs->GetScale());
UseMagn->setChecked(thePrs->IsColored());
+ myPrs = thePrs;
}
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<SVTK_Viewer>(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();
}
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<TPrs3d_i>(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<TPrs3d_i*>(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"));
+ }
+}