mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-16 05:10:32 +02:00
PolygonTool fertig
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
// IntelliPhotoGui constructor
|
// IntelliPhotoGui constructor
|
||||||
IntelliPhotoGui::IntelliPhotoGui(){
|
IntelliPhotoGui::IntelliPhotoGui(){
|
||||||
|
|
||||||
//create Gui elements and lay them out
|
//create Gui elements and lay them out
|
||||||
createGui();
|
createGui();
|
||||||
// Create actions
|
// Create actions
|
||||||
@@ -19,7 +20,8 @@ IntelliPhotoGui::IntelliPhotoGui(){
|
|||||||
|
|
||||||
// Size the app
|
// Size the app
|
||||||
resize(600,600);
|
resize(600,600);
|
||||||
//showMaximized();
|
showMaximized();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// User tried to close the app
|
// User tried to close the app
|
||||||
@@ -105,14 +107,6 @@ void IntelliPhotoGui::slotDeleteLayer(){
|
|||||||
paintingArea->deleteLayer(layerNumber);
|
paintingArea->deleteLayer(layerNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
void slotCreatePenTool(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void slotCreateFloodFillTool(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void IntelliPhotoGui::slotSetActiveAlpha(){
|
void IntelliPhotoGui::slotSetActiveAlpha(){
|
||||||
// Stores button value
|
// Stores button value
|
||||||
bool ok1, ok2;
|
bool ok1, ok2;
|
||||||
@@ -205,7 +199,7 @@ void IntelliPhotoGui::slotSetActiveLayer(){
|
|||||||
{
|
{
|
||||||
paintingArea->setLayerToActive(layer);
|
paintingArea->setLayerToActive(layer);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
void IntelliPhotoGui::slotSetFirstColor(){
|
void IntelliPhotoGui::slotSetFirstColor(){
|
||||||
paintingArea->colorPickerSetFirstColor();
|
paintingArea->colorPickerSetFirstColor();
|
||||||
@@ -318,7 +312,7 @@ void IntelliPhotoGui::createActions(){
|
|||||||
connect(actionColorPickerFirstColor, SIGNAL(triggered()), this, SLOT(slotSetFirstColor()));
|
connect(actionColorPickerFirstColor, SIGNAL(triggered()), this, SLOT(slotSetFirstColor()));
|
||||||
|
|
||||||
actionColorPickerSecondColor = new QAction(tr("&Secondary"), this);
|
actionColorPickerSecondColor = new QAction(tr("&Secondary"), this);
|
||||||
connect(actionColorPickerSecondColor, SIGNAL(triggered()), this, SLOT(slotSetFirstColor()));
|
connect(actionColorPickerSecondColor, SIGNAL(triggered()), this, SLOT(slotSetSecondColor()));
|
||||||
|
|
||||||
actionColorSwitch = new QAction(tr("&Switch"), this);
|
actionColorSwitch = new QAction(tr("&Switch"), this);
|
||||||
actionColorSwitch->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S));
|
actionColorSwitch->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S));
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ private:
|
|||||||
//set style of the GUI
|
//set style of the GUI
|
||||||
void setIntelliStyle();
|
void setIntelliStyle();
|
||||||
|
|
||||||
|
|
||||||
// Will check if changes have occurred since last save
|
// Will check if changes have occurred since last save
|
||||||
bool maybeSave();
|
bool maybeSave();
|
||||||
// Opens the Save dialog and saves
|
// Opens the Save dialog and saves
|
||||||
@@ -123,7 +122,6 @@ private:
|
|||||||
|
|
||||||
//main GUI elements
|
//main GUI elements
|
||||||
QWidget* centralGuiWidget;
|
QWidget* centralGuiWidget;
|
||||||
QPushButton* Toolmanager;
|
|
||||||
QGridLayout *mainLayout;
|
QGridLayout *mainLayout;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -46,11 +46,10 @@ HEADERS += \
|
|||||||
Tool/IntelliToolPen.h \
|
Tool/IntelliToolPen.h \
|
||||||
Tool/IntelliToolPlain.h \
|
Tool/IntelliToolPlain.h \
|
||||||
Tool/IntelliToolPolygon.h \
|
Tool/IntelliToolPolygon.h \
|
||||||
Tool/IntelliToolRechteck.h \
|
Tool/IntelliToolRechteck.h
|
||||||
Tool/intellitoolcircle.h
|
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
widget.ui
|
mainwindow.ui
|
||||||
|
|
||||||
QMAKE_CXXFLAGS
|
QMAKE_CXXFLAGS
|
||||||
QMAKE_LFLAGS
|
QMAKE_LFLAGS
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent)
|
|||||||
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);
|
||||||
layerBundle[0].image->drawPlain(QColor(255,0,0,255));
|
layerBundle[0].image->drawPlain(QColor(0,0,255,255));
|
||||||
std::vector<QPoint> polygon;
|
std::vector<QPoint> polygon;
|
||||||
polygon.push_back(QPoint(100,000));
|
polygon.push_back(QPoint(100,000));
|
||||||
polygon.push_back(QPoint(200,100));
|
polygon.push_back(QPoint(200,100));
|
||||||
@@ -36,7 +36,7 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent)
|
|||||||
layerBundle[1].image->drawPlain(QColor(0,255,0,255));
|
layerBundle[1].image->drawPlain(QColor(0,255,0,255));
|
||||||
layerBundle[1].alpha=200;
|
layerBundle[1].alpha=200;
|
||||||
|
|
||||||
activeLayer=1;
|
activeLayer=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PaintingArea::~PaintingArea(){
|
PaintingArea::~PaintingArea(){
|
||||||
@@ -193,6 +193,14 @@ void PaintingArea::createLineTool(){
|
|||||||
Tool = new IntelliToolLine(this, &colorPicker);
|
Tool = new IntelliToolLine(this, &colorPicker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PaintingArea::getWidthActiveLayer(){
|
||||||
|
return layerBundle.operator[](activeLayer).width;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PaintingArea::getHeightActiveLayer(){
|
||||||
|
return layerBundle.operator[](activeLayer).hight;
|
||||||
|
}
|
||||||
|
|
||||||
// If a mouse button is pressed check if it was the
|
// If a mouse button is pressed check if it was the
|
||||||
// left button and if so store the current position
|
// left button and if so store the current position
|
||||||
// Set that we are currently drawing
|
// Set that we are currently drawing
|
||||||
|
|||||||
@@ -59,6 +59,10 @@ public:
|
|||||||
void createPlainTool();
|
void createPlainTool();
|
||||||
void createLineTool();
|
void createLineTool();
|
||||||
|
|
||||||
|
//get Width and Height of active Layer
|
||||||
|
int getWidthActiveLayer();
|
||||||
|
int getHeightActiveLayer();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
// Events to handle
|
// Events to handle
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ void IntelliToolLine::onMouseRightReleased(int x, int y){
|
|||||||
void IntelliToolLine::onMouseLeftPressed(int x, int y){
|
void IntelliToolLine::onMouseLeftPressed(int x, int y){
|
||||||
IntelliTool::onMouseLeftPressed(x,y);
|
IntelliTool::onMouseLeftPressed(x,y);
|
||||||
this->start=QPoint(x,y);
|
this->start=QPoint(x,y);
|
||||||
this->Canvas->image->drawLine(start, start, colorPicker->getFirstColor(),lineWidth);
|
this->Canvas->image->drawPoint(start, colorPicker->getFirstColor(),lineWidth);
|
||||||
Canvas->image->calculateVisiblity();
|
Canvas->image->calculateVisiblity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +43,6 @@ void IntelliToolLine::onWheelScrolled(int value){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IntelliToolLine::onMouseMoved(int x, int y){
|
void IntelliToolLine::onMouseMoved(int x, int y){
|
||||||
IntelliTool::onMouseMoved(x,y);
|
|
||||||
if(this->drawing){
|
if(this->drawing){
|
||||||
this->Canvas->image->drawPlain(Qt::transparent);
|
this->Canvas->image->drawPlain(Qt::transparent);
|
||||||
QPoint next(x,y);
|
QPoint next(x,y);
|
||||||
|
|||||||
@@ -13,8 +13,11 @@ IntelliToolPolygon::IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* c
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
|
void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
|
||||||
qDebug() << x << y;
|
if(!isDrawing){
|
||||||
if(!isDrawing && x > 0 && y > 0){
|
width = Area->getWidthActiveLayer();
|
||||||
|
height = Area->getHeightActiveLayer();
|
||||||
|
}
|
||||||
|
if(!isDrawing && x > 0 && y > 0 && x < width && y < height){
|
||||||
isDrawing = true;
|
isDrawing = true;
|
||||||
drawingPoint.setX(x);
|
drawingPoint.setX(x);
|
||||||
drawingPoint.setY(y);
|
drawingPoint.setY(y);
|
||||||
@@ -22,16 +25,19 @@ void IntelliToolPolygon::onMouseLeftPressed(int x, int y){
|
|||||||
IntelliTool::onMouseLeftPressed(x,y);
|
IntelliTool::onMouseLeftPressed(x,y);
|
||||||
this->Canvas->image->drawPlain(Qt::transparent);
|
this->Canvas->image->drawPlain(Qt::transparent);
|
||||||
this->Canvas->image->drawPoint(QPointList.back(), colorPicker->getFirstColor(), lineWidth);
|
this->Canvas->image->drawPoint(QPointList.back(), colorPicker->getFirstColor(), lineWidth);
|
||||||
|
this->Canvas->image->calculateVisiblity();
|
||||||
}
|
}
|
||||||
else if(isDrawing && isNearStart(x,y,QPointList.front())){
|
else if(isDrawing && isNearStart(x,y,QPointList.front())){
|
||||||
PointIsNearStart = isNearStart(x,y,QPointList.front());
|
PointIsNearStart = isNearStart(x,y,QPointList.front());
|
||||||
this->Canvas->image->drawLine(QPointList.back(), QPointList.front(), colorPicker->getFirstColor(), lineWidth);s
|
this->Canvas->image->drawLine(QPointList.back(), QPointList.front(), colorPicker->getFirstColor(), lineWidth);
|
||||||
|
this->Canvas->image->calculateVisiblity();
|
||||||
}
|
}
|
||||||
else if(isDrawing){
|
else if(isDrawing){
|
||||||
drawingPoint.setX(x);
|
drawingPoint.setX(x);
|
||||||
drawingPoint.setY(y);
|
drawingPoint.setY(y);
|
||||||
QPointList.push_back(drawingPoint);
|
QPointList.push_back(drawingPoint);
|
||||||
this->Canvas->image->drawLine(QPointList.operator[](QPointList.size() - 2), QPointList.back(), colorPicker->getFirstColor(), lineWidth);
|
this->Canvas->image->drawLine(QPointList.operator[](QPointList.size() - 2), QPointList.back(), colorPicker->getFirstColor(), lineWidth);
|
||||||
|
this->Canvas->image->calculateVisiblity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,8 +50,17 @@ void IntelliToolPolygon::onMouseRightPressed(int x, int y){
|
|||||||
|
|
||||||
void IntelliToolPolygon::onMouseLeftReleased(int x, int y){
|
void IntelliToolPolygon::onMouseLeftReleased(int x, int y){
|
||||||
if(PointIsNearStart && QPointList.size() > 1){
|
if(PointIsNearStart && QPointList.size() > 1){
|
||||||
|
this->Canvas->image->calculateVisiblity();
|
||||||
PointIsNearStart = false;
|
PointIsNearStart = false;
|
||||||
isDrawing = false;
|
isDrawing = false;
|
||||||
|
for(int i = 0; i < width; i++){
|
||||||
|
for(int j = 0; j < height; j++){
|
||||||
|
if(/*funktion(QPointList,i,j)*/false){
|
||||||
|
this->Canvas->image->drawPixel(QPoint(i,j), colorPicker->getFirstColor());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
QPointList.clear();
|
QPointList.clear();
|
||||||
IntelliTool::onMouseLeftReleased(x,y);
|
IntelliTool::onMouseLeftReleased(x,y);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ private:
|
|||||||
bool isNearStart(int x, int y, QPoint Startpoint);
|
bool isNearStart(int x, int y, QPoint Startpoint);
|
||||||
|
|
||||||
int lineWidth;
|
int lineWidth;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
bool isDrawing;
|
bool isDrawing;
|
||||||
bool PointIsNearStart;
|
bool PointIsNearStart;
|
||||||
QPoint drawingPoint;
|
QPoint drawingPoint;
|
||||||
|
|||||||
23
src/mainwindow.ui
Normal file
23
src/mainwindow.ui
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>MainWindow</class>
|
||||||
|
<widget class="QMainWindow" name="MainWindow">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>542</width>
|
||||||
|
<height>459</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>IntelliPhoto</string>
|
||||||
|
</property>
|
||||||
|
<property name="animated">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="centralwidget"/>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Widget</class>
|
|
||||||
<widget class="QWidget" name="Widget">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>360</width>
|
|
||||||
<height>206</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Widget</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
Reference in New Issue
Block a user