Salome HOME
All modules must use SVTK package instead VTK
[modules/visu.git] / src / VISUGUI / VisuGUI_ScalarBarDlg.cxx
index b4a413e0f1b6c68828091719370d13884e9c7af8..6a24502f209e0062666744fa1f2d6d2094f3025b 100644 (file)
@@ -1,52 +1,54 @@
 //  VISU VISUGUI : GUI of VISU component
 //
 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
 //
 //
 //
 //  File   : VisuGUI_ScalarBarDlg.cxx
-//  Author : Laurent CORNABE & Hubert ROLLAND 
+//  Author : Laurent CORNABE & Hubert ROLLAND
 //  Module : VISU
 //  $Header$
 
-#include <limits.h>
-#include <qlayout.h>
-#include <qvalidator.h>
-#include <qcolordialog.h>
-
-#include "SUIT_MessageBox.h"
-#include "SUIT_ResourceMgr.h"
-
-#include "SalomeApp_Application.h"
+#include "VisuGUI_ScalarBarDlg.h"
 
 #include "VisuGUI.h"
+#include "VisuGUI_Tools.h"
+#include "VisuGUI_FontWg.h"
+
 #include "VISUConfig.hh"
 #include "VISU_Convertor.hxx"
 
 #include "VISU_ScalarMapPL.hxx"
 #include "VISU_ScalarMap_i.hh"
 
-#include "VisuGUI_ScalarBarDlg.h"
+#include "SalomeApp_Application.h"
 
-using namespace std;
+#include "SUIT_MessageBox.h"
+#include "SUIT_ResourceMgr.h"
+
+#include <limits.h>
+#include <qlayout.h>
+#include <qvalidator.h>
+#include <qcolordialog.h>
 
+using namespace std;
 
 
 VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref):
@@ -69,9 +71,9 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref):
   RangeGroupLayout->setAlignment( Qt::AlignTop );
   RangeGroupLayout->setSpacing( 6 );
   RangeGroupLayout->setMargin( 11 );
-  
+
   myModeLbl = new QLabel("Scalar Mode", RangeGroup);
-  
+
   myModeCombo = new QComboBox(RangeGroup);
   myModeCombo->insertItem("Modulus");
   myModeCombo->insertItem("Component 1");
@@ -80,7 +82,7 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref):
 
   CBLog = new QCheckBox (tr("LOGARITHMIC_SCALING"), RangeGroup);
   CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-  
+
   RBFrange = new QRadioButton (tr("FIELD_RANGE_BTN"), RangeGroup, "RBFrange");
   RBIrange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), RangeGroup, "RBIrange");
   RBFrange->setChecked( true );
@@ -134,7 +136,7 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref):
   LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
   LabelSpin->setMinimumWidth( 70 );
   LabelSpin->setValue( 5 );
-  
+
   ColLabGroupLayout->addWidget( ColorLabel, 0, 0);
   ColLabGroupLayout->addWidget( ColorSpin,  0, 1);
   ColLabGroupLayout->addWidget( LabelLabel, 0, 2);
@@ -157,7 +159,7 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref):
   RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), OrientGroup, "RBhori");
   OrientGroupLayout->addWidget( RBvert, 0, 0 );
   OrientGroupLayout->addWidget( RBhori, 0, 1 );
-  
+
   //  TopLayout->addWidget( OrientGroup );
 
   // Origin ===============================================================
@@ -181,7 +183,7 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref):
   YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
   YSpin->setMinimumWidth( 70 );
   YSpin->setValue( 0.01 );
-  
+
   OriginGroupLayout->addWidget( XLabel, 0, 0);
   OriginGroupLayout->addWidget( XSpin,  0, 1);
   OriginGroupLayout->addWidget( YLabel, 0, 2);
@@ -210,7 +212,7 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref):
   HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
   HeightSpin->setMinimumWidth( 70 );
   HeightSpin->setValue( 0.8 );
-  
+
   DimGroupLayout->addWidget( WidthLabel, 0, 0);
   DimGroupLayout->addWidget( WidthSpin,  0, 1);
   DimGroupLayout->addWidget( HeightLabel, 0, 2);
@@ -248,44 +250,48 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref):
  * Initializes dialog box values from resources
  */
 void VisuGUI_ScalarBarPane::initFromResources() {
-  int sbCol=64,sbLab=5,orient=1;
+  int sbCol=64,sbLab=5,orient=0;
   float sbX1=0.01,sbY1=0.1,sbW=0.1,sbH=0.8;
   float sbVmin=0., sbVmax=0.;
   bool sbRange=false;
   QString aString;
-  
+
   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
 
-  orient = aResourceMgr->integerValue("Visu:SBOrientation",orient);
-  if(orient != 1){
-    orient=0;
+  int aScalarMode = aResourceMgr->integerValue("VISU", "scalar_bar_mode", 0);
+  myModeCombo->setCurrentItem(aScalarMode);
+
+  orient = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", orient);
+  if(orient != 0){
+    orient=1;
     sbX1=0.2;
     sbY1=0.01;
     sbW=0.6;
     sbH=0.12;
   }
+  
+  QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
 
-  sbX1 = aResourceMgr->doubleValue("Visu:SBXorigin",sbX1);
-  sbY1 = aResourceMgr->doubleValue("Visu:SBYorigin",sbY1);
-
-  sbW = aResourceMgr->doubleValue("Visu:SBWidth",sbW);
-  sbH = aResourceMgr->doubleValue("Visu:SBHeight",sbH);
+  sbX1 = aResourceMgr->doubleValue("VISU", propertyName + "x", sbX1);
+  sbY1 = aResourceMgr->doubleValue("VISU", propertyName + "y", sbY1);
 
-  sbCol = aResourceMgr->integerValue("Visu:SBNumberOfColors",sbCol);
-  sbLab = aResourceMgr->integerValue("Visu:SBNumberOfLabels",sbLab);
-  sbRange = aResourceMgr->booleanValue("Visu:SBImposeRange",sbRange);
-  sbVmin = aResourceMgr->doubleValue("Visu:SBMinimumValue",sbVmin);
-  sbVmax = aResourceMgr->doubleValue("Visu:SBMaximumValue",sbVmax);
+  sbW = aResourceMgr->doubleValue("VISU", propertyName + "width", sbW);
+  sbH = aResourceMgr->doubleValue("VISU", propertyName + "height",sbH);
+  
+  sbCol = aResourceMgr->integerValue("VISU" ,"scalar_bar_num_colors", sbCol);
+  sbLab = aResourceMgr->integerValue("VISU", "scalar_bar_num_labels", sbLab);
 
-  QString aScaling = aResourceMgr->stringValue("Visu:SBMaximumValue","LINEAR");
-  if(aScaling.compare("LOGARITHMIC") == 0) 
-    setLogarithmic(true);
-  else 
-    setLogarithmic(false);
+  int rangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0);
+  if (rangeType == 1) sbRange = true;
+  sbVmin = aResourceMgr->doubleValue("VISU", "scalar_range_min", sbVmin);
+  sbVmax = aResourceMgr->doubleValue("VISU", "scalar_range_max", sbVmax);
 
-  if((sbX1 < 0.) || (sbY1 < 0.) || 
+  bool isLog = aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false);
+  setLogarithmic(isLog);
+  
+  if((sbX1 < 0.) || (sbY1 < 0.) ||
      ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
-    if(orient == 1) {
+    if(orient == 0) {
       sbX1=0.01;
       sbY1=0.1;
       sbW=0.1;
@@ -306,108 +312,74 @@ void VisuGUI_ScalarBarPane::initFromResources() {
     sbVmin=0.;
     sbVmax=0.;
   }
-  
+
   setRange( sbVmin, sbVmax, /*0.0, 0.0,*/ sbRange );
-  setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 1);
+  setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 0);
   setScalarBarData( sbCol, sbLab );
 
-  aString = aResourceMgr->stringValue("Visu:IsBoldTitle","true");
-  myTextDlg->setBoldTitle(aString.compare("true") == 0);
-
-  aString = aResourceMgr->stringValue("Visu:IsItalicTitle","true");
-  myTextDlg->setItalicTitle(aString.compare("true") == 0);
-
-  aString = aResourceMgr->stringValue("Visu:IsShadowTitle","true");
-  myTextDlg->setShadowTitle(aString.compare("true") == 0);
-
-  myTextDlg->setTitleFont(VTK_ARIAL);
-  switch(aResourceMgr->integerValue("Visu:TitFontType",0)){
-  case 0: 
-    myTextDlg->setTitleFont(VTK_ARIAL); 
-    break;
-  case 1: 
-    myTextDlg->setTitleFont(VTK_COURIER); 
-    break;
-  case 2: 
-    myTextDlg->setTitleFont(VTK_TIMES); 
-    break;
-  }
-
-  {
-    float R = aResourceMgr->doubleValue("Visu:TitleColorR",1.0);
-    if (R > 1) R = 1;
-    if (R < 0) R = 0;
-    
-    float G = aResourceMgr->doubleValue("Visu:TitleColorG",1.0);
-    if (G > 1) G = 1;
-    if (G < 0) G = 0;
-    
-    float B = aResourceMgr->doubleValue("Visu:TitleColorB",1.0);
-    if (B > 1) B = 1;
-    if (B < 0) B = 0;
-    
-    myTextDlg->setTitleColor(QColor((int)(R*255.),
-                                   (int)(G*255.),
-                                   (int)(B*255.)));
-  }
-
-  aString = aResourceMgr->stringValue("Visu:IsBoldLabel","true");
-  myTextDlg->setBoldLabel(aString.compare("true") == 0);
-
-  aString = aResourceMgr->stringValue("Visu:IsItalicLabel","true");
-  myTextDlg->setItalicLabel(aString.compare("true") == 0);
-
-  aString = aResourceMgr->stringValue("Visu:IsShadowLabel","true");
-  myTextDlg->setShadowLabel(aString.compare("true") == 0);
-
-  switch(aResourceMgr->integerValue("Visu:LblFontType",0)){
-  case 0: 
-    myTextDlg->setLabelFont(VTK_ARIAL); 
-    break;
-  case 1: 
-    myTextDlg->setLabelFont(VTK_COURIER); 
-    break;
-  case 2: 
-    myTextDlg->setLabelFont(VTK_TIMES); 
-    break;
-  }
-
-  {
-    float R = aResourceMgr->doubleValue("Visu:LabelColorR",1.0);
-    if (R > 1) R = 1;
-    if (R < 0) R = 0;
-    
-    float G = aResourceMgr->doubleValue("Visu:LabelColorG",1.0);
-    if (G > 1) G = 1;
-    if (G < 0) G = 0;
-    
-    float B = aResourceMgr->doubleValue("Visu:LabelColorB",1.0);
-    if (B > 1) B = 1;
-    if (B < 0) B = 0;
-    
-    myTextDlg->setLabelColor(QColor((int)(R*255.),
-                                   (int)(G*255.),
-                                   (int)(B*255.)));
-  }
-
+  // "Title"
+  bool isBold = false, isItalic = false, isShadow = false;
+  int aFontFamily = VTK_ARIAL;
+
+  if ( aResourceMgr->hasValue( "VISU", "scalar_bar_title_font" ) )
+    {
+      QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_title_font" );
+      
+      if ( f.family() == "Arial" )
+       aFontFamily = VTK_ARIAL;
+      else if ( f.family() == "Courier" )
+       aFontFamily = VTK_COURIER;
+      else if ( f.family() == "Times" )
+       aFontFamily = VTK_TIMES;
+      
+      isBold = f.bold();
+      isItalic = f.italic();
+      isShadow =  f.underline();
+    }
+  
+  QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
+  
+  myTextDlg->myTitleFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow);
+
+  // "Labels"
+  isBold = isItalic = isShadow = false;
+  aFontFamily = VTK_ARIAL;
+
+  if ( aResourceMgr->hasValue( "VISU", "scalar_bar_label_font" ) )
+    {
+      QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_label_font" );
+      
+      if ( f.family() == "Arial" )
+       aFontFamily = VTK_ARIAL;
+      else if ( f.family() == "Courier" )
+       aFontFamily = VTK_COURIER;
+      else if ( f.family() == "Times" )
+       aFontFamily = VTK_TIMES;
+      
+      isBold = f.bold();
+      isItalic = f.italic();
+      isShadow =  f.underline();
+    }
+  
+  aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
+  
+  myTextDlg->myLabelFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow);
 }
 
-
-
 /**
  * Stores dialog values to resources
  */
 void VisuGUI_ScalarBarPane::storeToResources() {
-  int orient = (RBvert->isChecked())? 1 : 0;
+  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 == 1) {
+    if(orient == 0) {
       sbX1=0.01;
       sbY1=0.1;
       sbW=0.17;
@@ -419,154 +391,165 @@ void VisuGUI_ScalarBarPane::storeToResources() {
       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:SBOrientation",orient);
-  aResourceMgr->setValue("Visu:SBXorigin",sbX1);
-  aResourceMgr->setValue("Visu:SBYorigin",sbY1);
-  aResourceMgr->setValue("Visu:SBWidth",sbW);
-  aResourceMgr->setValue("Visu:SBHeight",sbH);
-  aResourceMgr->setValue("Visu:SBNumberOfColors",sbCol);
-  aResourceMgr->setValue("Visu:SBNumberOfLabels",sbLab);
+  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:SBImposeRange", "true");
-  else
-    aResourceMgr->setValue("Visu:SBImposeRange", "false");
-  aResourceMgr->setValue("Visu:SBMinimumValue",sbVmin);
-  aResourceMgr->setValue("Visu:SBMaximumValue",sbVmax);
-  if(isLogarithmic())
-    aResourceMgr->setValue("Visu:SBScaling", "LOGARITHMIC");
+    {
+      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:SBScaling", "LINEAR");
-
+    aResourceMgr->setValue("VISU", "scalar_range_type", 0);
+  
+  aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic());
   ////
 
   if (myIsStoreTextProp) {
-    if (myTextDlg->isBoldTitle()) 
-      aResourceMgr->setValue("Visu:IsBoldTitle","true");
-    else
-      aResourceMgr->setValue("Visu:IsBoldTitle","false");
-    
-    if (myTextDlg->isItalicTitle()) 
-      aResourceMgr->setValue("Visu:IsItalicTitle","true");
-    else
-      aResourceMgr->setValue("Visu:IsItalicTitle","false");
+    // "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;
     
-    if (myTextDlg->isShadowTitle()) 
-      aResourceMgr->setValue("Visu:IsShadowTitle","true");
-    else
-      aResourceMgr->setValue("Visu:IsShadowTitle","false");
+    aTitleFont.setBold(isTitleBold);
+    aTitleFont.setItalic(isTitleItalic);
+    aTitleFont.setUnderline(isTitleShadow);
     
-    switch (myTextDlg->getTitleFont()) {
-    case VTK_ARIAL: 
-      aResourceMgr->setValue("Visu:TitFontType",0); 
+    QString titleFontFamily;
+    switch (aTitleFontFamily) {
+    case VTK_ARIAL:
+      titleFontFamily = "Arial";
       break;
-    case VTK_COURIER: 
-      aResourceMgr->setValue("Visu:TitFontType",1); 
+    case VTK_COURIER:
+      titleFontFamily = "Courier";
       break;
-    case VTK_TIMES: 
-      aResourceMgr->setValue("Visu:TitFontType",2); 
+    case VTK_TIMES:
+      titleFontFamily = "Times";
       break;
     }
-    QColor aColor = myTextDlg->getTitleColor();
-    aResourceMgr->setValue("Visu:TitleColorR", aColor.red()/255.);
-    aResourceMgr->setValue("Visu:TitleColorG", aColor.green()/255.);
-    aResourceMgr->setValue("Visu:TitleColorB", aColor.blue()/255.);
+    aTitleFont.setFamily(titleFontFamily);
     
-    if (myTextDlg->isBoldLabel()) 
-      aResourceMgr->setValue("Visu:IsBoldLabel","true");
-    else
-      aResourceMgr->setValue("Visu:IsBoldLabel","false");
+    aResourceMgr->setValue("VISU", "scalar_bar_title_font", aTitleFont);
     
-    if (myTextDlg->isItalicLabel()) 
-      aResourceMgr->setValue("Visu:IsItalicLabel","true");
-    else
-      aResourceMgr->setValue("Visu:IsItalicLabel","false");
+    aResourceMgr->setValue("VISU", "scalar_bar_title_color", aTitleColor);
     
-    if (myTextDlg->isShadowLabel()) 
-      aResourceMgr->setValue("Visu:IsShadowLabel","true");
-    else
-      aResourceMgr->setValue("Visu:IsShadowLabel","false");
+    // "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;
     
-    switch (myTextDlg->getLabelFont()) {
-    case VTK_ARIAL: 
-      aResourceMgr->setValue("Visu:LblFontType",0); 
+    aLabelFont.setBold(isLabelBold);
+    aLabelFont.setItalic(isLabelItalic);
+    aLabelFont.setUnderline(isLabelShadow);
+
+    QString labelFontFamily;
+    switch (aLabelFontFamily) {
+    case VTK_ARIAL:
+      labelFontFamily = "Arial";
       break;
-    case VTK_COURIER: 
-      aResourceMgr->setValue("Visu:LblFontType",1); 
+    case VTK_COURIER:
+      labelFontFamily = "Courier";
       break;
-    case VTK_TIMES: 
-      aResourceMgr->setValue("Visu:LblFontType",2); 
+    case VTK_TIMES:
+      labelFontFamily = "Times";
       break;
     }
-    aColor = myTextDlg->getLabelColor();
-    aResourceMgr->setValue("Visu:LabelColorR", aColor.red()/255.);
-    aResourceMgr->setValue("Visu:LabelColorG", aColor.green()/255.);
-    aResourceMgr->setValue("Visu:LabelColorB", aColor.blue()/255.);
+
+    aLabelFont.setFamily(labelFontFamily);
+    
+    aResourceMgr->setValue("VISU", "scalar_bar_label_font", aLabelFont);
+
+    aResourceMgr->setValue("VISU", "scalar_bar_label_color", aLabelColor);
   }
 }
 
-
 /**
  * Initialise dialog box from presentation object
  */
 void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ScalarMap_i* thePrs) {
   initFromResources();
   myModeCombo->setCurrentItem(thePrs->GetScalarMode());
-  setPosAndSize( thePrs->GetPosX(), 
-                thePrs->GetPosY(), 
-                thePrs->GetWidth(), 
-                thePrs->GetHeight(), 
+  setPosAndSize( thePrs->GetPosX(),
+                thePrs->GetPosY(),
+                thePrs->GetWidth(),
+                thePrs->GetHeight(),
                 thePrs->GetBarOrientation());
   switch(thePrs->GetScaling()){
-  case VISU::LOGARITHMIC : 
+  case VISU::LOGARITHMIC :
     setLogarithmic(true);
     break;
-  default:  
+  default:
     setLogarithmic(false);
   }
   float aRange[2];
   thePrs->GetScalarMapPL()->GetSourceRange(aRange);
   Rmin = aRange[0]; Rmax = aRange[1];
-  setRange( thePrs->GetMin(), thePrs->GetMax(), 
+  setRange( thePrs->GetMin(), thePrs->GetMax(),
            /*0.0, 0.0,*/ thePrs->IsRangeFixed() );
   setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() );
   bool isScalarMode = (thePrs->GetField()->myNbComp > 1);
   myModeLbl->setEnabled(isScalarMode);
   myModeCombo->setEnabled(isScalarMode);
 
+  // "Title"
   myTextDlg->setTitleText(QString(thePrs->GetTitle()));
 
-  myTextDlg->setBoldTitle(thePrs->IsBoldTitle());
-  myTextDlg->setItalicTitle(thePrs->IsItalicTitle());
-  myTextDlg->setShadowTitle(thePrs->IsShadowTitle());
-  myTextDlg->setTitleFont(thePrs->GetTitFontType());
   float R, G, B;
   thePrs->GetTitleColor(&R, &G, &B);
-  myTextDlg->setTitleColor(QColor((int)(R*255.),
-                                 (int)(G*255.),
-                                 (int)(B*255.)));
-
-  myTextDlg->setBoldLabel(thePrs->IsBoldLabel());
-  myTextDlg->setItalicLabel(thePrs->IsItalicLabel());
-  myTextDlg->setShadowLabel(thePrs->IsShadowLabel());
-  myTextDlg->setLabelFont(thePrs->GetLblFontType());
+
+  myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
+                                  thePrs->GetTitFontType(),
+                                  thePrs->IsBoldTitle(),
+                                  thePrs->IsItalicTitle(),
+                                  thePrs->IsShadowTitle());
+
+  // "Labels"
   thePrs->GetLabelColor(&R, &G, &B);
-  myTextDlg->setLabelColor(QColor((int)(R*255.),
-                                 (int)(G*255.),
-                                 (int)(B*255.)));
-}
 
+  myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
+                                  thePrs->GetLblFontType(),
+                                  thePrs->IsBoldLabel(),
+                                  thePrs->IsItalicLabel(),
+                                  thePrs->IsShadowLabel());
+}
 
 /**
  * Store values to presentation object
@@ -576,8 +559,8 @@ int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ScalarMap_i* thePrs) {
   thePrs->SetPosition(XSpin->value(), YSpin->value());
   thePrs->SetSize(WidthSpin->value(), HeightSpin->value());
   thePrs->SetBarOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
-  if(isLogarithmic()) 
-    thePrs->SetScaling(VISU::LOGARITHMIC); 
+  if(isLogarithmic())
+    thePrs->SetScaling(VISU::LOGARITHMIC);
   else
     thePrs->SetScaling(VISU::LINEAR);
 
@@ -585,39 +568,55 @@ int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ScalarMap_i* thePrs) {
     thePrs->SetSourceRange();
   } else {
     thePrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
-  }    
+  }
   thePrs->SetNbColors(ColorSpin->value());
   thePrs->SetLabels(LabelSpin->value());
-   
+
   if (isToSave()) storeToResources();
 
   if (myIsStoreTextProp) {
+    // "Title"
     thePrs->SetTitle(myTextDlg->getTitleText().latin1());
 
-    thePrs->SetBoldTitle(myTextDlg->isBoldTitle());
-    thePrs->SetItalicTitle(myTextDlg->isItalicTitle());
-    thePrs->SetShadowTitle(myTextDlg->isShadowTitle());
-    thePrs->SetTitFontType(myTextDlg->getTitleFont());
-    QColor aTitColor = myTextDlg->getTitleColor();
-    thePrs->SetTitleColor(aTitColor.red()/255., 
+    QColor aTitColor (255, 255, 255);
+    int aTitleFontFamily = VTK_ARIAL;
+    bool isTitleBold = false;
+    bool isTitleItalic = false;
+    bool isTitleShadow = false;
+
+    myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily,
+                                    isTitleBold, isTitleItalic, isTitleShadow);
+
+    thePrs->SetBoldTitle(isTitleBold);
+    thePrs->SetItalicTitle(isTitleItalic);
+    thePrs->SetShadowTitle(isTitleShadow);
+    thePrs->SetTitFontType(aTitleFontFamily);
+    thePrs->SetTitleColor(aTitColor.red()/255.,
                          aTitColor.green()/255.,
                          aTitColor.blue()/255.);
 
-    thePrs->SetBoldLabel(myTextDlg->isBoldLabel());
-    thePrs->SetItalicLabel(myTextDlg->isItalicLabel());
-    thePrs->SetShadowLabel(myTextDlg->isShadowLabel());
-    thePrs->SetLblFontType(myTextDlg->getLabelFont());
-    QColor aLblColor = myTextDlg->getLabelColor();
-    thePrs->SetLabelColor(aLblColor.red()/255., 
+    // "Label"
+    QColor aLblColor (255, 255, 255);
+    int aLabelFontFamily = VTK_ARIAL;
+    bool isLabelBold = false;
+    bool isLabelItalic = false;
+    bool isLabelShadow = false;
+
+    myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily,
+                                    isLabelBold, isLabelItalic, isLabelShadow);
+
+    thePrs->SetBoldLabel(isLabelBold);
+    thePrs->SetItalicLabel(isLabelItalic);
+    thePrs->SetShadowLabel(isLabelShadow);
+    thePrs->SetLblFontType(aLabelFontFamily);
+    thePrs->SetLabelColor(aLblColor.red()/255.,
                          aLblColor.green()/255.,
                          aLblColor.blue()/255.);
   }
-  
+
   return 1;
 }
 
-
-
 /*!
   Called when orientation is changed
 */
@@ -647,11 +646,11 @@ void VisuGUI_ScalarBarPane::changeRange( int )
     mode = 0;
   if ( RBIrange->isChecked() )
     mode = 1;
-  if ( myRangeMode == mode ) 
+  if ( myRangeMode == mode )
     return;
   //MinSpin->setMaxValue( Fmin );
   //MaxSpin->setMinValue( Fmax );
-  if ( RBFrange->isChecked() ) { 
+  if ( RBFrange->isChecked() ) {
     //MinLabel->setEnabled( false );
     MinEdit->setEnabled( false );
     //MaxLabel->setEnabled( false );
@@ -735,7 +734,7 @@ void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double
 /*!
   Sets colors and labels number
 */
-void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels ) 
+void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels )
 {
   ColorSpin->setValue( colors );
   LabelSpin->setValue( labels );
@@ -744,7 +743,7 @@ void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels )
 /*!
   Gets orientation
 */
-int  VisuGUI_ScalarBarPane::getOrientation() 
+int  VisuGUI_ScalarBarPane::getOrientation()
 {
   if (RBvert->isChecked() )
     return  1;
@@ -752,8 +751,6 @@ int  VisuGUI_ScalarBarPane::getOrientation()
     return 0;
 }
 
-
-
 /*!
   Called when <OK> button is clicked, validates data and closes dialog
 */
@@ -803,23 +800,20 @@ bool VisuGUI_ScalarBarPane::check()
   return true;
 }
 
-
-void VisuGUI_ScalarBarPane::onTextPref() {
+void VisuGUI_ScalarBarPane::onTextPref()
+{
   myIsStoreTextProp = myTextDlg->exec();
 }
 
 
-
-
-
 //#######################################################################################
 
-
 /*!
   Constructor
 */
-VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (QWidget* parent, bool SetPref)
-    : QDialog(parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
+VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool SetPref)
+    : QDialog(VISU::GetDesktop(theModule), 0, true,
+              WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
 {
   setName("VisuGUI_ScalarBarDlg");
   setCaption(SetPref ? tr("DLG_PREF_TITLE") : tr("DLG_PROP_TITLE"));
@@ -854,13 +848,10 @@ VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (QWidget* parent, bool SetPref)
 
   TopLayout->addWidget( GroupButtons );
 
-  connect( buttonOk,     SIGNAL( clicked() ),      this, SLOT( accept() ) );
-  connect( buttonCancel, SIGNAL( clicked() ),      this, SLOT( reject() ) );
-
+  connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
+  connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
 }
 
-
-
 /*!
   Called when <OK> button is clicked, validates data and closes dialog
 */
@@ -870,89 +861,40 @@ void VisuGUI_ScalarBarDlg::accept()
 }
 
 
-
-
-
 //#######################################################################################
-
-
-
-
-
-VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg(QWidget* parent) :
-  QDialog(parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent)
+  : QDialog(parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
 {
-  setName( "VisuGUI_TextPrefDlg" );
-  setCaption( tr("TIT_TEXT_PREF") );
-  setSizeGripEnabled( TRUE );
-  
+  setName("VisuGUI_TextPrefDlg");
+  setCaption(tr("TIT_TEXT_PREF"));
+  setSizeGripEnabled(TRUE);
+
   QVBoxLayout* TopLayout = new QVBoxLayout(this);
   TopLayout->setSpacing(6);
   TopLayout->setMargin(11);
 
-  QGroupBox* aTitleGrp = new QGroupBox( this );
-  aTitleGrp->setTitle(tr("LBL_TITLE"));
-  aTitleGrp->setColumnLayout(0, Qt::Vertical );
-  QGridLayout* aTitleLayout = new QGridLayout( aTitleGrp->layout() );
-  aTitleLayout->setSpacing( 6 );
-  aTitleLayout->setMargin( 3 );
-
-  myTitleEdt = new QLineEdit(aTitleGrp);
-  aTitleLayout->addMultiCellWidget(myTitleEdt, 0, 0, 0, 4);
-
-  QStrList aFontsLst;
-  aFontsLst.append("Arial");
-  aFontsLst.append("Courier");
-  aFontsLst.append("Times");
-
-  myTitColor = new QToolButton(aTitleGrp);
-  myTitColor->setUsesTextLabel(true);
-  myTitColor->setTextLabel("  ");
-  connect( myTitColor, SIGNAL(clicked()), this, SLOT(setTitleColor()) );
-  aTitleLayout->addWidget(myTitColor, 1, 0);
-
-  myTitFontCombo = new QComboBox(aTitleGrp);
-  myTitFontCombo->insertStrList(aFontsLst);
-  aTitleLayout->addWidget(myTitFontCombo, 1, 1);
-  
-  myTitBoldChk = new QCheckBox(tr("LBL_BOLD"), aTitleGrp);
-  aTitleLayout->addWidget(myTitBoldChk, 1, 2);
-
-  myTitItalicChk = new QCheckBox(tr("LBL_ITALIC"), aTitleGrp);
-  aTitleLayout->addWidget(myTitItalicChk, 1, 3);
-
-  myTitShadowChk = new QCheckBox(tr("LBL_SHADOW"), aTitleGrp);
-  aTitleLayout->addWidget(myTitShadowChk, 1, 4);
-
-  TopLayout->addWidget( aTitleGrp );
+  // "Title" grp
+  QGroupBox* aTitleGrp = new QGroupBox (2, Qt::Vertical, tr("LBL_TITLE"), this);
 
-  QGroupBox* aLabelsGrp = new QGroupBox( this );
-  aLabelsGrp->setTitle(tr("LBL_LABELS"));
-  aLabelsGrp->setColumnLayout(0, Qt::Vertical );
-  QGridLayout* aLabelLayout = new QGridLayout( aLabelsGrp->layout() );
-  aLabelLayout->setSpacing( 6 );
-  aLabelLayout->setMargin( 3 );
+  //   edit line
+  myTitleEdt = new QLineEdit (aTitleGrp);
 
-  myLblColor = new QToolButton(aLabelsGrp);
-  myLblColor->setUsesTextLabel(true);
-  myLblColor->setTextLabel("  ");
-  connect( myLblColor, SIGNAL(clicked()), this, SLOT(setLabelColor()) );
-  aLabelLayout->addWidget(myLblColor, 0, 0);
+  //   font
+  QHBox* aHBox = new QHBox (aTitleGrp);
+  aHBox->setSpacing(5);
+  myTitleFont = new VisuGUI_FontWg (aHBox);
 
-  myLblFontCombo = new QComboBox(aLabelsGrp);
-  myLblFontCombo->insertStrList(aFontsLst);
-  aLabelLayout->addWidget(myLblFontCombo, 0, 1);
-  
-  myLblBoldChk = new QCheckBox(tr("LBL_BOLD"), aLabelsGrp);
-  aLabelLayout->addWidget(myLblBoldChk, 0, 2);
+  TopLayout->addWidget(aTitleGrp);
 
-  myLblItalicChk = new QCheckBox(tr("LBL_ITALIC"), aLabelsGrp);
-  aLabelLayout->addWidget(myLblItalicChk, 0, 3);
+  // "Labels" grp
+  QGroupBox* aLabelsGrp = new QGroupBox (1, Qt::Vertical, tr("LBL_LABELS"), this);
 
-  myLblShadowChk = new QCheckBox(tr("LBL_SHADOW"), aLabelsGrp);
-  aLabelLayout->addWidget(myLblShadowChk, 0, 4);
+  //   font
+  aHBox = new QHBox (aLabelsGrp);
+  aHBox->setSpacing(5);
+  myLabelFont = new VisuGUI_FontWg (aHBox);
 
-  TopLayout->addWidget( aLabelsGrp );
+  TopLayout->addWidget(aLabelsGrp);
 
   // Common buttons ===========================================================
   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
@@ -976,49 +918,6 @@ VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg(QWidget* parent) :
 
   TopLayout->addWidget( GroupButtons );
 
-  connect( buttonOk,     SIGNAL( clicked() ),      this, SLOT( accept() ) );
-  connect( buttonCancel, SIGNAL( clicked() ),      this, SLOT( reject() ) );
-}
-
-
-void VisuGUI_TextPrefDlg::setTitleColor() {
-  QColor aColor = QColorDialog::getColor( getTitleColor(), this );
-  if (aColor.isValid()) setTitleColor(aColor);
-}
-
-void VisuGUI_TextPrefDlg::setLabelColor() {
-  QColor aColor = QColorDialog::getColor( getLabelColor(), this );
-  if (aColor.isValid()) setLabelColor(aColor);
-}
-
-
-
-#define GETFONT(FuncName, Control) \
-int VisuGUI_TextPrefDlg::FuncName() \
-{ \
-  switch (Control->currentItem()) { \
-  case 0: return VTK_ARIAL; \
-  case 1: return VTK_COURIER; \
-  case 2: return VTK_TIMES; \
-  } \
-  return VTK_ARIAL; \
+  connect(buttonOk,     SIGNAL(clicked()), this, SLOT(accept()));
+  connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
 }
-
-#define SETFONT(FuncName, Control) \
-void VisuGUI_TextPrefDlg::FuncName(int theFont) \
-{ \
-  switch (theFont) { \
-  case VTK_ARIAL: Control->setCurrentItem(0); break; \
-  case VTK_COURIER: Control->setCurrentItem(1); break; \
-  case VTK_TIMES: Control->setCurrentItem(2); break; \
-  } \
-}
-
-GETFONT(getTitleFont, myTitFontCombo);
-SETFONT(setTitleFont, myTitFontCombo);
-
-GETFONT(getLabelFont, myLblFontCombo);
-SETFONT(setLabelFont, myLblFontCombo);
-
-#undef GETFONT
-#undef SETFONT