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
00047 class ChargeTextTag: public gccv::PositionTextTag
00048 {
00049 public:
00055 ChargeTextTag (double size);
00059 virtual ~ChargeTextTag ();
00060
00067 TextTag *Restrict (TextTag *tag);
00068 };
00069
00076 class StoichiometryTextTag: public gccv::PositionTextTag
00077 {
00078 public:
00084 StoichiometryTextTag (double size);
00088 virtual ~StoichiometryTextTag ();
00089
00096 TextTag *Restrict (TextTag *tag);
00097 };
00098
00099 class FragmentAtom;
00100 class Atom;
00101
00109 class Fragment: public TextObject
00110 {
00111 public:
00115 Fragment ();
00123 Fragment (double x, double y);
00127 virtual ~Fragment ();
00128
00132 void AddItem ();
00136 void UpdateItem ();
00144 void SetSelected (int state);
00151 xmlNodePtr Save (xmlDocPtr xml) const;
00159 xmlNodePtr SaveSelection (xmlDocPtr xml) const;
00166 bool Load (xmlNodePtr node);
00172 bool OnChanged (bool save);
00176 void AnalContent ();
00183 void AnalContent (unsigned start, unsigned &end);
00192 Object* GetAtomAt (double x, double y, double z = 0.);
00200 void Move (double x, double y, double z = 0);
00208 void Transform2D (gcu::Matrix2D& m, double x, double y);
00213 void OnChangeAtom ();
00217 Atom* GetAtom () {return (Atom*) m_Atom;}
00225 int GetElementAtPos (unsigned start, unsigned &end);
00241 gccv::Anchor GetChargePosition (FragmentAtom *pAtom, unsigned char &Pos, double Angle, double &x, double &y);
00251 int GetAvailablePosition (double &x, double &y);
00259 bool GetPosition (double angle, double &x, double &y);
00263 bool Validate ();
00267 double GetYAlign ();
00268
00278 bool SetProperty (unsigned property, char const *value);
00279
00284 bool Analyze ();
00285
00290 void Update ();
00291
00295 gccv::Item *GetChargeItem ();
00296
00300 std::string Name ();
00308 typedef enum {
00312 Invalid,
00316 Valid,
00320 Valid2D,
00324 Valid3D
00325 } Validity;
00326
00333 typedef enum {
00337 AutoMode,
00341 NormalMode,
00345 SubscriptMode,
00349 SuperscriptMode,
00353 ChargeMode,
00357 StoichiometryMode
00358 } FragmentMode;
00359
00360 private:
00361 bool SavePortion (xmlDocPtr xml, xmlNodePtr node, unsigned start, unsigned end) const;
00362
00363 private:
00364 FragmentAtom *m_Atom;
00365 unsigned m_BeginAtom, m_EndAtom;
00366 double m_lbearing;
00367 double m_CHeight;
00368 bool m_Inversable;
00369
00373 GCU_RO_PROP (Validity, Valid)
00385 GCU_PROP (FragmentMode, Mode)
00386 };
00387
00388 }
00389
00390 #endif //GCHEMPAINT_FRAGMENT_H