fragment.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 /* 
00004  * GChemPaint library
00005  * fragment.h 
00006  *
00007  * Copyright (C) 2002-2010 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         TextTag *Restrict (TextTag *tag);
00048 };
00049 
00050 class StoichiometryTextTag: public gccv::PositionTextTag
00051 {
00052 public:
00053         StoichiometryTextTag (double size);
00054         virtual ~StoichiometryTextTag ();
00055 
00056         TextTag *Restrict (TextTag *tag);
00057 };
00058 
00059 class FragmentAtom;
00060 class Atom;
00061 
00069 class Fragment: public TextObject
00070 {
00071 public:
00075         Fragment ();
00083         Fragment (double x, double y);
00087         virtual ~Fragment ();
00088 
00092         void AddItem ();
00096         void UpdateItem ();
00104         void SetSelected (int state);
00111         xmlNodePtr Save (xmlDocPtr xml) const;
00119         xmlNodePtr SaveSelection (xmlDocPtr xml) const;
00126         bool Load (xmlNodePtr node);
00132         bool OnChanged (bool save);
00136         void AnalContent ();
00143         void AnalContent (unsigned start, unsigned &end);
00152         Object* GetAtomAt (double x, double y, double z = 0.);
00160         void Move (double x, double y, double z = 0);
00168         void Transform2D (gcu::Matrix2D& m, double x, double y);
00173         void OnChangeAtom ();
00177         Atom* GetAtom () {return (Atom*) m_Atom;}
00185         int GetElementAtPos (unsigned start, unsigned &end);
00201         gccv::Anchor GetChargePosition (FragmentAtom *pAtom, unsigned char &Pos, double Angle, double &x, double &y);
00211         int GetAvailablePosition (double &x, double &y);
00219         bool GetPosition (double angle, double &x, double &y);
00223         bool Validate ();
00227         double GetYAlign ();
00228 
00238         bool SetProperty (unsigned property, char const *value);
00239 
00244         bool Analyze ();
00245 
00250         void Update ();
00251         gccv::Item *GetChargeItem ();
00252 
00253         std::string Name ();
00254 
00255         typedef enum {
00256                 Invalid,
00257                 Valid,
00258                 Valid2D,
00259                 Valid3D
00260         } Validity;
00261 
00262         typedef enum {
00263                 AutoMode,
00264                 NormalMode,
00265                 SubscriptMode,
00266                 SuperscriptMode,
00267                 ChargeMode,
00268                 StoichiometryMode
00269         } FragmentMode;
00270 
00271 private:
00272         bool SavePortion (xmlDocPtr xml, xmlNodePtr node, unsigned start, unsigned end) const;
00273 
00274 private:
00275         FragmentAtom *m_Atom;
00276         unsigned m_BeginAtom, m_EndAtom;
00277         double m_lbearing;
00278         double m_CHeight;
00279         bool m_Inversable;
00280 
00281 GCU_RO_PROP (Validity, Valid)
00282 GCU_PROP (FragmentMode, Mode)
00283 };
00284 
00285 }       //      namespace gcp
00286 
00287 #endif  //GCHEMPAINT_FRAGMENT_H
Generated by  doxygen 1.6.2-20100208