diff --git a/IntelliPhoto/IntelliPhoto/LayerManager.cpp b/IntelliPhoto/IntelliPhoto/LayerManager.cpp index 6b8d7f6..bab6485 100644 --- a/IntelliPhoto/IntelliPhoto/LayerManager.cpp +++ b/IntelliPhoto/IntelliPhoto/LayerManager.cpp @@ -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(this->getLayerCount()); i++){ if(this->MetaEbenen[i].a==255){ if(i==static_cast(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(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(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; } diff --git a/IntelliPhoto/IntelliPhoto/LayerManager.h b/IntelliPhoto/IntelliPhoto/LayerManager.h index e652474..4590769 100644 --- a/IntelliPhoto/IntelliPhoto/LayerManager.h +++ b/IntelliPhoto/IntelliPhoto/LayerManager.h @@ -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 Ebenen; + + //all the meta data parallel to Ebenen Container std::vector 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(); }; diff --git a/IntelliPhoto/IntelliPhoto/intelligui.cpp b/IntelliPhoto/IntelliPhoto/intelligui.cpp index 28440dc..756ef8f 100644 --- a/IntelliPhoto/IntelliPhoto/intelligui.cpp +++ b/IntelliPhoto/IntelliPhoto/intelligui.cpp @@ -1,36 +1,44 @@ #include "intelligui.h" #include "ui_intelligui.h" -#include -#include -#include -#include +#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); -} diff --git a/IntelliPhoto/IntelliPhoto/intelligui.h b/IntelliPhoto/IntelliPhoto/intelligui.h index cf94619..629cb52 100644 --- a/IntelliPhoto/IntelliPhoto/intelligui.h +++ b/IntelliPhoto/IntelliPhoto/intelligui.h @@ -3,6 +3,8 @@ #include #include +#include +#include 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 diff --git a/IntelliPhoto/IntelliPhoto/layer.cpp b/IntelliPhoto/IntelliPhoto/layer.cpp index 7ec12b4..b2a5f0d 100644 --- a/IntelliPhoto/IntelliPhoto/layer.cpp +++ b/IntelliPhoto/IntelliPhoto/layer.cpp @@ -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(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::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){ diff --git a/IntelliPhoto/IntelliPhoto/layer.h b/IntelliPhoto/IntelliPhoto/layer.h index 2d7415f..43ff1ec 100644 --- a/IntelliPhoto/IntelliPhoto/layer.h +++ b/IntelliPhoto/IntelliPhoto/layer.h @@ -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(); }; diff --git a/IntelliPhoto/IntelliPhoto/main.cpp b/IntelliPhoto/IntelliPhoto/main.cpp index ee0cc28..1c72290 100644 --- a/IntelliPhoto/IntelliPhoto/main.cpp +++ b/IntelliPhoto/IntelliPhoto/main.cpp @@ -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(); } diff --git a/IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmp0l4rts b/IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmp0l4rts new file mode 100644 index 0000000..e69de29 diff --git a/IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmpcvzqoi b/IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmpcvzqoi new file mode 100644 index 0000000..e69de29 diff --git a/IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmpqakvqm b/IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmpqakvqm new file mode 100644 index 0000000..e69de29 diff --git a/IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmpu6gfxp b/IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug/usersjonasappdatalocaltemptmpu6gfxp new file mode 100644 index 0000000..e69de29