fragment.h

00001 // -*- C++ -*-
00002 
00003 /* 
00004  * GChemPaint library
00005  * fragment.h 
00006  *
00007  * Copyright (C) 2002-2007 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 
00031 namespace gcp {
00032 
00033 class FragmentAtom;
00034 class Atom;
00035 
00036 class Fragment: public TextObject
00037 {
00038 friend class FragmentTool;
00039 public:
00040         Fragment ();
00041         Fragment (double x, double y);
00042         virtual ~Fragment ();
00043 
00044         void SetSelected (GtkWidget *w, int state);
00045         void Add (GtkWidget *w);
00046         void Update (GtkWidget *w);
00047         xmlNodePtr Save (xmlDocPtr xml);
00048         xmlNodePtr SaveSelection (xmlDocPtr xml);
00049         bool Load (xmlNodePtr);
00050         bool OnChanged (bool save);
00051         void AnalContent ();
00052         void AnalContent (unsigned start, unsigned &end);
00053         Object* GetAtomAt (double x, double y, double z = 0.);
00054         void Move (double x, double y, double z = 0);
00055         void Transform2D (gcu::Matrix2D& m, double x, double y);
00056         void OnChangeAtom ();
00057         Atom* GetAtom () {return (Atom*) m_Atom;}
00058         int GetElementAtPos (unsigned start, unsigned &end);
00059         int GetChargePosition (FragmentAtom *pAtom, unsigned char &Pos, double Angle, double &x, double &y);
00060         int GetAvailablePosition (double &x, double &y);
00061         bool GetPosition (double angle, double &x, double &y);
00062         bool Validate ();
00063         double GetYAlign ();
00064 
00065 private:
00066         bool SavePortion (xmlDocPtr xml, xmlNodePtr node, unsigned start, unsigned end);
00067 
00068 private:
00069         FragmentAtom *m_Atom;
00070         unsigned m_BeginAtom, m_EndAtom;
00071         int m_lbearing;
00072         double m_CHeight;
00073 };
00074 
00075 }       //      namespace gcp
00076 
00077 #endif  //GCHEMPAINT_FRAGMENT_H

Generated on Tue Mar 18 16:06:03 2008 for The Gnome Chemistry Utils by  doxygen 1.5.5