ChartDirector Ver 4.1 (C++ Edition)

ViewPortManager


A view port can be imagined as a rectangular window of an underlying rectangular surface. For example, a chart that has 10 years of data can be imagined as a very long chart. If one only displays one of the year, we can say the view port covers only 10% of the underlying chart.

With the view port concept, scrolling can be handled as moving the view port, while zooming in and out can be handled as changing the view port size.

ViewPortManager is a utility class for handling view ports. It manages mapping of the mouse and display pixel coordinates to view port coordinates, and supports various user interface constraints that limits how the view port may be changed.

View port coordinates are represented as fractions of the width or height of the underlying surface. For example, the width of a view port is represented as a fraction of the width of the underlying surface, so it must be between 0 to 1. A value of 0.1 means the view port width is 10% of the underlying surface width.

If you are using MFC, there is no need to create a ViewPortManager object directly. You may simply use the MFC CChartViewer control, which is a derived class of ViewPortManager and contains all its functions.

If you are using other GUI framework, and would like to perform zooming and scrolling functions by mouse drag, the ViewPortManager may be useful to you. The section Using ChartDirector with Other GUI Frameworks contains outlines on how the ViewPortManager may be used in general GUI frameworks.

MethodInheritedDescription
setChartMetrics(Self)Sets the chart metrics to the ViewPortManager so it knows the positions of the necessary chart objects for supporting view ports.
getPlotAreaLeft(Self)Gets the x-coordinate of the left side of the plot area in pixels.
getPlotAreaTop(Self)Gets the y-coordinate of the top side of the plot area in pixels.
getPlotAreaWidth(Self)Gets the width of the plot area in pixels.
getPlotAreaHeight(Self)Gets the height of the plot area in pixels.
inPlotArea(Self)Determines if a given point is within the plot area.
setViewPortLeft(Self)Sets the position of the left side of the view port.
getViewPortLeft(Self)Gets the position of the left side of the view port.
setViewPortTop(Self)Sets the position of the top side of the view port.
getViewPortTop(Self)Gets the position of the top side of the view port.
setViewPortWidth(Self)Sets the width of the view port.
getViewPortWidth(Self)Gets the width of the view port.
setViewPortHeight(Self)Sets the height of the view port.
getViewPortHeight(Self)Gets the height of the view port.
validateViewPort(Self)Ensures the view port left, top, width and height are within valid ranges and adjusts them if necessary.
setZoomInWidthLimit(Self)Sets the view port width at maximum zoom in.
getZoomInWidthLimit(Self)Gets the view port width at maximum zoom in for mouse zoom in actions.
setZoomOutWidthLimit(Self)Sets the view port width at maximum zoom out.
getZoomOutWidthLimit(Self)Gets the view port width at maximum zoom out for mouse zoom out actions.
setZoomInHeightLimit(Self)Sets the view port height at maximum zoom in.
getZoomInHeightLimit(Self)Gets the view port height at maximum zoom in for mouse zoom in actions.
setZoomOutHeightLimit(Self)Sets the view port height at maximum zoom out.
getZoomOutHeightLimit(Self)Gets the view port height at maximum zoom out for mouse zoom out actions.
canZoomIn(Self)Checks if it is possible to zoom in further at a certain direction without violating zoom in limits.
canZoomOut(Self)Checks if it is possible to zoom out further at a certain direction without violating zoom out limits.
zoomAt(Self)Zooms in/out around a certain point.
zoomTo(Self)Zooms to the selected rectangular region.
startDrag(Self)Takes a snapshot of the view port to prepare for dragging. This method must be called before calling ViewPortManager.dragTo.
dragTo(Self)Scrolls the view port to reflect dragging of the underlying rectangular surface.