diff --git a/IntelliPhoto/IntelliPhoto/LayerManager.cpp b/IntelliPhoto/IntelliPhoto/LayerManager.cpp index bab6485..20cd902 100644 --- a/IntelliPhoto/IntelliPhoto/LayerManager.cpp +++ b/IntelliPhoto/IntelliPhoto/LayerManager.cpp @@ -103,3 +103,26 @@ QLabel* LayerManager::getDisplayable(){ this->imgLabel->setPixmap(aMap); return imgLabel; } + +void LayerManager::floodFillLayer(int r, int g, int b){ + for(size_t i=0; i< static_cast(this->getLayerCount()); i++){ + if(MetaEbenen[i].a==255){ + Ebenen[i]->floodFill(r,g,b); + this->UpdateLabel(); + return; + } + } +} + +void LayerManager::UpdateLabel(){ + //Tranzparenz der Ebenen muss möglich sein + QPixmap aMap; + for(size_t i=0; i(this->getLayerCount()); i++){ + if(MetaEbenen[i].a==255){ + aMap = Ebenen[i]->getAsPixmap(); + break; + } + } + + this->imgLabel->setPixmap(aMap); +} diff --git a/IntelliPhoto/IntelliPhoto/LayerManager.h b/IntelliPhoto/IntelliPhoto/LayerManager.h index 4590769..e98ed76 100644 --- a/IntelliPhoto/IntelliPhoto/LayerManager.h +++ b/IntelliPhoto/IntelliPhoto/LayerManager.h @@ -4,6 +4,7 @@ #include #include +#include @@ -34,6 +35,9 @@ private: //all the meta data parallel to Ebenen Container std::vector MetaEbenen; + + //updates the display + void UpdateLabel(); public: LayerManager(); ~LayerManager(); @@ -59,6 +63,9 @@ public: //delets a layer at the given index void DeleteLayer(int idx); + //fill active Layer + void floodFillLayer(int r, int g, int b); + //returns the output ready label QLabel* getDisplayable(); }; diff --git a/IntelliPhoto/IntelliPhoto/intelligui.cpp b/IntelliPhoto/IntelliPhoto/intelligui.cpp index 756ef8f..9f4d71e 100644 --- a/IntelliPhoto/IntelliPhoto/intelligui.cpp +++ b/IntelliPhoto/IntelliPhoto/intelligui.cpp @@ -2,6 +2,8 @@ #include "ui_intelligui.h" #include "LayerManager.h" +#include + IntelliGUI::IntelliGUI(QWidget *parent) : QMainWindow(parent), ui(new Ui::IntelliGUI){ @@ -21,13 +23,28 @@ IntelliGUI::IntelliGUI(QWidget *parent) //setup all gui elements down here this->EinKnopf = new QPushButton("Ein Knopf"); + this->Red = new QLineEdit(); + this->Blue = new QLineEdit(); + this->Green = new QLineEdit(); - + //Manage signals and slots in here + QObject::connect(EinKnopf, SIGNAL(clicked()), this, SLOT(on_EinKnopf_clicked())); //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); + this->Layout->addWidget(this->Red, 1,10); + this->Layout->addWidget(this->Green, 2,10); + this->Layout->addWidget(this->Blue, 3,10); + this->Layout->addWidget(this->EbenenManager->getDisplayable(),0,0,10,10); + + + //set style here + this->setStyleSheet("background-color:rgb(60,60,60)"); + this->EinKnopf->setStyleSheet("color:rgb(250,250,250)"); + this->Red->setStyleSheet("color:rgb(250,250,250)"); + this->Green->setStyleSheet("color:rgb(250,250,250)"); + this->Blue->setStyleSheet("color:rgb(250,250,250)"); + //Layout is set in here this->setLayout(Layout); } @@ -39,6 +56,18 @@ IntelliGUI::~IntelliGUI(){ delete EbenenManager; //delete all Gui elements down here + delete EinKnopf; + delete Red; + delete Blue; + delete Green; } + +void IntelliGUI::on_EinKnopf_clicked(){ + int redCol = Red->text().toInt(); + int greCol = Green->text().toInt(); + int bluCol = Blue->text().toInt(); + qDebug() << redCol << " " << greCol << " " << bluCol << '\n'; + EbenenManager->floodFillLayer(redCol, greCol, bluCol); +} diff --git a/IntelliPhoto/IntelliPhoto/intelligui.h b/IntelliPhoto/IntelliPhoto/intelligui.h index 629cb52..7c5081a 100644 --- a/IntelliPhoto/IntelliPhoto/intelligui.h +++ b/IntelliPhoto/IntelliPhoto/intelligui.h @@ -5,6 +5,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE namespace Ui { class IntelliGUI; } @@ -22,6 +23,9 @@ class IntelliGUI : public QMainWindow //Declare all Gui elements down here QPushButton *EinKnopf; + QLineEdit *Red; + QLineEdit *Blue; + QLineEdit *Green; private: Ui::IntelliGUI *ui; @@ -32,6 +36,7 @@ public: //Delets everything in connection to one project ~IntelliGUI(); -private slots: +public slots: + void on_EinKnopf_clicked(); }; #endif // INTELLIGUI_H diff --git a/IntelliPhoto/IntelliPhoto/layer.cpp b/IntelliPhoto/IntelliPhoto/layer.cpp index b2a5f0d..f0a3a75 100644 --- a/IntelliPhoto/IntelliPhoto/layer.cpp +++ b/IntelliPhoto/IntelliPhoto/layer.cpp @@ -22,3 +22,11 @@ QPixmap Layer::getAsPixmap(){ return QPixmap::fromImage(*(this->Canvas)); } + +void Layer::floodFill(int r, int g, int b){ + for(int i=0; iCanvas->setPixelColor(i,j,QColor(r,g,b,255)); + } + } +} diff --git a/IntelliPhoto/IntelliPhoto/layer.h b/IntelliPhoto/IntelliPhoto/layer.h index 43ff1ec..cf066b0 100644 --- a/IntelliPhoto/IntelliPhoto/layer.h +++ b/IntelliPhoto/IntelliPhoto/layer.h @@ -25,6 +25,9 @@ public: //load an image to the canvas void loadImage(const QString& fileName); + //flood fills canvas + void floodFill(int r, int g, int b); + //return the image as QPixmap QPixmap getAsPixmap(); }; diff --git a/IntelliPhoto/IntelliPhoto/main.cpp b/IntelliPhoto/IntelliPhoto/main.cpp index 1c72290..820878b 100644 --- a/IntelliPhoto/IntelliPhoto/main.cpp +++ b/IntelliPhoto/IntelliPhoto/main.cpp @@ -1,3 +1,5 @@ +#include + #include "intelligui.h" #include @@ -7,6 +9,7 @@ #include #include + int main(int argc, char *argv[]) { QApplication application(argc, argv);