Skip to content

Commit 3943835

Browse files
PYMOL-4854: Add cell_color setting for unit cell coloring
1 parent 6d9ddd4 commit 3943835

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

layer1/Setting.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,6 +2481,9 @@ void SettingGenerateSideEffects(PyMOLGlobals * G, int index, const char *sele, i
24812481
ExecutiveInvalidateRep(G, inv_sele, cRepSphere, cRepInvRep);
24822482
SceneInvalidate(G);
24832483
break;
2484+
case cSetting_cell_color:
2485+
ExecutiveInvalidateRep(G, inv_sele, cRepCell, cRepInvColor);
2486+
SceneInvalidate(G);
24842487
case cSetting_cull_spheres:
24852488
case cSetting_sphere_scale:
24862489
case cSetting_sphere_transparency:

layer1/SettingInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,7 @@ enum {
904904
REC_f( 794, halogen_bond_as_acceptor_max_acceptor_angle , global , 170.0f ),
905905
REC_f( 795, salt_bridge_distance , global , 5.0f ),
906906
REC_b( 796, use_tessellation_shaders , global , true ),
907+
REC_c( 797, cell_color , ostate , "-1" ),
907908

908909
#ifdef SETTINGINFO_IMPLEMENTATION
909910
#undef SETTINGINFO_IMPLEMENTATION

layer2/CoordSet.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,12 @@ void CoordSet::update(int state)
12871287
UnitCellCGO.reset(CrystalGetUnitCellCGO(&sym->Crystal));
12881288
auto use_shader = SettingGet<bool>(G, cSetting_use_shaders);
12891289
if (use_shader) {
1290-
auto color = ColorGet(G, Obj->Color);
1290+
auto cell_color = SettingGet_color(
1291+
G, this->Setting.get(), Obj->Setting.get(), cSetting_cell_color);
1292+
if (cell_color < 0) {
1293+
cell_color = Obj->Color;
1294+
}
1295+
auto color = ColorGet(G, cell_color);
12911296
auto preCGO = std::make_unique<CGO>(G);
12921297
CGOColorv(preCGO.get(), color);
12931298
CGOAppendNoStop(preCGO.get(), UnitCellCGO.get());

layer2/ObjectSurface.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,12 @@ static void ObjectSurfaceRenderCell(PyMOLGlobals *G, ObjectSurface * I,
870870
* TODO: Ray with primitive CGO
871871
*/
872872

873-
const float *color = ColorGet(G, I->Color);
873+
// TODO: Surface-state level color?
874+
auto cell_color = SettingGet_color(*I, cSetting_cell_color);
875+
if (cell_color < 0) {
876+
cell_color = I->Color;
877+
}
878+
const float *color = ColorGet(G, cell_color);
874879
if (use_shader != ms->UnitCellCGO->has_draw_buffers){
875880
if (use_shader){
876881
auto preCGO = std::make_unique<CGO>(G);

0 commit comments

Comments
 (0)