mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-18 06:10:29 +02:00
Modularisation
This commit is contained in:
@@ -111,18 +111,15 @@ void IntelliPhotoGui::slotDeleteLayer()
|
|||||||
paintingArea->deleteLayer(layerNumber);
|
paintingArea->deleteLayer(layerNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntelliPhotoGui::slotGetColorbar(){
|
void slotCreatePenTool(){
|
||||||
|
|
||||||
bool ok1;
|
|
||||||
|
|
||||||
int firstOrSecondColor = QInputDialog::getInt(this, tr("Which Color"),
|
|
||||||
tr("Number:"),
|
|
||||||
1,1, 2, 1, &ok1);
|
|
||||||
|
|
||||||
Tool = paintingArea->getTool();
|
|
||||||
Tool->getColorbar(firstOrSecondColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void slotCreateFloodFillTool(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void IntelliPhotoGui::slotSetActiveAlpha(){
|
void IntelliPhotoGui::slotSetActiveAlpha(){
|
||||||
// Stores button value
|
// Stores button value
|
||||||
bool ok1, ok2;
|
bool ok1, ok2;
|
||||||
@@ -218,6 +215,14 @@ void IntelliPhotoGui::slotSetActiveLayer(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void IntelliPhotoGui::slotCreatePenTool(){
|
||||||
|
paintingArea->createPenTool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliPhotoGui::slotCreateFloodFillTool(){
|
||||||
|
paintingArea->createFloodFillTool();
|
||||||
|
}
|
||||||
|
|
||||||
// Open an about dialog
|
// Open an about dialog
|
||||||
void IntelliPhotoGui::slotAboutDialog()
|
void IntelliPhotoGui::slotAboutDialog()
|
||||||
{
|
{
|
||||||
@@ -275,17 +280,10 @@ void IntelliPhotoGui::createActions()
|
|||||||
actionCreateNewLayer = new QAction(tr("&New Layer..."), this);
|
actionCreateNewLayer = new QAction(tr("&New Layer..."), this);
|
||||||
connect(actionCreateNewLayer, SIGNAL(triggered()), this, SLOT(slotCreateNewLayer()));
|
connect(actionCreateNewLayer, SIGNAL(triggered()), this, SLOT(slotCreateNewLayer()));
|
||||||
|
|
||||||
|
|
||||||
// Delete New Layer action and tie to IntelliPhotoGui::deleteLayer()
|
// Delete New Layer action and tie to IntelliPhotoGui::deleteLayer()
|
||||||
actionDeleteLayer = new QAction(tr("&Delete Layer..."), this);
|
actionDeleteLayer = new QAction(tr("&Delete Layer..."), this);
|
||||||
connect(actionDeleteLayer, SIGNAL(triggered()), this, SLOT(slotDeleteLayer()));
|
connect(actionDeleteLayer, SIGNAL(triggered()), this, SLOT(slotDeleteLayer()));
|
||||||
|
|
||||||
actionGetColorbar = new QAction(tr("&Set Color"),this);
|
|
||||||
connect(actionGetColorbar, SIGNAL(triggered()), this, SLOT(slotGetColorbar()));
|
|
||||||
|
|
||||||
actionFloodFill = new QAction(tr("&clear Image"), this);
|
|
||||||
connect(actionFloodFill, SIGNAL(triggered()), this, SLOT(slotClearActiveLayer()));
|
|
||||||
|
|
||||||
actionSetActiveLayer = new QAction(tr("&set Active"), this);
|
actionSetActiveLayer = new QAction(tr("&set Active"), this);
|
||||||
connect(actionSetActiveLayer, SIGNAL(triggered()), this, SLOT(slotSetActiveLayer()));
|
connect(actionSetActiveLayer, SIGNAL(triggered()), this, SLOT(slotSetActiveLayer()));
|
||||||
|
|
||||||
@@ -316,6 +314,14 @@ void IntelliPhotoGui::createActions()
|
|||||||
actionMoveLayerDown->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Down));
|
actionMoveLayerDown->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Down));
|
||||||
connect(actionMoveLayerDown, SIGNAL(triggered()), this, SLOT(slotMoveLayerDown()));
|
connect(actionMoveLayerDown, SIGNAL(triggered()), this, SLOT(slotMoveLayerDown()));
|
||||||
|
|
||||||
|
//Create Tool actions down here
|
||||||
|
actionCreateFloodFillTool = new QAction(tr("&Flood Fill"), this);
|
||||||
|
connect(actionCreateFloodFillTool, SIGNAL(triggered()), this, SLOT(slotCreateFloodFillTool()));
|
||||||
|
|
||||||
|
actionCreatePenTool = new QAction(tr("&Pen"),this);
|
||||||
|
connect(actionCreatePenTool, SIGNAL(triggered()), this, SLOT(slotCreatePenTool()));
|
||||||
|
|
||||||
|
|
||||||
// Create about action and tie to IntelliPhotoGui::about()
|
// Create about action and tie to IntelliPhotoGui::about()
|
||||||
actionAboutDialog = new QAction(tr("&About"), this);
|
actionAboutDialog = new QAction(tr("&About"), this);
|
||||||
connect(actionAboutDialog, SIGNAL(triggered()), this, SLOT(slotAboutDialog()));
|
connect(actionAboutDialog, SIGNAL(triggered()), this, SLOT(slotAboutDialog()));
|
||||||
@@ -343,7 +349,6 @@ void IntelliPhotoGui::createMenus()
|
|||||||
|
|
||||||
// Attach all actions to Options
|
// Attach all actions to Options
|
||||||
optionMenu = new QMenu(tr("&Options"), this);
|
optionMenu = new QMenu(tr("&Options"), this);
|
||||||
optionMenu->addAction(actionFloodFill);
|
|
||||||
optionMenu->addAction(actionSetActiveLayer);
|
optionMenu->addAction(actionSetActiveLayer);
|
||||||
optionMenu->addAction(actionSetActiveAlpha);
|
optionMenu->addAction(actionSetActiveAlpha);
|
||||||
optionMenu->addAction(actionMovePositionUp);
|
optionMenu->addAction(actionMovePositionUp);
|
||||||
@@ -360,7 +365,8 @@ void IntelliPhotoGui::createMenus()
|
|||||||
|
|
||||||
//Attach all Tool Options
|
//Attach all Tool Options
|
||||||
toolMenu = new QMenu(tr("&Tools"), this);
|
toolMenu = new QMenu(tr("&Tools"), this);
|
||||||
toolMenu->addAction(actionGetColorbar);
|
toolMenu->addAction(actionCreatePenTool);
|
||||||
|
toolMenu->addAction(actionCreateFloodFillTool);
|
||||||
|
|
||||||
// Attach all actions to Help
|
// Attach all actions to Help
|
||||||
helpMenu = new QMenu(tr("&Help"), this);
|
helpMenu = new QMenu(tr("&Help"), this);
|
||||||
|
|||||||
@@ -33,11 +33,6 @@ private slots:
|
|||||||
void slotSave();
|
void slotSave();
|
||||||
void slotCreateNewLayer();
|
void slotCreateNewLayer();
|
||||||
void slotDeleteLayer();
|
void slotDeleteLayer();
|
||||||
|
|
||||||
void slotGetColorbar();
|
|
||||||
|
|
||||||
void slotAboutDialog();
|
|
||||||
|
|
||||||
void slotClearActiveLayer();
|
void slotClearActiveLayer();
|
||||||
void slotSetActiveLayer();
|
void slotSetActiveLayer();
|
||||||
void slotSetActiveAlpha();
|
void slotSetActiveAlpha();
|
||||||
@@ -48,6 +43,11 @@ private slots:
|
|||||||
void slotMoveLayerUp();
|
void slotMoveLayerUp();
|
||||||
void slotMoveLayerDown();
|
void slotMoveLayerDown();
|
||||||
|
|
||||||
|
void slotCreatePenTool();
|
||||||
|
void slotCreateFloodFillTool();
|
||||||
|
|
||||||
|
void slotAboutDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Will tie user actions to functions
|
// Will tie user actions to functions
|
||||||
void createActions();
|
void createActions();
|
||||||
@@ -82,12 +82,12 @@ private:
|
|||||||
QAction *actionCreateNewLayer;
|
QAction *actionCreateNewLayer;
|
||||||
QAction *actionDeleteLayer;
|
QAction *actionDeleteLayer;
|
||||||
|
|
||||||
QAction *actionGetColorbar;
|
QAction *actionCreatePenTool;
|
||||||
|
QAction *actionCreateFloodFillTool;
|
||||||
|
|
||||||
QAction *actionAboutDialog;
|
QAction *actionAboutDialog;
|
||||||
QAction *actionAboutQtDialog;
|
QAction *actionAboutQtDialog;
|
||||||
|
|
||||||
QAction* actionFloodFill;
|
|
||||||
QAction* actionSetActiveLayer;
|
QAction* actionSetActiveLayer;
|
||||||
QAction* actionSetActiveAlpha;
|
QAction* actionSetActiveAlpha;
|
||||||
QAction* actionMovePositionUp;
|
QAction* actionMovePositionUp;
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ SOURCES += \
|
|||||||
Tool/IntelliTool.cpp \
|
Tool/IntelliTool.cpp \
|
||||||
Tool/IntelliToolFloodFillTool.cpp \
|
Tool/IntelliToolFloodFillTool.cpp \
|
||||||
Tool/IntelliToolPen.cpp \
|
Tool/IntelliToolPen.cpp \
|
||||||
Tool/IntelliToolSetColorTool.cpp \
|
|
||||||
main.cpp
|
main.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
@@ -37,8 +36,7 @@ HEADERS += \
|
|||||||
Layer/PaintingArea.h \
|
Layer/PaintingArea.h \
|
||||||
Tool/IntelliTool.h \
|
Tool/IntelliTool.h \
|
||||||
Tool/IntelliToolFloodFillTool.h \
|
Tool/IntelliToolFloodFillTool.h \
|
||||||
Tool/IntelliToolPen.h \
|
Tool/IntelliToolPen.h
|
||||||
Tool/IntelliToolSetColorTool.h
|
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
widget.ui
|
widget.ui
|
||||||
|
|||||||
@@ -11,14 +11,12 @@
|
|||||||
#include "Image/IntelliRasterImage.h"
|
#include "Image/IntelliRasterImage.h"
|
||||||
#include "Image/IntelliShapedImage.h"
|
#include "Image/IntelliShapedImage.h"
|
||||||
#include "Tool/IntelliToolPen.h"
|
#include "Tool/IntelliToolPen.h"
|
||||||
#include "Tool/IntelliToolSetColorTool.h"
|
|
||||||
#include "Tool/IntelliToolFloodFillTool.h"
|
#include "Tool/IntelliToolFloodFillTool.h"
|
||||||
|
|
||||||
|
|
||||||
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent)
|
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent)
|
||||||
:QWidget(parent){
|
:QWidget(parent){
|
||||||
this->Tool = new IntelliToolFloodFillTool(this);
|
this->Tool = nullptr;
|
||||||
this->ColorTool = new IntelliToolSetColorTool(this);
|
|
||||||
this->setUp(maxWidth, maxHeight);
|
this->setUp(maxWidth, maxHeight);
|
||||||
//tetsing
|
//tetsing
|
||||||
this->addLayer(200,200,0,0,ImageType::Shaped_Image);
|
this->addLayer(200,200,0,0,ImageType::Shaped_Image);
|
||||||
@@ -37,9 +35,6 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent)
|
|||||||
activeLayer=1;
|
activeLayer=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntelliToolSetColorTool* PaintingArea::getTool(){
|
|
||||||
return ColorTool;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PaintingArea::setUp(int maxWidth, int maxHeight){
|
void PaintingArea::setUp(int maxWidth, int maxHeight){
|
||||||
//set standart parameter
|
//set standart parameter
|
||||||
@@ -165,11 +160,23 @@ void PaintingArea::slotActivateLayer(int a){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PaintingArea::createPenTool(){
|
||||||
|
delete this->Tool;
|
||||||
|
Tool = new IntelliToolPen(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PaintingArea::createFloodFillTool(){
|
||||||
|
delete this->Tool;
|
||||||
|
Tool = new IntelliToolFloodFillTool(this);
|
||||||
|
}
|
||||||
|
|
||||||
// If a mouse button is pressed check if it was the
|
// If a mouse button is pressed check if it was the
|
||||||
// left button and if so store the current position
|
// left button and if so store the current position
|
||||||
// Set that we are currently drawing
|
// Set that we are currently drawing
|
||||||
void PaintingArea::mousePressEvent(QMouseEvent *event)
|
void PaintingArea::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
if(Tool == nullptr)
|
||||||
|
return;
|
||||||
int x = event->x()-layerBundle[activeLayer].widthOffset;
|
int x = event->x()-layerBundle[activeLayer].widthOffset;
|
||||||
int y = event->y()-layerBundle[activeLayer].hightOffset;
|
int y = event->y()-layerBundle[activeLayer].hightOffset;
|
||||||
if(event->button() == Qt::LeftButton){
|
if(event->button() == Qt::LeftButton){
|
||||||
@@ -185,6 +192,8 @@ void PaintingArea::mousePressEvent(QMouseEvent *event)
|
|||||||
// from the last position to the current
|
// from the last position to the current
|
||||||
void PaintingArea::mouseMoveEvent(QMouseEvent *event)
|
void PaintingArea::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
if(Tool == nullptr)
|
||||||
|
return;
|
||||||
int x = event->x()-layerBundle[activeLayer].widthOffset;
|
int x = event->x()-layerBundle[activeLayer].widthOffset;
|
||||||
int y = event->y()-layerBundle[activeLayer].hightOffset;
|
int y = event->y()-layerBundle[activeLayer].hightOffset;
|
||||||
Tool->onMouseMoved(x, y);
|
Tool->onMouseMoved(x, y);
|
||||||
@@ -193,6 +202,8 @@ void PaintingArea::mouseMoveEvent(QMouseEvent *event)
|
|||||||
// If the button is released we set variables to stop drawing
|
// If the button is released we set variables to stop drawing
|
||||||
void PaintingArea::mouseReleaseEvent(QMouseEvent *event)
|
void PaintingArea::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
if(Tool == nullptr)
|
||||||
|
return;
|
||||||
int x = event->x()-layerBundle[activeLayer].widthOffset;
|
int x = event->x()-layerBundle[activeLayer].widthOffset;
|
||||||
int y = event->y()-layerBundle[activeLayer].hightOffset;
|
int y = event->y()-layerBundle[activeLayer].hightOffset;
|
||||||
if(event->button() == Qt::LeftButton){
|
if(event->button() == Qt::LeftButton){
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include "Image/IntelliImage.h"
|
#include "Image/IntelliImage.h"
|
||||||
#include "Tool/IntelliTool.h"
|
#include "Tool/IntelliTool.h"
|
||||||
#include "Tool/IntelliToolSetColorTool.h"
|
|
||||||
|
|
||||||
|
|
||||||
struct LayerObject{
|
struct LayerObject{
|
||||||
@@ -33,8 +32,6 @@ class PaintingArea : public QWidget
|
|||||||
public:
|
public:
|
||||||
PaintingArea(int maxWidth=600, int maxHeight=600, QWidget *parent = nullptr);
|
PaintingArea(int maxWidth=600, int maxHeight=600, QWidget *parent = nullptr);
|
||||||
|
|
||||||
IntelliToolSetColorTool* getTool(); //TODO: rename function, when there are more Tools
|
|
||||||
|
|
||||||
// Handles all events
|
// Handles all events
|
||||||
bool open(const QString &fileName);
|
bool open(const QString &fileName);
|
||||||
bool save(const QString &fileName, const char *fileFormat);
|
bool save(const QString &fileName, const char *fileFormat);
|
||||||
@@ -51,6 +48,9 @@ public:
|
|||||||
// Has the image been modified since last save
|
// Has the image been modified since last save
|
||||||
bool isModified() const { return modified; }
|
bool isModified() const { return modified; }
|
||||||
|
|
||||||
|
//create tools
|
||||||
|
void createPenTool();
|
||||||
|
void createFloodFillTool();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
@@ -81,7 +81,6 @@ private:
|
|||||||
int maxHeight;
|
int maxHeight;
|
||||||
|
|
||||||
IntelliTool* Tool;
|
IntelliTool* Tool;
|
||||||
IntelliToolSetColorTool* ColorTool;
|
|
||||||
|
|
||||||
std::vector<LayerObject> layerBundle;
|
std::vector<LayerObject> layerBundle;
|
||||||
int activeLayer=-1;
|
int activeLayer=-1;
|
||||||
|
|||||||
@@ -1,41 +1,30 @@
|
|||||||
#include "IntelliToolFloodFillTool.h"
|
#include "IntelliToolFloodFillTool.h"
|
||||||
#include "Layer/PaintingArea.h"
|
#include "Layer/PaintingArea.h"
|
||||||
|
#include "QColorDialog"
|
||||||
|
|
||||||
IntelliToolFloodFillTool::IntelliToolFloodFillTool(PaintingArea* Area)
|
IntelliToolFloodFillTool::IntelliToolFloodFillTool(PaintingArea* Area)
|
||||||
:IntelliToolSetColorTool(Area)
|
:IntelliTool(Area){
|
||||||
{
|
|
||||||
Tool = Area->getTool();
|
this->color = QColorDialog::getColor(Qt::blue,nullptr,"Flood Fill Color");
|
||||||
isPressed = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntelliToolFloodFillTool::onMouseLeftPressed(int x, int y){
|
void IntelliToolFloodFillTool::onMouseLeftPressed(int x, int y){
|
||||||
if(!isPressed){
|
IntelliTool::onMouseLeftPressed(x,y);
|
||||||
isPressed = true;
|
this->Canvas->image->floodFill(color);
|
||||||
IntelliTool::onMouseLeftPressed(x,y);
|
|
||||||
Tool = Area->getTool();
|
|
||||||
this->Canvas->image->floodFill(Tool->getFirstColor());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntelliToolFloodFillTool::onMouseRightPressed(int x, int y){
|
void IntelliToolFloodFillTool::onMouseRightPressed(int x, int y){
|
||||||
if(!isPressed){
|
IntelliTool::onMouseRightPressed(x,y);
|
||||||
isPressed = true;
|
|
||||||
IntelliTool::onMouseLeftPressed(x,y);
|
|
||||||
Tool = Area->getTool();
|
|
||||||
this->Canvas->image->floodFill(Tool->getSecondColor());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntelliToolFloodFillTool::onMouseRightReleased(int x, int y){
|
void IntelliToolFloodFillTool::onMouseRightReleased(int x, int y){
|
||||||
IntelliTool::onMouseLeftReleased(x,y);
|
IntelliTool::onMouseRightReleased(x,y);
|
||||||
if(isPressed) isPressed = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntelliToolFloodFillTool::onMouseLeftReleased(int x, int y){
|
void IntelliToolFloodFillTool::onMouseLeftReleased(int x, int y){
|
||||||
IntelliTool::onMouseLeftReleased(x,y);
|
IntelliTool::onMouseLeftReleased(x,y);
|
||||||
if(isPressed) isPressed = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntelliToolFloodFillTool::onMouseMoved(int x, int y){
|
void IntelliToolFloodFillTool::onMouseMoved(int x, int y){
|
||||||
IntelliTool::onMouseRightPressed(x,y);
|
IntelliTool::onMouseMoved(x,y);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,21 @@
|
|||||||
#ifndef INTELLITOOLFLOODFILLTOOL_H
|
#ifndef INTELLITOOLFLOODFILLTOOL_H
|
||||||
#define INTELLITOOLFLOODFILLTOOL_H
|
#define INTELLITOOLFLOODFILLTOOL_H
|
||||||
|
|
||||||
#include "IntelliToolSetColorTool.h"
|
#include "IntelliTool.h"
|
||||||
|
#include "QColor"
|
||||||
|
|
||||||
class IntelliToolFloodFillTool : public IntelliToolSetColorTool
|
class IntelliToolFloodFillTool : public IntelliTool
|
||||||
{
|
{
|
||||||
|
QColor color;
|
||||||
public:
|
public:
|
||||||
IntelliToolFloodFillTool(PaintingArea *Area);
|
IntelliToolFloodFillTool(PaintingArea *Area);
|
||||||
|
|
||||||
void IntelliToolFloodFillTool::onMouseLeftPressed(int x, int y) override;
|
void onMouseLeftPressed(int x, int y) override;
|
||||||
void IntelliToolFloodFillTool::onMouseLeftReleased(int x, int y) override;
|
void onMouseLeftReleased(int x, int y) override;
|
||||||
void IntelliToolFloodFillTool::onMouseRightPressed(int x, int y) override;
|
void onMouseRightPressed(int x, int y) override;
|
||||||
void IntelliToolFloodFillTool::onMouseRightReleased(int x, int y) override;
|
void onMouseRightReleased(int x, int y) override;
|
||||||
void IntelliToolFloodFillTool::onMouseMoved(int x, int y) override;
|
void onMouseMoved(int x, int y) override;
|
||||||
|
|
||||||
private:
|
|
||||||
IntelliToolSetColorTool* Tool;
|
|
||||||
bool isPressed;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INTELLITOOLFLOODFILLTOOL_H
|
#endif // INTELLITOOLFLOODFILLTOOL_H
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
#include "IntelliToolPen.h"
|
#include "IntelliToolPen.h"
|
||||||
#include "Layer/PaintingArea.h"
|
#include "Layer/PaintingArea.h"
|
||||||
#include "QDebug"
|
#include "QDebug"
|
||||||
|
#include "QColorDialog"
|
||||||
|
#include "QInputDialog"
|
||||||
|
|
||||||
IntelliToolPen::IntelliToolPen(PaintingArea* Area)
|
IntelliToolPen::IntelliToolPen(PaintingArea* Area)
|
||||||
:IntelliToolSetColorTool(Area){
|
:IntelliTool(Area){
|
||||||
|
this->color = QColorDialog::getColor(Qt::blue,nullptr,"Flood Fill Color");
|
||||||
|
|
||||||
|
bool ok;
|
||||||
|
this->penWidth = QInputDialog::getInt(nullptr, "Pen width", "Number:", 1,0, 50, 1, &ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
IntelliToolPen::~IntelliToolPen(){
|
IntelliToolPen::~IntelliToolPen(){
|
||||||
@@ -35,9 +40,7 @@ void IntelliToolPen::onMouseLeftReleased(int x, int y){
|
|||||||
void IntelliToolPen::onMouseMoved(int x, int y){
|
void IntelliToolPen::onMouseMoved(int x, int y){
|
||||||
if(this->drawing){
|
if(this->drawing){
|
||||||
QPoint newPoint(x,y);
|
QPoint newPoint(x,y);
|
||||||
Tool = Area->getTool();
|
this->Canvas->image->drawLine(this->point, newPoint, color, penWidth);
|
||||||
qDebug() << Tool->getFirstColor();
|
|
||||||
this->Canvas->image->drawLine(this->point, newPoint, Tool->getFirstColor(), 2);
|
|
||||||
this->point=newPoint;
|
this->point=newPoint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
#ifndef INTELLITOOLPEN_H
|
#ifndef INTELLITOOLPEN_H
|
||||||
#define INTELLITOOLPEN_H
|
#define INTELLITOOLPEN_H
|
||||||
|
|
||||||
#include"IntelliToolSetColorTool.h"
|
#include"IntelliTool.h"
|
||||||
#include"QColor"
|
#include"QColor"
|
||||||
#include"QPoint"
|
#include"QPoint"
|
||||||
|
|
||||||
class IntelliToolPen : public IntelliToolSetColorTool{
|
class IntelliToolPen : public IntelliTool{
|
||||||
|
QColor color;
|
||||||
|
int penWidth;
|
||||||
QPoint point;
|
QPoint point;
|
||||||
public:
|
public:
|
||||||
IntelliToolPen(PaintingArea* Area);
|
IntelliToolPen(PaintingArea* Area);
|
||||||
@@ -17,9 +19,6 @@ public:
|
|||||||
virtual void onMouseLeftReleased(int x, int y) override;
|
virtual void onMouseLeftReleased(int x, int y) override;
|
||||||
|
|
||||||
virtual void onMouseMoved(int x, int y) override;
|
virtual void onMouseMoved(int x, int y) override;
|
||||||
|
|
||||||
private:
|
|
||||||
IntelliToolSetColorTool* Tool;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INTELLITOOLPEN_H
|
#endif // INTELLITOOLPEN_H
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
#include "IntelliToolSetColorTool.h"
|
|
||||||
#include "QDebug"
|
|
||||||
|
|
||||||
IntelliToolSetColorTool::IntelliToolSetColorTool(PaintingArea* Area)
|
|
||||||
:IntelliTool(Area){
|
|
||||||
firstColor = {255,0,0,255};
|
|
||||||
secondColor = {0,0,255,255};
|
|
||||||
}
|
|
||||||
|
|
||||||
IntelliToolSetColorTool::~IntelliToolSetColorTool(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void IntelliToolSetColorTool::getColorbar(int firstOrSecondColor = 1){
|
|
||||||
QString Titel;
|
|
||||||
QColor newColor;
|
|
||||||
if(firstOrSecondColor == 1){
|
|
||||||
Titel = "Choose first Color";
|
|
||||||
newColor = QColorDialog::getColor(this->firstColor,nullptr,Titel);
|
|
||||||
this->firstColor = newColor;
|
|
||||||
qDebug() << "Firstcolor" << this->firstColor;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
Titel = "Choose second Color";
|
|
||||||
newColor = QColorDialog::getColor(this->secondColor,nullptr,Titel);
|
|
||||||
this->secondColor = newColor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QColor IntelliToolSetColorTool::getFirstColor(){
|
|
||||||
return firstColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
QColor IntelliToolSetColorTool::getSecondColor(){
|
|
||||||
return secondColor;
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#ifndef INTELLITOOLSETCOLORTOOL_H
|
|
||||||
#define INTELLITOOLSETCOLORTOOL_H
|
|
||||||
|
|
||||||
#include"IntelliTool.h"
|
|
||||||
#include"QColor"
|
|
||||||
#include"QPoint"
|
|
||||||
#include"QColorDialog"
|
|
||||||
|
|
||||||
class IntelliToolSetColorTool: public IntelliTool{
|
|
||||||
public:
|
|
||||||
IntelliToolSetColorTool(PaintingArea *Area);
|
|
||||||
virtual ~IntelliToolSetColorTool() override;
|
|
||||||
|
|
||||||
void getColorbar(int firstOrSecondColor) override;
|
|
||||||
|
|
||||||
QColor IntelliToolSetColorTool::getFirstColor();
|
|
||||||
QColor IntelliToolSetColorTool::getSecondColor();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
QColor firstColor;
|
|
||||||
QColor secondColor;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // INTELLITOOLSETCOLORTOOL_H
|
|
||||||
Reference in New Issue
Block a user