-// VISU VISUGUI : GUI of VISU component
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// 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
// 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
-//
-//
+// 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
// Module : VISU
// $Header$
-
+//
#include "VisuGUI_ScalarBarDlg.h"
#include "VisuGUI.h"
#include "VisuGUI_Tools.h"
#include "VisuGUI_ViewTools.h"
+#include "VisuGUI_InputPane.h"
#include "SVTK_ViewWindow.h"
#include "SVTK_FontWidget.h"
#include "VISU_ScalarMap_i.hh"
#include "VISU_ScalarMapAct.h"
+#include "VISU_Result_i.hh"
+#include "VISU_ColoredPrs3dFactory.hh"
+
#include "LightApp_Application.h"
#include "SUIT_Session.h"
#include "SUIT_ResourceMgr.h"
#include <limits.h>
-#include <qlayout.h>
-#include <qvalidator.h>
-#include <qcolordialog.h>
+
+#include <QLayout>
+#include <QValidator>
+#include <QColorDialog>
+#include <QTabWidget>
+#include <QPushButton>
+#include <QGridLayout>
+#include <QKeyEvent>
#include <vtkTextProperty.h>
using namespace std;
-
-VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref):
- QVBox(parent), myPreviewActor(0)
-{
- SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
- QString propertyName;
- propertyName = QString("scalar_bar_vertical_");
- myVerX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.);
- myVerY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.);
- myVerW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.);
- myVerH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.);
-
- propertyName = QString("scalar_bar_horizontal_");
- myHorX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.);
- myHorY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.);
- myHorW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.);
- myHorH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.);
-
- 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);
-
- 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);
-
- QGroupBox* CheckGroup = new QGroupBox("", this, "CheckGroup");
- CheckGroup->setColumnLayout(0, Qt::Vertical );
- CheckGroup->layout()->setSpacing( 0 );
- CheckGroup->layout()->setMargin( 0 );
- QGridLayout* CheckGroupLayout = new QGridLayout( CheckGroup->layout() );
-
- myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), CheckGroup);
- myPreviewCheck->setChecked(false);
- CheckGroupLayout->addWidget(myPreviewCheck , 0, 0 );
-
- // signals and slots connections ===========================================
- connect( RangeGroup, SIGNAL( clicked( int ) ), this, SLOT( changeRange( int ) ) );
- connect( myModeCombo, SIGNAL( activated( int ) ), this, SLOT( changeScalarMode( 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() ) );
- connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) );
- connect( ColorSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ));
- connect( LabelSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() ));
- connect( WidthSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
- connect( HeightSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() ));
- connect( CBLog, SIGNAL( toggled( bool ) ), this, SLOT( updatePreview() ));
- changeRange( 0 );
- changeDefaults( 0 );
- myIsStoreTextProp = false;
- myBusy = false;
-}
-
-/**
- * Initializes dialog box values from resources
- */
-void VisuGUI_ScalarBarPane::initFromResources() {
- int sbCol=64,sbLab=5,orient=0;
- float sbX1=0.01,sbY1=0.1,sbW=0.1,sbH=0.8;
- float sbVmin=0., sbVmax=0.;
- bool sbRange=false;
- QString aString;
-
- SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
-
- bool anIsArrangeBar = aResourceMgr->booleanValue("VISU", "scalar_bars_default_position", 0);
- int aPlace = 1;
- if (anIsArrangeBar){
- aPlace = aResourceMgr->integerValue("VISU", "scalar_bar_position_num",0);
- }
-
- int aScalarMode = aResourceMgr->integerValue("VISU", "scalar_bar_mode", 0);
- myModeCombo->setCurrentItem(aScalarMode);
-
- orient = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", orient);
- if(orient != 0){
- orient=1;
- sbX1=0.2;
- sbY1=0.01;
- sbW=0.6;
- sbH=0.12;
- }
-
- QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
-
- sbX1 = aResourceMgr->doubleValue("VISU", propertyName + "x", sbX1);
- sbY1 = aResourceMgr->doubleValue("VISU", propertyName + "y", sbY1);
-
- sbW = aResourceMgr->doubleValue("VISU", propertyName + "width", sbW);
- sbH = aResourceMgr->doubleValue("VISU", propertyName + "height",sbH);
-
- if(orient){
- sbY1 += sbH*(aPlace-1);
- } else {
- sbX1 += sbW*(aPlace-1);
- }
- sbCol = aResourceMgr->integerValue("VISU" ,"scalar_bar_num_colors", sbCol);
- sbLab = aResourceMgr->integerValue("VISU", "scalar_bar_num_labels", sbLab);
-
- int rangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0);
- if (rangeType == 1) sbRange = true;
- sbVmin = aResourceMgr->doubleValue("VISU", "scalar_range_min", sbVmin);
- sbVmax = aResourceMgr->doubleValue("VISU", "scalar_range_max", sbVmax);
-
- bool isLog = aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false);
- setLogarithmic(isLog);
-
- if((sbX1 < 0.) || (sbY1 < 0.) ||
- ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
- if(orient == 0) {
- 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 == 0);
- setScalarBarData( sbCol, sbLab );
-
- // "Title"
- bool isBold = false, isItalic = false, isShadow = false;
- int aFontFamily = VTK_ARIAL;
-
- if ( aResourceMgr->hasValue( "VISU", "scalar_bar_title_font" ) )
- {
- QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_title_font" );
-
- if ( f.family() == "Arial" )
- aFontFamily = VTK_ARIAL;
- else if ( f.family() == "Courier" )
- aFontFamily = VTK_COURIER;
- else if ( f.family() == "Times" )
- aFontFamily = VTK_TIMES;
-
- isBold = f.bold();
- isItalic = f.italic();
- isShadow = f.underline();
- }
-
- QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
-
- myTextDlg->myTitleFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow);
-
- // "Labels"
- isBold = isItalic = isShadow = false;
- aFontFamily = VTK_ARIAL;
-
- if ( aResourceMgr->hasValue( "VISU", "scalar_bar_label_font" ) )
- {
- QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_label_font" );
-
- if ( f.family() == "Arial" )
- aFontFamily = VTK_ARIAL;
- else if ( f.family() == "Courier" )
- aFontFamily = VTK_COURIER;
- else if ( f.family() == "Times" )
- aFontFamily = VTK_TIMES;
-
- isBold = f.bold();
- isItalic = f.italic();
- isShadow = f.underline();
- }
-
- aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
-
- myTextDlg->myLabelFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow);
-}
-
-/**
- * Stores dialog values to resources
- */
-void VisuGUI_ScalarBarPane::storeToResources() {
- int orient = (RBvert->isChecked())? 0 : 1;
- float sbX1 = XSpin->value();
- float sbY1 = YSpin->value();
- float sbW = WidthSpin->value();
- float sbH = HeightSpin->value();
- int sbCol = ColorSpin->value();
- int sbLab = LabelSpin->value();
-
- if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) {
- if(orient == 0) {
- 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", "scalar_bar_orientation", orient);
-
- QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" );
-
- aResourceMgr->setValue("VISU", propertyName + "x", sbX1);
- aResourceMgr->setValue("VISU", propertyName + "y", sbY1);
- aResourceMgr->setValue("VISU", propertyName + "width", sbW);
- aResourceMgr->setValue("VISU", propertyName + "height", sbH);
-
- aResourceMgr->setValue("VISU", "scalar_bar_num_colors", sbCol);
- aResourceMgr->setValue("VISU", "scalar_bar_num_labels", sbLab);
-
- if(sbRange)
- {
- aResourceMgr->setValue("VISU", "scalar_range_type", 1);
- aResourceMgr->setValue("VISU", "scalar_range_min" ,sbVmin);
- aResourceMgr->setValue("VISU", "scalar_range_max" ,sbVmax);
- }
- else
- aResourceMgr->setValue("VISU", "scalar_range_type", 0);
-
- aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic());
-
- ////
-
- if (myIsStoreTextProp) {
- // "Title"
- QColor aTitleColor (255, 255, 255);
- int aTitleFontFamily = VTK_ARIAL;
- bool isTitleBold = false;
- bool isTitleItalic = false;
- bool isTitleShadow = false;
-
- myTextDlg->myTitleFont->GetData(aTitleColor, aTitleFontFamily,
- isTitleBold, isTitleItalic, isTitleShadow);
-
- QFont aTitleFont;
-
- aTitleFont.setBold(isTitleBold);
- aTitleFont.setItalic(isTitleItalic);
- aTitleFont.setUnderline(isTitleShadow);
-
- QString titleFontFamily;
- switch (aTitleFontFamily) {
- case VTK_ARIAL:
- titleFontFamily = "Arial";
- break;
- case VTK_COURIER:
- titleFontFamily = "Courier";
- break;
- case VTK_TIMES:
- titleFontFamily = "Times";
- break;
- }
- aTitleFont.setFamily(titleFontFamily);
-
- aResourceMgr->setValue("VISU", "scalar_bar_title_font", aTitleFont);
-
- aResourceMgr->setValue("VISU", "scalar_bar_title_color", aTitleColor);
-
- // "Label"
- QColor aLabelColor (255, 255, 255);
- int aLabelFontFamily = VTK_ARIAL;
- bool isLabelBold = false;
- bool isLabelItalic = false;
- bool isLabelShadow = false;
-
- myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
- isLabelBold, isLabelItalic, isLabelShadow);
-
-
- QFont aLabelFont;
-
- aLabelFont.setBold(isLabelBold);
- aLabelFont.setItalic(isLabelItalic);
- aLabelFont.setUnderline(isLabelShadow);
-
- QString labelFontFamily;
- switch (aLabelFontFamily) {
- case VTK_ARIAL:
- labelFontFamily = "Arial";
- break;
- case VTK_COURIER:
- labelFontFamily = "Courier";
- break;
- case VTK_TIMES:
- labelFontFamily = "Times";
- break;
- }
-
- aLabelFont.setFamily(labelFontFamily);
-
- aResourceMgr->setValue("VISU", "scalar_bar_label_font", aLabelFont);
-
- aResourceMgr->setValue("VISU", "scalar_bar_label_color", aLabelColor);
- }
-}
-
-/**
- * Initialise dialog box from presentation object
- */
-void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ScalarMap_i* thePrs) {
- initFromResources();
- myScalarMap = thePrs;
- myTitle = thePrs->GetTitle();
- setPosAndSize( thePrs->GetPosX(),
- thePrs->GetPosY(),
- thePrs->GetWidth(),
- thePrs->GetHeight(),
- thePrs->GetBarOrientation());
- switch(thePrs->GetScaling()){
- case VISU::LOGARITHMIC :
- setLogarithmic(true);
- break;
- default:
- setLogarithmic(false);
- }
- vtkFloatingPointType 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() );
-
- // Update myModeCombo
- int aNbComp = thePrs->GetField()->myNbComp;
- bool isScalarMode = (aNbComp > 1);
- myModeCombo->clear();
- myModeCombo->insertItem("<Modulus>");
- const VISU::PField& aField = thePrs->GetField();
- const VISU::TNames& aCompNames = aField->myCompNames;
- const VISU::TNames& aUnitNames = aField->myUnitNames;
- for(int i = 0; i < aNbComp; i++){
- QString aComponent = QString(aCompNames[i].c_str()).simplifyWhiteSpace();
- if(aComponent.isNull() || aComponent == "")
- aComponent = "Component " + QString::number(i+1);
- else
- aComponent = "[" + QString::number(i+1) + "] " + aComponent;
-
- QString anUnit = QString(aUnitNames[i].c_str()).simplifyWhiteSpace();
- if(anUnit.isNull() || anUnit == "")
- anUnit = "-";
-
- aComponent = aComponent + ", " + anUnit;
-
- myModeCombo->insertItem(aComponent);
- }
- //
- myModeCombo->setCurrentItem(thePrs->GetScalarMode());
- if (aNbComp==1){
- myModeCombo->setCurrentItem(1);
- }
- //
- myModeLbl->setEnabled(isScalarMode);
- myModeCombo->setEnabled(isScalarMode);
-
- // "Title"
- myTextDlg->setTitleText(QString(thePrs->GetTitle()));
-
- vtkFloatingPointType R, G, B;
- thePrs->GetTitleColor(&R, &G, &B);
-
- 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->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)),
- thePrs->GetLblFontType(),
- thePrs->IsBoldLabel(),
- thePrs->IsItalicLabel(),
- thePrs->IsShadowLabel());
-
- // Draw Preview
- if (myPreviewCheck->isChecked()) {
- createScalarBar();
- updatePreview();
- }
-
-}
-/*! Slot update preview of scalar bar, if preview is checked
- */
-void VisuGUI_ScalarBarPane::updatePreview()
-{
- if (myPreviewCheck->isChecked()) {
- if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
- deleteScalarBar();
- createScalarBar();
- vf->Repaint();
- }
- }
-}
-
-/*! Creating preview scalar bar
- */
-void VisuGUI_ScalarBarPane::createScalarBar()
-{
- if (VISU::GetActiveViewWindow<SVTK_ViewWindow>() == NULL) return;
- if (myPreviewActor != 0) return;
- if (myScalarMap == NULL) return;
-
- if (!check()) return;
- myScalarMapPL = VISU_ScalarMapPL::New();
- if(myScalarMap->GetScalarMapPL())
- myScalarMapPL->ShallowCopy(myScalarMap->GetScalarMapPL());
-
- if ( myBusy ) return;
-
- myBusy = true;
-
- int sbCol,sbLab;
- sbCol = getNbColors();
- sbLab = getNbLabels();
- if(sbCol < 2) sbCol=2;
- if(sbCol > 64) sbCol=64;
- if(sbLab < 2) sbLab=2;
- if(sbLab > 65) sbLab=65;
- myPreviewActor = VISU_ScalarMapAct::New();
- VISU_ScalarBarActor* aScalarBarActor = myPreviewActor->GetScalarBar();
- myPreviewActor->GetScalarBar()->VisibilityOn();
- myPreviewActor->PickableOff();
-
- myScalarMapPL->SetScalarMode(myModeCombo->currentItem());
- if(isLogarithmic())
- myScalarMapPL->SetScaling(VISU::LOGARITHMIC);
- else
- myScalarMapPL->SetScaling(VISU::LINEAR);
- vtkFloatingPointType theRange[2];
- theRange[0] = (vtkFloatingPointType)MinEdit->text().toDouble();
- theRange[1] = (vtkFloatingPointType)MaxEdit->text().toDouble();
- myScalarMapPL->SetScalarRange(theRange);
- myScalarMapPL->SetNbColors(sbCol);
-
- myScalarMapPL->Update();
-
- aScalarBarActor->SetLookupTable(myScalarMapPL->GetBarTable());
-
- if (myTextDlg->getTitleText().latin1() != "")
- aScalarBarActor->SetTitle(myTextDlg->getTitleText().latin1());
- else
- aScalarBarActor->SetTitle(myTitle.c_str());
- aScalarBarActor->SetOrientation(getOrientation());
- aScalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
- aScalarBarActor->GetPositionCoordinate()->SetValue(getX(),getY());
- aScalarBarActor->SetWidth(getWidth());
- aScalarBarActor->SetHeight(getHeight());
- aScalarBarActor->SetNumberOfLabels(sbLab);
- aScalarBarActor->SetMaximumNumberOfColors(sbCol);
-
- // title text property
- QColor aTitleColor;
- int aTitleFontFamily;
- bool isTitleBold;
- bool isTitleItalic;
- bool isTitleShadow;
- myTextDlg->myTitleFont->GetData(aTitleColor,aTitleFontFamily,
- isTitleBold,isTitleItalic,isTitleShadow);
- vtkTextProperty* aTitleProp = aScalarBarActor->GetTitleTextProperty();
- aTitleProp->SetFontFamily(aTitleFontFamily);
- aTitleProp->SetColor(vtkFloatingPointType(aTitleColor.red())/255.,
- vtkFloatingPointType(aTitleColor.green())/255.,
- vtkFloatingPointType(aTitleColor.blue())/255.);
- (isTitleBold)? aTitleProp->BoldOn() : aTitleProp->BoldOff();
- (isTitleItalic)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff();
- (isTitleShadow)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff();
-
- // label text property
- QColor aLabelColor;
- int aLabelFontFamily;
- bool isLabelBold;
- bool isLabelItalic;
- bool isLabelShadow;
- myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily,
- isLabelBold, isLabelItalic, isLabelShadow);
- vtkTextProperty* aLabelProp = aScalarBarActor->GetLabelTextProperty();
- aLabelProp->SetFontFamily(aLabelFontFamily);
- aLabelProp->SetColor(vtkFloatingPointType(aLabelColor.red())/255.,
- vtkFloatingPointType(aLabelColor.green())/255.,
- vtkFloatingPointType(aLabelColor.blue())/255.);
- (isLabelBold)? aLabelProp->BoldOn() : aLabelProp->BoldOff();
- (isLabelItalic)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff();
- (isLabelShadow)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff();
-
- aScalarBarActor->Modified();
-
- VISU::GetActiveViewWindow<SVTK_ViewWindow>()->AddActor(myPreviewActor);
-
- myBusy = false;
-}
-/*! Deleting preview scalar bar
- */
-void VisuGUI_ScalarBarPane::deleteScalarBar()
-{
- if ( myBusy ) return;
-
- if (myPreviewActor == 0) return;
- vtkRenderer* aRend = myPreviewActor->GetRenderer();
- if(aRend)
- myPreviewActor->RemoveFromRender(aRend);
- myPreviewActor->GetScalarBar()->VisibilityOff();
- myPreviewActor->Delete();
- myPreviewActor = 0;
-
- if (myScalarMapPL){
- myScalarMapPL->Delete();
- myScalarMapPL = 0;
- }
-}
-/*! public: Deleting preview scalar bar
- */
-void VisuGUI_ScalarBarPane::deletePreview()
-{
- deleteScalarBar();
- if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>())
- vf->Repaint();
-}
-/**
- * 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) {
- // "Title"
- thePrs->SetTitle(myTextDlg->getTitleText().latin1());
-
- 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.);
-
- // "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.);
- myIsStoreTextProp = false;
- }
-
- 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 );
- }
- updatePreview();
-}
-
-/*!
- 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;
- updatePreview();
-}
-
-/*!
- 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() );
- }
- updatePreview();
-}
-
-/*!
- Called when scalar mode is changed
-*/
-void VisuGUI_ScalarBarPane::changeScalarMode( int theMode )
-{
- if ( myScalarMap ) {
- if ( RBFrange->isChecked() ) {
- vtkFloatingPointType aRange[2];
- int aMode = myScalarMap->GetScalarMode();
- myScalarMap->SetScalarMode(theMode);
- myScalarMap->GetScalarMapPL()->GetSourceRange(aRange);
- MinEdit->setText( QString::number( aRange[0] ) );
- MaxEdit->setText( QString::number( aRange[1] ) );
- myScalarMap->SetScalarMode(aMode);
- }
- }
- updatePreview();
-}
-
-/*!
- 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 default values and range mode
-*/
-void VisuGUI_ScalarBarPane::setDefaultRange(double imin, double imax){
- Rmin = imin;
- Rmax = imax;
-}
-
-/*!
- 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()
-{
- myTextDlg->storeBeginValues();
- myIsStoreTextProp = myTextDlg->exec() || myIsStoreTextProp;
- updatePreview();
-}
-
-void VisuGUI_ScalarBarPane::onPreviewCheck (bool thePreview)
-{
- if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow<SVTK_ViewWindow>()) {
- if (thePreview) {
- createScalarBar();
- } else {
- deleteScalarBar();
- }
- vf->Repaint();
- }
-}
-
-//#######################################################################################
-
/*!
Constructor
*/
-VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool SetPref)
- : QDialog(VISU::GetDesktop(theModule), 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 );
- QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" );
+ QPushButton* buttonHelp = new QPushButton( tr("BUT_HELP") , GroupButtons );
buttonHelp->setAutoDefault( TRUE );
GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
}
-/*!
- Called when <OK> button is clicked, validates data and closes dialog
-*/
-void VisuGUI_ScalarBarDlg::accept()
-{
- if (myScalarPane->check())
- {
- myScalarPane->deletePreview();
- QDialog::accept();
- }
-}
+VisuGUI_ScalarBarDlg::~VisuGUI_ScalarBarDlg()
+{}
/*!
- Called when <Cancel> button is clicked, remove preview and closes dialog
+ Called when <Help> button is clicked, shows the corresponding help page in defined browser
*/
-void VisuGUI_ScalarBarDlg::reject()
+QString VisuGUI_ScalarBarDlg::GetContextHelpFilePath()
{
- myScalarPane->deletePreview();
- QDialog::reject();
+ return "scalar_map_page.html";
}
/*!
- Called when <Help> button is clicked, shows the corresponding help page in defined browser
+ Initialize dialog from the presentation
*/
-void VisuGUI_ScalarBarDlg::onHelp()
+void VisuGUI_ScalarBarDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs,
+ bool theInit )
{
- QString aHelpFileName = "/files/scalar_map_presentation.htm";
- LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
- if (app) {
- VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
- app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
- }
- else {
- SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
- QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
- arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName),
- QObject::tr("BUT_OK"));
- }
-}
-
-
-//#######################################################################################
-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 SVTK_FontWidget (aHBox);
-
- TopLayout->addWidget(aTitleGrp);
-
- // "Labels" grp
- QGroupBox* aLabelsGrp = new QGroupBox (1, Qt::Vertical, tr("LBL_LABELS"), this);
-
- // font
- aHBox = new QHBox (aLabelsGrp);
- aHBox->setSpacing(5);
- myLabelFont = new SVTK_FontWidget (aHBox);
+ if( theInit )
+ myPrsCopy = VISU::TSameAsFactory<VISU::TSCALARMAP>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
- TopLayout->addWidget(aLabelsGrp);
+ VisuGUI_ScalarBarBaseDlg::initFromPrsObject(myPrsCopy, theInit);
- // 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 );
-
- QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" );
- buttonHelp->setAutoDefault( TRUE );
- GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
-
- TopLayout->addWidget( GroupButtons );
-
- connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
- connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
- connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp()));
-}
+ if( !theInit )
+ return;
-void VisuGUI_TextPrefDlg::onHelp()
-{
- QString aHelpFileName = "/files/scalar_map_presentation.htm";
- LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
- if (app) {
- VisuGUI* aVisuGUI = dynamic_cast<VisuGUI*>( app->activeModule() );
- app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName);
- }
- else {
- SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
- QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
- arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName),
- QObject::tr("BUT_OK"));
- }
-}
-
-void VisuGUI_TextPrefDlg::storeBeginValues()
-{
- myTitle = myTitleEdt->text();
- myTitleFont->GetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]);
- myLabelFont->GetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]);
+ myInputPane->initFromPrsObject( myPrsCopy );
+ myTabBox->setCurrentIndex( 0 );
}
/*!
- Called when <Cancel> button is clicked, restore begin values
+ Store dialog to the presentation
*/
-void VisuGUI_TextPrefDlg::reject()
+int VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs)
{
- myTitleEdt->setText(myTitle);
- myTitleFont->SetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]);
- myLabelFont->SetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]);
+ if (!myInputPane->check() || !GetScalarPane()->check())
+ return 0;
+
+ int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
+ anIsOk &= GetScalarPane()->storeToPrsObject( myPrsCopy );
- QDialog::reject();
-}
-/*!
- Called when <Ok> button is clicked, store begin values
-*/
-void VisuGUI_TextPrefDlg::accept()
-{
- storeBeginValues();
+ VISU::TSameAsFactory<VISU::TSCALARMAP>().Copy(myPrsCopy, thePrs);
- QDialog::accept();
+ return anIsOk;
}