-// 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
+//
+// 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.
//
-// 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 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$
-
-using namespace std;
+//
#include "VisuGUI_ScalarBarDlg.h"
-#include <limits.h>
-#include <qlayout.h>
-#include <qvalidator.h>
-#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 )
-{
- 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;
- myRangeMode = -1;
-
- QVBoxLayout* TopLayout = new QVBoxLayout( this );
- TopLayout->setSpacing( 6 );
- TopLayout->setMargin( 11 );
-
- // Range ============================================================
- RangeGroup = new QButtonGroup( tr( "Scalar range" ), 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( "Use field range" ), RangeGroup, "RBFrange" );
- RBIrange = new QRadioButton( tr( "Use imposed range" ), 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( "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( "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 and labels" ), 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 );
+#include "VisuGUI.h"
+#include "VisuGUI_Tools.h"
+#include "VisuGUI_ViewTools.h"
+#include "VisuGUI_InputPane.h"
- QLabel* ColorLabel = new QLabel( tr( "Nb. of colors:" ), ColLabGroup, "ColorLabel" );
- ColorSpin = new QSpinBox( 2, 256, 1, ColLabGroup );
- ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- ColorSpin->setMinimumWidth( 70 );
- ColorSpin->setValue( 64 );
+#include "SVTK_ViewWindow.h"
+#include "SVTK_FontWidget.h"
- QLabel* LabelLabel = new QLabel( tr( "Nb. of 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);
+#include "VISUConfig.hh"
+#include "VISU_Convertor.hxx"
- TopLayout->addWidget( ColLabGroup );
+#include "VISU_ScalarMapPL.hxx"
+#include "VISU_ScalarMap_i.hh"
+#include "VISU_ScalarMapAct.h"
- // Orientation ==========================================================
- QButtonGroup* OrientGroup = new QButtonGroup( tr( "Orientation" ), 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 );
+#include "VISU_Result_i.hh"
+#include "VISU_ColoredPrs3dFactory.hh"
- RBvert = new QRadioButton( tr( "Vertical" ), OrientGroup, "RBvert" );
- RBvert->setChecked( true );
- RBhori = new QRadioButton( tr( "Horizontal" ), OrientGroup, "RBhori" );
- OrientGroupLayout->addWidget( RBvert, 0, 0 );
- OrientGroupLayout->addWidget( RBhori, 0, 1 );
-
- TopLayout->addWidget( OrientGroup );
+#include "LightApp_Application.h"
- // Origin ===============================================================
- QGroupBox* OriginGroup = new QGroupBox( tr( "Origin" ), 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 );
+#include "SUIT_Session.h"
+#include "SUIT_MessageBox.h"
+#include "SUIT_ResourceMgr.h"
- QLabel* XLabel = new QLabel( tr( "X:" ), OriginGroup, "XLabel" );
- XSpin = new QAD_SpinBoxDbl( OriginGroup, 0.0, 1.0, 0.1 );
- XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- XSpin->setMinimumWidth( 70 );
- XSpin->setValue( 0.01 );
+#include <limits.h>
- QLabel* YLabel = new QLabel( tr( "Y:" ), OriginGroup, "YLabel" );
- YSpin = new QAD_SpinBoxDbl( OriginGroup, 0.0, 1.0, 0.1 );
- 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);
+#include <QLayout>
+#include <QValidator>
+#include <QColorDialog>
+#include <QTabWidget>
+#include <QPushButton>
+#include <QGridLayout>
+#include <QKeyEvent>
- TopLayout->addWidget( OriginGroup );
+#include <vtkTextProperty.h>
- // Dimensions =========================================================
- QGroupBox* DimGroup = new QGroupBox( tr( "Dimensions" ), 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 );
+using namespace std;
- QLabel* WidthLabel = new QLabel( tr( "Width:" ), DimGroup, "WidthLabel" );
- WidthSpin = new QAD_SpinBoxDbl( DimGroup, 0.0, 1.0, 0.1 );
- WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- WidthSpin->setMinimumWidth( 70 );
- WidthSpin->setValue( 0.1 );
+/*!
+ Constructor
+*/
+VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule)
+ : VisuGUI_ScalarBarBaseDlg(theModule)
+{
+ setWindowTitle(tr("DLG_PROP_TITLE"));
+ setSizeGripEnabled(TRUE);
- QLabel* HeightLabel = new QLabel( tr( "Height:" ), DimGroup, "HeightLabel" );
- HeightSpin = new QAD_SpinBoxDbl( DimGroup, 0.0, 1.0, 0.1 );
- 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);
+ QVBoxLayout* TopLayout = new QVBoxLayout(this);
+ TopLayout->setSpacing(6);
+ TopLayout->setMargin(11);
- TopLayout->addWidget( DimGroup );
+ myTabBox = new QTabWidget(this);
+ myInputPane = new VisuGUI_InputPane(VISU::TSCALARMAP, theModule, this);
+ myTabBox->addTab(GetScalarPane(), "Scalar Bar");
+ myTabBox->addTab(myInputPane, "Input");
- // Save check box ===========================================================
- if ( !SetPref ) {
- CBSave = new QCheckBox( tr( "Save as default values" ), this, "CBSave" );
- TopLayout->addWidget( CBSave );
- }
- else {
- CBSave = 0;
- }
+ 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 );
- // 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() ) );
+ TopLayout->addWidget( GroupButtons );
- changeRange( 0 );
- changeDefaults( 0 );
+ connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
+ connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+ connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
}
-/*!
- Destructor
-*/
VisuGUI_ScalarBarDlg::~VisuGUI_ScalarBarDlg()
-{
-}
-
-
-/**
- * Initializes dialog box values from resources
- */
-void VisuGUI_ScalarBarDlg::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 Orientation = QAD_CONFIG->getSetting("Visu:SBOrientation");
- if ( !Orientation.isEmpty() ) {
- orient = Orientation.toInt();
- if(orient != 1) {
- orient=0;
- sbX1=0.2;
- sbY1=0.01;
- sbW=0.6;
- sbH=0.12;
- }
- }
-
- QString SBXorigin = QAD_CONFIG->getSetting("Visu:SBXorigin");
- if ( !SBXorigin.isEmpty() )
- sbX1 = SBXorigin.toFloat();
-
- QString SBYorigin = QAD_CONFIG->getSetting("Visu:SBYorigin");
- if ( !SBYorigin.isEmpty() )
- sbY1 = SBYorigin.toFloat();
-
- QString SBWidth = QAD_CONFIG->getSetting("Visu:SBWidth");
- if ( !SBWidth.isEmpty() )
- sbW = SBWidth.toFloat();
-
- QString SBHeight = QAD_CONFIG->getSetting("Visu:SBHeight");
- if ( !SBHeight.isEmpty() )
- sbH = SBHeight.toFloat();
-
- QString SBColors = QAD_CONFIG->getSetting("Visu:SBNumberOfColors");
- if ( !SBColors.isEmpty() )
- sbCol = SBColors.toInt();
-
- QString SBLabels = QAD_CONFIG->getSetting("Visu:SBNumberOfLabels");
- if ( !SBLabels.isEmpty() )
- sbLab = SBLabels.toInt();
-
- QString ImpRange = QAD_CONFIG->getSetting("Visu:SBImposeRange");
- if ( ImpRange.compare("true") == 0 )
- sbRange=true;
-
- QString SBVmin = QAD_CONFIG->getSetting("Visu:SBMinimumValue");
- if ( !SBVmin.isEmpty() )
- sbVmin = SBVmin.toFloat();
-
- QString SBVmax = QAD_CONFIG->getSetting("Visu:SBMaximumValue");
- if ( !SBVmax.isEmpty() )
- sbVmax = SBVmax.toFloat();
-
- QString aScaling = QAD_CONFIG->getSetting("Visu:SBScaling");
- 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 );
-}
-
-
-
-/**
- * Stores dialog values to resources
- */
-void VisuGUI_ScalarBarDlg::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.;
- }
-
- QAD_CONFIG->addSetting("Visu:SBOrientation",orient);
- QAD_CONFIG->addSetting("Visu:SBXorigin",sbX1);
- QAD_CONFIG->addSetting("Visu:SBYorigin",sbY1);
- QAD_CONFIG->addSetting("Visu:SBWidth",sbW);
- QAD_CONFIG->addSetting("Visu:SBHeight",sbH);
- QAD_CONFIG->addSetting("Visu:SBNumberOfColors",sbCol);
- QAD_CONFIG->addSetting("Visu:SBNumberOfLabels",sbLab);
- if(sbRange)
- QAD_CONFIG->addSetting("Visu:SBImposeRange", "true");
- else
- QAD_CONFIG->addSetting("Visu:SBImposeRange", "false");
- QAD_CONFIG->addSetting("Visu:SBMinimumValue",sbVmin);
- QAD_CONFIG->addSetting("Visu:SBMaximumValue",sbVmax);
- if(isLogarithmic())
- QAD_CONFIG->addSetting("Visu:SBScaling", "LOGARITHMIC");
- else
- QAD_CONFIG->addSetting("Visu:SBScaling", "LINEAR");
-}
-
-
-/**
- * Initialise dialog box from presentation object
- */
-void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::ScalarMap_i* thePrs) {
- myModeCombo->setCurrentItem(thePrs->GetScalarMode());
- setPosAndSize( thePrs->GetPosX(),
- thePrs->GetPosY(),
- thePrs->GetWidth(),
- thePrs->GetHeight(),
- thePrs->GetOrientation());
- switch(thePrs->GetScaling()){
- case VISU::LOGARITHMIC :
- setLogarithmic(true);
- break;
- default:
- setLogarithmic(false);
- }
- float aRange[2];
- thePrs->GetFieldRange(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);
-}
-
-
-/**
- * Store values to presentation object
- */
-void VisuGUI_ScalarBarDlg::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());
- }
- if(isLogarithmic())
- thePrs->SetScaling(VISU::LOGARITHMIC);
- else
- thePrs->SetScaling(VISU::LINEAR);
- thePrs->SetNbColors(ColorSpin->value());
- thePrs->SetLabels(LabelSpin->value());
- thePrs->Update();
-
- if (isToSave()) storeToResources();
-}
-
-
+{}
/*!
- Called when orientation is changed
+ Called when <Help> button is clicked, shows the corresponding help page in defined browser
*/
-void VisuGUI_ScalarBarDlg::changeDefaults( int )
+QString VisuGUI_ScalarBarDlg::GetContextHelpFilePath()
{
- 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 );
- }
+ return "scalar_map_page.html";
}
/*!
- Called when Range mode is changed
+ Initialize dialog from the presentation
*/
-void VisuGUI_ScalarBarDlg::changeRange( int )
+void VisuGUI_ScalarBarDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs,
+ bool theInit )
{
- 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;
-}
+ if( theInit )
+ myPrsCopy = VISU::TSameAsFactory<VISU::TSCALARMAP>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
-/*!
- Called when X,Y position is changed
-*/
-void VisuGUI_ScalarBarDlg::XYChanged( double )
-{
- QAD_SpinBoxDbl* snd = (QAD_SpinBoxDbl*)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_ScalarBarDlg::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 );
-}
+ VisuGUI_ScalarBarBaseDlg::initFromPrsObject(myPrsCopy, theInit);
-/*!
- Sets size and position
-*/
-void VisuGUI_ScalarBarDlg::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 );
-}
+ if( !theInit )
+ return;
-/*!
- Sets colors and labels number
-*/
-void VisuGUI_ScalarBarDlg::setScalarBarData( int colors, int labels )
-{
- ColorSpin->setValue( colors );
- LabelSpin->setValue( labels );
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->setCurrentIndex( 0 );
}
/*!
- Gets orientation
+ Store dialog to the presentation
*/
-int VisuGUI_ScalarBarDlg::getOrientation()
+int VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs)
{
- if (RBvert->isChecked() )
- return 1;
- else
+ if (!myInputPane->check() || !GetScalarPane()->check())
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();
-}
+
+ int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
+ anIsOk &= GetScalarPane()->storeToPrsObject( myPrsCopy );
-/*!
- Sets "Logarithmic scaling" check box on/off
-*/
-void VisuGUI_ScalarBarDlg::setLogarithmic( bool on )
-{
- CBLog->setChecked( on );
-}
+ VISU::TSameAsFactory<VISU::TSCALARMAP>().Copy(myPrsCopy, thePrs);
-/*!
- Called when <OK> button is clicked, validates data and closes dialog
-*/
-void VisuGUI_ScalarBarDlg::accept()
-{
- double minVal = MinEdit->text().toDouble();
- double maxVal = MaxEdit->text().toDouble();
- if ( RBIrange->isChecked() ) {
- if (minVal >= maxVal) {
- QAD_MessageBox::warn1( this,tr("VISU_WARNING"),
- tr("MSG_MINMAX_VALUES"),
- tr("VISU_BUT_OK"));
- return;
- }
- }
- // 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 {
- QAD_MessageBox::warn1( this,
- tr("VISU_WARNING"),
- tr("WRN_LOGARITHMIC_RANGE"),
- tr("VISU_BUT_OK"));
- return;
- }
- }
- else {
- if ( Rmin > 0 && Rmax > 0 ) {
- // nothing to do
- }
- else {
- QAD_MessageBox::warn1( this,
- tr("VISU_WARNING"),
- tr("WRN_LOGARITHMIC_FIELD_RANGE"),
- tr("VISU_BUT_OK"));
- RBIrange->setChecked(1);
- changeRange(1);
- //MinEdit->setText( QString::number( Rmin ) );
- //MaxEdit->setText( QString::number( Rmax ) );
- return;
- }
- }
- }
- QDialog::accept();
+ return anIsOk;
}