From 326f9c8948511ed07d102c4d0f0200b9e6b18af5 Mon Sep 17 00:00:00 2001 From: Conrad Date: Thu, 9 Jan 2020 10:12:38 +0100 Subject: [PATCH] Unified Index Variable Name --- src/IntelliHelper/IntelliTriangulation.cpp | 32 +++++++++++----------- src/Layer/PaintingArea.cpp | 22 +++++++-------- src/Layer/PaintingArea.h | 20 +++++++------- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/IntelliHelper/IntelliTriangulation.cpp b/src/IntelliHelper/IntelliTriangulation.cpp index 55ddd9a..42f44d9 100644 --- a/src/IntelliHelper/IntelliTriangulation.cpp +++ b/src/IntelliHelper/IntelliTriangulation.cpp @@ -9,7 +9,7 @@ std::vector IntelliTriangulation::calculateTriangles(std::vector IntelliTriangulation::calculateTriangles(std::vector=0 ? (index-1) : (length-1); + // get the vertex idx bevor idx in relation to the container length + auto getPrev = [](int idx, int length){ + return (idx-1)>=0 ? (idx-1) : (length-1); }; - // get the vertex Index after index in relation to the container lenght - auto getPost = [](int index, int length){ - return (index+1)%length; + // get the vertex idx after idx in relation to the container lenght + auto getPost = [](int idx, int length){ + return (idx+1)%length; }; // return if the vertex is a tip @@ -59,7 +59,7 @@ std::vector IntelliTriangulation::calculateTriangles(std::vector(polyPoints.size())); helper.vertex = polyPoints[static_cast(i)]; - helper.index = i; + helper.idx = i; helper.interiorAngle = calculateInner(polyPoints[static_cast(i)], polyPoints[static_cast(prev)], @@ -72,24 +72,24 @@ std::vector IntelliTriangulation::calculateTriangles(std::vector(Vertices.size())); - int post = getPost(smallest.index, static_cast(Vertices.size())); + int prev = getPrev(smallest.idx, static_cast(Vertices.size())); + int post = getPost(smallest.idx, static_cast(Vertices.size())); // set triangle and push it tri.A = Vertices[static_cast(prev)].vertex; - tri.B = Vertices[static_cast(smallest.index)].vertex; + tri.B = Vertices[static_cast(smallest.idx)].vertex; tri.C = Vertices[static_cast(post)].vertex; Triangles.push_back(tri); // update Vertice array - Vertices.erase(Vertices.begin()+smallest.index); - for(size_t i=static_cast(smallest.index); i(smallest.idx); i(Vertices.size())); diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index 0550c0d..bd52fab 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -71,10 +71,10 @@ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOff } -void PaintingArea::deleteLayer(int index){ - if(index(layerBundle.size())) { - this->layerBundle.erase(layerBundle.begin()+index); - if(activeLayer>=index && activeLayer != 0) { +void PaintingArea::deleteLayer(int idx){ + if(idx(layerBundle.size())) { + this->layerBundle.erase(layerBundle.begin()+idx); + if(activeLayer>=idx && activeLayer != 0) { activeLayer--; } } @@ -87,15 +87,15 @@ void PaintingArea::slotDeleteActiveLayer(){ } } -void PaintingArea::setLayerActive(int index){ - if(index>=0&&index(layerBundle.size())) { - this->activeLayer=index; +void PaintingArea::setLayerActive(int idx){ + if(idx>=0&&idx(layerBundle.size())) { + this->activeLayer=idx; } } -void PaintingArea::setLayerAlpha(int index, int alpha){ - if(index>=0&&index(layerBundle.size())) { - layerBundle[static_cast(index)].alpha=alpha; +void PaintingArea::setLayerAlpha(int idx, int alpha){ + if(idx>=0&&idx(layerBundle.size())) { + layerBundle[static_cast(idx)].alpha=alpha; } } @@ -119,7 +119,7 @@ bool PaintingArea::save(const QString &filePath, const char*fileFormat){ this->drawLayers(true); if(!strcmp(fileFormat,"PNG")) { - QImage visibleImage = Canvas->convertToFormat(QImage::Format_Indexed8); + QImage visibleImage = Canvas->convertToFormat(QImage::Format_idxed8); fileFormat = "png"; if (visibleImage.save(filePath, fileFormat)) { return true; diff --git a/src/Layer/PaintingArea.h b/src/Layer/PaintingArea.h index 10d9ce2..c996145 100644 --- a/src/Layer/PaintingArea.h +++ b/src/Layer/PaintingArea.h @@ -84,7 +84,7 @@ public: int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, IntelliImage::ImageType type = IntelliImage::ImageType::Raster_Image); /*! * \brief The addLayerAt adds a layer to the current project/ painting area at a specific position in the layer stack - * \param idx - ID of the position the new layer should be added + * \param idx - Index of the position the new layer should be added * \param width - Width of the layer in pixles * \param height - Height of the layer in pixles * \param widthOffset - Offset of the layer measured to the left border of the painting area in pixles @@ -94,21 +94,21 @@ public: */ int addLayerAt(int idx, int width, int height, int widthOffset=0, int heightOffset=0, IntelliImage::ImageType type = IntelliImage::ImageType::Raster_Image); /*! - * \brief The deleteLayer method removes a layer at a given index - * \param index - The index of the layer to be removed + * \brief The deleteLayer method removes a layer at a given idx + * \param idx - The index of the layer to be removed */ - void deleteLayer(int index); + void deleteLayer(int idx); /*! * \brief The setLayerToActive method marks a specific layer as active - * \param index - Index of the layer to be active + * \param idx - The index of the layer to be active */ - void setLayerActive(int index); + void setLayerActive(int idx); /*! * \brief The setAlphaOfLayer method sets the alpha value of a specific layer - * \param index - Index of the layer where the change should be applied + * \param idx - The index of the layer where the change should be applied * \param alpha - New alpha value of the layer */ - void setLayerAlpha(int index, int alpha); + void setLayerAlpha(int idx, int alpha); /*! * \brief The floodFill method fills a the active layer with a given color * \param r - Red value of the color the layer should be filled with @@ -125,7 +125,7 @@ public: void movePositionActive(int x, int y); /*! * \brief The moveActiveLayer moves the active layer to a specific position in the layer stack - * \param idx - The id of the new position the layer should be in + * \param idx - The index of the new position the layer should be in */ void moveActiveLayer(int idx); @@ -178,7 +178,7 @@ public slots: // Events to handle /*! * \brief The slotActivateLayer method handles the event of selecting one layer as active - * \param a - Index of the layer to be active + * \param a - idx of the layer to be active */ void slotActivateLayer(int a); /*!