From 2da9e15d3624ff964ce263b68ba18ed4d757b9ae Mon Sep 17 00:00:00 2001 From: Conrad Date: Thu, 19 Dec 2019 12:03:21 +0100 Subject: [PATCH] Minor Code Style Update + Documentation Spelling Fix --- src/GUI/IntelliPhotoGui.cpp | 38 +++++++++++++------------- src/GUI/IntelliPhotoGui.h | 28 +++++++++---------- src/Image/IntelliImage.cpp | 1 - src/Image/IntelliRasterImage.cpp | 2 +- src/IntelliHelper/IntelliColorPicker.h | 2 +- src/IntelliHelper/IntelliHelper.cpp | 31 ++++++++++----------- src/IntelliHelper/IntelliHelper.h | 2 -- src/Layer/PaintingArea.cpp | 4 +-- src/Layer/PaintingArea.h | 3 -- 9 files changed, 51 insertions(+), 60 deletions(-) diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index 16c8074..3429864 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -8,13 +8,13 @@ // IntelliPhotoGui constructor IntelliPhotoGui::IntelliPhotoGui(){ - //create Gui elements and lay them out + // create Gui elements and lay them out createGui(); // Create actions createActions(); - //create Menus + // create Menus createMenus(); - //set style of the gui + // set style of the gui setIntelliStyle(); // Size the app showMaximized(); @@ -69,7 +69,7 @@ void IntelliPhotoGui::slotCreateNewLayer(){ // Stores button value bool ok1, ok2; - // tr("New Layer") is the title + // "New Layer" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button int width = QInputDialog::getInt(this, tr("New Layer"), @@ -91,7 +91,7 @@ void IntelliPhotoGui::slotDeleteLayer(){ // Stores button value bool ok; - // tr("delete Layer") is the title + // "delete Layer" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button int layerNumber = QInputDialog::getInt(this, tr("delete Layer"), @@ -114,13 +114,13 @@ void IntelliPhotoGui::slotSetActiveAlpha(){ // Stores button value bool ok1, ok2; - // tr("Layer to set on") is the title + // "Layer to set on" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button int layer = QInputDialog::getInt(this, tr("Layer to set on"), tr("Layer:"), -1,-1,100,1, &ok1); - // tr("New Alpha") is the title + // "New Alpha" is the title of the window int alpha = QInputDialog::getInt(this, tr("New Alpha"), tr("Alpha:"), 255,0, 255, 1, &ok2); @@ -164,21 +164,21 @@ void IntelliPhotoGui::slotClearActiveLayer(){ // Stores button value bool ok1, ok2, ok3, ok4; - // tr("Red Input") is the title + // "Red Input" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button int red = QInputDialog::getInt(this, tr("Red Input"), tr("Red:"), 255,0, 255,1, &ok1); - // tr("Green Input") is the title + // "Green Input" is the title of the window int green = QInputDialog::getInt(this, tr("Green Input"), tr("Green:"), 255,0, 255, 1, &ok2); - // tr("Blue Input") is the title + // "Blue Input" is the title of the window int blue = QInputDialog::getInt(this, tr("Blue Input"), tr("Blue:"), 255,0, 255, 1, &ok3); - // tr("Alpha Input") is the title + // "Alpha Input" is the title of the window int alpha = QInputDialog::getInt(this, tr("Alpha Input"), tr("Alpha:"), 255,0, 255, 1, &ok4); @@ -192,7 +192,7 @@ void IntelliPhotoGui::slotSetActiveLayer(){ // Stores button value bool ok1; - // tr("Layer to set on") is the title + // "Layer to set on" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button int layer = QInputDialog::getInt(this, tr("Layer to set on"), @@ -400,25 +400,25 @@ void IntelliPhotoGui::createMenus(){ } void IntelliPhotoGui::createGui(){ - //create a central widget to work on + // create a central widget to work on centralGuiWidget = new QWidget(this); setCentralWidget(centralGuiWidget); - //create the grid for the layout + // create the grid for the layout mainLayout = new QGridLayout(centralGuiWidget); centralGuiWidget->setLayout(mainLayout); - //create Gui elements + // create Gui elements paintingArea = new PaintingArea(); - //set gui elements + // set gui elements mainLayout->addWidget(paintingArea); } void IntelliPhotoGui::setIntelliStyle(){ // Set the title setWindowTitle("IntelliPhoto Prototype"); - //set style sheet + // Set style sheet this->setStyleSheet("background-color:rgb(64,64,64)"); this->centralGuiWidget->setStyleSheet("color:rgb(255,255,255)"); this->menuBar()->setStyleSheet("color:rgb(255,255,255)"); @@ -427,11 +427,11 @@ void IntelliPhotoGui::setIntelliStyle(){ bool IntelliPhotoGui::maybeSave(){ // Check for changes since last save - //TODO insert variable for modified status here to make an save exit message + // TODO insert variable for modified status here to make an save exit message if (false) { QMessageBox::StandardButton ret; - // Painting is the title + // Painting is the title of the window // Add text and the buttons ret = QMessageBox::warning(this, tr("Painting"), tr("The image has been modified.\n" diff --git a/src/GUI/IntelliPhotoGui.h b/src/GUI/IntelliPhotoGui.h index 3865c1f..0e3e1c6 100644 --- a/src/GUI/IntelliPhotoGui.h +++ b/src/GUI/IntelliPhotoGui.h @@ -29,11 +29,11 @@ protected: void closeEvent(QCloseEvent *event) override; private slots: - //meta slots here (need further ) + // meta slots here (need further ) void slotOpen(); void slotSave(); - //layer slots here + // layer slots here void slotCreateNewLayer(); void slotDeleteLayer(); void slotClearActiveLayer(); @@ -46,26 +46,26 @@ private slots: void slotMoveLayerUp(); void slotMoveLayerDown(); - //color Picker slots here + // color Picker slots here void slotSetFirstColor(); void slotSetSecondColor(); void slotSwitchColor(); - //tool slots here + // tool slots here void slotCreatePenTool(); void slotCreatePlainTool(); void slotCreateLineTool(); - //slots for dialogs + // slots for dialogs void slotAboutDialog(); private: // Will tie user actions to functions void createActions(); void createMenus(); - //setup GUI elements + // setup GUI elements void createGui(); - //set style of the GUI + // set style of the GUI void setIntelliStyle(); @@ -87,26 +87,25 @@ private: QMenu *helpMenu; // All the actions that can occur - - //meta image actions (need further modularisation) + // meta image actions (need further modularisation) QAction *actionOpen; QAction *actionExit; - //color Picker actions + // color Picker actions QAction *actionColorPickerFirstColor; QAction *actionColorPickerSecondColor; QAction *actionColorSwitch; - //tool actions + // tool actions QAction *actionCreatePenTool; QAction *actionCreatePlainTool; QAction *actionCreateLineTool; - //dialog actions + // dialog actions QAction *actionAboutDialog; QAction *actionAboutQtDialog; - //layer change actions + // layer change actions QAction *actionCreateNewLayer; QAction *actionDeleteLayer; QAction* actionSetActiveLayer; @@ -121,10 +120,9 @@ private: // Actions tied to specific file formats QList actionSaveAs; - //main GUI elements + // main GUI elements QWidget* centralGuiWidget; QGridLayout *mainLayout; - }; #endif diff --git a/src/Image/IntelliImage.cpp b/src/Image/IntelliImage.cpp index fe1028b..e2f8a7b 100644 --- a/src/Image/IntelliImage.cpp +++ b/src/Image/IntelliImage.cpp @@ -71,7 +71,6 @@ void IntelliImage::drawLine(const QPoint &p1, const QPoint& p2, const QColor& co // Draw a line from the last registered point to the current painter.drawLine(p1, p2); - } void IntelliImage::drawPlain(const QColor& color){ diff --git a/src/Image/IntelliRasterImage.cpp b/src/Image/IntelliRasterImage.cpp index d92260f..977947c 100644 --- a/src/Image/IntelliRasterImage.cpp +++ b/src/Image/IntelliRasterImage.cpp @@ -19,7 +19,7 @@ IntelliImage* IntelliRasterImage::getDeepCopy(){ } void IntelliRasterImage::calculateVisiblity(){ - //not used in raster image + // not used in raster image } QImage IntelliRasterImage::getDisplayable(int alpha){ diff --git a/src/IntelliHelper/IntelliColorPicker.h b/src/IntelliHelper/IntelliColorPicker.h index f84e54e..be26d24 100644 --- a/src/IntelliHelper/IntelliColorPicker.h +++ b/src/IntelliHelper/IntelliColorPicker.h @@ -11,7 +11,7 @@ class IntelliColorPicker{ public: /*! - * \brief IntelliColorPicker construktor, setting 2 preset colors, be careful, theese color may change in production. + * \brief IntelliColorPicker constructor, setting 2 preset colors, be careful, theese color may change in production. */ IntelliColorPicker(); diff --git a/src/IntelliHelper/IntelliHelper.cpp b/src/IntelliHelper/IntelliHelper.cpp index d814296..2979bc5 100644 --- a/src/IntelliHelper/IntelliHelper.cpp +++ b/src/IntelliHelper/IntelliHelper.cpp @@ -5,7 +5,7 @@ std::vector IntelliHelper::calculateTriangles(std::vector polyPoints){ - //helper for managing the triangle vertices and their state + // helper for managing the triangle vertices and their state struct TriangleHelper{ QPoint vertex; float interiorAngle; @@ -13,7 +13,7 @@ std::vector IntelliHelper::calculateTriangles(std::vector poly bool isTip; }; - //calculates the inner angle of 'point' + // calculates the inner angle of 'point' auto calculateInner = [](QPoint& point, QPoint& prev, QPoint& post){ QPoint AP(point.x()-prev.x(), point.y()-prev.y()); QPoint BP(point.x()-post.x(), point.y()-post.y()); @@ -23,7 +23,7 @@ std::vector IntelliHelper::calculateTriangles(std::vector poly return acos(topSclar/absolute); }; - //gets the first element of vec for which element.isTip == true holds + // gets the first element of vec for which element.isTip == true holds auto getTip= [](const std::vector& vec){ for(auto element:vec){ if(element.isTip){ @@ -33,17 +33,17 @@ std::vector IntelliHelper::calculateTriangles(std::vector poly return vec[0]; }; - //get the vertex Index bevor index in relation to the container length + // 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 Index after index in relation to the container lenght + // get the vertex Index after index in relation to the container lenght auto getPost = [](int index, int length){ return (index+1)%length; }; - //return if the vertex is a tip + // return if the vertex is a tip auto isTip = [](float angle){ return angle<180.f; }; @@ -51,7 +51,7 @@ std::vector IntelliHelper::calculateTriangles(std::vector poly std::vector Vertices; std::vector Triangles; - //set up all vertices and calculate intirior angle + // set up all vertices and calculate intirior angle for(int i=0; i(polyPoints.size()); i++){ TriangleHelper helper; int prev = getPrev(i, static_cast(polyPoints.size())); @@ -67,48 +67,47 @@ std::vector IntelliHelper::calculateTriangles(std::vector poly Vertices.push_back(helper); } - //search triangles based on the intirior angles of each vertey + // search triangles based on the intirior angles of each vertey while(Triangles.size() != polyPoints.size()-2){ Triangle tri; TriangleHelper smallest = getTip(Vertices); int prev = getPrev(smallest.index, static_cast(Vertices.size())); int post = getPost(smallest.index, static_cast(Vertices.size())); - //set triangle and push it + // set triangle and push it tri.A = Vertices[static_cast(prev)].vertex; tri.B = Vertices[static_cast(smallest.index)].vertex; tri.C = Vertices[static_cast(post)].vertex; Triangles.push_back(tri); - //update Vertice array + // update Vertice array Vertices.erase(Vertices.begin()+smallest.index); for(size_t i=static_cast(smallest.index); i(Vertices.size())); int postOfPrev = getPost(prev, static_cast(Vertices.size())); int prevOfPost = getPrev(post, static_cast(Vertices.size())); int postOfPost = getPost(post, static_cast(Vertices.size())); - //update vertices with interior angles - //updtae prev + // update vertices with interior angles + // updtae prev Vertices[static_cast(prev)].interiorAngle = calculateInner(Vertices[static_cast(prev)].vertex, Vertices[static_cast(prevOfPrev)].vertex, Vertices[static_cast(postOfPrev)].vertex); Vertices[static_cast(prev)].isTip = isTip(Vertices[static_cast(prev)].interiorAngle); - //update post + // update post Vertices[static_cast(post)].interiorAngle = calculateInner(Vertices[static_cast(post)].vertex, Vertices[static_cast(prevOfPost)].vertex, Vertices[static_cast(postOfPost)].vertex); Vertices[static_cast(post)].isTip = isTip(Vertices[static_cast(post)].interiorAngle); - } return Triangles; } diff --git a/src/IntelliHelper/IntelliHelper.h b/src/IntelliHelper/IntelliHelper.h index ca3ec77..0e511a7 100644 --- a/src/IntelliHelper/IntelliHelper.h +++ b/src/IntelliHelper/IntelliHelper.h @@ -11,7 +11,6 @@ struct Triangle{ QPoint A,B,C; }; - namespace IntelliHelper { /*! @@ -59,7 +58,6 @@ namespace IntelliHelper { * \return Returns true if the point lies in the üpolygon, otherwise false. */ bool isInPolygon(std::vector &triangles, QPoint &point); - } #endif diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index 0275c00..294127f 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -19,10 +19,10 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent) :QWidget(parent){ - //test yout tool here and reset after accomplished test + // Testing Area + // test yout tool here and reset after accomplished test this->Tool = new IntelliToolFloodFill(this, &colorPicker); this->setUp(maxWidth, maxHeight); - //tetsing this->addLayer(200,200,0,0,ImageType::Shaped_Image); layerBundle[0].image->drawPlain(QColor(255,0,0,255)); std::vector polygon; diff --git a/src/Layer/PaintingArea.h b/src/Layer/PaintingArea.h index afe218e..d7e0083 100644 --- a/src/Layer/PaintingArea.h +++ b/src/Layer/PaintingArea.h @@ -13,7 +13,6 @@ #include "Tool/IntelliTool.h" #include "IntelliHelper/IntelliColorPicker.h" - struct LayerObject{ IntelliImage* image; int width; @@ -58,7 +57,6 @@ public: void createLineTool(); public slots: - // Events to handle void slotActivateLayer(int a); void slotDeleteActiveLayer(); @@ -95,7 +93,6 @@ private: void resizeImage(QImage *image_res, const QSize &newSize); - //Helper for Tool void createTempLayerAfter(int idx); };