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

@@ -16,7 +16,7 @@ IntelliPhotoGui::IntelliPhotoGui(){
// Size the app
resize(600,600);
showMaximized();
setDefaultToolValue();
setDefaultToolValue();
}
// User tried to close the app
@@ -81,7 +81,7 @@ void IntelliPhotoGui::slotCreateNewLayer(){
if (ok1&&ok2)
{
int layer = paintingArea->addLayer(width,height,0,0);
UpdateGui();
UpdateGui();
}
}
@@ -95,12 +95,12 @@ void IntelliPhotoGui::slotDeleteLayer(){
// Define the standard Value, min, max, step and ok button
int layerNumber = QInputDialog::getInt(this, tr("delete Layer"),
tr("Number:"),
paintingArea->getNumberOfActiveLayer(),0, 500, 1, &ok);
paintingArea->getNumberOfActiveLayer(),0, 500, 1, &ok);
// Create New Layer
if (ok){
if (ok) {
paintingArea->deleteLayer(layerNumber);
UpdateGui();
}
UpdateGui();
}
}
void IntelliPhotoGui::slotSetActiveAlpha(){
@@ -120,7 +120,7 @@ void IntelliPhotoGui::slotSetActiveAlpha(){
if (ok1&&ok2)
{
paintingArea->setLayerAlpha(layer,alpha);
UpdateGui();
UpdateGui();
}
}
@@ -179,7 +179,7 @@ void IntelliPhotoGui::slotClearActiveLayer(){
if (ok1&&ok2&&ok3&&ok4)
{
paintingArea->floodFill(red, green, blue, alpha);
UpdateGui();
UpdateGui();
}
}
@@ -196,57 +196,57 @@ void IntelliPhotoGui::slotSetActiveLayer(){
if (ok1)
{
paintingArea->setLayerActive(layer);
UpdateGui();
UpdateGui();
}
}
void IntelliPhotoGui::slotSetFirstColor(){
paintingArea->colorPickerSetFirstColor();
UpdateGui();
UpdateGui();
}
void IntelliPhotoGui::slotSetSecondColor(){
paintingArea->colorPickerSetSecondColor();
UpdateGui();
UpdateGui();
}
void IntelliPhotoGui::slotSwapColor(){
paintingArea->colorPickerSwapColors();
UpdateGui();
UpdateGui();
}
void IntelliPhotoGui::slotCreatePenTool(){
PenButton->setChecked(true);
PenButton->setChecked(true);
paintingArea->createPenTool();
}
void IntelliPhotoGui::slotCreatePlainTool(){
PlainButton->setChecked(true);
PlainButton->setChecked(true);
paintingArea->createPlainTool();
}
void IntelliPhotoGui::slotCreateLineTool(){
LineButton->setChecked(true);
LineButton->setChecked(true);
paintingArea->createLineTool();
}
void IntelliPhotoGui::slotCreateRectangleTool(){
RectangleButton->setChecked(true);
RectangleButton->setChecked(true);
paintingArea->createRectangleTool();
}
void IntelliPhotoGui::slotCreateCircleTool(){
CircleButton->setChecked(true);
CircleButton->setChecked(true);
paintingArea->createCircleTool();
}
void IntelliPhotoGui::slotCreatePolygonTool(){
PolygonButton->setChecked(true);
PolygonButton->setChecked(true);
paintingArea->createPolygonTool();
}
void IntelliPhotoGui::slotCreateFloodFillTool(){
FloodFillButton->setChecked(true);
FloodFillButton->setChecked(true);
paintingArea->createFloodFillTool();
}
@@ -258,26 +258,26 @@ void IntelliPhotoGui::slotAboutDialog(){
}
void IntelliPhotoGui::slotEnterPressed(){
QString string = EditLineWidth->text();
if(string.toInt() > 50){
EditLineWidth->setText("50");
}
paintingArea->Toolsettings.setLineWidth(string.toInt());
string = EditLineInnerAlpha->text();
if(string.toInt() > 255){
EditLineInnerAlpha->setText("255");
}
paintingArea->Toolsettings.setInnerAlpha(string.toInt());
QString string = EditLineWidth->text();
if(string.toInt() > 50) {
EditLineWidth->setText("50");
}
paintingArea->Toolsettings.setLineWidth(string.toInt());
string = EditLineInnerAlpha->text();
if(string.toInt() > 255) {
EditLineInnerAlpha->setText("255");
}
paintingArea->Toolsettings.setInnerAlpha(string.toInt());
}
void IntelliPhotoGui::slotResetTools(){
CircleButton->setChecked(false);
FloodFillButton->setChecked(false);
LineButton->setChecked(false);
PenButton->setChecked(false);
PlainButton->setChecked(false);
PolygonButton->setChecked(false);
RectangleButton->setChecked(false);
CircleButton->setChecked(false);
FloodFillButton->setChecked(false);
LineButton->setChecked(false);
PenButton->setChecked(false);
PlainButton->setChecked(false);
PolygonButton->setChecked(false);
RectangleButton->setChecked(false);
}
// Define menu actions that call functions
@@ -359,45 +359,45 @@ void IntelliPhotoGui::createActions(){
//Create Color Actions here
actionColorPickerFirstColor = new QAction(tr("&Main"), this);
connect(actionColorPickerFirstColor, SIGNAL(triggered()), this, SLOT(slotSetFirstColor()));
connect(FirstColorButton, SIGNAL(clicked()), this, SLOT(slotSetFirstColor()));
connect(FirstColorButton, SIGNAL(clicked()), this, SLOT(slotSetFirstColor()));
actionColorPickerSecondColor = new QAction(tr("&Secondary"), this);
connect(actionColorPickerSecondColor, SIGNAL(triggered()), this, SLOT(slotSetSecondColor()));
connect(SecondColorButton, SIGNAL(clicked()), this, SLOT(slotSetSecondColor()));
connect(SecondColorButton, SIGNAL(clicked()), this, SLOT(slotSetSecondColor()));
actionColorSwap = new QAction(tr("&Switch"), this);
actionColorSwap->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S));
connect(actionColorSwap, SIGNAL(triggered()), this, SLOT(slotSwapColor()));
connect(SwitchColorButton, SIGNAL(clicked()), this, SLOT(slotSwapColor()));
connect(SwitchColorButton, SIGNAL(clicked()), this, SLOT(slotSwapColor()));
//Create Tool actions down here
actionCreatePlainTool = new QAction(tr("&Plain"), this);
connect(actionCreatePlainTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreatePlainTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreatePlainTool, SIGNAL(triggered()), this, SLOT(slotCreatePlainTool()));
actionCreatePenTool = new QAction(tr("&Pen"),this);
connect(actionCreatePenTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreatePenTool, SIGNAL(triggered()), this, SLOT(slotCreatePenTool()));
connect(actionCreatePenTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreatePenTool, SIGNAL(triggered()), this, SLOT(slotCreatePenTool()));
actionCreateLineTool = new QAction(tr("&Line"), this);
connect(actionCreateLineTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreateLineTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreateLineTool, SIGNAL(triggered()), this, SLOT(slotCreateLineTool()));
actionCreateCircleTool = new QAction(tr("&Circle"), this);
connect(actionCreateCircleTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreateCircleTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreateCircleTool, SIGNAL(triggered()), this, SLOT(slotCreateCircleTool()));
actionCreateRectangleTool = new QAction(tr("&Rectangle"), this);
connect(actionCreateRectangleTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreateRectangleTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreateRectangleTool, SIGNAL(triggered()), this, SLOT(slotCreateRectangleTool()));
actionCreatePolygonTool = new QAction(tr("&Polygon"), this);
connect(actionCreatePolygonTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreatePolygonTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreatePolygonTool, SIGNAL(triggered()), this, SLOT(slotCreatePolygonTool()));
actionCreateFloodFillTool = new QAction(tr("&FloodFill"), this);
connect(actionCreateFloodFillTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreateFloodFillTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreateFloodFillTool, SIGNAL(triggered()), this, SLOT(slotCreateFloodFillTool()));
// Create about action and tie to IntelliPhotoGui::about()
@@ -408,29 +408,29 @@ void IntelliPhotoGui::createActions(){
actionAboutQtDialog = new QAction(tr("About &Qt"), this);
connect(actionAboutQtDialog, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
connect(EditLineWidth, SIGNAL(returnPressed()), this, SLOT(slotEnterPressed()));
connect(EditLineInnerAlpha, SIGNAL(returnPressed()), this, SLOT(slotEnterPressed()));
connect(EditLineWidth, SIGNAL(returnPressed()), this, SLOT(slotEnterPressed()));
connect(EditLineInnerAlpha, SIGNAL(returnPressed()), this, SLOT(slotEnterPressed()));
connect(CircleButton,SIGNAL(pressed()), this, SLOT(slotResetTools()));
connect(CircleButton, SIGNAL(clicked()), this, SLOT(slotCreateCircleTool()));
connect(CircleButton,SIGNAL(pressed()), this, SLOT(slotResetTools()));
connect(CircleButton, SIGNAL(clicked()), this, SLOT(slotCreateCircleTool()));
connect(FloodFillButton,SIGNAL(pressed()), this, SLOT(slotResetTools()));
connect(FloodFillButton, SIGNAL(clicked()), this, SLOT(slotCreateFloodFillTool()));
connect(FloodFillButton,SIGNAL(pressed()), this, SLOT(slotResetTools()));
connect(FloodFillButton, SIGNAL(clicked()), this, SLOT(slotCreateFloodFillTool()));
connect(LineButton,SIGNAL(pressed()), this, SLOT(slotResetTools()));
connect(LineButton, SIGNAL(clicked()), this, SLOT(slotCreateLineTool()));
connect(LineButton,SIGNAL(pressed()), this, SLOT(slotResetTools()));
connect(LineButton, SIGNAL(clicked()), this, SLOT(slotCreateLineTool()));
connect(PenButton,SIGNAL(pressed()), this, SLOT(slotResetTools()));
connect(PenButton, SIGNAL(clicked()), this, SLOT(slotCreatePenTool()));
connect(PenButton,SIGNAL(pressed()), this, SLOT(slotResetTools()));
connect(PenButton, SIGNAL(clicked()), this, SLOT(slotCreatePenTool()));
connect(PlainButton,SIGNAL(pressed()), this, SLOT(slotResetTools()));
connect(PlainButton, SIGNAL(clicked()), this, SLOT(slotCreatePlainTool()));
connect(PlainButton,SIGNAL(pressed()), this, SLOT(slotResetTools()));
connect(PlainButton, SIGNAL(clicked()), this, SLOT(slotCreatePlainTool()));
connect(PolygonButton,SIGNAL(pressed()), this, SLOT(slotResetTools()));
connect(PolygonButton, SIGNAL(clicked()), this, SLOT(slotCreatePolygonTool()));
connect(PolygonButton,SIGNAL(pressed()), this, SLOT(slotResetTools()));
connect(PolygonButton, SIGNAL(clicked()), this, SLOT(slotCreatePolygonTool()));
connect(RectangleButton,SIGNAL(pressed()), this, SLOT(slotResetTools()));
connect(RectangleButton, SIGNAL(clicked()), this, SLOT(slotCreateRectangleTool()));
connect(RectangleButton,SIGNAL(pressed()), this, SLOT(slotResetTools()));
connect(RectangleButton, SIGNAL(clicked()), this, SLOT(slotCreateRectangleTool()));
}
// Create the menubar
@@ -472,12 +472,12 @@ void IntelliPhotoGui::createMenus(){
//Attach all Tool Options
toolMenu = new QMenu(tr("&Tools"), this);
toolMenu->addAction(actionCreateCircleTool);
toolMenu->addAction(actionCreateFloodFillTool);
toolMenu->addAction(actionCreateLineTool);
toolMenu->addAction(actionCreateCircleTool);
toolMenu->addAction(actionCreateFloodFillTool);
toolMenu->addAction(actionCreateLineTool);
toolMenu->addAction(actionCreatePenTool);
toolMenu->addAction(actionCreatePlainTool);
toolMenu->addAction(actionCreatePolygonTool);
toolMenu->addAction(actionCreatePolygonTool);
toolMenu->addAction(actionCreateRectangleTool);
toolMenu->addSeparator();
toolMenu->addMenu(colorMenu);
@@ -506,137 +506,137 @@ void IntelliPhotoGui::createGui(){
// create Gui elements
paintingArea = new PaintingArea();
paintingArea->DumpyGui = this;
paintingArea->DumpyGui = this;
p = QPixmap(":/Icons/Buttons/icons/circle-tool.svg");
CircleButton = new QPushButton();
CircleButton->setFixedSize(Buttonsize);
CircleButton->setIcon(p);
CircleButton->setIconSize(Buttonsize);
CircleButton->setCheckable(true);
p = QPixmap(":/Icons/Buttons/icons/circle-tool.svg");
CircleButton = new QPushButton();
CircleButton->setFixedSize(Buttonsize);
CircleButton->setIcon(p);
CircleButton->setIconSize(Buttonsize);
CircleButton->setCheckable(true);
p = QPixmap(":/Icons/Buttons/icons/flood-fill-tool.svg");
FloodFillButton = new QPushButton();
FloodFillButton->setFixedSize(Buttonsize);
FloodFillButton->setIcon(p);
FloodFillButton->setIconSize(Buttonsize);
FloodFillButton->setCheckable(true);
p = QPixmap(":/Icons/Buttons/icons/flood-fill-tool.svg");
FloodFillButton = new QPushButton();
FloodFillButton->setFixedSize(Buttonsize);
FloodFillButton->setIcon(p);
FloodFillButton->setIconSize(Buttonsize);
FloodFillButton->setCheckable(true);
p = QPixmap(":/Icons/Buttons/icons/icon.png");
LineButton = new QPushButton();
LineButton->setFixedSize(Buttonsize);
LineButton->setIcon(p);
LineButton->setIconSize(Buttonsize);
LineButton->setCheckable(true);
p = QPixmap(":/Icons/Buttons/icons/icon.png");
LineButton = new QPushButton();
LineButton->setFixedSize(Buttonsize);
LineButton->setIcon(p);
LineButton->setIconSize(Buttonsize);
LineButton->setCheckable(true);
p = QPixmap(":/Icons/Buttons/icons/pen-tool.svg");
PenButton = new QPushButton();
PenButton->setFixedSize(Buttonsize);
PenButton->setIcon(p);
PenButton->setIconSize(Buttonsize);
PenButton->setCheckable(true);
p = QPixmap(":/Icons/Buttons/icons/pen-tool.svg");
PenButton = new QPushButton();
PenButton->setFixedSize(Buttonsize);
PenButton->setIcon(p);
PenButton->setIconSize(Buttonsize);
PenButton->setCheckable(true);
p = QPixmap(":/Icons/Buttons/icons/icon.png");
PlainButton = new QPushButton();
PlainButton->setFixedSize(Buttonsize);
PlainButton->setIcon(p);
PlainButton->setIconSize(Buttonsize);
PlainButton->setCheckable(true);
p = QPixmap(":/Icons/Buttons/icons/icon.png");
PlainButton = new QPushButton();
PlainButton->setFixedSize(Buttonsize);
PlainButton->setIcon(p);
PlainButton->setIconSize(Buttonsize);
PlainButton->setCheckable(true);
p = QPixmap(":/Icons/Buttons/icons/polygon-tool.svg");
PolygonButton = new QPushButton();
PolygonButton->setFixedSize(Buttonsize);
PolygonButton->setIcon(p);
PolygonButton->setIconSize(Buttonsize);
PolygonButton->setCheckable(true);
p = QPixmap(":/Icons/Buttons/icons/polygon-tool.svg");
PolygonButton = new QPushButton();
PolygonButton->setFixedSize(Buttonsize);
PolygonButton->setIcon(p);
PolygonButton->setIconSize(Buttonsize);
PolygonButton->setCheckable(true);
p = QPixmap(":/Icons/Buttons/icons/rectangle-tool.svg");
RectangleButton = new QPushButton();
RectangleButton->setFixedSize(Buttonsize);
RectangleButton->setIcon(p);
RectangleButton->setIconSize(Buttonsize);
RectangleButton->setCheckable(true);
p = QPixmap(":/Icons/Buttons/icons/rectangle-tool.svg");
RectangleButton = new QPushButton();
RectangleButton->setFixedSize(Buttonsize);
RectangleButton->setIcon(p);
RectangleButton->setIconSize(Buttonsize);
RectangleButton->setCheckable(true);
WidthLine = new QLabel();
WidthLine->setText("Width");
WidthLine->setFixedSize(Buttonsize.width(),Buttonsize.height()/3);
WidthLine = new QLabel();
WidthLine->setText("Width");
WidthLine->setFixedSize(Buttonsize.width(),Buttonsize.height()/3);
EditLineWidth = new QLineEdit();
EditLineWidth->setFixedSize(Buttonsize.width(),Buttonsize.height()/3);
EditLineWidth->setText("5");
ValidatorLineWidth = new QIntValidator();
ValidatorLineWidth->setTop(99);
ValidatorLineWidth->setBottom(1);
EditLineWidth->setValidator(ValidatorLineWidth);
EditLineWidth = new QLineEdit();
EditLineWidth->setFixedSize(Buttonsize.width(),Buttonsize.height()/3);
EditLineWidth->setText("5");
ValidatorLineWidth = new QIntValidator();
ValidatorLineWidth->setTop(99);
ValidatorLineWidth->setBottom(1);
EditLineWidth->setValidator(ValidatorLineWidth);
innerAlphaLine = new QLabel();
innerAlphaLine->setText("Inner Alpha");
innerAlphaLine->setFixedSize(Buttonsize.width(),Buttonsize.height()/3);
innerAlphaLine = new QLabel();
innerAlphaLine->setText("Inner Alpha");
innerAlphaLine->setFixedSize(Buttonsize.width(),Buttonsize.height()/3);
EditLineInnerAlpha = new QLineEdit();
EditLineInnerAlpha->setFixedSize(Buttonsize.width(),Buttonsize.height()/3);
EditLineInnerAlpha->setText("255");
ValidatorInnerAlpha = new QIntValidator();
ValidatorInnerAlpha->setTop(999);
ValidatorInnerAlpha->setBottom(0);
EditLineInnerAlpha->setValidator(ValidatorInnerAlpha);
EditLineInnerAlpha = new QLineEdit();
EditLineInnerAlpha->setFixedSize(Buttonsize.width(),Buttonsize.height()/3);
EditLineInnerAlpha->setText("255");
ValidatorInnerAlpha = new QIntValidator();
ValidatorInnerAlpha->setTop(999);
ValidatorInnerAlpha->setBottom(0);
EditLineInnerAlpha->setValidator(ValidatorInnerAlpha);
FirstColorButton = new QPushButton();
FirstColorButton->setFixedSize(Buttonsize/2);
FirstColorButton = new QPushButton();
FirstColorButton->setFixedSize(Buttonsize/2);
SecondColorButton = new QPushButton();
SecondColorButton->setFixedSize(Buttonsize/2);
SecondColorButton = new QPushButton();
SecondColorButton->setFixedSize(Buttonsize/2);
p = QPixmap(":/Icons/Buttons/icons/Wechselpfeile.png");
SwitchColorButton = new QPushButton();
SwitchColorButton->setFixedSize(Buttonsize.width(),Buttonsize.height()/2);
SwitchColorButton->setIcon(p);
SwitchColorButton->setIconSize(QSize(Buttonsize.width(),Buttonsize.height()/2));
p = QPixmap(":/Icons/Buttons/icons/Wechselpfeile.png");
SwitchColorButton = new QPushButton();
SwitchColorButton->setFixedSize(Buttonsize.width(),Buttonsize.height()/2);
SwitchColorButton->setIcon(p);
SwitchColorButton->setIconSize(QSize(Buttonsize.width(),Buttonsize.height()/2));
ActiveLayerLine = new QLabel();
QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer());
ActiveLayerLine->setText(string);
ActiveLayerLine->setFixedSize(Buttonsize.width()+10,Buttonsize.height()/3);
ActiveLayerLine = new QLabel();
QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer());
ActiveLayerLine->setText(string);
ActiveLayerLine->setFixedSize(Buttonsize.width()+10,Buttonsize.height()/3);
p = p.fromImage(paintingArea->getImageOfActiveLayer()->getImageData());
p = p.fromImage(paintingArea->getImageOfActiveLayer()->getImageData());
ActiveLayerImageButton = new QPushButton();
ActiveLayerImageButton->setFixedSize(Buttonsize);
ActiveLayerImageButton->setIcon(p);
ActiveLayerImageButton->setIconSize(Buttonsize);
ActiveLayerImageButton = new QPushButton();
ActiveLayerImageButton->setFixedSize(Buttonsize);
ActiveLayerImageButton->setIcon(p);
ActiveLayerImageButton->setIconSize(Buttonsize);
// set gui elements
mainLayout->addWidget(paintingArea,1,1,20,1);
mainLayout->addWidget(CircleButton,1,2,1,2);
mainLayout->addWidget(FloodFillButton,2,2,1,2);
mainLayout->addWidget(LineButton,3,2,1,2);
mainLayout->addWidget(PenButton,4,2,1,2);
mainLayout->addWidget(PlainButton,5,2,1,2);
mainLayout->addWidget(PolygonButton,6,2,1,2);
mainLayout->addWidget(RectangleButton,7,2,1,2);
mainLayout->addWidget(WidthLine,8,2,1,2);
mainLayout->addWidget(EditLineWidth,9,2,1,2);
mainLayout->addWidget(innerAlphaLine,10,2,1,2);
mainLayout->addWidget(EditLineInnerAlpha,11,2,1,2);
mainLayout->addWidget(FirstColorButton,12,2,1,1);
mainLayout->addWidget(SecondColorButton,12,3,1,1);
mainLayout->addWidget(SwitchColorButton,13,2,1,2);
mainLayout->addWidget(ActiveLayerLine,14,2,1,2);
mainLayout->addWidget(ActiveLayerImageButton,15,2,1,2);
mainLayout->addWidget(paintingArea,1,1,20,1);
mainLayout->addWidget(CircleButton,1,2,1,2);
mainLayout->addWidget(FloodFillButton,2,2,1,2);
mainLayout->addWidget(LineButton,3,2,1,2);
mainLayout->addWidget(PenButton,4,2,1,2);
mainLayout->addWidget(PlainButton,5,2,1,2);
mainLayout->addWidget(PolygonButton,6,2,1,2);
mainLayout->addWidget(RectangleButton,7,2,1,2);
mainLayout->addWidget(WidthLine,8,2,1,2);
mainLayout->addWidget(EditLineWidth,9,2,1,2);
mainLayout->addWidget(innerAlphaLine,10,2,1,2);
mainLayout->addWidget(EditLineInnerAlpha,11,2,1,2);
mainLayout->addWidget(FirstColorButton,12,2,1,1);
mainLayout->addWidget(SecondColorButton,12,3,1,1);
mainLayout->addWidget(SwitchColorButton,13,2,1,2);
mainLayout->addWidget(ActiveLayerLine,14,2,1,2);
mainLayout->addWidget(ActiveLayerImageButton,15,2,1,2);
}
void IntelliPhotoGui::setIntelliStyle(){
// Set the title
setWindowTitle("IntelliPhoto Prototype");
// Set style sheet
this->setStyleSheet("background-color:rgb(64,64,64)");
this->centralGuiWidget->setStyleSheet("color:rgb(255,255,255)");
this->setStyleSheet("background-color:rgb(64,64,64)");
this->centralGuiWidget->setStyleSheet("color:rgb(255,255,255)");
this->menuBar()->setStyleSheet("color:rgb(255,255,255)");
QString string = QString("background-color: %1").arg(paintingArea->colorPicker.getFirstColor().name());
FirstColorButton->setStyleSheet(string);
string = QString("background-color: %1").arg(paintingArea->colorPicker.getSecondColor().name());
SecondColorButton->setStyleSheet(string);
QString string = QString("background-color: %1").arg(paintingArea->colorPicker.getFirstColor().name());
FirstColorButton->setStyleSheet(string);
string = QString("background-color: %1").arg(paintingArea->colorPicker.getSecondColor().name());
SecondColorButton->setStyleSheet(string);
}
bool IntelliPhotoGui::maybeSave(){
@@ -688,18 +688,18 @@ bool IntelliPhotoGui::saveFile(const QByteArray &fileFormat){
}
void IntelliPhotoGui::setDefaultToolValue(){
slotEnterPressed();
slotEnterPressed();
}
void IntelliPhotoGui::UpdateGui(){
QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer());
ActiveLayerLine->setText(string);
p = p.fromImage(paintingArea->getImageOfActiveLayer()->getImageData());
ActiveLayerImageButton->setIcon(p);
ActiveLayerImageButton->setIconSize(Buttonsize);
QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer());
ActiveLayerLine->setText(string);
p = p.fromImage(paintingArea->getImageOfActiveLayer()->getImageData());
ActiveLayerImageButton->setIcon(p);
ActiveLayerImageButton->setIconSize(Buttonsize);
string = QString("background-color: %1").arg(paintingArea->colorPicker.getFirstColor().name());
FirstColorButton->setStyleSheet(string);
string = QString("background-color: %1").arg(paintingArea->colorPicker.getSecondColor().name());
SecondColorButton->setStyleSheet(string);
string = QString("background-color: %1").arg(paintingArea->colorPicker.getFirstColor().name());
FirstColorButton->setStyleSheet(string);
string = QString("background-color: %1").arg(paintingArea->colorPicker.getSecondColor().name());
SecondColorButton->setStyleSheet(string);
}

View File

@@ -24,7 +24,7 @@ bool IntelliImage::loadImage(const QString &filePath){
QImage loadedImage;
// If the image wasn't loaded leave this function
if (!loadedImage.load(filePath))
if (!loadedImage.load(filePath))
return false;
// scaled Image to size of Layer

View File

@@ -24,8 +24,8 @@ public:
* \brief The Types, which an Image can be.
*/
enum class ImageType {
Raster_Image,
Shaped_Image
RASTERIMAGE,
SHAPEDIMAGE
};
protected:
@@ -132,7 +132,7 @@ virtual std::vector<QPoint> getPolygonData(){
}
virtual ImageType getTypeOfImage(){
return TypeOfImage;
return TypeOfImage;
}
/*!

View File

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

View File

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

View File

@@ -6,5 +6,5 @@ IntelliRenderSettings::IntelliRenderSettings()
}
bool IntelliRenderSettings::getFastRenderer(){
return fastRenderer;
return fastRenderer;
}

View File

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

View File

@@ -3,9 +3,9 @@
IntelliToolsettings::IntelliToolsettings()
{
lineWidth = 1;
innerAlpha = 255;
Linestyle = LineStyle::SOLID_LINE;
lineWidth = 1;
innerAlpha = 255;
Linestyle = LineStyle::SOLID_LINE;
}
IntelliToolsettings::~IntelliToolsettings(){
@@ -13,41 +13,41 @@ IntelliToolsettings::~IntelliToolsettings(){
}
int IntelliToolsettings::getLineWidth(){
return lineWidth;
return lineWidth;
}
void IntelliToolsettings::setLineWidth(){
lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1);
lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1);
}
void IntelliToolsettings::setLineWidth(int LineWidth){
if(LineWidth < 1){
LineWidth = 1;
}
else if(LineWidth > 50){
LineWidth = 50;
}
lineWidth = LineWidth;
if(LineWidth < 1) {
LineWidth = 1;
}
else if(LineWidth > 50) {
LineWidth = 50;
}
lineWidth = LineWidth;
}
int IntelliToolsettings::getInnerAlpha(){
return this->innerAlpha;
return this->innerAlpha;
}
void IntelliToolsettings::setInnerAlpha(){
this->innerAlpha = QInputDialog::getInt(nullptr,"Inner Aplha Input", "Value",0,0,255,1);
this->innerAlpha = QInputDialog::getInt(nullptr,"Inner Aplha Input", "Value",0,0,255,1);
}
void IntelliToolsettings::setInnerAlpha(int innerAlpha){
if(innerAlpha < 0){
innerAlpha = 0;
}
else if(innerAlpha > 255){
innerAlpha = 255;
}
this->innerAlpha = innerAlpha;
if(innerAlpha < 0) {
innerAlpha = 0;
}
else if(innerAlpha > 255) {
innerAlpha = 255;
}
this->innerAlpha = innerAlpha;
}
IntelliToolsettings::LineStyle IntelliToolsettings::getLinestyle(){
return Linestyle;
return Linestyle;
}

View File

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

View File

@@ -9,7 +9,7 @@ std::vector<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoin
struct TriangleHelper {
QPoint vertex;
float interiorAngle;
int index;
int idx;
bool isTip;
};
@@ -19,7 +19,7 @@ std::vector<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoin
QPoint BP(point.x()-post.x(), point.y()-post.y());
float topSclar = AP.x()*BP.x()+AP.y()*BP.y();
float absolute = static_cast<float>(sqrt(pow(AP.x(),2.)+pow(AP.y(),2.))*sqrt(pow(BP.x(),2.)+pow(BP.y(),2.)));
float absolute = static_cast<float>(sqrt(pow(AP.x(),2.)+pow(AP.y(),2.))*sqrt(pow(BP.x(),2.)+pow(BP.y(),2.)));
return acos(topSclar/absolute);
};
@@ -34,19 +34,19 @@ std::vector<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoin
return vec[min];
};
// 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 idx bevor idx in relation to the container length
auto getPrev = [](int idx, int length){
return (idx-1)>=0 ? (idx-1) : (length-1);
};
// get the vertex Index after index in relation to the container lenght
auto getPost = [](int index, int length){
return (index+1)%length;
// get the vertex idx after idx in relation to the container lenght
auto getPost = [](int idx, int length){
return (idx+1)%length;
};
// return if the vertex is a tip
auto isTip = [](float angle){
return static_cast<double>(angle)<(pi/2.);
return static_cast<double>(angle)<(pi/2.);
};
std::vector<TriangleHelper> Vertices;
@@ -59,7 +59,7 @@ std::vector<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoin
int post = getPost(i, static_cast<int>(polyPoints.size()));
helper.vertex = polyPoints[static_cast<size_t>(i)];
helper.index = i;
helper.idx = i;
helper.interiorAngle = calculateInner(polyPoints[static_cast<size_t>(i)],
polyPoints[static_cast<size_t>(prev)],
@@ -72,24 +72,24 @@ std::vector<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoin
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()));
int prev = getPrev(smallest.idx, static_cast<int>(Vertices.size()));
int post = getPost(smallest.idx, static_cast<int>(Vertices.size()));
// 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.B = Vertices[static_cast<size_t>(smallest.idx)].vertex;
tri.C = Vertices[static_cast<size_t>(post)].vertex;
Triangles.push_back(tri);
// 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;
Vertices.erase(Vertices.begin()+smallest.idx);
for(size_t i=static_cast<size_t>(smallest.idx); i<Vertices.size(); i++) {
Vertices[i].idx-=1;
}
// update post und prev index
post = getPrev(post, Vertices.size());
prev = prev<smallest.index ? prev : (prev-1);
// update post und prev idx
post = getPrev(post, Vertices.size());
prev = prev<smallest.idx ? prev : (prev-1);
// calcultae neighboors of prev and post to calculate new interior angles
int prevOfPrev = getPrev(prev, static_cast<int>(Vertices.size()));
@@ -115,7 +115,7 @@ std::vector<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoin
bool IntelliTriangulation::isInPolygon(std::vector<Triangle> &triangles, QPoint &point){
for(auto triangle : triangles) {
if(IntelliTriangulation::isInTriangle(triangle, point)) {
if(IntelliTriangulation::isInTriangle(triangle, point)) {
return true;
}
}

View File

@@ -34,9 +34,9 @@ inline bool isInTriangle(Triangle& tri, QPoint& P){
float val1, val2, val3;
bool neg, pos;
val1 = IntelliTriangulation::sign(P,tri.A,tri.B);
val2 = IntelliTriangulation::sign(P,tri.B,tri.C);
val3 = IntelliTriangulation::sign(P,tri.C,tri.A);
val1 = IntelliTriangulation::sign(P,tri.A,tri.B);
val2 = IntelliTriangulation::sign(P,tri.B,tri.C);
val3 = IntelliTriangulation::sign(P,tri.C,tri.A);
neg = (val1<0.f) || (val2<0.f) || (val3<0.f);
pos = (val1>0.f) || (val2>0.f) || (val3>0.f);

View File

@@ -20,9 +20,9 @@
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent)
: QWidget(parent){
this->Tool = nullptr;
this->setLayerDimensions(maxWidth, maxHeight);
this->addLayer(200,200,0,0,IntelliImage::ImageType::Shaped_Image);
this->Tool = nullptr;
this->setLayerDimensions(maxWidth, maxHeight);
this->addLayer(200,200,0,0,IntelliImage::ImageType::SHAPEDIMAGE);
layerBundle[0].image->drawPlain(QColor(0,0,255,255));
std::vector<QPoint> polygon;
polygon.push_back(QPoint(100,000));
@@ -31,7 +31,7 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent)
polygon.push_back(QPoint(000,100));
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].alpha=200;
@@ -66,15 +66,15 @@ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOff
}
newLayer.alpha = 255;
this->layerBundle.push_back(newLayer);
activeLayer = static_cast<int>(layerBundle.size())-1;
return activeLayer;
activeLayer = static_cast<int>(layerBundle.size())-1;
return activeLayer;
}
void PaintingArea::deleteLayer(int index){
if(index<static_cast<int>(layerBundle.size())) {
this->layerBundle.erase(layerBundle.begin()+index);
if(activeLayer>=index && activeLayer != 0) {
void PaintingArea::deleteLayer(int idx){
if(idx<static_cast<int>(layerBundle.size())) {
this->layerBundle.erase(layerBundle.begin()+idx);
if(activeLayer>=idx && activeLayer != 0) {
activeLayer--;
}
}
@@ -87,15 +87,15 @@ void PaintingArea::slotDeleteActiveLayer(){
}
}
void PaintingArea::setLayerActive(int index){
if(index>=0&&index<static_cast<int>(layerBundle.size())) {
this->activeLayer=index;
void PaintingArea::setLayerActive(int idx){
if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
this->activeLayer=idx;
}
}
void PaintingArea::setLayerAlpha(int index, int alpha){
if(index>=0&&index<static_cast<int>(layerBundle.size())) {
layerBundle[static_cast<size_t>(index)].alpha=alpha;
void PaintingArea::setLayerAlpha(int idx, int alpha){
if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
layerBundle[static_cast<size_t>(idx)].alpha=alpha;
}
}
@@ -105,7 +105,7 @@ bool PaintingArea::open(const QString &filePath){
return false;
}
IntelliImage* active = layerBundle[static_cast<size_t>(activeLayer)].image;
bool open = active->loadImage(filePath);
bool open = active->loadImage(filePath);
active->calculateVisiblity();
update();
return open;
@@ -116,19 +116,19 @@ bool PaintingArea::save(const QString &filePath, const char*fileFormat){
if(layerBundle.size()==0) {
return false;
}
this->drawLayers(true);
this->drawLayers(true);
if(!strcmp(fileFormat,"PNG")) {
QImage visibleImage = Canvas->convertToFormat(QImage::Format_Indexed8);
fileFormat = "png";
if (visibleImage.save(filePath, fileFormat)) {
if (visibleImage.save(filePath, fileFormat)) {
return true;
} else {
return false;
}
}
if (Canvas->save(filePath, fileFormat)) {
if (Canvas->save(filePath, fileFormat)) {
return true;
} else {
return false;
@@ -146,14 +146,14 @@ void PaintingArea::floodFill(int r, int g, int b, int a){
}
void PaintingArea::movePositionActive(int x, int y){
if(Tool!=nullptr){
if(Tool->getIsDrawing()){
IntelliTool* temp = copyActiveTool();
delete this->Tool;
this->Tool = temp;
}
}
layerBundle[static_cast<size_t>(activeLayer)].widthOffset += x;
if(Tool!=nullptr) {
if(Tool->getIsDrawing()) {
IntelliTool* temp = copyActiveTool();
delete this->Tool;
this->Tool = temp;
}
}
layerBundle[static_cast<size_t>(activeLayer)].widthOffset += x;
layerBundle[static_cast<size_t>(activeLayer)].heightOffset += y;
}
@@ -173,13 +173,13 @@ void PaintingArea::moveActiveLayer(int idx){
}
void PaintingArea::slotActivateLayer(int a){
if(Tool != nullptr){
if(Tool->getIsDrawing()){
IntelliTool* temp = copyActiveTool();
delete this->Tool;
this->Tool = temp;
}
}
if(Tool != nullptr) {
if(Tool->getIsDrawing()) {
IntelliTool* temp = copyActiveTool();
delete this->Tool;
this->Tool = temp;
}
}
if(a>=0 && a < static_cast<int>(layerBundle.size())) {
this->setLayerActive(a);
}
@@ -201,52 +201,52 @@ void PaintingArea::colorPickerSwapColors(){
void PaintingArea::createPenTool(){
delete this->Tool;
Tool = new IntelliToolPen(this, &colorPicker, &Toolsettings);
Tool = new IntelliToolPen(this, &colorPicker, &Toolsettings);
}
void PaintingArea::createPlainTool(){
delete this->Tool;
Tool = new IntelliToolPlainTool(this, &colorPicker, &Toolsettings);
Tool = new IntelliToolPlainTool(this, &colorPicker, &Toolsettings);
}
void PaintingArea::createLineTool(){
delete this->Tool;
Tool = new IntelliToolLine(this, &colorPicker, &Toolsettings);
Tool = new IntelliToolLine(this, &colorPicker, &Toolsettings);
}
void PaintingArea::createRectangleTool(){
delete this->Tool;
Tool = new IntelliToolRectangle(this, &colorPicker, &Toolsettings);
Tool = new IntelliToolRectangle(this, &colorPicker, &Toolsettings);
}
void PaintingArea::createCircleTool(){
delete this->Tool;
Tool = new IntelliToolCircle(this, &colorPicker, &Toolsettings);
Tool = new IntelliToolCircle(this, &colorPicker, &Toolsettings);
}
void PaintingArea::createPolygonTool(){
delete this->Tool;
Tool = new IntelliToolPolygon(this, &colorPicker, &Toolsettings);
Tool = new IntelliToolPolygon(this, &colorPicker, &Toolsettings);
}
void PaintingArea::createFloodFillTool(){
delete this->Tool;
Tool = new IntelliToolFloodFill(this, &colorPicker, &Toolsettings);
Tool = new IntelliToolFloodFill(this, &colorPicker, &Toolsettings);
}
int PaintingArea::getWidthOfActive(){
return this->layerBundle[static_cast<unsigned long long>(activeLayer)].width;
return this->layerBundle[static_cast<unsigned long long>(activeLayer)].width;
}
int PaintingArea::getHeightOfActive(){
return this->layerBundle[static_cast<unsigned long long>(activeLayer)].height;
return this->layerBundle[static_cast<unsigned long long>(activeLayer)].height;
}
IntelliImage::ImageType PaintingArea::getTypeOfImageRealLayer(){
return this->layerBundle[static_cast<unsigned long long>(activeLayer)].image->getTypeOfImage();
return this->layerBundle[static_cast<unsigned long long>(activeLayer)].image->getTypeOfImage();
}
std::vector<QPoint> PaintingArea::getPolygonDataOfRealLayer(){
return this->layerBundle[static_cast<unsigned long long>(activeLayer)].image->getPolygonData();
return this->layerBundle[static_cast<unsigned long long>(activeLayer)].image->getPolygonData();
}
// If a mouse button is pressed check if it was the
@@ -255,8 +255,8 @@ std::vector<QPoint> PaintingArea::getPolygonDataOfRealLayer(){
void PaintingArea::mousePressEvent(QMouseEvent*event){
if(Tool == nullptr)
return;
int x = event->x()-layerBundle[static_cast<unsigned long long>(activeLayer)].widthOffset;
int y = event->y()-layerBundle[static_cast<unsigned long long>(activeLayer)].heightOffset;
int x = event->x()-layerBundle[static_cast<unsigned long long>(activeLayer)].widthOffset;
int y = event->y()-layerBundle[static_cast<unsigned long long>(activeLayer)].heightOffset;
if(event->button() == Qt::LeftButton) {
Tool->onMouseLeftPressed(x, y);
}else if(event->button() == Qt::RightButton) {
@@ -271,8 +271,8 @@ void PaintingArea::mousePressEvent(QMouseEvent*event){
void PaintingArea::mouseMoveEvent(QMouseEvent*event){
if(Tool == nullptr)
return;
int x = event->x()-layerBundle[static_cast<unsigned long long>(activeLayer)].widthOffset;
int y = event->y()-layerBundle[static_cast<unsigned long long>(activeLayer)].heightOffset;
int x = event->x()-layerBundle[static_cast<unsigned long long>(activeLayer)].widthOffset;
int y = event->y()-layerBundle[static_cast<unsigned long long>(activeLayer)].heightOffset;
Tool->onMouseMoved(x, y);
update();
}
@@ -281,8 +281,8 @@ void PaintingArea::mouseMoveEvent(QMouseEvent*event){
void PaintingArea::mouseReleaseEvent(QMouseEvent*event){
if(Tool == nullptr)
return;
int x = event->x()-layerBundle[static_cast<unsigned long long>(activeLayer)].widthOffset;
int y = event->y()-layerBundle[static_cast<unsigned long long>(activeLayer)].heightOffset;
int x = event->x()-layerBundle[static_cast<unsigned long long>(activeLayer)].widthOffset;
int y = event->y()-layerBundle[static_cast<unsigned long long>(activeLayer)].heightOffset;
if(event->button() == Qt::LeftButton) {
Tool->onMouseLeftReleased(x, y);
}else if(event->button() == Qt::RightButton) {
@@ -292,20 +292,20 @@ void PaintingArea::mouseReleaseEvent(QMouseEvent*event){
}
void PaintingArea::wheelEvent(QWheelEvent*event){
if(this->Tool != nullptr){
QPoint numDegrees = event->angleDelta() / 8;
if(!numDegrees.isNull()) {
QPoint numSteps = numDegrees / 15;
Tool->onWheelScrolled(numSteps.y()* -1);
}
}
if(this->Tool != nullptr) {
QPoint numDegrees = event->angleDelta() / 8;
if(!numDegrees.isNull()) {
QPoint numSteps = numDegrees / 15;
Tool->onWheelScrolled(numSteps.y()* -1);
}
}
}
// QPainter provides functions to draw on the widget
// The QPaintEvent is sent to widgets that need to
// update themselves
void PaintingArea::paintEvent(QPaintEvent*event){
this->drawLayers();
this->drawLayers();
QPainter painter(this);
QRect dirtyRec = event->rect();
@@ -325,15 +325,15 @@ void PaintingArea::resizeLayer(QImage*image_res, const QSize &newSize){
}
void PaintingArea::selectLayerUp(){
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)]);
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)]);
activeLayer++;
}
}
void PaintingArea::selectLayerDown(){
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--;
}
}
@@ -377,32 +377,32 @@ void PaintingArea::createTempTopLayer(int idx){
if(idx>=0) {
LayerObject newLayer;
newLayer.alpha = 255;
newLayer.height = layerBundle[static_cast<unsigned long long>(idx)].height;
newLayer.width = layerBundle[static_cast<unsigned long long>(idx)].width;
newLayer.heightOffset = layerBundle[static_cast<unsigned long long>(idx)].heightOffset;
newLayer.widthOffset = layerBundle[static_cast<unsigned long long>(idx)].widthOffset;
newLayer.image = layerBundle[static_cast<unsigned long long>(idx)].image->getDeepCopy();
newLayer.height = layerBundle[static_cast<unsigned long long>(idx)].height;
newLayer.width = layerBundle[static_cast<unsigned long long>(idx)].width;
newLayer.heightOffset = layerBundle[static_cast<unsigned long long>(idx)].heightOffset;
newLayer.widthOffset = layerBundle[static_cast<unsigned long long>(idx)].widthOffset;
newLayer.image = layerBundle[static_cast<unsigned long long>(idx)].image->getDeepCopy();
layerBundle.insert(layerBundle.begin()+idx+1,newLayer);
}
}
IntelliTool* PaintingArea::copyActiveTool(){
switch(Tool->getTooltype()){
case IntelliTool::Tooltype::CIRCLE: return new IntelliToolCircle(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::PEN: return new IntelliToolPen(this,&colorPicker, &Toolsettings);
case IntelliTool::Tooltype::PLAIN: return new IntelliToolPlainTool(this,&colorPicker, &Toolsettings);
case IntelliTool::Tooltype::POLYGON: return new IntelliToolPolygon(this,&colorPicker, &Toolsettings);
case IntelliTool::Tooltype::RECTANGLE: return new IntelliToolRectangle(this,&colorPicker, &Toolsettings);
default: return nullptr;
}
switch(Tool->getTooltype()) {
case IntelliTool::Tooltype::CIRCLE: return new IntelliToolCircle(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::PEN: return new IntelliToolPen(this,&colorPicker, &Toolsettings);
case IntelliTool::Tooltype::PLAIN: return new IntelliToolPlainTool(this,&colorPicker, &Toolsettings);
case IntelliTool::Tooltype::POLYGON: return new IntelliToolPolygon(this,&colorPicker, &Toolsettings);
case IntelliTool::Tooltype::RECTANGLE: return new IntelliToolRectangle(this,&colorPicker, &Toolsettings);
default: return nullptr;
}
}
int PaintingArea::getNumberOfActiveLayer(){
return activeLayer;
return activeLayer;
}
IntelliImage* PaintingArea::getImageOfActiveLayer(){
return layerBundle[activeLayer].image;
return layerBundle[activeLayer].image;
}

View File

@@ -81,10 +81,10 @@ public:
* \param type - Defining the ImageType of the new layer
* \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
* \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 height - Height of the layer 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
* \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
* \param index - The index of the layer to be removed
* \brief The deleteLayer method removes a layer at a given idx
* \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
* \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
* \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
*/
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
* \param r - Red value of the color the layer should be filled with
@@ -125,7 +125,7 @@ public:
void movePositionActive(int x, int y);
/*!
* \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);
@@ -178,7 +178,7 @@ public slots:
// Events to handle
/*!
* \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);
/*!

View File

@@ -4,7 +4,7 @@
IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings){
this->Area=Area;
this->colorPicker=colorPicker;
this->Toolsettings=Toolsettings;
this->Toolsettings=Toolsettings;
}
@@ -50,8 +50,8 @@ void IntelliTool::onWheelScrolled(int value){
void IntelliTool::createToolLayer(){
Area->createTempTopLayer(Area->activeLayer);
this->activeLayer=&Area->layerBundle[static_cast<unsigned long long>(Area->activeLayer)];
this->Canvas=&Area->layerBundle[static_cast<unsigned long long>(Area->activeLayer+1)];
this->activeLayer=&Area->layerBundle[static_cast<unsigned long long>(Area->activeLayer)];
this->Canvas=&Area->layerBundle[static_cast<unsigned long long>(Area->activeLayer+1)];
}
void IntelliTool::mergeToolLayer(){
@@ -74,7 +74,7 @@ void IntelliTool::mergeToolLayer(){
activeLayer->image->imageData.setPixelColor(x, y, clr_0);
}
}
Area->DumpyGui->UpdateGui();
Area->DumpyGui->UpdateGui();
}
void IntelliTool::deleteToolLayer(){
@@ -83,9 +83,9 @@ void IntelliTool::deleteToolLayer(){
}
IntelliTool::Tooltype IntelliTool::getTooltype(){
return ActiveType;
return ActiveType;
}
bool IntelliTool::getIsDrawing(){
return isDrawing;
return isDrawing;
}

View File

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

View File

@@ -4,46 +4,46 @@
#include <cmath>
IntelliToolCircle::IntelliToolCircle(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker, Toolsettings){
this->ActiveType = Tooltype::CIRCLE;
: IntelliTool(Area, colorPicker, Toolsettings){
this->ActiveType = Tooltype::CIRCLE;
}
IntelliToolCircle::~IntelliToolCircle(){
IntelliTool::onMouseRightPressed(0,0);
IntelliTool::onMouseRightPressed(0,0);
}
void IntelliToolCircle::drawCircle(int radius){
int outer = radius+20;
QColor inner = this->colorPicker->getSecondColor();
inner.setAlpha(Toolsettings->getInnerAlpha());
inner.setAlpha(Toolsettings->getInnerAlpha());
int yMin, yMax, xMin, xMax;
yMin = centerPoint.y()-radius;
yMax = centerPoint.y()+radius;
// x = x0+-sqrt(r2-(y-y0)2)
for(int i=yMin; i<=yMax; i++) {
xMin = static_cast<int>(centerPoint.x()-sqrt(pow(radius,2)-pow(i-centerPoint.y(),2)));
xMax = static_cast<int>(centerPoint.x()+sqrt(pow(radius,2)-pow(i-centerPoint.y(),2)));
xMin = static_cast<int>(centerPoint.x()-sqrt(pow(radius,2)-pow(i-centerPoint.y(),2)));
xMax = static_cast<int>(centerPoint.x()+sqrt(pow(radius,2)-pow(i-centerPoint.y(),2)));
this->Canvas->image->drawLine(QPoint(xMin,i), QPoint(xMax,i),inner,1);
}
//TODO implement circle drawing algorithm bresenham
radius = static_cast<int>(radius +(Toolsettings->getLineWidth()/2.)-1.);
radius = static_cast<int>(radius +(Toolsettings->getLineWidth()/2.)-1.);
yMin = (centerPoint.y()-radius);
yMax = (centerPoint.y()+radius);
for(int i=yMin; i<=yMax; i++) {
xMin = static_cast<int>(centerPoint.x()-sqrt(pow(radius,2)-pow(i-centerPoint.y(),2)));
xMax = static_cast<int>(centerPoint.x()+sqrt(pow(radius,2)-pow(i-centerPoint.y(),2)));
this->Canvas->image->drawPoint(QPoint(xMin,i), colorPicker->getFirstColor(),Toolsettings->getLineWidth());
this->Canvas->image->drawPoint(QPoint(xMax,i), colorPicker->getFirstColor(),Toolsettings->getLineWidth());
xMin = static_cast<int>(centerPoint.x()-sqrt(pow(radius,2)-pow(i-centerPoint.y(),2)));
xMax = static_cast<int>(centerPoint.x()+sqrt(pow(radius,2)-pow(i-centerPoint.y(),2)));
this->Canvas->image->drawPoint(QPoint(xMin,i), colorPicker->getFirstColor(),Toolsettings->getLineWidth());
this->Canvas->image->drawPoint(QPoint(xMax,i), colorPicker->getFirstColor(),Toolsettings->getLineWidth());
}
xMin = (centerPoint.x()-radius);
xMax = (centerPoint.x()+radius);
for(int i=xMin; i<=xMax; i++) {
int yMin = 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)));
this->Canvas->image->drawPoint(QPoint(i, yMin), colorPicker->getFirstColor(),Toolsettings->getLineWidth());
this->Canvas->image->drawPoint(QPoint(i, yMax), colorPicker->getFirstColor(),Toolsettings->getLineWidth());
int yMin = 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)));
this->Canvas->image->drawPoint(QPoint(i, yMin), colorPicker->getFirstColor(),Toolsettings->getLineWidth());
this->Canvas->image->drawPoint(QPoint(i, yMax), colorPicker->getFirstColor(),Toolsettings->getLineWidth());
}
}
@@ -69,7 +69,7 @@ void IntelliToolCircle::onMouseLeftReleased(int x, int y){
void IntelliToolCircle::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value);
Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
}
void IntelliToolCircle::onMouseMoved(int x, int y){

View File

@@ -6,12 +6,12 @@
#include <queue>
IntelliToolFloodFill::IntelliToolFloodFill(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker, Toolsettings){
this->ActiveType = Tooltype::FLOODFILL;
: IntelliTool(Area, colorPicker, Toolsettings){
this->ActiveType = Tooltype::FLOODFILL;
}
IntelliToolFloodFill::~IntelliToolFloodFill(){
IntelliTool::onMouseRightPressed(0,0);
IntelliTool::onMouseRightPressed(0,0);
}
void IntelliToolFloodFill::onMouseRightPressed(int x, int y){

View File

@@ -4,12 +4,12 @@
#include "QInputDialog"
IntelliToolLine::IntelliToolLine(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker, Toolsettings){
this->ActiveType = Tooltype::LINE;
: IntelliTool(Area, colorPicker, Toolsettings){
this->ActiveType = Tooltype::LINE;
}
IntelliToolLine::~IntelliToolLine(){
IntelliTool::onMouseRightPressed(0,0);
IntelliTool::onMouseRightPressed(0,0);
}
void IntelliToolLine::onMouseRightPressed(int x, int y){
@@ -23,7 +23,7 @@ void IntelliToolLine::onMouseRightReleased(int x, int y){
void IntelliToolLine::onMouseLeftPressed(int x, int y){
IntelliTool::onMouseLeftPressed(x,y);
this->lineStartingPoint=QPoint(x,y);
this->Canvas->image->drawPoint(lineStartingPoint, colorPicker->getFirstColor(),Toolsettings->getLineWidth());
this->Canvas->image->drawPoint(lineStartingPoint, colorPicker->getFirstColor(),Toolsettings->getLineWidth());
Canvas->image->calculateVisiblity();
}
@@ -33,21 +33,21 @@ void IntelliToolLine::onMouseLeftReleased(int x, int y){
void IntelliToolLine::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value);
Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
}
void IntelliToolLine::onMouseMoved(int x, int y){
if(this->isDrawing) {
this->Canvas->image->drawPlain(Qt::transparent);
QPoint next(x,y);
switch(Toolsettings->getLinestyle()) {
case IntelliToolsettings::LineStyle::SOLID_LINE:
this->Canvas->image->drawLine(lineStartingPoint,next,colorPicker->getFirstColor(),Toolsettings->getLineWidth());
switch(Toolsettings->getLinestyle()) {
case IntelliToolsettings::LineStyle::SOLID_LINE:
this->Canvas->image->drawLine(lineStartingPoint,next,colorPicker->getFirstColor(),Toolsettings->getLineWidth());
break;
case IntelliToolsettings::LineStyle::DOTTED_LINE:
case IntelliToolsettings::LineStyle::DOTTED_LINE:
QPoint p1 =lineStartingPoint.x() <= next.x() ? lineStartingPoint : next;
QPoint p2 =lineStartingPoint.x() < next.x() ? next : lineStartingPoint;
int m = static_cast<int>(static_cast<float>(p2.y()-p1.y())/static_cast<float>(p2.x()-p1.x())+0.5f);
int m = static_cast<int>(static_cast<float>(p2.y()-p1.y())/static_cast<float>(p2.x()-p1.x())+0.5f);
int c = lineStartingPoint.y()-lineStartingPoint.x()*m;
break;

View File

@@ -5,12 +5,12 @@
#include "QInputDialog"
IntelliToolPen::IntelliToolPen(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker, Toolsettings){
this->ActiveType = Tooltype::PEN;
: IntelliTool(Area, colorPicker, Toolsettings){
this->ActiveType = Tooltype::PEN;
}
IntelliToolPen::~IntelliToolPen(){
IntelliTool::onMouseRightPressed(0,0);
IntelliTool::onMouseRightPressed(0,0);
}
void IntelliToolPen::onMouseRightPressed(int x, int y){
@@ -24,7 +24,7 @@ void IntelliToolPen::onMouseRightReleased(int x, int y){
void IntelliToolPen::onMouseLeftPressed(int x, int y){
IntelliTool::onMouseLeftPressed(x,y);
this->previousPoint=QPoint(x,y);
this->Canvas->image->drawPoint(previousPoint, colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->Canvas->image->drawPoint(previousPoint, colorPicker->getFirstColor(), Toolsettings->getLineWidth());
Canvas->image->calculateVisiblity();
}
@@ -35,7 +35,7 @@ void IntelliToolPen::onMouseLeftReleased(int x, int y){
void IntelliToolPen::onMouseMoved(int x, int y){
if(this->isDrawing) {
QPoint newPoint(x,y);
this->Canvas->image->drawLine(this->previousPoint, newPoint, colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->Canvas->image->drawLine(this->previousPoint, newPoint, colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->previousPoint=newPoint;
}
IntelliTool::onMouseMoved(x,y);
@@ -43,5 +43,5 @@ void IntelliToolPen::onMouseMoved(int x, int y){
void IntelliToolPen::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value);
Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
}

View File

@@ -3,12 +3,12 @@
#include "QColorDialog"
IntelliToolPlainTool::IntelliToolPlainTool(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker, Toolsettings){
this->ActiveType = Tooltype::PLAIN;
: IntelliTool(Area, colorPicker, Toolsettings){
this->ActiveType = Tooltype::PLAIN;
}
IntelliToolPlainTool::~IntelliToolPlainTool(){
IntelliTool::onMouseRightPressed(0,0);
IntelliTool::onMouseRightPressed(0,0);
}
void IntelliToolPlainTool::onMouseLeftPressed(int x, int y){

View File

@@ -5,63 +5,63 @@
#include <QDebug>
IntelliToolPolygon::IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker, Toolsettings){
: IntelliTool(Area, colorPicker, Toolsettings){
isPointNearStart = false;
isDrawing = false;
isInside = false;
this->ActiveType = Tooltype::POLYGON;
isInside = false;
this->ActiveType = Tooltype::POLYGON;
}
IntelliToolPolygon::~IntelliToolPolygon(){
if(isDrawing){
IntelliTool::onMouseRightPressed(0,0);
}
if(isDrawing) {
IntelliTool::onMouseRightPressed(0,0);
}
}
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()){
std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(Area->getPolygonDataOfRealLayer());
QPoint Point(x,y);
isInside = IntelliTriangulation::isInPolygon(Triangles,Point);
}
else if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::Raster_Image && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()){
isInside = true;
}
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());
QPoint Point(x,y);
isInside = IntelliTriangulation::isInPolygon(Triangles,Point);
}
else if(!isDrawing && Area->getTypeOfImageRealLayer() == IntelliImage::ImageType::RASTERIMAGE && x > 0 && y > 0 && x<Area->getWidthOfActive() && y<Area->getHeightOfActive()) {
isInside = true;
}
if(isInside && !isDrawing) {
if(isInside && !isDrawing) {
IntelliTool::onMouseLeftPressed(x,y);
QPoint drawingPoint = QPoint(x,y);
isDrawing = true;
QPointList.push_back(drawingPoint);
this->Canvas->image->drawPoint(QPointList.back(), colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->Canvas->image->drawPoint(QPointList.back(), colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->Canvas->image->calculateVisiblity();
}
else if(isDrawing && isNearStart(x,y,QPointList.front())) {
if(QPointList.size() > 2){
isPointNearStart = true;
this->Canvas->image->drawLine(QPointList.back(), QPointList.front(), colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->Canvas->image->calculateVisiblity();
}
else{
isInside = false;
isDrawing = false;
QPointList.clear();
IntelliTool::onMouseRightPressed(x,y);
}
if(QPointList.size() > 2) {
isPointNearStart = true;
this->Canvas->image->drawLine(QPointList.back(), QPointList.front(), colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->Canvas->image->calculateVisiblity();
}
else{
isInside = false;
isDrawing = false;
QPointList.clear();
IntelliTool::onMouseRightPressed(x,y);
}
}
else if(isDrawing) {
QPoint drawingPoint(x,y);
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());
this->Canvas->image->calculateVisiblity();
}
}
void IntelliToolPolygon::onMouseRightPressed(int x, int y){
isInside = false;
isInside = false;
isDrawing = false;
isPointNearStart = false;
QPointList.clear();
@@ -69,14 +69,14 @@ void IntelliToolPolygon::onMouseRightPressed(int x, int y){
}
void IntelliToolPolygon::onMouseLeftReleased(int x, int y){
if(isPointNearStart) {
isInside = false;
if(isPointNearStart) {
isInside = false;
isPointNearStart = false;
isDrawing = false;
std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(QPointList);
QPoint Point;
QColor colorTwo(colorPicker->getSecondColor());
colorTwo.setAlpha(Toolsettings->getInnerAlpha());
colorTwo.setAlpha(Toolsettings->getInnerAlpha());
for(int i = 0; i < activeLayer->width; i++) {
for(int j = 0; j < activeLayer->height; j++) {
Point = QPoint(i,j);
@@ -85,9 +85,9 @@ void IntelliToolPolygon::onMouseLeftReleased(int x, int y){
}
}
}
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()));
this->Canvas->image->drawLine(QPointList[static_cast<unsigned long long>(i)], QPointList[static_cast<unsigned long long>(next)], colorPicker->getFirstColor(), Toolsettings->getLineWidth());
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()));
this->Canvas->image->drawLine(QPointList[static_cast<unsigned long long>(i)], QPointList[static_cast<unsigned long long>(next)], colorPicker->getFirstColor(), Toolsettings->getLineWidth());
}
QPointList.clear();
IntelliTool::onMouseLeftReleased(x,y);
@@ -101,7 +101,7 @@ void IntelliToolPolygon::onMouseRightReleased(int x, int y){
void IntelliToolPolygon::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value);
if(!isDrawing) {
Toolsettings->setLineWidth(Toolsettings->getLineWidth() + value);
Toolsettings->setLineWidth(Toolsettings->getLineWidth() + value);
}
}
@@ -113,7 +113,7 @@ bool IntelliToolPolygon::isNearStart(int x, int y, QPoint Startpoint){
bool isNear = false;
int StartX = Startpoint.x();
int StartY = Startpoint.y();
int valueToNear = 5;
int valueToNear = 5;
for(int i = StartX - valueToNear; i < StartX + valueToNear; i++) {
for(int j = StartY - valueToNear; j < StartY + valueToNear; j++) {

View File

@@ -3,30 +3,30 @@
#include "QInputDialog"
IntelliToolRectangle::IntelliToolRectangle(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker, Toolsettings){
this->ActiveType = Tooltype::RECTANGLE;
: IntelliTool(Area, colorPicker, Toolsettings){
this->ActiveType = Tooltype::RECTANGLE;
}
IntelliToolRectangle::~IntelliToolRectangle(){
IntelliTool::onMouseRightPressed(0,0);
IntelliTool::onMouseRightPressed(0,0);
}
void IntelliToolRectangle::drawRectangle(QPoint otherCorner){
int xMin = std::min(originCorner.x(), otherCorner.x());
int xMax = std::max(originCorner.x(), otherCorner.x());
int xMin = std::min(originCorner.x(), otherCorner.x());
int xMax = std::max(originCorner.x(), otherCorner.x());
int yMin = std::min(originCorner.y(), otherCorner.y());
int yMax = std::max(originCorner.y(), otherCorner.y());
int yMin = std::min(originCorner.y(), otherCorner.y());
int yMax = std::max(originCorner.y(), otherCorner.y());
QColor clr = colorPicker->getSecondColor();
clr.setAlpha(Toolsettings->getInnerAlpha());
clr.setAlpha(Toolsettings->getInnerAlpha());
for(int y=yMin; y<=yMax; y++) {
this->Canvas->image->drawLine(QPoint(xMin,y), QPoint(xMax, y), clr, 1);
}
this->Canvas->image->drawLine(QPoint(xMin, yMin),QPoint(xMin, yMax), this->colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->Canvas->image->drawLine(QPoint(xMin, yMin),QPoint(xMax, yMin), this->colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->Canvas->image->drawLine(QPoint(xMax, yMax),QPoint(xMin, yMax), this->colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->Canvas->image->drawLine(QPoint(xMax, yMax),QPoint(xMax, yMin), this->colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->Canvas->image->drawLine(QPoint(xMin, yMin),QPoint(xMin, yMax), this->colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->Canvas->image->drawLine(QPoint(xMin, yMin),QPoint(xMax, yMin), this->colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->Canvas->image->drawLine(QPoint(xMax, yMax),QPoint(xMin, yMax), this->colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->Canvas->image->drawLine(QPoint(xMax, yMax),QPoint(xMax, yMin), this->colorPicker->getFirstColor(), Toolsettings->getLineWidth());
}
void IntelliToolRectangle::onMouseRightPressed(int x, int y){
@@ -59,5 +59,5 @@ void IntelliToolRectangle::onMouseMoved(int x, int y){
void IntelliToolRectangle::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value);
Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
}