The Gnome Chemistry Utils  0.14.0
Public Types | Public Member Functions | List of all members
gcp::Fragment Class Reference

Atoms groups. More...

#include <gcp/fragment.h>

Inheritance diagram for gcp::Fragment:
gcp::TextObject gcu::Object gccv::TextClient gccv::ItemClient

Public Types

enum  Validity { Invalid, Valid, Valid2D, Valid3D }
 The validity state of a Fragment as it is currently evaluated by the framework. The 0.12.x version don't do anything useful with it and all Fragment instances are invalid. More...
enum  FragmentMode {
  AutoMode, NormalMode, SubscriptMode, SuperscriptMode,
  ChargeMode, StoichiometryMode
}
 Edition mode. More...

Public Member Functions

 Fragment ()
 Fragment (double x, double y)
virtual ~Fragment ()
void AddItem ()
void UpdateItem ()
void SetSelected (int state)
xmlNodePtr Save (xmlDocPtr xml) const
xmlNodePtr SaveSelection (xmlDocPtr xml) const
bool Load (xmlNodePtr node)
bool OnChanged (bool save)
void AnalContent ()
void AnalContent (unsigned start, unsigned &end)
ObjectGetAtomAt (double x, double y, double z=0.)
void Move (double x, double y, double z=0)
void Transform2D (gcu::Matrix2D &m, double x, double y)
void OnChangeAtom ()
AtomGetAtom ()
int GetElementAtPos (unsigned start, unsigned &end)
gccv::Anchor GetChargePosition (FragmentAtom *pAtom, unsigned char &Pos, double Angle, double &x, double &y)
int GetAvailablePosition (double &x, double &y)
bool GetPosition (double angle, double &x, double &y)
bool Validate ()
double GetYAlign ()
bool SetProperty (unsigned property, char const *value)
bool Analyze ()
void Update ()
gccv::ItemGetChargeItem ()
std::string Name ()
bool GetCoords (double *x, double *y, double *z=NULL) const
Validity GetValid (void) const
void SetMode (FragmentMode val)
FragmentMode GetMode (void) const
FragmentModeGetRefMode (void)
- Public Member Functions inherited from gcp::TextObject
 TextObject (gcu::TypeId Type)
 TextObject (double x, double y, gcu::TypeId Type)
virtual ~TextObject ()
void GetSize (double &x, double &y)
xmlNodePtr SaveSelected ()
void LoadSelected (xmlNodePtr node)
bool SaveNode (xmlDocPtr xml, xmlNodePtr node) const
bool IsLocked ()
void GetSelectionBounds (unsigned &start, unsigned &end)
std::string GetBuffer ()
virtual std::string GetProperty (unsigned property) const
void SelectionChanged (unsigned start, unsigned end)
void TextChanged (unsigned pos)
gccv::TextTagList GetTagList (void)
void SetEditor (TextEditor *val)
TextEditorGetEditor (void) const
TextEditor *& GetRefEditor (void)
gccv::TextGetTextItem (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)
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 bool Build (std::set< Object * > const &Children) throw (std::invalid_argument)
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)
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 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 gccv::TextClient
 TextClient ()
virtual ~TextClient ()
virtual void InterlineChanged (G_GNUC_UNUSED double interline)
virtual void JustificationChanged (G_GNUC_UNUSED GtkJustification justification)
- Public Member Functions inherited from gccv::ItemClient
 ItemClient ()
virtual ~ItemClient ()
ItemGetItem (void)

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 ()
- Protected Attributes inherited from gcp::TextObject
double m_x
double m_y
double m_length
double m_height
int m_ascent
int m_InsertOffset
std::string m_buf
bool m_bLoading
unsigned m_StartSel
unsigned m_EndSel
bool m_RealSave
gccv::TextTagList m_TagList
gccv::Textm_TextItem

Detailed Description

Atoms groups.

Represents atoms groups displayed as a string. Currntly, the string is not fully parsed, so that some non sense strings might be accepted. Anyway, this will not always be the case in the future.

Definition at line 109 of file fragment.h.

Member Enumeration Documentation

Edition mode.

Current edition mode for the fragment. Used to know how inserted symbolds need to be interpreted.

Enumerator:
AutoMode 

Automatic mode, try to guess what each new symbol represent.

NormalMode 

New characters are aligned on the base line.

SubscriptMode 

New characters are subscripts, but are not related to stoichiometry.

SuperscriptMode 

New characters are superscripts, but are not related to charge.

ChargeMode 

New characters are interpreted as charge and superscript.

StoichiometryMode 

New characters are interpreted as stoichiometry and subscript.

Definition at line 343 of file fragment.h.

The validity state of a Fragment as it is currently evaluated by the framework. The 0.12.x version don't do anything useful with it and all Fragment instances are invalid.

Enumerator:
Invalid 

Invalid Fragment or validity not checked.

Valid 

Valid Fragment, all symbols in the string can be interpreted.

Valid2D 

Valid Fragment, with a known and reasonable 2D structure.

Valid3D 

Valid Fragment, with a known and reasonable 3D structure.

Definition at line 318 of file fragment.h.

Constructor & Destructor Documentation

gcp::Fragment::Fragment ( )

The default constructor.

gcp::Fragment::Fragment ( double  x,
double  y 
)
Parameters
xthe x position of the new fragment.
ythe y position of the new fragment.

Constructs a new fragment and position it. x and y are the position of the main atom or residue in the fragment.

virtual gcp::Fragment::~Fragment ( )
virtual

The destructor.

Member Function Documentation

void gcp::Fragment::AddItem ( )
virtual

Used to add a representation of the fragment in the view.

Reimplemented from gccv::ItemClient.

void gcp::Fragment::AnalContent ( )

Analyses the whole contents.

void gcp::Fragment::AnalContent ( unsigned  start,
unsigned &  end 
)
Parameters
startthe start fo the substring to parse, in bytes.
endthe end fo the substring to parse, in bytes.

Analyses a substring.

bool gcp::Fragment::Analyze ( )

Analyses the text in the fragment. This calls gcp::Fragment::AnalContent() and updates the attribute list.

Atom* gcp::Fragment::GetAtom ( )
inline
Returns
the main atom, which might have a bond.

Definition at line 217 of file fragment.h.

Object* gcp::Fragment::GetAtomAt ( double  x,
double  y,
double  z = 0. 
)
virtual
Parameters
xthe x coordinate
ythe y coordinate
zthe z coordinate (unused)
Returns
a pointer to the Atom correpoding to the symbol at or near the position defined by the coordinates passed as parameters, if any.

Reimplemented from gcu::Object.

int gcp::Fragment::GetAvailablePosition ( double &  x,
double &  y 
)
Parameters
xthe x position.
ythe y position.

This method finds an available position for drawing a charge sign or electrons and returns it as a symbolic value (see POSITION_E, POSITION_N,...). The x and y are updated so that they give the absolute position.

Returns
an available position.
gccv::Item* gcp::Fragment::GetChargeItem ( )
Returns
the gccv::Item used to represent the formal charge of the main atom.
gccv::Anchor gcp::Fragment::GetChargePosition ( FragmentAtom pAtom,
unsigned char &  Pos,
double  Angle,
double &  x,
double &  y 
)
Parameters
pAtomthe main atom which will get the local charge.
Posthe approximate position of the charge.
Anglethe angle from horizontal left.
xthe x position of the charge symbol.
ythe y position of the charge symbol.

If pAtom is not the main atom of the fragment, 0 is returned and Pos is not updated. On input Pos can be one of POSITION_E, POSITION_N,... or 0xff, in which case, it will be given a default value. x and y are set to the position where the charge sign should be displayed usding the alignment code returned by this method.

Returns
the anchor for the charge symbol. On error, gccv::AnchorCenter is used as the returned value.
bool gcp::Fragment::GetCoords ( double *  x,
double *  y,
double *  z = NULL 
) const
virtual
Parameters
xa pointer to the double value which will receive the x coordinate of the Fragment.
ya pointer to the double value which will receive the y coordinate of the Fragment.
za pointer to the double value which will receive the z coordinate of the Fragment or NULL for 2D representations.

Retrieves the coordinates of this Arrow.

Returns
true if successful and false if an error occurs (if x or y is NULL).

Reimplemented from gcu::Object.

int gcp::Fragment::GetElementAtPos ( unsigned  start,
unsigned &  end 
)
Parameters
startthe start position of the atomic symbol.
endthe end position of the atomic symbol.
Returns
the atomic number corresponding to the symbol starting at start, if any, or 0. end is updated accordingly.
gcp::Fragment::GetMode ( void  ) const
inline
Returns
the current edition mode for the Fragment instance.

Definition at line 395 of file fragment.h.

bool gcp::Fragment::GetPosition ( double  angle,
double &  x,
double &  y 
)
Parameters
anglethe angle at which a charge sign should be displayed.
xthe x position.
ythe y position.
Returns
false and do not update the coordinates.
gcp::Fragment::GetRefMode ( void  )
inline
Returns
the current edition mode for the Fragment instance as a reference.

Definition at line 395 of file fragment.h.

gcp::Fragment::GetValid ( void  ) const
inline
Returns
the current Fragment::Validity for the Fragment instance.

Definition at line 383 of file fragment.h.

double gcp::Fragment::GetYAlign ( )
virtual
Returns
the y coordinate at half height of a carbon atom symbol if any was present.

Reimplemented from gcu::Object.

bool gcp::Fragment::Load ( xmlNodePtr  node)
virtual
Parameters
nodea pointer to the xmlNode containing the serialized fragment.

Used to load a fragment in memory. The Fragment must already exist.

Returns
true on succes, false otherwise.

Reimplemented from gcp::TextObject.

void gcp::Fragment::Move ( double  x,
double  y,
double  z = 0 
)
virtual
Parameters
xthe x component of the transation vector.
ythe y component of the transation vector.
zthe z component of the transation vector.

Moves the fragment.

Reimplemented from gcp::TextObject.

std::string gcp::Fragment::Name ( )
virtual
Returns
the localized object generic name.

Reimplemented from gcu::Object.

void gcp::Fragment::OnChangeAtom ( )

Called by the framework when the user changes the nature of an atom using the element tool.

bool gcp::Fragment::OnChanged ( bool  save)
virtual
Parameters
savewhether the text should be saved for undo/redo operations.

Called after any change in the text.

Implements gcp::TextObject.

xmlNodePtr gcp::Fragment::Save ( xmlDocPtr  xml) const
virtual
Parameters
xmlthe xmlDoc used to save the document.

Used to save the fragment to the xmlDoc.

Returns
the xmlNode containing the serialized fragment.

Reimplemented from gcu::Object.

xmlNodePtr gcp::Fragment::SaveSelection ( xmlDocPtr  xml) const
Parameters
xmlthe xmlDoc used for clipboard operations.

Saves the currently selected text inside the fragment. This method is used by the framework when editing the fragment.

Returns
the xmlNode containing the serialized selection.
gcp::Fragment::SetMode ( FragmentMode  mode)
inline
Parameters
modethe nexw edition mode.

Sets the current edition mode for the Fragment instance.

Definition at line 395 of file fragment.h.

bool gcp::Fragment::SetProperty ( unsigned  property,
char const *  value 
)
virtual
Parameters
propertythe property id as defined in objprops.h
valuethe property value as a string

Used when loading to set properties for the fragment. This method supports GCU_PROP_POS2D, GCU_PROP_TEXT_TEXT, GCU_PROP_FRAGMENT_ATOM_START, and GCU_PROP_FRAGMENT_ATOM_ID.

Returns
true if the property could be set, or if the property is not relevant, false otherwise.

Reimplemented from gcu::Object.

void gcp::Fragment::SetSelected ( int  state)
virtual
Parameters
statethe selection state of the fragment.

Used to set the selection state of the fragment inside the widget. The values of state might be gcp::SelStateUnselected, gcp::SelStateSelected, gcp::SelStateUpdating, or gcp::SelStateErasing.

Reimplemented from gccv::ItemClient.

void gcp::Fragment::Transform2D ( gcu::Matrix2D m,
double  x,
double  y 
)
virtual
Parameters
mthe Matrix2D of the transformation.
xthe x component of the center of the transformation.
ythe y component of the center of the transformation.

Moves and/or transform an object.

Reimplemented from gcu::Object.

void gcp::Fragment::Update ( )

Changes the order of the symbols if necessary when a bond is at an extremity of the fragment.

void gcp::Fragment::UpdateItem ( )
virtual

Used to update a representation of the fragment in the view.

Reimplemented from gccv::ItemClient.

bool gcp::Fragment::Validate ( )

Validates the contents of the fragment text, and display error messages when necessary.


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