def ChangeViewColor(self, entity, view): if isinstance(entity, gfx.Entity) and isinstance(view, mol.EntityView): if self.parent_.GetCarbonsOnly(): bco = gfx.ByChainColorOp( mol.QueryViewWrapper(mol.Query("ele=C"), view)) else: bco = gfx.ByChainColorOp(mol.QueryViewWrapper(view)) entity.Apply(bco)
def ChangeViewColor(self, entity, view): if isinstance(entity, gfx.Entity) and isinstance(view, mol.EntityView): gfx_color = self.color_select_widget_.GetGfxColor() if self.parent_.GetCarbonsOnly(): ufco = gfx.UniformColorOp( mol.QueryViewWrapper(mol.Query("ele=C"), view), gfx_color) else: ufco = gfx.UniformColorOp(mol.QueryViewWrapper(view), gfx_color) entity.Apply(ufco)
def _Select(self): scene_selection=gui.SceneSelection.Instance() ent=scene_selection.GetActiveNode(0) dialog=QueryDialog('Select...') if dialog.exec_(): q=mol.Query(dialog.query) if q.IsValid(): ent.selection=ent.view.Select(dialog.query, dialog.query_flags) else: ost.LogError("invalid query: %s" % q.error)
def _SelectViewsSameEntity(self): union=gui.SceneSelection.Instance().GetViewUnion() dialog=QueryDialog('Select...') if dialog.exec_(): q=mol.Query(dialog.query) if q.IsValid(): ve=gui.SceneSelection.Instance().GetViewEntity() ve.selection=union.Select(q, dialog.query_flags) else: ost.LogError("invalid query: %s" % q.error)
def ChangeViewColor(self, entity, view): if isinstance(entity, gfx.Entity) and isinstance(view, mol.EntityView): if self.parent_.GetCarbonsOnly(): glco = gfx.GradientLevelColorOp( mol.QueryViewWrapper(mol.Query("ele=C"), view), self.props[self.prop_combo_box_.currentIndex()], self.gradient_edit_.GetGfxGradient(), mol.Prop.Level.UNSPECIFIED) else: glco = gfx.GradientLevelColorOp( mol.QueryViewWrapper(view), self.props[self.prop_combo_box_.currentIndex()], self.gradient_edit_.GetGfxGradient(), mol.Prop.Level.UNSPECIFIED) entity.Apply(glco)
def _CopyViews(self): views_to_add=[] scene_selection=gui.SceneSelection.Instance() ent=scene_selection.GetActiveNode(0) dialog=QueryDialog('Select...') if dialog.exec_(): q=mol.Query(dialog.query) if q.IsValid(): for i in range(scene_selection.GetActiveNodeCount()): ent=scene_selection.GetActiveNode(i) selected=ent.view.Select(q, dialog.query_flags) gfx_ent=gfx.Entity(self._UniqueName(ent),selected) gfx.Scene().Add(gfx_ent) else: ost.LogError("invalid query: %s" % q.error)
def GetQuery(self): return mol.Query(str(self.selection_edit_.toPlainText()))
def _entity_reset(self, *args, **kwargs): import ost.mol as mol eh = None ev = None qr = None qf = None for a in args: if isinstance(a, mol.Query): if qr: raise TypeError("Reset: more than one query string given") qr = a elif isinstance(a, mol.EntityHandle): if eh: raise TypeError("Reset: more than one entity handle given") eh = a elif isinstance(a, mol.EntityView): if ev: raise TypeError("Reset: more than one entity view given") ev = a elif isinstance(a, str): if qr: raise TypeError("Reset: more than one query string given") qr = mol.Query(a) elif isinstance(a, int): if qf: raise TypeError("Reset: more than one QueryFlags given") qf = a else: raise TypeError("Reset: unknown option of type '%s' given" % type(a)) for key, val in kwargs.items(): if key == "entity": if not isinstance(val, mol.EntityHandle): raise TypeError( "Reset: expected mol.EntityHandle for 'entity' option") if eh: raise TypeError("Reset: more than one entity handle given") eh = val elif key == "view": if not isinstance(val, mol.EntityView): raise TypeError( "Reset: expected mol.EntityView for 'view' option") if ev: raise TypeError("Reset: more than one entity view given") ev = val elif key == "query": if isinstance(val, mol.Query): pass elif isinstance(val, str): val = mol.Query(val) else: raise TypeError( "Reset: expected mol.Query or string for 'query' option") if qr: raise TypeError("Reset: more than one query string given") qr = val elif key == "query_flags": if not isinstance(val, int): raise TypeError( "Reset: expected integer for 'query_flags' option") if qf: raise TypeError("Reset: more than one query flags given") qf = val else: raise TypeError("Reset: unknown key '%s'" % key) if eh and ev: raise TypeError( "Reset: entity and view are mutually exclusive options") if ev: self._reset4(ev) else: if not eh: eh = self.query_view.entity if not qr: qr = self.query_view.query if not qf: qf = self.query_view.GetFlags() self._reset3(eh, qr, qf)