OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
entity_detail.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_GFX_ENTITY_DETAIL_HH
20 #define OST_GFX_ENTITY_DETAIL_HH
21 
22 #include <map>
23 #include <vector>
24 
25 #include <boost/shared_ptr.hpp>
26 
27 #include <ost/geom/geom.hh>
28 
29 #include <ost/mol/atom_handle.hh>
30 #include <ost/mol/bond_handle.hh>
31 #include <ost/mol/query.hh>
32 
33 #include <ost/gfx/module_config.hh>
34 #include <ost/gfx/color.hh>
35 #include <ost/gfx/gfx.hh>
36 #include <ost/gfx/gfx_prim.hh>
37 #include <ost/gfx/entity_fw.hh>
38 
39 
40 namespace ost { namespace gfx { namespace impl {
41 
43 {
44  AtomEntry() {}
45  AtomEntry(const mol::AtomHandle& a, float r, float v, const Color& c):
46  atom(a),color(c),radius(r), vdwr(v) {}
49  float radius;
50  float vdwr;
51 };
52 
53 // hash table for fast bond<->atom lookup
54 typedef std::map<long, AtomEntry> AtomEntryMap;
55 typedef std::vector<AtomEntry> AtomEntryList;
56 
58 {
59  BondEntry(const mol::BondHandle& b, float r,AtomEntry* ae1, AtomEntry* ae2):
60  bond(b),atom1(ae1),atom2(ae2),radius(r),
61  pp1(ae1 ? ae1->atom.GetPos() : geom::Vec3()),
62  pp2(ae2 ? ae2->atom.GetPos() : geom::Vec3())
63  {}
67  float radius;
68  geom::Vec3 pp1,pp2; // prev atom positions
69 };
70 
71 typedef std::vector<BondEntry> BondEntryList;
72 
73 void DoRenderBlur(BondEntryList& bl, float bf1, float bf2);
75 
77 public:
78  void Clear();
79  void AddAtom(const mol::AtomView& av);
80  void AddBond(const mol::BondHandle& bv);
81 
84  std::vector<long> orphan_atom_list;
85 };
86 
87 typedef boost::shared_ptr<GfxView> GfxViewPtr;
88 
91  Color color1, color2;
92  geom::Vec3 direction,normal;
93  float rad;
94  geom::Vec3 v0,v1,v2; // helper vectors
95  bool nflip;
96  int id;
97 };
98 
99 typedef std::vector<NodeEntry> NodeEntryList;
100 typedef std::vector<NodeEntryList> NodeEntryListList;
101 typedef boost::shared_ptr<NodeEntryListList> NodeEntryListListPtr;
102 
104  TraceProfileEntry(): v(), n(), id(0) {}
106  const geom::Vec3& n_): v(v_),n(n_),id(0) {}
110 };
111 
112 typedef std::vector<TraceProfileEntry> TraceProfile;
113 
116  position(0.0,0.0,0.0),
117  direction(0.0,0.0,1.0),
118  normal(0.0,1.0,0.0),
119  color1(1.0,1.0,1.0,1.0),
120  color2(1.0,1.0,1.0,1.0),
121  rad(1.0),
122  type(0),
123  type1(0),
124  type2(0),
125  frac(0.0),
126  running_length(0.0),
127  v0(1.0,0.0,0.0),
128  v1(0.0,1.0,0.0),
129  v2(0.0,0.0,1.0),
130  nflip(false),
131  id(-1)
132  {
133  }
135  const geom::Vec3& d,
136  const geom::Vec3& n,
137  float r,
138  const Color& c1, const Color& c2,
139  unsigned int t, int i):
140  position(p),direction(d),normal(n),color1(c1),color2(c2),rad(r),type(t),
141  type1(t),type2(t),frac(0.0),running_length(0.0),v0(),v1(),v2(),nflip(false),id(i)
142  {
143  }
144 
145  geom::Vec3 position,direction,normal;
146  Color color1, color2;
147  float rad;
148  unsigned int type;
149  unsigned int type1, type2;
150  float frac,running_length;
151  geom::Vec3 v0,v1,v2; // helper vectors
152  bool nflip;
153  int id;
154 };
155 
156 typedef std::vector<SplineEntry> SplineEntryList;
157 typedef std::vector<SplineEntryList> SplineEntryListList;
158 
160 public:
161  static SplineEntryList Generate(const SplineEntryList& entry_list,int nsub,uint color_blend_mode=0);
162 };
163 
164 }}} // ns
165 
166 
167 #endif