fragment.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /* 
00004  * GChemPaint library
00005  * fragment.h 
00006  *
00007  * Copyright (C) 2002-2008 Jean Bréfort <jean.brefort@normalesup.org>
00008  *
00009  * This program is free software; you can redistribute it and/or 
00010  * modify it under the terms of the GNU General Public License as 
00011  * published by the Free Software Foundation; either version 2 of the
00012  * License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00022  * USA
00023  */
00024 
00025 #ifndef GCHEMPAINT_FRAGMENT_H
00026 #define GCHEMPAINT_FRAGMENT_H
00027 
00028 #include "text-object.h"
00029 #include "libgnomecanvas/gnome-canvas.h"
00030 
00032 namespace gcp {
00033 
00034 class FragmentAtom;
00035 class Atom;
00036 
00044 class Fragment: public TextObject
00045 {
00046 public:
00050         Fragment ();
00058         Fragment (double x, double y);
00062         virtual ~Fragment ();
00063 
00067         void SetSelected (GtkWidget *w, int state);
00071         void Add (GtkWidget *w) const;
00075         void Update (GtkWidget *w) const;
00079         xmlNodePtr Save (xmlDocPtr xml) const;
00083         xmlNodePtr SaveSelection (xmlDocPtr xml) const;
00087         bool Load (xmlNodePtr);
00091         bool OnChanged (bool save);
00095         void AnalContent ();
00099         void AnalContent (unsigned start, unsigned &end);
00103         Object* GetAtomAt (double x, double y, double z = 0.);
00107         void Move (double x, double y, double z = 0);
00111         void Transform2D (gcu::Matrix2D& m, double x, double y);
00115         void OnChangeAtom ();
00119         Atom* GetAtom () {return (Atom*) m_Atom;}
00123         int GetElementAtPos (unsigned start, unsigned &end);
00127         int GetChargePosition (FragmentAtom *pAtom, unsigned char &Pos, double Angle, double &x, double &y);
00131         int GetAvailablePosition (double &x, double &y);
00135         bool GetPosition (double angle, double &x, double &y);
00139         bool Validate ();
00143         double GetYAlign ();
00144 
00147         bool SetProperty (unsigned property, char const *value);
00148 
00151         bool Analyze ();
00152 
00155         void Update ();
00156 
00157 private:
00158         bool SavePortion (xmlDocPtr xml, xmlNodePtr node, unsigned start, unsigned end) const;
00159 
00160 private:
00161         FragmentAtom *m_Atom;
00162         unsigned m_BeginAtom, m_EndAtom;
00163         int m_lbearing;
00164         double m_CHeight;
00165         bool m_Inversable;
00166 };
00167 
00168 }       //      namespace gcp
00169 
00170 #endif  //GCHEMPAINT_FRAGMENT_H

Generated on Sat Sep 13 18:32:53 2008 for The Gnome Chemistry Utils by  doxygen 1.5.6