Skip to content
Snippets Groups Projects
Commit 50c36b27 authored by ariotte's avatar ariotte
Browse files

Merge branch 'dev2018' of https://github.com/eiimage/eiimage into dev2018

parents 936c1f4f ce92b2c3
No related branches found
No related tags found
No related merge requests found
......@@ -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})
......
......@@ -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>
......
#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();
}
......@@ -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
......@@ -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");
}
......@@ -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;
};
......
#include "ucharconvertdialog.h"
#include "ui_ucharconvertdialog.h"
UCharConvertDialog::UCharConvertDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::UCharConvertDialog)
{
ui->setupUi(this);
}
UCharConvertDialog::~UCharConvertDialog()
{
delete ui;
}
<?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>
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