mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-02-05 13:34:17 +05:00
[bos #32736][CEA] Threshold of criteria. Using vtkThreshold filter for hiding cells instead of lookup table.
This commit is contained in:
parent
fbabf737e2
commit
26cb19a6fe
@ -80,6 +80,9 @@
|
||||
#include <vtkImplicitBoolean.h>
|
||||
#include <vtkImplicitFunctionCollection.h>
|
||||
|
||||
#include <vtkThreshold.h>
|
||||
#include <vtkPassThrough.h>
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
|
||||
@ -838,6 +841,7 @@ void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
|
||||
my3DActor->GetMapper()->SetScalarVisibility(false);
|
||||
myBallActor->GetMapper()->SetScalarVisibility(false);
|
||||
myScalarBarActor->SetVisibility(false);
|
||||
ClipThreshold(false);
|
||||
|
||||
bool anIsScalarVisible = theMode > eNone;
|
||||
|
||||
@ -2487,6 +2491,41 @@ void SMESH_ActorDef::UpdateScalarBar()
|
||||
|
||||
}
|
||||
|
||||
// Hides the cells beyond threshold if isThresholdOn == true.
|
||||
void SMESH_ActorDef::ClipThreshold(bool isThresholdOn, double min /*= 0.0*/, double max /*= 0.0*/)
|
||||
{
|
||||
myIsClipThresholdOn = isThresholdOn;
|
||||
|
||||
if (isThresholdOn)
|
||||
{
|
||||
// Initialize the filter
|
||||
vtkSmartPointer<vtkThreshold> threshold = vtkSmartPointer<vtkThreshold>::New();
|
||||
|
||||
// We have set scalar data with SMESH_DeviceActor::SetControlMode() call as vtkDataSetAttributes::SCALARS.
|
||||
// So, we don't need to pass an array name in SetInputArrayToProcess().
|
||||
threshold->SetInputConnection(myControlActor->myMergeFilter->GetOutputPort());
|
||||
threshold->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_CELLS, vtkDataSetAttributes::SCALARS);
|
||||
|
||||
// Set range
|
||||
threshold->SetThresholdFunction(vtkThreshold::THRESHOLD_BETWEEN);
|
||||
threshold->SetLowerThreshold(min);
|
||||
threshold->SetUpperThreshold(max);
|
||||
|
||||
// Debug output
|
||||
threshold->Update();
|
||||
SCRUTE(threshold->GetOutput()->GetNumberOfCells());
|
||||
|
||||
// Add to the filters' chain
|
||||
vtkAlgorithmOutput* port = threshold->GetOutputPort();
|
||||
myControlActor->myPassFilter[0]->SetInputConnection(port);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Restore the filters' chain
|
||||
myControlActor->SetImplicitFunctionUsed(myControlActor->myIsImplicitFunctionUsed);
|
||||
}
|
||||
}
|
||||
|
||||
void SMESH_ActorDef::UpdateDistribution()
|
||||
{
|
||||
if(SMESH::Controls::NumericalFunctor* fun =
|
||||
|
@ -166,6 +166,8 @@ class SMESHOBJECT_EXPORT SMESH_Actor: public SALOME_Actor
|
||||
|
||||
virtual void UpdateScalarBar() = 0;
|
||||
virtual void UpdateDistribution() = 0;
|
||||
virtual void ClipThreshold(bool isThresholdOn, double min = 0.0, double max = 0.0) = 0;
|
||||
virtual bool IsClipThresholdOn() const = 0;
|
||||
|
||||
virtual void SetPointsFontProperties( SMESH::LabelFont family, int size,
|
||||
bool bold, bool italic, bool shadow,
|
||||
|
@ -226,6 +226,8 @@ class SMESH_ActorDef : public SMESH_Actor
|
||||
|
||||
virtual void UpdateScalarBar();
|
||||
virtual void UpdateDistribution();
|
||||
virtual void ClipThreshold(bool isThresholdOn, double min = 0.0, double max = 0.0);
|
||||
virtual bool IsClipThresholdOn() const { return myIsClipThresholdOn; }
|
||||
|
||||
#ifndef DISABLE_PLOT2DVIEWER
|
||||
virtual SPlot2d_Histogram* GetPlot2Histogram() { return my2dHistogram; }
|
||||
@ -300,6 +302,7 @@ class SMESH_ActorDef : public SMESH_Actor
|
||||
int myRepresentationCache;
|
||||
bool myIsEntityModeCache;
|
||||
bool myIsPointsVisible;
|
||||
bool myIsClipThresholdOn = false;
|
||||
|
||||
bool myIsShrinkable;
|
||||
bool myIsShrunk;
|
||||
|
@ -50,6 +50,8 @@
|
||||
|
||||
#include <QtxColorButton.h>
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
// Qt includes
|
||||
#include <QButtonGroup>
|
||||
#include <QCheckBox>
|
||||
@ -569,7 +571,7 @@ bool SMESHGUI_Preferences_ScalarBarDlg::onApply()
|
||||
|
||||
myLookupTable->SetRange( aMin, aMax );
|
||||
myLookupTable->SetNumberOfTableValues(myColorsSpin->value());
|
||||
applyThreshold(myLookupTable);
|
||||
applyThreshold(aMin, aMax);
|
||||
|
||||
bool scaleChanged = (myLogarithmicCheck->isChecked() != (myLookupTable->GetScale() == VTK_SCALE_LOG10));
|
||||
if (scaleChanged)
|
||||
@ -663,8 +665,8 @@ void SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged()
|
||||
//myLogarithmicCheck->setEnabled(range[0] > 1e-07 && range[1] > 1e-07);
|
||||
myLogarithmicCheck->setEnabled(range[0] != range[1]);
|
||||
|
||||
setThresholdFromTable(aLookupTable);
|
||||
applyThreshold(aLookupTable);
|
||||
myThresholdCheck->setChecked(myActor->IsClipThresholdOn());
|
||||
applyThreshold(range[0], range[1]);
|
||||
}
|
||||
|
||||
vtkTextProperty* aTitleTextPrp = myScalarBarActor->GetTitleTextProperty();
|
||||
@ -891,29 +893,6 @@ void SMESHGUI_Preferences_ScalarBarDlg::initScalarBarFromResources()
|
||||
}
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
/*!
|
||||
* SMESHGUI_Preferences_ScalarBarDlg::setThresholdFromTable()
|
||||
*
|
||||
* Checks if the table uses special color for values beyond the min-max range,
|
||||
* and this color is completely transparent - RGBA(0,0,0,0).
|
||||
*/
|
||||
//=================================================================================================
|
||||
void SMESHGUI_Preferences_ScalarBarDlg::setThresholdFromTable(vtkLookupTable* aLookupTable)
|
||||
{
|
||||
bool isUseBeyondRangeColor = aLookupTable->GetUseAboveRangeColor() && aLookupTable->GetUseBelowRangeColor();
|
||||
|
||||
if (isUseBeyondRangeColor)
|
||||
{
|
||||
const double* aboveRangeColor = aLookupTable->GetAboveRangeColor();
|
||||
const double* belowRangeColor = aLookupTable->GetBelowRangeColor();
|
||||
|
||||
isUseBeyondRangeColor = aboveRangeColor[3] == 0.0 && belowRangeColor[3] == 0.0;
|
||||
}
|
||||
|
||||
myThresholdCheck->setChecked(isUseBeyondRangeColor);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
/*!
|
||||
* SMESHGUI_Preferences_ScalarBarDlg::applyThreshold()
|
||||
@ -922,18 +901,8 @@ void SMESHGUI_Preferences_ScalarBarDlg::setThresholdFromTable(vtkLookupTable* aL
|
||||
* Now this color is completely transparent - RGBA(0,0,0,0).
|
||||
*/
|
||||
//=================================================================================================
|
||||
void SMESHGUI_Preferences_ScalarBarDlg::applyThreshold(vtkLookupTable* aLookupTable)
|
||||
//void SMESHGUI_Preferences_ScalarBarDlg::applyThreshold(vtkLookupTable* aLookupTable)
|
||||
void SMESHGUI_Preferences_ScalarBarDlg::applyThreshold(double min, double max)
|
||||
{
|
||||
const bool isChecked = myThresholdCheck->isChecked();
|
||||
|
||||
aLookupTable->SetUseAboveRangeColor(isChecked);
|
||||
aLookupTable->SetUseBelowRangeColor(isChecked);
|
||||
|
||||
if (isChecked)
|
||||
{
|
||||
const double beyondRangeColor[4] = {};
|
||||
|
||||
aLookupTable->SetAboveRangeColor(beyondRangeColor);
|
||||
aLookupTable->SetBelowRangeColor(beyondRangeColor);
|
||||
}
|
||||
myActor->ClipThreshold(myThresholdCheck->isChecked(), min, max);
|
||||
}
|
||||
|
@ -73,8 +73,7 @@ public:
|
||||
void initScalarBarFromResources();
|
||||
|
||||
protected:
|
||||
void setThresholdFromTable(vtkLookupTable* aLookupTable);
|
||||
void applyThreshold(vtkLookupTable* aLookupTable);
|
||||
void applyThreshold(double min, double max);
|
||||
|
||||
protected slots:
|
||||
virtual void reject();
|
||||
|
Loading…
Reference in New Issue
Block a user