Skip to content

Commit

Permalink
GUI: Add House event to diagram
Browse files Browse the repository at this point in the history
Issue #132
  • Loading branch information
rakhimov committed Jun 7, 2017
1 parent 6b513ef commit 04ba7d6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
15 changes: 14 additions & 1 deletion gui/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <QFontMetrics>
#include <QGraphicsLineItem>
#include <QGraphicsPathItem>
#include <QGraphicsPolygonItem>
#include <QPainter>
#include <QPainterPath>
#include <QRectF>
Expand Down Expand Up @@ -103,6 +104,15 @@ BasicEvent::BasicEvent(const mef::BasicEvent &event, QGraphicsItem *parent)
Event::setTypeGraphics(new QGraphicsEllipseItem(-d / 2, 0, d, d));
}

HouseEvent::HouseEvent(const mef::HouseEvent &event, QGraphicsItem *parent)
: Event(event, parent)
{
double h = int(m_size.height() - m_baseHeight) * units().height();
double y0 = h * 0.25;
Event::setTypeGraphics(new QGraphicsPolygonItem(
{{{0, 0}, {-h / 2, y0}, {-h / 2, h}, {h / 2, h}, {h / 2, y0}}}));
}

const QSize Gate::m_maxSize = {6, 3};
const double Gate::m_space = 1;

Expand All @@ -120,7 +130,10 @@ Gate::Gate(const mef::Gate &event, QGraphicsItem *parent) : Event(event, parent)
{
return new BasicEvent(*arg, m_parent);
}
Event *operator()(const mef::HouseEvent *) { return nullptr; }
Event *operator()(const mef::HouseEvent *arg)
{
return new HouseEvent(*arg, m_parent);
}
Event *operator()(const mef::Gate *arg)
{
return new Gate(*arg, m_parent);
Expand Down
10 changes: 10 additions & 0 deletions gui/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ class BasicEvent : public Event
QGraphicsItem *parent = nullptr);
};

/**
* @brief Representation of a fault tree house events.
*/
class HouseEvent : public Event
{
public:
explicit HouseEvent(const mef::HouseEvent &event,
QGraphicsItem *parent = nullptr);
};

/**
* @brief Fault tree intermediate events or gates.
*/
Expand Down

0 comments on commit 04ba7d6

Please sign in to comment.