diff --git a/IHM_Retouche_Photo/IHM_Retouche_Photo.pro b/IHM_Retouche_Photo/IHM_Retouche_Photo.pro index b51ded177c20da7f47c0d8ed7aeec6043078d433..347621d65be6a0b5724e7fdf2bd49d3dcb529980 100644 --- a/IHM_Retouche_Photo/IHM_Retouche_Photo.pro +++ b/IHM_Retouche_Photo/IHM_Retouche_Photo.pro @@ -15,8 +15,11 @@ SOURCES += \ main.cpp \ mainwindow.cpp \ tools/editable.cpp \ + tools/editable/bucket.cpp \ + tools/editable/pixelEraiser.cpp \ tools/editable/pixelpainter.cpp \ tools/hand.cpp \ + tools/picker.cpp \ tools/selectionable/ellipse.cpp \ tools/selectionable/polygone.cpp \ tools/selectionable/rectangle.cpp \ @@ -47,8 +50,11 @@ HEADERS += \ dialog/resizedialog.h \ mainwindow.h \ tools/editable.h \ + tools/editable/bucket.h \ + tools/editable/pixelEraiser.h \ tools/editable/pixelpainter.h \ tools/hand.h \ + tools/picker.h \ tools/selectionable/ellipse.h \ tools/selectionable/polygone.h \ tools/selectionable/rectangle.h \ diff --git a/IHM_Retouche_Photo/colorpickerwidget.cpp b/IHM_Retouche_Photo/colorpickerwidget.cpp index 3c6bfed66ea36cba8a28a36fa1d856c01ed154cc..1853201d90cb83235c843c78ceed9efda3bc352c 100644 --- a/IHM_Retouche_Photo/colorpickerwidget.cpp +++ b/IHM_Retouche_Photo/colorpickerwidget.cpp @@ -17,29 +17,44 @@ ColorPickerWidget::ColorPickerWidget(QWidget *parent) this->_currentColorLayout = new QHBoxLayout(this); - this->_currentColorLabel = new QLabel("Current Color :", this); + this->_currentColorLabel = new QLabel("Couleur courrante :", this); this->_currentColorLayout->addWidget(this->_currentColorLabel); this->_currentColorFrame = new QFrame(this); + this->_currentColorFrame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); 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->_addColorButton = new QPushButton("Ajouter une couleur", this); + QObject::connect(this->_addColorButton, SIGNAL(released()), this, SLOT(addColor())); this->_mainLayout->addWidget(this->_addColorButton); - this->_modifyColorButton = new QPushButton("Modify Color", this); - QObject::connect(this->_modifyColorButton, &QPushButton::clicked, this, &ColorPickerWidget::modifyColor); + this->_modifyColorButton = new QPushButton("Modifier la couleur courrante", this); + QObject::connect(this->_modifyColorButton, SIGNAL(released()), this, SLOT(modifyColor())); this->_mainLayout->addWidget(this->_modifyColorButton); - this->_chooseColorButton = new QPushButton("Finish", this); + this->_duplicateColorButton = new QPushButton("Dupliquer la couleur courrante", this); + QObject::connect(this->_duplicateColorButton, SIGNAL(released()), this, SLOT(duplicateCurrent())); + this->_mainLayout->addWidget(this->_duplicateColorButton); + + this->_eraseColorButton = new QPushButton("Effacer la couleur courrante de la liste", this); + QObject::connect(this->_eraseColorButton, SIGNAL(released()), this, SLOT(eraseSelectedColor())); + this->_mainLayout->addWidget(this->_eraseColorButton); + + this->_chooseColorButton = new QPushButton("Valider", this); QObject::connect(this->_chooseColorButton, &QPushButton::clicked, this, &ColorPickerWidget::close); this->_mainLayout->addWidget(this->_chooseColorButton); this->setFrameColor(this->_currentColor); + this->setWindowTitle("Couleur courrante"); + this->setWindowIcon(QIcon(":/icon/ressource/image/icon/icon.png")); + + this->addColor(QColorConstants::Black); + QObject::connect(this->_colorListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(chooseColor(QListWidgetItem*))); + QObject::connect(this->_colorListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(modifyColor(QListWidgetItem*))); } ColorPickerWidget::~ColorPickerWidget() { @@ -51,6 +66,7 @@ ColorPickerWidget::~ColorPickerWidget() { delete this->_addColorButton; delete this->_modifyColorButton; delete this->_chooseColorButton; + delete this->_duplicateColorButton; } void ColorPickerWidget::setCurrentColor(const QColor & color) { @@ -73,19 +89,46 @@ void ColorPickerWidget::setFrameColor(const QColor & color) { } void ColorPickerWidget::addColor() { - QColor color = QColorDialog::getColor(Qt::white, this, "Select Color"); - if (color.isValid()) { + this->addColor(QColorDialog::getColor(Qt::white, this, "Choix de la couleur")); +} + +void ColorPickerWidget::addColor(const QColor & color) { + if(color.isValid()) { QListWidgetItem *item = new QListWidgetItem(this->_colorListWidget); item->setBackground(QBrush(color)); } } +void ColorPickerWidget::eraseSelectedColor() { + this->_colorListWidget->takeItem(this->_colorListWidget->currentRow()); +} + +void ColorPickerWidget::eraseColor() { + this->eraseColor(this->_colorListWidget->currentItem()->background().color()); +} + +void ColorPickerWidget::eraseColor(const QColor & color) { + if(color.isValid()) { + for(int i = 0; i < this->_colorListWidget->count() ; i++) { + if(this->_colorListWidget->item(i)->background().color() == color) { + this->_colorListWidget->takeItem(i); + } + } + } +} + void ColorPickerWidget::modifyColor() { - QListWidgetItem * selectedItem = this->_colorListWidget->currentItem(); - if (selectedItem) { - QColor color = QColorDialog::getColor(selectedItem->background().color(), this, "Pick Color"); + this->modifyColor(this->_colorListWidget->currentItem()); +} + +void ColorPickerWidget::modifyColor(QListWidgetItem* item) { + QListWidgetItem * selectedItem = item; + if(selectedItem) { + QColor color = QColorDialog::getColor(selectedItem->background().color(), this, "Modification de l'iamge"); if (color.isValid()) { selectedItem->setBackground(QBrush(color)); + this->_currentColor = color; + this->setFrameColor(color); } } } @@ -101,3 +144,7 @@ void ColorPickerWidget::chooseColor(QListWidgetItem * item) { this->setFrameColor(this->_currentColor); } +void ColorPickerWidget::duplicateCurrent() { + this->addColor(this->currentColor()); +} + diff --git a/IHM_Retouche_Photo/colorpickerwidget.h b/IHM_Retouche_Photo/colorpickerwidget.h index d5097d6ea907cdb692018d8cf4e26e3926cdccf9..faec6fa9c4b07bd7e082fccae2456bfef0808ee7 100644 --- a/IHM_Retouche_Photo/colorpickerwidget.h +++ b/IHM_Retouche_Photo/colorpickerwidget.h @@ -23,6 +23,8 @@ class ColorPickerWidget : public QWidget { QPushButton * _addColorButton; QPushButton * _modifyColorButton; QPushButton * _chooseColorButton; + QPushButton * _eraseColorButton; + QPushButton * _duplicateColorButton; protected: void setFrameColor(const QColor &); @@ -37,7 +39,14 @@ class ColorPickerWidget : public QWidget { private slots: void addColor(); + void addColor(const QColor &); + void eraseColor(); + void eraseColor(const QColor &); + void eraseSelectedColor(); void modifyColor(); + void modifyColor(QListWidgetItem*); void chooseColor(); void chooseColor(QListWidgetItem*); + + void duplicateCurrent(); }; diff --git a/IHM_Retouche_Photo/dialog/rescaledialog.ui b/IHM_Retouche_Photo/dialog/rescaledialog.ui index f1a5b77a6455e632d2136c0b0a7b816f409cd346..a62a1afd4a82484a67f16847162afa33ee30e16a 100644 --- a/IHM_Retouche_Photo/dialog/rescaledialog.ui +++ b/IHM_Retouche_Photo/dialog/rescaledialog.ui @@ -9,12 +9,16 @@ <rect> <x>0</x> <y>0</y> - <width>306</width> + <width>301</width> <height>207</height> </rect> </property> <property name="windowTitle"> - <string>Dialog</string> + <string>Redimensionnement</string> + </property> + <property name="windowIcon"> + <iconset> + <normaloff>../ressource/image/icon/icon.png</normaloff>../ressource/image/icon/icon.png</iconset> </property> <layout class="QVBoxLayout" name="verticalLayout"> <property name="spacing"> @@ -115,15 +119,15 @@ </widget> </item> <item> - <layout class="QHBoxLayout" name="_heightArea"> + <layout class="QHBoxLayout" name="_widthArea"> <property name="leftMargin"> - <number>16</number> + <number>20</number> </property> <property name="rightMargin"> <number>16</number> </property> <item> - <widget class="QLabel" name="_heightLabel"> + <widget class="QLabel" name="_widthLabel"> <property name="sizePolicy"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -131,12 +135,12 @@ </sizepolicy> </property> <property name="text"> - <string>Height </string> + <string>Largeur</string> </property> </widget> </item> <item> - <widget class="QSpinBox" name="_heightSpinbox"> + <widget class="QSpinBox" name="_widthSpinbox"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <horstretch>0</horstretch> @@ -151,15 +155,15 @@ </layout> </item> <item> - <layout class="QHBoxLayout" name="_widthArea"> + <layout class="QHBoxLayout" name="_heightArea"> <property name="leftMargin"> - <number>20</number> + <number>16</number> </property> <property name="rightMargin"> <number>16</number> </property> <item> - <widget class="QLabel" name="_widthLabel"> + <widget class="QLabel" name="_heightLabel"> <property name="sizePolicy"> <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> <horstretch>0</horstretch> @@ -167,12 +171,12 @@ </sizepolicy> </property> <property name="text"> - <string>Width </string> + <string>Hauteur</string> </property> </widget> </item> <item> - <widget class="QSpinBox" name="_widthSpinbox"> + <widget class="QSpinBox" name="_heightSpinbox"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <horstretch>0</horstretch> diff --git a/IHM_Retouche_Photo/dialog/resizedialog.ui b/IHM_Retouche_Photo/dialog/resizedialog.ui index fb29c97693e8ec657066d28d75621f0f5fb7eb69..b1d53f6042d477fb258cef537ed6e50805799e82 100644 --- a/IHM_Retouche_Photo/dialog/resizedialog.ui +++ b/IHM_Retouche_Photo/dialog/resizedialog.ui @@ -9,12 +9,16 @@ <rect> <x>0</x> <y>0</y> - <width>330</width> + <width>228</width> <height>177</height> </rect> </property> <property name="windowTitle"> - <string>Dialog</string> + <string>Rognage</string> + </property> + <property name="windowIcon"> + <iconset resource="../ressource.qrc"> + <normaloff>:/icon/ressource/image/icon/icon.png</normaloff>:/icon/ressource/image/icon/icon.png</iconset> </property> <layout class="QVBoxLayout" name="verticalLayout"> <property name="spacing"> @@ -63,7 +67,7 @@ </sizepolicy> </property> <property name="text"> - <string>Anchor :</string> + <string>Ancre :</string> </property> </widget> </item> @@ -158,7 +162,7 @@ </sizepolicy> </property> <property name="text"> - <string>Height </string> + <string>Hauteur</string> </property> </widget> </item> @@ -194,7 +198,7 @@ </sizepolicy> </property> <property name="text"> - <string>Width </string> + <string>Largeur</string> </property> </widget> </item> @@ -251,7 +255,9 @@ </item> </layout> </widget> - <resources/> + <resources> + <include location="../ressource.qrc"/> + </resources> <connections> <connection> <sender>_validatePushButton</sender> diff --git a/IHM_Retouche_Photo/mainwindow.cpp b/IHM_Retouche_Photo/mainwindow.cpp index eaaaa5228de6c342e5229678df66da1d71db88b6..42ca3e3bc5c7dca650dc9666280fd107c3f709d9 100644 --- a/IHM_Retouche_Photo/mainwindow.cpp +++ b/IHM_Retouche_Photo/mainwindow.cpp @@ -9,7 +9,6 @@ #include <QPushButton> #include <colorpickerwidget.h> - #include <ui/menu/filemenulambda.h> #include <ui/menu/displaymenulambda.h> #include <ui/menu/imagemenulambda.h> @@ -17,20 +16,24 @@ #include <ui/files/treefileselector.h> #include <tools/hand.h> +#include <tools/picker.h> + #include <tools/selectionable/rectangle.h> #include <tools/selectionable/rectangleTriangle.h> #include <tools/selectionable/triangle.h> #include <tools/selectionable/ellipse.h> #include <tools/selectionable/polygone.h> + #include <tools/editable/pixelpainter.h> +#include <tools/editable/pixelEraiser.h> +#include <tools/editable/bucket.h> #include <ui/view/repercussion/ignore.h> #include <ui/view/repercussion/clamp.h> #include <ui/view/repercussion/average.h> MainWindow::MainWindow(QWidget * parent) - : QMainWindow(parent), _toolRegister(), _fileselectorManager(nullptr), _viewManager(nullptr) { - + : QMainWindow(parent), _fileselectorManager(nullptr), _toolRegister(nullptr), _viewManager(nullptr) { this->setupUi(this); this->setAcceptDrops(true); @@ -76,19 +79,22 @@ MainWindow::MainWindow(QWidget * parent) qDebug() << "Mark_6"; - this->_toolRegister.setToolbox(this->_toolbox); - this->_toolRegister.setViewManager(this->_viewManager); + this->_toolRegister = new ui::ToolboxRegister(this->_toolConfigButton, this->_toolbox, this->_viewManager); + + this->_toolRegister->push_back(QSharedPointer<tool::Tool>(new tool::Hand(this->colorPickerWidget))); + this->_toolRegister->push_back(QSharedPointer<tool::Tool>(new tool::Picker(this->colorPickerWidget))); - 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::Tool>(new tool::Rectangle(this->colorPickerWidget))); + this->_toolRegister->push_back(QSharedPointer<tool::Tool>(new tool::RectangleTriangle(this->colorPickerWidget))); + this->_toolRegister->push_back(QSharedPointer<tool::Tool>(new tool::Triangle(this->colorPickerWidget))); + this->_toolRegister->push_back(QSharedPointer<tool::Tool>(new tool::Ellipse(this->colorPickerWidget))); + this->_toolRegister->push_back(QSharedPointer<tool::Tool>(new tool::Polygone(this->colorPickerWidget))); - this->_toolRegister.push_back(QSharedPointer<tool::Pixelpainter>(new tool::Pixelpainter(this->colorPickerWidget))); + this->_toolRegister->push_back(QSharedPointer<tool::Tool>(new tool::Pixelpainter(this->colorPickerWidget))); + this->_toolRegister->push_back(QSharedPointer<tool::Tool>(new tool::Pixeleraiser(this->colorPickerWidget))); + this->_toolRegister->push_back(QSharedPointer<tool::Tool>(new tool::Bucket(this->colorPickerWidget))); - this->_toolRegister.update(); + this->_toolRegister->update(); qDebug() << "Mark_7"; @@ -101,32 +107,32 @@ MainWindow::MainWindow(QWidget * parent) qDebug() << "Mark_7"; _actionNoirEtBlanc = new QAction(QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/color-picker-black.png"), "Convertir en Noir et Blanc", this); - toolBar->addAction(_actionNoirEtBlanc); + toolBarLeft->addAction(_actionNoirEtBlanc); connect(_actionNoirEtBlanc, &QAction::triggered, this, &MainWindow::convertToNoirEtBlancActionTriggered); _actionAdjustBrightnessContrast = new QAction("Ajuster la luminosité et le contraste", this); - toolBar->addAction(_actionAdjustBrightnessContrast); + toolBarLeft->addAction(_actionAdjustBrightnessContrast); connect(_actionAdjustBrightnessContrast, &QAction::triggered, this, &MainWindow::adjustBrightnessContrastActionTriggered); _actionAdjustBrightness = new QAction("Augmenter la luminosité", this); - toolBar->addAction(_actionAdjustBrightness); + toolBarLeft->addAction(_actionAdjustBrightness); _actionAdjustBrightness->setVisible(false); connect(_actionAdjustBrightness, &QAction::triggered, this, &MainWindow::increaseBrightnessActionTriggered); _actionDecreaseBrightness = new QAction("Diminuer la luminosité", this); - toolBar->addAction(_actionDecreaseBrightness); + toolBarLeft->addAction(_actionDecreaseBrightness); _actionDecreaseBrightness->setVisible(false); connect(_actionDecreaseBrightness, &QAction::triggered, this, &MainWindow::decreaseBrightnessActionTriggered); _actionIncreaseContrast = new QAction("Augmenter le contraste", this); - toolBar->addAction(_actionIncreaseContrast); + toolBarLeft->addAction(_actionIncreaseContrast); _actionIncreaseContrast->setVisible(false); connect(_actionIncreaseContrast, &QAction::triggered, this, &MainWindow::increaseContrastActionTriggered); _actionDecreaseContrast = new QAction("Diminuer le contraste", this); - toolBar->addAction(_actionDecreaseContrast); + toolBarLeft->addAction(_actionDecreaseContrast); _actionDecreaseContrast->setVisible(false); connect(_actionDecreaseContrast, &QAction::triggered, this, &MainWindow::decreaseContrastActionTriggered); @@ -207,6 +213,7 @@ void MainWindow::decreaseContrastActionTriggered() { MainWindow::~MainWindow() { delete this->_fileselectorManager; + delete this->_toolRegister; delete this->_viewManager; delete this->_rescaleDialog; delete this->_resizeDialog; diff --git a/IHM_Retouche_Photo/mainwindow.h b/IHM_Retouche_Photo/mainwindow.h index 4b7db4f9717a7da62a180aeb8c0cd9353ec0def3..40abaa6924ec9cda8c32d2b9e767929901dace04 100644 --- a/IHM_Retouche_Photo/mainwindow.h +++ b/IHM_Retouche_Photo/mainwindow.h @@ -21,13 +21,14 @@ class QAction; class MainWindow : public QMainWindow, private Ui::MainWindow { Q_OBJECT private: - ui::ToolboxRegister _toolRegister; ui::MenubarManager _menubarManager; ui::FileSelector * _fileselectorManager; + ui::ToolboxRegister * _toolRegister; ui::ViewManager * _viewManager; ui::MultyImageModifier * _multyImageModifier; + dialog::ReScaleDialog * _rescaleDialog; dialog::ReSizeDialog * _resizeDialog; diff --git a/IHM_Retouche_Photo/mainwindow.ui b/IHM_Retouche_Photo/mainwindow.ui index 071e42a399d2cbf32090559e113991fd72f12e6b..895df07c89a469a8bec085468dc5fdb88e5da5b4 100644 --- a/IHM_Retouche_Photo/mainwindow.ui +++ b/IHM_Retouche_Photo/mainwindow.ui @@ -6,12 +6,22 @@ <rect> <x>0</x> <y>0</y> - <width>763</width> - <height>494</height> + <width>998</width> + <height>698</height> </rect> </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="windowTitle"> - <string>MainWindow</string> + <string>Magic Pixel</string> + </property> + <property name="windowIcon"> + <iconset resource="ressource.qrc"> + <normaloff>:/icon/ressource/image/icon/icon.png</normaloff>:/icon/ressource/image/icon/icon.png</iconset> </property> <widget class="QWidget" name="_mainArea"> <layout class="QHBoxLayout" name="horizontalLayout_2"> @@ -33,7 +43,7 @@ <item> <widget class="QSplitter" name="_mainSpliter"> <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <sizepolicy hsizetype="Minimum" vsizetype="Expanding"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> @@ -41,12 +51,18 @@ <property name="frameShape"> <enum>QFrame::NoFrame</enum> </property> + <property name="frameShadow"> + <enum>QFrame::Plain</enum> + </property> <property name="lineWidth"> <number>3</number> </property> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> + <property name="opaqueResize"> + <bool>true</bool> + </property> <widget class="QWidget" name="_fileWidget" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Minimum"> @@ -84,7 +100,7 @@ </sizepolicy> </property> <property name="statusTip"> - <string/> + <string>Liste de touts les fichiers dans un répertoire.</string> </property> <property name="accessibleName"> <string/> @@ -101,6 +117,9 @@ <property name="lineWidth"> <number>0</number> </property> + <property name="tabKeyNavigation"> + <bool>true</bool> + </property> <property name="dragEnabled"> <bool>false</bool> </property> @@ -115,6 +134,13 @@ </attribute> </widget> </item> + <item> + <widget class="QLabel" name="_cuurentFilesLabel"> + <property name="text"> + <string>Fichiers Courrant :</string> + </property> + </widget> + </item> <item> <widget class="QListWidget" name="_filesSelected"> <property name="sizePolicy"> @@ -441,12 +467,19 @@ <item> <layout class="QVBoxLayout" name="_toolParameterLayout"> <property name="spacing"> - <number>0</number> + <number>6</number> </property> + <item> + <widget class="QLabel" name="_toolLabel"> + <property name="text"> + <string>Outils :</string> + </property> + </widget> + </item> <item> <widget class="QListWidget" name="_toolbox"> <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <sizepolicy hsizetype="Minimum" vsizetype="Expanding"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> @@ -458,7 +491,7 @@ <string/> </property> <property name="statusTip"> - <string/> + <string>Listes des outils utilisable.</string> </property> <property name="frameShape"> <enum>QFrame::NoFrame</enum> @@ -480,6 +513,20 @@ </property> </widget> </item> + <item> + <widget class="QPushButton" name="_toolConfigButton"> + <property name="statusTip"> + <string>Button de configuration de l'outil courrant.</string> + </property> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset resource="ressource.qrc"> + <normaloff>:/oxygen/16x16/ressource/image/oxygen/icons/16x16/applications-system.png</normaloff>:/oxygen/16x16/ressource/image/oxygen/icons/16x16/applications-system.png</iconset> + </property> + </widget> + </item> <item> <layout class="QVBoxLayout" name="_multyDrawArea"> <property name="leftMargin"> @@ -494,6 +541,13 @@ <property name="bottomMargin"> <number>8</number> </property> + <item> + <widget class="QLabel" name="_multyEditingLabel"> + <property name="text"> + <string>Édition Multiple d'images :</string> + </property> + </widget> + </item> <item> <widget class="QCheckBox" name="_emitDrawCheckbox"> <property name="sizePolicy"> @@ -540,6 +594,9 @@ <verstretch>0</verstretch> </sizepolicy> </property> + <property name="statusTip"> + <string>Liste des algorithmes applicable lors de lédition multiple d'images.</string> + </property> <property name="frameShape"> <enum>QFrame::NoFrame</enum> </property> @@ -565,7 +622,7 @@ <rect> <x>0</x> <y>0</y> - <width>763</width> + <width>998</width> <height>21</height> </rect> </property> @@ -587,17 +644,6 @@ <addaction name="_action_close"/> <addaction name="_action_quit"/> </widget> - <widget class="QMenu" name="_menuEdit"> - <property name="title"> - <string>Édition</string> - </property> - <addaction name="_action_undo"/> - <addaction name="_action_redo"/> - <addaction name="separator"/> - <addaction name="_action_cut"/> - <addaction name="_action_copy"/> - <addaction name="_action_paste"/> - </widget> <widget class="QMenu" name="_menuImage"> <property name="title"> <string>Image</string> @@ -651,14 +697,13 @@ <addaction name="_action_del"/> </widget> <addaction name="_menuFile"/> - <addaction name="_menuEdit"/> <addaction name="_menuSelection"/> <addaction name="_menuAffichage"/> <addaction name="_menuImage"/> <addaction name="_menuHelp"/> </widget> <widget class="QStatusBar" name="_statusbar"/> - <widget class="QToolBar" name="toolBar"> + <widget class="QToolBar" name="toolBarLeft"> <property name="enabled"> <bool>true</bool> </property> @@ -686,6 +731,17 @@ <addaction name="_action_turn_verticaly"/> <addaction name="_action_turn_horizonaly"/> </widget> + <widget class="QToolBar" name="toolBarRight"> + <property name="windowTitle"> + <string>toolBar_2</string> + </property> + <attribute name="toolBarArea"> + <enum>RightToolBarArea</enum> + </attribute> + <attribute name="toolBarBreak"> + <bool>false</bool> + </attribute> + </widget> <action name="_action_new"> <property name="icon"> <iconset resource="ressource.qrc"> @@ -1094,6 +1150,18 @@ </action> </widget> <tabstops> + <tabstop>_filesSelector</tabstop> + <tabstop>_filesSelected</tabstop> + <tabstop>_add_selectable_element</tabstop> + <tabstop>_remove_selectable_element</tabstop> + <tabstop>_colorPicker</tabstop> + <tabstop>_rescaleButton</tabstop> + <tabstop>_resizeButton</tabstop> + <tabstop>_toolbox</tabstop> + <tabstop>_toolConfigButton</tabstop> + <tabstop>_emitDrawCheckbox</tabstop> + <tabstop>_receiveDrawCheckbox</tabstop> + <tabstop>_samplingDrawList</tabstop> <tabstop>_imageTabs</tabstop> <tabstop>_imageView</tabstop> </tabstops> @@ -1108,12 +1176,12 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>601</x> - <y>344</y> + <x>968</x> + <y>467</y> </hint> <hint type="destinationlabel"> - <x>591</x> - <y>374</y> + <x>968</x> + <y>665</y> </hint> </hints> </connection> diff --git a/IHM_Retouche_Photo/ressource.qrc b/IHM_Retouche_Photo/ressource.qrc index 16c0a8bfc2643bb3595f361a5a874a2872172a36..c596b9646953731f199f82958964ec5a6f874f2f 100644 --- a/IHM_Retouche_Photo/ressource.qrc +++ b/IHM_Retouche_Photo/ressource.qrc @@ -475,4 +475,7 @@ <file>ressource/image/oxygen/icons/64x64/transform-scale.png</file> <file>ressource/image/oxygen/icons/64x64/view-conversation-balloon.png</file> </qresource> + <qresource prefix="/icon"> + <file>ressource/image/icon/icon.png</file> + </qresource> </RCC> diff --git a/IHM_Retouche_Photo/ressource/image/icon/icon.png b/IHM_Retouche_Photo/ressource/image/icon/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..906c1b830e1d60e50861d432c8d447cd51ab89c7 Binary files /dev/null and b/IHM_Retouche_Photo/ressource/image/icon/icon.png differ diff --git a/IHM_Retouche_Photo/tools/editable.h b/IHM_Retouche_Photo/tools/editable.h index 48a8512e50f185dec830f793f923dd15ef254190..332cbe06d4bfc1f607aa65b61f9faaa548237eb6 100644 --- a/IHM_Retouche_Photo/tools/editable.h +++ b/IHM_Retouche_Photo/tools/editable.h @@ -13,6 +13,8 @@ namespace tool { public: Editable(const ColorPickerWidget &, const QString & = "NaN", const QIcon & = QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-freehand.png"), bool = false); + inline const ColorPickerWidget * colorPicker() const {return this->_colorPicker;} + 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; diff --git a/IHM_Retouche_Photo/tools/editable/bucket.cpp b/IHM_Retouche_Photo/tools/editable/bucket.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ac516896a3e0cbbb3de3c1ea824ba916b028168d --- /dev/null +++ b/IHM_Retouche_Photo/tools/editable/bucket.cpp @@ -0,0 +1,27 @@ +#include "bucket.h" + +namespace tool { + Bucket::Bucket(const ColorPickerWidget & cp) + : Editable(cp, "Pot de painture", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/actions-fill-color-icon.png")) {} + + void Bucket::onMousePressed(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &, const ColorPickerWidget &) {} + + void Bucket::onMouseReleased(ui::ImageArea & a, QImage & i, const QPoint & p, const ui::Selection & s, const QMouseEvent & e, const ColorPickerWidget & cp) { + if(e.button() == Qt::LeftButton) { + if(!s.empty() && s.contain(p)) { + for(auto & point : s.selection()) { + a.setColor(point, cp.currentColor()); + } + } + else { + for(int x = 0; x < i.width(); x++) { + for(int y = 0; y < i.height(); y++) { + a.setColor(QPoint(x,y), cp.currentColor()); + } + } + } + } + } + + void Bucket::onMouseMoved(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &, const ColorPickerWidget &, bool) {} +} diff --git a/IHM_Retouche_Photo/tools/editable/bucket.h b/IHM_Retouche_Photo/tools/editable/bucket.h new file mode 100644 index 0000000000000000000000000000000000000000..c5dd9bab3bd0cb6ea10cc0b03e7ac3db57af139e --- /dev/null +++ b/IHM_Retouche_Photo/tools/editable/bucket.h @@ -0,0 +1,14 @@ +#pragma once + +#include "../editable.h" + +namespace tool { + class Bucket : public Editable { + public: + Bucket(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/editable/pixelEraiser.cpp b/IHM_Retouche_Photo/tools/editable/pixelEraiser.cpp new file mode 100644 index 0000000000000000000000000000000000000000..16998de2cdc65482b738c3f7af8b6b417d45a7f3 --- /dev/null +++ b/IHM_Retouche_Photo/tools/editable/pixelEraiser.cpp @@ -0,0 +1,29 @@ +#include "pixelEraiser.h" + +namespace tool { + Pixeleraiser::Pixeleraiser(const ColorPickerWidget & cp) + : Editable(cp, "Gomme Pixel", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-eraser.png")), _leftButton(false) {} + + void Pixeleraiser::onMousePressed(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e, const ColorPickerWidget &) { + if(e.button() == Qt::LeftButton) { + this->_leftButton = true; + } + } + + void Pixeleraiser::onMouseReleased(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e, const ColorPickerWidget &) { + if(e.button() == Qt::LeftButton) { + this->_leftButton = false; + } + } + + void Pixeleraiser::onMouseMoved(ui::ImageArea & a, QImage &, const QPoint & p, const ui::Selection & s, const QMouseEvent &, const ColorPickerWidget &, bool hold) { + if(hold && this->_leftButton) { + if(s.empty()) { + a.setColor(p, QColor(0, 0, 0, 0)); + } + else if(s.contain(p)) { + a.setColor(p, QColor(0, 0, 0, 0)); + } + } + } +} diff --git a/IHM_Retouche_Photo/tools/editable/pixelEraiser.h b/IHM_Retouche_Photo/tools/editable/pixelEraiser.h new file mode 100644 index 0000000000000000000000000000000000000000..14a1495ff7228b0dbd8eba522b666aa6377af2c5 --- /dev/null +++ b/IHM_Retouche_Photo/tools/editable/pixelEraiser.h @@ -0,0 +1,17 @@ +#pragma once + +#include "../editable.h" + +namespace tool { + class Pixeleraiser : public Editable { + private: + bool _leftButton; + + public: + Pixeleraiser(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/editable/pixelpainter.cpp b/IHM_Retouche_Photo/tools/editable/pixelpainter.cpp index 693cb6723a842e835c1f013b7b2d30fdc91d84fd..4d96ffb22b193905a080e8fa111e5f837a4313c8 100644 --- a/IHM_Retouche_Photo/tools/editable/pixelpainter.cpp +++ b/IHM_Retouche_Photo/tools/editable/pixelpainter.cpp @@ -2,7 +2,7 @@ namespace tool { Pixelpainter::Pixelpainter(const ColorPickerWidget & cp) - : Editable(cp, "Pixel", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/application-pgp-signature.png")), _leftButton(false) {} + : Editable(cp, "Crayon Pixel", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/draw-freehand.png")), _leftButton(false) {} void Pixelpainter::onMousePressed(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent & e, const ColorPickerWidget &) { if(e.button() == Qt::LeftButton) { @@ -16,9 +16,12 @@ namespace tool { } } - void Pixelpainter::onMouseMoved(ui::ImageArea & a, QImage & , const QPoint & p, const ui::Selection & s, const QMouseEvent &, const ColorPickerWidget & cp, bool hold) { + void Pixelpainter::onMouseMoved(ui::ImageArea & a, QImage &, const QPoint & p, const ui::Selection & s, const QMouseEvent &, const ColorPickerWidget & cp, bool hold) { if(hold && this->_leftButton) { - if(s.contain(p)) { + if(s.empty()) { + a.setColor(p, cp.currentColor()); + } + else if(s.contain(p)) { a.setColor(p, cp.currentColor()); } } diff --git a/IHM_Retouche_Photo/tools/picker.cpp b/IHM_Retouche_Photo/tools/picker.cpp new file mode 100644 index 0000000000000000000000000000000000000000..47e823caade289c6b40d1535b1a0961800847878 --- /dev/null +++ b/IHM_Retouche_Photo/tools/picker.cpp @@ -0,0 +1,26 @@ +#include "picker.h" + +namespace tool { + Picker::Picker(const ColorPickerWidget & cp) + : Editable(cp, "Pipette", QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/color-picker.png"), true) { + QObject::connect(this, SIGNAL(colorPicked(QColor)), &cp, SLOT(addColor(QColor))); + } + + Picker::~Picker() { + QObject::connect(this, SIGNAL(colorPicked(QColor)), this->colorPicker(), SLOT(addColor(QColor))); + } + + void Picker::onMousePressed(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &, const ColorPickerWidget &) { + + } + + void Picker::onMouseReleased(ui::ImageArea &, QImage & i, const QPoint & p, const ui::Selection &, const QMouseEvent & e, const ColorPickerWidget &) { + if(e.button() == Qt::LeftButton) { + emit this->colorPicked(i.pixelColor(p)); + } + } + + void Picker::onMouseMoved(ui::ImageArea &, QImage &, const QPoint &, const ui::Selection &, const QMouseEvent &, const ColorPickerWidget &, bool) { + + } +} diff --git a/IHM_Retouche_Photo/tools/picker.h b/IHM_Retouche_Photo/tools/picker.h new file mode 100644 index 0000000000000000000000000000000000000000..d2252d1dbd855d5e411ea3dc74e2bbe26937cb4b --- /dev/null +++ b/IHM_Retouche_Photo/tools/picker.h @@ -0,0 +1,21 @@ +#pragma once + +#include "editable.h" + +namespace tool { + class Picker : public Editable { + Q_OBJECT + public: + Picker(const ColorPickerWidget &); + virtual ~Picker(); + + 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); + + signals: + void colorPicked(const QColor &); + + + }; +} diff --git a/IHM_Retouche_Photo/tools/selectionnable.h b/IHM_Retouche_Photo/tools/selectionnable.h index 40cd3e496de2fa4369eb1f56907964caeec7b80a..cbbabcf55c7458e6c0e4199fb56dc8d2c3b6167b 100644 --- a/IHM_Retouche_Photo/tools/selectionnable.h +++ b/IHM_Retouche_Photo/tools/selectionnable.h @@ -13,6 +13,8 @@ namespace tool { public: Selectionable(const ColorPickerWidget &, const QString & = "NaN", const QIcon & = QIcon(":/oxygen/16x16/ressource/image/oxygen/icons/16x16/transform-crop.png"), bool = false); + inline const ColorPickerWidget * colorPicker() const {return this->_colorPicker;} + 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; diff --git a/IHM_Retouche_Photo/tools/tool.cpp b/IHM_Retouche_Photo/tools/tool.cpp index 174e12e473ed4fb2ec4c224d73d48e7c4b33422f..715683553b73fdc46d75afca2995492487ee83c3 100644 --- a/IHM_Retouche_Photo/tools/tool.cpp +++ b/IHM_Retouche_Photo/tools/tool.cpp @@ -1,9 +1,15 @@ #include "tool.h" namespace tool { - Tool::Tool(const QString & name, const QIcon & icon) - : QListWidgetItem() { + Tool::Tool(const QString & name, const QIcon & icon, QSharedPointer<QDialog> configDialog) + : QListWidgetItem(), _configurationDialog(configDialog) { this->setText(name); this->setIcon(icon); } + + void Tool::showConfiguration() { + if(!this->_configurationDialog.isNull()) { + this->_configurationDialog.get()->exec(); + } + } } diff --git a/IHM_Retouche_Photo/tools/tool.h b/IHM_Retouche_Photo/tools/tool.h index 810fa5803a4be05c87a0fd1618a4b3d5422e2706..37c517262e524749e93e14443392148a5cb1ce52 100644 --- a/IHM_Retouche_Photo/tools/tool.h +++ b/IHM_Retouche_Photo/tools/tool.h @@ -3,17 +3,24 @@ #include <QListWidgetItem> #include <QObject> #include <QCursor> +#include <QDialog> #include "../ui/view/imagearea.h" namespace tool { class Tool : public QObject, public QListWidgetItem { Q_OBJECT + private: + QSharedPointer<QDialog> _configurationDialog; + public: - Tool(const QString &, const QIcon &); + Tool(const QString &, const QIcon &, QSharedPointer<QDialog> = nullptr); virtual inline Qt::CursorShape shape() const {return Qt::CursorShape::ArrowCursor;} + inline bool HaveConfigurationDialog() const {return !this->_configurationDialog.isNull();} + inline QDialog * configurationDialog() const {return this->_configurationDialog.get();} + public slots: virtual void pressed(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &) = 0; virtual void released(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QMouseEvent &) = 0; @@ -22,5 +29,7 @@ namespace tool { virtual void keyPressed(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QKeyEvent &) = 0; virtual void keyReleased(ui::ImageArea &, QImage &, QPoint &, ui::Selection &, QKeyEvent &) = 0; + void showConfiguration(); + }; } diff --git a/IHM_Retouche_Photo/ui/toolbox/toolRegister.cpp b/IHM_Retouche_Photo/ui/toolbox/toolRegister.cpp index 0e922948e79b80cf4245743d6a74fbe8eef8c4f5..04dfa4ffdbafc0ba8990e34f5c1c309151c4af04 100644 --- a/IHM_Retouche_Photo/ui/toolbox/toolRegister.cpp +++ b/IHM_Retouche_Photo/ui/toolbox/toolRegister.cpp @@ -1,11 +1,12 @@ #include "toolRegister.h" namespace ui { - ToolboxRegister::ToolboxRegister(Toolbox * toolbox, ViewManager * manager, const QList<tool::Tool *> & tools) - : _toolbox(toolbox), _viewManager(manager), _currentTool(nullptr), _currentImage(nullptr) { + ToolboxRegister::ToolboxRegister(QPushButton * configButton, Toolbox * toolbox, ViewManager * manager, const QList<tool::Tool *> & tools) + : _toolbox(toolbox), _viewManager(manager),_configButton(configButton) , _currentTool(nullptr), _currentImage(nullptr) { for(auto & tool : tools) { this->push_back(QSharedPointer<tool::Tool>(tool)); } + configButton->setEnabled(false); } void ToolboxRegister::update() { @@ -14,7 +15,7 @@ namespace ui { this->_toolbox->addItem(tool.get()); } - QObject::connect(this->_toolbox, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(updateCurrentTool(QListWidgetItem*))); + QObject::connect(this->_toolbox, SIGNAL(itemPressed(QListWidgetItem*)), this, SLOT(updateCurrentTool(QListWidgetItem*))); QObject::connect(this->_viewManager, SIGNAL(changedView(ImageArea*)), this, SLOT(updateCurrentView(ImageArea*))); QObject::connect(this->_viewManager, SIGNAL(createdView(ImageArea*)), this, SLOT(updateCurrentView(ImageArea*))); @@ -30,6 +31,9 @@ namespace ui { QObject::disconnect(this->_currentImage, SIGNAL(keyboardPress(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&)), this->_currentTool, SLOT(keyPressed(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&))); QObject::disconnect(this->_currentImage, SIGNAL(keyboardRelease(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&)), this->_currentTool, SLOT(keyReleased(ui::ImageArea&,QImage&,QPoint&,ui::Selection&,QKeyEvent&))); + if(this->_currentTool->HaveConfigurationDialog()) { + QObject::disconnect(this->_configButton, SIGNAL(released()), this->_currentTool, SLOT(showConfiguration())); + } } this->_currentTool = dynamic_cast<tool::Tool*>(item); @@ -42,6 +46,10 @@ 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&))); + + QObject::connect(this->_configButton, SIGNAL(released()), this->_currentTool, SLOT(showConfiguration())); + this->_configButton->setEnabled(this->_currentTool->HaveConfigurationDialog()); + } } diff --git a/IHM_Retouche_Photo/ui/toolbox/toolRegister.h b/IHM_Retouche_Photo/ui/toolbox/toolRegister.h index e93514ae32c8f739ccb94eefd9666882e4b43ffb..36afd3c085f9b5fdc62eab8712384415f226dce9 100644 --- a/IHM_Retouche_Photo/ui/toolbox/toolRegister.h +++ b/IHM_Retouche_Photo/ui/toolbox/toolRegister.h @@ -3,6 +3,7 @@ #include <QVector> #include <QSharedPointer> #include <QListWidget> +#include <QPushButton> #include <tools/tool.h> @@ -15,14 +16,18 @@ using Toolbox = QListWidget; public: Toolbox * _toolbox; ViewManager * _viewManager; + QPushButton * _configButton; + tool::Tool * _currentTool; ImageArea * _currentImage; public: - ToolboxRegister(Toolbox * = nullptr, ViewManager * = nullptr, const QList<tool::Tool *> & = {}); + ToolboxRegister(QPushButton * = nullptr, Toolbox * = nullptr, ViewManager * = nullptr, const QList<tool::Tool *> & = {}); inline void setToolbox(Toolbox * toolbox) {this->_toolbox = toolbox;} inline void setViewManager(ViewManager * viewManager) {this->_viewManager = viewManager;} + inline void setConfigurationButton(QPushButton * button) {this->_configButton = button;} + inline const Toolbox * toolbox() const {return this->_toolbox;} void update();