// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// SMESH OBJECT : interactive object for SMESH visualization
// File : SMESH_Actor.cxx
// Author : Nicolas REJNERI
// Module : SMESH
-//
+
#include "SMESH_ActorDef.h"
#include "SMESH_ActorUtils.h"
#include "SMESH_DeviceActor.h"
}
-SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
- const char* theEntry,
+SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
+ const char* theEntry,
const char* theName,
int theIsClear)
{
SMESH_ActorDef::SMESH_ActorDef()
{
- if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
+ if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
myBaseActor = SMESH_DeviceActor::New();
myTimeStamp = vtkTimeStamp::New();
QFont f = mgr->fontValue( "SMESH", "numbering_node_font" );
if ( f.family() == "Arial" ) aFamilyNd = SMESH::FntArial;
else if ( f.family() == "Courier" ) aFamilyNd = SMESH::FntCourier;
- else if ( f.family() == "Times" ) aFamilyNd = SMESH::FntTimes;
- aBoldNd = f.bold();
- anItalicNd = f.italic();
- aShadowNd = f.overline();
+ else if ( f.family() == "Times" ) aFamilyNd = SMESH::FntTimes;
+ aBoldNd = f.bold();
+ anItalicNd = f.italic();
+ aShadowNd = f.overline();
aSizeNd = f.pointSize();
}
vtkFloatingPointType anRGBNd[3] = {1,1,1};
QFont f = mgr->fontValue( "SMESH", "numbering_elem_font" );
if ( f.family() == "Arial" ) aFamilyEl = SMESH::FntArial;
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();
anItalicEl = f.italic();
- aShadowEl = f.overline();
+ aShadowEl = f.overline();
aSizeEl = f.pointSize();
}
vtkFloatingPointType anRGBEl[3] = {0,1,0};
my2DActor->SetStoreGemetryMapping(true);
my2DActor->SetUserMatrix(aMatrix);
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->SetBackfaceProperty(myBackSurfaceProp);
my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
my3DActor->SetStoreGemetryMapping(true);
my3DActor->SetUserMatrix(aMatrix);
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->SetBackfaceProperty(myReversedVProp);
my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
my1DProp->DeepCopy(myEdgeProp);
my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
my1DProp->SetPointSize(aElem0DSize);
-
+
my1DExtProp = vtkProperty::New();
my1DExtProp->DeepCopy(myEdgeProp);
anRGB[0] = 1 - anRGB[0];
//aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
aFilter->RegisterCellsWithType(VTK_VERTEX);
-
+
//Definition 0D device of the actor (ball elements)
//-----------------------------------------------
myBallProp = vtkProperty::New();
myBallActor->SetUserMatrix(aMatrix);
myBallActor->SetStoreGemetryMapping(true);
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->SetProperty(myBallProp);
myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
aFilter = myBallActor->GetExtractUnstructuredGrid();
aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
-
+
//my0DExtProp = vtkProperty::New();
//my0DExtProp->DeepCopy(my0DProp);
//anRGB[0] = 1 - anRGB[0];
myNodeActor->SetStoreClippingMapping(true);
myNodeActor->PickableOff();
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->SetRepresentation(SMESH_DeviceActor::ePoint);
aFilter = myNodeActor->GetExtractUnstructuredGrid();
aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
-
+
myNodeExtProp = vtkProperty::New();
myNodeExtProp->DeepCopy(myNodeProp);
anRGB[0] = 1 - anRGB[0];
myBaseActor->SetStoreGemetryMapping(true);
myBaseActor->GetProperty()->SetOpacity(0.0);
myPickableActor = myBaseActor;
-
+
myHighlightProp = vtkProperty::New();
myHighlightProp->SetAmbient(1.0);
myHighlightProp->SetDiffuse(0.0);
myBallHighlightProp = vtkProperty::New();
myBallHighlightProp->DeepCopy(myHighlightProp);
myBallHighlightProp->SetPointSize(aBallElemSize);
-
+
myOutLineProp = vtkProperty::New();
myOutLineProp->SetAmbient(1.0);
//Definition of myScalarBarActor
//------------------------------
myLookupTable = vtkLookupTable::New();
- //Fix for Bug PAL5195 - SMESH764:
+ //Fix for Bug PAL5195 - SMESH764:
//Controls - Aspect Ratio: incorrect colors of the best and worst values
myLookupTable->SetHueRange(0.667,0.0);
myEntityMode = eAllEntity;
myEntityModeCache = eAllEntity;
-
+
// Clipping planes
myImplicitBoolean = vtkImplicitBoolean::New();
myImplicitBoolean->SetOperationTypeToIntersection();
-
+
//Quadratic 2D elements representation
//-----------------------------------------------------------------------------
int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
my2DActor->SetQuadraticArcMode(true);
my1DActor->SetQuadraticArcMode(true);
}
-
+
int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
-
+
// Set colors of the name actor
SMESH::GetColor( "SMESH", "default_grp_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
// myControlActor->Delete(); myControlActor == my2DActor
myNodeExtProp->Delete();
- myNodeExtActor->Delete();
-
+ myNodeExtActor->Delete();
+
my1DProp->Delete();
my1DActor->Delete();
my1DExtProp->Delete();
myBallActor->Delete();
//my0DExtProp->Delete();
//my0DExtActor->Delete();
-
- myImplicitBoolean->Delete();
+
+ myImplicitBoolean->Delete();
#ifndef DISABLE_PLOT2DVIEWER
if(my2dHistogram) {
}
void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
-{
+{
if(myNodeActor) {
myNodeActor->SetPointsLabeled(theIsPointsLabeled);
SetRepresentation(GetRepresentation());
void SMESH_ActorDef::SetPointsFontProperties( SMESH::LabelFont theFamily, int theSize,
bool theBold, bool theItalic, bool theShadow,
vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b )
-{
+{
if(myNodeActor) {
myNodeActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
SetRepresentation( GetRepresentation() );
void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int theSize,
bool theBold, bool theItalic, bool theShadow,
vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b )
-{
+{
if(my3DActor) {
my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
SetRepresentation( GetRepresentation() );
if(my0DActor)
my0DActor->SetCellsLabeled(theIsCellsLabeled);
-
+
if(myBallActor)
myBallActor->SetCellsLabeled(theIsCellsLabeled);
-
+
myTimeStamp->Modified();
}
}
-void
+void
SMESH_ActorDef::
SetControlMode(eControl theMode)
{
}
-void
+void
SMESH_ActorDef::
SetControlMode(eControl theMode,
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 )
return;
if (!myIsEntityModeCache){
myEntityModeCache = GetEntityMode();
myIsEntityModeCache=true;
- }
+ }
SetEntityMode(eEdges);
}
else if(myControlActor == my2DActor) {
if (!myIsEntityModeCache){
myEntityModeCache = GetEntityMode();
myIsEntityModeCache=true;
- }
+ }
SetEntityMode(eFaces);
break;
default:
if (!myIsEntityModeCache){
myEntityModeCache = GetEntityMode();
myIsEntityModeCache=true;
- }
+ }
SetEntityMode(eVolumes);
}
}
myTimeStamp->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();
}
void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
-
+
//myHighlightActor->AddToRender(theRenderer);
- theRenderer->AddActor(myBaseActor);
+ theRenderer->AddActor(myBaseActor);
theRenderer->AddActor(myNodeExtActor);
theRenderer->AddActor(my1DExtActor);
//theRenderer->AddActor(my0DExtActor);
theRenderer->AddActor(myHighlitableActor);
-
+
theRenderer->AddActor2D(myScalarBarActor);
// the superclass' method should be called at the end
}
-bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
- const char* theEntry,
+bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
+ const char* theEntry,
const char* theName,
int theIsClear)
{
myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
-
+
my0DActor->Init(myVisualObj,myImplicitBoolean);
myBallActor->Init(myVisualObj,myImplicitBoolean);
//my0DExtActor->Init(myVisualObj,myImplicitBoolean);
-
+
my1DActor->Init(myVisualObj,myImplicitBoolean);
my1DExtActor->Init(myVisualObj,myImplicitBoolean);
-
+
my2DActor->Init(myVisualObj,myImplicitBoolean);
my2DExtActor->Init(myVisualObj,myImplicitBoolean);
my3DActor->Init(myVisualObj,myImplicitBoolean);
my3DExtActor->Init(myVisualObj,myImplicitBoolean);
-
+
my0DActor->GetMapper()->SetLookupTable(myLookupTable);
myBallActor->GetMapper()->SetLookupTable(myLookupTable);
//my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
-
+
my1DActor->GetMapper()->SetLookupTable(myLookupTable);
my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
my3DActor->GetMapper()->SetLookupTable(myLookupTable);
my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
-
+
vtkFloatingPointType aFactor, aUnits;
my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
int aMode = mgr->integerValue( "SMESH", "display_mode" );
SetRepresentation(-1);
-
+
if(aMode == 0){
SetRepresentation(eEdge);
}else if(aMode == 1){
}else if(aMode == 2){
SetRepresentation(ePoint);
}
-
+
if(aMode == 3){
SetShrink();
}
myNodeActor->SetTransform(theTransform);
myBaseActor->SetTransform(theTransform);
-
+
myHighlitableActor->SetTransform(theTransform);
myNodeExtActor->SetTransform(theTransform);
}
-vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
+vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
return myVisualObj->GetUnstructuredGrid();
}
vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
aDataSet->Update();
myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
- ( aDataSet->GetNumberOfCells() == 1 &&
+ ( aDataSet->GetNumberOfCells() == 1 &&
aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
return SALOME_Actor::IsInfinitive();
}
myNodeActor->VisibilityOff();
myBaseActor->VisibilityOff();
-
+
myNodeExtActor->VisibilityOff();
my0DActor->VisibilityOff();
my1DActor->VisibilityOff();
my1DExtActor->VisibilityOff();
-
+
my2DActor->VisibilityOff();
my2DExtActor->VisibilityOff();
my3DActor->VisibilityOff();
my3DExtActor->VisibilityOff();
-
+
myScalarBarActor->VisibilityOff();
-
+
if(GetVisibility()){
if(theIsUpdateRepersentation)
SetRepresentation(GetRepresentation());
-
+
if(myControlMode != eNone){
switch(myControlMode){
case eFreeNodes:
if(myEntityMode & eEdges && GetRepresentation() != ePoint){
my1DActor->VisibilityOn();
}
-
+
if(myEntityMode & eFaces && GetRepresentation() != ePoint){
my2DActor->VisibilityOn();
}
-
+
if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
my3DActor->VisibilityOn();
}
-
- if(myNodeActor->GetPointsLabeled()){
+
+ if(myNodeActor->GetPointsLabeled()){
myNodeActor->VisibilityOn();
}
if(my0DActor)
my0DActor->UpdateLabels();
-
+
if(myBallActor)
myBallActor->UpdateLabels();
-
+
if(my1DActor)
my1DActor->UpdateLabels();
-
+
if(my2DActor)
my2DActor->UpdateLabels();
-
+
if(my3DActor)
- my3DActor->UpdateLabels();
- }
+ my3DActor->UpdateLabels();
+ }
#ifndef DISABLE_PLOT2DVIEWER
else
SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
//#ifdef VTK_HAVE_POLYHEDRON
aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
//#endif
-
+
aHightFilter->RegisterCellsWithType(VTK_TETRA);
aHightFilter->RegisterCellsWithType(VTK_VOXEL);
aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
}
void SMESH_ActorDef::SetRepresentation (int theMode)
-{
+{
int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
case eSurface:
if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
break;
- }
+ }
myRepresentation = theMode;
}
myIsShrunk = true;
} else {
SetShrink();
- }
+ }
}
myPickableActor = myBaseActor;
my2DActor->SetQuadraticArcMode(true);
my2DExtActor->SetRepresentation(aReperesent);
-
+
my3DActor->SetProperty(aPropVN);
my3DActor->SetBackfaceProperty(aPropVR);
my3DActor->SetRepresentation(aReperesent);
aReperesent = SMESH_DeviceActor::eInsideframe;
break;
}
-
+
if(aQuadraticMode == SMESH_Actor::eLines)
my1DActor->SetQuadraticArcMode(false);
else if(aQuadraticMode == SMESH_Actor::eArcs)
SetRepresentation(GetRepresentation());
}
-bool SMESH_ActorDef::GetPointRepresentation(){
+bool SMESH_ActorDef::GetPointRepresentation(){
return myIsPointsVisible || myNodeActor->GetPointsLabeled();
}
myBallActor->SetProperty(myBallPreselectProp);
} else if(anIsVisible){
myBallActor->SetProperty(myBallProp);
- (myRepresentation == eSurface) ?
+ (myRepresentation == eSurface) ?
myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
}
if(GetUnstructuredGrid()->GetNumberOfCells()) {
}
-void SMESH_ActorDef::SetPreSelected(bool thePreselect){
+void SMESH_ActorDef::SetPreSelected(bool thePreselect){
if ( myIsPreselected == thePreselect )
return;
- myIsPreselected = thePreselect;
+ myIsPreselected = thePreselect;
UpdateHighlight();
}
if(my0DActor)
my0DActor->UpdateLabels();
-
+
if(myBallActor)
myBallActor->UpdateLabels();
-
+
if(my1DActor)
my1DActor->UpdateLabels();
-
+
if(my2DActor)
my2DActor->UpdateLabels();
if(my3DActor)
my3DActor->UpdateLabels();
-
+
if(myIsFacesOriented){
SetFacesOriented(myIsFacesOriented);
}
-
+
if(myVisualObj->GetEntitiesFlag()) {
myEntityMode |= myVisualObj->GetEntitiesState();
}
-
+
SetEntityMode(GetEntityMode());
SetVisibility(GetVisibility());
-
+
myTimeStamp->Modified();
Modified();
}
if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
if( aGroupObj->GetElementType() == SMDSAbs_Face )
myNameActor->SetBackgroundColor(r,g,b);
-
+
myDeltaBrightness = 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. );
if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
if( aGroupObj->GetElementType() == SMDSAbs_Volume )
myNameActor->SetBackgroundColor(r,g,b);
-
+
myDeltaVBrightness = 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. );
}
-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);
myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
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);
}
-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);
if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
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);
}
-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);
if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
if( aGroupObj->GetElementType() == SMDSAbs_Ball )
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);
}
-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);
myBallHighlightProp->SetColor(r,g,b);
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);
}
-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);
myBallPreselectProp->SetColor(r,g,b);
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);
}
myEdgeProp->SetLineWidth(theVal);
my1DProp->SetLineWidth(theVal + aLineWidthInc);
- my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
+ my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
my3DExtProp->SetLineWidth(theVal + aLineWidthInc);
myOutLineProp->SetLineWidth(theVal);
my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
}
-vtkIdType
+vtkIdType
SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
{
if(thePlane){
return myCippingPlaneCont.size();
}
-vtkPlane*
+vtkPlane*
SMESH_ActorDef::
GetClippingPlane(vtkIdType theID)
{
int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
myScalarBarActor->SetDistributionColoringType(coloringType);
-
+
QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
QColor(255, 255, 255));
double rgb[3];
rgb[2]= distributionColor.blue()/255.;
myScalarBarActor->SetDistributionColor(rgb);
-
+
}
void SMESH_ActorDef::UpdateDistribution()
elemIds.push_back( (*e)->GetID());
vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
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);
}
}
if(my2dHistogram)
my2dHistogram->clearAllPoints();
-
+
if(SMESH::Controls::NumericalFunctor* fun =
dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
{
-
+
if(!my2dHistogram) {
my2dHistogram = new SPlot2d_Histogram();
Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
my2dHistogram->setIO(anIO);
}
-
+
int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
std::vector<int> nbEvents;
std::vector<double> funValues;
if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
std::vector<int> elemIds;
-
+
for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
elemIds.push_back( (*e)->GetID());
vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
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]));
if(funValues.size() >= 2)
my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
}
-
+
//Color of the histogram
if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
my2dHistogram->setAutoAssign(true);
my2dHistogram->setColor(aColor);
}
-
+
return my2dHistogram;
}
#endif
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
// SMESH SMESHGUI : GUI for SMESH component
// File : SMESHGUI_Preferences_ScalarBarDlg.cxx
// Author : Nicolas REJNERI, Open CASCADE S.A.S.
// SMESH includes
-//
+
#include "SMESHGUI_Preferences_ScalarBarDlg.h"
#include "SMESHGUI.h"
/******************************************************************************/
// Scalar range
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 );
-
+
myMinEdit = new QLineEdit( myRangeGrp );
myMinEdit->setMinimumWidth( MINIMUM_WIDTH );
myMinEdit->setValidator( new QDoubleValidator( this ) );
-
+
myMaxEdit = new QLineEdit( myRangeGrp );
myMaxEdit->setMinimumWidth( MINIMUM_WIDTH );
myMaxEdit->setValidator( new QDoubleValidator( this ) );
-
- myRangeGrpLayout->addWidget( new QLabel( tr( "SMESH_RANGE_MIN" ), myRangeGrp ) );
- myRangeGrpLayout->addWidget( myMinEdit );
- myRangeGrpLayout->addWidget( new QLabel( tr( "SMESH_RANGE_MAX" ), myRangeGrp ) );
- myRangeGrpLayout->addWidget( myMaxEdit );
-
+
+ myLogarithmicCheck = new QCheckBox (myRangeGrp);
+ myLogarithmicCheck->setText(tr("SMESH_LOGARITHMIC_SCALARBAR"));
+ myLogarithmicCheck->setChecked(false);
+
+ 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 );
/******************************************************************************/
myYSpin = new SMESHGUI_SpinBox(myOriginDimGrp);
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->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
myWidthSpin = new SMESHGUI_SpinBox(myOriginDimGrp);
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->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
myHeightSpin = new SMESHGUI_SpinBox(myOriginDimGrp);
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->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
myDistribColorGrp->addButton(myDMonoColor);myDistribColorGrp->setId(myDMonoColor,1);
myDistribColorGrp->addButton(myDMultiColor);myDistribColorGrp->setId(myDMultiColor,2);
-
+
aDistributionGrpLayout->addWidget( myDMultiColor );
aDistributionGrpLayout->addWidget( myDMonoColor );
-
+
//Color of the Distribution in monocolor case:
myDistributionColorLbl = new QLabel( tr( "SMESH_DISTRIBUTION_COLOR" ), myDistributionGrp );
aDistributionGrpLayout->addWidget( myDistributionColorLbl );
myMonoColorBtn = new QtxColorButton( myDistributionGrp );
aDistributionGrpLayout->addWidget(myMonoColorBtn);
-
+
aTopLayout->addWidget(myDistributionGrp);
-
+
/******************************************************************************/
// Common buttons
myButtonGrp = new QGroupBox( this );
myTitleFontCombo->setCurrentIndex(1);
if( f.family()=="Times")
myTitleFontCombo->setCurrentIndex(2);
-
+
myTitleBoldCheck->setChecked ( f.bold() );
myTitleItalicCheck->setChecked( f.italic() );
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));
myLabelsColorBtn->setColor(labelColor);
myLabelsFontCombo->setCurrentIndex(0);
myLabelsFontCombo->setCurrentIndex(1);
if (f.family() == "Times")
myLabelsFontCombo->setCurrentIndex(2);
-
+
myLabelsBoldCheck ->setChecked( f.bold() );
myLabelsItalicCheck->setChecked( f.italic() );
myLabelsShadowCheck->setChecked( f.overline() );
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);
myIniY = mgr->doubleValue("SMESH", name.arg( "y" ),
int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
if( coloringType == SMESH_MONOCOLOR_TYPE ) {
myDMonoColor->setChecked(true);
- onDistributionChanged(myDistribColorGrp->id(myDMonoColor));
+ onDistributionChanged(myDistribColorGrp->id(myDMonoColor));
} else {
myDMultiColor->setChecked(true);
onDistributionChanged(myDistribColorGrp->id(myDMultiColor));
}
-
+
QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
QColor(255, 255, 255));
myMonoColorBtn->setColor(distributionColor);
-
-
// --> then init from selection if necessary
onSelectionChanged();
connect( myApplyBtn, SIGNAL( clicked() ), this, SLOT( onApply() ) );
connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( onCancel() ) );
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( myYSpin, SIGNAL( valueChanged( double ) ), this, SLOT( onXYChanged() ) );
connect( aOrientationGrp, SIGNAL( buttonClicked( int ) ), this, SLOT( onOrientationChanged() ) );
if( myDistributionGrp->isChecked() ) {
int ColoringType = myDMultiColor->isChecked() ? SMESH_MULTICOLOR_TYPE : SMESH_MONOCOLOR_TYPE;
distributionTypeChanged = (ColoringType != myScalarBarActor->GetDistributionColoringType());
- if(distributionTypeChanged)
+ if (distributionTypeChanged)
myScalarBarActor->SetDistributionColoringType(ColoringType);
-
+
if( !myDMultiColor->isChecked() ) {
QColor aTColor = myMonoColorBtn->color();
double rgb[3], oldRgb[3];;
double oldMinMax[2] = { myLookupTable->GetRange()[0], myLookupTable->GetRange()[1] };
bool rangeChanges = ( fabs( oldMinMax[0] - aMin ) + fabs( oldMinMax[1] - aMax ) >
0.001 * ( aMax-aMin + oldMinMax[1]-oldMinMax[0] ));
-
+
bool nbColorsChanged = (myColorsSpin->value() != myScalarBarActor->GetMaximumNumberOfColors());
if(nbColorsChanged)
myScalarBarActor->SetMaximumNumberOfColors(myColorsSpin->value());
-
myLookupTable->SetRange( aMin, aMax );
myLookupTable->SetNumberOfTableValues(myColorsSpin->value());
+
+ bool scaleChanged = (myLogarithmicCheck->isChecked() != (myLookupTable->GetScale() == VTK_SCALE_LOG10));
+ if (scaleChanged)
+ myLookupTable->SetScale(myLogarithmicCheck->isChecked() ? VTK_SCALE_LOG10 : VTK_SCALE_LINEAR);
+
myLookupTable->Build();
- if( nbColorsChanged || rangeChanges)
+ if (nbColorsChanged || rangeChanges || scaleChanged)
myActor->UpdateDistribution();
-
+
#ifndef DISABLE_PLOT2DVIEWER
- if( myActor->GetPlot2Histogram() &&
- (nbColorsChanged ||
+ if( myActor->GetPlot2Histogram() &&
+ (nbColorsChanged ||
rangeChanges ||
- distributionTypeChanged ||
+ distributionTypeChanged ||
colorChanged ))
SMESH::ProcessIn2DViewers(myActor);
#endif
-
-
SMESH::RepaintCurrentView();
return true;
void SMESHGUI_Preferences_ScalarBarDlg::onHelp()
{
LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
- if (app)
+ if (app)
app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
else {
QString platform;
#endif
SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
- arg(app->resourceMgr()->stringValue("ExternalBrowser",
+ arg(app->resourceMgr()->stringValue("ExternalBrowser",
platform)).
arg(myHelpFileName));
}
SMESH_ScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor();
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 ) );
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();
myMonoColorBtn->setColor( QColor( (int)( aTColor[0]*255 ), (int)( aTColor[1]*255 ), (int)( aTColor[2]*255 ) ) );
if ( coloringType == SMESH_MONOCOLOR_TYPE ) {
myDMonoColor->setChecked(true);
- onDistributionChanged(myDistribColorGrp->id(myDMonoColor));
+ onDistributionChanged(myDistribColorGrp->id(myDMonoColor));
} else {
myDMultiColor->setChecked(true);
onDistributionChanged(myDistribColorGrp->id(myDMultiColor));
}
myDistributionGrp->setChecked((bool)myScalarBarActor->GetDistributionVisibility());
onDistributionActivated(myScalarBarActor->GetDistributionVisibility());
-
-
+
myRangeGrp->setEnabled( true );
myFontGrp->setEnabled( true );
myLabColorGrp->setEnabled( true );
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
QString name;
if (mgr){
// initialize from resoources
-
+
// horizontal
name = QString("scalar_bar_horizontal_%1");
if (mgr->hasValue("SMESH", name.arg( "x" )))