clang-format gadget module

This commit is contained in:
Jarrett Johnson
2026-02-10 15:11:56 -05:00
parent 4edf9aab84
commit 7d7eed2b73
6 changed files with 693 additions and 663 deletions

View File

@@ -1,52 +1,52 @@
/*
/*
A* -------------------------------------------------------------------
B* This file contains source code for the PyMOL computer program
C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific.
C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific.
D* -------------------------------------------------------------------
E* It is unlawful to modify or remove this copyright notice.
F* -------------------------------------------------------------------
G* Please see the accompanying LICENSE file for further information.
G* Please see the accompanying LICENSE file for further information.
H* -------------------------------------------------------------------
I* Additional authors of this source file include:
-*
-*
-*
-*
-*
Z* -------------------------------------------------------------------
*/
#include"os_python.h"
#include "os_python.h"
#include"os_predef.h"
#include"os_std.h"
#include "os_predef.h"
#include "os_std.h"
#include"Base.h"
#include"MemoryDebug.h"
#include"Err.h"
#include"Scene.h"
#include"GadgetSet.h"
#include"ObjectGadget.h"
#include"Color.h"
#include"PConv.h"
#include"main.h"
#include"CGO.h"
#include"ShaderMgr.h"
#include"Ray.h"
#include "Base.h"
#include "CGO.h"
#include "Color.h"
#include "Err.h"
#include "GadgetSet.h"
#include "MemoryDebug.h"
#include "ObjectGadget.h"
#include "PConv.h"
#include "Ray.h"
#include "Scene.h"
#include "ShaderMgr.h"
#include "main.h"
int GadgetSetGetVertex(const GadgetSet * I, int index, int base, float *v)
int GadgetSetGetVertex(const GadgetSet* I, int index, int base, float* v)
{
int ok = true;
float *v0, *v1;
if(index < I->NCoord) {
if (index < I->NCoord) {
v0 = I->Coord + 3 * index;
if(base < 0) {
if (base < 0) {
copy3f(v0, v);
if(index){
if (index) {
add3f(I->Coord, v, v);
}
} else if(base < I->NCoord) {
} else if (base < I->NCoord) {
v1 = I->Coord + 3 * base;
add3f(v1, v0, v);
if(index)
if (index)
add3f(I->Coord, v, v);
} else {
ok = false;
@@ -56,26 +56,26 @@ int GadgetSetGetVertex(const GadgetSet * I, int index, int base, float *v)
return (ok);
}
int GadgetSetSetVertex(GadgetSet * I, int index, int base, const float *v)
int GadgetSetSetVertex(GadgetSet* I, int index, int base, const float* v)
{
int ok = true;
float *v0, *v1;
if(index < I->NCoord) {
if (index < I->NCoord) {
v0 = I->Coord + 3 * index;
if(base < 0) {
if (base < 0) {
copy3f(v, v0);
if(index){
if (index) {
subtract3f(v0, I->Coord, v0);
} else {
if (I->offsetPtOP)
copy3f(v0, &I->StdCGO->op[I->offsetPtOP]);
if (I->offsetPtOPick)
copy3f(v0, &I->PickCGO->op[I->offsetPtOPick]);
if (I->offsetPtOP)
copy3f(v0, &I->StdCGO->op[I->offsetPtOP]);
if (I->offsetPtOPick)
copy3f(v0, &I->PickCGO->op[I->offsetPtOPick]);
}
} else if(base < I->NCoord) {
} else if (base < I->NCoord) {
v1 = I->Coord + 3 * base;
subtract3f(v, v1, v0);
if(index)
if (index)
subtract3f(v0, I->Coord, v0);
} else {
ok = false;
@@ -85,64 +85,66 @@ int GadgetSetSetVertex(GadgetSet * I, int index, int base, const float *v)
return (ok);
}
int GadgetSetFromPyList(PyMOLGlobals * G, PyObject * list, GadgetSet ** gs, int version)
int GadgetSetFromPyList(
PyMOLGlobals* G, PyObject* list, GadgetSet** gs, int version)
{
int ok = true;
GadgetSet *I = nullptr;
PyObject *tmp = nullptr;
GadgetSet* I = nullptr;
PyObject* tmp = nullptr;
if(*gs) {
if (*gs) {
delete *gs;
*gs = nullptr;
}
if(list == Py_None) { /* allow None for GSet */
if (list == Py_None) { /* allow None for GSet */
*gs = nullptr;
} else {
if(ok)
if (ok)
I = GadgetSetNew(G);
if(ok)
if (ok)
ok = (I != nullptr);
if(ok)
if (ok)
ok = (list != nullptr);
if(ok)
if (ok)
ok = PyList_Check(list);
/* TO SUPPORT BACKWARDS COMPATIBILITY...
Always check ll when adding new PyList_GetItem's */
if(ok)
if (ok)
ok = PConvPyIntToInt(PyList_GetItem(list, 0), &I->NCoord);
if(ok && I->NCoord)
if (ok && I->NCoord)
ok = PConvPyListToFloatVLA(PyList_GetItem(list, 1), &I->Coord);
if(ok)
if (ok)
ok = PConvPyIntToInt(PyList_GetItem(list, 2), &I->NNormal);
if(ok && I->NNormal)
if (ok && I->NNormal)
ok = PConvPyListToFloatVLA(PyList_GetItem(list, 3), &I->Normal);
if(ok)
if (ok)
ok = PConvPyIntToInt(PyList_GetItem(list, 4), &I->NColor);
if(ok && I->NColor)
if (ok && I->NColor)
ok = PConvPyListToFloatVLA(PyList_GetItem(list, 5), &I->Color);
if(ok)
if (ok)
ok = ((tmp = PyList_GetItem(list, 6)) != nullptr);
if(ok && (tmp != Py_None))
if (ok && (tmp != Py_None))
ok = ((I->ShapeCGO = CGONewFromPyList(I->G, tmp, version)) != nullptr);
if(ok)
if (ok)
ok = ((tmp = PyList_GetItem(list, 7)) != nullptr);
if(ok && (tmp != Py_None))
ok = ((I->PickShapeCGO = CGONewFromPyList(I->G, tmp, version)) != nullptr);
if (ok && (tmp != Py_None))
ok =
((I->PickShapeCGO = CGONewFromPyList(I->G, tmp, version)) != nullptr);
if(ok && I->ShapeCGO)
if(CGOCheckForText(I->ShapeCGO)) {
if (ok && I->ShapeCGO)
if (CGOCheckForText(I->ShapeCGO)) {
CGOPreloadFonts(I->ShapeCGO);
}
if(!ok) {
if(I)
if (!ok) {
if (I)
delete I;
} else {
*gs = I;
@@ -152,61 +154,61 @@ int GadgetSetFromPyList(PyMOLGlobals * G, PyObject * list, GadgetSet ** gs, int
return (ok);
}
PyObject *GadgetSetAsPyList(GadgetSet * I, bool incl_cgos)
PyObject* GadgetSetAsPyList(GadgetSet* I, bool incl_cgos)
{
PyObject *result = nullptr;
PyObject* result = nullptr;
if(I) {
if (I) {
result = PyList_New(8);
PyList_SetItem(result, 0, PyInt_FromLong(I->NCoord));
if(I->NCoord) {
PyList_SetItem(result, 1, PConvFloatArrayToPyList(I->Coord, I->NCoord * 3));
if (I->NCoord) {
PyList_SetItem(
result, 1, PConvFloatArrayToPyList(I->Coord, I->NCoord * 3));
} else {
PyList_SetItem(result, 1, PConvAutoNone(nullptr));
}
PyList_SetItem(result, 2, PyInt_FromLong(I->NNormal));
if(I->NNormal) {
PyList_SetItem(result, 3, PConvFloatArrayToPyList(I->Normal, I->NNormal * 3));
if (I->NNormal) {
PyList_SetItem(
result, 3, PConvFloatArrayToPyList(I->Normal, I->NNormal * 3));
} else {
PyList_SetItem(result, 3, PConvAutoNone(nullptr));
}
PyList_SetItem(result, 4, PyInt_FromLong(I->NColor));
if(I->NColor) {
if (I->NColor) {
PyList_SetItem(result, 5, PConvFloatArrayToPyList(I->Color, I->NColor));
} else {
PyList_SetItem(result, 5, PConvAutoNone(nullptr));
}
if(incl_cgos && I->ShapeCGO) {
if (incl_cgos && I->ShapeCGO) {
PyList_SetItem(result, 6, CGOAsPyList(I->ShapeCGO));
} else {
PyList_SetItem(result, 6, PConvAutoNone(nullptr));
}
if(incl_cgos && I->PickShapeCGO) {
if (incl_cgos && I->PickShapeCGO) {
PyList_SetItem(result, 7, CGOAsPyList(I->PickShapeCGO));
} else {
PyList_SetItem(result, 7, PConvAutoNone(nullptr));
}
}
return (PConvAutoNone(result));
}
/*========================================================================*/
int GadgetSetGetExtent(GadgetSet * I, float *mn, float *mx)
int GadgetSetGetExtent(GadgetSet* I, float* mn, float* mx)
{
float *v;
float* v;
int a;
v = I->Coord;
for(a = 0; a < I->NCoord; a++) {
for (a = 0; a < I->NCoord; a++) {
min3f(v, mn, mn);
max3f(v, mx, mx);
v += 3;
@@ -214,38 +216,33 @@ int GadgetSetGetExtent(GadgetSet * I, float *mn, float *mx)
return (I->NCoord);
}
/*========================================================================*/
void GadgetSet::invalidateRep(cRep_t type, cRepInv_t level)
{
}
void GadgetSet::invalidateRep(cRep_t type, cRepInv_t level) {}
/*========================================================================*/
void GadgetSet::update()
{
GadgetSet * I = this;
if(I->StdCGO) {
GadgetSet* I = this;
if (I->StdCGO) {
CGOFree(I->StdCGO);
I->offsetPtOP = 0;
I->StdCGO = nullptr;
}
if(I->PickCGO) {
if (I->PickCGO) {
CGOFree(I->PickCGO);
I->offsetPtOPick = 0;
I->PickCGO = nullptr;
}
}
/*========================================================================*/
void GadgetSet::render(RenderInfo * info)
void GadgetSet::render(RenderInfo* info)
{
GadgetSet * I = this;
GadgetSet* I = this;
const RenderPass pass = info->pass;
CRay *ray = info->ray;
CRay* ray = info->ray;
auto pick = info->pick;
const float *color;
const float* color;
PickContext context;
context.object = I->Obj;
@@ -253,66 +250,69 @@ void GadgetSet::render(RenderInfo * info)
color = ColorGet(I->G, I->Obj->Color);
if(pass == RenderPass::Transparent || ray || pick) {
PyMOLGlobals *G = I->G;
if (pass == RenderPass::Transparent || ray || pick) {
PyMOLGlobals* G = I->G;
if(ray) {
if(I->ShapeCGO){
float mat[16] = { 1.f, 0.f, 0.f, I->Coord[0],
0.f, 1.f, 0.f, I->Coord[1],
0.f, 0.f, 1.f, I->Coord[2],
0.f, 0.f, 0.f, 1.f };
RayPushTTT(ray);
RaySetTTT(ray, true, mat); /* Used to set the ray-tracing matrix,
this works, but is there another way to do this? */
CGORenderRay(I->ShapeCGO, ray, info, color, nullptr, I->Obj->Setting.get(), nullptr);
RayPopTTT(ray);
if (ray) {
if (I->ShapeCGO) {
float mat[16] = {1.f, 0.f, 0.f, I->Coord[0], 0.f, 1.f, 0.f, I->Coord[1],
0.f, 0.f, 1.f, I->Coord[2], 0.f, 0.f, 0.f, 1.f};
RayPushTTT(ray);
RaySetTTT(ray, true,
mat); /* Used to set the ray-tracing matrix,
this works, but is there another way to do this? */
CGORenderRay(I->ShapeCGO, ray, info, color, nullptr,
I->Obj->Setting.get(), nullptr);
RayPopTTT(ray);
}
} else if(G->HaveGUI && G->ValidContext) {
} else if (G->HaveGUI && G->ValidContext) {
short use_shader = (short) SettingGetGlobal_b(I->G, cSetting_use_shaders);
if(pick) {
if (!I->PickCGO && I->PickShapeCGO){
CGO *convertcgo;
int ok = true;
convertcgo = CGOCombineBeginEnd(I->PickShapeCGO, 0);
CHECKOK(ok, convertcgo);
if (ok){
if (use_shader){
CGO *tmpCGO;
tmpCGO = CGOOptimizeToVBOIndexedNoShader(convertcgo, 0);
I->PickCGO = CGONew(G);
CGODisable(I->PickCGO, GL_DEPTH_TEST);
CGOEnable(I->PickCGO, GL_RAMP_SHADER);
I->offsetPtOPick = CGOUniform3f(I->PickCGO, RAMP_OFFSETPT, (const float*)I->Coord);
CGOAppendNoStop(I->PickCGO, tmpCGO);
CGOFreeWithoutVBOs(tmpCGO);
CGODisable(I->PickCGO, GL_RAMP_SHADER);
CGOEnable(I->PickCGO, GL_DEPTH_TEST);
CGOStop(I->PickCGO);
I->PickCGO->use_shader = true;
CGOFree(convertcgo);
} else {
I->PickCGO = convertcgo;
}
} else {
CGOFree(convertcgo);
}
}
if(I->PickCGO) {
if (use_shader){
CGORenderPicking(I->PickCGO, info, &context, I->Obj->Setting.get(), nullptr);
if (pick) {
if (!I->PickCGO && I->PickShapeCGO) {
CGO* convertcgo;
int ok = true;
convertcgo = CGOCombineBeginEnd(I->PickShapeCGO, 0);
CHECKOK(ok, convertcgo);
if (ok) {
if (use_shader) {
CGO* tmpCGO;
tmpCGO = CGOOptimizeToVBOIndexedNoShader(convertcgo, 0);
I->PickCGO = CGONew(G);
CGODisable(I->PickCGO, GL_DEPTH_TEST);
CGOEnable(I->PickCGO, GL_RAMP_SHADER);
I->offsetPtOPick = CGOUniform3f(
I->PickCGO, RAMP_OFFSETPT, (const float*) I->Coord);
CGOAppendNoStop(I->PickCGO, tmpCGO);
CGOFreeWithoutVBOs(tmpCGO);
CGODisable(I->PickCGO, GL_RAMP_SHADER);
CGOEnable(I->PickCGO, GL_DEPTH_TEST);
CGOStop(I->PickCGO);
I->PickCGO->use_shader = true;
CGOFree(convertcgo);
} else {
I->PickCGO = convertcgo;
}
} else {
CGOFree(convertcgo);
}
}
if (I->PickCGO) {
if (use_shader) {
CGORenderPicking(
I->PickCGO, info, &context, I->Obj->Setting.get(), nullptr);
#ifndef PURE_OPENGL_ES_2
} else {
glDisable(GL_DEPTH_TEST);
glTranslatef(I->Coord[0],I->Coord[1],I->Coord[2]);
CGORenderPicking(I->PickShapeCGO, info, &context, I->Obj->Setting.get(), nullptr);
glTranslatef(-I->Coord[0],-I->Coord[1],-I->Coord[2]);
glEnable(GL_DEPTH_TEST);
} else {
glDisable(GL_DEPTH_TEST);
glTranslatef(I->Coord[0], I->Coord[1], I->Coord[2]);
CGORenderPicking(I->PickShapeCGO, info, &context,
I->Obj->Setting.get(), nullptr);
glTranslatef(-I->Coord[0], -I->Coord[1], -I->Coord[2]);
glEnable(GL_DEPTH_TEST);
#endif
}
}
}
} else {
if (!I->StdCGO && I->ShapeCGO){
if (!I->StdCGO && I->ShapeCGO) {
if (!use_shader) {
I->StdCGO = CGOCombineBeginEnd(I->ShapeCGO);
assert(!I->StdCGO->has_begin_end);
@@ -329,41 +329,41 @@ void GadgetSet::render(RenderInfo * info)
assert(I->StdCGO->use_shader);
assert(!I->StdCGO->has_begin_end);
}
}
if(I->StdCGO) {
if (use_shader){
if (color)
CGORender(I->StdCGO, nullptr, I->Obj->Setting.get(), nullptr, info, nullptr);
}
if (I->StdCGO) {
if (use_shader) {
if (color)
CGORender(I->StdCGO, nullptr, I->Obj->Setting.get(), nullptr,
info, nullptr);
#ifndef PURE_OPENGL_ES_2
} else {
glDisable(GL_DEPTH_TEST);
glTranslatef(I->Coord[0],I->Coord[1],I->Coord[2]);
CGORender(I->ShapeCGO, nullptr, I->Obj->Setting.get(), nullptr, info, nullptr);
glTranslatef(-I->Coord[0],-I->Coord[1],-I->Coord[2]);
glEnable(GL_DEPTH_TEST);
} else {
glDisable(GL_DEPTH_TEST);
glTranslatef(I->Coord[0], I->Coord[1], I->Coord[2]);
CGORender(I->ShapeCGO, nullptr, I->Obj->Setting.get(), nullptr,
info, nullptr);
glTranslatef(-I->Coord[0], -I->Coord[1], -I->Coord[2]);
glEnable(GL_DEPTH_TEST);
#endif
}
}
}
}
}
}
}
/*========================================================================*/
GadgetSet *GadgetSetNew(PyMOLGlobals * G)
GadgetSet* GadgetSetNew(PyMOLGlobals* G)
{
auto I = new GadgetSet();
I->G = G;
return (I);
}
/*========================================================================*/
GadgetSet::~GadgetSet()
{
GadgetSet * I = this;
if(I) {
GadgetSet* I = this;
if (I) {
CGOFree(I->PickCGO);
CGOFree(I->PickShapeCGO);
CGOFree(I->StdCGO);

View File

@@ -1,23 +1,23 @@
/*
/*
A* -------------------------------------------------------------------
B* This file contains source code for the PyMOL computer program
C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific.
C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific.
D* -------------------------------------------------------------------
E* It is unlawful to modify or remove this copyright notice.
F* -------------------------------------------------------------------
G* Please see the accompanying LICENSE file for further information.
G* Please see the accompanying LICENSE file for further information.
H* -------------------------------------------------------------------
I* Additional authors of this source file include:
-*
-*
-*
-*
-*
Z* -------------------------------------------------------------------
*/
#ifndef _H_GadgetSet
#define _H_GadgetSet
#include"Rep.h"
#include "Rep.h"
#include <vector>
@@ -28,32 +28,33 @@ struct GadgetSet {
// methods
void update();
void render(RenderInfo * info);
void render(RenderInfo* info);
void invalidateRep(cRep_t type, cRepInv_t level);
PyMOLGlobals *G;
ObjectGadget* Obj = nullptr; /* NOT pickled -- restore manually */
int State = 0; /* NOT pickled -- restore manually */
float *Coord = nullptr;
float *Normal = nullptr;
float *Color = nullptr;
PyMOLGlobals* G;
ObjectGadget* Obj = nullptr; /* NOT pickled -- restore manually */
int State = 0; /* NOT pickled -- restore manually */
float* Coord = nullptr;
float* Normal = nullptr;
float* Color = nullptr;
int NCoord = 0;
int NNormal = 0;
int NColor = 0;
CGO *PickShapeCGO = nullptr;
CGO *PickCGO = nullptr;
CGO *StdCGO = nullptr;
CGO *ShapeCGO = nullptr;
CGO* PickShapeCGO = nullptr;
CGO* PickCGO = nullptr;
CGO* StdCGO = nullptr;
CGO* ShapeCGO = nullptr;
int offsetPtOP = 0;
int offsetPtOPick = 0;
};
GadgetSet *GadgetSetNew(PyMOLGlobals * G);
PyObject *GadgetSetAsPyList(GadgetSet * I, bool incl_cgos);
int GadgetSetFromPyList(PyMOLGlobals * G, PyObject * list, GadgetSet ** cs, int version);
int GadgetSetGetExtent(GadgetSet * I, float *mn, float *mx);
int GadgetSetGetVertex(const GadgetSet * I, int index, int base, float *v);
int GadgetSetSetVertex(GadgetSet * I, int index, int base, const float *v);
GadgetSet* GadgetSetNew(PyMOLGlobals* G);
PyObject* GadgetSetAsPyList(GadgetSet* I, bool incl_cgos);
int GadgetSetFromPyList(
PyMOLGlobals* G, PyObject* list, GadgetSet** cs, int version);
int GadgetSetGetExtent(GadgetSet* I, float* mn, float* mx);
int GadgetSetGetVertex(const GadgetSet* I, int index, int base, float* v);
int GadgetSetSetVertex(GadgetSet* I, int index, int base, const float* v);
std::vector<float> GadgetSetGetCoord(const GadgetSet* I);
#endif

View File

@@ -1,99 +1,135 @@
/*
/*
A* -------------------------------------------------------------------
B* This file contains source code for the PyMOL computer program
C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific.
C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific.
D* -------------------------------------------------------------------
E* It is unlawful to modify or remove this copyright notice.
F* -------------------------------------------------------------------
G* Please see the accompanying LICENSE file for further information.
G* Please see the accompanying LICENSE file for further information.
H* -------------------------------------------------------------------
I* Additional authors of this source file include:
-*
-*
-*
-*
-*
Z* -------------------------------------------------------------------
*/
#include"os_python.h"
#include "os_python.h"
#include"os_predef.h"
#include"os_std.h"
#include"os_gl.h"
#include "os_gl.h"
#include "os_predef.h"
#include "os_std.h"
#include"ObjectGadget.h"
#include"ObjectGadgetRamp.h"
#include"GadgetSet.h"
#include"Base.h"
#include"MemoryDebug.h"
#include"CGO.h"
#include"Scene.h"
#include"Setting.h"
#include"PConv.h"
#include"main.h"
#include"Color.h"
#include"VFont.h"
#include "Base.h"
#include "CGO.h"
#include "Color.h"
#include "GadgetSet.h"
#include "MemoryDebug.h"
#include "ObjectGadget.h"
#include "ObjectGadgetRamp.h"
#include "PConv.h"
#include "Scene.h"
#include "Setting.h"
#include "VFont.h"
#include "main.h"
CGO *ObjectGadgetPyListFloatToCGO(PyObject * list);
CGO* ObjectGadgetPyListFloatToCGO(PyObject* list);
int ObjectGadgetGetVertex(const ObjectGadget * I, int index, int base, float *v)
int ObjectGadgetGetVertex(const ObjectGadget* I, int index, int base, float* v)
{
GadgetSet *gs;
GadgetSet* gs;
int ok = false;
if(I->CurGSet < I->NGSet) {
if (I->CurGSet < I->NGSet) {
gs = I->GSet[I->CurGSet];
if(gs) {
if (gs) {
ok = GadgetSetGetVertex(gs, index, base, v);
}
}
return (ok);
}
int ObjectGadgetSetVertex(ObjectGadget * I, int index, int base, const float *v)
int ObjectGadgetSetVertex(ObjectGadget* I, int index, int base, const float* v)
{
GadgetSet *gs;
GadgetSet* gs;
int ok = false;
if(I->CurGSet < I->NGSet) {
if (I->CurGSet < I->NGSet) {
gs = I->GSet[I->CurGSet];
if(gs) {
if (gs) {
ok = GadgetSetSetVertex(gs, index, base, v);
}
}
if (index) // if 0 - xyz doesn't change, 1 - mouse position when changing colors
if (index) // if 0 - xyz doesn't change, 1 - mouse position when changing
// colors
I->Changed = true;
return (ok);
}
/* in current state */
ObjectGadget *ObjectGadgetTest(PyMOLGlobals * G)
ObjectGadget* ObjectGadgetTest(PyMOLGlobals* G)
{
ObjectGadget *I = nullptr;
GadgetSet *gs = nullptr;
CGO *cgo = nullptr;
ObjectGadget* I = nullptr;
GadgetSet* gs = nullptr;
CGO* cgo = nullptr;
int a;
float coord[] = {
0.5F, 0.5F, 0.0F,
0.0F, 0.0F, 0.0F,
0.3F, 0.0F, 0.0F,
0.0F, -0.3F, 0.0F,
0.3F, -0.3F, 0.0F,
0.03F, -0.03F, 0.03F,
0.27F, -0.03F, 0.03F,
0.03F, -0.27F, 0.03F,
0.27F, -0.27F, 0.03F,
0.02F, -0.02F, 0.01F,
0.28F, -0.02F, 0.01F,
0.02F, -0.28F, 0.01F,
0.28F, -0.28F, 0.01F,
0.5F,
0.5F,
0.0F,
0.0F,
0.0F,
0.0F,
0.3F,
0.0F,
0.0F,
0.0F,
-0.3F,
0.0F,
0.3F,
-0.3F,
0.0F,
0.03F,
-0.03F,
0.03F,
0.27F,
-0.03F,
0.03F,
0.03F,
-0.27F,
0.03F,
0.27F,
-0.27F,
0.03F,
0.02F,
-0.02F,
0.01F,
0.28F,
-0.02F,
0.01F,
0.02F,
-0.28F,
0.01F,
0.28F,
-0.28F,
0.01F,
};
float normal[] = {
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0,
-1.0, 0.0, 0.0,
0.0, -1.0, 0.0,
1.0,
0.0,
0.0,
0.0,
1.0,
0.0,
0.0,
0.0,
1.0,
-1.0,
0.0,
0.0,
0.0,
-1.0,
0.0,
};
I = new ObjectGadget(G);
@@ -101,13 +137,13 @@ ObjectGadget *ObjectGadgetTest(PyMOLGlobals * G)
gs->NCoord = 13;
gs->Coord = VLAlloc(float, gs->NCoord * 3);
for(a = 0; a < gs->NCoord * 3; a++) {
for (a = 0; a < gs->NCoord * 3; a++) {
gs->Coord[a] = coord[a];
}
gs->NNormal = 5;
gs->Normal = VLAlloc(float, gs->NNormal * 3);
for(a = 0; a < gs->NNormal * 3; a++) {
for (a = 0; a < gs->NNormal * 3; a++) {
gs->Normal[a] = normal[a];
}
@@ -230,60 +266,59 @@ ObjectGadget *ObjectGadgetTest(PyMOLGlobals * G)
gs->update();
ObjectGadgetUpdateExtents(I);
return (I);
}
void ObjectGadgetUpdateExtents(ObjectGadget * I)
void ObjectGadgetUpdateExtents(ObjectGadget* I)
{
float maxv[3] = { FLT_MAX, FLT_MAX, FLT_MAX };
float minv[3] = { -FLT_MAX, -FLT_MAX, -FLT_MAX };
float maxv[3] = {FLT_MAX, FLT_MAX, FLT_MAX};
float minv[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX};
int a;
GadgetSet *ds;
GadgetSet* ds;
/* update extents */
copy3f(maxv, I->ExtentMin);
copy3f(minv, I->ExtentMax);
I->ExtentFlag = false;
for(a = 0; a < I->NGSet; a++) {
for (a = 0; a < I->NGSet; a++) {
ds = I->GSet[a];
if(ds) {
if(GadgetSetGetExtent(ds, I->ExtentMin, I->ExtentMax))
if (ds) {
if (GadgetSetGetExtent(ds, I->ExtentMin, I->ExtentMax))
I->ExtentFlag = true;
}
}
}
static PyObject *ObjectGadgetGSetAsPyList(ObjectGadget * I, bool incl_cgos)
static PyObject* ObjectGadgetGSetAsPyList(ObjectGadget* I, bool incl_cgos)
{
PyObject *result = nullptr;
PyObject* result = nullptr;
int a;
result = PyList_New(I->NGSet);
for(a = 0; a < I->NGSet; a++) {
if(I->GSet[a]) {
for (a = 0; a < I->NGSet; a++) {
if (I->GSet[a]) {
PyList_SetItem(result, a, GadgetSetAsPyList(I->GSet[a], incl_cgos));
} else {
PyList_SetItem(result, a, PConvAutoNone(Py_None));
}
}
return (PConvAutoNone(result));
}
static int ObjectGadgetGSetFromPyList(ObjectGadget * I, PyObject * list, int version)
static int ObjectGadgetGSetFromPyList(
ObjectGadget* I, PyObject* list, int version)
{
int ok = true;
int a;
if(ok)
if (ok)
ok = PyList_Check(list);
if(ok) {
VLACheck(I->GSet, GadgetSet *, I->NGSet);
for(a = 0; a < I->NGSet; a++) {
if(ok){
auto *val = PyList_GetItem(list, a);
if (ok) {
VLACheck(I->GSet, GadgetSet*, I->NGSet);
for (a = 0; a < I->NGSet; a++) {
if (ok) {
auto* val = PyList_GetItem(list, a);
ok = GadgetSetFromPyList(I->G, val, &I->GSet[a], version);
}
if(ok && I->GSet[a]) {
if (ok && I->GSet[a]) {
I->GSet[a]->Obj = I;
I->GSet[a]->State = a;
}
@@ -292,31 +327,31 @@ static int ObjectGadgetGSetFromPyList(ObjectGadget * I, PyObject * list, int ver
return (ok);
}
int ObjectGadgetInitFromPyList(PyMOLGlobals * G, PyObject * list, ObjectGadget * I,
int version)
int ObjectGadgetInitFromPyList(
PyMOLGlobals* G, PyObject* list, ObjectGadget* I, int version)
{
int ok = true;
if(ok)
if (ok)
ok = (I != nullptr) && (list != nullptr);
if(ok)
if (ok)
ok = PyList_Check(list);
/* TO SUPPORT BACKWARDS COMPATIBILITY...
Always check ll when adding new PyList_GetItem's */
if(ok){
auto *val = PyList_GetItem(list, 0);
if (ok) {
auto* val = PyList_GetItem(list, 0);
ok = ObjectFromPyList(G, val, I);
}
if(ok)
if (ok)
ok = PConvPyIntToInt(PyList_GetItem(list, 1), &I->GadgetType);
if(ok)
if (ok)
ok = PConvPyIntToInt(PyList_GetItem(list, 2), &I->NGSet);
if(ok)
if (ok)
ok = ObjectGadgetGSetFromPyList(I, PyList_GetItem(list, 3), version);
if(ok)
if (ok)
ok = PConvPyIntToInt(PyList_GetItem(list, 4), &I->CurGSet);
/* ObjectGadgetInvalidateRep(I,cRepAll); */
if(ok) {
if (ok) {
ObjectGadgetUpdateExtents(I);
} else {
/* cleanup? */
@@ -324,41 +359,42 @@ int ObjectGadgetInitFromPyList(PyMOLGlobals * G, PyObject * list, ObjectGadget *
return (ok);
}
int ObjectGadgetNewFromPyList(PyMOLGlobals * G, PyObject * list, ObjectGadget ** result,
int version)
int ObjectGadgetNewFromPyList(
PyMOLGlobals* G, PyObject* list, ObjectGadget** result, int version)
{
int ok = true;
ObjectGadget *I = nullptr;
ObjectGadget* I = nullptr;
int gadget_type = -1;
PyObject *plain;
PyObject* plain;
(*result) = nullptr;
if(ok)
if (ok)
ok = (list != nullptr);
if(ok)
if (ok)
ok = PyList_Check(list);
/* NOTE there is a serious screw-up here...ramp gadgets aren't saved right, but
we've got to maintain backward compat...ugh */
/* NOTE there is a serious screw-up here...ramp gadgets aren't saved right,
but we've got to maintain backward compat...ugh */
if(ok)
if (ok)
ok = ((plain = PyList_GetItem(list, 0)) != nullptr);
if(ok)
if (ok)
ok = PyList_Check(plain);
if(ok)
if (ok)
ok = PConvPyIntToInt(PyList_GetItem(plain, 1), &gadget_type);
if(ok)
switch (gadget_type) { /* call the right routine to restore the gadget! */
if (ok)
switch (gadget_type) { /* call the right routine to restore the gadget! */
case cGadgetRamp:
ok = ObjectGadgetRampNewFromPyList(G, list, (ObjectGadgetRamp **) result, version);
ok = ObjectGadgetRampNewFromPyList(
G, list, (ObjectGadgetRamp**) result, version);
break;
case cGadgetPlain:
I = new ObjectGadget(G);
if(ok)
if (ok)
ok = (I != nullptr);
if(ok)
if (ok)
ok = ObjectGadgetInitFromPyList(G, list, I, version);
if(ok)
if (ok)
(*result) = I;
break;
default:
@@ -368,9 +404,9 @@ int ObjectGadgetNewFromPyList(PyMOLGlobals * G, PyObject * list, ObjectGadget **
return (ok);
}
PyObject *ObjectGadgetPlainAsPyList(ObjectGadget * I, bool incl_cgos)
PyObject* ObjectGadgetPlainAsPyList(ObjectGadget* I, bool incl_cgos)
{
PyObject *result = nullptr;
PyObject* result = nullptr;
/* first, dump the atoms */
@@ -383,15 +419,15 @@ PyObject *ObjectGadgetPlainAsPyList(ObjectGadget * I, bool incl_cgos)
return (PConvAutoNone(result));
}
PyObject *ObjectGadgetAsPyList(ObjectGadget * I)
PyObject* ObjectGadgetAsPyList(ObjectGadget* I)
{
PyObject *result = nullptr;
PyObject* result = nullptr;
/* first, dump the atoms */
switch (I->GadgetType) {
case cGadgetRamp:
result = ObjectGadgetRampAsPyList((ObjectGadgetRamp *) I);
result = ObjectGadgetRampAsPyList((ObjectGadgetRamp*) I);
break;
case cGadgetPlain:
result = ObjectGadgetPlainAsPyList(I);
@@ -403,38 +439,37 @@ PyObject *ObjectGadgetAsPyList(ObjectGadget * I)
ObjectGadget::~ObjectGadget()
{
auto I = this;
for(int a = 0; a < I->NGSet; a++)
if(I->GSet[a]) {
for (int a = 0; a < I->NGSet; a++)
if (I->GSet[a]) {
delete I->GSet[a];
I->GSet[a] = nullptr;
}
}
void ObjectGadgetUpdateStates(ObjectGadget * I)
void ObjectGadgetUpdateStates(ObjectGadget* I)
{
int a;
OrthoBusyPrime(I->G);
for(a = 0; a < I->NGSet; a++)
if(I->GSet[a]) {
for (a = 0; a < I->NGSet; a++)
if (I->GSet[a]) {
OrthoBusySlow(I->G, a, I->NGSet);
/* printf(" ObjectGadget: updating state %d of \"%s\".\n" , a+1, I->Name); */
/* printf(" ObjectGadget: updating state %d of \"%s\".\n" , a+1,
* I->Name); */
I->GSet[a]->update();
}
}
/*========================================================================*/
void ObjectGadget::update()
{
auto I = this;
if(I->Changed) {
if (I->Changed) {
ObjectGadgetUpdateStates(I);
ObjectGadgetUpdateExtents(I);
I->Changed = false;
}
}
/*========================================================================*/
int ObjectGadget::getNFrame() const
@@ -442,34 +477,32 @@ int ObjectGadget::getNFrame() const
return NGSet;
}
/*========================================================================*/
void ObjectGadget::render(RenderInfo * info)
void ObjectGadget::render(RenderInfo* info)
{
auto I = this;
int state = info->state;
const RenderPass pass = info->pass;
if(pass == RenderPass::Transparent || info->ray || info->pick) {
if (pass == RenderPass::Transparent || info->ray || info->pick) {
ObjectPrepareContext(I, info);
for(StateIterator iter(I->G, I->Setting.get(), state, I->NGSet);
for (StateIterator iter(I->G, I->Setting.get(), state, I->NGSet);
iter.next();) {
GadgetSet * gs = I->GSet[iter.state];
GadgetSet* gs = I->GSet[iter.state];
gs->render(info);
}
}
}
/*========================================================================*/
ObjectGadget::ObjectGadget(PyMOLGlobals * G) : pymol::CObject(G)
ObjectGadget::ObjectGadget(PyMOLGlobals* G)
: pymol::CObject(G)
{
type = cObjectGadget;
GSet = pymol::vla<GadgetSet*>(10); /* auto-zero */
GSet = pymol::vla<GadgetSet*>(10); /* auto-zero */
}
pymol::RenderContext ObjectGadget::getRenderContext() const
{
return pymol::RenderContext::UnitWindow;
}

View File

@@ -1,28 +1,28 @@
/*
/*
A* -------------------------------------------------------------------
B* This file contains source code for the PyMOL computer program
C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific.
C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific.
D* -------------------------------------------------------------------
E* It is unlawful to modify or remove this copyright notice.
F* -------------------------------------------------------------------
G* Please see the accompanying LICENSE file for further information.
G* Please see the accompanying LICENSE file for further information.
H* -------------------------------------------------------------------
I* Additional authors of this source file include:
-*
-*
-*
-*
-*
Z* -------------------------------------------------------------------
*/
#ifndef _H_ObjectGadget
#define _H_ObjectGadget
#include"os_python.h"
#include "os_python.h"
#include"PyMOLObject.h"
#include"Base.h"
#include "Base.h"
#include "PyMOLObject.h"
#include"GadgetSet.h"
#include "GadgetSet.h"
struct ObjectGadget : public pymol::CObject {
pymol::vla<GadgetSet*> GSet;
@@ -43,18 +43,20 @@ struct ObjectGadget : public pymol::CObject {
#define cGadgetPlain 0
#define cGadgetRamp 1
PyObject *ObjectGadgetAsPyList(ObjectGadget * I);
PyObject *ObjectGadgetPlainAsPyList(ObjectGadget * I, bool incl_cgos=true);
PyObject* ObjectGadgetAsPyList(ObjectGadget* I);
PyObject* ObjectGadgetPlainAsPyList(ObjectGadget* I, bool incl_cgos = true);
int ObjectGadgetNewFromPyList(PyMOLGlobals * G, PyObject * list, ObjectGadget ** result,
int version);
int ObjectGadgetInitFromPyList(PyMOLGlobals * G, PyObject * list, ObjectGadget * I,
int version);
int ObjectGadgetNewFromPyList(
PyMOLGlobals* G, PyObject* list, ObjectGadget** result, int version);
int ObjectGadgetInitFromPyList(
PyMOLGlobals* G, PyObject* list, ObjectGadget* I, int version);
ObjectGadget *ObjectGadgetTest(PyMOLGlobals * G);
int ObjectGadgetGetVertex(const ObjectGadget * I, int index, int base, float *v); /* in current state */
int ObjectGadgetSetVertex(ObjectGadget * I, int index, int base, const float *v); /* in current state */
void ObjectGadgetUpdateExtents(ObjectGadget * I);
void ObjectGadgetUpdateStates(ObjectGadget * I);
ObjectGadget* ObjectGadgetTest(PyMOLGlobals* G);
int ObjectGadgetGetVertex(const ObjectGadget* I, int index, int base,
float* v); /* in current state */
int ObjectGadgetSetVertex(ObjectGadget* I, int index, int base,
const float* v); /* in current state */
void ObjectGadgetUpdateExtents(ObjectGadget* I);
void ObjectGadgetUpdateStates(ObjectGadget* I);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,23 +1,23 @@
/*
/*
A* -------------------------------------------------------------------
B* This file contains source code for the PyMOL computer program
C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific.
C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific.
D* -------------------------------------------------------------------
E* It is unlawful to modify or remove this copyright notice.
F* -------------------------------------------------------------------
G* Please see the accompanying LICENSE file for further information.
G* Please see the accompanying LICENSE file for further information.
H* -------------------------------------------------------------------
I* Additional authors of this source file include:
-*
-*
-*
-*
-*
Z* -------------------------------------------------------------------
*/
#ifndef _H_ObjectGadgetRamp
#define _H_ObjectGadgetRamp
#include"os_python.h"
#include "os_python.h"
#include "ObjectGadget.h"
@@ -45,8 +45,8 @@ struct ObjectGadgetRamp : public ObjectGadget {
int CalcMode = 0;
/* fields below are not saved in session */
ObjectMap *Map = nullptr;
ObjectMolecule *Mol = nullptr;
ObjectMap* Map = nullptr;
ObjectMolecule* Mol = nullptr;
float border = 0.018f;
float width = 0.9f;
@@ -75,29 +75,22 @@ struct ObjectGadgetRamp : public ObjectGadget {
#define cRAMP_AFMHOT 7
#define cRAMP_GRAYSCALE 8
ObjectGadgetRamp *ObjectGadgetRampMapNewAsDefined(PyMOLGlobals * G,
ObjectGadgetRamp *I,
ObjectMap * map,
pymol::vla<float>&& level_vla,
pymol::vla<float>&& color_vla,
int map_state, float *vert_vla,
float beyond, float within, float sigma,
int zero, int calc_mode);
ObjectGadgetRamp* ObjectGadgetRampMapNewAsDefined(PyMOLGlobals* G,
ObjectGadgetRamp* I, ObjectMap* map, pymol::vla<float>&& level_vla,
pymol::vla<float>&& color_vla, int map_state, float* vert_vla, float beyond,
float within, float sigma, int zero, int calc_mode);
ObjectGadgetRamp *ObjectGadgetRampMolNewAsDefined(PyMOLGlobals * G,
ObjectGadgetRamp *I,
ObjectMolecule * mol,
pymol::vla<float>&& level_vla,
pymol::vla<float>&& color_vla,
int mol_state, int calc_mode);
ObjectGadgetRamp* ObjectGadgetRampMolNewAsDefined(PyMOLGlobals* G,
ObjectGadgetRamp* I, ObjectMolecule* mol, pymol::vla<float>&& level_vla,
pymol::vla<float>&& color_vla, int mol_state, int calc_mode);
int ObjectGadgetRampInterpolate(ObjectGadgetRamp * I, float level, float *color);
int ObjectGadgetRampInterVertex(ObjectGadgetRamp * I, const float *pos, float *color,
int state);
int ObjectGadgetRampInterpolate(ObjectGadgetRamp* I, float level, float* color);
int ObjectGadgetRampInterVertex(
ObjectGadgetRamp* I, const float* pos, float* color, int state);
PyObject *ObjectGadgetRampAsPyList(ObjectGadgetRamp * I);
int ObjectGadgetRampNewFromPyList(PyMOLGlobals * G, PyObject * list,
ObjectGadgetRamp ** result, int version);
PyObject* ObjectGadgetRampAsPyList(ObjectGadgetRamp* I);
int ObjectGadgetRampNewFromPyList(
PyMOLGlobals* G, PyObject* list, ObjectGadgetRamp** result, int version);
void ObjectGadgetRampFree(ObjectGadgetRamp * I);
void ObjectGadgetRampFree(ObjectGadgetRamp* I);
#endif