Question about use of 2-D Graphic API

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • need further help on this

    Adrian,

    What I am trying to do is hand-render some data that needs to be graphed on my window. I created most of the window using the GUIBuilder and everything is working fine except I'm having trouble with the graph part. I only want to draw the graph when some data changes that necessitates re-rendering of the graph. I have other items that are changing on the screen like some status text, the time of day, etc. The function that renders the graph is called from WM_PAINT but I don't want to re-render the graph every time WM_PAINT is called. I am using functions like GUI_DrawHLine, GUI_DRawVLine, GUI_SetColor, GUI_DrawPoint to render the graph. What's the recommended way for me to accomplish this?

    -Scott
  • saying it a different way

    I guess my question is the same as this other posting:"Using GUI_XXX function with WM_PAINT"


    I'm wanting to draw a graph on a dialog but I only want to re-draw the graph when it changes. I call the code that does the drawing inside the WM_PAINT tlike this:

    case WM_PAINT:
    // update graph whenever it changes
    if(last_graph_index != Treatment_last_graph_data_index)
    {
    paint_graph();
    last_graph_index = Treatment_last_graph_data_index;
    }
    break;


    I also have a 500 msec timer running that will call TEXT_SetText() to change some text items on the screen and whenever those items are changed the WM_PAINT is fired and the entire graph needs to be redrawn. I had to replace the if() statement in the code above with if(1) otherwise the graph disappears from the screen. How can I just update that text item and not require me to redraw the graph every time that text item changes?


  • I figured out a solution. I just created a separate child window that has its own timer and when the timer function expires it checks if the graph needs to be updated. If the graph needs updating then it invalidates the window and the WM_PAINT of just that child window is called and the graph is repainted. This avoids having to repaint the graph every time WM_PAINT occurs for the parent window.
  • Hello Scott,

    Are you implementing a custom graph or do you use our GRAPH widget?

    If you use the GRAPH widget invalidating is not required at all. In case you use a custom solution, I would recommend placing the actual graph in its own window (I think you are already doing this) invalidating it every time it changes.

    Is this what you wanted to know?

    Best regards,
    Adrian