Skip to content
Snippets Groups Projects
Commit 5a9fb43e authored by Sacha Percot-Tétu's avatar Sacha Percot-Tétu
Browse files

Added classes IntParam & ImgParam

IntParam is used to retrieve a bounded integer and ImgParam an
imagein::Image.
parent fd0858c2
No related branches found
No related tags found
No related merge requests found
#include "ImgParam.h"
using namespace imagein;
void ImgParam::fillDialog(QDialog*) {
}
void ImgParam::pickValue() {
}
Parameter<Image>* ImgParam::clone() const {
return new ImgParam(*this);
}
#ifndef EIIMAGE_IMGPARAM_H
#define EIIMAGE_IMGPARAM_H
#include <vector>
#include <string>
#include "Image.h"
#include "Parameter.h"
class ImgParam : public Parameter<imagein::Image> {
public:
ImgParam(std::string name, imagein::Image* ptr = NULL) : Parameter(name, ptr) {}
virtual void fillDialog(QDialog*);
virtual void pickValue();
virtual Parameter* clone() const;
};
#endif //!EIIMAGE_IMGPARAM_H
\ No newline at end of file
#include <QSpinBox>
#include <QDialog>
#include <QLayout>
#include <QFormLayout>
#include <QWidget>
#include "IntParam.h"
using namespace imagein;
IntParam::IntParam(std::string name, int min, int max, int def) : Parameter(name), _min(min), _max(max) {
_def = std::min(def, _max);
_def = std::max(def, _min);
}
void IntParam::fillDialog(QDialog* dialog) {
QWidget *widget = new QWidget();
QFormLayout* layout = new QFormLayout();
_spinbox = new QSpinBox();
_spinbox->setRange(_min, _max);
_spinbox->setValue(_def);
layout->insertRow(1, QString(_name.c_str()) + " : ", _spinbox);
widget->setLayout(layout);
dialog->layout()->addWidget(widget);
}
void IntParam::pickValue() {
int value = _spinbox->value();
value = std::min(value, _max);
value = std::max(value, _min);
*_ptr = value;
}
IntParam* IntParam::clone() const {
return new IntParam(*this);
}
#ifndef EIIMAGE_INTPARAM_H
#define EIIMAGE_INTPARAM_H
#include <vector>
#include <string>
#include "Image.h"
#include "Parameter.h"
class QSpinBox;
class QDialog;
class IntParam : public Parameter<int> {
public:
IntParam(std::string name, int min, int max, int def = 0);
virtual void fillDialog(QDialog*);
virtual void pickValue();
virtual IntParam* clone() const;
protected:
int _min, _max, _def;
QSpinBox* _spinbox;
};
#endif //!EIIMAGE_INTPARAM_H
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment