Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/visu.git] / src / VISUGUI / VisuGUI_OffsetDlg.cxx
index 3fca41a1d23db6973f7ec8d02551a5601f94ac12..7a28b3dccc03d7d513d2388aeb25a7a69155ecfc 100644 (file)
 #include "VISU_ViewManager_i.hh"
 #include "VISU_Actor.h"
 
+#include "LightApp_Application.h"
 #include "SalomeApp_Application.h"
 #include "SVTK_ViewWindow.h"
 #include "SVTK_ViewModel.h"
 #include "SUIT_Desktop.h"
+#include "SUIT_Session.h"
+#include "SUIT_MessageBox.h"
+#include "SUIT_ResourceMgr.h"
 
 #include "QtxDblSpinBox.h"
 
@@ -63,25 +67,25 @@ myModule(theModule)
   TopLayout->setSpacing(6);
   TopLayout->setMargin(11);
 
-  QHBox* aOffsetsPane = new QHBox (this);
-  aOffsetsPane->setSpacing(6);
+  QHBox* anOffsetsPane = new QHBox (this);
+  anOffsetsPane->setSpacing(6);
 
-  new QLabel ("dX:", aOffsetsPane);
-  myDxEdt = new QtxDblSpinBox (aOffsetsPane, "myDxEdt");
+  new QLabel ("dX:", anOffsetsPane);
+  myDxEdt = new QtxDblSpinBox (anOffsetsPane, "myDxEdt");
   myDxEdt->setRange(-MAXVAL, MAXVAL);
 
-  new QLabel("dY:", aOffsetsPane);
-  myDyEdt = new QtxDblSpinBox (aOffsetsPane, "myDyEdt");
+  new QLabel("dY:", anOffsetsPane);
+  myDyEdt = new QtxDblSpinBox (anOffsetsPane, "myDyEdt");
   myDyEdt->setRange(-MAXVAL, MAXVAL);
 
-  new QLabel("dZ:", aOffsetsPane);
-  myDzEdt = new QtxDblSpinBox (aOffsetsPane, "myDzEdt");
+  new QLabel("dZ:", anOffsetsPane);
+  myDzEdt = new QtxDblSpinBox (anOffsetsPane, "myDzEdt");
   myDzEdt->setRange(-MAXVAL, MAXVAL);
 
-  QPushButton* aResetBtn = new QPushButton(tr("BTN_RESET"), aOffsetsPane);
+  QPushButton* aResetBtn = new QPushButton(tr("BTN_RESET"), anOffsetsPane);
   connect(aResetBtn, SIGNAL(clicked()), this, SLOT(onReset()));
 
-  TopLayout->addWidget(aOffsetsPane);
+  TopLayout->addWidget(anOffsetsPane);
 
   if (!VISU::GetCStudy(VISU::GetAppStudy(theModule))->GetProperties()->IsLocked()) {
     mySaveChk = new QCheckBox ("Save to presentation", this);
@@ -115,37 +119,43 @@ myModule(theModule)
   QPushButton* buttonCancel = new QPushButton(tr("&Cancel") , GroupButtons, "buttonCancel");
   buttonCancel->setAutoDefault(TRUE);
   GroupButtonsLayout->addWidget(buttonCancel, 0, 4);
+  GroupButtonsLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 5);  
+
+  QPushButton* buttonHelp = new QPushButton(tr("&Help") , GroupButtons, "buttonHelp");
+  buttonHelp->setAutoDefault(TRUE);
+  GroupButtonsLayout->addWidget(buttonHelp, 0, 6);
 
   TopLayout->addWidget(GroupButtons);
 
   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()));
 }
 
 void VisuGUI_OffsetDlg::addPresentation (VISU::Prs3d_i* thePrs)
 {
   myPrsList.append(thePrs);
-  OffsetStruct aOffs;
-  thePrs->GetOffset(aOffs.myOffset);
-  myOldOffsets.append(aOffs);
+  CORBA::Float anOffset[3];
+  thePrs->GetOffset(anOffset[0],anOffset[1],anOffset[2]);
+  OffsetStruct anOffs(anOffset[0],anOffset[1],anOffset[2]);
+  myOldOffsets.append(anOffs);
   if (myPrsList.count() == 1) {
-    setOffset(aOffs.myOffset);
+    setOffset(anOffs.myOffset);
   } else if (myPrsList.count() == 2) {
-    float aOffset[3];
-    aOffset[0] = aOffset[1] = aOffset[2] = 0;
-    setOffset(aOffset);
+    OffsetStruct anOffs;
+    setOffset(anOffs.myOffset);
   }
 }
 
-void VisuGUI_OffsetDlg::setOffset (const float* theOffset)
+void VisuGUI_OffsetDlg::setOffset (const vtkFloatingPointType* theOffset)
 {
   myDxEdt->setValue(theOffset[0]);
   myDyEdt->setValue(theOffset[1]);
   myDzEdt->setValue(theOffset[2]);
 }
 
-void VisuGUI_OffsetDlg::getOffset (float* theOffset) const
+void VisuGUI_OffsetDlg::getOffset (vtkFloatingPointType* theOffset) const
 {
   theOffset[0] = myDxEdt->value();
   theOffset[1] = myDyEdt->value();
@@ -167,11 +177,11 @@ bool VisuGUI_OffsetDlg::isToSave() const
     return false;
 }
 
-void VisuGUI_OffsetDlg::updateOffset (VISU::Prs3d_i* thePrs, float* theOffset)
+void VisuGUI_OffsetDlg::updateOffset (VISU::Prs3d_i* thePrs, vtkFloatingPointType* theOffset)
 {
   if (myPrsList.count() == 0) return;
 
-  if (isToSave()) thePrs->SetOffset(theOffset);
+  if (isToSave()) thePrs->SetOffset(theOffset[0],theOffset[1],theOffset[2]);
 
   ViewManagerList aViewManagerList;
   SalomeApp_Application* anApp = myModule->getApp();
@@ -203,10 +213,10 @@ void VisuGUI_OffsetDlg::updateOffset (VISU::Prs3d_i* thePrs, float* theOffset)
 
 void VisuGUI_OffsetDlg::accept()
 {
-  float aOffset[3];
-  getOffset(aOffset);
+  vtkFloatingPointType anOffset[3];
+  getOffset(anOffset);
   for (int i = 0; i < myPrsList.count(); i++) {
-    updateOffset(myPrsList.at(i), aOffset);
+    updateOffset(myPrsList.at(i), anOffset);
   }
   QDialog::accept();
 }
@@ -221,9 +231,23 @@ void VisuGUI_OffsetDlg::reject()
 
 void VisuGUI_OffsetDlg::onApply()
 {
-  float aOffset[3];
-  getOffset(aOffset);
+  vtkFloatingPointType anOffset[3];
+  getOffset(anOffset);
   for (int i = 0; i < myPrsList.count(); i++) {
-    updateOffset(myPrsList.at(i), aOffset);
+    updateOffset(myPrsList.at(i), anOffset);
+  }
+}
+
+void VisuGUI_OffsetDlg::onHelp()
+{
+  QString aHelpFileName = "/files/scaling_presentations.htm";
+  LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+  if (app)
+    app->onHelpContextModule(myModule ? app->moduleName(myModule->moduleName()) : QString(""), aHelpFileName);
+  else {
+    SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
+                          QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+                          arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName),
+                          QObject::tr("BUT_OK"));
   }
 }