Graphics Reference
In-Depth Information
In our case, and in the case of most modern interactive graphics systems,
the application defines the timer event for simulation computation. To support
smooth simulation results, we have seen that the timer event typically triggers
within real-time response thresholds (e.g., 20-50 milliseconds). When servicing
the timer events, our application can take the opportunity to maintain coherent
states among all components. For example, in the ServiceTimer() function in
Listing 1.7, we update the velocity slider bars based on current HeroBall veloc-
ity. In effect, during each timer event service, the application pushes the up-to-
date model information to all components and forces the components to refresh
their presentation for the user. In this way, the communication protocol among
the components becomes trivial. All components keep a reference to the model,
and each view/controller pair in the application does not need to be aware of the
existence of other view/controller pairs. In between periodic timer events, the
user's asynchronous events change the model. These changes are only made in
the model component, and no other components in the application need to be
aware of the changes. During the periodic timer service, besides computing the
model's simulation update, the model flushes up-to-date state information to all
components. For example, when the user clicks and drags with the left mouse but-
ton pressed, a new HeroBall will be defined in the model component. During this
time, the large- and small-view components will not display the new HeroBall ,
and the velocity slider bars will not show the new HeroBall 's velocity. These
components will get and display up-to-date HeroBall information only during
the application timer event servicing. Since the timer event is triggered more than
30 times per second, the user will observe a smooth and up-to-date application
state in all components at all times.
5.5
Applying the MVC Concept
The MVC framework is applicable to general interactive systems. As we have
seen in this chapter, interactive systems with the MVC framework result in clearly
defined component behaviors. In addition, with clearly defined interfaces among
the components, it becomes straightforward to expand the system with additional
view/controller pairs.
An interactive system does not need to be an elaborate software application.
For example, the slider bar is a fully functional interactive system. The model
component contains a current value (typically a floating-point number), the view
component presents this value to the user, and the controller allows the user to in-
teractively change this value. A typical view component draws rectangular icons
Search WWH ::




Custom Search