The Gnome Chemistry Utils
0.14.0
|
#include <gcu/object.h>
Public Member Functions | |
Object (TypeId Id=OtherType) | |
virtual | ~Object () |
TypeId | GetType () const |
void | SetId (gchar const *Id) |
char const * | GetId () const |
virtual void | AddChild (Object *object) |
Object * | GetMolecule () const |
Object * | GetReaction () const |
Object * | GetGroup () const |
Document * | GetDocument () const |
Application * | GetApplication () const |
Object * | GetParentOfType (TypeId Id) const |
Object * | GetChild (const gchar *Id) const |
Object * | GetFirstChild (std::map< std::string, Object * >::iterator &i) |
Object * | GetNextChild (std::map< std::string, Object * >::iterator &i) |
Object * | GetDescendant (const char *Id) const |
Object * | GetParent () const |
void | SetParent (Object *Parent) |
virtual xmlNodePtr | Save (xmlDocPtr xml) const |
virtual bool | Load (xmlNodePtr node) |
virtual bool | GetCoords (double *x, double *y, double *z=NULL) const |
virtual void | Move (double x, double y, double z=0.) |
virtual void | Transform2D (Matrix2D &m, double x, double y) |
bool | SaveChildren (xmlDocPtr xml, xmlNodePtr node) const |
void | SaveId (xmlNodePtr node) const |
xmlNodePtr | GetNodeByProp (xmlNodePtr node, char const *Property, char const *Id) |
xmlNodePtr | GetNextNodeByProp (xmlNodePtr node, char const *Property, char const *Id) |
xmlNodePtr | GetNodeByName (xmlNodePtr node, char const *Name) |
xmlNodePtr | GetNextNodeByName (xmlNodePtr node, char const *Name) |
bool | HasChildren () const |
unsigned | GetChildrenNumber () const |
virtual Object * | GetAtomAt (double x, double y, double z=0.) |
virtual bool | Build (std::set< Object * > const &Children) throw (std::invalid_argument) |
virtual double | GetYAlign () |
virtual bool | BuildContextualMenu (UIManager *uim, Object *object, double x, double y) |
void | EmitSignal (SignalId Signal) |
virtual bool | OnSignal (SignalId Signal, Object *Child) |
void | Lock (bool state=true) |
bool | IsLocked () |
Object * | GetFirstLink (std::set< Object * >::iterator &i) |
Object * | GetNextLink (std::set< Object * >::iterator &i) |
void | Link (Object *object) |
void | Unlink (Object *object) |
virtual void | OnUnlink (Object *object) |
void | GetPossibleAncestorTypes (std::set< TypeId > &types) const |
virtual bool | SetProperty (unsigned property, char const *value) |
virtual std::string | GetProperty (unsigned property) const |
virtual void | OnLoaded () |
void | SetDirty (bool dirty=true) |
virtual void | Clear () |
virtual std::string | Name () |
std::string | Identity () |
virtual char const * | HasPropertiesDialog () const |
virtual bool | CanSelect () const |
virtual void | NotifyEmpty () |
void | ShowPropertiesDialog () |
bool | GetDirty (void) const |
Static Public Member Functions | |
static TypeId | AddType (std::string TypeName, Object *(*CreateFunc)(), TypeId id=OtherType) |
static void | AddAlias (TypeId id, std::string TypeName) |
static Object * | CreateObject (const std::string &TypeName, Object *parent=NULL) |
static TypeId | GetTypeId (const std::string &Name) |
static std::string | GetTypeName (TypeId Id) |
static void | AddMenuCallback (TypeId Id, BuildMenuCb cb) |
static void | AddRule (TypeId type1, RuleId rule, TypeId type2) |
static void | AddRule (const std::string &type1, RuleId rule, const std::string &type2) |
static const std::set< TypeId > & | GetRules (TypeId type, RuleId rule) |
static const std::set< TypeId > & | GetRules (const std::string &type, RuleId rule) |
static void | SetCreationLabel (TypeId Id, std::string Label) |
static const std::string & | GetCreationLabel (TypeId Id) |
static const std::string & | GetCreationLabel (const std::string &TypeName) |
static SignalId | CreateNewSignalId () |
Protected Member Functions | |
virtual Dialog * | BuildPropertiesDialog () |
This is the base class for most other objects in the gcu namespace.
gcu::Object::Object | ( | TypeId | Id = OtherType | ) |
Used to create an object of type Id. Should only be called from the constructor of a derived class.
|
virtual |
The standard destructor of Object instances. Automatically called when the object is destroyed.
|
static |
id | the Id of an existing type. |
TypeName | a new name for the type. |
This method is used to add an alternative name to an existing type.
|
virtual |
object | the Object instance to add as a child. |
Each Object instance maintains a list of its children. If object has already a parent, it will be removed from its parent children list. The new parent Object must have a Document ancestor to ensure that Ids are unique.
Reimplemented in gcu::Molecule, and gcp::Molecule.
|
static |
Id | the TypeId of the Object derived class |
cb | the BuildMenuCb callback to call when building the menu. |
adds a callback for modifying the contextual menu of objects of type Id.
This method is deprecated, use Application::AddMenuCallback() instead.
type1 | the TypeId of the first class in the rule |
rule | the new rule value |
type2 | the TypeId of the second class in the rule |
This method is deprecated, use Application::AddRule() instead.
Adds a rule.
|
static |
type1 | the name of the first class in the rule |
rule | the new rule value |
type2 | the name of the second class in the rule |
This method is deprecated, use Application::AddRule() instead.
Adds a rule.
|
static |
TypeName | the name of the new type. |
CreateFunc | a pointer to a function returning a pointer to a new object of the new type. |
id | the Id of the type to create if a standard one or OtherType for a new type. In this last case, this parameter can be omitted. |
This method is used to register a new type derived from Object.
This method is deprecated, use Application::AddType() instead.
|
virtual |
Children | the list of objects used as children to build the object |
This method is called to build a parent object from its children. The object must already exist.
|
virtual |
uim | the UIManager to populate. |
object | the Object on which occured the mouse click. |
x | x coordinate of the mouse click. |
y | y coordinate of the mouse click. |
This method is called to build a contextual menu for the object. It is called by Object::ShowContextualMenu, so it should not be necessary to call it directly. It should be overriden by derived classes when a contextual menu is needed. Typically, each class adds a submenu and calls the same method for its parent. Default implementation calls registered BuildMenuCb callbacks and the parent's method. Derived classes should call Object::BuildContextualMenu before returning.
Reimplemented in gcp::Molecule, gcp::Reactant, gcp::MechanismStep, gcp::ReactionArrow, gcp::Mesomery, and gcp::Reaction.
|
protectedvirtual |
|
inlinevirtual |
Reimplemented in gcp::MechanismArrow.
|
virtual |
Deletes all children. Derived classes might override this method if needed.
Reimplemented in gcu::Molecule, gcp::Molecule, gcu::Chem3dDoc, and gcp::Document.
|
static |
|
static |
TypeName | the name of the new type. |
parent | the parent of the newly created object or NULL. if NULL, the parameter can be omitted. |
Used to create an object of type name TypeName. The Object::AddType method must have been called with the same TypeName parameter. if parent is given and not NULL, the new Object will be a child of parent. It will also be given a default Id.
This method is deprecated, use Application::CreateObject() instead.
void gcu::Object::EmitSignal | ( | SignalId | Signal | ) |
Signal | the appropriate SignalId |
Sends a signal to the object parent. The signal may be propagated to the ancestors (see Object::OnSignal ()).
Application* gcu::Object::GetApplication | ( | ) | const |
Used to get the Application owning the Object.
|
virtual |
x | the x coordinate |
y | the y coordinate |
z | the z coordinate |
Reimplemented in gcp::Fragment, gcp::Molecule, and gcp::Bond.
Object* gcu::Object::GetChild | ( | const gchar * | Id | ) | const |
Id | the Id of the child searched. |
To search the Object in lower shells of the tree, use the Object::GetDescendant method.
|
inline |
|
virtual |
x | a pointer to the double value which will receive the x coordinate of the Object. |
y | a pointer to the double value which will receive the y coordinate of the Object. |
z | a pointer to the double value which will receive the z coordinate of the Object or NULL for 2D representations. |
Retrieves the coordinates of this Object if relevant.
Reimplemented in gcp::Fragment, gcp::Text, gcp::Arrow, gcu::Atom, and gcp::ReactionOperator.
|
static |
Id | the TypeId of a class |
This method is deprecated, use Application::GetCreationLabel() instead.
|
static |
TypeName | the name of a class |
This method is deprecated, use Application::GetCreationLabel() instead.
Object* gcu::Object::GetDescendant | ( | const char * | Id | ) | const |
|
inline |
Document* gcu::Object::GetDocument | ( | ) | const |
i | a C++ std::map iterator. |
Use this function to retrieve the first child of the object and initialize the iterator.
i | a C++ std::set<Object*> iterator. |
Use this function to retrieve the first object linked to the object and initialize the iterator. Links can be used when the relation between the objects is not a parent to child one.
Object* gcu::Object::GetGroup | ( | ) | const |
|
inline |
Definition at line 185 of file object.h.
Referenced by gcp::Molecule::GetAlignmentId().
Object* gcu::Object::GetMolecule | ( | ) | const |
Used to get the Molecule in the Object instances ancestors. Overloaded methods should call the base class Object::AddChild.
i | a C++ std::map iterator initialized by Object::GetFirstChild. |
Use this method to iterate through the list of the Object children.
i | a C++ std::set<Object*> iterator initialized by Object::GetFirstLink. |
Use this method to iterate through the list of Object instances linked to the object.
xmlNodePtr gcu::Object::GetNextNodeByName | ( | xmlNodePtr | node, |
char const * | Name | ||
) |
node | the xmlNodePtr returned by Object::GetNodeByName or the last call to Object::GetNextNodeByName. |
Name | the name of the xmlNode searched. |
Helper method used to iterate through a list of xmlNodePtr searching for nodes whose name is Name. Generally, the iteration is initialized by a call to Object::GetNodeByName.
xmlNodePtr gcu::Object::GetNextNodeByProp | ( | xmlNodePtr | node, |
char const * | Property, | ||
char const * | Id | ||
) |
node | the xmlNodePtr returned by Object::GetNodeByProp or the last call to Object::GetNextNodeByProp. |
Property | the name of the property used in the search. |
Id | the value to match to the property. |
Helper method used to iterate through a list of xmlNodePtr searching for a special value of a property. Generally, the iteration is initialized by a call to Object::GetNodeByProp.
xmlNodePtr gcu::Object::GetNodeByName | ( | xmlNodePtr | node, |
char const * | Name | ||
) |
node | the node where the search is to be done. |
Name | the name of the xmlNode searched. |
Helper method used in conjunction with Object::GetNextNodeByProp to search xmlNode instances of name Name in the children of node.
xmlNodePtr gcu::Object::GetNodeByProp | ( | xmlNodePtr | node, |
char const * | Property, | ||
char const * | Id | ||
) |
node | the node where the search is to be done. |
Property | the name of the property used in the search. |
Id | the value to match to the property. |
Helper method used in conjunction with Object::GetNextNodeByProp to search xmlNode instances having a property Property whose value is Id in the children of node.
|
inline |
Id | the type of the ancestor searched. Used to get the first ancestor of type Id in the Object instances ancestors. GetDocument, GetMolecule and GetReaction are special cases of this method. @return the first Object of type Id encountered when exploring the Objects tree (only one should be found) or NULL if none is found. |
void gcu::Object::GetPossibleAncestorTypes | ( | std::set< TypeId > & | types | ) | const |
types | the list of TypeId values to fill |
Fills types with all valid ancestor types for the object as defined by rules created with AddRule
|
virtual |
property | the property id as defined in objprops.h |
Used when saving to get properties from various objects. All classes supporting the mechanism must overload this method.
Reimplemented in gcp::Document, gcp::Bond, gcu::Atom, gcr::Atom, gcr::Document, gcu::Bond, and gcp::TextObject.
Object* gcu::Object::GetReaction | ( | ) | const |
type | the TypeId of a class |
rule | a RuleId value |
This method is deprecated, use Application::GetRules() instead.
|
static |
type | the name of a class |
rule | a RuleId value |
This method is deprecated, use Application::GetRules() instead.
|
inline |
Reimplemented in gcp::Brackets, and gcp::Bond.
|
static |
Name | the name of the Object derived class |
|
static |
Id | the TypeId of the Object derived class |
|
virtual |
Used to retrieve the y coordinate for alignment. The default implementation returns 0.0 and every derived class for which alignment has a meaning should implement this method.
Reimplemented in gcp::Document, gcp::Fragment, gcp::Atom, gcp::Bond, gcp::Text, gcp::Molecule, gcp::Arrow, gcp::Mesomery, gcp::Reaction, gcp::Mesomer, gcp::Reactant, gcp::ReactionOperator, gcp::ReactionStep, and gcp::MechanismStep.
|
inline |
|
virtual |
std::string gcu::Object::Identity | ( | ) |
|
inline |
void gcu::Object::Link | ( | Object * | object | ) |
object | the object to link. |
Adds a link to object.
|
virtual |
node | a pointer to the xmlNode containing the serialized object. |
Used to load an Object in memory. The Object must already exist.
Example:
Reimplemented in gcp::Atom, gcu::Atom, gcp::Fragment, gcp::ReactionProp, gcp::MechanismArrow, gcp::Document, gcp::Brackets, gcp::Molecule, gcu::Bond, gcp::TextObject, gcp::FragmentAtom, gcp::Electron, gcp::Text, gcp::Reaction, gcp::ReactionStep, gcp::MechanismStep, gcp::Arrow, gcp::Mesomer, gcp::Reactant, gcr::Bond, gcp::FragmentResidue, gcp::ReactionArrow, gcp::MesomeryArrow, and gcp::Mesomery.
void gcu::Object::Lock | ( | bool | state = true | ) |
state | whether to block signals or not |
Blocks signals if State is true and unblocs if state is false.
Since 0.4.2
|
virtual |
x | the x component of the transation vector. |
y | the y component of the transation vector. |
z | the z component of the transation vector. |
Used to move an object. This virtual method should most often be overrided by Object derived classes for which it makes sense. The base Object class has no coordinates and the default method only loads its id and children.
Reimplemented in gcp::Atom, gcu::Atom, gcp::Fragment, gcp::Bond, gcu::Bond, gcp::Arrow, gcp::TextObject, gcp::ReactionArrow, gcr::Bond, and gcp::ReactionOperator.
|
virtual |
Reimplemented in gcp::Fragment, gcu::Atom, gcu::Bond, gcp::Arrow, gcp::Text, gcu::Document, gcu::Chain, gcu::Molecule, gcp::MechanismArrow, gcp::ReactionProp, gcp::ReactionArrow, gcp::Reactant, gcp::Electron, gcp::Mesomer, gcp::Mesomery, gcp::Reaction, gcp::MesomeryArrow, gcp::ReactionStep, gcp::ReactionOperator, gcu::Cycle, and gcp::MechanismStep.
|
inlinevirtual |
Called by Object::Destructor() when the parent becomes empty. Default implementation does nothing.
Reimplemented in gcp::MechanismStep.
|
virtual |
This method should be called when an object has been fully loaded. The default method doesn't do anything.
Reimplemented in gcp::Bond, gcu::Bond, gcp::Arrow, gcp::Molecule, gcp::MechanismArrow, gcp::Brackets, and gcp::ReactionStep.
Signal | the appropriate SignalId |
Child | the child which emitted the signal or NULL |
This function is called by the framework when a signal has been emitted for the object. It should not be called by a program; call Object::EmitSignal instead.
Reimplemented in gcp::Document, gcp::Molecule, gcp::ReactionProp, gcp::ReactionArrow, gcp::Electron, gcp::Reactant, gcp::ReactionStep, gcp::Mesomery, gcp::Reaction, gcp::Mesomer, and gcp::MechanismStep.
|
virtual |
object | the object just unlinked by Object::Unlink. |
Virtual method called when an object has been unlinked. Programs should not call it directly, but should call Object::OnUnlink instead.
|
virtual |
xml | the xmlDoc used to save the document. |
Used to save the Object to the xmlDoc. Each serializable Object should implement this virtual method.
Reimplemented in gcp::Atom, gcu::Atom, gcp::Fragment, gcp::Brackets, gcp::MechanismArrow, gcp::Molecule, gcu::Bond, gcp::FragmentAtom, gcp::Electron, gcp::Text, gcp::ReactionStep, gcp::MechanismStep, gcp::Reactant, gcp::FragmentResidue, gcp::ReactionArrow, and gcp::MesomeryArrow.
bool gcu::Object::SaveChildren | ( | xmlDocPtr | xml, |
xmlNodePtr | node | ||
) | const |
xml | the xmlDoc used to save the document. |
node | the node representing the Object. |
This method calls Object::Save fo each child of the Object instance and add the xmlNode returned to the children of node. It might be called from the Save method of objects having serializable children.
void gcu::Object::SaveId | ( | xmlNodePtr | node | ) | const |
node | the node representing the Object. |
This helper method saves the Id of the node as a property of the xmlNode.
|
static |
Id | the TypeId of a class |
Label | the string to display in a contextual menu |
Used to give a label for contextual menus used when the creation of an instance of the class seems possible.
This method is deprecated, use Application::SetCreationLabel() instead.
void gcu::Object::SetDirty | ( | bool | dirty = true | ) |
dirty | should be true if the object needs some update, false otherwise. For a document, it means that the document has been changed. |
Reimplemented in gcp::Document.
void gcu::Object::SetId | ( | gchar const * | Id | ) |
Id | the id of the Object instance. |
Every object must have an Id, since searches in the document tree uses it.
void gcu::Object::SetParent | ( | Object * | Parent | ) |
|
virtual |
property | the property id as defined in objprops.h |
value | the property value as a string |
Used when loading to set properties to various objects. If the method returns false, the property should be set again later. This might happen if an atom does not exists when one of its bonds is loaded. All classes supporting the mechanism must overload this method.
Reimplemented in gcp::Atom, gcp::Document, gcugtk::SpectrumDocument, gcp::Fragment, gcp::Bond, gcu::Atom, gcr::Atom, gcr::Document, gcp::Text, gcu::Bond, gcu::Chem3dDoc, gcp::Arrow, and gcp::ReactionArrow.
void gcu::Object::ShowPropertiesDialog | ( | ) |
Exposes the gcu::Dialog related to the object properties if it exists.
|
virtual |
m | the Matrix2D of the transformation. |
x | the x component of the center of the transformation. |
y | the y component of the center of the transformation. |
Used to move and/or transform an object. This virtual method must be overrided by Object derived classes for which it makes sense. The base Object class has no coordinates and the default method calls the corresponding method for every child.
Reimplemented in gcp::Atom, gcu::Atom, gcp::Fragment, gcp::Bond, gcp::Brackets, gcp::Text, gcu::Bond, gcp::MechanismArrow, gcp::Arrow, gcp::Molecule, gcp::Electron, gcp::Mesomery, and gcp::Reaction.
void gcu::Object::Unlink | ( | Object * | object | ) |
object | the object to unlink. |
Unlinks object and calls Object::OnUnlink.