aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2017-11-26 23:36:26 +0100
committerNao Pross <naopross@thearcway.org>2017-11-26 23:36:26 +0100
commit7f7e6fe30ef4f9ba4507b89174676f57c42c0000 (patch)
treed6fc1ae62972568a1021c940f372903cda57cceb /src/ui
parentFirst commit (diff)
downloadOrbitingYeti-7f7e6fe30ef4f9ba4507b89174676f57c42c0000.tar.gz
OrbitingYeti-7f7e6fe30ef4f9ba4507b89174676f57c42c0000.zip
Implementation for Structogram iterator and Statement type
The interator is not (yet) aware of the scope in which it is iterating.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/AsciiRenderer.cpp23
-rw-r--r--src/ui/AsciiRenderer.hpp (renamed from src/ui/AsciiRenderer.h)12
-rw-r--r--src/ui/Window.cpp21
-rw-r--r--src/ui/Window.hpp27
4 files changed, 69 insertions, 14 deletions
diff --git a/src/ui/AsciiRenderer.cpp b/src/ui/AsciiRenderer.cpp
index 0f17d85..d06dadb 100644
--- a/src/ui/AsciiRenderer.cpp
+++ b/src/ui/AsciiRenderer.cpp
@@ -5,7 +5,7 @@
* Author: naopross
*/
-#include "AsciiRenderer.h"
+#include "AsciiRenderer.hpp"
#include <memory>
@@ -38,10 +38,9 @@ void AsciiRenderer::drawText(std::string text, unsigned int width, std::string b
unsigned int textWidth = width - before.length() - after.length();
-
std::cout << before;
- for (unsigned int i = 0; i < text.length(); i++) {
- if (i % textWidth == 0) {
+ for (std::size_t i = 0; i < text.length(); i++) {
+ if (i % textWidth == 0 && i != 0) {
std::cout << after << "\n" << before;
}
@@ -62,24 +61,24 @@ void AsciiRenderer::drawDecision(std::string condition, std::string trueText, st
}
void AsciiRenderer::render() {
- const std::list<Statement>& statements = m_structogram.getStatements();
- for (std::list<Statement>::const_iterator it = statements.begin(); it != statements.end(); it++) {
- Statement st = *it;
- switch (st.type) {
+ for (Structogram::iterator it = m_structogram.begin(); it != m_structogram.end(); ++it) {
+
+ switch (it->type) {
case Statement::Type::PROCESS:
drawLine();
- drawText(st.text);
+ drawText(it->text);
+ drawLine();
break;
case Statement::Type::DECISION:
- drawLine();
break;
case Statement::Type::SWITCH:
break;
case Statement::Type::SCOPE:
+ std::cout << "Title: " << it->text << std::endl;
break;
case Statement::Type::WHILE:
@@ -90,6 +89,10 @@ void AsciiRenderer::render() {
case Statement::Type::PARALLEL:
break;
+
+ case Statement::END:
+ // do nothing
+ break;
}
}
}
diff --git a/src/ui/AsciiRenderer.h b/src/ui/AsciiRenderer.hpp
index 4f9020a..76d6ff5 100644
--- a/src/ui/AsciiRenderer.h
+++ b/src/ui/AsciiRenderer.hpp
@@ -5,13 +5,17 @@
* Author: naopross
*/
-#ifndef SRC_UI_ASCIIRENDERER_H_
-#define SRC_UI_ASCIIRENDERER_H_
+#ifndef SRC_UI_ASCIIRENDERER_HPP_
+#define SRC_UI_ASCIIRENDERER_HPP_
-#include "../diagram/Structogram.h"
+#include "../diagram/Structogram.hpp"
namespace samb {
+/* Sample renderer for debug,
+ *
+ * TODO: implement PdfRenderer, UiRenderer with a common interface
+ */
class AsciiRenderer {
private:
Structogram m_structogram;
@@ -30,4 +34,4 @@ public:
} /* namespace samb */
-#endif /* SRC_UI_ASCIIRENDERER_H_ */
+#endif /* SRC_UI_ASCIIRENDERER_HPP_ */
diff --git a/src/ui/Window.cpp b/src/ui/Window.cpp
new file mode 100644
index 0000000..4572766
--- /dev/null
+++ b/src/ui/Window.cpp
@@ -0,0 +1,21 @@
+/*
+ * Window.cpp
+ *
+ * Created on: Nov 26, 2017
+ * Author: naopross
+ */
+
+#include "Window.hpp"
+
+namespace samb {
+
+Window::Window() {
+ // TODO Auto-generated constructor stub
+
+}
+
+Window::~Window() {
+ // TODO Auto-generated destructor stub
+}
+
+} /* namespace samb */
diff --git a/src/ui/Window.hpp b/src/ui/Window.hpp
new file mode 100644
index 0000000..5afad8c
--- /dev/null
+++ b/src/ui/Window.hpp
@@ -0,0 +1,27 @@
+/*
+ * Window.hpp
+ *
+ * Created on: Nov 26, 2017
+ * Author: naopross
+ */
+
+#ifndef SRC_UI_WINDOW_HPP_
+#define SRC_UI_WINDOW_HPP_
+
+#include <QWidget>
+
+namespace samb {
+
+class Window : public QWidget {
+Q_OBJECT
+public:
+ Window();
+ virtual ~Window();
+
+signals:
+public slots:
+};
+
+} /* namespace samb */
+
+#endif /* SRC_UI_WINDOW_HPP_ */