This commit is contained in:
Jan Schuffenhauer
2020-01-09 14:03:04 +01:00
6 changed files with 79 additions and 82 deletions

View File

@@ -10,7 +10,7 @@ src/IntelliHelper/IntelliColorPicker.cpp:5:3: performance: Variable 'secondColor
src/IntelliHelper/IntelliTriangulation.cpp:116:63: style: Parameter 'triangles' can be declared with const [constParameter] src/IntelliHelper/IntelliTriangulation.cpp:116:63: style: Parameter 'triangles' can be declared with const [constParameter]
bool IntelliTriangulation::isInPolygon(std::vector<Triangle> &triangles, QPoint &point){ 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] src/Layer/PaintingArea.cpp:335:22: style: Redundant condition: If 'activeLayer > 0', the comparison 'activeLayer != -1' is always true. [redundantCondition]
if(activeLayer!=-1 && activeLayer>0) { if(activeLayer!=-1 && activeLayer>0) {
^ ^
src/Tool/IntelliTool.cpp:4:14: warning: Member variable 'IntelliTool::ActiveType' is not initialized in the constructor. [uninitMemberVar] src/Tool/IntelliTool.cpp:4:14: warning: Member variable 'IntelliTool::ActiveType' is not initialized in the constructor. [uninitMemberVar]
@@ -58,28 +58,25 @@ bool isDrawing;
src/GUI/IntelliPhotoGui.cpp:23:0: style: The function 'closeEvent' is never used. [unusedFunction] 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:271:0: style: The function 'mouseMoveEvent' is never used. [unusedFunction]
^ ^
src/Layer/PaintingArea.cpp:269:0: style: The function 'mouseMoveEvent' is never used. [unusedFunction] src/Layer/PaintingArea.cpp:255:0: style: The function 'mousePressEvent' is never used. [unusedFunction]
^ ^
src/Layer/PaintingArea.cpp:253:0: style: The function 'mousePressEvent' is never used. [unusedFunction] src/Layer/PaintingArea.cpp:281:0: style: The function 'mouseReleaseEvent' is never used. [unusedFunction]
^ ^
src/Layer/PaintingArea.cpp:279:0: style: The function 'mouseReleaseEvent' is never used. [unusedFunction] src/Layer/PaintingArea.cpp:307:0: style: The function 'paintEvent' is never used. [unusedFunction]
^ ^
src/Layer/PaintingArea.cpp:305:0: style: The function 'paintEvent' is never used. [unusedFunction] src/Layer/PaintingArea.cpp:318:0: style: The function 'resizeEvent' is never used. [unusedFunction]
^ ^
src/Layer/PaintingArea.cpp:316:0: style: The function 'resizeEvent' is never used. [unusedFunction] src/Layer/PaintingArea.cpp:323:0: style: The function 'resizeLayer' is never used. [unusedFunction]
^ ^
src/Layer/PaintingArea.cpp:321:0: style: The function 'resizeLayer' is never used. [unusedFunction] src/Layer/PaintingArea.cpp:175:0: style: The function 'slotActivateLayer' 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/GUI/IntelliPhotoGui.cpp:157:0: style: The function 'slotClearActiveLayer' is never used. [unusedFunction]
@@ -88,7 +85,7 @@ src/GUI/IntelliPhotoGui.cpp:157:0: style: The function 'slotClearActiveLayer' is
src/Layer/PaintingArea.cpp:83:0: style: The function 'slotDeleteActiveLayer' 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] src/Layer/PaintingArea.cpp:294: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] nofile:0:0: information: Cppcheck cannot find all the include files (use --check-config for details) [missingInclude]

View File

@@ -40,7 +40,7 @@ void IntelliImage::resizeImage(QImage*image, const QSize &newSize){
return; return;
// Create a new image to display and fill it with white // Create a new image to display and fill it with white
QImage newImage(newSize, QImage::Format_ARGB32); QImage newImage(newSize, QImage::Format_ARGB32);
newImage.fill(qRgb(255, 255, 255)); newImage.fill(qRgb(255, 255, 255));
// Draw the image // Draw the image

View File

@@ -14,7 +14,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::RASTERIMAGE; raster->TypeOfImage = IntelliImage::ImageType::RASTERIMAGE;
return raster; return raster;

View File

@@ -19,7 +19,7 @@ QImage IntelliShapedImage::getDisplayable(int alpha){
} }
IntelliImage* IntelliShapedImage::getDeepCopy(){ 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::SHAPEDIMAGE; shaped->TypeOfImage = IntelliImage::ImageType::SHAPEDIMAGE;
@@ -31,7 +31,7 @@ void IntelliShapedImage::calculateVisiblity(){
this->imageData = imageData.convertToFormat(QImage::Format_ARGB32); this->imageData = imageData.convertToFormat(QImage::Format_ARGB32);
} }
if(polygonData.size()<=2) { if(polygonData.size()<=2) {
QColor clr; QColor clr;
for(int y=0; y<imageData.height(); y++) { for(int y=0; y<imageData.height(); y++) {
for(int x=0; x<imageData.width(); x++) { for(int x=0; x<imageData.width(); x++) {
@@ -50,7 +50,7 @@ void IntelliShapedImage::calculateVisiblity(){
for(int x=0; x<imageData.width(); x++) { for(int x=0; x<imageData.width(); x++) {
QPoint ptr(x,y); QPoint ptr(x,y);
clr = imageData.pixelColor(x,y); clr = imageData.pixelColor(x,y);
bool isInPolygon = IntelliTriangulation::isInPolygon(triangles, ptr); bool isInPolygon = IntelliTriangulation::isInPolygon(triangles, ptr);
if(isInPolygon) { if(isInPolygon) {
clr.setAlpha(std::min(255, clr.alpha())); clr.setAlpha(std::min(255, clr.alpha()));
}else{ }else{
@@ -90,7 +90,7 @@ void IntelliShapedImage::setPolygon(const std::vector<QPoint>& polygonData){
for(auto element:polygonData) { for(auto element:polygonData) {
this->polygonData.push_back(QPoint(element.x(), element.y())); this->polygonData.push_back(QPoint(element.x(), element.y()));
} }
triangles = IntelliTriangulation::calculateTriangles(polygonData); triangles = IntelliTriangulation::calculateTriangles(polygonData);
} }
calculateVisiblity(); calculateVisiblity();
return; return;

View File

@@ -21,21 +21,21 @@
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent) 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::SHAPEDIMAGE); 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));
//polygon.push_back(QPoint(200,100)); polygon.push_back(QPoint(200,100));
//polygon.push_back(QPoint(100,200)); polygon.push_back(QPoint(100,200));
//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::RASTERIMAGE);
//layerBundle[1].image->drawPlain(QColor(0,255,0,255));
//layerBundle[1].alpha=200;
activeLayer=-1; this->addLayer(200,200,150,150,IntelliImage::ImageType::RASTERIMAGE);
layerBundle[1].image->drawPlain(QColor(0,255,0,255));
layerBundle[1].alpha=200;
activeLayer=0;
} }
PaintingArea::~PaintingArea(){ PaintingArea::~PaintingArea(){
@@ -170,13 +170,13 @@ void PaintingArea::movePositionActive(int x, int y){
} }
void PaintingArea::moveActiveLayer(int idx){ void PaintingArea::moveActiveLayer(int idx){
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;
} }
} }
if(idx==1) { if(idx==1) {
this->selectLayerUp(); this->selectLayerUp();
}else if(idx==-1) { }else if(idx==-1) {

View File

@@ -22,13 +22,13 @@
* \param widthOffset - Stores the number of pixles from the left side of the painting area * \param widthOffset - Stores the number of pixles from the left side of the painting area
* \param heightOffset - Stores the number of pixles from the top of the painting area * \param heightOffset - Stores the number of pixles from the top of the painting area
*/ */
struct LayerObject{ struct LayerObject {
IntelliImage* image; IntelliImage* image;
int width; int width;
int height; int height;
int widthOffset; int widthOffset;
int heightOffset; int heightOffset;
int alpha=255; int alpha=255;
}; };
/*! /*!
@@ -36,12 +36,12 @@ struct LayerObject{
*/ */
class PaintingArea : public QWidget class PaintingArea : public QWidget
{ {
// Declares our class as a QObject which is the base class // Declares our class as a QObject which is the base class
// for all Qt objects // for all Qt objects
// QObjects handle events // QObjects handle events
Q_OBJECT Q_OBJECT
friend IntelliTool; friend IntelliTool;
friend IntelliPhotoGui; friend IntelliPhotoGui;
public: public:
/*! /*!
* \brief PaintingArea is the constructor of the PaintingArea class, which initiates the working environment * \brief PaintingArea is the constructor of the PaintingArea class, which initiates the working environment
@@ -181,50 +181,50 @@ public:
IntelliColorPicker colorPicker; IntelliColorPicker colorPicker;
public slots: 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 - idx of the layer to be active * \param a - idx of the layer to be active
*/ */
void slotActivateLayer(int a); void slotActivateLayer(int a);
/*! /*!
* \brief The slotDeleteActiveLayer method handles the deletion of the active layer * \brief The slotDeleteActiveLayer method handles the deletion of the active layer
*/ */
void slotDeleteActiveLayer(); void slotDeleteActiveLayer();
protected: protected:
void mousePressEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent*event) override;
void mouseMoveEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent*event) override;
void mouseReleaseEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent*event) override;
void wheelEvent(QWheelEvent *event) override; void wheelEvent(QWheelEvent*event) override;
// Updates the painting area where we are painting // Updates the painting area where we are painting
void paintEvent(QPaintEvent *event) override; void paintEvent(QPaintEvent*event) override;
// Makes sure the area we are drawing on remains // Makes sure the area we are drawing on remains
// as large as the widget // as large as the widget
void resizeEvent(QResizeEvent *event) override; void resizeEvent(QResizeEvent*event) override;
private: private:
void setLayerDimensions(int maxWidth, int maxHeight); void setLayerDimensions(int maxWidth, int maxHeight);
void selectLayerUp(); void selectLayerUp();
void selectLayerDown(); void selectLayerDown();
IntelliTool* copyActiveTool(); IntelliTool* copyActiveTool();
QImage* Canvas; QImage* Canvas;
int maxWidth; int maxWidth;
int maxHeight; int maxHeight;
IntelliRenderSettings renderSettings; IntelliRenderSettings renderSettings;
IntelliTool* Tool; IntelliTool* Tool;
IntelliPhotoGui* DummyGui; IntelliPhotoGui* DummyGui;
std::vector<LayerObject> layerBundle; std::vector<LayerObject> layerBundle;
int activeLayer=-1; int activeLayer=-1;
void drawLayers(bool forSaving=false); void drawLayers(bool forSaving=false);
void resizeLayer(QImage *image_res, const QSize &newSize); void resizeLayer(QImage*image_res, const QSize &newSize);
// Helper for Tool // Helper for Tool
bool createTempTopLayer(int idx); bool createTempTopLayer(int idx);