Redraw Detection

Respond when the view changes.

Explore the redraw-detection interface. Keep stated behavior and code examples exact when integrating display handling.

Detecting Redraw Events

The simulation window (SimView) will be redrawn whenever you:

  • resize the window,
  • change the zoom level,
  • navigate to a new module,
  • pan left, right, up, or down,
  • change an animation mode, or
  • click the ReDraw option under the View menu.

Any objects you have drawn by your models during a simulation, such as an XY-graph, will be erased by a redraw event. You can restore them by detecting the redraw events and re-initialing or redrawing your dynamic objects.

You can detect redraw events by monitoring the value of the following predefined global integer:

resizedraw_no

The resizedraw_no is changed (incremented) everytime there is a redraw event.

For example:

Suppose your model displays an XY-graph gadget. You might do the following: *``` DEFINE_THREAD: start_up { int old_redraw_number;

plot_init( MY_NAME, "x-axis", "y-axis" );
plot_axis_x( MY_NAME, 0.0, 105.0, 0, Gold, Blue );
plot_axis_y( MY_NAME, 50.0, 250.0, 0, Gold, Blue );

/* Record the initial redraw-number. */
old_redraw_number = resizedraw_no;

while (1)
 {
  DELAY(10.0);  /* Periodically check for redraws. */
  if (old_redraw_number != resizedraw_no)
   {
  /* Detected a redraw event.  Restore graph. */
  plot_init( MY_NAME, "x-axis", "y-axis" );
  plot_axis_x( MY_NAME, 0.0, 105.0, 0, Gold, Blue );
  plot_axis_y( MY_NAME, 50.0, 250.0, 0, Gold, Blue );
  /* Update the redraw-number. */
  old_redraw_number = resizedraw_no;
   }
 }
     }

END_DEFINE_THREAD. ```*

This page is an editorial rewrite of source documentation. Historical status, availability, and platform notes are not independently verified for a current release. Technical examples are reference material, not a live simulator.