fragment.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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 }
00285
00286 #endif //GCHEMPAINT_FRAGMENT_H