From 7a604c805a495041e2b755131501e658ca975373 Mon Sep 17 00:00:00 2001 From: Mienek Date: Fri, 20 Dec 2019 10:02:56 +0100 Subject: [PATCH] some fixes only unused Variable and shadowing left --- src/IntelliHelper/IntelliHelper.cpp | 2 +- src/Layer/PaintingArea.cpp | 32 ++++++++++++++--------------- src/Tool/IntelliTool.cpp | 4 ++-- src/Tool/IntelliTool.h | 2 +- src/Tool/IntelliToolCircle.cpp | 14 ++++++------- src/Tool/IntelliToolLine.cpp | 2 +- src/Tool/IntelliToolPolygon.cpp | 8 ++++---- 7 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/IntelliHelper/IntelliHelper.cpp b/src/IntelliHelper/IntelliHelper.cpp index 0fad4ca..0a8dfb9 100644 --- a/src/IntelliHelper/IntelliHelper.cpp +++ b/src/IntelliHelper/IntelliHelper.cpp @@ -20,7 +20,7 @@ std::vector IntelliHelper::calculateTriangles(std::vector poly QPoint BP(point.x()-post.x(), point.y()-post.y()); float topSclar = AP.x()*BP.x()+AP.y()*BP.y(); - float absolute = sqrt(pow(AP.x(),2.)+pow(AP.y(),2.))*sqrt(pow(BP.x(),2.)+pow(BP.y(),2.)); + float absolute = static_cast(sqrt(pow(AP.x(),2.)+pow(AP.y(),2.))*sqrt(pow(BP.x(),2.)+pow(BP.y(),2.))); return acos(topSclar/absolute); }; diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index 4a18918..c27622b 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -212,11 +212,11 @@ void PaintingArea::createFloodFillTool(){ } int PaintingArea::getWidthOfActive(){ - return this->layerBundle[activeLayer].width; + return this->layerBundle[static_cast(activeLayer)].width; } int PaintingArea::getHeightOfActive(){ - return this->layerBundle[activeLayer].height; + return this->layerBundle[static_cast(activeLayer)].height; } // If a mouse button is pressed check if it was the @@ -225,8 +225,8 @@ int PaintingArea::getHeightOfActive(){ void PaintingArea::mousePressEvent(QMouseEvent*event){ if(Tool == nullptr) return; - int x = event->x()-layerBundle[activeLayer].widthOffset; - int y = event->y()-layerBundle[activeLayer].heightOffset; + int x = event->x()-layerBundle[static_cast(activeLayer)].widthOffset; + int y = event->y()-layerBundle[static_cast(activeLayer)].heightOffset; if(event->button() == Qt::LeftButton) { Tool->onMouseLeftPressed(x, y); }else if(event->button() == Qt::RightButton) { @@ -241,8 +241,8 @@ void PaintingArea::mousePressEvent(QMouseEvent*event){ void PaintingArea::mouseMoveEvent(QMouseEvent*event){ if(Tool == nullptr) return; - int x = event->x()-layerBundle[activeLayer].widthOffset; - int y = event->y()-layerBundle[activeLayer].heightOffset; + int x = event->x()-layerBundle[static_cast(activeLayer)].widthOffset; + int y = event->y()-layerBundle[static_cast(activeLayer)].heightOffset; Tool->onMouseMoved(x, y); update(); } @@ -251,8 +251,8 @@ void PaintingArea::mouseMoveEvent(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; + int x = event->x()-layerBundle[static_cast(activeLayer)].widthOffset; + int y = event->y()-layerBundle[static_cast(activeLayer)].heightOffset; if(event->button() == Qt::LeftButton) { Tool->onMouseLeftReleased(x, y); }else if(event->button() == Qt::RightButton) { @@ -293,15 +293,15 @@ void PaintingArea::resizeImage(QImage*image_res, const QSize &newSize){ } void PaintingArea::activateUpperLayer(){ - if(activeLayer!=-1 && activeLayer(activeLayer)(activeLayer)], layerBundle[static_cast(activeLayer+1)]); activeLayer++; } } void PaintingArea::activateLowerLayer(){ if(activeLayer!=-1 && activeLayer>0) { - std::swap(layerBundle[activeLayer], layerBundle[activeLayer-1]); + std::swap(layerBundle[static_cast(activeLayer)], layerBundle[static_cast(activeLayer-1)]); activeLayer--; } } @@ -345,11 +345,11 @@ void PaintingArea::createTempLayerAfter(int idx){ if(idx>=0) { LayerObject newLayer; newLayer.alpha = 255; - newLayer.height = layerBundle[idx].height; - newLayer.width = layerBundle[idx].width; - newLayer.heightOffset = layerBundle[idx].heightOffset; - newLayer.widthOffset = layerBundle[idx].widthOffset; - newLayer.image = layerBundle[idx].image->getDeepCopy(); + newLayer.height = layerBundle[static_cast(idx)].height; + newLayer.width = layerBundle[static_cast(idx)].width; + newLayer.heightOffset = layerBundle[static_cast(idx)].heightOffset; + newLayer.widthOffset = layerBundle[static_cast(idx)].widthOffset; + newLayer.image = layerBundle[static_cast(idx)].image->getDeepCopy(); layerBundle.insert(layerBundle.begin()+idx+1,newLayer); } } diff --git a/src/Tool/IntelliTool.cpp b/src/Tool/IntelliTool.cpp index e83fef9..a4edf01 100644 --- a/src/Tool/IntelliTool.cpp +++ b/src/Tool/IntelliTool.cpp @@ -49,8 +49,8 @@ void IntelliTool::onWheelScrolled(int value){ void IntelliTool::createToolLayer(){ Area->createTempLayerAfter(Area->activeLayer); - this->Active=&Area->layerBundle[Area->activeLayer]; - this->Canvas=&Area->layerBundle[Area->activeLayer+1]; + this->Active=&Area->layerBundle[static_cast(Area->activeLayer)]; + this->Canvas=&Area->layerBundle[static_cast(Area->activeLayer+1)]; } void IntelliTool::mergeToolLayer(){ diff --git a/src/Tool/IntelliTool.h b/src/Tool/IntelliTool.h index 3903edb..b1d1910 100644 --- a/src/Tool/IntelliTool.h +++ b/src/Tool/IntelliTool.h @@ -4,7 +4,7 @@ #include "IntelliHelper/IntelliColorPicker.h" #include -class LayerObject; +struct LayerObject; class PaintingArea; /*! diff --git a/src/Tool/IntelliToolCircle.cpp b/src/Tool/IntelliToolCircle.cpp index c602f53..be7cf06 100644 --- a/src/Tool/IntelliToolCircle.cpp +++ b/src/Tool/IntelliToolCircle.cpp @@ -22,18 +22,18 @@ void IntelliToolCircle::drawCyrcle(int radius){ yMax = Middle.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 = 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->drawLine(QPoint(xMin,i), QPoint(xMax,i),inner,1); } //TODO implement circle drawing algorithm bresenham - radius = radius +(this->edgeWidth/2.)-1.; + radius = static_cast(radius +(this->edgeWidth/2.)-1.); yMin = (Middle.y()-radius); yMax = (Middle.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)); + 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); } @@ -41,8 +41,8 @@ void IntelliToolCircle::drawCyrcle(int radius){ xMin = (Middle.x()-radius); xMax = (Middle.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)); + 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); } diff --git a/src/Tool/IntelliToolLine.cpp b/src/Tool/IntelliToolLine.cpp index 39c07a4..50cbc66 100644 --- a/src/Tool/IntelliToolLine.cpp +++ b/src/Tool/IntelliToolLine.cpp @@ -52,7 +52,7 @@ void IntelliToolLine::onMouseMoved(int x, int y){ case LineStyle::DOTTED_LINE: QPoint p1 =start.x() <= next.x() ? start : next; QPoint p2 =start.x() < next.x() ? next : start; - int m = (float)(p2.y()-p1.y())/(float)(p2.x()-p1.x())+0.5f; + int m = static_cast((p2.y()-p1.y())/(p2.x()-p1.x())+0.5f); int c = start.y()-start.x()*m; break; diff --git a/src/Tool/IntelliToolPolygon.cpp b/src/Tool/IntelliToolPolygon.cpp index 4d95ee3..5a254cb 100644 --- a/src/Tool/IntelliToolPolygon.cpp +++ b/src/Tool/IntelliToolPolygon.cpp @@ -7,7 +7,7 @@ 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);; + lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1); PointIsNearStart = false; isDrawing = false; } @@ -63,9 +63,9 @@ void IntelliToolPolygon::onMouseLeftReleased(int x, int y){ } } } - for(int i=0; iCanvas->image->drawLine(QPointList[i], QPointList[next], colorPicker->getFirstColor(), lineWidth); + for(int i=0; i(QPointList.size()); i++) { + int next = static_cast((i+static_cast(1))%static_cast(QPointList.size())); + this->Canvas->image->drawLine(QPointList[static_cast(i)], QPointList[static_cast(next)], colorPicker->getFirstColor(), lineWidth); } QPointList.clear(); IntelliTool::onMouseLeftReleased(x,y);