In typical usage, the viewport control displays an "overall chart" that shows the full data range, and connects to the ViewPortManager using ViewPortControlBase.setViewPortManager. It can then include a rectangle on the overall chart to represent the viewport in the ViewPortManager. The region outside the rectangle can be dimmed out to highlight the viewport region. If the viewport is updated (such as if the user uses the mouse wheel to zoom in the chart), the rectangle will also update automatically.
To manipulate the viewport, the user can drag the rectangle to move the viewport (equivalent to scrolling). The user can also resize the viewport by dragging the border of the rectangle (equivalent to zooming), or drag a new rectangular region on the overall chart to be used as the new viewport, or click on a point on the chart to center the viewport at that point.
In C++, the user interface element depends on the GUI framework. There are many user interface frameworks, such as MFC, Qt and many others, and it is not practical to create viewport controls for all of them. In ChartDirector, the ViewPortControlBase implements the main logic of the viewport control without the GUI framework specific functions. The actual GUI framework specific control can derive from ViewPortControlBase and implement the GUI specific part. This greatly simplifies development of the actual control.
ChartDirector has included two examples in source code, CViewPortControl for the MFC framework and QViewPortControl for the Qt framework. Developers using other GUI framework can port use these controls as reference in developing their own GUI framework specific control.
Method | Inherited | Description |
---|---|---|
setChart | (Self) | Sets the BaseChart object to be displayed in the viewport control. |
setViewPortManager | (Self) | Sets the ViewPortManager object to be associated with the viewport control. |
handleMouseDown | (Self) | Handles the mouse down. |
handleMouseUp | (Self) | Handles the mouse up. |
handleMouseMove | (Self) | Handles the mouse move. |
paintViewPort | (Self) | Updates the viewport rectangle on the chart to reflect the state of the viewport. |
isOnPlotArea | (Self) | Determines if a point is on the plot area. |
setDragInsideToMove | (Self) | Enables or disables dragging inside the viewport to move it. |
getDragInsideToMove | (Self) | Checks if dragging inside the viewport to move it is enabled or disabled. |
setDragBorderToResize | (Self) | Enables or disables dragging the viewport border to resize it. |
getDragBorderToResize | (Self) | Checks if dragging the viewport border to resize it is enabled or disabled. |
setDragOutsideToSelect | (Self) | Enables or disables dragging outside the viewport to select a new viewport. |
getDragOutsideToSelect | (Self) | Checks if dragging outside the viewport to select a new viewport is enabled or disabled. |
setClickToCenter | (Self) | Enables or disables centering the viewport at the clicked point. |
getClickToCenter | (Self) | Checks if centering the viewport at the clicked point is enabled or disabled. |
setViewPortExternalColor | (Self) | Sets the fill color for the region outside the viewport. |
getViewPortExternalColor | (Self) | Gets the fill color for the region outside the viewport. |
setViewPortBorderColor | (Self) | Sets the viewport border color. |
getViewPortBorderColor | (Self) | Gets the viewport border color. |
setViewPortBorderWidth | (Self) | Sets the viewport border width. |
getViewPortBorderWidth | (Self) | Gets the viewport border width. |
setViewPortFillColor | (Self) | Sets the fill color for the region inside the viewport. |
getViewPortFillColor | (Self) | Gets the fill color for the region inside the viewport. |
setSelectionBorderColor | (Self) | Sets the border color of the selection box. |
getSelectionBorderColor | (Self) | Gets the border color of the selection box. |
setSelectionBorderWidth | (Self) | Sets the border width of the selection box. |
getSelectionBorderWidth | (Self) | Gets the border width of the selection box. |
setMouseMargin | (Self) | Sets the margin around the viewport border for mouse drag. |
getCursor | (Self) | Gets the mouse cursor to be used for user feedback. |
setZoomScrollDirection | (Self) | Sets the directions in which zooming and scrolling are allowed. |
needUpdateDisplay | (Self) | Checks if need to update the viewport control screen display. |
needUpdateChart | (Self) | Checks if need to update the chart in a viewport changed event. |
needUpdateImageMap | (Self) | Checks if need to update the image map in a viewport changed event. |