wxShapeFramework  1.13.0 beta
wxSFDiagramManager Class Reference

Class encapsulating framework's data layer. Its functions are responsible for managing shape objects and their serialialization/deserialization. Presentation layer is provided by wxSFShapeCanvas class which tightly cooperates with the shape manager. More...

#include <DiagramManager.h>

Inheritance diagram for wxSFDiagramManager:
Collaboration diagram for wxSFDiagramManager:

List of all members.

Public Types

enum  SEARCHMODE { searchSELECTED, searchUNSELECTED, searchBOTH }
 Search mode flags for GetShapeAtPosition function. More...

Public Member Functions

 XS_DECLARE_CLONABLE_CLASS (wxSFDiagramManager)
 wxSFDiagramManager ()
 Constructor.
 wxSFDiagramManager (const wxSFDiagramManager &obj)
 Copy constructor.
virtual ~wxSFDiagramManager ()
 Destructor.
const wxString & GetVersion () const
 Get wxShapeFramework version number.
wxSFShapeBaseCreateConnection (long srcId, long trgId, bool saveState=true, wxSF::ERRCODE *err=NULL)
 Create new direct connection between two shapes.
wxSFShapeBaseCreateConnection (long srcId, long trgId, wxClassInfo *lineInfo, bool saveState=true, wxSF::ERRCODE *err=NULL)
 Create new direct connection of given type between two shapes.
wxSFShapeBaseCreateConnection (long srcId, long trgId, wxSFLineShape *line, bool saveState=true, wxSF::ERRCODE *err=NULL)
 Create new direct connection of given type between two shapes.
wxSFShapeBaseAddShape (wxClassInfo *shapeInfo, bool saveState=true, wxSF::ERRCODE *err=NULL)
 Create new shape and add it to the shape canvas.
wxSFShapeBaseAddShape (wxClassInfo *shapeInfo, const wxPoint &pos, bool saveState=true, wxSF::ERRCODE *err=NULL)
 Create new shape and add it to the shape canvas.
wxSFShapeBaseAddShape (wxSFShapeBase *shape, xsSerializable *parent, const wxPoint &pos, bool initialize, bool saveState=true, wxSF::ERRCODE *err=NULL)
 Add an existing shape to the canvas.
void RemoveShape (wxSFShapeBase *shape, bool refresh=true)
 Remove given shape from the shape canvas. The shape object will be deleted as well.
void RemoveShapes (const ShapeList &selection)
 Remove shapes from the shape canvas.
void Clear ()
 Remove all shapes from canvas.
void MoveShapesFromNegatives ()
 Move all shapes so none of it will be located in negative position.
void UpdateAll ()
 Update all shapes in the diagram manager.
virtual bool SerializeToXml (const wxString &file, bool withroot=false)
 Serialize complete shape canvas to given file.
virtual bool DeserializeFromXml (const wxString &file)
 Deserialize complete shape canvas from given file.
virtual bool SerializeToXml (wxOutputStream &outstream, bool withroot=false)
 Serialize complete shape canvas to given output stream.
virtual bool DeserializeFromXml (wxInputStream &instream)
 Deserialize complete shape canvas from given input stream.
virtual void DeserializeObjects (xsSerializable *parent, wxXmlNode *node)
 Deserialize shapes from XML and assign them to given parent.
void AcceptShape (const wxString &type)
 Add given shape type to an acceptance list. The acceptance list contains class names of the shapes which can be inserted into this instance of shapes canvas. Note: Keyword 'All' behaves like any class name.
bool IsShapeAccepted (const wxString &type)
 Tells whether the given shape type is accepted by this canvas instance (it means whether this shape can be inserted into it).
void ClearAcceptedShapes ()
 Clear shape object acceptance list.
wxArrayString & GetAcceptedShapes ()
 Get reference to shape acceptance list.
void AcceptTopShape (const wxString &type)
 Add given shape type to list of accepted top shapes. The acceptance list contains class names of the shapes which can be inserted into this instance of shapes canvas as a shape without any parent (i.e. shape placed directly onto the canvas). Note: Keyword 'All' behaves like any class name.
bool IsTopShapeAccepted (const wxString &type)
 Tells whether the given shape type is accepted by this canvas instance as a top shape (it means whether this shape can be inserted directly into it without any parent).
void ClearAcceptedTopShapes ()
 Clear top shapes acceptance list.
wxArrayString & GetAcceptedTopShapes ()
 Get reference to top shapes acceptance list.
wxSFShapeBaseFindShape (long id)
 Find shape with given ID.
void GetAssignedConnections (wxSFShapeBase *parent, wxClassInfo *shapeInfo, wxSFShapeBase::CONNECTMODE mode, ShapeList &lines)
 Get list of connections assigned to given parent shape.
void GetShapes (wxClassInfo *shapeInfo, ShapeList &shapes, xsSerializable::SEARCHMODE mode=xsSerializable::searchBFS)
 Get list of shapes of given type.
wxSFShapeBaseGetShapeAtPosition (const wxPoint &pos, int zorder=1, SEARCHMODE mode=searchBOTH)
 Get shape at given logical position.
void GetShapesAtPosition (const wxPoint &pos, ShapeList &shapes)
 Get list of all shapes located at given position.
void GetShapesInside (const wxRect &rct, ShapeList &shapes)
 Get list of shapes located inside given rectangle.
bool IsEmpty () const
 Determines whether the diagram manager contains some shapes.
bool HasChildren (wxSFShapeBase *parent)
 Function finds out whether given shape has some children.
void GetNeighbours (wxSFShapeBase *parent, ShapeList &neighbours, wxClassInfo *shapeInfo, wxSFShapeBase::CONNECTMODE condir, bool direct=true)
 Get neighbour shapes connected to given parent shape.
bool IsModified ()
 Get information about managed diagram's modification.
void SetModified (bool state)
 Set diagram's modification flag manually.
void SetShapeCanvas (wxSFShapeCanvas *canvas)
 Set associated shape canvas.
wxSFShapeCanvasGetShapeCanvas ()
 Get associated shape canvas.

Protected Attributes

wxArrayString m_arrAcceptedShapes
 List of accepted shape types.
wxArrayString m_arrAcceptedTopShapes
 List of accepted top shape types.
wxSFShapeCanvasm_pShapeCanvas

Private Member Functions

void UpdateConnections ()
 Update connection shapes after importing/dropping of new shapes.
void UpdateGrids ()
 Update grid shapes after importing/dropping of new shapes.
void _DeserializeObjects (xsSerializable *parent, wxXmlNode *node)
 Deserialize shapes from XML and assign them to given parent.

Private Attributes

IDList m_lstIDPairs
 Auxiliary list.
ShapeList m_lstLinesForUpdate
 Auxiliary list.
ShapeList m_lstGridsForUpdate
 Auxiliary list.
wxString m_sSFVersion
 wxSF version number
bool m_fIsModified

Detailed Description

Class encapsulating framework's data layer. Its functions are responsible for managing shape objects and their serialialization/deserialization. Presentation layer is provided by wxSFShapeCanvas class which tightly cooperates with the shape manager.

An application using wxSF must have at least one shape manager object (one for each diagram) and every shape manager can be assigned as a source to one shape canvas (and vice versa).


Member Enumeration Documentation

Search mode flags for GetShapeAtPosition function.

Enumerator:
searchSELECTED 

Search for selected shapes only.

searchUNSELECTED 

Search for unselected shapes only.

searchBOTH 

Search for both selected and unselected shapes.


Constructor & Destructor Documentation

Copy constructor.

Destructor.


Member Function Documentation

void wxSFDiagramManager::_DeserializeObjects ( xsSerializable parent,
wxXmlNode *  node 
) [private]

Deserialize shapes from XML and assign them to given parent.

Parameters:
parentParent shapes
nodeSource XML node
void wxSFDiagramManager::AcceptShape ( const wxString &  type)

Add given shape type to an acceptance list. The acceptance list contains class names of the shapes which can be inserted into this instance of shapes canvas. Note: Keyword 'All' behaves like any class name.

Parameters:
typeClass name of accepted shape object
See also:
IsShapeAccepted
void wxSFDiagramManager::AcceptTopShape ( const wxString &  type)

Add given shape type to list of accepted top shapes. The acceptance list contains class names of the shapes which can be inserted into this instance of shapes canvas as a shape without any parent (i.e. shape placed directly onto the canvas). Note: Keyword 'All' behaves like any class name.

Parameters:
typeClass name of accepted shape object
See also:
IstopShapeAccepted
wxSFShapeBase* wxSFDiagramManager::AddShape ( wxClassInfo *  shapeInfo,
bool  saveState = true,
wxSF::ERRCODE err = NULL 
)

Create new shape and add it to the shape canvas.

Parameters:
shapeInfoShape type
saveStateSet the parameter TRUE if you wish to save canvas state after the operation
errPointer to variable where operation result will be stored. Can be NULL.
Returns:
Pointer to new shape object. The object is added to the shape canvas automaticaly.
wxSFShapeBase* wxSFDiagramManager::AddShape ( wxClassInfo *  shapeInfo,
const wxPoint &  pos,
bool  saveState = true,
wxSF::ERRCODE err = NULL 
)

Create new shape and add it to the shape canvas.

Parameters:
shapeInfoShape type
posShape position
saveStateSet the parameter TRUE if you wish to save canvas state after the operation
errPointer to variable where operation result will be stored. Can be NULL.
Returns:
Description
See also:
Seealso
wxSFShapeBase* wxSFDiagramManager::AddShape ( wxSFShapeBase shape,
xsSerializable parent,
const wxPoint &  pos,
bool  initialize,
bool  saveState = true,
wxSF::ERRCODE err = NULL 
)

Add an existing shape to the canvas.

Parameters:
shapePointer to the shape
parentPointer to the parent shape
posPosition
initializeTRUE if the shape should be reinitilialized, otherwise FALSE
saveStateTRUE if the canvas state should be saved
errPointer to variable where operation result will be stored. Can be NULL.
Returns:
Pointer to the shape

Remove all shapes from canvas.

Clear shape object acceptance list.

See also:
AcceptShape

Clear top shapes acceptance list.

See also:
AcceptShape
wxSFShapeBase* wxSFDiagramManager::CreateConnection ( long  srcId,
long  trgId,
bool  saveState = true,
wxSF::ERRCODE err = NULL 
)

Create new direct connection between two shapes.

This function creates new simple connection line (without arrows) between gived shapes.

Parameters:
srcIdID of a source shape
trgIdID of target shape
saveStateSet the parameter TRUE if you wish to save canvas state after the operation
errPointer to variable where operation result will be stored. Can be NULL.
Returns:
Pointer to new connection object. The object is added to the shape canvas automaticaly.
See also:
StartInteractiveConnection
wxSFShapeBase* wxSFDiagramManager::CreateConnection ( long  srcId,
long  trgId,
wxClassInfo *  lineInfo,
bool  saveState = true,
wxSF::ERRCODE err = NULL 
)

Create new direct connection of given type between two shapes.

This function creates new simple connection line (without arrows) between gived shapes.

Parameters:
srcIdID of a source shape
trgIdID of target shape
lineInfoConnection type (any class inherited from wxSFLineShape)
saveStateSet the parameter TRUE if you wish to save canvas state after the operation
errPointer to variable where operation result will be stored. Can be NULL.
Returns:
Pointer to new connection object. The object is added to the shape canvas automaticaly.
See also:
StartInteractiveConnection
wxSFShapeBase* wxSFDiagramManager::CreateConnection ( long  srcId,
long  trgId,
wxSFLineShape line,
bool  saveState = true,
wxSF::ERRCODE err = NULL 
)

Create new direct connection of given type between two shapes.

This function creates new simple connection line (without arrows) between gived shapes.

Parameters:
srcIdID of a source shape
trgIdID of target shape
linePointer to line shape
saveStateSet the parameter TRUE if you wish to save canvas state after the operation
errPointer to variable where operation result will be stored. Can be NULL.
Returns:
Pointer to new connection object. The object is added to the shape canvas automaticaly.
See also:
StartInteractiveConnection
virtual bool wxSFDiagramManager::DeserializeFromXml ( const wxString &  file) [virtual]

Deserialize complete shape canvas from given file.

Parameters:
fileInput file
Returns:
TRUE on success, otherwise FALSE

Reimplemented from wxXmlSerializer.

virtual bool wxSFDiagramManager::DeserializeFromXml ( wxInputStream &  instream) [virtual]

Deserialize complete shape canvas from given input stream.

Parameters:
instreamInput stream
Returns:
TRUE on success, otherwise FALSE

Reimplemented from wxXmlSerializer.

virtual void wxSFDiagramManager::DeserializeObjects ( xsSerializable parent,
wxXmlNode *  node 
) [virtual]

Deserialize shapes from XML and assign them to given parent.

The parent can be NULL (in that case topmost shapes will have no parent assigned).

Parameters:
parentParent shapes
nodeSource XML node

Reimplemented from wxXmlSerializer.

Find shape with given ID.

Parameters:
idShape's ID
Returns:
Pointer to shape if exists, otherwise NULL
wxArrayString& wxSFDiagramManager::GetAcceptedShapes ( ) [inline]

Get reference to shape acceptance list.

wxArrayString& wxSFDiagramManager::GetAcceptedTopShapes ( ) [inline]

Get reference to top shapes acceptance list.

void wxSFDiagramManager::GetAssignedConnections ( wxSFShapeBase parent,
wxClassInfo *  shapeInfo,
wxSFShapeBase::CONNECTMODE  mode,
ShapeList &  lines 
)

Get list of connections assigned to given parent shape.

Parameters:
parentPointer to parent shape
shapeInfoLine object type
modeSearch mode
linesReference to shape list where pointers to all found connections will be stored
See also:
wxSFShapeBase::CONNECTMODE
void wxSFDiagramManager::GetNeighbours ( wxSFShapeBase parent,
ShapeList &  neighbours,
wxClassInfo *  shapeInfo,
wxSFShapeBase::CONNECTMODE  condir,
bool  direct = true 
)

Get neighbour shapes connected to given parent shape.

Parameters:
parentPointer to parent shape (can be NULL for all topmost shapes)
neighboursList of neighbour shapes
shapeInfoLine object type
condirConnection direction
directSet this flag to TRUE if only closest shapes should be found, otherwise also shapes connected by forked lines will be found (also constants sfDIRECT and sfINDIRECT can be used)
See also:
wxSFShapeBase::CONNECTMODE
wxSFShapeBase* wxSFDiagramManager::GetShapeAtPosition ( const wxPoint &  pos,
int  zorder = 1,
SEARCHMODE  mode = searchBOTH 
)

Get shape at given logical position.

Parameters:
posLogical position
zorderZ-order of searched shape (usefull if several shapes are located at the given position)
modeSearch mode
Returns:
Pointer to shape if found, otherwise NULL
See also:
SEARCHMODE, wxSFShapeCanvas::DP2LP,, wxSFShapeCanvas::GetShapeUnderCursor

Get associated shape canvas.

Returns:
Pointer to shape canvas
void wxSFDiagramManager::GetShapes ( wxClassInfo *  shapeInfo,
ShapeList &  shapes,
xsSerializable::SEARCHMODE  mode = xsSerializable::searchBFS 
)

Get list of shapes of given type.

Parameters:
shapeInfoShape object type
shapesReference to shape list where pointers to all found shapes will be stored
modeSearch algorithm
See also:
xsSerializable::SEARCHMODE
void wxSFDiagramManager::GetShapesAtPosition ( const wxPoint &  pos,
ShapeList &  shapes 
)

Get list of all shapes located at given position.

Parameters:
posLogical position
shapesReference to shape list where pointers to all found shapes will be stored
See also:
wxSFShapeCanvas::DP2LP
void wxSFDiagramManager::GetShapesInside ( const wxRect &  rct,
ShapeList &  shapes 
)

Get list of shapes located inside given rectangle.

Parameters:
rctExamined rectangle
shapesReference to shape list where pointers to all found shapes will be stored
const wxString& wxSFDiagramManager::GetVersion ( ) const [inline]

Get wxShapeFramework version number.

Function finds out whether given shape has some children.

Parameters:
parentPointer to potential parent shape
Returns:
TRUE if the parent shape has children, otherwise FALSE
bool wxSFDiagramManager::IsEmpty ( ) const [inline]

Determines whether the diagram manager contains some shapes.

Returns:
TRUE if there are no shapes in the manager, otherwise FALSE
bool wxSFDiagramManager::IsModified ( ) [inline]

Get information about managed diagram's modification.

The function returns TRUE if the diagram has been modified and its content should be saved. The modification flag is cleared when the content is saved.

Returns:
TRUE if managed diagram is modified, othwerwise FALSE.
bool wxSFDiagramManager::IsShapeAccepted ( const wxString &  type)

Tells whether the given shape type is accepted by this canvas instance (it means whether this shape can be inserted into it).

The function is typically used by the framework for determination whether class type supplied by AddShape() function can be inserted into shape canvas.

Parameters:
typeClass name of examined shape object
Returns:
TRUE if the shape type is accepted, otherwise FALSE.
bool wxSFDiagramManager::IsTopShapeAccepted ( const wxString &  type)

Tells whether the given shape type is accepted by this canvas instance as a top shape (it means whether this shape can be inserted directly into it without any parent).

The function is typically used by the framework for determination whether class type supplied by AddShape() function can be inserted direclty onto shape canvas.

Parameters:
typeClass name of examined shape object
Returns:
TRUE if the shape type is accepted, otherwise FALSE.

Move all shapes so none of it will be located in negative position.

void wxSFDiagramManager::RemoveShape ( wxSFShapeBase shape,
bool  refresh = true 
)

Remove given shape from the shape canvas. The shape object will be deleted as well.

Parameters:
shapePointer to shape object should be deleted
refreshSet the paramater to TRUE if you wish to repaint the canvas
void wxSFDiagramManager::RemoveShapes ( const ShapeList &  selection)

Remove shapes from the shape canvas.

Parameters:
selectionList of shapes which should be removed from the canvas
virtual bool wxSFDiagramManager::SerializeToXml ( const wxString &  file,
bool  withroot = false 
) [virtual]

Serialize complete shape canvas to given file.

Parameters:
fileOutput file
withrootIf TRUE then the root item's properties are serialized as well
Returns:
TRUE on success, otherwise FALSE

Reimplemented from wxXmlSerializer.

virtual bool wxSFDiagramManager::SerializeToXml ( wxOutputStream &  outstream,
bool  withroot = false 
) [virtual]

Serialize complete shape canvas to given output stream.

Parameters:
outstreamOutput stream
withrootIf TRUE then the root item's properties are serialized as well
Returns:
TRUE on success, otherwise FALSE

Reimplemented from wxXmlSerializer.

void wxSFDiagramManager::SetModified ( bool  state) [inline]

Set diagram's modification flag manually.

Parameters:
stateState of diagram's modification flag.

Set associated shape canvas.

Parameters:
canvasPointer to shape canvas

Update all shapes in the diagram manager.

Update connection shapes after importing/dropping of new shapes.

void wxSFDiagramManager::UpdateGrids ( ) [private]

Update grid shapes after importing/dropping of new shapes.


Member Data Documentation

wxArrayString wxSFDiagramManager::m_arrAcceptedShapes [protected]

List of accepted shape types.

wxArrayString wxSFDiagramManager::m_arrAcceptedTopShapes [protected]

List of accepted top shape types.

Auxiliary list.

Auxiliary list.

Auxiliary list.

wxSF version number


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines