-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011 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-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.
+// 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// SMESH SMESHGUI : GUI for SMESH component
// File : SMESHGUI_Preferences_ScalarBarDlg.cxx
// Author : Nicolas REJNERI, Open CASCADE S.A.S.
#include "SMESHGUI_Preferences_ScalarBarDlg.h"
#include "SMESHGUI.h"
+#include "SMESHGUI_SpinBox.h"
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_Utils.h"
#include <SMESH_Actor.h>
+#include <SMESH_ActorUtils.h>
+#include <SMESH_ScalarBarActor.h>
+#include <SMESH_ControlsDef.hxx>
// SALOME GUI includes
#include <SUIT_Desktop.h>
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <SALOME_ListIO.hxx>
+#include <SalomeApp_IntSpinBox.h>
-#include <QtxDoubleSpinBox.h>
#include <QtxColorButton.h>
// Qt includes
#include <QLineEdit>
#include <QPushButton>
#include <QRadioButton>
-#include <QSpinBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
// VTK includes
#include <vtkTextProperty.h>
-#include <vtkScalarBarActor.h>
#include <vtkLookupTable.h>
#define MINIMUM_WIDTH 70
QHBoxLayout* myLabColorGrpLayout = new QHBoxLayout( myLabColorGrp );
myLabColorGrpLayout->setSpacing( SPACING_SIZE ); myLabColorGrpLayout->setMargin( MARGIN_SIZE );
- myColorsSpin = new QSpinBox( myLabColorGrp );
+ myColorsSpin = new SalomeApp_IntSpinBox( myLabColorGrp );
+ myColorsSpin->setAcceptNames( false ); // No Notebook variables allowed
myColorsSpin->setRange( 2, 256 );
myColorsSpin->setSingleStep( 1 );
myColorsSpin->setMinimumWidth( MINIMUM_WIDTH );
myColorsSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- myLabelsSpin = new QSpinBox( myLabColorGrp );
+ myLabelsSpin = new SalomeApp_IntSpinBox( myLabColorGrp );
+ myLabelsSpin->setAcceptNames( false ); // No Notebook variables allowed
myLabelsSpin->setRange( 2, 65 );
myLabelsSpin->setSingleStep( 1 );
myLabelsSpin->setMinimumWidth( MINIMUM_WIDTH );
QGridLayout* myOriginDimGrpLayout = new QGridLayout( myOriginDimGrp );
myOriginDimGrpLayout->setSpacing( SPACING_SIZE ); myOriginDimGrpLayout->setMargin( MARGIN_SIZE );
- myXSpin = new QtxDoubleSpinBox (0.0, 1.0, 0.1, myOriginDimGrp);
+ myXSpin = new SMESHGUI_SpinBox(myOriginDimGrp);
+ myXSpin->setAcceptNames( false );
+ myXSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" );
myXSpin->setMinimumWidth( MINIMUM_WIDTH );
myXSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- myYSpin = new QtxDoubleSpinBox(0.0, 1.0, 0.1, myOriginDimGrp);
+ myYSpin = new SMESHGUI_SpinBox(myOriginDimGrp);
+ myYSpin->setAcceptNames( false );
+ myYSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" );
myYSpin->setMinimumWidth( MINIMUM_WIDTH );
myYSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- myWidthSpin = new QtxDoubleSpinBox(0.0, 1.0, 0.1, myOriginDimGrp);
+ myWidthSpin = new SMESHGUI_SpinBox(myOriginDimGrp);
+ myWidthSpin->setAcceptNames( false );
+ myWidthSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" );
myWidthSpin->setMinimumWidth( MINIMUM_WIDTH );
myWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- myHeightSpin = new QtxDoubleSpinBox(0.0, 1.0, 0.1, myOriginDimGrp);
+ myHeightSpin = new SMESHGUI_SpinBox(myOriginDimGrp);
+ myHeightSpin->setAcceptNames( false );
+ myHeightSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" );
myHeightSpin->setMinimumWidth( MINIMUM_WIDTH );
myHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
myOriginDimGrpLayout->addWidget( myHeightSpin, 1, 3 );
aTopLayout->addWidget( myOriginDimGrp );
+ /******************************************************************************/
- /***************************************************************/
+ // Destribution
+ myDistributionGrp = new QGroupBox ( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), this );
+ myDistributionGrp->setCheckable(true);
+ QHBoxLayout* aDistributionGrpLayout = new QHBoxLayout( myDistributionGrp );
+ aDistributionGrpLayout->setSpacing( SPACING_SIZE ); aDistributionGrpLayout->setMargin( MARGIN_SIZE );
+
+ myDistribColorGrp = new QButtonGroup( this );
+
+ myDMonoColor = new QRadioButton( tr( "SMESH_MONOCOLOR" ) , myDistributionGrp );
+ myDMultiColor = new QRadioButton( tr( "SMESH_MULTICOLOR" ), myDistributionGrp );
+ myDMonoColor->setChecked( true );
+
+ myDistribColorGrp->addButton(myDMonoColor);myDistribColorGrp->setId(myDMonoColor,1);
+ myDistribColorGrp->addButton(myDMultiColor);myDistribColorGrp->setId(myDMultiColor,2);
+
+ aDistributionGrpLayout->addWidget( myDMultiColor );
+ aDistributionGrpLayout->addWidget( myDMonoColor );
+
+ //Color of the Distribution in monocolor case:
+ myDistributionColorLbl = new QLabel( tr( "SMESH_DISTRIBUTION_COLOR" ), myDistributionGrp );
+ aDistributionGrpLayout->addWidget( myDistributionColorLbl );
+ myMonoColorBtn = new QtxColorButton( myDistributionGrp );
+ aDistributionGrpLayout->addWidget(myMonoColorBtn);
+
+ aTopLayout->addWidget(myDistributionGrp);
+
+ /******************************************************************************/
// Common buttons
myButtonGrp = new QGroupBox( this );
QHBoxLayout* myButtonGrpLayout = new QHBoxLayout( myButtonGrp );
setOriginAndSize(myIniX, myIniY, myIniW, myIniH);
+
+ bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
+ myDistributionGrp->setChecked(distributionVisibility);
+
+ int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
+ if( coloringType == SMESH_MONOCOLOR_TYPE ) {
+ myDMonoColor->setChecked(true);
+ onDistributionChanged(myDistribColorGrp->id(myDMonoColor));
+ } else {
+ myDMultiColor->setChecked(true);
+ onDistributionChanged(myDistribColorGrp->id(myDMultiColor));
+
+ }
+
+ QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
+ QColor(255, 255, 255));
+ myMonoColorBtn->setColor(distributionColor);
+
+
+
// --> then init from selection if necessary
onSelectionChanged();
connect( myXSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) );
connect( myYSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) );
connect( aOrientationGrp, SIGNAL( buttonClicked( int ) ), this, SLOT( onOrientationChanged() ) );
+ connect( myDistributionGrp, SIGNAL( toggled(bool) ), this, SLOT(onDistributionActivated(bool)) );
+ connect( myDistribColorGrp, SIGNAL( buttonClicked( int ) ), this, SLOT( onDistributionChanged( int ) ) );
connect( mySelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) );
connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( onCancel() ) );
- myHelpFileName = "about_quality_controls_page.html";
+ myHelpFileName = "quality_page.html";
}
//=================================================================================================
// Scalar Bar properties
if (!myActor)
return false;
- vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor();
+ SMESH_ScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor();
vtkTextProperty* aTitleTextPrp = myScalarBarActor->GetTitleTextProperty();
QColor aTColor = myTitleColorBtn->color();
myScalarBarActor->SetLabelTextProperty( aLabelsTextPrp );
myScalarBarActor->SetNumberOfLabels( myLabelsSpin->value() );
- myScalarBarActor->SetMaximumNumberOfColors( myColorsSpin->value() );
if ( myHorizRadioBtn->isChecked() )
myScalarBarActor->SetOrientationToHorizontal();
myScalarBarActor->SetWidth( myWidthSpin->value() );
myScalarBarActor->SetHeight( myHeightSpin->value() );
+ // Distribution
+ bool distributionTypeChanged = false, colorChanged=false;
+ myScalarBarActor->SetDistributionVisibility((int)myDistributionGrp->isChecked());
+ if( myDistributionGrp->isChecked() ) {
+ int ColoringType = myDMultiColor->isChecked() ? SMESH_MULTICOLOR_TYPE : SMESH_MONOCOLOR_TYPE;
+ distributionTypeChanged = (ColoringType != myScalarBarActor->GetDistributionColoringType());
+ if(distributionTypeChanged)
+ myScalarBarActor->SetDistributionColoringType(ColoringType);
+
+ if( !myDMultiColor->isChecked() ) {
+ QColor aTColor = myMonoColorBtn->color();
+ double rgb[3], oldRgb[3];;
+ rgb [0] = aTColor.red()/255.;
+ rgb [1] = aTColor.green()/255.;
+ rgb [2] = aTColor.blue()/255.;
+ myScalarBarActor->GetDistributionColor(oldRgb);
+ colorChanged = (rgb[0] != oldRgb[0] || rgb[1] != oldRgb[1] || rgb[2] != oldRgb[2]);
+ if(colorChanged)
+ myScalarBarActor->SetDistributionColor(rgb);
+ }
+ }
+
double aMin = myMinEdit->text().toDouble();
double aMax = myMaxEdit->text().toDouble();
vtkLookupTable* myLookupTable =
static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
+ double oldMinMax[2] = { myLookupTable->GetRange()[0], myLookupTable->GetRange()[1] };
+ bool rangeChanges = ( fabs( oldMinMax[0] - aMin ) + fabs( oldMinMax[1] - aMax ) >
+ 0.001 * ( aMax-aMin + oldMinMax[1]-oldMinMax[0] ));
+
+ bool nbColorsChanged = (myColorsSpin->value() != myScalarBarActor->GetMaximumNumberOfColors());
+ if(nbColorsChanged)
+ myScalarBarActor->SetMaximumNumberOfColors(myColorsSpin->value());
+
+
myLookupTable->SetRange( aMin, aMax );
myLookupTable->SetNumberOfTableValues(myColorsSpin->value());
myLookupTable->Build();
+
+ if( nbColorsChanged || rangeChanges)
+ myActor->UpdateDistribution();
+
+#ifndef DISABLE_PLOT2DVIEWER
+ if( myActor->GetPlot2Histogram() &&
+ (nbColorsChanged ||
+ rangeChanges ||
+ distributionTypeChanged ||
+ colorChanged ))
+ SMESH::ProcessIn2DViewers(myActor);
+#endif
+
+
+
SMESH::RepaintCurrentView();
return true;
}
SMESH_Actor* anActor = SMESH::FindActorByEntry(anIO->getEntry());
if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
myActor = anActor;
- vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor();
+ SMESH_ScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor();
if ( myScalarBarActor->GetLookupTable() ) {
vtkFloatingPointType *range = myScalarBarActor->GetLookupTable()->GetRange();
myIniH = myScalarBarActor->GetHeight();
setOriginAndSize( myIniX, myIniY, myIniW, myIniH );
+ int coloringType = myScalarBarActor->GetDistributionColoringType();
+ myScalarBarActor->GetDistributionColor( aTColor );
+ myMonoColorBtn->setColor( QColor( (int)( aTColor[0]*255 ), (int)( aTColor[1]*255 ), (int)( aTColor[2]*255 ) ) );
+ if ( coloringType == SMESH_MONOCOLOR_TYPE ) {
+ myDMonoColor->setChecked(true);
+ onDistributionChanged(myDistribColorGrp->id(myDMonoColor));
+ } else {
+ myDMultiColor->setChecked(true);
+ onDistributionChanged(myDistribColorGrp->id(myDMultiColor));
+ }
+ myDistributionGrp->setChecked((bool)myScalarBarActor->GetDistributionVisibility());
+ onDistributionActivated(myScalarBarActor->GetDistributionVisibility());
+
+
myRangeGrp->setEnabled( true );
myFontGrp->setEnabled( true );
myLabColorGrp->setEnabled( true );
myOriginDimGrp->setEnabled( true );
myOkBtn->setEnabled( true );
myApplyBtn->setEnabled( true );
+ myDistributionGrp->setEnabled( true );
return;
}
}
myOriginDimGrp->setEnabled( false );
myOkBtn->setEnabled( false );
myApplyBtn->setEnabled( false );
+ myDistributionGrp->setEnabled( false );
}
//=================================================================================================
onXYChanged();
}
+
+//=================================================================================================
+/*!
+ * SMESHGUI_Preferences_ScalarBarDlg::onDistributionChanged
+ *
+ * Called when coloring type of the distribution is changed
+ */
+//=================================================================================================
+void SMESHGUI_Preferences_ScalarBarDlg::onDistributionChanged( int id ) {
+
+ bool isActive = myDistribColorGrp->id(myDMonoColor) == id;
+
+ myMonoColorBtn->setEnabled(isActive);
+ myDistributionColorLbl->setEnabled(isActive);
+}
+//=================================================================================================
+/*!
+ * SMESHGUI_Preferences_ScalarBarDlg::onDistributionActivated
+ *
+ * Called when distribution group check box is changed
+ */
+//=================================================================================================
+void SMESHGUI_Preferences_ScalarBarDlg::onDistributionActivated(bool on) {
+ if(on) {
+ if(myDMonoColor->isChecked())
+ onDistributionChanged(myDistribColorGrp->id(myDMonoColor) );
+ else if(myDMultiColor->isChecked())
+ onDistributionChanged(myDistribColorGrp->id(myDMultiColor) );
+ }
+ else {
+ myMonoColorBtn->setEnabled(false);
+ myDistributionColorLbl->setEnabled(false);
+ }
+}
+
+
//=================================================================================================
/*!
* SMESHGUI_Preferences_ScalarBarDlg::onOrientationChanged