The Gnome Chemistry Utils  0.14.0
fragment.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  * GChemPaint library
5  * fragment.h
6  *
7  * Copyright (C) 2002-2011 Jean Bréfort <jean.brefort@normalesup.org>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 3 of the
12  * License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
22  * USA
23  */
24 
25 #ifndef GCHEMPAINT_FRAGMENT_H
26 #define GCHEMPAINT_FRAGMENT_H
27 
28 #include "text-object.h"
29 #include <gccv/item-client.h>
30 #include <gccv/text-tag.h>
31 
32 namespace gccv {
33  class Text;
34 }
35 
37 namespace gcp {
38 
39 extern gccv::Tag ChargeTag, StoichiometryTag;
40 
48 {
49 public:
55  ChargeTextTag (double size);
59  virtual ~ChargeTextTag ();
60 
67  TextTag *Restrict (TextTag *tag);
68 };
69 
77 {
78 public:
84  StoichiometryTextTag (double size);
88  virtual ~StoichiometryTextTag ();
89 
96  TextTag *Restrict (TextTag *tag);
97 };
98 
99 class FragmentAtom;
100 class Atom;
101 
109 class Fragment: public TextObject
110 {
111 public:
115  Fragment ();
123  Fragment (double x, double y);
127  virtual ~Fragment ();
128 
132  void AddItem ();
136  void UpdateItem ();
144  void SetSelected (int state);
151  xmlNodePtr Save (xmlDocPtr xml) const;
159  xmlNodePtr SaveSelection (xmlDocPtr xml) const;
166  bool Load (xmlNodePtr node);
172  bool OnChanged (bool save);
176  void AnalContent ();
183  void AnalContent (unsigned start, unsigned &end);
192  Object* GetAtomAt (double x, double y, double z = 0.);
200  void Move (double x, double y, double z = 0);
208  void Transform2D (gcu::Matrix2D& m, double x, double y);
213  void OnChangeAtom ();
217  Atom *GetAtom () {return reinterpret_cast < Atom * > (m_Atom);}
218  Atom const *GetAtom () const {return reinterpret_cast < Atom const * > (m_Atom);}
226  int GetElementAtPos (unsigned start, unsigned &end);
242  gccv::Anchor GetChargePosition (FragmentAtom *pAtom, unsigned char &Pos, double Angle, double &x, double &y);
252  int GetAvailablePosition (double &x, double &y);
260  bool GetPosition (double angle, double &x, double &y);
264  bool Validate ();
268  double GetYAlign ();
269 
279  bool SetProperty (unsigned property, char const *value);
280 
285  bool Analyze ();
286 
291  void Update ();
292 
297 
301  std::string Name ();
310  bool GetCoords (double *x, double *y, double *z = NULL) const;
318  typedef enum {
335  } Validity;
336 
343  typedef enum {
368  } FragmentMode;
369 
370 private:
371  bool SavePortion (xmlDocPtr xml, xmlNodePtr node, unsigned start, unsigned end) const;
372 
373 private:
374  FragmentAtom *m_Atom;
375  unsigned m_BeginAtom, m_EndAtom;
376  double m_lbearing;
377  double m_CHeight;
378  bool m_Inversable;
379 
396 };
397 
398 } // namespace gcp
399 
400 #endif //GCHEMPAINT_FRAGMENT_H