-// VISU VISUGUI : GUI of VISU component
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// 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
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// VISU VISUGUI : GUI of VISU component
// File : VisuGUI_ScalarBarDlg.cxx
-// Author : Laurent CORNABE & Hubert ROLLAND
+// Author : Laurent CORNABE & Hubert ROLLAND
// Module : VISU
// $Header$
+//
+#include "VisuGUI_ScalarBarDlg.h"
-#include <limits.h>
-#include <qlayout.h>
-#include <qvalidator.h>
-#include <qcolordialog.h>
-
-#include "SUIT_MessageBox.h"
-#include "SUIT_ResourceMgr.h"
+#include "VisuGUI.h"
+#include "VisuGUI_Tools.h"
+#include "VisuGUI_ViewTools.h"
+#include "VisuGUI_InputPane.h"
-#include "SalomeApp_Application.h"
+#include "SVTK_ViewWindow.h"
+#include "SVTK_FontWidget.h"
-#include "VisuGUI.h"
#include "VISUConfig.hh"
#include "VISU_Convertor.hxx"
#include "VISU_ScalarMapPL.hxx"
#include "VISU_ScalarMap_i.hh"
+#include "VISU_ScalarMapAct.h"
-#include "VisuGUI_ScalarBarDlg.h"
-
-using namespace std;
-
-
-
-VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref):
- QVBox(parent)
-{
- 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;
- myRangeMode = -1;
-
- setSpacing(6);
- //setMargin(11);
-
- // Range ============================================================
- RangeGroup = new QButtonGroup (tr("SCALAR_RANGE_GRP"), this, "RangeGroup");
- RangeGroup->setColumnLayout(0, Qt::Vertical );
- RangeGroup->layout()->setSpacing( 0 );
- RangeGroup->layout()->setMargin( 0 );
- QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup->layout() );
- 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");
- myModeCombo->insertItem("Component 2");
- myModeCombo->insertItem("Component 3");
-
- 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 );
-
- MinEdit = new QLineEdit( RangeGroup, "MinEdit" );
- MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- MinEdit->setMinimumWidth( 70 );
- MinEdit->setValidator( new QDoubleValidator(this) );
- MinEdit->setText( "0.0" );
- QLabel* MinLabel = new QLabel (tr("LBL_MIN"), RangeGroup, "MinLabel");
- MinLabel->setBuddy(MinEdit);
-
- MaxEdit = new QLineEdit( RangeGroup, "MaxEdit" );
- MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- MaxEdit->setMinimumWidth( 70 );
- MaxEdit->setValidator( new QDoubleValidator(this) );
- MaxEdit->setText( "0.0" );
- QLabel* MaxLabel = new QLabel (tr("LBL_MAX"), RangeGroup, "MaxLabel");
- MaxLabel->setBuddy(MaxEdit);
-
- RangeGroupLayout->addWidget( myModeLbl, 0, 0 );
- RangeGroupLayout->addMultiCellWidget( myModeCombo, 0, 0, 1, 3);
- RangeGroupLayout->addMultiCellWidget( CBLog, 1, 1, 0, 3);
- RangeGroupLayout->addMultiCellWidget( RBFrange, 2, 2, 0, 1);
- RangeGroupLayout->addMultiCellWidget( RBIrange, 2, 2, 2, 3);
- RangeGroupLayout->addWidget( MinLabel, 3, 0 );
- RangeGroupLayout->addWidget( MinEdit, 3, 1 );
- RangeGroupLayout->addWidget( MaxLabel, 3, 2 );
- RangeGroupLayout->addWidget( MaxEdit, 3, 3 );
-
- //TopLayout->addWidget( RangeGroup );
-
- // Colors and Labels ========================================================
- QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this, "ColLabGroup");
- ColLabGroup->setColumnLayout(0, Qt::Vertical );
- ColLabGroup->layout()->setSpacing( 0 );
- ColLabGroup->layout()->setMargin( 0 );
- QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup->layout() );
- ColLabGroupLayout->setAlignment( Qt::AlignTop );
- ColLabGroupLayout->setSpacing( 6 );
- ColLabGroupLayout->setMargin( 11 );
-
- QLabel* ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup, "ColorLabel");
- ColorSpin = new QSpinBox( 2, 256, 1, ColLabGroup );
- ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- ColorSpin->setMinimumWidth( 70 );
- ColorSpin->setValue( 64 );
-
- QLabel* LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup, "LabelLabel");
- LabelSpin = new QSpinBox( 2, 65, 1, ColLabGroup );
- 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);
- ColLabGroupLayout->addWidget( LabelSpin, 0, 3);
-
- //TopLayout->addWidget( ColLabGroup );
-
- // Orientation ==========================================================
- QButtonGroup* OrientGroup = new QButtonGroup (tr("ORIENTATION_GRP"), this, "OrientGroup");
- OrientGroup->setColumnLayout(0, Qt::Vertical );
- OrientGroup->layout()->setSpacing( 0 );
- OrientGroup->layout()->setMargin( 0 );
- QGridLayout* OrientGroupLayout = new QGridLayout( OrientGroup->layout() );
- OrientGroupLayout->setAlignment( Qt::AlignTop );
- OrientGroupLayout->setSpacing( 6 );
- OrientGroupLayout->setMargin( 11 );
-
- RBvert = new QRadioButton (tr("VERTICAL_BTN"), OrientGroup, "RBvert");
- RBvert->setChecked( true );
- RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), OrientGroup, "RBhori");
- OrientGroupLayout->addWidget( RBvert, 0, 0 );
- OrientGroupLayout->addWidget( RBhori, 0, 1 );
-
- // TopLayout->addWidget( OrientGroup );
-
- // Origin ===============================================================
- QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this, "OriginGroup");
- OriginGroup->setColumnLayout(0, Qt::Vertical );
- OriginGroup->layout()->setSpacing( 0 );
- OriginGroup->layout()->setMargin( 0 );
- QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup->layout() );
- OriginGroupLayout->setAlignment( Qt::AlignTop );
- OriginGroupLayout->setSpacing( 6 );
- OriginGroupLayout->setMargin( 11 );
-
- QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup, "XLabel");
- XSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
- XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- XSpin->setMinimumWidth( 70 );
- XSpin->setValue( 0.01 );
-
- QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup, "YLabel");
- YSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup );
- 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);
- OriginGroupLayout->addWidget( YSpin, 0, 3);
-
- //TopLayout->addWidget( OriginGroup );
-
- // Dimensions =========================================================
- QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this, "DimGroup");
- DimGroup->setColumnLayout(0, Qt::Vertical );
- DimGroup->layout()->setSpacing( 0 );
- DimGroup->layout()->setMargin( 0 );
- QGridLayout* DimGroupLayout = new QGridLayout( DimGroup->layout() );
- DimGroupLayout->setAlignment( Qt::AlignTop );
- DimGroupLayout->setSpacing( 6 );
- DimGroupLayout->setMargin( 11 );
-
- QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup, "WidthLabel");
- WidthSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
- WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- WidthSpin->setMinimumWidth( 70 );
- WidthSpin->setValue( 0.1 );
-
- QLabel* HeightLabel = new QLabel (tr("LBL_HEIGHT"), DimGroup, "HeightLabel");
- HeightSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup );
- 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);
- DimGroupLayout->addWidget( HeightSpin, 0, 3);
-
- //TopLayout->addWidget( DimGroup );
-
- // Save check box ===========================================================
- QHBox* aSaveBox = new QHBox(this);
- if (!SetPref) {
- CBSave = new QCheckBox (tr("SAVE_DEFAULT_CHK"), aSaveBox, "CBSave");
- //TopLayout->addWidget(CBSave);
- }
- else {
- CBSave = 0;
- }
- 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( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) );
-
- changeRange( 0 );
- changeDefaults( 0 );
- myIsStoreTextProp = false;
-}
-
-
-/**
- * Initializes dialog box values from resources
- */
-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.;
- bool sbRange=false;
- QString aString;
-
- SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
-
- orient = aResourceMgr->integerValue("Visu:SBOrientation",orient);
- if(orient != 1){
- orient=0;
- sbX1=0.2;
- sbY1=0.01;
- sbW=0.6;
- sbH=0.12;
- }
-
- sbX1 = aResourceMgr->doubleValue("Visu:SBXorigin",sbX1);
- sbY1 = aResourceMgr->doubleValue("Visu:SBYorigin",sbY1);
-
- sbW = aResourceMgr->doubleValue("Visu:SBWidth",sbW);
- sbH = aResourceMgr->doubleValue("Visu:SBHeight",sbH);
-
- 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);
-
- QString aScaling = aResourceMgr->stringValue("Visu:SBMaximumValue","LINEAR");
- if(aScaling.compare("LOGARITHMIC") == 0)
- setLogarithmic(true);
- else
- setLogarithmic(false);
-
- if((sbX1 < 0.) || (sbY1 < 0.) ||
- ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
- if(orient == 1) {
- sbX1=0.01;
- sbY1=0.1;
- sbW=0.1;
- sbH=0.8;
- } else {
- sbX1=0.2;
- sbY1=0.01;
- sbW=0.6;
- sbH=0.12;
- }
- }
- if(sbCol < 2) sbCol=2;
- if(sbCol > 64) sbCol=64;
- if(sbLab < 2) sbLab=2;
- if(sbLab > 65) sbLab=65;
-
- if(sbVmin > sbVmax) {
- sbVmin=0.;
- sbVmax=0.;
- }
-
- setRange( sbVmin, sbVmax, /*0.0, 0.0,*/ sbRange );
- setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 1);
- 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.)));
- }
-
-}
-
-
-
-/**
- * Stores dialog values to resources
- */
-void VisuGUI_ScalarBarPane::storeToResources() {
- int orient = (RBvert->isChecked())? 1 : 0;
- 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) {
- sbX1=0.01;
- sbY1=0.1;
- sbW=0.17;
- sbH=0.8;
- } else {
- sbX1=0.2;
- sbY1=0.01;
- sbW=0.6;
- sbH=0.12;
- }
- }
-
- bool sbRange = RBIrange->isChecked();
- float sbVmin = (float)(MinEdit->text().toDouble());
- float sbVmax = (float)(MaxEdit->text().toDouble());
-
- if(sbVmin > sbVmax) {
- sbVmin=0.;
- sbVmax=0.;
- }
-
- SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
-
- aResourceMgr->setValue("Visu: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);
- 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");
- else
- aResourceMgr->setValue("Visu:SBScaling", "LINEAR");
-
- ////
-
- 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");
-
- if (myTextDlg->isShadowTitle())
- aResourceMgr->setValue("Visu:IsShadowTitle","true");
- else
- aResourceMgr->setValue("Visu:IsShadowTitle","false");
-
- switch (myTextDlg->getTitleFont()) {
- case VTK_ARIAL:
- aResourceMgr->setValue("Visu:TitFontType",0);
- break;
- case VTK_COURIER:
- aResourceMgr->setValue("Visu:TitFontType",1);
- break;
- 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:IsBoldLabel","true");
- else
- aResourceMgr->setValue("Visu:IsBoldLabel","false");
-
- if (myTextDlg->isItalicLabel())
- aResourceMgr->setValue("Visu:IsItalicLabel","true");
- else
- aResourceMgr->setValue("Visu:IsItalicLabel","false");
-
- if (myTextDlg->isShadowLabel())
- aResourceMgr->setValue("Visu:IsShadowLabel","true");
- else
- aResourceMgr->setValue("Visu:IsShadowLabel","false");
-
- switch (myTextDlg->getLabelFont()) {
- case VTK_ARIAL:
- aResourceMgr->setValue("Visu:LblFontType",0);
- break;
- case VTK_COURIER:
- aResourceMgr->setValue("Visu:LblFontType",1);
- break;
- 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.);
- }
-}
-
-
-/**
- * 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(),
- thePrs->GetBarOrientation());
- switch(thePrs->GetScaling()){
- case VISU::LOGARITHMIC :
- setLogarithmic(true);
- break;
- default:
- setLogarithmic(false);
- }
- float aRange[2];
- thePrs->GetScalarMapPL()->GetSourceRange(aRange);
- Rmin = aRange[0]; Rmax = aRange[1];
- 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);
-
- 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
- */
-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->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());
-
- 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_ScalarBarPane::changeDefaults( int )
-{
- if ( RBvert->isChecked() ) {
- XSpin->setValue( myVerX );
- YSpin->setValue( myVerY );
- WidthSpin->setValue( myVerW );
- HeightSpin->setValue( myVerH );
- }
- else {
- XSpin->setValue( myHorX );
- YSpin->setValue( myHorY );
- WidthSpin->setValue( myHorW );
- HeightSpin->setValue( myHorH );
- }
-}
-
-/*!
- Called when Range mode is changed
-*/
-void VisuGUI_ScalarBarPane::changeRange( int )
-{
- int mode = -1;
- if ( RBFrange->isChecked() )
- mode = 0;
- if ( RBIrange->isChecked() )
- mode = 1;
- if ( myRangeMode == mode )
- return;
- //MinSpin->setMaxValue( Fmin );
- //MaxSpin->setMinValue( Fmax );
- if ( RBFrange->isChecked() ) {
- //MinLabel->setEnabled( false );
- MinEdit->setEnabled( false );
- //MaxLabel->setEnabled( false );
- MaxEdit->setEnabled( false );
- if ( mode != -1 ) {
- Imin = MinEdit->text().toDouble();
- Imax = MaxEdit->text().toDouble();
- }
- MinEdit->setText( QString::number( Rmin ) );
- MaxEdit->setText( QString::number( Rmax ) );
- }
- else {
- //MinLabel->setEnabled( true );
- MinEdit->setEnabled( true );
- //MaxLabel->setEnabled( true );
- MaxEdit->setEnabled( true );
- MinEdit->setText( QString::number( Imin ) );
- MaxEdit->setText( QString::number( Imax ) );
- }
- myRangeMode = mode;
-}
-
-/*!
- Called when X,Y position is changed
-*/
-void VisuGUI_ScalarBarPane::XYChanged( double )
-{
- QtxDblSpinBox* snd = (QtxDblSpinBox*)sender();
- if ( snd == XSpin ) {
- WidthSpin->setMaxValue( 1.0 - XSpin->value() );
- }
- if ( snd == YSpin ) {
- HeightSpin->setMaxValue( 1.0 - YSpin->value() );
- }
-}
-
-/*!
- Sets default values and range mode
-*/
-void VisuGUI_ScalarBarPane::setRange( double imin, double imax/*, double fmin, double fmax*/, bool sbRange )
-{
- Imin = imin; Imax = imax;// Fmin = fmin; Fmax = fmax;
- if ( RBIrange->isChecked() ) {
- MinEdit->setText( QString::number( Imin ) );
- MaxEdit->setText( QString::number( Imax ) );
- }
- else {
- MinEdit->setText( QString::number( Rmin ) );
- MaxEdit->setText( QString::number( Rmax ) );
- }
- myRangeMode = -1;
- if( sbRange )
- RBIrange->setChecked( true );
- else
- RBFrange->setChecked( true );
- changeRange( 0 );
-}
-
-/*!
- Sets size and position
-*/
-void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert )
-{
- if ( vert ) {
- myVerX = x;
- myVerY = y;
- myVerW = w;
- myVerH = h;
- RBvert->setChecked( true );
- }
- else {
- myHorX = x;
- myHorY = y;
- myHorW = w;
- myHorH = h;
- RBhori->setChecked( true );
- }
- changeDefaults( 0 );
-}
-
-/*!
- Sets colors and labels number
-*/
-void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels )
-{
- ColorSpin->setValue( colors );
- LabelSpin->setValue( labels );
-}
-
-/*!
- Gets orientation
-*/
-int VisuGUI_ScalarBarPane::getOrientation()
-{
- if (RBvert->isChecked() )
- return 1;
- else
- return 0;
-}
-
-
-
-/*!
- Called when <OK> button is clicked, validates data and closes dialog
-*/
-bool VisuGUI_ScalarBarPane::check()
-{
- double minVal = MinEdit->text().toDouble();
- double maxVal = MaxEdit->text().toDouble();
- if ( RBIrange->isChecked() ) {
- if (minVal >= maxVal) {
- SUIT_MessageBox::warn1( this,tr("WRN_VISU"),
- tr("MSG_MINMAX_VALUES"),
- tr("BUT_OK"));
- return false;
- }
- }
- // check if logarithmic mode is on and check imposed range to not contain negative values
- if ( CBLog->isChecked() ) {
- if ( RBIrange->isChecked() ) {
- if ( (minVal > 0) && (maxVal > 0) ) {
- // nothing to do
- }
- else {
- SUIT_MessageBox::warn1( this,
- tr("WRN_VISU"),
- tr("WRN_LOGARITHMIC_RANGE"),
- tr("BUT_OK"));
- return false;
- }
- }
- else {
- if ( Rmin > 0 && Rmax > 0 ) {
- // nothing to do
- }
- else {
- SUIT_MessageBox::warn1( this,
- tr("WRN_VISU"),
- tr("WRN_LOGARITHMIC_FIELD_RANGE"),
- tr("BUT_OK"));
- RBIrange->setChecked(1);
- changeRange(1);
- //MinEdit->setText( QString::number( Rmin ) );
- //MaxEdit->setText( QString::number( Rmax ) );
- return false;
- }
- }
- }
- return true;
-}
-
-
-void VisuGUI_ScalarBarPane::onTextPref() {
- myIsStoreTextProp = myTextDlg->exec();
-}
+#include "VISU_Result_i.hh"
+#include "VISU_ColoredPrs3dFactory.hh"
+#include "LightApp_Application.h"
+#include "SUIT_Session.h"
+#include "SUIT_MessageBox.h"
+#include "SUIT_ResourceMgr.h"
+#include <limits.h>
+#include <QLayout>
+#include <QValidator>
+#include <QColorDialog>
+#include <QTabWidget>
+#include <QPushButton>
+#include <QGridLayout>
+#include <QKeyEvent>
-//#######################################################################################
+#include <vtkTextProperty.h>
+using namespace std;
/*!
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)
+ : VisuGUI_ScalarBarBaseDlg(theModule)
{
- setName("VisuGUI_ScalarBarDlg");
- setCaption(SetPref ? tr("DLG_PREF_TITLE") : tr("DLG_PROP_TITLE"));
+ setWindowTitle(tr("DLG_PROP_TITLE"));
setSizeGripEnabled(TRUE);
QVBoxLayout* TopLayout = new QVBoxLayout(this);
TopLayout->setSpacing(6);
TopLayout->setMargin(11);
- myScalarPane = new VisuGUI_ScalarBarPane(this, SetPref);
- TopLayout->addWidget(myScalarPane);
+ myTabBox = new QTabWidget(this);
+ myInputPane = new VisuGUI_InputPane(VISU::TSCALARMAP, theModule, this);
+ myTabBox->addTab(GetScalarPane(), "Scalar Bar");
+ myTabBox->addTab(myInputPane, "Input");
+
+ TopLayout->addWidget(myTabBox);
// 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() );
+ QGroupBox* GroupButtons = new QGroupBox( this );
+ //GroupButtons->setColumnLayout(0, Qt::Vertical );
+ //GroupButtons->layout()->setSpacing( 0 );
+ //GroupButtons->layout()->setMargin( 0 );
+ QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons );
GroupButtonsLayout->setAlignment( Qt::AlignTop );
GroupButtonsLayout->setSpacing( 6 );
GroupButtonsLayout->setMargin( 11 );
- QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
+ QPushButton* buttonOk = new QPushButton( tr("BUT_OK"), GroupButtons );
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" );
+ QPushButton* buttonCancel = new QPushButton( tr("BUT_CANCEL") , GroupButtons );
buttonCancel->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
- TopLayout->addWidget( GroupButtons );
+ QPushButton* buttonHelp = new QPushButton( tr("BUT_HELP") , GroupButtons );
+ buttonHelp->setAutoDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
- connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
- connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+ TopLayout->addWidget( GroupButtons );
+ connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
+ connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+ connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
}
-
+VisuGUI_ScalarBarDlg::~VisuGUI_ScalarBarDlg()
+{}
/*!
- Called when <OK> button is clicked, validates data and closes dialog
+ Called when <Help> button is clicked, shows the corresponding help page in defined browser
*/
-void VisuGUI_ScalarBarDlg::accept()
+QString VisuGUI_ScalarBarDlg::GetContextHelpFilePath()
{
- if (myScalarPane->check()) QDialog::accept();
+ return "scalar_map_page.html";
}
-
-
-
-
-//#######################################################################################
-
-
-
-
-
-VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg(QWidget* parent) :
- QDialog(parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+/*!
+ Initialize dialog from the presentation
+*/
+void VisuGUI_ScalarBarDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs,
+ bool theInit )
{
- 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 );
+ if( theInit )
+ myPrsCopy = VISU::TSameAsFactory<VISU::TSCALARMAP>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
- TopLayout->addWidget( GroupButtons );
-
- connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
- connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
-}
+ VisuGUI_ScalarBarBaseDlg::initFromPrsObject(myPrsCopy, theInit);
+ if( !theInit )
+ return;
-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);
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->setCurrentIndex( 0 );
}
+/*!
+ Store dialog to the presentation
+*/
+int VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs)
+{
+ if (!myInputPane->check() || !GetScalarPane()->check())
+ return 0;
+
+ int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
+ anIsOk &= GetScalarPane()->storeToPrsObject( myPrsCopy );
+ VISU::TSameAsFactory<VISU::TSCALARMAP>().Copy(myPrsCopy, thePrs);
-#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; \
- } \
+ return anIsOk;
}
-
-GETFONT(getTitleFont, myTitFontCombo);
-SETFONT(setTitleFont, myTitFontCombo);
-
-GETFONT(getLabelFont, myLblFontCombo);
-SETFONT(setLabelFont, myLblFontCombo);
-
-#undef GETFONT
-#undef SETFONT