Trouble getting custom DrawingArea derived widget to udpate
- From: Genís <mailtogenis gmail com>
- To: gtkmm-list gnome org
- Subject: Trouble getting custom DrawingArea derived widget to udpate
- Date: Tue, 26 Jan 2010 07:44:13 -0800 (PST)
Hello, I have some trouble handling with drawing area widgets. I have
implemented a GUI with gtkmm to display a sequence of images that my
application processes. I obtain these images either from files allocated in
the hard disc and from a pair of video cameras. Briefly, I have a main
widget (a window) that launches a thread to process and display the images.
The main thread, though, remains executing the idle loop. I think that is
necessary to avoid the interface to hang up. The other thread, once it
processed every pair images it passes them as a parameter to an object
derived from Gtk::DrawingArea that I implemented myself. It's only function
is to convert IplImages (images in opencv format) to Gdk::PixBuffer and
display it. Its something like that:
class Window{
Displayer displayer;
void start(){
create a glib::thread that executes Window::loop();
}
void loop(){
for_every_pair_of_images(a,b){
process_images
displayer.load_left(a);
displayer.load_right(b);
}
}
};
class Displayer :: Gtk::DrawingArea{
Gdk::Pixbuf buf;
virtual bool load(IplImage* ){
buf = create a pixbuf from input iplimage parameter
paint()
}
virtual bool on_expose_event(GdkEventExpose* e){
paint();
}
void paint(){
if(buf!=NULL) {
buf->render_to_drawable(get_window(),
get_style()->get_black_gc(),
0, 0, 0, 0, buf->get_width(), buf->get_height(),
Gdk::RGB_DITHER_NONE, 0, 0);
}
}
};
I dindn't just copy-pasted my code because there are some hundreds of
non-interesting lines (at least in this context) in it and they will just
ofuscate the code. The conversion of IplImage to Pixbuf and the process of
images are done properly (with a 99% of reliability). I thought that
overloading DrawingArea::on_expose_event and letting main thread to capture
and process events was enough to get images changed every time new ones were
read, but it seems I was wrong. Does someone notice my error? By the way,
every time I try to display two new images processing thread hangs until
main thread gets some other event (for example a mouse pointer passing over
the main window), and then it resumes until a new pair of images are to be
shown.
Thank you in advance
--
View this message in context: http://old.nabble.com/Trouble-getting-custom-DrawingArea-derived-widget-to-udpate-tp27324703p27324703.html
Sent from the Gtkmm mailing list archive at Nabble.com.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]