diff --git a/Gebouw.png b/Gebouw.png new file mode 100644 index 0000000..8c863fa Binary files /dev/null and b/Gebouw.png differ diff --git a/deur.h b/deur.h index a8e595b..dbd42ff 100644 --- a/deur.h +++ b/deur.h @@ -6,8 +6,7 @@ using namespace std; -class Deur -{ +class Deur{ private: bool status; int x_coordinaat, y_coordinaat; diff --git a/draaideur.cpp b/draaideur.cpp index fec764c..02ee686 100644 --- a/draaideur.cpp +++ b/draaideur.cpp @@ -3,21 +3,23 @@ #include #include -Draaideur::Draaideur(int x, int y, int lengte): Deur(x,y,lengte){ +draaideur::draaideur(int x, int y, int lengte, bool liggend): Deur(x,y,lengte), liggend(liggend){ } -void Draaideur::teken(QPaintDevice* tp){ +void draaideur::teken(QPaintDevice *tp){ QPainter p(tp); - QColor kleur; + QColor kleur=Qt::black; p.setBrush(Qt::SolidPattern); - if(isDeurOpen()) - kleur=Qt::blue; - else - kleur=Qt::yellow; - - p.setBrush(kleur); - QPen pen(kleur,2,Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - p.setPen(pen); - p.drawEllipse(coordinaten().first,coordinaten().second,20,20); + p.setBrush(kleur); + QPen pen(kleur,2,Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); + p.setPen(pen); + if(!isDeurOpen() && !liggend) + p.drawLine(coordinaten().first, coordinaten().second, coordinaten().first, coordinaten().second - deurLengte()); + else if(!isDeurOpen() && liggend) + p.drawLine(coordinaten().first, coordinaten().second, coordinaten().first - deurLengte(), coordinaten().second); + else if(isDeurOpen() && !liggend) + p.drawLine(coordinaten().first, coordinaten().second, coordinaten().first + deurLengte(), coordinaten().second); + else if(isDeurOpen() && liggend) + p.drawLine(coordinaten().first, coordinaten().second, coordinaten().first, coordinaten().second - deurLengte()); } diff --git a/draaideur.h b/draaideur.h index 250a02a..463389d 100644 --- a/draaideur.h +++ b/draaideur.h @@ -5,12 +5,13 @@ class QPaintDevice; -class Draaideur : public Deur{ +class draaideur : public Deur{ private: bool liggend; public: - Draaideur(int, int, int); - void teken(QPaintDevice*); + draaideur(int,int,int,bool); + void teken(QPaintDevice*) override; + }; #endif // DRAAIDEUR_H diff --git a/gebouw.pro.user b/gebouw.pro.user new file mode 100644 index 0000000..9d450a5 --- /dev/null +++ b/gebouw.pro.user @@ -0,0 +1,308 @@ + + + + + + EnvironmentId + {daf7231d-d0bf-4367-8947-ae949d9f2d27} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + *.md, *.MD, Makefile + false + true + + + + ProjectExplorer.Project.PluginSettings + + + true + true + true + true + true + + + 0 + true + + false + {52ee9352-13f8-4418-955f-9ca6cac4ac63} + + true + true + Builtin.DefaultTidyAndClazy + 4 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + Desktop + {56611235-07dd-4b90-81ed-415f033053fc} + 0 + 0 + 0 + + /home/shaquille/Downloads/build-gebouw-Desktop-Debug + /home/shaquille/Downloads/build-gebouw-Desktop-Debug + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + /home/shaquille/Downloads/build-gebouw-Desktop-Release + /home/shaquille/Downloads/build-gebouw-Desktop-Release + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + + /home/shaquille/Downloads/build-gebouw-Desktop-Profile + /home/shaquille/Downloads/build-gebouw-Desktop-Profile + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:/home/shaquille/Downloads/gebouw/gebouw.pro + /home/shaquille/Downloads/gebouw/gebouw.pro + false + true + true + false + true + /home/shaquille/Downloads/build-gebouw-Desktop-Debug + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/gebouw.pro.user.22 b/gebouw.pro.user.22 new file mode 100644 index 0000000..0aadb7b --- /dev/null +++ b/gebouw.pro.user.22 @@ -0,0 +1,308 @@ + + + + + + EnvironmentId + {daf7231d-d0bf-4367-8947-ae949d9f2d27} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + *.md, *.MD, Makefile + false + true + + + + ProjectExplorer.Project.PluginSettings + + + true + true + true + true + true + + + 0 + true + + true + Builtin.Questionable + + true + true + Builtin.DefaultTidyAndClazy + 4 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + Desktop + {56611235-07dd-4b90-81ed-415f033053fc} + 0 + 0 + 0 + + /home/shaquille/Downloads/build-gebouw-Desktop-Debug + /home/shaquille/Downloads/build-gebouw-Desktop-Debug + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + /home/shaquille/Downloads/build-gebouw-Desktop-Release + /home/shaquille/Downloads/build-gebouw-Desktop-Release + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + + /home/shaquille/Downloads/build-gebouw-Desktop-Profile + /home/shaquille/Downloads/build-gebouw-Desktop-Profile + + + true + QtProjectManager.QMakeBuildStep + + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + dwarf + + cpu-cycles + + + 250 + + -e + cpu-cycles + --call-graph + dwarf,4096 + -F + 250 + + -F + true + 4096 + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + kcachegrind + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:/home/shaquille/Downloads/gebouw/gebouw.pro + /home/shaquille/Downloads/gebouw/gebouw.pro + false + true + true + false + true + /home/shaquille/Downloads/build-gebouw-Desktop-Debug + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/gebouw.pro.user.381fadd b/gebouw.pro.user.381fadd new file mode 100644 index 0000000..c55633e --- /dev/null +++ b/gebouw.pro.user.381fadd @@ -0,0 +1,325 @@ + + + + + + EnvironmentId + {381fadd3-f7c1-4b5d-9456-fef8a11202f3} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + 1 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.8.0 GCC 64bit + Desktop Qt 5.8.0 GCC 64bit + qt.58.gcc_64_kit + 0 + 0 + 0 + + /home/oopr1/Documents/build-gebouw-Desktop_Qt_5_8_0_GCC_64bit-Debug + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + /home/oopr1/Documents/build-gebouw-Desktop_Qt_5_8_0_GCC_64bit-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + /home/oopr1/Documents/build-gebouw-Desktop_Qt_5_8_0_GCC_64bit-Profile + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy locally + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + gebouw + + Qt4ProjectManager.Qt4RunConfiguration:/home/oopr1/Documents/gebouw/gebouw.pro + true + + gebouw.pro + false + + /home/oopr1/Documents/build-gebouw-Desktop_Qt_5_8_0_GCC_64bit-Debug + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/gebouw.pro.user.4.8-pre1 b/gebouw.pro.user.4.8-pre1 new file mode 100644 index 0000000..b698317 --- /dev/null +++ b/gebouw.pro.user.4.8-pre1 @@ -0,0 +1,336 @@ + + + + + + EnvironmentId + {daf7231d-d0bf-4367-8947-ae949d9f2d27} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop + {56611235-07dd-4b90-81ed-415f033053fc} + 0 + 0 + 0 + + /home/shaquille/Downloads/build-gebouw-Desktop-Debug + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + /home/shaquille/Downloads/build-gebouw-Desktop-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + /home/shaquille/Downloads/build-gebouw-Desktop-Profile + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy locally + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + gebouw + + Qt4ProjectManager.Qt4RunConfiguration:/home/shaquille/Downloads/gebouw/gebouw.pro + true + + gebouw.pro + false + + + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/mainwindow.cpp b/mainwindow.cpp index 788e970..84b8d10 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -4,19 +4,29 @@ #include "sensor.h" #include "hallsensor.h" #include "schuifdeur.h" +#include "draaideur.h" +#include +#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); - s1=new Sensor(515,160); - vd = new Schuifdeur(503,250,80); + s1=new Hallsensor(515,160); + deuren.push_back(std::shared_ptr (new Schuifdeur(503,250,80,s1))); + deuren.push_back(std::shared_ptr (new draaideur(248,140,40,false))); + deuren.push_back(std::shared_ptr (new draaideur(295,290,30,true))); +// vd = (new Schuifdeur(503,250,80,s1)); +// d1 = (new draaideur(248,140,40,false)); +// d2 = (new draaideur(295,290,30,true)); +// deuren.push_back(vd); +// deuren.push_back(d1); +// deuren.push_back(d2); } MainWindow::~MainWindow(){ delete ui; delete s1; - delete vd; } void MainWindow::paintEvent(QPaintEvent *event){ @@ -31,7 +41,9 @@ void MainWindow::paintEvent(QPaintEvent *event){ painter.drawImage(10,10,image); s1->teken(this); - vd->teken(this); + deuren.at(0)->teken(this); + deuren.at(1)->teken(this); + deuren.at(2)->teken(this); } void MainWindow::on_schuifdeurSensorKnop_clicked(){ @@ -43,9 +55,32 @@ void MainWindow::on_schuifdeurSensorKnop_clicked(){ } void MainWindow::on_vd_clicked(){ - if(vd->isDeurOpen()) - vd->sluit(); - else - vd->open(); + if(deuren.at(0)->isDeurOpen()){ + deuren.at(0)->sluit(); + } + else{ + deuren.at(0)->open(); + s1->deactiveer(); + } update(); } + +void MainWindow::on_d1_clicked(){ + if(deuren.at(1)->isDeurOpen()){ + deuren.at(1)->sluit(); + } + else{ + deuren.at(1)->open(); + } + update(); +} + +void MainWindow::on_d2_clicked(){ + if(deuren.at(2)->isDeurOpen()){ + deuren.at(2)->sluit(); + } + else{ + deuren.at(2)->open(); + } + update(); +} diff --git a/mainwindow.h b/mainwindow.h index 3acbffb..2582b02 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -9,6 +9,8 @@ class MainWindow; class Hallsensor; class Sensor; class Schuifdeur; +class draaideur; +class Deur; class MainWindow : public QMainWindow { Q_OBJECT @@ -20,11 +22,18 @@ public: private slots: void on_schuifdeurSensorKnop_clicked(); void on_vd_clicked(); + void on_d1_clicked(); + void on_d2_clicked(); private: Ui::MainWindow *ui; - Sensor *s1; - Schuifdeur *vd; + Hallsensor *s1; + std::shared_ptr *vd; + std::shared_ptr *d1, *d2; +// std::vector> deuren; +// Schuifdeur *vd; +// draaideur *d1, *d2; + std::vector> deuren; }; #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index 7e18860..337a667 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -46,6 +46,38 @@ false + + + + 260 + 140 + 31 + 31 + + + + d1 + + + false + + + + + + 330 + 240 + 31 + 31 + + + + d1 + + + false + + diff --git a/schuifdeur.cpp b/schuifdeur.cpp index 08ff54b..08260b1 100644 --- a/schuifdeur.cpp +++ b/schuifdeur.cpp @@ -2,9 +2,9 @@ #include #include #include -#include "sensor.h" +#include "hallsensor.h" -Schuifdeur::Schuifdeur(int x, int y, int lengte): Deur(x,y,lengte){ +Schuifdeur::Schuifdeur(int x, int y, int lengte, Sensor *sensor): Deur(x,y,lengte), s(sensor){ } @@ -22,5 +22,8 @@ void Schuifdeur::teken(QPaintDevice *tp){ } void Schuifdeur::sluit(){ - s->activeer(); + if (!s->isGeactiveerd()){ + Deur::sluit(); + s->activeer(); + } } diff --git a/schuifdeur.h b/schuifdeur.h index d70c7d2..90490be 100644 --- a/schuifdeur.h +++ b/schuifdeur.h @@ -8,7 +8,7 @@ class Sensor; class Schuifdeur : public Deur{ public: - Schuifdeur(int, int, int); + Schuifdeur(int, int, int, Sensor*); void teken(QPaintDevice*) override; void sluit(); Sensor* s;