class OEDepictView
The OEDepictView class provides all of the knowledge (and state)
for drawing a 2D molecular depiction.
OEDepictView()
Default constructor. By default, the width and height of an
OEDepictView are 200 pixels wide by 200 pixels high.
The current width and height can be determined using the
OEDepictView::XRange and OEDepictView::YRange
methods. If required, the dimensions of an OEDepictView
may be adjusted using either the OEDepictView::AdjustView
or OEDepictView::DetermineView methods.
OEDepictView(int width, int height)
Construct with a specified width and height. The current width and
height can be determined using the OEDepictView::XRange and
OEDepictView::YRange methods. If required, the dimensions
of an OEDepictView may be adjusted using either the
OEDepictView::AdjustView or OEDepictView::DetermineView
methods.
OEDepictView(const OEDepictView ©)
Copy constructor.
void AdjustView(int wide, int high)
Set the dimensions of the view of the current molecule to the specified
dimensions. The wide argument specifies the width of the
view in pixels, and the high argument specifies the height
of the view in pixels. This method must be called after the molecule
to be displayed has been set by the OEDepictView::SetMolecule
method.
This function sets the xscale, yscale, xoffset and yoffset properties
of the OEDepictView, as can be retrieved by the methods
OEDepictView::XScale, OEDepictView::YScale,
OEDepictView::XOffset and OEDepictView::YOffset.
OEAtomStyle *AStyle(unsigned int i)
Return a pointer to the ``atom style'' structure associated with a
particular atom of the molecule currently associated with the
OEDepictView. The i argument is the atom index
of the atom, as returned by OEAtomBase::GetIdx. If no
molecule is associated with the OEDepictBase, or the atom
index i is out of range for the current molecule, this
method returns a NULL pointer.
A molecule may be associated with the OEDepictView using
the method OEDepictView::SetMolecule.
OEBondStyle *BStyle(unsigned int i)
Return a pointer to the ``bond style'' structure associated with a
particular bond of the molecule currently associated with the
OEDepictView. The i argument is the bond index
of the bond, as returned by OEBondBase::GetIdx. If no
molecule is associated with the OEDepictBase, or the bond
index i is out of range for the current molecule, this
method returns a NULL pointer.
A molecule may be associated with the OEDepictView using
the method OEDepictView::SetMolecule.
void DetermineView(int wide, int high)
The DetermineView method can be used to set the drawing
area of the OEDepictView to the size preferred by the
currently associated molecule. This method must be called after
the molecule to be displayed has been set by the
OEDepictView::SetMolecule method.
If both the wide and high arguments are both zero,
the width and height of the depiction, as retrieved using the
OEDepictView::XRange and OEDepictView::YRange
methods, as set to snugly fit around the depiction at the
current `pixel scale'. The `pixel scale' corresponds to the
number of pixels represented to a unit length in the molecule's
co-ordinate system. The default pixel scale is 28 pixels, hence
a bond of length 1.0 will be displayed as a line 28 pixels long.
The pixel scale can get modified and retrieved using the
OEDepictView::SetPixScale and OEDepictView::GetPixScale
methods, respectively.
If either the wide or the high arguments are non-zero,
they specify the width and height bounds to be used. If these values
are larger than the size that would be chosen for the molecule, the
molecule is displayed at it's default scale centered within a larger
box. Otherwise, the molecule is shrunk to fit in the specified size.
This functionality is useful in spreadsheets and WWW pages where a
depiction may have to fit within a particular column width but may
be of any height.
This function also sets the xscale, yscale, xoffset and yoffset
properties of the OEDepictView, as can be retrieved by the
methods OEDepictView::XScale, OEDepictView::YScale,
OEDepictView::XOffset and OEDepictView::YOffset.
void GetBackColor(unsigned char *r,
unsigned char *g,
unsigned char *b)
Retrieve the current background color of the OEDepictView.
Upon return, the 8-bit red, green and blue components of the background
color are stored in the variables pointed to by r, g and
b arguments respectively.
The background color may be specified using the
OEDepictView::SetBackColor method.
int GetFontSize()
void GetForeColor(unsigned int *r,
unsigned int *g,
unsigned int *b)
Retrieve the current foreground color of the OEDepictView.
Upon return, the 8-bit red, green and blue components of the foreground
color are stored in the variables pointed to by r, g and
b arguments respectively.
The foreground color may be specified using the
OEDepictView::SetForeColor method.
const OEChem::OEMolBase *GetMolecule()
Return a pointer to the molecule currently associated with this
OEDepictView or a NULL pointer if no molecule has been set.
The molecule associated with a OEDepictView may be set with
the method OEDepictView::SetMolecule. By default, no molecule
is associated a OEDepictView.
int GetTitleSize()
bool GetTitleTop()
void RenderImage(OEDepictBase *img, bool clear=true,
int startx = 0, int starty = 0)
Display the current molecule using the given OEDepictBase, img.
The clear argument controls whether the drawing area should be cleared
before displaying the molecule (by default true), and the startx and
starty arguments allow the image to display at the specified offset
withing the specified OEDepictBase.
void SetBackColor(unsigned char r,
unsigned char g,
unsigned char b)
bool SetFontSize(int size)
void SetForeColor(unsigned char r,
unsigned char g,
unsigned char b)
void SetMolecule(const OEChem::OEMolBase *mol)
Set the molecule to be displayed. A pointer is kept to the original
molecule, but the molecule itself is neither modified nor copied.
Great care should be used when modifying the molecule associated with
a OEDepictView. After modifying a molecules, for example, by
adding or deleting atoms or bonds, or modifying co-ordinates, this
SetMolecule function should be called again. A pointer to the
current molecule associated with a OEDepictView may be retrieved
using the OEDepictView::GetMolecule method.
This function allocates (or reallocates) the `atom style' and `bond
style' arrays associated with the molecule. These arrays may be
retrieved and modified using the OEDepictView::AStyle and
OEDepictView::BStyle methods.
Passing a NULL pointer to SetMolecule can be used to reset
the association between the OEDepictView and a molecule. It
is not necessary to do this explicitly prior to destroying the
OEDepictView.
void SetTitleSize(int size)
void SetTitleTop(bool top)
int XOffset()
int XRange()
int XScale()
int YOffset()
int YRange()
int YScale()