Qt-Gebouw/mainwindow.cpp

87 lines
1.9 KiB
C++
Raw Normal View History

2022-02-10 16:44:22 +00:00
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPainter>
#include "sensor.h"
#include "hallsensor.h"
#include "schuifdeur.h"
2022-02-17 23:51:34 +00:00
#include "draaideur.h"
#include <stdio.h>
#include <iostream>
2022-02-10 16:44:22 +00:00
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow){
ui->setupUi(this);
2022-02-17 23:51:34 +00:00
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);
2022-02-10 16:44:22 +00:00
}
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);
2022-02-17 23:51:34 +00:00
deuren.at(0)->teken(this);
deuren.at(1)->teken(this);
deuren.at(2)->teken(this);
2022-02-10 16:44:22 +00:00
}
void MainWindow::on_schuifdeurSensorKnop_clicked(){
if(s1->isGeactiveerd())
s1->deactiveer();
else
s1->activeer();
update();
}
void MainWindow::on_vd_clicked(){
2022-02-17 23:51:34 +00:00
if(deuren.at(0)->isDeurOpen()){
deuren.at(0)->sluit();
}
else{
deuren.at(0)->open();
s1->deactiveer();
}
2022-02-10 16:44:22 +00:00
update();
}
2022-02-17 23:51:34 +00:00
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();
}