diff --git a/IHM_Retouche_Photo/IHM_Retouche_Photo.pro b/IHM_Retouche_Photo/IHM_Retouche_Photo.pro index 1f60245329692f203c5b4b26e73d6847a480c0e1..2f59791f2e9ce7b7aa2878c007bb5b3351cae9c4 100644 --- a/IHM_Retouche_Photo/IHM_Retouche_Photo.pro +++ b/IHM_Retouche_Photo/IHM_Retouche_Photo.pro @@ -24,6 +24,7 @@ SOURCES += \ tools/selectionable/color.cpp \ tools/selectionable/ellipse.cpp \ tools/selectionable/polygone.cpp \ + tools/selectionable/quad.cpp \ tools/selectionable/rectangle.cpp \ tools/selectionable/rectangleTriangle.cpp \ tools/selectionable/triangle.cpp \ @@ -62,6 +63,7 @@ HEADERS += \ tools/selectionable/color.h \ tools/selectionable/ellipse.h \ tools/selectionable/polygone.h \ + tools/selectionable/quad.h \ tools/selectionable/rectangle.h \ tools/selectionable/rectangleTriangle.h \ tools/selectionable/triangle.h \ diff --git a/IHM_Retouche_Photo/mainwindow.cpp b/IHM_Retouche_Photo/mainwindow.cpp index 2f7e7f2b8fcdb98420d4b0df6e2ffb2b7b236d65..3fa51372d2ddb0f74b4fe6b2e78ba156816df374 100644 --- a/IHM_Retouche_Photo/mainwindow.cpp +++ b/IHM_Retouche_Photo/mainwindow.cpp @@ -25,6 +25,7 @@ #include <tools/selectionable/ellipse.h> #include <tools/selectionable/polygone.h> #include <tools/selectionable/color.h> +#include <tools/selectionable/quad.h> #include <tools/editable/pixelpainter.h> #include <tools/editable/pixelEraiser.h> @@ -92,6 +93,7 @@ MainWindow::MainWindow(QWidget * parent) this->_toolRegister->add(QSharedPointer<tool::Tool>(new tool::Ellipse(this->colorPickerWidget)), ui::ToolboxRegister::ToolType::SELECTION); this->_toolRegister->add(QSharedPointer<tool::Tool>(new tool::Polygone(this->colorPickerWidget)), ui::ToolboxRegister::ToolType::SELECTION); this->_toolRegister->add(QSharedPointer<tool::Tool>(new tool::Color(this->colorPickerWidget)), ui::ToolboxRegister::ToolType::SELECTION); + this->_toolRegister->add(QSharedPointer<tool::Tool>(new tool::Quad(this->colorPickerWidget)), ui::ToolboxRegister::ToolType::SELECTION); this->_toolRegister->add(QSharedPointer<tool::Tool>(new tool::Pixelpainter(this->colorPickerWidget)), ui::ToolboxRegister::ToolType::EDIT); this->_toolRegister->add(QSharedPointer<tool::Tool>(new tool::Pixeleraiser(this->colorPickerWidget)), ui::ToolboxRegister::ToolType::EDIT); @@ -150,6 +152,8 @@ MainWindow::MainWindow(QWidget * parent) connect(_actionDecreaseContrast, &QAction::triggered, this, &MainWindow::decreaseContrastActionTriggered); qDebug() << "Mark_11"; + + QObject::connect(this->_action_unselect, SIGNAL(triggered(bool)), this, SLOT(unselect())); } void MainWindow::dragEnterEvent(QDragEnterEvent *e) { @@ -191,6 +195,7 @@ void MainWindow::adjustBrightnessContrastActionTriggered() { isVisible = !isVisible; } + void MainWindow::increaseBrightnessActionTriggered() { ui::ImageArea *currentImageArea = this->_viewManager->currentView(); if (currentImageArea) { @@ -199,6 +204,7 @@ void MainWindow::increaseBrightnessActionTriggered() { qDebug() << "Aucun onglet d'image actif."; } } + void MainWindow::decreaseBrightnessActionTriggered() { ui::ImageArea *currentImageArea = this->_viewManager->currentView(); if (currentImageArea) { @@ -207,6 +213,7 @@ void MainWindow::decreaseBrightnessActionTriggered() { qDebug() << "Aucun onglet d'image actif."; } } + void MainWindow::increaseContrastActionTriggered() { ui::ImageArea *currentImageArea = this->_viewManager->currentView(); if (currentImageArea) { @@ -215,6 +222,7 @@ void MainWindow::increaseContrastActionTriggered() { qDebug() << "Aucun onglet d'image actif."; } } + void MainWindow::decreaseContrastActionTriggered() { ui::ImageArea *currentImageArea = this->_viewManager->currentView(); if (currentImageArea) { @@ -224,6 +232,13 @@ void MainWindow::decreaseContrastActionTriggered() { } } +void MainWindow::unselect() { + ui::ImageArea * currentImage = this->_viewManager->currentView(); + if(currentImage != nullptr) { + currentImage->clearSelection(); + } +} + MainWindow::~MainWindow() { delete this->_fileselectorManager; delete this->_toolRegister; diff --git a/IHM_Retouche_Photo/mainwindow.h b/IHM_Retouche_Photo/mainwindow.h index 40abaa6924ec9cda8c32d2b9e767929901dace04..da1118a8be19377c1051668a7d0f5d109c7f3838 100644 --- a/IHM_Retouche_Photo/mainwindow.h +++ b/IHM_Retouche_Photo/mainwindow.h @@ -44,8 +44,6 @@ class MainWindow : public QMainWindow, private Ui::MainWindow { QAction* _actionIncreaseContrast; QAction* _actionDecreaseContrast; - - public: MainWindow(QWidget * parent = nullptr); ~MainWindow(); @@ -64,5 +62,7 @@ class MainWindow : public QMainWindow, private Ui::MainWindow { void increaseContrastActionTriggered(); void decreaseContrastActionTriggered(); + void unselect(); + }; diff --git a/IHM_Retouche_Photo/mainwindow.ui b/IHM_Retouche_Photo/mainwindow.ui index 20d918980872951e5a025ca440d146410d9b5fbc..27a5e4435a5db280c21dbd718f12b9becc48a3fe 100644 --- a/IHM_Retouche_Photo/mainwindow.ui +++ b/IHM_Retouche_Photo/mainwindow.ui @@ -748,15 +748,20 @@ </attribute> <addaction name="_action_new"/> <addaction name="_action_close"/> + <addaction name="separator"/> <addaction name="_action_save"/> <addaction name="_action_saveAs"/> <addaction name="_action_saveAll"/> + <addaction name="separator"/> <addaction name="_action_zoom_in"/> <addaction name="_action_zoom_out"/> + <addaction name="separator"/> <addaction name="_action_rotate_left_90"/> <addaction name="_action_rotate_right_90"/> <addaction name="_action_turn_verticaly"/> <addaction name="_action_turn_horizonaly"/> + <addaction name="separator"/> + <addaction name="_action_unselect"/> </widget> <action name="_action_new"> <property name="icon"> diff --git a/IHM_Retouche_Photo/ressource.qrc b/IHM_Retouche_Photo/ressource.qrc index e3b830043b7c6bf3e829a44852bc509687ef2e9d..6a5912e88a8fcdee6d56847c6e3a94747bfb2713 100644 --- a/IHM_Retouche_Photo/ressource.qrc +++ b/IHM_Retouche_Photo/ressource.qrc @@ -417,6 +417,7 @@ <file>ressource/image/oxygen/icons/16x16/align-none.png</file> <file>ressource/image/oxygen/icons/16x16/actions-fill-color-icon.png</file> <file>ressource/image/oxygen/icons/16x16/draw-unselect.png</file> + <file>ressource/image/oxygen/icons/16x16/draw-quad.png</file> </qresource> <qresource prefix="/stylesheet"/> <qresource prefix="/oxygen/64x64"> diff --git a/IHM_Retouche_Photo/ressource/image/oxygen/icons/16x16/draw-quad.png b/IHM_Retouche_Photo/ressource/image/oxygen/icons/16x16/draw-quad.png new file mode 100644 index 0000000000000000000000000000000000000000..647bf8e0f58ad530c62e30b9f86cc23286e9f597 Binary files /dev/null and b/IHM_Retouche_Photo/ressource/image/oxygen/icons/16x16/draw-quad.png differ diff --git a/IHM_Retouche_Photo/tools/editable.cpp b/IHM_Retouche_Photo/tools/editable.cpp index 37aab19d29ceb2c6333c320f86f2040de27d7005..f09917da3aa10eaca759335f0f7e3557d8851fb0 100644 --- a/IHM_Retouche_Photo/tools/editable.cpp +++ b/IHM_Retouche_Photo/tools/editable.cpp @@ -4,6 +4,7 @@ namespace tool { Editable::Editable(const ColorPickerWidget & cp, const QString & name, const QIcon & icon, bool free) : Tool(name, icon), _colorPicker(&cp), _free(free) {} + void Editable::initialize(ui::ImageArea *) {} void Editable::onKeyPress(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QKeyEvent &, const ColorPickerWidget &) {} void Editable::onKeyReleased(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QKeyEvent &, const ColorPickerWidget &) {} @@ -32,4 +33,6 @@ namespace tool { void Editable::keyReleased(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QKeyEvent & e) { this->onKeyReleased(area, image, click, selection, e, *this->_colorPicker); } + + void Editable::selectionCleared() {} } diff --git a/IHM_Retouche_Photo/tools/editable.h b/IHM_Retouche_Photo/tools/editable.h index 332cbe06d4bfc1f607aa65b61f9faaa548237eb6..b9d6dd711cc7a40bef6e4bae431a1947f7909744 100644 --- a/IHM_Retouche_Photo/tools/editable.h +++ b/IHM_Retouche_Photo/tools/editable.h @@ -22,6 +22,8 @@ namespace tool { virtual void onKeyPress(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QKeyEvent &, const ColorPickerWidget &); virtual void onKeyReleased(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QKeyEvent &, const ColorPickerWidget &); + virtual void initialize(ui::ImageArea *); + public slots: virtual void pressed(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &) final; virtual void released(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &) final; @@ -29,5 +31,7 @@ namespace tool { virtual void keyPressed(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QKeyEvent &) final; virtual void keyReleased(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QKeyEvent &) final; + + virtual void selectionCleared(); }; } diff --git a/IHM_Retouche_Photo/tools/editable/pixelEraiser.cpp b/IHM_Retouche_Photo/tools/editable/pixelEraiser.cpp index 3fb1ecdeb2beda4ffaa124a28893d227c71808fe..ec235798faf0041addd8e8ffa167e66dd3cb7f65 100644 --- a/IHM_Retouche_Photo/tools/editable/pixelEraiser.cpp +++ b/IHM_Retouche_Photo/tools/editable/pixelEraiser.cpp @@ -27,7 +27,7 @@ namespace tool { } } - void Pixeleraiser::onMouseMoved(ui::ImageArea & area, QImage & img, const QPoint & c, const ui::Selection & s, const QMouseEvent &, const ColorPickerWidget & cp, bool hold) { + void Pixeleraiser::onMouseMoved(ui::ImageArea & area, QImage & img, const QPoint & c, const ui::Selection & s, const QMouseEvent &, const ColorPickerWidget &, bool hold) { if(hold) { int cx = c.x(); int cy = c.y(); diff --git a/IHM_Retouche_Photo/tools/editable/pixelpainter.cpp b/IHM_Retouche_Photo/tools/editable/pixelpainter.cpp index 1dfcff5c325e6bb330e76e2d613d491a103545da..eda1db46b251ca3f1f7a1600a7cac4edd18512db 100644 --- a/IHM_Retouche_Photo/tools/editable/pixelpainter.cpp +++ b/IHM_Retouche_Photo/tools/editable/pixelpainter.cpp @@ -37,20 +37,20 @@ namespace tool { for(int dy = 1; dy < h; dy++) { QPoint p(x, cy + dy); if(img.rect().contains(p)) { - if(!s.empty() && s.contain(p)) { + if(s.empty()) { area.setColor(p, color); } - else { + else if(s.contain(p)) { area.setColor(p, color); } } p = QPoint(x, cy - dy); if(img.rect().contains(p)) { - if(!s.empty() && s.contain(p)) { + if(s.empty()) { area.setColor(p, color); } - else { + else if(s.contain(p)) { area.setColor(p, color); } } @@ -59,10 +59,10 @@ namespace tool { if(h >= 0) { QPoint p(x, cy); if(img.rect().contains(p)) { - if(!s.empty() && s.contain(p)) { + if(s.empty()) { area.setColor(p, color); } - else { + else if(s.contain(p)) { area.setColor(p, color); } } diff --git a/IHM_Retouche_Photo/tools/selectionable/color.cpp b/IHM_Retouche_Photo/tools/selectionable/color.cpp index 1057d8dbac837c1802d9edda1e3a35df732974fa..c448f3c655e0768803ba83c15a2a435b78a3cf2a 100644 --- a/IHM_Retouche_Photo/tools/selectionable/color.cpp +++ b/IHM_Retouche_Photo/tools/selectionable/color.cpp @@ -3,7 +3,7 @@ namespace tool { Color::Color(const ColorPickerWidget & cp) : Selectionable(cp, "Couleur", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/preferences-activities.png"), true), - _config(new dialog::SizeDialog("Paramètre de la séléction par couleur", "Proximité de la couleur", 0, 255, 0)),_lastClicked(-1,-1), _ctrl(false) { + _config(new dialog::SizeDialog("Paramètre de la séléction par couleur", "Proximité de la couleur", 0, 255, 16)),_lastClicked(-1,-1), _ctrl(false) { this->setCongigurationDialog(this->_config.get()); } diff --git a/IHM_Retouche_Photo/tools/selectionable/polygone.cpp b/IHM_Retouche_Photo/tools/selectionable/polygone.cpp index 0686566cfa4e4679a5299a742da4f32527726091..70b52af6592b24a4f9d90a35f25fd1ea557d7196 100644 --- a/IHM_Retouche_Photo/tools/selectionable/polygone.cpp +++ b/IHM_Retouche_Photo/tools/selectionable/polygone.cpp @@ -6,6 +6,10 @@ namespace tool { } + void Polygone::initialize(ui::ImageArea *) { + this->_polygon.clear(); + } + void Polygone::onMousePressed(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &, const ColorPickerWidget &) { } @@ -41,4 +45,8 @@ namespace tool { } } } + + void Polygone::onClear() { + this->_polygon.clear(); + } } diff --git a/IHM_Retouche_Photo/tools/selectionable/polygone.h b/IHM_Retouche_Photo/tools/selectionable/polygone.h index 922df6b58206abad6fe08c1430b1e6920c373ff7..4ef1806e243497b8d5b730d8d6ad8c8716d729f1 100644 --- a/IHM_Retouche_Photo/tools/selectionable/polygone.h +++ b/IHM_Retouche_Photo/tools/selectionable/polygone.h @@ -14,5 +14,8 @@ namespace tool { virtual void onMousePressed(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &, const ColorPickerWidget &); virtual void onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &, const ColorPickerWidget &); virtual void onMouseMoved(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &, const ColorPickerWidget &, bool); + + virtual void initialize(ui::ImageArea *); + virtual void onClear(); }; } diff --git a/IHM_Retouche_Photo/tools/selectionable/quad.cpp b/IHM_Retouche_Photo/tools/selectionable/quad.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dc4debd263431724793ead2f02343219ae00858d --- /dev/null +++ b/IHM_Retouche_Photo/tools/selectionable/quad.cpp @@ -0,0 +1,48 @@ +#include "quad.h" + +namespace tool { + Quad::Quad(const ColorPickerWidget & cp) + : Selectionable(cp, "Quadrilatère", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-quad.png"), true) { + + } + + void Quad::initialize(ui::ImageArea *) { + this->_polygon.clear(); + } + + void Quad::onMousePressed(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &, const ColorPickerWidget &) { + + } + + void Quad::onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint & clicked, const QImage &, const QMouseEvent & e, const ColorPickerWidget &) { + if(e.button() == Qt::LeftButton) { + if(this->_polygon.count() >= 4) { + this->_polygon.clear(); + } + this->_polygon << clicked; + } + } + + void Quad::onMouseMoved(ui::ImageArea &, ui::Selection & s, const QPoint & clicked, const QImage &, const QMouseEvent &, const ColorPickerWidget &, bool) { + s.clear(); + QPolygon poly = this->_polygon; + + if(this->_polygon.count() < 4) { + poly << clicked; + } + + QRect boundingBox = poly.boundingRect(); + for(int x = 0; x < boundingBox.width(); x++) { + for(int y = 0; y < boundingBox.height(); y++) { + QPoint p(boundingBox.x() + x, boundingBox.y() + y); + if(poly.containsPoint(p, Qt::FillRule::OddEvenFill)) { + s.select(p); + } + } + } + } + + void Quad::onClear() { + this->_polygon.clear(); + } +} diff --git a/IHM_Retouche_Photo/tools/selectionable/quad.h b/IHM_Retouche_Photo/tools/selectionable/quad.h new file mode 100644 index 0000000000000000000000000000000000000000..9bf980369c4b677d6e8280798e47bbd42031d64a --- /dev/null +++ b/IHM_Retouche_Photo/tools/selectionable/quad.h @@ -0,0 +1,22 @@ +#pragma once + +#include <QPolygon> + +#include "../selectionnable.h" + +namespace tool { + class Quad : public Selectionable { + private: + QPolygon _polygon; + + public: + Quad(const ColorPickerWidget &); + + virtual void onMousePressed(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &, const ColorPickerWidget &); + virtual void onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &, const ColorPickerWidget &); + virtual void onMouseMoved(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &, const ColorPickerWidget &, bool); + + virtual void initialize(ui::ImageArea *); + virtual void onClear(); + }; +} diff --git a/IHM_Retouche_Photo/tools/selectionnable.cpp b/IHM_Retouche_Photo/tools/selectionnable.cpp index aea2c1243c831cf46065115c3b0b556048916f47..13ded16c89c66505cd6ed69125cee63d74b8b468 100644 --- a/IHM_Retouche_Photo/tools/selectionnable.cpp +++ b/IHM_Retouche_Photo/tools/selectionnable.cpp @@ -4,8 +4,10 @@ namespace tool { Selectionable::Selectionable(const ColorPickerWidget & cp, const QString & name, const QIcon & icon, bool free) : Tool(name, icon), _colorPicker(&cp) ,_free(free) {} + void Selectionable::initialize(ui::ImageArea *) {} void Selectionable::onKeyPress(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent &, const ColorPickerWidget &) {} void Selectionable::onKeyReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent &, const ColorPickerWidget &) {} + void Selectionable::onClear() {}; void Selectionable::pressed(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QMouseEvent & e) { if(image.rect().contains(click) || this->_free) { @@ -32,4 +34,8 @@ namespace tool { void Selectionable::keyReleased(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QKeyEvent & e) { this->onKeyReleased(area, selection, click, image, e, *this->_colorPicker); } + + void Selectionable::selectionCleared() { + this->onClear(); + } } diff --git a/IHM_Retouche_Photo/tools/selectionnable.h b/IHM_Retouche_Photo/tools/selectionnable.h index cbbabcf55c7458e6c0e4199fb56dc8d2c3b6167b..68af877e6c8028268cc2752250325b0c208dcda5 100644 --- a/IHM_Retouche_Photo/tools/selectionnable.h +++ b/IHM_Retouche_Photo/tools/selectionnable.h @@ -22,6 +22,10 @@ namespace tool { virtual void onKeyPress(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent &, const ColorPickerWidget &); virtual void onKeyReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent &, const ColorPickerWidget &); + virtual void onClear(); + + virtual void initialize(ui::ImageArea *); + public slots: virtual void pressed(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &) final; virtual void released(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &) final; @@ -29,5 +33,7 @@ namespace tool { virtual void keyPressed(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QKeyEvent &) final; virtual void keyReleased(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QKeyEvent &) final; + + virtual void selectionCleared() final; }; } diff --git a/IHM_Retouche_Photo/tools/tool.h b/IHM_Retouche_Photo/tools/tool.h index 8917e0f6edf0c5355b8bee723aaab15385caffd2..6f355464cde80eb91bccf55830aac68929dd7973 100644 --- a/IHM_Retouche_Photo/tools/tool.h +++ b/IHM_Retouche_Photo/tools/tool.h @@ -23,6 +23,9 @@ namespace tool { inline void setCongigurationDialog(QDialog * dial) {this->_configurationDialog = dial;} + virtual void initialize(ui::ImageArea *) = 0; + + public slots: virtual void pressed(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &) = 0; virtual void released(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &) = 0; @@ -31,6 +34,8 @@ namespace tool { virtual void keyPressed(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QKeyEvent &) = 0; virtual void keyReleased(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QKeyEvent &) = 0; + virtual void selectionCleared() = 0; + void showConfiguration(); }; diff --git a/IHM_Retouche_Photo/ui/toolbox/toolRegister.cpp b/IHM_Retouche_Photo/ui/toolbox/toolRegister.cpp index accb5cf0562a2cbdd786f3d29ec33287177ac35b..e9810e92b2a01aa8bd25b032af6e614733a621d0 100644 --- a/IHM_Retouche_Photo/ui/toolbox/toolRegister.cpp +++ b/IHM_Retouche_Photo/ui/toolbox/toolRegister.cpp @@ -40,7 +40,9 @@ ToolboxRegister::ToolboxRegister(Toolbox * selectionToolbox, Toolbox * editToobl QObject::disconnect(this->_currentImage, SIGNAL(mouseMoved(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QMouseEvent&,bool)), this->_currentTool, SLOT(moved(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QMouseEvent&,bool))); QObject::disconnect(this->_currentImage, SIGNAL(keyboardPress(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&)), this->_currentTool, SLOT(keyPressed(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&))); - QObject::disconnect(this->_currentImage, SIGNAL(keyboardRelease(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&)), this->_currentTool, SLOT(keyReleased(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&))); + QObject::disconnect(this->_currentImage, SIGNAL(keyboardRelease(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&)), this->_currentTool, SLOT(keyReleased(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&))); + + QObject::disconnect(&this->_currentImage->selection(), SIGNAL(cleared()), this->_currentTool, SLOT(selectionCleared())); if(this->_currentTool->HaveConfigurationDialog()) { QObject::disconnect(this->_configButton, SIGNAL(released()), this->_currentTool, SLOT(showConfiguration())); @@ -58,6 +60,8 @@ ToolboxRegister::ToolboxRegister(Toolbox * selectionToolbox, Toolbox * editToobl QObject::connect(this->_currentImage, SIGNAL(keyboardPress(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&)), this->_currentTool, SLOT(keyPressed(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&))); QObject::connect(this->_currentImage, SIGNAL(keyboardRelease(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&)), this->_currentTool, SLOT(keyReleased(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&))); + QObject::connect(&this->_currentImage->selection(), SIGNAL(cleared()), this->_currentTool, SLOT(selectionCleared())); + QObject::connect(this->_configButton, SIGNAL(released()), this->_currentTool, SLOT(showConfiguration())); this->_configButton->setEnabled(this->_currentTool->HaveConfigurationDialog()); @@ -73,6 +77,8 @@ ToolboxRegister::ToolboxRegister(Toolbox * selectionToolbox, Toolbox * editToobl QObject::disconnect(this->_currentImage, SIGNAL(keyboardPress(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&)), this->_currentTool, SLOT(keyPressed(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&))); QObject::disconnect(this->_currentImage, SIGNAL(keyboardRelease(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&)), this->_currentTool, SLOT(keyReleased(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&))); + QObject::disconnect(&this->_currentImage->selection(), SIGNAL(cleared()), this->_currentTool, SLOT(selectionCleared())); + if(this->_currentTool->HaveConfigurationDialog()) { QObject::disconnect(this->_configButton, SIGNAL(released()), this->_currentTool, SLOT(showConfiguration())); } @@ -89,9 +95,13 @@ ToolboxRegister::ToolboxRegister(Toolbox * selectionToolbox, Toolbox * editToobl QObject::connect(this->_currentImage, SIGNAL(keyboardPress(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&)), this->_currentTool, SLOT(keyPressed(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&))); QObject::connect(this->_currentImage, SIGNAL(keyboardRelease(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&)), this->_currentTool, SLOT(keyReleased(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&))); + QObject::connect(&this->_currentImage->selection(), SIGNAL(cleared()), this->_currentTool, SLOT(selectionCleared())); + QObject::connect(this->_configButton, SIGNAL(released()), this->_currentTool, SLOT(showConfiguration())); this->_configButton->setEnabled(this->_currentTool->HaveConfigurationDialog()); + this->_currentTool->initialize(this->_currentImage); + } } } diff --git a/IHM_Retouche_Photo/ui/view/imagearea.h b/IHM_Retouche_Photo/ui/view/imagearea.h index 8d37a58e3f3a705ad26e85d2c871de7b1bc771ca..ed6d1376b42a30a875029f5228e0a322e60333f4 100644 --- a/IHM_Retouche_Photo/ui/view/imagearea.h +++ b/IHM_Retouche_Photo/ui/view/imagearea.h @@ -91,6 +91,7 @@ namespace ui { public slots: inline void changeModificationEmit(bool status) {this->_emitModification = status;} inline void changeModificationReceive(bool status) {this->_receiveModification = status;} + inline void clearSelection() {this->_selection.clear(false); this->repaint();} void increaseZoom(); void decreaseZoom(); diff --git a/IHM_Retouche_Photo/ui/view/selection.cpp b/IHM_Retouche_Photo/ui/view/selection.cpp index 38a737ae3f48d54d737e94c6542725fb482a159c..4b15fd00aa497d518a2413529c207e9a644bea55 100644 --- a/IHM_Retouche_Photo/ui/view/selection.cpp +++ b/IHM_Retouche_Photo/ui/view/selection.cpp @@ -99,7 +99,10 @@ namespace ui { } } - void Selection::clear() { + void Selection::clear(bool silent) { this->_pixels.clear(); + if(!silent) { + emit this->cleared(); + } } } diff --git a/IHM_Retouche_Photo/ui/view/selection.h b/IHM_Retouche_Photo/ui/view/selection.h index 9535ed0d5a4d7b83f789d09d988aac9a83e2e944..2042f2de06b12d9ef8f320351cbeef3acd33afdc 100644 --- a/IHM_Retouche_Photo/ui/view/selection.h +++ b/IHM_Retouche_Photo/ui/view/selection.h @@ -34,15 +34,15 @@ namespace ui { void invert(const QImage &); void invert(unsigned int, unsigned int); - inline bool contain(const QPoint & point) const {return this->_pixels.contains(point);}; inline bool empty() const {return this->_pixels.empty();} public slots: - void clear(); + void clear(bool silent = true); signals: void selected(const QPoint &); void unselected(const QPoint &); + void cleared(); }; }