"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "layer2/RepAngle.cpp" between
pymol-v2.1.0.tar.bz2 and pymol-open-source-2.2.0.tar.gz

About: PyMOL is a Python-enhanced molecular graphics tool. It excels at 3D visualization of proteins, small molecules, density, surfaces, and trajectories. It also includes molecular editing, ray tracing, and movies. Open Source version.

RepAngle.cpp  (pymol-v2.1.0.tar.bz2):RepAngle.cpp  (pymol-open-source-2.2.0)
skipping to change at line 60 skipping to change at line 60
{ {
if (I->shaderCGO){ if (I->shaderCGO){
CGOFree(I->shaderCGO); CGOFree(I->shaderCGO);
I->shaderCGO = 0; I->shaderCGO = 0;
} }
VLAFreeP(I->V); VLAFreeP(I->V);
RepPurge(&I->R); RepPurge(&I->R);
OOFreeP(I); OOFreeP(I);
} }
static int RepAngleCGOGenerate(RepAngle * I, RenderInfo * info)
{
PyMOLGlobals *G = I->R.G;
float *v = I->V;
int c = I->N;
float line_width;
int ok = true;
CGO *convertcgo = NULL;
int dash_as_cylinders = SettingGetGlobal_b(G, cSetting_render_as_cylinders) &&
SettingGetGlobal_b(G, cSetting_dash_as_cylinders);
int color =
SettingGet_color(G, NULL, I->ds->Obj->Obj.Setting, cSetting_angle_color);
I->linewidth = line_width =
SettingGet_f(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dash_width);
I->radius =
SettingGet_f(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dash_radius);
line_width = SceneGetDynamicLineWidth(info, line_width);
ok &= CGOSpecial(I->shaderCGO, LINEWIDTH_DYNAMIC_WITH_SCALE_DASH);
if (ok)
ok &= CGOResetNormal(I->shaderCGO, true);
if (ok){
if(color >= 0){
ok &= CGOColorv(I->shaderCGO, ColorGet(G, color));
} else if (I->Obj && I->Obj->Color >= 0){
ok &= CGOColorv(I->shaderCGO, ColorGet(G, I->Obj->Color));
}
}
v = I->V;
c = I->N;
if (dash_as_cylinders){
float *origin = NULL, axis[3];
while(ok && c > 0) {
origin = v;
v += 3;
axis[0] = v[0] - origin[0];
axis[1] = v[1] - origin[1];
axis[2] = v[2] - origin[2];
v += 3;
ok &= (bool)I->shaderCGO->add<cgo::draw::shadercylinder>(origin, axis, 1.f
, 15);
c -= 2;
}
} else if (ok) {
ok &= CGOBegin(I->shaderCGO, GL_LINES);
while(ok && c > 0) {
ok &= CGOVertexv(I->shaderCGO, v);
v += 3;
if (ok)
ok &= CGOVertexv(I->shaderCGO, v);
v += 3;
c -= 2;
}
if (ok)
ok &= CGOEnd(I->shaderCGO);
}
if (ok)
ok &= CGOStop(I->shaderCGO);
if (ok)
convertcgo = CGOCombineBeginEnd(I->shaderCGO, 0);
CHECKOK(ok, convertcgo);
CGOFree(I->shaderCGO);
I->shaderCGO = convertcgo;
convertcgo = NULL;
if (ok){
if (dash_as_cylinders){
CGO *tmpCGO = CGONew(G);
if (ok) ok &= CGOEnable(tmpCGO, GL_CYLINDER_SHADER);
if (ok) ok &= CGOSpecial(tmpCGO, CYLINDER_WIDTH_FOR_DISTANCES);
convertcgo = CGOConvertShaderCylindersToCylinderShader(I->shaderCGO, tmpCG
O);
if (ok) ok &= CGOEnable(tmpCGO, GL_DASH_TRANSPARENCY_DEPTH_TEST);
if (ok) ok &= CGOAppendNoStop(tmpCGO, convertcgo);
if (ok) ok &= CGODisable(tmpCGO, GL_DASH_TRANSPARENCY_DEPTH_TEST);
if (ok) ok &= CGODisable(tmpCGO, GL_CYLINDER_SHADER);
if (ok) ok &= CGOStop(tmpCGO);
CGOFreeWithoutVBOs(convertcgo);
convertcgo = tmpCGO;
} else {
CGO *tmpCGO = CGONew(G);
if (ok) ok &= CGOEnable(tmpCGO, GL_DEFAULT_SHADER);
if (ok) ok &= CGODisable(tmpCGO, CGO_GL_LIGHTING);
convertcgo = CGOOptimizeToVBONotIndexedNoShader(I->shaderCGO, 0);
if (ok) ok &= CGOEnable(tmpCGO, GL_DASH_TRANSPARENCY_DEPTH_TEST);
if (ok) ok &= CGOAppendNoStop(tmpCGO, convertcgo);
if (ok) ok &= CGODisable(tmpCGO, GL_DASH_TRANSPARENCY_DEPTH_TEST);
if (ok) ok &= CGODisable(tmpCGO, GL_DEFAULT_SHADER);
if (ok) ok &= CGOStop(tmpCGO);
CGOFreeWithoutVBOs(convertcgo);
convertcgo = tmpCGO;
}
convertcgo->use_shader = true;
}
CHECKOK(ok, convertcgo);
if (convertcgo){
CGOFree(I->shaderCGO);
I->shaderCGO = convertcgo;
convertcgo = NULL;
}
return ok;
}
static void RepAngleRenderImmediate(RepAngle * I, RenderInfo * info, int color,
short dash_transparency_enabled, float dash_
transparency)
{
#ifndef PURE_OPENGL_ES_2
PyMOLGlobals *G = I->R.G;
float *v = I->V;
int c = I->N;
float line_width;
bool t_mode_3 =
SettingGet_i(G, NULL, I->ds->Obj->Obj.Setting, cSetting_transparency_mode) =
= 3;
line_width =
SettingGet_f(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dash_width);
line_width = SceneGetDynamicLineWidth(info, line_width);
if(info->width_scale_flag) {
glLineWidth(line_width * info->width_scale);
} else {
glLineWidth(line_width);
}
SceneResetNormal(G, true);
if (dash_transparency_enabled){
const float *col = ColorGet(G, color);
glColor4f(col[0], col[1], col[2], 1.f-dash_transparency);
} else {
glColor3fv(ColorGet(G, color));
}
if (dash_transparency_enabled && !t_mode_3)
glDisable(GL_DEPTH_TEST);
if(!info->line_lighting)
glDisable(GL_LIGHTING);
glBegin(GL_LINES);
while(c > 0) {
glVertex3fv(v);
v += 3;
glVertex3fv(v);
v += 3;
c -= 2;
}
glEnd();
glEnable(GL_LIGHTING);
if (dash_transparency_enabled && !t_mode_3)
glEnable(GL_DEPTH_TEST);
#endif
}
static void RepAngleRender(RepAngle * I, RenderInfo * info) static void RepAngleRender(RepAngle * I, RenderInfo * info)
{ {
CRay *ray = info->ray; CRay *ray = info->ray;
Picking **pick = info->pick; Picking **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;
float *vc; const float *vc;
int round_ends; int round_ends;
float line_width; float line_width;
int ok = true; int ok = true;
float dash_transparency;
short dash_transparency_enabled;
int color = int color =
SettingGet_color(G, NULL, I->ds->Obj->Obj.Setting, cSetting_angle_color); SettingGet_color(G, NULL, I->ds->Obj->Obj.Setting, cSetting_angle_color);
if(color < 0)
color = I->Obj->Color;
I->linewidth = line_width = I->linewidth = line_width =
SettingGet_f(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dash_width); SettingGet_f(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dash_width);
I->radius = I->radius =
SettingGet_f(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dash_radius); SettingGet_f(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dash_radius);
round_ends = round_ends =
SettingGet_b(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dash_round_ends); SettingGet_b(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dash_round_ends);
line_width = SceneGetDynamicLineWidth(info, line_width); line_width = SceneGetDynamicLineWidth(info, line_width);
dash_transparency =
SettingGet_f(G, NULL, I->ds->Obj->Obj.Setting, cSetting_dash_transparency);
dash_transparency = (dash_transparency < 0.f ? 0.f : (dash_transparency > 1.f
? 1.f : dash_transparency));
dash_transparency_enabled = (dash_transparency > 0.f);
if (!(ray || pick) && (!info->pass || (info->pass > 0) == dash_transparency_en
abled))
return;
if(ray) { if(ray) {
float radius; float radius;
if (dash_transparency_enabled){
ray->transparentf(dash_transparency);
}
if(I->radius == 0.0F) { if(I->radius == 0.0F) {
radius = ray->PixelRadius * line_width / 2.0F; radius = ray->PixelRadius * line_width / 2.0F;
} else { } else {
radius = I->radius; radius = I->radius;
} }
if(color < 0)
color = I->Obj->Color;
vc = ColorGet(G, color); vc = ColorGet(G, color);
v = I->V; v = I->V;
c = I->N; c = I->N;
while(ok && c > 0) { while(ok && c > 0) {
/* printf("%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f \n",v[3],v[4],v[5],v [6],v[7],v[8]); */ /* printf("%8.3f %8.3f %8.3f %8.3f %8.3f %8.3f \n",v[3],v[4],v[5],v [6],v[7],v[8]); */
if(round_ends) { if(round_ends) {
ok &= ray->sausage3fv(v, v + 3, radius, vc, vc); ok &= ray->sausage3fv(v, v + 3, radius, vc, vc);
} else { } else {
ok &= ray->customCylinder3fv(v, v + 3, radius, vc, vc, cCylCapFlat, cCyl CapFlat); ok &= ray->customCylinder3fv(v, v + 3, radius, vc, vc, cCylCapFlat, cCyl CapFlat);
} }
v += 6; v += 6;
c -= 2; c -= 2;
} }
} else if(G->HaveGUI && G->ValidContext) { } else if(G->HaveGUI && G->ValidContext) {
if(pick) { if(pick) {
} else { } else {
short use_shader, generate_shader_cgo = 0, dash_as_cylinders = 0; short use_shader, generate_shader_cgo = 0;
use_shader = SettingGetGlobal_b(G, cSetting_dash_use_shader) & use_shader = SettingGetGlobal_b(G, cSetting_dash_use_shader) &
SettingGetGlobal_b(G, cSetting_use_shaders); SettingGetGlobal_b(G, cSetting_use_shaders);
dash_as_cylinders = SettingGetGlobal_b(G, cSetting_render_as_cylinders) && SettingGetGlobal_b(G, cSetting_dash_as_cylinders);
if (!use_shader && I->shaderCGO){ if (!use_shader && I->shaderCGO){
CGOFree(I->shaderCGO); CGOFree(I->shaderCGO);
I->shaderCGO = 0; I->shaderCGO = 0;
} }
if (use_shader){ if (use_shader){
if (!I->shaderCGO){ if (!I->shaderCGO){
I->shaderCGO = CGONew(G); I->shaderCGO = CGONew(G);
CHECKOK(ok, I->shaderCGO); CHECKOK(ok, I->shaderCGO);
if (ok) if (ok)
I->shaderCGO->use_shader = true; I->shaderCGO->use_shader = true;
generate_shader_cgo = 1; generate_shader_cgo = 1;
} else { if (dash_transparency_enabled){
CShaderPrg *shaderPrg; CGOAlpha(I->shaderCGO, 1.f-dash_transparency);
if (dash_as_cylinders){ }
float pixel_scale_value = SettingGetGlobal_f(G, cSetting_ray_pixel_sc ok &= RepAngleCGOGenerate(I, info);
ale); } else {
if(pixel_scale_value < 0)
pixel_scale_value = 1.0F;
shaderPrg = CShaderPrg_Enable_CylinderShader(G);
if(I->radius == 0.0F) {
CShaderPrg_Set1f(shaderPrg, "uni_radius", info->vertex_scale * pixe
l_scale_value * line_width/ 2.f);
} else {
CShaderPrg_Set1f(shaderPrg, "uni_radius", I->radius);
}
if (!round_ends){
CShaderPrg_Set1f(shaderPrg, "no_flat_caps", 0.f);
}
} else {
shaderPrg = CShaderPrg_Enable_DefaultShader(G);
CShaderPrg_SetLightingEnabled(shaderPrg, 0);
}
if (!shaderPrg) return;
CGORenderGL(I->shaderCGO, NULL, NULL, NULL, info, &I->R); CGORenderGL(I->shaderCGO, NULL, NULL, NULL, info, &I->R);
CShaderPrg_Disable(shaderPrg);
return; return;
} }
} }
if (generate_shader_cgo){ if (!generate_shader_cgo) {
if (ok) RepAngleRenderImmediate(I, info, color, dash_transparency_enabled, dash_t
ok &= CGOLinewidthSpecial(I->shaderCGO, LINEWIDTH_DYNAMIC_WITH_SCALE_DA ransparency);
SH);
if (ok)
ok &= CGOResetNormal(I->shaderCGO, true);
} else {
if(info->width_scale_flag) {
glLineWidth(line_width * info->width_scale);
} else {
glLineWidth(line_width);
}
SceneResetNormal(G, true);
}
if (generate_shader_cgo){
if (ok){
if(color >= 0){
ok &= CGOColorv(I->shaderCGO, ColorGet(G, color));
} else if (I->Obj && I->Obj->Color >= 0){
ok &= CGOColorv(I->shaderCGO, ColorGet(G, I->Obj->Color));
}
}
v = I->V;
c = I->N;
if (dash_as_cylinders){
float *origin = NULL, axis[3];
while(ok && c > 0) {
origin = v;
v += 3;
axis[0] = v[0] - origin[0];
axis[1] = v[1] - origin[1];
axis[2] = v[2] - origin[2];
v += 3;
ok &= CGOShaderCylinder(I->shaderCGO, origin, axis, 1.f, 15);
c -= 2;
}
} else if (ok) {
ok &= CGOBegin(I->shaderCGO, GL_LINES);
while(ok && c > 0) {
ok &= CGOVertexv(I->shaderCGO, v);
v += 3;
if (ok)
ok &= CGOVertexv(I->shaderCGO, v);
v += 3;
c -= 2;
}
if (ok)
ok &= CGOEnd(I->shaderCGO);
}
} else { } else {
if(color >= 0){ CGORenderGL(I->shaderCGO, NULL, NULL, NULL, info, &I->R);
glColor3fv(ColorGet(G, color));
}
v = I->V;
c = I->N;
if(!info->line_lighting)
glDisable(GL_LIGHTING);
glBegin(GL_LINES);
while(c > 0) {
glVertex3fv(v);
v += 3;
glVertex3fv(v);
v += 3;
c -= 2;
}
glEnd();
glEnable(GL_LIGHTING);
}
if (use_shader) {
if (generate_shader_cgo){
CGO *convertcgo = NULL;
if (ok)
ok &= CGOStop(I->shaderCGO);
if (ok)
convertcgo = CGOCombineBeginEnd(I->shaderCGO, 0);
CHECKOK(ok, convertcgo);
CGOFree(I->shaderCGO);
I->shaderCGO = convertcgo;
convertcgo = NULL;
if (ok){
if (dash_as_cylinders){
convertcgo = CGOOptimizeGLSLCylindersToVBOIndexed(I->shaderCGO, 0);
} else {
convertcgo = CGOOptimizeToVBONotIndexed(I->shaderCGO, 0);
}
}
CHECKOK(ok, convertcgo);
if (convertcgo){
CGOFree(I->shaderCGO);
I->shaderCGO = convertcgo;
convertcgo = NULL;
}
}
if (ok) {
CShaderPrg *shaderPrg;
if (dash_as_cylinders){
float pixel_scale_value = SettingGetGlobal_f(G, cSetting_ray_pixel_sc
ale);
if(pixel_scale_value < 0)
pixel_scale_value = 1.0F;
shaderPrg = CShaderPrg_Enable_CylinderShader(G);
if(I->radius == 0.0F) {
CShaderPrg_Set1f(shaderPrg, "uni_radius", info->vertex_scale * pixe
l_scale_value * line_width/ 2.f);
} else {
CShaderPrg_Set1f(shaderPrg, "uni_radius", I->radius);
}
if (!round_ends){
CShaderPrg_Set1f(shaderPrg, "no_flat_caps", 0.f);
}
} else {
shaderPrg = CShaderPrg_Enable_DefaultShader(G);
CShaderPrg_SetLightingEnabled(shaderPrg, 0);
}
CGORenderGL(I->shaderCGO, NULL, NULL, NULL, info, &I->R);
CShaderPrg_Disable(shaderPrg);
}
} }
} }
} }
if (!ok){ if (!ok){
CGOFree(I->shaderCGO); CGOFree(I->shaderCGO);
I->ds->Rep[cRepAngle] = NULL; I->ds->Rep[cRepAngle] = NULL;
RepAngleFree(I); RepAngleFree(I);
} }
} }
Rep *RepAngleNew(DistSet * ds, int state) Rep *RepAngleNew(DistSet * ds, int state)
{ {
PyMOLGlobals *G = ds->State.G; PyMOLGlobals *G = ds->State.G;
int a; int a;
int n = 0; int n = 0;
float *v, *v1, *v2, *v3, *v4, d1[3], d2[3], d3[3], n1[3], n3[3], l1, l2, x[3], y[3]; float *v, *v1, *v2, *v3, *v4, d1[3], d2[3], d3[3], n1[3], n3[3], l1, l2, x[3], y[3];
float length, radius, angle, pos, phase; float length, radius, angle, pos, phase;
float dash_len, dash_gap, dash_sum; float dash_len, dash_gap, dash_sum;
int ok = true; int ok = true;
float dash_transparency;
dash_transparency =
SettingGet_f(G, NULL, ds->Obj->Obj.Setting, cSetting_dash_transparency);
dash_transparency = (dash_transparency < 0.f ? 0.f : (dash_transparency > 1.f
? 1.f : dash_transparency));
OOAlloc(G, RepAngle); OOAlloc(G, RepAngle);
CHECKOK(ok, I); CHECKOK(ok, I);
PRINTFD(G, FB_RepAngle) PRINTFD(G, FB_RepAngle)
"RepAngleNew: entered.\n" ENDFD; "RepAngleNew: entered.\n" ENDFD;
if(!ok || !ds->NAngleIndex) { if(!ok || !ds->NAngleIndex) {
OOFreeP(I); OOFreeP(I);
return (NULL); return (NULL);
} }
 End of changes. 14 change blocks. 
150 lines changed or deleted 181 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)