aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/debugtools.h4
-rw-r--r--include/diagram/branch.h (renamed from include/diagram/branchstatement.h)6
-rw-r--r--include/diagram/iterator.h (renamed from include/diagram/iteratorstatement.h)4
-rw-r--r--include/diagram/scope.h11
-rw-r--r--include/diagram/statement.h6
-rw-r--r--include/io/serializer.h4
-rw-r--r--include/ui/painter.h26
-rw-r--r--include/ui/statementdialog.h22
8 files changed, 65 insertions, 18 deletions
diff --git a/include/debugtools.h b/include/debugtools.h
index cd6940b..1b34a2e 100644
--- a/include/debugtools.h
+++ b/include/debugtools.h
@@ -3,8 +3,8 @@
#ifdef QT_NO_DEBUG
-void debug_msg(...) {}
-void debug_err(...) {}
+#define debug_msg(msg)
+#define debug_err(msg)
#else
#include <iostream>
diff --git a/include/diagram/branchstatement.h b/include/diagram/branch.h
index 3d8c385..2024d78 100644
--- a/include/diagram/branchstatement.h
+++ b/include/diagram/branch.h
@@ -10,14 +10,14 @@ namespace samb {
/* Implementation for Statement::DECISION, Statement::SWITCH
*/
-class BranchStatement : public Statement
+class Branch : public Statement
{
public:
- BranchStatement(Type t, const QString &condition, pointer next);
+ Branch(Type t, const QString &condition, pointer next);
/* accessors */
std::map<QString, pointer>& branches() { return _branches; }
- std::size_t branches_count() const { return _branchesCount; }
+ std::size_t branchesCount() const { return _branchesCount; }
inline const QString& condition() const { return text(); }
inline void condition(const QString &condition) { return text(condition); }
diff --git a/include/diagram/iteratorstatement.h b/include/diagram/iterator.h
index e7fbba0..71c6a34 100644
--- a/include/diagram/iteratorstatement.h
+++ b/include/diagram/iterator.h
@@ -10,10 +10,10 @@ namespace samb {
/* Implementation for Statement::WHILE Statement::UNTIL
*/
-class IteratorStatement : public Statement
+class Iterator : public Statement
{
public:
- IteratorStatement(Type t, const QString &condition, pointer next);
+ Iterator(Type t, const QString &condition, pointer next);
/* accessors */
Scope& inner() { return _inner; }
diff --git a/include/diagram/scope.h b/include/diagram/scope.h
index 63698dd..8ae7e79 100644
--- a/include/diagram/scope.h
+++ b/include/diagram/scope.h
@@ -22,6 +22,9 @@ public:
explicit iterator(pointer statement);
~iterator();
+ bool operator==(const iterator &other) const;
+ bool operator!=(const iterator &other) const;
+
iterator& operator++();
iterator& operator++(int);
@@ -32,7 +35,7 @@ public:
Statement::pointer _current;
};
- explicit Scope(const QString &label);
+ Scope(const QString &label);
Scope(const QString &label, Statement::pointer first);
virtual ~Scope();
@@ -43,8 +46,10 @@ public:
std::size_t size() const { return _size; }
/* iterator */
- iterator begin() { return iterator(_head); }
- iterator end() { return iterator(_tail); }
+ iterator begin();
+ const iterator begin() const;
+ iterator end();
+ const iterator end() const;
private:
Statement::pointer _head;
diff --git a/include/diagram/statement.h b/include/diagram/statement.h
index 5cce908..1d44d6a 100644
--- a/include/diagram/statement.h
+++ b/include/diagram/statement.h
@@ -26,7 +26,8 @@ namespace samb {
class Statement
{
public:
- using pointer = std::shared_ptr<Statement>;
+// using pointer = std::shared_ptr<Statement>;
+ using pointer = Statement*;
enum Type {
PROCESS,
@@ -40,6 +41,9 @@ public:
const Type type;
+ template<class... Args>
+ static pointer make(Type t, Args&& ...args);
+
Statement(Type t, const QString &text);
Statement(Type t, const QString &text, pointer next);
virtual ~Statement();
diff --git a/include/io/serializer.h b/include/io/serializer.h
index 901d913..e6a9b32 100644
--- a/include/io/serializer.h
+++ b/include/io/serializer.h
@@ -11,8 +11,8 @@ public:
explicit Serializer();
virtual ~Serializer();
- bool write(const samb::Structogram &structogram, QFileInfo into);
- bool load(samb::Structogram &structogram, QFileInfo from);
+ bool write(const samb::Structogram &structogram, const QFileInfo &into);
+ bool load(samb::Structogram &structogram, const QFileInfo &from);
};
#endif // SERIALIZER_H
diff --git a/include/ui/painter.h b/include/ui/painter.h
index df62776..0a2accc 100644
--- a/include/ui/painter.h
+++ b/include/ui/painter.h
@@ -1,11 +1,15 @@
#ifndef PAINTER_H
#define PAINTER_H
-#include <QWidget>
+#include "diagram/statement.h"
+#include "diagram/structogram.h"
-namespace Ui {
-class Painter;
-}
+#include <QWidget>
+#include <QFont>
+#include <QFontMetrics>
+#include <QPaintEvent>
+#include <QPainter>
+#include <QRect>
class Painter : public QWidget
{
@@ -15,8 +19,20 @@ public:
explicit Painter(QWidget *parent = 0);
~Painter();
+ void structogram(samb::Structogram **structogram) { _structogram = structogram; }
+ const samb::Structogram structogram() const { return **_structogram; }
+
+protected:
+ void paintEvent(QPaintEvent *event);
+
private:
- Ui::Painter *_ui;
+ samb::Structogram **_structogram = nullptr;
+ QFont _font;
+ QFontMetrics _fontMetrics;
+
+ int _margin = 10;
+
+ void drawStatement(QPainter &qp, samb::Statement &statement, const QRect &rect);
};
#endif // PAINTER_H
diff --git a/include/ui/statementdialog.h b/include/ui/statementdialog.h
new file mode 100644
index 0000000..658ea53
--- /dev/null
+++ b/include/ui/statementdialog.h
@@ -0,0 +1,22 @@
+#ifndef STATEMENTDIALOG_H
+#define STATEMENTDIALOG_H
+
+#include <QDialog>
+
+namespace Ui {
+class StatementDialog;
+}
+
+class StatementDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit StatementDialog(QWidget *parent = 0);
+ ~StatementDialog();
+
+private:
+ Ui::StatementDialog *ui;
+};
+
+#endif // STATEMENTDIALOG_H