Presentation Models
Frequently, a model contains graphical information that is directly rendered to the viewport. For example, a model might contain visual components that draw themselves onto the viewport. Mixing graphical information with non-graphical information can blur the distinction between the model and viewport. To provide a clear distinction between graphical and non-graphical data, models are classified as either system models or presentation models. A system model is a CMvcModel derived class that represents a non-graphical, real-world system or process. A presentation model is both a model and a visual component that can render itself to a device context. The term visual model can also be used to describe this type of model. System and presentation models can be used exclusively or in combination. Used in combination, a presentation model provides the presentation for a system model, essentially mapping the real-world system into the graphical realm. Relationship between the system model and the presentation model shows the relationship between the system model and presentation model.
Relationship between the system model and the presentation model
MvcPresentationModel_T is a template class used to implement presentation models. The template parameter passed to MvcPresentationModel_T is a visual component type, which is declared as a base class. MvcPresentationModel_T also mixes in the CMvcModel class, making the presentation model both a model and a visual component.
A good example of where this idea is useful is in the implementation of a diagramming application. It is natural to implement a diagram class as a presentation model. A diagram would be a kind of presentation model, which manages the graphical symbol data, font choices, pen widths, and so forth. Like a model, it manages data, albeit graphical data, and exports functionality. However, like a visual component, a diagram can draw itself, and it can even be nested as a symbol inside of a parent diagram. Consequently, a diagram is both a model and a visual component.
Because a presentation model can draw itself, the role of the associated viewport changes to some degree. The viewport provides a perspective onto another visual component. The presentation model is essentially a graphics server, serving up whatever rectangular area of the canvas the viewport instructs it to paint.






