From d81afbb8ee686e9d7b6c69642f39406761ff7620 Mon Sep 17 00:00:00 2001 From: Conrad Date: Fri, 20 Dec 2019 10:05:57 +0100 Subject: [PATCH] Refractoring Update 2 - Adjusted variable names to naming conventions - Concluded header files --- src/IntelliHelper/IntelliColorPicker.h | 2 +- .../IntelliColorPicker.h.autosave | 64 ------------------- src/Layer/PaintingArea.cpp | 2 +- src/Layer/PaintingArea.h | 2 +- src/Tool/IntelliTool.cpp | 24 +++---- src/Tool/IntelliTool.h | 4 +- src/Tool/IntelliToolCircle.cpp | 58 ++++++++--------- src/Tool/IntelliToolCircle.h | 8 +-- src/Tool/IntelliToolFloodFill.cpp | 10 +-- src/Tool/IntelliToolLine.cpp | 14 ++-- src/Tool/IntelliToolLine.h | 2 +- src/Tool/IntelliToolPen.cpp | 10 +-- src/Tool/IntelliToolPen.h | 2 +- src/Tool/IntelliToolPolygon.cpp | 18 +++--- src/Tool/IntelliToolPolygon.h | 4 +- src/Tool/IntelliToolRectangle.cpp | 22 +++---- src/Tool/IntelliToolRectangle.h | 4 +- 17 files changed, 93 insertions(+), 157 deletions(-) delete mode 100644 src/IntelliHelper/IntelliColorPicker.h.autosave diff --git a/src/IntelliHelper/IntelliColorPicker.h b/src/IntelliHelper/IntelliColorPicker.h index 817511d..4ea686b 100644 --- a/src/IntelliHelper/IntelliColorPicker.h +++ b/src/IntelliHelper/IntelliColorPicker.h @@ -23,7 +23,7 @@ virtual ~IntelliColorPicker(); /*! * \brief A function switching primary and secondary color. */ -void switchColors(); +void swapColors(); /*! * \brief A function to read the primary selected color. diff --git a/src/IntelliHelper/IntelliColorPicker.h.autosave b/src/IntelliHelper/IntelliColorPicker.h.autosave deleted file mode 100644 index 4ea686b..0000000 --- a/src/IntelliHelper/IntelliColorPicker.h.autosave +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef INTELLITOOLSETCOLORTOOL_H -#define INTELLITOOLSETCOLORTOOL_H - -#include "QColor" -#include "QPoint" -#include "QColorDialog" - -/*! - * \brief The IntelliColorPicker manages the selected colors for one whole project. - */ -class IntelliColorPicker { -public: -/*! - * \brief IntelliColorPicker constructor, setting 2 preset colors, be careful, theese color may change in production. - */ -IntelliColorPicker(); - -/*! - * \brief IntelliColorPicker destructor clears up his used memory, if there is some. - */ -virtual ~IntelliColorPicker(); - -/*! - * \brief A function switching primary and secondary color. - */ -void swapColors(); - -/*! - * \brief A function to read the primary selected color. - * \return Returns the primary color. - */ -QColor getFirstColor(); - -/*! - * \brief A function to read the secondary selected color. - * \return Returns the secondary color. - */ -QColor getSecondColor(); - -/*! - * \brief A function to set the primary color. - * \param Color - The color to be set as primary. - */ -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); - -private: -/*! - * \brief The primary color. - */ -QColor firstColor; - -/*! - * \brief The secondary color. - */ -QColor secondColor; -}; - -#endif // INTELLITOOLSETCOLORTOOL_H diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index cb65271..d6bc34e 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -341,7 +341,7 @@ void PaintingArea::drawLayers(bool forSaving){ } } -void PaintingArea::createTempLayerAfter(int idx){ +void PaintingArea::createTempTopLayer(int idx){ if(idx>=0) { LayerObject newLayer; newLayer.alpha = 255; diff --git a/src/Layer/PaintingArea.h b/src/Layer/PaintingArea.h index 27812b1..e271a8c 100644 --- a/src/Layer/PaintingArea.h +++ b/src/Layer/PaintingArea.h @@ -90,7 +90,7 @@ public: * \param type - Defining the ImageType of the new layer * \return Returns the id of the layer position */ - int addLayerAt(int width, int height, int widthOffset=0, int heightOffset=0, ImageType type = ImageType::Raster_Image, int idx); + int addLayerAt(int idx, int width, int height, int widthOffset=0, int heightOffset=0, ImageType type = ImageType::Raster_Image); /*! * \brief The deleteLayer method removes a layer at a given index * \param index - The index of the layer to be removed diff --git a/src/Tool/IntelliTool.cpp b/src/Tool/IntelliTool.cpp index 5fdd6d2..e61ff42 100644 --- a/src/Tool/IntelliTool.cpp +++ b/src/Tool/IntelliTool.cpp @@ -12,8 +12,8 @@ IntelliTool::~IntelliTool(){ } void IntelliTool::onMouseRightPressed(int x, int y){ - if(drawing) { - drawing=false; + if(isDrawing) { + isDrawing=false; this->deleteToolLayer(); } } @@ -23,23 +23,23 @@ void IntelliTool::onMouseRightReleased(int x, int y){ } void IntelliTool::onMouseLeftPressed(int x, int y){ - this->drawing=true; + this->isDrawing=true; //create drawing layer this->createToolLayer(); Canvas->image->calculateVisiblity(); } void IntelliTool::onMouseLeftReleased(int x, int y){ - if(drawing) { - drawing=false; + if(isDrawing) { + isDrawing=false; this->mergeToolLayer(); this->deleteToolLayer(); - Active->image->calculateVisiblity(); + activeLayer->image->calculateVisiblity(); } } void IntelliTool::onMouseMoved(int x, int y){ - if(drawing) + if(isDrawing) Canvas->image->calculateVisiblity(); } @@ -49,16 +49,16 @@ void IntelliTool::onWheelScrolled(int value){ void IntelliTool::createToolLayer(){ Area->createTempTopLayer(Area->activeLayer); - this->Active=&Area->layerBundle[Area->activeLayer]; + this->activeLayer=&Area->layerBundle[Area->activeLayer]; this->Canvas=&Area->layerBundle[Area->activeLayer+1]; } void IntelliTool::mergeToolLayer(){ QColor clr_0; QColor clr_1; - for(int y=0; yheight; y++) { - for(int x=0; xwidth; x++) { - clr_0=Active->image->imageData.pixelColor(x,y); + for(int y=0; yheight; y++) { + for(int x=0; xwidth; x++) { + clr_0=activeLayer->image->imageData.pixelColor(x,y); clr_1=Canvas->image->imageData.pixelColor(x,y); float t = static_cast(clr_1.alpha())/255.f; int r =static_cast(static_cast(clr_1.red())*(t)+static_cast(clr_0.red())*(1.f-t)+0.5f); @@ -70,7 +70,7 @@ void IntelliTool::mergeToolLayer(){ clr_0.setBlue(b); clr_0.setAlpha(a); - Active->image->imageData.setPixelColor(x, y, clr_0); + activeLayer->image->imageData.setPixelColor(x, y, clr_0); } } } diff --git a/src/Tool/IntelliTool.h b/src/Tool/IntelliTool.h index 3903edb..1a23b97 100644 --- a/src/Tool/IntelliTool.h +++ b/src/Tool/IntelliTool.h @@ -40,7 +40,7 @@ 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* activeLayer; /*! * \brief A pointer to the drawing canvas of the tool, work on this. @@ -50,7 +50,7 @@ LayerObject* Canvas; /*! * \brief A flag checking if the user is currently drawing or not. */ -bool drawing = false; +bool isDrawing = false; public: /*! diff --git a/src/Tool/IntelliToolCircle.cpp b/src/Tool/IntelliToolCircle.cpp index c602f53..84f8bcb 100644 --- a/src/Tool/IntelliToolCircle.cpp +++ b/src/Tool/IntelliToolCircle.cpp @@ -5,46 +5,46 @@ IntelliToolCircle::IntelliToolCircle(PaintingArea* Area, IntelliColorPicker* 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); + this->innerAlpha = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 0,0,255,1); + this->borderWidth = QInputDialog::getInt(nullptr,"Outer edge width", "Value:", 0,1,255,1); } IntelliToolCircle::~IntelliToolCircle(){ } -void IntelliToolCircle::drawCyrcle(int radius){ +void IntelliToolCircle::drawCircle(int radius){ int outer = radius+20; QColor inner = this->colorPicker->getSecondColor(); - inner.setAlpha(alphaInner); + inner.setAlpha(innerAlpha); int yMin, yMax, xMin, xMax; - yMin = Middle.y()-radius; - yMax = Middle.y()+radius; + yMin = centerPoint.y()-radius; + yMax = centerPoint.y()+radius; // x = x0+-sqrt(r2-(y-y0)2) 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)); + xMin = centerPoint.x()-sqrt(pow(radius,2)-pow(i-centerPoint.y(),2)); + xMax = centerPoint.x()+sqrt(pow(radius,2)-pow(i-centerPoint.y(),2)); this->Canvas->image->drawLine(QPoint(xMin,i), QPoint(xMax,i),inner,1); } //TODO implement circle drawing algorithm bresenham - radius = radius +(this->edgeWidth/2.)-1.; - yMin = (Middle.y()-radius); - yMax = (Middle.y()+radius); + radius = radius +(this->borderWidth/2.)-1.; + yMin = (centerPoint.y()-radius); + yMax = (centerPoint.y()+radius); 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); - this->Canvas->image->drawPoint(QPoint(xMax,i), colorPicker->getFirstColor(),edgeWidth); + xMin = centerPoint.x()-sqrt(pow(radius,2)-pow(i-centerPoint.y(),2)); + xMax = centerPoint.x()+sqrt(pow(radius,2)-pow(i-centerPoint.y(),2)); + this->Canvas->image->drawPoint(QPoint(xMin,i), colorPicker->getFirstColor(),borderWidth); + this->Canvas->image->drawPoint(QPoint(xMax,i), colorPicker->getFirstColor(),borderWidth); } - xMin = (Middle.x()-radius); - xMax = (Middle.x()+radius); + xMin = (centerPoint.x()-radius); + xMax = (centerPoint.x()+radius); 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); - this->Canvas->image->drawPoint(QPoint(i, yMax), colorPicker->getFirstColor(),edgeWidth); + int yMin = centerPoint.y()-sqrt(pow(radius,2)-pow(i-centerPoint.x(),2)); + int yMax = centerPoint.y()+sqrt(pow(radius,2)-pow(i-centerPoint.x(),2)); + this->Canvas->image->drawPoint(QPoint(i, yMin), colorPicker->getFirstColor(),borderWidth); + this->Canvas->image->drawPoint(QPoint(i, yMax), colorPicker->getFirstColor(),borderWidth); } } @@ -58,9 +58,9 @@ void IntelliToolCircle::onMouseRightReleased(int x, int y){ void IntelliToolCircle::onMouseLeftPressed(int x, int y){ IntelliTool::onMouseLeftPressed(x,y); - this->Middle=QPoint(x,y); + this->centerPoint=QPoint(x,y); int radius = 1; - drawCyrcle(radius); + drawCircle(radius); Canvas->image->calculateVisiblity(); } @@ -70,18 +70,18 @@ void IntelliToolCircle::onMouseLeftReleased(int x, int y){ void IntelliToolCircle::onWheelScrolled(int value){ IntelliTool::onWheelScrolled(value); - this->edgeWidth+=value; - if(this->edgeWidth<=0) { - this->edgeWidth=1; + this->borderWidth+=value; + if(this->borderWidth<=0) { + this->borderWidth=1; } } void IntelliToolCircle::onMouseMoved(int x, int y){ - if(this->drawing) { + if(this->isDrawing) { this->Canvas->image->drawPlain(Qt::transparent); QPoint next(x,y); - int radius = static_cast(sqrt(pow((Middle.x()-x),2)+pow((Middle.y()-y),2))); - drawCyrcle(radius); + int radius = static_cast(sqrt(pow((centerPoint.x()-x),2)+pow((centerPoint.y()-y),2))); + drawCircle(radius); } IntelliTool::onMouseMoved(x,y); } diff --git a/src/Tool/IntelliToolCircle.h b/src/Tool/IntelliToolCircle.h index a748950..94f34e1 100644 --- a/src/Tool/IntelliToolCircle.h +++ b/src/Tool/IntelliToolCircle.h @@ -12,22 +12,22 @@ 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 drawCircle(int radius); /*! * \brief The center of the circle. */ -QPoint Middle; +QPoint centerPoint; /*! * \brief The alpha value of the inner circle. */ -int alphaInner; +int innerAlpha; /*! * \brief The width of the outer circle edge. */ -int edgeWidth; +int borderWidth; public: /*! * \brief A constructor setting the general paintingArea and colorPicker. And reading in the inner alpha and edgeWidth. diff --git a/src/Tool/IntelliToolFloodFill.cpp b/src/Tool/IntelliToolFloodFill.cpp index 1c4fcac..d0dcc34 100644 --- a/src/Tool/IntelliToolFloodFill.cpp +++ b/src/Tool/IntelliToolFloodFill.cpp @@ -31,7 +31,7 @@ void IntelliToolFloodFill::onMouseLeftPressed(int x, int y){ std::queue Q; Q.push(start); - QColor oldColor = this->Active->image->getPixelColor(start); + QColor oldColor = this->activeLayer->image->getPixelColor(start); QColor newColor = this->colorPicker->getFirstColor(); Canvas->image->drawPixel(start,newColor); @@ -44,19 +44,19 @@ void IntelliToolFloodFill::onMouseLeftPressed(int x, int 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)) { + if((right.x() < Canvas->width) && (Canvas->image->getPixelColor(right) != newColor) && (activeLayer->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) && (activeLayer->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) && (activeLayer->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) && (activeLayer->image->getPixelColor(down) == oldColor)) { Canvas->image->drawPixel(down,newColor); Q.push(down); } diff --git a/src/Tool/IntelliToolLine.cpp b/src/Tool/IntelliToolLine.cpp index 39c07a4..26636e4 100644 --- a/src/Tool/IntelliToolLine.cpp +++ b/src/Tool/IntelliToolLine.cpp @@ -24,8 +24,8 @@ void IntelliToolLine::onMouseRightReleased(int x, int y){ void IntelliToolLine::onMouseLeftPressed(int x, int y){ IntelliTool::onMouseLeftPressed(x,y); - this->start=QPoint(x,y); - this->Canvas->image->drawPoint(start, colorPicker->getFirstColor(),lineWidth); + this->lineStartingPoint=QPoint(x,y); + this->Canvas->image->drawPoint(lineStartingPoint, colorPicker->getFirstColor(),lineWidth); Canvas->image->calculateVisiblity(); } @@ -42,18 +42,18 @@ void IntelliToolLine::onWheelScrolled(int value){ } void IntelliToolLine::onMouseMoved(int x, int y){ - if(this->drawing) { + if(this->isDrawing) { this->Canvas->image->drawPlain(Qt::transparent); QPoint next(x,y); switch(lineStyle) { case LineStyle::SOLID_LINE: - this->Canvas->image->drawLine(start,next,colorPicker->getFirstColor(),lineWidth); + this->Canvas->image->drawLine(lineStartingPoint,next,colorPicker->getFirstColor(),lineWidth); break; case LineStyle::DOTTED_LINE: - QPoint p1 =start.x() <= next.x() ? start : next; - QPoint p2 =start.x() < next.x() ? next : start; + QPoint p1 =lineStartingPoint.x() <= next.x() ? lineStartingPoint : next; + QPoint p2 =lineStartingPoint.x() < next.x() ? next : lineStartingPoint; int m = (float)(p2.y()-p1.y())/(float)(p2.x()-p1.x())+0.5f; - int c = start.y()-start.x()*m; + int c = lineStartingPoint.y()-lineStartingPoint.x()*m; break; } diff --git a/src/Tool/IntelliToolLine.h b/src/Tool/IntelliToolLine.h index 3463092..c134c34 100644 --- a/src/Tool/IntelliToolLine.h +++ b/src/Tool/IntelliToolLine.h @@ -19,7 +19,7 @@ class IntelliToolLine : public IntelliTool { /*! * \brief The starting point of the line. */ -QPoint start; +QPoint lineStartingPoint; /*! * \brief The width of the line to draw. diff --git a/src/Tool/IntelliToolPen.cpp b/src/Tool/IntelliToolPen.cpp index 7b12270..30ff5fe 100644 --- a/src/Tool/IntelliToolPen.cpp +++ b/src/Tool/IntelliToolPen.cpp @@ -23,8 +23,8 @@ void IntelliToolPen::onMouseRightReleased(int x, int y){ void IntelliToolPen::onMouseLeftPressed(int x, int y){ IntelliTool::onMouseLeftPressed(x,y); - this->point=QPoint(x,y); - this->Canvas->image->drawPixel(point, colorPicker->getFirstColor()); + this->previousPoint=QPoint(x,y); + this->Canvas->image->drawPixel(previousPoint, colorPicker->getFirstColor()); Canvas->image->calculateVisiblity(); } @@ -33,10 +33,10 @@ void IntelliToolPen::onMouseLeftReleased(int x, int y){ } void IntelliToolPen::onMouseMoved(int x, int y){ - if(this->drawing) { + if(this->isDrawing) { QPoint newPoint(x,y); - this->Canvas->image->drawLine(this->point, newPoint, colorPicker->getFirstColor(), penWidth); - this->point=newPoint; + this->Canvas->image->drawLine(this->previousPoint, newPoint, colorPicker->getFirstColor(), penWidth); + this->previousPoint=newPoint; } IntelliTool::onMouseMoved(x,y); } diff --git a/src/Tool/IntelliToolPen.h b/src/Tool/IntelliToolPen.h index 22694f7..1a8985e 100644 --- a/src/Tool/IntelliToolPen.h +++ b/src/Tool/IntelliToolPen.h @@ -15,7 +15,7 @@ int penWidth; /*! * \brief point - Represents the previous point to help drawing a line. */ -QPoint point; +QPoint previousPoint; public: /*! * \brief A constructor setting the general paintingArea and colorPicker. Reading the penWidth. diff --git a/src/Tool/IntelliToolPolygon.cpp b/src/Tool/IntelliToolPolygon.cpp index 4d95ee3..02444ad 100644 --- a/src/Tool/IntelliToolPolygon.cpp +++ b/src/Tool/IntelliToolPolygon.cpp @@ -6,9 +6,9 @@ IntelliToolPolygon::IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker) : IntelliTool(Area, colorPicker){ - this->alphaInner = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 0,0,255,1); + this->innerAlpha = 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; + isPointNearStart = false; isDrawing = false; } @@ -28,7 +28,7 @@ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){ this->Canvas->image->calculateVisiblity(); } else if(isDrawing && isNearStart(x,y,QPointList.front())) { - PointIsNearStart = true; + isPointNearStart = true; this->Canvas->image->drawLine(QPointList.back(), QPointList.front(), colorPicker->getFirstColor(), lineWidth); this->Canvas->image->calculateVisiblity(); } @@ -42,21 +42,21 @@ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){ void IntelliToolPolygon::onMouseRightPressed(int x, int y){ isDrawing = false; - PointIsNearStart = false; + isPointNearStart = false; QPointList.clear(); IntelliTool::onMouseRightPressed(x,y); } void IntelliToolPolygon::onMouseLeftReleased(int x, int y){ - if(PointIsNearStart && QPointList.size() > 1) { - PointIsNearStart = false; + if(isPointNearStart && QPointList.size() > 1) { + isPointNearStart = false; isDrawing = false; std::vector 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++) { + colorTwo.setAlpha(innerAlpha); + for(int i = 0; i < activeLayer->width; i++) { + for(int j = 0; j < activeLayer->height; j++) { Point = QPoint(i,j); if(IntelliHelper::isInPolygon(Triangles,Point)) { this->Canvas->image->drawPixel(Point, colorTwo); diff --git a/src/Tool/IntelliToolPolygon.h b/src/Tool/IntelliToolPolygon.h index 1d7228d..297173f 100644 --- a/src/Tool/IntelliToolPolygon.h +++ b/src/Tool/IntelliToolPolygon.h @@ -32,12 +32,12 @@ bool isDrawing; /*! * \brief PointIsNearStart true, when last click near startpoint, else false. */ -bool PointIsNearStart; +bool isPointNearStart; /*! * \brief The alpha value of the inner circle. */ -int alphaInner; +int innerAlpha; /*! * \brief QPointList list of all points of the polygon. diff --git a/src/Tool/IntelliToolRectangle.cpp b/src/Tool/IntelliToolRectangle.cpp index d2cc49a..8a429fa 100644 --- a/src/Tool/IntelliToolRectangle.cpp +++ b/src/Tool/IntelliToolRectangle.cpp @@ -4,8 +4,8 @@ IntelliToolRectangle::IntelliToolRectangle(PaintingArea* Area, IntelliColorPicker* 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); + this->innerAlpha = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 0,0,255,1); + this->borderWidth = QInputDialog::getInt(nullptr,"Outer edge width", "Value:", 0,1,255,1); } IntelliToolRectangle::~IntelliToolRectangle(){ @@ -20,14 +20,14 @@ void IntelliToolRectangle::drawRectangle(QPoint otherCorner){ int yMax = std::max(originCorner.y(), otherCorner.y()); QColor clr = colorPicker->getSecondColor(); - clr.setAlpha(alphaInner); + clr.setAlpha(innerAlpha); 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); - this->Canvas->image->drawLine(QPoint(xMin, yMin),QPoint(xMax, yMin), this->colorPicker->getFirstColor(), edgeWidth); - this->Canvas->image->drawLine(QPoint(xMax, yMax),QPoint(xMin, yMax), this->colorPicker->getFirstColor(), edgeWidth); - this->Canvas->image->drawLine(QPoint(xMax, yMax),QPoint(xMax, yMin), this->colorPicker->getFirstColor(), edgeWidth); + this->Canvas->image->drawLine(QPoint(xMin, yMin),QPoint(xMin, yMax), this->colorPicker->getFirstColor(), borderWidth); + this->Canvas->image->drawLine(QPoint(xMin, yMin),QPoint(xMax, yMin), this->colorPicker->getFirstColor(), borderWidth); + this->Canvas->image->drawLine(QPoint(xMax, yMax),QPoint(xMin, yMax), this->colorPicker->getFirstColor(), borderWidth); + this->Canvas->image->drawLine(QPoint(xMax, yMax),QPoint(xMax, yMin), this->colorPicker->getFirstColor(), borderWidth); } void IntelliToolRectangle::onMouseRightPressed(int x, int y){ @@ -50,7 +50,7 @@ void IntelliToolRectangle::onMouseLeftReleased(int x, int y){ } void IntelliToolRectangle::onMouseMoved(int x, int y){ - if(this->drawing) { + if(this->isDrawing) { this->Canvas->image->drawPlain(Qt::transparent); QPoint next(x,y); drawRectangle(next); @@ -60,8 +60,8 @@ void IntelliToolRectangle::onMouseMoved(int x, int y){ void IntelliToolRectangle::onWheelScrolled(int value){ IntelliTool::onWheelScrolled(value); - this->edgeWidth+=value; - if(this->edgeWidth<=0) { - this->edgeWidth=1; + this->borderWidth+=value; + if(this->borderWidth<=0) { + this->borderWidth=1; } } diff --git a/src/Tool/IntelliToolRectangle.h b/src/Tool/IntelliToolRectangle.h index e9db958..31d9edd 100644 --- a/src/Tool/IntelliToolRectangle.h +++ b/src/Tool/IntelliToolRectangle.h @@ -22,11 +22,11 @@ QPoint originCorner; /*! * \brief alphaInner- Represents the alpha value of the inside. */ -int alphaInner; +int innerAlpha; /*! * \brief edgeWidth - The width of the rectangle edges. */ -int edgeWidth; +int borderWidth; public: /*! * \brief A constructor setting the general paintingArea and colorPicker. And reading in the alphaInner and edgeWidth.