From f42eea85143089b25f4b7312cbb4dae213085290 Mon Sep 17 00:00:00 2001 From: tchernobog Date: Thu, 17 Aug 2006 17:03:42 +0000 Subject: [PATCH] - The problem with CairoWidget was that it did scale a pixmap of ~100x100 with a *factor* of ~640x480. That means ~64*48*10^6*3 bytes = a ~1.1 Gb RAM pixmap. The problem didn't show in versions of cairo >= 1.2 because it automagically clips (yeah, cairo programmers *are* smart :-)) It is temporary fixed for the moment, will be made better asap. git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@892 3ecf2c5c-341e-0410-92b4-d18e462d057c --- src/cairo_widget.cc | 12 ++++++++++++ src/cairo_widget.hh | 1 + src/simulation_widget.cc | 8 +++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/cairo_widget.cc b/src/cairo_widget.cc index ca95689..e0d0df0 100644 --- a/src/cairo_widget.cc +++ b/src/cairo_widget.cc @@ -27,6 +27,7 @@ #include #include +#include #include using namespace sgpem; @@ -73,6 +74,7 @@ CairoWidget::update(const History& history) cairo_t* ctx = gdk_cairo_create(_buf->gobj()); // do the drawing... + std::cout << " Dimensions, w : " << _w << ", h : " << _h << std::endl; cairo_scale(ctx, _w, _h); draw_widget(ctx); cairo_destroy(ctx); @@ -133,6 +135,16 @@ CairoWidget::on_size_allocate(const Gtk::Allocation& allocation) } +void +CairoWidget::on_size_request(Gtk::Requisition* requisition) +{ + *requisition = Gtk::Requisition(); + + requisition->width = _w; + requisition->height = _h; +} + + bool CairoWidget::on_expose_event(GdkEventExpose* event) { diff --git a/src/cairo_widget.hh b/src/cairo_widget.hh index 13d02bc..6914cc6 100644 --- a/src/cairo_widget.hh +++ b/src/cairo_widget.hh @@ -44,6 +44,7 @@ namespace sgpem virtual void on_realize(); virtual void on_size_allocate(const Gtk::Allocation& allocation); + virtual void on_size_request(Gtk::Requisition* request); virtual bool on_expose_event(GdkEventExpose* event); virtual bool on_button_press_event(GdkEventButton* event); virtual void draw_widget(cairo_t* ctx) = 0; diff --git a/src/simulation_widget.cc b/src/simulation_widget.cc index 3fff453..fb1ed00 100644 --- a/src/simulation_widget.cc +++ b/src/simulation_widget.cc @@ -46,13 +46,13 @@ SimulationWidget::draw_widget(cairo_t* ctx) // NOTE: just to try CairoElements ce(ctx); - Rectangle area = { 30, 30, 100, 100 }; + Rectangle area = { 0.3, 0.3, 1.0, 1.0 }; ce.draw_container(area); Color red = { 1, 0, 0 }; - Point center = { 25, 25 }; + Point center = { 0.25, 0.25 }; - ce.draw_3dsphere(center, 20, red); + ce.draw_3dsphere(center, 0.20, red); } @@ -63,10 +63,12 @@ SimulationWidget::calc_size(const History& history, size_t& width, size_t& heigh width = get_allocation().get_width(); height = get_allocation().get_height(); +/* #ifndef NDEBUG using namespace std; clog << " [DD] New allocation event on " << hex << this << ": " << dec << width << 'x' << height << endl; #endif +*/ }