mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-13 20:00:32 +02:00
Merge branch 'dev-warnings' into 'dev'
Dev warnings See merge request creyd/intelliphoto!45
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
#include "IntelliInputDialog.h"
|
||||
#include <QFile>
|
||||
|
||||
|
||||
IntelliInputDialog::IntelliInputDialog(QString Title, QString Label, int value, int minValue, int maxValue, int step, bool* ok)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
#ifndef INTELLIINPUTDIALOG_H
|
||||
#define INTELLIINPUTDIALOG_H
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QSize>
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
#include <QGridLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
#include <QSpinBox>
|
||||
|
||||
class IntelliInputDialog : public QDialog
|
||||
{
|
||||
@@ -25,7 +31,6 @@ int valueInt;
|
||||
|
||||
QGridLayout* Layout;
|
||||
QDialogButtonBox* ButtonBox;
|
||||
QEventLoop loop;
|
||||
bool* notClosed;
|
||||
|
||||
const QSize Linesize = QSize(150,20);
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
#ifndef IntelliPhotoGui_H
|
||||
#define IntelliPhotoGui_H
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QPixmap>
|
||||
#include <QAction>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QImageWriter>
|
||||
#include <QMenu>
|
||||
#include <QMenuBar>
|
||||
#include <QList>
|
||||
#include <QMainWindow>
|
||||
#include <QGridLayout>
|
||||
|
||||
@@ -73,7 +73,7 @@ virtual ~IntelliImage() = 0;
|
||||
virtual void drawPixel(const QPoint &p1, const QColor& color);
|
||||
|
||||
/*!
|
||||
* \brief A function that draws A Line between two given Points in a given color.
|
||||
* \brief A function that draws a line between two given points in a given color.
|
||||
* \param p1 - The coordinates of the first Point.
|
||||
* \param p2 - The coordinates of the second Point.
|
||||
* \param color - The color of the line.
|
||||
@@ -82,10 +82,10 @@ virtual void drawPixel(const QPoint &p1, const QColor& color);
|
||||
virtual void drawLine(const QPoint &p1, const QPoint& p2, const QColor& color, const int& penWidth);
|
||||
|
||||
/*!
|
||||
* \brief A
|
||||
* \param p1
|
||||
* \param color
|
||||
* \param penWidth
|
||||
* \brief A function that draws a point between on a given point in a given color.
|
||||
* \param p1 - The coordinates of the first Point.
|
||||
* \param color - The color of the point.
|
||||
* \param penWidth - The size of the point.
|
||||
*/
|
||||
virtual void drawPoint(const QPoint &p1, const QColor& color, const int& penWidth);
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "IntelliColorPicker.h"
|
||||
|
||||
IntelliColorPicker::IntelliColorPicker(){
|
||||
firstColor = {255,0,0,255};
|
||||
secondColor = {0,255,255,255};
|
||||
initializeColors();
|
||||
}
|
||||
|
||||
IntelliColorPicker::~IntelliColorPicker(){
|
||||
@@ -28,3 +27,8 @@ void IntelliColorPicker::setFirstColor(QColor Color){
|
||||
void IntelliColorPicker::setSecondColor(QColor Color){
|
||||
this->secondColor = Color;
|
||||
}
|
||||
|
||||
void IntelliColorPicker::initializeColors(){
|
||||
this->firstColor = QColor(255,0,0,255);
|
||||
this->secondColor = QColor(0,0,0,255);
|
||||
}
|
||||
|
||||
@@ -63,6 +63,11 @@ QColor firstColor;
|
||||
* \brief The secondary color.
|
||||
*/
|
||||
QColor secondColor;
|
||||
|
||||
/*!
|
||||
* \brief initializeColors initializes the first and second color.
|
||||
*/
|
||||
void initializeColors();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -113,7 +113,7 @@ std::vector<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoin
|
||||
return Triangles;
|
||||
}
|
||||
|
||||
bool IntelliTriangulation::isInPolygon(std::vector<Triangle> &triangles, QPoint &point){
|
||||
bool IntelliTriangulation::isInPolygon(const std::vector<Triangle> &triangles, QPoint &point){
|
||||
for(auto triangle : triangles) {
|
||||
if(IntelliTriangulation::isInTriangle(triangle, point)) {
|
||||
return true;
|
||||
|
||||
@@ -60,7 +60,7 @@ std::vector<Triangle> calculateTriangles(std::vector<QPoint> polyPoints);
|
||||
* \param point - The point to checl, if it lies in the polygon.
|
||||
* \return Returns true if the point lies in the üpolygon, otherwise false.
|
||||
*/
|
||||
bool isInPolygon(std::vector<Triangle> &triangles, QPoint &point);
|
||||
bool isInPolygon(const std::vector<Triangle> &triangles, QPoint &point);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -330,28 +330,17 @@ void PaintingArea::paintEvent(QPaintEvent*event){
|
||||
update();
|
||||
}
|
||||
|
||||
//TODOJ Resize the image to slightly larger then the main window
|
||||
// to cut down on the need to resize the image
|
||||
void PaintingArea::resizeEvent(QResizeEvent*event){
|
||||
//TODO wait till tool works
|
||||
update();
|
||||
}
|
||||
|
||||
void PaintingArea::resizeLayer(QImage*image_res, const QSize &newSize){
|
||||
//TODO implement
|
||||
}
|
||||
|
||||
void PaintingArea::selectLayerUp(){
|
||||
updateTools();
|
||||
if(activeLayer!=-1 && static_cast<unsigned long long>(activeLayer)<layerBundle.size() - 1) {
|
||||
std::swap(layerBundle[static_cast<unsigned long long>(activeLayer)], layerBundle[static_cast<unsigned long long>(activeLayer + 1)]);
|
||||
if(activeLayer != -1 && static_cast<size_t>(activeLayer)<layerBundle.size() - 1) {
|
||||
std::swap(layerBundle[static_cast<size_t>(activeLayer)], layerBundle[static_cast<size_t>(activeLayer + 1)]);
|
||||
activeLayer++;
|
||||
}
|
||||
}
|
||||
|
||||
void PaintingArea::selectLayerDown(){
|
||||
updateTools();
|
||||
if(activeLayer!=-1 && activeLayer>0) {
|
||||
if(activeLayer>0) {
|
||||
std::swap(layerBundle[static_cast<unsigned long long>(activeLayer)], layerBundle[static_cast<unsigned long long>(activeLayer - 1)]);
|
||||
activeLayer--;
|
||||
}
|
||||
|
||||
@@ -19,18 +19,31 @@ class UnitTest;
|
||||
|
||||
/*!
|
||||
* \brief The LayerObject struct holds all the information needed to construct a layer
|
||||
* \param width - Stores the width of a layer in pixels
|
||||
* \param height - Stores the height of a layer in pixels
|
||||
* \param alpha - Stores the alpha value of the layer (default=255)
|
||||
* \param widthOffset - Stores the number of pixles from the left side of the painting area
|
||||
* \param heightOffset - Stores the number of pixles from the top of the painting area
|
||||
*/
|
||||
struct LayerObject {
|
||||
/*!
|
||||
* \brief image - Stores the imageData of the current LayerObject.
|
||||
*/
|
||||
IntelliImage* image;
|
||||
/*!
|
||||
* \brief width - Stores the width of a layer in pixels.
|
||||
*/
|
||||
int width;
|
||||
/*!
|
||||
* \brief height - Stores the height of a layer in pixels.
|
||||
*/
|
||||
int height;
|
||||
/*!
|
||||
* \brief widthOffset - Stores the number of pixles from the left side of the painting area.
|
||||
*/
|
||||
int widthOffset;
|
||||
/*!
|
||||
* \brief heightOffset - Stores the number of pixles from the top of the painting area.
|
||||
*/
|
||||
int heightOffset;
|
||||
/*!
|
||||
* \brief alpha - Stores the alpha value of the layer (default=255).
|
||||
*/
|
||||
int alpha = 255;
|
||||
};
|
||||
|
||||
@@ -67,15 +80,15 @@ PaintingArea(int maxWidth = 600, int maxHeight = 600, QWidget*parent = nullptr);
|
||||
void setRenderSettings(bool isFastRenderingOn);
|
||||
|
||||
/*!
|
||||
* \brief The open method is used for loading a picture into the current layer
|
||||
* \param fileName - Path and filename which are used to determine where the to-be-opened file is stored
|
||||
* \return Returns a boolean variable whether the file was successfully opened or not
|
||||
* \brief The open method is used for loading a picture into the current layer.
|
||||
* \param filePath - Path and Name which are used to determine where the to-be-opened file is stored.
|
||||
* \return Returns a boolean variable whether the file was successfully opened or not.
|
||||
*/
|
||||
bool open(const QString &filePath);
|
||||
/*!
|
||||
* \brief The save method is used for exporting the current project as one picture
|
||||
* \param fileName
|
||||
* \param fileFormat
|
||||
* \param filePath - Specifies the path and name of the file to create.
|
||||
* \param fileFormat - Specifies the format of the file to create.
|
||||
* \return Returns a boolean variable, true if the file was saved successfully, false if not
|
||||
*/
|
||||
bool save(const QString &filePath, const char*fileFormat);
|
||||
@@ -208,8 +221,6 @@ void wheelEvent(QWheelEvent*event) override;
|
||||
|
||||
void paintEvent(QPaintEvent*event) override;
|
||||
|
||||
void resizeEvent(QResizeEvent*event) override;
|
||||
|
||||
private:
|
||||
void setLayerDimensions(int maxWidth, int maxHeight);
|
||||
void selectLayerUp();
|
||||
@@ -231,8 +242,6 @@ int activeLayer = -1;
|
||||
|
||||
void drawLayers(bool forSaving = false);
|
||||
|
||||
void resizeLayer(QImage*image_res, const QSize &newSize);
|
||||
|
||||
bool createTempTopLayer(int idx);
|
||||
|
||||
void updateTools();
|
||||
|
||||
@@ -6,6 +6,9 @@ IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker, In
|
||||
this->colorPicker = colorPicker;
|
||||
this->Toolsettings = Toolsettings;
|
||||
this->isDrawing = false;
|
||||
this->ActiveType = Tooltype::NONE;
|
||||
this->activeLayer = nullptr;
|
||||
this->Canvas = nullptr;
|
||||
}
|
||||
|
||||
IntelliTool::~IntelliTool(){
|
||||
@@ -14,7 +17,7 @@ IntelliTool::~IntelliTool(){
|
||||
|
||||
void IntelliTool::onMouseRightPressed(int x, int y){
|
||||
if(isDrawing) {
|
||||
isDrawing = false;
|
||||
isDrawing = false;
|
||||
this->deleteToolLayer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ enum class Tooltype {
|
||||
PEN,
|
||||
PLAIN,
|
||||
POLYGON,
|
||||
RECTANGLE
|
||||
RECTANGLE,
|
||||
NONE
|
||||
};
|
||||
private:
|
||||
/*!
|
||||
|
||||
@@ -15,30 +15,30 @@ IntelliToolCircle::~IntelliToolCircle(){
|
||||
void IntelliToolCircle::drawCircle(int radius){
|
||||
QColor inner = this->colorPicker->getSecondColor();
|
||||
inner.setAlpha(Toolsettings->getInnerAlpha());
|
||||
int yMin, yMax, xMin, xMax;
|
||||
yMin = centerPoint.y() - radius;
|
||||
yMax = centerPoint.y() + radius;
|
||||
int yMinimum, yMaximum, xMinimum, xMaximum;
|
||||
yMinimum = centerPoint.y() - radius;
|
||||
yMaximum = centerPoint.y() + radius;
|
||||
// x = x0+-sqrt(r2-(y-y0)2)
|
||||
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->drawLine(QPoint(xMin,i), QPoint(xMax,i),inner,1);
|
||||
for(int i = yMinimum; i<=yMaximum; i++) {
|
||||
xMinimum = static_cast<int>(centerPoint.x() - sqrt(pow(radius,2) - pow(i - centerPoint.y(),2)));
|
||||
xMaximum = static_cast<int>(centerPoint.x() + sqrt(pow(radius,2) - pow(i - centerPoint.y(),2)));
|
||||
this->Canvas->image->drawLine(QPoint(xMinimum,i), QPoint(xMaximum,i),inner,1);
|
||||
}
|
||||
|
||||
//TODO implement circle drawing algorithm bresenham
|
||||
radius = static_cast<int>(radius + (Toolsettings->getLineWidth() / 2.));
|
||||
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(),Toolsettings->getLineWidth());
|
||||
this->Canvas->image->drawPoint(QPoint(xMax,i), colorPicker->getFirstColor(),Toolsettings->getLineWidth());
|
||||
yMinimum = (centerPoint.y() - radius);
|
||||
yMaximum = (centerPoint.y() + radius);
|
||||
for(int i = yMinimum; i<=yMaximum; i++) {
|
||||
xMinimum = static_cast<int>(centerPoint.x() - sqrt(pow(radius,2) - pow(i - centerPoint.y(),2)));
|
||||
xMaximum = static_cast<int>(centerPoint.x() + sqrt(pow(radius,2) - pow(i - centerPoint.y(),2)));
|
||||
this->Canvas->image->drawPoint(QPoint(xMinimum,i), colorPicker->getFirstColor(),Toolsettings->getLineWidth());
|
||||
this->Canvas->image->drawPoint(QPoint(xMaximum,i), colorPicker->getFirstColor(),Toolsettings->getLineWidth());
|
||||
}
|
||||
|
||||
xMin = (centerPoint.x() - radius);
|
||||
xMax = (centerPoint.x() + radius);
|
||||
for(int i = xMin; i<=xMax; i++) {
|
||||
xMinimum = (centerPoint.x() - radius);
|
||||
xMaximum = (centerPoint.x() + radius);
|
||||
for(int i = xMinimum; i<=xMaximum; 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(),Toolsettings->getLineWidth());
|
||||
|
||||
Reference in New Issue
Block a user