Uncrustified Commits and Updated Errors

This commit is contained in:
2020-01-15 14:48:50 +01:00
parent 1f0b856079
commit cf3c542250
6 changed files with 205 additions and 214 deletions

View File

@@ -1,6 +1,3 @@
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] 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}; firstColor = {255,0,0,255};
^ ^
@@ -10,9 +7,9 @@ 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:335:22: style: Redundant condition: If 'activeLayer > 0', the comparison 'activeLayer != -1' is always true. [redundantCondition] src/Layer/PaintingArea.cpp:334:28: 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]
IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings){ IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings){
^ ^
@@ -22,34 +19,31 @@ IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker, In
src/Tool/IntelliTool.cpp:4:14: warning: Member variable 'IntelliTool::Canvas' is not initialized in the constructor. [uninitMemberVar] 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){ IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings){
^ ^
src/Tool/IntelliToolCircle.cpp:43:9: style: Local variable 'yMin' shadows outer variable [shadowVariable] src/Tool/IntelliToolCircle.cpp:42: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))); 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 src/Tool/IntelliToolCircle.cpp:18:7: note: Shadowed declaration
int yMin, yMax, xMin, xMax; int yMin, yMax, xMin, xMax;
^ ^
src/Tool/IntelliToolCircle.cpp:43:9: note: Shadow variable src/Tool/IntelliToolCircle.cpp:42:9: note: Shadow variable
int yMin = static_cast<int>(centerPoint.y()-sqrt(pow(radius,2)-pow(i-centerPoint.x(),2))); 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] src/Tool/IntelliToolCircle.cpp:43: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))); 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 src/Tool/IntelliToolCircle.cpp:18:13: note: Shadowed declaration
int yMin, yMax, xMin, xMax; int yMin, yMax, xMin, xMax;
^ ^
src/Tool/IntelliToolCircle.cpp:44:9: note: Shadow variable src/Tool/IntelliToolCircle.cpp:43:9: note: Shadow variable
int yMax = static_cast<int>(centerPoint.y()+sqrt(pow(radius,2)-pow(i-centerPoint.x(),2))); 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] 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; 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] 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; bool isDrawing;
^ ^
src/Tool/IntelliTool.h:68:6: note: Parent variable 'IntelliTool::isDrawing' src/Tool/IntelliTool.h:69:6: note: Parent variable 'IntelliTool::isDrawing'
bool isDrawing = false; bool isDrawing = false;
^ ^
src/Tool/IntelliToolPolygon.h:25:6: note: Derived variable 'IntelliToolPolygon::isDrawing' src/Tool/IntelliToolPolygon.h:25:6: note: Derived variable 'IntelliToolPolygon::isDrawing'
@@ -58,34 +52,31 @@ 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/Layer/PaintingArea.cpp:271:0: style: The function 'mouseMoveEvent' is never used. [unusedFunction] src/Layer/PaintingArea.cpp:261: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:242: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:274: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:304: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:315: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:320: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:168: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:88: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:289: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

@@ -85,34 +85,34 @@ void IntelliPhotoGui::slotCreateNewRasterLayer(){
200,1, 500, 1, &ok2); 200,1, 500, 1, &ok2);
// Create New Layer // Create New Layer
if (ok1&&ok2) { if (ok1&&ok2) {
paintingArea->addLayer(width,height,0,0,IntelliImage::ImageType::RASTERIMAGE); paintingArea->addLayer(width,height,0,0,IntelliImage::ImageType::RASTERIMAGE);
UpdateGui(); UpdateGui();
} }
} }
// Opens a dialog that allows the user to create a New SHAPED Layer // Opens a dialog that allows the user to create a New SHAPED Layer
void IntelliPhotoGui::slotCreateNewShapedLayer(){ void IntelliPhotoGui::slotCreateNewShapedLayer(){
// Stores button value // Stores button value
bool ok1, ok2; bool ok1, ok2;
// "New Layer" is the title of the window // "New Layer" is the title of the window
// the next tr is the text to display // the next tr is the text to display
// Define the standard Value, min, max, step and ok button // Define the standard Value, min, max, step and ok button
QInputDialog Input; QInputDialog Input;
Input.setPalette(Palette); Input.setPalette(Palette);
int width = Input.getInt(this, tr("New Layer"), int width = Input.getInt(this, tr("New Layer"),
tr("Width:"), tr("Width:"),
200,1, 500, 1, &ok1); 200,1, 500, 1, &ok1);
int height = QInputDialog::getInt(this, tr("New Layer"), int height = QInputDialog::getInt(this, tr("New Layer"),
tr("Height:"), tr("Height:"),
200,1, 500, 1, &ok2); 200,1, 500, 1, &ok2);
// Create New Layer // Create New Layer
if (ok1&&ok2) { if (ok1&&ok2) {
paintingArea->addLayer(width,height,0,0,IntelliImage::ImageType::SHAPEDIMAGE); paintingArea->addLayer(width,height,0,0,IntelliImage::ImageType::SHAPEDIMAGE);
UpdateGui(); UpdateGui();
} }
} }
// Opens a dialog that allows the user to delete a Layer // Opens a dialog that allows the user to delete a Layer
@@ -155,21 +155,21 @@ void IntelliPhotoGui::slotSetActiveAlpha(){
} }
void IntelliPhotoGui::slotSetPolygon(){ void IntelliPhotoGui::slotSetPolygon(){
// Stores button value // Stores button value
bool ok1; bool ok1;
// "Layer to set on" is the title of the window // "Layer to set on" is the title of the window
// the next tr is the text to display // the next tr is the text to display
// Define the standard Value, min, max, step and ok button // Define the standard Value, min, max, step and ok button
int layer = QInputDialog::getInt(this, tr("Layer to set on"), int layer = QInputDialog::getInt(this, tr("Layer to set on"),
tr("Layer:"), tr("Layer:"),
1,1,500,1, &ok1); 1,1,500,1, &ok1);
if (ok1) if (ok1)
{ {
paintingArea->setPolygon(layer-1); paintingArea->setPolygon(layer-1);
UpdateGui(); UpdateGui();
} }
} }
void IntelliPhotoGui::slotPositionMoveUp(){ void IntelliPhotoGui::slotPositionMoveUp(){
@@ -357,16 +357,16 @@ void IntelliPhotoGui::createActions(){
actionOpen->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O)); actionOpen->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
connect(actionOpen, SIGNAL(triggered()), this, SLOT(slotOpen())); connect(actionOpen, SIGNAL(triggered()), this, SLOT(slotOpen()));
// Create New RASTER Layer action and tie to IntelliPhotoGui::newLayer() // Create New RASTER Layer action and tie to IntelliPhotoGui::newLayer()
actionCreateNewRasterLayer = new QAction(tr("&Raster Image"), this); actionCreateNewRasterLayer = new QAction(tr("&Raster Image"), this);
actionCreateNewRasterLayer->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N)); actionCreateNewRasterLayer->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N));
connect(actionCreateNewRasterLayer, SIGNAL(triggered()), this, SLOT(slotCreateNewRasterLayer())); connect(actionCreateNewRasterLayer, SIGNAL(triggered()), this, SLOT(slotCreateNewRasterLayer()));
// Create New SHAPED Layer action and tie to IntelliPhotoGui::newLayer() // Create New SHAPED Layer action and tie to IntelliPhotoGui::newLayer()
actionCreateNewShapedLayer = new QAction(tr("&Shaped Image"), this); actionCreateNewShapedLayer = new QAction(tr("&Shaped Image"), this);
actionCreateNewShapedLayer->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N + Qt::ALT)); actionCreateNewShapedLayer->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N + Qt::ALT));
connect(actionCreateNewShapedLayer, SIGNAL(triggered()), this, SLOT(slotCreateNewShapedLayer())); connect(actionCreateNewShapedLayer, SIGNAL(triggered()), this, SLOT(slotCreateNewShapedLayer()));
// Delete New Layer action and tie to IntelliPhotoGui::deleteLayer() // Delete New Layer action and tie to IntelliPhotoGui::deleteLayer()
actionDeleteLayer = new QAction(tr("&Delete Layer..."), this); actionDeleteLayer = new QAction(tr("&Delete Layer..."), this);
@@ -381,9 +381,9 @@ void IntelliPhotoGui::createActions(){
actionSetActiveAlpha->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_A)); actionSetActiveAlpha->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_A));
connect(actionSetActiveAlpha, SIGNAL(triggered()), this, SLOT(slotSetActiveAlpha())); connect(actionSetActiveAlpha, SIGNAL(triggered()), this, SLOT(slotSetActiveAlpha()));
actionSetPolygon = new QAction(tr("&set new Polygondata"), this); actionSetPolygon = new QAction(tr("&set new Polygondata"), this);
actionSetPolygon->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_P)); actionSetPolygon->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_P));
connect(actionSetPolygon, SIGNAL(triggered()), this, SLOT(slotSetPolygon())); connect(actionSetPolygon, SIGNAL(triggered()), this, SLOT(slotSetPolygon()));
actionMovePositionUp = new QAction(tr("&move Up"), this); actionMovePositionUp = new QAction(tr("&move Up"), this);
actionMovePositionUp->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Up)); actionMovePositionUp->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Up));
@@ -534,17 +534,17 @@ void IntelliPhotoGui::createMenus(){
renderMenu->addAction(actionUpdateRenderSettingsOn); renderMenu->addAction(actionUpdateRenderSettingsOn);
renderMenu->addAction(actionUpdateRenderSettingsOff); renderMenu->addAction(actionUpdateRenderSettingsOff);
//Attach all Layer Creations to Menu //Attach all Layer Creations to Menu
layerCreationMenu = new QMenu(tr("&Create new Layer"), this); layerCreationMenu = new QMenu(tr("&Create new Layer"), this);
layerCreationMenu->addAction(actionCreateNewRasterLayer); layerCreationMenu->addAction(actionCreateNewRasterLayer);
layerCreationMenu->addAction(actionCreateNewShapedLayer); layerCreationMenu->addAction(actionCreateNewShapedLayer);
// Attach all actions to Layer // Attach all actions to Layer
layerMenu = new QMenu(tr("&Layer"), this); layerMenu = new QMenu(tr("&Layer"), this);
layerMenu->addMenu(layerCreationMenu); layerMenu->addMenu(layerCreationMenu);
layerMenu->addSeparator(); layerMenu->addSeparator();
layerMenu->addAction(actionSetActiveAlpha); layerMenu->addAction(actionSetActiveAlpha);
layerMenu->addAction(actionSetActiveLayer); layerMenu->addAction(actionSetActiveLayer);
layerMenu->addAction(actionSetPolygon); layerMenu->addAction(actionSetPolygon);
layerMenu->addSeparator(); layerMenu->addSeparator();
layerMenu->addAction(actionMovePositionUp); layerMenu->addAction(actionMovePositionUp);
layerMenu->addAction(actionMovePositionDown); layerMenu->addAction(actionMovePositionDown);
@@ -759,7 +759,7 @@ void IntelliPhotoGui::setIntelliStyle(){
this->helpMenu->setPalette(Palette); this->helpMenu->setPalette(Palette);
this->renderMenu->setPalette(Palette); this->renderMenu->setPalette(Palette);
this->toolMenu->setPalette(Palette); this->toolMenu->setPalette(Palette);
this->layerCreationMenu->setPalette(Palette); this->layerCreationMenu->setPalette(Palette);
this->layerMenu->setPalette(Palette); this->layerMenu->setPalette(Palette);
this->colorMenu->setPalette(Palette); this->colorMenu->setPalette(Palette);
this->toolCreationMenu->setPalette(Palette); this->toolCreationMenu->setPalette(Palette);

View File

@@ -27,17 +27,17 @@ IntelliImage* IntelliShapedImage::getDeepCopy(){
} }
void IntelliShapedImage::calculateVisiblity(){ void IntelliShapedImage::calculateVisiblity(){
if(polygonData.size()<2){ if(polygonData.size()<2) {
return; return;
} }
if(fastRenderering) { if(fastRenderering) {
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++) {
clr = imageData.pixel(x,y); clr = imageData.pixel(x,y);
clr.setAlpha(255); clr.setAlpha(255);
imageData.setPixelColor(x,y,clr); imageData.setPixelColor(x,y,clr);
@@ -55,7 +55,7 @@ void IntelliShapedImage::calculateVisiblity(){
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{
clr.setAlpha(0); clr.setAlpha(0);
} }
@@ -94,19 +94,19 @@ void IntelliShapedImage::setPolygon(const std::vector<QPoint>& 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);
if(fastRenderering){ if(fastRenderering) {
imageData = imageData.convertToFormat(QImage::Format_ARGB32); imageData = imageData.convertToFormat(QImage::Format_ARGB32);
} }
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++) {
QColor clr = imageData.pixelColor(x,y); QColor clr = imageData.pixelColor(x,y);
clr.setAlpha(255); clr.setAlpha(255);
imageData.setPixelColor(x,y,clr); imageData.setPixelColor(x,y,clr);
} }
} }
if(fastRenderering){ if(fastRenderering) {
imageData = imageData.convertToFormat(QImage::Format_Indexed8); imageData = imageData.convertToFormat(QImage::Format_Indexed8);
} }
} }
calculateVisiblity(); calculateVisiblity();
return; return;

View File

@@ -24,7 +24,7 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent)
this->Tool = nullptr; this->Tool = nullptr;
this->setLayerDimensions(maxWidth, maxHeight); this->setLayerDimensions(maxWidth, maxHeight);
activeLayer=-1; activeLayer=-1;
} }
PaintingArea::~PaintingArea(){ PaintingArea::~PaintingArea(){
@@ -53,7 +53,7 @@ void PaintingArea::setLayerDimensions(int maxWidth, int maxHeight){
int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOffset, IntelliImage::ImageType type){ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOffset, IntelliImage::ImageType type){
LayerObject newLayer; LayerObject newLayer;
updateTools(); updateTools();
newLayer.width = width; newLayer.width = width;
newLayer.height = height; newLayer.height = height;
newLayer.widthOffset = widthOffset; newLayer.widthOffset = widthOffset;
@@ -71,9 +71,9 @@ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOff
void PaintingArea::deleteLayer(int idx, bool isTool){ void PaintingArea::deleteLayer(int idx, bool isTool){
if(!isTool){ if(!isTool) {
updateTools(); updateTools();
} }
if(idx<static_cast<int>(layerBundle.size())) { if(idx<static_cast<int>(layerBundle.size())) {
this->layerBundle.erase(layerBundle.begin()+idx); this->layerBundle.erase(layerBundle.begin()+idx);
if(activeLayer>=idx) { if(activeLayer>=idx) {
@@ -93,8 +93,8 @@ void PaintingArea::slotDeleteActiveLayer(){
} }
void PaintingArea::setLayerActive(int idx){ void PaintingArea::setLayerActive(int idx){
updateTools(); updateTools();
if(idx>=0&&idx<static_cast<int>(layerBundle.size())) { if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
this->activeLayer=idx; this->activeLayer=idx;
} }
} }
@@ -105,13 +105,13 @@ void PaintingArea::setLayerAlpha(int idx, int alpha){
} }
} }
void PaintingArea::setPolygon(int idx){ void PaintingArea::setPolygon(int idx){
if(idx>=0&&idx<static_cast<int>(layerBundle.size())) { if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
if(layerBundle[static_cast<size_t>(idx)].image->getTypeOfImage()==IntelliImage::ImageType::SHAPEDIMAGE){ if(layerBundle[static_cast<size_t>(idx)].image->getTypeOfImage()==IntelliImage::ImageType::SHAPEDIMAGE) {
delete this->Tool; delete this->Tool;
this->Tool = new IntelliToolPolygon(this,&colorPicker,&Toolsettings, true); this->Tool = new IntelliToolPolygon(this,&colorPicker,&Toolsettings, true);
isSettingPolygon = true; isSettingPolygon = true;
} }
} }
} }
// Used to load the image and place it in the widget // Used to load the image and place it in the widget
@@ -151,13 +151,13 @@ bool PaintingArea::save(const QString &filePath, const char*fileFormat){
} }
void PaintingArea::movePositionActive(int x, int y){ void PaintingArea::movePositionActive(int x, int y){
updateTools(); updateTools();
layerBundle[static_cast<size_t>(activeLayer)].widthOffset += x; layerBundle[static_cast<size_t>(activeLayer)].widthOffset += x;
layerBundle[static_cast<size_t>(activeLayer)].heightOffset += y; layerBundle[static_cast<size_t>(activeLayer)].heightOffset += y;
} }
void PaintingArea::moveActiveLayer(int idx){ void PaintingArea::moveActiveLayer(int idx){
updateTools(); updateTools();
if(idx==1) { if(idx==1) {
this->selectLayerUp(); this->selectLayerUp();
}else if(idx==-1) { }else if(idx==-1) {
@@ -166,8 +166,8 @@ void PaintingArea::moveActiveLayer(int idx){
} }
void PaintingArea::slotActivateLayer(int a){ void PaintingArea::slotActivateLayer(int a){
updateTools(); updateTools();
if(a>=0 && a < static_cast<int>(layerBundle.size())) { if(a>=0 && a < static_cast<int>(layerBundle.size())) {
this->setLayerActive(a); this->setLayerActive(a);
} }
} }
@@ -322,16 +322,16 @@ void PaintingArea::resizeLayer(QImage*image_res, const QSize &newSize){
} }
void PaintingArea::selectLayerUp(){ void PaintingArea::selectLayerUp(){
updateTools(); updateTools();
if(activeLayer!=-1 && static_cast<unsigned long long>(activeLayer)<layerBundle.size()-1) { if(activeLayer!=-1 && static_cast<unsigned long long>(activeLayer)<layerBundle.size()-1) {
std::swap(layerBundle[static_cast<unsigned long long>(activeLayer)], layerBundle[static_cast<unsigned long long>(activeLayer+1)]); std::swap(layerBundle[static_cast<unsigned long long>(activeLayer)], layerBundle[static_cast<unsigned long long>(activeLayer+1)]);
activeLayer++; activeLayer++;
} }
} }
void PaintingArea::selectLayerDown(){ void PaintingArea::selectLayerDown(){
updateTools(); updateTools();
if(activeLayer!=-1 && activeLayer>0) { if(activeLayer!=-1 && activeLayer>0) {
std::swap(layerBundle[static_cast<unsigned long long>(activeLayer)], layerBundle[static_cast<unsigned long long>(activeLayer-1)]); std::swap(layerBundle[static_cast<unsigned long long>(activeLayer)], layerBundle[static_cast<unsigned long long>(activeLayer-1)]);
activeLayer--; activeLayer--;
} }
@@ -408,35 +408,35 @@ IntelliImage* PaintingArea::getImageOfActiveLayer(){
if(activeLayer<0) { if(activeLayer<0) {
return nullptr; return nullptr;
} }
return layerBundle[static_cast<size_t>(activeLayer)].image; return layerBundle[static_cast<size_t>(activeLayer)].image;
} }
QImage PaintingArea::getImageDataOfActiveLayer(){ QImage PaintingArea::getImageDataOfActiveLayer(){
QImage returnImage; QImage returnImage;
if(activeLayer<0) { if(activeLayer<0) {
returnImage = QImage(QSize(10,10),QImage::Format_ARGB32); returnImage = QImage(QSize(10,10),QImage::Format_ARGB32);
returnImage.fill(QColor(255,255,255,255)); returnImage.fill(QColor(255,255,255,255));
} }
else{ else{
returnImage = layerBundle[static_cast<size_t>(activeLayer)].image->getImageData(); returnImage = layerBundle[static_cast<size_t>(activeLayer)].image->getImageData();
if(renderSettings.isFastRenderering()){ if(renderSettings.isFastRenderering()) {
returnImage = returnImage.convertToFormat(QImage::Format_ARGB32); returnImage = returnImage.convertToFormat(QImage::Format_ARGB32);
} }
} }
return returnImage; return returnImage;
} }
void PaintingArea::updateTools(){ void PaintingArea::updateTools(){
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(isSettingPolygon){ if(isSettingPolygon) {
delete this->Tool; delete this->Tool;
this->Tool = nullptr; this->Tool = nullptr;
isSettingPolygon = false; isSettingPolygon = false;
} }
} }
} }

View File

@@ -32,8 +32,8 @@ void IntelliTool::onMouseLeftPressed(int x, int y){
void IntelliTool::onMouseLeftReleased(int x, int y){ void IntelliTool::onMouseLeftReleased(int x, int y){
if(isDrawing) { if(isDrawing) {
isDrawing=false; isDrawing=false;
this->mergeToolLayer(); this->mergeToolLayer();
this->deleteToolLayer(); this->deleteToolLayer();
activeLayer->image->calculateVisiblity(); activeLayer->image->calculateVisiblity();
@@ -63,32 +63,32 @@ void IntelliTool::mergeToolLayer(){
QColor clr_1; QColor clr_1;
QImage updatedImage = activeLayer->image->getImageData(); QImage updatedImage = activeLayer->image->getImageData();
for(int y=0; y<activeLayer->height; y++) { for(int y=0; y<activeLayer->height; y++) {
for(int x=0; x<activeLayer->width; x++) { for(int x=0; x<activeLayer->width; x++) {
clr_0=updatedImage.pixelColor(x,y); clr_0=updatedImage.pixelColor(x,y);
clr_1=Canvas->image->imageData.pixelColor(x,y); clr_1=Canvas->image->imageData.pixelColor(x,y);
float t = static_cast<float>(clr_1.alpha())/255.f; float t = static_cast<float>(clr_1.alpha())/255.f;
int r =static_cast<int>(static_cast<float>(clr_1.red())*(t)+static_cast<float>(clr_0.red())*(1.f-t)+0.5f); int r =static_cast<int>(static_cast<float>(clr_1.red())*(t)+static_cast<float>(clr_0.red())*(1.f-t)+0.5f);
int g =static_cast<int>(static_cast<float>(clr_1.green())*(t)+static_cast<float>(clr_0.green())*(1.f-t)+0.5f); int g =static_cast<int>(static_cast<float>(clr_1.green())*(t)+static_cast<float>(clr_0.green())*(1.f-t)+0.5f);
int b =static_cast<int>(static_cast<float>(clr_1.blue())*(t)+static_cast<float>(clr_0.blue()*(1.f-t))+0.5f); int b =static_cast<int>(static_cast<float>(clr_1.blue())*(t)+static_cast<float>(clr_0.blue()*(1.f-t))+0.5f);
int a =std::min(clr_0.alpha()+clr_1.alpha(), 255); int a =std::min(clr_0.alpha()+clr_1.alpha(), 255);
clr_0.setRed(r); clr_0.setRed(r);
clr_0.setGreen(g); clr_0.setGreen(g);
clr_0.setBlue(b); clr_0.setBlue(b);
clr_0.setAlpha(a); clr_0.setAlpha(a);
updatedImage.setPixelColor(x, y, clr_0); updatedImage.setPixelColor(x, y, clr_0);
} }
} }
activeLayer->image->setImageData(updatedImage); activeLayer->image->setImageData(updatedImage);
if(Canvas->image->getPolygonData().size() > 0){ if(Canvas->image->getPolygonData().size() > 0) {
activeLayer->image->setPolygon(Canvas->image->getPolygonData()); activeLayer->image->setPolygon(Canvas->image->getPolygonData());
} }
Area->DummyGui->UpdateGui(); Area->DummyGui->UpdateGui();
} }
void IntelliTool::deleteToolLayer(){ void IntelliTool::deleteToolLayer(){
Area->deleteLayer(Area->activeLayer+1, true); Area->deleteLayer(Area->activeLayer+1, true);
this->Canvas=nullptr; this->Canvas=nullptr;
} }

View File

@@ -9,7 +9,7 @@ IntelliToolPolygon::IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* c
isPointNearStart = false; isPointNearStart = false;
isDrawing = false; isDrawing = false;
isInside = false; isInside = false;
this->isSettingPolygon = isSettingPolygon; this->isSettingPolygon = isSettingPolygon;
this->ActiveType = Tooltype::POLYGON; this->ActiveType = Tooltype::POLYGON;
} }
@@ -20,18 +20,18 @@ IntelliToolPolygon::~IntelliToolPolygon(){
} }
void IntelliToolPolygon::onMouseLeftPressed(int x, int y){ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::SHAPEDIMAGE && 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()) {
if(Area->getPolygonDataOfRealLayer().size()>2){ if(Area->getPolygonDataOfRealLayer().size()>2) {
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{ else{
isInside = true; isInside = true;
} }
if(isSettingPolygon){ if(isSettingPolygon) {
isInside = true; isInside = true;
} }
} }
else if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::RASTERIMAGE && 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;
@@ -45,18 +45,18 @@ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
QPointList.push_back(drawingPoint); QPointList.push_back(drawingPoint);
this->Canvas->image->drawPoint(QPointList.back(), colorPicker->getFirstColor(), Toolsettings->getLineWidth()); this->Canvas->image->drawPoint(QPointList.back(), colorPicker->getFirstColor(), Toolsettings->getLineWidth());
if(!isSettingPolygon){ if(!isSettingPolygon) {
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());
if(!isSettingPolygon){ if(!isSettingPolygon) {
this->Canvas->image->calculateVisiblity(); this->Canvas->image->calculateVisiblity();
} }
} }
else{ else{
isInside = false; isInside = false;
isDrawing = false; isDrawing = false;
@@ -69,9 +69,9 @@ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
QPoint drawingPoint(x,y); QPoint drawingPoint(x,y);
QPointList.push_back(drawingPoint); QPointList.push_back(drawingPoint);
this->Canvas->image->drawLine(QPointList[QPointList.size() - 2], QPointList[QPointList.size() - 1], colorPicker->getFirstColor(), Toolsettings->getLineWidth()); this->Canvas->image->drawLine(QPointList[QPointList.size() - 2], QPointList[QPointList.size() - 1], colorPicker->getFirstColor(), Toolsettings->getLineWidth());
if(!isSettingPolygon){ if(!isSettingPolygon) {
this->Canvas->image->calculateVisiblity(); this->Canvas->image->calculateVisiblity();
} }
} }
} }
@@ -88,31 +88,31 @@ void IntelliToolPolygon::onMouseLeftReleased(int x, int y){
isInside = false; isInside = false;
isPointNearStart = false; isPointNearStart = false;
isDrawing = false; isDrawing = false;
if(!isSettingPolygon){ if(!isSettingPolygon) {
std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(QPointList); std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(QPointList);
QPoint Point; QPoint Point;
QColor colorTwo(colorPicker->getSecondColor()); QColor colorTwo(colorPicker->getSecondColor());
colorTwo.setAlpha(Toolsettings->getInnerAlpha()); colorTwo.setAlpha(Toolsettings->getInnerAlpha());
for(int i = 0; i < activeLayer->width; i++) { for(int i = 0; i < activeLayer->width; i++) {
for(int j = 0; j < activeLayer->height; j++) { for(int j = 0; j < activeLayer->height; j++) {
Point = QPoint(i,j); Point = QPoint(i,j);
if(IntelliTriangulation::isInPolygon(Triangles,Point)) { if(IntelliTriangulation::isInPolygon(Triangles,Point)) {
this->Canvas->image->drawPixel(Point, colorTwo); this->Canvas->image->drawPixel(Point, colorTwo);
} }
} }
} }
for(int i=0; i<static_cast<int>(QPointList.size()); i++) { for(int i=0; i<static_cast<int>(QPointList.size()); i++) {
int next = static_cast<int>((i+static_cast<int>(1))%static_cast<int>(QPointList.size())); int next = static_cast<int>((i+static_cast<int>(1))%static_cast<int>(QPointList.size()));
this->Canvas->image->drawLine(QPointList[static_cast<unsigned long long>(i)], QPointList[static_cast<unsigned long long>(next)], colorPicker->getFirstColor(), Toolsettings->getLineWidth()); this->Canvas->image->drawLine(QPointList[static_cast<unsigned long long>(i)], QPointList[static_cast<unsigned long long>(next)], colorPicker->getFirstColor(), Toolsettings->getLineWidth());
} }
} }
else{ else{
Canvas->image->setPolygon(QPointList); Canvas->image->setPolygon(QPointList);
Canvas->image->setImageData(Area->getImageDataOfActiveLayer()); Canvas->image->setImageData(Area->getImageDataOfActiveLayer());
} }
IntelliTool::onMouseLeftReleased(x,y); IntelliTool::onMouseLeftReleased(x,y);
QPointList.clear(); QPointList.clear();
} }
} }