#include "VisuGUI_DeformedShapeDlg.h"
-#include "VisuGUI.h"
#include "VisuGUI_Tools.h"
#include "VisuGUI_InputPane.h"
-
+#include "VisuGUI.h"
#include "VISU_ColoredPrs3dFactory.hh"
#include "VISU_DeformedShape_i.hh"
-
+#include "VisuGUI_ViewTools.h"
+#include "VISU_Gen_i.hh"
+#include "VISU_Result_i.hh"
+#include "VisuGUI_Prs3dTools.h"
+#include "SVTK_ViewWindow.h"
#include "SalomeApp_Module.h"
#include "LightApp_Application.h"
#include "SUIT_Desktop.h"
* Constructor
*/
VisuGUI_DeformedShapeDlg::VisuGUI_DeformedShapeDlg (SalomeApp_Module* theModule)
- : VisuGUI_ScalarBarBaseDlg(theModule)
+ : VisuGUI_ScalarBarBaseDlg(theModule, true)
{
setCaption(tr("DLG_TITLE"));
setSizeGripEnabled(TRUE);
+ myModule = theModule;
QVBoxLayout* TopLayout = new QVBoxLayout (this);
TopLayout->setSpacing(6);
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()));
}
int VisuGUI_DeformedShapeDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs)
{
- if(!myInputPane->check() || !GetScalarPane()->check())
+ if( !isValid() )
return 0;
int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
void VisuGUI_DeformedShapeDlg::accept()
{
- VisuGUI_ScalarBarBaseDlg::accept();
+ VisuGUI_ScalarBarBaseDlg::done( isValid() );
}
void VisuGUI_DeformedShapeDlg::reject()
{
- VisuGUI_ScalarBarBaseDlg::reject();
+ if ( myPrsCopy->GetNumberOfActors() != 0 )
+ VisuGUI_ScalarBarBaseDlg::done( 1 );
+ else
+ VisuGUI_ScalarBarBaseDlg::reject();
}
QString VisuGUI_DeformedShapeDlg::GetContextHelpFilePath()
{
return "deformed_shape_page.html";
}
+
+bool VisuGUI_DeformedShapeDlg::onApply()
+{
+ if ( storeToPrsObject( myPrsCopy ) )
+ {
+ if ( myPrsCopy->GetNumberOfActors() == 0 ) {
+ SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
+ VisuGUI* aVisuGUI = dynamic_cast <VisuGUI*>(myModule);
+ PublishInView(aVisuGUI, myPrsCopy, aViewWindow);
+ aViewWindow->onFitAll();
+ int aPos = VISU::GetFreePositionOfDefaultScalarBar(aVisuGUI, aViewWindow);
+ VISU::AddScalarBarPosition(aVisuGUI, aViewWindow, myPrsCopy, aPos);
+ } else {
+ try {
+ myPrsCopy->UpdateActors();
+ } catch (std::runtime_error& exc) {
+ myPrsCopy->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;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Create and Edit
+////////////////////////////////////////////////////////////////////////////////
+
+void VisuGUI_DeformedShapeDlg::CreatePrs3d(VisuGUI* theModule)
+{
+ _PTR(SObject) aTimeStamp;
+ Handle(SALOME_InteractiveObject) anIO;
+ VISU::ColoredPrs3d_i::EPublishInStudyMode aPublishInStudyMode;
+
+ if (VISU::CheckTimeStamp(theModule, aTimeStamp, anIO, aPublishInStudyMode))
+ {
+ VISU::Storable::TRestoringMap aRestoringMap = VISU::Storable::GetStorableMap(aTimeStamp);
+ VISU::VISUType aType = VISU::Storable::RestoringMap2Type(aRestoringMap);
+ if ( aType == VISU::TTIMESTAMP )
+ {
+
+ QString aMeshName = aRestoringMap["myMeshName"];
+ QString anEntity = aRestoringMap["myEntityId"];
+ QString aFieldName = aRestoringMap["myFieldName"];
+ QString aTimeStampId = aRestoringMap["myTimeStampId"];
+
+ typedef VISU::DeformedShape_i TPrs3d_i;
+
+ TPrs3d_i* aPrs3d =
+ VISU::CreatePrs3dFromFactory<TPrs3d_i>(theModule,
+ aTimeStamp,
+ aMeshName.latin1(),
+ (VISU::Entity)anEntity.toInt(),
+ aFieldName.latin1(),
+ aTimeStampId.toInt(),
+ aPublishInStudyMode);
+
+ VisuGUI_DeformedShapeDlg* aDlg = new VisuGUI_DeformedShapeDlg (theModule);
+ aDlg->initFromPrsObject(aPrs3d, true);
+ VisuGUI_DialogRunner r(aDlg);
+ int dlgResult = r.run( false );
+
+ if ( dlgResult == 0 )
+ aPrs3d->RemoveFromStudy();
+ else {
+ aDlg->storeToPrsObject( aPrs3d );
+ SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>();
+ PublishInView(theModule, aPrs3d, aViewWindow);
+ aViewWindow->onFitAll();
+ int aPos = VISU::GetFreePositionOfDefaultScalarBar(theModule, aViewWindow);
+ VISU::AddScalarBarPosition(theModule, aViewWindow, aPrs3d, aPos);
+ }
+
+ 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, true);
+ VisuGUI_DialogRunner r(aDlg);
+ int dlgResult = r.run( false );
+
+ if ( dlgResult != 0 )
+ aDlg->storeToPrsObject( aPrs3d );
+
+ try {
+ aPrs3d->UpdateActors();
+ }
+ catch (std::runtime_error& exc) {
+ aPrs3d->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"));
+ }
+ delete aDlg;
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////////
+int VisuGUI_DeformedShapeDlg::isValid()
+{
+ if(myInputPane->check() && GetScalarPane()->check())
+ return 1;
+ else
+ return 0;
+}