mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-12 19:40:28 +02:00
Comments and compile fähig
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#include "LayerManager.h"
|
||||
|
||||
LayerManager::LayerManager(){
|
||||
//setup the label for the image
|
||||
this->imgLabel = new QLabel("");
|
||||
|
||||
}
|
||||
|
||||
LayerManager::~LayerManager(){
|
||||
@@ -18,6 +18,7 @@ int LayerManager::getLayerCount(){
|
||||
|
||||
void LayerManager::setLayerVisbility(int idx, int alpha){
|
||||
//current alpha is ignored, just one image is shown
|
||||
//all images should hold on to their current alpha
|
||||
for(auto &element: this->MetaEbenen){
|
||||
element.a=0;
|
||||
}
|
||||
@@ -25,6 +26,7 @@ void LayerManager::setLayerVisbility(int idx, int alpha){
|
||||
}
|
||||
|
||||
void LayerManager::activateLayer(int idx){
|
||||
//all images should blurr an active layer should show
|
||||
for(auto& element: this->MetaEbenen){
|
||||
element.a = 0;
|
||||
}
|
||||
@@ -32,6 +34,7 @@ void LayerManager::activateLayer(int idx){
|
||||
}
|
||||
|
||||
void LayerManager::goLayerUp(){
|
||||
//at current state, sets the alpha of the higher one up
|
||||
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){
|
||||
@@ -45,6 +48,7 @@ void LayerManager::goLayerUp(){
|
||||
}
|
||||
|
||||
void LayerManager::goLayerDown(){
|
||||
//at current state, sets the alpha of the higher one down
|
||||
for(size_t i=0; i<static_cast<size_t>(this->getLayerCount()); i++){
|
||||
if(this->MetaEbenen[i].a==255){
|
||||
if(i==0){
|
||||
@@ -58,23 +62,44 @@ void LayerManager::goLayerDown(){
|
||||
}
|
||||
|
||||
void LayerManager::AddLayerAfer(int idx){
|
||||
Layer* newLayer = new Layer(100,100);
|
||||
//layer dimension needs to be asked, maybe in seperat window
|
||||
Layer* newLayer = new Layer(600,400);
|
||||
|
||||
//hardcoded layer for test sake
|
||||
for(int i=0; i<600; i++){
|
||||
for(int j=0; j<400; j++){
|
||||
newLayer->setPixel(i,j,255,0,0,255);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0; i<300; i++){
|
||||
for(int j = 0; j<5; j++)
|
||||
newLayer->setPixel(i,j,0,255,255,255);
|
||||
}
|
||||
maxWidth=100;
|
||||
maxHeight=100;
|
||||
|
||||
|
||||
Ebenen.insert(Ebenen.begin()+idx, newLayer);
|
||||
MetaEbenen.insert(MetaEbenen.begin()+idx, EbenenMetaDaten(0,0,0));
|
||||
}
|
||||
|
||||
void LayerManager::DeleteLayer(int idx){
|
||||
Ebenen.erase(Ebenen.begin()+idx);
|
||||
MetaEbenen.erase(MetaEbenen.begin()+idx);
|
||||
}
|
||||
|
||||
QLabel* LayerManager::getDisplayable(){
|
||||
|
||||
//Tranzparenz der Ebenen muss möglich sein
|
||||
QPixmap Map(maxWidth, maxHeight);
|
||||
QPixmap aMap;
|
||||
for(size_t i=0; i<static_cast<size_t>(this->getLayerCount()); i++){
|
||||
if(MetaEbenen[i].a==255){
|
||||
Map = Ebenen[i]->getAsPixmap();
|
||||
aMap = Ebenen[i]->getAsPixmap();
|
||||
break;
|
||||
}
|
||||
}
|
||||
this->imgLabel->setPixmap(Map);
|
||||
|
||||
this->imgLabel->setPixmap(aMap);
|
||||
return imgLabel;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
class LayerManager{
|
||||
private:
|
||||
//Uses to handle the Meta Data of each layer in comparission to 'global' propteries
|
||||
struct EbenenMetaDaten{
|
||||
unsigned int x;
|
||||
unsigned int y;
|
||||
@@ -20,23 +21,45 @@ private:
|
||||
this->a = a;
|
||||
}
|
||||
};
|
||||
//max width of the layer (max(EbenenMetaDaten.x+Layer.width))
|
||||
int maxWidth;
|
||||
//max width of the layer (max(EbenenMetaDaten.y+Layer.height))
|
||||
int maxHeight;
|
||||
|
||||
// The label where the image is shown
|
||||
QLabel* imgLabel;
|
||||
|
||||
//all the possible layers in one container
|
||||
std::vector<Layer*> Ebenen;
|
||||
|
||||
//all the meta data parallel to Ebenen Container
|
||||
std::vector<EbenenMetaDaten> MetaEbenen;
|
||||
public:
|
||||
LayerManager();
|
||||
~LayerManager();
|
||||
|
||||
//gets the count of layers
|
||||
int getLayerCount();
|
||||
|
||||
//set one layer to a given alpha value
|
||||
void setLayerVisbility(int idx, int alpha);
|
||||
|
||||
//activates one layer to work on it
|
||||
void activateLayer(int idx);
|
||||
|
||||
//changes the active layer one up
|
||||
void goLayerUp();
|
||||
|
||||
//changes the active layer one down
|
||||
void goLayerDown();
|
||||
|
||||
//adds a new layer after (on top of) the given idx (-1 create bottom layer)
|
||||
void AddLayerAfer(int idx);
|
||||
|
||||
//delets a layer at the given index
|
||||
void DeleteLayer(int idx);
|
||||
|
||||
//returns the output ready label
|
||||
QLabel* getDisplayable();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,36 +1,44 @@
|
||||
#include "intelligui.h"
|
||||
#include "ui_intelligui.h"
|
||||
#include<QDebug>
|
||||
#include<QGridLayout>
|
||||
#include<QLabel>
|
||||
#include<QColor>
|
||||
#include "LayerManager.h"
|
||||
|
||||
IntelliGUI::IntelliGUI(QWidget *parent)
|
||||
: QMainWindow(parent),
|
||||
ui(new Ui::IntelliGUI){
|
||||
ui->setupUi(this);
|
||||
|
||||
//Setting up basic IntelliPhoto structure
|
||||
this->EbenenManager = new LayerManager();
|
||||
|
||||
//Test Layer
|
||||
this->EbenenManager->AddLayerAfer(0);
|
||||
this->EbenenManager->activateLayer(0);
|
||||
|
||||
//Setting up basic IntelliGui Structure
|
||||
this->GUI = new QWidget();
|
||||
this->Layout = new QGridLayout(GUI);
|
||||
this->setCentralWidget(GUI);
|
||||
|
||||
//setup all gui elements down here
|
||||
this->EinKnopf = new QPushButton("Ein Knopf");
|
||||
|
||||
|
||||
|
||||
//Merge all gui elements to Layout down here
|
||||
this->Layout->addWidget(this->EinKnopf, 0,10);
|
||||
this->Layout->addWidget(this->EbenenManager->getDisplayable(),1,1,10,10);
|
||||
//this->Layout->addWidget(this->EbenenManager->getDisplayable(),0,0,10,10);
|
||||
//Layout is set in here
|
||||
this->setLayout(Layout);
|
||||
}
|
||||
|
||||
IntelliGUI::~IntelliGUI(){
|
||||
delete ui;
|
||||
delete GUI;
|
||||
delete Layout;
|
||||
delete EbenenManager;
|
||||
|
||||
//delete all Gui elements down here
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QPushButton>
|
||||
#include <LayerManager.h>
|
||||
#include <QGridLayout>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui { class IntelliGUI; }
|
||||
@@ -11,20 +13,25 @@ QT_END_NAMESPACE
|
||||
class IntelliGUI : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
//basics for programm logic
|
||||
LayerManager *EbenenManager;
|
||||
|
||||
//basics for GUI build
|
||||
QWidget *GUI;
|
||||
QGridLayout *Layout;
|
||||
|
||||
//Declare all Gui elements down here
|
||||
QPushButton *EinKnopf;
|
||||
|
||||
private:
|
||||
Ui::IntelliGUI *ui;
|
||||
QString color="rgb(255,255,255)";
|
||||
|
||||
public:
|
||||
//Sets up everything to display first loaded projekt, maybe show load window for a project
|
||||
IntelliGUI(QWidget *parent = nullptr);
|
||||
//Delets everything in connection to one project
|
||||
~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
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
#include "layer.h"
|
||||
|
||||
Layer::Layer(const int& width,const int& height){
|
||||
this->Canvas = new QImage(width, height, QImage::Format::Format_ARGB32);
|
||||
this->Canvas = new QImage(width, height, QImage::Format_RGB32);
|
||||
this->width=width;
|
||||
this->height=height;
|
||||
}
|
||||
|
||||
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::setPixel(const int& w,const int& h, const int& r,const int& g,const int& b, const int& a){
|
||||
this->Canvas->setPixelColor(w,h,QColor(r,g,b,a));
|
||||
}
|
||||
|
||||
void Layer::loadImage(const QString& fileName){
|
||||
|
||||
@@ -6,14 +6,26 @@
|
||||
|
||||
class Layer{
|
||||
private:
|
||||
//pixelmap for the image, used because of performance and api reasons
|
||||
QImage* Canvas;
|
||||
|
||||
//width of the image
|
||||
int width;
|
||||
|
||||
//height of the imahe
|
||||
int height;
|
||||
public:
|
||||
//setup everything for the image
|
||||
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);
|
||||
|
||||
//set one pixel with rgba values
|
||||
void setPixel(const int& w,const int& h,const int& r,const int& g,const int& b, const int& a);
|
||||
|
||||
//load an image to the canvas
|
||||
void loadImage(const QString& fileName);
|
||||
|
||||
//return the image as QPixmap
|
||||
QPixmap getAsPixmap();
|
||||
};
|
||||
|
||||
|
||||
@@ -11,16 +11,6 @@ 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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user