]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for IPAL17681 mergeto_BR_QT4_Dev_17Jan08
authorenk <enk@opencascade.com>
Mon, 14 Jan 2008 14:08:34 +0000 (14:08 +0000)
committerenk <enk@opencascade.com>
Mon, 14 Jan 2008 14:08:34 +0000 (14:08 +0000)
src/VISUGUI/VisuGUI_Prs3dDlg.cxx
src/VISUGUI/VisuGUI_Prs3dDlg.h

index 98daa46d1355aa540e3b8dcabb43a91d145db1dc..b574799518778f725371e20c08415fb4a05c99fb 100644 (file)
@@ -732,10 +732,16 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool thePreview)
 
   // Save check box ===========================================================
   QHBox* aSaveBox = new QHBox(this);
+  if (!thePreview) {
+    CBSave = new QCheckBox (tr("SAVE_DEFAULT_CHK"), aSaveBox, "CBSave");
+  }
+  else {
+    CBSave = 0;
+  }
   myTextBtn = new QPushButton("Text properties...", aSaveBox);
   myBarBtn = new QPushButton("Bar properties...", aSaveBox);
   myTextDlg = new VisuGUI_TextPrefDlg(this);
-  myTextDlg->setTitleVisible(TRUE);
+  myTextDlg->setTitleVisible(!thePreview);
   myBarDlg = new VisuGUI_BarPrefDlg(this);
 
   QGroupBox* CheckGroup = new QGroupBox("", this, "CheckGroup");
@@ -781,6 +787,140 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool thePreview)
   myBusy = false;
 }
 
+/**
+ * Stores dialog values to resources
+ */
+void VisuGUI_ScalarBarPane::storeToResources() {
+  int orient = (RBvert->isChecked())? 0 : 1;
+  float sbX1   = XSpin->value();
+  float sbY1   = YSpin->value();
+  float sbW    = WidthSpin->value();
+  float sbH    = HeightSpin->value();
+  int sbCol  = ColorSpin->value();
+  int sbLab  = LabelSpin->value();
+
+  if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
+    if(orient == 0) {
+      sbX1=0.01;
+      sbY1=0.1;
+      sbW=0.17;
+      sbH=0.8;
+    } else {
+      sbX1=0.2;
+      sbY1=0.01;
+      sbW=0.6;
+      sbH=0.12;
+    }
+  }
+
+  bool sbRange = RBIrange->isChecked();
+  float sbVmin = (float)(MinEdit->text().toDouble());
+  float sbVmax = (float)(MaxEdit->text().toDouble());
+
+  if(sbVmin > sbVmax) {
+    sbVmin=0.;
+    sbVmax=0.;
+  }
+
+  SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
+
+  aResourceMgr->setValue("VISU", "scalar_bar_orientation", orient);
+
+  QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
+
+  aResourceMgr->setValue("VISU", propertyName + "x", sbX1);
+  aResourceMgr->setValue("VISU", propertyName + "y", sbY1);
+  aResourceMgr->setValue("VISU", propertyName + "width", sbW);
+  aResourceMgr->setValue("VISU", propertyName + "height", sbH);
+
+  aResourceMgr->setValue("VISU", "scalar_bar_num_colors", sbCol);
+  aResourceMgr->setValue("VISU", "scalar_bar_num_labels", sbLab);
+
+  if(sbRange)
+    {
+      aResourceMgr->setValue("VISU", "scalar_range_type", 1);
+      aResourceMgr->setValue("VISU", "scalar_range_min" ,sbVmin);
+      aResourceMgr->setValue("VISU", "scalar_range_max" ,sbVmax);
+    }
+  else
+    aResourceMgr->setValue("VISU", "scalar_range_type", 0);
+  
+  aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic());
+  ////
+
+  if (myIsStoreTextProp) {
+    // "Title"
+    QColor aTitleColor (255, 255, 255);
+    int aTitleFontFamily = VTK_ARIAL;
+    bool isTitleBold = false;
+    bool isTitleItalic = false;
+    bool isTitleShadow = false;
+
+    myTextDlg->myTitleFont->GetData(aTitleColor, aTitleFontFamily,
+                                    isTitleBold, isTitleItalic, isTitleShadow);
+
+    QFont aTitleFont;
+    
+    aTitleFont.setBold(isTitleBold);
+    aTitleFont.setItalic(isTitleItalic);
+    aTitleFont.setUnderline(isTitleShadow);
+    
+    QString titleFontFamily;
+    switch (aTitleFontFamily) {
+    case VTK_ARIAL:
+      titleFontFamily = "Arial";
+      break;
+    case VTK_COURIER:
+      titleFontFamily = "Courier";
+      break;
+    case VTK_TIMES:
+      titleFontFamily = "Times";
+      break;
+    }
+    aTitleFont.setFamily(titleFontFamily);
+    
+    aResourceMgr->setValue("VISU", "scalar_bar_title_font", aTitleFont);
+    
+    aResourceMgr->setValue("VISU", "scalar_bar_title_color", aTitleColor);
+    
+    // "Label"
+    QColor aLabelColor (255, 255, 255);
+    int aLabelFontFamily = VTK_ARIAL;
+    bool isLabelBold = false;
+    bool isLabelItalic = false;
+    bool isLabelShadow = false;
+
+    myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
+                                    isLabelBold, isLabelItalic, isLabelShadow);
+
+
+    QFont aLabelFont;
+    
+    aLabelFont.setBold(isLabelBold);
+    aLabelFont.setItalic(isLabelItalic);
+    aLabelFont.setUnderline(isLabelShadow);
+
+    QString labelFontFamily;
+    switch (aLabelFontFamily) {
+    case VTK_ARIAL:
+      labelFontFamily = "Arial";
+      break;
+    case VTK_COURIER:
+      labelFontFamily = "Courier";
+      break;
+    case VTK_TIMES:
+      labelFontFamily = "Times";
+      break;
+    }
+
+    aLabelFont.setFamily(labelFontFamily);
+    
+    aResourceMgr->setValue("VISU", "scalar_bar_label_font", aLabelFont);
+
+    aResourceMgr->setValue("VISU", "scalar_bar_label_color", aLabelColor);
+  }
+}
 
 //----------------------------------------------------------------------------
 VisuGUI_ScalarBarPane::~VisuGUI_ScalarBarPane()
@@ -1108,6 +1248,8 @@ int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) {
   myScalarMap->SetNbColors(ColorSpin->value());
   myScalarMap->SetLabels(LabelSpin->value());
 
+  if (isToSave()) storeToResources();
+
   if (myIsStoreTextProp) {
     // "Title"
     myScalarMap->SetTitle(myTextDlg->getTitleText().latin1());
index fb30012d117d996868f2d6600327b8c744995da3..f6a17167904ffb33150ce468f2cec059ff2f89ea 100644 (file)
@@ -29,6 +29,7 @@
 #define VISUGUI_PRS3DDLG_H
 
 #include <qdialog.h>
+#include <qcheckbox.h>
 #include <qvbox.h>
 
 #include "SALOME_GenericObjPointer.hh"
@@ -176,7 +177,9 @@ class VisuGUI_ScalarBarPane : public QVBox
   int     getNbLabels();
   bool    isLogarithmic();
   void    setLogarithmic( bool on );
+  bool    isToSave() {return CBSave ? CBSave->isChecked() : false;}
 
+  void storeToResources();
   void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs);
 
   int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs);
@@ -202,6 +205,7 @@ class VisuGUI_ScalarBarPane : public QVBox
   QSpinBox*       ColorSpin;
   QSpinBox*       LabelSpin;
 
+  QCheckBox*      CBSave;
   QCheckBox*      CBLog;
   QLabel*         myModeLbl;
   QComboBox*      myModeCombo;