Basic skeleton of the C++ class model done with a functional test. GSL shell build currently broken. - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot/plot.cpp
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2009年12月13日 17:41:07 +0000
committerFrancesco Abbate <francesco.bbt@gmail.com>2009年12月13日 17:41:07 +0000
commitd00328bd46965223c83f3880204943d8e5844034 (patch)
tree86436dedafa24ce7e628df7467ca063237fd7cc5 /agg-plot/plot.cpp
parent220963841157dd309b3e26c879ad3bb9ba626580 (diff)
downloadgsl-shell-d00328bd46965223c83f3880204943d8e5844034.tar.gz
Basic skeleton of the C++ class model done with a functional test. GSL shell build currently broken.
Diffstat (limited to 'agg-plot/plot.cpp')
-rw-r--r--agg-plot/plot.cpp 84
1 files changed, 84 insertions, 0 deletions
diff --git a/agg-plot/plot.cpp b/agg-plot/plot.cpp
new file mode 100644
index 00000000..6c908c8c
--- /dev/null
+++ b/agg-plot/plot.cpp
@@ -0,0 +1,84 @@
+
+#include "utils.h"
+#include "plot.h"
+
+#include "agg_conv_stroke.h"
+#include "agg_conv_dash.h"
+#include "agg_conv_contour.h"
+#include "agg_vcgen_markers_term.h"
+#include "agg_bounding_rect.h"
+
+void
+plot::bounding_box(double *px1, double *py1, double *px2, double *py2)
+{
+ bool is_set = false;
+ double& m_x1 = *px1;
+ double& m_y1 = *py1;
+ double& m_x2 = *px2;
+ double& m_y2 = *py2;
+
+ for (unsigned j = 0; j < m_elements.size(); j++)
+ {
+ drawable& d = m_elements[j];
+
+ double x1, y1, x2, y2;
+ d.vs->bounding_box(&x1, &y1, &x2, &y2);
+
+ if (! is_set)
+ {
+ m_x1 = x1;
+ m_x2 = x2;
+ m_y1 = y1;
+ m_y2 = y2;
+
+ is_set = true;
+ }
+ else if (x2 > m_x2 || x1 < m_x1 || y2 > m_y2 || y1 < m_y1)
+ {
+ m_x1 = min(x1, m_x1);
+ m_y1 = min(y1, m_y1);
+ m_x2 = max(x2, m_x2);
+ m_y2 = max(y2, m_y2);
+ }
+ }
+}
+
+void
+plot::trans_matrix_update()
+{
+ if (! m_bbox_updated)
+ {
+ double x1, y1, x2, y2;
+ bounding_box(&x1, &y1, &x2, &y2);
+
+ double fx = x2 - x1, fy = y2 - y1;
+ m_trans.reset();
+ m_trans.scale(1/fx, 1/fy);
+ m_trans.translate(-x1/fx, -y1/fy);
+ m_bbox_updated = true;
+ }
+}
+
+void
+plot::draw_elements(canvas &canvas)
+{
+ agg::trans_affine m = m_trans;
+ viewport_scale(m);
+ canvas.scale(m);
+
+ for (unsigned j = 0; j < m_elements.size(); j++)
+ {
+ drawable& d = m_elements[j];
+ vertex_source& vs = d.get_vertex_source();
+ vs.apply_transform(m, 1.0);
+ canvas.draw(vs, d.color);
+ }
+}
+
+void
+plot::viewport_scale(agg::trans_affine& m)
+{
+ const double xoffs = 0.09375, yoffs = 0.09375;
+ static agg::trans_affine rsz(1-2*xoffs, 0.0, 0.0, 1-2*yoffs, xoffs, yoffs);
+ trans_affine_compose (m, rsz);
+}
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月21日 22:51:45 +0000

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