Automated Merge Preparation

This commit is contained in:
2020-01-15 15:22:08 +01:00
parent aae3e5f89f
commit 9e81d953af
17 changed files with 149 additions and 149 deletions

View File

@@ -121,10 +121,10 @@ void IntelliPhotoGui::slotDeleteLayer(){
// Define the standard Value, min, max, step and ok button
int layerNumber = QInputDialog::getInt(this, tr("delete Layer"),
tr("Number:"),
paintingArea->getNumberOfActiveLayer()+1,1, 501, 1, &ok);
paintingArea->getNumberOfActiveLayer() + 1,1, 501, 1, &ok);
// Create New Layer
if (ok) {
paintingArea->deleteLayer(layerNumber-1);
paintingArea->deleteLayer(layerNumber - 1);
UpdateGui();
}
}
@@ -145,7 +145,7 @@ void IntelliPhotoGui::slotSetActiveAlpha(){
255,0, 255, 1, &ok2);
if (ok1&&ok2)
{
paintingArea->setLayerAlpha(layer-1,alpha);
paintingArea->setLayerAlpha(layer - 1,alpha);
UpdateGui();
}
}
@@ -163,7 +163,7 @@ void IntelliPhotoGui::slotSetPolygon(){
if (ok1)
{
paintingArea->setPolygon(layer-1);
paintingArea->setPolygon(layer - 1);
UpdateGui();
}
}
@@ -210,7 +210,7 @@ void IntelliPhotoGui::slotSetActiveLayer(){
1, 1, 500, 1, &ok1);
if (ok1)
{
paintingArea->setLayerActive(layer-1);
paintingArea->setLayerActive(layer - 1);
UpdateGui();
}
}
@@ -401,17 +401,17 @@ void IntelliPhotoGui::createActions(){
actionMoveLayerUp->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Up));
connect(actionMoveLayerUp, SIGNAL(triggered()), this, SLOT(slotMoveLayerUp()));
actionMoveLayerDown= new QAction(tr("&move Layer Down"), this);
actionMoveLayerDown = new QAction(tr("&move Layer Down"), this);
actionMoveLayerDown->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Down));
connect(actionMoveLayerDown, SIGNAL(triggered()), this, SLOT(slotMoveLayerDown()));
//Create Update RenderSettings Actions here
actionUpdateRenderSettingsOn = new QAction(tr("&On"), this);
actionUpdateRenderSettingsOn->setShortcut(QKeySequence(Qt::ALT +Qt::SHIFT + +Qt::Key_A));
actionUpdateRenderSettingsOn->setShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + +Qt::Key_A));
connect(actionUpdateRenderSettingsOn, SIGNAL(triggered()),this, SLOT(slotUpdateRenderSettingsOn()));
actionUpdateRenderSettingsOff = new QAction(tr("&Off"), this);
actionUpdateRenderSettingsOff->setShortcut(QKeySequence(Qt::ALT +Qt::SHIFT + +Qt::Key_D));
actionUpdateRenderSettingsOff->setShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + +Qt::Key_D));
connect(actionUpdateRenderSettingsOff, SIGNAL(triggered()),this, SLOT(slotUpdateRenderSettingsOff()));
//Create Color Actions here
@@ -432,38 +432,38 @@ void IntelliPhotoGui::createActions(){
//Create Tool actions down here
actionCreatePlainTool = new QAction(tr("&Plain"), this);
actionCreatePlainTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_P));
actionCreatePlainTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_P));
connect(actionCreatePlainTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreatePlainTool, SIGNAL(triggered()), this, SLOT(slotCreatePlainTool()));
actionCreatePenTool = new QAction(tr("&Pen"),this);
actionCreatePenTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_S));
actionCreatePenTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_S));
connect(actionCreatePenTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreatePenTool, SIGNAL(triggered()), this, SLOT(slotCreatePenTool()));
actionCreateLineTool = new QAction(tr("&Line"), this);
actionCreateLineTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_L));
actionCreateLineTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_L));
connect(actionCreateLineTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreateLineTool, SIGNAL(triggered()), this, SLOT(slotCreateLineTool()));
actionCreateCircleTool = new QAction(tr("&Circle"), this);
actionCreateCircleTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_C));
actionCreateCircleTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_C));
connect(actionCreateCircleTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreateCircleTool, SIGNAL(triggered()), this, SLOT(slotCreateCircleTool()));
actionCreateRectangleTool = new QAction(tr("&Rectangle"), this);
actionCreateRectangleTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_R));
actionCreateRectangleTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_R));
connect(actionCreateRectangleTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreateRectangleTool, SIGNAL(triggered()), this, SLOT(slotCreateRectangleTool()));
actionCreatePolygonTool = new QAction(tr("&Polygon"), this);
actionCreatePolygonTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_V));
actionCreatePolygonTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_V));
connect(actionCreatePolygonTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreatePolygonTool, SIGNAL(triggered()), this, SLOT(slotCreatePolygonTool()));
actionCreateFloodFillTool = new QAction(tr("&FloodFill"), this);
actionCreateFloodFillTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_F));
actionCreateFloodFillTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT + Qt::Key_F));
connect(actionCreateFloodFillTool, SIGNAL(triggered()), this, SLOT(slotResetTools()));
connect(actionCreateFloodFillTool, SIGNAL(triggered()), this, SLOT(slotCreateFloodFillTool()));
@@ -514,7 +514,7 @@ void IntelliPhotoGui::createActions(){
void IntelliPhotoGui::createMenus(){
// Create Save As option and the list of file types
saveAsMenu = new QMenu(tr("&Save As"), this);
foreach (QAction *action, actionSaveAs)
foreach (QAction * action, actionSaveAs)
saveAsMenu->addAction(action);
@@ -661,10 +661,10 @@ void IntelliPhotoGui::createGui(){
WidthLine = new QLabel();
WidthLine->setText("Width");
WidthLine->setFixedSize(Buttonsize.width(),Buttonsize.height()/3);
WidthLine->setFixedSize(Buttonsize.width(),Buttonsize.height() / 3);
EditLineWidth = new QLineEdit();
EditLineWidth->setFixedSize(Buttonsize.width(),Buttonsize.height()/3);
EditLineWidth->setFixedSize(Buttonsize.width(),Buttonsize.height() / 3);
EditLineWidth->setText("5");
ValidatorLineWidth = new QIntValidator();
ValidatorLineWidth->setTop(99);
@@ -673,10 +673,10 @@ void IntelliPhotoGui::createGui(){
innerAlphaLine = new QLabel();
innerAlphaLine->setText("Inner Alpha");
innerAlphaLine->setFixedSize(Buttonsize.width(),Buttonsize.height()/3);
innerAlphaLine->setFixedSize(Buttonsize.width(),Buttonsize.height() / 3);
EditLineInnerAlpha = new QLineEdit();
EditLineInnerAlpha->setFixedSize(Buttonsize.width(),Buttonsize.height()/3);
EditLineInnerAlpha->setFixedSize(Buttonsize.width(),Buttonsize.height() / 3);
EditLineInnerAlpha->setText("255");
ValidatorInnerAlpha = new QIntValidator();
ValidatorInnerAlpha->setTop(999);
@@ -684,21 +684,21 @@ void IntelliPhotoGui::createGui(){
EditLineInnerAlpha->setValidator(ValidatorInnerAlpha);
FirstColorButton = new QPushButton();
FirstColorButton->setFixedSize(Buttonsize/2);
FirstColorButton->setFixedSize(Buttonsize / 2);
SecondColorButton = new QPushButton();
SecondColorButton->setFixedSize(Buttonsize/2);
SecondColorButton->setFixedSize(Buttonsize / 2);
preview = QPixmap(":/Icons/Buttons/icons/Wechselpfeile.png");
SwitchColorButton = new QPushButton();
SwitchColorButton->setFixedSize(Buttonsize.width(),Buttonsize.height()/2);
SwitchColorButton->setFixedSize(Buttonsize.width(),Buttonsize.height() / 2);
SwitchColorButton->setIcon(preview);
SwitchColorButton->setIconSize(QSize(Buttonsize.width(),Buttonsize.height()/2));
SwitchColorButton->setIconSize(QSize(Buttonsize.width(),Buttonsize.height() / 2));
ActiveLayerLine = new QLabel();
QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer() + 1);
ActiveLayerLine->setText(string);
ActiveLayerLine->setFixedSize(Buttonsize.width()+10,Buttonsize.height()/3);
ActiveLayerLine->setFixedSize(Buttonsize.width() + 10,Buttonsize.height() / 3);
IntelliImage* activePicture = paintingArea->getImageOfActiveLayer();
if(activePicture) {

View File

@@ -104,7 +104,7 @@ virtual QImage getDisplayable(const QSize& displaySize, int alpha) = 0;
* @param alpha - The maximum alpha value, a pixel can have.
* @return A QImage which is ready to be displayed.
*/
virtual QImage getDisplayable(int alpha=255) = 0;
virtual QImage getDisplayable(int alpha = 255) = 0;
/*!
* \brief A function that copys all that returns a [allocated] Image

View File

@@ -47,6 +47,6 @@ QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){
}
void IntelliRasterImage::setPolygon(const std::vector<QPoint>& polygonData){
qDebug() << "Raster Image has no polygon data " << polygonData.size() <<"\n";
qDebug() << "Raster Image has no polygon data " << polygonData.size() << "\n";
return;
}

View File

@@ -40,7 +40,7 @@ virtual QImage getDisplayable(const QSize& displaySize,int alpha) override;
* @param alpha - The maximum alpha value, a pixel can have.
* @return A QImage which is ready to be displayed.
*/
virtual QImage getDisplayable(int alpha=255) override;
virtual QImage getDisplayable(int alpha = 255) override;
/*!
* \brief A function that copys all that returns a [allocated] Image

View File

@@ -36,8 +36,8 @@ void IntelliShapedImage::calculateVisiblity(){
if(polygonData.size()<=2) {
QColor clr;
for(int y=0; y<imageData.height(); y++) {
for(int x=0; x<imageData.width(); x++) {
for(int y = 0; y<imageData.height(); y++) {
for(int x = 0; x<imageData.width(); x++) {
clr = imageData.pixel(x,y);
clr.setAlpha(255);
imageData.setPixelColor(x,y,clr);
@@ -49,8 +49,8 @@ void IntelliShapedImage::calculateVisiblity(){
return;
}
QColor clr;
for(int y=0; y<imageData.height(); y++) {
for(int x=0; x<imageData.width(); x++) {
for(int y = 0; y<imageData.height(); y++) {
for(int x = 0; x<imageData.width(); x++) {
QPoint ptr(x,y);
clr = imageData.pixelColor(x,y);
bool isInPolygon = IntelliTriangulation::isInPolygon(triangles, ptr);

View File

@@ -45,14 +45,14 @@ virtual ~IntelliShapedImage() override;
* \param alpha - The maximum alpha value, a pixel can have.
* \return A QImage which is ready to be displayed.
*/
virtual QImage getDisplayable(const QSize& displaySize, int alpha=255) override;
virtual QImage getDisplayable(const QSize& displaySize, int alpha = 255) override;
/**
* @brief A function returning the displayable ImageData in a requested transparence and it's standart size.
* @param alpha - The maximum alpha value, a pixel can have.
* @return A QImage which is ready to be displayed.
*/
virtual QImage getDisplayable(int alpha=255) override;
virtual QImage getDisplayable(int alpha = 255) override;
/*!
* \brief A function that copys all that returns a [allocated] Image

View File

@@ -15,45 +15,45 @@ std::vector<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoin
// calculates the inner angle of 'point'
auto calculateInner = [](QPoint& point, QPoint& prev, QPoint& post){
QPoint AP(point.x()-prev.x(), point.y()-prev.y());
QPoint BP(point.x()-post.x(), point.y()-post.y());
QPoint AP(point.x() - prev.x(), point.y() - prev.y());
QPoint BP(point.x() - post.x(), point.y() - post.y());
float topSclar = AP.x()*BP.x()+AP.y()*BP.y();
float absolute = static_cast<float>(sqrt(pow(AP.x(),2.)+pow(AP.y(),2.))*sqrt(pow(BP.x(),2.)+pow(BP.y(),2.)));
return acos(topSclar/absolute);
float topSclar = AP.x() * BP.x() + AP.y() * BP.y();
float absolute = static_cast<float>(sqrt(pow(AP.x(),2.) + pow(AP.y(),2.)) * sqrt(pow(BP.x(),2.) + pow(BP.y(),2.)));
return acos(topSclar / absolute);
};
// gets the first element of vec for which element.isTip == true holds
auto getTip= [](const std::vector<TriangleHelper>& vec){
size_t min = 0;
for(size_t i=0; i<vec.size(); i++) {
if(vec[i].interiorAngle<vec[min].interiorAngle) {
min = i;
}
}
return vec[min];
};
auto getTip = [](const std::vector<TriangleHelper>& vec){
size_t min = 0;
for(size_t i = 0; i<vec.size(); i++) {
if(vec[i].interiorAngle<vec[min].interiorAngle) {
min = i;
}
}
return vec[min];
};
// get the vertex idx bevor idx in relation to the container length
auto getPrev = [](int idx, int length){
return (idx-1)>=0 ? (idx-1) : (length-1);
return (idx - 1)>=0 ? (idx - 1) : (length - 1);
};
// get the vertex idx after idx in relation to the container lenght
auto getPost = [](int idx, int length){
return (idx+1)%length;
return (idx + 1) % length;
};
// return if the vertex is a tip
auto isTip = [](float angle){
return static_cast<double>(angle)<(pi/2.);
return static_cast<double>(angle)<(pi / 2.);
};
std::vector<TriangleHelper> Vertices;
std::vector<Triangle> Triangles;
// set up all vertices and calculate intirior angle
for(int i=0; i<static_cast<int>(polyPoints.size()); i++) {
for(int i = 0; i<static_cast<int>(polyPoints.size()); i++) {
TriangleHelper helper;
int prev = getPrev(i, static_cast<int>(polyPoints.size()));
int post = getPost(i, static_cast<int>(polyPoints.size()));
@@ -69,7 +69,7 @@ std::vector<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoin
}
// search triangles based on the intirior angles of each vertey
while(Triangles.size() != polyPoints.size()-2) {
while(Triangles.size() != polyPoints.size() - 2) {
Triangle tri;
TriangleHelper smallest = getTip(Vertices);
int prev = getPrev(smallest.idx, static_cast<int>(Vertices.size()));
@@ -82,14 +82,14 @@ std::vector<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoin
Triangles.push_back(tri);
// update Vertice array
Vertices.erase(Vertices.begin()+smallest.idx);
for(size_t i=static_cast<size_t>(smallest.idx); i<Vertices.size(); i++) {
Vertices[i].idx-=1;
Vertices.erase(Vertices.begin() + smallest.idx);
for(size_t i = static_cast<size_t>(smallest.idx); i<Vertices.size(); i++) {
Vertices[i].idx -= 1;
}
// update post und prev idx
post = getPrev(post, Vertices.size());
prev = prev<smallest.idx ? prev : (prev-1);
prev = prev<smallest.idx ? prev : (prev - 1);
// calcultae neighboors of prev and post to calculate new interior angles
int prevOfPrev = getPrev(prev, static_cast<int>(Vertices.size()));

View File

@@ -21,7 +21,7 @@ namespace IntelliTriangulation {
* \return Returns the area of the traingle*2
*/
inline float sign(QPoint& p1, QPoint& p2, QPoint& p3){
return (p1.x()-p3.x())*(p2.y()-p3.y())-(p2.x()-p3.x())*(p1.y()-p3.y());
return (p1.x() - p3.x()) * (p2.y() - p3.y()) - (p2.x() - p3.x()) * (p1.y() - p3.y());
}
/*!

View File

@@ -24,7 +24,7 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent)
this->Tool = nullptr;
this->setLayerDimensions(maxWidth, maxHeight);
activeLayer=-1;
activeLayer = -1;
}
PaintingArea::~PaintingArea(){
@@ -65,7 +65,7 @@ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOff
}
newLayer.alpha = 255;
this->layerBundle.push_back(newLayer);
activeLayer = static_cast<int>(layerBundle.size())-1;
activeLayer = static_cast<int>(layerBundle.size()) - 1;
return activeLayer;
}
@@ -75,19 +75,19 @@ void PaintingArea::deleteLayer(int idx, bool isTool){
updateTools();
}
if(idx<static_cast<int>(layerBundle.size())) {
this->layerBundle.erase(layerBundle.begin()+idx);
this->layerBundle.erase(layerBundle.begin() + idx);
if(activeLayer>=idx) {
activeLayer--;
}
if(activeLayer < 0 && layerBundle.size()) {
activeLayer=0;
activeLayer = 0;
}
}
}
void PaintingArea::slotDeleteActiveLayer(){
if(activeLayer>=0 && activeLayer < static_cast<int>(layerBundle.size())) {
this->layerBundle.erase(layerBundle.begin()+activeLayer);
this->layerBundle.erase(layerBundle.begin() + activeLayer);
activeLayer--;
}
}
@@ -95,13 +95,13 @@ void PaintingArea::slotDeleteActiveLayer(){
void PaintingArea::setLayerActive(int idx){
updateTools();
if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
this->activeLayer=idx;
this->activeLayer = idx;
}
}
void PaintingArea::setLayerAlpha(int idx, int alpha){
if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
layerBundle[static_cast<size_t>(idx)].alpha=alpha;
layerBundle[static_cast<size_t>(idx)].alpha = alpha;
}
}
void PaintingArea::setPolygon(int idx){
@@ -245,8 +245,8 @@ void PaintingArea::mousePressEvent(QMouseEvent*event){
}
if(Tool == nullptr)
return;
int x = event->x()-layerBundle[static_cast<unsigned long long>(activeLayer)].widthOffset;
int y = event->y()-layerBundle[static_cast<unsigned long long>(activeLayer)].heightOffset;
int x = event->x() - layerBundle[static_cast<unsigned long long>(activeLayer)].widthOffset;
int y = event->y() - layerBundle[static_cast<unsigned long long>(activeLayer)].heightOffset;
if(event->button() == Qt::LeftButton) {
Tool->onMouseLeftPressed(x, y);
}else if(event->button() == Qt::RightButton) {
@@ -264,8 +264,8 @@ void PaintingArea::mouseMoveEvent(QMouseEvent*event){
}
if(Tool == nullptr)
return;
int x = event->x()-layerBundle[static_cast<unsigned long long>(activeLayer)].widthOffset;
int y = event->y()-layerBundle[static_cast<unsigned long long>(activeLayer)].heightOffset;
int x = event->x() - layerBundle[static_cast<unsigned long long>(activeLayer)].widthOffset;
int y = event->y() - layerBundle[static_cast<unsigned long long>(activeLayer)].heightOffset;
Tool->onMouseMoved(x, y);
update();
}
@@ -276,8 +276,8 @@ void PaintingArea::mouseReleaseEvent(QMouseEvent*event){
return;
if(Tool == nullptr)
return;
int x = event->x()-layerBundle[static_cast<unsigned long long>(activeLayer)].widthOffset;
int y = event->y()-layerBundle[static_cast<unsigned long long>(activeLayer)].heightOffset;
int x = event->x() - layerBundle[static_cast<unsigned long long>(activeLayer)].widthOffset;
int y = event->y() - layerBundle[static_cast<unsigned long long>(activeLayer)].heightOffset;
if(event->button() == Qt::LeftButton) {
Tool->onMouseLeftReleased(x, y);
}else if(event->button() == Qt::RightButton) {
@@ -293,7 +293,7 @@ void PaintingArea::wheelEvent(QWheelEvent*event){
QPoint numDegrees = event->angleDelta() / 8;
if(!numDegrees.isNull()) {
QPoint numSteps = numDegrees / 15;
Tool->onWheelScrolled(numSteps.y()* -1);
Tool->onWheelScrolled(numSteps.y() * -1);
}
}
}
@@ -323,8 +323,8 @@ void PaintingArea::resizeLayer(QImage*image_res, const QSize &newSize){
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<unsigned long long>(activeLayer)<layerBundle.size() - 1) {
std::swap(layerBundle[static_cast<unsigned long long>(activeLayer)], layerBundle[static_cast<unsigned long long>(activeLayer + 1)]);
activeLayer++;
}
}
@@ -332,7 +332,7 @@ void PaintingArea::selectLayerUp(){
void PaintingArea::selectLayerDown(){
updateTools();
if(activeLayer!=-1 && activeLayer>0) {
std::swap(layerBundle[static_cast<unsigned long long>(activeLayer)], layerBundle[static_cast<unsigned long long>(activeLayer-1)]);
std::swap(layerBundle[static_cast<unsigned long long>(activeLayer)], layerBundle[static_cast<unsigned long long>(activeLayer - 1)]);
activeLayer--;
}
}
@@ -343,30 +343,30 @@ void PaintingArea::drawLayers(bool forSaving){
}else{
Canvas->fill(Qt::GlobalColor::black);
}
for(size_t i=0; i<layerBundle.size(); i++) {
for(size_t i = 0; i<layerBundle.size(); i++) {
LayerObject layer = layerBundle[i];
QImage cpy = layer.image->getDisplayable(layer.alpha);
QColor clr_0;
QColor clr_1;
for(int y=0; y<layer.height; y++) {
if(layer.heightOffset+y<0) continue;
if(layer.heightOffset+y>=maxHeight) break;
for(int x=0; x<layer.width; x++) {
if(layer.widthOffset+x<0) continue;
if(layer.widthOffset+x>=maxWidth) break;
clr_0=Canvas->pixelColor(layer.widthOffset+x, layer.heightOffset+y);
clr_1=cpy.pixelColor(x,y);
float t = static_cast<float>(clr_1.alpha())/255.f;
int r =static_cast<int>(static_cast<float>(clr_1.red())*(t)+static_cast<float>(clr_0.red())*(1.f-t)+0.5f);
int g =static_cast<int>(static_cast<float>(clr_1.green())*(t)+static_cast<float>(clr_0.green())*(1.f-t)+0.5f);
int b =static_cast<int>(static_cast<float>(clr_1.blue())*(t)+static_cast<float>(clr_0.blue()*(1.f-t))+0.5f);
int a =std::min(clr_0.alpha()+clr_1.alpha(), 255);
for(int y = 0; y<layer.height; y++) {
if(layer.heightOffset + y<0) continue;
if(layer.heightOffset + y>=maxHeight) break;
for(int x = 0; x<layer.width; x++) {
if(layer.widthOffset + x<0) continue;
if(layer.widthOffset + x>=maxWidth) break;
clr_0 = Canvas->pixelColor(layer.widthOffset + x, layer.heightOffset + y);
clr_1 = cpy.pixelColor(x,y);
float t = static_cast<float>(clr_1.alpha()) / 255.f;
int r = static_cast<int>(static_cast<float>(clr_1.red()) * (t) + static_cast<float>(clr_0.red()) * (1.f - t) + 0.5f);
int g = static_cast<int>(static_cast<float>(clr_1.green()) * (t) + static_cast<float>(clr_0.green()) * (1.f - t) + 0.5f);
int b = static_cast<int>(static_cast<float>(clr_1.blue()) * (t) + static_cast<float>(clr_0.blue() * (1.f - t)) + 0.5f);
int a = std::min(clr_0.alpha() + clr_1.alpha(), 255);
clr_0.setRed(r);
clr_0.setGreen(g);
clr_0.setBlue(b);
clr_0.setAlpha(a);
Canvas->setPixelColor(layer.widthOffset+x, layer.heightOffset+y, clr_0);
Canvas->setPixelColor(layer.widthOffset + x, layer.heightOffset + y, clr_0);
}
}
}
@@ -381,7 +381,7 @@ bool PaintingArea::createTempTopLayer(int idx){
newLayer.heightOffset = layerBundle[static_cast<unsigned long long>(idx)].heightOffset;
newLayer.widthOffset = layerBundle[static_cast<unsigned long long>(idx)].widthOffset;
newLayer.image = layerBundle[static_cast<unsigned long long>(idx)].image->getDeepCopy();
layerBundle.insert(layerBundle.begin()+idx+1,newLayer);
layerBundle.insert(layerBundle.begin() + idx + 1,newLayer);
return true;
}
return false;

View File

@@ -28,7 +28,7 @@ struct LayerObject {
int height;
int widthOffset;
int heightOffset;
int alpha=255;
int alpha = 255;
};
/*!
@@ -46,7 +46,7 @@ public:
* \param maxHeight - The maximum amount of pixles that are inside painting area from top to bottom (default=600px)
* \param parent - The parent window of the main window (default=nullptr)
*/
PaintingArea(int maxWidth=600, int maxHeight=600, QWidget*parent = nullptr);
PaintingArea(int maxWidth = 600, int maxHeight = 600, QWidget*parent = nullptr);
/*!
* \brief This deconstructor is used to clear up the memory and remove the currently active window
@@ -82,7 +82,7 @@ bool save(const QString &filePath, const char*fileFormat);
* \param type - Defining the ImageType of the new layer
* \return Returns the number of layers in the project
*/
int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, IntelliImage::ImageType type = IntelliImage::ImageType::RASTERIMAGE);
int addLayer(int width, int height, int widthOffset = 0, int heightOffset = 0, IntelliImage::ImageType type = IntelliImage::ImageType::RASTERIMAGE);
/*!
* \brief The addLayerAt adds a layer to the current project/ painting area at a specific position in the layer stack
* \param idx - Index of the position the new layer should be added
@@ -93,7 +93,7 @@ int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, Intel
* \param type - Defining the ImageType of the new layer
* \return Returns the id of the layer position
*/
int addLayerAt(int idx, int width, int height, int widthOffset=0, int heightOffset=0, IntelliImage::ImageType type = IntelliImage::ImageType::RASTERIMAGE);
int addLayerAt(int idx, int width, int height, int widthOffset = 0, int heightOffset = 0, IntelliImage::ImageType type = IntelliImage::ImageType::RASTERIMAGE);
/*!
* \brief The deleteLayer method removes a layer at a given idx
* \param idx - The index of the layer to be removed
@@ -216,9 +216,9 @@ IntelliTool* Tool;
IntelliPhotoGui* DummyGui;
std::vector<LayerObject> layerBundle;
int activeLayer=-1;
int activeLayer = -1;
void drawLayers(bool forSaving=false);
void drawLayers(bool forSaving = false);
void resizeLayer(QImage*image_res, const QSize &newSize);

View File

@@ -2,9 +2,9 @@
#include "Layer/PaintingArea.h"
IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings){
this->Area=Area;
this->colorPicker=colorPicker;
this->Toolsettings=Toolsettings;
this->Area = Area;
this->colorPicker = colorPicker;
this->Toolsettings = Toolsettings;
}
@@ -14,7 +14,7 @@ IntelliTool::~IntelliTool(){
void IntelliTool::onMouseRightPressed(int x, int y){
if(isDrawing) {
isDrawing=false;
isDrawing = false;
this->deleteToolLayer();
}
}
@@ -24,7 +24,7 @@ void IntelliTool::onMouseRightReleased(int x, int y){
}
void IntelliTool::onMouseLeftPressed(int x, int y){
this->isDrawing=this->createToolLayer();
this->isDrawing = this->createToolLayer();
if(isDrawing) {
Canvas->image->calculateVisiblity();
}
@@ -32,7 +32,7 @@ void IntelliTool::onMouseLeftPressed(int x, int y){
void IntelliTool::onMouseLeftReleased(int x, int y){
if(isDrawing) {
isDrawing=false;
isDrawing = false;
this->mergeToolLayer();
this->deleteToolLayer();
activeLayer->image->calculateVisiblity();
@@ -51,8 +51,8 @@ void IntelliTool::onWheelScrolled(int value){
bool IntelliTool::createToolLayer(){
if(Area->createTempTopLayer(Area->activeLayer)) {
this->activeLayer=&Area->layerBundle[static_cast<unsigned long long>(Area->activeLayer)];
this->Canvas=&Area->layerBundle[static_cast<unsigned long long>(Area->activeLayer+1)];
this->activeLayer = &Area->layerBundle[static_cast<unsigned long long>(Area->activeLayer)];
this->Canvas = &Area->layerBundle[static_cast<unsigned long long>(Area->activeLayer + 1)];
return true;
}
return false;
@@ -63,15 +63,15 @@ void IntelliTool::mergeToolLayer(){
QColor clr_1;
QImage updatedImage = activeLayer->image->getImageData();
for(int y=0; y<activeLayer->height; y++) {
for(int x=0; x<activeLayer->width; x++) {
clr_0=updatedImage.pixelColor(x,y);
clr_1=Canvas->image->imageData.pixelColor(x,y);
float t = static_cast<float>(clr_1.alpha())/255.f;
int r =static_cast<int>(static_cast<float>(clr_1.red())*(t)+static_cast<float>(clr_0.red())*(1.f-t)+0.5f);
int g =static_cast<int>(static_cast<float>(clr_1.green())*(t)+static_cast<float>(clr_0.green())*(1.f-t)+0.5f);
int b =static_cast<int>(static_cast<float>(clr_1.blue())*(t)+static_cast<float>(clr_0.blue()*(1.f-t))+0.5f);
int a =std::min(clr_0.alpha()+clr_1.alpha(), 255);
for(int y = 0; y<activeLayer->height; y++) {
for(int x = 0; x<activeLayer->width; x++) {
clr_0 = updatedImage.pixelColor(x,y);
clr_1 = Canvas->image->imageData.pixelColor(x,y);
float t = static_cast<float>(clr_1.alpha()) / 255.f;
int r = static_cast<int>(static_cast<float>(clr_1.red()) * (t) + static_cast<float>(clr_0.red()) * (1.f - t) + 0.5f);
int g = static_cast<int>(static_cast<float>(clr_1.green()) * (t) + static_cast<float>(clr_0.green()) * (1.f - t) + 0.5f);
int b = static_cast<int>(static_cast<float>(clr_1.blue()) * (t) + static_cast<float>(clr_0.blue() * (1.f - t)) + 0.5f);
int a = std::min(clr_0.alpha() + clr_1.alpha(), 255);
clr_0.setRed(r);
clr_0.setGreen(g);
clr_0.setBlue(b);
@@ -88,8 +88,8 @@ void IntelliTool::mergeToolLayer(){
}
void IntelliTool::deleteToolLayer(){
Area->deleteLayer(Area->activeLayer+1, true);
this->Canvas=nullptr;
Area->deleteLayer(Area->activeLayer + 1, true);
this->Canvas = nullptr;
}
IntelliTool::Tooltype IntelliTool::getTooltype(){

View File

@@ -16,31 +16,31 @@ 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;
yMin = centerPoint.y() - radius;
yMax = 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)));
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);
}
//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)));
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());
}
xMin = (centerPoint.x()-radius);
xMax = (centerPoint.x()+radius);
for(int i=xMin; i<=xMax; 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)));
xMin = (centerPoint.x() - radius);
xMax = (centerPoint.x() + radius);
for(int i = xMin; i<=xMax; 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());
this->Canvas->image->drawPoint(QPoint(i, yMax), colorPicker->getFirstColor(),Toolsettings->getLineWidth());
}
@@ -57,7 +57,7 @@ void IntelliToolCircle::onMouseRightReleased(int x, int y){
void IntelliToolCircle::onMouseLeftPressed(int x, int y){
IntelliTool::onMouseLeftPressed(x,y);
if(this->isDrawing) {
this->centerPoint=QPoint(x,y);
this->centerPoint = QPoint(x,y);
int radius = 1;
drawCircle(radius);
Canvas->image->calculateVisiblity();
@@ -70,14 +70,14 @@ void IntelliToolCircle::onMouseLeftReleased(int x, int y){
void IntelliToolCircle::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value);
Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
Toolsettings->setLineWidth(Toolsettings->getLineWidth() + value);
}
void IntelliToolCircle::onMouseMoved(int x, int y){
if(this->isDrawing) {
this->Canvas->image->drawPlain(Qt::transparent);
QPoint next(x,y);
int radius = static_cast<int>(sqrt(pow((centerPoint.x()-x),2)+pow((centerPoint.y()-y),2)));
int radius = static_cast<int>(sqrt(pow((centerPoint.x() - x),2) + pow((centerPoint.y() - y),2)));
drawCircle(radius);
}
IntelliTool::onMouseMoved(x,y);

View File

@@ -41,10 +41,10 @@ void IntelliToolFloodFill::onMouseLeftPressed(int x, int y){
QPoint Current = Q.front();
Q.pop();
left = QPoint(Current.x()-1,Current.y() );
right = QPoint(Current.x()+1,Current.y() );
top = QPoint(Current.x(),Current.y()-1);
down = QPoint(Current.x(),Current.y()+1);
left = QPoint(Current.x() - 1,Current.y() );
right = QPoint(Current.x() + 1,Current.y() );
top = QPoint(Current.x(),Current.y() - 1);
down = QPoint(Current.x(),Current.y() + 1);
if((right.x() < Canvas->width) && (Canvas->image->getPixelColor(right) != newColor) && (activeLayer->image->getPixelColor(right) == oldColor)) {
Canvas->image->drawPixel(right,newColor);
Q.push(right);

View File

@@ -22,7 +22,7 @@ void IntelliToolLine::onMouseRightReleased(int x, int y){
void IntelliToolLine::onMouseLeftPressed(int x, int y){
IntelliTool::onMouseLeftPressed(x,y);
this->lineStartingPoint=QPoint(x,y);
this->lineStartingPoint = QPoint(x,y);
this->Canvas->image->drawPoint(lineStartingPoint, colorPicker->getFirstColor(),Toolsettings->getLineWidth());
Canvas->image->calculateVisiblity();
}
@@ -33,7 +33,7 @@ void IntelliToolLine::onMouseLeftReleased(int x, int y){
void IntelliToolLine::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value);
Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
Toolsettings->setLineWidth(Toolsettings->getLineWidth() + value);
}
void IntelliToolLine::onMouseMoved(int x, int y){

View File

@@ -23,7 +23,7 @@ void IntelliToolPen::onMouseRightReleased(int x, int y){
void IntelliToolPen::onMouseLeftPressed(int x, int y){
IntelliTool::onMouseLeftPressed(x,y);
this->previousPoint=QPoint(x,y);
this->previousPoint = QPoint(x,y);
this->Canvas->image->drawPoint(previousPoint, colorPicker->getFirstColor(), Toolsettings->getLineWidth());
Canvas->image->calculateVisiblity();
}
@@ -36,12 +36,12 @@ void IntelliToolPen::onMouseMoved(int x, int y){
if(this->isDrawing) {
QPoint newPoint(x,y);
this->Canvas->image->drawLine(this->previousPoint, newPoint, colorPicker->getFirstColor(), Toolsettings->getLineWidth());
this->previousPoint=newPoint;
this->previousPoint = newPoint;
}
IntelliTool::onMouseMoved(x,y);
}
void IntelliToolPen::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value);
Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
Toolsettings->setLineWidth(Toolsettings->getLineWidth() + value);
}

View File

@@ -101,8 +101,8 @@ void IntelliToolPolygon::onMouseLeftReleased(int x, int y){
}
}
}
for(int i=0; i<static_cast<int>(QPointList.size()); i++) {
int next = static_cast<int>((i+static_cast<int>(1))%static_cast<int>(QPointList.size()));
for(int i = 0; i<static_cast<int>(QPointList.size()); i++) {
int next = static_cast<int>((i + static_cast<int>(1)) % static_cast<int>(QPointList.size()));
this->Canvas->image->drawLine(QPointList[static_cast<unsigned long long>(i)], QPointList[static_cast<unsigned long long>(next)], colorPicker->getFirstColor(), Toolsettings->getLineWidth());
}

View File

@@ -20,7 +20,7 @@ void IntelliToolRectangle::drawRectangle(QPoint otherCorner){
QColor clr = colorPicker->getSecondColor();
clr.setAlpha(Toolsettings->getInnerAlpha());
for(int y=yMin; y<=yMax; y++) {
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(), Toolsettings->getLineWidth());
@@ -39,7 +39,7 @@ void IntelliToolRectangle::onMouseRightReleased(int x, int y){
void IntelliToolRectangle::onMouseLeftPressed(int x, int y){
IntelliTool::onMouseLeftPressed(x,y);
this->originCorner=QPoint(x,y);
this->originCorner = QPoint(x,y);
drawRectangle(originCorner);
Canvas->image->calculateVisiblity();
}
@@ -59,5 +59,5 @@ void IntelliToolRectangle::onMouseMoved(int x, int y){
void IntelliToolRectangle::onWheelScrolled(int value){
IntelliTool::onWheelScrolled(value);
Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value);
Toolsettings->setLineWidth(Toolsettings->getLineWidth() + value);
}