CGO.h (pymol-open-source-2.2.0) | : | CGO.h (pymol-open-source-2.3.0) | ||
---|---|---|---|---|
skipping to change at line 26 | skipping to change at line 26 | |||
*/ | */ | |||
#ifndef _H_CGO | #ifndef _H_CGO | |||
#define _H_CGO | #define _H_CGO | |||
#include"Base.h" | #include"Base.h" | |||
#include"Ray.h" | #include"Ray.h" | |||
#include"Setting.h" | #include"Setting.h" | |||
#include"os_gl.h" | #include"os_gl.h" | |||
#include"Rep.h" | #include"Rep.h" | |||
#include"ObjectGadgetRamp.h" | #include"ObjectGadgetRamp.h" | |||
#include <vector> | ||||
#include <unordered_map> | #include <unordered_map> | |||
#include <typeinfo> | #include <typeinfo> | |||
#include <type_traits> | #include <type_traits> | |||
#include <memory> | #include <memory> | |||
#include "GenericBuffer.h" | #include "GenericBuffer.h" | |||
#include <set> | #include <set> | |||
/* Compiled Graphics Library for simple graphics objects | /* Compiled Graphics Library for simple graphics objects | |||
in floating point three-space, with the goal of achieving | in floating point three-space, with the goal of achieving | |||
quick and easy rendering in multiple environments without the | quick and easy rendering in multiple environments without the | |||
skipping to change at line 255 | skipping to change at line 256 | |||
#define CGO_VERTEX_BEGIN_LINE_STRIP_SZ 3 | #define CGO_VERTEX_BEGIN_LINE_STRIP_SZ 3 | |||
#define CGO_INTERPOLATED 0x3E | #define CGO_INTERPOLATED 0x3E | |||
#define CGO_INTERPOLATED_SZ 1 | #define CGO_INTERPOLATED_SZ 1 | |||
#define CGO_VERTEX_CROSS 0x3F | #define CGO_VERTEX_CROSS 0x3F | |||
#define CGO_VERTEX_CROSS_SZ 3 | #define CGO_VERTEX_CROSS_SZ 3 | |||
#define CGO_VERTEX_ATTRIB_4UB_IF_PICKING 0x40 | #define CGO_VERTEX_ATTRIB_4UB_IF_PICKING 0x40 | |||
#define CGO_CUSTOM_CYLINDER_ALPHA 0x41 | ||||
#define CGO_MASK 0x7F | #define CGO_MASK 0x7F | |||
#define CGO_LIGHTING 0x0B50 | #define CGO_LIGHTING 0x0B50 | |||
#define CGO_VERTEX_ARRAY 0x01 | #define CGO_VERTEX_ARRAY 0x01 | |||
#define CGO_NORMAL_ARRAY 0x02 | #define CGO_NORMAL_ARRAY 0x02 | |||
#define CGO_COLOR_ARRAY 0x04 | #define CGO_COLOR_ARRAY 0x04 | |||
#define CGO_PICK_COLOR_ARRAY 0x08 | #define CGO_PICK_COLOR_ARRAY 0x08 | |||
#define CGO_ACCESSIBILITY_ARRAY 0x10 | #define CGO_ACCESSIBILITY_ARRAY 0x10 | |||
#define CGO_TEX_COORD_ARRAY 0x20 | #define CGO_TEX_COORD_ARRAY 0x20 | |||
skipping to change at line 314 | skipping to change at line 317 | |||
int narrays; | int narrays; | |||
int nverts; | int nverts; | |||
int get_data_length() const { return narrays * nverts; }; | int get_data_length() const { return narrays * nverts; }; | |||
}; | }; | |||
struct buffers_indexed : op_with_data, op_with_draw_buffers { | struct buffers_indexed : op_with_data, op_with_draw_buffers { | |||
static const int op_code = CGO_DRAW_BUFFERS_INDEXED; | static const int op_code = CGO_DRAW_BUFFERS_INDEXED; | |||
buffers_indexed(int _mode, short _arrays, int _nindices, | buffers_indexed(int _mode, short _arrays, int _nindices, | |||
int _nverts, size_t _vboid, size_t _iboid, int _n_data, si ze_t _pickvboid = 0) : | int _nverts, size_t _vboid, size_t _iboid, int _n_data, si ze_t _pickvboid = 0) : | |||
mode(_mode), arraybits(_arrays), narrays(0), nindices(_nindices), | mode(_mode), arraybits(_arrays), narrays(0), nindices(_nindices), | |||
nverts(_nverts), vboid(_vboid), iboid(_iboid), n_data(_n_data), pickvboi | nverts(_nverts), vboid(_vboid), iboid(_iboid) | |||
d(_pickvboid), pickcolorsset(0) { | , pickvboid(_pickvboid) | |||
, pickcolorsset(0) | ||||
, n_data(_n_data) | ||||
{ | ||||
short bit; | short bit; | |||
for (bit = 0; bit < 4; bit++){ | for (bit = 0; bit < 4; bit++){ | |||
if ((1 << bit) & arraybits){ | if ((1 << bit) & arraybits){ | |||
narrays++; | narrays++; | |||
} | } | |||
} | } | |||
if (arraybits & CGO_ACCESSIBILITY_ARRAY) narrays++; | if (arraybits & CGO_ACCESSIBILITY_ARRAY) narrays++; | |||
if (arraybits & CGO_COLOR_ARRAY) narrays++; | if (arraybits & CGO_COLOR_ARRAY) narrays++; | |||
} | } | |||
int mode; | int mode; | |||
skipping to change at line 427 | skipping to change at line 434 | |||
vec3 screen_min; | vec3 screen_min; | |||
vec3 screen_max; | vec3 screen_max; | |||
vec4 text_extent; | vec4 text_extent; | |||
float relative_mode; | float relative_mode; | |||
vec3 target_pos; | vec3 target_pos; | |||
}; | }; | |||
struct labels : op_with_data, op_with_draw_buffers { | struct labels : op_with_data, op_with_draw_buffers { | |||
static const int op_code = CGO_DRAW_LABELS; | static const int op_code = CGO_DRAW_LABELS; | |||
labels(int _ntextures, size_t _vboid, size_t _pickvboid) : | labels(int _ntextures, size_t _vboid, size_t _pickvboid) : | |||
ntextures(_ntextures), vboid(_vboid), pickvboid(_pickvboid), pickcolorss | vboid(_vboid) | |||
et(0) {}; | , pickvboid(_pickvboid) | |||
, ntextures(_ntextures) | ||||
, pickcolorsset(0) | ||||
{} | ||||
size_t vboid; | size_t vboid; | |||
size_t pickvboid; | size_t pickvboid; | |||
int ntextures; | int ntextures; | |||
int pickcolorsset; | int pickcolorsset; | |||
int get_data_length() const { return ntextures * 18; }; | int get_data_length() const { return ntextures * 18; }; | |||
}; | }; | |||
struct connectors : op_with_draw_buffers { | struct connectors : op_with_draw_buffers { | |||
static const int op_code = CGO_DRAW_CONNECTORS; | static const int op_code = CGO_DRAW_CONNECTORS; | |||
connectors(int _nconnectors, size_t _vboid) : | connectors(int _nconnectors, size_t _vboid) : | |||
skipping to change at line 501 | skipping to change at line 512 | |||
which_attr_idx = _which_attr_idx; | which_attr_idx = _which_attr_idx; | |||
npickattrs = _npickattrs; | npickattrs = _npickattrs; | |||
}; | }; | |||
size_t vboid; | size_t vboid; | |||
int which_attr_idx; | int which_attr_idx; | |||
int npickattrs; | int npickattrs; | |||
}; | }; | |||
struct custom : op_with_data, op_with_draw_buffers { | struct custom : op_with_data, op_with_draw_buffers { | |||
static const int op_code = CGO_DRAW_CUSTOM; | static const int op_code = CGO_DRAW_CUSTOM; | |||
custom(int _mode, int _nverts, size_t _vboid, size_t _pickvboid, int _vertsp | custom(int _mode, int _nverts, size_t _vboid, size_t _pickvboid, | |||
erpickinfo=1, int _npickbufs=1, size_t _iboid=0, int _nindices=0) : | int _vertsperpickinfo = 1, int _npickbufs = 1, size_t _iboid = 0, | |||
mode(_mode), nverts(_nverts), vboid(_vboid), pickvboid(_pickvboid), npickb | int _nindices = 0) | |||
ufs(_npickbufs), | : mode(_mode), nverts(_nverts), vboid(_vboid), pickvboid(_pickvboid), | |||
vertsperpickinfo(_vertsperpickinfo), iboid(_iboid), nindices(_nindices), | pickcolorsset(0), iboid(_iboid), nindices(_nindices), | |||
pickcolorsset(0){}; | npickbufs(_npickbufs), vertsperpickinfo(_vertsperpickinfo){}; | |||
int mode; | int mode; | |||
int nverts; | int nverts; | |||
size_t vboid; | size_t vboid; | |||
size_t pickvboid; | size_t pickvboid; | |||
int pickcolorsset; | int pickcolorsset; | |||
size_t iboid; | size_t iboid; | |||
int nindices; | int nindices; | |||
int npickbufs; | int npickbufs; | |||
int vertsperpickinfo; | int vertsperpickinfo; | |||
int get_data_length() const { return npickbufs*nverts*2/vertsperpickinfo; }; | int get_data_length() const { return npickbufs*nverts*2/vertsperpickinfo; }; | |||
skipping to change at line 570 | skipping to change at line 584 | |||
copy3f(_origin, origin); | copy3f(_origin, origin); | |||
copy3f(_axis, axis); | copy3f(_axis, axis); | |||
}; | }; | |||
float origin[3], axis[3], tube_size; | float origin[3], axis[3], tube_size; | |||
int cap; | int cap; | |||
}; | }; | |||
struct shadercylinder2ndcolor { | struct shadercylinder2ndcolor { | |||
static const int op_code = CGO_SHADER_CYLINDER_WITH_2ND_COLOR; | static const int op_code = CGO_SHADER_CYLINDER_WITH_2ND_COLOR; | |||
shadercylinder2ndcolor(CGO *I, const float *_origin, const float *_axis, c onst float _radius, | shadercylinder2ndcolor(CGO *I, const float *_origin, const float *_axis, c onst float _radius, | |||
int _cap, const float *_color2, Pickable *pickcolor | int _cap, const float *_color2, Pickable *pickcolor | |||
2 = NULL); | 2 = NULL, | |||
const float alpha = 1.0f); | ||||
float origin[3], axis[3], tube_size; | float origin[3], axis[3], tube_size; | |||
int cap; | int cap; | |||
float color2[3]; | float color2[3]; | |||
unsigned int pick_color_index; | unsigned int pick_color_index; | |||
int pick_color_bond; | int pick_color_bond; | |||
float alpha; | ||||
}; | }; | |||
struct sausage { | struct sausage { | |||
static const int op_code = CGO_SAUSAGE; | static const int op_code = CGO_SAUSAGE; | |||
sausage(const float *_vertex1, const float *_vertex2, const float _radius, const float *_color1, const float *_color2) : | sausage(const float *_vertex1, const float *_vertex2, const float _radius, const float *_color1, const float *_color2) : | |||
radius(_radius) { | radius(_radius) { | |||
copy3f(_vertex1, vertex1); | copy3f(_vertex1, vertex1); | |||
copy3f(_vertex2, vertex2); | copy3f(_vertex2, vertex2); | |||
copy3f(_color1, color1); | copy3f(_color1, color1); | |||
copy3f(_color2, color2); | copy3f(_color2, color2); | |||
skipping to change at line 614 | skipping to change at line 630 | |||
custom_cylinder(const float *_vertex1, const float *_vertex2, const float _r adius, const float *_color1, const float *_color2, const float _cap1, const floa t _cap2) : | custom_cylinder(const float *_vertex1, const float *_vertex2, const float _r adius, const float *_color1, const float *_color2, const float _cap1, const floa t _cap2) : | |||
radius(_radius), cap1(_cap1), cap2(_cap2) { | radius(_radius), cap1(_cap1), cap2(_cap2) { | |||
copy3f(_vertex1, vertex1); | copy3f(_vertex1, vertex1); | |||
copy3f(_vertex2, vertex2); | copy3f(_vertex2, vertex2); | |||
copy3f(_color1, color1); | copy3f(_color1, color1); | |||
copy3f(_color2, color2); | copy3f(_color2, color2); | |||
}; | }; | |||
float vertex1[3], vertex2[3], radius, color1[3], color2[3]; | float vertex1[3], vertex2[3], radius, color1[3], color2[3]; | |||
float cap1, cap2; | float cap1, cap2; | |||
}; | }; | |||
struct custom_cylinder_alpha { | ||||
static const int op_code = CGO_CUSTOM_CYLINDER_ALPHA; | ||||
custom_cylinder_alpha(const float *_vertex1, const float *_vertex2, const | ||||
float _radius, const float *_color1, const float *_color2, | ||||
const float _alpha1, const float _alpha2, | ||||
const float _cap1, const float _cap2) : | ||||
radius(_radius), cap1(_cap1), cap2(_cap2) { | ||||
copy3f(_vertex1, vertex1); | ||||
copy3f(_vertex2, vertex2); | ||||
copy3f(_color1, color1); | ||||
copy3f(_color2, color2); | ||||
color1[3] = _alpha1; | ||||
color2[3] = _alpha2; | ||||
}; | ||||
float vertex1[3], vertex2[3], radius, color1[4], color2[4]; | ||||
float cap1, cap2; | ||||
}; | ||||
}; | }; | |||
}; | }; | |||
class CGO { | class CGO { | |||
public: | public: | |||
PyMOLGlobals *G { nullptr }; | PyMOLGlobals *G { nullptr }; | |||
float *op { nullptr }; | float *op { nullptr }; | |||
int c { 0 }; | int c { 0 }; | |||
int z_flag { 0 }; | int z_flag { 0 }; | |||
float z_min { 0 }, z_max { 0 }; | float z_min { 0 }, z_max { 0 }; | |||
skipping to change at line 825 | skipping to change at line 858 | |||
bool CGOOptimizeToVBONotIndexed(CGO ** I); | bool CGOOptimizeToVBONotIndexed(CGO ** I); | |||
CGO *CGOOptimizeToVBONotIndexed(const CGO * I, int est, bool addshaders=true, fl oat **returnedData=NULL); | CGO *CGOOptimizeToVBONotIndexed(const CGO * I, int est, bool addshaders=true, fl oat **returnedData=NULL); | |||
#define CGOOptimizeToVBONotIndexedWithReturnedData CGOOptimizeToVBONotIndexed | #define CGOOptimizeToVBONotIndexedWithReturnedData CGOOptimizeToVBONotIndexed | |||
#define CGOOptimizeToVBONotIndexedNoShader(I, est) CGOOptimizeToVBONotIndexed(I, est, false) | #define CGOOptimizeToVBONotIndexedNoShader(I, est) CGOOptimizeToVBONotIndexed(I, est, false) | |||
CGO *CGOOptimizeSpheresToVBONonIndexed(const CGO * I, int est=0, bool addshaders =false, CGO *leftOverCGO=NULL); | CGO *CGOOptimizeSpheresToVBONonIndexed(const CGO * I, int est=0, bool addshaders =false, CGO *leftOverCGO=NULL); | |||
#define CGOOptimizeSpheresToVBONonIndexedNoShader(I, est) CGOOptimizeSpheresToVB ONonIndexed(I, est, false, NULL) | #define CGOOptimizeSpheresToVBONonIndexedNoShader(I, est) CGOOptimizeSpheresToVB ONonIndexed(I, est, false, NULL) | |||
void CGOReserve(CGO * ptr, int est); | ||||
int CGOCheckComplex(CGO * I); | int CGOCheckComplex(CGO * I); | |||
int CGOPreloadFonts(CGO * I); | int CGOPreloadFonts(CGO * I); | |||
int CGOCheckForText(CGO * I); | int CGOCheckForText(CGO * I); | |||
int CGOFromFloatArray(CGO * I, const float *src, int len); | int CGOFromFloatArray(CGO * I, const float *src, int len); | |||
int CGOBegin(CGO * I, int mode); | int CGOBegin(CGO * I, int mode); | |||
int CGOEnd(CGO * I); | int CGOEnd(CGO * I); | |||
skipping to change at line 951 | skipping to change at line 982 | |||
void CGORenderGLAlpha(CGO * I, RenderInfo * info, bool calcDepth); | void CGORenderGLAlpha(CGO * I, RenderInfo * info, bool calcDepth); | |||
int CGORenderRay(CGO * I, CRay * ray, RenderInfo * info, const float *color, Obj ectGadgetRamp *ramp, CSetting * set1, CSetting * set2); | int CGORenderRay(CGO * I, CRay * ray, RenderInfo * info, const float *color, Obj ectGadgetRamp *ramp, CSetting * set1, CSetting * set2); | |||
void CGOReset(CGO * I); | void CGOReset(CGO * I); | |||
void CGOSetUseShader(CGO *I, int use_shader); | void CGOSetUseShader(CGO *I, int use_shader); | |||
PyObject *CGOAsPyList(CGO * I); | PyObject *CGOAsPyList(CGO * I); | |||
CGO *CGONewFromPyList(PyMOLGlobals * G, PyObject * list, int version, bool shoul dCombine=true); | CGO *CGONewFromPyList(PyMOLGlobals * G, PyObject * list, int version, bool shoul dCombine=true); | |||
void SetCGOPickColor(float *colorVals, int nverts, int pl, unsigned int index, i nt bond); | void SetCGOPickColor(float *colorVals, int nverts, int pl, unsigned int index, i nt bond); | |||
int CGOPickColor(CGO * I, unsigned int index, int bond); | int CGOPickColor(CGO * I, unsigned int index, int bond); | |||
float *CGO_add_GLfloat(CGO * I, int c); | ||||
float *CGOGetNextDrawBufferedIndex(float *cgo_op, int optype=CGO_DRAW_BUFFERS_IN DEXED); | float *CGOGetNextDrawBufferedIndex(float *cgo_op, int optype=CGO_DRAW_BUFFERS_IN DEXED); | |||
#define CGOGetNextDrawBufferedNotIndex(cgo_op) CGOGetNextDrawBufferedIndex(cgo_o p, CGO_DRAW_BUFFERS_NOT_INDEXED) | #define CGOGetNextDrawBufferedNotIndex(cgo_op) CGOGetNextDrawBufferedIndex(cgo_o p, CGO_DRAW_BUFFERS_NOT_INDEXED) | |||
float *CGOGetNextOp(float *cgo_op, int optype); | float *CGOGetNextOp(float *cgo_op, int optype); | |||
int CGOAppend(CGO *dest, const CGO *source, bool stopAtEnd=true); | int CGOAppend(CGO *dest, const CGO *source, bool stopAtEnd=true); | |||
inline int CGOAppendNoStop(CGO *dest, const CGO *source) { | inline int CGOAppendNoStop(CGO *dest, const CGO *source) { | |||
return CGOAppend(dest, source, false); | return CGOAppend(dest, source, false); | |||
} | } | |||
int CGOCountNumberOfOperationsOfTypeDEBUG(const CGO *I, int optype); | int CGOCountNumberOfOperationsOfTypeDEBUG(const CGO *I, int optype); | |||
int CGOCountNumberOfOperationsOfType(const CGO *I, int op); | int CGOCountNumberOfOperationsOfType(const CGO *I, int op); | |||
int CGOCountNumberOfOperationsOfTypeN(const CGO *I, const std::set<int> &optype, bool debug=false); | int CGOCountNumberOfOperationsOfTypeN(const CGO *I, const std::set<int> &optype, bool debug=false); | |||
int CGOCountNumberOfOperationsOfTypeN(const CGO *I, const std::map<int, int> &op type); | int CGOCountNumberOfOperationsOfTypeN(const CGO *I, const std::map<int, int> &op type); | |||
bool CGOHasOperations(const CGO *I); | bool CGOHasOperations(const CGO *I); | |||
bool CGOHasOperationsOfType(const CGO *I, int optype); | bool CGOHasOperationsOfType(const CGO *I, int optype); | |||
bool CGOHasOperationsOfTypeN(const CGO *I, const std::set<int> &optype); | bool CGOHasOperationsOfTypeN(const CGO *I, const std::set<int> &optype); | |||
bool CGOHasCylinderOperations(const CGO *I); | bool CGOHasCylinderOperations(const CGO *I); | |||
bool CGOHasSphereOperations(const CGO *I); | bool CGOHasSphereOperations(const CGO *I); | |||
bool CGOFilterOutOperationsOfTypeNInto(const CGO *I, CGO *cgo, const std::set<in t> &optype); | ||||
bool CGOFilterOutCylinderOperationsInto(const CGO *I, CGO *cgo); | bool CGOFilterOutCylinderOperationsInto(const CGO *I, CGO *cgo); | |||
bool CGOCheckWhetherToFree(PyMOLGlobals * G, CGO *I); | bool CGOCheckWhetherToFree(PyMOLGlobals * G, CGO *I); | |||
CGO *CGOConvertLinesToShaderCylinders(const CGO * I, int est); | CGO *CGOConvertLinesToShaderCylinders(const CGO * I, int est); | |||
CGO *CGOSplitUpLinesForPicking(const CGO * I); | CGO *CGOSplitUpLinesForPicking(const CGO * I); | |||
CGO *CGOConvertLinesToTrilines(const CGO * I, bool addshaders=true); | CGO *CGOConvertLinesToTrilines(const CGO * I, bool addshaders=true); | |||
CGO *CGOConvertToLabelShader(const CGO *I, CGO * addTo); | CGO *CGOConvertToLabelShader(const CGO *I, CGO * addTo); | |||
int CGOChangeShadersTo(CGO *I, int frommode, int tomode); | int CGOChangeShadersTo(CGO *I, int frommode, int tomode); | |||
skipping to change at line 1052 | skipping to change at line 1081 | |||
CGO *CGOConvertToTrilinesShader(const CGO *I, CGO *addTo, bool add_color=true); | CGO *CGOConvertToTrilinesShader(const CGO *I, CGO *addTo, bool add_color=true); | |||
CGO *CGOConvertToLinesShader(const CGO *I, CGO *addTo, bool add_color=true); | CGO *CGOConvertToLinesShader(const CGO *I, CGO *addTo, bool add_color=true); | |||
CGO *CGOConvertLinesToCylinderShader(const CGO *I, CGO *addTo, bool add_color = true); | CGO *CGOConvertLinesToCylinderShader(const CGO *I, CGO *addTo, bool add_color = true); | |||
CGO *CGOConvertCrossesToCylinderShader(const CGO *I, CGO *addTo, float cross_siz e); | CGO *CGOConvertCrossesToCylinderShader(const CGO *I, CGO *addTo, float cross_siz e); | |||
CGO *CGOConvertCrossesToLinesShader(const CGO *I, CGO *addTo, float cross_size); | CGO *CGOConvertCrossesToLinesShader(const CGO *I, CGO *addTo, float cross_size); | |||
CGO *CGOConvertCrossesToTrilinesShader(const CGO *I, CGO *addTo, float cross_siz e); | CGO *CGOConvertCrossesToTrilinesShader(const CGO *I, CGO *addTo, float cross_siz e); | |||
CGO *CGOConvertShaderCylindersToCylinderShader(const CGO *I, CGO *addTo); | CGO *CGOConvertShaderCylindersToCylinderShader(const CGO *I, CGO *addTo); | |||
bool AssignNewPickColor(CGO *cgo, unsigned int &i, Picking ** pick, PickContext * context, unsigned char *color, unsigned int index, int bond); | bool AssignNewPickColor(CGO *cgo, unsigned int &i, std::vector<Picking>* pick, P ickContext * context, unsigned char *color, unsigned int index, int bond); | |||
#endif | #endif | |||
End of changes. 12 change blocks. | ||||
17 lines changed or deleted | 42 lines changed or added |