From: jfa Date: Thu, 21 Jul 2005 05:54:03 +0000 (+0000) Subject: IPAL9528: small size of Select Color buttons X-Git-Tag: V3_0_1~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d8530e7cb2711307d3d46871d16043620c931bc3;p=modules%2Fvisu.git IPAL9528: small size of Select Color buttons --- diff --git a/src/VISUGUI/VisuGUI_FontWg.cxx b/src/VISUGUI/VisuGUI_FontWg.cxx index b8a0d434..78d62a1c 100755 --- a/src/VISUGUI/VisuGUI_FontWg.cxx +++ b/src/VISUGUI/VisuGUI_FontWg.cxx @@ -48,6 +48,7 @@ VisuGUI_FontWg::VisuGUI_FontWg( QWidget* theParent ) { setSpacing( 5 ); myColorBtn = new QToolButton( this ); + myColorBtn->setMinimumWidth( 20 ); myFamily = new QComboBox( this ); myFamily->insertItem( tr( "ARIAL" ) ); diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx index b4a413e0..bee38dc5 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -1,52 +1,53 @@ // 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 -#include -#include -#include - -#include "SUIT_MessageBox.h" -#include "SUIT_ResourceMgr.h" - -#include "SalomeApp_Application.h" +#include "VisuGUI_ScalarBarDlg.h" #include "VisuGUI.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 +#include +#include +#include + +using namespace std; VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref): @@ -69,9 +70,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 +81,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 +135,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 +158,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 +182,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 +211,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); @@ -253,7 +254,7 @@ void VisuGUI_ScalarBarPane::initFromResources() { float sbVmin=0., sbVmax=0.; bool sbRange=false; QString aString; - + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); orient = aResourceMgr->integerValue("Visu:SBOrientation",orient); @@ -278,12 +279,12 @@ void VisuGUI_ScalarBarPane::initFromResources() { sbVmax = aResourceMgr->doubleValue("Visu:SBMaximumValue",sbVmax); QString aScaling = aResourceMgr->stringValue("Visu:SBMaximumValue","LINEAR"); - if(aScaling.compare("LOGARITHMIC") == 0) + if(aScaling.compare("LOGARITHMIC") == 0) setLogarithmic(true); - else + else setLogarithmic(false); - if((sbX1 < 0.) || (sbY1 < 0.) || + if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) { if(orient == 1) { sbX1=0.01; @@ -306,93 +307,81 @@ void VisuGUI_ScalarBarPane::initFromResources() { sbVmin=0.; sbVmax=0.; } - + setRange( sbVmin, sbVmax, /*0.0, 0.0,*/ sbRange ); setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 1); setScalarBarData( sbCol, sbLab ); + // "Title" aString = aResourceMgr->stringValue("Visu:IsBoldTitle","true"); - myTextDlg->setBoldTitle(aString.compare("true") == 0); - + bool isBold = (aString.compare("true") == 0); aString = aResourceMgr->stringValue("Visu:IsItalicTitle","true"); - myTextDlg->setItalicTitle(aString.compare("true") == 0); - + bool isItalic = (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; + bool isShadow = (aString.compare("true") == 0); + + int aFontType = aResourceMgr->integerValue("Visu:TitFontType",0); + int aFontFamily = VTK_ARIAL; + switch (aFontType) { + case 0: + aFontFamily = VTK_ARIAL; break; + case 1: + aFontFamily = VTK_COURIER; break; + case 2: + aFontFamily = 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.))); - } + float R = aResourceMgr->doubleValue("Visu:TitleColorR",1.0); + if (R > 1) R = 1; + if (R < 0) R = 0; - aString = aResourceMgr->stringValue("Visu:IsBoldLabel","true"); - myTextDlg->setBoldLabel(aString.compare("true") == 0); + float G = aResourceMgr->doubleValue("Visu:TitleColorG",1.0); + if (G > 1) G = 1; + if (G < 0) G = 0; - aString = aResourceMgr->stringValue("Visu:IsItalicLabel","true"); - myTextDlg->setItalicLabel(aString.compare("true") == 0); + float B = aResourceMgr->doubleValue("Visu:TitleColorB",1.0); + if (B > 1) B = 1; + if (B < 0) B = 0; - aString = aResourceMgr->stringValue("Visu:IsShadowLabel","true"); - myTextDlg->setShadowLabel(aString.compare("true") == 0); + myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)), + aFontFamily, + isBold, isItalic, isShadow); - 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; + // "Labels" + aString = aResourceMgr->stringValue("Visu:IsBoldLabel","true"); + isBold = (aString.compare("true") == 0); + aString = aResourceMgr->stringValue("Visu:IsItalicLabel","true"); + isItalic = (aString.compare("true") == 0); + aString = aResourceMgr->stringValue("Visu:IsShadowLabel","true"); + isShadow = (aString.compare("true") == 0); + + aFontType = aResourceMgr->integerValue("Visu:LblFontType",0); + aFontFamily = VTK_ARIAL; + switch (aFontType) { + case 0: + aFontFamily = VTK_ARIAL; break; + case 1: + aFontFamily = VTK_COURIER; break; + case 2: + aFontFamily = 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.))); - } + R = aResourceMgr->doubleValue("Visu:LabelColorR",1.0); + if (R > 1) R = 1; + if (R < 0) R = 0; -} + G = aResourceMgr->doubleValue("Visu:LabelColorG",1.0); + if (G > 1) G = 1; + if (G < 0) G = 0; + B = aResourceMgr->doubleValue("Visu:LabelColorB",1.0); + if (B > 1) B = 1; + if (B < 0) B = 0; + myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)), + aFontFamily, + isBold, isItalic, isShadow); +} /** * Stores dialog values to resources @@ -405,7 +394,7 @@ void VisuGUI_ScalarBarPane::storeToResources() { 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) { sbX1=0.01; @@ -419,16 +408,16 @@ 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); @@ -452,121 +441,137 @@ void VisuGUI_ScalarBarPane::storeToResources() { //// if (myIsStoreTextProp) { - if (myTextDlg->isBoldTitle()) + // "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); + + if (isTitleBold) aResourceMgr->setValue("Visu:IsBoldTitle","true"); else aResourceMgr->setValue("Visu:IsBoldTitle","false"); - - if (myTextDlg->isItalicTitle()) + + if (isTitleItalic) aResourceMgr->setValue("Visu:IsItalicTitle","true"); else aResourceMgr->setValue("Visu:IsItalicTitle","false"); - - if (myTextDlg->isShadowTitle()) + + if (isTitleShadow) aResourceMgr->setValue("Visu:IsShadowTitle","true"); else aResourceMgr->setValue("Visu:IsShadowTitle","false"); - - switch (myTextDlg->getTitleFont()) { - case VTK_ARIAL: - aResourceMgr->setValue("Visu:TitFontType",0); + + switch (aTitleFontFamily) { + case VTK_ARIAL: + aResourceMgr->setValue("Visu:TitFontType",0); break; - case VTK_COURIER: - aResourceMgr->setValue("Visu:TitFontType",1); + case VTK_COURIER: + aResourceMgr->setValue("Visu:TitFontType",1); break; - case VTK_TIMES: - aResourceMgr->setValue("Visu:TitFontType",2); + case VTK_TIMES: + aResourceMgr->setValue("Visu:TitFontType",2); 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.); - - if (myTextDlg->isBoldLabel()) + aResourceMgr->setValue("Visu:TitleColorR", aTitleColor.red()/255.); + aResourceMgr->setValue("Visu:TitleColorG", aTitleColor.green()/255.); + aResourceMgr->setValue("Visu:TitleColorB", aTitleColor.blue()/255.); + + // "Label" + QColor aLabelColor (255, 255, 255); + int aLabelFontFamily = VTK_ARIAL; + bool isLabelBold = false; + bool isLabelItalic = false; + bool isLabelShadow = false; + + myTextDlg->myTitleFont->GetData(aLabelColor, aLabelFontFamily, + isLabelBold, isLabelItalic, isLabelShadow); + + if (isLabelBold) aResourceMgr->setValue("Visu:IsBoldLabel","true"); else aResourceMgr->setValue("Visu:IsBoldLabel","false"); - - if (myTextDlg->isItalicLabel()) + + if (isLabelItalic) aResourceMgr->setValue("Visu:IsItalicLabel","true"); else aResourceMgr->setValue("Visu:IsItalicLabel","false"); - - if (myTextDlg->isShadowLabel()) + + if (isLabelShadow) aResourceMgr->setValue("Visu:IsShadowLabel","true"); else aResourceMgr->setValue("Visu:IsShadowLabel","false"); - - switch (myTextDlg->getLabelFont()) { - case VTK_ARIAL: - aResourceMgr->setValue("Visu:LblFontType",0); + + switch (aLabelFontFamily) { + case VTK_ARIAL: + aResourceMgr->setValue("Visu:LblFontType",0); break; - case VTK_COURIER: - aResourceMgr->setValue("Visu:LblFontType",1); + case VTK_COURIER: + aResourceMgr->setValue("Visu:LblFontType",1); break; - case VTK_TIMES: - aResourceMgr->setValue("Visu:LblFontType",2); + case VTK_TIMES: + aResourceMgr->setValue("Visu:LblFontType",2); 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.); + aResourceMgr->setValue("Visu:LabelColorR", aLabelColor.red()/255.); + aResourceMgr->setValue("Visu:LabelColorG", aLabelColor.green()/255.); + aResourceMgr->setValue("Visu:LabelColorB", aLabelColor.blue()/255.); } } - /** * 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 +581,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 +590,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 +668,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 +756,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 +765,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 +773,6 @@ int VisuGUI_ScalarBarPane::getOrientation() return 0; } - - /*! Called when button is clicked, validates data and closes dialog */ @@ -803,18 +822,14 @@ bool VisuGUI_ScalarBarPane::check() return true; } - -void VisuGUI_ScalarBarPane::onTextPref() { +void VisuGUI_ScalarBarPane::onTextPref() +{ myIsStoreTextProp = myTextDlg->exec(); } - - - //####################################################################################### - /*! Constructor */ @@ -854,13 +869,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 button is clicked, validates data and closes dialog */ @@ -870,89 +882,40 @@ void VisuGUI_ScalarBarDlg::accept() } +//####################################################################################### +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); + QVBoxLayout* TopLayout = new QVBoxLayout(this); + TopLayout->setSpacing(6); + TopLayout->setMargin(11); + // "Title" grp + QGroupBox* aTitleGrp = new QGroupBox (2, Qt::Vertical, tr("LBL_TITLE"), this); -//####################################################################################### - + // edit line + myTitleEdt = new QLineEdit (aTitleGrp); + // font + QHBox* aHBox = new QHBox (aTitleGrp); + aHBox->setSpacing(5); + myTitleFont = new VisuGUI_FontWg (aHBox); + TopLayout->addWidget(aTitleGrp); + // "Labels" grp + QGroupBox* aLabelsGrp = new QGroupBox (1, Qt::Vertical, tr("LBL_LABELS"), this); -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 ); - - QVBoxLayout* TopLayout = new QVBoxLayout(this); - TopLayout->setSpacing(6); - TopLayout->setMargin(11); + // font + aHBox = new QHBox (aLabelsGrp); + aHBox->setSpacing(5); + myLabelFont = new VisuGUI_FontWg (aHBox); - 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 ); - - 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 ); - - myLblColor = new QToolButton(aLabelsGrp); - myLblColor->setUsesTextLabel(true); - myLblColor->setTextLabel(" "); - connect( myLblColor, SIGNAL(clicked()), this, SLOT(setLabelColor()) ); - aLabelLayout->addWidget(myLblColor, 0, 0); - - myLblFontCombo = new QComboBox(aLabelsGrp); - myLblFontCombo->insertStrList(aFontsLst); - aLabelLayout->addWidget(myLblFontCombo, 0, 1); - - myLblBoldChk = new QCheckBox(tr("LBL_BOLD"), aLabelsGrp); - aLabelLayout->addWidget(myLblBoldChk, 0, 2); - - myLblItalicChk = new QCheckBox(tr("LBL_ITALIC"), aLabelsGrp); - aLabelLayout->addWidget(myLblItalicChk, 0, 3); - - myLblShadowChk = new QCheckBox(tr("LBL_SHADOW"), aLabelsGrp); - aLabelLayout->addWidget(myLblShadowChk, 0, 4); - - TopLayout->addWidget( aLabelsGrp ); + TopLayout->addWidget(aLabelsGrp); // Common buttons =========================================================== QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); @@ -976,49 +939,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); + connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); } - -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; \ -} - -#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 diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.h b/src/VISUGUI/VisuGUI_ScalarBarDlg.h index 6e23c913..ad8f4f18 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.h +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.h @@ -1,34 +1,35 @@ // 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.h -// Author : Laurent CORNABE & Hubert ROLLAND +// Author : Laurent CORNABE & Hubert ROLLAND // Module : VISU // $Header$ #ifndef VISUGUI_SCALARBARDLG_H #define VISUGUI_SCALARBARDLG_H +#include #include #include #include @@ -43,6 +44,8 @@ #include "QtxDblSpinBox.h" +#include "VISU_ScalarMap_i.hh" + class QButtonGroup; class QGroupBox; class QLabel; @@ -57,72 +60,28 @@ class QToolButton; class QtxDblSpinBox; -#include - -#include "VISU_ScalarMap_i.hh" +class VisuGUI_FontWg; -class VisuGUI_TextPrefDlg: public QDialog +class VisuGUI_TextPrefDlg: public QDialog { Q_OBJECT; -public: - VisuGUI_TextPrefDlg(QWidget* parent); - ~VisuGUI_TextPrefDlg() {}; - - bool isBoldTitle() { return myTitBoldChk->isChecked();} - void setBoldTitle(bool isBold) { myTitBoldChk->setChecked(isBold);} - - bool isItalicTitle() { return myTitItalicChk->isChecked();} - void setItalicTitle(bool isItalic) { myTitItalicChk->setChecked(isItalic);} - - bool isShadowTitle() { return myTitShadowChk->isChecked();} - void setShadowTitle(bool isShadow) { myTitShadowChk->setChecked(isShadow);} - - QString getTitleText() { return myTitleEdt->text();} - void setTitleText(QString theText) { myTitleEdt->setText(theText);} + public: + VisuGUI_TextPrefDlg (QWidget* parent); + ~VisuGUI_TextPrefDlg() {}; - QColor getTitleColor() { return myTitColor->paletteBackgroundColor();} - void setTitleColor(QColor theColor) { myTitColor->setPaletteBackgroundColor(theColor);} + QString getTitleText() { return myTitleEdt->text(); } + void setTitleText(QString theText) { myTitleEdt->setText(theText); } - int getTitleFont(); - void setTitleFont(int theFont); + void setTitleVisible (bool isVisible) + { (isVisible)? myTitleEdt->show() : myTitleEdt->hide(); } - - bool isBoldLabel() { return myLblBoldChk->isChecked();} - void setBoldLabel(bool isBold) { myLblBoldChk->setChecked(isBold);} - - bool isItalicLabel() { return myLblItalicChk->isChecked();} - void setItalicLabel(bool isItalic) { myLblItalicChk->setChecked(isItalic);} - - bool isShadowLabel() { return myLblShadowChk->isChecked();} - void setShadowLabel(bool isShadow) { myLblShadowChk->setChecked(isShadow);} - - QColor getLabelColor() { return myLblColor->paletteBackgroundColor();} - void setLabelColor(QColor theColor) { myLblColor->setPaletteBackgroundColor(theColor);} - - int getLabelFont(); - void setLabelFont(int theFont); - - void setTitleVisible(bool isVisible) - { (isVisible)? myTitleEdt->show() : myTitleEdt->hide();} - -private slots: - void setTitleColor(); - void setLabelColor(); + public: + VisuGUI_FontWg* myTitleFont; + VisuGUI_FontWg* myLabelFont; private: - QLineEdit* myTitleEdt; - QComboBox* myTitFontCombo; - QCheckBox* myTitBoldChk; - QCheckBox* myTitItalicChk; - QCheckBox* myTitShadowChk; - QToolButton* myTitColor; - - QComboBox* myLblFontCombo; - QCheckBox* myLblBoldChk; - QCheckBox* myLblItalicChk; - QCheckBox* myLblShadowChk; - QToolButton* myLblColor; + QLineEdit* myTitleEdt; }; @@ -130,99 +89,96 @@ class VisuGUI_ScalarBarPane : public QVBox { Q_OBJECT; -public: - VisuGUI_ScalarBarPane(QWidget* parent, bool SetPref); - ~VisuGUI_ScalarBarPane() {}; - - void setRange( double imin, double imax, /*double fmin, double fmax,*/ bool sbRange ); - bool isIRange() {return RBIrange->isChecked();} - double getMin() {return MinEdit->text().toDouble();} - double getMax() {return MaxEdit->text().toDouble();} - int getOrientation(); - void setPosAndSize( double x, double y, double w, double h, bool vert ); - double getX() {return XSpin->value();} - double getY() {return YSpin->value();} - double getWidth() {return WidthSpin->value();} - double getHeight() {return HeightSpin->value();} - void setScalarBarData( int colors, int labels ); - int getNbColors() {return ColorSpin->value();} - int getNbLabels() {return LabelSpin->value();} - bool isLogarithmic() {return CBLog->isChecked();} - void setLogarithmic( bool on ) {CBLog->setChecked( on );} - bool isToSave() {return CBSave ? CBSave->isChecked() : false;} - - void initFromResources(); - void storeToResources(); - - void initFromPrsObject(VISU::ScalarMap_i* thePrs); - int storeToPrsObject(VISU::ScalarMap_i* thePrs); - - bool check(); - -protected: - QButtonGroup* RangeGroup; - QRadioButton* RBFrange; - QRadioButton* RBIrange; - QLineEdit* MinEdit; - QLineEdit* MaxEdit; - - QRadioButton* RBhori; - QRadioButton* RBvert; - - QtxDblSpinBox* XSpin; - QtxDblSpinBox* YSpin; - - QtxDblSpinBox* WidthSpin; - QtxDblSpinBox* HeightSpin; - - QSpinBox* ColorSpin; - QSpinBox* LabelSpin; - - QCheckBox* CBSave; - QCheckBox* CBLog; - QLabel* myModeLbl; - QComboBox* myModeCombo; - QPushButton* myTextBtn; - VisuGUI_TextPrefDlg* myTextDlg; - - double Imin, Imax, /* Fmin, Fmax,*/ Rmin, Rmax; - double myHorX, myHorY, myHorW, myHorH; - double myVerX, myVerY, myVerW, myVerH; - int myRangeMode; - bool myIsStoreTextProp; - -private slots: - void changeDefaults( int ); - void changeRange( int ); - void XYChanged( double ); - void onTextPref(); -}; + public: + VisuGUI_ScalarBarPane(QWidget* parent, bool SetPref); + ~VisuGUI_ScalarBarPane() {}; + + void setRange( double imin, double imax, /*double fmin, double fmax,*/ bool sbRange ); + bool isIRange() {return RBIrange->isChecked();} + double getMin() {return MinEdit->text().toDouble();} + double getMax() {return MaxEdit->text().toDouble();} + int getOrientation(); + void setPosAndSize( double x, double y, double w, double h, bool vert ); + double getX() {return XSpin->value();} + double getY() {return YSpin->value();} + double getWidth() {return WidthSpin->value();} + double getHeight() {return HeightSpin->value();} + void setScalarBarData( int colors, int labels ); + int getNbColors() {return ColorSpin->value();} + int getNbLabels() {return LabelSpin->value();} + bool isLogarithmic() {return CBLog->isChecked();} + void setLogarithmic( bool on ) {CBLog->setChecked( on );} + bool isToSave() {return CBSave ? CBSave->isChecked() : false;} + + void initFromResources(); + void storeToResources(); + + void initFromPrsObject(VISU::ScalarMap_i* thePrs); + int storeToPrsObject(VISU::ScalarMap_i* thePrs); + + bool check(); + protected: + QButtonGroup* RangeGroup; + QRadioButton* RBFrange; + QRadioButton* RBIrange; + QLineEdit* MinEdit; + QLineEdit* MaxEdit; + + QRadioButton* RBhori; + QRadioButton* RBvert; + + QtxDblSpinBox* XSpin; + QtxDblSpinBox* YSpin; + + QtxDblSpinBox* WidthSpin; + QtxDblSpinBox* HeightSpin; + + QSpinBox* ColorSpin; + QSpinBox* LabelSpin; + + QCheckBox* CBSave; + QCheckBox* CBLog; + QLabel* myModeLbl; + QComboBox* myModeCombo; + QPushButton* myTextBtn; + VisuGUI_TextPrefDlg* myTextDlg; + + double Imin, Imax, /* Fmin, Fmax,*/ Rmin, Rmax; + double myHorX, myHorY, myHorW, myHorH; + double myVerX, myVerY, myVerW, myVerH; + int myRangeMode; + bool myIsStoreTextProp; + + private slots: + void changeDefaults( int ); + void changeRange( int ); + void XYChanged( double ); + void onTextPref(); +}; class VisuGUI_ScalarBarDlg : public QDialog -{ +{ Q_OBJECT; -public: - VisuGUI_ScalarBarDlg( QWidget* parent = 0, bool SetPref = FALSE ); - ~VisuGUI_ScalarBarDlg() {}; - - bool isToSave() {return myScalarPane->isToSave();} + public: + VisuGUI_ScalarBarDlg( QWidget* parent = 0, bool SetPref = FALSE ); + ~VisuGUI_ScalarBarDlg() {}; - void initFromResources() {myScalarPane->initFromResources();} - void storeToResources() {myScalarPane->storeToResources();} + bool isToSave() {return myScalarPane->isToSave();} - void initFromPrsObject(VISU::ScalarMap_i* thePrs) {myScalarPane->initFromPrsObject(thePrs);} - int storeToPrsObject(VISU::ScalarMap_i* thePrs) {return myScalarPane->storeToPrsObject(thePrs);} + void initFromResources() {myScalarPane->initFromResources();} + void storeToResources() {myScalarPane->storeToResources();} + void initFromPrsObject(VISU::ScalarMap_i* thePrs) {myScalarPane->initFromPrsObject(thePrs);} + int storeToPrsObject(VISU::ScalarMap_i* thePrs) {return myScalarPane->storeToPrsObject(thePrs);} -protected slots: - void accept(); + protected slots: + void accept(); protected: - VisuGUI_ScalarBarPane* myScalarPane; - + VisuGUI_ScalarBarPane* myScalarPane; }; #endif // VISUGUI_SCALARBARDLG_H