ObjectSlice.cpp (pymol-open-source-2.2.0) | : | ObjectSlice.cpp (pymol-open-source-2.3.0) | ||
---|---|---|---|---|
skipping to change at line 50 | skipping to change at line 50 | |||
#include"Text.h" | #include"Text.h" | |||
#include"Util.h" | #include"Util.h" | |||
#include"ButMode.h" | #include"ButMode.h" | |||
#include"ObjectGadgetRamp.h" | #include"ObjectGadgetRamp.h" | |||
#include"CGO.h" | #include"CGO.h" | |||
#include"ShaderMgr.h" | #include"ShaderMgr.h" | |||
#define START_STRIP -1 | #define START_STRIP -1 | |||
#define STOP_STRIP -2 | #define STOP_STRIP -2 | |||
ObjectSlice *ObjectSliceNew(PyMOLGlobals * G); | static ObjectSlice *ObjectSliceNew(PyMOLGlobals * G); | |||
static void ObjectSliceFree(ObjectSlice * I); | static void ObjectSliceFree(ObjectSlice * I); | |||
void ObjectSliceStateInit(PyMOLGlobals * G, ObjectSliceState * ms); | static void ObjectSliceStateInit(PyMOLGlobals * G, ObjectSliceState * ms); | |||
void ObjectSliceRecomputeExtent(ObjectSlice * I); | static void ObjectSliceRecomputeExtent(ObjectSlice * I); | |||
static PyObject *ObjectSliceStateAsPyList(ObjectSliceState * I) | static PyObject *ObjectSliceStateAsPyList(ObjectSliceState * I) | |||
{ | { | |||
PyObject *result = NULL; | PyObject *result = NULL; | |||
result = PyList_New(10); | result = PyList_New(10); | |||
PyList_SetItem(result, 0, PyInt_FromLong(I->Active)); | PyList_SetItem(result, 0, PyInt_FromLong(I->Active)); | |||
PyList_SetItem(result, 1, PyString_FromString(I->MapName)); | PyList_SetItem(result, 1, PyString_FromString(I->MapName)); | |||
skipping to change at line 99 | skipping to change at line 98 | |||
} | } | |||
return (PConvAutoNone(result)); | return (PConvAutoNone(result)); | |||
} | } | |||
static int ObjectSliceStateFromPyList(PyMOLGlobals * G, ObjectSliceState * I, | static int ObjectSliceStateFromPyList(PyMOLGlobals * G, ObjectSliceState * I, | |||
PyObject * list) | PyObject * list) | |||
{ | { | |||
int ok = true; | int ok = true; | |||
int ll; | ||||
if(ok) | if(ok) | |||
ok = (list != NULL); | ok = (list != NULL); | |||
if(ok) { | if(ok) { | |||
if(!PyList_Check(list)) | if(!PyList_Check(list)) | |||
I->Active = false; | I->Active = false; | |||
else { | else { | |||
ObjectSliceStateInit(G, I); | ObjectSliceStateInit(G, I); | |||
if(ok) | if(ok) | |||
ok = (list != NULL); | ok = (list != NULL); | |||
if(ok) | if(ok) | |||
ok = PyList_Check(list); | ok = PyList_Check(list); | |||
if(ok) | ||||
ll = PyList_Size(list); | ||||
/* TO SUPPORT BACKWARDS COMPATIBILITY... | /* TO SUPPORT BACKWARDS COMPATIBILITY... | |||
Always check ll when adding new PyList_GetItem's */ | Always check ll when adding new PyList_GetItem's */ | |||
if(ok) | if(ok) | |||
ok = PConvPyIntToInt(PyList_GetItem(list, 0), &I->Active); | ok = PConvPyIntToInt(PyList_GetItem(list, 0), &I->Active); | |||
if(ok) | if(ok) | |||
ok = PConvPyStrToStr(PyList_GetItem(list, 1), I->MapName, WordLength); | ok = PConvPyStrToStr(PyList_GetItem(list, 1), I->MapName, WordLength); | |||
if(ok) | if(ok) | |||
ok = PConvPyIntToInt(PyList_GetItem(list, 2), &I->MapState); | ok = PConvPyIntToInt(PyList_GetItem(list, 2), &I->MapState); | |||
if(ok) | if(ok) | |||
skipping to change at line 164 | skipping to change at line 160 | |||
if(!ok) | if(!ok) | |||
break; | break; | |||
} | } | |||
} | } | |||
return (ok); | return (ok); | |||
} | } | |||
int ObjectSliceNewFromPyList(PyMOLGlobals * G, PyObject * list, ObjectSlice ** r esult) | int ObjectSliceNewFromPyList(PyMOLGlobals * G, PyObject * list, ObjectSlice ** r esult) | |||
{ | { | |||
int ok = true; | int ok = true; | |||
int ll; | ||||
ObjectSlice *I = NULL; | ObjectSlice *I = NULL; | |||
(*result) = NULL; | (*result) = NULL; | |||
if(ok) | if(ok) | |||
ok = (list != NULL); | ok = (list != NULL); | |||
if(ok) | if(ok) | |||
ok = PyList_Check(list); | ok = PyList_Check(list); | |||
if(ok) | ||||
ll = PyList_Size(list); | ||||
/* TO SUPPORT BACKWARDS COMPATIBILITY... | /* TO SUPPORT BACKWARDS COMPATIBILITY... | |||
Always check ll when adding new PyList_GetItem's */ | Always check ll when adding new PyList_GetItem's */ | |||
I = ObjectSliceNew(G); | I = ObjectSliceNew(G); | |||
if(ok) | if(ok) | |||
ok = (I != NULL); | ok = (I != NULL); | |||
if(ok) | if(ok) | |||
ok = ObjectFromPyList(G, PyList_GetItem(list, 0), &I->Obj); | ok = ObjectFromPyList(G, PyList_GetItem(list, 0), &I->Obj); | |||
if(ok) | if(ok) | |||
skipping to change at line 811 | skipping to change at line 804 | |||
if(oss) { | if(oss) { | |||
if((offset >= 0) && (offset < oss->n_points)) | if((offset >= 0) && (offset < oss->n_points)) | |||
if(oss->flags[offset]) { | if(oss->flags[offset]) { | |||
copy3f(oss->points + 3 * offset, v); | copy3f(oss->points + 3 * offset, v); | |||
result = true; | result = true; | |||
} | } | |||
} | } | |||
return (result); | return (result); | |||
} | } | |||
#if 0 | ||||
static int ObjectSliceAddSlicePoint(float *pt0, float *pt1, float *zaxis, float d, | static int ObjectSliceAddSlicePoint(float *pt0, float *pt1, float *zaxis, float d, | |||
float *coords, float *origin) | float *coords, float *origin) | |||
{ | { | |||
float p0[3]; | float p0[3]; | |||
float p1[3]; | float p1[3]; | |||
float u; | float u; | |||
p0[0] = pt0[0] - origin[0]; | p0[0] = pt0[0] - origin[0]; | |||
p0[1] = pt0[1] - origin[1]; | p0[1] = pt0[1] - origin[1]; | |||
skipping to change at line 838 | skipping to change at line 832 | |||
if (u>=0.0F && u<=1.0F) { | if (u>=0.0F && u<=1.0F) { | |||
coords[0] = pt0[0] + (pt1[0]-pt0[0])*u; | coords[0] = pt0[0] + (pt1[0]-pt0[0])*u; | |||
coords[1] = pt0[1] + (pt1[1]-pt0[1])*u; | coords[1] = pt0[1] + (pt1[1]-pt0[1])*u; | |||
coords[2] = pt0[2] + (pt1[2]-pt0[2])*u; | coords[2] = pt0[2] + (pt1[2]-pt0[2])*u; | |||
return 3; | return 3; | |||
} | } | |||
return 0; | return 0; | |||
} | } | |||
#ifndef PURE_OPENGL_ES_2 | ||||
static | ||||
void ObjectSliceDrawSlice(CGO *cgo, float *points, int n_points, float *zaxis) | void ObjectSliceDrawSlice(CGO *cgo, float *points, int n_points, float *zaxis) | |||
{ | { | |||
float center[3], v[3], w[3], q[3]; | float center[3], v[3], w[3], q[3]; | |||
float angles[12]; | float angles[12]; | |||
float a, c, s; | float a, c, s; | |||
int vertices[12]; | int vertices[12]; | |||
int i, j; | int i, j; | |||
if (!n_points) return; | if (!n_points) return; | |||
skipping to change at line 904 | skipping to change at line 900 | |||
CGOEnd(cgo); | CGOEnd(cgo); | |||
} else { | } else { | |||
glBegin(GL_LINE_LOOP); | glBegin(GL_LINE_LOOP); | |||
for (i=0; i<n_points; i++) { | for (i=0; i<n_points; i++) { | |||
glVertex3fv(&points[3*vertices[(i)%n_points]]); | glVertex3fv(&points[3*vertices[(i)%n_points]]); | |||
} | } | |||
glEnd(); | glEnd(); | |||
} | } | |||
} | } | |||
static | ||||
void GenerateOutlineOfSlice(PyMOLGlobals *G, ObjectSliceState *oss, CGO *cgo){ | void GenerateOutlineOfSlice(PyMOLGlobals *G, ObjectSliceState *oss, CGO *cgo){ | |||
int n_points = oss->outline_n_points; | int n_points = oss->outline_n_points; | |||
float *points = oss->outline_points; | float *points = oss->outline_points; | |||
float *m = SceneGetMatrix(G); | float *m = SceneGetMatrix(G); | |||
float *zaxis = oss->outline_zaxis, *origin;//, origin[3]; | float *zaxis = oss->outline_zaxis, *origin;//, origin[3]; | |||
float d = 0.f; // not sure what this should be | float d = 0.f; // not sure what this should be | |||
if (!oss->outline_n_points){ | if (!oss->outline_n_points){ | |||
zaxis[0] = m[2]; | zaxis[0] = m[2]; | |||
zaxis[1] = m[6]; | zaxis[1] = m[6]; | |||
zaxis[2] = m[10]; | zaxis[2] = m[10]; | |||
skipping to change at line 943 | skipping to change at line 940 | |||
} | } | |||
if (cgo){ | if (cgo){ | |||
CGOColor(cgo, 1.f, 0.f, 0.f ); | CGOColor(cgo, 1.f, 0.f, 0.f ); | |||
CGOSphere(cgo, origin, 1.f); | CGOSphere(cgo, origin, 1.f); | |||
CGOColor(cgo, 1.f, 1.f, 1.f ); | CGOColor(cgo, 1.f, 1.f, 1.f ); | |||
} else { | } else { | |||
glColor3f(1.f,1.f,1.f); | glColor3f(1.f,1.f,1.f); | |||
} | } | |||
ObjectSliceDrawSlice(cgo, points, n_points/3, zaxis); | ObjectSliceDrawSlice(cgo, points, n_points/3, zaxis); | |||
} | } | |||
#endif | ||||
#endif | ||||
static void ObjectSliceRender(ObjectSlice * I, RenderInfo * info) | static void ObjectSliceRender(ObjectSlice * I, RenderInfo * info) | |||
{ | { | |||
PyMOLGlobals *G = I->Obj.G; | PyMOLGlobals *G = I->Obj.G; | |||
int state = info->state; | int state = info->state; | |||
CRay *ray = info->ray; | CRay *ray = info->ray; | |||
Picking **pick = info->pick; | auto pick = info->pick; | |||
int pass = info->pass; | int pass = info->pass; | |||
int cur_state = 0; | int cur_state = 0; | |||
float alpha; | float alpha; | |||
int track_camera = SettingGet_b(G, NULL, I->Obj.Setting, cSetting_slice_track_ camera); | int track_camera = SettingGet_b(G, NULL, I->Obj.Setting, cSetting_slice_track_ camera); | |||
int dynamic_grid = SettingGet_b(G, NULL, I->Obj.Setting, cSetting_slice_dynami c_grid); | int dynamic_grid = SettingGet_b(G, NULL, I->Obj.Setting, cSetting_slice_dynami c_grid); | |||
ObjectSliceState *oss = NULL; | ObjectSliceState *oss = NULL; | |||
int use_shaders = !track_camera && SettingGet_b(G, NULL, I->Obj.Setting, cSett ing_use_shaders); | int use_shaders = !track_camera && SettingGet_b(G, NULL, I->Obj.Setting, cSett ing_use_shaders); | |||
if (G->ShaderMgr->Get_Current_Shader()){ | if (G->ShaderMgr->Get_Current_Shader()){ | |||
// just in case, since slice uses immediate mode, but this should never happ en | // just in case, since slice uses immediate mode, but this should never happ en | |||
G->ShaderMgr->Get_Current_Shader()->Disable(); | G->ShaderMgr->Get_Current_Shader()->Disable(); | |||
skipping to change at line 1115 | skipping to change at line 1114 | |||
} | } | |||
} | } | |||
} | } | |||
ray->transparentf(0.0); | ray->transparentf(0.0); | |||
} else if(G->HaveGUI && G->ValidContext) { | } else if(G->HaveGUI && G->ValidContext) { | |||
if(pick) { | if(pick) { | |||
if (oss->shaderCGO && (I->Obj.visRep & cRepSliceBit)){ | if (oss->shaderCGO && (I->Obj.visRep & cRepSliceBit)){ | |||
CGORenderGLPicking(oss->shaderCGO, info, &I->context, I->Obj.Setti ng, NULL); | CGORenderGLPicking(oss->shaderCGO, info, &I->context, I->Obj.Setti ng, NULL); | |||
} else { | } else { | |||
#ifndef PURE_OPENGL_ES_2 | #ifndef PURE_OPENGL_ES_2 | |||
unsigned int i = (*pick)->src.index; | unsigned int i = pick->begin()->src.index; | |||
Picking p; | Picking p; | |||
SceneSetupGLPicking(G); | SceneSetupGLPicking(G); | |||
p.context.object = (void *) I; | p.context.object = (void *) I; | |||
p.context.state = 0; | p.context.state = 0; | |||
p.src.index = state + 1; | p.src.index = state + 1; | |||
p.src.bond = 0; | p.src.bond = 0; | |||
if((I->Obj.visRep & cRepSliceBit)) { | if((I->Obj.visRep & cRepSliceBit)) { | |||
int *strip = oss->strips; | int *strip = oss->strips; | |||
float *point = oss->points; | float *point = oss->points; | |||
End of changes. 12 change blocks. | ||||
12 lines changed or deleted | 11 lines changed or added |