Re: Some advice creating a graph class

From: rs (removethis4spam.rastacey_at_nl.rogers.com)
Date: 02/20/05


Date: Sun, 20 Feb 2005 17:10:34 -0330

Thanks. I didn't realize I could use the dc in the view without passing it
in as a parameter.

"Edward H. Fabrega" <spiritualfields@wavecable.com> wrote in message
news:PYednVSm3qMrcoXfRVn-vg@wavecable.com...
>
> "rs" <removethis4spam.rastacey@nl.rogers.com> wrote in message
> news:B_udnaD6CuV5LYXfRVn-iA@rogers.com...
> >I am developing a program to draw a graph of database data using the
> >OnPaint
> > function in the View class.
> > In the CView class I am grabbing the device context and then passing it
to
> > a
> > function where I draw the actual graph by creating pens & brushes and
> > using
> > moveto/lineto functions etc.
> >
> > void CBView::OnPaint()
> > {
> > CPaintDC dc(this); // device context for painting
> > DrawGraph(&dc);
> > }
> >
> > This is working well but becoming quite large as a function and would
> > think
> > it is time to create a class to encapsulate the graph function.
> > This seemed pretty straight forward until I started and realized it's
not
> > all that straight forward.
> >
> > Questions like what base class should this be derived from? How should
the
> > parameters be passed? etc.
> >
> > Any ideas, or tutorials or examples would be appreciated.
> >
> > Thanks.
> >
> >
> >
>
> Take a look at this. Are you trying to draw a grid like this?
>
> http://members.aol.com/spiritualfields/main_screenshot.htm
>
> That screen shot is of a CView drawn to reperesent a database. All of the
> drawing takes place in the view. There is no way of keeping your OnPaint
> small. It is a monumental task to draw and then populate the cells.
> Especially if the "cell"s are really rectangles that you keep track of as
> you draw the grid. If your only problem is that the function is big then
you
> have no problem. If you get more specific as to functionality, i.e. "how
do
> I keep track of the data?" "How do I scroll the window so that different
> parts of the database are visible?" "How do I keep the column headers
from
> scrolling vertically" How do I keep the row headers from scrolling
> horizontally?" How do I write into the cells from the database?" then I
> might be able to help you, at least with the building of the grid. If you
> are also building your database, then I might be able to help you there,
as
> well. Joe Newcomer's advice about letting OnPaint (I use OnDraw) worry
about
> drawing the grid is a good one, as it makes no sense to farm out painting
> functionalilty to a function other than the one designed for painting.
>
> Ed
>
>
>



Relevant Pages

  • Re: Some advice creating a graph class
    ... >I am developing a program to draw a graph of database data using the ... Are you trying to draw a grid like this? ... That screen shot is of a CView drawn to reperesent a database. ...
    (microsoft.public.vc.mfc)
  • Re: Ontarios Provincial 49 In My Lotto Ponds
    ... grid and randoming dropping the numbers onto the grid. ... The different number group exercise thingy I did probe, as well as play ... non-changeable numbers for Pond C. ... standard combination of the 3 X 16-number lines I was posting every draw ...
    (rec.gambling.lottery)
  • Re: Ontarios Provincial 49 In My Lotto Ponds
    ... grid and randoming dropping the numbers onto the grid. ... The different number group exercise thingy I did probe, as well as play ... non-changeable numbers for Pond C. ... standard combination of the 3 X 16-number lines I was posting every draw ...
    (rec.gambling.lottery)
  • Graphics - need to draw to the screen and then erase it
    ... and then use lines to create a grid. ... I then draw sine-waves ontop of the ... So the user presses on the display with the stylus and a line is ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: grid pair puzzle
    ... so if I pick one to move how it can be solved to move and draw how it ... it looks like pairs in a grid can say any machine the way they can be ... just be moving one that solves. ... Try stating the question in English. ...
    (rec.puzzles)