mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-15 21:00:37 +02:00
Polygon Update
This commit is contained in:
@@ -18,7 +18,8 @@ IntelliPhotoGui::IntelliPhotoGui(){
|
|||||||
setIntelliStyle();
|
setIntelliStyle();
|
||||||
|
|
||||||
// Size the app
|
// Size the app
|
||||||
showMaximized();
|
resize(600,600);
|
||||||
|
//showMaximized();
|
||||||
}
|
}
|
||||||
|
|
||||||
// User tried to close the app
|
// User tried to close the app
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ private:
|
|||||||
|
|
||||||
//main GUI elements
|
//main GUI elements
|
||||||
QWidget* centralGuiWidget;
|
QWidget* centralGuiWidget;
|
||||||
|
QPushButton* Toolmanager;
|
||||||
QGridLayout *mainLayout;
|
QGridLayout *mainLayout;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ SOURCES += \
|
|||||||
Tool/IntelliToolLine.cpp \
|
Tool/IntelliToolLine.cpp \
|
||||||
Tool/IntelliToolPen.cpp \
|
Tool/IntelliToolPen.cpp \
|
||||||
Tool/IntelliToolPlain.cpp \
|
Tool/IntelliToolPlain.cpp \
|
||||||
|
Tool/IntelliToolPolygon.cpp \
|
||||||
Tool/IntelliToolRechteck.cpp \
|
Tool/IntelliToolRechteck.cpp \
|
||||||
main.cpp
|
main.cpp
|
||||||
|
|
||||||
@@ -44,6 +45,7 @@ HEADERS += \
|
|||||||
Tool/IntelliToolLine.h \
|
Tool/IntelliToolLine.h \
|
||||||
Tool/IntelliToolPen.h \
|
Tool/IntelliToolPen.h \
|
||||||
Tool/IntelliToolPlain.h \
|
Tool/IntelliToolPlain.h \
|
||||||
|
Tool/IntelliToolPolygon.h \
|
||||||
Tool/IntelliToolRechteck.h \
|
Tool/IntelliToolRechteck.h \
|
||||||
Tool/intellitoolcircle.h
|
Tool/intellitoolcircle.h
|
||||||
|
|
||||||
|
|||||||
@@ -15,11 +15,12 @@
|
|||||||
#include "Tool/IntelliToolLine.h"
|
#include "Tool/IntelliToolLine.h"
|
||||||
#include "Tool/IntelliToolCircle.h"
|
#include "Tool/IntelliToolCircle.h"
|
||||||
#include "Tool/IntelliToolRechteck.h"
|
#include "Tool/IntelliToolRechteck.h"
|
||||||
|
#include "Tool/IntelliToolPolygon.h"
|
||||||
|
|
||||||
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent)
|
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent)
|
||||||
:QWidget(parent){
|
:QWidget(parent){
|
||||||
//test yout tool here and reset after accomplished test
|
//test yout tool here and reset after accomplished test
|
||||||
this->Tool = new IntelliToolRechteck(this, &colorPicker);
|
this->Tool = new IntelliToolPolygon(this, &colorPicker);
|
||||||
this->setUp(maxWidth, maxHeight);
|
this->setUp(maxWidth, maxHeight);
|
||||||
//tetsing
|
//tetsing
|
||||||
this->addLayer(200,200,0,0,ImageType::Shaped_Image);
|
this->addLayer(200,200,0,0,ImageType::Shaped_Image);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class PaintingArea : public QWidget
|
|||||||
friend IntelliTool;
|
friend IntelliTool;
|
||||||
public:
|
public:
|
||||||
PaintingArea(int maxWidth=600, int maxHeight=600, QWidget *parent = nullptr);
|
PaintingArea(int maxWidth=600, int maxHeight=600, QWidget *parent = nullptr);
|
||||||
~PaintingArea();
|
~PaintingArea() override;
|
||||||
|
|
||||||
// Handles all events
|
// Handles all events
|
||||||
bool open(const QString &fileName);
|
bool open(const QString &fileName);
|
||||||
|
|||||||
87
src/Tool/IntelliToolPolygon.cpp
Normal file
87
src/Tool/IntelliToolPolygon.cpp
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
#include "IntelliToolPolygon.h"
|
||||||
|
#include "Layer/PaintingArea.h"
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QCursor>
|
||||||
|
|
||||||
|
IntelliToolPolygon::IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker)
|
||||||
|
:IntelliTool(Area, colorPicker){
|
||||||
|
lineWidth = 5;
|
||||||
|
isDrawing = false;
|
||||||
|
PointIsNearStart = false;
|
||||||
|
drawingPoint.setX(0);
|
||||||
|
drawingPoint.setY(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
|
||||||
|
qDebug() << x << y;
|
||||||
|
if(!isDrawing && x > 0 && y > 0){
|
||||||
|
isDrawing = true;
|
||||||
|
drawingPoint.setX(x);
|
||||||
|
drawingPoint.setY(y);
|
||||||
|
QPointList.push_back(drawingPoint);
|
||||||
|
IntelliTool::onMouseLeftPressed(x,y);
|
||||||
|
this->Canvas->image->drawPlain(Qt::transparent);
|
||||||
|
this->Canvas->image->drawPoint(QPointList.back(), colorPicker->getFirstColor(), lineWidth);
|
||||||
|
}
|
||||||
|
else if(isDrawing && isNearStart(x,y,QPointList.front())){
|
||||||
|
PointIsNearStart = isNearStart(x,y,QPointList.front());
|
||||||
|
this->Canvas->image->drawLine(QPointList.back(), QPointList.front(), colorPicker->getFirstColor(), lineWidth);s
|
||||||
|
}
|
||||||
|
else if(isDrawing){
|
||||||
|
drawingPoint.setX(x);
|
||||||
|
drawingPoint.setY(y);
|
||||||
|
QPointList.push_back(drawingPoint);
|
||||||
|
this->Canvas->image->drawLine(QPointList.operator[](QPointList.size() - 2), QPointList.back(), colorPicker->getFirstColor(), lineWidth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolPolygon::onMouseRightPressed(int x, int y){
|
||||||
|
isDrawing = false;
|
||||||
|
PointIsNearStart = false;
|
||||||
|
QPointList.clear();
|
||||||
|
IntelliTool::onMouseRightPressed(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolPolygon::onMouseLeftReleased(int x, int y){
|
||||||
|
if(PointIsNearStart && QPointList.size() > 1){
|
||||||
|
PointIsNearStart = false;
|
||||||
|
isDrawing = false;
|
||||||
|
QPointList.clear();
|
||||||
|
IntelliTool::onMouseLeftReleased(x,y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolPolygon::onMouseRightReleased(int x, int y){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolPolygon::onWheelScrolled(int value){
|
||||||
|
if(!isDrawing){
|
||||||
|
if(lineWidth + value < 10){
|
||||||
|
lineWidth += value;
|
||||||
|
}
|
||||||
|
if(lineWidth < 1){
|
||||||
|
lineWidth = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolPolygon::onMouseMoved(int x, int y){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IntelliToolPolygon::isNearStart(int x, int y, QPoint Startpoint){
|
||||||
|
bool isNear = false;
|
||||||
|
int StartX = Startpoint.x();
|
||||||
|
int StartY = Startpoint.y();
|
||||||
|
int valueToNear = 10;
|
||||||
|
|
||||||
|
for(int i = StartX - valueToNear; i < StartX + valueToNear; i++){
|
||||||
|
for(int j = StartY - valueToNear; j < StartY + valueToNear; j++){
|
||||||
|
if((i == x) && (j == y)){
|
||||||
|
isNear = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isNear;
|
||||||
|
}
|
||||||
33
src/Tool/IntelliToolPolygon.h
Normal file
33
src/Tool/IntelliToolPolygon.h
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef INTELLITOOLPOLYGON_H
|
||||||
|
#define INTELLITOOLPOLYGON_H
|
||||||
|
|
||||||
|
#include "IntelliTool.h"
|
||||||
|
#include <vector>
|
||||||
|
#include <QPoint>
|
||||||
|
|
||||||
|
class IntelliToolPolygon : public IntelliTool
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* colorPicker);
|
||||||
|
|
||||||
|
virtual void onMouseLeftPressed(int x, int y) override;
|
||||||
|
virtual void onMouseLeftReleased(int x, int y) override;
|
||||||
|
virtual void onMouseRightPressed(int x, int y) override;
|
||||||
|
virtual void onMouseRightReleased(int x, int y) override;
|
||||||
|
|
||||||
|
virtual void onWheelScrolled(int value) override;
|
||||||
|
|
||||||
|
virtual void onMouseMoved(int x, int y) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool isNearStart(int x, int y, QPoint Startpoint);
|
||||||
|
|
||||||
|
int lineWidth;
|
||||||
|
bool isDrawing;
|
||||||
|
bool PointIsNearStart;
|
||||||
|
QPoint drawingPoint;
|
||||||
|
std::vector<QPoint> QPointList;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // INTELLITOOLPOLYGON_H
|
||||||
Reference in New Issue
Block a user