From 43f0de4cdc90b6ed4a5e9f2c1b943478000478e4 Mon Sep 17 00:00:00 2001 From: BertrandP <bertrand.provot@insa-rennes.fr> Date: Thu, 28 Jun 2018 16:35:14 +0200 Subject: [PATCH] starting to build new op for the Uchar/Double conversion, update on the cmakelists and cleaning some comments on OpService --- app/CMakeLists.txt | 7 +- app/Operations/UCharConvertOp.cpp | 42 ++++++++++ app/Operations/UCharConvertOp.h | 19 +++++ app/Operations/ucharconvertdialog.cpp | 14 ++++ app/Operations/ucharconvertdialog.h | 22 +++++ app/Operations/ucharconvertdialog.ui | 112 ++++++++++++++++++++++++++ app/Services/OperationService.cpp | 43 ---------- app/main.cpp | 3 + 8 files changed, 217 insertions(+), 45 deletions(-) create mode 100644 app/Operations/UCharConvertOp.cpp create mode 100644 app/Operations/UCharConvertOp.h create mode 100644 app/Operations/ucharconvertdialog.cpp create mode 100644 app/Operations/ucharconvertdialog.h create mode 100644 app/Operations/ucharconvertdialog.ui diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 0690c8a..82822c2 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -124,14 +124,12 @@ set(imageinsa_SOURCES Operations/SignalToNoiseOp.cpp Operations/SignalToNoiseOp.h Operations/SinusSynthesisOp.cpp - Operations/SinusSynthesisOp.cpp Operations/SinusSynthesisOp.h Operations/SplitColorOp.cpp Operations/SplitColorOp.h Operations/SplitHsvOp.cpp Operations/SplitHsvOp.h Operations/ThresholdDialog.cpp - Operations/ThresholdDialog.cpp Operations/ThresholdDialog.h Operations/ThresholdOp.cpp Operations/ThresholdOp.cpp @@ -140,6 +138,10 @@ set(imageinsa_SOURCES Operations/Transforms.h Operations/TranslateOp.cpp Operations/TranslateOp.h + Operations/UCharConvertOp.cpp + Operations/UCharConvertOp.h + Operations/ucharconvertdialog.cpp + Operations/ucharconvertdialog.h Operations/ZeroCrossingOp.cpp Operations/ZeroCrossingOp.h Services/ImageINSAService.cpp @@ -185,6 +187,7 @@ 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/UCharConvertOp.cpp b/app/Operations/UCharConvertOp.cpp new file mode 100644 index 0000000..81f982e --- /dev/null +++ b/app/Operations/UCharConvertOp.cpp @@ -0,0 +1,42 @@ +/* + * Copyright 2011-2012 INSA Rennes + * + * This file is part of ImageINSA. + * + * ImageINSA is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * ImageINSA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ImageINSA. If not, see <http://www.gnu.org/licenses/>. +*/ + + +#include "UCharConvertOp.h" +#include "../Tools.h" +#include <QApplication> +#include <QObject> +#include "Operation.h" +#include "ucharconvertdialog.h" + + +UCharConvertOp::UCharConvertOp() : DoubleOperation(qApp->translate("Operations", "UChar converter").toStdString()) +{ +} + +bool UCharConvertOp::needCurrentImg() const{ + return true; +} + +void UCharConvertOp::operator()(const imagein::Image_t<double>*, 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()); + + if(code!=QDialog::Accepted) return; +} diff --git a/app/Operations/UCharConvertOp.h b/app/Operations/UCharConvertOp.h new file mode 100644 index 0000000..06c8d1b --- /dev/null +++ b/app/Operations/UCharConvertOp.h @@ -0,0 +1,19 @@ +#ifndef UCHARCONVERTOP_H +#define UCHARCONVERTOP_H + +#include <QObject> +#include "Operation.h" +#include "ucharconvertdialog.h" + + +class UCharConvertOp : public DoubleOperation +{ +public: + UCharConvertOp(); + + bool needCurrentImg() const; + + void operator()(const imagein::Image_t<double>*, const std::map<const imagein::Image_t<double>*, std::string>&); +}; + +#endif // UCHARCONVERTOP_H diff --git a/app/Operations/ucharconvertdialog.cpp b/app/Operations/ucharconvertdialog.cpp new file mode 100644 index 0000000..efbdd6e --- /dev/null +++ b/app/Operations/ucharconvertdialog.cpp @@ -0,0 +1,14 @@ +#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.h b/app/Operations/ucharconvertdialog.h new file mode 100644 index 0000000..2757e4b --- /dev/null +++ b/app/Operations/ucharconvertdialog.h @@ -0,0 +1,22 @@ +#ifndef UCHARCONVERTDIALOG_H +#define UCHARCONVERTDIALOG_H + +#include <QDialog> + +namespace Ui { +class UCharConvertDialog; +} + +class UCharConvertDialog : public QDialog +{ + Q_OBJECT + +public: + explicit UCharConvertDialog(QWidget *parent = 0); + ~UCharConvertDialog(); + +private: + Ui::UCharConvertDialog *ui; +}; + +#endif // UCHARCONVERTDIALOG_H diff --git a/app/Operations/ucharconvertdialog.ui b/app/Operations/ucharconvertdialog.ui new file mode 100644 index 0000000..12cb7da --- /dev/null +++ b/app/Operations/ucharconvertdialog.ui @@ -0,0 +1,112 @@ +<?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> diff --git a/app/Services/OperationService.cpp b/app/Services/OperationService.cpp index b1e60ae..fdfdc2a 100644 --- a/app/Services/OperationService.cpp +++ b/app/Services/OperationService.cpp @@ -55,21 +55,8 @@ void OperationService::connect(GenericInterface* gi) void OperationService::operation() { -// cout << _operation->getName() << endl; - WindowService* ws = _gi->windowService(); ImageWindow* curImgWnd = ws->getCurrentImageWindow(); - -// StandardImageWindow* curStdImgWnd = NULL; -// if (curImgWnd != NULL) -// { -// curStdImgWnd = dynamic_cast<StandardImageWindow*>(curImgWnd); -// } - -// const Image* image = NULL; -// if(curStdImgWnd != NULL) { -// image = curStdImgWnd->getImage(); -// } if(_operation->needCurrentImg() && !_operation->isValidImgWnd(curImgWnd)) return; map<const ImageWindow*, string> wndList; @@ -80,36 +67,6 @@ void OperationService::operation() { _operation->operator()(dynamic_cast<ImageINSAService*>(ws)); -// for(vector<QWidget*>::iterator it = result.begin(); it < result.end(); ++it) { -// QWidget* widget = *it; -// QLabel* twdgt = dynamic_cast<QLabel*>(widget); -// if((typeid(*widget) == typeid(ImgWidget)) || (typeid(*widget) == typeid(DoubleImgWidget))) { -// QString title = _operation->needCurrentImg() ? (curImgWnd->windowTitle() + " - ") : ""; -// ImageWindow* siw; -// if(typeid(*widget)==typeid(ImgWidget)) { -// ImgWidget* w = dynamic_cast<ImgWidget*>(widget); -// title += w->name.c_str(); -// siw = new StandardImageWindow(_operation->needCurrentImg() ? curImgWnd->getPath() : w->name.c_str(), w->img); -// } -// else { -// DoubleImgWidget* w = dynamic_cast<DoubleImgWidget*>(widget); -// title += w->name.c_str(); -// siw = new DoubleImageWindow(_operation->needCurrentImg() ? curImgWnd->getPath() : w->name.c_str(), w->img, w->normalize, w->logScale); -// } -// NodeId id = _operation->needCurrentImg() ? ws->getNodeId(curImgWnd) : NodeId(siw->getDisplayImage()); -// ws->addImage(id, siw); -// siw->setWindowTitle(title); -// } -// else if(twdgt != NULL) { -// emit outputText(twdgt->text()); -// } -// else { -// ws->addWidget(ws->getNodeId(curImgWnd), widget); -// } - -// } - - } void OperationService::setEnabled(bool enabled) { diff --git a/app/main.cpp b/app/main.cpp index 3ccdee1..260b57b 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -71,6 +71,7 @@ #include "Operations/ClassResultOp.h" #include "Operations/SeparatorOp.h" #include "Operations/MedianOp.h" +#include "Operations/UCharConvertOp.h" #include "Services/MorphoMatService.h" @@ -142,6 +143,8 @@ int main(int argc, char** argv) image->addOperation(new QuantificationOp()); image->addOperation(new ThresholdOp()); image->addOperation(new HistogramOp()); + image->addOperation(new SeparatorOp()); + image->addOperation(new UCharConvertOp()); BuiltinOpSet* tools = new BuiltinOpSet(qApp->translate("", "&Tools").toStdString()); -- GitLab