87 lines
1.9 KiB
C++
87 lines
1.9 KiB
C++
#include "mainwindow.h"
|
|
#include "ui_mainwindow.h"
|
|
#include <QPainter>
|
|
#include "sensor.h"
|
|
#include "hallsensor.h"
|
|
#include "schuifdeur.h"
|
|
#include "draaideur.h"
|
|
#include <stdio.h>
|
|
#include <iostream>
|
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
|
QMainWindow(parent),
|
|
ui(new Ui::MainWindow){
|
|
ui->setupUi(this);
|
|
s1=new Hallsensor(515,160);
|
|
deuren.push_back(std::shared_ptr<Schuifdeur> (new Schuifdeur(503,250,80,s1)));
|
|
deuren.push_back(std::shared_ptr<draaideur> (new draaideur(248,140,40,false)));
|
|
deuren.push_back(std::shared_ptr<draaideur> (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;
|
|
}
|
|
|
|
void MainWindow::paintEvent(QPaintEvent *event){
|
|
|
|
QPainter painter(this);
|
|
QPen pen;
|
|
QImage image("/home/shaquille/Downloads/gebouw/Gebouw.png");
|
|
|
|
pen.setColor(Qt::green);
|
|
pen.setWidth(4);
|
|
painter.setPen(pen);
|
|
painter.drawImage(10,10,image);
|
|
|
|
s1->teken(this);
|
|
deuren.at(0)->teken(this);
|
|
deuren.at(1)->teken(this);
|
|
deuren.at(2)->teken(this);
|
|
}
|
|
|
|
void MainWindow::on_schuifdeurSensorKnop_clicked(){
|
|
if(s1->isGeactiveerd())
|
|
s1->deactiveer();
|
|
else
|
|
s1->activeer();
|
|
update();
|
|
}
|
|
|
|
void MainWindow::on_vd_clicked(){
|
|
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();
|
|
}
|