30 #include <libxml/parser.h> 37 #define square(x) ((x)*(x)) 117 std::set <TypeId> PossibleChildren;
118 std::set <TypeId> PossibleParents;
119 std::set <TypeId> RequiredChildren;
120 std::set <TypeId> RequiredParents;
121 std::string CreationLabel;
122 std::list <BuildMenuCb> MenuCbs;
165 Object (TypeId Id = OtherType);
181 void SetId (gchar
const *Id);
185 char const *
GetId ()
const {
return m_Id;}
192 virtual void AddChild (
Object*
object);
200 Object* GetMolecule ()
const;
207 Object* GetReaction ()
const;
215 Object* GetGroup ()
const;
238 Object* GetParentOfType (TypeId Id)
const;
245 Object* GetChild (
const gchar* Id)
const;
252 Object *GetFirstChild (std::map<std::string, Object*>::iterator& i);
253 Object const *GetFirstChild (std::map<std::string, Object*>::const_iterator& i)
const;
260 Object *GetNextChild (std::map<std::string, Object*>::iterator& i);
261 Object const *GetNextChild (std::map<std::string, Object*>::const_iterator& i)
const;
268 Object* GetDescendant (
const char* Id)
const;
279 void SetParent (
Object* Parent);
288 virtual xmlNodePtr Save (xmlDocPtr xml)
const;
305 virtual bool Load (xmlNodePtr node);
314 virtual bool GetCoords (
double *x,
double *y,
double *z = NULL)
const;
323 virtual void Move (
double x,
double y,
double z = 0.);
334 virtual void Transform2D (
Matrix2D& m,
double x,
double y);
343 bool SaveChildren (xmlDocPtr xml, xmlNodePtr node)
const;
349 void SaveId (xmlNodePtr node)
const;
360 xmlNodePtr GetNodeByProp (xmlNodePtr node,
char const *Property,
char const *Id);
370 xmlNodePtr GetNextNodeByProp (xmlNodePtr node,
char const *Property,
char const *Id);
380 xmlNodePtr GetNodeByName (xmlNodePtr node,
char const *Name);
389 xmlNodePtr GetNextNodeByName (xmlNodePtr node,
char const *Name);
408 virtual Object* GetAtomAt (
double x,
double y,
double z = 0.);
416 virtual bool Build (std::set < Object * >
const &Children)
throw (std::invalid_argument);
423 virtual double GetYAlign ();
438 virtual bool BuildContextualMenu (
UIManager *uim,
Object *
object,
double x,
double y);
446 void EmitSignal (SignalId Signal);
457 virtual bool OnSignal (SignalId Signal,
Object *Child);
466 void Lock (
bool state =
true);
483 Object* GetFirstLink (std::set<Object*>::iterator& i);
491 Object* GetNextLink (std::set<Object*>::iterator& i);
498 void Link (
Object *
object);
505 void Unlink (
Object *
object);
513 virtual void OnUnlink (
Object *
object);
520 void GetPossibleAncestorTypes (std::set<TypeId>& types)
const;
531 virtual bool SetProperty (
unsigned property,
char const *value);
540 virtual std::string GetProperty (
unsigned property)
const;
545 virtual void OnLoaded ();
551 void SetDirty (
bool dirty =
true);
556 virtual void Clear ();
561 virtual std::string Name ();
567 std::string Identity ();
572 virtual char const *HasPropertiesDialog ()
const;
588 void ShowPropertiesDialog ();
602 static TypeId AddType (std::string TypeName,
Object* (*CreateFunc) (), TypeId
id = OtherType);
610 static void AddAlias (TypeId
id, std::string TypeName);
624 static Object* CreateObject (
const std::string& TypeName,
Object* parent = NULL);
631 static TypeId GetTypeId (
const std::string& Name);
638 static std::string GetTypeName (TypeId Id);
648 static void AddMenuCallback (TypeId Id,
BuildMenuCb cb);
659 static void AddRule (TypeId type1,
RuleId rule, TypeId type2);
670 static void AddRule (
const std::string& type1,
RuleId rule,
const std::string& type2);
680 static const std::set<TypeId>& GetRules (TypeId type,
RuleId rule);
690 static const std::set<TypeId>& GetRules (
const std::string& type,
RuleId rule);
701 static void SetCreationLabel (TypeId Id, std::string Label);
710 static const std::string& GetCreationLabel (TypeId Id);
719 static const std::string& GetCreationLabel (
const std::string& TypeName);
724 static SignalId CreateNewSignalId ();
730 virtual Dialog *BuildPropertiesDialog ();
733 Object* RealGetDescendant (
const gchar* Id)
const;
739 std::map<std::string, Object*> m_Children;
740 std::set<Object*> m_Links;
741 TypeDesc
const *m_TypeDesc;
757 #endif //GCU_OBJECT_H
#define GCU_RO_PROP(type, member)
bool(* BuildMenuCb)(Object *target, UIManager *uim, Object *object, double x, double y)
virtual void NotifyEmpty()
base class for a user interface manager
The Gnome Chemistry Utils C++ classes.
char const * GetId() const
Object * GetParent() const
virtual bool CanSelect() const
unsigned GetChildrenNumber() const