Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 697276ce authored by Tiffet Théophile's avatar Tiffet Théophile
Browse files

Correction of the bug 62 (Manual Threshold value could only be between 0 and 255)

parent f01a7319
......@@ -24,6 +24,7 @@
****************************************************************************/
// CamiTK incldues
#include "ManualThreshold.h"
#include "ActionWidget.h"
#include <Application.h>
#include <ItkProgressObserver.h>
#include <Property.h>
......@@ -72,6 +73,40 @@ ManualThreshold::~ManualThreshold() {
// do not delete the widget has it might have been used in the ActionViewer (i.e. the ownership might have been taken by the stacked widget)
}
// --------------- trigger -------------------
Action::ApplyStatus ManualThreshold::trigger(QWidget* parent) {
if (Action::trigger(parent) == ERROR)
return ERROR;
// Computing the maximum and the minimum possible value for the image
double min = 0;
double max = 0;
foreach(Component *comp, getTargets()) {
vtkSmartPointer<vtkImageData> inputImage =
dynamic_cast<ImageComponent*>(comp)->getImageData();
if (min > inputImage->GetScalarTypeMin())
min = inputImage->GetScalarTypeMin();
if (max < inputImage->GetScalarTypeMax())
max = inputImage->GetScalarTypeMax();
}
// Applying those value to the thresholds
camitk::Property *lowThresholdProperty = getProperty("Low threshold");
lowThresholdProperty->setAttribute("minimum", min);
lowThresholdProperty->setAttribute("maximum", max);
lowThresholdProperty->setAttribute("singleStep", (max - min) / 255);
addParameter(lowThresholdProperty);
camitk::Property *highThresholdProperty = getProperty("High threshold");
highThresholdProperty->setAttribute("minimum", min);
highThresholdProperty->setAttribute("maximum", max);
highThresholdProperty->setAttribute("singleStep", (max - min) / 255);
addParameter(highThresholdProperty);
// Updating the widget
if (actionWidget)
dynamic_cast<camitk::ActionWidget*>(actionWidget)->update();
return SUCCESS;
}
// --------------- apply -------------------
Action::ApplyStatus ManualThreshold::apply() {
foreach (Component* comp, getTargets()) {
......
......@@ -47,6 +47,12 @@ public:
virtual ~ManualThreshold();
public slots:
/**
* This method triggers the action.
* The parent widget is used if the action is embedded, see class description for more information about the algorithm.
* This method cannot be redefined in inherited class.
*/
virtual ApplyStatus trigger(QWidget* parent = nullptr);
/** this method is automatically called when the action is triggered.
* Use getTargets() QList to get the list of component to use.
* \note getTargets() is automatically filtered so that it only contains compatible components,
......
......@@ -241,7 +241,7 @@ public slots:
* The parent widget is used if the action is embedded, see class description for more information about the algorithm.
* This method cannot be redefined in inherited class.
*/
ApplyStatus trigger(QWidget* parent = nullptr);
virtual ApplyStatus trigger(QWidget* parent = nullptr);
/**
* This method is called when the action has to be applied on the target list (get the target lists using getTargets())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment