fixed problem with plot_auto region update - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2010年09月20日 01:23:45 +0200
committerFrancesco Abbate <francesco.bbt@gmail.com>2010年09月20日 01:23:45 +0200
commit0733e9943a6041324938ec9d112387c715cca7ac (patch)
tree99db12a4c7801d4b525e04a48bccaaeaa148c2fd
parenta648800282d2bd763fbf6a182a1673b1f7ac4596 (diff)
downloadgsl-shell-0733e9943a6041324938ec9d112387c715cca7ac.tar.gz
fixed problem with plot_auto region update
Diffstat
-rw-r--r--agg-plot/plot-auto.h 55
-rw-r--r--agg-plot/plot.h 17
-rw-r--r--agg-plot/rect.h 12
-rw-r--r--agg-plot/window.cpp 1
4 files changed, 54 insertions, 31 deletions
diff --git a/agg-plot/plot-auto.h b/agg-plot/plot-auto.h
index b493072d..c8080e4c 100644
--- a/agg-plot/plot-auto.h
+++ b/agg-plot/plot-auto.h
@@ -35,13 +35,15 @@ class plot_auto : public plot<VertexSource, resource_manager> {
public:
plot_auto() :
plot<VertexSource, resource_manager>(true),
- m_bbox_updated(true), m_is_empty(true)
+ m_bbox_updated(true)
{ };
virtual ~plot_auto() { };
virtual void add(VertexSource* vs, agg::rgba8& color, bool outline);
- virtual void on_draw() { check_bounding_box(); };
+ virtual void before_draw() { check_bounding_box(); };
+
+ virtual bool pop_layer();
private:
void calc_layer_bounding_box(item_list& layer, opt_rect<double>& rect);
@@ -52,7 +54,6 @@ private:
// bounding box
bool m_bbox_updated;
- bool m_is_empty;
};
template <class VS, class RM>
@@ -64,15 +65,10 @@ void plot_auto<VS,RM>::add(VS* vs, agg::rgba8& color, bool outline)
{
this->m_bbox_updated = false;
this->m_need_redraw = true;
- this->current_layer().add(d);
- }
- else
- {
- pod_list<item> *nn = new pod_list<item>(d);
- this->m_drawing_queue = pod_list<item>::push_back(this->m_drawing_queue, nn);
}
- this->m_is_empty = false;
+ pod_list<item> *nn = new pod_list<item>(d);
+ this->m_drawing_queue = pod_list<item>::push_back(this->m_drawing_queue, nn);
RM::acquire(vs);
}
@@ -80,17 +76,20 @@ void plot_auto<VS,RM>::add(VS* vs, agg::rgba8& color, bool outline)
template<class VS, class RM>
void plot_auto<VS,RM>::check_bounding_box()
{
- if (this->m_bbox_updated || this->m_is_empty)
+ if (this->m_bbox_updated)
return;
this->calc_bounding_box();
- const agg::rect_base<double>& bb = this->m_rect;
- this->m_ux = units(bb.x1, bb.x2);
- this->m_uy = units(bb.y1, bb.y2);
+ if (this->m_rect.is_defined())
+ {
+ const agg::rect_base<double>& bb = this->m_rect.rect();
+ this->m_ux = units(bb.x1, bb.x2);
+ this->m_uy = units(bb.y1, bb.y2);
- this->compute_user_trans();
- this->m_bbox_updated = true;
+ this->compute_user_trans();
+ this->m_bbox_updated = true;
+ }
}
template<class VS, class RM>
@@ -111,27 +110,43 @@ template<class VS, class RM>
void plot_auto<VS,RM>::calc_bounding_box()
{
opt_rect<double> box;
+
calc_layer_bounding_box(this->m_root_layer, box);
for (unsigned j = 0; j < this->m_layers.size(); j++)
{
calc_layer_bounding_box(*(this->m_layers[j]), box);
}
- if (box.is_defined())
- this->m_rect = box.rect();
+ for (pod_list<item> *t = this->m_drawing_queue; t; t = t->next())
+ {
+ const item& d = t->content();
+ agg::rect_base<double> r;
+ d.vs->bounding_box(&r.x1, &r.y1, &r.x2, &r.y2);
+ box.add(r);
+ }
+
+ this->m_rect.add(box);
}
template<class VS, class RM>
bool plot_auto<VS,RM>::fit_inside(VS* obj) const
{
- if (this->m_is_empty || !this->m_bbox_updated)
+ if (!this->m_bbox_updated || !this->m_rect.is_defined())
return false;
agg::rect_base<double> r;
obj->bounding_box(&r.x1, &r.y1, &r.x2, &r.y2);
- const agg::rect_base<double>& bb = this->m_rect;
+ const agg::rect_base<double>& bb = this->m_rect.rect();
return bb.hit_test(r.x1, r.y1) && bb.hit_test(r.x2, r.y2);
}
+template<class VS, class RM>
+bool plot_auto<VS,RM>::pop_layer()
+{
+ bool retval = this->plot<VS,RM>::pop_layer();
+ this->m_bbox_updated = false;
+ return retval;
+}
+
#endif
diff --git a/agg-plot/plot.h b/agg-plot/plot.h
index a4c2db7a..f4bb68af 100644
--- a/agg-plot/plot.h
+++ b/agg-plot/plot.h
@@ -28,6 +28,7 @@
#include "units.h"
#include "resource-manager.h"
#include "colors.h"
+#include "rect.h"
#include "agg_array.h"
#include "agg_bounding_rect.h"
@@ -101,12 +102,12 @@ public:
void set_limits(const agg::rect_base<double>& r);
virtual void add(vertex_source* vs, agg::rgba8& color, bool outline);
- virtual void on_draw() { };
+ virtual void before_draw() { };
void draw(canvas &canvas, agg::trans_affine& m);
- bool push_layer();
- bool pop_layer();
+ virtual bool push_layer();
+ virtual bool pop_layer();
/* drawing queue related methods */
void push_drawing_queue();
@@ -149,7 +150,7 @@ protected:
pod_list<item> *m_drawing_queue;
bool m_need_redraw;
- agg::rect_base<double> m_rect;
+ opt_rect<double> m_rect;
bool m_use_units;
units m_ux, m_uy;
@@ -229,7 +230,7 @@ void plot<VS,RM>::clear_drawing_queue()
template <class VS, class RM>
void plot<VS,RM>::draw(canvas &canvas, agg::trans_affine& canvas_mtx)
{
- on_draw();
+ before_draw();
draw_title(canvas, canvas_mtx);
if (m_use_units)
draw_axis(canvas, canvas_mtx);
@@ -347,7 +348,9 @@ void plot<VS,RM>::compute_user_trans()
}
else
{
- r = m_rect;
+ if (! m_rect.is_defined())
+ return;
+ r = m_rect.rect();
}
double fx = 1/(r.x2 - r.x1), fy = 1/(r.y2 - r.y1);
@@ -489,7 +492,7 @@ void plot<VS,RM>::set_units(bool use_units)
template<class VS, class RM>
void plot<VS,RM>::set_limits(const agg::rect_base<double>& r)
{
- m_rect = r;
+ m_rect.set(r);
m_ux = units(r.x1, r.x2);
m_uy = units(r.y1, r.y2);
m_need_redraw = true;
diff --git a/agg-plot/rect.h b/agg-plot/rect.h
index d9e09099..82e761f5 100644
--- a/agg-plot/rect.h
+++ b/agg-plot/rect.h
@@ -25,7 +25,7 @@ public:
{
assert (m_defined);
return m_rect;
- };
+ }
void compose(rect_type& dst, const rect_type& r)
{
@@ -33,13 +33,19 @@ public:
dst = (m_defined ? agg::unite_rectangles(m_rect, r) : r);
else
dst = (m_defined ? agg::intersect_rectangles(m_rect, r) : r);
- };
+ }
void add(const rect_type& r)
{
this->compose(m_rect, r);
m_defined = true;
- };
+ }
+
+ void add(const opt_rect& optr)
+ {
+ if (optr.m_defined)
+ this->add(optr.m_rect);
+ }
};
#endif
diff --git a/agg-plot/window.cpp b/agg-plot/window.cpp
index b30a9f68..00a5eba3 100644
--- a/agg-plot/window.cpp
+++ b/agg-plot/window.cpp
@@ -227,7 +227,6 @@ window::restore_slot_image(int slot_id)
m_canvas->clear_box(r);
draw_slot_by_ref (*ref, false);
ref->save_image(this->rbuf_window(), r, this->bpp(), this->flip_y());
- ref->dirty_rect.clear();
}
else
{
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月19日 05:41:21 +0000

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