Commit 245d05f6 authored by Emmanuel Promayon's avatar Emmanuel Promayon

FIXED some property insertion code

parent ba94b7f9
......@@ -170,8 +170,8 @@
<camitk:action>
<camitk:name>Manual Threshold Filter</camitk:name>
<camitk:parameters>
<camitk:parameter name="Low threshold" value="1" type="int"/>
<camitk:parameter name="High threshold" value="1" type="int"/>
<camitk:parameter name="Low Threshold" value="1" type="int"/>
<camitk:parameter name="High Threshold" value="1" type="int"/>
</camitk:parameters>
<camitk:inputs>
<camitk:component name="output-3.mha" type="ImageComponent"/>
......
......@@ -51,17 +51,17 @@ ManualThreshold::ManualThreshold(ActionExtension* extension) : Action(extension)
// Setting classification family and tags
this->setFamily("ITK Segmentation");
this->addTag("Threshold");
this->addTag("Manal");
this->addTag("Manual");
this->addTag("Classification");
// Setting parameters default values
Property* lowThresholdProperty = new Property(tr("Low threshold"), 128, tr("Voxels which have a scalar value below this threshold will considered as black (0). Above it AND below high threshold, they will be considered as white (255)."), "");
Property* lowThresholdProperty = new Property(tr("Low Threshold"), 128, tr("Voxels which have a scalar value below this low threshold value will be set to black (min possible value). Above it AND below the high threshold value, they will be set to white (max possible value)."), "");
lowThresholdProperty->setAttribute("minimum", 0);
lowThresholdProperty->setAttribute("maximum", 255);
lowThresholdProperty->setAttribute("singleStep", 1);
addParameter(lowThresholdProperty);
Property* highThresholdProperty = new Property(tr("High threshold"), 255, tr("Voxels which have a scalar value above this threshold will considered as black (0). Below it AND above low threshold, they will be considered as white (255)."), "");
Property* highThresholdProperty = new Property(tr("High Threshold"), 255, tr("Voxels which have a scalar value above this high threshold will be set to black (min possible value). Below it AND above the low threshold value, they will be set to white (max possible value)."), "");
highThresholdProperty->setAttribute("minimum", 0);
highThresholdProperty->setAttribute("maximum", 255);
highThresholdProperty->setAttribute("singleStep", 1);
......@@ -75,30 +75,30 @@ ManualThreshold::~ManualThreshold() {
// --------------- getWidget -------------------
QWidget* ManualThreshold::getWidget() {
// Computing the maximum and the minimum possible value for the image
// Computing the maximum and the minimum possible value for the selected images
double min = 0;
double max = 0;
foreach(Component *comp, getTargets()) {
vtkSmartPointer<vtkImageData> inputImage =
dynamic_cast<ImageComponent*>(comp)->getImageData();
for(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");
// Applying those min/max value to the threshold properties
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");
camitk::Property *highThresholdProperty = getProperty("High Threshold");
highThresholdProperty->setAttribute("minimum", min);
highThresholdProperty->setAttribute("maximum", max);
highThresholdProperty->setAttribute("singleStep", (max - min) / 255);
addParameter(highThresholdProperty);
// Call the parent method
// return the default widget
return Action::getWidget();
}
......@@ -114,8 +114,8 @@ Action::ApplyStatus ManualThreshold::apply() {
// --------------- process -------------------
void ManualThreshold::process(ImageComponent* comp) {
// Get the parameters
this->lowThreshold = property("Low threshold").toInt();
this->highThreshold = property("High threshold").toInt();
this->lowThreshold = property("Low Threshold").toInt();
this->highThreshold = property("High Threshold").toInt();
// ITK filter implementation using templates
vtkSmartPointer<vtkImageData> inputImage = comp->getImageData();
......
......@@ -108,7 +108,7 @@ void Property::setEnumTypeName(QString nameOfTheEnum, QObject* objectDeclaringTh
setAttribute("enumNames", enumAutoGuiLiterals);
}
// -------------------- setAttribute --------------------
// -------------------- getEnumValueAsString --------------------
QString Property::getEnumValueAsString(const QObject* objectDeclaringTheEnum) const {
if (!enumTypeName.isNull()) {
int indexOfEnum = objectDeclaringTheEnum->metaObject()->indexOfEnumerator(enumTypeName.toStdString().c_str());
......@@ -159,7 +159,8 @@ QStringList Property::getAttributeList() {
// -------------------- setAttribute --------------------
void Property::setAttribute(const QString& attribute, const QVariant& value) {
attributeValues[attribute] = value;
// If there is already an item with the key attribute, that item's value is replaced with the given value
attributeValues.insert(attribute,value);
}
......
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