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

View File

@@ -1,9 +1,9 @@
#include"Image/IntelliImage.h"
#include<QSize>
#include<QPainter>
#include "Image/IntelliImage.h"
#include <QSize>
#include <QPainter>
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));
}
@@ -26,7 +26,7 @@ bool IntelliImage::loadImage(const QString &fileName){
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
if (image->size() == newSize)
return;

View File

@@ -1,17 +1,17 @@
#ifndef INTELLIIMAGE_H
#define INTELLIIMAGE_H
#include<QImage>
#include<QPoint>
#include<QColor>
#include<QSize>
#include<QWidget>
#include<vector>
#include <QImage>
#include <QPoint>
#include <QColor>
#include <QSize>
#include <QWidget>
#include <vector>
/*!
* \brief The Types, which an Image can be.
*/
enum class ImageType{
enum class ImageType {
Raster_Image,
Shaped_Image
};
@@ -21,110 +21,112 @@ class IntelliTool;
/*!
* \brief An abstract class which manages the basic IntelliImage operations.
*/
class IntelliImage{
friend IntelliTool;
class IntelliImage {
friend IntelliTool;
protected:
void resizeImage(QImage *image, const QSize &newSize);
void resizeImage(QImage*image, const QSize &newSize);
/*!
/*!
* \brief The underlying image data.
*/
QImage imageData;
QImage imageData;
public:
/*!
/*!
* \brief The Construcor of the IntelliImage. Given the Image dimensions.
* \param weight - The weight of the Image.
* \param height - The height of the Image.
*/
IntelliImage(int weight, int height);
IntelliImage(int weight, int height);
/*!
/*!
* \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.
* \param p1 - The coordinates of the pixel, which should be drawn. [Top-Left-System]
* \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.
* \param p1 - The coordinates of the first Point.
* \param p2 - The coordinates of the second Point.
* \param color - The color 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
* \param p1
* \param color
* \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.
* \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.
* \param displaySize - The size, in whcih the Image should be displayed.
* \param alpha - The maximum alpha value, a pixel can have.
* \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.
* @param alpha - The maximum alpha value, a pixel can have.
* @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
* \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.
*/
virtual void calculateVisiblity()=0;
virtual void calculateVisiblity() = 0;
/*!
/*!
* \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.
*/
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.
* \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.
* \param fileName - The path+name of the image which to loaded.
* \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
* \param point - The point from whcih to get the coordinates.
* \return The color of the Pixel as QColor.
*/
virtual QColor getPixelColor(QPoint& point);
virtual QColor getPixelColor(QPoint& point);
};
#endif

View File

@@ -1,10 +1,10 @@
#include"Image/IntelliRasterImage.h"
#include<QPainter>
#include<QRect>
#include<QDebug>
#include "Image/IntelliRasterImage.h"
#include <QPainter>
#include <QRect>
#include <QDebug>
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 copy = imageData;
for(int y = 0; y<copy.height(); y++){
for(int x = 0; x<copy.width(); x++){
for(int y = 0; y<copy.height(); y++) {
for(int x = 0; x<copy.width(); x++) {
QColor clr = copy.pixelColor(x,y);
clr.setAlpha(std::min(alpha, clr.alpha()));
copy.setPixelColor(x,y, clr);

View File

@@ -1,57 +1,57 @@
#ifndef INTELLIRASTER_H
#define INTELLIRASTER_H
#include"Image/IntelliImage.h"
#include "Image/IntelliImage.h"
/*!
* \brief The IntelliRasterImage manages a Rasterimage.
*/
class IntelliRasterImage : public IntelliImage{
friend IntelliTool;
class IntelliRasterImage : public IntelliImage {
friend IntelliTool;
protected:
/*!
/*!
* \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:
/*!
/*!
* \brief The Construcor of the IntelliRasterImage. Given the Image dimensions.
* \param weight - The weight of the Image.
* \param height - The height of the Image.
*/
IntelliRasterImage(int weight, int height);
IntelliRasterImage(int weight, int height);
/*!
/*!
* \brief An Destructor.
*/
virtual ~IntelliRasterImage() override;
virtual ~IntelliRasterImage() override;
/*!
/*!
* \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 alpha - The maximum alpha value, a pixel can have.
* \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.
* @param alpha - The maximum alpha value, a pixel can have.
* @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
* \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.
* \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

View File

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

View File

@@ -1,76 +1,78 @@
#ifndef INTELLISHAPE_H
#define INTELLISHAPE_H
#include"Image/IntelliRasterImage.h"
#include<vector>
#include"IntelliHelper/IntelliHelper.h"
#include "Image/IntelliRasterImage.h"
#include <vector>
#include "IntelliHelper/IntelliHelper.h"
/*!
* \brief The IntelliShapedImage manages a Shapedimage.
*/
class IntelliShapedImage : public IntelliRasterImage{
friend IntelliTool;
class IntelliShapedImage : public IntelliRasterImage {
friend IntelliTool;
private:
/*!
/*!
* \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.
*/
virtual void calculateVisiblity() override;
virtual void calculateVisiblity() override;
protected:
/*!
/*!
* \brief The Vertices of The Polygon. Needs to be a planar Polygon.
*/
std::vector<QPoint> polygonData;
std::vector<QPoint> polygonData;
public:
/*!
/*!
* \brief The Construcor of the IntelliShapedImage. Given the Image dimensions.
* \param weight - The weight of the Image.
* \param height - The height of the Image.
*/
IntelliShapedImage(int weight, int height);
IntelliShapedImage(int weight, int height);
/*!
/*!
* \brief An Destructor.
*/
virtual ~IntelliShapedImage() override;
virtual ~IntelliShapedImage() override;
/*!
/*!
* \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 alpha - The maximum alpha value, a pixel can have.
* \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.
* @param alpha - The maximum alpha value, a pixel can have.
* @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
* \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.
* \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.
* \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

View File

@@ -1,64 +1,64 @@
#ifndef INTELLITOOLSETCOLORTOOL_H
#define INTELLITOOLSETCOLORTOOL_H
#include"QColor"
#include"QPoint"
#include"QColorDialog"
#include "QColor"
#include "QPoint"
#include "QColorDialog"
/*!
* \brief The IntelliColorPicker manages the selected colors for one whole project.
*/
class IntelliColorPicker{
class IntelliColorPicker {
public:
/*!
/*!
* \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.
*/
virtual ~IntelliColorPicker();
virtual ~IntelliColorPicker();
/*!
/*!
* \brief A function switching primary and secondary color.
*/
void switchColors();
void switchColors();
/*!
/*!
* \brief A function to read the primary selected color.
* \return Returns the primary color.
*/
QColor getFirstColor();
QColor getFirstColor();
/*!
/*!
* \brief A function to read the secondary selected color.
* \return Returns the secondary color.
*/
QColor getSecondColor();
QColor getSecondColor();
/*!
/*!
* \brief A function to set the primary color.
* \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.
* \param Color - The color to be set as secondary.
*/
void setSecondColor(QColor Color);
void setSecondColor(QColor Color);
private:
/*!
/*!
* \brief The primary color.
*/
QColor firstColor;
QColor firstColor;
/*!
/*!
* \brief The secondary color.
*/
QColor secondColor;
QColor secondColor;
};
#endif // INTELLITOOLSETCOLORTOOL_H

View File

@@ -1,12 +1,12 @@
#include"IntelliHelper.h"
#include<algorithm>
#include<queue>
#include<cmath>
#include "IntelliHelper.h"
#include <algorithm>
#include <queue>
#include <cmath>
std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> polyPoints){
// helper for managing the triangle vertices and their state
struct TriangleHelper{
struct TriangleHelper {
QPoint vertex;
float interiorAngle;
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
auto getTip= [](const std::vector<TriangleHelper>& vec){
size_t min = 0;
for(size_t i=0; i<vec.size(); i++){
if(vec[i].interiorAngle<vec[min].interiorAngle){
for(size_t i=0; i<vec.size(); i++) {
if(vec[i].interiorAngle<vec[min].interiorAngle) {
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
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
@@ -53,7 +53,7 @@ std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> poly
std::vector<Triangle> Triangles;
// 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;
int prev = getPrev(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
while(Triangles.size() != polyPoints.size()-2){
while(Triangles.size() != polyPoints.size()-2) {
Triangle tri;
TriangleHelper smallest = getTip(Vertices);
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
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;
}
// update post und prev index
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
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){
for(auto triangle : triangles){
if(IntelliHelper::isInTriangle(triangle, point)){
for(auto triangle : triangles) {
if(IntelliHelper::isInTriangle(triangle, point)) {
return true;
}
}

View File

@@ -1,36 +1,36 @@
#ifndef INTELLIHELPER_H
#define INTELLIHELPER_H
#include<QPoint>
#include<vector>
#include <QPoint>
#include <vector>
/*!
* \brief The Triangle struct holds the 3 vertices of a triangle.
*/
struct Triangle{
struct Triangle {
QPoint A,B,C;
};
namespace IntelliHelper {
/*!
/*!
* \brief A function to get the 2*area of a traingle, using its determinat.
* \param p1 - The Point to check its side.
* \param p2 - The first Point of the spanning Line
* \param p3 - The second Point of the spanning line.
* \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());
}
}
/*!
/*!
* \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 P - The point to check if it is in the triangle.
* \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;
bool neg, pos;
@@ -42,22 +42,22 @@ namespace IntelliHelper {
pos = (val1>0.f) || (val2>0.f) || (val3>0.f);
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.
* \param polyPoints - The Vertices of the polygon.
* \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.
* \param triangles - The spanning triangles of the planar 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.
*/
bool isInPolygon(std::vector<Triangle> &triangles, QPoint &point);
bool isInPolygon(std::vector<Triangle> &triangles, QPoint &point);
}
#endif

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
#include"IntelliTool.h"
#include"Layer/PaintingArea.h"
#include "IntelliTool.h"
#include "Layer/PaintingArea.h"
IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker){
this->Area=Area;
@@ -12,7 +12,7 @@ IntelliTool::~IntelliTool(){
}
void IntelliTool::onMouseRightPressed(int x, int y){
if(drawing){
if(drawing) {
drawing=false;
this->deleteToolLayer();
}
@@ -30,7 +30,7 @@ void IntelliTool::onMouseLeftPressed(int x, int y){
}
void IntelliTool::onMouseLeftReleased(int x, int y){
if(drawing){
if(drawing) {
drawing=false;
this->mergeToolLayer();
this->deleteToolLayer();
@@ -56,8 +56,8 @@ void IntelliTool::createToolLayer(){
void IntelliTool::mergeToolLayer(){
QColor clr_0;
QColor clr_1;
for(int y=0; y<Active->height; y++){
for(int x=0; x<Active->width; x++){
for(int y=0; y<Active->height; y++) {
for(int x=0; x<Active->width; x++) {
clr_0=Active->image->imageData.pixelColor(x,y);
clr_1=Canvas->image->imageData.pixelColor(x,y);
float t = static_cast<float>(clr_1.alpha())/255.f;
@@ -79,4 +79,3 @@ void IntelliTool::deleteToolLayer(){
Area->deleteLayer(Area->activeLayer+1);
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.
*/
class IntelliTool{
class IntelliTool {
private:
/*!
/*!
* \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.
*/
void mergeToolLayer();
void mergeToolLayer();
/*!
/*!
* \brief A function that deletes the drawinglayer.
*/
void deleteToolLayer();
void deleteToolLayer();
protected:
/*!
/*!
* \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.
*/
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.
*/
LayerObject* Active;
LayerObject* Active;
/*!
/*!
* \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.
*/
bool drawing = false;
bool drawing = false;
public:
/*!
/*!
* \brief A constructor setting the general Painting Area and colorPicker.
* \param Area - The general PaintingArea 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.
*/
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!
* \param x - The x 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!
* \param x - The x 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!
* \param x - The x 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!
* \param x - The x 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!
* \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!
* \param x - The x 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>
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->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;
yMax = Middle.y()+radius;
// 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));
xMax = Middle.x()+sqrt(pow(radius,2)-pow(i-Middle.y(),2));
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.;
yMin = (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));
xMax = Middle.x()+sqrt(pow(radius,2)-pow(i-Middle.y(),2));
this->Canvas->image->drawPoint(QPoint(xMin,i), colorPicker->getFirstColor(),edgeWidth);
@@ -40,7 +40,7 @@ void IntelliToolCircle::drawCyrcle(int radius){
xMin = (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 yMax = Middle.y()+sqrt(pow(radius,2)-pow(i-Middle.x(),2));
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){
IntelliTool::onWheelScrolled(value);
this->edgeWidth+=value;
if(this->edgeWidth<=0){
if(this->edgeWidth<=0) {
this->edgeWidth=1;
}
}
void IntelliToolCircle::onMouseMoved(int x, int y){
if(this->drawing){
if(this->drawing) {
this->Canvas->image->drawPlain(Qt::transparent);
QPoint next(x,y);
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.
*/
class IntelliToolCircle : public IntelliTool{
/*!
class IntelliToolCircle : public IntelliTool {
/*!
* \brief A function that implements a circle drawing algorithm.
* \param radius - The radius of the circle.
*/
void drawCyrcle(int radius);
void drawCyrcle(int radius);
/*!
/*!
* \brief The center of the circle.
*/
QPoint Middle;
QPoint Middle;
/*!
/*!
* \brief The alpha value of the inner circle.
*/
int alphaInner;
int alphaInner;
/*!
/*!
* \brief The width of the outer circle edge.
*/
int edgeWidth;
int edgeWidth;
public:
/*!
/*!
* \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 colorPicker - The general colorPicker used by the project.
*/
IntelliToolCircle(PaintingArea* Area, IntelliColorPicker* colorPicker);
IntelliToolCircle(PaintingArea* Area, IntelliColorPicker* colorPicker);
/*!
/*!
* \brief A Destructor.
*/
virtual ~IntelliToolCircle() override;
virtual ~IntelliToolCircle() override;
/*!
/*!
* \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 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.
* \param x - The x 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.
* \param x - The x 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.
* \param x - The x 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.
* \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.
* \param x - The x 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

View File

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

View File

@@ -7,61 +7,61 @@
/*!
* \brief The IntelliToolFloodFill class represents a tool to flood FIll a certian area.
*/
class IntelliToolFloodFill : public IntelliTool{
class IntelliToolFloodFill : public IntelliTool {
public:
/*!
/*!
* \brief A constructor setting the general paintingArea and colorPicker.
* \param Area - The general paintingArea 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.
*/
virtual ~IntelliToolFloodFill() override;
virtual ~IntelliToolFloodFill() override;
/*!
/*!
* \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 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.
* \param x - The x 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.
* \param x - The x 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.
* \param x - The x 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.
* \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.
* \param x - The x 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

View File

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

View File

@@ -7,7 +7,7 @@
/*!
* \brief The LineStyle enum classifing all ways of drawing a line.
*/
enum class LineStyle{
enum class LineStyle {
SOLID_LINE,
DOTTED_LINE
};
@@ -15,75 +15,75 @@ enum class LineStyle{
/*!
* \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.
*/
QPoint start;
QPoint start;
/*!
/*!
* \brief The width of the line to draw.
*/
int lineWidth;
int lineWidth;
/*!
/*!
* \brief The style of the line. Apropriate to LineStyle.
*/
LineStyle lineStyle;
LineStyle lineStyle;
public:
/*!
/*!
* \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 colorPicker - The general colorPicker used by the project.
*/
IntelliToolLine(PaintingArea* Area, IntelliColorPicker* colorPicker);
IntelliToolLine(PaintingArea* Area, IntelliColorPicker* colorPicker);
/*!
/*!
* \brief An abstract Destructor.
*/
virtual ~IntelliToolLine() override;
virtual ~IntelliToolLine() override;
/*!
/*!
* \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 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.
* \param x - The x 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.
* \param x - The x 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.
* \param x - The x 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.
* \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.
* \param x - The x 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

View File

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

View File

@@ -1,73 +1,73 @@
#ifndef INTELLITOOLPEN_H
#define INTELLITOOLPEN_H
#include"IntelliTool.h"
#include"QColor"
#include"QPoint"
#include "IntelliTool.h"
#include "QColor"
#include "QPoint"
/*!
* \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.
*/
int penWidth;
/*!
int penWidth;
/*!
* \brief point - Represents the previous point to help drawing a line.
*/
QPoint point;
QPoint point;
public:
/*!
/*!
* \brief A constructor setting the general paintingArea and colorPicker. Reading the penWidth.
* \param Area - The general PaintingArea 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.
*/
virtual ~IntelliToolPen() override;
virtual ~IntelliToolPen() override;
/*!
/*!
* \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 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.
* \param x - The x 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.
* \param x - The x 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.
* \param x - The x 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.
* \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.
* \param x - The x 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

View File

@@ -3,7 +3,7 @@
#include "QColorDialog"
IntelliToolPlainTool::IntelliToolPlainTool(PaintingArea* Area, IntelliColorPicker* colorPicker)
:IntelliTool(Area, colorPicker){
: IntelliTool(Area, colorPicker){
}
IntelliToolPlainTool::~IntelliToolPlainTool(){
@@ -28,7 +28,6 @@ void IntelliToolPlainTool::onMouseRightReleased(int x, int y){
IntelliTool::onMouseRightReleased(x,y);
}
void IntelliToolPlainTool::onMouseMoved(int x, int 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.
*/
class IntelliToolPlainTool : public IntelliTool{
class IntelliToolPlainTool : public IntelliTool {
public:
/*!
/*!
* \brief A constructor setting the general paintingArea and colorPicker.
* \param Area - The general paintingArea 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.
*/
virtual ~IntelliToolPlainTool() override;
virtual ~IntelliToolPlainTool() override;
/*!
/*!
* \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 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.
* \param x - The x 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.
* \param x - The x 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.
* \param x - The x 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.
* \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.
* \param x - The x 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>
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);
lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1);;
PointIsNearStart = false;
@@ -17,7 +17,7 @@ IntelliToolPolygon::~IntelliToolPolygon(){
}
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);
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->calculateVisiblity();
}
else if(isDrawing && isNearStart(x,y,QPointList.front())){
else if(isDrawing && isNearStart(x,y,QPointList.front())) {
PointIsNearStart = true;
this->Canvas->image->drawLine(QPointList.back(), QPointList.front(), colorPicker->getFirstColor(), lineWidth);
this->Canvas->image->calculateVisiblity();
}
else if(isDrawing){
else if(isDrawing) {
QPoint drawingPoint(x,y);
QPointList.push_back(drawingPoint);
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){
if(PointIsNearStart && QPointList.size() > 1){
if(PointIsNearStart && QPointList.size() > 1) {
PointIsNearStart = false;
isDrawing = false;
std::vector<Triangle> Triangles = IntelliHelper::calculateTriangles(QPointList);
QPoint Point;
QColor colorTwo(colorPicker->getSecondColor());
colorTwo.setAlpha(alphaInner);
for(int i = 0; i < Active->width; i++){
for(int j = 0; j < Active->height; j++){
for(int i = 0; i < Active->width; i++) {
for(int j = 0; j < Active->height; j++) {
Point = QPoint(i,j);
if(IntelliHelper::isInPolygon(Triangles,Point)){
if(IntelliHelper::isInPolygon(Triangles,Point)) {
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();
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){
IntelliTool::onWheelScrolled(value);
if(!isDrawing){
if(lineWidth + value < 10){
if(!isDrawing) {
if(lineWidth + value < 10) {
lineWidth += value;
}
if(lineWidth < 1){
if(lineWidth < 1) {
lineWidth = 1;
}
}
@@ -98,9 +98,9 @@ bool IntelliToolPolygon::isNearStart(int x, int y, QPoint Startpoint){
int StartY = Startpoint.y();
int valueToNear = 10;
for(int i = StartX - valueToNear; i < StartX + valueToNear; i++){
for(int j = StartY - valueToNear; j < StartY + valueToNear; j++){
if((i == x) && (j == y)){
for(int i = StartX - valueToNear; i < StartX + valueToNear; i++) {
for(int j = StartY - valueToNear; j < StartY + valueToNear; j++) {
if((i == x) && (j == y)) {
isNear = true;
}
}

View File

@@ -10,92 +10,91 @@
*/
class IntelliToolPolygon : public IntelliTool
{
/*!
/*!
* \brief Checks if the given Point lies near the starting Point.
* \param x - x coordinate of a point.
* \param y - y coordinate of a point.
* \param Startpoint - The startingpoint to check for.
* \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.
*/
int lineWidth;
int lineWidth;
/*!
/*!
* \brief IsDrawing true while drawing, else false.
*/
bool isDrawing;
bool isDrawing;
/*!
/*!
* \brief PointIsNearStart true, when last click near startpoint, else false.
*/
bool PointIsNearStart;
bool PointIsNearStart;
/*!
/*!
* \brief The alpha value of the inner circle.
*/
int alphaInner;
int alphaInner;
/*!
/*!
* \brief QPointList list of all points of the polygon.
*/
std::vector<QPoint> QPointList;
std::vector<QPoint> QPointList;
public:
/*!
/*!
* \brief A constructor setting the general paintingArea and colorPicker.
* \param Area - The general paintingArea 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.
*/
~IntelliToolPolygon() override;
~IntelliToolPolygon() override;
/*!
/*!
* \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 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.
* \param x - The x 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.
* \param x - The x 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.
* \param x - The x 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.
* \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.
* \param x - The x 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 "QInputDialog"
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->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();
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, 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){
if(this->drawing){
if(this->drawing) {
this->Canvas->image->drawPlain(Qt::transparent);
QPoint next(x,y);
drawRectangle(next);
@@ -61,7 +61,7 @@ void IntelliToolRectangle::onMouseMoved(int x, int y){
void IntelliToolRectangle::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value);
this->edgeWidth+=value;
if(this->edgeWidth<=0){
if(this->edgeWidth<=0) {
this->edgeWidth=1;
}
}

View File

@@ -8,77 +8,77 @@
/*!
* \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.
* \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.
*/
QPoint originCornor;
/*!
QPoint originCornor;
/*!
* \brief alphaInner- Represents the alpha value of the inside.
*/
int alphaInner;
/*!
int alphaInner;
/*!
* \brief edgeWidth - The width of the rectangle edges.
*/
int edgeWidth;
int edgeWidth;
public:
/*!
/*!
* \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 colorPicker - The general colorPicker used by the project.
*/
IntelliToolRectangle(PaintingArea* Area, IntelliColorPicker* colorPicker);
/*!
IntelliToolRectangle(PaintingArea* Area, IntelliColorPicker* colorPicker);
/*!
* \brief A Destructor.
*/
virtual ~IntelliToolRectangle() override;
virtual ~IntelliToolRectangle() override;
/*!
/*!
* \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 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.
* \param x - The x 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.
* \param x - The x 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.
* \param x - The x 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.
* \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.
* \param x - The x 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