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 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 }
00286
00287 #endif //GCHEMPAINT_FRAGMENT_H