Create a directory with C++ generic functions - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2012年03月26日 23:07:49 +0200
committerFrancesco Abbate <francesco.bbt@gmail.com>2012年03月26日 23:07:49 +0200
commit7c09c1f9527ea7ab8accef1c9d68d9a251c2bb8d (patch)
tree1f02e61df5a6eae90fa09b2ed3823db154e8cd25 /agg-plot
parent822de113f7d3b9f7bbd0a80159808e0fa3dcdc51 (diff)
downloadgsl-shell-7c09c1f9527ea7ab8accef1c9d68d9a251c2bb8d.tar.gz
Create a directory with C++ generic functions
Diffstat (limited to 'agg-plot')
-rw-r--r--agg-plot/Makefile 2
-rw-r--r--agg-plot/canvas_svg.cpp 2
-rw-r--r--agg-plot/draw_svg.h 4
-rw-r--r--agg-plot/my_list.h 75
-rw-r--r--agg-plot/my_tree.h 91
-rw-r--r--agg-plot/plot-auto.h 6
-rw-r--r--agg-plot/plot.h 16
-rw-r--r--agg-plot/sg_object.h 2
-rw-r--r--agg-plot/split-parser.h 2
-rw-r--r--agg-plot/trans.h 4
-rw-r--r--agg-plot/window-cpp.h 2
-rw-r--r--agg-plot/window.cpp 12
12 files changed, 26 insertions, 192 deletions
diff --git a/agg-plot/Makefile b/agg-plot/Makefile
index 8e40ee19..b9503fba 100644
--- a/agg-plot/Makefile
+++ b/agg-plot/Makefile
@@ -34,7 +34,7 @@ else
PLATSUP_SRC_FILES = agg_platform_support_x11.cpp
endif
-INCLUDES += $(AGG_INCLUDES) -I$(GSH_BASE_DIR) -I$(LUADIR)/src
+INCLUDES += $(AGG_INCLUDES) -I$(GSH_BASE_DIR) -I$(LUADIR)/src -I$(GSH_BASE_DIR)/cpp-utils
AGGPLOT_SRC_FILES = $(PLATSUP_SRC_FILES) utils.cpp units.cpp colors.cpp markers.cpp draw_svg.cpp canvas_svg.cpp lua-draw.cpp lua-text.cpp text.cpp agg-parse-trans.cpp window_registry.cpp window.cpp lua-plot.cpp canvas-window.cpp bitmap-plot.cpp
diff --git a/agg-plot/canvas_svg.cpp b/agg-plot/canvas_svg.cpp
index fc5a859e..e5ef6d88 100644
--- a/agg-plot/canvas_svg.cpp
+++ b/agg-plot/canvas_svg.cpp
@@ -17,6 +17,6 @@ void canvas_svg::draw_outline<sg_object>(sg_object& vs, agg::rgba8 c)
str path;
svg_property_list* ls = vs.svg_path(path, m_height);
str s = svg_stroke_path(path, canvas_svg::default_stroke_width, id, c, ls);
- list::free(ls);
+ svg_property_list::free(ls);
canvas_svg::writeln(m_output, s, " ");
}
diff --git a/agg-plot/draw_svg.h b/agg-plot/draw_svg.h
index ba61f86e..a997c5b7 100644
--- a/agg-plot/draw_svg.h
+++ b/agg-plot/draw_svg.h
@@ -3,7 +3,7 @@
#include "agg_basics.h"
#include "agg_color_rgba.h"
-#include "my_list.h"
+#include "list.h"
#include "strpp.h"
enum svg_path_property_e {
@@ -33,7 +33,7 @@ vertex_flip(VertexSource* vs, double* x, double* y, double h)
return cmd;
}
-typedef pod_list<svg_property_item> svg_property_list;
+typedef list<svg_property_item> svg_property_list;
template <typename VertexSource>
void svg_coords_from_vs(VertexSource* vs, str& s, double h)
diff --git a/agg-plot/my_list.h b/agg-plot/my_list.h
deleted file mode 100644
index 34e7cf0d..00000000
--- a/agg-plot/my_list.h
+++ /dev/null
@@ -1,75 +0,0 @@
-#ifndef AGGPLOT_LIST_H
-#define AGGPLOT_LIST_H
-
-template <class T>
-class pod_list {
- T m_content;
- pod_list *m_next;
-
-public:
- pod_list(const T& c, pod_list* next = 0) : m_content(c), m_next(next) { };
-
- T& content() { return m_content; };
- const T& content() const { return m_content; };
-
- static pod_list* push_back(pod_list* head, pod_list* n)
- {
- pod_list* k = head;
-
- if (! k)
- return n;
-
- while (k->m_next)
- k = k->m_next;
- k->m_next = n;
-
- return head;
- }
-
- pod_list* next() { return m_next; };
-};
-
-namespace list {
-
- template <class T>
- int length(pod_list<T> *ls)
- {
- int n = 0;
- for ( ; ls; ls = ls->next())
- n++;
- return n;
- }
-
- template <class T>
- void free(pod_list<T> *p)
- {
- pod_list<T> *n;
- for (/* */; p; p = n)
- {
- n = p->next();
- delete p;
- }
- }
-
- template <class T>
- pod_list<T> * pop(pod_list<T> *p)
- {
- pod_list<T> *tail = p->next();
- delete p;
- return tail;
- }
-
- template <class T, class f>
- void apply(pod_list<T> *p)
- {
- pod_list<T> *n;
- for ( ; p; p = n)
- {
- n = p->m_next;
- T& val = p->content();
- f::func(val);
- }
- }
-}
-
-#endif
diff --git a/agg-plot/my_tree.h b/agg-plot/my_tree.h
deleted file mode 100644
index de238cbb..00000000
--- a/agg-plot/my_tree.h
+++ /dev/null
@@ -1,91 +0,0 @@
-#ifndef AGGPLOT_MY_TREE_H
-#define AGGPLOT_MY_TREE_H
-
-#include "my_list.h"
-
-namespace tree {
-
- template <class base_type, class tree_data_type>
- struct node {
- typedef pod_list<node*> list;
-
- virtual list* tree() { return 0; };
- virtual list* tree(tree_data_type& data) { return 0; };
-
- virtual base_type* content() = 0;
- virtual void content(const base_type& src) = 0;
-
- virtual ~node() {};
- };
-
- template <class base_type, class tree_data_type>
- class leaf : public node<base_type, tree_data_type> {
- base_type m_content;
-
- public:
- leaf() : m_content() {};
-
- virtual base_type* content() { return &m_content; };
- virtual void content(const base_type& src) { m_content = src; };
- };
-
- template <class base_type, class tree_data_type>
- class tree_node : public node<base_type, tree_data_type> {
-
- typedef node<base_type, tree_data_type> node_type;
- typedef typename node<base_type, tree_data_type>::list node_list;
-
- node_list *m_head;
- tree_data_type m_data;
-
- public:
- tree_node() : m_head(0), m_data() {};
-
- template <class init_type>
- tree_node(const init_type& init_val) : m_head(0), m_data(init_val) {};
-
- ~tree_node()
- {
- node_list *n;
- for (node_list *p = m_head; p; p = n)
- {
- n = p->next();
- delete p->content();
- delete p;
- }
- };
-
- virtual node_list* tree() { return m_head; };
- virtual node_list* tree(tree_data_type& data)
- {
- data = m_data;
- return m_head;
- };
-
- virtual base_type* content() { return 0; };
- virtual void content(const base_type& src) { };
-
- void add(node_type* child)
- {
- node_list *t = new node_list(child);
- m_head = node_list::push_back(m_head, t);
- }
- };
-
- template <class base_type, class tree_data_type, class f>
- void walk_rec(node<base_type, tree_data_type> *t)
- {
- base_type *c = t->content();
- if (c)
- f::func(*c);
-
- typename node<base_type, tree_data_type>::list *ls = t->tree();
- if (ls)
- {
- for ( ; ls; ls = ls->next())
- walk_rec<base_type, tree_data_type, f> (ls->content());
- }
- }
-}
-
-#endif
diff --git a/agg-plot/plot-auto.h b/agg-plot/plot-auto.h
index 17b83c1c..d8349303 100644
--- a/agg-plot/plot-auto.h
+++ b/agg-plot/plot-auto.h
@@ -71,8 +71,8 @@ void plot_auto<VS,RM>::add(VS* vs, agg::rgba8& color, bool outline)
this->m_need_redraw = true;
}
- pod_list<item> *nn = new pod_list<item>(d);
- this->m_drawing_queue = pod_list<item>::push_back(this->m_drawing_queue, nn);
+ list<item> *nn = new list<item>(d);
+ this->m_drawing_queue = list<item>::push_back(this->m_drawing_queue, nn);
RM::acquire(vs);
}
@@ -121,7 +121,7 @@ void plot_auto<VS,RM>::calc_bounding_box()
calc_layer_bounding_box(*(this->m_layers[j]), box);
}
- for (pod_list<item> *t = this->m_drawing_queue; t; t = t->next())
+ for (list<item> *t = this->m_drawing_queue; t; t = t->next())
{
const item& d = t->content();
agg::rect_base<double> r;
diff --git a/agg-plot/plot.h b/agg-plot/plot.h
index 539b29c0..1bda3c8c 100644
--- a/agg-plot/plot.h
+++ b/agg-plot/plot.h
@@ -24,7 +24,7 @@
#include <new>
#include "utils.h"
-#include "my_list.h"
+#include "list.h"
#include "strpp.h"
#include "canvas.h"
#include "units.h"
@@ -92,7 +92,7 @@ class plot {
};
public:
- typedef pod_list<item> iterator;
+ typedef list<item> iterator;
typedef virtual_canvas<VertexSource> canvas_type;
enum axis_e { x_axis, y_axis };
@@ -276,7 +276,7 @@ protected:
item_list *m_current_layer;
agg::trans_affine m_trans;
- pod_list<item> *m_drawing_queue;
+ list<item> *m_drawing_queue;
bool m_clip_flag;
@@ -326,21 +326,21 @@ template <class VS, class RM>
void plot<VS,RM>::add(VS* vs, agg::rgba8& color, bool outline)
{
item d(vs, color, outline);
- pod_list<item> *new_node = new pod_list<item>(d);
- m_drawing_queue = pod_list<item>::push_back(m_drawing_queue, new_node);
+ list<item> *new_node = new list<item>(d);
+ m_drawing_queue = list<item>::push_back(m_drawing_queue, new_node);
RM::acquire(vs);
}
template <class VS, class RM>
void plot<VS,RM>::push_drawing_queue()
{
- for (pod_list<item> *c = m_drawing_queue; c != 0; c = c->next())
+ for (list<item> *c = m_drawing_queue; c != 0; c = c->next())
{
m_current_layer->add(c->content());
}
while (m_drawing_queue)
- m_drawing_queue = list::pop(m_drawing_queue);
+ m_drawing_queue = list<item>::pop(m_drawing_queue);
}
template <class VS, class RM>
@@ -350,7 +350,7 @@ void plot<VS,RM>::clear_drawing_queue()
{
item& d = m_drawing_queue->content();
RM::dispose(d.vs);
- m_drawing_queue = list::pop(m_drawing_queue);
+ m_drawing_queue = list<item>::pop(m_drawing_queue);
}
}
diff --git a/agg-plot/sg_object.h b/agg-plot/sg_object.h
index 00dabda1..26b06af2 100644
--- a/agg-plot/sg_object.h
+++ b/agg-plot/sg_object.h
@@ -47,7 +47,7 @@ struct sg_object : public vertex_source {
str path;
svg_property_list* ls = this->svg_path(path, h);
str s = svg_fill_path(path, id, c, ls);
- list::free(ls);
+ svg_property_list::free(ls);
return s;
}
diff --git a/agg-plot/split-parser.h b/agg-plot/split-parser.h
index dcf7dc20..07aa71cc 100644
--- a/agg-plot/split-parser.h
+++ b/agg-plot/split-parser.h
@@ -1,7 +1,7 @@
#ifndef AGGPLOT_SPLIT_PARSER_H
#define AGGPLOT_SPLIT_PARSER_H
-#include "my_tree.h"
+#include "tree.h"
enum direction_e { along_x, along_y };
diff --git a/agg-plot/trans.h b/agg-plot/trans.h
index c3aa60c2..e0aa9ecb 100644
--- a/agg-plot/trans.h
+++ b/agg-plot/trans.h
@@ -39,7 +39,7 @@ struct trans {
str path;
svg_property_list* ls = this->m_source->svg_path(path, h);
str s = svg_stroke_path(path, m_width, id, c, ls);
- list::free(ls);
+ svg_property_list::free(ls);
return s;
}
@@ -179,7 +179,7 @@ struct trans {
ls = new svg_property_list(item3, ls);
str svg = svg_marker_path(path, m_size, id, ls);
- list::free(ls);
+ svg_property_list::free(ls);
return str::print("%s\n %s", marker_def.cstr(), svg.cstr());
}
diff --git a/agg-plot/window-cpp.h b/agg-plot/window-cpp.h
index f2b88f5f..02f72987 100644
--- a/agg-plot/window-cpp.h
+++ b/agg-plot/window-cpp.h
@@ -10,7 +10,7 @@ extern "C" {
#include "lua-cpp-utils.h"
#include "plot.h"
#include "rect.h"
-#include "my_list.h"
+#include "list.h"
#include "agg_color_rgba.h"
#include "agg_trans_affine.h"
diff --git a/agg-plot/window.cpp b/agg-plot/window.cpp
index 6880c79a..4a412b7b 100644
--- a/agg-plot/window.cpp
+++ b/agg-plot/window.cpp
@@ -64,14 +64,14 @@ int window::ref::calculate(window::ref::node* t, const bmatrix& m, int id)
r->matrix = m;
}
- int nb = list::length(t->tree());
+ int nb = list<ref::node*>::length(t->tree());
if (nb > 0)
{
double frac = 1 / (double) nb;
direction_e dir;
- ref::node::list *ls = t->tree(dir);
+ list<ref::node*> *ls = t->tree(dir);
if (ls)
{
bmatrix lm;
@@ -117,7 +117,7 @@ window::ref::save_image (agg::rendering_buffer& win_buf,
void
window::draw_rec(ref::node *n)
{
- ref::node::list *ls;
+ list<ref::node*> *ls;
for (ls = n->tree(); ls != NULL; ls = ls->next())
draw_rec(ls->content());
@@ -130,7 +130,7 @@ window::draw_rec(ref::node *n)
window::ref* window::ref_lookup (ref::node *p, int slot_id)
{
- ref::node::list *t = p->tree();
+ list<ref::node*> *t = p->tree();
for (/* */; t; t = t->next())
{
ref *ref = window::ref_lookup(t->content(), slot_id);
@@ -274,7 +274,7 @@ window::on_resize(int sx, int sy)
void
window::cleanup_tree_rec (lua_State *L, int window_index, ref::node* n)
{
- for (ref::node::list *ls = n->tree(); ls != NULL; ls = ls->next())
+ for (list<ref::node*> *ls = n->tree(); ls != NULL; ls = ls->next())
cleanup_tree_rec(L, window_index, ls->content());
ref *ref = n->content();
@@ -335,7 +335,7 @@ int window::attach(sg_plot* plot, const char *spec)
for (ptr = next_int (spec, k); ptr; ptr = next_int (ptr, k))
{
- ref::node::list* list = n->tree();
+ list<ref::node*>* list = n->tree();
if (! list)
return -1;
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月17日 20:23:22 +0000

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