fragment.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /* 
00004  * GChemPaint library
00005  * fragment.h 
00006  *
00007  * Copyright (C) 2002-2009 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 <gccv/item-client.h>
00030 #include <gccv/text-tag.h>
00031 
00032 namespace gccv {
00033         class Text;
00034 }
00035 
00037 namespace gcp {
00038 
00039 extern gccv::Tag ChargeTag, StoichiometryTag;
00040 
00041 class ChargeTextTag: public gccv::PositionTextTag
00042 {
00043 public:
00044         ChargeTextTag (double size);
00045         virtual ~ChargeTextTag ();
00046 };
00047 
00048 class StoichiometryTextTag: public gccv::PositionTextTag
00049 {
00050 public:
00051         StoichiometryTextTag (double size);
00052         virtual ~StoichiometryTextTag ();
00053 };
00054 
00055 class FragmentAtom;
00056 class Atom;
00057 
00065 class Fragment: public TextObject
00066 {
00067 public:
00071         Fragment ();
00079         Fragment (double x, double y);
00083         virtual ~Fragment ();
00084 
00088         void AddItem ();
00092         void UpdateItem ();
00100         void SetSelected (int state);
00107         xmlNodePtr Save (xmlDocPtr xml) const;
00115         xmlNodePtr SaveSelection (xmlDocPtr xml) const;
00122         bool Load (xmlNodePtr node);
00128         bool OnChanged (bool save);
00132         void AnalContent ();
00139         void AnalContent (unsigned start, unsigned &end);
00148         Object* GetAtomAt (double x, double y, double z = 0.);
00156         void Move (double x, double y, double z = 0);
00164         void Transform2D (gcu::Matrix2D& m, double x, double y);
00169         void OnChangeAtom ();
00173         Atom* GetAtom () {return (Atom*) m_Atom;}
00181         int GetElementAtPos (unsigned start, unsigned &end);
00202         int GetChargePosition (FragmentAtom *pAtom, unsigned char &Pos, double Angle, double &x, double &y);
00212         int GetAvailablePosition (double &x, double &y);
00220         bool GetPosition (double angle, double &x, double &y);
00224         bool Validate ();
00228         double GetYAlign ();
00229 
00239         bool SetProperty (unsigned property, char const *value);
00240 
00245         bool Analyze ();
00246 
00251         void Update ();
00252 
00253         typedef enum {
00254                 Invalid,
00255                 Valid,
00256                 Valid2D,
00257                 Valid3D
00258         } Validity;
00259 
00260         typedef enum {
00261                 AutoMode,
00262                 NormalMode,
00263                 SubscriptMode,
00264                 SuperscriptMode,
00265                 ChargeMode,
00266                 StoichiometryMode
00267         } FragmentMode;
00268 
00269 private:
00270         bool SavePortion (xmlDocPtr xml, xmlNodePtr node, unsigned start, unsigned end) const;
00271 
00272 private:
00273         FragmentAtom *m_Atom;
00274         unsigned m_BeginAtom, m_EndAtom;
00275         int m_lbearing;
00276         double m_CHeight;
00277         bool m_Inversable;
00278 
00279 GCU_RO_PROP (gccv::Text *, TextItem)
00280 GCU_RO_PROP (Validity, Valid)
00281 GCU_PROP (FragmentMode, Mode)
00282 };
00283 
00284 }       //      namespace gcp
00285 
00286 #endif  //GCHEMPAINT_FRAGMENT_H

Generated on Thu Jun 25 13:24:19 2009 for The Gnome Chemistry Utils by  doxygen 1.5.9