mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-12 19:40:28 +02:00
Merge branch 'dev' into RechteckTool
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,6 +13,7 @@ CMakeLists.txt.user*
|
||||
/share/qtcreator/fonts/
|
||||
/share/qtcreator/generic-highlighter/
|
||||
/share/qtcreator/qmldesigner/QtProject/
|
||||
/build-*/
|
||||
app_version.h
|
||||
phony.c
|
||||
|
||||
|
||||
@@ -52,6 +52,16 @@ void IntelliImage::drawPixel(const QPoint &p1, const QColor& color){
|
||||
painter.drawPoint(p1);
|
||||
}
|
||||
|
||||
void IntelliImage::drawPoint(const QPoint &p1, const QColor& color, const int& penWidth){
|
||||
// Used to draw on the widget
|
||||
QPainter painter(&imageData);
|
||||
|
||||
// Set the current settings for the pen
|
||||
painter.setPen(QPen(color, penWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
// Draw a line from the last registered point to the current
|
||||
painter.drawPoint(p1);
|
||||
}
|
||||
|
||||
void IntelliImage::drawLine(const QPoint &p1, const QPoint& p2, const QColor& color, const int& penWidth){
|
||||
// Used to draw on the widget
|
||||
QPainter painter(&imageData);
|
||||
|
||||
@@ -30,6 +30,7 @@ public:
|
||||
|
||||
//start on top left
|
||||
virtual void drawPixel(const QPoint &p1, const QColor& color);
|
||||
virtual void drawPoint(const QPoint &p1, const QColor& color, const int& penWidth);
|
||||
virtual void drawLine(const QPoint &p1, const QPoint& p2, const QColor& color, const int& penWidth);
|
||||
virtual void drawPlain(const QColor& color);
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ SOURCES += \
|
||||
IntelliHelper/IntelliHelper.cpp \
|
||||
Layer/PaintingArea.cpp \
|
||||
Tool/IntelliTool.cpp \
|
||||
Tool/IntelliToolCircle.cpp \
|
||||
Tool/IntelliToolLine.cpp \
|
||||
Tool/IntelliToolPen.cpp \
|
||||
Tool/IntelliToolPlain.cpp \
|
||||
@@ -38,9 +39,11 @@ HEADERS += \
|
||||
IntelliHelper/IntelliHelper.h \
|
||||
Layer/PaintingArea.h \
|
||||
Tool/IntelliTool.h \
|
||||
Tool/IntelliToolCircle.h \
|
||||
Tool/IntelliToolLine.h \
|
||||
Tool/IntelliToolPen.h \
|
||||
Tool/IntelliToolPlain.h
|
||||
Tool/IntelliToolPlain.h \
|
||||
Tool/intellitoolcircle.h
|
||||
|
||||
FORMS += \
|
||||
widget.ui
|
||||
|
||||
@@ -13,9 +13,11 @@
|
||||
#include "Tool/IntelliToolPen.h"
|
||||
#include "Tool/IntelliToolPlain.h"
|
||||
#include "Tool/IntelliToolLine.h"
|
||||
#include "Tool/IntelliToolCircle.h"
|
||||
|
||||
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent)
|
||||
:QWidget(parent){
|
||||
//test yout tool here and reset after accomplished test
|
||||
this->Tool = nullptr;
|
||||
this->setUp(maxWidth, maxHeight);
|
||||
//tetsing
|
||||
@@ -32,7 +34,7 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent)
|
||||
layerBundle[1].image->drawPlain(QColor(0,255,0,255));
|
||||
layerBundle[1].alpha=200;
|
||||
|
||||
activeLayer=0;
|
||||
activeLayer=1;
|
||||
}
|
||||
|
||||
PaintingArea::~PaintingArea(){
|
||||
|
||||
80
src/Tool/IntelliToolCircle.cpp
Normal file
80
src/Tool/IntelliToolCircle.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
#include "IntelliToolCircle.h"
|
||||
#include "Layer/PaintingArea.h"
|
||||
#include "QInputDialog"
|
||||
#include <cmath>
|
||||
|
||||
IntelliToolCircle::IntelliToolCircle(PaintingArea* Area, IntelliColorPicker* colorPicker)
|
||||
:IntelliTool(Area, colorPicker){
|
||||
this->alphaInner = QInputDialog::getInt(nullptr,"Inner Alpha Value", "Value:", 0,0,255,1);
|
||||
this->edgeWidth = QInputDialog::getInt(nullptr,"Outer edge width", "Value:", 0,1,255,1);
|
||||
}
|
||||
|
||||
IntelliToolCircle::~IntelliToolCircle(){
|
||||
|
||||
}
|
||||
|
||||
void IntelliToolCircle::drawCyrcle(int radius){
|
||||
int outer = radius+20;
|
||||
QColor inner = this->colorPicker->getSecondColor();
|
||||
inner.setAlpha(alphaInner);
|
||||
int yMin, yMax, xMin, xMax;
|
||||
yMin = Middle.y()-radius;
|
||||
yMax = Middle.y()+radius;
|
||||
// x = x0+-sqrt(r2-(y-y0)2)
|
||||
for(int i=yMin; i<=yMax; i++){
|
||||
xMin = Middle.x()-sqrt(pow(radius,2)-pow(i-Middle.y(),2));
|
||||
xMax = Middle.x()+sqrt(pow(radius,2)-pow(i-Middle.y(),2));
|
||||
this->Canvas->image->drawLine(QPoint(xMin,i), QPoint(xMax,i),inner,1);
|
||||
}
|
||||
|
||||
//TODO implement circle drawing algorithm
|
||||
radius = radius +(this->edgeWidth/2.)-0.5;
|
||||
yMin = (Middle.y()-radius);
|
||||
yMax = (Middle.y()+radius);
|
||||
for(int i=yMin; i<=yMax; i++){
|
||||
xMin = Middle.x()-sqrt(pow(radius,2)-pow(i-Middle.y(),2));
|
||||
xMax = Middle.x()+sqrt(pow(radius,2)-pow(i-Middle.y(),2));
|
||||
this->Canvas->image->drawPoint(QPoint(xMin,i), colorPicker->getFirstColor(),edgeWidth);
|
||||
this->Canvas->image->drawPoint(QPoint(xMax,i), colorPicker->getFirstColor(),edgeWidth);
|
||||
}
|
||||
|
||||
xMin = (Middle.x()-radius);
|
||||
xMax = (Middle.x()+radius);
|
||||
for(int i=xMin; i<=xMax; i++){
|
||||
int yMin = Middle.y()-sqrt(pow(radius,2)-pow(i-Middle.x(),2));
|
||||
int yMax = Middle.y()+sqrt(pow(radius,2)-pow(i-Middle.x(),2));
|
||||
this->Canvas->image->drawPoint(QPoint(i, yMin), colorPicker->getFirstColor(),edgeWidth);
|
||||
this->Canvas->image->drawPoint(QPoint(i, yMax), colorPicker->getFirstColor(),edgeWidth);
|
||||
}
|
||||
}
|
||||
|
||||
void IntelliToolCircle::onMouseRightPressed(int x, int y){
|
||||
IntelliTool::onMouseRightPressed(x,y);
|
||||
}
|
||||
|
||||
void IntelliToolCircle::onMouseRightReleased(int x, int y){
|
||||
IntelliTool::onMouseRightReleased(x,y);
|
||||
}
|
||||
|
||||
void IntelliToolCircle::onMouseLeftPressed(int x, int y){
|
||||
IntelliTool::onMouseLeftPressed(x,y);
|
||||
this->Middle=QPoint(x,y);
|
||||
int radius = 1;
|
||||
drawCyrcle(radius);
|
||||
Canvas->image->calculateVisiblity();
|
||||
}
|
||||
|
||||
void IntelliToolCircle::onMouseLeftReleased(int x, int y){
|
||||
IntelliTool::onMouseLeftReleased(x,y);
|
||||
}
|
||||
|
||||
void IntelliToolCircle::onMouseMoved(int x, int y){
|
||||
IntelliTool::onMouseMoved(x,y);
|
||||
if(this->drawing){
|
||||
this->Canvas->image->drawPlain(Qt::transparent);
|
||||
QPoint next(x,y);
|
||||
int radius = static_cast<int>(sqrt(pow((Middle.x()-x),2)+pow((Middle.y()-y),2)));
|
||||
drawCyrcle(radius);
|
||||
}
|
||||
IntelliTool::onMouseMoved(x,y);
|
||||
}
|
||||
26
src/Tool/IntelliToolCircle.h
Normal file
26
src/Tool/IntelliToolCircle.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef INTELLITOOLCIRCLE_H
|
||||
#define INTELLITOOLCIRCLE_H
|
||||
#include "IntelliTool.h"
|
||||
|
||||
#include "QColor"
|
||||
#include "QPoint"
|
||||
|
||||
class IntelliToolCircle : public IntelliTool{
|
||||
void drawCyrcle(int radius);
|
||||
|
||||
QPoint Middle;
|
||||
int alphaInner;
|
||||
int edgeWidth;
|
||||
public:
|
||||
IntelliToolCircle(PaintingArea* Area, IntelliColorPicker* colorPicker);
|
||||
virtual ~IntelliToolCircle() override;
|
||||
|
||||
virtual void onMouseRightPressed(int x, int y);
|
||||
virtual void onMouseRightReleased(int x, int y);
|
||||
virtual void onMouseLeftPressed(int x, int y);
|
||||
virtual void onMouseLeftReleased(int x, int y);
|
||||
|
||||
virtual void onMouseMoved(int x, int y);
|
||||
};
|
||||
|
||||
#endif // INTELLITOOLCIRCLE_H
|
||||
Reference in New Issue
Block a user