Graphics Reference
In-Depth Information
class CModel {
void CreateCircleAt( int centerX, int centerY);
// Create circle at (centerX, centerY)
void ResizeCircle( int perimeterX, int perimeterY);
// Resize such input point is on the circumference
void MoveCirceTo( int centerX, int centerY);
// Move center of circle to (centerX, centerY)
void DrawModel();
Source files.
Model.h/cpp
in
the Model
folder
of
the
// Draw the circle
D3D _ MouseInput project.
private :
UWBD3D _ CircleGeometry m _ Circle; // Simple world with one circle
};
Listing 5.12. The model for Tutorial 5.2.
A: Left Mouse Click (atX, atY)
Convert HadwareCoordinate to DeviceCoordinate(atX, atY -> dcX, dcY)
getTheModel().CreateCircleAt(dcX, dcY)
B: Left Mouse Drag (atX, atY)
Convert HadwareCoordinate to DeviceCoordinate(atX, atY -> dcX, dcY)
getTheModel().ResizeCircle(dcX, dcY)
C: Right Mouse Click (atX, atY)
Convert HadwareCoordinate to DeviceCoordinate(atX, atY -> dcX, dcY)
getTheModel().MoveCircleTo(dcX, dcY)
D: Right Mouse Drag (atX, atY)
Convert HadwareCoordinate to DeviceCoordinate(atX, atY -> dcX, dcY)
getTheModel().MoveCircle(dcX, dcY)
Listing 5.13. Mouse event services (Tutorial 5.2).
Implementation. We once again subclass from WindowHandler to implement
the desired view/controller pair functionality. With the single circle application
HardwareToDevice() . The
implementation of this func-
tion can be found in uw-
bgl_WindowHandler2.cpp in
the Common folder of the UW-
BGL_D3D_Lib2 project.
state, the output view component functionality is identical to that from Tuto-
rial 5.1. However, in this tutorial we must support mouse events. Listing 5.14
shows the definition of the CDrawAndMouseHandler class. Similar to the CDraw
OnlyHandler calss, the CDrawAndMouseHandler view/controller pair also sub-
classes from the UWBD3D _ WindowHandler . In this case, the view component
functionality is identical to that of CDrawOnlyHandler from Tutorial 5.1. List-
ing 5.15 shows the two new mouse event service routines implementing the event
services defined in Listing 5.13. With the new CDrawAndMouseHandler ,the
CTutorialDlg main application window class is similar to that from Tutorial 5.1.
Search WWH ::




Custom Search