diff --git a/IHM_Retouche_Photo/IHM_Retouche_Photo.pro b/IHM_Retouche_Photo/IHM_Retouche_Photo.pro index 36f8a75bbeae2f115c1dfefa2906e6520aa33848..55a805c04500365a67b903830c01da5da737bf43 100644 --- a/IHM_Retouche_Photo/IHM_Retouche_Photo.pro +++ b/IHM_Retouche_Photo/IHM_Retouche_Photo.pro @@ -15,6 +15,7 @@ SOURCES += \ main.cpp \ mainwindow.cpp \ tools/editable.cpp \ + tools/editable/pixelpainter.cpp \ tools/hand.cpp \ tools/selectionable/ellipse.cpp \ tools/selectionable/polygone.cpp \ @@ -23,6 +24,9 @@ SOURCES += \ tools/selectionable/triangle.cpp \ tools/selectionnable.cpp \ tools/tool.cpp \ + ui/effect/blackandwhite.cpp \ + ui/effect/contrast.cpp \ + ui/effect/effect.cpp \ ui/files/treefileselector.cpp \ ui/menu/displaymenulambda.cpp \ ui/menu/filemenulambda.cpp \ @@ -30,6 +34,8 @@ SOURCES += \ ui/menu/menubarmanager.cpp \ ui/toolbox/toolRegister.cpp \ ui/view/imagearea.cpp \ + ui/view/multyimagemodifier.cpp \ + ui/view/repercussion/ignore.cpp \ ui/view/selection.cpp \ ui/view/viewmanager.cpp @@ -39,6 +45,7 @@ HEADERS += \ dialog/resizedialog.h \ mainwindow.h \ tools/editable.h \ + tools/editable/pixelpainter.h \ tools/hand.h \ tools/selectionable/ellipse.h \ tools/selectionable/polygone.h \ @@ -47,6 +54,9 @@ HEADERS += \ tools/selectionable/triangle.h \ tools/selectionnable.h \ tools/tool.h \ + ui/effect/blackandwhite.h \ + ui/effect/contrast.h \ + ui/effect/effect.h \ ui/files/fileselector.h \ ui/files/treefileselector.h \ ui/menu/displaymenulambda.h \ @@ -55,6 +65,9 @@ HEADERS += \ ui/menu/menubarmanager.h \ ui/toolbox/toolRegister.h \ ui/view/imagearea.h \ + ui/view/multyimagemodifier.h \ + ui/view/repercussion/ignore.h \ + ui/view/repercussion/repercussion.h \ ui/view/selection.h \ ui/view/viewmanager.h diff --git a/IHM_Retouche_Photo/colorpickerwidget.cpp b/IHM_Retouche_Photo/colorpickerwidget.cpp index f249f91732f955a26cd2bad1b89dfd40892dbc5b..3c6bfed66ea36cba8a28a36fa1d856c01ed154cc 100644 --- a/IHM_Retouche_Photo/colorpickerwidget.cpp +++ b/IHM_Retouche_Photo/colorpickerwidget.cpp @@ -9,31 +9,79 @@ #include <QKeyEvent> ColorPickerWidget::ColorPickerWidget(QWidget *parent) - : QWidget(parent) { - QVBoxLayout *layout = new QVBoxLayout(this); + : QWidget(parent), _currentColor(QColorConstants::Black) { + this->_mainLayout = new QVBoxLayout(this); - colorListWidget = new QListWidget(this); - layout->addWidget(colorListWidget); + this->_colorListWidget = new QListWidget(this); + this->_mainLayout->addWidget(this->_colorListWidget); - QPushButton *addColorButton = new QPushButton("Add Color", this); - connect(addColorButton, &QPushButton::clicked, this, &ColorPickerWidget::addColor); - layout->addWidget(addColorButton); + this->_currentColorLayout = new QHBoxLayout(this); - QPushButton *pickColorButton = new QPushButton("Pick Color", this); - connect(pickColorButton, &QPushButton::clicked, this, &ColorPickerWidget::pickColor); - layout->addWidget(pickColorButton); + this->_currentColorLabel = new QLabel("Current Color :", this); + this->_currentColorLayout->addWidget(this->_currentColorLabel); + + this->_currentColorFrame = new QFrame(this); + this->_currentColorLayout->addWidget(this->_currentColorFrame); + + this->_mainLayout->addLayout(this->_currentColorLayout); + + this->_addColorButton = new QPushButton("Add Color", this); + QObject::connect(this->_addColorButton, &QPushButton::clicked, this, &ColorPickerWidget::addColor); + this->_mainLayout->addWidget(this->_addColorButton); + + this->_modifyColorButton = new QPushButton("Modify Color", this); + QObject::connect(this->_modifyColorButton, &QPushButton::clicked, this, &ColorPickerWidget::modifyColor); + this->_mainLayout->addWidget(this->_modifyColorButton); + + this->_chooseColorButton = new QPushButton("Finish", this); + QObject::connect(this->_chooseColorButton, &QPushButton::clicked, this, &ColorPickerWidget::close); + this->_mainLayout->addWidget(this->_chooseColorButton); + + this->setFrameColor(this->_currentColor); + + QObject::connect(this->_colorListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(chooseColor(QListWidgetItem*))); +} + +ColorPickerWidget::~ColorPickerWidget() { + delete this->_mainLayout; + delete this->_colorListWidget; + delete this->_currentColorLayout; + delete this->_currentColorLabel; + delete this->_currentColorFrame; + delete this->_addColorButton; + delete this->_modifyColorButton; + delete this->_chooseColorButton; +} + +void ColorPickerWidget::setCurrentColor(const QColor & color) { + if(color.isValid()) { + QListWidgetItem * item = new QListWidgetItem(this->_colorListWidget); + item->setBackground(QBrush(color)); + this->_currentColor = color; + this->setFrameColor(this->_currentColor); + } +} + + +void ColorPickerWidget::setFrameColor(const QColor & color) { + if(color.isValid()) { + QPalette palette; + palette.setColor(QPalette::Window, color); + this->_currentColorFrame->setAutoFillBackground(true); + this->_currentColorFrame->setPalette(palette); + } } void ColorPickerWidget::addColor() { QColor color = QColorDialog::getColor(Qt::white, this, "Select Color"); if (color.isValid()) { - QListWidgetItem *item = new QListWidgetItem(colorListWidget); + QListWidgetItem *item = new QListWidgetItem(this->_colorListWidget); item->setBackground(QBrush(color)); } } -void ColorPickerWidget::pickColor() { - QListWidgetItem *selectedItem = colorListWidget->currentItem(); +void ColorPickerWidget::modifyColor() { + QListWidgetItem * selectedItem = this->_colorListWidget->currentItem(); if (selectedItem) { QColor color = QColorDialog::getColor(selectedItem->background().color(), this, "Pick Color"); if (color.isValid()) { @@ -42,4 +90,14 @@ void ColorPickerWidget::pickColor() { } } +void ColorPickerWidget::chooseColor() { + this->_currentColor = this->_colorListWidget->currentItem()->background().color(); + this->setFrameColor(this->_currentColor); + this->close(); +} + +void ColorPickerWidget::chooseColor(QListWidgetItem * item) { + this->_currentColor = item->background().color(); + this->setFrameColor(this->_currentColor); +} diff --git a/IHM_Retouche_Photo/colorpickerwidget.h b/IHM_Retouche_Photo/colorpickerwidget.h index 7439b0f54053ce698978595289cd12353c974c32..d5097d6ea907cdb692018d8cf4e26e3926cdccf9 100644 --- a/IHM_Retouche_Photo/colorpickerwidget.h +++ b/IHM_Retouche_Photo/colorpickerwidget.h @@ -1,25 +1,43 @@ -#ifndef COLORPICKERWIDGET_H -#define COLORPICKERWIDGET_H +#pragma once #include <QColorDialog> #include <QListWidget> #include <QListWidgetItem> #include <QVBoxLayout> #include <QPushButton> +#include <QLabel> class ColorPickerWidget : public QWidget { Q_OBJECT + private: + QColor _currentColor; -public: - ColorPickerWidget(QWidget *parent = nullptr); + QVBoxLayout * _mainLayout; + QHBoxLayout * _currentColorLayout; -private slots: - void addColor(); - void pickColor(); + QListWidget * _colorListWidget; -private: - QListWidget *colorListWidget; -}; + QLabel * _currentColorLabel; + QFrame * _currentColorFrame; + + QPushButton * _addColorButton; + QPushButton * _modifyColorButton; + QPushButton * _chooseColorButton; + + protected: + void setFrameColor(const QColor &); + public: + ColorPickerWidget(QWidget *parent = nullptr); + ~ColorPickerWidget(); -#endif // COLORPICKERWIDGET_H + inline const QColor & currentColor() const {return this->_currentColor;} + void setCurrentColor(const QColor &); + + + private slots: + void addColor(); + void modifyColor(); + void chooseColor(); + void chooseColor(QListWidgetItem*); +}; diff --git a/IHM_Retouche_Photo/dialog/clip.cpp b/IHM_Retouche_Photo/dialog/clip.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8c787d327e58d251daca40282490d62c1ca8c8a1 --- /dev/null +++ b/IHM_Retouche_Photo/dialog/clip.cpp @@ -0,0 +1,14 @@ +#include "clip.h" +#include "ui_clip.h" + +Clip::Clip(QWidget *parent) + : QDialog(parent) + , ui(new Ui::Clip) +{ + ui->setupUi(this); +} + +Clip::~Clip() +{ + delete ui; +} diff --git a/IHM_Retouche_Photo/dialog/clip.h b/IHM_Retouche_Photo/dialog/clip.h new file mode 100644 index 0000000000000000000000000000000000000000..2c466a330613daea54b5bc1e1d97ca3440aa1126 --- /dev/null +++ b/IHM_Retouche_Photo/dialog/clip.h @@ -0,0 +1,22 @@ +#ifndef CLIP_H +#define CLIP_H + +#include <QDialog> + +namespace Ui { +class Clip; +} + +class Clip : public QDialog +{ + Q_OBJECT + +public: + explicit Clip(QWidget *parent = nullptr); + ~Clip(); + +private: + Ui::Clip *ui; +}; + +#endif // CLIP_H diff --git a/IHM_Retouche_Photo/dialog/clip.ui b/IHM_Retouche_Photo/dialog/clip.ui new file mode 100644 index 0000000000000000000000000000000000000000..62ab243353145afdfb85f308945b4cdcd98358e9 --- /dev/null +++ b/IHM_Retouche_Photo/dialog/clip.ui @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ClipDialog</class> + <widget class="QDialog" name="ClipDialog"> + <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> + <resources/> + <connections/> +</ui> diff --git a/IHM_Retouche_Photo/mainwindow.cpp b/IHM_Retouche_Photo/mainwindow.cpp index d20220598b000a9d1047165a71fb6fb058082507..72fe43d6f84ce42d4b09a2734d7679be0da609b7 100644 --- a/IHM_Retouche_Photo/mainwindow.cpp +++ b/IHM_Retouche_Photo/mainwindow.cpp @@ -22,6 +22,9 @@ #include <tools/selectionable/triangle.h> #include <tools/selectionable/ellipse.h> #include <tools/selectionable/polygone.h> +#include <tools/editable/pixelpainter.h> + +#include <ui/view/repercussion/ignore.h> MainWindow::MainWindow(QWidget * parent) : QMainWindow(parent), _toolRegister(), _fileselectorManager(nullptr), _viewManager(nullptr) { @@ -43,11 +46,11 @@ MainWindow::MainWindow(QWidget * parent) ColorWindow = this->_colorPicker; // Connect the button's clicked signal to the openColorPicker slot - connect(ColorWindow, &QPushButton::clicked, this, &MainWindow::openColorPicker); + QObject::connect(ColorWindow, &QPushButton::clicked, this, &MainWindow::openColorPicker); // Create an action for Ctrl+C ctrlCAction = new QAction(this); ctrlCAction->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_C)); // Change the shortcut - connect(ctrlCAction, &QAction::triggered, this, &MainWindow::handleCtrlCKey); + QObject::connect(ctrlCAction, &QAction::triggered, this, &MainWindow::handleCtrlCKey); addAction(ctrlCAction); qDebug() << "Mark_3"; @@ -56,28 +59,39 @@ 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(); + + qDebug() << "mark_5"; + this->_rescaleDialog = new dialog::ReScaleDialog(this->_viewManager); QObject::connect(this->_rescaleButton, SIGNAL(released()), this->_rescaleDialog, SLOT(use())); this->_resizeDialog = new dialog::ReSizeDialog(this->_viewManager); QObject::connect(this->_resizeButton, SIGNAL(released()), this->_resizeDialog, SLOT(use())); - qDebug() << "Mark_5"; - + qDebug() << "Mark_6"; this->_toolRegister.setToolbox(this->_toolbox); this->_toolRegister.setViewManager(this->_viewManager); - this->_toolRegister.push_back(QSharedPointer<tool::Tool>(new tool::Hand())); - this->_toolRegister.push_back(QSharedPointer<tool::Rectangle>(new tool::Rectangle())); - this->_toolRegister.push_back(QSharedPointer<tool::RectangleTriangle>(new tool::RectangleTriangle())); - this->_toolRegister.push_back(QSharedPointer<tool::Triangle>(new tool::Triangle())); - this->_toolRegister.push_back(QSharedPointer<tool::Ellipse>(new tool::Ellipse())); - this->_toolRegister.push_back(QSharedPointer<tool::Polygone>(new tool::Polygone())); + this->_toolRegister.push_back(QSharedPointer<tool::Tool>(new tool::Hand(this->colorPickerWidget))); + this->_toolRegister.push_back(QSharedPointer<tool::Rectangle>(new tool::Rectangle(this->colorPickerWidget))); + this->_toolRegister.push_back(QSharedPointer<tool::RectangleTriangle>(new tool::RectangleTriangle(this->colorPickerWidget))); + this->_toolRegister.push_back(QSharedPointer<tool::Triangle>(new tool::Triangle(this->colorPickerWidget))); + this->_toolRegister.push_back(QSharedPointer<tool::Ellipse>(new tool::Ellipse(this->colorPickerWidget))); + this->_toolRegister.push_back(QSharedPointer<tool::Polygone>(new tool::Polygone(this->colorPickerWidget))); + + this->_toolRegister.push_back(QSharedPointer<tool::Pixelpainter>(new tool::Pixelpainter(this->colorPickerWidget))); this->_toolRegister.update(); - qDebug() << "Mark_6"; + qDebug() << "Mark_7"; this->_menubarManager.insert(this->_menuFile, QSharedPointer<ui::MenuLambda>(new ui::FilemenuLambda(this->_fileselectorManager, this->_viewManager))); this->_menubarManager.insert(this->_menuAffichage, QSharedPointer<ui::MenuLambda>(new ui::DisplayMenuLambda(this->_viewManager))); @@ -118,7 +132,6 @@ MainWindow::MainWindow(QWidget * parent) connect(_actionDecreaseContrast, &QAction::triggered, this, &MainWindow::decreaseContrastActionTriggered); qDebug() << "Mark_8"; - } void MainWindow::dragEnterEvent(QDragEnterEvent *e) { @@ -130,9 +143,9 @@ void MainWindow::dragEnterEvent(QDragEnterEvent *e) { void MainWindow::dropEvent(QDropEvent * e) { this->_fileselectorManager->onDrop(e); } + void MainWindow::openColorPicker() { - colorPickerWidget.show(); } void MainWindow::handleCtrlCKey() @@ -143,16 +156,15 @@ void MainWindow::handleCtrlCKey() void MainWindow::convertToNoirEtBlancActionTriggered() { - ui::ImageArea *currentImageArea = dynamic_cast<ui::ImageArea *>(_imageTabs->currentWidget()); + ui::ImageArea *currentImageArea = this->_viewManager->currentView(); if (currentImageArea) { - currentImageArea->convertToNoirEtBlanc(); + currentImageArea->blackAndWhite(); } else { qDebug() << "Aucun onglet d'image actif."; } } void MainWindow::adjustBrightnessContrastActionTriggered() { - static bool isVisible = true; _actionAdjustBrightness->setVisible(isVisible); _actionDecreaseBrightness->setVisible(isVisible); @@ -160,16 +172,9 @@ void MainWindow::adjustBrightnessContrastActionTriggered() { _actionDecreaseContrast->setVisible(isVisible); isVisible = !isVisible; - -// ui::ImageArea *currentImageArea = dynamic_cast<ui::ImageArea *>(_imageTabs->currentWidget()); -// if (currentImageArea) { -// currentImageArea->adjustBrightnessContrast(1.2,1.5); -// } else { -// qDebug() << "Aucun onglet d'image actif."; -// } } void MainWindow::increaseBrightnessActionTriggered() { - ui::ImageArea *currentImageArea = dynamic_cast<ui::ImageArea *>(_imageTabs->currentWidget()); + ui::ImageArea *currentImageArea = this->_viewManager->currentView(); if (currentImageArea) { currentImageArea->increaseBrightness(); } else { @@ -177,7 +182,7 @@ void MainWindow::increaseBrightnessActionTriggered() { } } void MainWindow::decreaseBrightnessActionTriggered() { - ui::ImageArea *currentImageArea = dynamic_cast<ui::ImageArea *>(_imageTabs->currentWidget()); + ui::ImageArea *currentImageArea = this->_viewManager->currentView(); if (currentImageArea) { currentImageArea->decreaseBrightness(); } else { @@ -185,7 +190,7 @@ void MainWindow::decreaseBrightnessActionTriggered() { } } void MainWindow::increaseContrastActionTriggered() { - ui::ImageArea *currentImageArea = dynamic_cast<ui::ImageArea *>(_imageTabs->currentWidget()); + ui::ImageArea *currentImageArea = this->_viewManager->currentView(); if (currentImageArea) { currentImageArea->increaseContrast(); } else { @@ -193,7 +198,7 @@ void MainWindow::increaseContrastActionTriggered() { } } void MainWindow::decreaseContrastActionTriggered() { - ui::ImageArea *currentImageArea = dynamic_cast<ui::ImageArea *>(_imageTabs->currentWidget()); + ui::ImageArea *currentImageArea = this->_viewManager->currentView(); if (currentImageArea) { currentImageArea->decreaseContrast(); } else { @@ -201,11 +206,11 @@ void MainWindow::decreaseContrastActionTriggered() { } } - MainWindow::~MainWindow() { delete this->_fileselectorManager; delete this->_viewManager; delete this->_rescaleDialog; delete this->_resizeDialog; + delete this->_multyImageModifier; } diff --git a/IHM_Retouche_Photo/mainwindow.h b/IHM_Retouche_Photo/mainwindow.h index 4f68367cdd85ae5d1c509dc658d847c93fd460a5..4b7db4f9717a7da62a180aeb8c0cd9353ec0def3 100644 --- a/IHM_Retouche_Photo/mainwindow.h +++ b/IHM_Retouche_Photo/mainwindow.h @@ -9,6 +9,7 @@ #include "ui/menu/menubarmanager.h" #include "ui/files/fileselector.h" #include "ui/view/viewmanager.h" +#include "ui/view/multyimagemodifier.h" #include "dialog/rescaledialog.h" #include "dialog/resizedialog.h" @@ -25,11 +26,11 @@ class MainWindow : public QMainWindow, private Ui::MainWindow { ui::FileSelector * _fileselectorManager; ui::ViewManager * _viewManager; + ui::MultyImageModifier * _multyImageModifier; dialog::ReScaleDialog * _rescaleDialog; dialog::ReSizeDialog * _resizeDialog; - ColorPickerWidget colorPickerWidget; // Declare ColorPickerWidget as a private member QPushButton *ColorWindow; // Assuming you have a QPushButton in your UI QAction *ctrlCAction; // New QAction for Ctrl+C diff --git a/IHM_Retouche_Photo/mainwindow.ui b/IHM_Retouche_Photo/mainwindow.ui index 168f0b7e1bc5b759a07838f672aa5f0399f0fc4b..eead692afff98a21f8ec5cab78dd7cc070654255 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>1026</width> - <height>541</height> + <width>992</width> + <height>613</height> </rect> </property> <property name="windowTitle"> @@ -31,64 +31,94 @@ <number>0</number> </property> <item> - <layout class="QVBoxLayout" name="_utilitaryLayout"> - <property name="spacing"> - <number>0</number> + <widget class="QSplitter" name="_mainSpliter"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> - <item> - <layout class="QVBoxLayout" name="verticalLayout"> + <property name="frameShape"> + <enum>QFrame::NoFrame</enum> + </property> + <property name="lineWidth"> + <number>3</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <widget class="QWidget" name="_fileWidget" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> <property name="spacing"> <number>0</number> </property> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> <item> - <widget class="QTreeView" name="_filesSelector"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="statusTip"> - <string/> - </property> - <property name="accessibleName"> - <string/> - </property> - <property name="autoFillBackground"> - <bool>false</bool> - </property> - <property name="frameShape"> - <enum>QFrame::HLine</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Plain</enum> - </property> - <property name="lineWidth"> - <number>0</number> - </property> - <property name="dragEnabled"> - <bool>false</bool> - </property> - <property name="textElideMode"> - <enum>Qt::ElideRight</enum> - </property> - <attribute name="headerDefaultSectionSize"> - <number>57</number> - </attribute> - <attribute name="headerHighlightSections"> - <bool>false</bool> - </attribute> - </widget> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout_2"> + <layout class="QVBoxLayout" name="_filesArea"> <property name="spacing"> <number>0</number> </property> + <item> + <widget class="QTreeView" name="_filesSelector"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="statusTip"> + <string/> + </property> + <property name="accessibleName"> + <string/> + </property> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + <property name="frameShape"> + <enum>QFrame::HLine</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Plain</enum> + </property> + <property name="lineWidth"> + <number>0</number> + </property> + <property name="dragEnabled"> + <bool>false</bool> + </property> + <property name="textElideMode"> + <enum>Qt::ElideRight</enum> + </property> + <attribute name="headerDefaultSectionSize"> + <number>57</number> + </attribute> + <attribute name="headerHighlightSections"> + <bool>false</bool> + </attribute> + </widget> + </item> <item> <widget class="QListWidget" name="_filesSelected"> <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <sizepolicy hsizetype="Minimum" vsizetype="Maximum"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> @@ -129,26 +159,16 @@ </widget> </item> <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> + <layout class="QHBoxLayout" name="_selectableArea"> <property name="spacing"> - <number>0</number> + <number>64</number> + </property> + <property name="leftMargin"> + <number>32</number> + </property> + <property name="rightMargin"> + <number>32</number> </property> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Minimum</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> <item> <widget class="QPushButton" name="_add_selectable_element"> <property name="toolTip"> @@ -169,22 +189,6 @@ </property> </widget> </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Minimum</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> <item> <widget class="QPushButton" name="_remove_selectable_element"> <property name="toolTip"> @@ -205,244 +209,329 @@ </property> </widget> </item> - <item> - <spacer name="horizontalSpacer_3"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Minimum</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> </layout> </item> </layout> </item> </layout> - </item> - </layout> - </item> - <item> - <layout class="QVBoxLayout" name="_imageLayout"> - <item> - <widget class="QTabWidget" name="_imageTabs"> - <property name="cursor"> - <cursorShape>OpenHandCursor</cursorShape> - </property> - <property name="mouseTracking"> - <bool>true</bool> - </property> - <property name="tabPosition"> - <enum>QTabWidget::North</enum> - </property> - <property name="tabShape"> - <enum>QTabWidget::Rounded</enum> - </property> - <property name="currentIndex"> + </widget> + <widget class="QWidget" name="_imageWidget" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="spacing"> <number>0</number> </property> - <property name="elideMode"> - <enum>Qt::ElideRight</enum> - </property> - <property name="documentMode"> - <bool>false</bool> + <property name="leftMargin"> + <number>0</number> </property> - <property name="tabsClosable"> - <bool>true</bool> + <property name="topMargin"> + <number>0</number> </property> - <property name="movable"> - <bool>true</bool> + <property name="rightMargin"> + <number>0</number> </property> - <property name="tabBarAutoHide"> - <bool>false</bool> + <property name="bottomMargin"> + <number>0</number> </property> - <widget class="QWidget" name="_imageTabs_1"> - <attribute name="icon"> - <iconset> - <normaloff>:/image/oxygen/icons/16x16/ressource/image/oxygen/icons/16x16/preferences-system.png</normaloff>:/image/oxygen/icons/16x16/ressource/image/oxygen/icons/16x16/preferences-system.png</iconset> - </attribute> - <attribute name="title"> - <string>Blank</string> - </attribute> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="spacing"> - <number>0</number> - </property> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> + <item> + <layout class="QVBoxLayout" name="_imageLayout"> <item> - <widget class="QGraphicsView" name="_imageView"> - <property name="cursor" stdset="0"> - <cursorShape>CrossCursor</cursorShape> + <widget class="QTabWidget" name="_imageTabs"> + <property name="cursor"> + <cursorShape>OpenHandCursor</cursorShape> </property> <property name="mouseTracking"> <bool>true</bool> </property> - <property name="frameShape"> - <enum>QFrame::NoFrame</enum> + <property name="tabPosition"> + <enum>QTabWidget::North</enum> </property> - <property name="frameShadow"> - <enum>QFrame::Plain</enum> + <property name="tabShape"> + <enum>QTabWidget::Rounded</enum> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <property name="elideMode"> + <enum>Qt::ElideRight</enum> </property> + <property name="documentMode"> + <bool>false</bool> + </property> + <property name="tabsClosable"> + <bool>true</bool> + </property> + <property name="movable"> + <bool>true</bool> + </property> + <property name="tabBarAutoHide"> + <bool>false</bool> + </property> + <widget class="QWidget" name="_imageTabs_1"> + <attribute name="icon"> + <iconset> + <normaloff>:/image/oxygen/icons/16x16/ressource/image/oxygen/icons/16x16/preferences-system.png</normaloff>:/image/oxygen/icons/16x16/ressource/image/oxygen/icons/16x16/preferences-system.png</iconset> + </attribute> + <attribute name="title"> + <string>Blank</string> + </attribute> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="spacing"> + <number>0</number> + </property> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QGraphicsView" name="_imageView"> + <property name="cursor" stdset="0"> + <cursorShape>CrossCursor</cursorShape> + </property> + <property name="mouseTracking"> + <bool>true</bool> + </property> + <property name="frameShape"> + <enum>QFrame::NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Plain</enum> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="_imageTabs_2"> + <attribute name="title"> + <string>Tab 2</string> + </attribute> + </widget> </widget> </item> </layout> - </widget> - <widget class="QWidget" name="_imageTabs_2"> - <attribute name="title"> - <string>Tab 2</string> - </attribute> - </widget> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QVBoxLayout" name="_toolLayout"> - <property name="spacing"> - <number>0</number> - </property> - <item> - <layout class="QHBoxLayout" name="_globalTool"> - <property name="spacing"> - <number>0</number> - </property> - <item> - <widget class="QPushButton" name="_colorPicker"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - <property name="icon"> - <iconset resource="ressource.qrc"> - <normaloff>:/oxygen/64x64/ressource/image/oxygen/icons/64x64/preferences-desktop-color.png</normaloff>:/oxygen/64x64/ressource/image/oxygen/icons/64x64/preferences-desktop-color.png</iconset> - </property> - <property name="iconSize"> - <size> - <width>32</width> - <height>32</height> - </size> - </property> - <property name="flat"> - <bool>false</bool> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="_rescaleButton"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - <property name="icon"> - <iconset resource="ressource.qrc"> - <normaloff>:/oxygen/64x64/ressource/image/oxygen/icons/64x64/transform-scale.png</normaloff>:/oxygen/64x64/ressource/image/oxygen/icons/64x64/transform-scale.png</iconset> - </property> - <property name="iconSize"> - <size> - <width>32</width> - <height>32</height> - </size> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="_resizeButton"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - <property name="icon"> - <iconset resource="ressource.qrc"> - <normaloff>:/oxygen/64x64/ressource/image/oxygen/icons/64x64/transform-crop-and-resize.png</normaloff>:/oxygen/64x64/ressource/image/oxygen/icons/64x64/transform-crop-and-resize.png</iconset> - </property> - <property name="iconSize"> - <size> - <width>32</width> - <height>32</height> - </size> - </property> - </widget> </item> </layout> - </item> - <item> - <widget class="QListWidget" name="_toolbox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="cursor" stdset="0"> - <cursorShape>PointingHandCursor</cursorShape> - </property> - <property name="toolTip"> - <string/> - </property> - <property name="statusTip"> - <string/> - </property> - <property name="frameShape"> - <enum>QFrame::NoFrame</enum> - </property> - <property name="tabKeyNavigation"> - <bool>true</bool> - </property> - <property name="alternatingRowColors"> - <bool>true</bool> + </widget> + <widget class="QWidget" name="_toolWidget" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <property name="leftMargin"> + <number>0</number> </property> - <property name="iconSize"> - <size> - <width>16</width> - <height>16</height> - </size> + <property name="topMargin"> + <number>0</number> </property> - <property name="sortingEnabled"> - <bool>true</bool> + <property name="rightMargin"> + <number>0</number> </property> - </widget> - </item> - <item> - <layout class="QVBoxLayout" name="_toolParameterLayout"> - <property name="spacing"> + <property name="bottomMargin"> <number>0</number> </property> + <item> + <layout class="QVBoxLayout" name="_toolLayout"> + <property name="spacing"> + <number>0</number> + </property> + <item> + <layout class="QHBoxLayout" name="_globalTool"> + <property name="spacing"> + <number>0</number> + </property> + <item> + <widget class="QPushButton" name="_colorPicker"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="statusTip"> + <string>Change la couleur courante.</string> + </property> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset resource="ressource.qrc"> + <normaloff>:/oxygen/64x64/ressource/image/oxygen/icons/64x64/preferences-desktop-color.png</normaloff>:/oxygen/64x64/ressource/image/oxygen/icons/64x64/preferences-desktop-color.png</iconset> + </property> + <property name="iconSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + <property name="flat"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="_rescaleButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="statusTip"> + <string>Change la taille de l'image courante.</string> + </property> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset resource="ressource.qrc"> + <normaloff>:/oxygen/64x64/ressource/image/oxygen/icons/64x64/transform-scale.png</normaloff>:/oxygen/64x64/ressource/image/oxygen/icons/64x64/transform-scale.png</iconset> + </property> + <property name="iconSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="_resizeButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="statusTip"> + <string>Permet de rogner l'image courante.</string> + </property> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset resource="ressource.qrc"> + <normaloff>:/oxygen/64x64/ressource/image/oxygen/icons/64x64/transform-crop-and-resize.png</normaloff>:/oxygen/64x64/ressource/image/oxygen/icons/64x64/transform-crop-and-resize.png</iconset> + </property> + <property name="iconSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="_toolParameterLayout"> + <property name="spacing"> + <number>0</number> + </property> + <item> + <widget class="QListWidget" name="_toolbox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="cursor" stdset="0"> + <cursorShape>PointingHandCursor</cursorShape> + </property> + <property name="toolTip"> + <string/> + </property> + <property name="statusTip"> + <string/> + </property> + <property name="frameShape"> + <enum>QFrame::NoFrame</enum> + </property> + <property name="tabKeyNavigation"> + <bool>true</bool> + </property> + <property name="alternatingRowColors"> + <bool>true</bool> + </property> + <property name="iconSize"> + <size> + <width>16</width> + <height>16</height> + </size> + </property> + <property name="sortingEnabled"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <layout class="QVBoxLayout" name="_multyDrawArea"> + <property name="leftMargin"> + <number>16</number> + </property> + <property name="topMargin"> + <number>8</number> + </property> + <property name="rightMargin"> + <number>16</number> + </property> + <property name="bottomMargin"> + <number>8</number> + </property> + <item> + <widget class="QCheckBox" name="_emitDrawCheckbox"> + <property name="statusTip"> + <string>Permet à image courante de modifier toutes les autres images modifiable.</string> + </property> + <property name="text"> + <string>Modifie les autres Image</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="_receiveDrawCheckbox"> + <property name="statusTip"> + <string>Permet de laisser l'image courante être modifié par les autres images.</string> + </property> + <property name="text"> + <string>Modifiable par les autres Image</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <property name="tristate"> + <bool>false</bool> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="_samplingDrawCombobox"/> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </item> </layout> - </item> - </layout> + </widget> + </widget> </item> </layout> </widget> @@ -451,8 +540,8 @@ <rect> <x>0</x> <y>0</y> - <width>1026</width> - <height>22</height> + <width>992</width> + <height>21</height> </rect> </property> <widget class="QMenu" name="_menuFile"> @@ -986,5 +1075,22 @@ <resources> <include location="ressource.qrc"/> </resources> - <connections/> + <connections> + <connection> + <sender>_receiveDrawCheckbox</sender> + <signal>toggled(bool)</signal> + <receiver>_samplingDrawCombobox</receiver> + <slot>setEnabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>702</x> + <y>542</y> + </hint> + <hint type="destinationlabel"> + <x>698</x> + <y>575</y> + </hint> + </hints> + </connection> + </connections> </ui> diff --git a/IHM_Retouche_Photo/tools/brush.cpp b/IHM_Retouche_Photo/tools/brush.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b6d3dcd8424bc0ad1918627a8b9936bdfdf61c53 --- /dev/null +++ b/IHM_Retouche_Photo/tools/brush.cpp @@ -0,0 +1,19 @@ +#include "brush.h" + +#include <QDebug> + +namespace tool { + Brush::Brush() + : Tool("Brush", QIcon(":/image/test/icons/16x16/ressource/image/test/icons/16x16/Circle.png")) { + + } + + Brush::Brush(QListWidget *) + : Tool("Brush", QIcon(":/image/test/icons/16x16/ressource/image/test/icons/16x16/Circle.png")) { + + } + + void Brush::use() const { + qDebug() << "Hello Brush"; + } +} diff --git a/IHM_Retouche_Photo/tools/brush.h b/IHM_Retouche_Photo/tools/brush.h new file mode 100644 index 0000000000000000000000000000000000000000..50059f8efd4818aae9306c5b0e8175c44045aaba --- /dev/null +++ b/IHM_Retouche_Photo/tools/brush.h @@ -0,0 +1,13 @@ +#pragma once + +#include "tool.h" + +namespace tool { + class Brush : public Tool { + public: + Brush(QListWidget *); + Brush(); + virtual void use() const; + }; +} + diff --git a/IHM_Retouche_Photo/tools/editable.cpp b/IHM_Retouche_Photo/tools/editable.cpp index 3ca01adfa30adc25dbe7df9568d7ab49efbc1f06..1f12669acee8f86063b9295958db3ff60badc075 100644 --- a/IHM_Retouche_Photo/tools/editable.cpp +++ b/IHM_Retouche_Photo/tools/editable.cpp @@ -1,35 +1,35 @@ #include "editable.h" namespace tool { - Editable::Editable(const QString & name, const QIcon & icon,bool free) - : Tool(name, icon), _free(free) {} + Editable::Editable(const ColorPickerWidget & cp, const QString & name, const QIcon & icon,bool free) + : Tool(name, icon), _colorPicker(&cp), _free(free) {} - void Editable::onKeyPress(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QKeyEvent &) {} - void Editable::onKeyReleased(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QKeyEvent &) {} + 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 &) {} void Editable::pressed(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QMouseEvent & e) { if(image.rect().contains(click) || this->_free) { - this->onMousePressed(area, image, click, selection, e); + this->onMousePressed(area, image, click, selection, e, *this->_colorPicker); } } void Editable::released(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QMouseEvent & e) { if(image.rect().contains(click) || this->_free) { - this->onMouseReleased(area, image, click, selection, e); + this->onMouseReleased(area, image, click, selection, e, *this->_colorPicker); } } void Editable::moved(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QMouseEvent & e, bool hold) { if(image.rect().contains(click) || this->_free) { - this->onMouseMoved(area, image, click, selection, e, hold); + this->onMouseMoved(area, image, click, selection, e, *this->_colorPicker, hold); } } void Editable::keyPressed(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QKeyEvent & e) { - this->onKeyPress(area, image, click, selection, e); + this->onKeyPress(area, image, click, selection, e, *this->_colorPicker); } void Editable::keyReleased(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QKeyEvent & e) { - this->onKeyReleased(area, image, click, selection, e); + this->onKeyReleased(area, image, click, selection, e, *this->_colorPicker); } } diff --git a/IHM_Retouche_Photo/tools/editable.h b/IHM_Retouche_Photo/tools/editable.h index 03ebf863606da6782a04cc8a8b70db27efb0ccb4..48a8512e50f185dec830f793f923dd15ef254190 100644 --- a/IHM_Retouche_Photo/tools/editable.h +++ b/IHM_Retouche_Photo/tools/editable.h @@ -2,20 +2,23 @@ #include "tool.h" +#include "colorpickerwidget.h" + namespace tool { class Editable : public Tool { private: + const ColorPickerWidget * _colorPicker; bool _free; public: - Editable(const QString & = "NaN", const QIcon & = QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-freehand.png"), bool = false); + Editable(const ColorPickerWidget &, const QString & = "NaN", const QIcon & = QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-freehand.png"), bool = false); - virtual void onMousePressed(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &) = 0; - virtual void onMouseReleased(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &) = 0; - virtual void onMouseMoved(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &, bool) = 0; + virtual void onMousePressed(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &, const ColorPickerWidget &) = 0; + virtual void onMouseReleased(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &, const ColorPickerWidget &) = 0; + virtual void onMouseMoved(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &, const ColorPickerWidget &, bool) = 0; - virtual void onKeyPress(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QKeyEvent &); - virtual void onKeyReleased(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QKeyEvent &); + 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 &); public slots: virtual void pressed(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &) final; diff --git a/IHM_Retouche_Photo/tools/editable/pixelpainter.cpp b/IHM_Retouche_Photo/tools/editable/pixelpainter.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9339d8a96e8a378bc4785a0d4e3a687c1de126a2 --- /dev/null +++ b/IHM_Retouche_Photo/tools/editable/pixelpainter.cpp @@ -0,0 +1,24 @@ +#include "pixelpainter.h" + +namespace tool { + Pixelpainter::Pixelpainter(const ColorPickerWidget & cp) + : Editable(cp, "Pixel", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/application-pgp-signature.png")), _leftButton(false) {} + + void Pixelpainter::onMousePressed(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e, const ColorPickerWidget &) { + if(e.button() == Qt::LeftButton) { + this->_leftButton = true; + } + } + + void Pixelpainter::onMouseReleased(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e, const ColorPickerWidget &) { + if(e.button() == Qt::LeftButton) { + this->_leftButton = false; + } + } + + void Pixelpainter::onMouseMoved(ui::ImageArea & a, QImage & , const QPoint & p, const ui::Selection &, const QMouseEvent &, const ColorPickerWidget & cp, bool hold) { + if(hold && this->_leftButton) { + a.setColor(p, cp.currentColor()); + } + } +} diff --git a/IHM_Retouche_Photo/tools/editable/pixelpainter.h b/IHM_Retouche_Photo/tools/editable/pixelpainter.h new file mode 100644 index 0000000000000000000000000000000000000000..0ecdbc88573991c8f464ef4da382e9b5e366e84a --- /dev/null +++ b/IHM_Retouche_Photo/tools/editable/pixelpainter.h @@ -0,0 +1,17 @@ +#pragma once + +#include "../editable.h" + +namespace tool { + class Pixelpainter : public Editable { + private: + bool _leftButton; + + public: + Pixelpainter(const ColorPickerWidget &); + + virtual void onMousePressed(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &, const ColorPickerWidget &); + virtual void onMouseReleased(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &, const ColorPickerWidget &); + virtual void onMouseMoved(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &, const ColorPickerWidget &, bool); + }; +} diff --git a/IHM_Retouche_Photo/tools/hand.cpp b/IHM_Retouche_Photo/tools/hand.cpp index 24f6fbbced6ecb777de2ccd6b0797703daa3addc..445b64608bd3c6537cbedabd1298b4d56251b4d7 100644 --- a/IHM_Retouche_Photo/tools/hand.cpp +++ b/IHM_Retouche_Photo/tools/hand.cpp @@ -1,17 +1,17 @@ #include "hand.h" namespace tool { - Hand::Hand() - : Editable("Main", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/transform-move.png"), true), _leftButton(false) {} + Hand::Hand(const ColorPickerWidget & cp) + : Editable(cp, "Main", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/transform-move.png"), true), _leftButton(false) {} - void Hand::onMousePressed(ui::ImageArea & area, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e) { + void Hand::onMousePressed(ui::ImageArea & area, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e, const ColorPickerWidget &) { if(e.button() == Qt::LeftButton) { area.setCursor(QCursor(Qt::CursorShape::ClosedHandCursor)); this->_leftButton = true; } } - void Hand::onMouseReleased(ui::ImageArea & area, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e) { + void Hand::onMouseReleased(ui::ImageArea & area, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e, const ColorPickerWidget &) { if(e.button() == Qt::LeftButton) { area.setCursor(QCursor(Qt::CursorShape::OpenHandCursor)); area.setLast_Positon(e.pos()); @@ -19,7 +19,7 @@ namespace tool { } } - void Hand::onMouseMoved(ui::ImageArea & area, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e, bool hold) { + void Hand::onMouseMoved(ui::ImageArea & area, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e, const ColorPickerWidget &, bool hold) { if(hold && this->_leftButton) { QPoint move = e.pos() - area.last_position(); area.setPosition(QPoint(area.position().x() + move.x(),area.position().y() + move.y())); diff --git a/IHM_Retouche_Photo/tools/hand.h b/IHM_Retouche_Photo/tools/hand.h index cf0bfbf39c46eec3fde138329b0a4e83b7f8329c..b9a44ca24ff89e9dde333920d46bfd2f1eacdec4 100644 --- a/IHM_Retouche_Photo/tools/hand.h +++ b/IHM_Retouche_Photo/tools/hand.h @@ -8,12 +8,12 @@ namespace tool { bool _leftButton; public: - Hand(); + Hand(const ColorPickerWidget &); inline virtual Qt::CursorShape shape() const {return Qt::CursorShape::OpenHandCursor;} - virtual void onMousePressed(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &); - virtual void onMouseReleased(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &); - virtual void onMouseMoved(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &, bool); + virtual void onMousePressed(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &, const ColorPickerWidget &); + virtual void onMouseReleased(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &, const ColorPickerWidget &); + virtual void onMouseMoved(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &, const ColorPickerWidget &, bool); }; } diff --git a/IHM_Retouche_Photo/tools/selectionable.cpp b/IHM_Retouche_Photo/tools/selectionable.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9e396a2c6dc397efe24814e37b9578d2147ec566 --- /dev/null +++ b/IHM_Retouche_Photo/tools/selectionable.cpp @@ -0,0 +1,5 @@ +#include "selectionable.h" + +Selectionable::Selectionable() { + +} diff --git a/IHM_Retouche_Photo/tools/selectionable.h b/IHM_Retouche_Photo/tools/selectionable.h new file mode 100644 index 0000000000000000000000000000000000000000..e8127f5a907eae19f108717a98bb235b02d87dca --- /dev/null +++ b/IHM_Retouche_Photo/tools/selectionable.h @@ -0,0 +1,19 @@ +#pragma once + +#include "tool.h" +#include "../ui/view/selection.h" + +namespace tool { + class Selectionable : public Tool { + private: + const QString _name; + const QIcon _icon; + + protected: + void onPressed(ui::Selection *); + void onreleased(ui::Selection *); + + public: + Selectionable(const QString &, const QIcon &); + }; +} diff --git a/IHM_Retouche_Photo/tools/selectionable/ellipse.cpp b/IHM_Retouche_Photo/tools/selectionable/ellipse.cpp index 4baaba8e28456c16dc3bb11134a6def897b417ba..5bc5d3e6ae1f0f06f6b6444ce8f3734bd4fd7977 100644 --- a/IHM_Retouche_Photo/tools/selectionable/ellipse.cpp +++ b/IHM_Retouche_Photo/tools/selectionable/ellipse.cpp @@ -1,12 +1,12 @@ #include "ellipse.h" namespace tool { - Ellipse::Ellipse() - : Selectionable("Elipse", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-ellipse.png"), true), _clicked(0,0), _hold(false), _multy(false) { + Ellipse::Ellipse(const ColorPickerWidget & cp) + : Selectionable(cp, "Elipse", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-ellipse.png"), true), _clicked(0,0), _hold(false), _multy(false) { } - void Ellipse::onMousePressed(ui::ImageArea &, ui::Selection & s, const QPoint & clicked, const QImage &, const QMouseEvent & e) { + void Ellipse::onMousePressed(ui::ImageArea &, ui::Selection & s, const QPoint & clicked, const QImage &, const QMouseEvent & e, const ColorPickerWidget &) { if(!this->_multy) { s.clear(); } @@ -17,13 +17,13 @@ namespace tool { } } - void Ellipse::onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent & e) { + void Ellipse::onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent & e, const ColorPickerWidget &) { if(e.button() == Qt::LeftButton) { this->_hold = false; } } - void Ellipse::onMouseMoved(ui::ImageArea &, ui::Selection & s, const QPoint & c, const QImage & img, const QMouseEvent &, bool) { + void Ellipse::onMouseMoved(ui::ImageArea &, ui::Selection & s, const QPoint & c, const QImage & img, const QMouseEvent &, const ColorPickerWidget &, bool) { if(this->_hold) { s.clear(); QVector<QPoint> selection; @@ -63,14 +63,14 @@ namespace tool { } } - void Ellipse::onKeyPress(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent & e) { + void Ellipse::onKeyPress(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent & e, const ColorPickerWidget &) { if(e.key() == Qt::Key_Control) { this->_multy = true; qDebug() << "ctrl"; } } - void Ellipse::onKeyReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent & e) { + void Ellipse::onKeyReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent & e, const ColorPickerWidget &) { if(e.key() == Qt::Key_Control) { this->_multy = false; } diff --git a/IHM_Retouche_Photo/tools/selectionable/ellipse.h b/IHM_Retouche_Photo/tools/selectionable/ellipse.h index dab06ab5280b48663113af7b0857b01d37abfe95..de129168a18792f134464c1f49b508f00bf8873d 100644 --- a/IHM_Retouche_Photo/tools/selectionable/ellipse.h +++ b/IHM_Retouche_Photo/tools/selectionable/ellipse.h @@ -10,13 +10,13 @@ namespace tool { bool _multy; public: - Ellipse(); + Ellipse(const ColorPickerWidget &); - virtual void onMousePressed(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &); - virtual void onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &); - virtual void onMouseMoved(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &, bool); + 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 onKeyPress(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent &); - virtual void onKeyReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent &); + 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 &); }; } diff --git a/IHM_Retouche_Photo/tools/selectionable/polygone.cpp b/IHM_Retouche_Photo/tools/selectionable/polygone.cpp index 2b1c83873d7b831a479cf2628e701c8479750087..0686566cfa4e4679a5299a742da4f32527726091 100644 --- a/IHM_Retouche_Photo/tools/selectionable/polygone.cpp +++ b/IHM_Retouche_Photo/tools/selectionable/polygone.cpp @@ -1,16 +1,16 @@ #include "polygone.h" namespace tool { - Polygone::Polygone() - : Selectionable("Polygone", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-polygon.png"), true), _preview(true) { + Polygone::Polygone(const ColorPickerWidget & cp) + : Selectionable(cp, "Polygone", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-polygon.png"), true), _preview(true) { } - void Polygone::onMousePressed(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &) { + void Polygone::onMousePressed(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &, const ColorPickerWidget &) { } - void Polygone::onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint & clicked, const QImage &, const QMouseEvent & e) { + void Polygone::onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint & clicked, const QImage &, const QMouseEvent & e, const ColorPickerWidget &) { if(e.button() == Qt::LeftButton) { if(this->_preview == false) { this->_polygon.clear(); @@ -23,7 +23,7 @@ namespace tool { } } - void Polygone::onMouseMoved(ui::ImageArea &, ui::Selection & s, const QPoint & clicked, const QImage &, const QMouseEvent &, bool) { + void Polygone::onMouseMoved(ui::ImageArea &, ui::Selection & s, const QPoint & clicked, const QImage &, const QMouseEvent &, const ColorPickerWidget &, bool) { s.clear(); QPolygon poly = this->_polygon; diff --git a/IHM_Retouche_Photo/tools/selectionable/polygone.h b/IHM_Retouche_Photo/tools/selectionable/polygone.h index fb4bf6524678d6fa3e61f7ccd5d84188d51b0041..922df6b58206abad6fe08c1430b1e6920c373ff7 100644 --- a/IHM_Retouche_Photo/tools/selectionable/polygone.h +++ b/IHM_Retouche_Photo/tools/selectionable/polygone.h @@ -9,10 +9,10 @@ namespace tool { bool _preview; public: - Polygone(); + Polygone(const ColorPickerWidget &); - virtual void onMousePressed(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &); - virtual void onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &); - virtual void onMouseMoved(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &, bool); + 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); }; } diff --git a/IHM_Retouche_Photo/tools/selectionable/rectangle.cpp b/IHM_Retouche_Photo/tools/selectionable/rectangle.cpp index e77915d58a36f861b7300dd8534ba507afd4d2c9..5b379908f590e965282ce037d6115d308c25eb21 100644 --- a/IHM_Retouche_Photo/tools/selectionable/rectangle.cpp +++ b/IHM_Retouche_Photo/tools/selectionable/rectangle.cpp @@ -1,12 +1,12 @@ #include "rectangle.h" namespace tool { - Rectangle::Rectangle() - : Selectionable("Rectangle", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-rectangle.png"), true), _clicked(0,0), _hold(false), _multy(false) { + Rectangle::Rectangle(const ColorPickerWidget & cp) + : Selectionable(cp, "Rectangle", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-rectangle.png"), true), _clicked(0,0), _hold(false), _multy(false) { } - void Rectangle::onMousePressed(ui::ImageArea &, ui::Selection & s, const QPoint & clicked, const QImage &, const QMouseEvent & e) { + void Rectangle::onMousePressed(ui::ImageArea &, ui::Selection & s, const QPoint & clicked, const QImage &, const QMouseEvent & e, const ColorPickerWidget &) { if(!this->_multy) { s.clear(); } @@ -17,13 +17,13 @@ namespace tool { } } - void Rectangle::onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent & e) { + void Rectangle::onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent & e, const ColorPickerWidget &) { if(e.button() == Qt::LeftButton) { this->_hold = false; } } - void Rectangle::onMouseMoved(ui::ImageArea &, ui::Selection & s, const QPoint & c, const QImage &, const QMouseEvent &, bool) { + void Rectangle::onMouseMoved(ui::ImageArea &, ui::Selection & s, const QPoint & c, const QImage &, const QMouseEvent &, const ColorPickerWidget &, bool) { if(this->_hold) { s.clear(); if(this->_clicked.x() < c.x() || this->_clicked.y() < c.y()) { @@ -35,14 +35,14 @@ namespace tool { } } - void Rectangle::onKeyPress(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent & e) { + void Rectangle::onKeyPress(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent & e, const ColorPickerWidget &) { if(e.key() == Qt::Key_Control) { this->_multy = true; qDebug() << "ctrl"; } } - void Rectangle::onKeyReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent & e) { + void Rectangle::onKeyReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent & e, const ColorPickerWidget &) { if(e.key() == Qt::Key_Control) { this->_multy = false; } diff --git a/IHM_Retouche_Photo/tools/selectionable/rectangle.h b/IHM_Retouche_Photo/tools/selectionable/rectangle.h index d383b682470f159a5fe8bcd951efb8f64f4d7897..e0a7eab7fdc9bb4f1325e14f9202e6503e2aebbb 100644 --- a/IHM_Retouche_Photo/tools/selectionable/rectangle.h +++ b/IHM_Retouche_Photo/tools/selectionable/rectangle.h @@ -10,13 +10,13 @@ namespace tool { bool _multy; public: - Rectangle(); + Rectangle(const ColorPickerWidget &); - virtual void onMousePressed(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &); - virtual void onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &); - virtual void onMouseMoved(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &, bool); + 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 onKeyPress(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent &); - virtual void onKeyReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent &); + 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 &); }; } diff --git a/IHM_Retouche_Photo/tools/selectionable/rectangleTriangle.cpp b/IHM_Retouche_Photo/tools/selectionable/rectangleTriangle.cpp index 0b08515ff45c205bfff7c794765031c521d89c1c..fcc74bb608240b008c57d13128d43bf073521598 100644 --- a/IHM_Retouche_Photo/tools/selectionable/rectangleTriangle.cpp +++ b/IHM_Retouche_Photo/tools/selectionable/rectangleTriangle.cpp @@ -1,12 +1,12 @@ #include "rectangleTriangle.h" namespace tool { - RectangleTriangle::RectangleTriangle() - : Selectionable("Triangle Rectangle", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-triangle.png"), true), _clicked(0,0), _hold(false), _multy(false) { + RectangleTriangle::RectangleTriangle(const ColorPickerWidget & cp) + : Selectionable(cp, "Triangle Rectangle", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-triangle.png"), true), _clicked(0,0), _hold(false), _multy(false) { } - void RectangleTriangle::onMousePressed(ui::ImageArea &, ui::Selection & s, const QPoint & clicked, const QImage &, const QMouseEvent & e) { + void RectangleTriangle::onMousePressed(ui::ImageArea &, ui::Selection & s, const QPoint & clicked, const QImage &, const QMouseEvent & e, const ColorPickerWidget &) { if(!this->_multy) { s.clear(); } @@ -17,13 +17,13 @@ namespace tool { } } - void RectangleTriangle::onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent & e) { + void RectangleTriangle::onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent & e, const ColorPickerWidget &) { if(e.button() == Qt::LeftButton) { this->_hold = false; } } - void RectangleTriangle::onMouseMoved(ui::ImageArea &, ui::Selection & s, const QPoint & position, const QImage & image, const QMouseEvent &, bool) { + void RectangleTriangle::onMouseMoved(ui::ImageArea &, ui::Selection & s, const QPoint & position, const QImage & image, const QMouseEvent &, const ColorPickerWidget &, bool) { if(this->_hold) { s.clear(); QVector<QPoint> selection; @@ -40,14 +40,14 @@ namespace tool { } } - void RectangleTriangle::onKeyPress(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent & e) { + void RectangleTriangle::onKeyPress(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent & e, const ColorPickerWidget &) { if(e.key() == Qt::Key_Control) { this->_multy = true; qDebug() << "ctrl"; } } - void RectangleTriangle::onKeyReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent & e) { + void RectangleTriangle::onKeyReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent & e, const ColorPickerWidget &) { if(e.key() == Qt::Key_Control) { this->_multy = false; } diff --git a/IHM_Retouche_Photo/tools/selectionable/rectangleTriangle.h b/IHM_Retouche_Photo/tools/selectionable/rectangleTriangle.h index 6d2da1f9ef75a78336742459f0a2fd70625e7954..bd1632ce6c41cc1640d95af2094fcf03a2396dbb 100644 --- a/IHM_Retouche_Photo/tools/selectionable/rectangleTriangle.h +++ b/IHM_Retouche_Photo/tools/selectionable/rectangleTriangle.h @@ -10,13 +10,13 @@ namespace tool { bool _multy; public: - RectangleTriangle(); + RectangleTriangle(const ColorPickerWidget &); - virtual void onMousePressed(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &); - virtual void onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &); - virtual void onMouseMoved(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &, bool); + 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 onKeyPress(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent &); - virtual void onKeyReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent &); + 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 &); }; } diff --git a/IHM_Retouche_Photo/tools/selectionable/triangle.cpp b/IHM_Retouche_Photo/tools/selectionable/triangle.cpp index c7111b95c1520127daaf5b55292128d8850a45ec..f2334ddf5b4a3b822a46ac7683e97da100c5a6b5 100644 --- a/IHM_Retouche_Photo/tools/selectionable/triangle.cpp +++ b/IHM_Retouche_Photo/tools/selectionable/triangle.cpp @@ -1,12 +1,12 @@ #include "triangle.h" namespace tool { - Triangle::Triangle() - : Selectionable("Triangle", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-triangle3.png"), true), _clicked(0,0), _hold(false), _multy(false) { + Triangle::Triangle(const ColorPickerWidget & cp) + : Selectionable(cp, "Triangle", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-triangle3.png"), true), _clicked(0,0), _hold(false), _multy(false) { } - void Triangle::onMousePressed(ui::ImageArea &, ui::Selection & s, const QPoint & clicked, const QImage &, const QMouseEvent & e) { + void Triangle::onMousePressed(ui::ImageArea &, ui::Selection & s, const QPoint & clicked, const QImage &, const QMouseEvent & e, const ColorPickerWidget &) { if(!this->_multy) { s.clear(); } @@ -17,13 +17,13 @@ namespace tool { } } - void Triangle::onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent & e) { + void Triangle::onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent & e, const ColorPickerWidget &) { if(e.button() == Qt::LeftButton) { this->_hold = false; } } - void Triangle::onMouseMoved(ui::ImageArea &, ui::Selection & s, const QPoint & position, const QImage & image, const QMouseEvent &, bool) { + void Triangle::onMouseMoved(ui::ImageArea &, ui::Selection & s, const QPoint & position, const QImage & image, const QMouseEvent &, const ColorPickerWidget &, bool) { if(this->_hold) { s.clear(); QVector<QPoint> selection; @@ -50,14 +50,14 @@ namespace tool { } } - void Triangle::onKeyPress(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent & e) { + void Triangle::onKeyPress(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent & e, const ColorPickerWidget &) { if(e.key() == Qt::Key_Control) { this->_multy = true; qDebug() << "ctrl"; } } - void Triangle::onKeyReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent & e) { + void Triangle::onKeyReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent & e, const ColorPickerWidget &) { if(e.key() == Qt::Key_Control) { this->_multy = false; } diff --git a/IHM_Retouche_Photo/tools/selectionable/triangle.h b/IHM_Retouche_Photo/tools/selectionable/triangle.h index 7405087d3b8c95db782d5a35df969f5557308781..1afd7bd8f9f934e7051987e0d62f16f9ba6ae8b5 100644 --- a/IHM_Retouche_Photo/tools/selectionable/triangle.h +++ b/IHM_Retouche_Photo/tools/selectionable/triangle.h @@ -10,13 +10,13 @@ namespace tool { bool _multy; public: - Triangle(); + Triangle(const ColorPickerWidget &); - virtual void onMousePressed(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &); - virtual void onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &); - virtual void onMouseMoved(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &, bool); + 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 onKeyPress(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent &); - virtual void onKeyReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent &); + 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 &); }; } diff --git a/IHM_Retouche_Photo/tools/selectionnable.cpp b/IHM_Retouche_Photo/tools/selectionnable.cpp index 307c3d2b23429e13328c05f25f112e6866d0cc98..aea2c1243c831cf46065115c3b0b556048916f47 100644 --- a/IHM_Retouche_Photo/tools/selectionnable.cpp +++ b/IHM_Retouche_Photo/tools/selectionnable.cpp @@ -1,35 +1,35 @@ #include "selectionnable.h" namespace tool { - Selectionable::Selectionable(const QString & name, const QIcon & icon, bool free) - : Tool(name, icon), _free(free) {} + Selectionable::Selectionable(const ColorPickerWidget & cp, const QString & name, const QIcon & icon, bool free) + : Tool(name, icon), _colorPicker(&cp) ,_free(free) {} - void Selectionable::onKeyPress(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent &) {} - void Selectionable::onKeyReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent &) {} + 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::pressed(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QMouseEvent & e) { if(image.rect().contains(click) || this->_free) { - this->onMousePressed(area, selection, click, image, e); + this->onMousePressed(area, selection, click, image, e, *this->_colorPicker); } } void Selectionable::released(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QMouseEvent & e) { if(image.rect().contains(click) || this->_free) { - this->onMouseReleased(area, selection, click, image, e); + this->onMouseReleased(area, selection, click, image, e, *this->_colorPicker); } } void Selectionable::moved(ui::ImageArea & area, QImage & image, QPoint & click ,ui::Selection & selection, QMouseEvent & e, bool hold) { if(image.rect().contains(click) || this->_free) { - this->onMouseMoved(area, selection, click, image, e, hold); + this->onMouseMoved(area, selection, click, image, e, *this->_colorPicker, hold); } } void Selectionable::keyPressed(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QKeyEvent & e) { - this->onKeyPress(area, selection, click, image, e); + this->onKeyPress(area, selection, click, image, e, *this->_colorPicker); } void Selectionable::keyReleased(ui::ImageArea & area, QImage & image, QPoint & click, ui::Selection & selection, QKeyEvent & e) { - this->onKeyReleased(area, selection, click, image, e); + this->onKeyReleased(area, selection, click, image, e, *this->_colorPicker); } } diff --git a/IHM_Retouche_Photo/tools/selectionnable.h b/IHM_Retouche_Photo/tools/selectionnable.h index 120be81b10f216e9ce9d8aa0f94343e7cc6f5c5b..40cd3e496de2fa4369eb1f56907964caeec7b80a 100644 --- a/IHM_Retouche_Photo/tools/selectionnable.h +++ b/IHM_Retouche_Photo/tools/selectionnable.h @@ -2,20 +2,23 @@ #include "tool.h" +#include "colorpickerwidget.h" + namespace tool { class Selectionable : public Tool { private: + const ColorPickerWidget * _colorPicker; bool _free; public: - Selectionable(const QString & = "NaN", const QIcon & = QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/transform-crop.png"), bool = false); + Selectionable(const ColorPickerWidget &, const QString & = "NaN", const QIcon & = QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/transform-crop.png"), bool = false); - virtual void onMousePressed(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &) = 0; - virtual void onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &) = 0; - virtual void onMouseMoved(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &, bool) = 0; + virtual void onMousePressed(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &, const ColorPickerWidget &) = 0; + virtual void onMouseReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &, const ColorPickerWidget &) = 0; + virtual void onMouseMoved(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QMouseEvent &, const ColorPickerWidget &, bool) = 0; - virtual void onKeyPress(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent &); - virtual void onKeyReleased(ui::ImageArea &, ui::Selection &, const QPoint &, const QImage &, const QKeyEvent &); + 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 &); public slots: virtual void pressed(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &) final; diff --git a/IHM_Retouche_Photo/ui/effect/blackandwhite.cpp b/IHM_Retouche_Photo/ui/effect/blackandwhite.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9b2d7dc315fc18a5c0004db83b9fc09e4b594f09 --- /dev/null +++ b/IHM_Retouche_Photo/ui/effect/blackandwhite.cpp @@ -0,0 +1,24 @@ +#include "blackandwhite.h" + +#include <QDebug> + +namespace effect { + BlackAndWhite::BlackAndWhite() {} + + BlackAndWhite::~BlackAndWhite() {} + + void BlackAndWhite::apply(const QSet<QPoint> & points, QImage & image) const { + if (image.isNull()) { + qDebug() << "L'image est vide."; + return; + } + + for(auto & pixel : points) { + int luminance = qGray(image.pixelColor(pixel).rgb()); + QColor newColor(luminance, luminance, luminance); + image.setPixelColor(pixel, newColor); + } + + qDebug() << "Conversion en noir et blanc effectuée."; + } +} diff --git a/IHM_Retouche_Photo/ui/effect/blackandwhite.h b/IHM_Retouche_Photo/ui/effect/blackandwhite.h new file mode 100644 index 0000000000000000000000000000000000000000..ad9c446ffffbdffc72d74514ff78881d4860ce0a --- /dev/null +++ b/IHM_Retouche_Photo/ui/effect/blackandwhite.h @@ -0,0 +1,15 @@ +#pragma once + +#include "effect.h" + + +namespace effect { + class BlackAndWhite : public Effect { + public: + BlackAndWhite(); + virtual ~BlackAndWhite(); + + virtual void apply(const QSet<QPoint> &, QImage &) const; + }; +} + diff --git a/IHM_Retouche_Photo/ui/effect/contrast.cpp b/IHM_Retouche_Photo/ui/effect/contrast.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3acfe6e4189fbc1cecce3e35c824cf878f8fd75c --- /dev/null +++ b/IHM_Retouche_Photo/ui/effect/contrast.cpp @@ -0,0 +1,24 @@ +#include "contrast.h"" + +#include <QDebug> + +namespace effect { + Contrast::Contrast(float brightnessFactor, float contrastFactor) + : _brightnessFactor(brightnessFactor), _contrastFactor(contrastFactor) {} + + Contrast::~Contrast() {} + + void Contrast::apply(const QSet<QPoint> & points, QImage & image) const { + for(auto & point : points) { + QColor pixelColor = image.pixelColor(point); + + int adjustedRed = qBound(0, static_cast<int>(pixelColor.red() * this->_brightnessFactor * this->_contrastFactor), 255); + int adjustedGreen = qBound(0, static_cast<int>(pixelColor.green() * this->_brightnessFactor * this->_contrastFactor), 255); + int adjustedBlue = qBound(0, static_cast<int>(pixelColor.blue() * this->_brightnessFactor * this->_contrastFactor), 255); + + image.setPixelColor(point, QColor(adjustedRed, adjustedGreen, adjustedBlue)); + } + + qDebug() << "Ajustement de la luminosité et du contraste effectué."; + } +} diff --git a/IHM_Retouche_Photo/ui/effect/contrast.h b/IHM_Retouche_Photo/ui/effect/contrast.h new file mode 100644 index 0000000000000000000000000000000000000000..3f33c804815991d975359e3efe8bbe083942f2c4 --- /dev/null +++ b/IHM_Retouche_Photo/ui/effect/contrast.h @@ -0,0 +1,18 @@ +#pragma once + +#include "effect.h" + +namespace effect { + class Contrast : public Effect { + private: + float _brightnessFactor; + float _contrastFactor; + + public: + Contrast(float brightnessFactor, float contrastFactor); + virtual ~Contrast(); + + virtual void apply(const QSet<QPoint> &, QImage &) const; + }; +} + diff --git a/IHM_Retouche_Photo/ui/effect/effect.cpp b/IHM_Retouche_Photo/ui/effect/effect.cpp new file mode 100644 index 0000000000000000000000000000000000000000..564f376acb47cda9871e704261302bf6d8478c14 --- /dev/null +++ b/IHM_Retouche_Photo/ui/effect/effect.cpp @@ -0,0 +1,18 @@ +#include "effect.h" + +namespace effect { + void Effect::use(const ui::Selection & selection, QImage & image) const { + QSet<QPoint> pixels; + if(selection.empty()) { + for(int x = 0; x < image.width(); x++) { + for(int y = 0; y < image.height(); y++) { + pixels.insert(QPoint(x,y)); + } + } + } + else { + pixels = selection.selection(); + } + this->apply(pixels, image); + } +} diff --git a/IHM_Retouche_Photo/ui/effect/effect.h b/IHM_Retouche_Photo/ui/effect/effect.h new file mode 100644 index 0000000000000000000000000000000000000000..ae3c23e0b6f9eadd29583a4839bf36fce2ad9f27 --- /dev/null +++ b/IHM_Retouche_Photo/ui/effect/effect.h @@ -0,0 +1,14 @@ +#pragma once + +#include "../view/selection.h" + +namespace effect { + class Effect { + public: + Effect() {} + virtual ~Effect() {} + + virtual void apply(const QSet<QPoint> &, QImage &) const = 0; + void use(const ui::Selection &, QImage &) const; + }; +} diff --git a/IHM_Retouche_Photo/ui/files/fileitem.cpp b/IHM_Retouche_Photo/ui/files/fileitem.cpp new file mode 100644 index 0000000000000000000000000000000000000000..51016165d5f17733d194c7fa9ea7cd1bfb214e19 --- /dev/null +++ b/IHM_Retouche_Photo/ui/files/fileitem.cpp @@ -0,0 +1,4 @@ +#include "fileitem.h" + +FileItem::FileItem(const QString & path) + : QListWidgetItem(path), _file(path) {} diff --git a/IHM_Retouche_Photo/ui/files/fileitem.h b/IHM_Retouche_Photo/ui/files/fileitem.h new file mode 100644 index 0000000000000000000000000000000000000000..31085eb548d3c4344f29cf99c924f2bc3f2f6026 --- /dev/null +++ b/IHM_Retouche_Photo/ui/files/fileitem.h @@ -0,0 +1,16 @@ +#pragma once + +#include <QListWidgetItem> +#include <QFile> + +class FileItem : public QListWidgetItem { + private: + const QFile _file; + + public: + FileItem() = delete; + FileItem(const QString & path); + + inline const QFile & file() const {return this->_file;} +}; + diff --git a/IHM_Retouche_Photo/ui/toolbox/toolRegister.cpp b/IHM_Retouche_Photo/ui/toolbox/toolRegister.cpp index ebc28321996552da01d3da651587cfd79d2d59af..0e922948e79b80cf4245743d6a74fbe8eef8c4f5 100644 --- a/IHM_Retouche_Photo/ui/toolbox/toolRegister.cpp +++ b/IHM_Retouche_Photo/ui/toolbox/toolRegister.cpp @@ -43,8 +43,6 @@ namespace ui { 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&))); } - - qDebug() << "tool choose"; } void ToolboxRegister::updateCurrentView(ImageArea * image) { @@ -68,7 +66,5 @@ namespace ui { 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&))); } - - qDebug() << "view changed"; } } diff --git a/IHM_Retouche_Photo/ui/view/imagearea.cpp b/IHM_Retouche_Photo/ui/view/imagearea.cpp index 319417cb7123862746bcc3013ed77e29e94dffd0..15992bd4b043be626720a6fa312b5faeee1c9cff 100644 --- a/IHM_Retouche_Photo/ui/view/imagearea.cpp +++ b/IHM_Retouche_Photo/ui/view/imagearea.cpp @@ -7,18 +7,26 @@ #include <QFileDialog> #include <cmath> +#include <QColorTransform> + +#include "../effect/contrast.h" +#include "../effect/blackandwhite.h" + namespace ui { ImageArea::ImageArea() : _selection(), _fileinfo(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/New"), _image(800, 600, QImage::Format_RGB32), _checkboard(ImageArea::Generate_Checkboard(4, 4, 16)), + _transformation(), _position(0, 0), _lastPos(0, 0), + _repercution(nullptr), _zoom(1.f), + _status(NEW), _mouseClickHold(false), - _status(NEW), _originalImage(QImage()), - _isBlackAndWhite(false) { + _emitModification(false), + _receiveModification(true) { this->setMouseTracking(true); this->setFocusPolicy(Qt::StrongFocus); this->_image.fill(QColorConstants::White); @@ -28,13 +36,16 @@ namespace ui { : _selection(), _fileinfo(info), _image(info.absoluteFilePath()), - _checkboard(ImageArea::Generate_Checkboard(4, 4, 16)) , + _checkboard(ImageArea::Generate_Checkboard(4, 4, 16)), + _transformation(), _position(0, 0), _lastPos(0, 0), + _repercution(nullptr), _zoom(1.f), + _status(ORIGINAL), _mouseClickHold(false), - _status(ORIGINAL), _originalImage(QImage()), - _isBlackAndWhite(false) { + _emitModification(false), + _receiveModification(true) { this->setMouseTracking(true); this->setFocusPolicy(Qt::StrongFocus); } @@ -129,20 +140,20 @@ namespace ui { void ImageArea::changeZoom(float value) { this->_zoom = value; - emit this->zoomChange(value); + emit this->zoomChanged(value); this->repaint(); } void ImageArea::increaseZoom() { this->_zoom += 1; - emit this->zoomChange(this->_zoom); + emit this->zoomChanged(this->_zoom); this->repaint(); } void ImageArea::decreaseZoom() { if(this->_zoom > 1) { this->_zoom -= 1; - emit this->zoomChange(this->_zoom); + emit this->zoomChanged(this->_zoom); this->repaint(); } } @@ -150,18 +161,27 @@ namespace ui { void ImageArea::setImage(const QImage & image) { this->_image = image; this->_checkboard = ImageArea::Generate_Checkboard(this->_image.width()/2, this->_image.height()/2, 1); + emit this->imageChanged(image); } void ImageArea::setColor(const QPoint & pixel, const QColor & color) { - this->_image.setPixelColor(pixel, color); + if(this->_repercution != nullptr) { + this->_repercution->apply(pixel, color , &this->_image); + } + else { + if(this->_image.rect().contains(pixel)) { + this->_image.setPixelColor(pixel, color); + } + } + this->_status |= MODIFIED; - emit this->pixelChange(pixel); + emit this->modified(pixel, color); } void ImageArea::setColor(const QVector<QPoint> & pixels, const QColor & color) { for(auto & pixel : pixels) { - this->_image.setPixelColor(pixel, color); + this->setColor(pixel, color); } } @@ -189,7 +209,18 @@ namespace ui { void ImageArea::transform(const QTransform & transformation, Qt::TransformationMode mode) { this->_image = this->_image.transformed(transformation, mode); - emit this->imageChanged(this->_image); + this->_transformation = transformation; + this->_selection.clear(); + this->repaint(); + + emit this->transformed(transformation, mode); + } + + void ImageArea::effect(const effect::Effect & effect) { + effect.use(this->_selection, this->_image); + this->repaint(); + + emit this->effected(effect); } void ImageArea::save() { @@ -197,6 +228,11 @@ namespace ui { QString path = QFileDialog::getSaveFileName(nullptr, "", "New"); this->_fileinfo = QFileInfo(path); } + + this->setModified(false); + this->setNew(false); + this->setOriginal(false); + this->save(this->_fileinfo.absoluteFilePath()); } @@ -208,7 +244,11 @@ namespace ui { this->_image.save(path); this->_fileinfo.setFile(path); - this->_status &= ~MODIFIED; + + this->setModified(false); + this->setNew(false); + this->setOriginal(false); + emit this->saved(this->_image, this->_fileinfo); } @@ -232,83 +272,30 @@ namespace ui { return img; } - void ImageArea::convertToNoirEtBlanc() { - if (_isBlackAndWhite) { - qDebug() << "L'image est déjà en noir et blanc."; - qDebug() << "Retour à l'état initial."; - this->setImage(_originalImage); - _isBlackAndWhite = false; - this->repaint(); - return; - } - - QImage currentImage = this->_image; - - _originalImage = currentImage; - _isBlackAndWhite = true; - - if (currentImage.isNull()) { - qDebug() << "L'image est vide."; - return; - } - - for (int y = 0; y < currentImage.height(); ++y) { - for (int x = 0; x < currentImage.width(); ++x) { - QColor pixelColor = currentImage.pixelColor(x, y); - - int luminance = qGray(pixelColor.rgb()); - - QColor newColor(luminance, luminance, luminance); - - currentImage.setPixelColor(x, y, newColor); - } - } - - this->setImage(currentImage); - - this->repaint(); - - - qDebug() << "Conversion en noir et blanc effectuée."; - } - - void ImageArea::adjustBrightnessContrast(float brightnessFactor, float contrastFactor) { - QImage currentImage = this->_image; - - for (int y = 0; y < currentImage.height(); ++y) { - for (int x = 0; x < currentImage.width(); ++x) { - QColor pixelColor = currentImage.pixelColor(x, y); - - int adjustedRed = qBound(0, static_cast<int>(pixelColor.red() * brightnessFactor * contrastFactor), 255); - int adjustedGreen = qBound(0, static_cast<int>(pixelColor.green() * brightnessFactor * contrastFactor), 255); - int adjustedBlue = qBound(0, static_cast<int>(pixelColor.blue() * brightnessFactor * contrastFactor), 255); - - QColor newColor(adjustedRed, adjustedGreen, adjustedBlue); - currentImage.setPixelColor(x, y, newColor); - } - } - - this->setImage(currentImage); - - this->repaint(); - - qDebug() << "Ajustement de la luminosité et du contraste effectué."; - } - + void ImageArea::increaseBrightness() { + effect::Contrast c(1.2, 1.0); + this->effect(c); + // Utilisation de la méthode effecte pour que les modification de l'image + // actuelle soit aussi effectuer sur les autres images. + } - void ImageArea::increaseBrightness() { - adjustBrightnessContrast(1.2, 1.0); - } + void ImageArea::decreaseBrightness() { + effect::Contrast c(0.8, 1.0); + this->effect(c); + } - void ImageArea::decreaseBrightness() { - adjustBrightnessContrast(0.8, 1.0); - } + void ImageArea::increaseContrast() { + effect::Contrast c(1.0, 1.2); + this->effect(c); + } - void ImageArea::increaseContrast() { - adjustBrightnessContrast(1.0, 1.2); - } + void ImageArea::decreaseContrast() { + effect::Contrast c(1.0, 0.8); + this->effect(c); + } - void ImageArea::decreaseContrast() { - adjustBrightnessContrast(1.0, 0.8); - } + void ImageArea::blackAndWhite() { + effect::BlackAndWhite bw; + this->effect(bw); + } } diff --git a/IHM_Retouche_Photo/ui/view/imagearea.h b/IHM_Retouche_Photo/ui/view/imagearea.h index 2eeee86fd9a1bfe5e7bb218c1e3d7995bb9e1f2c..5e4c12af2327c3f093ca43e9c979215012f94c85 100644 --- a/IHM_Retouche_Photo/ui/view/imagearea.h +++ b/IHM_Retouche_Photo/ui/view/imagearea.h @@ -7,8 +7,9 @@ #include <QShortcut> #include <QKeyEvent> - #include "selection.h" +#include "repercussion/repercussion.h" +#include "../effect/effect.h" namespace ui { class ImageArea : public QWidget { @@ -18,20 +19,23 @@ namespace ui { QFileInfo _fileinfo; QImage _image; QImage _checkboard; + QTransform _transformation; QPoint _position; QPoint _lastPos; + Repercution * _repercution; + float _zoom; - bool _mouseClickHold; - uint32_t _status; + uint8_t _status; - QImage _originalImage; - bool _isBlackAndWhite; + bool _mouseClickHold; + bool _emitModification; + bool _receiveModification; protected: - enum Status { + enum ImageStatus { NONE = 0, ORIGINAL = 1, MODIFIED = 2, @@ -44,12 +48,19 @@ namespace ui { inline const QFileInfo & file() const {return this->_fileinfo;} inline const QImage & image() const {return this->_image;} + inline const Repercution * repercution() const {return this->_repercution;} + inline const QTransform & transformation() const {return this->_transformation;} + inline float zoom() const {return this->_zoom;} + inline bool isOriginal() const {return (this->_status & ORIGINAL) != 0;} inline bool isModified() const {return (this->_status & MODIFIED) != 0;} inline bool isNew() const {return (this->_status & NEW) != 0;} inline bool isMouseHolded() const {return this->_mouseClickHold;} + inline bool isEmitingModification() const {return this->_emitModification;} + inline bool isReceivingModification() const {return this->_receiveModification;} + inline const QPoint & position() const {return this->_position;} inline const QPoint & last_position() const {return this->_lastPos;} @@ -61,6 +72,8 @@ namespace ui { inline void setPosition(const QPoint & position) {this->_position = position;} inline void setLast_Positon(const QPoint & lastPosition) {this->_lastPos = lastPosition;} + inline void setRepercution(Repercution * repercution) {this->_repercution = repercution;} + virtual void paintEvent(QPaintEvent *); virtual void mouseMoveEvent(QMouseEvent *); @@ -75,9 +88,12 @@ namespace ui { static QImage Generate_Checkboard(qsizetype, qsizetype, qsizetype); public slots: - void changeZoom(float); + inline void changeModificationEmit(bool status) {this->_emitModification = status;} + inline void changeModificationReceive(bool status) {this->_receiveModification = status;} + void increaseZoom(); void decreaseZoom(); + void changeZoom(float); void setImage(const QImage &); void setColor(const QPoint &, const QColor &); @@ -86,23 +102,26 @@ namespace ui { void setSize(const QPoint &, const QPoint &); void transform(const QTransform &, Qt::TransformationMode = Qt::TransformationMode::FastTransformation); + void effect(const effect::Effect &); void save(); void save(const QString &); - void convertToNoirEtBlanc(); - - void adjustBrightnessContrast(float brightnessFactor, float contrastFactor); void increaseBrightness(); void decreaseBrightness(); void increaseContrast(); void decreaseContrast(); + void blackAndWhite(); + signals: - void zoomChange(float); + void zoomChanged(float); void imageChanged(const QImage &); - void pixelChange(const QPoint &); + + void modified(const QPoint &, const QColor &); + void transformed(const QTransform &, Qt::TransformationMode); + void effected(const effect::Effect &); void saved(const QImage &, const QFileInfo &); diff --git a/IHM_Retouche_Photo/ui/view/multyimagemodifier.cpp b/IHM_Retouche_Photo/ui/view/multyimagemodifier.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4985dbfb1492e6d058d72d3b981cd207107eca94 --- /dev/null +++ b/IHM_Retouche_Photo/ui/view/multyimagemodifier.cpp @@ -0,0 +1,123 @@ +#include "multyimagemodifier.h" + + +namespace ui { + MultyImageModifier::MultyImageModifier(ViewManager * manager, QCheckBox * emitCheckbox, QCheckBox * receiveCheckbox, QComboBox * samplingCombobox) + : _manager(manager), _current(nullptr), _emitCheckbox(emitCheckbox), _receiveCheckbox(receiveCheckbox), _samplingCombobox(samplingCombobox) { + 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))); + } + + 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::changeCurrentImage(ImageArea * area) { + if(this->_current != nullptr) { + QObject::disconnect(this->_emitCheckbox, SIGNAL(toggled(bool)), this->_current, SLOT(changeModificationEmit(bool))); + + QObject::disconnect(this->_receiveCheckbox, SIGNAL(toggled(bool)), this, SLOT(changeCurrentAsTarget(bool))); + QObject::disconnect(this->_receiveCheckbox, SIGNAL(toggled(bool)), this->_current, SLOT(changeModificationReceive(bool))); + + QObject::disconnect(this->_current, SIGNAL(modified(QPoint,QColor)), this, SLOT(modify(QPoint,QColor))); + QObject::disconnect(this->_current, SIGNAL(transformed(QTransform,Qt::TransformationMode)), this, SLOT(transform(QTransform,Qt::TransformationMode))); + QObject::disconnect(this->_current, SIGNAL(effected(effect::Effect)), this, SLOT(effect(effect::Effect))); + } + + this->_current = area; + + if(this->_current != nullptr) { + if(this->_current->repercution() == nullptr && !this->empty()) { + this->_current->setRepercution(this->at(0).get()); + } + + if(this->_current->isReceivingModification()) { + this->_targets.insert(this->_current); + } + + 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))); + + QObject::connect(this->_receiveCheckbox, SIGNAL(toggled(bool)), this, SLOT(changeCurrentAsTarget(bool))); + QObject::connect(this->_receiveCheckbox, SIGNAL(toggled(bool)), this->_current, SLOT(changeModificationReceive(bool))); + + QObject::connect(this->_current, SIGNAL(modified(QPoint,QColor)), this, SLOT(modify(QPoint,QColor))); + QObject::connect(this->_current, SIGNAL(transformed(QTransform,Qt::TransformationMode)), this, SLOT(transform(QTransform,Qt::TransformationMode))); + QObject::connect(this->_current, SIGNAL(effected(effect::Effect)), this, SLOT(effect(effect::Effect))); + } + 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::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); + } + } + } + } + + void MultyImageModifier::transform(const QTransform & transformation, Qt::TransformationMode mode) { + if(this->_current != nullptr && this->_current->isEmitingModification()) { + for(auto * area : this->_targets) { + if(area != this->_current) { + area->transform(transformation, mode); + } + } + } + } + + void MultyImageModifier::effect(const effect::Effect & effect) { + if(this->_current != nullptr && this->_current->isEmitingModification()) { + for(auto * area : this->_targets) { + if(area != this->_current) { + area->effect(effect); + } + } + } + } + + void MultyImageModifier::changeCurrentAsTarget(bool status) { + if(this->_current == nullptr) { + return; + } + + if(status) { + this->_targets.insert(this->_current); + } + else { + this->_targets.remove(this->_current); + } + } + + void MultyImageModifier::pushTarget(ImageArea * area) { + if(area->isReceivingModification()) { + this->_targets.insert(area); + } + } + + void MultyImageModifier::eraseTarget(ImageArea * area) { + this->_targets.remove(area); + } +} diff --git a/IHM_Retouche_Photo/ui/view/multyimagemodifier.h b/IHM_Retouche_Photo/ui/view/multyimagemodifier.h new file mode 100644 index 0000000000000000000000000000000000000000..8ea52ab5e6227a44eb09d09bf7d1eaf7a6897bc0 --- /dev/null +++ b/IHM_Retouche_Photo/ui/view/multyimagemodifier.h @@ -0,0 +1,43 @@ +#pragma once + +#include <QObject> + +#include <QCheckBox> +#include <QComboBox> +#include <QVector> + +#include "viewmanager.h" +#include "repercussion/repercussion.h" + +namespace ui { +class MultyImageModifier : public QObject, public QVector<QSharedPointer<Repercution>> { + Q_OBJECT + private: + ViewManager * _manager; + ImageArea * _current; + QSet<ImageArea *> _targets; + + QCheckBox * _emitCheckbox; + QCheckBox * _receiveCheckbox; + QComboBox * _samplingCombobox; + + public: + MultyImageModifier() = delete; + MultyImageModifier(ViewManager *, QCheckBox * emitCheckbox, QCheckBox * receiveCheckbox, QComboBox * samplingCombobox); + + void update(); + + public slots: + void changeCurrentRepercution(int); + void changeCurrentImage(ImageArea *); + + void modify(const QPoint &, const QColor &); + void transform(const QTransform &, Qt::TransformationMode); + void effect(const effect::Effect &); + + void changeCurrentAsTarget(bool); + + void pushTarget(ImageArea *); + void eraseTarget(ImageArea *); + }; +} diff --git a/IHM_Retouche_Photo/ui/view/repercussion/ignore.cpp b/IHM_Retouche_Photo/ui/view/repercussion/ignore.cpp new file mode 100644 index 0000000000000000000000000000000000000000..504a1787d65402d149c0aa038440d2de4e76ff30 --- /dev/null +++ b/IHM_Retouche_Photo/ui/view/repercussion/ignore.cpp @@ -0,0 +1,9 @@ +#include "ignore.h" + +namespace ui { + void Ignore::apply(const QPoint & point, const QColor & color, 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 new file mode 100644 index 0000000000000000000000000000000000000000..634d95a99cdb9175774a7c16091b087fddbef3db --- /dev/null +++ b/IHM_Retouche_Photo/ui/view/repercussion/ignore.h @@ -0,0 +1,15 @@ +#pragma once + +#include "repercussion.h" + +namespace ui { + class Ignore : public Repercution{ + public: + Ignore() {} + virtual ~Ignore() {} + + inline QString name() const {return "Ignore";} + virtual void apply(const QPoint &, const QColor &, QImage *); + }; +} + diff --git a/IHM_Retouche_Photo/ui/view/repercussion/repercussion.h b/IHM_Retouche_Photo/ui/view/repercussion/repercussion.h new file mode 100644 index 0000000000000000000000000000000000000000..8dea5c6c91d10faae8ccc6077fd490c835851be4 --- /dev/null +++ b/IHM_Retouche_Photo/ui/view/repercussion/repercussion.h @@ -0,0 +1,16 @@ +#pragma once + +#include <QString> +#include <QPoint> +#include <QImage> + +namespace ui { + class Repercution { + public: + Repercution() {} + virtual ~Repercution() {} + + inline virtual QString name() const = 0; + virtual void apply(const QPoint &, const QColor &, QImage *) = 0; + }; +} diff --git a/IHM_Retouche_Photo/ui/view/selection.h b/IHM_Retouche_Photo/ui/view/selection.h index aac17dc35831ea7be31369d6b9529e2ffba21d46..96b100f43bbcb70859097588a519123c45bcc5f7 100644 --- a/IHM_Retouche_Photo/ui/view/selection.h +++ b/IHM_Retouche_Photo/ui/view/selection.h @@ -36,6 +36,8 @@ namespace ui { void clear(); bool contain(const QPoint &); + inline bool empty() const {return this->_pixels.empty();} + signals: void selected(const QPoint &); diff --git a/IHM_Retouche_Photo/ui/view/viewmanager.cpp b/IHM_Retouche_Photo/ui/view/viewmanager.cpp index 1125d440797ce81b0c35e77e8ce24ece3ca8066b..4b8dfed69a015f93c5413f83ac2f28c7f833879b 100644 --- a/IHM_Retouche_Photo/ui/view/viewmanager.cpp +++ b/IHM_Retouche_Photo/ui/view/viewmanager.cpp @@ -15,43 +15,34 @@ namespace ui { QObject::connect(this->_tabs, SIGNAL(tabCloseRequested(int)), this, SLOT(deleteView(int))); } - void ViewManager::deleteView(int index) { - emit this->deletedView(this->currentView()); - if(this->_tabs->count() != 0) { - emit this->changedView(this->currentView()); - } - this->_tabs->removeTab(index); - } - - void ViewManager::deleteCurrentView() { - this->deleteView(this->_tabs->currentIndex()); - } - - void ViewManager::changeView(int) { - emit this->changedView(this->currentView()); - } - - void ViewManager::viewModified(const QFileInfo &) { - for(int i = 0 ; i < this->_tabs->count(); i++ ) { - ImageArea * area = dynamic_cast<ImageArea *>(this->_tabs->widget(i)); - if(area->isModified()) { - this->_tabs->setTabText(i, "*" + area->file().fileName()); - } + QVector<ImageArea *> ViewManager::areas() const { + QVector<ImageArea *> area; + for(int i = 0 ; i < this->_tabs->count(); i++) { + area.push_back(dynamic_cast<ImageArea *>(this->_tabs->widget(i))); } + return area; } void ViewManager::newView() { - int tabs = this->_tabs->count(); - this->_tabs->addTab(new ImageArea(), "New"); - emit this->createdView(this->currentView()); - if(tabs == 0) { + this->_tabs->addTab(QPointer<ImageArea>(new ImageArea()), "New"); + this->_tabs->setCurrentIndex(this->_tabs->count()-1); + emit this->createdView(dynamic_cast<ImageArea*>(this->currentView())); + if(this->_tabs->count() == 0) { emit this->changedView(this->currentView()); } } void ViewManager::newView(const QFileInfo & info) { this->_tabs->addTab(QPointer<ImageArea>(new ImageArea(info)), info.fileName()); - emit this->createdView(this->currentView()); + this->_tabs->setCurrentIndex(this->_tabs->count()-1); + emit this->createdView(dynamic_cast<ImageArea*>(this->currentView())); + if(this->_tabs->count() == 0) { + emit this->changedView(this->currentView()); + } + } + + void ViewManager::deleteCurrentView() { + this->deleteView(this->_tabs->currentIndex()); } void ViewManager::deleteView(const QFileInfo & info) { @@ -65,6 +56,22 @@ namespace ui { } } + void ViewManager::deleteView(int index) { + emit this->deletedView(this->currentView()); + if(this->_tabs->count() != 0) { + emit this->changedView(this->currentView()); + } + this->_tabs->removeTab(index); + } + + void ViewManager::changeView(int) { + emit this->changedView(this->currentView()); + } + + void ViewManager::saveCurrentView() { + this->saveView(this->_tabs->currentIndex()); + } + void ViewManager::saveView(int index) { ImageArea * area = dynamic_cast<ImageArea *>(this->_tabs->widget(index)); if(area != nullptr) { @@ -90,6 +97,10 @@ namespace ui { } } + void ViewManager::saveAsCurrentView() { + this->saveAsView(this->_tabs->currentIndex()); + } + void ViewManager::saveAsView(int index) { ImageArea * area = dynamic_cast<ImageArea *>(this->_tabs->widget(index)); if(area != nullptr) { @@ -111,12 +122,4 @@ namespace ui { this->saveView(i); } } - - void ViewManager::saveCurrentView() { - this->saveView(this->_tabs->currentIndex()); - } - - void ViewManager::saveAsCurrentView() { - this->saveAsView(this->_tabs->currentIndex()); - } } diff --git a/IHM_Retouche_Photo/ui/view/viewmanager.h b/IHM_Retouche_Photo/ui/view/viewmanager.h index ceb16dea0269d9be1ef0daf28a2a052bfe13c5f1..956b20a16bd4eb97dbd7c6fe88032b3af6057872 100644 --- a/IHM_Retouche_Photo/ui/view/viewmanager.h +++ b/IHM_Retouche_Photo/ui/view/viewmanager.h @@ -24,22 +24,24 @@ namespace ui { inline QTabWidget * tabs() const {return this->_tabs;} inline FileSelector * fileselector() const {return this->_selector;} - protected slots: - void deleteView(int index); + QVector<ImageArea *> areas() const; public slots: void newView(); void newView(const QFileInfo &); - void changeView(int); - void viewModified(const QFileInfo &); - void deleteView(const QFileInfo &); + void deleteCurrentView(); + void deleteView(const QFileInfo &); + void deleteView(int); - void saveView(int index); - void saveAsView(int index); + void changeView(int); void saveCurrentView(); + void saveView(int); + void saveAsCurrentView(); + void saveAsView(int); + void saveAll(); signals: