class CODViewport: public MvcViewport
The viewport renders the model to an area of a window. The viewport takes care of preparing a device context for rendering in the OnPrepareDC method. The Draw method performs the rendering to a device context. The viewport contains various other helper methods that draw different aspects of the view, such as the grid, selection handles, page boundaries, and background.The viewport contains mapping mode and extent ratio information that allow it uses to prepare the device context. The mapping mode and extents are used to map logical coordinates to device coordinates. The viewport also contains a CODRuler object that uses the coordinate mapping information to provide methods for converting to and from real-world measurements and logical units.
Defined in: OdViewport.h
VIEWS_API CODViewport()
Constructor.
VIEWS_API virtual ~CODViewport()
Destructor.
BOOL m_bAngleSnap
Angle snap.
BOOL m_bSnapToGrid
Snap to grid.
BOOL m_bGridVisible
Grid is visible.
CODMeasure m_gridSpacingX
Horizontal grid spacing.
CODMeasure m_gridSpacingY
Vertical grid spacing.
COLORREF m_crGridColor
Grid color.
OD_SELECTION_MODE m_selectionMode
Current viewport rubber-band selection mode.
BOOL m_bPagesVisible
Indicates if page boundaries are visible.
int m_nPadding
Padding to go around lines for selection.
CSize m_sizeHandles
Size of the control and vertex handles.
int m_nZoomMin
Minimum zoom percentage
int m_nZoomMax
Maximum zoom percentage
int m_nZoomIncrement
Percentage to zoom in or out.
int m_nNumPreviewPages
Maximum extent used for printing/scaling.
CSize m_szOldExtent
Previous extents for x and y values, so we can keep track over MFC print calls.
CODPropertySet m_setDefProperties
Default property set
CPoint m_ptPasteInsPoint
Paste insertion point.
CSize m_szPageDimensions
Page dimensions in logical units.
CODRuler* m_pRuler
Pointer to ruler object for this viewport.
sfl::YAxisDirection m_YAxisDirection
Enum representing desired direction of positive Y-Axis
BOOL m_bPrintCurView
Print the currently zoomed view. i.e. what is displayed on screen.
BOOL m_bPrintXByYPages
Print content to X by Y pages.
BOOL m_bPrintMaintainAspectRatio
Maintain the aspect ratio when printing X by Y pages.
CSize m_szMag
Viewport Magnification
VIEWS_API virtual void OnInitialUpdate()
Initializes the viewport.
VIEWS_API virtual BOOL CreateController()
Creates the controller that works with this viewport.
VIEWS_API virtual BOOL CreateChildWnd(CODWndComponent* pWndComp)
Creates the window component as a child of the viewport's owner window.
VIEWS_API virtual BOOL DestroyChildWnd(CODWndComponent* pWndComp)
Destroys the window of a windowed component
VIEWS_API virtual BOOL CreateChildrenWnds(CODComponent* pComp)
Creates the window components as children of the viewport's owner window for the all windowed components in a brunch from the given component
VIEWS_API virtual BOOL DestroyChildrenWnds(CODComponent* pComp)
Destroys the window components for the all windowed components in a brunch from the given component
VIEWS_API CODModel* GetCanvasModel()
Returns the pointer to the model this viewport is observing.
VIEWS_API CODController* GetCanvasCtlr()
Returns the controller that handles user interaction for this viewport.
VIEWS_API CODModel* GetModel()
Returns the pointer to the model this viewport is observing.
VIEWS_API CODController* GetCtlr()
Returns the controller that handles user interaction for this viewport.
VIEWS_API CODRuler* GetRuler()
Return a pointer to the ruler.
VIEWS_API BOOL GetAngleSnap() const
Returns TRUE if angle snap is on.
VIEWS_API void SetAngleSnap(BOOL bAngleSnap)
Sets angle snap on or off.
VIEWS_API void CenterOnComponents(CODComponentSet* pCompSet)
Centers the viewport on a set of components.
VIEWS_API virtual BOOL SizeToModel()
Changes the viewport size to match the size of the model.
VIEWS_API virtual BOOL PageIsBlank(int nPageIndex)
Determines if a diagram page is blank
VIEWS_API virtual CRect GetHiMetricBounds() const
Returns bounding rectangle in MM_HIMETRIC units.
VIEWS_API virtual CSize GetAspectRatio()
Determines the aspect ratio of the viewport.
VIEWS_API BOOL GetGridVisible() const
Returns TRUE if the grid is visible.
VIEWS_API void SetGridVisible(BOOL bGridVisible)
Sets whether the grid is visible.
VIEWS_API BOOL GetSnapToGrid() const
Returns TRUE if snap to grid is on.
VIEWS_API void SetSnapToGrid(BOOL bSnapToGrid)
Set snap to grid on or off.
VIEWS_API void GetHorizontalGridSpacing(float& fGridSpacingX) const
Gets the horizontal grid spacing.
VIEWS_API const CODMeasure& GetHorizontalGridSpacing() const
Gets the horizontal grid spacing.
VIEWS_API void SetHorizontalGridSpacing(float fGridSpacingX)
Sets the horizontal grid spacing.
VIEWS_API void SetHorizontalGridSpacing(const CODMeasure& gridSpacingX)
Sets the horizontal grid spacing.
VIEWS_API void GetVerticalGridSpacing(float& fGridSpacingY) const
Gets the vertical grid spacing.
VIEWS_API const CODMeasure& GetVerticalGridSpacing() const
Gets the vertical grid spacing.
VIEWS_API void SetVerticalGridSpacing(float fGridSpacingY)
Sets the vertical grid spacing.
VIEWS_API void SetVerticalGridSpacing(const CODMeasure& gridSpacingY)
Sets the vertical grid spacing.
VIEWS_API virtual CODMeasure GetMinGridSpacing() const
Return minimum logical grid spacing value.
VIEWS_API virtual CODMeasure GetMaxGridSpacing() const
Return maximum logical grid spacing value.
VIEWS_API virtual CSize GetMinGridPelSpacing() const
Return the minimum grid spacing in pixels.
VIEWS_API virtual CSize GetMaxGridPelSpacing() const
Return the minimum grid spacing in pixels.
VIEWS_API COLORREF GetGridColor()
Gets the color of the grid.
VIEWS_API void SetGridColor(COLORREF crGridColor)
Sets the color of the grid.
VIEWS_API CPoint FindClosestGridPoint(CPoint point)
Finds the closest grid point to the point passed in.
VIEWS_API OD_SELECTION_MODE GetSelectionMode() const
Gets the current viewport rubber-band selection mode.
VIEWS_API void SetSelectionMode(OD_SELECTION_MODE selectionMode)
Sets the current viewport rubber-band selection mode.
VIEWS_API virtual void CreateHandlePolygon(CPoint ptHandle, LPPOINT lpPolygon)
Creates a polygon that represents a control handle.
VIEWS_API virtual CRect CreateHandleRect(CPoint ptHandle)
Creates a rectangle that represents a control handle.
VIEWS_API virtual void DrawHandles(CDC* pDC, CODComponentSet* pCompSet, CODComponent* pAnchor, const CRect &rcUpdate)
Draw the control handles for a list of components.
VIEWS_API virtual void UpdateSelection(CODComponentSet* pCompSet)
Called when the set of selected components changes.
VIEWS_API CPoint GetPasteInsertionPoint() const
Gets paste insertion point (point at which components are inserted when paste command issued.
VIEWS_API void SetPasteInsertionPoint(CPoint ptPasteInsPoint)
Sets paste insertion point (point at which components are inserted when paste command issued.
VIEWS_API CODPropertySet* GetDefProperties()
Gets pointer to viewport's set of default properties.
VIEWS_API void SetDefProperties(CODPropertySet* pDefProperties)
Sets viewport's default properties.
VIEWS_API void InitCompProperties(CODComponent* pComp)
Initializes a component with the viewport's default set of properties.
VIEWS_API void InitCompProperties(CODComponentSet* pCompSet)
Initializes a set of components with the viewport's default set of properties.
VIEWS_API int PointsToLog(const int nPoints, BOOL bVertical = TRUE)
Converts points to logical units.
VIEWS_API int LogToPoints(const int nLog, BOOL bVertical = TRUE)
Converts logical units to points.
VIEWS_API float PointsToInches(int nPoints, BOOL bWidth)
Converts pixels to inches.
VIEWS_API int InchesToPoints(float fInches, BOOL bWidth)
Converts inches to pixels.
VIEWS_API virtual void PrepareDC(CDC* pDC, const BOOL bEnableZooming = TRUE)
Readies the device context for subsequent rendering or logical to device coordinate mapping.
VIEWS_API virtual void CalculateLogicalUnits(CDC* pDC)
Convert any real-world measurements, such as points, to logical units using the given device context.
VIEWS_API virtual void Draw(CDC* pDC)
Draw the viewport to a device context.
VIEWS_API virtual void DrawRect(CDC* pDC, const CRect& rcUpdate)
Draw a rectangular area of the viewport to a device context.
VIEWS_API virtual void DrawComponents(CDC* pDC, CODComponentSet* pCompSet = NULL)
Draws a set of components onto a given device context.
VIEWS_API virtual void DrawGrid(CDC* pDC, const CRect &rcUpdate)
Draws the grid.
VIEWS_API virtual void DrawAxes(CDC* pDC, const CRect &rcUpdate)
Draws the X and Y axes.
VIEWS_API virtual void DrawBkgndComponent(CDC* pDC, const CRect &rcUpdate)
Draws the background component.
VIEWS_API virtual void DrawPageBounds(CDC* pDC, const CRect &rcUpdate)
Draw page boundaries
VIEWS_API virtual void EraseBkgnd(CDC* pDC, const CRect& rcUpdate)
Erase the background with the background color.
VIEWS_API void EraseBkgnd(CDC* pDC)
Erase the background with the background color.
VIEWS_API virtual COLORREF GetOutOfBoundsColor() const
Get the color used to fill the area outside of the diagram
VIEWS_API virtual void DrawMetafile(CDC* pDC)
Draw the viewport to a metafile device context.
VIEWS_API virtual CMetaFileDC* CreateMetafile(CODComponentSet& setComponents)
Creates a metafile DC and draws the set of components into it.
VIEWS_API virtual BOOL TrackMovement(CODComponentSetTracker* pSetTracker, int nOffsetX, int nOffsetY)
Draws the tracking for components that are being moved.
VIEWS_API virtual void TrackRotation(CODComponentSetTracker* pSetTracker, int nAngle)
Draws the tracking for components that are being rotated.
VIEWS_API virtual void TrackScaling(CODComponentSetTracker* pSetTracker, float fScaleX, float fScaleY, OD_CONTROL_POINT nControlPoint)
Draws the tracking for components that are being scaled.
VIEWS_API virtual OD_MOVEVERTEX_RC TrackMovingVertex(CODComponentSetTracker* pSetTracker, int nVertexIndex, int nOffsetX, int nOffsetY)
Draws the tracking for a component whose vertex is being moved.
VIEWS_API virtual void DrawTracking(CODComponentSetTracker* pSetTracker)
Draw tracking for a set of components.
VIEWS_API virtual void EraseTracking(CODComponentSetTracker* pSetTracker)
Draw tracking for a set of components.
VIEWS_API virtual void ClipToVirtualBounds(CRect& rcClip)
Clip the given rectangle to the virtual size of the viewport.
VIEWS_API void UpdateAll()
Redraws the entire viewport.
VIEWS_API virtual void UpdateComponents(CODComponentSet* pCompSet)
Draws the given components and invalidates their regions
VIEWS_API virtual CRect DrawComponents(CODComponentSet* pCompSet)
Draws the given components
VIEWS_API virtual void InvalidateComponents(CODComponentSet* pCompSet)
Invalidate the area occupied by the given set of components
VIEWS_API virtual CODComponent* ComponentHitTest(CPoint ptHit)
Returns a pointer to the topmost component that contains the point, or NULL if there is no component at the point.
VIEWS_API virtual CODComponent* ControlHandleHitTest(CPoint ptHit, int& nHandleIndex)
Checks if one of the control handles of a selected component hit is at the point.
VIEWS_API virtual CODComponent* EdgeHitTest(CPoint ptHit, int& nEdgeIndex)
Checks to see if a component's edges have been hit.
VIEWS_API CODPortComponent* PortHitTest(CPoint ptHit, const int nSlop)
Returns a pointer to the topmost port that contains the point, or NULL if there is no port at the point.
VIEWS_API void ZoomIn(const CRect& rcZoom)
Zoom in on a given rectangle
VIEWS_API void ZoomIn(CPoint ptDev)
Increase magnification by 25%
VIEWS_API void ZoomOut(CPoint ptDev)
Decrease magnification by 25%
VIEWS_API void GetZoomRange(int& nZoomMin, int& nZoomMax)
Get minimum and maximum zoom percentages
VIEWS_API void SetZoomRange(int nZoomMin, int nZoomMax)
Sets the minimum and maximum zoom percentages
VIEWS_API virtual CSize SetMagnification(const int nPctX, const int nPctY)
Set logical scaling as percent magnification
VIEWS_API BOOL GetPagesVisible() const
Returns TRUE if page boundaries are visible.
VIEWS_API void SetPagesVisible(BOOL bPagesVisible)
Sets whether page boundaries are visible.
VIEWS_API virtual void CalcPageDimensions()
Calculate the page dimensions in logical units based on page settings in the diagram model.
VIEWS_API void GetPageDimensions(int& nPageWidth, int& nPageLength) const
Returns the page dimensions in logical units.
VIEWS_API CSize GetPageDimensions() const
Returns the page dimensions in logical units.
VIEWS_API int GetPageCount()
Returns the page count based on the diagram's page info.
VIEWS_API CRect GetPageBounds(const int nPageNo)
Returns the page boundaries given a page number.
VIEWS_API CRect GetPageBoundsNormal(const int nPageNo)
Internal - Returns page boundaries for normal printing.
VIEWS_API CRect GetPageBoundsCurView(const int nPageNo)
Internal - Returns page boundaries for current view printing.
VIEWS_API CRect GetPageMargins()
Returns the page margins.
VIEWS_API virtual BOOL WriteMetafile(CFile& outFile, LPCTSTR lpszDescription = NULL)
Writes contents of viewport to an enhanced metafile.
VIEWS_API virtual BOOL DrawImage(sfl::SECImage* pImage, CDC* pDC = NULL)
Draws contents of viewport to an image.
VIEWS_API virtual void OnUpdate(sfl::IMvcSubject* pSubject, sfl::IMvcMessage* pMsg)
Called when the model that this viewport observes is changed.
VIEWS_API virtual void OnUpdateMappingMode()
Called when the mapping mode or extents are modified.
VIEWS_API virtual void OnPrepareDC(CDC* pDC)
Readies the device context for subsequent rendering or logical to device coordinate mapping.
VIEWS_API virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
Readies the device context for subsequent rendering or logical to device coordinate mapping.
VIEWS_API virtual BOOL PreparePrinting(CPrintInfo* pInfo)
Prepares the diagram for printing.
VIEWS_API virtual BOOL PreparePrinting(CPrintInfo* pInfo, long percentOfNorm)
Prepares the diagram for printing fit to xxx% normal size.
VIEWS_API virtual BOOL PreparePrinting(CPrintInfo* pInfo, long percentOfNorm, CRect rcCurView)
Prepares the diagram for printing the current view and the current zoom.
VIEWS_API virtual BOOL PreparePrinting(CPrintInfo* pInfo, long x_pages_wide, long y_pages_tall)
Prepares the diagram for printing fit to X page(s) wide by Y page(s) tall
VIEWS_API virtual BOOL PreparePrinting(CPrintInfo* pInfo, long percentOfNorm, long x_pages_wide, long y_pages_tall, CRect rcCurView)
Prepares the diagram for printing fit to X page(s) wide by Y page(s) tall
VIEWS_API virtual void Print(CDC* pDC, CPrintInfo* pInfo)
Prints the diagram.
VIEWS_API virtual void EndPrinting(CDC* pDC, CPrintInfo* pInfo)
Cleanup when printing is finished.
VIEWS_API virtual void SetVirtualSize(int cx,int cy)
Set the total virtual size in logical units
VIEWS_API virtual CSize GetVirtualSize() const
Get the total virtual size in logical units
VIEWS_API virtual void SetVirtualOrigin(int x,int y)
Set the total virtual size in logical units
VIEWS_API virtual CPoint GetVirtualOrigin() const
Get the location of the virtual origin in logical units.
VIEWS_API virtual sfl::YAxisDirection GetYAxisDirection() const
Returns the direction of the positive Y axis
VIEWS_API virtual void SetYAxisDirection(sfl::YAxisDirection direction)
Sets the direction of the positive Y Axis
VIEWS_API virtual sfl::CEventFactory* GetEventFactory()
Returns a pointer to the event factory for this viewport.
inline virtual void SetIsPrintCurView(BOOL bPrintCurView)
Set whether or not the area to print will be the currently zoomed view.
inline virtual BOOL GetIsPrintCurView()
Returns TRUE or FALSE if the current area to print is the current zoomed view.
inline virtual void SetIsPrintXByYPages(BOOL bPrintXByYPages)
Enable printing X by Y pages.
inline virtual BOOL GetIsPrintXByYPages()
Is printing X by Y pages enabled?
inline virtual void SetIsPrintMaintainAspect(BOOL bMaintainAspectRatio)
Enable print with aspect ratio maintained.
inline virtual BOOL GetIsPrintMaintainAspect()
Is print with aspect ratio maintained enabled?
VIEWS_API CRect CalcVisibleVpRect()
Calculate the visible portion of the viewport displayed on the screen. Returns a rect in logical units.