The Gnome Chemistry Utils  0.14.0
Public Member Functions | Protected Attributes | List of all members
gcu::Document Class Reference

#include <gcu/document.h>

Inheritance diagram for gcu::Document:
gcu::Object gcu::DialogOwner gcp::Document gcu::GLDocument gcugtk::SpectrumDocument gcr::Document gcu::Chem3dDoc gcugtk::Chem3dDoc

Public Member Functions

 Document (Application *App=NULL)
virtual ~Document ()
std::string & GetTranslatedId (const char *id)
void EraseTranslationId (const char *Id)
void EmptyTranslationTable ()
virtual void SetTitle (std::string &title)
virtual void SetTitle (char const *title)
std::string & GetTitle ()
void NotifyDirty (Object *pObject)
virtual void Save () const
virtual ResidueCreateResidue (char const *name, char const *symbol, Molecule *molecule)
virtual Residue const * GetResidue (char const *symbol, bool *ambiguous=NULL)
virtual GtkWindow * GetGtkWindow ()
bool SetTarget (char const *id, Object **target, Object *parent, Object *owner=NULL, Action action=ActionException) throw (std::runtime_error)
virtual bool Loaded () throw (LoaderError)
std::string Name ()
void ObjectLoaded (Object *obj)
std::set< Object * > GetNewObjects ()
virtual WindowGetWindow ()
ApplicationGetApp (void)
bool GetEmpty (void)
void SetScale (double val)
double GetScale (void) const
double & GetRefScale (void)
- Public Member Functions inherited from gcu::Object
 Object (TypeId Id=OtherType)
virtual ~Object ()
TypeId GetType () const
void SetId (gchar const *Id)
char const * GetId () const
virtual void AddChild (Object *object)
ObjectGetMolecule () const
ObjectGetReaction () const
ObjectGetGroup () const
DocumentGetDocument () const
ApplicationGetApplication () const
ObjectGetParentOfType (TypeId Id) const
ObjectGetChild (const gchar *Id) const
ObjectGetFirstChild (std::map< std::string, Object * >::iterator &i)
ObjectGetNextChild (std::map< std::string, Object * >::iterator &i)
ObjectGetDescendant (const char *Id) const
ObjectGetParent () 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 ObjectGetAtomAt (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 ()
ObjectGetFirstLink (std::set< Object * >::iterator &i)
ObjectGetNextLink (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 ()
std::string Identity ()
virtual char const * HasPropertiesDialog () const
virtual bool CanSelect () const
virtual void NotifyEmpty ()
void ShowPropertiesDialog ()
bool GetDirty (void) const
- Public Member Functions inherited from gcu::DialogOwner
 DialogOwner ()
virtual ~DialogOwner ()
DialogGetDialog (std::string name) const
void ClearDialogs ()

Protected Attributes

std::string m_Title
std::set< Object * > m_DirtyObjects
Applicationm_App
bool m_Empty

Additional Inherited Members

- Static Public Member Functions inherited from gcu::Object
static TypeId AddType (std::string TypeName, Object *(*CreateFunc)(), TypeId id=OtherType)
static void AddAlias (TypeId id, std::string TypeName)
static ObjectCreateObject (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 inherited from gcu::Object
virtual DialogBuildPropertiesDialog ()

Detailed Description

This class is the base document class.

Definition at line 61 of file gcu/document.h.

Constructor & Destructor Documentation

gcu::Document::Document ( Application App = NULL)
Parameters
Appthe Appllcation which owns the new document.

The default constructor. Creates an empty document.

Reimplemented in gcr::Document.

virtual gcu::Document::~Document ( )
virtual

The destructor of Document.

Reimplemented in gcr::Document, and gcp::Document.

Member Function Documentation

virtual Residue* gcu::Document::CreateResidue ( char const *  name,
char const *  symbol,
Molecule molecule 
)
virtual
Parameters
namethe name of the new residue.
symbolthe symbol of the new residue.
moleculea molecule with a pseudo atom which describes the structure of the residue.

This methodshould be overloaded by derived classes necessitating it. Default implementation just returns NULL.

Returns
the new Residue on success or NULL.

Reimplemented in gcp::Document.

void gcu::Document::EmptyTranslationTable ( )
inline

When pasting, objects added to the document might have the same Id as objects already existing. In such cases, the document maintains a table to update links using Ids as identifiers. The EmptyTranslationTable method should be called after pasting to reinitialize the table to avoid errors on the next paste event.

Definition at line 113 of file gcu/document.h.

void gcu::Document::EraseTranslationId ( const char *  Id)
inline
Parameters
Idthe entry to remove

When pasting, objects added to the document might have the same Id as objects already existing. In such cases, the document maintains a table to update links using Ids as identifiers. The EraseTranslationTable method removes thenentry correspondig to id.

Definition at line 106 of file gcu/document.h.

gcu::Document::GetApp ( void  )
inline
Returns
a pointer to the Application instance owning the document or NULL for an orphan document.

Definition at line 248 of file gcu/document.h.

gcu::Document::GetEmpty ( void  )
inline
Returns
true if the document does not contain anything, false otherwise.

Definition at line 255 of file gcu/document.h.

virtual GtkWindow* gcu::Document::GetGtkWindow ( )
inlinevirtual

This method is used to get the active window of the document. Derived classes should, override it to return a consistent value. Default implementation returns NULL.

Returns
the active GtkWindow for the document if any.

Reimplemented in gcp::Document.

Definition at line 166 of file gcu/document.h.

std::set< Object * > gcu::Document::GetNewObjects ( )
inline
Returns
the set of objects that have just been loaded.

Reimplemented in gcp::Document.

Definition at line 204 of file gcu/document.h.

gcu::Document::GetRefScale ( void  )
inline
Returns
the current scale factor as a reference.

Definition at line 267 of file gcu/document.h.

virtual Residue const* gcu::Document::GetResidue ( char const *  symbol,
bool *  ambiguous = NULL 
)
virtual
Parameters
symbolthe symbol for which a Residue* is searched.
ambiguouswhere to store the boolean telling if the symbol is ambiguous or NULL.

Documents might own not global residues with the same symbol or name but a different meaning from the standard residue.

Returns
the Residue* found or NULL.

Reimplemented in gcp::Document.

gcu::Document::GetScale ( void  ) const
inline
Returns
the current scale factor.

Definition at line 267 of file gcu/document.h.

std::string& gcu::Document::GetTitle ( )
inline
Returns
the current document title.

Reimplemented in gcr::Document.

Definition at line 126 of file gcu/document.h.

References m_Title.

std::string& gcu::Document::GetTranslatedId ( const char *  id)
Parameters
idthe original id to tranlate

When pasting, objects added to the document might have the same Id as objects already existing. In such cases, the document maintains a table to update links using Ids as identifiers. GetTranslatedId returns the translated id corresponding to the parameter id.

virtual Window* gcu::Document::GetWindow ( )
inlinevirtual
Returns
the Window associated with the document. The default implementation always returns NULL.

Reimplemented in gcp::Document.

Definition at line 210 of file gcu/document.h.

virtual bool gcu::Document::Loaded ( ) throw (LoaderError)
virtual

Processes pending references resulting from failed calls to SetTarget().

Returns
true if any reference was set.

Reimplemented in gcugtk::SpectrumDocument, and gcr::Document.

std::string gcu::Document::Name ( )
virtual
Returns
the localized object generic name.

Reimplemented from gcu::Object.

void gcu::Document::NotifyDirty ( Object pObject)
inline
Parameters
pObjectan object needing some update.

The gcu::Document class just stores dirty objects, but don't do anything with them. Derived classes need to implement that, if meaningful.

Definition at line 134 of file gcu/document.h.

References m_DirtyObjects.

void gcu::Document::ObjectLoaded ( Object obj)
Parameters
obja just loaded object.

Inserts obj in the set of new objects. This set is used to avoid a confusion with pre-existing objects with the same Id when processing pending links.

virtual void gcu::Document::Save ( ) const
inlinevirtual

Saves the document. Need to be overloaded by derived class if meaningful. Default implementation doesn't do anything.

Reimplemented in gcr::Document, and gcp::Document.

Definition at line 139 of file gcu/document.h.

gcu::Document::SetScale ( double  scale)
inline
Parameters
scalethe new scale factor.

Sets the new scale factor.

Definition at line 267 of file gcu/document.h.

bool gcu::Document::SetTarget ( char const *  id,
Object **  target,
Object parent,
Object owner = NULL,
Action  action = ActionException 
) throw (std::runtime_error)
Parameters
idthe id of the target Object.
targetwhere to store the found object.
parentthe ancestor of the search object or NULL.
ownerthe owner of the reference to the search object.
actionwhat to do with owner if the target is not found.

Search the descendant of parent, or of the whole document if parent is not set whose Id is id. I not found, the parameters are stored for post loading processing using gcu::Document::Loaded(), and target is set to NULL. if owner is not NULL, post processing will call its OnLoaded() method.

Returns
true if the target object was found.
virtual void gcu::Document::SetTitle ( std::string &  title)
inlinevirtual
Parameters
titlethe new document title.

Reimplemented in gcr::Document.

Definition at line 118 of file gcu/document.h.

References m_Title.

virtual void gcu::Document::SetTitle ( char const *  title)
inlinevirtual
Parameters
titlethe new document title.

Reimplemented in gcr::Document.

Definition at line 122 of file gcu/document.h.

References m_Title.

Member Data Documentation

gcu::Document::m_App
protected

The Application instance owning the document.

Definition at line 248 of file gcu/document.h.

std::set<Object*> gcu::Document::m_DirtyObjects
protected

The set of dirty objects, see gcu::Document::NotifyDirty.

Definition at line 239 of file gcu/document.h.

Referenced by NotifyDirty().

gcu::Document::m_Empty
protected

Tells if the document is empty or not.

Definition at line 255 of file gcu/document.h.

std::string gcu::Document::m_Title
protected

The document title.

Definition at line 234 of file gcu/document.h.

Referenced by GetTitle(), gcr::Document::GetTitle(), and SetTitle().


The documentation for this class was generated from the following file: