gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot/split-parser.h
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2010年08月19日 00:19:58 +0200
committerFrancesco Abbate <francesco.bbt@gmail.com>2010年08月19日 00:19:58 +0200
commitbef124c9c9e081062a457f6d0b2ab1eda6283a3e (patch)
tree5a757e1c2a84900feb642a9790dad5d61f870509 /agg-plot/split-parser.h
parent7cdb95a74e7f352620cd500940b73bf221f9e91a (diff)
downloadgsl-shell-bef124c9c9e081062a457f6d0b2ab1eda6283a3e.tar.gz
improved window slot identification vs plot
The code to generate a tree, to parse a split spec and to store window plot tree information is now factored. Now each plot area get a slot_id and redraw is made only in the region when required.
Diffstat (limited to 'agg-plot/split-parser.h')
-rw-r--r--agg-plot/split-parser.h 97
1 files changed, 97 insertions, 0 deletions
diff --git a/agg-plot/split-parser.h b/agg-plot/split-parser.h
new file mode 100644
index 00000000..7c13988b
--- /dev/null
+++ b/agg-plot/split-parser.h
@@ -0,0 +1,97 @@
+#ifndef AGGPLOT_SPLIT_PARSER_H
+#define AGGPLOT_SPLIT_PARSER_H
+
+#include "my_tree.h"
+
+enum direction_e { along_x, along_y };
+
+template <class base_type>
+class split {
+
+ typedef tree::node<base_type, direction_e> node_type;
+
+public:
+ // ----------------------------------------------------string_lexer
+ class lexer {
+ const char *m_content;
+ const char *m_ptr;
+
+ public:
+ lexer(const char *str) : m_content(str), m_ptr(m_content) {};
+
+ char next()
+ {
+ char c = *m_ptr;
+ if (c != '0円')
+ m_ptr++;
+ return c;
+ };
+
+ void push()
+ {
+ if (m_ptr > m_content)
+ m_ptr--;
+ };
+
+ bool checknext(char reqchar)
+ {
+ char c = *m_ptr;
+ if (c == reqchar)
+ {
+ m_ptr++;
+ return true;
+ }
+ return false;
+ };
+ };
+
+ // ------------------------------------------------parser: exprlist
+ static node_type* exprlist (lexer& lex, direction_e dir)
+ {
+ typedef tree::tree_node<base_type, direction_e> tree_type;
+
+ tree_type *t = new tree_type(dir);
+
+ for (int c = 0; ; c++)
+ {
+ node_type* child = parse(lex);
+ if (! child)
+ break;
+ t->add(child);
+ }
+
+ return t;
+ }
+
+// ------------------------------------------------parser: parse
+ static node_type* parse (lexer& lex)
+ {
+ char t = lex.next();
+
+ switch (t)
+ {
+ case '.':
+ return new tree::leaf<base_type, direction_e>();
+ case 'h':
+ return exprlist(lex, along_x);
+ case 'v':
+ return exprlist(lex, along_y);
+ case '(':
+ {
+ node_type *nd = parse(lex);
+ if (! lex.checknext(')'))
+ return 0;
+ return nd;
+ }
+ case ')':
+ lex.push();
+ return 0;
+ default:
+ return 0;
+ }
+
+ return 0;
+ }
+};
+
+#endif
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月14日 19:49:51 +0000

AltStyle によって変換されたページ (->オリジナル) /