SourceForge logo
SourceForge logo
Menu

Re: [matplotlib-devel] First cut on a QtAgg backend

From: Ted D. <ted...@jp...> - 2005年01月31日 17:55:25
We've also been working on a Qt front end. It's been going slow because 
we've only been able to spend about 1 oerson-day per week on it. But, 
starting this week I have someone full time on it. He's gotten a basic 
widget working using the same organization that the GTK code 
uses. Sigve's code has a lot more functionality in the tool bars than 
ours right now.
Here's where we're at:
- Finished C++ routine to convert AGG -> QPixmap (in /src/_qtagg.cpp)
- Finished low level widget to display the AGG pixmap using a widget 
derived from QLabel (in ./lib/matplotlib/backends/backend_qtagg.py)
- Working on a higher level window widget to display the plot and the tool 
bar. We implemented the tool bar as a Qt tool bar which allows you drag it 
around, detach it, etc.
The guy working on it doesn't think it would take more than a day or two to 
incorporate Sigve's code for the tool bar handling into our code. We're 
close enough to finishing that it probably doesn't make a lot of sense to 
try and set up a collaboration right now but I'm open to that possibility 
if that's what people want. All I really interested in is seeing the QtAgg 
front end in matplotlib as a supported component (which we'd be happy to 
help maintain) so whatever gets us there the quickest sounds good to me.
Ted
PS: here's the code we used to do the AGG->QPixmap conversion. It may not 
be the fastest way to do it but it does work which is all we were after for 
the first cut.
PyQObject* pyDrawable = static_cast< PyQObject* >( args[0].ptr() );
QLabel* label = static_cast< QLabel* >( pyDrawable->obj );
RendererAgg* aggRenderer = static_cast< RendererAgg* >( args[1].ptr() );
unsigned int width = aggRenderer->get_width();
unsigned int height = aggRenderer->get_height();
QImage image( aggRenderer->pixBuffer, width, height, 32, 0, 256,
 QImage::LittleEndian );
QPixmap pixmap;
pixmap.convertFromImage( image, QPixmap::Color );
label->setPixmap( pixmap );
At 07:25 AM 1/31/2005, John Hunter wrote:
> >>>>> "John" == John Hunter <jdh...@ac...> writes:
>
> John> * The only explanation I can think of for why the colors
> John> are wrong is that qt has a different byte order for images
> John> than you are getting from agg (is could it be bgra instead
> John> of rgba, or that something is wrong with the endianess...)
> John> If you need a different byte ordering /pixel format, I can
> John> provide the required method in the agg backend. I note that
> John> the saved figures *do* have the right color scheme, which
> John> supports this idea.
>
>Another clue that endianess is playing a role here is that the colors
>are dramatically different on OSX (which I tested yesterday) ans linux
>which I tested today. But I think it's more than an endian problem,
>because the colors are wrong on both platforms. On linux, it looks
>like the endianess is right, but it's an rgb versus bgr thing, since
>the colors are backwards on
>
> from pylab import *
> subplot(211)
> plot([1,2,3], color='red')
>
> subplot(212)
> plot([1,2,3], color='blue')
>
> show()
>
>On OSX, it looks like the endianess is wrong because the colors are
>really off...
>
>Also, I took a quick at the qimage class docs at
>http://doc.trolltech.com/3.3/qimage.html and saw
>
> It is one of the two classes Qt provides for dealing with images, the
> other being QPixmap. QImage is designed and optimized for I/O and for
> direct pixel access/manipulation. QPixmap is designed and optimized
> for drawing. There are (slow) functions to convert between QImage and
> QPixmap: QPixmap::convertToImage() and QPixmap::convertFromImage().
>
>Does this suggest that QPixmap might be more appropriate / faster
>since you don't need to do the individual pixel manipulation provided
>by QImage (spoken as a total qt newbie, so please forgive any
>stupidities on my part...)
>
>
>An unrelated observation regarding event handling: the qt backend is
>not connecting to mouse motion unless a pan/zoom button is pressed and
>released, eg coords_demo.py does not work properly.
>
>Cheers!
>JDH
>
>
>-------------------------------------------------------
>This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
>Tool for open source databases. Create drag-&-drop reports. Save time
>by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
>Download a FREE copy at http://www.intelliview.com/go/osdn_nl
>_______________________________________________
>Matplotlib-devel mailing list
>Mat...@li...
>https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Ted Drain Jet Propulsion Laboratory ted...@jp... 

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

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