From b5623e123e33f275b030650ef87da5fd15dfa963 Mon Sep 17 00:00:00 2001 From: enk Date: Mon, 14 Jan 2008 14:08:34 +0000 Subject: [PATCH] Fix for IPAL17681 --- src/VISUGUI/VisuGUI_Prs3dDlg.cxx | 144 ++++++++++++++++++++++++++++++- src/VISUGUI/VisuGUI_Prs3dDlg.h | 4 + 2 files changed, 147 insertions(+), 1 deletion(-) diff --git a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx index 98daa46d..b5747995 100644 --- a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx +++ b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx @@ -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()); diff --git a/src/VISUGUI/VisuGUI_Prs3dDlg.h b/src/VISUGUI/VisuGUI_Prs3dDlg.h index fb30012d..f6a17167 100644 --- a/src/VISUGUI/VisuGUI_Prs3dDlg.h +++ b/src/VISUGUI/VisuGUI_Prs3dDlg.h @@ -29,6 +29,7 @@ #define VISUGUI_PRS3DDLG_H #include +#include #include #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; -- 2.39.2