Unified Index Variable Name

This commit is contained in:
2020-01-09 10:12:38 +01:00
parent 72b235689e
commit 326f9c8948
3 changed files with 37 additions and 37 deletions

View File

@@ -9,7 +9,7 @@ std::vector<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoin
struct TriangleHelper {
QPoint vertex;
float interiorAngle;
int index;
int idx;
bool isTip;
};
@@ -34,14 +34,14 @@ std::vector<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoin
return vec[min];
};
// 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);
// 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<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoin
int post = getPost(i, static_cast<int>(polyPoints.size()));
helper.vertex = polyPoints[static_cast<size_t>(i)];
helper.index = i;
helper.idx = i;
helper.interiorAngle = calculateInner(polyPoints[static_cast<size_t>(i)],
polyPoints[static_cast<size_t>(prev)],
@@ -72,24 +72,24 @@ std::vector<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoin
while(Triangles.size() != polyPoints.size()-2) {
Triangle tri;
TriangleHelper smallest = getTip(Vertices);
int prev = getPrev(smallest.index, static_cast<int>(Vertices.size()));
int post = getPost(smallest.index, static_cast<int>(Vertices.size()));
int prev = getPrev(smallest.idx, static_cast<int>(Vertices.size()));
int post = getPost(smallest.idx, static_cast<int>(Vertices.size()));
// set triangle and push it
tri.A = Vertices[static_cast<size_t>(prev)].vertex;
tri.B = Vertices[static_cast<size_t>(smallest.index)].vertex;
tri.B = Vertices[static_cast<size_t>(smallest.idx)].vertex;
tri.C = Vertices[static_cast<size_t>(post)].vertex;
Triangles.push_back(tri);
// update Vertice array
Vertices.erase(Vertices.begin()+smallest.index);
for(size_t i=static_cast<size_t>(smallest.index); i<Vertices.size(); i++) {
Vertices[i].index-=1;
Vertices.erase(Vertices.begin()+smallest.idx);
for(size_t i=static_cast<size_t>(smallest.idx); i<Vertices.size(); i++) {
Vertices[i].idx-=1;
}
// update post und prev index
// update post und prev idx
post = getPrev(post, Vertices.size());
prev = prev<smallest.index ? prev : (prev-1);
prev = prev<smallest.idx ? prev : (prev-1);
// calcultae neighboors of prev and post to calculate new interior angles
int prevOfPrev = getPrev(prev, static_cast<int>(Vertices.size()));

View File

@@ -71,10 +71,10 @@ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOff
}
void PaintingArea::deleteLayer(int index){
if(index<static_cast<int>(layerBundle.size())) {
this->layerBundle.erase(layerBundle.begin()+index);
if(activeLayer>=index && activeLayer != 0) {
void PaintingArea::deleteLayer(int idx){
if(idx<static_cast<int>(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<static_cast<int>(layerBundle.size())) {
this->activeLayer=index;
void PaintingArea::setLayerActive(int idx){
if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
this->activeLayer=idx;
}
}
void PaintingArea::setLayerAlpha(int index, int alpha){
if(index>=0&&index<static_cast<int>(layerBundle.size())) {
layerBundle[static_cast<size_t>(index)].alpha=alpha;
void PaintingArea::setLayerAlpha(int idx, int alpha){
if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
layerBundle[static_cast<size_t>(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;

View File

@@ -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);
/*!