CODModel Class

class CODModel: public MvcPresentationModel_T, public IODIdGenerator, public IODGraph

This class is a container for the components on a canvas. The class CODViewport is an observer of the model and is used to render the information stored in the model. The model also contains information describing the background and page settings.

The model is responsible for maintaining a map of unique component identifiers. All component IDs are unique within a given model. The IODIdGenerator interface is implemented by the model. Components have a method to return a pointer to this interface, which follows the chain of parents until it reaches the model.

The model is derived from CODComponent so that canvases can be nested just like components. Like all components, models have logical bounding rectangles, a logical origin, and properties.

Commands can be executed against the model. The model stores a transaction model object that contains undo and redo buffers. The Do function is used to execute commands and store then in the transaction model. MvcPresentationModel_T::Undo will undo the last command executed.

Defined in: OdModel.h

Class Members

Constructors & Destructor

VIEWS_API CODModel()

Constructor.

VIEWS_API virtual ~CODModel()

Destructor.

VIEWS_API virtual void Initialize()

Initialize the canvas model.

Attributes

BOOL m_bIsModified

Modified status flag.

CODComponent* m_pBkgndComponent

A component displayed behind the canvas.

BOOL m_bBkgndCompRefCount

Non-zero if the background component is to be reference counted.

CMap<ODComponentId,ODComponentId,CODComponent*,CODComponent*> m_mapID

Register of instance IDs.

CODPageSettings m_pageSettings

Page settings for this canvas.

sfl::MvcTransactionModel m_tm

Canvas's internal transaction model.

BOOL m_bDragSource

True if OLE drag operation is originating from this canvas.

BOOL m_bDragTarget

True if OLE drag operation is terminating at (dragging objects over) this canvas.

CODBspTree m_bspTree

The binary space partitioning tree used for hit testing.

sfl::CCArray_T<IPropertyNotifySink*,IPropertyNotifySink*> m_propNotifySink

Array of interfaces to components that receive property change notifications.

VIEWS_API static BOOL m_bIsSerializing

a flag to indicating if serialization is taking place

CSize m_szMag

Viewport Magnification.

virtual ODComponentId GetID() const

Return the component ID of the canvas.

virtual BOOL GetDesignMode() const

Sets the design mode state of the model

virtual void SetDesignMode(BOOL bDesignMode)

Returns the design mode state of the model

virtual BOOL GetReadOnly() const

Returns the read-only state of the model

virtual void SetReadOnly(BOOL bReadOnly)

Sets the read-only state of the model

virtual BOOL GetCanSelect() const

Returns the current can-select state of the model

virtual void SetCanSelect(BOOL bCanSelect)

Sets the current can-select state of the model

virtual BOOL GetCanEditProps() const

Returns the current can-edit-properties state of the model

virtual void SetCanEditProps(BOOL bCanEditProps)

Sets the current can-edit-properties state of the model

virtual BOOL IsModified() const

Check for any canvas modifications.

virtual void SetModifiedFlag(const BOOL bIsModified)

Flag the canvas as modified or unmodified.

BOOL IsDragSource() const

Returns True if OLE drag operation is originating from this canvas.

void SetDragSource(const BOOL bDragSource)

Indicate if OLE drag operation is originating from this canvas.

BOOL IsDragTarget() const

True if OLE drag operation is terminating at (dragging objects over) this canvas.

void SetDragTarget(const BOOL bDragTarget)

Indicate if OLE drag operation is terminating at (dragging objects over) this canvas.

CSize GetCanvasSize() const

Returns the size of the canvas in logical units.

VIEWS_API CSize SetCanvasSize(const CSize& szCanvas)

Sets the size of the canvas in logical units.

CPoint GetCanvasOrigin() const

Gets the origin of the canvas in logical units.

VIEWS_API CPoint SetCanvasOrigin(const CPoint& ptCanvasOrg)

Sets the origin of the canvas in logical units.

COLORREF GetBkgndColor() const

Gets the background color of the canvas.

VIEWS_API void SetBkgndColor(const COLORREF crBkgndColor)

Sets the background color of the canvas.

virtual CODComponent* GetBkgndComponent() const

Gets the background component of the canvas.

VIEWS_API void SetBkgndComponent(CODComponent* pBkgndComponent, BOOL bRefCount=FALSE)

Sets the background component of the canvas.

CODPageSettings& GetPageSettings()

Return reference to the page settings object

VIEWS_API void GetPageSetupDlg(PAGESETUPDLG& pageSetupDlg)

Get page setup information

VIEWS_API void SetPageSetupDlg(const PAGESETUPDLG& pageSetupDlg)

Put page setup information

VIEWS_API void GetPrintInfo(CPrintInfo* pInfo)

Gets the printing information.

VIEWS_API void UpdatePageSettingUnits(const OD_UNIT_OF_MEASURE units)

Updates the unit of measurement used for page settings.

VIEWS_API void SetLabelSelect(const BOOL bLabelSelect)

Set a flag that indicates if labels can be individually selected and moved.

virtual CODBspTree* GetBspTree()

Gets the binary space partitioning tree in which to store positional information.

inline CSize GetMagnification() { return m_szMag; }

Get Viewport Magnification.

inline void SetMagnification(const int nPctX, const int nPctY) { m_szMag.cx = nPctX; m_szMag.cy = nPctY; }

Set Viewport Magnification.

Instance IDs

VIEWS_API virtual IODIdGenerator* GetIdGenerator()

Get a pointer to the ID generator interface for this model.

VIEWS_API virtual ODComponentId CreateUniqueID()

Creates a unique ID to register for a component.

VIEWS_API virtual BOOL RegisterID(ODComponentId lID, CODComponent* pComp)

Registers the ID as unique to the component within this model.

VIEWS_API virtual BOOL UnregisterID(ODComponentId lID)

Unregisters an ID as unique

VIEWS_API virtual BOOL UnregisterID(CODComponent* pComp)

Unregisters an ID as unique

VIEWS_API virtual CODComponent* GetComponent(ODComponentId lID)

Gets a component by ID

Operations

Transformation and movement methods

VIEWS_API virtual CPoint SetOrigin(int x, int y)

Set the origin of this component relative to the container and in the container's units

VIEWS_API virtual CPoint OffsetOrigin(int xOff, int yOff)

Offset the origin of this component by specified deltas

VIEWS_API virtual CPoint MoveOrigin(int xOff,int yOff)

Move the origin of this component by specified deltas

VIEWS_API virtual BOOL AppendChild(CODComponent* pChild)

Add a child to the end of the collection

VIEWS_API virtual BOOL InsertChild(CODComponent* pChild, const int nIndex)

Insert a child into the composite at a given position

VIEWS_API virtual BOOL RemoveChild(const int nIndex)

Remove a child from the composite

BOOL RemoveChild(CODComponent* pChild)

Remove a child from the composite

VIEWS_API virtual BOOL AppendChildren(CODComponentSet* pCompSet)

Append a set of child components to the model.

VIEWS_API virtual void OnAddChild(CODComponent* pChild)

Called by the framework when a child is added to this component.

VIEWS_API virtual void OnRemoveChild(CODComponent* pChild)

Called by the framework when a child is removed from this component.

VIEWS_API virtual void InitChildProperties(CODComponent* pChild)

Parent has a chance to initialize properties for new children

VIEWS_API virtual BOOL IsValidLocation(CPoint& ptLoc, CODComponent* pComp)

Test to see if the given component can be moved to the position specified

VIEWS_API virtual BOOL IsValidMove(CODComponentSet& setComponents, int nMoveX, int nMoveY)

Test to see if the given component can be moved by the offset specified

VIEWS_API virtual BOOL FindValidLocation(CODComponentSet& setComponents, int& nLocX, int &nLocY, LPRECT lprcComps=NULL)

Finds a location for the components within the model.

VIEWS_API virtual BOOL FindValidMove(CODComponentSet& setComponents, int& nMoveX, int &nMoveY, LPRECT lprcComps=NULL)

Finds a valid location to move the components within the model.

VIEWS_API virtual BOOL FindValidPoints(LPPOINT lpptStart, LPPOINT lpptPoints, int nCount)

Finds a valid location for a set of points within the model.

VIEWS_API virtual int GetComponentsHit(const CPoint& pt, CODComponentSet& setComponents, int nPadding)

This method is obsolete and should not be used anymore. Instead, use the quicker method GetComponentsContaining.

VIEWS_API virtual int GetComponentsContaining(CODComponentSet* pCompSet, const CPoint point, const int nPadding)

Gets all top level components containing the point passed in.

VIEWS_API virtual int GetComponentsWithin(CODComponentSet* pCompSet, const CRect rect)

Gets all top level components within the rectangle passed in.

VIEWS_API virtual int GetComponentsIntersecting(CODComponentSet* pCompSet, const CRect rect)

Gets all top level components intersecting with the rectangle passed in.

VIEWS_API virtual CODComponent* GetComponentFromFocus(HWND hWndFocus)

Get component with focus.

VIEWS_API virtual CODComponent* GetNextTabStop(const int nTabIndex)

Gets the next component in the tab order after the given tab index.

VIEWS_API virtual CODComponent* GetPrevTabStop(const int nTabIndex)

Gets the previous component in the tab order before the given tab index.

VIEWS_API virtual void MoveComponents(CODComponentSet* pCompSet, int nMoveX, int nMoveY)

Move components by an offset

VIEWS_API virtual void RotateComponents(CODComponentSet* pCompSet, int nAngle, CSize sizeAspectRatio = odg_sizeDefaultAspectRatio)

Rotate components in place

VIEWS_API virtual void ScaleComponents(CODComponentSet* pCompSet, float fScaleX, float fScaleY, OD_CONTROL_POINT nControlPoint)

Scale components in relation to a control point

VIEWS_API virtual void AlignComponents(CODComponentSet* pCompSet, OD_ALIGNMENT nAlignment)

Align the sides of a set of components.

VIEWS_API virtual void OrderComponents(CODComponentSet* pCompSet, OD_ORDER nOrderType)

Change the order of the components on the canvas.

VIEWS_API virtual void SpaceComponentsDown(CODComponentSet* pCompSet, const int nVertSpacing)

Space the components evenly down the canvas.

VIEWS_API virtual void SpaceComponentsDown(CODComponentSet* pCompSet)

Space the components evenly down the canvas.

VIEWS_API virtual void SpaceComponentsAcross(CODComponentSet* pCompSet, const int nHorzSpacing)

Space the components evenly across the canvas.

VIEWS_API virtual void SpaceComponentsAcross(CODComponentSet* pCompSet)

Space the components evenly across the canvas.

VIEWS_API virtual void SetComponentWidth(CODComponentSet* pCompSet, const int nWidth, OD_CONTROL_POINT nControlPoint)

Set the width of a set of components.

VIEWS_API virtual void SetComponentHeight(CODComponentSet* pCompSet, const int nHeight, OD_CONTROL_POINT nControlPoint)

Set the height of a set of components.

VIEWS_API virtual void SetComponentSize(CODComponentSet* pCompSet, const CSize& szBounds, OD_CONTROL_POINT nControlPoint)

Set the size of a set of components.

VIEWS_API virtual void GroupComponents(CODComponentSet* pCompSet, CODComponent* pGroup, int nIndex = -1)

Group a set of components together in one composite component.

VIEWS_API virtual void UngroupComponent(CODComponent* pGroup, CODIndexMap* pIndexMap = NULL)

Ungroup composite components into their subcomponents.

VIEWS_API virtual void InsertVertex(CODComponentSet* pCompSet, int nVertexIndex, CPoint ptVertex)

Insert a vertex into a set of CODPointComponent-derived components

VIEWS_API virtual void DeleteVertex(CODComponentSet* pCompSet, int nVertexIndex)

Deletes a vertex from a set of CODPointComponent-derived components

VIEWS_API virtual void MoveVertex(CODComponentSet* pCompSet, int nVertexIndex, int nOffsetX, int nOffsetY)

Moves a vertex into a set of CODPointComponent-derived components

VIEWS_API virtual void ChangeProperty(CODComponentSet* pCompSet, CODProperty* pProperty, DWORD dwChangeFlags = OD_CHANGE_ALL)

Changes the provided property amongst the set of provided components

VIEWS_API virtual void ChangeName(CODComponent* pComp, CString strName)

Change the name of a component.

VIEWS_API virtual void ChangeText(CODComponentSet* pCompSet, const LPCTSTR lpszText)

Change the text of a component.

VIEWS_API virtual void ChangeLineColor(CODComponentSet* pCompSet, COLORREF crLineColor)

Change the line color of a component.

VIEWS_API virtual void ChangeLineWidth(CODComponentSet* pCompSet, int nLineWidth)

Change the line width of a component.

VIEWS_API virtual void ChangeLineStyle(CODComponentSet* pCompSet, int nLineStyle)

Change the line style of a component.

VIEWS_API virtual void ChangeFillColor(CODComponentSet* pCompSet, COLORREF crFillColor)

Change the fill color of the provided set of components

VIEWS_API virtual void ChangeFillStyle(CODComponentSet* pCompSet, int nFillStyle)

Change the fill style of the provided set of components

VIEWS_API virtual void ChangeFillHatch(CODComponentSet* pCompSet, int nFillHatch)

Change the fill hatch of the provided set of components

VIEWS_API virtual void ChangeFillPattern(CODComponentSet* pCompSet, sfl::SECDib* pPattern)

Change the fill pattern of the provided set of components

VIEWS_API virtual void ChangeFontFaceName(CODComponentSet* pCompSet, LPCTSTR lpszFontFaceName)

Change the font of the provided set of components

VIEWS_API virtual void ChangeFontPointSize(CODComponentSet* pCompSet, int nPointSize)

Change the font point size of the provided set of components

VIEWS_API virtual void ChangeFontColor(CODComponentSet* pCompSet, COLORREF crFontColor)

Change the font color of the provided set of components

VIEWS_API virtual void ChangeFontWeight(CODComponentSet* pCompSet, int nFontWeight)

Change the font weight of the provided set of components

VIEWS_API virtual void ChangeFontItalic(CODComponentSet* pCompSet, BOOL bFontItalic)

Change the font italic attribute of the provided set of components

VIEWS_API virtual void ChangeFontUnderline(CODComponentSet* pCompSet, BOOL bFontUnderline)

Change the font underline attribute of the provided set of components

VIEWS_API virtual void ChangeFontStrikeout(CODComponentSet* pCompSet, BOOL bFontStrikeout)

Change the font strikeout attribute of the provided set of components

Graph navigation

VIEWS_API virtual IODNode* GetNode(const ODComponentId nodeId)

Get an interface pointer to the given node.

VIEWS_API virtual IODEdge* GetEdge(const ODComponentId edgeId)

Get an interface pointer to the given edge.

Implementation

VIEWS_API void UpdateComponent(CODComponent* pComp, int nType = OD_UPDATE_CURRENT_POS)

Updates component region amongst all canvas model observers

VIEWS_API void UpdateComponents(CODComponentSet* pCompSet, int nType = OD_UPDATE_CURRENT_POS)

Updates regions of components in provided component set amongst all canvas model observers

virtual void PushTransform()

Push this component's transform onto the transform stack

virtual void PopTransform()

Pop the transform stack.

VIEWS_API virtual void CalculateRgn(CODRgn* pRgn)

Calculates a region based on the model's clipping rectangle

virtual void OnChildRgnUpdate(CODComponent* pComp)

Callback used to notify a parent that a child region has changed.

VIEWS_API virtual void OnPropertyChange(const CODProperty& prop)

Called when a property is changed.

VIEWS_API virtual void Serialize(CArchive& ar)

Serialize the model.

VIEWS_API virtual ULONG STDMETHODCALLTYPE AddRef()

Add a reference to this object.

VIEWS_API virtual ULONG STDMETHODCALLTYPE Release()

Release a reference to this object.