# gcp::Atom Class Reference

`#include <atom.h>`

Inheritance diagram for gcp::Atom:

List of all members.

## Public Member Functions

| Atom ()
| Atom (int Z, double x, double y, double z)
| Atom (OpenBabel::OBAtom *atom)
virtual | ~Atom ()
virtual void | SetZ (int Z)
void | AddBond (gcu::Bond *pBond)
void | RemoveBond (gcu::Bond *pBond)
virtual void | Update ()
virtual void | Add (GtkWidget *w) const
virtual void | Update (GtkWidget *w) const
int | GetTotalBondsNumber () const
int | GetAttachedHydrogens () const
HPos | GetBestSide ()
virtual int | GetChargePosition (unsigned char &Pos, double Angle, double &x, double &y)
virtual int | GetAvailablePosition (double &x, double &y)
virtual bool | GetPosition (double angle, double &x, double &y)
virtual xmlNodePtr | Save (xmlDocPtr xml) const
virtual bool | Load (xmlNodePtr node)
virtual bool | LoadNode (xmlNodePtr node)
virtual void | SetSelected (GtkWidget *w, int state)
virtual bool | AcceptNewBonds (int nb=1)
virtual bool | AcceptCharge (int charge)
virtual double | GetYAlign ()
virtual void | Transform2D (gcu::Matrix2D &m, double x, double y)
bool | BuildContextualMenu (GtkUIManager *UIManager, Object *object, double x, double y)
virtual void | AddToMolecule (Molecule *Mol)
bool | HasImplicitElectronPairs ()
bool | MayHaveImplicitUnpairedElectrons ()
void | AddElectron (Electron *electron)
void | RemoveElectron (Electron *electron)
void | NotifyPositionOccupation (unsigned char pos, bool occupied)
void | SetChargePosition (unsigned char Pos, bool def, double angle=0., double distance=0.)
char | GetChargePosition (double *Angle, double *Dist) const
void | SetCharge (int charge)
int | GetCharge () const
void | ForceChanged ()
bool | Match (gcu::Atom *atom, gcu::AtomMatchState &state)
void | GetSymbolGeometry (double &width, double &height, double &angle, bool up) const
void | SetShowSymbol (bool val)
bool | GetShowSymbol (void) const
bool & | GetRefShowSymbol (void)
void | SetHPosStyle (HPos val)
HPos | GetHPosStyle (void) const
HPos & | GetRefHPosStyle (void)

## Protected Member Functions

void | BuildSymbolGeometry (double width, double height, double ascent)

## Protected Attributes

double | m_CHeight

## Detailed Description

Represents atoms in GChemPaint.

Definition at line 113 of file gcp/atom.h.

## Constructor & Destructor Documentation

gcp::Atom::Atom | ( |  | ) |

Default construtor.

Reimplemented from gcu::Atom.

gcp::Atom::Atom | ( | int | Z,
|  | double | x,
|  | double | y,
|  | double | z |
| ) |  |  |

Parameters:

  | Z | the atomic number.
  | x | the x coordinate.
  | y | the y coordinate.
  | z | the z coordinate.

Reimplemented from gcu::Atom.

gcp::Atom::Atom | ( | OpenBabel::OBAtom * | atom | ) |

Parameters:

  | atom | an OpenBabel Atom instance.

Builds an atom importing as many properties from an existing OpenBabel Atom instance.

virtual gcp::Atom::~Atom | ( |  | ) | `[virtual]`

The destructor.

Reimplemented from gcu::Atom.

## Member Function Documentation

virtual void gcp::Atom::SetZ | ( | int | Z | ) | `[virtual]`

Parameters:

  | Z | the new atomic number.

Changes the atomic number of the atom.

Reimplemented from gcu::Atom.

Reimplemented in gcp::FragmentAtom.

void gcp::Atom::AddBond | ( | gcu::Bond * | pBond | ) | `[virtual]`

Parameters:

  | pBond | a bond.

Adds a bond to the atom.

Reimplemented from gcu::Atom.

void gcp::Atom::RemoveBond | ( | gcu::Bond * | pBond | ) | `[virtual]`

Parameters:

  | pBond | a bond.

Removes a bond from the atom.

Reimplemented from gcu::Atom.

virtual void gcp::Atom::Update | ( |  | ) | `[virtual]`

Updates the atom after changing its bonds, charge or explicit electrons.

Reimplemented in gcp::FragmentAtom.

virtual void gcp::Atom::Add | ( | GtkWidget * | w | ) | const`[virtual]`

Parameters:

  | w | a GtkWidget.

Adds the representation of the atom to the canvas widget.

Reimplemented from gcu::Object.

Reimplemented in gcp::FragmentAtom.

virtual void gcp::Atom::Update | ( | GtkWidget * | w | ) | const`[virtual]`

Parameters:

  | w | a GtkWidget.

Updates the representation of the atom in the canvas widget.

Reimplemented from gcu::Object.

Reimplemented in gcp::FragmentAtom.

int gcp::Atom::GetTotalBondsNumber | ( |  | ) | const

Returns:
  the bonds number for this atom taking bond order into account

int gcp::Atom::GetAttachedHydrogens | ( |  | ) | const`[inline]`

Returns:
  the number of implicit hydrogens lnked to the atom.

Definition at line 183 of file gcp/atom.h.

HPos gcp::Atom::GetBestSide | ( |  | ) |

Returns:
  the position of the attached hydrogen atoms symbol when automatically arranged.

virtual int gcp::Atom::GetChargePosition | ( | unsigned char & | Pos,
|  | double | Angle,
|  | double & | x,
|  | double & | y |
| ) |  |  | `[virtual]`

Parameters:

  | Pos | the approximate position of the charge.
  | Angle | the angle from horizontal left.
  | x | the x position of the charge symbol.
  | y | the y position of the charge symbol.

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:
  a number to set how the charge symbol should be aligned relative to its position. Possible values are:
  - −2: center top.
  - −1: right.
  - 0: center.
  - 1: left.
  - 2: center bottom.

Reimplemented in gcp::FragmentAtom.

virtual int gcp::Atom::GetAvailablePosition | ( | double & | x,
|  | double & | y |
| ) |  |  | `[virtual]`

Parameters:

  | x | the x position.
  | y | the 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.

Reimplemented in gcp::FragmentAtom.

virtual bool gcp::Atom::GetPosition | ( | double | angle,
|  | double & | x,
|  | double & | y |
| ) |  |  | `[virtual]`

Parameters:

  | angle | the angle at which a charge sign or an electron should be displayed.
  | x | the x position.
  | y | the y position.

Updates x and y so that they become the absolute position corresponding to the angle when the position is available.

Returns:
  true on success, false otherwise.

Reimplemented in gcp::FragmentAtom.

virtual xmlNodePtr gcp::Atom::Save | ( | xmlDocPtr | xml | ) | const`[virtual]`

Parameters:

  | xml | the xmlDoc used to save the document.

Used to save the Atom to the xmlDoc.

Returns:
  the xmlNode containing the serialized atom.

Reimplemented from gcu::Atom.

Reimplemented in gcp::FragmentAtom, and gcp::FragmentResidue.

virtual bool gcp::Atom::Load | ( | xmlNodePtr | node | ) | `[virtual]`

Parameters:

  | node | a pointer to the xmlNode containing the serialized atom.

Used to load an atom in memory. The Atom must already exist.

Returns:
  true on succes, false otherwise.

Reimplemented from gcu::Atom.

Reimplemented in gcp::FragmentAtom, and gcp::FragmentResidue.

virtual bool gcp::Atom::LoadNode | ( | xmlNodePtr | node | ) | `[virtual]`

Parameters:

  | node | a pointer to the xmlNode containing the serialized Atom.

Used in this class to correctly set the atomic number.

Reimplemented from gcu::Atom.

virtual void gcp::Atom::SetSelected | ( | GtkWidget * | w,
|  | int | state |
| ) |  |  | `[virtual]`

Parameters:

  | w | the GtkWidget inside which the atom is displayed.
  | state | the selection state of the atom.

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

Reimplemented from gcu::Object.

Reimplemented in gcp::FragmentAtom.

virtual bool gcp::Atom::AcceptNewBonds | ( | int | nb = `1` | ) | `[virtual]`

Parameters:

  | nb | the number of bonds to add, taking orders into account.

Returns:
  true if the operation is allowed, false if the new bonds would exceed the maximum valence for the element.

Reimplemented in gcp::FragmentAtom.

virtual bool gcp::Atom::AcceptCharge | ( | int | charge | ) | `[virtual]`

Parameters:

  | charge | the charge that might be set.

Returns:
  true if the charge is acceptable.

Reimplemented in gcp::FragmentAtom.

virtual double gcp::Atom::GetYAlign | ( |  | ) | `[virtual]`

Returns:
  the y coordinate at half height of the atom symbol if it was carbon.

Reimplemented from gcu::Object.

virtual void gcp::Atom::Transform2D | ( | gcu::Matrix2D & | m,
|  | double | x,
|  | double | y |
| ) |  |  | `[virtual]`

Parameters:

  | 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.

Reimplemented from gcu::Atom.

bool gcp::Atom::BuildContextualMenu | ( | GtkUIManager * | UIManager,
|  | Object * | object,
|  | double | x,
|  | double | y |
| ) |  |  |

Parameters:

  | UIManager,: | the GtkUIManager to populate.
  | object | the atom 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 atom.

virtual void gcp::Atom::AddToMolecule | ( | Molecule * | Mol | ) | `[virtual]`

Parameters:

  | Mol,: | a pointer to a molecule

Adds the atom to the molecule calling gcpMolecule::AddAtom()

Reimplemented in gcp::FragmentAtom.

bool gcp::Atom::HasImplicitElectronPairs | ( |  | ) |

Returns:
  true if the atom has implicit electron pairs, false otherwise.

bool gcp::Atom::MayHaveImplicitUnpairedElectrons | ( |  | ) |

Returns:
  true if the atom has implcit electrons that might be unpaired.

void gcp::Atom::AddElectron | ( | Electron * | electron | ) |

Parameters:

  | electron | a pointer to an Electron instance.

Adds the Electron (representing either a single electron or a pair) to the Atom.

void gcp::Atom::RemoveElectron | ( | Electron * | electron | ) |

Parameters:

  | electron | a pointer to an Electron instance.

Removes the Electron (representing either a single electron or a pair) from the Atom.

void gcp::Atom::NotifyPositionOccupation | ( | unsigned char | pos,
|  | bool | occupied |
| ) |  |  |

Parameters:

  | pos | one of POSITION_E, POSITION_N,...
  | occupied | true if occupied, false otherwise.

Notifies if a position is occupied or not.

void gcp::Atom::SetChargePosition | ( | unsigned char | Pos,
|  | bool | def,
|  | double | angle = `0.`,
|  | double | distance = `0.` |
| ) |  |  |

Parameters:

  | Pos | one of POSITION_E, POSITION_N,...
  | def | true if the position is automatic.
  | angle | the angle from the east direction in the trigonometric convention.
  | distance | the distance from the center of the atom, or 0. if automatic.

Sets the relative position of a charge sign.

char gcp::Atom::GetChargePosition | ( | double * | Angle,
|  | double * | Dist |
| ) |  |  | const

Parameters:

  | Angle | where to store the angle from east direction in the trigonometric convention.
  | Dist | where to store the distance from the center of the atom.

Returns:
  the charge position as one of POSITION_E, POSITION_N,...

void gcp::Atom::SetCharge | ( | int | charge | ) |

Parameters:

  | charge | the charge to set.

Sets the formal local charge of an atom.

int gcp::Atom::GetCharge | ( |  | ) | const`[inline]`

Returns:
  the current formal local charge.

Definition at line 347 of file gcp/atom.h.

References gcu::Atom::m_Charge.

void gcp::Atom::ForceChanged | ( |  | ) | `[inline]`

Forces an update.

Definition at line 351 of file gcp/atom.h.

bool gcp::Atom::Match | ( | gcu::Atom * | atom,
|  | gcu::AtomMatchState & | state |
| ) |  |  | `[virtual]`

Parameters:

  | atom | the atom to which the this instance is to be compared.
  | state | the AtomMatchState representing the current comparison state.

Try to match atoms from two molecules which are compared. This function calls itself recursively until all atoms from the two molecules have been matched or until an difference is found. Overriden methods should call this base function and return its result.

Returns:
  true if the atoms match, false otherwise.

Reimplemented from gcu::Atom.

Reimplemented in gcp::FragmentAtom.

void gcp::Atom::GetSymbolGeometry | ( | double & | width,
|  | double & | height,
|  | double & | angle,
|  | bool | up |
| ) |  |  | const

Parameters:

  | width | where to store the width.
  | height | where to store the height.
  | angle | where to store the limit angle.
  | up | whether considering the top half or the bottom half

Used to retrieve the size of the ink rectangle of the atom symbol (if displayed). angle is absolute value of the angle between an horizontal line and the line joining the center and the top left or the bottom left vertex. The returned width value is actually half the full width. Height is the height. This method is used to avoid bonds lines extyending over their atoms symbols.

void gcp::Atom::BuildSymbolGeometry | ( | double | width,
|  | double | height,
|  | double | ascent |
| ) |  |  | `[protected]`

Parameters:

  | width | the witdh of the atomic symbol.
  | height | the height of the atomic symbol.
  | ascent | the ascent of the atomic symbol.

Evaluates where lines representing bonds should end to not overload the symbol.

gcp::Atom::SetShowSymbol | ( | bool | ShowSymbol | ) | `[inline]`

Parameters:

  | ShowSymbol | whether the symbol of a carbon atom is to be displayed or not.

Sets the visibility of a carbon atom symbol in a chain.

Definition at line 442 of file gcp/atom.h.

gcp::Atom::GetShowSymbol | ( | void |  | ) | const`[inline]`

Returns:
  whether the symbol of a carbon atom is displayed or not.

Definition at line 442 of file gcp/atom.h.

gcp::Atom::GetRefShowSymbol | ( | void |  | ) | `[inline]`

Returns:
  whether the symbol of a carbon atom is displayed or not as a reference.

Definition at line 442 of file gcp/atom.h.

gcp::Atom::SetHPosStyle | ( | HPos | val | ) | `[inline]`

Parameters:

  | val | the new position.

Sets the position of attached hydrogen atoms symbol.

Definition at line 455 of file gcp/atom.h.

gcp::Atom::GetHPosStyle | ( | void |  | ) | const`[inline]`

Returns:
  the position of attached hydrogen atoms symbol.

Definition at line 455 of file gcp/atom.h.

gcp::Atom::GetRefHPosStyle | ( | void |  | ) | `[inline]`

Returns:
  the position of attached hydrogen atoms symbol as a reference.

Definition at line 455 of file gcp/atom.h.

## Member Data Documentation

double gcp::Atom::m_CHeight `[protected]`

Half the height of the "C" character.

Definition at line 429 of file gcp/atom.h.

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

- gcp/atom.h