Start of Dev

This commit is contained in:
Sonaion
2019-11-19 16:39:23 +01:00
parent 40e7fbe201
commit c49c3c5e9c
10 changed files with 393 additions and 0 deletions

73
IntelliPhoto/IntelliPhoto/.gitignore vendored Normal file
View File

@@ -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

View File

@@ -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

View File

@@ -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<int>(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<size_t>(idx)].a=255;
}
void LayerManager::activateLayer(int idx){
for(auto& element: this->MetaEbenen){
element.a = 0;
}
MetaEbenen[static_cast<size_t>(idx)].a=255;
}
void LayerManager::goLayerUp(){
for(size_t i=0; i<static_cast<size_t>(this->getLayerCount()); i++){
if(this->MetaEbenen[i].a==255){
if(i==static_cast<size_t>(this->getLayerCount())-1){
return;
}
MetaEbenen[i].a=0;
MetaEbenen[i+1].a=255;
return;
}
}
}
void LayerManager::goLayerDown(){
for(size_t i=0; i<static_cast<size_t>(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<static_cast<size_t>(this->getLayerCount()); i++){
if(MetaEbenen[i].a==255){
Map = Ebenen[i]->getAsPixmap();
break;
}
}
this->imgLabel->setPixmap(Map);
return imgLabel;
}

View File

@@ -0,0 +1,43 @@
#ifndef CANVAS_H
#define CANVAS_H
#include"layer.h"
#include<vector>
#include <QLabel>
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<Layer*> Ebenen;
std::vector<EbenenMetaDaten> 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

View File

@@ -0,0 +1,36 @@
#include "intelligui.h"
#include "ui_intelligui.h"
#include<QDebug>
#include<QGridLayout>
#include<QLabel>
#include<QColor>
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);
}

View File

@@ -0,0 +1,30 @@
#ifndef INTELLIGUI_H
#define INTELLIGUI_H
#include <QMainWindow>
#include <QPushButton>
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

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>IntelliGUI</class>
<widget class="QMainWindow" name="IntelliGUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>438</height>
</rect>
</property>
<property name="windowTitle">
<string>IntelliGUI</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QWidget" name="centralwidget"/>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -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<quint16>(r));
clr.setGreen(static_cast<quint16>(g));
clr.setBlue(static_cast<quint16>(b));
clr.setAlpha(static_cast<quint16>(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));
}

View File

@@ -0,0 +1,20 @@
#ifndef LAYER_H
#define LAYER_H
#include<QImage>
#include<QPixmap>
#include<QString>
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

View File

@@ -0,0 +1,26 @@
#include "intelligui.h"
#include <QApplication>
#include<QHBoxLayout>
#include<QLabel>
#include<QPushButton>
#include<QImage>
#include<QPixmap>
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();
}