0021840: [CEA 655] Scalar bar: using a logarithmic scale

This commit is contained in:
jfa 2013-02-08 12:40:16 +00:00
parent 86a9f36ce4
commit aea880cf9e
13 changed files with 238 additions and 180 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -7,8 +7,12 @@ In this dialog you can specify the properties of the scalar bar
\image html scalar_bar_dlg.png \image html scalar_bar_dlg.png
<ul> <ul>
<li><b>Scalar Range</b> in this menu you can specify <li><b>Scalar Range</b> - in this menu you can specify
<b>Min value</b> and <b>Max value</b> of the <b>Scalar Bar</b> </li> <b>Min value</b> and <b>Max value</b> of the <b>Scalar Bar</b>, and
also you can turn on/off <b>Logarithmic</b> scaling of the scalar bar.</li>
\note <b>Logarithmic scale</b> is not applicable in case of
negative and zero values in the range. In such cases it is disabled.
<li><b>Font</b> - in this menu you can set type, face and color for <li><b>Font</b> - in this menu you can set type, face and color for
the font of <b>Title</b> and <b>Labels</b> of the <b>Scalar the font of <b>Title</b> and <b>Labels</b> of the <b>Scalar
@ -29,7 +33,7 @@ location (<b>X</b> and <b>Y</b>) and size (<b>Width</b> and
side)</li> side)</li>
<li><b>Y</b>: ordinate of the origin (from the bottom)</li> <li><b>Y</b>: ordinate of the origin (from the bottom)</li>
</ul> </ul>
<li><b>Distribution</b> in this menu you can Show/Hide distribution histogram of the values of the <b>Scalar Bar</b> and specify histogram properties</li> <li><b>Distribution</b> - in this menu you can Show/Hide distribution histogram of the values of the <b>Scalar Bar</b> and specify histogram properties</li>
<ul> <ul>
<li><b>Multicolor</b> the histogram is colored as <b>Scalar Bar</b></li> <li><b>Multicolor</b> the histogram is colored as <b>Scalar Bar</b></li>
<li><b>Monocolor</b> the histogram is colored as selected with <b>Distribution color</b> selector</li> <li><b>Monocolor</b> the histogram is colored as selected with <b>Distribution color</b> selector</li>

View File

@ -115,7 +115,7 @@ module SMESH
{ {
double GetValue( in long theElementId ); double GetValue( in long theElementId );
Histogram GetHistogram( in short nbIntervals ); Histogram GetHistogram( in short nbIntervals, in boolean isLogarithmic );
/*! /*!
* Set precision for calculation. It is a position after point which is * Set precision for calculation. It is a position after point which is

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 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
//
#include "SMESH_ControlsDef.hxx" #include "SMESH_ControlsDef.hxx"
@ -322,12 +321,12 @@ double NumericalFunctor::Round( const double & aVal )
* \param minmax - boundaries of diapason of values to divide into intervals * \param minmax - boundaries of diapason of values to divide into intervals
*/ */
//================================================================================ //================================================================================
void NumericalFunctor::GetHistogram(int nbIntervals, void NumericalFunctor::GetHistogram(int nbIntervals,
std::vector<int>& nbEvents, std::vector<int>& nbEvents,
std::vector<double>& funValues, std::vector<double>& funValues,
const vector<int>& elements, const vector<int>& elements,
const double* minmax) const double* minmax,
const bool isLogarithmic)
{ {
if ( nbIntervals < 1 || if ( nbIntervals < 1 ||
!myMesh || !myMesh ||
@ -380,8 +379,15 @@ void NumericalFunctor::GetHistogram(int nbIntervals,
for ( int i = 0; i < nbIntervals; ++i ) for ( int i = 0; i < nbIntervals; ++i )
{ {
// find end value of i-th interval // find end value of i-th interval
double r = (i+1) / double( nbIntervals ); double r = (i+1) / double(nbIntervals);
funValues[i+1] = funValues.front() * (1-r) + funValues.back() * r; if (isLogarithmic && funValues.front() > 1e-07 && funValues.back() > 1e-07) {
double logmin = log10(funValues.front());
double lval = logmin + r * (log10(funValues.back()) - logmin);
funValues[i+1] = pow(10.0, lval);
}
else {
funValues[i+1] = funValues.front() * (1-r) + funValues.back() * r;
}
// count values in the i-th interval if there are any // count values in the i-th interval if there are any
if ( min != values.end() && *min <= funValues[i+1] ) if ( min != values.end() && *min <= funValues[i+1] )

View File

@ -125,7 +125,8 @@ namespace SMESH{
std::vector<int>& nbEvents, std::vector<int>& nbEvents,
std::vector<double>& funValues, std::vector<double>& funValues,
const std::vector<int>& elements, const std::vector<int>& elements,
const double* minmax=0); const double* minmax=0,
const bool isLogarithmic = false);
virtual SMDSAbs_ElementType GetType() const = 0; virtual SMDSAbs_ElementType GetType() const = 0;
virtual double GetBadRate( double Value, int nbNodes ) const = 0; virtual double GetBadRate( double Value, int nbNodes ) const = 0;
long GetPrecision() const; long GetPrecision() const;

View File

@ -18,13 +18,12 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 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 OBJECT : interactive object for SMESH visualization // SMESH OBJECT : interactive object for SMESH visualization
// File : SMESH_Actor.cxx // File : SMESH_Actor.cxx
// Author : Nicolas REJNERI // Author : Nicolas REJNERI
// Module : SMESH // Module : SMESH
//
#include "SMESH_ActorDef.h" #include "SMESH_ActorDef.h"
#include "SMESH_ActorUtils.h" #include "SMESH_ActorUtils.h"
#include "SMESH_DeviceActor.h" #include "SMESH_DeviceActor.h"
@ -99,8 +98,8 @@ SMESH_ActorDef* SMESH_ActorDef::New(){
} }
SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj, SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
const char* theEntry, const char* theEntry,
const char* theName, const char* theName,
int theIsClear) int theIsClear)
{ {
@ -120,7 +119,7 @@ SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
SMESH_ActorDef::SMESH_ActorDef() SMESH_ActorDef::SMESH_ActorDef()
{ {
if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this); if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
myBaseActor = SMESH_DeviceActor::New(); myBaseActor = SMESH_DeviceActor::New();
myTimeStamp = vtkTimeStamp::New(); myTimeStamp = vtkTimeStamp::New();
@ -161,10 +160,10 @@ SMESH_ActorDef::SMESH_ActorDef()
QFont f = mgr->fontValue( "SMESH", "numbering_node_font" ); QFont f = mgr->fontValue( "SMESH", "numbering_node_font" );
if ( f.family() == "Arial" ) aFamilyNd = SMESH::FntArial; if ( f.family() == "Arial" ) aFamilyNd = SMESH::FntArial;
else if ( f.family() == "Courier" ) aFamilyNd = SMESH::FntCourier; else if ( f.family() == "Courier" ) aFamilyNd = SMESH::FntCourier;
else if ( f.family() == "Times" ) aFamilyNd = SMESH::FntTimes; else if ( f.family() == "Times" ) aFamilyNd = SMESH::FntTimes;
aBoldNd = f.bold(); aBoldNd = f.bold();
anItalicNd = f.italic(); anItalicNd = f.italic();
aShadowNd = f.overline(); aShadowNd = f.overline();
aSizeNd = f.pointSize(); aSizeNd = f.pointSize();
} }
vtkFloatingPointType anRGBNd[3] = {1,1,1}; vtkFloatingPointType anRGBNd[3] = {1,1,1};
@ -179,10 +178,10 @@ SMESH_ActorDef::SMESH_ActorDef()
QFont f = mgr->fontValue( "SMESH", "numbering_elem_font" ); QFont f = mgr->fontValue( "SMESH", "numbering_elem_font" );
if ( f.family() == "Arial" ) aFamilyEl = SMESH::FntArial; if ( f.family() == "Arial" ) aFamilyEl = SMESH::FntArial;
else if ( f.family() == "Courier" ) aFamilyEl = SMESH::FntCourier; else if ( f.family() == "Courier" ) aFamilyEl = SMESH::FntCourier;
else if ( f.family() == "Times" ) aFamilyEl = SMESH::FntTimes; else if ( f.family() == "Times" ) aFamilyEl = SMESH::FntTimes;
aBoldEl = f.bold(); aBoldEl = f.bold();
anItalicEl = f.italic(); anItalicEl = f.italic();
aShadowEl = f.overline(); aShadowEl = f.overline();
aSizeEl = f.pointSize(); aSizeEl = f.pointSize();
} }
vtkFloatingPointType anRGBEl[3] = {0,1,0}; vtkFloatingPointType anRGBEl[3] = {0,1,0};
@ -218,7 +217,7 @@ SMESH_ActorDef::SMESH_ActorDef()
my2DActor->SetStoreGemetryMapping(true); my2DActor->SetStoreGemetryMapping(true);
my2DActor->SetUserMatrix(aMatrix); my2DActor->SetUserMatrix(aMatrix);
my2DActor->PickableOff(); my2DActor->PickableOff();
my2DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] ); my2DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
my2DActor->SetProperty(mySurfaceProp); my2DActor->SetProperty(mySurfaceProp);
my2DActor->SetBackfaceProperty(myBackSurfaceProp); my2DActor->SetBackfaceProperty(myBackSurfaceProp);
my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface); my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
@ -257,7 +256,7 @@ SMESH_ActorDef::SMESH_ActorDef()
my3DActor->SetStoreGemetryMapping(true); my3DActor->SetStoreGemetryMapping(true);
my3DActor->SetUserMatrix(aMatrix); my3DActor->SetUserMatrix(aMatrix);
my3DActor->PickableOff(); my3DActor->PickableOff();
my3DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] ); my3DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
my3DActor->SetProperty(myNormalVProp); my3DActor->SetProperty(myNormalVProp);
my3DActor->SetBackfaceProperty(myReversedVProp); my3DActor->SetBackfaceProperty(myReversedVProp);
my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface); my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
@ -339,7 +338,7 @@ SMESH_ActorDef::SMESH_ActorDef()
my1DProp->DeepCopy(myEdgeProp); my1DProp->DeepCopy(myEdgeProp);
my1DProp->SetLineWidth(aLineWidth + aLineWidthInc); my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
my1DProp->SetPointSize(aElem0DSize); my1DProp->SetPointSize(aElem0DSize);
my1DExtProp = vtkProperty::New(); my1DExtProp = vtkProperty::New();
my1DExtProp->DeepCopy(myEdgeProp); my1DExtProp->DeepCopy(myEdgeProp);
anRGB[0] = 1 - anRGB[0]; anRGB[0] = 1 - anRGB[0];
@ -381,7 +380,7 @@ SMESH_ActorDef::SMESH_ActorDef()
//aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints); //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
aFilter->RegisterCellsWithType(VTK_VERTEX); aFilter->RegisterCellsWithType(VTK_VERTEX);
//Definition 0D device of the actor (ball elements) //Definition 0D device of the actor (ball elements)
//----------------------------------------------- //-----------------------------------------------
myBallProp = vtkProperty::New(); myBallProp = vtkProperty::New();
@ -393,14 +392,14 @@ SMESH_ActorDef::SMESH_ActorDef()
myBallActor->SetUserMatrix(aMatrix); myBallActor->SetUserMatrix(aMatrix);
myBallActor->SetStoreGemetryMapping(true); myBallActor->SetStoreGemetryMapping(true);
myBallActor->PickableOff(); myBallActor->PickableOff();
myBallActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] ); myBallActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
myBallActor->SetVisibility(false); myBallActor->SetVisibility(false);
myBallActor->SetProperty(myBallProp); myBallActor->SetProperty(myBallProp);
myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface); myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
aFilter = myBallActor->GetExtractUnstructuredGrid(); aFilter = myBallActor->GetExtractUnstructuredGrid();
aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
aFilter->RegisterCellsWithType(VTK_POLY_VERTEX); aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
//my0DExtProp = vtkProperty::New(); //my0DExtProp = vtkProperty::New();
//my0DExtProp->DeepCopy(my0DProp); //my0DExtProp->DeepCopy(my0DProp);
//anRGB[0] = 1 - anRGB[0]; //anRGB[0] = 1 - anRGB[0];
@ -434,12 +433,12 @@ SMESH_ActorDef::SMESH_ActorDef()
myNodeActor->SetStoreClippingMapping(true); myNodeActor->SetStoreClippingMapping(true);
myNodeActor->PickableOff(); myNodeActor->PickableOff();
myNodeActor->SetVisibility(false); myNodeActor->SetVisibility(false);
myNodeActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] ); myNodeActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] );
myNodeActor->SetProperty(myNodeProp); myNodeActor->SetProperty(myNodeProp);
myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint); myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
aFilter = myNodeActor->GetExtractUnstructuredGrid(); aFilter = myNodeActor->GetExtractUnstructuredGrid();
aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints); aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
myNodeExtProp = vtkProperty::New(); myNodeExtProp = vtkProperty::New();
myNodeExtProp->DeepCopy(myNodeProp); myNodeExtProp->DeepCopy(myNodeProp);
anRGB[0] = 1 - anRGB[0]; anRGB[0] = 1 - anRGB[0];
@ -466,7 +465,7 @@ SMESH_ActorDef::SMESH_ActorDef()
myBaseActor->SetStoreGemetryMapping(true); myBaseActor->SetStoreGemetryMapping(true);
myBaseActor->GetProperty()->SetOpacity(0.0); myBaseActor->GetProperty()->SetOpacity(0.0);
myPickableActor = myBaseActor; myPickableActor = myBaseActor;
myHighlightProp = vtkProperty::New(); myHighlightProp = vtkProperty::New();
myHighlightProp->SetAmbient(1.0); myHighlightProp->SetAmbient(1.0);
myHighlightProp->SetDiffuse(0.0); myHighlightProp->SetDiffuse(0.0);
@ -480,7 +479,7 @@ SMESH_ActorDef::SMESH_ActorDef()
myBallHighlightProp = vtkProperty::New(); myBallHighlightProp = vtkProperty::New();
myBallHighlightProp->DeepCopy(myHighlightProp); myBallHighlightProp->DeepCopy(myHighlightProp);
myBallHighlightProp->SetPointSize(aBallElemSize); myBallHighlightProp->SetPointSize(aBallElemSize);
myOutLineProp = vtkProperty::New(); myOutLineProp = vtkProperty::New();
myOutLineProp->SetAmbient(1.0); myOutLineProp->SetAmbient(1.0);
@ -522,7 +521,7 @@ SMESH_ActorDef::SMESH_ActorDef()
//Definition of myScalarBarActor //Definition of myScalarBarActor
//------------------------------ //------------------------------
myLookupTable = vtkLookupTable::New(); myLookupTable = vtkLookupTable::New();
//Fix for Bug PAL5195 - SMESH764: //Fix for Bug PAL5195 - SMESH764:
//Controls - Aspect Ratio: incorrect colors of the best and worst values //Controls - Aspect Ratio: incorrect colors of the best and worst values
myLookupTable->SetHueRange(0.667,0.0); myLookupTable->SetHueRange(0.667,0.0);
@ -541,11 +540,11 @@ SMESH_ActorDef::SMESH_ActorDef()
myEntityMode = eAllEntity; myEntityMode = eAllEntity;
myEntityModeCache = eAllEntity; myEntityModeCache = eAllEntity;
// Clipping planes // Clipping planes
myImplicitBoolean = vtkImplicitBoolean::New(); myImplicitBoolean = vtkImplicitBoolean::New();
myImplicitBoolean->SetOperationTypeToIntersection(); myImplicitBoolean->SetOperationTypeToIntersection();
//Quadratic 2D elements representation //Quadratic 2D elements representation
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0); int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
@ -559,11 +558,11 @@ SMESH_ActorDef::SMESH_ActorDef()
my2DActor->SetQuadraticArcMode(true); my2DActor->SetQuadraticArcMode(true);
my1DActor->SetQuadraticArcMode(true); my1DActor->SetQuadraticArcMode(true);
} }
int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2); int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle); myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
my2DActor->SetQuadraticArcAngle(aQuadraticAngle); my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
// Set colors of the name actor // Set colors of the name actor
SMESH::GetColor( "SMESH", "default_grp_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) ); SMESH::GetColor( "SMESH", "default_grp_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]); myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
@ -619,8 +618,8 @@ SMESH_ActorDef::~SMESH_ActorDef()
// myControlActor->Delete(); myControlActor == my2DActor // myControlActor->Delete(); myControlActor == my2DActor
myNodeExtProp->Delete(); myNodeExtProp->Delete();
myNodeExtActor->Delete(); myNodeExtActor->Delete();
my1DProp->Delete(); my1DProp->Delete();
my1DActor->Delete(); my1DActor->Delete();
my1DExtProp->Delete(); my1DExtProp->Delete();
@ -632,8 +631,8 @@ SMESH_ActorDef::~SMESH_ActorDef()
myBallActor->Delete(); myBallActor->Delete();
//my0DExtProp->Delete(); //my0DExtProp->Delete();
//my0DExtActor->Delete(); //my0DExtActor->Delete();
myImplicitBoolean->Delete(); myImplicitBoolean->Delete();
#ifndef DISABLE_PLOT2DVIEWER #ifndef DISABLE_PLOT2DVIEWER
if(my2dHistogram) { if(my2dHistogram) {
@ -656,7 +655,7 @@ void SMESH_ActorDef::Delete()
} }
void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled ) void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
{ {
if(myNodeActor) { if(myNodeActor) {
myNodeActor->SetPointsLabeled(theIsPointsLabeled); myNodeActor->SetPointsLabeled(theIsPointsLabeled);
SetRepresentation(GetRepresentation()); SetRepresentation(GetRepresentation());
@ -667,7 +666,7 @@ void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
void SMESH_ActorDef::SetPointsFontProperties( SMESH::LabelFont theFamily, int theSize, void SMESH_ActorDef::SetPointsFontProperties( SMESH::LabelFont theFamily, int theSize,
bool theBold, bool theItalic, bool theShadow, bool theBold, bool theItalic, bool theShadow,
vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b ) vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b )
{ {
if(myNodeActor) { if(myNodeActor) {
myNodeActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b ); myNodeActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
SetRepresentation( GetRepresentation() ); SetRepresentation( GetRepresentation() );
@ -678,7 +677,7 @@ void SMESH_ActorDef::SetPointsFontProperties( SMESH::LabelFont theFamily, int th
void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int theSize, void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int theSize,
bool theBold, bool theItalic, bool theShadow, bool theBold, bool theItalic, bool theShadow,
vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b ) vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b )
{ {
if(my3DActor) { if(my3DActor) {
my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b ); my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
SetRepresentation( GetRepresentation() ); SetRepresentation( GetRepresentation() );
@ -723,10 +722,10 @@ void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
if(my0DActor) if(my0DActor)
my0DActor->SetCellsLabeled(theIsCellsLabeled); my0DActor->SetCellsLabeled(theIsCellsLabeled);
if(myBallActor) if(myBallActor)
myBallActor->SetCellsLabeled(theIsCellsLabeled); myBallActor->SetCellsLabeled(theIsCellsLabeled);
myTimeStamp->Modified(); myTimeStamp->Modified();
} }
@ -801,7 +800,7 @@ bool SMESH_ActorDef::GetFacesOrientation3DVectors()
} }
void void
SMESH_ActorDef:: SMESH_ActorDef::
SetControlMode(eControl theMode) SetControlMode(eControl theMode)
{ {
@ -809,12 +808,16 @@ SetControlMode(eControl theMode)
} }
void void
SMESH_ActorDef:: SMESH_ActorDef::
SetControlMode(eControl theMode, SetControlMode(eControl theMode,
bool theCheckEntityMode) bool theCheckEntityMode)
{ {
SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr(); vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
lookupTable->SetScale(VTK_SCALE_LINEAR);
SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
if( !mgr ) if( !mgr )
return; return;
@ -1036,7 +1039,7 @@ SetControlMode(eControl theMode,
if (!myIsEntityModeCache){ if (!myIsEntityModeCache){
myEntityModeCache = GetEntityMode(); myEntityModeCache = GetEntityMode();
myIsEntityModeCache=true; myIsEntityModeCache=true;
} }
SetEntityMode(eEdges); SetEntityMode(eEdges);
} }
else if(myControlActor == my2DActor) { else if(myControlActor == my2DActor) {
@ -1048,7 +1051,7 @@ SetControlMode(eControl theMode,
if (!myIsEntityModeCache){ if (!myIsEntityModeCache){
myEntityModeCache = GetEntityMode(); myEntityModeCache = GetEntityMode();
myIsEntityModeCache=true; myIsEntityModeCache=true;
} }
SetEntityMode(eFaces); SetEntityMode(eFaces);
break; break;
default: default:
@ -1062,7 +1065,7 @@ SetControlMode(eControl theMode,
if (!myIsEntityModeCache){ if (!myIsEntityModeCache){
myEntityModeCache = GetEntityMode(); myEntityModeCache = GetEntityMode();
myIsEntityModeCache=true; myIsEntityModeCache=true;
} }
SetEntityMode(eVolumes); SetEntityMode(eVolumes);
} }
} }
@ -1080,15 +1083,22 @@ SetControlMode(eControl theMode,
myTimeStamp->Modified(); myTimeStamp->Modified();
Modified(); Modified();
lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
double * range = lookupTable->GetRange();
if (isLogarithmic && range[0] > 1e-07 && range[1] > 1e-07)
lookupTable->SetScale(VTK_SCALE_LOG10);
Update(); Update();
} }
void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){ void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
//myHighlightActor->AddToRender(theRenderer); //myHighlightActor->AddToRender(theRenderer);
theRenderer->AddActor(myBaseActor); theRenderer->AddActor(myBaseActor);
theRenderer->AddActor(myNodeExtActor); theRenderer->AddActor(myNodeExtActor);
theRenderer->AddActor(my1DExtActor); theRenderer->AddActor(my1DExtActor);
@ -1103,7 +1113,7 @@ void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
//theRenderer->AddActor(my0DExtActor); //theRenderer->AddActor(my0DExtActor);
theRenderer->AddActor(myHighlitableActor); theRenderer->AddActor(myHighlitableActor);
theRenderer->AddActor2D(myScalarBarActor); theRenderer->AddActor2D(myScalarBarActor);
// the superclass' method should be called at the end // the superclass' method should be called at the end
@ -1137,8 +1147,8 @@ void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
} }
bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj, bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
const char* theEntry, const char* theEntry,
const char* theName, const char* theName,
int theIsClear) int theIsClear)
{ {
@ -1155,23 +1165,23 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
myHighlitableActor->Init(myVisualObj,myImplicitBoolean); myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
myNodeExtActor->Init(myVisualObj,myImplicitBoolean); myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
my0DActor->Init(myVisualObj,myImplicitBoolean); my0DActor->Init(myVisualObj,myImplicitBoolean);
myBallActor->Init(myVisualObj,myImplicitBoolean); myBallActor->Init(myVisualObj,myImplicitBoolean);
//my0DExtActor->Init(myVisualObj,myImplicitBoolean); //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
my1DActor->Init(myVisualObj,myImplicitBoolean); my1DActor->Init(myVisualObj,myImplicitBoolean);
my1DExtActor->Init(myVisualObj,myImplicitBoolean); my1DExtActor->Init(myVisualObj,myImplicitBoolean);
my2DActor->Init(myVisualObj,myImplicitBoolean); my2DActor->Init(myVisualObj,myImplicitBoolean);
my2DExtActor->Init(myVisualObj,myImplicitBoolean); my2DExtActor->Init(myVisualObj,myImplicitBoolean);
my3DActor->Init(myVisualObj,myImplicitBoolean); my3DActor->Init(myVisualObj,myImplicitBoolean);
my3DExtActor->Init(myVisualObj,myImplicitBoolean); my3DExtActor->Init(myVisualObj,myImplicitBoolean);
my0DActor->GetMapper()->SetLookupTable(myLookupTable); my0DActor->GetMapper()->SetLookupTable(myLookupTable);
myBallActor->GetMapper()->SetLookupTable(myLookupTable); myBallActor->GetMapper()->SetLookupTable(myLookupTable);
//my0DExtActor->GetMapper()->SetLookupTable(myLookupTable); //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
my1DActor->GetMapper()->SetLookupTable(myLookupTable); my1DActor->GetMapper()->SetLookupTable(myLookupTable);
my1DExtActor->GetMapper()->SetLookupTable(myLookupTable); my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
@ -1179,7 +1189,7 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
my2DExtActor->GetMapper()->SetLookupTable(myLookupTable); my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
my3DActor->GetMapper()->SetLookupTable(myLookupTable); my3DActor->GetMapper()->SetLookupTable(myLookupTable);
my3DExtActor->GetMapper()->SetLookupTable(myLookupTable); my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
vtkFloatingPointType aFactor, aUnits; vtkFloatingPointType aFactor, aUnits;
my2DActor->GetPolygonOffsetParameters(aFactor,aUnits); my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75); my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
@ -1197,7 +1207,7 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
int aMode = mgr->integerValue( "SMESH", "display_mode" ); int aMode = mgr->integerValue( "SMESH", "display_mode" );
SetRepresentation(-1); SetRepresentation(-1);
if(aMode == 0){ if(aMode == 0){
SetRepresentation(eEdge); SetRepresentation(eEdge);
}else if(aMode == 1){ }else if(aMode == 1){
@ -1205,7 +1215,7 @@ bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
}else if(aMode == 2){ }else if(aMode == 2){
SetRepresentation(ePoint); SetRepresentation(ePoint);
} }
if(aMode == 3){ if(aMode == 3){
SetShrink(); SetShrink();
} }
@ -1238,7 +1248,7 @@ void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
myNodeActor->SetTransform(theTransform); myNodeActor->SetTransform(theTransform);
myBaseActor->SetTransform(theTransform); myBaseActor->SetTransform(theTransform);
myHighlitableActor->SetTransform(theTransform); myHighlitableActor->SetTransform(theTransform);
myNodeExtActor->SetTransform(theTransform); myNodeExtActor->SetTransform(theTransform);
@ -1274,7 +1284,7 @@ vtkMapper* SMESH_ActorDef::GetMapper(){
} }
vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){ vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
return myVisualObj->GetUnstructuredGrid(); return myVisualObj->GetUnstructuredGrid();
} }
@ -1283,7 +1293,7 @@ bool SMESH_ActorDef::IsInfinitive(){
vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid(); vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
aDataSet->Update(); aDataSet->Update();
myIsInfinite = aDataSet->GetNumberOfCells() == 0 || myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
( aDataSet->GetNumberOfCells() == 1 && ( aDataSet->GetNumberOfCells() == 1 &&
aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX ); aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
return SALOME_Actor::IsInfinitive(); return SALOME_Actor::IsInfinitive();
} }
@ -1381,7 +1391,7 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
myNodeActor->VisibilityOff(); myNodeActor->VisibilityOff();
myBaseActor->VisibilityOff(); myBaseActor->VisibilityOff();
myNodeExtActor->VisibilityOff(); myNodeExtActor->VisibilityOff();
my0DActor->VisibilityOff(); my0DActor->VisibilityOff();
@ -1390,18 +1400,18 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
my1DActor->VisibilityOff(); my1DActor->VisibilityOff();
my1DExtActor->VisibilityOff(); my1DExtActor->VisibilityOff();
my2DActor->VisibilityOff(); my2DActor->VisibilityOff();
my2DExtActor->VisibilityOff(); my2DExtActor->VisibilityOff();
my3DActor->VisibilityOff(); my3DActor->VisibilityOff();
my3DExtActor->VisibilityOff(); my3DExtActor->VisibilityOff();
myScalarBarActor->VisibilityOff(); myScalarBarActor->VisibilityOff();
if(GetVisibility()){ if(GetVisibility()){
if(theIsUpdateRepersentation) if(theIsUpdateRepersentation)
SetRepresentation(GetRepresentation()); SetRepresentation(GetRepresentation());
if(myControlMode != eNone){ if(myControlMode != eNone){
switch(myControlMode){ switch(myControlMode){
case eFreeNodes: case eFreeNodes:
@ -1449,34 +1459,34 @@ void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
if(myEntityMode & eEdges && GetRepresentation() != ePoint){ if(myEntityMode & eEdges && GetRepresentation() != ePoint){
my1DActor->VisibilityOn(); my1DActor->VisibilityOn();
} }
if(myEntityMode & eFaces && GetRepresentation() != ePoint){ if(myEntityMode & eFaces && GetRepresentation() != ePoint){
my2DActor->VisibilityOn(); my2DActor->VisibilityOn();
} }
if(myEntityMode & eVolumes && GetRepresentation() != ePoint){ if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
my3DActor->VisibilityOn(); my3DActor->VisibilityOn();
} }
if(myNodeActor->GetPointsLabeled()){ if(myNodeActor->GetPointsLabeled()){
myNodeActor->VisibilityOn(); myNodeActor->VisibilityOn();
} }
if(my0DActor) if(my0DActor)
my0DActor->UpdateLabels(); my0DActor->UpdateLabels();
if(myBallActor) if(myBallActor)
myBallActor->UpdateLabels(); myBallActor->UpdateLabels();
if(my1DActor) if(my1DActor)
my1DActor->UpdateLabels(); my1DActor->UpdateLabels();
if(my2DActor) if(my2DActor)
my2DActor->UpdateLabels(); my2DActor->UpdateLabels();
if(my3DActor) if(my3DActor)
my3DActor->UpdateLabels(); my3DActor->UpdateLabels();
} }
#ifndef DISABLE_PLOT2DVIEWER #ifndef DISABLE_PLOT2DVIEWER
else else
SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer); SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
@ -1597,7 +1607,7 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
//#ifdef VTK_HAVE_POLYHEDRON //#ifdef VTK_HAVE_POLYHEDRON
aFilter->RegisterCellsWithType(VTK_POLYHEDRON); aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
//#endif //#endif
aHightFilter->RegisterCellsWithType(VTK_TETRA); aHightFilter->RegisterCellsWithType(VTK_TETRA);
aHightFilter->RegisterCellsWithType(VTK_VOXEL); aHightFilter->RegisterCellsWithType(VTK_VOXEL);
aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON); aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
@ -1620,7 +1630,7 @@ void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
} }
void SMESH_ActorDef::SetRepresentation (int theMode) void SMESH_ActorDef::SetRepresentation (int theMode)
{ {
int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge); int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face); int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume); int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
@ -1642,7 +1652,7 @@ void SMESH_ActorDef::SetRepresentation (int theMode)
case eSurface: case eSurface:
if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return; if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
break; break;
} }
myRepresentation = theMode; myRepresentation = theMode;
} }
@ -1655,7 +1665,7 @@ void SMESH_ActorDef::SetRepresentation (int theMode)
myIsShrunk = true; myIsShrunk = true;
} else { } else {
SetShrink(); SetShrink();
} }
} }
myPickableActor = myBaseActor; myPickableActor = myBaseActor;
@ -1696,7 +1706,7 @@ void SMESH_ActorDef::SetRepresentation (int theMode)
my2DActor->SetQuadraticArcMode(true); my2DActor->SetQuadraticArcMode(true);
my2DExtActor->SetRepresentation(aReperesent); my2DExtActor->SetRepresentation(aReperesent);
my3DActor->SetProperty(aPropVN); my3DActor->SetProperty(aPropVN);
my3DActor->SetBackfaceProperty(aPropVR); my3DActor->SetBackfaceProperty(aPropVR);
my3DActor->SetRepresentation(aReperesent); my3DActor->SetRepresentation(aReperesent);
@ -1721,7 +1731,7 @@ void SMESH_ActorDef::SetRepresentation (int theMode)
aReperesent = SMESH_DeviceActor::eInsideframe; aReperesent = SMESH_DeviceActor::eInsideframe;
break; break;
} }
if(aQuadraticMode == SMESH_Actor::eLines) if(aQuadraticMode == SMESH_Actor::eLines)
my1DActor->SetQuadraticArcMode(false); my1DActor->SetQuadraticArcMode(false);
else if(aQuadraticMode == SMESH_Actor::eArcs) else if(aQuadraticMode == SMESH_Actor::eArcs)
@ -1753,7 +1763,7 @@ void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
SetRepresentation(GetRepresentation()); SetRepresentation(GetRepresentation());
} }
bool SMESH_ActorDef::GetPointRepresentation(){ bool SMESH_ActorDef::GetPointRepresentation(){
return myIsPointsVisible || myNodeActor->GetPointsLabeled(); return myIsPointsVisible || myNodeActor->GetPointsLabeled();
} }
@ -1776,7 +1786,7 @@ void SMESH_ActorDef::UpdateHighlight(){
myBallActor->SetProperty(myBallPreselectProp); myBallActor->SetProperty(myBallPreselectProp);
} else if(anIsVisible){ } else if(anIsVisible){
myBallActor->SetProperty(myBallProp); myBallActor->SetProperty(myBallProp);
(myRepresentation == eSurface) ? (myRepresentation == eSurface) ?
myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp); myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
} }
if(GetUnstructuredGrid()->GetNumberOfCells()) { if(GetUnstructuredGrid()->GetNumberOfCells()) {
@ -1813,10 +1823,10 @@ void SMESH_ActorDef::highlight(bool theHighlight){
} }
void SMESH_ActorDef::SetPreSelected(bool thePreselect){ void SMESH_ActorDef::SetPreSelected(bool thePreselect){
if ( myIsPreselected == thePreselect ) if ( myIsPreselected == thePreselect )
return; return;
myIsPreselected = thePreselect; myIsPreselected = thePreselect;
UpdateHighlight(); UpdateHighlight();
} }
@ -1870,30 +1880,30 @@ void SMESH_ActorDef::Update(){
if(my0DActor) if(my0DActor)
my0DActor->UpdateLabels(); my0DActor->UpdateLabels();
if(myBallActor) if(myBallActor)
myBallActor->UpdateLabels(); myBallActor->UpdateLabels();
if(my1DActor) if(my1DActor)
my1DActor->UpdateLabels(); my1DActor->UpdateLabels();
if(my2DActor) if(my2DActor)
my2DActor->UpdateLabels(); my2DActor->UpdateLabels();
if(my3DActor) if(my3DActor)
my3DActor->UpdateLabels(); my3DActor->UpdateLabels();
if(myIsFacesOriented){ if(myIsFacesOriented){
SetFacesOriented(myIsFacesOriented); SetFacesOriented(myIsFacesOriented);
} }
if(myVisualObj->GetEntitiesFlag()) { if(myVisualObj->GetEntitiesFlag()) {
myEntityMode |= myVisualObj->GetEntitiesState(); myEntityMode |= myVisualObj->GetEntitiesState();
} }
SetEntityMode(GetEntityMode()); SetEntityMode(GetEntityMode());
SetVisibility(GetVisibility()); SetVisibility(GetVisibility());
myTimeStamp->Modified(); myTimeStamp->Modified();
Modified(); Modified();
} }
@ -1940,7 +1950,7 @@ void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType
if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) ) if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
if( aGroupObj->GetElementType() == SMDSAbs_Face ) if( aGroupObj->GetElementType() == SMDSAbs_Face )
myNameActor->SetBackgroundColor(r,g,b); myNameActor->SetBackgroundColor(r,g,b);
myDeltaBrightness = delta; myDeltaBrightness = delta;
QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta); QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. ); myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
@ -1958,7 +1968,7 @@ void SMESH_ActorDef::SetVolumeColor(vtkFloatingPointType r,vtkFloatingPointType
if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) ) if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
if( aGroupObj->GetElementType() == SMDSAbs_Volume ) if( aGroupObj->GetElementType() == SMDSAbs_Volume )
myNameActor->SetBackgroundColor(r,g,b); myNameActor->SetBackgroundColor(r,g,b);
myDeltaVBrightness = delta; myDeltaVBrightness = delta;
QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta); QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. ); myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
@ -1994,7 +2004,7 @@ void SMESH_ActorDef::GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointTyp
} }
void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
myNodeProp->SetColor(r,g,b); myNodeProp->SetColor(r,g,b);
myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b); myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) ) if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
@ -2003,11 +2013,11 @@ void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,
Modified(); Modified();
} }
void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
::GetColor(myNodeProp,r,g,b); ::GetColor(myNodeProp,r,g,b);
} }
void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
my0DProp->SetColor(r,g,b); my0DProp->SetColor(r,g,b);
if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) ) if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
if( aGroupObj->GetElementType() == SMDSAbs_0DElement ) if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
@ -2015,11 +2025,11 @@ void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vt
Modified(); Modified();
} }
void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
::GetColor(my0DProp,r,g,b); ::GetColor(my0DProp,r,g,b);
} }
void SMESH_ActorDef::SetBallColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ void SMESH_ActorDef::SetBallColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
myBallProp->SetColor(r,g,b); myBallProp->SetColor(r,g,b);
if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) ) if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
if( aGroupObj->GetElementType() == SMDSAbs_Ball ) if( aGroupObj->GetElementType() == SMDSAbs_Ball )
@ -2027,27 +2037,27 @@ void SMESH_ActorDef::SetBallColor(vtkFloatingPointType r,vtkFloatingPointType g,
Modified(); Modified();
} }
void SMESH_ActorDef::GetBallColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ void SMESH_ActorDef::GetBallColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
::GetColor(myBallProp,r,g,b); ::GetColor(myBallProp,r,g,b);
} }
void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
myHighlightProp->SetColor(r,g,b); myHighlightProp->SetColor(r,g,b);
myBallHighlightProp->SetColor(r,g,b); myBallHighlightProp->SetColor(r,g,b);
Modified(); Modified();
} }
void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
::GetColor(myHighlightProp,r,g,b); ::GetColor(myHighlightProp,r,g,b);
} }
void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
myPreselectProp->SetColor(r,g,b); myPreselectProp->SetColor(r,g,b);
myBallPreselectProp->SetColor(r,g,b); myBallPreselectProp->SetColor(r,g,b);
Modified(); Modified();
} }
void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){ void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
::GetColor(myPreselectProp,r,g,b); ::GetColor(myPreselectProp,r,g,b);
} }
@ -2061,7 +2071,7 @@ void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
myEdgeProp->SetLineWidth(theVal); myEdgeProp->SetLineWidth(theVal);
my1DProp->SetLineWidth(theVal + aLineWidthInc); my1DProp->SetLineWidth(theVal + aLineWidthInc);
my1DExtProp->SetLineWidth(theVal + aLineWidthInc); my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
my2DExtProp->SetLineWidth(theVal + aLineWidthInc); my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
my3DExtProp->SetLineWidth(theVal + aLineWidthInc); my3DExtProp->SetLineWidth(theVal + aLineWidthInc);
myOutLineProp->SetLineWidth(theVal); myOutLineProp->SetLineWidth(theVal);
@ -2153,7 +2163,7 @@ SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed); my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
} }
vtkIdType vtkIdType
SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane) SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
{ {
if(thePlane){ if(thePlane){
@ -2184,7 +2194,7 @@ GetNumberOfClippingPlanes()
return myCippingPlaneCont.size(); return myCippingPlaneCont.size();
} }
vtkPlane* vtkPlane*
SMESH_ActorDef:: SMESH_ActorDef::
GetClippingPlane(vtkIdType theID) GetClippingPlane(vtkIdType theID)
{ {
@ -2312,7 +2322,7 @@ void SMESH_ActorDef::UpdateScalarBar()
int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0); int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
myScalarBarActor->SetDistributionColoringType(coloringType); myScalarBarActor->SetDistributionColoringType(coloringType);
QColor distributionColor = mgr->colorValue("SMESH", "distribution_color", QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
QColor(255, 255, 255)); QColor(255, 255, 255));
double rgb[3]; double rgb[3];
@ -2321,7 +2331,7 @@ void SMESH_ActorDef::UpdateScalarBar()
rgb[2]= distributionColor.blue()/255.; rgb[2]= distributionColor.blue()/255.;
myScalarBarActor->SetDistributionColor(rgb); myScalarBarActor->SetDistributionColor(rgb);
} }
void SMESH_ActorDef::UpdateDistribution() void SMESH_ActorDef::UpdateDistribution()
@ -2340,7 +2350,8 @@ void SMESH_ActorDef::UpdateDistribution()
elemIds.push_back( (*e)->GetID()); elemIds.push_back( (*e)->GetID());
vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable()); vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
double * range = lookupTable->GetRange(); double * range = lookupTable->GetRange();
fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range); bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
myScalarBarActor->SetDistribution(nbEvents); myScalarBarActor->SetDistribution(nbEvents);
} }
} }
@ -2394,17 +2405,17 @@ SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
if(my2dHistogram) if(my2dHistogram)
my2dHistogram->clearAllPoints(); my2dHistogram->clearAllPoints();
if(SMESH::Controls::NumericalFunctor* fun = if(SMESH::Controls::NumericalFunctor* fun =
dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get())) dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
{ {
if(!my2dHistogram) { if(!my2dHistogram) {
my2dHistogram = new SPlot2d_Histogram(); my2dHistogram = new SPlot2d_Histogram();
Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName()); Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
my2dHistogram->setIO(anIO); my2dHistogram->setIO(anIO);
} }
int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors(); int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
std::vector<int> nbEvents; std::vector<int> nbEvents;
std::vector<double> funValues; std::vector<double> funValues;
@ -2412,22 +2423,23 @@ SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get())) if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems ); dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
std::vector<int> elemIds; std::vector<int> elemIds;
for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e) for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
elemIds.push_back( (*e)->GetID()); elemIds.push_back( (*e)->GetID());
vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable()); vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
double * range = lookupTable->GetRange(); double * range = lookupTable->GetRange();
fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range); bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ ) for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i])); my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
if(funValues.size() >= 2) if(funValues.size() >= 2)
my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ; my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
} }
//Color of the histogram //Color of the histogram
if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE) if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
my2dHistogram->setAutoAssign(true); my2dHistogram->setAutoAssign(true);
@ -2438,7 +2450,7 @@ SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
my2dHistogram->setColor(aColor); my2dHistogram->setColor(aColor);
} }
return my2dHistogram; return my2dHistogram;
} }
#endif #endif

View File

@ -1108,9 +1108,10 @@
vtkLookupTable* lookupTable = vtkLookupTable* lookupTable =
static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable()); static_cast<vtkLookupTable*>(aScalarBarActor->GetLookupTable());
double * minmax = lookupTable->GetRange(); double * minmax = lookupTable->GetRange();
bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
std::vector<int> nbEvents; std::vector<int> nbEvents;
std::vector<double> funValues; std::vector<double> funValues;
aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax ); aNumFun->GetHistogram( nbIntervals, nbEvents, funValues, elements, minmax, isLogarithmic );
QString anInitialPath = ""; QString anInitialPath = "";
if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() ) if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() )
anInitialPath = QDir::currentPath(); anInitialPath = QDir::currentPath();
@ -1603,7 +1604,7 @@
aControl = SMESH_Actor::eCoincidentElems3D; aControl = SMESH_Actor::eCoincidentElems3D;
break; break;
} }
anActor->SetControlMode(aControl); anActor->SetControlMode(aControl);
anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() ); anActor->GetScalarBarActor()->SetTitle( functorToString( anActor->GetFunctor() ).toLatin1().constData() );
SMESH::RepaintCurrentView(); SMESH::RepaintCurrentView();

View File

@ -18,13 +18,12 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 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 // SMESH SMESHGUI : GUI for SMESH component
// File : SMESHGUI_Preferences_ScalarBarDlg.cxx // File : SMESHGUI_Preferences_ScalarBarDlg.cxx
// Author : Nicolas REJNERI, Open CASCADE S.A.S. // Author : Nicolas REJNERI, Open CASCADE S.A.S.
// SMESH includes // SMESH includes
//
#include "SMESHGUI_Preferences_ScalarBarDlg.h" #include "SMESHGUI_Preferences_ScalarBarDlg.h"
#include "SMESHGUI.h" #include "SMESHGUI.h"
@ -130,22 +129,28 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI*
/******************************************************************************/ /******************************************************************************/
// Scalar range // Scalar range
myRangeGrp = new QGroupBox ( tr( "SMESH_RANGE_SCALARBAR" ), this ); myRangeGrp = new QGroupBox ( tr( "SMESH_RANGE_SCALARBAR" ), this );
QHBoxLayout* myRangeGrpLayout = new QHBoxLayout( myRangeGrp ); //QHBoxLayout* myRangeGrpLayout = new QHBoxLayout( myRangeGrp );
QGridLayout* myRangeGrpLayout = new QGridLayout( myRangeGrp );
myRangeGrpLayout->setSpacing( SPACING_SIZE ); myRangeGrpLayout->setMargin( MARGIN_SIZE ); myRangeGrpLayout->setSpacing( SPACING_SIZE ); myRangeGrpLayout->setMargin( MARGIN_SIZE );
myMinEdit = new QLineEdit( myRangeGrp ); myMinEdit = new QLineEdit( myRangeGrp );
myMinEdit->setMinimumWidth( MINIMUM_WIDTH ); myMinEdit->setMinimumWidth( MINIMUM_WIDTH );
myMinEdit->setValidator( new QDoubleValidator( this ) ); myMinEdit->setValidator( new QDoubleValidator( this ) );
myMaxEdit = new QLineEdit( myRangeGrp ); myMaxEdit = new QLineEdit( myRangeGrp );
myMaxEdit->setMinimumWidth( MINIMUM_WIDTH ); myMaxEdit->setMinimumWidth( MINIMUM_WIDTH );
myMaxEdit->setValidator( new QDoubleValidator( this ) ); myMaxEdit->setValidator( new QDoubleValidator( this ) );
myRangeGrpLayout->addWidget( new QLabel( tr( "SMESH_RANGE_MIN" ), myRangeGrp ) ); myLogarithmicCheck = new QCheckBox (myRangeGrp);
myRangeGrpLayout->addWidget( myMinEdit ); myLogarithmicCheck->setText(tr("SMESH_LOGARITHMIC_SCALARBAR"));
myRangeGrpLayout->addWidget( new QLabel( tr( "SMESH_RANGE_MAX" ), myRangeGrp ) ); myLogarithmicCheck->setChecked(false);
myRangeGrpLayout->addWidget( myMaxEdit );
myRangeGrpLayout->addWidget( new QLabel( tr( "SMESH_RANGE_MIN" ), myRangeGrp ), 0, 0, 1, 1 );
myRangeGrpLayout->addWidget( myMinEdit, 0, 1, 1, 1 );
myRangeGrpLayout->addWidget( new QLabel( tr( "SMESH_RANGE_MAX" ), myRangeGrp ), 0, 2, 1, 1 );
myRangeGrpLayout->addWidget( myMaxEdit, 0, 3, 1, 1 );
myRangeGrpLayout->addWidget( myLogarithmicCheck, 1, 0, 1, 4 );
aTopLayout->addWidget( myRangeGrp ); aTopLayout->addWidget( myRangeGrp );
/******************************************************************************/ /******************************************************************************/
@ -255,19 +260,19 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI*
myYSpin = new SMESHGUI_SpinBox(myOriginDimGrp); myYSpin = new SMESHGUI_SpinBox(myOriginDimGrp);
myYSpin->setAcceptNames( false ); myYSpin->setAcceptNames( false );
myYSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" ); myYSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" );
myYSpin->setMinimumWidth( MINIMUM_WIDTH ); myYSpin->setMinimumWidth( MINIMUM_WIDTH );
myYSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myYSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
myWidthSpin = new SMESHGUI_SpinBox(myOriginDimGrp); myWidthSpin = new SMESHGUI_SpinBox(myOriginDimGrp);
myWidthSpin->setAcceptNames( false ); myWidthSpin->setAcceptNames( false );
myWidthSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" ); myWidthSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" );
myWidthSpin->setMinimumWidth( MINIMUM_WIDTH ); myWidthSpin->setMinimumWidth( MINIMUM_WIDTH );
myWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myWidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
myHeightSpin = new SMESHGUI_SpinBox(myOriginDimGrp); myHeightSpin = new SMESHGUI_SpinBox(myOriginDimGrp);
myHeightSpin->setAcceptNames( false ); myHeightSpin->setAcceptNames( false );
myHeightSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" ); myHeightSpin->RangeStepAndValidator( 0.0, 1.0, 0.1, "parametric_precision" );
myHeightSpin->setMinimumWidth( MINIMUM_WIDTH ); myHeightSpin->setMinimumWidth( MINIMUM_WIDTH );
myHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); myHeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
@ -297,18 +302,18 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI*
myDistribColorGrp->addButton(myDMonoColor);myDistribColorGrp->setId(myDMonoColor,1); myDistribColorGrp->addButton(myDMonoColor);myDistribColorGrp->setId(myDMonoColor,1);
myDistribColorGrp->addButton(myDMultiColor);myDistribColorGrp->setId(myDMultiColor,2); myDistribColorGrp->addButton(myDMultiColor);myDistribColorGrp->setId(myDMultiColor,2);
aDistributionGrpLayout->addWidget( myDMultiColor ); aDistributionGrpLayout->addWidget( myDMultiColor );
aDistributionGrpLayout->addWidget( myDMonoColor ); aDistributionGrpLayout->addWidget( myDMonoColor );
//Color of the Distribution in monocolor case: //Color of the Distribution in monocolor case:
myDistributionColorLbl = new QLabel( tr( "SMESH_DISTRIBUTION_COLOR" ), myDistributionGrp ); myDistributionColorLbl = new QLabel( tr( "SMESH_DISTRIBUTION_COLOR" ), myDistributionGrp );
aDistributionGrpLayout->addWidget( myDistributionColorLbl ); aDistributionGrpLayout->addWidget( myDistributionColorLbl );
myMonoColorBtn = new QtxColorButton( myDistributionGrp ); myMonoColorBtn = new QtxColorButton( myDistributionGrp );
aDistributionGrpLayout->addWidget(myMonoColorBtn); aDistributionGrpLayout->addWidget(myMonoColorBtn);
aTopLayout->addWidget(myDistributionGrp); aTopLayout->addWidget(myDistributionGrp);
/******************************************************************************/ /******************************************************************************/
// Common buttons // Common buttons
myButtonGrp = new QGroupBox( this ); myButtonGrp = new QGroupBox( this );
@ -351,13 +356,13 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI*
myTitleFontCombo->setCurrentIndex(1); myTitleFontCombo->setCurrentIndex(1);
if( f.family()=="Times") if( f.family()=="Times")
myTitleFontCombo->setCurrentIndex(2); myTitleFontCombo->setCurrentIndex(2);
myTitleBoldCheck->setChecked ( f.bold() ); myTitleBoldCheck->setChecked ( f.bold() );
myTitleItalicCheck->setChecked( f.italic() ); myTitleItalicCheck->setChecked( f.italic() );
myTitleShadowCheck->setChecked( f.overline() ); myTitleShadowCheck->setChecked( f.overline() );
} }
QColor labelColor = mgr->colorValue("SMESH", "scalar_bar_label_color", QColor labelColor = mgr->colorValue("SMESH", "scalar_bar_label_color",
QColor(255, 255, 255)); QColor(255, 255, 255));
myLabelsColorBtn->setColor(labelColor); myLabelsColorBtn->setColor(labelColor);
myLabelsFontCombo->setCurrentIndex(0); myLabelsFontCombo->setCurrentIndex(0);
@ -369,7 +374,7 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI*
myLabelsFontCombo->setCurrentIndex(1); myLabelsFontCombo->setCurrentIndex(1);
if (f.family() == "Times") if (f.family() == "Times")
myLabelsFontCombo->setCurrentIndex(2); myLabelsFontCombo->setCurrentIndex(2);
myLabelsBoldCheck ->setChecked( f.bold() ); myLabelsBoldCheck ->setChecked( f.bold() );
myLabelsItalicCheck->setChecked( f.italic() ); myLabelsItalicCheck->setChecked( f.italic() );
myLabelsShadowCheck->setChecked( f.overline() ); myLabelsShadowCheck->setChecked( f.overline() );
@ -391,7 +396,7 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI*
QString name = isHoriz ? "scalar_bar_horizontal_%1" : "scalar_bar_vertical_%1"; QString name = isHoriz ? "scalar_bar_horizontal_%1" : "scalar_bar_vertical_%1";
myIniX = mgr->doubleValue("SMESH", name.arg( "x" ), myIniX = mgr->doubleValue("SMESH", name.arg( "x" ),
myHorizRadioBtn->isChecked() ? DEF_HOR_X : DEF_VER_X); myHorizRadioBtn->isChecked() ? DEF_HOR_X : DEF_VER_X);
myIniY = mgr->doubleValue("SMESH", name.arg( "y" ), myIniY = mgr->doubleValue("SMESH", name.arg( "y" ),
@ -412,18 +417,16 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI*
int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0); int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
if( coloringType == SMESH_MONOCOLOR_TYPE ) { if( coloringType == SMESH_MONOCOLOR_TYPE ) {
myDMonoColor->setChecked(true); myDMonoColor->setChecked(true);
onDistributionChanged(myDistribColorGrp->id(myDMonoColor)); onDistributionChanged(myDistribColorGrp->id(myDMonoColor));
} else { } else {
myDMultiColor->setChecked(true); myDMultiColor->setChecked(true);
onDistributionChanged(myDistribColorGrp->id(myDMultiColor)); onDistributionChanged(myDistribColorGrp->id(myDMultiColor));
} }
QColor distributionColor = mgr->colorValue("SMESH", "distribution_color", QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
QColor(255, 255, 255)); QColor(255, 255, 255));
myMonoColorBtn->setColor(distributionColor); myMonoColorBtn->setColor(distributionColor);
// --> then init from selection if necessary // --> then init from selection if necessary
onSelectionChanged(); onSelectionChanged();
@ -434,6 +437,8 @@ SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( SMESHGUI*
connect( myApplyBtn, SIGNAL( clicked() ), this, SLOT( onApply() ) ); connect( myApplyBtn, SIGNAL( clicked() ), this, SLOT( onApply() ) );
connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( onCancel() ) ); connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( onCancel() ) );
connect( myHelpBtn, SIGNAL(clicked()), this, SLOT( onHelp() ) ); connect( myHelpBtn, SIGNAL(clicked()), this, SLOT( onHelp() ) );
connect( myMinEdit, SIGNAL( textChanged(const QString &) ), this, SLOT( onMinMaxChanged() ) );
connect( myMaxEdit, SIGNAL( textChanged(const QString &) ), this, SLOT( onMinMaxChanged() ) );
connect( myXSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) ); connect( myXSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) );
connect( myYSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) ); connect( myYSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) );
connect( aOrientationGrp, SIGNAL( buttonClicked( int ) ), this, SLOT( onOrientationChanged() ) ); connect( aOrientationGrp, SIGNAL( buttonClicked( int ) ), this, SLOT( onOrientationChanged() ) );
@ -528,9 +533,9 @@ bool SMESHGUI_Preferences_ScalarBarDlg::onApply()
if( myDistributionGrp->isChecked() ) { if( myDistributionGrp->isChecked() ) {
int ColoringType = myDMultiColor->isChecked() ? SMESH_MULTICOLOR_TYPE : SMESH_MONOCOLOR_TYPE; int ColoringType = myDMultiColor->isChecked() ? SMESH_MULTICOLOR_TYPE : SMESH_MONOCOLOR_TYPE;
distributionTypeChanged = (ColoringType != myScalarBarActor->GetDistributionColoringType()); distributionTypeChanged = (ColoringType != myScalarBarActor->GetDistributionColoringType());
if(distributionTypeChanged) if (distributionTypeChanged)
myScalarBarActor->SetDistributionColoringType(ColoringType); myScalarBarActor->SetDistributionColoringType(ColoringType);
if( !myDMultiColor->isChecked() ) { if( !myDMultiColor->isChecked() ) {
QColor aTColor = myMonoColorBtn->color(); QColor aTColor = myMonoColorBtn->color();
double rgb[3], oldRgb[3];; double rgb[3], oldRgb[3];;
@ -551,29 +556,31 @@ bool SMESHGUI_Preferences_ScalarBarDlg::onApply()
double oldMinMax[2] = { myLookupTable->GetRange()[0], myLookupTable->GetRange()[1] }; double oldMinMax[2] = { myLookupTable->GetRange()[0], myLookupTable->GetRange()[1] };
bool rangeChanges = ( fabs( oldMinMax[0] - aMin ) + fabs( oldMinMax[1] - aMax ) > bool rangeChanges = ( fabs( oldMinMax[0] - aMin ) + fabs( oldMinMax[1] - aMax ) >
0.001 * ( aMax-aMin + oldMinMax[1]-oldMinMax[0] )); 0.001 * ( aMax-aMin + oldMinMax[1]-oldMinMax[0] ));
bool nbColorsChanged = (myColorsSpin->value() != myScalarBarActor->GetMaximumNumberOfColors()); bool nbColorsChanged = (myColorsSpin->value() != myScalarBarActor->GetMaximumNumberOfColors());
if(nbColorsChanged) if(nbColorsChanged)
myScalarBarActor->SetMaximumNumberOfColors(myColorsSpin->value()); myScalarBarActor->SetMaximumNumberOfColors(myColorsSpin->value());
myLookupTable->SetRange( aMin, aMax ); myLookupTable->SetRange( aMin, aMax );
myLookupTable->SetNumberOfTableValues(myColorsSpin->value()); myLookupTable->SetNumberOfTableValues(myColorsSpin->value());
bool scaleChanged = (myLogarithmicCheck->isChecked() != (myLookupTable->GetScale() == VTK_SCALE_LOG10));
if (scaleChanged)
myLookupTable->SetScale(myLogarithmicCheck->isChecked() ? VTK_SCALE_LOG10 : VTK_SCALE_LINEAR);
myLookupTable->Build(); myLookupTable->Build();
if( nbColorsChanged || rangeChanges) if (nbColorsChanged || rangeChanges || scaleChanged)
myActor->UpdateDistribution(); myActor->UpdateDistribution();
#ifndef DISABLE_PLOT2DVIEWER #ifndef DISABLE_PLOT2DVIEWER
if( myActor->GetPlot2Histogram() && if( myActor->GetPlot2Histogram() &&
(nbColorsChanged || (nbColorsChanged ||
rangeChanges || rangeChanges ||
distributionTypeChanged || distributionTypeChanged ||
colorChanged )) colorChanged ))
SMESH::ProcessIn2DViewers(myActor); SMESH::ProcessIn2DViewers(myActor);
#endif #endif
SMESH::RepaintCurrentView(); SMESH::RepaintCurrentView();
return true; return true;
@ -601,7 +608,7 @@ void SMESHGUI_Preferences_ScalarBarDlg::onCancel()
void SMESHGUI_Preferences_ScalarBarDlg::onHelp() void SMESHGUI_Preferences_ScalarBarDlg::onHelp()
{ {
LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
if (app) if (app)
app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName); app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
else { else {
QString platform; QString platform;
@ -612,7 +619,7 @@ void SMESHGUI_Preferences_ScalarBarDlg::onHelp()
#endif #endif
SUIT_MessageBox::warning(this, tr("WRN_WARNING"), SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
arg(app->resourceMgr()->stringValue("ExternalBrowser", arg(app->resourceMgr()->stringValue("ExternalBrowser",
platform)). platform)).
arg(myHelpFileName)); arg(myHelpFileName));
} }
@ -639,9 +646,13 @@ void SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged()
SMESH_ScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor(); SMESH_ScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor();
if ( myScalarBarActor->GetLookupTable() ) { if ( myScalarBarActor->GetLookupTable() ) {
vtkFloatingPointType *range = myScalarBarActor->GetLookupTable()->GetRange(); vtkLookupTable* aLookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
vtkFloatingPointType *range = aLookupTable->GetRange();
myMinEdit->setText( QString::number( range[0],'g',12 ) ); myMinEdit->setText( QString::number( range[0],'g',12 ) );
myMaxEdit->setText( QString::number( range[1],'g',12 ) ); myMaxEdit->setText( QString::number( range[1],'g',12 ) );
myLogarithmicCheck->setChecked(aLookupTable->GetScale() == VTK_SCALE_LOG10);
myLogarithmicCheck->setEnabled(range[0] > 1e-07 && range[1] > 1e-07);
} }
vtkTextProperty* aTitleTextPrp = myScalarBarActor->GetTitleTextProperty(); vtkTextProperty* aTitleTextPrp = myScalarBarActor->GetTitleTextProperty();
@ -682,15 +693,14 @@ void SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged()
myMonoColorBtn->setColor( QColor( (int)( aTColor[0]*255 ), (int)( aTColor[1]*255 ), (int)( aTColor[2]*255 ) ) ); myMonoColorBtn->setColor( QColor( (int)( aTColor[0]*255 ), (int)( aTColor[1]*255 ), (int)( aTColor[2]*255 ) ) );
if ( coloringType == SMESH_MONOCOLOR_TYPE ) { if ( coloringType == SMESH_MONOCOLOR_TYPE ) {
myDMonoColor->setChecked(true); myDMonoColor->setChecked(true);
onDistributionChanged(myDistribColorGrp->id(myDMonoColor)); onDistributionChanged(myDistribColorGrp->id(myDMonoColor));
} else { } else {
myDMultiColor->setChecked(true); myDMultiColor->setChecked(true);
onDistributionChanged(myDistribColorGrp->id(myDMultiColor)); onDistributionChanged(myDistribColorGrp->id(myDMultiColor));
} }
myDistributionGrp->setChecked((bool)myScalarBarActor->GetDistributionVisibility()); myDistributionGrp->setChecked((bool)myScalarBarActor->GetDistributionVisibility());
onDistributionActivated(myScalarBarActor->GetDistributionVisibility()); onDistributionActivated(myScalarBarActor->GetDistributionVisibility());
myRangeGrp->setEnabled( true ); myRangeGrp->setEnabled( true );
myFontGrp->setEnabled( true ); myFontGrp->setEnabled( true );
myLabColorGrp->setEnabled( true ); myLabColorGrp->setEnabled( true );
@ -727,6 +737,22 @@ void SMESHGUI_Preferences_ScalarBarDlg::closeEvent( QCloseEvent* e )
QDialog::closeEvent( e ); QDialog::closeEvent( e );
} }
//=================================================================================================
/*!
* SMESHGUI_Preferences_ScalarBarDlg::onMinMaxChanged
*
* Called when Scalar Range values are changed
*/
//=================================================================================================
void SMESHGUI_Preferences_ScalarBarDlg::onMinMaxChanged()
{
double aMin = myMinEdit->text().toDouble();
double aMax = myMaxEdit->text().toDouble();
bool isLogarithmicEnabled = (aMin > 1e-07 && aMax > 1e-07);
myLogarithmicCheck->setChecked(isLogarithmicEnabled);
myLogarithmicCheck->setEnabled(isLogarithmicEnabled);
}
//================================================================================================= //=================================================================================================
/*! /*!
* SMESHGUI_Preferences_ScalarBarDlg::onXYChanged * SMESHGUI_Preferences_ScalarBarDlg::onXYChanged
@ -833,7 +859,7 @@ void SMESHGUI_Preferences_ScalarBarDlg::initScalarBarFromResources()
QString name; QString name;
if (mgr){ if (mgr){
// initialize from resoources // initialize from resoources
// horizontal // horizontal
name = QString("scalar_bar_horizontal_%1"); name = QString("scalar_bar_horizontal_%1");
if (mgr->hasValue("SMESH", name.arg( "x" ))) if (mgr->hasValue("SMESH", name.arg( "x" )))

View File

@ -23,7 +23,7 @@
// SMESH SMESHGUI : GUI for SMESH component // SMESH SMESHGUI : GUI for SMESH component
// File : SMESHGUI_Preferences_ScalarBarDlg.h // File : SMESHGUI_Preferences_ScalarBarDlg.h
// Author : Nicolas REJNERI, Open CASCADE S.A.S. // Author : Nicolas REJNERI, Open CASCADE S.A.S.
//
#ifndef SMESHGUI_PREFERENCES_SCALARBARDLG_H #ifndef SMESHGUI_PREFERENCES_SCALARBARDLG_H
#define SMESHGUI_PREFERENCES_SCALARBARDLG_H #define SMESHGUI_PREFERENCES_SCALARBARDLG_H
@ -78,6 +78,7 @@ protected slots:
void onHelp(); void onHelp();
void onSelectionChanged(); void onSelectionChanged();
void onXYChanged(); void onXYChanged();
void onMinMaxChanged();
void onOrientationChanged(); void onOrientationChanged();
void onDistributionChanged( int ); void onDistributionChanged( int );
void onDistributionActivated( bool ); void onDistributionActivated( bool );
@ -94,6 +95,7 @@ private:
QGroupBox* myRangeGrp; QGroupBox* myRangeGrp;
QLineEdit* myMinEdit; QLineEdit* myMinEdit;
QLineEdit* myMaxEdit; QLineEdit* myMaxEdit;
QCheckBox* myLogarithmicCheck;
QGroupBox* myFontGrp; QGroupBox* myFontGrp;
QtxColorButton* myTitleColorBtn; QtxColorButton* myTitleColorBtn;

View File

@ -1828,6 +1828,10 @@ Check algorithm documentation for supported geometry</translation>
<source>SMESH_LENGTH</source> <source>SMESH_LENGTH</source>
<translation>Length</translation> <translation>Length</translation>
</message> </message>
<message>
<source>SMESH_LOGARITHMIC_SCALARBAR</source>
<translation>Logarithmic</translation>
</message>
<message> <message>
<source>SMESH_MAKE_GROUPS</source> <source>SMESH_MAKE_GROUPS</source>
<translation>Generate groups</translation> <translation>Generate groups</translation>

View File

@ -1800,6 +1800,10 @@ Référez-vous à la documentation sur l&apos;algorithme et la géométrie suppo
<source>SMESH_LENGTH</source> <source>SMESH_LENGTH</source>
<translation>Longueur</translation> <translation>Longueur</translation>
</message> </message>
<message>
<source>SMESH_LOGARITHMIC_SCALARBAR</source>
<translation type="unfinished">Logarithmic</translation>
</message>
<message> <message>
<source>SMESH_MAKE_GROUPS</source> <source>SMESH_MAKE_GROUPS</source>
<translation>Générer les groupes</translation> <translation>Générer les groupes</translation>

View File

@ -18,13 +18,12 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 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 SMESH_I : idl implementation based on 'SMESH' unit's calsses // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
// File : SMESH_Filter_i.cxx // File : SMESH_Filter_i.cxx
// Author : Alexey Petrov, OCC // Author : Alexey Petrov, OCC
// Module : SMESH // Module : SMESH
//
#include "SMESH_Filter_i.hxx" #include "SMESH_Filter_i.hxx"
#include "SMDS_ElemIterator.hxx" #include "SMDS_ElemIterator.hxx"
@ -580,12 +579,12 @@ CORBA::Double NumericalFunctor_i::GetValue( CORBA::Long theId )
return myNumericalFunctorPtr->GetValue( theId ); return myNumericalFunctorPtr->GetValue( theId );
} }
SMESH::Histogram* NumericalFunctor_i::GetHistogram(CORBA::Short nbIntervals) SMESH::Histogram* NumericalFunctor_i::GetHistogram(CORBA::Short nbIntervals, CORBA::Boolean isLogarithmic)
{ {
std::vector<int> nbEvents; std::vector<int> nbEvents;
std::vector<double> funValues; std::vector<double> funValues;
std::vector<int> elements; std::vector<int> elements;
myNumericalFunctorPtr->GetHistogram(nbIntervals,nbEvents,funValues,elements); myNumericalFunctorPtr->GetHistogram(nbIntervals,nbEvents,funValues,elements,0,isLogarithmic);
#ifdef WIN32 #ifdef WIN32
nbIntervals = CORBA::Short( min( nbEvents.size(), funValues.size() - 1)); nbIntervals = CORBA::Short( min( nbEvents.size(), funValues.size() - 1));

View File

@ -18,13 +18,12 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 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 SMESH_I : idl implementation based on 'SMESH' unit's calsses // SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
// File : SMESH_Filter_i.hxx // File : SMESH_Filter_i.hxx
// Author : Alexey Petrov, OCC // Author : Alexey Petrov, OCC
// Module : SMESH // Module : SMESH
//
#ifndef _SMESH_FILTER_I_HXX_ #ifndef _SMESH_FILTER_I_HXX_
#define _SMESH_FILTER_I_HXX_ #define _SMESH_FILTER_I_HXX_
@ -162,7 +161,7 @@ namespace SMESH
{ {
public: public:
CORBA::Double GetValue( CORBA::Long theElementId ); CORBA::Double GetValue( CORBA::Long theElementId );
SMESH::Histogram* GetHistogram(CORBA::Short nbIntervals); SMESH::Histogram* GetHistogram(CORBA::Short nbIntervals, CORBA::Boolean isLogarithmic);
void SetPrecision( CORBA::Long thePrecision ); void SetPrecision( CORBA::Long thePrecision );
CORBA::Long GetPrecision(); CORBA::Long GetPrecision();
Controls::NumericalFunctorPtr GetNumericalFunctor(); Controls::NumericalFunctorPtr GetNumericalFunctor();