Graphics Contexts and DCs explanations?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • RgeeK

    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.GraphicsCont ext 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.GraphicsCont ext.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.
  • Chris Mellon

    #2
    Re: Graphics Contexts and DCs explanations?

    On Tue, Aug 19, 2008 at 1:16 PM, RgeeK <Ross@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.GraphicsCont ext 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.GraphicsCont ext.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. wxGraphicsConte xt is a vector/path based API. If you're
    doing drawing that's suited for a vector format (like line drawing
    probably is), using wxGraphicsConte xt will give you better image
    quality as well as the general vector features like free scaling,
    rotation, transforms, etc,

    Comment

    • RgeeK

      #3
      Re: Graphics Contexts and DCs explanations?

      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. wxGraphicsConte xt is a vector/path based API. If you're
      doing drawing that's suited for a vector format (like line drawing
      probably is), using wxGraphicsConte xt 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.

      Comment

      • Tim Roberts

        #4
        Re: Graphics Contexts and DCs explanations?

        RgeeK <Ross@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.GraphicsCont ext 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, timr@probo.com
        Providenza & Boekelheide, Inc.

        Comment

        Working...