]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
NPAL 16841
authordmv <dmv@opencascade.com>
Wed, 21 Nov 2007 08:07:00 +0000 (08:07 +0000)
committerdmv <dmv@opencascade.com>
Wed, 21 Nov 2007 08:07:00 +0000 (08:07 +0000)
12 files changed:
src/VISUGUI/VISU_msg_en.po
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI_ActionsDef.h
src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx
src/VISUGUI/VisuGUI_DeformedShapeDlg.h
src/VISUGUI/VisuGUI_Plot3DDlg.h
src/VISUGUI/VisuGUI_Prs3dTools.h
src/VISUGUI/VisuGUI_ScalarBarDlg.cxx
src/VISUGUI/VisuGUI_ScalarBarDlg.h
src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx
src/VISU_I/VISU_Prs3d_i.cc
src/VISU_I/VISU_Prs3d_i.hh

index 56c4ca5bf5f4ccb6a405ae737a8f9dc3eb0392f8..c34c1188edf7086622c4488765e9480bc408483d 100644 (file)
@@ -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"
 
index fc85a1428c84a6c4ede917541db18c1949e14620..83868456d1f7c81c69f016cbe760bc925baa13be 100644 (file)
@@ -647,7 +647,7 @@ void
 VisuGUI::
 OnCreateDeformedShape()
 {
-  CreatePrs3d<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg,1>(this);
+  VisuGUI_DeformedShapeDlg::CreatePrs3d(this);
 }
 
 void
@@ -854,7 +854,8 @@ OnEditDeformedShape()
 {
   Handle(SALOME_InteractiveObject) anIO;
   if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
-    EditPrs3d<VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg, 1>(this, anIO, aPrs3d);
+    VisuGUI_DeformedShapeDlg::EditPrs3d(this, aPrs3d, anIO);
+  //    EditPrs3d<VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg, 1>(this, anIO, aPrs3d);
 }
 
 void
index 12ffe37793dea241ace15338a798158502aab967..0da54c95f4834efe49bca8e6c37a2d33cf99586a 100644 (file)
@@ -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
index 2eddd716fb32cda9d6999ae21ce695446a340c0d..2a6be6962cf90855581a05416dd1da236648c94b 100644 (file)
 
 #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<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();
 }
 
@@ -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<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"));
+    }
+}
index 32c10f4cc79ccc77ad7c30439f09dda8b4f8588d..3ed55d385e39b31d76940831e967da196fb6b167 100644 (file)
@@ -30,9 +30,7 @@
 #define VISUGUI_DEFORMEDSHAPEDLS_H
 
 #include "VisuGUI_ScalarBarDlg.h"
-
 #include "QtxDblSpinBox.h"
-
 #include <qdialog.h>
 #include <qgroupbox.h>
 #include <qcheckbox.h>
 #include <qpushbutton.h>
 
 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
index 230df0004e3b1bc1bf8887ed651441ee83e5e0f3..84eb3ffc9003b8d8544ad87e4360a67d0671b04c 100644 (file)
@@ -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:
index fd1fa76b3cf4d49bf9771f2a1f7385d0dd21297c..61180fb1f21eff93277c73716a98d3c026ccb423 100644 (file)
@@ -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<TPrs3d_i,SVTK_Viewer,TDlg,IsDlgModal>(theModule);
   }
+
 }
 
 #endif
index 3060c85149a94b519d8902763339b2baf60748e4..8f4ac0a6c312d93ce99fa19ecb4f1672d8131e9b 100644 (file)
@@ -730,6 +730,11 @@ void VisuGUI_ScalarBarPane::updatePreview()
   }
 }
 
+void VisuGUI_ScalarBarPane::removePreview()
+{
+  myPreviewCheck->hide();
+}
+
 /*! Creating preview scalar bar
  */
 void VisuGUI_ScalarBarPane::createScalarBar()
index 9426ba2da483a595ac7cf01e7b03a54af1c39da9..839faab135835acc4f78508b85152a4b47500ad6 100644 (file)
@@ -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);
 
index a2b331294b07150cff9620119c6e16941b7b812b..865ece3019b6fee815f58782337aef2bf50397e1 100644 (file)
@@ -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)));
 }
index 461b04f47800ea55dbaa95942c81b3d0584199aa..0e7ac28c49c37999b597a5c6ad40576ee5f247ad 100644 (file)
@@ -444,3 +444,10 @@ VISU::GetResult(SALOMEDS::SObject_ptr theSObject)
   return NULL;
 }
 
+int
+VISU::Prs3d_i
+::GetNumberOfActors()
+{
+  return myActorCollection->GetNumberOfItems();
+}
+
index d7bf76280339d94ac7700b9505b319cd272762a0..df4c15dbcc68fa15ebb7185b900d6405dab6525c 100644 (file)
@@ -194,6 +194,9 @@ namespace VISU
     void
     GetBounds(vtkFloatingPointType aBounds[6]);
 
+    int
+    GetNumberOfActors ();
+
     void
     SetOffset(const CORBA::Float* theOffsets);