ChartDirector 6.0 (C++ Edition)

ViewPortManager


A viewport 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 viewport covers only 10% of the underlying chart.

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

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

Viewport coordinates are represented as fractions of the width or height of the underlying surface. For example, the width of a viewport 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 viewport width is 10% of the underlying surface width.

If you are using MFC or QT, there is no need to create a ViewPortManager object directly. You may simply use the MFC CChartViewer control or the QT QChartViewer widget, 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 viewports.
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 viewport.
getViewPortLeft(Self)Gets the position of the left side of the viewport.
setViewPortTop(Self)Sets the position of the top side of the viewport.
getViewPortTop(Self)Gets the position of the top side of the viewport.
setViewPortWidth(Self)Sets the width of the viewport.
getViewPortWidth(Self)Gets the width of the viewport.
setViewPortHeight(Self)Sets the height of the viewport.
getViewPortHeight(Self)Gets the height of the viewport.
validateViewPort(Self)Ensures the viewport left, top, width and height are within valid ranges and adjusts them if necessary.
setZoomInWidthLimit(Self)Sets the viewport width at maximum zoom in.
getZoomInWidthLimit(Self)Gets the viewport width at maximum zoom in for mouse zoom in actions.
setZoomOutWidthLimit(Self)Sets the viewport width at maximum zoom out.
getZoomOutWidthLimit(Self)Gets the viewport width at maximum zoom out for mouse zoom out actions.
setZoomInHeightLimit(Self)Sets the viewport height at maximum zoom in.
getZoomInHeightLimit(Self)Gets the viewport height at maximum zoom in for mouse zoom in actions.
setZoomOutHeightLimit(Self)Sets the viewport height at maximum zoom out.
getZoomOutHeightLimit(Self)Gets the viewport 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 at a certain point.
zoomAround(Self)Zooms around a certain point.
zoomTo(Self)Zooms to the selected rectangular region.
startDrag(Self)Takes a snapshot of the viewport to prepare for dragging. This method must be called before calling ViewPortManager.dragTo.
dragTo(Self)Scrolls the viewport to reflect dragging of the underlying rectangular surface.
setFullRange(Self)Defines the full range of a viewport data scale.
updateFullRangeH(Self)Updates the full range of a horizontal viewport data scale.
updateFullRangeV(Self)Updates the full range of a vertical viewport data scale.
getValueAtViewPort(Self)Converts a viewport coordinate to a value of the specified data scale.
getViewPortAtValue(Self)Converts a value of the specified data scale to a viewport coordinate.
syncLinearAxisWithViewPort(Self)Synchronizes a linear Axis with the part of the data scale in viewport.
syncLogAxisWithViewPort(Self)Synchronizes a logarithmic Axis with the part of the data scale in viewport.
syncDateAxisWithViewPort(Self)Synchronizes a date/time Axis with the part of the data scale in viewport.