mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-14 20:30:32 +02:00
rectangle tool
This commit is contained in:
@@ -28,6 +28,7 @@ SOURCES += \
|
|||||||
Tool/IntelliToolLine.cpp \
|
Tool/IntelliToolLine.cpp \
|
||||||
Tool/IntelliToolPen.cpp \
|
Tool/IntelliToolPen.cpp \
|
||||||
Tool/IntelliToolPlain.cpp \
|
Tool/IntelliToolPlain.cpp \
|
||||||
|
Tool/IntelliToolRechteck.cpp \
|
||||||
main.cpp
|
main.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
@@ -43,6 +44,7 @@ HEADERS += \
|
|||||||
Tool/IntelliToolLine.h \
|
Tool/IntelliToolLine.h \
|
||||||
Tool/IntelliToolPen.h \
|
Tool/IntelliToolPen.h \
|
||||||
Tool/IntelliToolPlain.h \
|
Tool/IntelliToolPlain.h \
|
||||||
|
Tool/IntelliToolRechteck.h \
|
||||||
Tool/intellitoolcircle.h
|
Tool/intellitoolcircle.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "Tool/IntelliToolPlain.h"
|
#include "Tool/IntelliToolPlain.h"
|
||||||
#include "Tool/IntelliToolLine.h"
|
#include "Tool/IntelliToolLine.h"
|
||||||
#include "Tool/IntelliToolCircle.h"
|
#include "Tool/IntelliToolCircle.h"
|
||||||
|
#include "Tool/IntelliToolRechteck.h"
|
||||||
|
|
||||||
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent)
|
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent)
|
||||||
:QWidget(parent){
|
:QWidget(parent){
|
||||||
|
|||||||
60
src/Tool/IntelliToolRechteck.cpp
Normal file
60
src/Tool/IntelliToolRechteck.cpp
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
#include"IntelliToolRechteck.h"
|
||||||
|
#include "Layer/PaintingArea.h"
|
||||||
|
#include "QInputDialog"
|
||||||
|
|
||||||
|
IntelliToolRechteck::IntelliToolRechteck(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);
|
||||||
|
}
|
||||||
|
|
||||||
|
IntelliToolRechteck::~IntelliToolRechteck(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolRechteck::drawRechteck(QPoint otherCornor){
|
||||||
|
int xMin = std::min(originCornor.x(), otherCornor.x());
|
||||||
|
int xMax = std::max(originCornor.x(), otherCornor.x());
|
||||||
|
|
||||||
|
int yMin = std::min(originCornor.y(), otherCornor.y());
|
||||||
|
int yMax = std::max(originCornor.y(), otherCornor.y());
|
||||||
|
|
||||||
|
QColor clr = colorPicker->getSecondColor();
|
||||||
|
clr.setAlpha(alphaInner);
|
||||||
|
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(), edgeWidth);
|
||||||
|
this->Canvas->image->drawLine(QPoint(xMin, yMin),QPoint(xMax, yMin), this->colorPicker->getFirstColor(), edgeWidth);
|
||||||
|
this->Canvas->image->drawLine(QPoint(xMax, yMax),QPoint(xMin, yMax), this->colorPicker->getFirstColor(), edgeWidth);
|
||||||
|
this->Canvas->image->drawLine(QPoint(xMax, yMax),QPoint(xMax, yMin), this->colorPicker->getFirstColor(), edgeWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolRechteck::onMouseRightPressed(int x, int y){
|
||||||
|
IntelliTool::onMouseRightPressed(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolRechteck::onMouseRightReleased(int x, int y){
|
||||||
|
IntelliTool::onMouseRightReleased(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolRechteck::onMouseLeftPressed(int x, int y){
|
||||||
|
IntelliTool::onMouseLeftPressed(x,y);
|
||||||
|
this->originCornor=QPoint(x,y);
|
||||||
|
drawRechteck(originCornor);
|
||||||
|
Canvas->image->calculateVisiblity();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolRechteck::onMouseLeftReleased(int x, int y){
|
||||||
|
IntelliTool::onMouseLeftReleased(x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliToolRechteck::onMouseMoved(int x, int y){
|
||||||
|
IntelliTool::onMouseMoved(x,y);
|
||||||
|
if(this->drawing){
|
||||||
|
this->Canvas->image->drawPlain(Qt::transparent);
|
||||||
|
QPoint next(x,y);
|
||||||
|
drawRechteck(next);
|
||||||
|
}
|
||||||
|
IntelliTool::onMouseMoved(x,y);
|
||||||
|
}
|
||||||
27
src/Tool/IntelliToolRechteck.h
Normal file
27
src/Tool/IntelliToolRechteck.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#ifndef INTELLIRECHTECKTOOL_H
|
||||||
|
#define INTELLIRECHTECKTOOL_H
|
||||||
|
|
||||||
|
#include "IntelliTool.h"
|
||||||
|
|
||||||
|
#include "QColor"
|
||||||
|
#include "QPoint"
|
||||||
|
|
||||||
|
class IntelliToolRechteck : public IntelliTool{
|
||||||
|
void drawRechteck(QPoint otherCornor);
|
||||||
|
|
||||||
|
QPoint originCornor;
|
||||||
|
int alphaInner;
|
||||||
|
int edgeWidth;
|
||||||
|
public:
|
||||||
|
IntelliToolRechteck(PaintingArea* Area, IntelliColorPicker* colorPicker);
|
||||||
|
virtual ~IntelliToolRechteck() override;
|
||||||
|
|
||||||
|
virtual void onMouseRightPressed(int x, int y) override;
|
||||||
|
virtual void onMouseRightReleased(int x, int y) override;
|
||||||
|
virtual void onMouseLeftPressed(int x, int y) override;
|
||||||
|
virtual void onMouseLeftReleased(int x, int y) override;
|
||||||
|
|
||||||
|
virtual void onMouseMoved(int x, int y) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // INTELLIRECHTECKTOOL_H
|
||||||
Reference in New Issue
Block a user