Graphics Reference
In-Depth Information
// Mouse button services
void CMainHandler::OnMouseButton( bool down, unsigned int nFlags, int hwX, int hwY)
.
A:
HardwareToDevice(hwX, hwY, deviceX, deviceY); // hwXY -> deviceXY
.
if (nFlags & MK _ LBUTTON) // Left Mouse Button down
// Compute new center for small view WC Window
ComputeBoundPosition(deviceX, deviceY);
B:
// Mouse move services
void CMainHandler::OnMouseMove( unsigned int nFlags, int hwX, int hwY)
.
A:
HardwareToDevice(hwX, hwY, deviceX, deviceY);
.
if (nFlags & MK _ LBUTTON) // Left Mouse Button drag
// Compute new center for small view WC Window
B:
Source file.
DrawAndMouseHandler.cpp
file
ComputeBoundPosition(deviceX, deviceY);
in
the WindowHan-
dler
folder
of
the
D3D _ BadMousePan project.
Listing 10.15. The MainHandler mouse event service routines of Tutorial 10.13.
that in our discussion, these are in WC coordinate units, while we know that the
mouse positions are in device coordinates. Tutorial 10.13 shows us the results of
not transforming points to the WC space and using the mouse positions in the DC
space directly. Listing 10.15 shows the mouse button click ( OnMouseButton )and
mouse move ( OnMouseMove ) service routines of Tutorial 10.13. In both service
routines, at label A we transform the mouse click position from hardware to de-
vice coordinate, and then use the DC position to compute the center position for
the small-view WC window. For this reason, in Tutorial 10.13, if we click around
the top region of the main view, the corresponding DC points will have values
around 300, and thus the small-view WC window will be moved to corresponding
positions. Because nothing is defined in the 300 range in the WC space, nothing
will show up in the small-view drawing area. Recall from Figure 10.10 that the ge-
ometric person is defined within the range of
. This means if we left mouse
button click/drag around the lower-left region of the main view, limiting our DC
position to within the range of
[
0
,
40
]
, we will see the small-view WC window
panning around the geometric person. Clearly we must transform the DC posi-
tions to WC before computing the WC window position. Tutorial 10.14 extends
from Tutorial 10.13 with the simple inclusion of the DeviceToWorld() function
[
0
,
40
]
Search WWH ::




Custom Search