#include <vtkImplicitBoolean.h>
#include <vtkImplicitFunctionCollection.h>
+#include <vtkThreshold.h>
+#include <vtkPassThrough.h>
+
#include "utilities.h"
my3DActor->GetMapper()->SetScalarVisibility(false);
myBallActor->GetMapper()->SetScalarVisibility(false);
myScalarBarActor->SetVisibility(false);
+ ClipThreshold(false);
bool anIsScalarVisible = theMode > eNone;
}
+// 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 =
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,
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; }
int myRepresentationCache;
bool myIsEntityModeCache;
bool myIsPointsVisible;
+ bool myIsClipThresholdOn = false;
bool myIsShrinkable;
bool myIsShrunk;
#include <QtxColorButton.h>
+#include "utilities.h"
+
// Qt includes
#include <QButtonGroup>
#include <QCheckBox>
myLookupTable->SetRange( aMin, aMax );
myLookupTable->SetNumberOfTableValues(myColorsSpin->value());
- applyThreshold(myLookupTable);
+ applyThreshold(aMin, aMax);
bool scaleChanged = (myLogarithmicCheck->isChecked() != (myLookupTable->GetScale() == VTK_SCALE_LOG10));
if (scaleChanged)
//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();
}
}
-//=================================================================================================
-/*!
- * 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()
* 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);
}
void initScalarBarFromResources();
protected:
- void setThresholdFromTable(vtkLookupTable* aLookupTable);
- void applyThreshold(vtkLookupTable* aLookupTable);
+ void applyThreshold(double min, double max);
protected slots:
virtual void reject();