473,396 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Graphics Contexts and DCs explanations?

Experimenting with graphics in an app: it's AUI based with a few panes,
one of which has a panel containing a few sizers holding UI elements.
One sizer contains a panel that needs some basic line-drawing graphics
in it.

I use the wxPython demo app heavily to figure this stuff out, and my
experiments seem to work, but I'm flying blind somewhat.

Can someone englighten me about the wx.GraphicsContext versus wx.PaintDC
(BTW what does PaintDC stand for? Drawing Context perhaps?)

The scrolledWindow and GraphicsContext examples are helpful, but it
appears I can draw a rectangles, lines and text in either just a
straight wxPaintDC, or can do:

dc = wx.PaintDC(self)
gc = wx.GraphicsContext.Create(dc)

....and do the same drawing with gc.DrawText etc...

Can someone clarify the differences or added value of the gc over the
dc, and is using the dc alone a valid approach? Where will it end up
biting me - I don't mean which body part :) Perhaps I should say in
which situation will it bite...

Thx,
Ross.
Aug 19 '08 #1
3 2557
On Tue, Aug 19, 2008 at 1:16 PM, RgeeK <Ro**@no.thanks.spammerswrote:
Experimenting with graphics in an app: it's AUI based with a few panes, one
of which has a panel containing a few sizers holding UI elements. One sizer
contains a panel that needs some basic line-drawing graphics in it.

I use the wxPython demo app heavily to figure this stuff out, and my
experiments seem to work, but I'm flying blind somewhat.

Can someone englighten me about the wx.GraphicsContext versus wx.PaintDC
(BTW what does PaintDC stand for? Drawing Context perhaps?)

The scrolledWindow and GraphicsContext examples are helpful, but it appears
I can draw a rectangles, lines and text in either just a straight wxPaintDC,
or can do:

dc = wx.PaintDC(self)
gc = wx.GraphicsContext.Create(dc)

...and do the same drawing with gc.DrawText etc...

Can someone clarify the differences or added value of the gc over the dc,
and is using the dc alone a valid approach? Where will it end up biting me
- I don't mean which body part :) Perhaps I should say in which situation
will it bite...
This is probably better suited to the wxPython ML instead of c.l.p,
because it's so specific.

In short: wxDC (and friends) are traditional raster based drawing
contexts. wxGraphicsContext is a vector/path based API. If you're
doing drawing that's suited for a vector format (like line drawing
probably is), using wxGraphicsContext will give you better image
quality as well as the general vector features like free scaling,
rotation, transforms, etc,
Aug 19 '08 #2
Chris Mellon wrote:
This is probably better suited to the wxPython ML instead of c.l.p,
because it's so specific.

In short: wxDC (and friends) are traditional raster based drawing
contexts. wxGraphicsContext is a vector/path based API. If you're
doing drawing that's suited for a vector format (like line drawing
probably is), using wxGraphicsContext will give you better image
quality as well as the general vector features like free scaling,
rotation, transforms, etc,
Thx Chris - I wasn't aware of the wxPython ML. I'll hunt around for it
for further q's in that vein.

Your explanation is helpful tho' - thx.
Aug 21 '08 #3
RgeeK <Ro**@no.thanks.spammerswrote:
>...
I use the wxPython demo app heavily to figure this stuff out, and my
experiments seem to work, but I'm flying blind somewhat.

Can someone englighten me about the wx.GraphicsContext versus wx.PaintDC
(BTW what does PaintDC stand for? Drawing Context perhaps?)
Yes. The DC is a concept straight from the Windows GDI API. It holds your
current surface, your current foreground and background colors, your
current pattern, your current raster op, etc. In X, the same concept is
called a "gc" -- graphics context.

Windows requires special handling to create a DC within a WM_PAINT handler
(which is what calls OnPaint). That's why wx.PaintDC is separate. Outside
of OnPaint, you'd usually use wx.ClientDC.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Aug 22 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tristan | last post by:
I'm developing a class which is to draw to a given graphics context i.e a CClientDC in Visual C++. The problem I have it is that my functions implement a specific interface which are platform...
17
by: black tractor | last post by:
HI there.. l was just wondering, if l place a "table" in the "editable region" of my template, will the text, graphics placed inside the this "table" MOVE BY ITSELF?? l mean, recently l had a...
2
by: JBiagio | last post by:
Hello All, I am attempting to learn a bit about the GDI+ transforms and charting data and I feel like I'm getting a handle on how the transforms work. My chart object has a large "canvas" bitmap...
12
by: Sanjay | last post by:
hi, We are currently porting our project from VB6 to VB .NET. Earlier we used to make scale transformations on objects like pictureBox , forms etc.Now Such transformations are made on the...
5
by: steve bull | last post by:
When adding a new user control to a panel I get the following call stack. Having put debugs everywhere I can think of I cannot get the program to break anywhere near where it is having this problem....
4
by: Peter Oliphant | last post by:
There doesn't seem to be any documentation on how to create and/or use an instance of System::Drawing::Graphics. On-line MSDN talks about this class, and says: " The Graphics class provides...
5
by: Charles A. Lackman | last post by:
Hello, I have created a complete PrintDocument and need to create an image from it. How is this done? e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality...
12
by: Xah Lee | last post by:
Of Interest: Introduction to 3D Graphics Programing http://xahlee.org/3d/index.html Currently, this introduction introduces you to the graphics format of Mathematica, and two Java Applet...
8
by: Pierre Dagenais | last post by:
What is the easiest way to draw to a window? I'd like to draw something like sine waves from a mathematical equation. Newbie to python.
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.