diff --git a/IHM_Retouche_Photo/IHM_Retouche_Photo.pro b/IHM_Retouche_Photo/IHM_Retouche_Photo.pro index 55a805c04500365a67b903830c01da5da737bf43..b51ded177c20da7f47c0d8ed7aeec6043078d433 100644 --- a/IHM_Retouche_Photo/IHM_Retouche_Photo.pro +++ b/IHM_Retouche_Photo/IHM_Retouche_Photo.pro @@ -35,6 +35,8 @@ SOURCES += \ ui/toolbox/toolRegister.cpp \ ui/view/imagearea.cpp \ ui/view/multyimagemodifier.cpp \ + ui/view/repercussion/average.cpp \ + ui/view/repercussion/clamp.cpp \ ui/view/repercussion/ignore.cpp \ ui/view/selection.cpp \ ui/view/viewmanager.cpp @@ -66,6 +68,8 @@ HEADERS += \ ui/toolbox/toolRegister.h \ ui/view/imagearea.h \ ui/view/multyimagemodifier.h \ + ui/view/repercussion/average.h \ + ui/view/repercussion/clamp.h \ ui/view/repercussion/ignore.h \ ui/view/repercussion/repercussion.h \ ui/view/selection.h \ diff --git a/IHM_Retouche_Photo/mainwindow.cpp b/IHM_Retouche_Photo/mainwindow.cpp index 72fe43d6f84ce42d4b09a2734d7679be0da609b7..eaaaa5228de6c342e5229678df66da1d71db88b6 100644 --- a/IHM_Retouche_Photo/mainwindow.cpp +++ b/IHM_Retouche_Photo/mainwindow.cpp @@ -25,6 +25,8 @@ #include <tools/editable/pixelpainter.h> #include <ui/view/repercussion/ignore.h> +#include <ui/view/repercussion/clamp.h> +#include <ui/view/repercussion/average.h> MainWindow::MainWindow(QWidget * parent) : QMainWindow(parent), _toolRegister(), _fileselectorManager(nullptr), _viewManager(nullptr) { @@ -59,13 +61,10 @@ MainWindow::MainWindow(QWidget * parent) qDebug() << "Mark_4"; - this->_multyImageModifier = new ui::MultyImageModifier(this->_viewManager, this->_emitDrawCheckbox, this->_receiveDrawCheckbox, this->_samplingDrawCombobox); - qDebug() << "Mark_4.1"; - - this->_multyImageModifier->push_back(QSharedPointer<ui::Repercution>(new ui::Ignore())); - qDebug() << "Mark_4.2"; - - this->_multyImageModifier->update(); + this->_multyImageModifier = new ui::MultyImageModifier(this->_viewManager, this->_emitDrawCheckbox, this->_receiveDrawCheckbox, this->_samplingDrawList); + this->_multyImageModifier->push(QSharedPointer<ui::Repercution>(new ui::Ignore())); + this->_multyImageModifier->push(QSharedPointer<ui::Repercution>(new ui::Clamp())); + this->_multyImageModifier->push(QSharedPointer<ui::Repercution>(new ui::Average())); qDebug() << "mark_5"; diff --git a/IHM_Retouche_Photo/mainwindow.ui b/IHM_Retouche_Photo/mainwindow.ui index eead692afff98a21f8ec5cab78dd7cc070654255..071e42a399d2cbf32090559e113991fd72f12e6b 100644 --- a/IHM_Retouche_Photo/mainwindow.ui +++ b/IHM_Retouche_Photo/mainwindow.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>992</width> - <height>613</height> + <width>763</width> + <height>494</height> </rect> </property> <property name="windowTitle"> @@ -358,7 +358,7 @@ <item> <widget class="QPushButton" name="_colorPicker"> <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> @@ -387,7 +387,7 @@ <item> <widget class="QPushButton" name="_rescaleButton"> <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> @@ -413,7 +413,7 @@ <item> <widget class="QPushButton" name="_resizeButton"> <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> @@ -446,7 +446,7 @@ <item> <widget class="QListWidget" name="_toolbox"> <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Expanding"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> @@ -496,6 +496,12 @@ </property> <item> <widget class="QCheckBox" name="_emitDrawCheckbox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="statusTip"> <string>Permet à image courante de modifier toutes les autres images modifiable.</string> </property> @@ -506,6 +512,12 @@ </item> <item> <widget class="QCheckBox" name="_receiveDrawCheckbox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="statusTip"> <string>Permet de laisser l'image courante être modifié par les autres images.</string> </property> @@ -521,7 +533,20 @@ </widget> </item> <item> - <widget class="QComboBox" name="_samplingDrawCombobox"/> + <widget class="QListWidget" name="_samplingDrawList"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>QFrame::NoFrame</enum> + </property> + <property name="tabKeyNavigation"> + <bool>true</bool> + </property> + </widget> </item> </layout> </item> @@ -540,7 +565,7 @@ <rect> <x>0</x> <y>0</y> - <width>992</width> + <width>763</width> <height>21</height> </rect> </property> @@ -1079,16 +1104,16 @@ <connection> <sender>_receiveDrawCheckbox</sender> <signal>toggled(bool)</signal> - <receiver>_samplingDrawCombobox</receiver> + <receiver>_samplingDrawList</receiver> <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>702</x> - <y>542</y> + <x>601</x> + <y>344</y> </hint> <hint type="destinationlabel"> - <x>698</x> - <y>575</y> + <x>591</x> + <y>374</y> </hint> </hints> </connection> diff --git a/IHM_Retouche_Photo/tools/editable/pixelpainter.cpp b/IHM_Retouche_Photo/tools/editable/pixelpainter.cpp index 9339d8a96e8a378bc4785a0d4e3a687c1de126a2..693cb6723a842e835c1f013b7b2d30fdc91d84fd 100644 --- a/IHM_Retouche_Photo/tools/editable/pixelpainter.cpp +++ b/IHM_Retouche_Photo/tools/editable/pixelpainter.cpp @@ -16,9 +16,11 @@ namespace tool { } } - void Pixelpainter::onMouseMoved(ui::ImageArea & a, QImage & , const QPoint & p, const ui::Selection &, const QMouseEvent &, const ColorPickerWidget & cp, bool hold) { + void Pixelpainter::onMouseMoved(ui::ImageArea & a, QImage & , const QPoint & p, const ui::Selection & s, const QMouseEvent &, const ColorPickerWidget & cp, bool hold) { if(hold && this->_leftButton) { - a.setColor(p, cp.currentColor()); + if(s.contain(p)) { + a.setColor(p, cp.currentColor()); + } } } } diff --git a/IHM_Retouche_Photo/ui/effect/contrast.cpp b/IHM_Retouche_Photo/ui/effect/contrast.cpp index 3acfe6e4189fbc1cecce3e35c824cf878f8fd75c..5fb86a18d5f62fe099946c2d341256f68d26e29e 100644 --- a/IHM_Retouche_Photo/ui/effect/contrast.cpp +++ b/IHM_Retouche_Photo/ui/effect/contrast.cpp @@ -1,4 +1,4 @@ -#include "contrast.h"" +#include "contrast.h" #include <QDebug> diff --git a/IHM_Retouche_Photo/ui/view/imagearea.cpp b/IHM_Retouche_Photo/ui/view/imagearea.cpp index 15992bd4b043be626720a6fa312b5faeee1c9cff..0cad5c145a94523ba72c1ec5312aef4476e39fcf 100644 --- a/IHM_Retouche_Photo/ui/view/imagearea.cpp +++ b/IHM_Retouche_Photo/ui/view/imagearea.cpp @@ -65,11 +65,20 @@ namespace ui { painter.drawImage(drawZone, this->_checkboard); painter.drawImage(drawZone, this->_image); - this->_selection.paint(painter, QPoint(drawZone.x(), drawZone.y()), this->_zoom); + this->_selection.paint(painter, QPoint(drawZone.x(), drawZone.y()), this->_image, this->_zoom); + + QPoint pixelPosition = this->_lastPos - this->_position; + pixelPosition.setX(abs(pixelPosition.x()) / this->_zoom); + pixelPosition.setY(abs(pixelPosition.y()) / this->_zoom); + + if(this->_image.rect().contains(pixelPosition)) { + painter.drawRect(this->_position.x() + pixelPosition.x() * this->_zoom, this->_position.y() + pixelPosition.y() * this->_zoom, this->_zoom, this->_zoom); + } } void ImageArea::mouseMoveEvent(QMouseEvent * e) { QPoint pixelPosition = this->_position - this->_lastPos; + if(pixelPosition.x() <= 0 && pixelPosition.y() <= 0) { pixelPosition.setX(abs(pixelPosition.x()) / this->_zoom); pixelPosition.setY(abs(pixelPosition.y()) / this->_zoom); @@ -138,21 +147,31 @@ namespace ui { } } - void ImageArea::changeZoom(float value) { + void ImageArea::changeZoom(double value) { this->_zoom = value; emit this->zoomChanged(value); this->repaint(); } void ImageArea::increaseZoom() { - this->_zoom += 1; + if(this->_zoom > 2) { + this->_zoom = std::floor(this->_zoom + 1); + } + else { + this->_zoom *= 1.1; + } emit this->zoomChanged(this->_zoom); this->repaint(); } void ImageArea::decreaseZoom() { - if(this->_zoom > 1) { - this->_zoom -= 1; + if(this->_zoom > 0.15) { + if(this->_zoom > 2) { + this->_zoom = std::floor(this->_zoom - 1); + } + else { + this->_zoom *= 0.9; + } emit this->zoomChanged(this->_zoom); this->repaint(); } @@ -165,9 +184,9 @@ namespace ui { emit this->imageChanged(image); } - void ImageArea::setColor(const QPoint & pixel, const QColor & color) { - if(this->_repercution != nullptr) { - this->_repercution->apply(pixel, color , &this->_image); + void ImageArea::setColor(const QPoint & pixel, const QColor & color, const QImage * origin) { + if(this->_repercution != nullptr && origin != nullptr) { + this->_repercution->apply(pixel, color , origin, &this->_image); } else { if(this->_image.rect().contains(pixel)) { @@ -179,12 +198,6 @@ namespace ui { emit this->modified(pixel, color); } - void ImageArea::setColor(const QVector<QPoint> & pixels, const QColor & color) { - for(auto & pixel : pixels) { - this->setColor(pixel, color); - } - } - void ImageArea::setScale(const QPoint & scaling, Qt::TransformationMode mode) { this->setImage(this->_image.scaled(scaling.x(), scaling.y(), Qt::IgnoreAspectRatio, mode)); this->repaint(); diff --git a/IHM_Retouche_Photo/ui/view/imagearea.h b/IHM_Retouche_Photo/ui/view/imagearea.h index 5e4c12af2327c3f093ca43e9c979215012f94c85..5d302a2e76efb73a428f80aa1201494af986682b 100644 --- a/IHM_Retouche_Photo/ui/view/imagearea.h +++ b/IHM_Retouche_Photo/ui/view/imagearea.h @@ -26,7 +26,7 @@ namespace ui { Repercution * _repercution; - float _zoom; + double _zoom; uint8_t _status; @@ -51,7 +51,7 @@ namespace ui { inline const Repercution * repercution() const {return this->_repercution;} inline const QTransform & transformation() const {return this->_transformation;} - inline float zoom() const {return this->_zoom;} + inline double zoom() const {return this->_zoom;} inline bool isOriginal() const {return (this->_status & ORIGINAL) != 0;} inline bool isModified() const {return (this->_status & MODIFIED) != 0;} @@ -93,11 +93,10 @@ namespace ui { void increaseZoom(); void decreaseZoom(); - void changeZoom(float); + void changeZoom(double); void setImage(const QImage &); - void setColor(const QPoint &, const QColor &); - void setColor(const QVector<QPoint> &, const QColor &); + void setColor(const QPoint &, const QColor &, const QImage * = nullptr); void setScale(const QPoint &, Qt::TransformationMode = Qt::TransformationMode::FastTransformation); void setSize(const QPoint &, const QPoint &); @@ -115,7 +114,7 @@ namespace ui { void blackAndWhite(); signals: - void zoomChanged(float); + void zoomChanged(double); void imageChanged(const QImage &); diff --git a/IHM_Retouche_Photo/ui/view/multyimagemodifier.cpp b/IHM_Retouche_Photo/ui/view/multyimagemodifier.cpp index 4985dbfb1492e6d058d72d3b981cd207107eca94..12a7246c4f1423dd49ec75ab76248a9602f7e553 100644 --- a/IHM_Retouche_Photo/ui/view/multyimagemodifier.cpp +++ b/IHM_Retouche_Photo/ui/view/multyimagemodifier.cpp @@ -2,23 +2,19 @@ namespace ui { - MultyImageModifier::MultyImageModifier(ViewManager * manager, QCheckBox * emitCheckbox, QCheckBox * receiveCheckbox, QComboBox * samplingCombobox) - : _manager(manager), _current(nullptr), _emitCheckbox(emitCheckbox), _receiveCheckbox(receiveCheckbox), _samplingCombobox(samplingCombobox) { + MultyImageModifier::MultyImageModifier(ViewManager * manager, QCheckBox * emitCheckbox, QCheckBox * receiveCheckbox, QListWidget * samplingList) + : _manager(manager), _current(nullptr), _emitCheckbox(emitCheckbox), _receiveCheckbox(receiveCheckbox), _samplingList(samplingList) { QObject::connect(manager, SIGNAL(changedView(ImageArea*)), this, SLOT(changeCurrentImage(ImageArea*))); QObject::connect(manager, SIGNAL(createdView(ImageArea*)), this, SLOT(pushTarget(ImageArea*))); QObject::connect(manager, SIGNAL(deletedView(ImageArea*)), this, SLOT(eraseTarget(ImageArea*))); - QObject::connect(samplingCombobox, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCurrentRepercution(int))); + QObject::connect(samplingList, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(changeCurrentRepercution(QListWidgetItem*))); } - void MultyImageModifier::update() { - this->_samplingCombobox->clear(); - //qDebug() << "Mark_4.3"; - //for(int i = 0; i < this->size() ; i++) { - // this->_samplingCombobox->addItem("test"); - //} - //qDebug() << "Mark_4.5"; + void MultyImageModifier::push(QSharedPointer<Repercution> r) { + this->_repercutions.push_back(r); + this->_samplingList->addItem(r.get()); } void MultyImageModifier::changeCurrentImage(ImageArea * area) { @@ -36,8 +32,8 @@ namespace ui { this->_current = area; if(this->_current != nullptr) { - if(this->_current->repercution() == nullptr && !this->empty()) { - this->_current->setRepercution(this->at(0).get()); + if(this->_current->repercution() == nullptr && !this->_repercutions.empty()) { + this->_current->setRepercution(this->_repercutions.at(0).get()); } if(this->_current->isReceivingModification()) { @@ -46,7 +42,6 @@ namespace ui { this->_emitCheckbox->setChecked(this->_current->isEmitingModification()); this->_receiveCheckbox->setChecked(this->_current->isReceivingModification()); - this->_samplingCombobox->setCurrentIndex(this->indexOf(this->_current->repercution())); QObject::connect(this->_emitCheckbox, SIGNAL(toggled(bool)), this->_current, SLOT(changeModificationEmit(bool))); @@ -60,19 +55,20 @@ namespace ui { else { this->_emitCheckbox->setChecked(false); this->_receiveCheckbox->setChecked(false); - this->_samplingCombobox->setCurrentIndex(0); } } - void MultyImageModifier::changeCurrentRepercution(int index) { - this->_current->setRepercution(this->at(index).get()); + void MultyImageModifier::changeCurrentRepercution(QListWidgetItem * e) { + if(this->_current != nullptr) { + this->_current->setRepercution(dynamic_cast<Repercution *>(e)); + } } void MultyImageModifier::modify(const QPoint & point, const QColor & color) { if(this->_current != nullptr && this->_current->isEmitingModification()) { for(auto * area : this->_targets) { if(area != this->_current) { - area->setColor(point, color); + area->setColor(point, color, &this->_current->image()); } } } diff --git a/IHM_Retouche_Photo/ui/view/multyimagemodifier.h b/IHM_Retouche_Photo/ui/view/multyimagemodifier.h index 8ea52ab5e6227a44eb09d09bf7d1eaf7a6897bc0..a8b1b31cdac48f55b3c4adbbe4b3af531fd51b17 100644 --- a/IHM_Retouche_Photo/ui/view/multyimagemodifier.h +++ b/IHM_Retouche_Photo/ui/view/multyimagemodifier.h @@ -5,30 +5,36 @@ #include <QCheckBox> #include <QComboBox> #include <QVector> +#include <QListWidget> #include "viewmanager.h" #include "repercussion/repercussion.h" namespace ui { -class MultyImageModifier : public QObject, public QVector<QSharedPointer<Repercution>> { +class MultyImageModifier : public QObject { Q_OBJECT private: ViewManager * _manager; ImageArea * _current; + QSet<ImageArea *> _targets; + QVector<QSharedPointer<Repercution>> _repercutions; QCheckBox * _emitCheckbox; QCheckBox * _receiveCheckbox; - QComboBox * _samplingCombobox; + QListWidget * _samplingList; + + QString _tmp_test; + QStringList _tmp_test_2; public: MultyImageModifier() = delete; - MultyImageModifier(ViewManager *, QCheckBox * emitCheckbox, QCheckBox * receiveCheckbox, QComboBox * samplingCombobox); + MultyImageModifier(ViewManager *, QCheckBox * emitCheckbox, QCheckBox * receiveCheckbox, QListWidget * samplinglist); - void update(); + inline const QVector<QSharedPointer<Repercution>> & repercutions() const {return this->_repercutions;} public slots: - void changeCurrentRepercution(int); + void changeCurrentRepercution(QListWidgetItem*); void changeCurrentImage(ImageArea *); void modify(const QPoint &, const QColor &); @@ -39,5 +45,7 @@ class MultyImageModifier : public QObject, public QVector<QSharedPointer<Repercu void pushTarget(ImageArea *); void eraseTarget(ImageArea *); + + void push(QSharedPointer<Repercution> repercution); }; } diff --git a/IHM_Retouche_Photo/ui/view/repercussion/average.cpp b/IHM_Retouche_Photo/ui/view/repercussion/average.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2094e18449e26e51ebbada25d238adc2e11b8cbb --- /dev/null +++ b/IHM_Retouche_Photo/ui/view/repercussion/average.cpp @@ -0,0 +1,8 @@ +#include "average.h" + +namespace ui { + void Average::apply(const QPoint & point, const QColor & color, const QImage * origin, QImage * image) { + QPoint newPoint(point.x() * image->width() / origin->height(), point.y() * image->height() / origin->height()); + image->setPixelColor(newPoint, color); + } +} diff --git a/IHM_Retouche_Photo/ui/view/repercussion/average.h b/IHM_Retouche_Photo/ui/view/repercussion/average.h new file mode 100644 index 0000000000000000000000000000000000000000..7af415e33b58c28434b45d5d5f16dc29be2ad19c --- /dev/null +++ b/IHM_Retouche_Photo/ui/view/repercussion/average.h @@ -0,0 +1,14 @@ +#pragma once + +#include "repercussion.h" + +namespace ui { + class Average : public Repercution { + public: + Average() : Repercution("Average") {} + virtual ~Average() {} + + virtual void apply(const QPoint &, const QColor &, const QImage *, QImage *); + }; +} + diff --git a/IHM_Retouche_Photo/ui/view/repercussion/clamp.cpp b/IHM_Retouche_Photo/ui/view/repercussion/clamp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f927792cb2ec201c8c0e058bbca462c93addfe4c --- /dev/null +++ b/IHM_Retouche_Photo/ui/view/repercussion/clamp.cpp @@ -0,0 +1,11 @@ +#include "clamp.h" + +namespace ui { + void Clamp::apply(const QPoint & point, const QColor & color, const QImage *, QImage * image) { + QPoint newPoint( + point.x() > image->width()-1 ? image->width()-1 : point.x(), + point.y() > image->height()-1 ? image->height()-1 : point.y() + ); + image->setPixelColor(newPoint, color); + } +} diff --git a/IHM_Retouche_Photo/ui/view/repercussion/clamp.h b/IHM_Retouche_Photo/ui/view/repercussion/clamp.h new file mode 100644 index 0000000000000000000000000000000000000000..d21b4fd7528bc963d319c93442d2276d9be9bf4d --- /dev/null +++ b/IHM_Retouche_Photo/ui/view/repercussion/clamp.h @@ -0,0 +1,14 @@ +#pragma once + +#include "repercussion.h" + +namespace ui { + class Clamp : public Repercution { + public: + Clamp() : Repercution("Clamp") {} + virtual ~Clamp() {} + + virtual void apply(const QPoint &, const QColor &, const QImage *, QImage *); + }; +} + diff --git a/IHM_Retouche_Photo/ui/view/repercussion/ignore.cpp b/IHM_Retouche_Photo/ui/view/repercussion/ignore.cpp index 504a1787d65402d149c0aa038440d2de4e76ff30..ea615b53c19ea49303c627970bdf757dccf3ade7 100644 --- a/IHM_Retouche_Photo/ui/view/repercussion/ignore.cpp +++ b/IHM_Retouche_Photo/ui/view/repercussion/ignore.cpp @@ -1,7 +1,7 @@ #include "ignore.h" namespace ui { - void Ignore::apply(const QPoint & point, const QColor & color, QImage * image) { + void Ignore::apply(const QPoint & point, const QColor & color, const QImage *, QImage * image) { if(image->rect().contains(point)) { image->setPixelColor(point, color); } diff --git a/IHM_Retouche_Photo/ui/view/repercussion/ignore.h b/IHM_Retouche_Photo/ui/view/repercussion/ignore.h index 634d95a99cdb9175774a7c16091b087fddbef3db..3031358ad7f930fc2e43aa5e67d4c8bd1cb6db21 100644 --- a/IHM_Retouche_Photo/ui/view/repercussion/ignore.h +++ b/IHM_Retouche_Photo/ui/view/repercussion/ignore.h @@ -5,11 +5,10 @@ namespace ui { class Ignore : public Repercution{ public: - Ignore() {} + Ignore() : Repercution("Ignore") {} virtual ~Ignore() {} - inline QString name() const {return "Ignore";} - virtual void apply(const QPoint &, const QColor &, QImage *); + virtual void apply(const QPoint &, const QColor &, const QImage *, QImage *); }; } diff --git a/IHM_Retouche_Photo/ui/view/repercussion/repercussion.h b/IHM_Retouche_Photo/ui/view/repercussion/repercussion.h index 8dea5c6c91d10faae8ccc6077fd490c835851be4..e0d83b90f970d3ce94a3caec154bac2577dc3ae2 100644 --- a/IHM_Retouche_Photo/ui/view/repercussion/repercussion.h +++ b/IHM_Retouche_Photo/ui/view/repercussion/repercussion.h @@ -3,14 +3,14 @@ #include <QString> #include <QPoint> #include <QImage> +#include <QListWidgetItem> namespace ui { - class Repercution { + class Repercution : public QListWidgetItem { public: - Repercution() {} + Repercution(const QString & name) : QListWidgetItem(name) {} virtual ~Repercution() {} - inline virtual QString name() const = 0; - virtual void apply(const QPoint &, const QColor &, QImage *) = 0; + virtual void apply(const QPoint &, const QColor &, const QImage *, QImage *) = 0; }; } diff --git a/IHM_Retouche_Photo/ui/view/selection.cpp b/IHM_Retouche_Photo/ui/view/selection.cpp index 340ee73bd9580f5037de75b22530b25fb892155d..38a737ae3f48d54d737e94c6542725fb482a159c 100644 --- a/IHM_Retouche_Photo/ui/view/selection.cpp +++ b/IHM_Retouche_Photo/ui/view/selection.cpp @@ -6,9 +6,11 @@ namespace ui { Selection::Selection(const QSet<QPoint> & preselection,const QColor & color) : _pixels(preselection), _color(color) {} - void Selection::paint(QPainter & painter, const QPoint & position, float zoom) { + void Selection::paint(QPainter & painter, const QPoint & position, const QImage & image, float zoom) { for(auto & pixel : this->_pixels) { - painter.fillRect(position.x() + pixel.x() * zoom, position.y() + pixel.y() * zoom, zoom, zoom, this->_color); + if(image.rect().contains(pixel)) { + painter.fillRect(position.x() + pixel.x() * zoom, position.y() + pixel.y() * zoom, zoom, zoom, this->_color); + } } } @@ -100,8 +102,4 @@ namespace ui { void Selection::clear() { this->_pixels.clear(); } - - bool Selection::contain(const QPoint & point) { - return this->_pixels.contains(point); - } } diff --git a/IHM_Retouche_Photo/ui/view/selection.h b/IHM_Retouche_Photo/ui/view/selection.h index 96b100f43bbcb70859097588a519123c45bcc5f7..dcb9e85addab52cf758742461becf3cdf06c88cb 100644 --- a/IHM_Retouche_Photo/ui/view/selection.h +++ b/IHM_Retouche_Photo/ui/view/selection.h @@ -17,7 +17,7 @@ namespace ui { inline const QSet<QPoint> selection() const {return this->_pixels;} - void paint(QPainter &, const QPoint &, float); + void paint(QPainter &, const QPoint &, const QImage &, float); void select(const QPoint &); void select(const QSet<QPoint> &); @@ -35,7 +35,7 @@ namespace ui { void invert(unsigned int, unsigned int); void clear(); - bool contain(const QPoint &); + inline bool contain(const QPoint & point) const {return this->_pixels.contains(point);}; inline bool empty() const {return this->_pixels.empty();}