/>
</FileConfiguration>
</File>
+ <File
+ RelativePath="..\..\src\Plot3d\resources\plot3d_merge_scalar_bars.png"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Update $(InputFileName)..."
+ CommandLine="type $(InputPath) > ..\..\$(ConfigurationName)\share\salome\resources\gui\$(InputFileName)
"
+ Outputs="..\..\$(ConfigurationName)\share\salome\resources\gui\$(InputFileName)"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Update $(InputFileName)..."
+ CommandLine="type $(InputPath) > ..\..\$(ConfigurationName)\share\salome\resources\gui\$(InputFileName)
"
+ Outputs="..\..\$(ConfigurationName)\share\salome\resources\gui\$(InputFileName)"
+ />
+ </FileConfiguration>
+ </File>
<File
RelativePath="..\..\src\Plot3d\resources\plot3d_minus.png"
>
{
myColorDic = new Plot3d_ColorDic();
+ myIsGlobalColorDic = false;
+ myGlobalColorDic = 0;
+
myIsDistance = false;
myStartPoint = 0;
return myColorDic;
}
+//=======================================================================
+//function : SetIsGlobalColorDic
+//purpose :
+//=======================================================================
+void Plot3d_Actor::SetIsGlobalColorDic( const bool theIsGlobalColorDic )
+{
+ myIsGlobalColorDic = theIsGlobalColorDic;
+}
+
+//=======================================================================
+//function : IsGlobalColorDic
+//purpose :
+//=======================================================================
+bool Plot3d_Actor::IsGlobalColorDic() const
+{
+ return myIsGlobalColorDic;
+}
+
+//=============================================================================
+// Function : SetGlobalColorDic
+// Purpose :
+//=============================================================================
+void Plot3d_Actor::SetGlobalColorDic( Plot3d_ColorDic* theColorDic )
+{
+ myGlobalColorDic = theColorDic;
+}
+
//=============================================================================
// Function : GetScalarBarActor
// Purpose :
//=============================================================================
void Plot3d_Actor::RecomputeLookupTable()
{
- if( !myColorDic )
+ Plot3d_ColorDic* aColorDic = IsGlobalColorDic() && myGlobalColorDic ? myGlobalColorDic : myColorDic;
+ if( !aColorDic )
return;
vtkPolyDataMapper* aMapper = dynamic_cast<vtkPolyDataMapper*>( GetMapper() );
if( !aMapper )
return;
- double myMinimum = myColorDic->GetMin();
- double myMaximum = myColorDic->GetMax();
+ double myMinimum = aColorDic->GetMin();
+ double myMaximum = aColorDic->GetMax();
- int aScaleMode = (int)myColorDic->GetScaleMode();
+ int aScaleMode = (int)aColorDic->GetScaleMode();
- int nbColors = myColorDic->GetNumber();
+ int nbColors = aColorDic->GetNumber();
if ( aScaleMode == Plot3d_ColorDic::Specific )
{
nbColors = 1000;
double range[2] = { aMin, aMax };
double aHueMin, aHueMax, aSaturationMin, aSaturationMax, aValueMin, aValueMax;
- myColorDic->GetHSVRange( aHueMin, aHueMax, aSaturationMin, aSaturationMax, aValueMin, aValueMax );
+ aColorDic->GetHSVRange( aHueMin, aHueMax, aSaturationMin, aSaturationMax, aValueMin, aValueMax );
double range1[2] = { 0, 0 };
if ( aScaleMode == Plot3d_ColorDic::Linear ||
{
if ( aScaleMode == Plot3d_ColorDic::Specific )
{
- const Value2ColorList& aSpecificScale = myColorDic->GetSpecificScale();
+ const Value2ColorList& aSpecificScale = aColorDic->GetSpecificScale();
if ( aSpecificScale.size() < 2 )
return;
Plot3d_ColorDic* GetColorDic();
+ void SetIsGlobalColorDic( const bool );
+ bool IsGlobalColorDic() const;
+
+ void SetGlobalColorDic( Plot3d_ColorDic* );
+
vtkSmartPointer<vtkScalarBarActor> GetScalarBarActor() const;
void DisplayScalarBar( const bool );
protected:
Plot3d_ColorDic* myColorDic;
+ bool myIsGlobalColorDic;
+ Plot3d_ColorDic* myGlobalColorDic;
+
vtkLookupTable* myLookupTable;
vtkSmartPointer<vtkScalarBarActor> myScalarBarActor;
// Function : Plot3d_SetupColorScaleDlg
// Purpose : Constructor
//=============================================================================
-Plot3d_SetupColorScaleDlg::Plot3d_SetupColorScaleDlg( QWidget* theParent )
-: QtxDialog( theParent, true, false, QtxDialog::OKCancel )
+Plot3d_SetupColorScaleDlg::Plot3d_SetupColorScaleDlg( QWidget* theParent,
+ bool theIsGlobal )
+: QtxDialog( theParent, true, false, QtxDialog::OKCancel ),
+ myIsGlobal( theIsGlobal )
{
setWindowTitle( tr( "SETUP_COLOR_SCALE" ) );
connect( aScaleModeSpecific, SIGNAL( toggled( bool ) ), aScaleModeSpecificSetup, SLOT( setEnabled( bool ) ) );
connect( aScaleModeSpecificSetup, SIGNAL( clicked() ), this, SLOT( onColorScaleSpecificSetup() ) );
+ aScaleModeSpecific->setVisible( !myIsGlobal );
+ aScaleModeSpecificSetup->setVisible( !myIsGlobal );
+ aRangeGroup->setVisible( !myIsGlobal );
+
onColorModeChanged( 0 ); // Blue-Red by default
setButtonPosition( Right, Cancel );
bool isMaxIncorrect = aMax < 0 || fabs( aMax ) < Precision::Confusion();
if ( isMinIncorrect || isMaxIncorrect )
{
- if ( SUIT_MessageBox::warning( this, tr( "WARNING" ), tr( "INCORRECT_RANGE" ),
- tr( "CORRECT_RANGE" ), tr( "SWITCH_TO_LINEAR" ), 0, 1 ) == 0 )
- { // correct range
- if ( isMinIncorrect )
- aMin = aCorrectValue;
-
- if ( isMaxIncorrect )
- aMax = aCorrectValue;
-
- bool minBlock = myMinLimit->blockSignals( true );
- bool maxBlock = myMaxLimit->blockSignals( true );
-
- myMinLimit->setValue( aMin );
- myMaxLimit->setValue( aMax );
-
- myMinLimit->blockSignals( minBlock );
- myMaxLimit->blockSignals( maxBlock );
- }
- else // switch to linear mode
+ int anAnswer = 0;
+ if( myIsGlobal )
+ {
+ SUIT_MessageBox::warning( this, tr( "WARNING" ), tr( "INCORRECT_RANGE" ) );
setColorScaleMode( Plot3d_ColorDic::Linear );
+ }
+ else
+ {
+ if ( SUIT_MessageBox::warning( this, tr( "WARNING" ), tr( "INCORRECT_RANGE" ),
+ tr( "CORRECT_RANGE" ), tr( "SWITCH_TO_LINEAR" ), 0, 1 ) == 0 )
+ { // correct range
+ if ( isMinIncorrect )
+ aMin = aCorrectValue;
+
+ if ( isMaxIncorrect )
+ aMax = aCorrectValue;
+
+ bool minBlock = myMinLimit->blockSignals( true );
+ bool maxBlock = myMaxLimit->blockSignals( true );
+
+ myMinLimit->setValue( aMin );
+ myMaxLimit->setValue( aMax );
+
+ myMinLimit->blockSignals( minBlock );
+ myMaxLimit->blockSignals( maxBlock );
+ }
+ else // switch to linear mode
+ setColorScaleMode( Plot3d_ColorDic::Linear );
+ }
}
}
return colorScaleMode();
TCollection_AsciiString Quantity;
int ColorMode;
QColor CustomColors[2];
+
+ ColorDicData()
+ {
+ Num = 99;
+ Min = 0;
+ Max = 1;
+ HueMin = 0.667;
+ HueMax = 0;
+ SaturationMin = 1;
+ SaturationMax = 1;
+ ValueMin = 1;
+ ValueMax = 1;
+ TimeStep = 0;
+ ColorMode = 0;
+ };
};
typedef QList < ColorDicData > ColorDicDataList;
enum { BlueRed = 0, BlueWhite, Monochrome, Custom };
public:
- Plot3d_SetupColorScaleDlg( QWidget* theParent = 0 );
+ Plot3d_SetupColorScaleDlg( QWidget* theParent = 0,
+ bool theIsGlobal = false );
virtual ~Plot3d_SetupColorScaleDlg();
void setData( const ColorDicData& theColorDicData );
void updateMinMax();
private:
+ bool myIsGlobal;
+
QtxIntSpinBox* myInterval;
QComboBox* myColorMode;
QVBoxLayout* aMainLay = new QVBoxLayout( aMainFrame );
aMainLay->setMargin( 5 );
- myGrp = new QtxGroupBox( aMainFrame );
- myGrp->setTitle( tr( "PARAMETERS" ) );
- aMainLay->addWidget( myGrp );
+ QtxGroupBox* aParamGrp = new QtxGroupBox( aMainFrame );
+ aParamGrp->setTitle( tr( "PARAMETERS" ) );
+ aMainLay->addWidget( aParamGrp );
- QVBoxLayout* aLay = new QVBoxLayout( myGrp );
- aLay->setMargin( 0 );
+ QVBoxLayout* aLay = new QVBoxLayout( aParamGrp );
+ aLay->setMargin( 5 );
+ aLay->setSpacing( 5 );
// Create table
- myTable = new QTableWidget( myGrp );
+ myTable = new QTableWidget( aParamGrp );
myTable->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
aLay->addWidget( myTable );
// Minus button
QPixmap minusPix = aResMgr->loadPixmap( "VTKViewer", tr( "ICON_PLOT3D_MINUS" ) );
- myRemoveBtn = new QToolButton( 0 );
- myRemoveBtn->setIcon( minusPix );
- myRemoveBtn->setFixedSize( minusPix.size() );
- myGrp->insertTitleWidget( myRemoveBtn );
+ QToolButton* aRemoveBtn = new QToolButton( 0 );
+ aRemoveBtn->setIcon( minusPix );
+ aRemoveBtn->setFixedSize( minusPix.size() );
+ aParamGrp->insertTitleWidget( aRemoveBtn );
- connect( myRemoveBtn, SIGNAL( clicked() ), SLOT( onRemove() ) );
+ connect( aRemoveBtn, SIGNAL( clicked() ), SLOT( onRemove() ) );
+
+ // "Edit global color scale" button
+ QPushButton* anEditGlobalBtn = new QPushButton( tr( "EDIT_GLOBAL_COLOR_SCALE" ), aParamGrp );
+ aLay->addWidget( anEditGlobalBtn );
+
+ connect( anEditGlobalBtn, SIGNAL( clicked() ), SLOT( onGlobalColorScale() ) );
setButtonPosition( Right, Cancel );
setMinimumWidth( 300 );
// Purpose :
//=============================================================================
void Plot3d_SetupSurfacesDlg::SetParameters( const QStringList& theTexts,
- const ColorDicDataList& theColorDicDataList )
+ const ColorDicDataList& theColorDicDataList,
+ const ColorDicData& theGlobalColorDicData )
{
int nbRows = theTexts.size();
myColorDicDataList = theColorDicDataList;
+ myGlobalColorDicData = theGlobalColorDicData;
+
myRemovedIndexes.clear();
}
// Purpose :
//=============================================================================
void Plot3d_SetupSurfacesDlg::GetParameters( QStringList& theTexts,
- ColorDicDataList& theColorDicDataList ) const
+ ColorDicDataList& theColorDicDataList,
+ ColorDicData& theGlobalColorDicData ) const
{
int nbRows = myTable->rowCount();
}
theColorDicDataList = myColorDicDataList;
+
+ theGlobalColorDicData = myGlobalColorDicData;
}
//=============================================================================
myColorDicDataList[ aRow ] = aColorDicData;
}
}
+
+//=============================================================================
+// Function : onGlobalColorScale
+// Purpose :
+//=============================================================================
+void Plot3d_SetupSurfacesDlg::onGlobalColorScale()
+{
+ Plot3d_SetupColorScaleDlg aDlg( this, true );
+ aDlg.setData( myGlobalColorDicData );
+
+ if( aDlg.exec() )
+ myGlobalColorDicData = aDlg.getData();
+}
#include "Plot3d_SetupColorScaleDlg.h"
#include <QtxDialog.h>
-#include <QVector>
+
#include <QList>
-class QtxGroupBox;
class QTableWidget;
-class QwtLegend;
-class QToolButton;
/*
Class : Plot3d_SetupSurfacesDlg
virtual ~Plot3d_SetupSurfacesDlg();
void SetParameters( const QStringList& theTexts,
- const ColorDicDataList& theColorDicDataList );
+ const ColorDicDataList& theColorDicDataList,
+ const ColorDicData& theGlobalColorDicData );
+
void GetParameters( QStringList& theTexts,
- ColorDicDataList& theColorDicDataList ) const;
+ ColorDicDataList& theColorDicDataList,
+ ColorDicData& theGlobalColorDicData ) const;
const QList< int >& GetRemovedIndexes() const;
private slots:
void onRemove();
void onColorScaleBtn();
+ void onGlobalColorScale();
private:
void setText( const int theRow,
const int theCol,
const QString& theText );
private:
-
- QtxGroupBox* myGrp;
QTableWidget* myTable;
- QToolButton* myRemoveBtn;
ColorDicDataList myColorDicDataList;
+ ColorDicData myGlobalColorDicData;
QList< int > myRemovedIndexes;
};
#include <QtxActionToolMgr.h>
#include <QtxMultiAction.h>
+#include <SUIT_MessageBox.h>
#include <SUIT_ResourceMgr.h>
#include <SVTK_ComboAction.h>
#include <vtkAxisActor2D.h>
#include <vtkCamera.h>
+#include <vtkLookupTable.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkScalarBarActor.h>
+#include <vtkScalarBarWidget.h>
+#include <vtkTextProperty.h>
+
+#include <Precision.hxx>
/*!
Constructor
myMode2D( false ),
myMode2DNormalAxis( AxisZ )
{
+ // Global scalar bar
+ myColorDic = new Plot3d_ColorDic();
+
+ myToDisplayScalarBar = false;
+
+ myScalarBarActor = vtkScalarBarActor::New();
+ myScalarBarActor->SetTitle( "All surfaces" );
+ myScalarBarActor->SetVisibility( false );
+
+ // Title props
+ QColor aTextColor = Qt::white;
+
+ vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
+ aScalarBarTitleProp->SetColor( aTextColor.redF(), aTextColor.greenF(), aTextColor.blueF() );
+ aScalarBarTitleProp->SetFontFamilyToArial();
+ int aSize = 24;
+ aScalarBarTitleProp->SetFontSize( aSize );
+ myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
+ aScalarBarTitleProp->Delete();
+
+ // Label props
+ vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
+ aScalarBarLabelProp->SetColor( aTextColor.redF(), aTextColor.greenF(), aTextColor.blueF() );
+ aScalarBarLabelProp->SetFontFamilyToArial();
+ myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
+ aScalarBarLabelProp->Delete();
+
+ // Position
+ double aXPos = 0.01, aYPos = 0.1;
+ myScalarBarActor->SetPosition( aXPos, aYPos );
+
+ // Width
+ double aWidth = 0.10, aHeight = 0.80;
+ myScalarBarActor->SetWidth( aWidth );
+ myScalarBarActor->SetHeight( aHeight );
+
+ // Number of labels and Maximum number of colors
+ myScalarBarActor->SetNumberOfLabels( 5 );
+ myScalarBarActor->SetMaximumNumberOfColors( 99 );
+
+ // ScalarBar widget
+ myScalarBarWg = vtkScalarBarWidget::New();
+ myScalarBarWg->SetScalarBarActor( myScalarBarActor.GetPointer() );
+
+ // Lookup table
+ myLookupTable = vtkLookupTable::New();
+ myLookupTable->SetHueRange( 0.667, 0.0 );
+ myLookupTable->ForceBuild();
+
+ myScalarBarActor->SetLookupTable( myLookupTable );
}
/*!
*/
Plot3d_ViewWindow::~Plot3d_ViewWindow()
{
+ myScalarBarWg->EnabledOff();
+ if( vtkRenderer* aRenderer = getRenderer() )
+ aRenderer->RemoveActor( myScalarBarActor.GetPointer() );
+
+ if( myColorDic )
+ {
+ delete myColorDic;
+ myColorDic = 0;
+ }
}
/*!
myPlot3dToolBar = toolMgr()->createToolBar( tr( "PLOT3D" ), -1, this );
SVTK_ViewWindow::Initialize( theModel );
+
+ // Initialize global scalar bar
+ if( vtkRenderWindow* aRenderWindow = getRenderWindow() )
+ {
+ if( vtkRenderWindowInteractor* aRWI = aRenderWindow->GetInteractor() )
+ {
+ myScalarBarWg->SetInteractor( aRWI );
+ if( myToDisplayScalarBar )
+ myScalarBarWg->EnabledOn();
+ }
+ }
+
+ if( vtkRenderer* aRenderer = getRenderer() )
+ aRenderer->AddActor( myScalarBarActor.GetPointer() );
}
/*!
anAction->setStatusTip( tr( "DSC_PLOT3D_SURFACES_SETTINGS" ) );
connect( anAction, SIGNAL( activated() ), this, SLOT( onSurfacesSettings() ) );
mgr->registerAction( anAction, SurfacesSettingsId );
+
+ anAction = new QtxAction( tr( "MNU_PLOT3D_MERGE_SCALAR_BARS" ),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_PLOT3D_MERGE_SCALAR_BARS" ) ),
+ tr( "MNU_PLOT3D_MERGE_SCALAR_BARS" ), 0, this );
+ anAction->setStatusTip( tr( "DSC_PLOT3D_MERGE_SCALAR_BARS" ) );
+ anAction->setCheckable( true );
+ connect( anAction, SIGNAL( toggled( bool ) ), this, SLOT( onMergeScalarBars( bool ) ) );
+ mgr->registerAction( anAction, MergeScalarBarsId );
}
/*!
mgr->append( Mode2DId, myPlot3dToolBar );
mgr->append( SurfacesSettingsId, myPlot3dToolBar );
+ mgr->append( MergeScalarBarsId, myPlot3dToolBar );
}
/*!
QList< Plot3d_Actor* > aSurfaces;
QStringList aTexts;
ColorDicDataList aColorDicDataList;
- vtkActor* anActor = 0;
VTK::ActorCollectionCopy aCopy( aRenderer->GetActors() );
vtkActorCollection* aCollection = aCopy.GetActors();
aCollection->InitTraversal();
- while( anActor = aCollection->GetNextActor() )
+ while( vtkActor* anActor = aCollection->GetNextActor() )
{
if( Plot3d_Actor* aSurface = dynamic_cast<Plot3d_Actor*>( anActor ) )
{
}
}
+ ColorDicData aGlobalColorDicData;
+ if( myColorDic )
+ {
+ aGlobalColorDicData.Num = myColorDic->GetNumber();
+ aGlobalColorDicData.Min = myColorDic->GetMin(); // non-editable, just to check log scale
+ aGlobalColorDicData.Max = myColorDic->GetMax(); // non-editable, just to check log scale
+ myColorDic->GetHSVRange( aGlobalColorDicData.HueMin, aGlobalColorDicData.HueMax,
+ aGlobalColorDicData.SaturationMin, aGlobalColorDicData.SaturationMax,
+ aGlobalColorDicData.ValueMin, aGlobalColorDicData.ValueMax );
+ aGlobalColorDicData.ScaleMode = myColorDic->GetScaleMode();
+ aGlobalColorDicData.ColorMode = myColorDic->GetColorMode();
+ myColorDic->GetCustomColors( aGlobalColorDicData.CustomColors[0], aGlobalColorDicData.CustomColors[1] );
+ }
+
Plot3d_SetupSurfacesDlg aDlg( this );
- aDlg.SetParameters( aTexts, aColorDicDataList );
+ aDlg.SetParameters( aTexts, aColorDicDataList, aGlobalColorDicData );
if ( aDlg.exec() != QDialog::Accepted )
return;
- aDlg.GetParameters( aTexts, aColorDicDataList );
+ aDlg.GetParameters( aTexts, aColorDicDataList, aGlobalColorDicData );
// Note: Indexes retrieved from dialog do not correspond to the real indexes of
// plot 3d surfaces. They correspond to the user actions. For example, if user removes
}
}
+ if( myColorDic )
+ {
+ myColorDic->SetNumber( aGlobalColorDicData.Num );
+ myColorDic->SetHSVRange( aGlobalColorDicData.HueMin, aGlobalColorDicData.HueMax,
+ aGlobalColorDicData.SaturationMin, aGlobalColorDicData.SaturationMax,
+ aGlobalColorDicData.ValueMin, aGlobalColorDicData.ValueMax );
+ myColorDic->SetScaleMode( aGlobalColorDicData.ScaleMode );
+ myColorDic->SetColorMode( aGlobalColorDicData.ColorMode );
+ myColorDic->SetCustomColors( aGlobalColorDicData.CustomColors[0], aGlobalColorDicData.CustomColors[1] );
+ }
+
+ UpdateScalarBar( false );
+
vtkFloatingPointType aGlobalBounds[6] = { VTK_DOUBLE_MAX, VTK_DOUBLE_MIN,
VTK_DOUBLE_MAX, VTK_DOUBLE_MIN,
VTK_DOUBLE_MAX, VTK_DOUBLE_MIN };
aScale[0] = fabs( aDX ) > DBL_EPSILON ? 1.0 / aDX : 1.0;
aScale[1] = fabs( aDY ) > DBL_EPSILON ? 1.0 / aDY : 1.0;
aScale[2] = fabs( aDZ ) > DBL_EPSILON ? 1.0 / aDZ : 1.0;
- SetScale( aScale );
+ SetScale( aScale, false );
onFitAll();
}
+/*!
+ Merge the scalar bars of all surfaces to a global scalar bar
+*/
+void Plot3d_ViewWindow::onMergeScalarBars( bool theOn )
+{
+ myToDisplayScalarBar = theOn;
+ UpdateScalarBar();
+}
+
/*!
Fit 2D surfaces to the specified data range
*/
else
myStored3DViewState.IsInitialized = false;
}
+
+/*!
+ Get actor of the global scalar bar
+ \return actor of the global scalar bar
+*/
+vtkSmartPointer<vtkScalarBarActor> Plot3d_ViewWindow::GetScalarBarActor() const
+{
+ return myScalarBarActor;
+}
+
+/*!
+ Update representation of the global scalar bar
+ \param theIsRepaint flag used to repaint the view
+*/
+void Plot3d_ViewWindow::UpdateScalarBar( const bool theIsRepaint )
+{
+ vtkRenderer* aRenderer = getRenderer();
+ if( !aRenderer )
+ return;
+
+ QList< Plot3d_Actor* > aSurfaces;
+
+ double aMin = VTK_DOUBLE_MAX;
+ double aMax = VTK_DOUBLE_MIN;
+
+ VTK::ActorCollectionCopy aCopy( aRenderer->GetActors() );
+ vtkActorCollection* aCollection = aCopy.GetActors();
+ aCollection->InitTraversal();
+ while( vtkActor* anActor = aCollection->GetNextActor() )
+ {
+ if( Plot3d_Actor* aSurface = dynamic_cast<Plot3d_Actor*>( anActor ) )
+ {
+ if( aSurface->GetVisibility() )
+ {
+ if( Plot3d_ColorDic* aColorDic = aSurface->GetColorDic() )
+ {
+ aSurfaces << aSurface;
+ aMin = qMin( aMin, aColorDic->GetMin() );
+ aMax = qMax( aMax, aColorDic->GetMax() );
+ }
+ }
+ }
+ }
+
+ bool anIsDisplayedSurfaces = !aSurfaces.isEmpty();
+ if( anIsDisplayedSurfaces )
+ {
+ // check the range and reset the scale mode to linear if necessary
+ if( myColorDic->GetScaleMode() == Plot3d_ColorDic::Logarithmic )
+ {
+ bool isMinIncorrect = aMin < 0 || fabs( aMin ) < Precision::Confusion();
+ bool isMaxIncorrect = aMax < 0 || fabs( aMax ) < Precision::Confusion();
+ if( isMinIncorrect || isMaxIncorrect )
+ {
+ SUIT_MessageBox::warning( this, tr( "WARNING" ), tr( "INCORRECT_RANGE" ) );
+ myColorDic->SetScaleMode( Plot3d_ColorDic::Linear );
+ myLookupTable->SetScale( (int)myColorDic->GetScaleMode() );
+ }
+ }
+
+ myColorDic->SetRange( aMin, aMax );
+
+ myLookupTable->SetRange( aMin, aMax );
+
+ myLookupTable->SetNumberOfTableValues( myColorDic->GetNumber() );
+
+ double aHueMin, aHueMax, aSaturationMin, aSaturationMax, aValueMin, aValueMax;
+ myColorDic->GetHSVRange( aHueMin, aHueMax, aSaturationMin, aSaturationMax, aValueMin, aValueMax );
+ myLookupTable->SetHueRange( aHueMin, aHueMax );
+ myLookupTable->SetSaturationRange( aSaturationMin, aSaturationMax );
+ myLookupTable->SetValueRange( aValueMin, aValueMax );
+
+ myLookupTable->SetScale( (int)myColorDic->GetScaleMode() );
+ myLookupTable->ForceBuild();
+ }
+
+ bool anIsDisplayScalarBar = myToDisplayScalarBar && anIsDisplayedSurfaces;
+
+ myScalarBarActor->SetVisibility( anIsDisplayScalarBar );
+ myScalarBarWg->SetEnabled( anIsDisplayScalarBar );
+
+ QListIterator< Plot3d_Actor* > aSurfaceIter( aSurfaces );
+ while( aSurfaceIter.hasNext() )
+ {
+ if( Plot3d_Actor* aSurface = aSurfaceIter.next() )
+ {
+ aSurface->SetIsGlobalColorDic( myToDisplayScalarBar );
+ aSurface->SetGlobalColorDic( myColorDic );
+
+ aSurface->RecomputeLookupTable();
+ aSurface->DisplayScalarBar( !anIsDisplayScalarBar );
+ }
+ }
+
+ if( theIsRepaint )
+ Repaint();
+}
#include <SVTK_ViewWindow.h>
+class vtkLookupTable;
+class vtkScalarBarActor;
+class vtkScalarBarWidget;
+
+class Plot3d_ColorDic;
+
class PLOT3D_EXPORT Plot3d_ViewWindow : public SVTK_ViewWindow
{
Q_OBJECT
public:
enum { FirstId = SVTK_ViewWindow::LastId,
- Mode2DId, SurfacesSettingsId,
+ Mode2DId, SurfacesSettingsId, MergeScalarBarsId,
LastId };
enum Axis { AxisX = 0, AxisY, AxisZ };
void clearViewState( const bool theIs2D );
+ vtkSmartPointer<vtkScalarBarActor> GetScalarBarActor() const;
+ void UpdateScalarBar( const bool theIsRepaint = true );
+
public slots:
void onMode2D( bool theOn );
void onSurfacesSettings();
+ void onMergeScalarBars( bool theOn );
void onFitData();
protected:
int myMode2DNormalAxis;
ViewState myStored2DViewState;
ViewState myStored3DViewState;
+
+ Plot3d_ColorDic* myColorDic;
+ vtkSmartPointer<vtkLookupTable> myLookupTable;
+ vtkSmartPointer<vtkScalarBarActor> myScalarBarActor;
+ vtkSmartPointer<vtkScalarBarWidget> myScalarBarWg;
+ bool myToDisplayScalarBar;
};
#endif
<context>
<name>@default</name>
<message>
- <source>ICON_PLOT3D_SURFACES_SETTINGS</source>
- <translation>plot3d_surfaces_settings.png</translation>
+ <source>ICON_PLOT3D_MERGE_SCALAR_BARS</source>
+ <translation>plot3d_merge_scalar_bars.png</translation>
+ </message>
+ <message>
+ <source>ICON_PLOT3D_MINUS</source>
+ <translation>plot3d_minus.png</translation>
</message>
<message>
<source>ICON_PLOT3D_MODE_2D</source>
<translation>plot3d_mode_2d.png</translation>
</message>
<message>
- <source>ICON_PLOT3D_MINUS</source>
- <translation>plot3d_minus.png</translation>
+ <source>ICON_PLOT3D_SURFACES_SETTINGS</source>
+ <translation>plot3d_surfaces_settings.png</translation>
</message>
</context>
</TS>
<source>ERROR</source>
<translation>Error</translation>
</message>
+ <message>
+ <source>INCORRECT_RANGE</source>
+ <translation>Logarithmic scale could not be used when the
+minimum value of the range is less or equal zero.
+The scale has been switched to linear.</translation>
+ </message>
+ <message>
+ <source>INCORRECT_RANGE_WITH_QUESTION</source>
+ <translation>Logarithmic scale could not be used when the
+minimum value of the range is less or equal zero.
+Correct the range or switch to linear scale?</translation>
+ </message>
<message>
<source>WARNING</source>
<translation>Warning</translation>
<source>CUSTOM</source>
<translation>Custom</translation>
</message>
- <message>
- <source>INCORRECT_RANGE</source>
- <translation>Logarithmic scale could not be used when the
-minimum value of the range is less or equal zero.
-Correct the range or switch to linear scale?</translation>
- </message>
<message>
<source>LINEAR</source>
<translation>Linear</translation>
<message>
<source>WRN_INCORRECT_RANGE_MIN_MAX</source>
<translation>The minimum value of the range should not be greater
-or equal the maximum value.
- </translation>
+or equal the maximum value.</translation>
</message>
<message>
<source>WRN_INCORRECT_RANGE_LOGARITHMIC</source>
<translation>The minimum value of the range should not be less
-or equal zero in case of logarithmic interpolation.
- </translation>
+or equal zero in case of logarithmic interpolation.</translation>
</message>
<message>
<source>WRN_INCONSISTENT_VALUES</source>
<source>EDIT</source>
<translation>Edit</translation>
</message>
+ <message>
+ <source>EDIT_GLOBAL_COLOR_SCALE</source>
+ <translation>Edit global color scale</translation>
+ </message>
<message>
<source>PARAMETERS</source>
<translation>Parameters</translation>
</context>
<context>
<name>Plot3d_ViewWindow</name>
+ <message>
+ <source>DSC_PLOT3D_MERGE_SCALAR_BARS</source>
+ <translation>Merge scalar bars</translation>
+ </message>
<message>
<source>DSC_PLOT3D_MODE_2D</source>
<translation>Toggle 2D mode</translation>
<source>FIT_RANGE</source>
<translation>Fit range</translation>
</message>
+ <message>
+ <source>MNU_PLOT3D_MERGE_SCALAR_BARS</source>
+ <translation>Merge scalar bars</translation>
+ </message>
<message>
<source>MNU_PLOT3D_MODE_2D</source>
<translation>Toggle 2D mode</translation>
*/
void
SVTK_View
-::EraseAll()
+::EraseAll(const bool theIsUpdate)
{
using namespace SVTK;
ForEach<SALOME_Actor>(getRenderer()->GetActors(),
TErase());
- Repaint();
+ if(theIsUpdate)
+ Repaint();
}
/*!
*/
void
SVTK_View
-::DisplayAll()
+::DisplayAll(const bool theIsUpdate)
{
using namespace SVTK;
ForEach<SALOME_Actor>(getRenderer()->GetActors(),
TSetVisibility<SALOME_Actor>(true));
- Repaint();
+ if(theIsUpdate)
+ Repaint();
}
/*!
void
SVTK_View
::Erase(SALOME_Actor* theActor,
- bool theIsUpdate)
+ const bool theIsUpdate)
{
SVTK::TErase()(theActor);
void
SVTK_View
::Erase(const Handle(SALOME_InteractiveObject)& theIObject,
- bool theIsUpdate)
+ const bool theIsUpdate)
{
using namespace SVTK;
ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
void
SVTK_View
::Display(SALOME_Actor* theActor,
- bool theIsUpdate)
+ const bool theIsUpdate)
{
GetRenderer()->AddActor(theActor);
theActor->SetVisibility(true);
void
SVTK_View
::Display(const Handle(SALOME_InteractiveObject)& theIObject,
- bool theIsUpdate)
+ const bool theIsUpdate)
{
using namespace SVTK;
ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
*/
void
SVTK_View
-::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject)
+::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject,
+ const bool theIsUpdate)
{
- EraseAll();
- Display(theIObject);
+ EraseAll(theIsUpdate);
+ Display(theIObject, theIsUpdate);
}
void
SVTK_View
::Remove(const Handle(SALOME_InteractiveObject)& theIObject,
- bool theIsUpdate)
+ const bool theIsUpdate)
{
using namespace SVTK;
ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
void
SVTK_View
::Remove(SALOME_Actor* theActor,
- bool theIsUpdate)
+ const bool theIsUpdate)
{
GetRenderer()->RemoveActor(theActor);
if(theIsUpdate)
*/
void
SVTK_View
-::RemoveAll(bool theIsUpdate)
+::RemoveAll(const bool theIsUpdate)
{
vtkRenderer* aRenderer = getRenderer();
if(vtkActorCollection* anActors = aRenderer->GetActors()){
// Erase Display functions
//! To erase all existing VTK presentations
void
- EraseAll();
+ EraseAll(const bool theIsUpdate = true);
//! To display all existing VTK presentations
void
- DisplayAll();
+ DisplayAll(const bool theIsUpdate = true);
//! To remove from the view all existing VTK presentations
void
- RemoveAll( const bool immediatly );
+ RemoveAll(const bool theIsUpdate = true);
//! To erase VTK presentation with defined #SALOME_InteractiveObject
void
Erase(const Handle(SALOME_InteractiveObject)& IObject,
- bool immediatly = true);
+ const bool theIsUpdate = true);
void
Remove(const Handle(SALOME_InteractiveObject)& IObject,
- bool immediatly = true);
+ const bool theIsUpdate = true);
//! To display VTK presentation with defined #SALOME_InteractiveObject
void
Display(const Handle(SALOME_InteractiveObject)& IObject,
- bool immediatly = true);
+ const bool theIsUpdate = true);
//! To display VTK presentation with defined #SALOME_InteractiveObject and erase all anothers
void
- DisplayOnly(const Handle(SALOME_InteractiveObject)& IObject);
+ DisplayOnly(const Handle(SALOME_InteractiveObject)& IObject,
+ const bool theIsUpdate = true);
//! To display the VTK presentation
void
Display(SALOME_Actor* SActor,
- bool immediatly = true);
+ const bool theIsUpdate = true);
//! To erase the VTK presentation
void
Erase(SALOME_Actor* SActor,
- bool immediatly = true);
+ const bool theIsUpdate = true);
//! To remove the VTK presentation
void
Remove(SALOME_Actor* SActor,
- bool updateViewer = true);
+ const bool theIsUpdate = true);
//----------------------------------------------------------------------------
//! Redirect the request to #SVTK_Renderer::SetPreselectionProp
/*!
Display object
\param theIO - object
- \param theImmediatly - update viewer
+ \param theIsUpdate - update viewer
*/
void SVTK_ViewWindow::Display(const Handle(SALOME_InteractiveObject)& theIO,
- bool theImmediatly)
+ bool theIsUpdate)
{
- myView->Display(theIO,theImmediatly);
+ myView->Display(theIO,theIsUpdate);
}
/*!
Erase object
\param theIO - object
- \param theImmediatly - update viewer
+ \param theIsUpdate - update viewer
*/
void SVTK_ViewWindow::Erase(const Handle(SALOME_InteractiveObject)& theIO,
- bool theImmediatly)
+ bool theIsUpdate)
{
- myView->Erase(theIO,theImmediatly);
+ myView->Erase(theIO,theIsUpdate);
}
/*!
Display only passed object
\param theIO - object
+ \param theIsUpdate - update viewer
*/
-void SVTK_ViewWindow::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO)
+void SVTK_ViewWindow::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO,
+ bool theIsUpdate)
{
- myView->DisplayOnly(theIO);
+ myView->DisplayOnly(theIO,theIsUpdate);
}
/*!
Display all objects in view
+ \param theIsUpdate - update viewer
*/
-void SVTK_ViewWindow::DisplayAll()
+void SVTK_ViewWindow::DisplayAll(bool theIsUpdate)
{
- myView->DisplayAll();
+ myView->DisplayAll(theIsUpdate);
}
/*!
Erase all objects in view
+ \param theIsUpdate - update viewer
*/
-void SVTK_ViewWindow::EraseAll()
+void SVTK_ViewWindow::EraseAll(bool theIsUpdate)
{
- myView->EraseAll();
+ myView->EraseAll(theIsUpdate);
}
/*!
/*!
Redirect the request to #SVTK_Renderer::SetScale
*/
-void SVTK_ViewWindow::SetScale( double theScale[3] )
+void SVTK_ViewWindow::SetScale( double theScale[3],
+ bool theIsUpdate )
{
//myMainWindow->SetScale( theScale );
GetRenderer()->SetScale( theScale );
- Repaint();
+ if( theIsUpdate )
+ Repaint();
}
/*!
//----------------------------------------------------------------------------
//! Redirect the request to #SVTK_View::Display (to support old code)
virtual void Display(const Handle(SALOME_InteractiveObject)& theIObject,
- bool theImmediatly = true);
+ bool theIsUpdate = true);
//! Redirect the request to #SVTK_View::DisplayOnly (to support old code)
- virtual void DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject);
+ virtual void DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject,
+ bool theIsUpdate = true);
//! Redirect the request to #SVTK_View::Erase (to support old code)
virtual void Erase(const Handle(SALOME_InteractiveObject)& theIObject,
- bool theImmediatly = true);
+ bool theIsUpdate = true);
//! Redirect the request to #SVTK_View::DisplayAll (to support old code)
- virtual void DisplayAll();
+ virtual void DisplayAll(bool theIsUpdate = true);
//! Redirect the request to #SVTK_View::EraseAll (to support old code)
- virtual void EraseAll();
+ virtual void EraseAll(bool theIsUpdate = true);
//! To repaint the viewer
virtual void Repaint(bool theUpdateTrihedron = true);
//----------------------------------------------------------------------------
//! Redirect the request to #SVTK_Renderer::SetScale
- virtual void SetScale( double theScale[3] );
+ virtual void SetScale( double theScale[3],
+ bool theIsUpdate = true );
//! Redirect the request to #SVTK_Renderer::GetScale
virtual void GetScale( double theScale[3] );