RepLabel.cpp (pymol-open-source-2.2.0) | : | RepLabel.cpp (pymol-open-source-2.3.0) | ||
---|---|---|---|---|
skipping to change at line 76 | skipping to change at line 76 | |||
float bg_alpha; // 22: 1.0 - label_bg_transparency | float bg_alpha; // 22: 1.0 - label_bg_transparency | |||
float bg_color[3]; // 23-25: label_bg_color | float bg_color[3]; // 23-25: label_bg_color | |||
float connector_width; // 26: label_connector_width | float connector_width; // 26: label_connector_width | |||
float connector_ext_len; // 27: label_connector_ext_length | float connector_ext_len; // 27: label_connector_ext_length | |||
}; | }; | |||
typedef struct RepLabel { | typedef struct RepLabel { | |||
Rep R; | Rep R; | |||
// VItemType *V; | // VItemType *V; | |||
float *V; | float *V; | |||
int *L; | lexidx_t *L; | |||
int N; | int N; | |||
int OutlineColor; | int OutlineColor; | |||
CGO *shaderCGO; | CGO *shaderCGO; | |||
int texture_font_size; | int texture_font_size; | |||
} RepLabel; | } RepLabel; | |||
#define SHADERCGO I->shaderCGO | #define SHADERCGO I->shaderCGO | |||
#include"ObjectMolecule.h" | #include"ObjectMolecule.h" | |||
void RepLabelFree(RepLabel * I); | ||||
static void RepLabelInit(RepLabel *I) | static void RepLabelInit(RepLabel *I) | |||
{ | { | |||
I->shaderCGO = NULL; | I->shaderCGO = NULL; | |||
I->texture_font_size = 0; | I->texture_font_size = 0; | |||
} | } | |||
static | ||||
void RepLabelFree(RepLabel * I) | void RepLabelFree(RepLabel * I) | |||
{ | { | |||
RepPurge(&I->R); | RepPurge(&I->R); | |||
FreeP(I->V); | FreeP(I->V); | |||
FreeP(I->L); | FreeP(I->L); | |||
if (I->shaderCGO){ | if (I->shaderCGO){ | |||
CGOFree(I->shaderCGO); | CGOFree(I->shaderCGO); | |||
} | } | |||
OOFreeP(I); | OOFreeP(I); | |||
} | } | |||
skipping to change at line 211 | skipping to change at line 210 | |||
addXYtoVertex(-dirv[0], -dirv[1], xn, yn, pt2, pt2E); | addXYtoVertex(-dirv[0], -dirv[1], xn, yn, pt2, pt2E); | |||
addXYtoVertex(-bottomext * linev[0], -bottomext * linev[1], xn, yn, pt2E, pts[ 3]); | addXYtoVertex(-bottomext * linev[0], -bottomext * linev[1], xn, yn, pt2E, pts[ 3]); | |||
ray->triangle3fv(pts[0], pts[1], pts[2], zn, zn, zn, color, color, color); | ray->triangle3fv(pts[0], pts[1], pts[2], zn, zn, zn, color, color, color); | |||
ray->setLastToNoLighting(noLighting); | ray->setLastToNoLighting(noLighting); | |||
ray->triangle3fv(pts[1], pts[2], pts[3], zn, zn, zn, color, color, color); | ray->triangle3fv(pts[1], pts[2], pts[3], zn, zn, zn, color, color, color); | |||
ray->setLastToNoLighting(noLighting); | ray->setLastToNoLighting(noLighting); | |||
} | } | |||
#ifndef PURE_OPENGL_ES_2 | #ifndef PURE_OPENGL_ES_2 | |||
static | ||||
void drawLine2DCross(float cw, float x1, float y1, float x2, float y2, float *cr oss){ | void drawLine2DCross(float cw, float x1, float y1, float x2, float y2, float *cr oss){ | |||
float lvect[3]; | float lvect[3]; | |||
float nzn[3] = { 0.f, 0.f, 1.f }; | float nzn[3] = { 0.f, 0.f, 1.f }; | |||
lvect[0] = x2 - x1; | lvect[0] = x2 - x1; | |||
lvect[1] = y2 - y1; | lvect[1] = y2 - y1; | |||
normalize2f(lvect); | normalize2f(lvect); | |||
cross_product3f(lvect, nzn, cross); | cross_product3f(lvect, nzn, cross); | |||
mult3f(cross, cw, cross); | mult3f(cross, cw, cross); | |||
glBegin(GL_TRIANGLE_STRIP); | glBegin(GL_TRIANGLE_STRIP); | |||
glVertex3f(x1 + cross[0], y1 + cross[1], 0.f); | glVertex3f(x1 + cross[0], y1 + cross[1], 0.f); | |||
glVertex3f(x2 + cross[0], y2 + cross[1], 0.f); | glVertex3f(x2 + cross[0], y2 + cross[1], 0.f); | |||
glVertex3f(x1 - cross[0], y1 - cross[1], 0.f); | glVertex3f(x1 - cross[0], y1 - cross[1], 0.f); | |||
glVertex3f(x2 - cross[0], y2 - cross[1], 0.f); | glVertex3f(x2 - cross[0], y2 - cross[1], 0.f); | |||
glEnd(); | glEnd(); | |||
} | } | |||
void drawLine2D(float cw, float x1, float y1, float x2, float y2){ | ||||
float cross[3]; | ||||
drawLine2DCross(cw, x1, y1, x2, y2, cross); | ||||
} | ||||
/* Draw Line/Polygon from point (x1,y1) to (x2,y2) with different Z's, where the current Z is | /* Draw Line/Polygon from point (x1,y1) to (x2,y2) with different Z's, where the current Z is | |||
at world point curpt with the line starting at (x1,y1), and the second point (x2,y2) is | at world point curpt with the line starting at (x1,y1), and the second point (x2,y2) is | |||
at the world point pt (i.e., the offset is embedded into the matrix convMatri x computed from | at the world point pt (i.e., the offset is embedded into the matrix convMatri x computed from | |||
SceneGenerateMatrixToAnotherZFromZ */ | SceneGenerateMatrixToAnotherZFromZ */ | |||
static | ||||
void drawLineToPointInWorldCross(PyMOLGlobals *G, float cw, float x1, float y1, float x2, float y2, float *cross, float *pt, float *curpt){ | void drawLineToPointInWorldCross(PyMOLGlobals *G, float cw, float x1, float y1, float x2, float y2, float *cross, float *pt, float *curpt){ | |||
float lvect[3]; | float lvect[3]; | |||
float nzn[3] = { 0.f, 0.f, 1.f }; | float nzn[3] = { 0.f, 0.f, 1.f }; | |||
float convMatrix[16]; | float convMatrix[16]; | |||
float tmppt[3]; | float tmppt[3]; | |||
SceneGenerateMatrixToAnotherZFromZ(G, convMatrix, curpt, pt); | SceneGenerateMatrixToAnotherZFromZ(G, convMatrix, curpt, pt); | |||
lvect[0] = x2 - x1; | lvect[0] = x2 - x1; | |||
lvect[1] = y2 - y1; | lvect[1] = y2 - y1; | |||
normalize2f(lvect); | normalize2f(lvect); | |||
skipping to change at line 272 | skipping to change at line 269 | |||
glVertex3fv(tmppt); | glVertex3fv(tmppt); | |||
glEnd(); | glEnd(); | |||
} | } | |||
#define CLIP_LEFT 1 | #define CLIP_LEFT 1 | |||
#define CLIP_RIGHT 2 | #define CLIP_RIGHT 2 | |||
#define CLIP_TOP 4 | #define CLIP_TOP 4 | |||
#define CLIP_BOTTOM 8 | #define CLIP_BOTTOM 8 | |||
static | ||||
short CLIPt(float denom, float num, float *tE, float *tL, short *clipedges, shor t bitmask){ | short CLIPt(float denom, float num, float *tE, float *tL, short *clipedges, shor t bitmask){ | |||
float t; | float t; | |||
if (denom > 0){ | if (denom > 0){ | |||
t = num / denom; | t = num / denom; | |||
if (t > *tL) | if (t > *tL) | |||
return 0; | return 0; | |||
else if (t > *tE){ | else if (t > *tE){ | |||
*tE = t; | *tE = t; | |||
*clipedges = bitmask; | *clipedges = bitmask; | |||
} | } | |||
skipping to change at line 296 | skipping to change at line 294 | |||
else if (t < *tL){ | else if (t < *tL){ | |||
*tL = t; | *tL = t; | |||
*clipedges = bitmask; | *clipedges = bitmask; | |||
} | } | |||
} else if (num > 0) | } else if (num > 0) | |||
return 0; | return 0; | |||
return 1; | return 1; | |||
} | } | |||
/* This function clips the line inside of the (-xmax,-ymax, xmax, ymax) rectangl e */ | /* This function clips the line inside of the (-xmax,-ymax, xmax, ymax) rectangl e */ | |||
static | ||||
void Clip2D(float xmax, float ymax, float *x0, float *y0, float *x1, float *y1, short *visible, short *clipedges){ | void Clip2D(float xmax, float ymax, float *x0, float *y0, float *x1, float *y1, short *visible, short *clipedges){ | |||
float dx = *x1 - *x0; | float dx = *x1 - *x0; | |||
float dy = *y1 - *y0; | float dy = *y1 - *y0; | |||
*visible = 0; | *visible = 0; | |||
*clipedges = 0; | *clipedges = 0; | |||
if (dx == 0.f && dy == 0.f && fabs(*x0) < xmax && fabs(*y0) < ymax) | if (dx == 0.f && dy == 0.f && fabs(*x0) < xmax && fabs(*y0) < ymax) | |||
*visible = 1; | *visible = 1; | |||
else { | else { | |||
float tE = 0.f, tL = 1.f; | float tE = 0.f, tL = 1.f; | |||
if (CLIPt(dx, -xmax - *x0, &tE, &tL, clipedges, CLIP_LEFT)) // left | if (CLIPt(dx, -xmax - *x0, &tE, &tL, clipedges, CLIP_LEFT)) // left | |||
skipping to change at line 323 | skipping to change at line 322 | |||
*y1 = *y0 + tL * dy; | *y1 = *y0 + tL * dy; | |||
} | } | |||
if (tE > 0.f){ | if (tE > 0.f){ | |||
*x0 =+ tE * dx; | *x0 =+ tE * dx; | |||
*y0 += tE * dy; | *y0 += tE * dy; | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
} | } | |||
static | ||||
void Clip2DLine(float xmax, float ymax, float *line, short *visible, short *clip edges){ | void Clip2DLine(float xmax, float ymax, float *line, short *visible, short *clip edges){ | |||
Clip2D(xmax, ymax, &line[0], &line[1], &line[2], &line[3], visible, clipedges) ; | Clip2D(xmax, ymax, &line[0], &line[1], &line[2], &line[3], visible, clipedges) ; | |||
} | } | |||
static | ||||
void glVertex3fTransformed(float *convMatrix, float x, float y, float z){ | void glVertex3fTransformed(float *convMatrix, float x, float y, float z){ | |||
float tmppt[3] = { x, y, z }; | float tmppt[3] = { x, y, z }; | |||
MatrixTransformC44f3f(convMatrix, tmppt, tmppt); | MatrixTransformC44f3f(convMatrix, tmppt, tmppt); | |||
glVertex3fv(tmppt); | glVertex3fv(tmppt); | |||
} | } | |||
static | ||||
void drawLineToPointInWorldCrossClip(PyMOLGlobals *G, int label_z_target, float cw, float x1, float y1, float x2, float y2, float *cross, float *pt, float *curp t, float cx, float cy){ | void drawLineToPointInWorldCrossClip(PyMOLGlobals *G, int label_z_target, float cw, float x1, float y1, float x2, float y2, float *cross, float *pt, float *curp t, float cx, float cy){ | |||
float lvect[3]; | float lvect[3]; | |||
float nzn[3] = { 0.f, 0.f, 1.f }; | float nzn[3] = { 0.f, 0.f, 1.f }; | |||
float convMatrix[16]; | float convMatrix[16]; | |||
short visible1, edges1, visible2, edges2; | short visible1, edges1, visible2, edges2; | |||
float line1[4], line2[4]; | float line1[4], line2[4]; | |||
if (!label_z_target){ | if (!label_z_target){ | |||
SceneGenerateMatrixToAnotherZFromZ(G, convMatrix, curpt, pt); | SceneGenerateMatrixToAnotherZFromZ(G, convMatrix, curpt, pt); | |||
} else { | } else { | |||
skipping to change at line 390 | skipping to change at line 393 | |||
glVertex3f(line1[2], line1[3], 0.f); | glVertex3f(line1[2], line1[3], 0.f); | |||
glVertex3fTransformed(convMatrix, cross[0], cross[1], 0.f); | glVertex3fTransformed(convMatrix, cross[0], cross[1], 0.f); | |||
glVertex3f(corner[0], corner[1], 0.f); | glVertex3f(corner[0], corner[1], 0.f); | |||
glVertex3fTransformed(convMatrix, - cross[0], - cross[1], 0.f); | glVertex3fTransformed(convMatrix, - cross[0], - cross[1], 0.f); | |||
glVertex3f(line2[2], line2[3], 0.f); | glVertex3f(line2[2], line2[3], 0.f); | |||
glEnd(); | glEnd(); | |||
} | } | |||
} | } | |||
} | } | |||
void drawLineToPointInWorld(PyMOLGlobals *G, float cw, float x1, float y1, float | static | |||
x2, float y2, float *pt, float *curpt){ | ||||
float cross[3]; | ||||
drawLineToPointInWorldCross(G, cw, x1, y1, x2, y2, cross, pt, curpt); | ||||
} | ||||
void drawLine2DCheckZTargetCross(PyMOLGlobals *G, short label_z_target, float *p t, float *curpt, float cw, float x1, float y1, float x2, float y2, float *cross) { | void drawLine2DCheckZTargetCross(PyMOLGlobals *G, short label_z_target, float *p t, float *curpt, float cw, float x1, float y1, float x2, float y2, float *cross) { | |||
if (label_z_target){ | if (label_z_target){ | |||
drawLine2DCross(cw, x1, y1, x2, y2, cross); | drawLine2DCross(cw, x1, y1, x2, y2, cross); | |||
} else { | } else { | |||
drawLineToPointInWorldCross(G, cw, x1, y1, x2, y2, cross, pt, curpt); | drawLineToPointInWorldCross(G, cw, x1, y1, x2, y2, cross, pt, curpt); | |||
} | } | |||
} | } | |||
static | ||||
void drawLine2DCheckZTarget(PyMOLGlobals *G, short label_z_target, float *pt, fl oat *curpt, float cw, float x1, float y1, float x2, float y2){ | void drawLine2DCheckZTarget(PyMOLGlobals *G, short label_z_target, float *pt, fl oat *curpt, float cw, float x1, float y1, float x2, float y2){ | |||
float cross[3]; | float cross[3]; | |||
drawLine2DCheckZTargetCross(G, label_z_target, pt, curpt, cw, x1, y1, x2, y2, cross); | drawLine2DCheckZTargetCross(G, label_z_target, pt, curpt, cw, x1, y1, x2, y2, cross); | |||
} | } | |||
static | ||||
void drawLine2DCheckZTargetClip(PyMOLGlobals *G, short label_z_target, float *pt , float *curpt, float cw, float x1, float y1, float x2, float y2, float cx, floa t cy){ | void drawLine2DCheckZTargetClip(PyMOLGlobals *G, short label_z_target, float *pt , float *curpt, float cw, float x1, float y1, float x2, float y2, float cx, floa t cy){ | |||
float cross[3]; | float cross[3]; | |||
drawLineToPointInWorldCrossClip(G, label_z_target, cw, x1, y1, x2, y2, cross, pt, curpt, cx, cy); | drawLineToPointInWorldCrossClip(G, label_z_target, cw, x1, y1, x2, y2, cross, pt, curpt, cx, cy); | |||
} | } | |||
void drawLineAsGeometryWithOffsets(float *pt1, float *pt2, float *spt1, float *s pt2, float *xn, float *yn, float *zn, float line_width, float topext, float bott omext, float *dirv){ | void drawLineAsGeometryWithOffsets(float *pt1, float *pt2, float *spt1, float *s pt2, float *xn, float *yn, float *zn, float line_width, float topext, float bott omext, float *dirv){ | |||
float pt1E[3], pt2E[3]; | float pt1E[3], pt2E[3]; | |||
float tmpV[3], tmpV2[3], linev[3]; | float tmpV[3], tmpV2[3], linev[3]; | |||
float nzn[3] = { 0.f, 0.f, 1.f }; | float nzn[3] = { 0.f, 0.f, 1.f }; | |||
copy3f(pt1, pt1E); | copy3f(pt1, pt1E); | |||
skipping to change at line 448 | skipping to change at line 449 | |||
addXYtoVertex(bottomext * linev[0], bottomext * linev[1], xn, yn, pt1E, pt1E); | addXYtoVertex(bottomext * linev[0], bottomext * linev[1], xn, yn, pt1E, pt1E); | |||
glVertex3fv(pt1E); | glVertex3fv(pt1E); | |||
addXYtoVertex(-dirv[0], -dirv[1], xn, yn, pt2, pt2E); | addXYtoVertex(-dirv[0], -dirv[1], xn, yn, pt2, pt2E); | |||
addXYtoVertex(-bottomext * linev[0], -bottomext * linev[1], xn, yn, pt2E, pt2E ); | addXYtoVertex(-bottomext * linev[0], -bottomext * linev[1], xn, yn, pt2E, pt2E ); | |||
glVertex3fv(pt2E); | glVertex3fv(pt2E); | |||
glEnd(); | glEnd(); | |||
} | } | |||
static | ||||
void RepLabelRenderBackgroundInImmediate(PyMOLGlobals *G, RepLabel *I, float *v, int draw_var, float *tCenterPt, short relativeMode, float *xn, float *yn, | void RepLabelRenderBackgroundInImmediate(PyMOLGlobals *G, RepLabel *I, float *v, int draw_var, float *tCenterPt, short relativeMode, float *xn, float *yn, | |||
float *PmvMatrix, float *RotMatrix, int screenwidth, int screenheight, float *screenWorldOffset, float *indentFactor, | float *PmvMatrix, float *RotMatrix, int screenwidth, int screenheight, float *screenWorldOffset, float *indentFactor, | |||
float text_width, float text_height, flo at font_size){ | float text_width, float text_height, flo at font_size){ | |||
float pos[3], *labelpos = TextGetLabelPushPos(G); | float pos[3], *labelpos = TextGetLabelPushPos(G); | |||
float hwidth = text_width / 2.f, hheight = text_height / 2.f; | float hwidth = text_width / 2.f, hheight = text_height / 2.f; | |||
short label_connector_mode = (draw_var & 8) ? 1 : (draw_var & 16) ? 2 : (draw_ var & 32) ? 3 : (draw_var & 64) ? 4 : 0; | short label_connector_mode = (draw_var & 8) ? 1 : (draw_var & 16) ? 2 : (draw_ var & 32) ? 3 : (draw_var & 64) ? 4 : 0; | |||
float cw = *(v + 26) / 2.f; | float cw = *(v + 26) / 2.f; | |||
short label_z_target = relativeMode & 8; | short label_z_target = relativeMode & 8; | |||
float indentFactorT[2] = { indentFactor[0]*text_width/2.f, indentFactor[1]*tex t_height/2.f }; | float indentFactorT[2] = { indentFactor[0]*text_width/2.f, indentFactor[1]*tex t_height/2.f }; | |||
skipping to change at line 1114 | skipping to change at line 1116 | |||
} | } | |||
} | } | |||
static | static | |||
void RepLabelRenderRay(RepLabel * I, RenderInfo * info){ | void RepLabelRenderRay(RepLabel * I, RenderInfo * info){ | |||
#ifndef _PYMOL_NO_RAY | #ifndef _PYMOL_NO_RAY | |||
PyMOLGlobals *G = I->R.G; | PyMOLGlobals *G = I->R.G; | |||
CRay *ray = info->ray; | CRay *ray = info->ray; | |||
int c = I->N; | int c = I->N; | |||
float *v = I->V; | float *v = I->V; | |||
int *l = I->L; | lexidx_t *l = I->L; | |||
int font_id = SettingGet_i(G, I->R.cs->Setting, I->R.obj->Setting, | int font_id = SettingGet_i(G, I->R.cs->Setting, I->R.obj->Setting, | |||
cSetting_label_font_id); | cSetting_label_font_id); | |||
float font_size = SettingGet_f(G, I->R.cs->Setting, I->R.obj->Setting, | float font_size = SettingGet_f(G, I->R.cs->Setting, I->R.obj->Setting, | |||
cSetting_label_size); | cSetting_label_size); | |||
if(c) { | if(c) { | |||
char *st; | const char *st; | |||
TextSetOutlineColor(G, I->OutlineColor); | TextSetOutlineColor(G, I->OutlineColor); | |||
while(c--) { | while(c--) { | |||
if(*l) { | if(*l) { | |||
float xn[3], yn[3], tCenter[3], offpt[3]; | float xn[3], yn[3], tCenter[3], offpt[3]; | |||
short relativeMode = ((short)*(v + 15)); | short relativeMode = ((short)*(v + 15)); | |||
int draw_var = 127 & (int)*(v + 21); | int draw_var = 127 & (int)*(v + 21); | |||
copy3f(v + 6, tCenter); | copy3f(v + 6, tCenter); | |||
SceneGetCenter(G, offpt); | SceneGetCenter(G, offpt); | |||
RayGetScaledAxes(ray, xn, yn); | RayGetScaledAxes(ray, xn, yn); | |||
st = OVLexicon_FetchCString(G->Lexicon, *l); | st = LexStr(G, *l); | |||
TextSetLabelBkgrdInfo(G, *(v + 16), *(v + 17), (v + 18)); | TextSetLabelBkgrdInfo(G, *(v + 16), *(v + 17), (v + 18)); | |||
if (relativeMode & 8){ // label_z_target, adjust z to target | if (relativeMode & 8){ // label_z_target, adjust z to target | |||
TextGetLabelPos(G)[0] = (SceneGetDepth(G, v+3) - .5) * 2.f; | TextGetLabelPos(G)[0] = (SceneGetDepth(G, v+3) - .5) * 2.f; | |||
TextSetLabelPosIsSet(G, 1); | TextSetLabelPosIsSet(G, 1); | |||
} else if (relativeMode & 6){ // label_relative_mode 1 or 2, i.e., scree n stabilized, adjust z | } else if (relativeMode & 6){ // label_relative_mode 1 or 2, i.e., scree n stabilized, adjust z | |||
if (relativeMode & 4){ // label_relative_mode = 2 | if (relativeMode & 4){ // label_relative_mode = 2 | |||
tCenter[0] = (tCenter[0] / ray->Width) * 2.f - 1.f; | tCenter[0] = (tCenter[0] / ray->Width) * 2.f - 1.f; | |||
tCenter[1] = (tCenter[1] / ray->Height) * 2.f - 1.f; | tCenter[1] = (tCenter[1] / ray->Height) * 2.f - 1.f; | |||
} | } | |||
skipping to change at line 1173 | skipping to change at line 1175 | |||
v += 28; | v += 28; | |||
l++; | l++; | |||
} | } | |||
} | } | |||
#endif | #endif | |||
} | } | |||
static void RepLabelRender(RepLabel * I, RenderInfo * info) | static void RepLabelRender(RepLabel * I, RenderInfo * info) | |||
{ | { | |||
CRay *ray = info->ray; | CRay *ray = info->ray; | |||
Picking **pick = info->pick; | auto pick = info->pick; | |||
PyMOLGlobals *G = I->R.G; | PyMOLGlobals *G = I->R.G; | |||
float *v = I->V; | float *v = I->V; | |||
int c = I->N; | int c = I->N; | |||
int *l = I->L; | lexidx_t *l = I->L; | |||
int font_id = SettingGet_i(G, I->R.cs->Setting, I->R.obj->Setting, | int font_id = SettingGet_i(G, I->R.cs->Setting, I->R.obj->Setting, | |||
cSetting_label_font_id); | cSetting_label_font_id); | |||
float font_size = SettingGet_f(G, I->R.cs->Setting, I->R.obj->Setting, | float font_size = SettingGet_f(G, I->R.cs->Setting, I->R.obj->Setting, | |||
cSetting_label_size); | cSetting_label_size); | |||
int float_text = SettingGet_i(G, I->R.cs->Setting, I->R.obj->Setting, | int float_text = SettingGet_i(G, I->R.cs->Setting, I->R.obj->Setting, | |||
cSetting_float_labels); | cSetting_float_labels); | |||
if (!(ray || pick) && info->pass >= 0) | if (!(ray || pick) && info->pass >= 0) | |||
return; | return; | |||
if(I->R.MaxInvalid >= cRepInvRep){ | if(I->R.MaxInvalid >= cRepInvRep){ | |||
skipping to change at line 1219 | skipping to change at line 1221 | |||
CGORenderGLPicking(I->shaderCGO, info, &I->R.context, I->R.cs->Setting, I ->R.obj->Setting); | CGORenderGLPicking(I->shaderCGO, info, &I->R.context, I->R.cs->Setting, I ->R.obj->Setting); | |||
if(float_text) | if(float_text) | |||
glEnable(GL_DEPTH_TEST); | glEnable(GL_DEPTH_TEST); | |||
return; | return; | |||
} else { | } else { | |||
Pickable *p = I->R.P; | Pickable *p = I->R.P; | |||
unsigned int i; | unsigned int i; | |||
TextSetIsPicking(G, true); | TextSetIsPicking(G, true); | |||
SceneSetupGLPicking(G); | SceneSetupGLPicking(G); | |||
if(c) { | if(c) { | |||
char *st; | const char *st; | |||
int screenwidth, screenheight; | int screenwidth, screenheight; | |||
if(float_text) | if(float_text) | |||
glDisable(GL_DEPTH_TEST); | glDisable(GL_DEPTH_TEST); | |||
if (!I->shaderCGO){ | if (!I->shaderCGO){ | |||
SceneGetWidthHeight(G, &screenwidth, &screenheight); | SceneGetWidthHeight(G, &screenwidth, &screenheight); | |||
} | } | |||
i = (*pick)->src.index; | i = pick->begin()->src.index; | |||
while(c--) { | while(c--) { | |||
if(*l) { | if(*l) { | |||
float xn[3], yn[3], tCenterPt[3], offpt[3]; | float xn[3], yn[3], tCenterPt[3], offpt[3]; | |||
short relativeMode = ((short)*(v + 15)); | short relativeMode = ((short)*(v + 15)); | |||
copy3f(v + 6, tCenterPt); | copy3f(v + 6, tCenterPt); | |||
SceneGetCenter(G, offpt); | SceneGetCenter(G, offpt); | |||
TextSetPosNColor(G, offpt, v); | TextSetPosNColor(G, offpt, v); | |||
SceneGetScaledAxes(G, I->R.obj, xn, yn); | SceneGetScaledAxes(G, I->R.obj, xn, yn); | |||
if (!I->shaderCGO){ | if (!I->shaderCGO){ | |||
skipping to change at line 1266 | skipping to change at line 1268 | |||
TextSetTargetPos(G, v + 3); | TextSetTargetPos(G, v + 3); | |||
TextSetLabelBkgrdInfo(G, *(v + 16), *(v + 17), (v + 18)); | TextSetLabelBkgrdInfo(G, *(v + 16), *(v + 17), (v + 18)); | |||
if (p) { | if (p) { | |||
p++; | p++; | |||
AssignNewPickColor(NULL, i, pick, &I->R.context, TextGetColorUCh ar4uv(G), p->index, p->bond); | AssignNewPickColor(NULL, i, pick, &I->R.context, TextGetColorUCh ar4uv(G), p->index, p->bond); | |||
} | } | |||
TextSetColorFromUColor(G); | TextSetColorFromUColor(G); | |||
st = OVLexicon_FetchCString(G->Lexicon, *l); | st = LexStr(G, *l); | |||
if (!TextRenderOpenGL(G, info, font_id, st, font_size, v + 12, fal se, (short)*(v + 15), 1, SHADERCGO)){ | if (!TextRenderOpenGL(G, info, font_id, st, font_size, v + 12, fal se, (short)*(v + 15), 1, SHADERCGO)){ | |||
TextSetIsPicking(G, false); | TextSetIsPicking(G, false); | |||
return ; | return ; | |||
} | } | |||
} | } | |||
l++; | l++; | |||
v += 28; | v += 28; | |||
} | } | |||
if(float_text) | if(float_text) | |||
glEnable(GL_DEPTH_TEST); | glEnable(GL_DEPTH_TEST); | |||
(*pick)[0].src.index = i; /* pass the count */ | (*pick)[0].src.index = i; /* pass the count */ | |||
} | } | |||
TextSetIsPicking(G, false); | TextSetIsPicking(G, false); | |||
} | } | |||
} else { // not pick or ray, render | } else { // not pick or ray, render | |||
if(c) { | if(c) { | |||
char *st; | const char *st; | |||
short use_shader, has_connector = 0; | short use_shader, has_connector = 0; | |||
CGO *connectorCGO = NULL; | CGO *connectorCGO = NULL; | |||
float *PmvMatrix = NULL; | float *PmvMatrix = NULL; | |||
int screenwidth, screenheight; | int screenwidth, screenheight; | |||
float xn[3] = { 1.0F, 0.0F, 0.0F }; | float xn[3] = { 1.0F, 0.0F, 0.0F }; | |||
float yn[3] = { 0.0F, 1.0F, 0.0F }; | float yn[3] = { 0.0F, 1.0F, 0.0F }; | |||
int pre_use_shaders = info->use_shaders; | int pre_use_shaders = info->use_shaders; | |||
Pickable *p = I->R.P; | Pickable *p = I->R.P; | |||
use_shader = SettingGetGlobal_b(G, cSetting_use_shaders) | use_shader = SettingGetGlobal_b(G, cSetting_use_shaders) | |||
skipping to change at line 1369 | skipping to change at line 1371 | |||
} | } | |||
if (p) { | if (p) { | |||
p++; | p++; | |||
if (I->shaderCGO) | if (I->shaderCGO) | |||
CGOPickColor(I->shaderCGO, p->index, p->bond); | CGOPickColor(I->shaderCGO, p->index, p->bond); | |||
} | } | |||
TextSetPosNColor(G, tCenterPt, v); | TextSetPosNColor(G, tCenterPt, v); | |||
TextSetTargetPos(G, v + 3); | TextSetTargetPos(G, v + 3); | |||
st = OVLexicon_FetchCString(G->Lexicon, *l); | st = LexStr(G, *l); | |||
TextSetLabelBkgrdInfo(G, *(v + 16), *(v + 17), (v + 18)); | TextSetLabelBkgrdInfo(G, *(v + 16), *(v + 17), (v + 18)); | |||
if (relativeMode & 8){ // label_z_target, adjust z to target | if (relativeMode & 8){ // label_z_target, adjust z to target | |||
TextGetLabelPos(G)[0] = (SceneGetDepth(G, v+3) - .5) * 2.f; | TextGetLabelPos(G)[0] = (SceneGetDepth(G, v+3) - .5) * 2.f; | |||
TextSetLabelPosIsSet(G, 1); | TextSetLabelPosIsSet(G, 1); | |||
} else if (relativeMode & 6){ // label_relative_mode 1 or 2, i.e., sc reen stabilized, adjust z | } else if (relativeMode & 6){ // label_relative_mode 1 or 2, i.e., sc reen stabilized, adjust z | |||
TextSetLabelPos(G, v+6); | TextSetLabelPos(G, v+6); | |||
TextSetLabelPosIsSet(G, 2); | TextSetLabelPosIsSet(G, 2); | |||
#ifndef PURE_OPENGL_ES_2 | #ifndef PURE_OPENGL_ES_2 | |||
glDisable(GL_FOG); | glDisable(GL_FOG); | |||
#endif | #endif | |||
skipping to change at line 1510 | skipping to change at line 1512 | |||
} | } | |||
} | } | |||
Rep *RepLabelNew(CoordSet * cs, int state) | Rep *RepLabelNew(CoordSet * cs, int state) | |||
{ | { | |||
PyMOLGlobals *G = cs->State.G; | PyMOLGlobals *G = cs->State.G; | |||
ObjectMolecule *obj; | ObjectMolecule *obj; | |||
int a, a1, c1; | int a, a1, c1; | |||
float *v, *v0; | float *v, *v0; | |||
const float *vc; | const float *vc; | |||
int *l; | lexidx_t *l; | |||
int label_color; | int label_color; | |||
Pickable *rp = NULL; | Pickable *rp = NULL; | |||
AtomInfoType *ai; | AtomInfoType *ai; | |||
// skip if no labels are visible | // skip if no labels are visible | |||
if(!cs->hasRep(cRepLabelBit)) | if(!cs->hasRep(cRepLabelBit)) | |||
return NULL; | return NULL; | |||
OOAlloc(G, RepLabel); | OOAlloc(G, RepLabel); | |||
RepLabelInit(I); | RepLabelInit(I); | |||
skipping to change at line 1536 | skipping to change at line 1538 | |||
I->R.fRender = (void (*)(struct Rep *, RenderInfo *)) RepLabelRender; | I->R.fRender = (void (*)(struct Rep *, RenderInfo *)) RepLabelRender; | |||
I->R.fFree = (void (*)(struct Rep *)) RepLabelFree; | I->R.fFree = (void (*)(struct Rep *)) RepLabelFree; | |||
I->R.fRecolor = NULL; | I->R.fRecolor = NULL; | |||
I->R.obj = (CObject *) obj; | I->R.obj = (CObject *) obj; | |||
I->R.cs = cs; | I->R.cs = cs; | |||
I->R.context.object = (void *) obj; | I->R.context.object = (void *) obj; | |||
I->R.context.state = state; | I->R.context.state = state; | |||
/* raytracing primitives */ | /* raytracing primitives */ | |||
I->L = Alloc(int, cs->NIndex); | I->L = Calloc(lexidx_t, cs->NIndex); | |||
ErrChkPtr(G, I->L); | ErrChkPtr(G, I->L); | |||
I->V = Calloc(float, cs->NIndex * 28); | I->V = Calloc(float, cs->NIndex * 28); | |||
ErrChkPtr(G, I->V); | ErrChkPtr(G, I->V); | |||
I->OutlineColor = | I->OutlineColor = | |||
SettingGet_color(G, cs->Setting, obj->Obj.Setting, cSetting_label_outline_co lor); | SettingGet_color(G, cs->Setting, obj->Obj.Setting, cSetting_label_outline_co lor); | |||
if(SettingGet_b(G, cs->Setting, obj->Obj.Setting, cSetting_pickable)) { | if(SettingGet_b(G, cs->Setting, obj->Obj.Setting, cSetting_pickable)) { | |||
I->R.P = Alloc(Pickable, cs->NIndex + 1); | I->R.P = Alloc(Pickable, cs->NIndex + 1); | |||
ErrChkPtr(G, I->R.P); | ErrChkPtr(G, I->R.P); | |||
skipping to change at line 1680 | skipping to change at line 1682 | |||
rp->index = a1; | rp->index = a1; | |||
rp->bond = ai->masked ? cPickableNoPick : cPickableLabel; /* label indicator */ | rp->bond = ai->masked ? cPickableNoPick : cPickableLabel; /* label indicator */ | |||
rp++; | rp++; | |||
} | } | |||
*(l++) = ai->label; | *(l++) = ai->label; | |||
} | } | |||
} | } | |||
if(I->N) { | if(I->N) { | |||
I->V = ReallocForSure(I->V, float, (v - I->V)); | I->V = ReallocForSure(I->V, float, (v - I->V)); | |||
I->L = ReallocForSure(I->L, int, (l - I->L)); | I->L = ReallocForSure(I->L, lexidx_t, (l - I->L)); | |||
if(rp) { | if(rp) { | |||
I->R.P = ReallocForSure(I->R.P, Pickable, (rp - I->R.P)); | I->R.P = ReallocForSure(I->R.P, Pickable, (rp - I->R.P)); | |||
I->R.P[0].index = I->N; /* unnec? */ | I->R.P[0].index = I->N; /* unnec? */ | |||
} | } | |||
} else { | } else { | |||
I->V = ReallocForSure(I->V, float, 1); | I->V = ReallocForSure(I->V, float, 1); | |||
I->L = ReallocForSure(I->L, int, 1); | I->L = ReallocForSure(I->L, lexidx_t, 1); | |||
if(rp) { | if(rp) { | |||
FreeP(I->R.P); | FreeP(I->R.P); | |||
} | } | |||
} | } | |||
return (Rep *) I; | return (Rep *) I; | |||
} | } | |||
End of changes. 29 change blocks. | ||||
27 lines changed or deleted | 28 lines changed or added |