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 f694939d authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

FIXED max value for dimensions depends on current selection

The maximum value of resampling now corresponds to the currently
selected image
Also, 2D image is now working properly
parent 2eaece56
......@@ -27,6 +27,8 @@
#include <Application.h>
#include <Property.h>
#include <Log.h>
// Vtk includes
#include <vtkCallbackCommand.h>
#include "vtkImageShiftScale.h"
......@@ -51,22 +53,25 @@ ResampleAction::ResampleAction(ActionExtension* extension) : Action(extension) {
// You can add tags here with the method addTag("tagName");
// Setting the actions parameters
Property* newImageDimensionPropertyX = new Property(tr("New image X dimension"), 256, tr("The new image width (in voxels)."), "");
Property* newImageDimensionPropertyX = new Property(tr("New Image X Dimension"), 256, tr("The new image width (in voxels)."), "");
newImageDimensionPropertyX->setAttribute("minimum", 1);
newImageDimensionPropertyX->setAttribute("maximum", std::numeric_limits<int>::max());
newImageDimensionPropertyX->setAttribute("singleStep", 1);
addParameter(newImageDimensionPropertyX);
Property* newImageDimensionPropertyY = new Property(tr("New image Y dimension"), 256, tr("The new image height (in voxels)."), "");
Property* newImageDimensionPropertyY = new Property(tr("New Image Y Dimension"), 256, tr("The new image height (in voxels)."), "");
newImageDimensionPropertyY->setAttribute("minimum", 1);
newImageDimensionPropertyY->setAttribute("maximum", std::numeric_limits<int>::max());
newImageDimensionPropertyY->setAttribute("singleStep", 1);
addParameter(newImageDimensionPropertyY);
Property* newImageDimensionPropertyZ = new Property(tr("New image Z dimension"), 256, tr("The new image depth (in voxels)."), "");
Property* newImageDimensionPropertyZ = new Property(tr("New Image Z Dimension"), 256, tr("The new image depth (in voxels)."), "");
newImageDimensionPropertyZ->setAttribute("minimum", 1);
newImageDimensionPropertyZ->setAttribute("maximum", std::numeric_limits<int>::max());
newImageDimensionPropertyZ->setAttribute("singleStep", 1);
addParameter(newImageDimensionPropertyZ);
Property* scalarTypeProperty = new Property(tr("New image scalar type"), SAME_AS_INPUT, tr("The new image voxels scalar type"), "");
Property* scalarTypeProperty = new Property(tr("New Image Scalar Type"), SAME_AS_INPUT, tr("The new image voxels scalar type"), "");
scalarTypeProperty->setEnumTypeName("ScalarType", this);
addParameter(scalarTypeProperty);
}
......@@ -76,6 +81,32 @@ ResampleAction::~ResampleAction() {
}
// --------------- getWidget -------------------
QWidget* ResampleAction::getWidget() {
// set min/max for the dimensions using the last selected target dimensions
int * dims = getTargets().last()->getImageData()->GetDimensions();
camitk::Property *dimProperty = getProperty("New Image X Dimension");
dimProperty->setAttribute("minimum", 1);
dimProperty->setAttribute("maximum", dims[0]);
setProperty("New Image X Dimension", dims[0]);
dimProperty = getProperty("New Image Y Dimension");
dimProperty->setAttribute("minimum", 1);
dimProperty->setAttribute("maximum", dims[1]);
setProperty("New Image Y Dimension", dims[1]);
dimProperty = getProperty("New Image Z Dimension");
dimProperty->setAttribute("minimum", 1);
dimProperty->setAttribute("maximum", dims[2]);
setProperty("New Image Z Dimension", dims[2]);
dimProperty->setReadOnly(dims[2] == 1);
// return the default widget
return Action::getWidget();
}
// --------------- apply -------------------
Action::ApplyStatus ResampleAction::apply() {
......@@ -87,6 +118,7 @@ Action::ApplyStatus ResampleAction::apply() {
return SUCCESS;
}
// --------------- process -------------------
void ResampleAction::process(ImageComponent* comp) {
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
Application::showStatusBarMessage(tr("Compute resample..."));
......@@ -95,9 +127,9 @@ void ResampleAction::process(ImageComponent* comp) {
progressCallback->SetCallback(&Application::vtkProgressFunction);
// Get the parameters
double xSize = property("New image X dimension").toDouble();
double ySize = property("New image Y dimension").toDouble();
double zSize = property("New image Z dimension").toDouble();
double xSize = property("New Image X Dimension").toDouble();
double ySize = property("New Image Y Dimension").toDouble();
double zSize = property("New Image Z Dimension").toDouble();
// Getting the input image
vtkSmartPointer<vtkImageData> inputImage = comp->getImageData();
......@@ -210,7 +242,7 @@ void ResampleAction::process(ImageComponent* comp) {
resampleFilter->Update();
// Create the output component
ImageComponent* outputComp = new ImageComponent(resampleFilter->GetOutput(), comp->getName() + nameScalarType + "_" + property("Size X (nb of Voxels)").toInt() + "*" + property("Size Y (nb of Voxels)").toInt() + "*" + property("Size Z (nb of Voxels)").toInt());
ImageComponent* outputComp = new ImageComponent(resampleFilter->GetOutput(), comp->getName() + nameScalarType + "_" + property("New Image X Dimension").toString() + "x" + property("New Image Y Dimension").toString() + "x" + property("New Image Z Dimension").toString());
// consider frame policy on new image created
Action::applyTargetPosition(comp, outputComp);
......@@ -223,7 +255,8 @@ void ResampleAction::process(ImageComponent* comp) {
}
// --------------- getScalarType -------------------
ResampleAction::ScalarType ResampleAction::getScalarType() {
return (ScalarType) property("New image scalar type").toInt();
return (ScalarType) property("New Image Scalar Type").toInt();
}
......@@ -63,20 +63,24 @@ public:
/// Default Destructor
virtual ~ResampleAction();
/// Retrieve the scalar type
ScalarType getScalarType();
/// Required to update the resize values to half of the currently selected image size
virtual QWidget* getWidget();
public slots:
/// method called when the action is applied
virtual ApplyStatus apply();
private:
///Scalar type of the output
ScalarType Scalar_Type;
/// Scalar type of the output
ScalarType scalarType;
/// helper method to simplify the target component processing
virtual void process(camitk::ImageComponent*);
/// Retrieve the scalar type
ScalarType getScalarType();
};
Q_DECLARE_METATYPE(ResampleAction::ScalarType)
......
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