Skip to content

Commit

Permalink
PYMOL-4854: Add cell_color setting for unit cell coloring
Browse files Browse the repository at this point in the history
  • Loading branch information
JarrettSJohnson committed May 13, 2024
1 parent 6d9ddd4 commit 3943835
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions layer1/Setting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2481,6 +2481,9 @@ void SettingGenerateSideEffects(PyMOLGlobals * G, int index, const char *sele, i
ExecutiveInvalidateRep(G, inv_sele, cRepSphere, cRepInvRep);
SceneInvalidate(G);
break;
case cSetting_cell_color:
ExecutiveInvalidateRep(G, inv_sele, cRepCell, cRepInvColor);
SceneInvalidate(G);
case cSetting_cull_spheres:
case cSetting_sphere_scale:
case cSetting_sphere_transparency:
Expand Down
1 change: 1 addition & 0 deletions layer1/SettingInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,7 @@ enum {
REC_f( 794, halogen_bond_as_acceptor_max_acceptor_angle , global , 170.0f ),
REC_f( 795, salt_bridge_distance , global , 5.0f ),
REC_b( 796, use_tessellation_shaders , global , true ),
REC_c( 797, cell_color , ostate , "-1" ),

#ifdef SETTINGINFO_IMPLEMENTATION
#undef SETTINGINFO_IMPLEMENTATION
Expand Down
7 changes: 6 additions & 1 deletion layer2/CoordSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,12 @@ void CoordSet::update(int state)
UnitCellCGO.reset(CrystalGetUnitCellCGO(&sym->Crystal));
auto use_shader = SettingGet<bool>(G, cSetting_use_shaders);
if (use_shader) {
auto color = ColorGet(G, Obj->Color);
auto cell_color = SettingGet_color(
G, this->Setting.get(), Obj->Setting.get(), cSetting_cell_color);
if (cell_color < 0) {
cell_color = Obj->Color;
}
auto color = ColorGet(G, cell_color);
auto preCGO = std::make_unique<CGO>(G);
CGOColorv(preCGO.get(), color);
CGOAppendNoStop(preCGO.get(), UnitCellCGO.get());
Expand Down
7 changes: 6 additions & 1 deletion layer2/ObjectSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,12 @@ static void ObjectSurfaceRenderCell(PyMOLGlobals *G, ObjectSurface * I,
* TODO: Ray with primitive CGO
*/

const float *color = ColorGet(G, I->Color);
// TODO: Surface-state level color?
auto cell_color = SettingGet_color(*I, cSetting_cell_color);
if (cell_color < 0) {
cell_color = I->Color;
}
const float *color = ColorGet(G, cell_color);
if (use_shader != ms->UnitCellCGO->has_draw_buffers){
if (use_shader){
auto preCGO = std::make_unique<CGO>(G);
Expand Down

1 comment on commit 3943835

@JarrettSJohnson
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.