From c49c3c5e9c17ff8c526e3ede547ce4a17980ccaa Mon Sep 17 00:00:00 2001 From: Sonaion Date: Tue, 19 Nov 2019 16:39:23 +0100 Subject: [PATCH] Start of Dev --- IntelliPhoto/IntelliPhoto/.gitignore | 73 ++++++++++++++++++++ IntelliPhoto/IntelliPhoto/IntelliPhoto.pro | 35 ++++++++++ IntelliPhoto/IntelliPhoto/LayerManager.cpp | 80 ++++++++++++++++++++++ IntelliPhoto/IntelliPhoto/LayerManager.h | 43 ++++++++++++ IntelliPhoto/IntelliPhoto/intelligui.cpp | 36 ++++++++++ IntelliPhoto/IntelliPhoto/intelligui.h | 30 ++++++++ IntelliPhoto/IntelliPhoto/intelligui.ui | 23 +++++++ IntelliPhoto/IntelliPhoto/layer.cpp | 27 ++++++++ IntelliPhoto/IntelliPhoto/layer.h | 20 ++++++ IntelliPhoto/IntelliPhoto/main.cpp | 26 +++++++ 10 files changed, 393 insertions(+) create mode 100644 IntelliPhoto/IntelliPhoto/.gitignore create mode 100644 IntelliPhoto/IntelliPhoto/IntelliPhoto.pro create mode 100644 IntelliPhoto/IntelliPhoto/LayerManager.cpp create mode 100644 IntelliPhoto/IntelliPhoto/LayerManager.h create mode 100644 IntelliPhoto/IntelliPhoto/intelligui.cpp create mode 100644 IntelliPhoto/IntelliPhoto/intelligui.h create mode 100644 IntelliPhoto/IntelliPhoto/intelligui.ui create mode 100644 IntelliPhoto/IntelliPhoto/layer.cpp create mode 100644 IntelliPhoto/IntelliPhoto/layer.h create mode 100644 IntelliPhoto/IntelliPhoto/main.cpp diff --git a/IntelliPhoto/IntelliPhoto/.gitignore b/IntelliPhoto/IntelliPhoto/.gitignore new file mode 100644 index 0000000..fab7372 --- /dev/null +++ b/IntelliPhoto/IntelliPhoto/.gitignore @@ -0,0 +1,73 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + diff --git a/IntelliPhoto/IntelliPhoto/IntelliPhoto.pro b/IntelliPhoto/IntelliPhoto/IntelliPhoto.pro new file mode 100644 index 0000000..42fc620 --- /dev/null +++ b/IntelliPhoto/IntelliPhoto/IntelliPhoto.pro @@ -0,0 +1,35 @@ +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +CONFIG += c++11 + +# The following define makes your compiler emit warnings if you use +# any Qt feature that has been marked deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + LayerManager.cpp \ + intelligui.cpp \ + layer.cpp \ + main.cpp + +HEADERS += \ + LayerManager.h \ + intelligui.h \ + layer.h + +FORMS += \ + intelligui.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/IntelliPhoto/IntelliPhoto/LayerManager.cpp b/IntelliPhoto/IntelliPhoto/LayerManager.cpp new file mode 100644 index 0000000..6b8d7f6 --- /dev/null +++ b/IntelliPhoto/IntelliPhoto/LayerManager.cpp @@ -0,0 +1,80 @@ +#include "LayerManager.h" + +LayerManager::LayerManager(){ + this->imgLabel = new QLabel(""); + +} + +LayerManager::~LayerManager(){ + delete this->imgLabel; + for(auto element:Ebenen){ + delete element; + } +} + +int LayerManager::getLayerCount(){ + return static_cast(this->Ebenen.size()); +} + +void LayerManager::setLayerVisbility(int idx, int alpha){ + //current alpha is ignored, just one image is shown + for(auto &element: this->MetaEbenen){ + element.a=0; + } + MetaEbenen[static_cast(idx)].a=255; +} + +void LayerManager::activateLayer(int idx){ + for(auto& element: this->MetaEbenen){ + element.a = 0; + } + MetaEbenen[static_cast(idx)].a=255; +} + +void LayerManager::goLayerUp(){ + for(size_t i=0; i(this->getLayerCount()); i++){ + if(this->MetaEbenen[i].a==255){ + if(i==static_cast(this->getLayerCount())-1){ + return; + } + MetaEbenen[i].a=0; + MetaEbenen[i+1].a=255; + return; + } + } +} + +void LayerManager::goLayerDown(){ + for(size_t i=0; i(this->getLayerCount()); i++){ + if(this->MetaEbenen[i].a==255){ + if(i==0){ + return; + } + MetaEbenen[i].a=0; + MetaEbenen[i-1].a=255; + return; + } + } +} + +void LayerManager::AddLayerAfer(int idx){ + Layer* newLayer = new Layer(100,100); + Ebenen.insert(Ebenen.begin()+idx, newLayer); +} + +void LayerManager::DeleteLayer(int idx){ + Ebenen.erase(Ebenen.begin()+idx); +} + +QLabel* LayerManager::getDisplayable(){ + //Tranzparenz der Ebenen muss möglich sein + QPixmap Map(maxWidth, maxHeight); + for(size_t i=0; i(this->getLayerCount()); i++){ + if(MetaEbenen[i].a==255){ + Map = Ebenen[i]->getAsPixmap(); + break; + } + } + this->imgLabel->setPixmap(Map); + return imgLabel; +} diff --git a/IntelliPhoto/IntelliPhoto/LayerManager.h b/IntelliPhoto/IntelliPhoto/LayerManager.h new file mode 100644 index 0000000..e652474 --- /dev/null +++ b/IntelliPhoto/IntelliPhoto/LayerManager.h @@ -0,0 +1,43 @@ +#ifndef CANVAS_H +#define CANVAS_H +#include"layer.h" + +#include +#include + + + + +class LayerManager{ +private: + struct EbenenMetaDaten{ + unsigned int x; + unsigned int y; + unsigned int a; + EbenenMetaDaten(unsigned int x, unsigned int y, unsigned int a){ + this->x = x; + this->y = y; + this->a = a; + } + }; + int maxWidth; + int maxHeight; + + QLabel* imgLabel; + std::vector Ebenen; + std::vector MetaEbenen; +public: + LayerManager(); + ~LayerManager(); + + int getLayerCount(); + void setLayerVisbility(int idx, int alpha); + void activateLayer(int idx); + void goLayerUp(); + void goLayerDown(); + void AddLayerAfer(int idx); + void DeleteLayer(int idx); + QLabel* getDisplayable(); +}; + +#endif // CANVAS_H diff --git a/IntelliPhoto/IntelliPhoto/intelligui.cpp b/IntelliPhoto/IntelliPhoto/intelligui.cpp new file mode 100644 index 0000000..28440dc --- /dev/null +++ b/IntelliPhoto/IntelliPhoto/intelligui.cpp @@ -0,0 +1,36 @@ +#include "intelligui.h" +#include "ui_intelligui.h" +#include +#include +#include +#include + +IntelliGUI::IntelliGUI(QWidget *parent) + : QMainWindow(parent), + ui(new Ui::IntelliGUI){ + ui->setupUi(this); +} + +IntelliGUI::~IntelliGUI(){ + delete ui; +} + +void IntelliGUI::setColor(double R, double G, double B){ + R *= 255; + G *= 255; + B *= 255; + QString color = "rgb("; + color += QString::number(R)+ ","; + color += QString::number(G)+ ","; + color += QString::number(B)+ ")"; + this->setStyleSheet("background-color:"+color); +} + +void IntelliGUI::setColor(int R, int G, int B){ + QString color = "rgb("; + color += QString::number(R)+ ","; + color += QString::number(G)+ ","; + color += QString::number(B)+ ")"; + this->setStyleSheet("background-color:"+color); +} + diff --git a/IntelliPhoto/IntelliPhoto/intelligui.h b/IntelliPhoto/IntelliPhoto/intelligui.h new file mode 100644 index 0000000..cf94619 --- /dev/null +++ b/IntelliPhoto/IntelliPhoto/intelligui.h @@ -0,0 +1,30 @@ +#ifndef INTELLIGUI_H +#define INTELLIGUI_H + +#include +#include + +QT_BEGIN_NAMESPACE +namespace Ui { class IntelliGUI; } +QT_END_NAMESPACE + +class IntelliGUI : public QMainWindow +{ + Q_OBJECT + QWidget *GUI; + +private: + Ui::IntelliGUI *ui; + QString color="rgb(255,255,255)"; + +public: + IntelliGUI(QWidget *parent = nullptr); + ~IntelliGUI(); + + //COlor Values between 0 and 1 + void setColor(double R, double G, double B); + void setColor(int R, int G, int B); + +private slots: +}; +#endif // INTELLIGUI_H diff --git a/IntelliPhoto/IntelliPhoto/intelligui.ui b/IntelliPhoto/IntelliPhoto/intelligui.ui new file mode 100644 index 0000000..83ba604 --- /dev/null +++ b/IntelliPhoto/IntelliPhoto/intelligui.ui @@ -0,0 +1,23 @@ + + + IntelliGUI + + + + 0 + 0 + 800 + 438 + + + + IntelliGUI + + + + + + + + + diff --git a/IntelliPhoto/IntelliPhoto/layer.cpp b/IntelliPhoto/IntelliPhoto/layer.cpp new file mode 100644 index 0000000..7ec12b4 --- /dev/null +++ b/IntelliPhoto/IntelliPhoto/layer.cpp @@ -0,0 +1,27 @@ +#include "layer.h" + +Layer::Layer(const int& width,const int& height){ + this->Canvas = new QImage(width, height, QImage::Format::Format_ARGB32); +} + +Layer::~Layer(){ + delete this->Canvas; +} + +void Layer::setPixel(const int& w,const int& h,const int& a,const int& r,const int& g,const int& b){ + QRgba64 clr; + clr.setRed(static_cast(r)); + clr.setGreen(static_cast(g)); + clr.setBlue(static_cast(b)); + clr.setAlpha(static_cast(a)); + this->Canvas->setPixelColor(w,h,QColor(clr)); +} + +void Layer::loadImage(const QString& fileName){ + //load of image an specifing fileformat needs to be implemented +} + +QPixmap Layer::getAsPixmap(){ + return QPixmap::fromImage(*(this->Canvas)); +} + diff --git a/IntelliPhoto/IntelliPhoto/layer.h b/IntelliPhoto/IntelliPhoto/layer.h new file mode 100644 index 0000000..2d7415f --- /dev/null +++ b/IntelliPhoto/IntelliPhoto/layer.h @@ -0,0 +1,20 @@ +#ifndef LAYER_H +#define LAYER_H +#include +#include +#include + +class Layer{ +private: + QImage* Canvas; + int width; + int height; +public: + Layer(const int& width,const int& height); + ~Layer(); + void setPixel(const int& w,const int& h,const int& a,const int& r,const int& g,const int& b); + void loadImage(const QString& fileName); + QPixmap getAsPixmap(); +}; + +#endif // LAYER_H diff --git a/IntelliPhoto/IntelliPhoto/main.cpp b/IntelliPhoto/IntelliPhoto/main.cpp new file mode 100644 index 0000000..ee0cc28 --- /dev/null +++ b/IntelliPhoto/IntelliPhoto/main.cpp @@ -0,0 +1,26 @@ +#include "intelligui.h" + +#include +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication application(argc, argv); + IntelliGUI* win = new IntelliGUI(); + QWidget *window = new QWidget(win); + win->setCentralWidget(window); + + QGridLayout* Layout = new QGridLayout(window); + QPushButton* Button= new QPushButton("Button"); + QImage* Canvas = new QImage(200,200, QImage::Format::Format_ARGB32); + QLabel* imgLabel = new QLabel(""); + imgLabel->setPixmap(QPixmap::fromImage(*Canvas)); + Layout->addWidget(imgLabel,0,0,10,10); + Layout->addWidget(Button,10,0); + win->show(); + return application.exec(); +}