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 
42 struct RGBAColor {
44  rgba[0]=1.0; rgba[1]=1.0; rgba[2]=1.0; rgba[3]=1.0;
45  }
46  RGBAColor(float r, float g, float b, float a=1.0) {
47  rgba[0]=r; rgba[1]=g; rgba[2]=b; rgba[3]=a;
48  }
49  RGBAColor(const Color& c) {
50  rgba[0]=c.GetRed(); rgba[1]=c.GetGreen(); rgba[2]=c.GetBlue(); rgba[3]=c.GetAlpha();
51  }
52 
53  RGBAColor& operator=(const Color& c) {
54  rgba[0]=c.GetRed(); rgba[1]=c.GetGreen(); rgba[2]=c.GetBlue(); rgba[3]=c.GetAlpha();
55  return *this;
56  }
57 
58  operator Color () const {return RGBA(rgba[0],rgba[1],rgba[2],rgba[3]);}
59 
60  operator float* () {return rgba;}
61  operator const float* () const {return rgba;}
62  float rgba[4];
63 };
64 
66 {
67  AtomEntry() {}
68  AtomEntry(const mol::AtomHandle& a, float r, float v, const Color& c):
69  atom(a), color(c), radius(r), vdwr(v)
70  {
71  }
74  float radius;
75  float vdwr;
76 };
77 
78 // hash table for fast bond<->atom lookup
79 typedef std::map<long, AtomEntry> AtomEntryMap;
80 typedef std::vector<AtomEntry> AtomEntryList;
81 
83 {
84  BondEntry(const mol::BondHandle& b, float r,AtomEntry* ae1, AtomEntry* ae2):
85  bond(b),atom1(ae1),atom2(ae2),radius(r),
86  pp1(ae1 ? ae1->atom.GetPos() : geom::Vec3()),
87  pp2(ae2 ? ae2->atom.GetPos() : geom::Vec3())
88  {}
92  float radius;
93  geom::Vec3 pp1,pp2; // prev atom positions
94 };
95 
96 typedef std::vector<BondEntry> BondEntryList;
97 
98 void DoRenderBlur(BondEntryList& bl, float bf1, float bf2);
100 
102 public:
103  void Clear();
104  void AddAtom(const mol::AtomView& av);
105  void AddBond(const mol::BondHandle& bv);
106 
109  std::vector<long> orphan_atom_list;
110 };
111 
112 typedef boost::shared_ptr<GfxView> GfxViewPtr;
113 
116  RGBAColor color1, color2;
117  geom::Vec3 direction,normal;
118  float rad;
119  geom::Vec3 v0,v1,v2; // helper vectors
120  bool nflip;
121  int id;
122 };
123 
124 typedef std::vector<NodeEntry> NodeEntryList;
125 typedef std::vector<NodeEntryList> NodeEntryListList;
126 typedef boost::shared_ptr<NodeEntryListList> NodeEntryListListPtr;
127 
129  TraceProfileEntry(): v(), n(), id(0) {}
131  const geom::Vec3& n_): v(v_),n(n_),id(0) {}
135 };
136 
137 typedef std::vector<TraceProfileEntry> TraceProfile;
138 
141  position(0.0,0.0,0.0),
142  direction(0.0,0.0,1.0),
143  normal(0.0,1.0,0.0),
144  color1(1.0,1.0,1.0,1.0),
145  color2(1.0,1.0,1.0,1.0),
146  rad(1.0),
147  type(0),
148  type1(0),
149  type2(0),
150  frac(0.0),
151  running_length(0.0),
152  v0(1.0,0.0,0.0),
153  v1(0.0,1.0,0.0),
154  v2(0.0,0.0,1.0),
155  nflip(false),
156  id(-1)
157  {
158  }
160  const geom::Vec3& d,
161  const geom::Vec3& n,
162  float r,
163  const RGBAColor& c1, const RGBAColor& c2,
164  unsigned int t, int i):
165  position(p),direction(d),normal(n),color1(c1),color2(c2),rad(r),type(t),
166  type1(t),type2(t),frac(0.0),running_length(0.0),v0(),v1(),v2(),nflip(false),id(i)
167  {
168  }
170  const geom::Vec3& d,
171  const geom::Vec3& n,
172  float r,
173  const Color& c1, const Color& c2,
174  unsigned int t, int i):
175  position(p),direction(d),normal(n),color1(c1),color2(c2),rad(r),type(t),
176  type1(t),type2(t),frac(0.0),running_length(0.0),v0(),v1(),v2(),nflip(false),id(i)
177  {
178  }
179 
180  geom::Vec3 position,direction,normal;
181  RGBAColor color1, color2;
182  float rad;
183  unsigned int type;
184  unsigned int type1, type2;
185  float frac,running_length;
186  geom::Vec3 v0,v1,v2; // helper vectors
187  bool nflip;
188  int id;
189 };
190 
191 typedef std::vector<SplineEntry> SplineEntryList;
192 typedef std::vector<SplineEntryList> SplineEntryListList;
193 
195 public:
196  static SplineEntryList Generate(const SplineEntryList& entry_list,int nsub,uint color_blend_mode=0);
197 };
198 
199 }}} // ns
200 
201 
202 #endif
float rad
std::vector< AtomEntry > AtomEntryList
VertexID id
std::vector< NodeEntryList > NodeEntryListList
unsigned int type2
float GetBlue() const
retrieve blue
float running_length
Handle to atom datatype.
Definition: atom_handle.hh:37
geom::Vec3 pp2
std::vector< BondEntry > BondEntryList
std::vector< TraceProfileEntry > TraceProfile
geom::Vec3 v
float radius
geom::Vec3 n
float rad
std::vector< long > orphan_atom_list
SplineEntry()
AtomEntry * atom2
RGBAColor & operator=(const Color &c)
RGBAColor color2
SplineEntry(const geom::Vec3 &p, const geom::Vec3 &d, const geom::Vec3 &n, float r, const Color &c1, const Color &c2, unsigned int t, int i)
int id
float vdwr
BondEntry(const mol::BondHandle &b, float r, AtomEntry *ae1, AtomEntry *ae2)
#define DLLEXPORT_OST_GFX
geom::Vec3 position
bool nflip
AtomEntry * atom1
geom::Vec3 normal
std::vector< SplineEntryList > SplineEntryListList
void DoBlurSnapshot(BondEntryList &bl)
boost::shared_ptr< NodeEntryListList > NodeEntryListListPtr
boost::shared_ptr< GfxView > GfxViewPtr
AtomEntry(const mol::AtomHandle &a, float r, float v, const Color &c)
TraceProfileEntry()
mol::AtomHandle atom
std::vector< SplineEntry > SplineEntryList
std::vector< NodeEntry > NodeEntryList
SplineEntry(const geom::Vec3 &p, const geom::Vec3 &d, const geom::Vec3 &n, float r, const RGBAColor &c1, const RGBAColor &c2, unsigned int t, int i)
float GetRed() const
retrieve red
float GetAlpha() const
retrieve alpha
mol::AtomHandle atom
Color DLLEXPORT_OST_GFX RGBA(float r, float g, float b, float a)
RGBA color spec from floats (0.0-1.0)
TraceProfileEntry(const geom::Vec3 &v_, const geom::Vec3 &n_)
Three dimensional vector class, using Real precision.
Definition: vec3.hh:42
int id
float GetGreen() const
retrieve green
AtomEntry()
ImageStateConstModIPAlgorithm< ClearFnc > Clear
Definition: clear.hh:47
definition of AtomView
Definition: atom_view.hh:34
std::map< long, AtomEntry > AtomEntryMap
chemical bond
Definition: bond_handle.hh:34
mol::BondHandle bond
void DoRenderBlur(BondEntryList &bl, float bf1, float bf2)
unsigned int VertexID
Definition: vertex_array.hh:46
RGBAColor color
geom::Vec3 v2
RGBAColor color2
float radius
geom::Vec3 v2
RGBAColor(const Color &c)
bool nflip
RGBAColor(float r, float g, float b, float a=1.0)
unsigned int uint
Definition: base.hh:29
unsigned int type