diff --git a/modules/gfx/pymod/export_entity.cc b/modules/gfx/pymod/export_entity.cc index c17fe7b3dcde4a9efb9cc58d6f1e47dbdad72160..e8d78cd325e651d3c42968ba631d4bfa5e98c0f9 100644 --- a/modules/gfx/pymod/export_entity.cc +++ b/modules/gfx/pymod/export_entity.cc @@ -28,6 +28,16 @@ using namespace ost::gfx; namespace { +void color_by_chain_01(Entity* e) +{ + e->ColorByChain(); +} + +void color_by_chain_02(Entity* e, const String& selection) +{ + e->ColorByChain(selection); +} + void color_by_01(Entity* e, const String& prop, const Gradient& gradient, @@ -308,7 +318,8 @@ void export_Entity() .def("PickAtom", &Entity::PickAtom) .def("PickBond", &Entity::PickBond) .def("ColorByElement",&Entity::ColorByElement) - .def("ColorByChain",&Entity::ColorByChain) + .def("ColorByChain", color_by_chain_01) + .def("ColorByChain", color_by_chain_02) .def("CleanColorOps", &Entity::CleanColorOps) .def("ReapplyColorOps", &Entity::ReapplyColorOps) .def("GetOptions", &Entity::GetOptions) diff --git a/modules/gfx/src/entity.cc b/modules/gfx/src/entity.cc index 29927009dd77bfdeca7b409b21e075cc809c3b1a..9111b9140339093991131ab7a828630f126fa71f 100644 --- a/modules/gfx/src/entity.cc +++ b/modules/gfx/src/entity.cc @@ -792,6 +792,12 @@ void Entity::ColorByChain() this->Apply(cop); } +void Entity::ColorByChain(const String& selection) +{ + ByChainColorOp cop = ByChainColorOp(selection); + this->Apply(cop); +} + void Entity::ColorBy(const mol::EntityView& ev, const String& prop, const Gradient& g, float minv, float maxv) diff --git a/modules/gfx/src/entity.hh b/modules/gfx/src/entity.hh index 1073b561a674d5fe8dced4c8e63b8d7740677c36..328b4852eb36b593ef1ec32ba397a1cca7b786ef 100644 --- a/modules/gfx/src/entity.hh +++ b/modules/gfx/src/entity.hh @@ -177,6 +177,9 @@ public: /// \brief color by chain void ColorByChain(); + /// \brief color by chain for a specific selection + void ColorByChain(const String& selection); + /// \brief get view mol::EntityView GetView() const; diff --git a/modules/gui/pymod/scene/color_options_widget.py b/modules/gui/pymod/scene/color_options_widget.py index 55b26a6a4c980f4140211957f8edd5c901b6afae..fb176038843e7649ad556088c5a85a84762b26bc 100644 --- a/modules/gui/pymod/scene/color_options_widget.py +++ b/modules/gui/pymod/scene/color_options_widget.py @@ -149,9 +149,13 @@ class ByChainWidget(QtGui.QWidget): font = text_label.font() font.setBold(True) + conly_label = QtGui.QLabel('carbons only') + self.conly_box = QtGui.QCheckBox() + grid = QtGui.QGridLayout() grid.addWidget(text_label,0,0,1,1) - grid.addWidget(QtGui.QLabel("No Settings available"), 1, 0, 1, 3) + grid.addWidget(self.conly_box, 1,0,1,1) + grid.addWidget(conly_label, 1,1,1,3) grid.setRowStretch(2,1) self.setLayout(grid) self.setMinimumSize(250,60) @@ -162,7 +166,11 @@ class ByChainWidget(QtGui.QWidget): def ChangeColor(self, node): if isinstance(node, gfx.Entity): node.CleanColorOps() - node.ColorByChain() + if self.conly_box.isChecked(): + node.ColorByChain('ele=C') + else: + node.ColorByChain() + def ChangeViewColor(self, entity, view): if isinstance(entity, gfx.Entity) and isinstance(view, mol.EntityView): @@ -184,9 +192,13 @@ class ByEntityWidget(QtGui.QWidget): font = text_label.font() font.setBold(True) + conly_label = QtGui.QLabel('carbons only') + self.conly_box = QtGui.QCheckBox() + grid = QtGui.QGridLayout() grid.addWidget(text_label,0,0,1,1) - grid.addWidget(QtGui.QLabel("No Settings available"), 1, 0, 1, 3) + grid.addWidget(self.conly_box, 1,0,1,1) + grid.addWidget(conly_label, 1,1,1,3) grid.setRowStretch(2,1) self.setLayout(grid) self.setMinimumSize(250,60) @@ -205,7 +217,10 @@ class ByEntityWidget(QtGui.QWidget): else: color=self.gradient_.GetColorAt(float(i) / entity_count) node = scene_selection.GetActiveNode(i) - node.SetColor(color) + if self.conly_box.isChecked(): + node.SetColor(color, 'ele=C') + else: + node.SetColor(color) def ChangeColor(self, node): pass diff --git a/modules/gui/pymod/scene/uniform_color_widget.py b/modules/gui/pymod/scene/uniform_color_widget.py index d214bbee811e51dd767f43862e0384b5640a779d..29bc7cf9f6e1fcccf72c6bcbdda6e1ae508902d3 100644 --- a/modules/gui/pymod/scene/uniform_color_widget.py +++ b/modules/gui/pymod/scene/uniform_color_widget.py @@ -42,6 +42,8 @@ class UniformColorWidget(QtGui.QWidget): font = uniform_label.font() font.setBold(True) + conly_label = QtGui.QLabel('carbons only') + self.conly_box = QtGui.QCheckBox() self.color_select_widget_ = ColorSelectWidget(1,1,QtGui.QColor("White")) @@ -54,6 +56,9 @@ class UniformColorWidget(QtGui.QWidget): grid.setColumnStretch(0,1) grid.setColumnStretch(2,1) + grid.addWidget(self.conly_box, 4,0) + grid.addWidget(conly_label, 4,1) + top_layout.addWidget(uniform_label) top_layout.addLayout(grid) self.setLayout(top_layout) @@ -87,7 +92,10 @@ class UniformColorWidget(QtGui.QWidget): gfx_color = self.color_select_widget_.GetGfxColor() if isinstance(node, gfx.Entity) or isinstance(node, gfx.Surface): node.CleanColorOps() - node.SetColor(gfx_color,"") + if self.conly_box.isChecked(): + node.SetColor(gfx_color,"ele=C") + else: + node.SetColor(gfx_color,"") elif _img_present and isinstance(node, gfx.MapIso): node.SetColor(gfx_color)