INT PAL 0052685: Add possibility to show/hide Scalar Bar of Actor

This commit is contained in:
imn 2015-04-21 10:37:02 +03:00
parent 718926b36c
commit 25190cc8a5
7 changed files with 99 additions and 22 deletions

View File

@ -1187,7 +1187,7 @@ namespace
} }
} }
void ShowDistribution() { void ShowElement(int theCommandID ) {
LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr(); LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
SALOME_ListIO selected; SALOME_ListIO selected;
if ( aSel ) if ( aSel )
@ -1199,7 +1199,12 @@ namespace
SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ); SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) { if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor(); SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility()); if ( theCommandID == SMESHOp::OpShowDistribution ) {
aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
}
else if ( theCommandID == SMESHOp::OpShowScalarBar ) {
aScalarBarActor->SetVisibility( !aScalarBarActor->GetVisibility());
}
} }
} }
} }
@ -1323,7 +1328,7 @@ namespace
QColor orientationColor, outlineColor, volumeColor; QColor orientationColor, outlineColor, volumeColor;
int deltaF = 0, deltaV = 0; int deltaF = 0, deltaV = 0;
int elem0dSize = 1; int elem0dSize = 1;
int ballSize = 1; //int ballSize = 1;
double ballScale = 1.0; double ballScale = 1.0;
int edgeWidth = 1; int edgeWidth = 1;
int outlineWidth = 1; int outlineWidth = 1;
@ -1368,7 +1373,7 @@ namespace
// balls: color, size // balls: color, size
anActor->GetBallColor( color[0], color[1], color[2] ); anActor->GetBallColor( color[0], color[1], color[2] );
ballColor.setRgbF( color[0], color[1], color[2] ); ballColor.setRgbF( color[0], color[1], color[2] );
ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1 //ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2 ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2
// outlines: color // outlines: color
anActor->GetOutlineColor( color[0], color[1], color[2] ); anActor->GetOutlineColor( color[0], color[1], color[2] );
@ -1425,7 +1430,7 @@ namespace
dlg.setElem0dSize( elem0dSize ); dlg.setElem0dSize( elem0dSize );
// balls: color, size // balls: color, size
dlg.setBallColor( ballColor ); dlg.setBallColor( ballColor );
dlg.setBallSize( ballSize ); //dlg.setBallSize( ballSize );
dlg.setBallScale( ballScale ); dlg.setBallScale( ballScale );
// orientation: color, scale, 3d flag // orientation: color, scale, 3d flag
dlg.setOrientationColor( orientationColor ); dlg.setOrientationColor( orientationColor );
@ -1452,7 +1457,7 @@ namespace
elem0dColor = dlg.elem0dColor(); elem0dColor = dlg.elem0dColor();
elem0dSize = dlg.elem0dSize(); elem0dSize = dlg.elem0dSize();
ballColor = dlg.ballColor(); ballColor = dlg.ballColor();
ballSize = dlg.ballSize(); // ballSize = dlg.ballSize();
ballScale = dlg.ballScale(); ballScale = dlg.ballScale();
orientationColor = dlg.orientationColor(); orientationColor = dlg.orientationColor();
orientationScale = dlg.orientationSize() / 100.; orientationScale = dlg.orientationSize() / 100.;
@ -1496,7 +1501,7 @@ namespace
anActor->Set0DSize( elem0dSize ); anActor->Set0DSize( elem0dSize );
// balls: color, size // balls: color, size
anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() ); anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
anActor->SetBallSize( ballSize ); // anActor->SetBallSize( ballSize );
anActor->SetBallScale( ballScale ); anActor->SetBallScale( ballScale );
// orientation: color, scale, 3d flag // orientation: color, scale, 3d flag
anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() ); anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
@ -2482,6 +2487,12 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this ); SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
break; break;
} }
case SMESHOp::OpShowScalarBar:
{
// show/hide scalar bar
::ShowElement(theCommandID);
break;
}
case SMESHOp::OpSaveDistribution: case SMESHOp::OpSaveDistribution:
{ {
// dump control distribution data to the text file // dump control distribution data to the text file
@ -2491,8 +2502,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpShowDistribution: case SMESHOp::OpShowDistribution:
{ {
// show/ distribution // show/hide distribution
::ShowDistribution(); ::ShowElement(theCommandID);
break; break;
} }
@ -3921,6 +3932,7 @@ void SMESHGUI::initialize( CAM_Application* app )
createSMESHAction( SMESHOp::OpReset, "RESET" ); createSMESHAction( SMESHOp::OpReset, "RESET" );
createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" ); createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" );
createSMESHAction( SMESHOp::OpShowScalarBar, "SHOW_SCALAR_BAR","",0, true );
createSMESHAction( SMESHOp::OpSaveDistribution, "SAVE_DISTRIBUTION" ); createSMESHAction( SMESHOp::OpSaveDistribution, "SAVE_DISTRIBUTION" );
createSMESHAction( SMESHOp::OpShowDistribution, "SHOW_DISTRIBUTION","",0, true ); createSMESHAction( SMESHOp::OpShowDistribution, "SHOW_DISTRIBUTION","",0, true );
#ifndef DISABLE_PLOT2DVIEWER #ifndef DISABLE_PLOT2DVIEWER
@ -4639,6 +4651,9 @@ void SMESHGUI::initialize( CAM_Application* app )
popupMgr()->insert( separator(), anId, -1 ); popupMgr()->insert( separator(), anId, -1 );
popupMgr()->insert( action( SMESHOp::OpShowScalarBar ), anId, -1 );
popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone' && isScalarBarVisible", QtxPopupMgr::ToggleRule );
popupMgr()->insert( action( SMESHOp::OpScalarBarProperties ), anId, -1 ); popupMgr()->insert( action( SMESHOp::OpScalarBarProperties ), anId, -1 );
popupMgr()->setRule( action( SMESHOp::OpScalarBarProperties ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule ); popupMgr()->setRule( action( SMESHOp::OpScalarBarProperties ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
@ -4651,7 +4666,7 @@ void SMESHGUI::initialize( CAM_Application* app )
popupMgr()->insert( action( SMESHOp::OpShowDistribution ), aSubId, -1 ); popupMgr()->insert( action( SMESHOp::OpShowDistribution ), aSubId, -1 );
popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule ); popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule); popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isScalarBarVisible && isDistributionVisible", QtxPopupMgr::ToggleRule);
#ifndef DISABLE_PLOT2DVIEWER #ifndef DISABLE_PLOT2DVIEWER
popupMgr()->insert( action( SMESHOp::OpPlotDistribution ), aSubId, -1 ); popupMgr()->insert( action( SMESHOp::OpPlotDistribution ), aSubId, -1 );
@ -5129,8 +5144,10 @@ void SMESHGUI::createPreferences()
int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup, int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
LightApp_Preferences::IntSpin, "SMESH", "elem0d_size"); LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup, /* int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size"); LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size"); */
int ballDiameter = addPreference(tr("PREF_BALL_DIAMETER"), elemGroup,
LightApp_Preferences::IntSpin, "SMESH", "ball_elem_diameter");
double ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup, double ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale"); LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
int elemW = addPreference(tr("PREF_WIDTH"), elemGroup, int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
@ -5143,8 +5160,12 @@ void SMESHGUI::createPreferences()
setPreferenceProperty( size0d, "min", 1 ); setPreferenceProperty( size0d, "min", 1 );
setPreferenceProperty( size0d, "max", 10 ); setPreferenceProperty( size0d, "max", 10 );
setPreferenceProperty( ballSize, "min", 1 ); // setPreferenceProperty( ballSize, "min", 1 );
setPreferenceProperty( ballSize, "max", 10 ); // setPreferenceProperty( ballSize, "max", 10 );
setPreferenceProperty( ballDiameter, "min", 1e-7 );
setPreferenceProperty( ballDiameter, "max", 1e9 );
setPreferenceProperty( ballDiameter, "step", 0.1 );
setPreferenceProperty( ballScale, "min", 1e-2 ); setPreferenceProperty( ballScale, "min", 1e-2 );
setPreferenceProperty( ballScale, "max", 1e7 ); setPreferenceProperty( ballScale, "max", 1e7 );
@ -5821,7 +5842,8 @@ void SMESHGUI::storeVisualParameters (int savePoint)
sizeStr << "elem0d"; sizeStr << "elem0d";
sizeStr << QString::number((int)aSmeshActor->Get0DSize()); sizeStr << QString::number((int)aSmeshActor->Get0DSize());
sizeStr << "ball"; sizeStr << "ball";
sizeStr << QString::number((int)aSmeshActor->GetBallSize()); //sizeStr << QString::number((int)aSmeshActor->GetBallSize());
sizeStr << QString::number((double)aSmeshActor->GetBallSize());
sizeStr << QString::number((double)aSmeshActor->GetBallScale()); sizeStr << QString::number((double)aSmeshActor->GetBallScale());
sizeStr << "shrink"; sizeStr << "shrink";
sizeStr << QString::number(aSmeshActor->GetShrinkFactor()); sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
@ -6406,7 +6428,8 @@ void SMESHGUI::restoreVisualParameters (int savePoint)
int lineWidth = -1; int lineWidth = -1;
int outlineWidth = -1; int outlineWidth = -1;
int elem0dSize = -1; int elem0dSize = -1;
int ballSize = -1; //int ballSize = -1;
double ballDiameter = -1.0;
double ballScale = -1.0; double ballScale = -1.0;
double shrinkSize = -1; double shrinkSize = -1;
double orientationSize = -1; double orientationSize = -1;
@ -6439,10 +6462,12 @@ void SMESHGUI::restoreVisualParameters (int savePoint)
// - size - is a integer value specifying size // - size - is a integer value specifying size
// - scale - is a double value specifying scale factor // - scale - is a double value specifying scale factor
if ( i+1 >= sizes.count() ) break; // format error if ( i+1 >= sizes.count() ) break; // format error
int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error //int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
double v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
if ( i+2 >= sizes.count() ) break; // format error if ( i+2 >= sizes.count() ) break; // format error
double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
ballSize = v1; //ballSize = v1;
ballDiameter = v1;
ballScale = v2; ballScale = v2;
i += 2; i += 2;
} }
@ -6478,8 +6503,11 @@ void SMESHGUI::restoreVisualParameters (int savePoint)
if ( elem0dSize > 0 ) if ( elem0dSize > 0 )
aSmeshActor->Set0DSize( elem0dSize ); aSmeshActor->Set0DSize( elem0dSize );
// ball size // ball size
if ( ballSize > 0 ) /*if ( ballSize > 0 )
aSmeshActor->SetBallSize( ballSize ); aSmeshActor->SetBallSize( ballSize );*/
// ball diameter
if ( ballDiameter > 0 )
aSmeshActor->SetBallSize( ballDiameter );
// ball scale // ball scale
if ( ballScale > 0.0 ) if ( ballScale > 0.0 )
aSmeshActor->SetBallScale( ballScale ); aSmeshActor->SetBallScale( ballScale );

View File

@ -29,6 +29,7 @@ namespace SMESHOp {
OpSelectFiltersLibrary = 1010, // MENU TOOLS - SELECTION FILTERS LIBRARY OpSelectFiltersLibrary = 1010, // MENU TOOLS - SELECTION FILTERS LIBRARY
OpReset = 1020, // RESET OpReset = 1020, // RESET
OpScalarBarProperties = 1021, // SCALAR BAR PROPERTIES OpScalarBarProperties = 1021, // SCALAR BAR PROPERTIES
OpShowScalarBar = 1022, // SHOW SCALAR BAR
OpSaveDistribution = 1030, // SAVE DISTRIBUTION OpSaveDistribution = 1030, // SAVE DISTRIBUTION
OpShowDistribution = 1031, // SHOW DISTRIBUTION OpShowDistribution = 1031, // SHOW DISTRIBUTION
#ifndef DISABLE_PLOT2DVIEWER #ifndef DISABLE_PLOT2DVIEWER

View File

@ -134,6 +134,7 @@ QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const
else if ( p=="groupType" ) val = QVariant( groupType( ind ) ); else if ( p=="groupType" ) val = QVariant( groupType( ind ) );
else if ( p=="quadratic2DMode") val = QVariant( quadratic2DMode( ind ) ); else if ( p=="quadratic2DMode") val = QVariant( quadratic2DMode( ind ) );
else if ( p=="isDistributionVisible") val = QVariant( isDistributionVisible( ind ) ); else if ( p=="isDistributionVisible") val = QVariant( isDistributionVisible( ind ) );
else if ( p=="isScalarBarVisible") val = QVariant( isScalarBarVisible( ind ) );
else if ( p=="hasChildren") val = QVariant( hasChildren( ind ) ); else if ( p=="hasChildren") val = QVariant( hasChildren( ind ) );
else if ( p=="nbChildren") val = QVariant( nbChildren( ind ) ); else if ( p=="nbChildren") val = QVariant( nbChildren( ind ) );
else if ( p=="isContainer") val = QVariant( isContainer( ind ) ); else if ( p=="isContainer") val = QVariant( isContainer( ind ) );
@ -257,6 +258,16 @@ bool SMESHGUI_Selection::isDistributionVisible(int ind) const {
return (actor && actor->GetScalarBarActor() && actor->GetScalarBarActor()->GetDistributionVisibility()); return (actor && actor->GetScalarBarActor() && actor->GetScalarBarActor()->GetDistributionVisibility());
} }
//=======================================================================
//function : isScalarBarVisible
//purpose : Visible/Invisible Scalar Bar
//=======================================================================
bool SMESHGUI_Selection::isScalarBarVisible(int ind) const {
SMESH_Actor* actor = getActor( ind );
return (actor && actor->GetScalarBarActor() && actor->GetScalarBarActor()->GetVisibility());
}
//======================================================================= //=======================================================================
//function : shrinkMode //function : shrinkMode
//purpose : return either 'IsSrunk', 'IsNotShrunk' or 'IsNotShrinkable' //purpose : return either 'IsSrunk', 'IsNotShrunk' or 'IsNotShrinkable'

View File

@ -61,9 +61,10 @@ public:
virtual QVariant hasReference( int ) const; virtual QVariant hasReference( int ) const;
virtual QVariant isVisible( int ) const; virtual QVariant isVisible( int ) const;
virtual QString quadratic2DMode(int ) const; virtual QString quadratic2DMode( int ) const;
virtual bool isDistributionVisible(int ) const; virtual bool isDistributionVisible( int ) const;
virtual bool isScalarBarVisible( int ) const;
virtual bool hasChildren( int ) const; virtual bool hasChildren( int ) const;
virtual int nbChildren( int ) const; virtual int nbChildren( int ) const;
virtual bool isContainer( int ) const; virtual bool isContainer( int ) const;

View File

@ -932,6 +932,10 @@
<source>MEN_SHADE</source> <source>MEN_SHADE</source>
<translation>Shading</translation> <translation>Shading</translation>
</message> </message>
<message>
<source>MEN_SHOW_SCALAR_BAR</source>
<translation>Show Scalar Bar</translation>
</message>
<message> <message>
<source>MEN_QUADRATIC_REPRESENT</source> <source>MEN_QUADRATIC_REPRESENT</source>
<translation>2D Quadratic</translation> <translation>2D Quadratic</translation>
@ -2581,6 +2585,10 @@ Check algorithm documentation for supported geometry</translation>
<source>SMESH_SEWING</source> <source>SMESH_SEWING</source>
<translation>Sewing</translation> <translation>Sewing</translation>
</message> </message>
<message>
<source>SMESH_SHOW_SCALAR_BAR</source>
<translation>Show Scalar Bar</translation>
</message>
<message> <message>
<source>SMESH_SMOOTHING</source> <source>SMESH_SMOOTHING</source>
<translation>Smoothing</translation> <translation>Smoothing</translation>
@ -3328,6 +3336,10 @@ Use Display Entity menu command to show them.
<source>STB_SHOW</source> <source>STB_SHOW</source>
<translation>Show</translation> <translation>Show</translation>
</message> </message>
<message>
<source>STB_SHOW_SCALAR_BAR</source>
<translation>Show Scalar Bar</translation>
</message>
<message> <message>
<source>STB_SHRINK</source> <source>STB_SHRINK</source>
<translation>Shrink</translation> <translation>Shrink</translation>

View File

@ -932,6 +932,10 @@
<source>MEN_SHADE</source> <source>MEN_SHADE</source>
<translation>Ombrage</translation> <translation>Ombrage</translation>
</message> </message>
<message>
<source>MEN_SHOW_SCALAR_BAR</source>
<translation type="unfinished">Show Scalar Bar</translation>
</message>
<message> <message>
<source>MEN_QUADRATIC_REPRESENT</source> <source>MEN_QUADRATIC_REPRESENT</source>
<translation>Quadratique 2D</translation> <translation>Quadratique 2D</translation>
@ -2577,6 +2581,10 @@ Référez-vous à la documentation sur l&apos;algorithme et la géométrie suppo
<source>SMESH_SEWING</source> <source>SMESH_SEWING</source>
<translation>Couture</translation> <translation>Couture</translation>
</message> </message>
<message>
<source>SMESH_SHOW_SCALAR_BAR</source>
<translation type="unfinished">Show Scalar Bar</translation>
</message>
<message> <message>
<source>SMESH_SMOOTHING</source> <source>SMESH_SMOOTHING</source>
<translation>Lissage</translation> <translation>Lissage</translation>
@ -3289,6 +3297,10 @@ Utilisez le menu &quot;Visualiser une entité&quot; pour les afficher.
<source>STB_SHOW_DISTRIBUTION</source> <source>STB_SHOW_DISTRIBUTION</source>
<translation>Afficher la distribution</translation> <translation>Afficher la distribution</translation>
</message> </message>
<message>
<source>STB_SHOW_SCALAR_BAR</source>
<translation type="unfinished">Show Scalar Bar</translation>
</message>
<message> <message>
<source>STB_REVOLUTION</source> <source>STB_REVOLUTION</source>
<translation>Révolution</translation> <translation>Révolution</translation>

View File

@ -931,6 +931,10 @@
<source>MEN_SHADE</source> <source>MEN_SHADE</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>MEN_SHOW_SCALAR_BAR</source>
<translation type="unfinished">Show Scalar Bar</translation>
</message>
<message> <message>
<source>MEN_QUADRATIC_REPRESENT</source> <source>MEN_QUADRATIC_REPRESENT</source>
<translation> 2D</translation> <translation> 2D</translation>
@ -2267,6 +2271,10 @@
<source>SMESH_SHOW_DISTRIBUTION_SCALARBAR</source> <source>SMESH_SHOW_DISTRIBUTION_SCALARBAR</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>SMESH_SHOW_SCALAR_BAR</source>
<translation type="unfinished">Show Scalar Bar</translation>
</message>
<message> <message>
<source>SMESH_PRECISION</source> <source>SMESH_PRECISION</source>
<translation></translation> <translation></translation>
@ -3247,6 +3255,10 @@
<source>STB_SHOW_DISTRIBUTION</source> <source>STB_SHOW_DISTRIBUTION</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>STB_SHOW_SCALAR_BAR</source>
<translation type="unfinished">Show Scalar Bar</translation>
</message>
<message> <message>
<source>STB_REVOLUTION</source> <source>STB_REVOLUTION</source>
<translation>Revolution</translation> <translation>Revolution</translation>