diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 82822c20ba7fc4e0acab67f977e8bc9f1ad97b1d..3b28d420b8f09de63a1bff5468606ebbd96e5088 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -140,8 +140,8 @@ set(imageinsa_SOURCES Operations/TranslateOp.h Operations/UCharConvertOp.cpp Operations/UCharConvertOp.h - Operations/ucharconvertdialog.cpp - Operations/ucharconvertdialog.h + Operations/UCharConvertDialog.cpp + Operations/UCharConvertDialog.h Operations/ZeroCrossingOp.cpp Operations/ZeroCrossingOp.h Services/ImageINSAService.cpp @@ -187,7 +187,6 @@ set(UIS Operations/DCTDialog.ui Operations/ColorDialog.ui Operations/MedianDialog.ui - Operations/ucharconvertdialog.ui ) qt5_wrap_ui(WRAPPED_UIS ${UIS}) diff --git a/app/Operations/HoughDialog.ui b/app/Operations/HoughDialog.ui index d8123e92ec448b1647e1441673503e5ebec46b54..5c083febecf3549c36a2d6216d79af0077f801ff 100644 --- a/app/Operations/HoughDialog.ui +++ b/app/Operations/HoughDialog.ui @@ -6,7 +6,7 @@ <rect> <x>0</x> <y>0</y> - <width>259</width> + <width>262</width> <height>180</height> </rect> </property> @@ -120,6 +120,9 @@ <verstretch>0</verstretch> </sizepolicy> </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> @@ -139,12 +142,12 @@ <slot>accept()</slot> <hints> <hint type="sourcelabel"> - <x>248</x> - <y>254</y> + <x>252</x> + <y>170</y> </hint> <hint type="destinationlabel"> <x>157</x> - <y>274</y> + <y>179</y> </hint> </hints> </connection> @@ -155,12 +158,12 @@ <slot>reject()</slot> <hints> <hint type="sourcelabel"> - <x>316</x> - <y>260</y> + <x>252</x> + <y>170</y> </hint> <hint type="destinationlabel"> - <x>286</x> - <y>274</y> + <x>261</x> + <y>179</y> </hint> </hints> </connection> diff --git a/app/Operations/UCharConvertDialog.cpp b/app/Operations/UCharConvertDialog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dd68b7511a00ab26182b99ade9e5139bbc179544 --- /dev/null +++ b/app/Operations/UCharConvertDialog.cpp @@ -0,0 +1,76 @@ +#include "UCharConvertDialog.h" +#include "ui_ucharconvertdialog.h" +#include <Converter.h> +#include <QDialog> +#include <QDialogButtonBox> +#include <QHBoxLayout> +#include <QFormLayout> +#include <QLabel> +#include <QSpinBox> +#include <QComboBox> +#include <QStringList> + + +UCharConvertDialog::UCharConvertDialog(QWidget *parent) : + QDialog(parent) +{ + this->setWindowTitle(qApp->translate("Operations","Convert to UChar")); + this->setMinimumWidth(180); + + QFormLayout* layout = new QFormLayout(this); + + QStringList text = (QStringList() << "crop" << "normalize" << "Add Offset" << "Scale" << "Add offset and scale"); + QLabel* label1 = new QLabel("Operation"); + _comboBox = new QComboBox(); + _comboBox->addItems(text); + + _label2 = new QLabel("Offset"); + _spinBox = new QSpinBox(); + _spinBox->setMaximum(255); + _spinBox->setMinimum(0); + _spinBox->setValue(127); + _spinBox->setEnabled(false); + _label2->setEnabled(false); + _spinBox->setVisible(false); + _label2->setVisible(false); + + layout->addRow(label1, _comboBox); + layout->addRow(_label2, _spinBox); + + QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel, Qt::Horizontal, this); + layout->insertRow(3, buttonBox); + + QObject::connect(_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(enableOffset(int))); + QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); + QObject::connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); +} + + +void UCharConvertDialog::enableOffset(int n){ + std::cout << "which case it is ? -> " << n << "\n"; + if(n==2){ + _spinBox->setEnabled(true); + _label2->setEnabled(true); + _spinBox->setVisible(true); + _label2->setVisible(true); + }else if(n==4){ + _spinBox->setEnabled(false); + _label2->setEnabled(false); + _spinBox->setValue(127); + _spinBox->setVisible(true); + _label2->setVisible(true); + }else{ + _spinBox->setEnabled(false); + _label2->setEnabled(false); + _spinBox->setVisible(false); + _label2->setVisible(false); + } +} + +int UCharConvertDialog::getCombo(){ + return _comboBox->currentIndex(); +} + +int UCharConvertDialog::getOffset(){ + return _spinBox->value(); +} diff --git a/app/Operations/ucharconvertdialog.h b/app/Operations/UCharConvertDialog.h similarity index 55% rename from app/Operations/ucharconvertdialog.h rename to app/Operations/UCharConvertDialog.h index 2757e4b62d26fe8fa1ad22a64cd56eb00597a1b2..fbcae6228de63565a5685ce3b8b3c92450281419 100644 --- a/app/Operations/ucharconvertdialog.h +++ b/app/Operations/UCharConvertDialog.h @@ -2,6 +2,9 @@ #define UCHARCONVERTDIALOG_H #include <QDialog> +#include <QSpinBox> +#include <QLabel> +#include <QComboBox> namespace Ui { class UCharConvertDialog; @@ -13,10 +16,18 @@ class UCharConvertDialog : public QDialog public: explicit UCharConvertDialog(QWidget *parent = 0); - ~UCharConvertDialog(); + int getCombo(); + int getOffset(); + + +public slots: + void enableOffset(int); + +protected: + QLabel* _label2; + QSpinBox* _spinBox; + QComboBox* _comboBox; -private: - Ui::UCharConvertDialog *ui; }; #endif // UCHARCONVERTDIALOG_H diff --git a/app/Operations/UCharConvertOp.cpp b/app/Operations/UCharConvertOp.cpp index 45c4b47888d43f62493923bd876ae5d9fb6b8550..8c39c07c88d1a29dce7ef166e2de0493fe33e1e7 100644 --- a/app/Operations/UCharConvertOp.cpp +++ b/app/Operations/UCharConvertOp.cpp @@ -23,9 +23,17 @@ #include <QApplication> #include <QObject> #include "Operation.h" -#include "ucharconvertdialog.h" +#include "UCharConvertDialog.h" #include "Image.h" #include <Converter.h> +#include <QDialog> +#include <QDialogButtonBox> +#include <QHBoxLayout> +#include <QFormLayout> +#include <QLabel> +#include <QSpinBox> +#include <QComboBox> +#include <QStringList> using namespace imagein; @@ -38,46 +46,45 @@ bool UCharConvertOp::needCurrentImg() const{ } void UCharConvertOp::operator()(const imagein::Image_t<double>* from, const std::map<const imagein::Image_t<double>*, std::string>&){ + UCharConvertDialog* dialog = new UCharConvertDialog(QApplication::activeWindow()); - QDialog::DialogCode code = static_cast<QDialog::DialogCode>(dialog->exec()); + QDialog::DialogCode code = static_cast<QDialog::DialogCode>(dialog->exec()); if(code!=QDialog::Accepted) return; - - - - Image * resImg; std::string LogMessage = ""; Image_t<int> * tempIntImg; int offset; - switch(conversionTYPE) + + switch(dialog->getCombo()) { - case CROP : + case 0 : resImg = Converter<Image>::convertAndRound(*from); break; - case NORMALIZE : + case 1 : tempIntImg = Converter<Image_t<double>>::convertToInt(*from); tempIntImg->normalize(); resImg = Converter<Image>::convert(*tempIntImg); delete tempIntImg; break; - case OFFSET : + case 2 : + std::cout << "offset : " << dialog->getOffset() << " \n"; tempIntImg = Converter<Image_t<double>>::convertToInt(*from); - offset = 130; //getOffset() + offset = dialog->getOffset(); resImg = Converter<Image>::convertAndOffset(*tempIntImg, &LogMessage, offset); delete tempIntImg; break; - case OFFSETNSCALE : + case 4 : tempIntImg = Converter<Image_t<double>>::convertToInt(*from); resImg = Converter<Image>::convertScaleAndOffset(*tempIntImg, &LogMessage); delete tempIntImg; break; - case SCALE : + case 3 : tempIntImg = Converter<Image_t<double>>::convertToInt(*from); resImg = Converter<Image>::convertAndScale(*tempIntImg, &LogMessage); delete tempIntImg; @@ -91,3 +98,5 @@ void UCharConvertOp::operator()(const imagein::Image_t<double>* from, const std: outImage(resImg, "Title"); } + + diff --git a/app/Operations/UCharConvertOp.h b/app/Operations/UCharConvertOp.h index 1091d40b68bcc9c120686ffb88fb978eaa2b63bb..2301ad26642c16abc9fa7acd7c5b5f8a8c75113f 100644 --- a/app/Operations/UCharConvertOp.h +++ b/app/Operations/UCharConvertOp.h @@ -3,7 +3,10 @@ #include <QObject> #include "Operation.h" -#include "ucharconvertdialog.h" +#include "UCharConvertDialog.h" +#include <QLabel> +#include <QSpinBox> +#include <QComboBox> class UCharConvertOp : public DoubleOperation @@ -14,9 +17,7 @@ public: bool needCurrentImg() const; void operator()(const imagein::Image_t<double>*, const std::map<const imagein::Image_t<double>*, std::string>&); - private : - enum{CROP, NORMALIZE, OFFSET, OFFSETNSCALE, SCALE} conversionTYPE; }; diff --git a/app/Operations/ucharconvertdialog.cpp b/app/Operations/ucharconvertdialog.cpp deleted file mode 100644 index efbdd6e1f51d827e45429ea46c9ac1d5e7115fde..0000000000000000000000000000000000000000 --- a/app/Operations/ucharconvertdialog.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "ucharconvertdialog.h" -#include "ui_ucharconvertdialog.h" - -UCharConvertDialog::UCharConvertDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::UCharConvertDialog) -{ - ui->setupUi(this); -} - -UCharConvertDialog::~UCharConvertDialog() -{ - delete ui; -} diff --git a/app/Operations/ucharconvertdialog.ui b/app/Operations/ucharconvertdialog.ui deleted file mode 100644 index 12cb7da19c3b12a42f7fef964d0cca2a92237bd6..0000000000000000000000000000000000000000 --- a/app/Operations/ucharconvertdialog.ui +++ /dev/null @@ -1,112 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>UCharConvertDialog</class> - <widget class="QDialog" name="UCharConvertDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>300</height> - </rect> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="geometry"> - <rect> - <x>40</x> - <y>260</y> - <width>341</width> - <height>32</height> - </rect> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - <widget class="QWidget" name="verticalLayoutWidget"> - <property name="geometry"> - <rect> - <x>30</x> - <y>40</y> - <width>311</width> - <height>81</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="comboBox"/> - </item> - </layout> - </widget> - <widget class="QWidget" name="verticalLayoutWidget_2"> - <property name="geometry"> - <rect> - <x>30</x> - <y>150</y> - <width>160</width> - <height>80</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>TextLabel</string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="spinBox"/> - </item> - </layout> - </widget> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>UCharConvertDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>UCharConvertDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui>