# gcp::FragmentAtom Class Reference

`#include <gcp/fragment-atom.h>`

Inheritance diagram for gcp::FragmentAtom:

List of all members.

## Public Member Functions

| FragmentAtom ()
| FragmentAtom (Fragment *fragment, int Z)
virtual | ~FragmentAtom ()
void | SetZ (int Z)
bool | AcceptNewBonds (int nb)
void | Add (GtkWidget *w) const
void | Update ()
void | Update (GtkWidget *w) const
void | SetSelected (GtkWidget *w, int state)
xmlNodePtr | Save (xmlDocPtr xml) const
bool | Load (xmlNodePtr node)
int | GetChargePosition (unsigned char &Pos, double Angle, double &x, double &y)
int | GetAvailablePosition (double &x, double &y)
bool | GetPosition (double angle, double &x, double &y)
bool | AcceptCharge (int charge)
void | AddToMolecule (Molecule *Mol)
bool | Match (gcu::Atom *atom, gcu::AtomMatchState &state)
void | DoBuildSymbolGeometry (View *pView)

## Detailed Description

Represents an atom inside a atoms group (see gcp::Fragment class).

Definition at line 39 of file fragment-atom.h.

## Constructor & Destructor Documentation

gcp::FragmentAtom::FragmentAtom | ( |  | ) |

The default constructor.

gcp::FragmentAtom::FragmentAtom | ( | Fragment * | fragment,
|  | int | Z |
| ) |  |  |

Parameters:

  | fragment | the parent Fragment.
  | Z | the atomic number.

Constructs a FragmentAtom inside fragment with atomic number Z. This does not add the symbol to the string.

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

The destructor.

## Member Function Documentation

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

Parameters:

  | Z | the new atomic number.

Changes the atomic number of the atom.

Reimplemented from gcp::Atom.

bool gcp::FragmentAtom::AcceptNewBonds | ( | int | nb | ) | `[virtual]`

Parameters:

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

This atom class does not currently support more than one single bond and no multiple bond at all.

Returns:
  true if the operation is allowed, false otherwise.

Reimplemented from gcp::Atom.

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

Parameters:

  | w | a GtkWidget.

Overrided to avoid Atom::Add execution. Don't do anything.

Reimplemented from gcp::Atom.

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

Overrided to avoid Atom::Update execution. Just call Fragment::Update() method.

Reimplemented from gcp::Atom.

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

Parameters:

  | w | a GtkWidget.

Overrided to avoid Atom::Update execution. Just call Fragment::Update(w).

Reimplemented from gcp::Atom.

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

Parameters:

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

Overrided to avoid Atom::SetSelected execution. Just call Fragment::SetSelected method.

Reimplemented from gcp::Atom.

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

Parameters:

  | xml | the xmlDoc used to save the document.

Used to save the atome specific data to the xmlDoc.

Returns:
  the xmlNode containing the serialized atom.

Reimplemented from gcp::Atom.

Reimplemented in gcp::FragmentResidue.

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

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

Used to load the atom specific properties in memory. The FragmentAtom must already exist.

Returns:
  true on succes, false otherwise.

Reimplemented from gcp::Atom.

Reimplemented in gcp::FragmentResidue.

int gcp::FragmentAtom::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 from gcp::Atom.

int gcp::FragmentAtom::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 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 from gcp::Atom.

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

Parameters:

  | angle | the angle at which a charge sign 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 from gcp::Atom.

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

Parameters:

  | charge | the charge that might be set.

Currently, these atoms only accept -1, 0, and +1 as charges.

Returns:
  true if the charge is acceptable.

Reimplemented from gcp::Atom.

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

Parameters:

  | Mol,: | a pointer to a molecule

Adds the fragment containing the atom to the molecule calling gcpMolecule::AddFragment()

Reimplemented from gcp::Atom.

bool gcp::FragmentAtom::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. FragmentAtom instances can't be matched currently.

Returns:
  always false.

Reimplemented from gcp::Atom.

void gcp::FragmentAtom::DoBuildSymbolGeometry | ( | View * | pView | ) |

Parameters:

  | pView | the document view.

Builds the symbol geometry if necessary.

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

- fragment-atom.h