00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OST_GFX_ENTITY_DETAIL_HH
00020 #define OST_GFX_ENTITY_DETAIL_HH
00021
00022 #include <map>
00023 #include <vector>
00024
00025 #include <boost/shared_ptr.hpp>
00026
00027 #include <ost/geom/geom.hh>
00028
00029 #include <ost/mol/atom_handle.hh>
00030 #include <ost/mol/bond_handle.hh>
00031 #include <ost/mol/query.hh>
00032
00033 #include <ost/gfx/module_config.hh>
00034 #include <ost/gfx/color.hh>
00035 #include <ost/gfx/gfx.hh>
00036 #include <ost/gfx/gfx_prim.hh>
00037 #include <ost/gfx/entity_fw.hh>
00038
00039
00040 namespace ost { namespace gfx { namespace impl {
00041
00042 struct RGBAColor {
00043 RGBAColor() {
00044 rgba[0]=1.0; rgba[1]=1.0; rgba[2]=1.0; rgba[3]=1.0;
00045 }
00046 RGBAColor(float r, float g, float b, float a=1.0) {
00047 rgba[0]=r; rgba[1]=g; rgba[2]=b; rgba[3]=a;
00048 }
00049 RGBAColor(const Color& c) {
00050 rgba[0]=c.GetRed(); rgba[1]=c.GetGreen(); rgba[2]=c.GetBlue(); rgba[3]=c.GetAlpha();
00051 }
00052
00053 RGBAColor& operator=(const Color& c) {
00054 rgba[0]=c.GetRed(); rgba[1]=c.GetGreen(); rgba[2]=c.GetBlue(); rgba[3]=c.GetAlpha();
00055 return *this;
00056 }
00057
00058 operator Color () const {return RGBA(rgba[0],rgba[1],rgba[2],rgba[3]);}
00059
00060 operator float* () {return rgba;}
00061 operator const float* () const {return rgba;}
00062 float rgba[4];
00063 };
00064
00065 struct DLLEXPORT_OST_GFX AtomEntry
00066 {
00067 AtomEntry() {}
00068 AtomEntry(const mol::AtomHandle& a, float r, float v, const Color& c):
00069 atom(a), color(c), radius(r), vdwr(v)
00070 {
00071 }
00072 mol::AtomHandle atom;
00073 RGBAColor color;
00074 float radius;
00075 float vdwr;
00076 };
00077
00078
00079 typedef std::map<long, AtomEntry> AtomEntryMap;
00080 typedef std::vector<AtomEntry> AtomEntryList;
00081
00082 struct DLLEXPORT_OST_GFX BondEntry
00083 {
00084 BondEntry(const mol::BondHandle& b, float r,AtomEntry* ae1, AtomEntry* ae2):
00085 bond(b),atom1(ae1),atom2(ae2),radius(r),
00086 pp1(ae1 ? ae1->atom.GetPos() : geom::Vec3()),
00087 pp2(ae2 ? ae2->atom.GetPos() : geom::Vec3())
00088 {}
00089 mol::BondHandle bond;
00090 AtomEntry* atom1;
00091 AtomEntry* atom2;
00092 float radius;
00093 geom::Vec3 pp1,pp2;
00094 };
00095
00096 typedef std::vector<BondEntry> BondEntryList;
00097
00098 void DoRenderBlur(BondEntryList& bl, float bf1, float bf2);
00099 void DoBlurSnapshot(BondEntryList& bl);
00100
00101 class DLLEXPORT_OST_GFX GfxView {
00102 public:
00103 void Clear();
00104 void AddAtom(const mol::AtomView& av);
00105 void AddBond(const mol::BondHandle& bv);
00106
00107 AtomEntryMap atom_map;
00108 BondEntryList bond_list;
00109 std::vector<long> orphan_atom_list;
00110 };
00111
00112 typedef boost::shared_ptr<GfxView> GfxViewPtr;
00113
00114 struct DLLEXPORT_OST_GFX NodeEntry {
00115 mol::AtomHandle atom;
00116 RGBAColor color1, color2;
00117 geom::Vec3 direction,normal;
00118 float rad;
00119 geom::Vec3 v0,v1,v2;
00120 bool nflip;
00121 int id;
00122 };
00123
00124 typedef std::vector<NodeEntry> NodeEntryList;
00125 typedef std::vector<NodeEntryList> NodeEntryListList;
00126 typedef boost::shared_ptr<NodeEntryListList> NodeEntryListListPtr;
00127
00128 struct DLLEXPORT_OST_GFX TraceProfileEntry {
00129 TraceProfileEntry(): v(), n(), id(0) {}
00130 TraceProfileEntry(const geom::Vec3& v_,
00131 const geom::Vec3& n_): v(v_),n(n_),id(0) {}
00132 geom::Vec3 v;
00133 geom::Vec3 n;
00134 VertexID id;
00135 };
00136
00137 typedef std::vector<TraceProfileEntry> TraceProfile;
00138
00139 struct DLLEXPORT_OST_GFX SplineEntry {
00140 SplineEntry():
00141 position(0.0,0.0,0.0),
00142 direction(0.0,0.0,1.0),
00143 normal(0.0,1.0,0.0),
00144 color1(1.0,1.0,1.0,1.0),
00145 color2(1.0,1.0,1.0,1.0),
00146 rad(1.0),
00147 type(0),
00148 type1(0),
00149 type2(0),
00150 frac(0.0),
00151 running_length(0.0),
00152 v0(1.0,0.0,0.0),
00153 v1(0.0,1.0,0.0),
00154 v2(0.0,0.0,1.0),
00155 nflip(false),
00156 id(-1)
00157 {
00158 }
00159 SplineEntry(const geom::Vec3& p,
00160 const geom::Vec3& d,
00161 const geom::Vec3& n,
00162 float r,
00163 const RGBAColor& c1, const RGBAColor& c2,
00164 unsigned int t, int i):
00165 position(p),direction(d),normal(n),color1(c1),color2(c2),rad(r),type(t),
00166 type1(t),type2(t),frac(0.0),running_length(0.0),v0(),v1(),v2(),nflip(false),id(i)
00167 {
00168 }
00169 SplineEntry(const geom::Vec3& p,
00170 const geom::Vec3& d,
00171 const geom::Vec3& n,
00172 float r,
00173 const Color& c1, const Color& c2,
00174 unsigned int t, int i):
00175 position(p),direction(d),normal(n),color1(c1),color2(c2),rad(r),type(t),
00176 type1(t),type2(t),frac(0.0),running_length(0.0),v0(),v1(),v2(),nflip(false),id(i)
00177 {
00178 }
00179
00180 geom::Vec3 position,direction,normal;
00181 RGBAColor color1, color2;
00182 float rad;
00183 unsigned int type;
00184 unsigned int type1, type2;
00185 float frac,running_length;
00186 geom::Vec3 v0,v1,v2;
00187 bool nflip;
00188 int id;
00189 };
00190
00191 typedef std::vector<SplineEntry> SplineEntryList;
00192 typedef std::vector<SplineEntryList> SplineEntryListList;
00193
00194 class DLLEXPORT_OST_GFX Spline {
00195 public:
00196 static SplineEntryList Generate(const SplineEntryList& entry_list,int nsub,uint color_blend_mode=0);
00197 };
00198
00199 }}}
00200
00201
00202 #endif