Minor Code Style Update + Documentation Spelling Fix

This commit is contained in:
2019-12-19 12:03:21 +01:00
parent 9db5304edc
commit 2da9e15d36
9 changed files with 51 additions and 60 deletions

View File

@@ -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"

View File

@@ -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<QAction *> actionSaveAs;
//main GUI elements
// main GUI elements
QWidget* centralGuiWidget;
QGridLayout *mainLayout;
};
#endif

View File

@@ -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){

View File

@@ -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){

View File

@@ -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();

View File

@@ -5,7 +5,7 @@
std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> 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<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> 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<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> 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<TriangleHelper>& vec){
for(auto element:vec){
if(element.isTip){
@@ -33,17 +33,17 @@ std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> 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<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> poly
std::vector<TriangleHelper> Vertices;
std::vector<Triangle> Triangles;
//set up all vertices and calculate intirior angle
// set up all vertices and calculate intirior angle
for(int i=0; i<static_cast<int>(polyPoints.size()); i++){
TriangleHelper helper;
int prev = getPrev(i, static_cast<int>(polyPoints.size()));
@@ -67,48 +67,47 @@ std::vector<Triangle> IntelliHelper::calculateTriangles(std::vector<QPoint> 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<int>(Vertices.size()));
int post = getPost(smallest.index, static_cast<int>(Vertices.size()));
//set triangle and push it
// 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.C = Vertices[static_cast<size_t>(post)].vertex;
Triangles.push_back(tri);
//update Vertice array
// 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;
}
//update post und prev index
// update post und prev index
post = post-1;
prev = prev<smallest.index?prev:(prev-1);
//calcultae neighboors of prev and post to calculate new interior angles
// calcultae neighboors of prev and post to calculate new interior angles
int prevOfPrev = getPrev(prev, static_cast<int>(Vertices.size()));
int postOfPrev = getPost(prev, static_cast<int>(Vertices.size()));
int prevOfPost = getPrev(post, static_cast<int>(Vertices.size()));
int postOfPost = getPost(post, static_cast<int>(Vertices.size()));
//update vertices with interior angles
//updtae prev
// update vertices with interior angles
// updtae prev
Vertices[static_cast<size_t>(prev)].interiorAngle = calculateInner(Vertices[static_cast<size_t>(prev)].vertex,
Vertices[static_cast<size_t>(prevOfPrev)].vertex,
Vertices[static_cast<size_t>(postOfPrev)].vertex);
Vertices[static_cast<size_t>(prev)].isTip = isTip(Vertices[static_cast<size_t>(prev)].interiorAngle);
//update post
// update post
Vertices[static_cast<size_t>(post)].interiorAngle = calculateInner(Vertices[static_cast<size_t>(post)].vertex,
Vertices[static_cast<size_t>(prevOfPost)].vertex,
Vertices[static_cast<size_t>(postOfPost)].vertex);
Vertices[static_cast<size_t>(post)].isTip = isTip(Vertices[static_cast<size_t>(post)].interiorAngle);
}
return Triangles;
}

View File

@@ -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<Triangle> &triangles, QPoint &point);
}
#endif

View File

@@ -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<QPoint> polygon;

View File

@@ -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);
};