gcp::Document Class Reference
#include <gcp/document.h>
List of all members.
Public Member Functions |
| Document (Application *App, bool StandAlone, Window *window=NULL) |
virtual | ~Document () |
void | Clear () |
GtkWidget * | GetWidget () |
View * | GetView () |
bool | ImportOB (OpenBabel::OBMol &Mol) |
void | ExportOB () const |
void | Save () const |
virtual bool | Load (xmlNodePtr node) |
const gchar * | GetTitle () const |
void | SetTitle (const gchar *title) |
void | SetLabel (const gchar *label) |
const gchar * | GetLabel () const |
void | SetFileName (std::string const &filename, const gchar *mime_type) |
const gchar * | GetFileName () const |
void | DoPrint (GtkPrintOperation *print, GtkPrintContext *context, int page) const |
void | AddObject (Object *pObject) |
void | AddAtom (Atom *pAtom) |
void | AddFragment (Fragment *pFragment) |
void | AddBond (Bond *pBond) |
void | ParseXMLTree (xmlDocPtr xml) |
void | LoadObjects (xmlNodePtr node) |
xmlDocPtr | BuildXMLTree () const |
void | Update () |
void | Remove (Object *object) |
void | Remove (const char *Id) |
void | OnProperties () |
void | OnUndo () |
void | OnRedo () |
const GDate * | GetCreationDate () |
const GDate * | GetRevisionDate () |
const gchar * | GetAuthor () |
const gchar * | GetMail () |
const gchar * | GetComment () |
void | SetAuthor (const gchar *author) |
void | SetMail (const gchar *mail) |
void | SetComment (const gchar *comment) |
void | FinishOperation () |
void | AbortOperation () |
void | PopOperation () |
void | PushOperation (Operation *operation, bool undo=true) |
void | SetActive () |
Operation * | GetNewOperation (OperationType type) |
Operation * | GetCurrentOperation () |
void | AddData (xmlNodePtr node) |
bool | CanUndo () |
void | SetEditable (bool editable) |
bool | GetEditable () |
gcp::Application * | GetApplication () |
void | ExportImage (std::string const &filename, const char *type, int resolution=-1) |
void | SetReadOnly (bool ro) |
bool | GetReadOnly () |
virtual double | GetYAlign () |
Window * | GetWindow () |
GtkWindow * | GetGtkWindow () |
void | SetTheme (Theme *theme) |
bool | OnSignal (gcu::SignalId Signal, gcu::Object *Child) |
void | SetDirty (bool isDirty=true) |
void | OnThemeNamesChanged () |
double | GetMedianBondLength () |
bool | SetProperty (unsigned property, char const *value) |
std::string | GetProperty (unsigned property) const |
void | SetLoading (bool loading) |
void | SaveResidue (Residue const *r, xmlNodePtr node) |
gcu::Residue const * | GetResidue (char const *symbol, bool *ambiguous=NULL) |
gcu::Residue * | CreateResidue (char const *name, char const *symbol, gcu::Molecule *molecule) |
Detailed Description
The document class for GChemPaint.
Definition at line 77 of file gcp/document.h.
Constructor & Destructor Documentation
gcp::Document::Document |
( |
Application * |
App, |
|
|
bool |
StandAlone, |
|
|
Window * |
window = NULL | |
|
) |
| | |
- Parameters:
-
| App | the application. |
| StandAlone | whether the document is opened in its own window or embedded in something else. |
| window | the document window if it has already been created or NULL. |
Constructs a new empty document using default theme.
virtual gcp::Document::~Document |
( |
|
) |
[virtual] |
Member Function Documentation
void gcp::Document::AbortOperation |
( |
|
) |
|
Aborts and deletyes the current operation.
void gcp::Document::AddAtom |
( |
Atom * |
pAtom |
) |
|
- Parameters:
-
Adds a new atom to the document.
void gcp::Document::AddBond |
( |
Bond * |
pBond |
) |
|
- Parameters:
-
Adds a new bond to the document and checks the connectivity of the new covalent structure.
void gcp::Document::AddData |
( |
xmlNodePtr |
node |
) |
|
- Parameters:
-
| node | the XML node representing objects to add to the document. |
Adds previously serialized objects to the document.
void gcp::Document::AddFragment |
( |
Fragment * |
pFragment |
) |
|
- Parameters:
-
| pFragment | a new atoms group. |
Adds a new fragment to the document.
void gcp::Document::AddObject |
( |
Object * |
pObject |
) |
|
- Parameters:
-
Adds a new object to the document.
xmlDocPtr gcp::Document::BuildXMLTree |
( |
|
) |
const |
Builds the XML tree representing the document. The returned value must be freed using xmlFree.
- Returns:
- the new XML document.
bool gcp::Document::CanUndo |
( |
|
) |
[inline] |
- Returns:
- true if the undo stack is not empty.
Definition at line 322 of file gcp/document.h.
void gcp::Document::Clear |
( |
|
) |
[virtual] |
Empties a document and reinitialize it.
Reimplemented from gcu::Object.
- Parameters:
-
| name | the name of the new residue. |
| symbol | the symbol of the new residue. |
| molecule | a molecule with a pseudo atom which describes the structure of the residue. |
- Returns:
- the new Residue on success or NULL.
Reimplemented from gcu::Document.
void gcp::Document::DoPrint |
( |
GtkPrintOperation * |
print, |
|
|
GtkPrintContext * |
context, |
|
|
int |
page | |
|
) |
| | const [virtual] |
- Parameters:
-
| print | a GtkPrintOperation. |
| context | a GtkPrintContext. |
| page | the page to print. |
Prints the document.
Implements gcu::Printable.
void gcp::Document::ExportImage |
( |
std::string const & |
filename, |
|
|
const char * |
type, |
|
|
int |
resolution = -1 | |
|
) |
| | |
- Parameters:
-
| filename | the image filename. |
| type | a string representing the image type like "png", "svg", or "eps". |
| resolution | the resolution to use in the image for bitmaps or −1. |
Exports the current document as an image. The image is limited to the real bounds of the document. For bitmaps, the size is evaluated using the perceived screen resolution. If the default resolution (−1) is used, the resoution will be the screen resolution.
void gcp::Document::ExportOB |
( |
|
) |
const |
Exports the current file using OpenBabel. Only molecules will be exported.
void gcp::Document::FinishOperation |
( |
|
) |
|
Ends the current operation and pushes it on top of the undo stack. This method must be called after all changes have been done in the document and the changes described in the operation.
- Returns:
- the application owning the document.
Definition at line 336 of file gcp/document.h.
const gchar* gcp::Document::GetAuthor |
( |
|
) |
[inline] |
const gchar* gcp::Document::GetComment |
( |
|
) |
[inline] |
- Returns:
- the comment associated with the document.
Definition at line 258 of file gcp/document.h.
const GDate* gcp::Document::GetCreationDate |
( |
|
) |
[inline] |
- Returns:
- the date at which the document was first created.
Definition at line 242 of file gcp/document.h.
Operation* gcp::Document::GetCurrentOperation |
( |
|
) |
[inline] |
- Returns:
- the current undo/redo operation.
Definition at line 312 of file gcp/document.h.
bool gcp::Document::GetEditable |
( |
|
) |
[inline] |
- Returns:
- true if the document can be edited.
Definition at line 332 of file gcp/document.h.
const gchar* gcp::Document::GetFileName |
( |
|
) |
const [inline] |
- Returns:
- the current file name, actually the URI.
Definition at line 160 of file gcp/document.h.
GtkWindow* gcp::Document::GetGtkWindow |
( |
|
) |
[virtual] |
- Returns:
- GtkWindow displaying the document if any.
Reimplemented from gcu::Document.
const gchar* gcp::Document::GetLabel |
( |
|
) |
const |
- Returns:
- the window title.
const gchar* gcp::Document::GetMail |
( |
|
) |
[inline] |
double gcp::Document::GetMedianBondLength |
( |
|
) |
|
- Returns:
- the median value of bond lengths. This is used when importing data from a document with a different theme or from an other program to scale the data so that the bond lengths fit the themed bond length.
- Parameters:
-
| type | the type of the new undo/redo operation. |
- Returns:
- the new operation.
std::string gcp::Document::GetProperty |
( |
unsigned |
property |
) |
const [virtual] |
- Parameters:
-
Used when saving to get properties from document.. Supported properties for documents are: GCU_PROP_DOC_FILENAME, GCU_PROP_DOC_MIMETYPE, GCU_PROP_DOC_TITLE, GCU_PROP_DOC_COMMENT, GCU_PROP_DOC_CREATOR, GCU_PROP_DOC_CREATION_TIME, GCU_PROP_DOC_MODIFICATION_TIME, and GCU_PROP_THEME_BOND_LENGTH.
Reimplemented from gcu::Object.
bool gcp::Document::GetReadOnly |
( |
|
) |
[inline] |
- Returns:
- true if the file is read-only or false if it is writeable.
Definition at line 356 of file gcp/document.h.
gcu::Residue const* gcp::Document::GetResidue |
( |
char const * |
symbol, |
|
|
bool * |
ambiguous = NULL | |
|
) |
| | [virtual] |
- Parameters:
-
| symbol | the symbol for which a Residue* is searched. |
| ambiguous | where to store the boolean telling if the symbol is ambiguous or NULL. |
Documents might own not global residues with the samesymbol or name but a different meaning from the standard residue.
- Returns:
- the Residue* found or NULL.
Reimplemented from gcu::Document.
const GDate* gcp::Document::GetRevisionDate |
( |
|
) |
[inline] |
- Returns:
- the last date at which the document was modified.
Definition at line 246 of file gcp/document.h.
const gchar* gcp::Document::GetTitle |
( |
|
) |
const |
- Returns:
- the document title.
View* gcp::Document::GetView |
( |
void |
|
) |
[inline] |
GtkWidget* gcp::Document::GetWidget |
( |
|
) |
|
- Returns:
- the canvas widget where the document is displayed.
Window* gcp::Document::GetWindow |
( |
void |
|
) |
[inline] |
virtual double gcp::Document::GetYAlign |
( |
|
) |
[virtual] |
Used to retrieve the y coordinate for alignment. If the documetn contains just one objecst as a molecule or a reaction, it will reurn it's alignment value, otherwise 0 is returned.
- Returns:
- y coordinate used for alignment.
Reimplemented from gcu::Object.
bool gcp::Document::ImportOB |
( |
OpenBabel::OBMol & |
Mol |
) |
|
- Parameters:
-
| Mol | an OpenBabel molecule to import. |
Imports a molecule using OpenBabel.
virtual bool gcp::Document::Load |
( |
xmlNodePtr |
node |
) |
[virtual] |
- Parameters:
-
| node | the XML root node for the document. |
Loads the document from the XML tree representing it.
- Returns:
- true on success, false otherwise.
Reimplemented from gcu::Object.
void gcp::Document::LoadObjects |
( |
xmlNodePtr |
node |
) |
|
- Parameters:
-
| node | the XML node representing objects to add to the document. |
void gcp::Document::OnProperties |
( |
|
) |
|
Called by the framework when the user fires the File/Properties command.
void gcp::Document::OnRedo |
( |
|
) |
|
Called by the framework when the user fires the Edit/Redo command.
- Parameters:
-
| Signal | a SignalId |
| Child | the child which emitted the signal or NULL |
Called when a signal has been emitted by a child. Only OnThemeChangedSignal is relevant for documents.
- Returns:
- false since documents have no parent.
Reimplemented from gcu::Object.
void gcp::Document::OnThemeNamesChanged |
( |
|
) |
|
Called by the framework when the theme names have changed, i.e. a new theme has ben added, or a theme has been removed or renamed.
void gcp::Document::OnUndo |
( |
|
) |
|
Called by the framework when the user fires the Edit/Undo command.
void gcp::Document::ParseXMLTree |
( |
xmlDocPtr |
xml |
) |
|
- Parameters:
-
| xml | the XML document representing the GChemPaint document being loaded. |
Parses the XML tree and creates all objects it represents.
void gcp::Document::PopOperation |
( |
|
) |
|
Removes an operation from the udo stack and deletes it.
void gcp::Document::PushOperation |
( |
Operation * |
operation, |
|
|
bool |
undo = true | |
|
) |
| | |
- Parameters:
-
| operation | the operation to add. |
| undo | whether to put he operation on the undo or the redo stack. |
Adds the current operation to the appropriate task.
void gcp::Document::Remove |
( |
const char * |
Id |
) |
|
- Parameters:
-
| Id | the Id of the object to be removed. |
Removes a child object from the document, and deletes it.
void gcp::Document::Remove |
( |
Object * |
object |
) |
|
- Parameters:
-
| object | the object to remove. |
Removes a child object from the document, and deletes it.
void gcp::Document::Save |
( |
|
) |
const [virtual] |
void gcp::Document::SaveResidue |
( |
Residue const * |
r, |
|
|
xmlNodePtr |
node | |
|
) |
| | |
- Parameters:
-
| r | the residue to be saved. |
| node | the XML node to which add the saved residue if needed. |
GChemPaint saves the meaning of a residue the first time it is encountered, and maintains a list of saved residues to avoid duplicates.
void gcp::Document::SetActive |
( |
|
) |
|
Called by the framework when the document becomes the active one. Updates the menus according to the document state.
void gcp::Document::SetAuthor |
( |
const gchar * |
author |
) |
|
- Parameters:
-
| author | the new author name. |
Setes the document author name.
void gcp::Document::SetComment |
( |
const gchar * |
comment |
) |
|
- Parameters:
-
Sets the comment associated with the document any.
void gcp::Document::SetDirty |
( |
bool |
isDirty = true |
) |
|
Mark the document as dirty. On any attempt to close a dirty document, a dialog box is opened to ask the user if he wants to save the modified document or drop the changes.
Reimplemented from gcu::Object.
void gcp::Document::SetEditable |
( |
bool |
editable |
) |
[inline] |
- Parameters:
-
| editable | whether the document might be edited or not |
This method is used to lock a document and inhibit any change in it.
Definition at line 328 of file gcp/document.h.
void gcp::Document::SetFileName |
( |
std::string const & |
filename, |
|
|
const gchar * |
mime_type | |
|
) |
| | |
- Parameters:
-
| filename | the new file name (URI). |
| mime_type | the new mime type. |
Sets the new file name and its associated mime type.
void gcp::Document::SetLabel |
( |
const gchar * |
label |
) |
|
- Parameters:
-
| label | the new window title. |
Sets the label to use as window title.
void gcp::Document::SetLoading |
( |
bool |
loading |
) |
[inline] |
- Parameters:
-
| loading | whether the document is loading data or not. |
Used to inhibit undo/redo operation creation when loading.
Definition at line 431 of file gcp/document.h.
void gcp::Document::SetMail |
( |
const gchar * |
mail |
) |
|
- Parameters:
-
| mail | the new e-mail address. |
Sets the document author e-mail address.
bool gcp::Document::SetProperty |
( |
unsigned |
property, |
|
|
char const * |
value | |
|
) |
| | [virtual] |
- Parameters:
-
| property | the property id as defined in objprops.h |
| value | the property value as a string |
Used when loading to set properties. Supported properties for documents are: GCU_PROP_DOC_FILENAME, GCU_PROP_DOC_MIMETYPE, GCU_PROP_DOC_TITLE, GCU_PROP_DOC_COMMENT, GCU_PROP_DOC_CREATOR, GCU_PROP_DOC_CREATION_TIME, GCU_PROP_DOC_MODIFICATION_TIME, and GCU_PROP_THEME_BOND_LENGTH.
Reimplemented from gcu::Object.
void gcp::Document::SetReadOnly |
( |
bool |
ro |
) |
|
- Parameters:
-
| ro | whether the file is read-only or not. |
If ro is true, the File/Save menu item and corresponding button will be disabled.
void gcp::Document::SetTheme |
( |
Theme * |
theme |
) |
|
- Parameters:
-
| theme | the new theme for the document. |
Sets the theme to be used by the document. This will not change lengths of existing bonds or size of existing text.
void gcp::Document::SetTitle |
( |
const gchar * |
title |
) |
|
- Parameters:
-
The document title.
void gcp::Document::Update |
( |
|
) |
|
Updates the view for all objects which have been marked as dirty.
The documentation for this class was generated from the following file: