Restyled project for uncrustify

This commit is contained in:
2019-12-19 18:27:46 +01:00
parent c415a53c83
commit a838e3869f
30 changed files with 1649 additions and 1650 deletions

View File

@@ -19,123 +19,123 @@ class IntelliColorPicker;
/*! /*!
* \brief The IntelliPhotoGui class handles the graphical user interface for the intelliPhoto program * \brief The IntelliPhotoGui class handles the graphical user interface for the intelliPhoto program
*/ */
class IntelliPhotoGui : public QMainWindow{ class IntelliPhotoGui : public QMainWindow {
// Declares our class as a QObject which is the base class // Declares our class as a QObject which is the base class
// for all Qt objects // for all Qt objects
// QObjects handle events // QObjects handle events
Q_OBJECT Q_OBJECT
public: public:
/*! /*!
* \brief The IntelliPhotoGui method is the constructor and is used to create a new instance of the main program window * \brief The IntelliPhotoGui method is the constructor and is used to create a new instance of the main program window
*/ */
IntelliPhotoGui(); IntelliPhotoGui();
protected: protected:
// Function used to close an event // Function used to close an event
void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent*event) override;
private slots: private slots:
// meta slots here (need further ) // meta slots here (need further )
void slotOpen(); void slotOpen();
void slotSave(); void slotSave();
// layer slots here // layer slots here
void slotCreateNewLayer(); void slotCreateNewLayer();
void slotDeleteLayer(); void slotDeleteLayer();
void slotClearActiveLayer(); void slotClearActiveLayer();
void slotSetActiveLayer(); void slotSetActiveLayer();
void slotSetActiveAlpha(); void slotSetActiveAlpha();
void slotPositionMoveUp(); void slotPositionMoveUp();
void slotPositionMoveDown(); void slotPositionMoveDown();
void slotPositionMoveLeft(); void slotPositionMoveLeft();
void slotPositionMoveRight(); void slotPositionMoveRight();
void slotMoveLayerUp(); void slotMoveLayerUp();
void slotMoveLayerDown(); void slotMoveLayerDown();
// color Picker slots here // color Picker slots here
void slotSetFirstColor(); void slotSetFirstColor();
void slotSetSecondColor(); void slotSetSecondColor();
void slotSwitchColor(); void slotSwitchColor();
// tool slots here // tool slots here
void slotCreatePenTool(); void slotCreatePenTool();
void slotCreatePlainTool(); void slotCreatePlainTool();
void slotCreateLineTool(); void slotCreateLineTool();
void slotCreateRectangleTool(); void slotCreateRectangleTool();
void slotCreateCircleTool(); void slotCreateCircleTool();
void slotCreatePolygonTool(); void slotCreatePolygonTool();
void slotCreateFloodFillTool(); void slotCreateFloodFillTool();
// slots for dialogs // slots for dialogs
void slotAboutDialog(); void slotAboutDialog();
private: private:
// Will tie user actions to functions // Will tie user actions to functions
void createActions(); void createActions();
void createMenus(); void createMenus();
// setup GUI elements // setup GUI elements
void createGui(); void createGui();
// set style of the GUI // set style of the GUI
void setIntelliStyle(); void setIntelliStyle();
// Will check if changes have occurred since last save // Will check if changes have occurred since last save
bool maybeSave(); bool maybeSave();
// Opens the Save dialog and saves // Opens the Save dialog and saves
bool saveFile(const QByteArray &fileFormat); bool saveFile(const QByteArray &fileFormat);
// What we'll draw on // What we'll draw on
PaintingArea* paintingArea; PaintingArea* paintingArea;
// The menu widgets // The menu widgets
QMenu *saveAsMenu; QMenu*saveAsMenu;
QMenu *fileMenu; QMenu*fileMenu;
QMenu *optionMenu; QMenu*optionMenu;
QMenu *layerMenu; QMenu*layerMenu;
QMenu *colorMenu; QMenu*colorMenu;
QMenu *toolMenu; QMenu*toolMenu;
QMenu *helpMenu; QMenu*helpMenu;
// All the actions that can occur // All the actions that can occur
// meta image actions (need further modularisation) // meta image actions (need further modularisation)
QAction *actionOpen; QAction*actionOpen;
QAction *actionExit; QAction*actionExit;
// color Picker actions // color Picker actions
QAction *actionColorPickerFirstColor; QAction*actionColorPickerFirstColor;
QAction *actionColorPickerSecondColor; QAction*actionColorPickerSecondColor;
QAction *actionColorSwitch; QAction*actionColorSwitch;
// tool actions // tool actions
QAction *actionCreatePenTool; QAction*actionCreatePenTool;
QAction *actionCreatePlainTool; QAction*actionCreatePlainTool;
QAction *actionCreateLineTool; QAction*actionCreateLineTool;
QAction *actionCreateRectangleTool; QAction*actionCreateRectangleTool;
QAction *actionCreateCircleTool; QAction*actionCreateCircleTool;
QAction *actionCreatePolygonTool; QAction*actionCreatePolygonTool;
QAction *actionCreateFloodFillTool; QAction*actionCreateFloodFillTool;
// dialog actions // dialog actions
QAction *actionAboutDialog; QAction*actionAboutDialog;
QAction *actionAboutQtDialog; QAction*actionAboutQtDialog;
// layer change actions // layer change actions
QAction *actionCreateNewLayer; QAction*actionCreateNewLayer;
QAction *actionDeleteLayer; QAction*actionDeleteLayer;
QAction* actionSetActiveLayer; QAction* actionSetActiveLayer;
QAction* actionSetActiveAlpha; QAction* actionSetActiveAlpha;
QAction* actionMovePositionUp; QAction* actionMovePositionUp;
QAction* actionMovePositionDown; QAction* actionMovePositionDown;
QAction* actionMovePositionLeft; QAction* actionMovePositionLeft;
QAction* actionMovePositionRight; QAction* actionMovePositionRight;
QAction* actionMoveLayerUp; QAction* actionMoveLayerUp;
QAction* actionMoveLayerDown; QAction* actionMoveLayerDown;
// Actions tied to specific file formats // Actions tied to specific file formats
QList<QAction *> actionSaveAs; QList<QAction*> actionSaveAs;
// main GUI elements // main GUI elements
QWidget* centralGuiWidget; QWidget* centralGuiWidget;
QGridLayout *mainLayout; QGridLayout*mainLayout;
}; };
#endif #endif

View File

@@ -1,9 +1,9 @@
#include"Image/IntelliImage.h" #include "Image/IntelliImage.h"
#include<QSize> #include <QSize>
#include<QPainter> #include <QPainter>
IntelliImage::IntelliImage(int weight, int height) IntelliImage::IntelliImage(int weight, int height)
:imageData(QSize(weight, height), QImage::Format_ARGB32){ : imageData(QSize(weight, height), QImage::Format_ARGB32){
imageData.fill(QColor(255,255,255,255)); imageData.fill(QColor(255,255,255,255));
} }
@@ -26,7 +26,7 @@ bool IntelliImage::loadImage(const QString &fileName){
return true; return true;
} }
void IntelliImage::resizeImage(QImage *image, const QSize &newSize){ void IntelliImage::resizeImage(QImage*image, const QSize &newSize){
// Check if we need to redraw the image // Check if we need to redraw the image
if (image->size() == newSize) if (image->size() == newSize)
return; return;

View File

@@ -1,17 +1,17 @@
#ifndef INTELLIIMAGE_H #ifndef INTELLIIMAGE_H
#define INTELLIIMAGE_H #define INTELLIIMAGE_H
#include<QImage> #include <QImage>
#include<QPoint> #include <QPoint>
#include<QColor> #include <QColor>
#include<QSize> #include <QSize>
#include<QWidget> #include <QWidget>
#include<vector> #include <vector>
/*! /*!
* \brief The Types, which an Image can be. * \brief The Types, which an Image can be.
*/ */
enum class ImageType{ enum class ImageType {
Raster_Image, Raster_Image,
Shaped_Image Shaped_Image
}; };
@@ -21,110 +21,112 @@ class IntelliTool;
/*! /*!
* \brief An abstract class which manages the basic IntelliImage operations. * \brief An abstract class which manages the basic IntelliImage operations.
*/ */
class IntelliImage{ class IntelliImage {
friend IntelliTool; friend IntelliTool;
protected: protected:
void resizeImage(QImage *image, const QSize &newSize); void resizeImage(QImage*image, const QSize &newSize);
/*! /*!
* \brief The underlying image data. * \brief The underlying image data.
*/ */
QImage imageData; QImage imageData;
public: public:
/*! /*!
* \brief The Construcor of the IntelliImage. Given the Image dimensions. * \brief The Construcor of the IntelliImage. Given the Image dimensions.
* \param weight - The weight of the Image. * \param weight - The weight of the Image.
* \param height - The height of the Image. * \param height - The height of the Image.
*/ */
IntelliImage(int weight, int height); IntelliImage(int weight, int height);
/*! /*!
* \brief An Abstract Destructor. * \brief An Abstract Destructor.
*/ */
virtual ~IntelliImage() = 0; virtual ~IntelliImage() = 0;
/*! /*!
* \brief A funtcion used to draw a pixel on the Image with the given Color. * \brief A funtcion used to draw a pixel on the Image with the given Color.
* \param p1 - The coordinates of the pixel, which should be drawn. [Top-Left-System] * \param p1 - The coordinates of the pixel, which should be drawn. [Top-Left-System]
* \param color - The color of the pixel. * \param color - The color of the pixel.
*/ */
virtual void drawPixel(const QPoint &p1, const QColor& color); virtual void drawPixel(const QPoint &p1, const QColor& color);
/*! /*!
* \brief A function that draws A Line between two given Points in a given color. * \brief A function that draws A Line between two given Points in a given color.
* \param p1 - The coordinates of the first Point. * \param p1 - The coordinates of the first Point.
* \param p2 - The coordinates of the second Point. * \param p2 - The coordinates of the second Point.
* \param color - The color of the line. * \param color - The color of the line.
* \param penWidth - The width of the line. * \param penWidth - The width of the line.
*/ */
virtual void drawLine(const QPoint &p1, const QPoint& p2, const QColor& color, const int& penWidth); virtual void drawLine(const QPoint &p1, const QPoint& p2, const QColor& color, const int& penWidth);
/*! /*!
* \brief A * \brief A
* \param p1 * \param p1
* \param color * \param color
* \param penWidth * \param penWidth
*/ */
virtual void drawPoint(const QPoint &p1, const QColor& color, const int& penWidth); virtual void drawPoint(const QPoint &p1, const QColor& color, const int& penWidth);
/*! /*!
* \brief A function that clears the whole image in a given Color. * \brief A function that clears the whole image in a given Color.
* \param color - The color, in which the image will be filled. * \param color - The color, in which the image will be filled.
*/ */
virtual void drawPlain(const QColor& color); virtual void drawPlain(const QColor& color);
/*! /*!
* \brief A function returning the displayable ImageData in a requested transparence and size. * \brief A function returning the displayable ImageData in a requested transparence and size.
* \param displaySize - The size, in whcih the Image should be displayed. * \param displaySize - The size, in whcih the Image should be displayed.
* \param alpha - The maximum alpha value, a pixel can have. * \param alpha - The maximum alpha value, a pixel can have.
* \return A QImage which is ready to be displayed. * \return A QImage which is ready to be displayed.
*/ */
virtual QImage getDisplayable(const QSize& displaySize, int alpha)=0; virtual QImage getDisplayable(const QSize& displaySize, int alpha) = 0;
/** /**
* @brief A function returning the displayable ImageData in a requested transparence and it's standart size. * @brief A function returning the displayable ImageData in a requested transparence and it's standart size.
* @param alpha - The maximum alpha value, a pixel can have. * @param alpha - The maximum alpha value, a pixel can have.
* @return A QImage which is ready to be displayed. * @return A QImage which is ready to be displayed.
*/ */
virtual QImage getDisplayable(int alpha=255)=0; virtual QImage getDisplayable(int alpha=255) = 0;
/*! /*!
* \brief A function that copys all that returns a [allocated] Image * \brief A function that copys all that returns a [allocated] Image
* \return A [allocated] Image with all the properties of the instance. * \return A [allocated] Image with all the properties of the instance.
*/ */
virtual IntelliImage* getDeepCopy()=0; virtual IntelliImage* getDeepCopy() = 0;
/*! /*!
* \brief An abstract function that calculates the visiblity of the Image data if needed. * \brief An abstract function that calculates the visiblity of the Image data if needed.
*/ */
virtual void calculateVisiblity()=0; virtual void calculateVisiblity() = 0;
/*! /*!
* \brief An abstract function that sets the data of the visible Polygon, if needed. * \brief An abstract function that sets the data of the visible Polygon, if needed.
* \param polygonData - The Vertices of the Polygon. Just Planar Polygons are allowed. * \param polygonData - The Vertices of the Polygon. Just Planar Polygons are allowed.
*/ */
virtual void setPolygon(const std::vector<QPoint>& polygonData)=0; virtual void setPolygon(const std::vector<QPoint>& polygonData) = 0;
/*! /*!
* \brief A function that returns the Polygondata if existent. * \brief A function that returns the Polygondata if existent.
* \return The Polygondata if existent. * \return The Polygondata if existent.
*/ */
virtual std::vector<QPoint> getPolygonData(){ return std::vector<QPoint>();} virtual std::vector<QPoint> getPolygonData(){
return std::vector<QPoint>();
}
/*! /*!
* \brief A function that loads and sclaes an image to the fitting dimensions. * \brief A function that loads and sclaes an image to the fitting dimensions.
* \param fileName - The path+name of the image which to loaded. * \param fileName - The path+name of the image which to loaded.
* \return True if the image could be loaded, false otherwise. * \return True if the image could be loaded, false otherwise.
*/ */
virtual bool loadImage(const QString &fileName); virtual bool loadImage(const QString &fileName);
/*! /*!
* \brief A function that returns the pixelcolor at a certain point * \brief A function that returns the pixelcolor at a certain point
* \param point - The point from whcih to get the coordinates. * \param point - The point from whcih to get the coordinates.
* \return The color of the Pixel as QColor. * \return The color of the Pixel as QColor.
*/ */
virtual QColor getPixelColor(QPoint& point); virtual QColor getPixelColor(QPoint& point);
}; };
#endif #endif

View File

@@ -1,10 +1,10 @@
#include"Image/IntelliRasterImage.h" #include "Image/IntelliRasterImage.h"
#include<QPainter> #include <QPainter>
#include<QRect> #include <QRect>
#include<QDebug> #include <QDebug>
IntelliRasterImage::IntelliRasterImage(int weight, int height) IntelliRasterImage::IntelliRasterImage(int weight, int height)
:IntelliImage(weight, height){ : IntelliImage(weight, height){
} }
@@ -28,8 +28,8 @@ QImage IntelliRasterImage::getDisplayable(int alpha){
QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){ QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){
QImage copy = imageData; QImage copy = imageData;
for(int y = 0; y<copy.height(); y++){ for(int y = 0; y<copy.height(); y++) {
for(int x = 0; x<copy.width(); x++){ for(int x = 0; x<copy.width(); x++) {
QColor clr = copy.pixelColor(x,y); QColor clr = copy.pixelColor(x,y);
clr.setAlpha(std::min(alpha, clr.alpha())); clr.setAlpha(std::min(alpha, clr.alpha()));
copy.setPixelColor(x,y, clr); copy.setPixelColor(x,y, clr);

View File

@@ -1,57 +1,57 @@
#ifndef INTELLIRASTER_H #ifndef INTELLIRASTER_H
#define INTELLIRASTER_H #define INTELLIRASTER_H
#include"Image/IntelliImage.h" #include "Image/IntelliImage.h"
/*! /*!
* \brief The IntelliRasterImage manages a Rasterimage. * \brief The IntelliRasterImage manages a Rasterimage.
*/ */
class IntelliRasterImage : public IntelliImage{ class IntelliRasterImage : public IntelliImage {
friend IntelliTool; friend IntelliTool;
protected: protected:
/*! /*!
* \brief A function that calculates the visibility of the image if a polygon is given. [does nothing in Rasterimage] * \brief A function that calculates the visibility of the image if a polygon is given. [does nothing in Rasterimage]
*/ */
virtual void calculateVisiblity() override; virtual void calculateVisiblity() override;
public: public:
/*! /*!
* \brief The Construcor of the IntelliRasterImage. Given the Image dimensions. * \brief The Construcor of the IntelliRasterImage. Given the Image dimensions.
* \param weight - The weight of the Image. * \param weight - The weight of the Image.
* \param height - The height of the Image. * \param height - The height of the Image.
*/ */
IntelliRasterImage(int weight, int height); IntelliRasterImage(int weight, int height);
/*! /*!
* \brief An Destructor. * \brief An Destructor.
*/ */
virtual ~IntelliRasterImage() override; virtual ~IntelliRasterImage() override;
/*! /*!
* \brief A function returning the displayable ImageData in a requested transparence and size. * \brief A function returning the displayable ImageData in a requested transparence and size.
* \param displaySize - The size, in whcih the Image should be displayed. * \param displaySize - The size, in whcih the Image should be displayed.
* \param alpha - The maximum alpha value, a pixel can have. * \param alpha - The maximum alpha value, a pixel can have.
* \return A QImage which is ready to be displayed. * \return A QImage which is ready to be displayed.
*/ */
virtual QImage getDisplayable(const QSize& displaySize,int alpha) override; virtual QImage getDisplayable(const QSize& displaySize,int alpha) override;
/** /**
* @brief A function returning the displayable ImageData in a requested transparence and it's standart size. * @brief A function returning the displayable ImageData in a requested transparence and it's standart size.
* @param alpha - The maximum alpha value, a pixel can have. * @param alpha - The maximum alpha value, a pixel can have.
* @return A QImage which is ready to be displayed. * @return A QImage which is ready to be displayed.
*/ */
virtual QImage getDisplayable(int alpha=255) override; virtual QImage getDisplayable(int alpha=255) override;
/*! /*!
* \brief A function that copys all that returns a [allocated] Image * \brief A function that copys all that returns a [allocated] Image
* \return A [allocated] Image with all the properties of the instance. * \return A [allocated] Image with all the properties of the instance.
*/ */
virtual IntelliImage* getDeepCopy() override; virtual IntelliImage* getDeepCopy() override;
/*! /*!
* \brief An abstract function that sets the data of the visible Polygon, if needed. * \brief An abstract function that sets the data of the visible Polygon, if needed.
* \param polygonData - The Vertices of the Polygon. Nothing happens. * \param polygonData - The Vertices of the Polygon. Nothing happens.
*/ */
virtual void setPolygon(const std::vector<QPoint>& polygonData) override; virtual void setPolygon(const std::vector<QPoint>& polygonData) override;
}; };
#endif #endif

View File

@@ -1,11 +1,11 @@
#include"Image/IntelliShapedImage.h" #include "Image/IntelliShapedImage.h"
#include"IntelliHelper/IntelliHelper.h" #include "IntelliHelper/IntelliHelper.h"
#include<QPainter> #include <QPainter>
#include<QRect> #include <QRect>
#include<QDebug> #include <QDebug>
IntelliShapedImage::IntelliShapedImage(int weight, int height) IntelliShapedImage::IntelliShapedImage(int weight, int height)
:IntelliRasterImage(weight, height){ : IntelliRasterImage(weight, height){
} }
IntelliShapedImage::~IntelliShapedImage(){ IntelliShapedImage::~IntelliShapedImage(){
@@ -24,10 +24,10 @@ IntelliImage* IntelliShapedImage::getDeepCopy(){
} }
void IntelliShapedImage::calculateVisiblity(){ void IntelliShapedImage::calculateVisiblity(){
if(polygonData.size()<=2){ if(polygonData.size()<=2) {
QColor clr; QColor clr;
for(int y=0; y<imageData.height(); y++){ for(int y=0; y<imageData.height(); y++) {
for(int x=0; x<imageData.width(); x++){ for(int x=0; x<imageData.width(); x++) {
clr = imageData.pixel(x,y); clr = imageData.pixel(x,y);
clr.setAlpha(255); clr.setAlpha(255);
imageData.setPixelColor(x,y,clr); imageData.setPixelColor(x,y,clr);
@@ -36,12 +36,12 @@ void IntelliShapedImage::calculateVisiblity(){
return; return;
} }
QColor clr; QColor clr;
for(int y=0; y<imageData.height(); y++){ for(int y=0; y<imageData.height(); y++) {
for(int x=0; x<imageData.width(); x++){ for(int x=0; x<imageData.width(); x++) {
QPoint ptr(x,y); QPoint ptr(x,y);
clr = imageData.pixelColor(x,y); clr = imageData.pixelColor(x,y);
bool isInPolygon = IntelliHelper::isInPolygon(triangles, ptr); bool isInPolygon = IntelliHelper::isInPolygon(triangles, ptr);
if(isInPolygon){ if(isInPolygon) {
clr.setAlpha(std::min(255, clr.alpha())); clr.setAlpha(std::min(255, clr.alpha()));
}else{ }else{
clr.setAlpha(0); clr.setAlpha(0);
@@ -53,8 +53,8 @@ void IntelliShapedImage::calculateVisiblity(){
QImage IntelliShapedImage::getDisplayable(const QSize& displaySize, int alpha){ QImage IntelliShapedImage::getDisplayable(const QSize& displaySize, int alpha){
QImage copy = imageData; QImage copy = imageData;
for(int y = 0; y<copy.height(); y++){ for(int y = 0; y<copy.height(); y++) {
for(int x = 0; x<copy.width(); x++){ for(int x = 0; x<copy.width(); x++) {
QColor clr = copy.pixelColor(x,y); QColor clr = copy.pixelColor(x,y);
clr.setAlpha(std::min(alpha,clr.alpha())); clr.setAlpha(std::min(alpha,clr.alpha()));
copy.setPixelColor(x,y, clr); copy.setPixelColor(x,y, clr);
@@ -64,11 +64,11 @@ QImage IntelliShapedImage::getDisplayable(const QSize& displaySize, int alpha){
} }
void IntelliShapedImage::setPolygon(const std::vector<QPoint>& polygonData){ void IntelliShapedImage::setPolygon(const std::vector<QPoint>& polygonData){
if(polygonData.size()<3){ if(polygonData.size()<3) {
this->polygonData.clear(); this->polygonData.clear();
}else{ }else{
this->polygonData.clear(); this->polygonData.clear();
for(auto element:polygonData){ for(auto element:polygonData) {
this->polygonData.push_back(QPoint(element.x(), element.y())); this->polygonData.push_back(QPoint(element.x(), element.y()));
} }
triangles = IntelliHelper::calculateTriangles(polygonData); triangles = IntelliHelper::calculateTriangles(polygonData);

View File

@@ -1,76 +1,78 @@
#ifndef INTELLISHAPE_H #ifndef INTELLISHAPE_H
#define INTELLISHAPE_H #define INTELLISHAPE_H
#include"Image/IntelliRasterImage.h" #include "Image/IntelliRasterImage.h"
#include<vector> #include <vector>
#include"IntelliHelper/IntelliHelper.h" #include "IntelliHelper/IntelliHelper.h"
/*! /*!
* \brief The IntelliShapedImage manages a Shapedimage. * \brief The IntelliShapedImage manages a Shapedimage.
*/ */
class IntelliShapedImage : public IntelliRasterImage{ class IntelliShapedImage : public IntelliRasterImage {
friend IntelliTool; friend IntelliTool;
private: private:
/*! /*!
* \brief The Triangulation of the Polygon. Saved here for performance reasons. * \brief The Triangulation of the Polygon. Saved here for performance reasons.
*/ */
std::vector<Triangle> triangles; std::vector<Triangle> triangles;
/*! /*!
* \brief Calculates the visibility based on the underlying polygon. * \brief Calculates the visibility based on the underlying polygon.
*/ */
virtual void calculateVisiblity() override; virtual void calculateVisiblity() override;
protected: protected:
/*! /*!
* \brief The Vertices of The Polygon. Needs to be a planar Polygon. * \brief The Vertices of The Polygon. Needs to be a planar Polygon.
*/ */
std::vector<QPoint> polygonData; std::vector<QPoint> polygonData;
public: public:
/*! /*!
* \brief The Construcor of the IntelliShapedImage. Given the Image dimensions. * \brief The Construcor of the IntelliShapedImage. Given the Image dimensions.
* \param weight - The weight of the Image. * \param weight - The weight of the Image.
* \param height - The height of the Image. * \param height - The height of the Image.
*/ */
IntelliShapedImage(int weight, int height); IntelliShapedImage(int weight, int height);
/*! /*!
* \brief An Destructor. * \brief An Destructor.
*/ */
virtual ~IntelliShapedImage() override; virtual ~IntelliShapedImage() override;
/*! /*!
* \brief A function returning the displayable ImageData in a requested transparence and size. * \brief A function returning the displayable ImageData in a requested transparence and size.
* \param displaySize - The size, in whcih the Image should be displayed. * \param displaySize - The size, in whcih the Image should be displayed.
* \param alpha - The maximum alpha value, a pixel can have. * \param alpha - The maximum alpha value, a pixel can have.
* \return A QImage which is ready to be displayed. * \return A QImage which is ready to be displayed.
*/ */
virtual QImage getDisplayable(const QSize& displaySize, int alpha=255) override; virtual QImage getDisplayable(const QSize& displaySize, int alpha=255) override;
/** /**
* @brief A function returning the displayable ImageData in a requested transparence and it's standart size. * @brief A function returning the displayable ImageData in a requested transparence and it's standart size.
* @param alpha - The maximum alpha value, a pixel can have. * @param alpha - The maximum alpha value, a pixel can have.
* @return A QImage which is ready to be displayed. * @return A QImage which is ready to be displayed.
*/ */
virtual QImage getDisplayable(int alpha=255) override; virtual QImage getDisplayable(int alpha=255) override;
/*! /*!
* \brief A function that copys all that returns a [allocated] Image * \brief A function that copys all that returns a [allocated] Image
* \return A [allocated] Image with all the properties of the instance. * \return A [allocated] Image with all the properties of the instance.
*/ */
virtual IntelliImage* getDeepCopy() override; virtual IntelliImage* getDeepCopy() override;
/*! /*!
* \brief A function that returns the Polygondata if existent. * \brief A function that returns the Polygondata if existent.
* \return The Polygondata if existent. * \return The Polygondata if existent.
*/ */
virtual std::vector<QPoint> getPolygonData() override{return polygonData;} virtual std::vector<QPoint> getPolygonData() override {
return polygonData;
}
/*! /*!
* \brief A function that sets the data of the visible Polygon. * \brief A function that sets the data of the visible Polygon.
* \param polygonData - The Vertices of the Polygon. Just Planar Polygons are allowed. * \param polygonData - The Vertices of the Polygon. Just Planar Polygons are allowed.
*/ */
virtual void setPolygon(const std::vector<QPoint>& polygonData) override; virtual void setPolygon(const std::vector<QPoint>& polygonData) override;
}; };
#endif #endif

View File

@@ -1,64 +1,64 @@
#ifndef INTELLITOOLSETCOLORTOOL_H #ifndef INTELLITOOLSETCOLORTOOL_H
#define INTELLITOOLSETCOLORTOOL_H #define INTELLITOOLSETCOLORTOOL_H
#include"QColor" #include "QColor"
#include"QPoint" #include "QPoint"
#include"QColorDialog" #include "QColorDialog"
/*! /*!
* \brief The IntelliColorPicker manages the selected colors for one whole project. * \brief The IntelliColorPicker manages the selected colors for one whole project.
*/ */
class IntelliColorPicker{ class IntelliColorPicker {
public: public:
/*! /*!
* \brief IntelliColorPicker constructor, setting 2 preset colors, be careful, theese color may change in production. * \brief IntelliColorPicker constructor, setting 2 preset colors, be careful, theese color may change in production.
*/ */
IntelliColorPicker(); IntelliColorPicker();
/*! /*!
* \brief IntelliColorPicker destructor clears up his used memory, if there is some. * \brief IntelliColorPicker destructor clears up his used memory, if there is some.
*/ */
virtual ~IntelliColorPicker(); virtual ~IntelliColorPicker();
/*! /*!
* \brief A function switching primary and secondary color. * \brief A function switching primary and secondary color.
*/ */
void switchColors(); void switchColors();
/*! /*!
* \brief A function to read the primary selected color. * \brief A function to read the primary selected color.
* \return Returns the primary color. * \return Returns the primary color.
*/ */
QColor getFirstColor(); QColor getFirstColor();
/*! /*!
* \brief A function to read the secondary selected color. * \brief A function to read the secondary selected color.
* \return Returns the secondary color. * \return Returns the secondary color.
*/ */
QColor getSecondColor(); QColor getSecondColor();
/*! /*!
* \brief A function to set the primary color. * \brief A function to set the primary color.
* \param Color - The color to be set as primary. * \param Color - The color to be set as primary.
*/ */
void setFirstColor(QColor Color); void setFirstColor(QColor Color);
/*! /*!
* \brief A function to set the secondary color. * \brief A function to set the secondary color.
* \param Color - The color to be set as secondary. * \param Color - The color to be set as secondary.
*/ */
void setSecondColor(QColor Color); void setSecondColor(QColor Color);
private: private:
/*! /*!
* \brief The primary color. * \brief The primary color.
*/ */
QColor firstColor; QColor firstColor;
/*! /*!
* \brief The secondary color. * \brief The secondary color.
*/ */
QColor secondColor; QColor secondColor;
}; };
#endif // INTELLITOOLSETCOLORTOOL_H #endif // INTELLITOOLSETCOLORTOOL_H

View File

@@ -1,12 +1,12 @@
#include"IntelliHelper.h" #include "IntelliHelper.h"
#include<algorithm> #include <algorithm>
#include<queue> #include <queue>
#include<cmath> #include <cmath>
std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> polyPoints){ std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> polyPoints){
// helper for managing the triangle vertices and their state // helper for managing the triangle vertices and their state
struct TriangleHelper{ struct TriangleHelper {
QPoint vertex; QPoint vertex;
float interiorAngle; float interiorAngle;
int index; int index;
@@ -26,8 +26,8 @@ std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> poly
// gets the first element of vec for which element.isTip == true holds // gets the first element of vec for which element.isTip == true holds
auto getTip= [](const std::vector<TriangleHelper>& vec){ auto getTip= [](const std::vector<TriangleHelper>& vec){
size_t min = 0; size_t min = 0;
for(size_t i=0; i<vec.size(); i++){ for(size_t i=0; i<vec.size(); i++) {
if(vec[i].interiorAngle<vec[min].interiorAngle){ if(vec[i].interiorAngle<vec[min].interiorAngle) {
min = i; min = i;
} }
} }
@@ -36,7 +36,7 @@ std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> poly
// get the vertex Index bevor index in relation to the container length // get the vertex Index bevor index in relation to the container length
auto getPrev = [](int index, int length){ auto getPrev = [](int index, int length){
return (index-1)>=0?(index-1):(length-1); return (index-1)>=0 ? (index-1) : (length-1);
}; };
// get the vertex Index after index in relation to the container lenght // get the vertex Index after index in relation to the container lenght
@@ -53,7 +53,7 @@ std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> poly
std::vector<Triangle> Triangles; std::vector<Triangle> Triangles;
// set up all vertices and calculate intirior angle // set up all vertices and calculate intirior angle
for(int i=0; i<static_cast<int>(polyPoints.size()); i++){ for(int i=0; i<static_cast<int>(polyPoints.size()); i++) {
TriangleHelper helper; TriangleHelper helper;
int prev = getPrev(i, static_cast<int>(polyPoints.size())); int prev = getPrev(i, static_cast<int>(polyPoints.size()));
int post = getPost(i, static_cast<int>(polyPoints.size())); int post = getPost(i, static_cast<int>(polyPoints.size()));
@@ -69,7 +69,7 @@ std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> poly
} }
// search triangles based on the intirior angles of each vertey // search triangles based on the intirior angles of each vertey
while(Triangles.size() != polyPoints.size()-2){ while(Triangles.size() != polyPoints.size()-2) {
Triangle tri; Triangle tri;
TriangleHelper smallest = getTip(Vertices); TriangleHelper smallest = getTip(Vertices);
int prev = getPrev(smallest.index, static_cast<int>(Vertices.size())); int prev = getPrev(smallest.index, static_cast<int>(Vertices.size()));
@@ -83,13 +83,13 @@ std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> poly
// update Vertice array // update Vertice array
Vertices.erase(Vertices.begin()+smallest.index); Vertices.erase(Vertices.begin()+smallest.index);
for(size_t i=static_cast<size_t>(smallest.index); i<Vertices.size(); i++){ for(size_t i=static_cast<size_t>(smallest.index); i<Vertices.size(); i++) {
Vertices[i].index-=1; Vertices[i].index-=1;
} }
// update post und prev index // update post und prev index
post = post-1; post = post-1;
prev = prev<smallest.index?prev:(prev-1); prev = prev<smallest.index ? prev : (prev-1);
// calcultae neighboors of prev and post to calculate new interior angles // calcultae neighboors of prev and post to calculate new interior angles
int prevOfPrev = getPrev(prev, static_cast<int>(Vertices.size())); int prevOfPrev = getPrev(prev, static_cast<int>(Vertices.size()));
@@ -114,8 +114,8 @@ std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> poly
} }
bool IntelliHelper::isInPolygon(std::vector<Triangle> &triangles, QPoint &point){ bool IntelliHelper::isInPolygon(std::vector<Triangle> &triangles, QPoint &point){
for(auto triangle : triangles){ for(auto triangle : triangles) {
if(IntelliHelper::isInTriangle(triangle, point)){ if(IntelliHelper::isInTriangle(triangle, point)) {
return true; return true;
} }
} }

View File

@@ -1,36 +1,36 @@
#ifndef INTELLIHELPER_H #ifndef INTELLIHELPER_H
#define INTELLIHELPER_H #define INTELLIHELPER_H
#include<QPoint> #include <QPoint>
#include<vector> #include <vector>
/*! /*!
* \brief The Triangle struct holds the 3 vertices of a triangle. * \brief The Triangle struct holds the 3 vertices of a triangle.
*/ */
struct Triangle{ struct Triangle {
QPoint A,B,C; QPoint A,B,C;
}; };
namespace IntelliHelper { namespace IntelliHelper {
/*! /*!
* \brief A function to get the 2*area of a traingle, using its determinat. * \brief A function to get the 2*area of a traingle, using its determinat.
* \param p1 - The Point to check its side. * \param p1 - The Point to check its side.
* \param p2 - The first Point of the spanning Line * \param p2 - The first Point of the spanning Line
* \param p3 - The second Point of the spanning line. * \param p3 - The second Point of the spanning line.
* \return Returns the area of the traingle*2 * \return Returns the area of the traingle*2
*/ */
inline float sign(QPoint& p1, QPoint& p2, QPoint& p3){ inline float sign(QPoint& p1, QPoint& p2, QPoint& p3){
return (p1.x()-p3.x())*(p2.y()-p3.y())-(p2.x()-p3.x())*(p1.y()-p3.y()); return (p1.x()-p3.x())*(p2.y()-p3.y())-(p2.x()-p3.x())*(p1.y()-p3.y());
} }
/*! /*!
* \brief A function to check if a given point is in a triangle. * \brief A function to check if a given point is in a triangle.
* \param tri - The triangle to check, if it contains the point. * \param tri - The triangle to check, if it contains the point.
* \param P - The point to check if it is in the triangle. * \param P - The point to check if it is in the triangle.
* \return Returns true if the point is in the triangle, false otheriwse * \return Returns true if the point is in the triangle, false otheriwse
*/ */
inline bool isInTriangle(Triangle& tri, QPoint& P){ inline bool isInTriangle(Triangle& tri, QPoint& P){
float val1, val2, val3; float val1, val2, val3;
bool neg, pos; bool neg, pos;
@@ -42,22 +42,22 @@ namespace IntelliHelper {
pos = (val1>0.f) || (val2>0.f) || (val3>0.f); pos = (val1>0.f) || (val2>0.f) || (val3>0.f);
return !(neg && pos); return !(neg && pos);
} }
/*! /*!
* \brief A function to split a polygon in its spanning traingles by using Meisters Theorem of graph theory by clipping ears of a planar graph. * \brief A function to split a polygon in its spanning traingles by using Meisters Theorem of graph theory by clipping ears of a planar graph.
* \param polyPoints - The Vertices of the polygon. * \param polyPoints - The Vertices of the polygon.
* \return Returns a Container of disjoint Triangles, which desribe the polygon area. * \return Returns a Container of disjoint Triangles, which desribe the polygon area.
*/ */
std::vector<Triangle> calculateTriangles(std::vector<QPoint> polyPoints); std::vector<Triangle> calculateTriangles(std::vector<QPoint> polyPoints);
/*! /*!
* \brief A function to check if a point lies in a polygon by checking its spanning triangles. * \brief A function to check if a point lies in a polygon by checking its spanning triangles.
* \param triangles - The spanning triangles of the planar polygon. * \param triangles - The spanning triangles of the planar polygon.
* \param point - The point to checl, if it lies in the polygon. * \param point - The point to checl, if it lies in the polygon.
* \return Returns true if the point lies in the üpolygon, otherwise false. * \return Returns true if the point lies in the üpolygon, otherwise false.
*/ */
bool isInPolygon(std::vector<Triangle> &triangles, QPoint &point); bool isInPolygon(std::vector<Triangle> &triangles, QPoint &point);
} }
#endif #endif

View File

@@ -18,8 +18,8 @@
#include "Tool/IntelliToolFloodFill.h" #include "Tool/IntelliToolFloodFill.h"
#include "Tool/IntelliToolPolygon.h" #include "Tool/IntelliToolPolygon.h"
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent) PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent)
:QWidget(parent){ : QWidget(parent){
this->Tool = nullptr; this->Tool = nullptr;
this->setUp(maxWidth, maxHeight); this->setUp(maxWidth, maxHeight);
this->addLayer(200,200,0,0,ImageType::Shaped_Image); this->addLayer(200,200,0,0,ImageType::Shaped_Image);
@@ -59,9 +59,9 @@ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOff
newLayer.height = height; newLayer.height = height;
newLayer.widthOffset = widthOffset; newLayer.widthOffset = widthOffset;
newLayer.heightOffset = heightOffset; newLayer.heightOffset = heightOffset;
if(type==ImageType::Raster_Image){ if(type==ImageType::Raster_Image) {
newLayer.image = new IntelliRasterImage(width,height); newLayer.image = new IntelliRasterImage(width,height);
}else if(type==ImageType::Shaped_Image){ }else if(type==ImageType::Shaped_Image) {
newLayer.image = new IntelliShapedImage(width, height); newLayer.image = new IntelliShapedImage(width, height);
} }
newLayer.alpha = 255; newLayer.alpha = 255;
@@ -71,36 +71,36 @@ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOff
void PaintingArea::deleteLayer(int index){ void PaintingArea::deleteLayer(int index){
if(index<static_cast<int>(layerBundle.size())){ if(index<static_cast<int>(layerBundle.size())) {
this->layerBundle.erase(layerBundle.begin()+index); this->layerBundle.erase(layerBundle.begin()+index);
if(activeLayer>=index){ if(activeLayer>=index) {
activeLayer--; activeLayer--;
} }
} }
} }
void PaintingArea::slotDeleteActiveLayer(){ void PaintingArea::slotDeleteActiveLayer(){
if(activeLayer>=0 && activeLayer < static_cast<int>(layerBundle.size())){ if(activeLayer>=0 && activeLayer < static_cast<int>(layerBundle.size())) {
this->layerBundle.erase(layerBundle.begin()+activeLayer); this->layerBundle.erase(layerBundle.begin()+activeLayer);
activeLayer--; activeLayer--;
} }
} }
void PaintingArea::setLayerToActive(int index){ void PaintingArea::setLayerToActive(int index){
if(index>=0&&index<static_cast<int>(layerBundle.size())){ if(index>=0&&index<static_cast<int>(layerBundle.size())) {
this->activeLayer=index; this->activeLayer=index;
} }
} }
void PaintingArea::setAlphaOfLayer(int index, int alpha){ void PaintingArea::setAlphaOfLayer(int index, int alpha){
if(index>=0&&index<static_cast<int>(layerBundle.size())){ if(index>=0&&index<static_cast<int>(layerBundle.size())) {
layerBundle[static_cast<size_t>(index)].alpha=alpha; layerBundle[static_cast<size_t>(index)].alpha=alpha;
} }
} }
// Used to load the image and place it in the widget // Used to load the image and place it in the widget
bool PaintingArea::open(const QString &fileName){ bool PaintingArea::open(const QString &fileName){
if(this->activeLayer==-1){ if(this->activeLayer==-1) {
return false; return false;
} }
IntelliImage* active = layerBundle[static_cast<size_t>(activeLayer)].image; IntelliImage* active = layerBundle[static_cast<size_t>(activeLayer)].image;
@@ -111,13 +111,13 @@ bool PaintingArea::open(const QString &fileName){
} }
// Save the current image // Save the current image
bool PaintingArea::save(const QString &fileName, const char *fileFormat){ bool PaintingArea::save(const QString &fileName, const char*fileFormat){
if(layerBundle.size()==0){ if(layerBundle.size()==0) {
return false; return false;
} }
this->assembleLayers(true); this->assembleLayers(true);
if(!strcmp(fileFormat,"PNG")){ if(!strcmp(fileFormat,"PNG")) {
QImage visibleImage = Canvas->convertToFormat(QImage::Format_Indexed8); QImage visibleImage = Canvas->convertToFormat(QImage::Format_Indexed8);
fileFormat = "png"; fileFormat = "png";
if (visibleImage.save(fileName, fileFormat)) { if (visibleImage.save(fileName, fileFormat)) {
@@ -136,7 +136,7 @@ bool PaintingArea::save(const QString &fileName, const char *fileFormat){
// Color the image area with white // Color the image area with white
void PaintingArea::floodFill(int r, int g, int b, int a){ void PaintingArea::floodFill(int r, int g, int b, int a){
if(this->activeLayer==-1){ if(this->activeLayer==-1) {
return; return;
} }
IntelliImage* active = layerBundle[static_cast<size_t>(activeLayer)].image; IntelliImage* active = layerBundle[static_cast<size_t>(activeLayer)].image;
@@ -150,15 +150,15 @@ void PaintingArea::movePositionActive(int x, int y){
} }
void PaintingArea::moveActiveLayer(int idx){ void PaintingArea::moveActiveLayer(int idx){
if(idx==1){ if(idx==1) {
this->activateUpperLayer(); this->activateUpperLayer();
}else if(idx==-1){ }else if(idx==-1) {
this->activateLowerLayer(); this->activateLowerLayer();
} }
} }
void PaintingArea::slotActivateLayer(int a){ void PaintingArea::slotActivateLayer(int a){
if(a>=0 && a < static_cast<int>(layerBundle.size())){ if(a>=0 && a < static_cast<int>(layerBundle.size())) {
this->setLayerToActive(a); this->setLayerToActive(a);
} }
} }
@@ -222,14 +222,14 @@ int PaintingArea::getHeightOfActive(){
// 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) if(Tool == nullptr)
return; return;
int x = event->x()-layerBundle[activeLayer].widthOffset; int x = event->x()-layerBundle[activeLayer].widthOffset;
int y = event->y()-layerBundle[activeLayer].heightOffset; int y = event->y()-layerBundle[activeLayer].heightOffset;
if(event->button() == Qt::LeftButton){ if(event->button() == Qt::LeftButton) {
Tool->onMouseLeftPressed(x, y); Tool->onMouseLeftPressed(x, y);
}else if(event->button() == Qt::RightButton){ }else if(event->button() == Qt::RightButton) {
Tool->onMouseRightPressed(x, y); Tool->onMouseRightPressed(x, y);
} }
update(); update();
@@ -238,7 +238,7 @@ void PaintingArea::mousePressEvent(QMouseEvent *event){
// When the mouse moves if the left button is clicked // When the mouse moves if the left button is clicked
// we call the drawline function which draws a line // we call the drawline function which draws a line
// 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) if(Tool == nullptr)
return; return;
int x = event->x()-layerBundle[activeLayer].widthOffset; int x = event->x()-layerBundle[activeLayer].widthOffset;
@@ -248,31 +248,31 @@ 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) if(Tool == nullptr)
return; return;
int x = event->x()-layerBundle[activeLayer].widthOffset; int x = event->x()-layerBundle[activeLayer].widthOffset;
int y = event->y()-layerBundle[activeLayer].heightOffset; int y = event->y()-layerBundle[activeLayer].heightOffset;
if(event->button() == Qt::LeftButton){ if(event->button() == Qt::LeftButton) {
Tool->onMouseLeftReleased(x, y); Tool->onMouseLeftReleased(x, y);
}else if(event->button() == Qt::RightButton){ }else if(event->button() == Qt::RightButton) {
Tool->onMouseRightReleased(x, y); Tool->onMouseRightReleased(x, y);
} }
update(); update();
} }
void PaintingArea::wheelEvent(QWheelEvent *event){ void PaintingArea::wheelEvent(QWheelEvent*event){
QPoint numDegrees = event->angleDelta() / 8; QPoint numDegrees = event->angleDelta() / 8;
if(!numDegrees.isNull()){ if(!numDegrees.isNull()) {
QPoint numSteps = numDegrees / 15; QPoint numSteps = numDegrees / 15;
Tool->onWheelScrolled(numSteps.y()*-1); Tool->onWheelScrolled(numSteps.y()* -1);
} }
} }
// QPainter provides functions to draw on the widget // QPainter provides functions to draw on the widget
// The QPaintEvent is sent to widgets that need to // The QPaintEvent is sent to widgets that need to
// update themselves // update themselves
void PaintingArea::paintEvent(QPaintEvent *event){ void PaintingArea::paintEvent(QPaintEvent*event){
this->assembleLayers(); this->assembleLayers();
QPainter painter(this); QPainter painter(this);
@@ -283,44 +283,44 @@ void PaintingArea::paintEvent(QPaintEvent *event){
// Resize the image to slightly larger then the main window // Resize the image to slightly larger then the main window
// to cut down on the need to resize the image // to cut down on the need to resize the image
void PaintingArea::resizeEvent(QResizeEvent *event){ void PaintingArea::resizeEvent(QResizeEvent*event){
//TODO wait till tool works //TODO wait till tool works
update(); update();
} }
void PaintingArea::resizeImage(QImage *image_res, const QSize &newSize){ void PaintingArea::resizeImage(QImage*image_res, const QSize &newSize){
//TODO implement //TODO implement
} }
void PaintingArea::activateUpperLayer(){ void PaintingArea::activateUpperLayer(){
if(activeLayer!=-1 && activeLayer<layerBundle.size()-1){ if(activeLayer!=-1 && activeLayer<layerBundle.size()-1) {
std::swap(layerBundle[activeLayer], layerBundle[activeLayer+1]); std::swap(layerBundle[activeLayer], layerBundle[activeLayer+1]);
activeLayer++; activeLayer++;
} }
} }
void PaintingArea::activateLowerLayer(){ void PaintingArea::activateLowerLayer(){
if(activeLayer!=-1 && activeLayer>0){ if(activeLayer!=-1 && activeLayer>0) {
std::swap(layerBundle[activeLayer], layerBundle[activeLayer-1]); std::swap(layerBundle[activeLayer], layerBundle[activeLayer-1]);
activeLayer--; activeLayer--;
} }
} }
void PaintingArea::assembleLayers(bool forSaving){ void PaintingArea::assembleLayers(bool forSaving){
if(forSaving){ if(forSaving) {
Canvas->fill(Qt::GlobalColor::transparent); Canvas->fill(Qt::GlobalColor::transparent);
}else{ }else{
Canvas->fill(Qt::GlobalColor::black); Canvas->fill(Qt::GlobalColor::black);
} }
for(size_t i=0; i<layerBundle.size(); i++){ for(size_t i=0; i<layerBundle.size(); i++) {
LayerObject layer = layerBundle[i]; LayerObject layer = layerBundle[i];
QImage cpy = layer.image->getDisplayable(layer.alpha); QImage cpy = layer.image->getDisplayable(layer.alpha);
QColor clr_0; QColor clr_0;
QColor clr_1; QColor clr_1;
for(int y=0; y<layer.height; y++){ for(int y=0; y<layer.height; y++) {
if(layer.heightOffset+y<0) continue; if(layer.heightOffset+y<0) continue;
if(layer.heightOffset+y>=maxHeight) break; if(layer.heightOffset+y>=maxHeight) break;
for(int x=0; x<layer.width; x++){ for(int x=0; x<layer.width; x++) {
if(layer.widthOffset+x<0) continue; if(layer.widthOffset+x<0) continue;
if(layer.widthOffset+x>=maxWidth) break; if(layer.widthOffset+x>=maxWidth) break;
clr_0=Canvas->pixelColor(layer.widthOffset+x, layer.heightOffset+y); clr_0=Canvas->pixelColor(layer.widthOffset+x, layer.heightOffset+y);
@@ -342,7 +342,7 @@ void PaintingArea::assembleLayers(bool forSaving){
} }
void PaintingArea::createTempLayerAfter(int idx){ void PaintingArea::createTempLayerAfter(int idx){
if(idx>=0){ if(idx>=0) {
LayerObject newLayer; LayerObject newLayer;
newLayer.alpha = 255; newLayer.alpha = 255;
newLayer.height = layerBundle[idx].height; newLayer.height = layerBundle[idx].height;

View File

@@ -2,7 +2,7 @@
#include "QDebug" #include "QDebug"
IntelliColorPicker::IntelliColorPicker(PaintingArea* Area) IntelliColorPicker::IntelliColorPicker(PaintingArea* Area)
:IntelliTool(Area){ : IntelliTool(Area){
firstColor = {255,0,0,255}; firstColor = {255,0,0,255};
secondColor = {0,0,255,255}; secondColor = {0,0,255,255};
} }
@@ -14,7 +14,7 @@ IntelliColorPicker::~IntelliColorPicker(){
void IntelliColorPicker::getColorbar(int firstOrSecondColor = 1){ void IntelliColorPicker::getColorbar(int firstOrSecondColor = 1){
QString Titel; QString Titel;
QColor newColor; QColor newColor;
if(firstOrSecondColor == 1){ if(firstOrSecondColor == 1) {
Titel = "Choose first Color"; Titel = "Choose first Color";
newColor = QColorDialog::getColor(this->firstColor,nullptr,Titel); newColor = QColorDialog::getColor(this->firstColor,nullptr,Titel);
this->firstColor = newColor; this->firstColor = newColor;

View File

@@ -1,5 +1,5 @@
#include"IntelliTool.h" #include "IntelliTool.h"
#include"Layer/PaintingArea.h" #include "Layer/PaintingArea.h"
IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker){ IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker){
this->Area=Area; this->Area=Area;
@@ -12,7 +12,7 @@ IntelliTool::~IntelliTool(){
} }
void IntelliTool::onMouseRightPressed(int x, int y){ void IntelliTool::onMouseRightPressed(int x, int y){
if(drawing){ if(drawing) {
drawing=false; drawing=false;
this->deleteToolLayer(); this->deleteToolLayer();
} }
@@ -30,7 +30,7 @@ void IntelliTool::onMouseLeftPressed(int x, int y){
} }
void IntelliTool::onMouseLeftReleased(int x, int y){ void IntelliTool::onMouseLeftReleased(int x, int y){
if(drawing){ if(drawing) {
drawing=false; drawing=false;
this->mergeToolLayer(); this->mergeToolLayer();
this->deleteToolLayer(); this->deleteToolLayer();
@@ -56,8 +56,8 @@ void IntelliTool::createToolLayer(){
void IntelliTool::mergeToolLayer(){ void IntelliTool::mergeToolLayer(){
QColor clr_0; QColor clr_0;
QColor clr_1; QColor clr_1;
for(int y=0; y<Active->height; y++){ for(int y=0; y<Active->height; y++) {
for(int x=0; x<Active->width; x++){ for(int x=0; x<Active->width; x++) {
clr_0=Active->image->imageData.pixelColor(x,y); clr_0=Active->image->imageData.pixelColor(x,y);
clr_1=Canvas->image->imageData.pixelColor(x,y); clr_1=Canvas->image->imageData.pixelColor(x,y);
float t = static_cast<float>(clr_1.alpha())/255.f; float t = static_cast<float>(clr_1.alpha())/255.f;
@@ -79,4 +79,3 @@ void IntelliTool::deleteToolLayer(){
Area->deleteLayer(Area->activeLayer+1); Area->deleteLayer(Area->activeLayer+1);
this->Canvas=nullptr; this->Canvas=nullptr;
} }

View File

@@ -10,101 +10,101 @@ class PaintingArea;
/*! /*!
* \brief An abstract class that manages the basic events, like mouse clicks or scrolls events. * \brief An abstract class that manages the basic events, like mouse clicks or scrolls events.
*/ */
class IntelliTool{ class IntelliTool {
private: private:
/*! /*!
* \brief A function that creates a layer to draw on. * \brief A function that creates a layer to draw on.
*/ */
void createToolLayer(); void createToolLayer();
/*! /*!
* \brief A function that merges the drawing- and the active- layer. * \brief A function that merges the drawing- and the active- layer.
*/ */
void mergeToolLayer(); void mergeToolLayer();
/*! /*!
* \brief A function that deletes the drawinglayer. * \brief A function that deletes the drawinglayer.
*/ */
void deleteToolLayer(); void deleteToolLayer();
protected: protected:
/*! /*!
* \brief A pointer to the general PaintingArea to interact with. * \brief A pointer to the general PaintingArea to interact with.
*/ */
PaintingArea* Area; PaintingArea* Area;
/*! /*!
* \brief A pointer to the IntelliColorPicker of the PaintingArea to interact with, and get the colors. * \brief A pointer to the IntelliColorPicker of the PaintingArea to interact with, and get the colors.
*/ */
IntelliColorPicker* colorPicker; IntelliColorPicker* colorPicker;
/*! /*!
* \brief A pointer to the underlying active Layer, do not work on this. This is used for data grabbing or previews. * \brief A pointer to the underlying active Layer, do not work on this. This is used for data grabbing or previews.
*/ */
LayerObject* Active; LayerObject* Active;
/*! /*!
* \brief A pointer to the drawing canvas of the tool, work on this. * \brief A pointer to the drawing canvas of the tool, work on this.
*/ */
LayerObject* Canvas; LayerObject* Canvas;
/*! /*!
* \brief A flag checking if the user is currently drawing or not. * \brief A flag checking if the user is currently drawing or not.
*/ */
bool drawing = false; bool drawing = false;
public: public:
/*! /*!
* \brief A constructor setting the general Painting Area and colorPicker. * \brief A constructor setting the general Painting Area and colorPicker.
* \param Area - The general PaintingArea used by the project. * \param Area - The general PaintingArea used by the project.
* \param colorPicker - The general colorPicker used by the project. * \param colorPicker - The general colorPicker used by the project.
*/ */
IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker); IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker);
/*! /*!
* \brief An abstract Destructor. * \brief An abstract Destructor.
*/ */
virtual ~IntelliTool() = 0; virtual ~IntelliTool() = 0;
/*! /*!
* \brief A function managing the right click Pressed of a Mouse. Constructing the Canvas to draw on. Call this in child classes! * \brief A function managing the right click Pressed of a Mouse. Constructing the Canvas to draw on. Call this in child classes!
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseRightPressed(int x, int y); virtual void onMouseRightPressed(int x, int y);
/*! /*!
* \brief A function managing the right click Released of a Mouse. Merging the Canvas to Active. Call this in child classes! * \brief A function managing the right click Released of a Mouse. Merging the Canvas to Active. Call this in child classes!
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseRightReleased(int x, int y); virtual void onMouseRightReleased(int x, int y);
/*! /*!
* \brief A function managing the left click Pressed of a Mouse. Resetting the current draw. Call this in child classes! * \brief A function managing the left click Pressed of a Mouse. Resetting the current draw. Call this in child classes!
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseLeftPressed(int x, int y); virtual void onMouseLeftPressed(int x, int y);
/*! /*!
* \brief A function managing the left click Released of a Mouse. Call this in child classes! * \brief A function managing the left click Released of a Mouse. Call this in child classes!
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseLeftReleased(int x, int y); virtual void onMouseLeftReleased(int x, int y);
/*! /*!
* \brief A function managing the scroll event. A positive value means scrolling outwards. Call this in child classes! * \brief A function managing the scroll event. A positive value means scrolling outwards. Call this in child classes!
* \param value - The absolute the scroll has changed. * \param value - The absolute the scroll has changed.
*/ */
virtual void onWheelScrolled(int value); virtual void onWheelScrolled(int value);
/*! /*!
* \brief A function managing the mouse moved event. Call this in child classes! * \brief A function managing the mouse moved event. Call this in child classes!
* \param x - The x coordinate of the new mouse position. * \param x - The x coordinate of the new mouse position.
* \param y - The y coordinate of the new mouse position. * \param y - The y coordinate of the new mouse position.
*/ */
virtual void onMouseMoved(int x, int y); virtual void onMouseMoved(int x, int y);
}; };

View File

@@ -4,7 +4,7 @@
#include <cmath> #include <cmath>
IntelliToolCircle::IntelliToolCircle(PaintingArea* Area, IntelliColorPicker* colorPicker) IntelliToolCircle::IntelliToolCircle(PaintingArea* Area, IntelliColorPicker* colorPicker)
:IntelliTool(Area, colorPicker){ : IntelliTool(Area, colorPicker){
this->alphaInner = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 0,0,255,1); this->alphaInner = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 0,0,255,1);
this->edgeWidth = QInputDialog::getInt(nullptr,"Outer edge width", "Value:", 0,1,255,1); this->edgeWidth = QInputDialog::getInt(nullptr,"Outer edge width", "Value:", 0,1,255,1);
} }
@@ -21,7 +21,7 @@ void IntelliToolCircle::drawCyrcle(int radius){
yMin = Middle.y()-radius; yMin = Middle.y()-radius;
yMax = Middle.y()+radius; yMax = Middle.y()+radius;
// x = x0+-sqrt(r2-(y-y0)2) // x = x0+-sqrt(r2-(y-y0)2)
for(int i=yMin; i<=yMax; i++){ for(int i=yMin; i<=yMax; i++) {
xMin = Middle.x()-sqrt(pow(radius,2)-pow(i-Middle.y(),2)); xMin = Middle.x()-sqrt(pow(radius,2)-pow(i-Middle.y(),2));
xMax = Middle.x()+sqrt(pow(radius,2)-pow(i-Middle.y(),2)); xMax = Middle.x()+sqrt(pow(radius,2)-pow(i-Middle.y(),2));
this->Canvas->image->drawLine(QPoint(xMin,i), QPoint(xMax,i),inner,1); this->Canvas->image->drawLine(QPoint(xMin,i), QPoint(xMax,i),inner,1);
@@ -31,7 +31,7 @@ void IntelliToolCircle::drawCyrcle(int radius){
radius = radius +(this->edgeWidth/2.)-1.; radius = radius +(this->edgeWidth/2.)-1.;
yMin = (Middle.y()-radius); yMin = (Middle.y()-radius);
yMax = (Middle.y()+radius); yMax = (Middle.y()+radius);
for(int i=yMin; i<=yMax; i++){ for(int i=yMin; i<=yMax; i++) {
xMin = Middle.x()-sqrt(pow(radius,2)-pow(i-Middle.y(),2)); xMin = Middle.x()-sqrt(pow(radius,2)-pow(i-Middle.y(),2));
xMax = Middle.x()+sqrt(pow(radius,2)-pow(i-Middle.y(),2)); xMax = Middle.x()+sqrt(pow(radius,2)-pow(i-Middle.y(),2));
this->Canvas->image->drawPoint(QPoint(xMin,i), colorPicker->getFirstColor(),edgeWidth); this->Canvas->image->drawPoint(QPoint(xMin,i), colorPicker->getFirstColor(),edgeWidth);
@@ -40,7 +40,7 @@ void IntelliToolCircle::drawCyrcle(int radius){
xMin = (Middle.x()-radius); xMin = (Middle.x()-radius);
xMax = (Middle.x()+radius); xMax = (Middle.x()+radius);
for(int i=xMin; i<=xMax; i++){ for(int i=xMin; i<=xMax; i++) {
int yMin = Middle.y()-sqrt(pow(radius,2)-pow(i-Middle.x(),2)); int yMin = Middle.y()-sqrt(pow(radius,2)-pow(i-Middle.x(),2));
int yMax = Middle.y()+sqrt(pow(radius,2)-pow(i-Middle.x(),2)); int yMax = Middle.y()+sqrt(pow(radius,2)-pow(i-Middle.x(),2));
this->Canvas->image->drawPoint(QPoint(i, yMin), colorPicker->getFirstColor(),edgeWidth); this->Canvas->image->drawPoint(QPoint(i, yMin), colorPicker->getFirstColor(),edgeWidth);
@@ -71,13 +71,13 @@ void IntelliToolCircle::onMouseLeftReleased(int x, int y){
void IntelliToolCircle::onWheelScrolled(int value){ void IntelliToolCircle::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value); IntelliTool::onWheelScrolled(value);
this->edgeWidth+=value; this->edgeWidth+=value;
if(this->edgeWidth<=0){ if(this->edgeWidth<=0) {
this->edgeWidth=1; this->edgeWidth=1;
} }
} }
void IntelliToolCircle::onMouseMoved(int x, int y){ void IntelliToolCircle::onMouseMoved(int x, int y){
if(this->drawing){ if(this->drawing) {
this->Canvas->image->drawPlain(Qt::transparent); this->Canvas->image->drawPlain(Qt::transparent);
QPoint next(x,y); QPoint next(x,y);
int radius = static_cast<int>(sqrt(pow((Middle.x()-x),2)+pow((Middle.y()-y),2))); int radius = static_cast<int>(sqrt(pow((Middle.x()-x),2)+pow((Middle.y()-y),2)));

View File

@@ -7,80 +7,80 @@
/*! /*!
* \brief The IntelliToolCircle class represents a tool to draw a circle. * \brief The IntelliToolCircle class represents a tool to draw a circle.
*/ */
class IntelliToolCircle : public IntelliTool{ class IntelliToolCircle : public IntelliTool {
/*! /*!
* \brief A function that implements a circle drawing algorithm. * \brief A function that implements a circle drawing algorithm.
* \param radius - The radius of the circle. * \param radius - The radius of the circle.
*/ */
void drawCyrcle(int radius); void drawCyrcle(int radius);
/*! /*!
* \brief The center of the circle. * \brief The center of the circle.
*/ */
QPoint Middle; QPoint Middle;
/*! /*!
* \brief The alpha value of the inner circle. * \brief The alpha value of the inner circle.
*/ */
int alphaInner; int alphaInner;
/*! /*!
* \brief The width of the outer circle edge. * \brief The width of the outer circle edge.
*/ */
int edgeWidth; int edgeWidth;
public: public:
/*! /*!
* \brief A constructor setting the general paintingArea and colorPicker. And reading in the inner alpha and edgeWidth. * \brief A constructor setting the general paintingArea and colorPicker. And reading in the inner alpha and edgeWidth.
* \param Area - The general paintingArea used by the project. * \param Area - The general paintingArea used by the project.
* \param colorPicker - The general colorPicker used by the project. * \param colorPicker - The general colorPicker used by the project.
*/ */
IntelliToolCircle(PaintingArea* Area, IntelliColorPicker* colorPicker); IntelliToolCircle(PaintingArea* Area, IntelliColorPicker* colorPicker);
/*! /*!
* \brief A Destructor. * \brief A Destructor.
*/ */
virtual ~IntelliToolCircle() override; virtual ~IntelliToolCircle() override;
/*! /*!
* \brief A function managing the right click pressed of a mouse. Clearing the canvas layer. * \brief A function managing the right click pressed of a mouse. Clearing the canvas layer.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseRightPressed(int x, int y) override; virtual void onMouseRightPressed(int x, int y) override;
/*! /*!
* \brief A function managing the right click released of a mouse. * \brief A function managing the right click released of a mouse.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseRightReleased(int x, int y) override; virtual void onMouseRightReleased(int x, int y) override;
/*! /*!
* \brief A function managing the left click pressed of a mouse. Sets the middle point of the cricle. * \brief A function managing the left click pressed of a mouse. Sets the middle point of the cricle.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseLeftPressed(int x, int y) override; virtual void onMouseLeftPressed(int x, int y) override;
/*! /*!
* \brief A function managing the left click released of a mouse. * \brief A function managing the left click released of a mouse.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseLeftReleased(int x, int y) override; virtual void onMouseLeftReleased(int x, int y) override;
/*! /*!
* \brief A function managing the scroll event. Changing the edge Width relative to value. * \brief A function managing the scroll event. Changing the edge Width relative to value.
* \param value - The absolute the scroll has changed. * \param value - The absolute the scroll has changed.
*/ */
virtual void onWheelScrolled(int value) override; virtual void onWheelScrolled(int value) override;
/*! /*!
* \brief A function managing the mouse moved event. Draws a circle with radius of eulerian norm of mouse position and the middle point. * \brief A function managing the mouse moved event. Draws a circle with radius of eulerian norm of mouse position and the middle point.
* \param x - The x coordinate of the new mouse position. * \param x - The x coordinate of the new mouse position.
* \param y - The y coordinate of the new mouse position. * \param y - The y coordinate of the new mouse position.
*/ */
virtual void onMouseMoved(int x, int y) override; virtual void onMouseMoved(int x, int y) override;
}; };
#endif // INTELLITOOLCIRCLE_H #endif // INTELLITOOLCIRCLE_H

View File

@@ -6,14 +6,13 @@
#include <queue> #include <queue>
IntelliToolFloodFill::IntelliToolFloodFill(PaintingArea* Area, IntelliColorPicker* colorPicker) IntelliToolFloodFill::IntelliToolFloodFill(PaintingArea* Area, IntelliColorPicker* colorPicker)
:IntelliTool(Area, colorPicker){ : IntelliTool(Area, colorPicker){
} }
IntelliToolFloodFill::~IntelliToolFloodFill(){ IntelliToolFloodFill::~IntelliToolFloodFill(){
} }
void IntelliToolFloodFill::onMouseRightPressed(int x, int y){ void IntelliToolFloodFill::onMouseRightPressed(int x, int y){
IntelliTool::onMouseRightPressed(x,y); IntelliTool::onMouseRightPressed(x,y);
} }
@@ -23,7 +22,7 @@ void IntelliToolFloodFill::onMouseRightReleased(int x, int y){
} }
void IntelliToolFloodFill::onMouseLeftPressed(int x, int y){ void IntelliToolFloodFill::onMouseLeftPressed(int x, int y){
if(!(x>=0 && x<Area->getWidthOfActive() && y>=0 && y<Area->getHeightOfActive())){ if(!(x>=0 && x<Area->getWidthOfActive() && y>=0 && y<Area->getHeightOfActive())) {
return; return;
} }
IntelliTool::onMouseLeftPressed(x,y); IntelliTool::onMouseLeftPressed(x,y);
@@ -37,27 +36,27 @@ void IntelliToolFloodFill::onMouseLeftPressed(int x, int y){
Canvas->image->drawPixel(start,newColor); Canvas->image->drawPixel(start,newColor);
QPoint left, right, top, down; QPoint left, right, top, down;
while(!Q.empty()){ while(!Q.empty()) {
QPoint Current = Q.front(); QPoint Current = Q.front();
Q.pop(); Q.pop();
left = QPoint(Current.x()-1,Current.y() ); left = QPoint(Current.x()-1,Current.y() );
right = QPoint(Current.x()+1,Current.y() ); right = QPoint(Current.x()+1,Current.y() );
top = QPoint(Current.x() ,Current.y()-1); top = QPoint(Current.x(),Current.y()-1);
down = QPoint(Current.x() ,Current.y()+1); down = QPoint(Current.x(),Current.y()+1);
if((right.x() < Canvas->width) && (Canvas->image->getPixelColor(right) != newColor) && (Active->image->getPixelColor(right) == oldColor)){ if((right.x() < Canvas->width) && (Canvas->image->getPixelColor(right) != newColor) && (Active->image->getPixelColor(right) == oldColor)) {
Canvas->image->drawPixel(right,newColor); Canvas->image->drawPixel(right,newColor);
Q.push(right); Q.push(right);
} }
if((left.x() >= 0) && (Canvas->image->getPixelColor(left) != newColor) && (Active->image->getPixelColor(left) == oldColor)){ if((left.x() >= 0) && (Canvas->image->getPixelColor(left) != newColor) && (Active->image->getPixelColor(left) == oldColor)) {
Canvas->image->drawPixel(left,newColor); Canvas->image->drawPixel(left,newColor);
Q.push(left); Q.push(left);
} }
if((top.y() >= 0) && (Canvas->image->getPixelColor(top) != newColor) && (Active->image->getPixelColor(top) == oldColor)){ if((top.y() >= 0) && (Canvas->image->getPixelColor(top) != newColor) && (Active->image->getPixelColor(top) == oldColor)) {
Canvas->image->drawPixel(top,newColor); Canvas->image->drawPixel(top,newColor);
Q.push(top); Q.push(top);
} }
if((down.y() < Canvas->height) && (Canvas->image->getPixelColor(down) != newColor) && (Active->image->getPixelColor(down) == oldColor)){ if((down.y() < Canvas->height) && (Canvas->image->getPixelColor(down) != newColor) && (Active->image->getPixelColor(down) == oldColor)) {
Canvas->image->drawPixel(down,newColor); Canvas->image->drawPixel(down,newColor);
Q.push(down); Q.push(down);
} }

View File

@@ -7,61 +7,61 @@
/*! /*!
* \brief The IntelliToolFloodFill class represents a tool to flood FIll a certian area. * \brief The IntelliToolFloodFill class represents a tool to flood FIll a certian area.
*/ */
class IntelliToolFloodFill : public IntelliTool{ class IntelliToolFloodFill : public IntelliTool {
public: public:
/*! /*!
* \brief A constructor setting the general paintingArea and colorPicker. * \brief A constructor setting the general paintingArea and colorPicker.
* \param Area - The general paintingArea used by the project. * \param Area - The general paintingArea used by the project.
* \param colorPicker - The general colorPicker used by the project. * \param colorPicker - The general colorPicker used by the project.
*/ */
IntelliToolFloodFill(PaintingArea* Area, IntelliColorPicker* colorPicker); IntelliToolFloodFill(PaintingArea* Area, IntelliColorPicker* colorPicker);
/*! /*!
* \brief A Destructor. * \brief A Destructor.
*/ */
virtual ~IntelliToolFloodFill() override; virtual ~IntelliToolFloodFill() override;
/*! /*!
* \brief A function managing the right click pressed of a mouse. Clearing the canvas. * \brief A function managing the right click pressed of a mouse. Clearing the canvas.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseRightPressed(int x, int y) override; virtual void onMouseRightPressed(int x, int y) override;
/*! /*!
* \brief A function managing the right click released of a mouse. * \brief A function managing the right click released of a mouse.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseRightReleased(int x, int y) override; virtual void onMouseRightReleased(int x, int y) override;
/*! /*!
* \brief A function managing the left click pressed of a mouse. Sets the point to flood fill around and does this. * \brief A function managing the left click pressed of a mouse. Sets the point to flood fill around and does this.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseLeftPressed(int x, int y) override; virtual void onMouseLeftPressed(int x, int y) override;
/*! /*!
* \brief A function managing the left click released of a mouse. * \brief A function managing the left click released of a mouse.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseLeftReleased(int x, int y) override; virtual void onMouseLeftReleased(int x, int y) override;
/*! /*!
* \brief A function managing the scroll event. * \brief A function managing the scroll event.
* \param value - The absolute the scroll has changed. * \param value - The absolute the scroll has changed.
*/ */
virtual void onWheelScrolled(int value) override; virtual void onWheelScrolled(int value) override;
/*! /*!
* \brief A function managing the mouse moved event. * \brief A function managing the mouse moved event.
* \param x - The x coordinate of the new mouse position. * \param x - The x coordinate of the new mouse position.
* \param y - The y coordinate of the new mouse position. * \param y - The y coordinate of the new mouse position.
*/ */
virtual void onMouseMoved(int x, int y) override; virtual void onMouseMoved(int x, int y) override;
}; };
#endif // INTELLITOOLFLOODFILL_H #endif // INTELLITOOLFLOODFILL_H

View File

@@ -4,7 +4,7 @@
#include "QInputDialog" #include "QInputDialog"
IntelliToolLine::IntelliToolLine(PaintingArea* Area, IntelliColorPicker* colorPicker) IntelliToolLine::IntelliToolLine(PaintingArea* Area, IntelliColorPicker* colorPicker)
:IntelliTool(Area, colorPicker){ : IntelliTool(Area, colorPicker){
this->lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1); this->lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1);
//create checkbox or scroll dialog to get line style //create checkbox or scroll dialog to get line style
this->lineStyle = LineStyle::SOLID_LINE; this->lineStyle = LineStyle::SOLID_LINE;
@@ -14,7 +14,6 @@ IntelliToolLine::~IntelliToolLine(){
} }
void IntelliToolLine::onMouseRightPressed(int x, int y){ void IntelliToolLine::onMouseRightPressed(int x, int y){
IntelliTool::onMouseRightPressed(x,y); IntelliTool::onMouseRightPressed(x,y);
} }
@@ -37,16 +36,16 @@ void IntelliToolLine::onMouseLeftReleased(int x, int y){
void IntelliToolLine::onWheelScrolled(int value){ void IntelliToolLine::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value); IntelliTool::onWheelScrolled(value);
this->lineWidth+=value; this->lineWidth+=value;
if(this->lineWidth<=0){ if(this->lineWidth<=0) {
this->lineWidth=1; this->lineWidth=1;
} }
} }
void IntelliToolLine::onMouseMoved(int x, int y){ void IntelliToolLine::onMouseMoved(int x, int y){
if(this->drawing){ if(this->drawing) {
this->Canvas->image->drawPlain(Qt::transparent); this->Canvas->image->drawPlain(Qt::transparent);
QPoint next(x,y); QPoint next(x,y);
switch(lineStyle){ switch(lineStyle) {
case LineStyle::SOLID_LINE: case LineStyle::SOLID_LINE:
this->Canvas->image->drawLine(start,next,colorPicker->getFirstColor(),lineWidth); this->Canvas->image->drawLine(start,next,colorPicker->getFirstColor(),lineWidth);
break; break;

View File

@@ -7,7 +7,7 @@
/*! /*!
* \brief The LineStyle enum classifing all ways of drawing a line. * \brief The LineStyle enum classifing all ways of drawing a line.
*/ */
enum class LineStyle{ enum class LineStyle {
SOLID_LINE, SOLID_LINE,
DOTTED_LINE DOTTED_LINE
}; };
@@ -15,75 +15,75 @@ enum class LineStyle{
/*! /*!
* \brief The IntelliToolFloodFill class represents a tool to draw a line. * \brief The IntelliToolFloodFill class represents a tool to draw a line.
*/ */
class IntelliToolLine : public IntelliTool{ class IntelliToolLine : public IntelliTool {
/*! /*!
* \brief The starting point of the line. * \brief The starting point of the line.
*/ */
QPoint start; QPoint start;
/*! /*!
* \brief The width of the line to draw. * \brief The width of the line to draw.
*/ */
int lineWidth; int lineWidth;
/*! /*!
* \brief The style of the line. Apropriate to LineStyle. * \brief The style of the line. Apropriate to LineStyle.
*/ */
LineStyle lineStyle; LineStyle lineStyle;
public: public:
/*! /*!
* \brief A constructor setting the general paintingArea and colorPicker. And reading in the lineWidth and lineStyle. * \brief A constructor setting the general paintingArea and colorPicker. And reading in the lineWidth and lineStyle.
* \param Area - The general paintingArea used by the project. * \param Area - The general paintingArea used by the project.
* \param colorPicker - The general colorPicker used by the project. * \param colorPicker - The general colorPicker used by the project.
*/ */
IntelliToolLine(PaintingArea* Area, IntelliColorPicker* colorPicker); IntelliToolLine(PaintingArea* Area, IntelliColorPicker* colorPicker);
/*! /*!
* \brief An abstract Destructor. * \brief An abstract Destructor.
*/ */
virtual ~IntelliToolLine() override; virtual ~IntelliToolLine() override;
/*! /*!
* \brief A function managing the right click pressed of a mouse. Clearing the canvas. * \brief A function managing the right click pressed of a mouse. Clearing the canvas.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseRightPressed(int x, int y) override; virtual void onMouseRightPressed(int x, int y) override;
/*! /*!
* \brief A function managing the right click released of a mouse. * \brief A function managing the right click released of a mouse.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseRightReleased(int x, int y) override; virtual void onMouseRightReleased(int x, int y) override;
/*! /*!
* \brief A function managing the left click pressed of a mouse. Sets the starting point of the line. * \brief A function managing the left click pressed of a mouse. Sets the starting point of the line.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseLeftPressed(int x, int y) override; virtual void onMouseLeftPressed(int x, int y) override;
/*! /*!
* \brief A function managing the left click released of a mouse. * \brief A function managing the left click released of a mouse.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseLeftReleased(int x, int y) override; virtual void onMouseLeftReleased(int x, int y) override;
/*! /*!
* \brief A function managing the scroll event. Changing the lineWidth relative to value. * \brief A function managing the scroll event. Changing the lineWidth relative to value.
* \param value - The absolute the scroll has changed. * \param value - The absolute the scroll has changed.
*/ */
virtual void onWheelScrolled(int value) override; virtual void onWheelScrolled(int value) override;
/*! /*!
* \brief A function managing the mouse moved event. Drawing a Line from the startpoint to the current mouse position. * \brief A function managing the mouse moved event. Drawing a Line from the startpoint to the current mouse position.
* \param x - The x coordinate of the new mouse position. * \param x - The x coordinate of the new mouse position.
* \param y - The y coordinate of the new mouse position. * \param y - The y coordinate of the new mouse position.
*/ */
virtual void onMouseMoved(int x, int y) override; virtual void onMouseMoved(int x, int y) override;
}; };
#endif // INTELLITOOLLINE_H #endif // INTELLITOOLLINE_H

View File

@@ -5,7 +5,7 @@
#include "QInputDialog" #include "QInputDialog"
IntelliToolPen::IntelliToolPen(PaintingArea* Area, IntelliColorPicker* colorPicker) IntelliToolPen::IntelliToolPen(PaintingArea* Area, IntelliColorPicker* colorPicker)
:IntelliTool(Area, colorPicker){ : IntelliTool(Area, colorPicker){
this->penWidth = QInputDialog::getInt(nullptr, "Pen width", "Width:", 1,0, 50, 1); this->penWidth = QInputDialog::getInt(nullptr, "Pen width", "Width:", 1,0, 50, 1);
} }
@@ -33,7 +33,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);
this->Canvas->image->drawLine(this->point, newPoint, colorPicker->getFirstColor(), penWidth); this->Canvas->image->drawLine(this->point, newPoint, colorPicker->getFirstColor(), penWidth);
this->point=newPoint; this->point=newPoint;
@@ -44,7 +44,7 @@ void IntelliToolPen::onMouseMoved(int x, int y){
void IntelliToolPen::onWheelScrolled(int value){ void IntelliToolPen::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value); IntelliTool::onWheelScrolled(value);
this->penWidth+=value; this->penWidth+=value;
if(this->penWidth<=0){ if(this->penWidth<=0) {
this->penWidth=1; this->penWidth=1;
} }
} }

View File

@@ -1,73 +1,73 @@
#ifndef INTELLITOOLPEN_H #ifndef INTELLITOOLPEN_H
#define INTELLITOOLPEN_H #define INTELLITOOLPEN_H
#include"IntelliTool.h" #include "IntelliTool.h"
#include"QColor" #include "QColor"
#include"QPoint" #include "QPoint"
/*! /*!
* \brief The IntelliToolPen class represents a tool to draw a line. * \brief The IntelliToolPen class represents a tool to draw a line.
*/ */
class IntelliToolPen : public IntelliTool{ class IntelliToolPen : public IntelliTool {
/*! /*!
* \brief penWidth - The width of the Pen while drawing. * \brief penWidth - The width of the Pen while drawing.
*/ */
int penWidth; int penWidth;
/*! /*!
* \brief point - Represents the previous point to help drawing a line. * \brief point - Represents the previous point to help drawing a line.
*/ */
QPoint point; QPoint point;
public: public:
/*! /*!
* \brief A constructor setting the general paintingArea and colorPicker. Reading the penWidth. * \brief A constructor setting the general paintingArea and colorPicker. Reading the penWidth.
* \param Area - The general PaintingArea used by the project. * \param Area - The general PaintingArea used by the project.
* \param colorPicker - The general colorPicker used by the project. * \param colorPicker - The general colorPicker used by the project.
*/ */
IntelliToolPen(PaintingArea* Area, IntelliColorPicker* colorPicker); IntelliToolPen(PaintingArea* Area, IntelliColorPicker* colorPicker);
/*! /*!
* \brief A Destructor. * \brief A Destructor.
*/ */
virtual ~IntelliToolPen() override; virtual ~IntelliToolPen() override;
/*! /*!
* \brief A function managing the right click pressed of a mouse. Resetting the current draw. * \brief A function managing the right click pressed of a mouse. Resetting the current draw.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseRightPressed(int x, int y) override; virtual void onMouseRightPressed(int x, int y) override;
/*! /*!
* \brief A function managing the right click released of a mouse. * \brief A function managing the right click released of a mouse.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseRightReleased(int x, int y) override; virtual void onMouseRightReleased(int x, int y) override;
/*! /*!
* \brief A function managing the left click pressed of a mouse. Starting the drawing procedure. * \brief A function managing the left click pressed of a mouse. Starting the drawing procedure.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseLeftPressed(int x, int y) override; virtual void onMouseLeftPressed(int x, int y) override;
/*! /*!
* \brief A function managing the left click released of a mouse. Merging the drawing to the active layer. * \brief A function managing the left click released of a mouse. Merging the drawing to the active layer.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseLeftReleased(int x, int y) override; virtual void onMouseLeftReleased(int x, int y) override;
/*! /*!
* \brief A function managing the scroll event. Changing penWidth relativ to value. * \brief A function managing the scroll event. Changing penWidth relativ to value.
* \param value - The absolute the scroll has changed. * \param value - The absolute the scroll has changed.
*/ */
virtual void onWheelScrolled(int value) override; virtual void onWheelScrolled(int value) override;
/*! /*!
* \brief A function managing the mouse moved event. To draw the line. * \brief A function managing the mouse moved event. To draw the line.
* \param x - The x coordinate of the new mouse position. * \param x - The x coordinate of the new mouse position.
* \param y - The y coordinate of the new mouse position. * \param y - The y coordinate of the new mouse position.
*/ */
virtual void onMouseMoved(int x, int y) override; virtual void onMouseMoved(int x, int y) override;
}; };
#endif // INTELLITOOLPEN_H #endif // INTELLITOOLPEN_H

View File

@@ -3,7 +3,7 @@
#include "QColorDialog" #include "QColorDialog"
IntelliToolPlainTool::IntelliToolPlainTool(PaintingArea* Area, IntelliColorPicker* colorPicker) IntelliToolPlainTool::IntelliToolPlainTool(PaintingArea* Area, IntelliColorPicker* colorPicker)
:IntelliTool(Area, colorPicker){ : IntelliTool(Area, colorPicker){
} }
IntelliToolPlainTool::~IntelliToolPlainTool(){ IntelliToolPlainTool::~IntelliToolPlainTool(){
@@ -28,7 +28,6 @@ void IntelliToolPlainTool::onMouseRightReleased(int x, int y){
IntelliTool::onMouseRightReleased(x,y); IntelliTool::onMouseRightReleased(x,y);
} }
void IntelliToolPlainTool::onMouseMoved(int x, int y){ void IntelliToolPlainTool::onMouseMoved(int x, int y){
IntelliTool::onMouseMoved(x,y); IntelliTool::onMouseMoved(x,y);
} }

View File

@@ -6,59 +6,59 @@
/*! /*!
* \brief The IntelliToolPlainTool class represents a tool to fill the whole canvas with one color. * \brief The IntelliToolPlainTool class represents a tool to fill the whole canvas with one color.
*/ */
class IntelliToolPlainTool : public IntelliTool{ class IntelliToolPlainTool : public IntelliTool {
public: public:
/*! /*!
* \brief A constructor setting the general paintingArea and colorPicker. * \brief A constructor setting the general paintingArea and colorPicker.
* \param Area - The general paintingArea used by the project. * \param Area - The general paintingArea used by the project.
* \param colorPicker - The general colorPicker used by the project. * \param colorPicker - The general colorPicker used by the project.
*/ */
IntelliToolPlainTool(PaintingArea *Area, IntelliColorPicker* colorPicker); IntelliToolPlainTool(PaintingArea*Area, IntelliColorPicker* colorPicker);
/*! /*!
* \brief A Destructor. * \brief A Destructor.
*/ */
virtual ~IntelliToolPlainTool() override; virtual ~IntelliToolPlainTool() override;
/*! /*!
* \brief A function managing the right click pressed of a mouse. Resetting the current fill. * \brief A function managing the right click pressed of a mouse. Resetting the current fill.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseRightPressed(int x, int y) override; virtual void onMouseRightPressed(int x, int y) override;
/*! /*!
* \brief A function managing the right click released of a mouse. * \brief A function managing the right click released of a mouse.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseRightReleased(int x, int y) override; virtual void onMouseRightReleased(int x, int y) override;
/*! /*!
* \brief A function managing the left click pressed of a mouse. Filling the whole canvas. * \brief A function managing the left click pressed of a mouse. Filling the whole canvas.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseLeftPressed(int x, int y) override; virtual void onMouseLeftPressed(int x, int y) override;
/*! /*!
* \brief A function managing the left click released of a mouse. Merging the fill to the active layer. * \brief A function managing the left click released of a mouse. Merging the fill to the active layer.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseLeftReleased(int x, int y) override; virtual void onMouseLeftReleased(int x, int y) override;
/*! /*!
* \brief A function managing the scroll event. * \brief A function managing the scroll event.
* \param value - The absolute the scroll has changed. * \param value - The absolute the scroll has changed.
*/ */
virtual void onWheelScrolled(int value) override; virtual void onWheelScrolled(int value) override;
/*! /*!
* \brief A function managing the mouse moved event. * \brief A function managing the mouse moved event.
* \param x - The x coordinate of the new mouse position. * \param x - The x coordinate of the new mouse position.
* \param y - The y coordinate of the new mouse position. * \param y - The y coordinate of the new mouse position.
*/ */
virtual void onMouseMoved(int x, int y) override; virtual void onMouseMoved(int x, int y) override;
}; };

View File

@@ -5,7 +5,7 @@
#include <QInputDialog> #include <QInputDialog>
IntelliToolPolygon::IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker) IntelliToolPolygon::IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker)
:IntelliTool(Area, colorPicker){ : IntelliTool(Area, colorPicker){
this->alphaInner = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 0,0,255,1); this->alphaInner = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 0,0,255,1);
lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1);; lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1);;
PointIsNearStart = false; PointIsNearStart = false;
@@ -17,7 +17,7 @@ IntelliToolPolygon::~IntelliToolPolygon(){
} }
void IntelliToolPolygon::onMouseLeftPressed(int x, int y){ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
if(!isDrawing && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()){ if(!isDrawing && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()) {
IntelliTool::onMouseLeftPressed(x,y); IntelliTool::onMouseLeftPressed(x,y);
QPoint drawingPoint = QPoint(x,y); QPoint drawingPoint = QPoint(x,y);
@@ -27,12 +27,12 @@ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
this->Canvas->image->drawPoint(QPointList.back(), colorPicker->getFirstColor(), lineWidth); this->Canvas->image->drawPoint(QPointList.back(), colorPicker->getFirstColor(), lineWidth);
this->Canvas->image->calculateVisiblity(); this->Canvas->image->calculateVisiblity();
} }
else if(isDrawing && isNearStart(x,y,QPointList.front())){ else if(isDrawing && isNearStart(x,y,QPointList.front())) {
PointIsNearStart = true; PointIsNearStart = true;
this->Canvas->image->drawLine(QPointList.back(), QPointList.front(), colorPicker->getFirstColor(), lineWidth); this->Canvas->image->drawLine(QPointList.back(), QPointList.front(), colorPicker->getFirstColor(), lineWidth);
this->Canvas->image->calculateVisiblity(); this->Canvas->image->calculateVisiblity();
} }
else if(isDrawing){ else if(isDrawing) {
QPoint drawingPoint(x,y); QPoint drawingPoint(x,y);
QPointList.push_back(drawingPoint); QPointList.push_back(drawingPoint);
this->Canvas->image->drawLine(QPointList[QPointList.size() - 2], QPointList[QPointList.size() - 1], colorPicker->getFirstColor(), lineWidth); this->Canvas->image->drawLine(QPointList[QPointList.size() - 2], QPointList[QPointList.size() - 1], colorPicker->getFirstColor(), lineWidth);
@@ -48,22 +48,22 @@ void IntelliToolPolygon::onMouseRightPressed(int x, int y){
} }
void IntelliToolPolygon::onMouseLeftReleased(int x, int y){ void IntelliToolPolygon::onMouseLeftReleased(int x, int y){
if(PointIsNearStart && QPointList.size() > 1){ if(PointIsNearStart && QPointList.size() > 1) {
PointIsNearStart = false; PointIsNearStart = false;
isDrawing = false; isDrawing = false;
std::vector<Triangle> Triangles = IntelliHelper::calculateTriangles(QPointList); std::vector<Triangle> Triangles = IntelliHelper::calculateTriangles(QPointList);
QPoint Point; QPoint Point;
QColor colorTwo(colorPicker->getSecondColor()); QColor colorTwo(colorPicker->getSecondColor());
colorTwo.setAlpha(alphaInner); colorTwo.setAlpha(alphaInner);
for(int i = 0; i < Active->width; i++){ for(int i = 0; i < Active->width; i++) {
for(int j = 0; j < Active->height; j++){ for(int j = 0; j < Active->height; j++) {
Point = QPoint(i,j); Point = QPoint(i,j);
if(IntelliHelper::isInPolygon(Triangles,Point)){ if(IntelliHelper::isInPolygon(Triangles,Point)) {
this->Canvas->image->drawPixel(Point, colorTwo); this->Canvas->image->drawPixel(Point, colorTwo);
} }
} }
} }
for(int i=0; i<QPointList.size(); i++){ for(int i=0; i<QPointList.size(); i++) {
int next = (i+1)%QPointList.size(); int next = (i+1)%QPointList.size();
this->Canvas->image->drawLine(QPointList[i], QPointList[next], colorPicker->getFirstColor(), lineWidth); this->Canvas->image->drawLine(QPointList[i], QPointList[next], colorPicker->getFirstColor(), lineWidth);
} }
@@ -78,11 +78,11 @@ void IntelliToolPolygon::onMouseRightReleased(int x, int y){
void IntelliToolPolygon::onWheelScrolled(int value){ void IntelliToolPolygon::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value); IntelliTool::onWheelScrolled(value);
if(!isDrawing){ if(!isDrawing) {
if(lineWidth + value < 10){ if(lineWidth + value < 10) {
lineWidth += value; lineWidth += value;
} }
if(lineWidth < 1){ if(lineWidth < 1) {
lineWidth = 1; lineWidth = 1;
} }
} }
@@ -98,9 +98,9 @@ bool IntelliToolPolygon::isNearStart(int x, int y, QPoint Startpoint){
int StartY = Startpoint.y(); int StartY = Startpoint.y();
int valueToNear = 10; int valueToNear = 10;
for(int i = StartX - valueToNear; i < StartX + valueToNear; i++){ for(int i = StartX - valueToNear; i < StartX + valueToNear; i++) {
for(int j = StartY - valueToNear; j < StartY + valueToNear; j++){ for(int j = StartY - valueToNear; j < StartY + valueToNear; j++) {
if((i == x) && (j == y)){ if((i == x) && (j == y)) {
isNear = true; isNear = true;
} }
} }

View File

@@ -10,92 +10,91 @@
*/ */
class IntelliToolPolygon : public IntelliTool class IntelliToolPolygon : public IntelliTool
{ {
/*! /*!
* \brief Checks if the given Point lies near the starting Point. * \brief Checks if the given Point lies near the starting Point.
* \param x - x coordinate of a point. * \param x - x coordinate of a point.
* \param y - y coordinate of a point. * \param y - y coordinate of a point.
* \param Startpoint - The startingpoint to check for. * \param Startpoint - The startingpoint to check for.
* \return Returns true if the (x,y) point is near to the startpoint, otherwise false. * \return Returns true if the (x,y) point is near to the startpoint, otherwise false.
*/ */
bool isNearStart(int x, int y, QPoint Startpoint); bool isNearStart(int x, int y, QPoint Startpoint);
/*! /*!
* \brief LineWidth of the drawing polygon. * \brief LineWidth of the drawing polygon.
*/ */
int lineWidth; int lineWidth;
/*! /*!
* \brief IsDrawing true while drawing, else false. * \brief IsDrawing true while drawing, else false.
*/ */
bool isDrawing; bool isDrawing;
/*! /*!
* \brief PointIsNearStart true, when last click near startpoint, else false. * \brief PointIsNearStart true, when last click near startpoint, else false.
*/ */
bool PointIsNearStart; bool PointIsNearStart;
/*! /*!
* \brief The alpha value of the inner circle. * \brief The alpha value of the inner circle.
*/ */
int alphaInner; int alphaInner;
/*! /*!
* \brief QPointList list of all points of the polygon. * \brief QPointList list of all points of the polygon.
*/ */
std::vector<QPoint> QPointList; std::vector<QPoint> QPointList;
public: public:
/*! /*!
* \brief A constructor setting the general paintingArea and colorPicker. * \brief A constructor setting the general paintingArea and colorPicker.
* \param Area - The general paintingArea used by the project. * \param Area - The general paintingArea used by the project.
* \param colorPicker - The general colorPicker used by the project. * \param colorPicker - The general colorPicker used by the project.
*/ */
IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker); IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker);
/*! /*!
* \brief A Destructor. * \brief A Destructor.
*/ */
~IntelliToolPolygon() override; ~IntelliToolPolygon() override;
/*! /*!
* \brief A function managing the left click pressed of a mouse. Setting polygon points. * \brief A function managing the left click pressed of a mouse. Setting polygon points.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseLeftPressed(int x, int y) override; virtual void onMouseLeftPressed(int x, int y) override;
/*! /*!
* \brief A function managing the left click released of a mouse. Merging the fill to the active layer. * \brief A function managing the left click released of a mouse. Merging the fill to the active layer.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseLeftReleased(int x, int y) override; virtual void onMouseLeftReleased(int x, int y) override;
/*! /*!
* \brief A function managing the right click pressed of a mouse. Resetting the current fill. * \brief A function managing the right click pressed of a mouse. Resetting the current fill.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseRightPressed(int x, int y) override; virtual void onMouseRightPressed(int x, int y) override;
/*! /*!
* \brief A function managing the right click released of a mouse. * \brief A function managing the right click released of a mouse.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseRightReleased(int x, int y) override; virtual void onMouseRightReleased(int x, int y) override;
/*! /*!
* \brief A function managing the scroll event. CHanging the lineWidth relative to value. * \brief A function managing the scroll event. CHanging the lineWidth relative to value.
* \param value - The absolute the scroll has changed. * \param value - The absolute the scroll has changed.
*/ */
virtual void onWheelScrolled(int value) override; virtual void onWheelScrolled(int value) override;
/*! /*!
* \brief A function managing the mouse moved event. * \brief A function managing the mouse moved event.
* \param x - The x coordinate of the new mouse position. * \param x - The x coordinate of the new mouse position.
* \param y - The y coordinate of the new mouse position. * \param y - The y coordinate of the new mouse position.
*/ */
virtual void onMouseMoved(int x, int y) override; virtual void onMouseMoved(int x, int y) override;
}; };

View File

@@ -1,9 +1,9 @@
#include"IntelliToolRectangle.h" #include "IntelliToolRectangle.h"
#include "Layer/PaintingArea.h" #include "Layer/PaintingArea.h"
#include "QInputDialog" #include "QInputDialog"
IntelliToolRectangle::IntelliToolRectangle(PaintingArea* Area, IntelliColorPicker* colorPicker) IntelliToolRectangle::IntelliToolRectangle(PaintingArea* Area, IntelliColorPicker* colorPicker)
:IntelliTool(Area, colorPicker){ : IntelliTool(Area, colorPicker){
this->alphaInner = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 0,0,255,1); this->alphaInner = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 0,0,255,1);
this->edgeWidth = QInputDialog::getInt(nullptr,"Outer edge width", "Value:", 0,1,255,1); this->edgeWidth = QInputDialog::getInt(nullptr,"Outer edge width", "Value:", 0,1,255,1);
} }
@@ -21,7 +21,7 @@ void IntelliToolRectangle::drawRectangle(QPoint otherCornor){
QColor clr = colorPicker->getSecondColor(); QColor clr = colorPicker->getSecondColor();
clr.setAlpha(alphaInner); clr.setAlpha(alphaInner);
for(int y=yMin; y<=yMax; y++){ for(int y=yMin; y<=yMax; y++) {
this->Canvas->image->drawLine(QPoint(xMin,y), QPoint(xMax, y), clr, 1); this->Canvas->image->drawLine(QPoint(xMin,y), QPoint(xMax, y), clr, 1);
} }
this->Canvas->image->drawLine(QPoint(xMin, yMin),QPoint(xMin, yMax), this->colorPicker->getFirstColor(), edgeWidth); this->Canvas->image->drawLine(QPoint(xMin, yMin),QPoint(xMin, yMax), this->colorPicker->getFirstColor(), edgeWidth);
@@ -50,7 +50,7 @@ void IntelliToolRectangle::onMouseLeftReleased(int x, int y){
} }
void IntelliToolRectangle::onMouseMoved(int x, int y){ void IntelliToolRectangle::onMouseMoved(int x, int y){
if(this->drawing){ if(this->drawing) {
this->Canvas->image->drawPlain(Qt::transparent); this->Canvas->image->drawPlain(Qt::transparent);
QPoint next(x,y); QPoint next(x,y);
drawRectangle(next); drawRectangle(next);
@@ -61,7 +61,7 @@ void IntelliToolRectangle::onMouseMoved(int x, int y){
void IntelliToolRectangle::onWheelScrolled(int value){ void IntelliToolRectangle::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value); IntelliTool::onWheelScrolled(value);
this->edgeWidth+=value; this->edgeWidth+=value;
if(this->edgeWidth<=0){ if(this->edgeWidth<=0) {
this->edgeWidth=1; this->edgeWidth=1;
} }
} }

View File

@@ -8,77 +8,77 @@
/*! /*!
* \brief The IntelliToolRectangle class represents a tool to draw a rectangle. * \brief The IntelliToolRectangle class represents a tool to draw a rectangle.
*/ */
class IntelliToolRectangle : public IntelliTool{ class IntelliToolRectangle : public IntelliTool {
/*! /*!
* \brief A function that implements a rectagle drawing algorithm. * \brief A function that implements a rectagle drawing algorithm.
* \param otherCornor - The second corner point of the rectangle. * \param otherCornor - The second corner point of the rectangle.
*/ */
void drawRectangle(QPoint otherCornor); void drawRectangle(QPoint otherCornor);
/*! /*!
* \brief originCornor - The first corner point of the rectangle. * \brief originCornor - The first corner point of the rectangle.
*/ */
QPoint originCornor; QPoint originCornor;
/*! /*!
* \brief alphaInner- Represents the alpha value of the inside. * \brief alphaInner- Represents the alpha value of the inside.
*/ */
int alphaInner; int alphaInner;
/*! /*!
* \brief edgeWidth - The width of the rectangle edges. * \brief edgeWidth - The width of the rectangle edges.
*/ */
int edgeWidth; int edgeWidth;
public: public:
/*! /*!
* \brief A constructor setting the general paintingArea and colorPicker. And reading in the alphaInner and edgeWidth. * \brief A constructor setting the general paintingArea and colorPicker. And reading in the alphaInner and edgeWidth.
* \param Area - The general paintingArea used by the project. * \param Area - The general paintingArea used by the project.
* \param colorPicker - The general colorPicker used by the project. * \param colorPicker - The general colorPicker used by the project.
*/ */
IntelliToolRectangle(PaintingArea* Area, IntelliColorPicker* colorPicker); IntelliToolRectangle(PaintingArea* Area, IntelliColorPicker* colorPicker);
/*! /*!
* \brief A Destructor. * \brief A Destructor.
*/ */
virtual ~IntelliToolRectangle() override; virtual ~IntelliToolRectangle() override;
/*! /*!
* \brief A function managing the right click pressed of a mouse.Resetting the current draw. * \brief A function managing the right click pressed of a mouse.Resetting the current draw.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseRightPressed(int x, int y) override; virtual void onMouseRightPressed(int x, int y) override;
/*! /*!
* \brief A function managing the right click released of a mouse. * \brief A function managing the right click released of a mouse.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseRightReleased(int x, int y) override; virtual void onMouseRightReleased(int x, int y) override;
/*! /*!
* \brief A function managing the left click pressed of a mouse. Setting the originCorner and draws a rectangle. * \brief A function managing the left click pressed of a mouse. Setting the originCorner and draws a rectangle.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseLeftPressed(int x, int y) override; virtual void onMouseLeftPressed(int x, int y) override;
/*! /*!
* \brief A function managing the left click released of a mouse. Merging the draw to the active layer. * \brief A function managing the left click released of a mouse. Merging the draw to the active layer.
* \param x - The x coordinate relative to the active/canvas layer. * \param x - The x coordinate relative to the active/canvas layer.
* \param y - The y coordinate relative to the active/canvas layer. * \param y - The y coordinate relative to the active/canvas layer.
*/ */
virtual void onMouseLeftReleased(int x, int y) override; virtual void onMouseLeftReleased(int x, int y) override;
/*! /*!
* \brief A function managing the scroll event.Changing edgeWidth relativ to value. * \brief A function managing the scroll event.Changing edgeWidth relativ to value.
* \param value - The absolute the scroll has changed. * \param value - The absolute the scroll has changed.
*/ */
virtual void onWheelScrolled(int value) override; virtual void onWheelScrolled(int value) override;
/*! /*!
* \brief A function managing the mouse moved event.Drawing a rectangle to currrent mouse position. * \brief A function managing the mouse moved event.Drawing a rectangle to currrent mouse position.
* \param x - The x coordinate of the new mouse position. * \param x - The x coordinate of the new mouse position.
* \param y - The y coordinate of the new mouse position. * \param y - The y coordinate of the new mouse position.
*/ */
virtual void onMouseMoved(int x, int y) override; virtual void onMouseMoved(int x, int y) override;
}; };
#endif // INTELLIRECTANGLETOOL_H #endif // INTELLIRECTANGLETOOL_H