diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index 063f4b7..a2b0206 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -206,8 +206,8 @@ void IntelliPhotoGui::slotSetSecondColor(){ paintingArea->colorPickerSetSecondColor(); } -void IntelliPhotoGui::slotSwitchColor(){ - paintingArea->colorPickerSwitchColor(); +void IntelliPhotoGui::slotSwapColor(){ + paintingArea->colorPickerSwapColors(); } void IntelliPhotoGui::slotCreatePenTool(){ @@ -328,9 +328,9 @@ void IntelliPhotoGui::createActions(){ actionColorPickerSecondColor = new QAction(tr("&Secondary"), this); connect(actionColorPickerSecondColor, SIGNAL(triggered()), this, SLOT(slotSetSecondColor())); - actionColorSwitch = new QAction(tr("&Switch"), this); - actionColorSwitch->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S)); - connect(actionColorSwitch, SIGNAL(triggered()), this, SLOT(slotSwitchColor())); + actionColorSwap = new QAction(tr("&Switch"), this); + actionColorSwap->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S)); + connect(actionColorSwap, SIGNAL(triggered()), this, SLOT(slotSwapColor())); //Create Tool actions down here actionCreatePlainTool = new QAction(tr("&Plain"), this); @@ -398,7 +398,7 @@ void IntelliPhotoGui::createMenus(){ colorMenu = new QMenu(tr("&Color"), this); colorMenu->addAction(actionColorPickerFirstColor); colorMenu->addAction(actionColorPickerSecondColor); - colorMenu->addAction(actionColorSwitch); + colorMenu->addAction(actionColorSwap); //Attach all Tool Options toolMenu = new QMenu(tr("&Tools"), this); diff --git a/src/GUI/IntelliPhotoGui.h b/src/GUI/IntelliPhotoGui.h index e6acca9..e76485c 100644 --- a/src/GUI/IntelliPhotoGui.h +++ b/src/GUI/IntelliPhotoGui.h @@ -55,7 +55,7 @@ void slotMoveLayerDown(); // color Picker slots here void slotSetFirstColor(); void slotSetSecondColor(); -void slotSwitchColor(); +void slotSwapColor(); // tool slots here void slotCreatePenTool(); @@ -103,7 +103,7 @@ QAction*actionExit; // color Picker actions QAction*actionColorPickerFirstColor; QAction*actionColorPickerSecondColor; -QAction*actionColorSwitch; +QAction*actionColorSwap; // tool actions QAction*actionCreatePenTool; diff --git a/src/Image/IntelliImage.cpp b/src/Image/IntelliImage.cpp index 059fe4c..4254f63 100644 --- a/src/Image/IntelliImage.cpp +++ b/src/Image/IntelliImage.cpp @@ -11,12 +11,12 @@ IntelliImage::~IntelliImage(){ } -bool IntelliImage::loadImage(const QString &fileName){ +bool IntelliImage::loadImage(const QString &filePath){ // Holds the image QImage loadedImage; // If the image wasn't loaded leave this function - if (!loadedImage.load(fileName)) + if (!loadedImage.load(filePath)) return false; // scaled Image to size of Layer diff --git a/src/Image/IntelliImage.h b/src/Image/IntelliImage.h index 12f965b..be99c1d 100644 --- a/src/Image/IntelliImage.h +++ b/src/Image/IntelliImage.h @@ -33,10 +33,10 @@ QImage imageData; public: /*! * \brief The Construcor of the IntelliImage. Given the Image dimensions. - * \param weight - The weight of the Image. + * \param width - The width of the Image. * \param height - The height of the Image. */ -IntelliImage(int weight, int height); +IntelliImage(int width, int height); /*! * \brief An Abstract Destructor. @@ -91,7 +91,7 @@ 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. + * \return An [allocated] image with all the properties of the instance. */ virtual IntelliImage* getDeepCopy() = 0; @@ -116,10 +116,10 @@ virtual std::vector getPolygonData(){ /*! * \brief A function that loads and sclaes an image to the fitting dimensions. - * \param fileName - The path+name of the image which to loaded. + * \param filePath - 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 &filePath); /*! * \brief A function that returns the pixelcolor at a certain point diff --git a/src/Image/IntelliRasterImage.h b/src/Image/IntelliRasterImage.h index 5a3de15..0879abb 100644 --- a/src/Image/IntelliRasterImage.h +++ b/src/Image/IntelliRasterImage.h @@ -16,10 +16,10 @@ virtual void calculateVisiblity() override; public: /*! * \brief The Construcor of the IntelliRasterImage. Given the Image dimensions. - * \param weight - The weight of the Image. + * \param width - The width of the Image. * \param height - The height of the Image. */ -IntelliRasterImage(int weight, int height); +IntelliRasterImage(int width, int height); /*! * \brief An Destructor. diff --git a/src/Image/IntelliShapedImage.h b/src/Image/IntelliShapedImage.h index fbdd22e..5d1288d 100644 --- a/src/Image/IntelliShapedImage.h +++ b/src/Image/IntelliShapedImage.h @@ -29,10 +29,10 @@ std::vector polygonData; public: /*! * \brief The Construcor of the IntelliShapedImage. Given the Image dimensions. - * \param weight - The weight of the Image. + * \param width - The width of the Image. * \param height - The height of the Image. */ -IntelliShapedImage(int weight, int height); +IntelliShapedImage(int width, int height); /*! * \brief An Destructor. diff --git a/src/IntelliHelper/IntelliColorPicker.cpp b/src/IntelliHelper/IntelliColorPicker.cpp index 534a8e5..104039b 100644 --- a/src/IntelliHelper/IntelliColorPicker.cpp +++ b/src/IntelliHelper/IntelliColorPicker.cpp @@ -9,7 +9,7 @@ IntelliColorPicker::~IntelliColorPicker(){ } -void IntelliColorPicker::switchColors(){ +void IntelliColorPicker::swapColors(){ std::swap(firstColor, secondColor); } 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/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index c27622b..29f1908 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -21,7 +21,7 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent) : QWidget(parent){ this->Tool = nullptr; - this->setUp(maxWidth, maxHeight); + this->setLayerDimensions(maxWidth, maxHeight); this->addLayer(200,200,0,0,ImageType::Shaped_Image); layerBundle[0].image->drawPlain(QColor(0,0,255,255)); std::vector polygon; @@ -42,7 +42,7 @@ PaintingArea::~PaintingArea(){ delete Tool; } -void PaintingArea::setUp(int maxWidth, int maxHeight){ +void PaintingArea::setLayerDimensions(int maxWidth, int maxHeight){ //set standart parameter this->maxWidth = maxWidth; this->maxHeight = maxHeight; @@ -99,35 +99,35 @@ void PaintingArea::setAlphaOfLayer(int index, int alpha){ } // Used to load the image and place it in the widget -bool PaintingArea::open(const QString &fileName){ +bool PaintingArea::open(const QString &filePath){ if(this->activeLayer==-1) { return false; } IntelliImage* active = layerBundle[static_cast(activeLayer)].image; - bool open = active->loadImage(fileName); + bool open = active->loadImage(filePath); active->calculateVisiblity(); update(); return open; } // Save the current image -bool PaintingArea::save(const QString &fileName, const char*fileFormat){ +bool PaintingArea::save(const QString &filePath, const char*fileFormat){ if(layerBundle.size()==0) { return false; } - this->assembleLayers(true); + this->drawLayers(true); if(!strcmp(fileFormat,"PNG")) { QImage visibleImage = Canvas->convertToFormat(QImage::Format_Indexed8); fileFormat = "png"; - if (visibleImage.save(fileName, fileFormat)) { + if (visibleImage.save(filePath, fileFormat)) { return true; } else { return false; } } - if (Canvas->save(fileName, fileFormat)) { + if (Canvas->save(filePath, fileFormat)) { return true; } else { return false; @@ -151,9 +151,9 @@ void PaintingArea::movePositionActive(int x, int y){ void PaintingArea::moveActiveLayer(int idx){ if(idx==1) { - this->activateUpperLayer(); + this->selectLayerUp(); }else if(idx==-1) { - this->activateLowerLayer(); + this->selectLayerDown(); } } @@ -173,8 +173,8 @@ void PaintingArea::colorPickerSetSecondColor(){ this->colorPicker.setSecondColor(clr); } -void PaintingArea::colorPickerSwitchColor(){ - this->colorPicker.switchColors(); +void PaintingArea::colorPickerSwapColors(){ + this->colorPicker.swapColors(); } void PaintingArea::createPenTool(){ @@ -273,7 +273,7 @@ void PaintingArea::wheelEvent(QWheelEvent*event){ // The QPaintEvent is sent to widgets that need to // update themselves void PaintingArea::paintEvent(QPaintEvent*event){ - this->assembleLayers(); + this->drawLayers(); QPainter painter(this); QRect dirtyRec = event->rect(); @@ -288,25 +288,25 @@ void PaintingArea::resizeEvent(QResizeEvent*event){ update(); } -void PaintingArea::resizeImage(QImage*image_res, const QSize &newSize){ +void PaintingArea::resizeLayer(QImage*image_res, const QSize &newSize){ //TODO implement } -void PaintingArea::activateUpperLayer(){ +void PaintingArea::selectLayerUp(){ if(activeLayer!=-1 && static_cast(activeLayer)(activeLayer)], layerBundle[static_cast(activeLayer+1)]); activeLayer++; } } -void PaintingArea::activateLowerLayer(){ +void PaintingArea::selectLayerDown(){ if(activeLayer!=-1 && activeLayer>0) { std::swap(layerBundle[static_cast(activeLayer)], layerBundle[static_cast(activeLayer-1)]); activeLayer--; } } -void PaintingArea::assembleLayers(bool forSaving){ +void PaintingArea::drawLayers(bool forSaving){ if(forSaving) { Canvas->fill(Qt::GlobalColor::transparent); }else{ @@ -341,7 +341,7 @@ void PaintingArea::assembleLayers(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 591f693..e271a8c 100644 --- a/src/Layer/PaintingArea.h +++ b/src/Layer/PaintingArea.h @@ -61,14 +61,14 @@ public: * \param fileName - Path and filename which are used to determine where the to-be-opened file is stored * \return Returns a boolean variable whether the file was successfully opened or not */ - bool open(const QString &fileName); + bool open(const QString &filePath); /*! * \brief The save method is used for exporting the current project as one picture * \param fileName * \param fileFormat * \return Returns a boolean variable, true if the file was saved successfully, false if not */ - bool save(const QString &fileName, const char *fileFormat); + bool save(const QString &filePath, const char *fileFormat); /*! * \brief The addLayer adds a layer to the current project/ painting area @@ -139,7 +139,7 @@ public: /*! * \brief The colorPickerSwitchColor swaps the primary color with the secondary drawing color */ - void colorPickerSwitchColor(); + void colorPickerSwapColors(); // Create tools void createPenTool(); @@ -187,9 +187,9 @@ protected: void resizeEvent(QResizeEvent *event) override; private: - void setUp(int maxWidth, int maxHeight); - void activateUpperLayer(); - void activateLowerLayer(); + void setLayerDimensions(int maxWidth, int maxHeight); + void selectLayerUp(); + void selectLayerDown(); QImage* Canvas; int maxWidth; @@ -201,12 +201,13 @@ private: std::vector layerBundle; int activeLayer=-1; - void assembleLayers(bool forSaving=false); + void drawLayers(bool forSaving=false); - void resizeImage(QImage *image_res, const QSize &newSize); + void resizeLayer(QImage *image_res, const QSize &newSize); // Helper for Tool - void createTempLayerAfter(int idx); + // TODO: Always create this layer on top and return the id here! + void createTempTopLayer(int idx); }; #endif diff --git a/src/Tool/IntelliTool.cpp b/src/Tool/IntelliTool.cpp index a4edf01..b20c4d1 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(); } @@ -48,17 +48,17 @@ void IntelliTool::onWheelScrolled(int value){ } void IntelliTool::createToolLayer(){ - Area->createTempLayerAfter(Area->activeLayer); - this->Active=&Area->layerBundle[static_cast(Area->activeLayer)]; - this->Canvas=&Area->layerBundle[static_cast(Area->activeLayer+1)]; + Area->createTempTopLayer(Area->activeLayer); + this->activeLayer=&Area->layerBundle[static_cast(Area->activeLayer)]; + this->Canvas=&Area->layerBundle[static_cast(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 b1d1910..26b89be 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 be7cf06..33a5016 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 = static_cast(Middle.x()-sqrt(pow(radius,2)-pow(i-Middle.y(),2))); - xMax = static_cast(Middle.x()+sqrt(pow(radius,2)-pow(i-Middle.y(),2))); + xMin = static_cast(centerPoint.x()-sqrt(pow(radius,2)-pow(i-centerPoint.y(),2))); + xMax = static_cast(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 = static_cast(radius +(this->edgeWidth/2.)-1.); - yMin = (Middle.y()-radius); - yMax = (Middle.y()+radius); + radius = static_cast(radius +(this->borderWidth/2.)-1.); + yMin = (centerPoint.y()-radius); + yMax = (centerPoint.y()+radius); for(int i=yMin; i<=yMax; i++) { - xMin = static_cast(Middle.x()-sqrt(pow(radius,2)-pow(i-Middle.y(),2))); - xMax = static_cast(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 = static_cast(centerPoint.x()-sqrt(pow(radius,2)-pow(i-centerPoint.y(),2))); + xMax = static_cast(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 = static_cast(Middle.y()-sqrt(pow(radius,2)-pow(i-Middle.x(),2))); - int yMax = static_cast(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 = static_cast(centerPoint.y()-sqrt(pow(radius,2)-pow(i-centerPoint.x(),2))); + int yMax = static_cast(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 50cbc66..71f67c0 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; - int m = static_cast((p2.y()-p1.y())/(p2.x()-p1.x())+0.5f); - int c = start.y()-start.x()*m; + QPoint p1 =lineStartingPoint.x() <= next.x() ? lineStartingPoint : next; + QPoint p2 =lineStartingPoint.x() < next.x() ? next : lineStartingPoint; + int m = static_cast(static_cast(p2.y()-p1.y())/static_cast(p2.x()-p1.x())+0.5f); + 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 5a254cb..e834126 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); - lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1); - PointIsNearStart = false; + 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); + 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 e5f0cdd..8a429fa 100644 --- a/src/Tool/IntelliToolRectangle.cpp +++ b/src/Tool/IntelliToolRectangle.cpp @@ -4,30 +4,30 @@ 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(){ } -void IntelliToolRectangle::drawRectangle(QPoint otherCornor){ - int xMin = std::min(originCornor.x(), otherCornor.x()); - int xMax = std::max(originCornor.x(), otherCornor.x()); +void IntelliToolRectangle::drawRectangle(QPoint otherCorner){ + int xMin = std::min(originCorner.x(), otherCorner.x()); + int xMax = std::max(originCorner.x(), otherCorner.x()); - int yMin = std::min(originCornor.y(), otherCornor.y()); - int yMax = std::max(originCornor.y(), otherCornor.y()); + int yMin = std::min(originCorner.y(), otherCorner.y()); + 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){ @@ -40,8 +40,8 @@ void IntelliToolRectangle::onMouseRightReleased(int x, int y){ void IntelliToolRectangle::onMouseLeftPressed(int x, int y){ IntelliTool::onMouseLeftPressed(x,y); - this->originCornor=QPoint(x,y); - drawRectangle(originCornor); + this->originCorner=QPoint(x,y); + drawRectangle(originCorner); Canvas->image->calculateVisiblity(); } @@ -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 afd0030..31d9edd 100644 --- a/src/Tool/IntelliToolRectangle.h +++ b/src/Tool/IntelliToolRectangle.h @@ -11,22 +11,22 @@ class IntelliToolRectangle : public IntelliTool { /*! * \brief A function that implements a rectagle drawing algorithm. - * \param otherCornor - The second corner point of the rectangle. + * \param othercorner - The second corner point of the rectangle. */ -void drawRectangle(QPoint otherCornor); +void drawRectangle(QPoint otherCorner); /*! - * \brief originCornor - The first corner point of the rectangle. + * \brief origincorner - The first corner point of the rectangle. */ -QPoint originCornor; +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.