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

 CODModel()

Constructor.

virtual  ~CODModel()

Destructor.

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.

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.

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.

CPoint  SetCanvasOrigin(const CPoint& ptCanvasOrg)

Sets the origin of the canvas in logical units.

COLORREF  GetBkgndColor() const

Gets the background color of the canvas.

void  SetBkgndColor(const COLORREF crBkgndColor)

Sets the background color of the canvas.

virtual CODComponent*  GetBkgndComponent() const

Gets the background component of the canvas.

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

Sets the background component of the canvas.

CODPageSettings&  GetPageSettings()

Return reference to the page settings object

void  GetPageSetupDlg(PAGESETUPDLG& pageSetupDlg)

Get page setup information

void  SetPageSetupDlg(const PAGESETUPDLG& pageSetupDlg)

Put page setup information

void  GetPrintInfo(CPrintInfo* pInfo)

Gets the printing information.

void  UpdatePageSettingUnits(const OD_UNIT_OF_MEASURE units)

Updates the unit of measurement used for page settings.

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.

void  SetNoUndo(BOOL bNoUndo = TRUE)

Disables or enables the Undo functionality.

Instance IDs

virtual IODIdGenerator*  GetIdGenerator()

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

virtual ODComponentId  CreateUniqueID()

Creates a unique ID to register for a component.

virtual BOOL  RegisterID(ODComponentId lID, CODComponent* pComp)

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

virtual BOOL  UnregisterID(ODComponentId lID)

Unregisters an ID as unique

virtual BOOL  UnregisterID(CODComponent* pComp)

Unregisters an ID as unique

virtual CODComponent*  GetComponent(ODComponentId lID)

Gets a component by ID

Operations

Transformation and movement methods

virtual CPoint  SetOrigin(int x, int y)

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

virtual CPoint  OffsetOrigin(int xOff, int yOff)

Offset the origin of this component by specified deltas

virtual CPoint  MoveOrigin(int xOff,int yOff)

Move the origin of this component by specified deltas

virtual BOOL  AppendChild(CODComponent* pChild)

Add a child to the end of the collection

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

Insert a child into the composite at a given position

virtual BOOL  RemoveChild(const int nIndex)

Remove a child from the composite

BOOL  RemoveChild(CODComponent* pChild)

Remove a child from the composite

virtual BOOL  AppendChildren(CODComponentSet* pCompSet)

Append a set of child components to the model.

virtual void  OnAddChild(CODComponent* pChild)

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

virtual void  OnRemoveChild(CODComponent* pChild)

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

virtual void  InitChildProperties(CODComponent* pChild)

Parent has a chance to initialize properties for new children

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

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

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

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

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

Finds a location for the components within the model.

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

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

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

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

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.

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

Gets all top level components containing the point passed in.

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

Gets all top level components within the rectangle passed in.

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

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

virtual CODComponent*  GetComponentFromFocus(HWND hWndFocus)

Get component with focus.

virtual CODComponent*  GetNextTabStop(const int nTabIndex)

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

virtual CODComponent*  GetPrevTabStop(const int nTabIndex)

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

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

Move components by an offset

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

Rotate components in place

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

Scale components in relation to a control point

virtual void  AlignComponents(CODComponentSet* pCompSet, OD_ALIGNMENT nAlignment)

Align the sides of a set of components.

virtual void  OrderComponents(CODComponentSet* pCompSet, OD_ORDER nOrderType)

Change the order of the components on the canvas.

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

Space the components evenly down the canvas.

virtual void  SpaceComponentsDown(CODComponentSet* pCompSet)

Space the components evenly down the canvas.

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

Space the components evenly across the canvas.

virtual void  SpaceComponentsAcross(CODComponentSet* pCompSet)

Space the components evenly across the canvas.

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

Set the width of a set of components.

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

Set the height of a set of components.

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

Set the size of a set of components.

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

Group a set of components together in one composite component.

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

Ungroup composite components into their subcomponents.

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

Insert a vertex into a set of  CODPointComponent-derived components

virtual void  DeleteVertex(CODComponentSet* pCompSet, int nVertexIndex)

Deletes a vertex from a set of  CODPointComponent-derived components

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

Moves a vertex into a set of  CODPointComponent-derived components

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

Changes the provided property amongst the set of provided components

virtual void  ChangeName(CODComponent* pComp, CString strName)

Change the name of a component.

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

Change the text of a component.

virtual void  ChangeLineColor(CODComponentSet* pCompSet, COLORREF crLineColor)

Change the line color of a component.

virtual void  ChangeLineWidth(CODComponentSet* pCompSet, int nLineWidth)

Change the line width of a component.

virtual void  ChangeLineStyle(CODComponentSet* pCompSet, int nLineStyle)

Change the line style of a component.

virtual void  ChangeFillColor(CODComponentSet* pCompSet, COLORREF crFillColor)

Change the fill color of the provided set of components

virtual void  ChangeFillStyle(CODComponentSet* pCompSet, int nFillStyle)

Change the fill style of the provided set of components

virtual void  ChangeFillHatch(CODComponentSet* pCompSet, int nFillHatch)

Change the fill hatch of the provided set of components

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

Change the fill pattern of the provided set of components

virtual void  ChangeFontFaceName(CODComponentSet* pCompSet, LPCTSTR lpszFontFaceName)

Change the font of the provided set of components

virtual void  ChangeFontPointSize(CODComponentSet* pCompSet, int nPointSize)

Change the font point size of the provided set of components

virtual void  ChangeFontColor(CODComponentSet* pCompSet, COLORREF crFontColor)

Change the font color of the provided set of components

virtual void  ChangeFontWeight(CODComponentSet* pCompSet, int nFontWeight)

Change the font weight of the provided set of components

virtual void  ChangeFontItalic(CODComponentSet* pCompSet, BOOL bFontItalic)

Change the font italic attribute of the provided set of components

virtual void  ChangeFontUnderline(CODComponentSet* pCompSet, BOOL bFontUnderline)

Change the font underline attribute of the provided set of components

virtual void  ChangeFontStrikeout(CODComponentSet* pCompSet, BOOL bFontStrikeout)

Change the font strikeout attribute of the provided set of components

Graph navigation

virtual IODNode*  GetNode(const ODComponentId nodeId)

Get an interface pointer to the given node.

virtual IODEdge*  GetEdge(const ODComponentId edgeId)

Get an interface pointer to the given edge.

Implementation

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

Updates component region amongst all canvas model observers

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.

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.

virtual void  OnPropertyChange(const CODProperty& prop)

Called when a property is changed.

virtual void  Serialize(CArchive& ar)

Serialize the model.

virtual ULONG STDMETHODCALLTYPE  AddRef()

Add a reference to this object.

virtual ULONG STDMETHODCALLTYPE  Release()

Release a reference to this object.