wxShapeFramework
1.13.0 beta
|
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>
Public Types | |
enum | SEARCHMODE { searchSELECTED , searchUNSELECTED , searchBOTH } |
Search mode flags for GetShapeAtPosition function. More... | |
Public Member Functions | |
XS_DECLARE_CLONABLE_CLASS (wxSFDiagramManager) | |
wxSFDiagramManager () | |
Constructor. More... | |
wxSFDiagramManager (const wxSFDiagramManager &obj) | |
Copy constructor. More... | |
virtual | ~wxSFDiagramManager () |
Destructor. More... | |
const wxString & | GetVersion () const |
Get wxShapeFramework version number. More... | |
wxSFShapeBase * | CreateConnection (long srcId, long trgId, bool saveState=true, wxSF::ERRCODE *err=NULL) |
Create new direct connection between two shapes. More... | |
wxSFShapeBase * | CreateConnection (long srcId, long trgId, wxClassInfo *lineInfo, bool saveState=true, wxSF::ERRCODE *err=NULL) |
Create new direct connection of given type between two shapes. More... | |
wxSFShapeBase * | CreateConnection (long srcId, long trgId, wxSFLineShape *line, bool saveState=true, wxSF::ERRCODE *err=NULL) |
Create new direct connection of given type between two shapes. More... | |
wxSFShapeBase * | AddShape (wxClassInfo *shapeInfo, bool saveState=true, wxSF::ERRCODE *err=NULL) |
Create new shape and add it to the shape canvas. More... | |
wxSFShapeBase * | AddShape (wxClassInfo *shapeInfo, const wxPoint &pos, bool saveState=true, wxSF::ERRCODE *err=NULL) |
Create new shape and add it to the shape canvas. More... | |
wxSFShapeBase * | AddShape (wxSFShapeBase *shape, xsSerializable *parent, const wxPoint &pos, bool initialize, bool saveState=true, wxSF::ERRCODE *err=NULL) |
Add an existing shape to the canvas. More... | |
void | RemoveShape (wxSFShapeBase *shape, bool refresh=true) |
Remove given shape from the shape canvas. The shape object will be deleted as well. More... | |
void | RemoveShapes (const ShapeList &selection) |
Remove shapes from the shape canvas. More... | |
void | Clear () |
Remove all shapes from canvas. More... | |
void | MoveShapesFromNegatives () |
Move all shapes so none of it will be located in negative position. More... | |
void | UpdateAll () |
Update all shapes in the diagram manager. More... | |
virtual bool | SerializeToXml (const wxString &file, bool withroot=false) |
Serialize complete shape canvas to given file. More... | |
virtual bool | DeserializeFromXml (const wxString &file) |
Deserialize complete shape canvas from given file. More... | |
virtual bool | SerializeToXml (wxOutputStream &outstream, bool withroot=false) |
Serialize complete shape canvas to given output stream. More... | |
virtual bool | DeserializeFromXml (wxInputStream &instream) |
Deserialize complete shape canvas from given input stream. More... | |
virtual void | DeserializeObjects (xsSerializable *parent, wxXmlNode *node) |
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. More... | |
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). More... | |
void | ClearAcceptedShapes () |
Clear shape object acceptance list. More... | |
wxArrayString & | GetAcceptedShapes () |
Get reference to shape acceptance list. More... | |
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. More... | |
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). More... | |
void | ClearAcceptedTopShapes () |
Clear top shapes acceptance list. More... | |
wxArrayString & | GetAcceptedTopShapes () |
Get reference to top shapes acceptance list. More... | |
wxSFShapeBase * | FindShape (long id) |
Find shape with given ID. More... | |
void | GetAssignedConnections (wxSFShapeBase *parent, wxClassInfo *shapeInfo, wxSFShapeBase::CONNECTMODE mode, ShapeList &lines) |
Get list of connections assigned to given parent shape. More... | |
void | GetShapes (wxClassInfo *shapeInfo, ShapeList &shapes, xsSerializable::SEARCHMODE mode=xsSerializable::searchBFS) |
Get list of shapes of given type. More... | |
wxSFShapeBase * | GetShapeAtPosition (const wxPoint &pos, int zorder=1, SEARCHMODE mode=searchBOTH) |
Get shape at given logical position. More... | |
void | GetShapesAtPosition (const wxPoint &pos, ShapeList &shapes) |
Get list of all shapes located at given position. More... | |
void | GetShapesInside (const wxRect &rct, ShapeList &shapes) |
Get list of shapes located inside given rectangle. More... | |
bool | IsEmpty () const |
Determines whether the diagram manager contains some shapes. More... | |
bool | HasChildren (wxSFShapeBase *parent) |
Function finds out whether given shape has some children. More... | |
void | GetNeighbours (wxSFShapeBase *parent, ShapeList &neighbours, wxClassInfo *shapeInfo, wxSFShapeBase::CONNECTMODE condir, bool direct=true) |
Get neighbour shapes connected to given parent shape. More... | |
bool | IsModified () |
Get information about managed diagram's modification. More... | |
void | SetModified (bool state) |
Set diagram's modification flag manually. More... | |
void | SetShapeCanvas (wxSFShapeCanvas *canvas) |
Set associated shape canvas. More... | |
wxSFShapeCanvas * | GetShapeCanvas () |
Get associated shape canvas. More... | |
![]() | |
XS_DECLARE_CLONABLE_CLASS (wxXmlSerializer) | |
wxXmlSerializer () | |
Constructor. More... | |
wxXmlSerializer (const wxString &owner, const wxString &root, const wxString &version) | |
User constructor. More... | |
wxXmlSerializer (const wxXmlSerializer &obj) | |
Copy constructor. More... | |
virtual | ~wxXmlSerializer () |
Destructor. More... | |
void | SetSerializerOwner (const wxString &name) |
Set owner name. More... | |
void | SetSerializerRootName (const wxString &name) |
Set root name. More... | |
void | SetSerializerVersion (const wxString &name) |
Set file version. More... | |
const wxString & | GetSerializerOwner () const |
Get owner name. More... | |
const wxString & | GetSerializerRootName () const |
Get name of root node. More... | |
const wxString & | GetSerializerVersion () const |
Get file version. More... | |
const wxString & | GetLibraryVersion () const |
Get the library version. More... | |
const wxString & | GetErrMessage () const |
Get last occured error state/message. More... | |
xsSerializable * | GetRootItem () const |
Get pointer to root serializable object. More... | |
xsSerializable * | GetItem (long id) |
Get serializable object with given ID. More... | |
void | GetItems (wxClassInfo *type, SerializableList &list, xsSerializable::SEARCHMODE mode=xsSerializable::searchBFS) |
Get items of given class type. More... | |
bool | Contains (xsSerializable *object) const |
Check whether given object is included in the serializer. More... | |
bool | Contains (wxClassInfo *type) |
Check whether any object of given type is included in the serializer. More... | |
void | SetRootItem (xsSerializable *root) |
Set root item. More... | |
void | CopyItems (const wxXmlSerializer &src) |
Replace current stored data with a content stored in given source manager. More... | |
xsSerializable * | AddItem (long parentId, xsSerializable *item) |
Add serializable object to the serializer. More... | |
xsSerializable * | AddItem (xsSerializable *parent, xsSerializable *item) |
Add serializable object to the serializer. More... | |
void | RemoveItem (long id) |
Remove serializable object from the serializer (object will be destroyed). More... | |
void | RemoveItem (xsSerializable *item) |
Remove serializable object from the serializer (object will be destroyed). More... | |
void | RemoveAll () |
Remove and destroy all stored serializable objects. More... | |
void | EnableCloning (bool enab) |
Enable/disable object cloning. More... | |
bool | IsCloned () const |
Returns information whether the object can be cloned or not. More... | |
virtual void | SerializeObjects (xsSerializable *parent, wxXmlNode *node, bool withparent) |
Serialize child objects of given parent object (parent object can be optionaly serialized as well) to given XML node. The function can be overriden if necessary. More... | |
long | GetNewId () |
Get the lowest free object ID. More... | |
bool | IsIdUsed (long id) |
Find out whether given object ID is already used. More... | |
int | GetIDCount (long id) |
Get number of occurences of given ID. More... | |
IDMap & | GetUsedIDs () |
Get map of used IDs. More... | |
void | InitializeAllIOHandlers () |
Initialize all standard property IO handlers. More... | |
void | ClearIOHandlers () |
Clear all initialized property IO handlers. More... | |
wxXmlSerializer & | operator<< (xsSerializable *obj) |
Add serializable object to the serializer's root node. More... | |
wxXmlSerializer & | operator<< (SerializableList &src) |
Add serializable objects stored in source serializable list to the serializer's root node. More... | |
void | operator>> (SerializableList &dest) |
Get all items managed by the serializer (note that the items will be stored in given target list in a row regardless their original hierarchy). More... | |
Protected Attributes | |
wxArrayString | m_arrAcceptedShapes |
List of accepted shape types. More... | |
wxArrayString | m_arrAcceptedTopShapes |
List of accepted top shape types. More... | |
wxSFShapeCanvas * | m_pShapeCanvas |
![]() | |
wxString | m_sOwner |
Owner name. More... | |
wxString | m_sRootName |
Root node name. More... | |
wxString | m_sVersion |
File version. More... | |
wxString | m_sErr |
Error message. More... | |
xsSerializable * | m_pRoot |
Pointer to root object. More... | |
bool | m_fClone |
Object cloning flag. More... | |
IDMap | m_mapUsedIDs |
Map storing information which ID is already used. More... | |
Private Member Functions | |
void | UpdateConnections () |
Update connection shapes after importing/dropping of new shapes. More... | |
void | UpdateGrids () |
Update grid shapes after importing/dropping of new shapes. More... | |
void | _DeserializeObjects (xsSerializable *parent, wxXmlNode *node) |
Deserialize shapes from XML and assign them to given parent. More... | |
Private Attributes | |
IDList | m_lstIDPairs |
Auxiliary list. More... | |
ShapeList | m_lstLinesForUpdate |
Auxiliary list. More... | |
ShapeList | m_lstGridsForUpdate |
Auxiliary list. More... | |
wxString | m_sSFVersion |
wxSF version number More... | |
bool | m_fIsModified |
Additional Inherited Members | |
![]() | |
static xsPropertyIO * | GetPropertyIOHandler (const wxString &datatype) |
Get property I/O handler for given datatype. More... | |
![]() | |
static PropertyIOMap | m_mapPropertyIOHandlers |
Map of property IO handlers. More... | |
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).
wxSFDiagramManager::wxSFDiagramManager | ( | ) |
Constructor.
wxSFDiagramManager::wxSFDiagramManager | ( | const wxSFDiagramManager & | obj | ) |
Copy constructor.
|
virtual |
Destructor.
|
private |
Deserialize shapes from XML and assign them to given parent.
parent | Parent shapes |
node | Source 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.
type | Class name of accepted shape object |
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.
type | Class name of accepted shape object |
wxSFShapeBase* wxSFDiagramManager::AddShape | ( | wxClassInfo * | shapeInfo, |
bool | saveState = true , |
||
wxSF::ERRCODE * | err = NULL |
||
) |
Create new shape and add it to the shape canvas.
shapeInfo | Shape type |
saveState | Set the parameter TRUE if you wish to save canvas state after the operation |
err | Pointer to variable where operation result will be stored. Can be NULL. |
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.
shapeInfo | Shape type |
pos | Shape position |
saveState | Set the parameter TRUE if you wish to save canvas state after the operation |
err | Pointer to variable where operation result will be stored. Can be NULL. |
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.
shape | Pointer to the shape |
parent | Pointer to the parent shape |
pos | Position |
initialize | TRUE if the shape should be reinitilialized, otherwise FALSE |
saveState | TRUE if the canvas state should be saved |
err | Pointer to variable where operation result will be stored. Can be NULL. |
void wxSFDiagramManager::Clear | ( | ) |
Remove all shapes from canvas.
|
inline |
Clear shape object acceptance list.
|
inline |
Clear top shapes acceptance list.
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.
srcId | ID of a source shape |
trgId | ID of target shape |
saveState | Set the parameter TRUE if you wish to save canvas state after the operation |
err | Pointer to variable where operation result will be stored. Can be NULL. |
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.
srcId | ID of a source shape |
trgId | ID of target shape |
lineInfo | Connection type (any class inherited from wxSFLineShape) |
saveState | Set the parameter TRUE if you wish to save canvas state after the operation |
err | Pointer to variable where operation result will be stored. Can be NULL. |
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.
srcId | ID of a source shape |
trgId | ID of target shape |
line | Pointer to line shape |
saveState | Set the parameter TRUE if you wish to save canvas state after the operation |
err | Pointer to variable where operation result will be stored. Can be NULL. |
|
virtual |
Deserialize complete shape canvas from given file.
file | Input file |
Reimplemented from wxXmlSerializer.
|
virtual |
Deserialize complete shape canvas from given input stream.
instream | Input stream |
Reimplemented from wxXmlSerializer.
|
virtual |
\brief 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).
parent | Parent shapes |
node | Source XML node |
Reimplemented from wxXmlSerializer.
wxSFShapeBase* wxSFDiagramManager::FindShape | ( | long | id | ) |
Find shape with given ID.
id | Shape's ID |
|
inline |
Get reference to shape acceptance list.
|
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.
parent | Pointer to parent shape |
shapeInfo | Line object type |
mode | Search mode |
lines | Reference to shape list where pointers to all found connections will be stored |
void wxSFDiagramManager::GetNeighbours | ( | wxSFShapeBase * | parent, |
ShapeList & | neighbours, | ||
wxClassInfo * | shapeInfo, | ||
wxSFShapeBase::CONNECTMODE | condir, | ||
bool | direct = true |
||
) |
Get neighbour shapes connected to given parent shape.
parent | Pointer to parent shape (can be NULL for all topmost shapes) |
neighbours | List of neighbour shapes |
shapeInfo | Line object type |
condir | Connection direction |
direct | Set 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) |
wxSFShapeBase* wxSFDiagramManager::GetShapeAtPosition | ( | const wxPoint & | pos, |
int | zorder = 1 , |
||
SEARCHMODE | mode = searchBOTH |
||
) |
Get shape at given logical position.
pos | Logical position |
zorder | Z-order of searched shape (usefull if several shapes are located at the given position) |
mode | Search mode |
|
inline |
Get associated shape canvas.
void wxSFDiagramManager::GetShapes | ( | wxClassInfo * | shapeInfo, |
ShapeList & | shapes, | ||
xsSerializable::SEARCHMODE | mode = xsSerializable::searchBFS |
||
) |
Get list of shapes of given type.
shapeInfo | Shape object type |
shapes | Reference to shape list where pointers to all found shapes will be stored |
mode | Search algorithm |
void wxSFDiagramManager::GetShapesAtPosition | ( | const wxPoint & | pos, |
ShapeList & | shapes | ||
) |
Get list of all shapes located at given position.
pos | Logical position |
shapes | Reference to shape list where pointers to all found shapes will be stored |
void wxSFDiagramManager::GetShapesInside | ( | const wxRect & | rct, |
ShapeList & | shapes | ||
) |
Get list of shapes located inside given rectangle.
rct | Examined rectangle |
shapes | Reference to shape list where pointers to all found shapes will be stored |
|
inline |
Get wxShapeFramework version number.
bool wxSFDiagramManager::HasChildren | ( | wxSFShapeBase * | parent | ) |
Function finds out whether given shape has some children.
parent | Pointer to potential parent shape |
|
inline |
Determines whether the diagram manager contains some shapes.
|
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.
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.
type | Class name of examined shape object |
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.
type | Class name of examined shape object |
void wxSFDiagramManager::MoveShapesFromNegatives | ( | ) |
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.
shape | Pointer to shape object should be deleted |
refresh | Set the paramater to TRUE if you wish to repaint the canvas |
void wxSFDiagramManager::RemoveShapes | ( | const ShapeList & | selection | ) |
Remove shapes from the shape canvas.
selection | List of shapes which should be removed from the canvas |
|
virtual |
Serialize complete shape canvas to given file.
file | Output file |
withroot | If TRUE then the root item's properties are serialized as well |
Reimplemented from wxXmlSerializer.
|
virtual |
Serialize complete shape canvas to given output stream.
outstream | Output stream |
withroot | If TRUE then the root item's properties are serialized as well |
Reimplemented from wxXmlSerializer.
|
inline |
Set diagram's modification flag manually.
state | State of diagram's modification flag. |
|
inline |
Set associated shape canvas.
canvas | Pointer to shape canvas |
void wxSFDiagramManager::UpdateAll | ( | ) |
Update all shapes in the diagram manager.
|
private |
Update connection shapes after importing/dropping of new shapes.
|
private |
Update grid shapes after importing/dropping of new shapes.
wxSFDiagramManager::XS_DECLARE_CLONABLE_CLASS | ( | wxSFDiagramManager | ) |
|
protected |
List of accepted shape types.
|
protected |
List of accepted top shape types.
|
private |
|
private |
Auxiliary list.
|
private |
Auxiliary list.
|
private |
Auxiliary list.
|
protected |
|
private |
wxSF version number