// Module : VISU
// $Header$
-using namespace std;
#include "VisuGUI_ScalarBarDlg.h"
-#include <limits.h>
-#include <qlayout.h>
-#include <qvalidator.h>
+#include "VISU_ScalarMap_i.hh"
+#include "VISU_ScalarMapPL.hxx"
+
#include "QAD_Application.h"
#include "QAD_Desktop.h"
#include "QAD_Config.h"
#include "QAD_MessageBox.h"
#include "VISU_Convertor.hxx"
-/*!
- Constructor
-*/
-VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg(bool SetPref)
- : QDialog( QAD_Application::getDesktop(), 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+#include <limits.h>
+#include <qlayout.h>
+#include <qvalidator.h>
+#include <qcolordialog.h>
+
+using namespace std;
+
+
+
+VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane(QWidget * parent, bool SetPref):
+ QVBox(parent)
{
- setName( "VisuGUI_ScalarBarDlg" );
- setCaption( SetPref ? tr( "Scalar Bar Preferences" ) : tr( "Scalar Bar Properties" ) );
- setSizeGripEnabled( TRUE );
-
myVerX = 0.01; myVerY = 0.10; myVerW = 0.10; myVerH = 0.80;
myHorX = 0.20; myHorY = 0.01; myHorW = 0.60; myHorH = 0.12;
- Imin = 0.0; Imax = 0.0; Fmin = 0.0; Fmax = 0.0; Rmin = 0.0; Rmax = 0.0;
+ Imin = 0.0; Imax = 0.0; /*Fmin = 0.0; Fmax = 0.0;*/ Rmin = 0.0; Rmax = 0.0;
myRangeMode = -1;
-
- QVBoxLayout* TopLayout = new QVBoxLayout( this );
- TopLayout->setSpacing( 6 );
- TopLayout->setMargin( 11 );
+
+ setSpacing(6);
+ //setMargin(11);
// Range ============================================================
RangeGroup = new QButtonGroup( tr( "Scalar range" ), this, "RangeGroup" );
RangeGroupLayout->addWidget( MaxLabel, 3, 2 );
RangeGroupLayout->addWidget( MaxEdit, 3, 3 );
- TopLayout->addWidget( RangeGroup );
+ //TopLayout->addWidget( RangeGroup );
// Colors and Labels ========================================================
QGroupBox* ColLabGroup = new QGroupBox( tr( "Colors and labels" ), this, "ColLabGroup" );
ColLabGroupLayout->addWidget( LabelLabel, 0, 2);
ColLabGroupLayout->addWidget( LabelSpin, 0, 3);
- TopLayout->addWidget( ColLabGroup );
+ //TopLayout->addWidget( ColLabGroup );
// Orientation ==========================================================
QButtonGroup* OrientGroup = new QButtonGroup( tr( "Orientation" ), this, "OrientGroup" );
OrientGroupLayout->addWidget( RBvert, 0, 0 );
OrientGroupLayout->addWidget( RBhori, 0, 1 );
- TopLayout->addWidget( OrientGroup );
+ // TopLayout->addWidget( OrientGroup );
// Origin ===============================================================
QGroupBox* OriginGroup = new QGroupBox( tr( "Origin" ), this, "OriginGroup" );
OriginGroupLayout->addWidget( YLabel, 0, 2);
OriginGroupLayout->addWidget( YSpin, 0, 3);
- TopLayout->addWidget( OriginGroup );
+ //TopLayout->addWidget( OriginGroup );
// Dimensions =========================================================
QGroupBox* DimGroup = new QGroupBox( tr( "Dimensions" ), this, "DimGroup" );
DimGroupLayout->addWidget( HeightLabel, 0, 2);
DimGroupLayout->addWidget( HeightSpin, 0, 3);
- TopLayout->addWidget( DimGroup );
+ //TopLayout->addWidget( DimGroup );
// Save check box ===========================================================
+ QHBox* aSaveBox = new QHBox(this);
if ( !SetPref ) {
- CBSave = new QCheckBox( tr( "Save as default values" ), this, "CBSave" );
- TopLayout->addWidget( CBSave );
+ CBSave = new QCheckBox( tr( "Save as default values" ), aSaveBox, "CBSave" );
+ //TopLayout->addWidget( CBSave );
}
else {
CBSave = 0;
}
-
- // Common buttons ===========================================================
- QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
- GroupButtons->setColumnLayout(0, Qt::Vertical );
- GroupButtons->layout()->setSpacing( 0 );
- GroupButtons->layout()->setMargin( 0 );
- QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
- GroupButtonsLayout->setAlignment( Qt::AlignTop );
- GroupButtonsLayout->setSpacing( 6 );
- GroupButtonsLayout->setMargin( 11 );
-
- QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
- buttonOk->setAutoDefault( TRUE );
- buttonOk->setDefault( TRUE );
- GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
- GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
-
- QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
- buttonCancel->setAutoDefault( TRUE );
- GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
-
- TopLayout->addWidget( GroupButtons );
+ myTextBtn = new QPushButton("Text properties...", aSaveBox);
+ myTextDlg = new VisuGUI_TextPrefDlg(this);
+ myTextDlg->setTitleVisible(!SetPref);
// signals and slots connections ===========================================
connect( RangeGroup, SIGNAL( clicked( int ) ), this, SLOT( changeRange( int ) ) );
connect( OrientGroup, SIGNAL( clicked( int ) ), this, SLOT( changeDefaults( int ) ) );
connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) );
- connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
- connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+ connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) );
changeRange( 0 );
changeDefaults( 0 );
-}
-
-/*!
- Destructor
-*/
-VisuGUI_ScalarBarDlg::~VisuGUI_ScalarBarDlg()
-{
+ myIsStoreTextProp = false;
}
/**
* Initializes dialog box values from resources
*/
-void VisuGUI_ScalarBarDlg::initFromResources() {
+void VisuGUI_ScalarBarPane::initFromResources() {
int sbCol=64,sbLab=5,orient=1;
float sbX1=0.01,sbY1=0.1,sbW=0.1,sbH=0.8;
float sbVmin=0., sbVmax=0.;
sbVmax=0.;
}
- setRange( sbVmin, sbVmax, 0.0, 0.0, sbRange );
+ setRange( sbVmin, sbVmax, /*0.0, 0.0,*/ sbRange );
setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 1);
setScalarBarData( sbCol, sbLab );
+
+ QString aIsBoldTitle = QAD_CONFIG->getSetting("Visu:IsBoldTitle");
+ if (aIsBoldTitle.isEmpty())
+ myTextDlg->setBoldTitle(true);
+ else
+ myTextDlg->setBoldTitle(aIsBoldTitle.compare("true") == 0);
+
+ QString aIsItalicTitle = QAD_CONFIG->getSetting("Visu:IsItalicTitle");
+ if (aIsItalicTitle.isEmpty())
+ myTextDlg->setItalicTitle(true);
+ else
+ myTextDlg->setItalicTitle(aIsItalicTitle.compare("true") == 0);
+
+ QString aIsShadowTitle = QAD_CONFIG->getSetting("Visu:IsShadowTitle");
+ if (aIsShadowTitle.isEmpty())
+ myTextDlg->setShadowTitle(true);
+ else
+ myTextDlg->setShadowTitle(aIsShadowTitle.compare("true") == 0);
+
+ QString aTitFontType = QAD_CONFIG->getSetting("Visu:TitFontType");
+ if (!aTitFontType.isEmpty()) {
+ switch (aTitFontType.toInt()) {
+ case 0: myTextDlg->setTitleFont(VTK_ARIAL); break;
+ case 1: myTextDlg->setTitleFont(VTK_COURIER); break;
+ case 2: myTextDlg->setTitleFont(VTK_TIMES); break;
+ }
+ } else {
+ myTextDlg->setTitleFont(VTK_ARIAL);
+ }
+ float R,G,B;
+ QString aRTitColor = QAD_CONFIG->getSetting("Visu:TitleColorR");
+ R = (aRTitColor.isEmpty())? 1 : aRTitColor.toFloat();
+ if (R > 1) R = 1;
+ if (R < 0) R = 0;
+
+ QString aGTitColor = QAD_CONFIG->getSetting("Visu:TitleColorG");
+ G = (aGTitColor.isEmpty())? 1 : aGTitColor.toFloat();
+ if (G > 1) G = 1;
+ if (G < 0) G = 0;
+
+ QString aBTitColor = QAD_CONFIG->getSetting("Visu:TitleColorB");
+ B = (aBTitColor.isEmpty())? 1 : aBTitColor.toFloat();
+ if (B > 1) B = 1;
+ if (B < 0) B = 0;
+
+ myTextDlg->setTitleColor(QColor((int)(R*255.),
+ (int)(G*255.),
+ (int)(B*255.)));
+ ///
+
+ QString aIsBoldLabel = QAD_CONFIG->getSetting("Visu:IsBoldLabel");
+ if (aIsBoldLabel.isEmpty())
+ myTextDlg->setBoldLabel(true);
+ else
+ myTextDlg->setBoldLabel(aIsBoldLabel.compare("true") == 0);
+
+ QString aIsItalicLabel = QAD_CONFIG->getSetting("Visu:IsItalicLabel");
+ if (aIsItalicLabel.isEmpty())
+ myTextDlg->setItalicLabel(true);
+ else
+ myTextDlg->setItalicLabel(aIsItalicLabel.compare("true") == 0);
+
+ QString aIsShadowLabel = QAD_CONFIG->getSetting("Visu:IsShadowLabel");
+ if (aIsShadowLabel.isEmpty())
+ myTextDlg->setShadowLabel(true);
+ else
+ myTextDlg->setShadowLabel(aIsShadowLabel.compare("true") == 0);
+
+ QString aLblFontType = QAD_CONFIG->getSetting("Visu:LblFontType");
+ if (!aLblFontType.isEmpty()) {
+ switch (aLblFontType.toInt()) {
+ case 0: myTextDlg->setLabelFont(VTK_ARIAL); break;
+ case 1: myTextDlg->setLabelFont(VTK_COURIER); break;
+ case 2: myTextDlg->setLabelFont(VTK_TIMES); break;
+ }
+ } else {
+ myTextDlg->setLabelFont(VTK_ARIAL);
+ }
+ QString aRLblColor = QAD_CONFIG->getSetting("Visu:LabelColorR");
+ R = (aRLblColor.isEmpty())? 1 : aRLblColor.toFloat();
+ if (R > 1) R = 1;
+ if (R < 0) R = 0;
+
+ QString aGLblColor = QAD_CONFIG->getSetting("Visu:LabelColorG");
+ G = (aGLblColor.isEmpty())? 1 : aGLblColor.toFloat();
+ if (G > 1) G = 1;
+ if (G < 0) G = 0;
+
+ QString aBLblColor = QAD_CONFIG->getSetting("Visu:LabelColorB");
+ B = (aBLblColor.isEmpty())? 1 : aBLblColor.toFloat();
+ if (B > 1) B = 1;
+ if (B < 0) B = 0;
+
+ myTextDlg->setLabelColor(QColor((int)(R*255.),
+ (int)(G*255.),
+ (int)(B*255.)));
}
/**
* Stores dialog values to resources
*/
-void VisuGUI_ScalarBarDlg::storeToResources() {
+void VisuGUI_ScalarBarPane::storeToResources() {
int orient = (RBvert->isChecked())? 1 : 0;
float sbX1 = XSpin->value();
float sbY1 = YSpin->value();
QAD_CONFIG->addSetting("Visu:SBScaling", "LOGARITHMIC");
else
QAD_CONFIG->addSetting("Visu:SBScaling", "LINEAR");
+
+ ////
+
+ if (myIsStoreTextProp) {
+ if (myTextDlg->isBoldTitle())
+ QAD_CONFIG->addSetting("Visu:IsBoldTitle","true");
+ else
+ QAD_CONFIG->addSetting("Visu:IsBoldTitle","false");
+
+ if (myTextDlg->isItalicTitle())
+ QAD_CONFIG->addSetting("Visu:IsItalicTitle","true");
+ else
+ QAD_CONFIG->addSetting("Visu:IsItalicTitle","false");
+
+ if (myTextDlg->isShadowTitle())
+ QAD_CONFIG->addSetting("Visu:IsShadowTitle","true");
+ else
+ QAD_CONFIG->addSetting("Visu:IsShadowTitle","false");
+
+ switch (myTextDlg->getTitleFont()) {
+ case VTK_ARIAL: QAD_CONFIG->addSetting("Visu:TitFontType",0); break;
+ case VTK_COURIER: QAD_CONFIG->addSetting("Visu:TitFontType",1); break;
+ case VTK_TIMES: QAD_CONFIG->addSetting("Visu:TitFontType",2); break;
+ }
+ QColor aColor = myTextDlg->getTitleColor();
+ QAD_CONFIG->addSetting("Visu:TitleColorR", aColor.red()/255.);
+ QAD_CONFIG->addSetting("Visu:TitleColorG", aColor.green()/255.);
+ QAD_CONFIG->addSetting("Visu:TitleColorB", aColor.blue()/255.);
+ ///
+
+ if (myTextDlg->isBoldLabel())
+ QAD_CONFIG->addSetting("Visu:IsBoldLabel","true");
+ else
+ QAD_CONFIG->addSetting("Visu:IsBoldLabel","false");
+
+ if (myTextDlg->isItalicLabel())
+ QAD_CONFIG->addSetting("Visu:IsItalicLabel","true");
+ else
+ QAD_CONFIG->addSetting("Visu:IsItalicLabel","false");
+
+ if (myTextDlg->isShadowLabel())
+ QAD_CONFIG->addSetting("Visu:IsShadowLabel","true");
+ else
+ QAD_CONFIG->addSetting("Visu:IsShadowLabel","false");
+
+ switch (myTextDlg->getLabelFont()) {
+ case VTK_ARIAL: QAD_CONFIG->addSetting("Visu:LblFontType",0); break;
+ case VTK_COURIER: QAD_CONFIG->addSetting("Visu:LblFontType",1); break;
+ case VTK_TIMES: QAD_CONFIG->addSetting("Visu:LblFontType",2); break;
+ }
+ aColor = myTextDlg->getLabelColor();
+ QAD_CONFIG->addSetting("Visu:LabelColorR", aColor.red()/255.);
+ QAD_CONFIG->addSetting("Visu:LabelColorG", aColor.green()/255.);
+ QAD_CONFIG->addSetting("Visu:LabelColorB", aColor.blue()/255.);
+ }
}
/**
* Initialise dialog box from presentation object
*/
-void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::ScalarMap_i* thePrs) {
+void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ScalarMap_i* thePrs) {
+ initFromResources();
myModeCombo->setCurrentItem(thePrs->GetScalarMode());
setPosAndSize( thePrs->GetPosX(),
thePrs->GetPosY(),
thePrs->GetWidth(),
thePrs->GetHeight(),
- thePrs->GetOrientation());
+ thePrs->GetBarOrientation());
switch(thePrs->GetScaling()){
case VISU::LOGARITHMIC :
setLogarithmic(true);
setLogarithmic(false);
}
float aRange[2];
- thePrs->GetFieldRange(aRange);
+ thePrs->GetScalarMapPL()->GetSourceRange(aRange);
Rmin = aRange[0]; Rmax = aRange[1];
setRange( thePrs->GetMin(), thePrs->GetMax(),
- 0.0, 0.0, thePrs->isRangeFixed() );
+ /*0.0, 0.0,*/ thePrs->IsRangeFixed() );
setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() );
bool isScalarMode = (thePrs->GetField()->myNbComp > 1);
myModeLbl->setEnabled(isScalarMode);
myModeCombo->setEnabled(isScalarMode);
+
+ 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());
+ thePrs->GetLabelColor(&R, &G, &B);
+ myTextDlg->setLabelColor(QColor((int)(R*255.),
+ (int)(G*255.),
+ (int)(B*255.)));
}
/**
* Store values to presentation object
*/
-void VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ScalarMap_i* thePrs) {
+int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ScalarMap_i* thePrs) {
thePrs->SetScalarMode(myModeCombo->currentItem());
thePrs->SetPosition(XSpin->value(), YSpin->value());
thePrs->SetSize(WidthSpin->value(), HeightSpin->value());
- thePrs->SetOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
- if (RBFrange->isChecked()) {
- thePrs->CalculateRange();
- } else {
- thePrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
- }
+ thePrs->SetBarOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL);
if(isLogarithmic())
thePrs->SetScaling(VISU::LOGARITHMIC);
else
thePrs->SetScaling(VISU::LINEAR);
+
+ if (RBFrange->isChecked()) {
+ thePrs->SetSourceRange();
+ } else {
+ thePrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble());
+ }
thePrs->SetNbColors(ColorSpin->value());
thePrs->SetLabels(LabelSpin->value());
- thePrs->Update();
-
+
if (isToSave()) storeToResources();
+
+ if (myIsStoreTextProp) {
+ 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.,
+ 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.,
+ aLblColor.green()/255.,
+ aLblColor.blue()/255.);
+ }
+
+ return 1;
}
/*!
Called when orientation is changed
*/
-void VisuGUI_ScalarBarDlg::changeDefaults( int )
+void VisuGUI_ScalarBarPane::changeDefaults( int )
{
if ( RBvert->isChecked() ) {
XSpin->setValue( myVerX );
/*!
Called when Range mode is changed
*/
-void VisuGUI_ScalarBarDlg::changeRange( int )
+void VisuGUI_ScalarBarPane::changeRange( int )
{
int mode = -1;
if ( RBFrange->isChecked() )
/*!
Called when X,Y position is changed
*/
-void VisuGUI_ScalarBarDlg::XYChanged( double )
+void VisuGUI_ScalarBarPane::XYChanged( double )
{
QAD_SpinBoxDbl* snd = (QAD_SpinBoxDbl*)sender();
if ( snd == XSpin ) {
/*!
Sets default values and range mode
*/
-void VisuGUI_ScalarBarDlg::setRange( double imin, double imax, double fmin, double fmax, bool sbRange )
+void VisuGUI_ScalarBarPane::setRange( double imin, double imax/*, double fmin, double fmax*/, bool sbRange )
{
- Imin = imin; Imax = imax; Fmin = fmin; Fmax = fmax;
+ Imin = imin; Imax = imax;// Fmin = fmin; Fmax = fmax;
if ( RBIrange->isChecked() ) {
MinEdit->setText( QString::number( Imin ) );
MaxEdit->setText( QString::number( Imax ) );
/*!
Sets size and position
*/
-void VisuGUI_ScalarBarDlg::setPosAndSize( double x, double y, double w, double h, bool vert )
+void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
{
if ( vert ) {
myVerX = x;
/*!
Sets colors and labels number
*/
-void VisuGUI_ScalarBarDlg::setScalarBarData( int colors, int labels )
+void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels )
{
ColorSpin->setValue( colors );
LabelSpin->setValue( labels );
/*!
Gets orientation
*/
-int VisuGUI_ScalarBarDlg::getOrientation()
+int VisuGUI_ScalarBarPane::getOrientation()
{
if (RBvert->isChecked() )
return 1;
return 0;
}
-/*!
- Gets Scalar Bar's x position
-*/
-double VisuGUI_ScalarBarDlg::getX()
-{
- return XSpin->value();
-}
-
-/*!
- Gets Scalar Bar's y position
-*/
-double VisuGUI_ScalarBarDlg::getY()
-{
- return YSpin->value();
-}
-
-/*!
- Gets Scalar Bar's width
-*/
-double VisuGUI_ScalarBarDlg::getWidth()
-{
- return WidthSpin->value();
-}
-
-/*!
- Gets Scalar Bar's height
-*/
-double VisuGUI_ScalarBarDlg::getHeight()
-{
- return HeightSpin->value();
-}
-
-/*!
- Gets Scalar Bar's number of colors
-*/
-int VisuGUI_ScalarBarDlg::getNbColors()
-{
- return ColorSpin->value();
-}
-
-/*!
- Gets Scalar Bar's number of labels
-*/
-int VisuGUI_ScalarBarDlg::getNbLabels()
-{
- return LabelSpin->value();
-}
-
-/*!
- Returns true if imposed range is used
-*/
-bool VisuGUI_ScalarBarDlg::isIRange()
-{
- return RBIrange->isChecked();
-}
-/*!
- Gets Min value
-*/
-double VisuGUI_ScalarBarDlg::getMin()
-{
- return MinEdit->text().toDouble();
-}
-
-/*!
- Gets Max value
-*/
-double VisuGUI_ScalarBarDlg::getMax()
-{
- return MaxEdit->text().toDouble();
-}
-
-/*!
- return true if "save pref" flag is on
-*/
-bool VisuGUI_ScalarBarDlg::isToSave()
-{
- return CBSave ? CBSave->isChecked() : false;
-}
-
-/*!
- Returns true if "Logarithmic scaling" check box is on
-*/
-bool VisuGUI_ScalarBarDlg::isLogarithmic()
-{
- return CBLog->isChecked();
-}
-
-/*!
- Sets "Logarithmic scaling" check box on/off
-*/
-void VisuGUI_ScalarBarDlg::setLogarithmic( bool on )
-{
- CBLog->setChecked( on );
-}
/*!
Called when <OK> button is clicked, validates data and closes dialog
*/
-void VisuGUI_ScalarBarDlg::accept()
+bool VisuGUI_ScalarBarPane::check()
{
double minVal = MinEdit->text().toDouble();
double maxVal = MaxEdit->text().toDouble();
QAD_MessageBox::warn1( this,tr("VISU_WARNING"),
tr("MSG_MINMAX_VALUES"),
tr("VISU_BUT_OK"));
- return;
+ return false;
}
}
// check if logarithmic mode is on and check imposed range to not contain negative values
tr("VISU_WARNING"),
tr("WRN_LOGARITHMIC_RANGE"),
tr("VISU_BUT_OK"));
- return;
+ return false;
}
}
else {
changeRange(1);
//MinEdit->setText( QString::number( Rmin ) );
//MaxEdit->setText( QString::number( Rmax ) );
- return;
+ return false;
}
}
}
- QDialog::accept();
+ return true;
+}
+
+
+void VisuGUI_ScalarBarPane::onTextPref() {
+ myIsStoreTextProp = myTextDlg->exec();
+}
+
+
+
+
+
+//#######################################################################################
+
+
+/*!
+ Constructor
+*/
+VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg(bool SetPref)
+ : QDialog( QAD_Application::getDesktop(), 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+{
+ setName( "VisuGUI_ScalarBarDlg" );
+ setCaption( SetPref ? tr( "Scalar Bar Preferences" ) : tr( "Scalar Bar Properties" ) );
+ setSizeGripEnabled( TRUE );
+
+ QVBoxLayout* TopLayout = new QVBoxLayout(this);
+ TopLayout->setSpacing(6);
+ TopLayout->setMargin(11);
+
+ myScalarPane = new VisuGUI_ScalarBarPane(this, SetPref);
+ TopLayout->addWidget(myScalarPane);
+
+ // Common buttons ===========================================================
+ QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
+ GroupButtons->setColumnLayout(0, Qt::Vertical );
+ GroupButtons->layout()->setSpacing( 0 );
+ GroupButtons->layout()->setMargin( 0 );
+ QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
+ GroupButtonsLayout->setAlignment( Qt::AlignTop );
+ GroupButtonsLayout->setSpacing( 6 );
+ GroupButtonsLayout->setMargin( 11 );
+
+ QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
+ buttonOk->setAutoDefault( TRUE );
+ buttonOk->setDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
+ GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
+
+ QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
+ buttonCancel->setAutoDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
+
+ TopLayout->addWidget( GroupButtons );
+
+ 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
+*/
+void VisuGUI_ScalarBarDlg::accept()
+{
+ if (myScalarPane->check()) QDialog::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);
+
+ 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);
+ 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);
+ 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 );
+
+ // Common buttons ===========================================================
+ QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
+ GroupButtons->setColumnLayout(0, Qt::Vertical );
+ GroupButtons->layout()->setSpacing( 0 );
+ GroupButtons->layout()->setMargin( 0 );
+ QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
+ GroupButtonsLayout->setAlignment( Qt::AlignTop );
+ GroupButtonsLayout->setSpacing( 6 );
+ GroupButtonsLayout->setMargin( 11 );
+
+ QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
+ buttonOk->setAutoDefault( TRUE );
+ buttonOk->setDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
+ GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
+
+ QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
+ buttonCancel->setAutoDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
+
+ 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; \
+ } \
+}
+
+#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