Merge branch 'dev' into 'dev-stupidrenderer'

# Conflicts:
#   src/Image/IntelliImage.cpp
#   src/Image/IntelliRasterImage.cpp
#   src/Image/IntelliShapedImage.cpp
#   src/Layer/PaintingArea.cpp
This commit is contained in:
Jan Schuffenhauer
2020-01-09 09:39:38 +00:00
23 changed files with 549 additions and 454 deletions

95
cppcheck_errors.txt Normal file
View File

@@ -0,0 +1,95 @@
src/GUI/IntelliPhotoGui.cpp:83:15: style: Variable 'layer' is assigned a value that is never used. [unreadVariable]
int layer = paintingArea->addLayer(width,height,0,0);
^
src/IntelliHelper/IntelliColorPicker.cpp:4:3: performance: Variable 'firstColor' is assigned in constructor body. Consider performing initialization in initialization list. [useInitializationList]
firstColor = {255,0,0,255};
^
src/IntelliHelper/IntelliColorPicker.cpp:5:3: performance: Variable 'secondColor' is assigned in constructor body. Consider performing initialization in initialization list. [useInitializationList]
secondColor = {0,255,255,255};
^
src/IntelliHelper/IntelliTriangulation.cpp:116:63: style: Parameter 'triangles' can be declared with const [constParameter]
bool IntelliTriangulation::isInPolygon(std::vector<Triangle> &triangles, QPoint &point){
^
src/Layer/PaintingArea.cpp:333:22: style: Redundant condition: If 'activeLayer > 0', the comparison 'activeLayer != -1' is always true. [redundantCondition]
if(activeLayer!=-1 && activeLayer>0) {
^
src/Tool/IntelliTool.cpp:4:14: warning: Member variable 'IntelliTool::ActiveType' is not initialized in the constructor. [uninitMemberVar]
IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings){
^
src/Tool/IntelliTool.cpp:4:14: warning: Member variable 'IntelliTool::activeLayer' is not initialized in the constructor. [uninitMemberVar]
IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings){
^
src/Tool/IntelliTool.cpp:4:14: warning: Member variable 'IntelliTool::Canvas' is not initialized in the constructor. [uninitMemberVar]
IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings){
^
src/Tool/IntelliToolCircle.cpp:43:9: style: Local variable 'yMin' shadows outer variable [shadowVariable]
int yMin = static_cast<int>(centerPoint.y()-sqrt(pow(radius,2)-pow(i-centerPoint.x(),2)));
^
src/Tool/IntelliToolCircle.cpp:19:7: note: Shadowed declaration
int yMin, yMax, xMin, xMax;
^
src/Tool/IntelliToolCircle.cpp:43:9: note: Shadow variable
int yMin = static_cast<int>(centerPoint.y()-sqrt(pow(radius,2)-pow(i-centerPoint.x(),2)));
^
src/Tool/IntelliToolCircle.cpp:44:9: style: Local variable 'yMax' shadows outer variable [shadowVariable]
int yMax = static_cast<int>(centerPoint.y()+sqrt(pow(radius,2)-pow(i-centerPoint.x(),2)));
^
src/Tool/IntelliToolCircle.cpp:19:13: note: Shadowed declaration
int yMin, yMax, xMin, xMax;
^
src/Tool/IntelliToolCircle.cpp:44:9: note: Shadow variable
int yMax = static_cast<int>(centerPoint.y()+sqrt(pow(radius,2)-pow(i-centerPoint.x(),2)));
^
src/Tool/IntelliToolCircle.cpp:16:13: style: Variable 'outer' is assigned a value that is never used. [unreadVariable]
int outer = radius+20;
^
src/Tool/IntelliToolLine.cpp:51:13: style: Variable 'c' is assigned a value that is never used. [unreadVariable]
int c = lineStartingPoint.y()-lineStartingPoint.x()*m;
^
src/Tool/IntelliToolPolygon.h:25:6: warning: The class 'IntelliToolPolygon' defines member variable with name 'isDrawing' also defined in its parent class 'IntelliTool'. [duplInheritedMember]
bool isDrawing;
^
src/Tool/IntelliTool.h:68:6: note: Parent variable 'IntelliTool::isDrawing'
bool isDrawing = false;
^
src/Tool/IntelliToolPolygon.h:25:6: note: Derived variable 'IntelliToolPolygon::isDrawing'
bool isDrawing;
^
src/GUI/IntelliPhotoGui.cpp:23:0: style: The function 'closeEvent' is never used. [unusedFunction]
^
src/IntelliHelper/IntelliRenderSettings.cpp:8:0: style: The function 'getFastRenderer' is never used. [unusedFunction]
^
src/Layer/PaintingArea.cpp:269:0: style: The function 'mouseMoveEvent' is never used. [unusedFunction]
^
src/Layer/PaintingArea.cpp:253:0: style: The function 'mousePressEvent' is never used. [unusedFunction]
^
src/Layer/PaintingArea.cpp:279:0: style: The function 'mouseReleaseEvent' is never used. [unusedFunction]
^
src/Layer/PaintingArea.cpp:305:0: style: The function 'paintEvent' is never used. [unusedFunction]
^
src/Layer/PaintingArea.cpp:316:0: style: The function 'resizeEvent' is never used. [unusedFunction]
^
src/Layer/PaintingArea.cpp:321:0: style: The function 'resizeLayer' is never used. [unusedFunction]
^
src/Layer/PaintingArea.cpp:173:0: style: The function 'slotActivateLayer' is never used. [unusedFunction]
^
src/GUI/IntelliPhotoGui.cpp:157:0: style: The function 'slotClearActiveLayer' is never used. [unusedFunction]
^
src/Layer/PaintingArea.cpp:83:0: style: The function 'slotDeleteActiveLayer' is never used. [unusedFunction]
^
src/Layer/PaintingArea.cpp:292:0: style: The function 'wheelEvent' is never used. [unusedFunction]
^
nofile:0:0: information: Cppcheck cannot find all the include files (use --check-config for details) [missingInclude]

View File

@@ -97,7 +97,7 @@ void IntelliPhotoGui::slotDeleteLayer(){
tr("Number:"), tr("Number:"),
paintingArea->getNumberOfActiveLayer(),0, 500, 1, &ok); paintingArea->getNumberOfActiveLayer(),0, 500, 1, &ok);
// Create New Layer // Create New Layer
if (ok){ if (ok) {
paintingArea->deleteLayer(layerNumber); paintingArea->deleteLayer(layerNumber);
UpdateGui(); UpdateGui();
} }
@@ -259,12 +259,12 @@ void IntelliPhotoGui::slotAboutDialog(){
void IntelliPhotoGui::slotEnterPressed(){ void IntelliPhotoGui::slotEnterPressed(){
QString string = EditLineWidth->text(); QString string = EditLineWidth->text();
if(string.toInt() > 50){ if(string.toInt() > 50) {
EditLineWidth->setText("50"); EditLineWidth->setText("50");
} }
paintingArea->Toolsettings.setLineWidth(string.toInt()); paintingArea->Toolsettings.setLineWidth(string.toInt());
string = EditLineInnerAlpha->text(); string = EditLineInnerAlpha->text();
if(string.toInt() > 255){ if(string.toInt() > 255) {
EditLineInnerAlpha->setText("255"); EditLineInnerAlpha->setText("255");
} }
paintingArea->Toolsettings.setInnerAlpha(string.toInt()); paintingArea->Toolsettings.setInnerAlpha(string.toInt());

View File

@@ -24,8 +24,8 @@ public:
* \brief The Types, which an Image can be. * \brief The Types, which an Image can be.
*/ */
enum class ImageType { enum class ImageType {
Raster_Image, RASTERIMAGE,
Shaped_Image SHAPEDIMAGE
}; };
protected: protected:

View File

@@ -16,7 +16,7 @@ IntelliRasterImage::~IntelliRasterImage(){
IntelliImage* IntelliRasterImage::getDeepCopy(){ IntelliImage* IntelliRasterImage::getDeepCopy(){
IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), false); IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), false);
raster->imageData.fill(Qt::transparent); raster->imageData.fill(Qt::transparent);
raster->TypeOfImage = IntelliImage::ImageType::Raster_Image; raster->TypeOfImage = IntelliImage::ImageType::RASTERIMAGE;
return raster; return raster;
} }

View File

@@ -22,7 +22,7 @@ IntelliImage* IntelliShapedImage::getDeepCopy(){
IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), false); IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), false);
shaped->setPolygon(this->polygonData); shaped->setPolygon(this->polygonData);
shaped->imageData.fill(Qt::transparent); shaped->imageData.fill(Qt::transparent);
shaped->TypeOfImage = IntelliImage::ImageType::Shaped_Image; shaped->TypeOfImage = IntelliImage::ImageType::SHAPEDIMAGE;
return shaped; return shaped;
} }

View File

@@ -5,16 +5,16 @@
class IntelliRenderSettings class IntelliRenderSettings
{ {
public: public:
IntelliRenderSettings(); IntelliRenderSettings();
/*! /*!
* \brief The getfastRenderer gets the value of the flag for the fastRenderer setting. * \brief The getfastRenderer gets the value of the flag for the fastRenderer setting.
* \return Returns true if fastRenderer is active else false * \return Returns true if fastRenderer is active else false
*/ */
bool getFastRenderer(); bool getFastRenderer();
private: private:
bool fastRenderer = true; bool fastRenderer = true;
}; };
#endif // INTELLIRENDERSETTINGS_H #endif // INTELLIRENDERSETTINGS_H

View File

@@ -21,10 +21,10 @@ void IntelliToolsettings::setLineWidth(){
} }
void IntelliToolsettings::setLineWidth(int LineWidth){ void IntelliToolsettings::setLineWidth(int LineWidth){
if(LineWidth < 1){ if(LineWidth < 1) {
LineWidth = 1; LineWidth = 1;
} }
else if(LineWidth > 50){ else if(LineWidth > 50) {
LineWidth = 50; LineWidth = 50;
} }
lineWidth = LineWidth; lineWidth = LineWidth;
@@ -39,10 +39,10 @@ void IntelliToolsettings::setInnerAlpha(){
} }
void IntelliToolsettings::setInnerAlpha(int innerAlpha){ void IntelliToolsettings::setInnerAlpha(int innerAlpha){
if(innerAlpha < 0){ if(innerAlpha < 0) {
innerAlpha = 0; innerAlpha = 0;
} }
else if(innerAlpha > 255){ else if(innerAlpha > 255) {
innerAlpha = 255; innerAlpha = 255;
} }
this->innerAlpha = innerAlpha; this->innerAlpha = innerAlpha;

View File

@@ -3,27 +3,27 @@
class IntelliToolsettings { class IntelliToolsettings {
public: public:
/*! /*!
* \brief The LineStyle enum classifing all ways of drawing a line. * \brief The LineStyle enum classifing all ways of drawing a line.
*/ */
enum class LineStyle { enum class LineStyle {
SOLID_LINE, SOLID_LINE,
DOTTED_LINE DOTTED_LINE
}; };
IntelliToolsettings(); IntelliToolsettings();
virtual ~IntelliToolsettings(); virtual ~IntelliToolsettings();
int getLineWidth(); int getLineWidth();
void setLineWidth(); void setLineWidth();
void setLineWidth(int LineWidth); void setLineWidth(int LineWidth);
int getInnerAlpha(); int getInnerAlpha();
void setInnerAlpha(); void setInnerAlpha();
void setInnerAlpha(int innerAlpha); void setInnerAlpha(int innerAlpha);
LineStyle getLinestyle(); LineStyle getLinestyle();
private: private:
int lineWidth; int lineWidth;
int innerAlpha; int innerAlpha;
LineStyle Linestyle; LineStyle Linestyle;
}; };
#endif // INTELLITOOLSETTINGS_H #endif // INTELLITOOLSETTINGS_H

View File

@@ -9,7 +9,7 @@ std::vector<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoin
struct TriangleHelper { struct TriangleHelper {
QPoint vertex; QPoint vertex;
float interiorAngle; float interiorAngle;
int index; int idx;
bool isTip; bool isTip;
}; };
@@ -34,14 +34,14 @@ std::vector<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoin
return vec[min]; return vec[min];
}; };
// get the vertex Index bevor index in relation to the container length // get the vertex idx bevor idx in relation to the container length
auto getPrev = [](int index, int length){ auto getPrev = [](int idx, int length){
return (index-1)>=0 ? (index-1) : (length-1); return (idx-1)>=0 ? (idx-1) : (length-1);
}; };
// get the vertex Index after index in relation to the container lenght // get the vertex idx after idx in relation to the container lenght
auto getPost = [](int index, int length){ auto getPost = [](int idx, int length){
return (index+1)%length; return (idx+1)%length;
}; };
// return if the vertex is a tip // 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())); int post = getPost(i, static_cast<int>(polyPoints.size()));
helper.vertex = polyPoints[static_cast<size_t>(i)]; helper.vertex = polyPoints[static_cast<size_t>(i)];
helper.index = i; helper.idx = i;
helper.interiorAngle = calculateInner(polyPoints[static_cast<size_t>(i)], helper.interiorAngle = calculateInner(polyPoints[static_cast<size_t>(i)],
polyPoints[static_cast<size_t>(prev)], polyPoints[static_cast<size_t>(prev)],
@@ -72,24 +72,24 @@ std::vector<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoin
while(Triangles.size() != polyPoints.size()-2) { while(Triangles.size() != polyPoints.size()-2) {
Triangle tri; Triangle tri;
TriangleHelper smallest = getTip(Vertices); TriangleHelper smallest = getTip(Vertices);
int prev = getPrev(smallest.index, static_cast<int>(Vertices.size())); int prev = getPrev(smallest.idx, static_cast<int>(Vertices.size()));
int post = getPost(smallest.index, static_cast<int>(Vertices.size())); int post = getPost(smallest.idx, 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.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; tri.C = Vertices[static_cast<size_t>(post)].vertex;
Triangles.push_back(tri); Triangles.push_back(tri);
// update Vertice array // update Vertice array
Vertices.erase(Vertices.begin()+smallest.index); Vertices.erase(Vertices.begin()+smallest.idx);
for(size_t i=static_cast<size_t>(smallest.index); i<Vertices.size(); i++) { for(size_t i=static_cast<size_t>(smallest.idx); i<Vertices.size(); i++) {
Vertices[i].index-=1; Vertices[i].idx-=1;
} }
// update post und prev index // update post und prev idx
post = getPrev(post, Vertices.size()); 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 // calcultae neighboors of prev and post to calculate new interior angles
int prevOfPrev = getPrev(prev, static_cast<int>(Vertices.size())); int prevOfPrev = getPrev(prev, static_cast<int>(Vertices.size()));

View File

@@ -22,7 +22,7 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent)
: QWidget(parent){ : QWidget(parent){
this->Tool = nullptr; this->Tool = nullptr;
this->setLayerDimensions(maxWidth, maxHeight); this->setLayerDimensions(maxWidth, maxHeight);
this->addLayer(200,200,0,0,IntelliImage::ImageType::Shaped_Image); this->addLayer(200,200,0,0,IntelliImage::ImageType::SHAPEDIMAGE);
layerBundle[0].image->drawPlain(QColor(0,0,255,255)); layerBundle[0].image->drawPlain(QColor(0,0,255,255));
std::vector<QPoint> polygon; std::vector<QPoint> polygon;
polygon.push_back(QPoint(100,000)); polygon.push_back(QPoint(100,000));
@@ -31,7 +31,7 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent)
polygon.push_back(QPoint(000,100)); polygon.push_back(QPoint(000,100));
layerBundle[0].image->setPolygon(polygon); layerBundle[0].image->setPolygon(polygon);
this->addLayer(200,200,150,150,IntelliImage::ImageType::Raster_Image); this->addLayer(200,200,150,150,IntelliImage::ImageType::RASTERIMAGE);
layerBundle[1].image->drawPlain(QColor(0,255,0,255)); layerBundle[1].image->drawPlain(QColor(0,255,0,255));
layerBundle[1].alpha=200; layerBundle[1].alpha=200;
@@ -71,10 +71,10 @@ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOff
} }
void PaintingArea::deleteLayer(int index){ void PaintingArea::deleteLayer(int idx){
if(index<static_cast<int>(layerBundle.size())) { if(idx<static_cast<int>(layerBundle.size())) {
this->layerBundle.erase(layerBundle.begin()+index); this->layerBundle.erase(layerBundle.begin()+idx);
if(activeLayer>=index && activeLayer != 0) { if(activeLayer>=idx && activeLayer != 0) {
activeLayer--; activeLayer--;
} }
} }
@@ -87,15 +87,15 @@ void PaintingArea::slotDeleteActiveLayer(){
} }
} }
void PaintingArea::setLayerActive(int index){ void PaintingArea::setLayerActive(int idx){
if(index>=0&&index<static_cast<int>(layerBundle.size())) { if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
this->activeLayer=index; this->activeLayer=idx;
} }
} }
void PaintingArea::setLayerAlpha(int index, int alpha){ void PaintingArea::setLayerAlpha(int idx, int alpha){
if(index>=0&&index<static_cast<int>(layerBundle.size())) { if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
layerBundle[static_cast<size_t>(index)].alpha=alpha; layerBundle[static_cast<size_t>(idx)].alpha=alpha;
} }
} }
@@ -146,8 +146,8 @@ void PaintingArea::floodFill(int r, int g, int b, int a){
} }
void PaintingArea::movePositionActive(int x, int y){ void PaintingArea::movePositionActive(int x, int y){
if(Tool!=nullptr){ if(Tool!=nullptr) {
if(Tool->getIsDrawing()){ if(Tool->getIsDrawing()) {
IntelliTool* temp = copyActiveTool(); IntelliTool* temp = copyActiveTool();
delete this->Tool; delete this->Tool;
this->Tool = temp; this->Tool = temp;
@@ -173,8 +173,8 @@ void PaintingArea::moveActiveLayer(int idx){
} }
void PaintingArea::slotActivateLayer(int a){ void PaintingArea::slotActivateLayer(int a){
if(Tool != nullptr){ if(Tool != nullptr) {
if(Tool->getIsDrawing()){ if(Tool->getIsDrawing()) {
IntelliTool* temp = copyActiveTool(); IntelliTool* temp = copyActiveTool();
delete this->Tool; delete this->Tool;
this->Tool = temp; this->Tool = temp;
@@ -292,7 +292,7 @@ void PaintingArea::mouseReleaseEvent(QMouseEvent*event){
} }
void PaintingArea::wheelEvent(QWheelEvent*event){ void PaintingArea::wheelEvent(QWheelEvent*event){
if(this->Tool != nullptr){ if(this->Tool != nullptr) {
QPoint numDegrees = event->angleDelta() / 8; QPoint numDegrees = event->angleDelta() / 8;
if(!numDegrees.isNull()) { if(!numDegrees.isNull()) {
QPoint numSteps = numDegrees / 15; QPoint numSteps = numDegrees / 15;
@@ -387,7 +387,7 @@ void PaintingArea::createTempTopLayer(int idx){
} }
IntelliTool* PaintingArea::copyActiveTool(){ IntelliTool* PaintingArea::copyActiveTool(){
switch(Tool->getTooltype()){ switch(Tool->getTooltype()) {
case IntelliTool::Tooltype::CIRCLE: return new IntelliToolCircle(this,&colorPicker, &Toolsettings); case IntelliTool::Tooltype::CIRCLE: return new IntelliToolCircle(this,&colorPicker, &Toolsettings);
case IntelliTool::Tooltype::FLOODFILL: return new IntelliToolFloodFill(this,&colorPicker, &Toolsettings); case IntelliTool::Tooltype::FLOODFILL: return new IntelliToolFloodFill(this,&colorPicker, &Toolsettings);
case IntelliTool::Tooltype::LINE: return new IntelliToolLine(this,&colorPicker, &Toolsettings); case IntelliTool::Tooltype::LINE: return new IntelliToolLine(this,&colorPicker, &Toolsettings);

View File

@@ -81,10 +81,10 @@ public:
* \param type - Defining the ImageType of the new layer * \param type - Defining the ImageType of the new layer
* \return Returns the number of layers in the project * \return Returns the number of layers in the project
*/ */
int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, IntelliImage::ImageType type = IntelliImage::ImageType::Raster_Image); int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, IntelliImage::ImageType type = IntelliImage::ImageType::RASTERIMAGE);
/*! /*!
* \brief The addLayerAt adds a layer to the current project/ painting area at a specific position in the layer stack * \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 width - Width of the layer in pixles
* \param height - Height 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 * \param widthOffset - Offset of the layer measured to the left border of the painting area in pixles
@@ -92,23 +92,23 @@ public:
* \param type - Defining the ImageType of the new layer * \param type - Defining the ImageType of the new layer
* \return Returns the id of the layer position * \return Returns the id of the layer position
*/ */
int addLayerAt(int idx, int width, int height, int widthOffset=0, int heightOffset=0, IntelliImage::ImageType type = IntelliImage::ImageType::Raster_Image); int addLayerAt(int idx, int width, int height, int widthOffset=0, int heightOffset=0, IntelliImage::ImageType type = IntelliImage::ImageType::RASTERIMAGE);
/*! /*!
* \brief The deleteLayer method removes a layer at a given index * \brief The deleteLayer method removes a layer at a given idx
* \param index - The index of the layer to be removed * \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 * \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 * \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 * \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 * \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 * \param r - Red value of the color the layer should be filled with
@@ -125,7 +125,7 @@ public:
void movePositionActive(int x, int y); void movePositionActive(int x, int y);
/*! /*!
* \brief The moveActiveLayer moves the active layer to a specific position in the layer stack * \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); void moveActiveLayer(int idx);
@@ -178,7 +178,7 @@ public slots:
// Events to handle // Events to handle
/*! /*!
* \brief The slotActivateLayer method handles the event of selecting one layer as active * \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); void slotActivateLayer(int a);
/*! /*!

View File

@@ -13,7 +13,7 @@ class PaintingArea;
*/ */
class IntelliTool { class IntelliTool {
public: public:
enum class Tooltype{ enum class Tooltype {
CIRCLE, CIRCLE,
FLOODFILL, FLOODFILL,
LINE, LINE,
@@ -21,7 +21,7 @@ public:
PLAIN, PLAIN,
POLYGON, POLYGON,
RECTANGLE RECTANGLE
}; };
private: private:
/*! /*!
* \brief A function that creates a layer to draw on. * \brief A function that creates a layer to draw on.

View File

@@ -13,18 +13,18 @@ IntelliToolPolygon::IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* c
} }
IntelliToolPolygon::~IntelliToolPolygon(){ IntelliToolPolygon::~IntelliToolPolygon(){
if(isDrawing){ if(isDrawing) {
IntelliTool::onMouseRightPressed(0,0); IntelliTool::onMouseRightPressed(0,0);
} }
} }
void IntelliToolPolygon::onMouseLeftPressed(int x, int y){ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::Shaped_Image && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()){ if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::SHAPEDIMAGE && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()) {
std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(Area->getPolygonDataOfRealLayer()); std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(Area->getPolygonDataOfRealLayer());
QPoint Point(x,y); QPoint Point(x,y);
isInside = IntelliTriangulation::isInPolygon(Triangles,Point); isInside = IntelliTriangulation::isInPolygon(Triangles,Point);
} }
else if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::Raster_Image && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()){ else if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::RASTERIMAGE && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()) {
isInside = true; isInside = true;
} }
@@ -39,7 +39,7 @@ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
this->Canvas->image->calculateVisiblity(); this->Canvas->image->calculateVisiblity();
} }
else if(isDrawing && isNearStart(x,y,QPointList.front())) { else if(isDrawing && isNearStart(x,y,QPointList.front())) {
if(QPointList.size() > 2){ if(QPointList.size() > 2) {
isPointNearStart = true; isPointNearStart = true;
this->Canvas->image->drawLine(QPointList.back(), QPointList.front(), colorPicker->getFirstColor(), Toolsettings->getLineWidth()); this->Canvas->image->drawLine(QPointList.back(), QPointList.front(), colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->Canvas->image->calculateVisiblity(); this->Canvas->image->calculateVisiblity();