Linenverwaltung

This commit is contained in:
AshBastian
2020-01-08 16:41:56 +01:00
parent 6d4a4e52b5
commit c321a181b1
14 changed files with 65 additions and 88 deletions

View File

@@ -436,9 +436,11 @@ void IntelliPhotoGui::createGui(){
// create Gui elements
paintingArea = new PaintingArea();
Push
// set gui elements
mainLayout->addWidget(paintingArea);
mainLayout->addWidget(paintingArea,1,1,10,10);
mainLayout->addWiget();
}
void IntelliPhotoGui::setIntelliStyle(){

View File

@@ -86,6 +86,8 @@ bool saveFile(const QByteArray &fileFormat);
// What we'll draw on
PaintingArea* paintingArea;
QPushButton* PushButton;
// The menu widgets
QMenu*saveAsMenu;
QMenu*fileMenu;
@@ -135,7 +137,7 @@ QList<QAction*> actionSaveAs;
// main GUI elements
QWidget* centralGuiWidget;
QGridLayout*mainLayout;
QGridLayout* mainLayout;
};
#endif

View File

@@ -1,4 +1,5 @@
#include "IntelliToolsettings.h"
#include <QInputDialog>
IntelliToolsettings::IntelliToolsettings()
{
@@ -15,8 +16,36 @@ int IntelliToolsettings::getLineWidth(){
return lineWidth;
}
void IntelliToolsettings::setLineWidth(){
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;
}
int IntelliToolsettings::getInnerAlpha(){
return innerAlpha;
return this->innerAlpha;
}
void IntelliToolsettings::setInnerAlpha(){
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;
}
IntelliToolsettings::LineStyle IntelliToolsettings::getLinestyle(){

View File

@@ -13,7 +13,11 @@ public:
IntelliToolsettings();
virtual ~IntelliToolsettings();
int getLineWidth();
void setLineWidth();
void setLineWidth(int LineWidth);
int getInnerAlpha();
void setInnerAlpha();
void setInnerAlpha(int innerAlpha);
LineStyle getLinestyle();
private:

View File

@@ -5,8 +5,6 @@
IntelliToolCircle::IntelliToolCircle(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker, Toolsettings){
this->innerAlpha = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 0,0,255,1);
this->borderWidth = QInputDialog::getInt(nullptr,"Outer edge width", "Value:", 0,1,255,1);
this->ActiveType = Tooltype::CIRCLE;
}
@@ -17,7 +15,7 @@ IntelliToolCircle::~IntelliToolCircle(){
void IntelliToolCircle::drawCircle(int radius){
int outer = radius+20;
QColor inner = this->colorPicker->getSecondColor();
inner.setAlpha(innerAlpha);
inner.setAlpha(Toolsettings->getInnerAlpha());
int yMin, yMax, xMin, xMax;
yMin = centerPoint.y()-radius;
yMax = centerPoint.y()+radius;
@@ -29,14 +27,14 @@ void IntelliToolCircle::drawCircle(int radius){
}
//TODO implement circle drawing algorithm bresenham
radius = static_cast<int>(radius +(this->borderWidth/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(),borderWidth);
this->Canvas->image->drawPoint(QPoint(xMax,i), colorPicker->getFirstColor(),borderWidth);
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);
@@ -44,8 +42,8 @@ void IntelliToolCircle::drawCircle(int 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(),borderWidth);
this->Canvas->image->drawPoint(QPoint(i, yMax), colorPicker->getFirstColor(),borderWidth);
this->Canvas->image->drawPoint(QPoint(i, yMin), colorPicker->getFirstColor(),Toolsettings->getLineWidth());
this->Canvas->image->drawPoint(QPoint(i, yMax), colorPicker->getFirstColor(),Toolsettings->getLineWidth());
}
}
@@ -71,10 +69,7 @@ void IntelliToolCircle::onMouseLeftReleased(int x, int y){
void IntelliToolCircle::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value);
this->borderWidth+=value;
if(this->borderWidth<=0) {
this->borderWidth=1;
}
Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
}
void IntelliToolCircle::onMouseMoved(int x, int y){

View File

@@ -19,15 +19,6 @@ void drawCircle(int radius);
*/
QPoint centerPoint;
/*!
* \brief The alpha value of the inner circle.
*/
int innerAlpha;
/*!
* \brief The width of the outer circle edge.
*/
int borderWidth;
public:
/*!
* \brief A constructor setting the general paintingArea and colorPicker. And reading in the inner alpha and edgeWidth.

View File

@@ -5,7 +5,6 @@
IntelliToolLine::IntelliToolLine(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker, Toolsettings){
this->lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1);
this->ActiveType = Tooltype::LINE;
}
@@ -24,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(),lineWidth);
this->Canvas->image->drawPoint(lineStartingPoint, colorPicker->getFirstColor(),Toolsettings->getLineWidth());
Canvas->image->calculateVisiblity();
}
@@ -34,10 +33,7 @@ void IntelliToolLine::onMouseLeftReleased(int x, int y){
void IntelliToolLine::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value);
this->lineWidth+=value;
if(this->lineWidth<=0) {
this->lineWidth=1;
}
Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
}
void IntelliToolLine::onMouseMoved(int x, int y){
@@ -46,7 +42,7 @@ void IntelliToolLine::onMouseMoved(int x, int y){
QPoint next(x,y);
switch(Toolsettings->getLinestyle()) {
case IntelliToolsettings::LineStyle::SOLID_LINE:
this->Canvas->image->drawLine(lineStartingPoint,next,colorPicker->getFirstColor(),lineWidth);
this->Canvas->image->drawLine(lineStartingPoint,next,colorPicker->getFirstColor(),Toolsettings->getLineWidth());
break;
case IntelliToolsettings::LineStyle::DOTTED_LINE:
QPoint p1 =lineStartingPoint.x() <= next.x() ? lineStartingPoint : next;

View File

@@ -13,10 +13,6 @@ class IntelliToolLine : public IntelliTool {
*/
QPoint lineStartingPoint;
/*!
* \brief The width of the line to draw.
*/
int lineWidth;
public:
/*!

View File

@@ -6,7 +6,6 @@
IntelliToolPen::IntelliToolPen(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker, Toolsettings){
this->penWidth = QInputDialog::getInt(nullptr, "Pen width", "Width:", 1,0, 50, 1);
this->ActiveType = Tooltype::PEN;
}
@@ -25,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(), penWidth);
this->Canvas->image->drawPoint(previousPoint, colorPicker->getFirstColor(), Toolsettings->getLineWidth());
Canvas->image->calculateVisiblity();
}
@@ -36,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(), penWidth);
this->Canvas->image->drawLine(this->previousPoint, newPoint, colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->previousPoint=newPoint;
}
IntelliTool::onMouseMoved(x,y);
@@ -44,8 +43,5 @@ void IntelliToolPen::onMouseMoved(int x, int y){
void IntelliToolPen::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value);
this->penWidth+=value;
if(this->penWidth<=0) {
this->penWidth=1;
}
Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
}

View File

@@ -9,10 +9,6 @@
* \brief The IntelliToolPen class represents a tool to draw a line.
*/
class IntelliToolPen : public IntelliTool {
/*!
* \brief penWidth - The width of the Pen while drawing.
*/
int penWidth;
/*!
* \brief point - Represents the previous point to help drawing a line.
*/

View File

@@ -6,8 +6,6 @@
IntelliToolPolygon::IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker, Toolsettings){
this->innerAlpha = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 255,0,255,1);
lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",5,1,10,1);
isPointNearStart = false;
isDrawing = false;
isInside = false;
@@ -37,13 +35,13 @@ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
isDrawing = true;
QPointList.push_back(drawingPoint);
this->Canvas->image->drawPoint(QPointList.back(), colorPicker->getFirstColor(), lineWidth);
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(), lineWidth);
this->Canvas->image->drawLine(QPointList.back(), QPointList.front(), colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->Canvas->image->calculateVisiblity();
}
else{
@@ -57,7 +55,7 @@ void IntelliToolPolygon::onMouseLeftPressed(int x, int 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(), lineWidth);
this->Canvas->image->drawLine(QPointList[QPointList.size() - 2], QPointList[QPointList.size() - 1], colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->Canvas->image->calculateVisiblity();
}
}
@@ -78,7 +76,7 @@ void IntelliToolPolygon::onMouseLeftReleased(int x, int y){
std::vector<Triangle> Triangles = IntelliTriangulation::calculateTriangles(QPointList);
QPoint Point;
QColor colorTwo(colorPicker->getSecondColor());
colorTwo.setAlpha(innerAlpha);
colorTwo.setAlpha(Toolsettings->getInnerAlpha());
for(int i = 0; i < activeLayer->width; i++) {
for(int j = 0; j < activeLayer->height; j++) {
Point = QPoint(i,j);
@@ -89,7 +87,7 @@ 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(), lineWidth);
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);
@@ -103,12 +101,7 @@ void IntelliToolPolygon::onMouseRightReleased(int x, int y){
void IntelliToolPolygon::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value);
if(!isDrawing) {
if(lineWidth + value < 10) {
lineWidth += value;
}
if(lineWidth < 1) {
lineWidth = 1;
}
Toolsettings->setLineWidth(Toolsettings->getLineWidth() + value);
}
}

View File

@@ -19,11 +19,6 @@ class IntelliToolPolygon : public IntelliTool
*/
bool isNearStart(int x, int y, QPoint Startpoint);
/*!
* \brief LineWidth of the drawing polygon.
*/
int lineWidth;
/*!
* \brief IsDrawing true while drawing, else false.
*/
@@ -39,11 +34,6 @@ bool isInside;
*/
bool isPointNearStart;
/*!
* \brief The alpha value of the inner circle.
*/
int innerAlpha;
/*!
* \brief QPointList list of all points of the polygon.
*/

View File

@@ -4,8 +4,6 @@
IntelliToolRectangle::IntelliToolRectangle(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings)
: IntelliTool(Area, colorPicker, Toolsettings){
this->innerAlpha = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 0,0,255,1);
this->borderWidth = QInputDialog::getInt(nullptr,"Outer edge width", "Value:", 0,1,255,1);
this->ActiveType = Tooltype::RECTANGLE;
}
@@ -21,14 +19,14 @@ void IntelliToolRectangle::drawRectangle(QPoint otherCorner){
int yMax = std::max(originCorner.y(), otherCorner.y());
QColor clr = colorPicker->getSecondColor();
clr.setAlpha(innerAlpha);
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(), borderWidth);
this->Canvas->image->drawLine(QPoint(xMin, yMin),QPoint(xMax, yMin), this->colorPicker->getFirstColor(), borderWidth);
this->Canvas->image->drawLine(QPoint(xMax, yMax),QPoint(xMin, yMax), this->colorPicker->getFirstColor(), borderWidth);
this->Canvas->image->drawLine(QPoint(xMax, yMax),QPoint(xMax, yMin), this->colorPicker->getFirstColor(), borderWidth);
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){
@@ -61,8 +59,5 @@ void IntelliToolRectangle::onMouseMoved(int x, int y){
void IntelliToolRectangle::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value);
this->borderWidth+=value;
if(this->borderWidth<=0) {
this->borderWidth=1;
}
Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
}

View File

@@ -19,14 +19,6 @@ void drawRectangle(QPoint otherCorner);
* \brief origincorner - The first corner point of the rectangle.
*/
QPoint originCorner;
/*!
* \brief alphaInner- Represents the alpha value of the inside.
*/
int innerAlpha;
/*!
* \brief edgeWidth - The width of the rectangle edges.
*/
int borderWidth;
public:
/*!
* \brief A constructor setting the general paintingArea and colorPicker. And reading in the alphaInner and edgeWidth.