def edit_initialize(self, fitsimage, obj): # remove old params self.w.drawvbox.remove_all() self.edit_obj = obj if (obj is not None) and self.canvas.is_selected(obj): self.w.attrlbl.set_text("Editing a %s" % (obj.kind)) drawClass = obj.__class__ # Build up a set of control widgets for the parameters # of the canvas object to be drawn paramlst = drawClass.get_params_metadata() self.draw_params = ParamSet.ParamSet(self.logger, obj) w = self.draw_params.build_params(paramlst, orientation=self.orientation) self.draw_params.add_callback('changed', self.edit_params_changed_cb) self.w.drawvbox.add_widget(w, stretch=1) self.w.delete_obj.set_enabled(True) self.w.scale_by.set_enabled(True) self.w.rotate_by.set_enabled(True) else: self.w.attrlbl.set_text("") self.w.delete_obj.set_enabled(False) self.w.scale_by.set_enabled(False) self.w.rotate_by.set_enabled(False)
def config_autocut_params(self, method): index = self.autocut_methods.index(method) self.w.auto_method.set_index(index) # remove old params self.w.acvbox.remove_all() # Create new autocuts object of the right kind ac_class = AutoCuts.get_autocuts(method) # Build up a set of control widgets for the autocuts # algorithm tweakable parameters paramlst = ac_class.get_params_metadata() # Get the canonical version of this object stored in our cache # and make a ParamSet from it params = self.autocuts_cache.setdefault(method, Bunch.Bunch()) self.ac_params = ParamSet.ParamSet(self.logger, params) # Build widgets for the parameter/attribute list w = self.ac_params.build_params(paramlst, orientation=self.orientation) self.ac_params.add_callback('changed', self.autocut_params_changed_cb) # Add this set of widgets to the pane self.w.acvbox.add_widget(w, stretch=1)
def set_drawparams_cb(self): index = self.w.draw_type.get_index() kind = self.drawtypes[index] # remove old params self.w.drawvbox.remove_all() # Create new drawing class of the right kind drawClass = self.canvas.get_draw_class(kind) self.w.attrlbl.set_text("New Object: %s" % (kind)) # Build up a set of control widgets for the parameters # of the canvas object to be drawn paramlst = drawClass.get_params_metadata() params = self.drawparams_cache.setdefault(kind, Bunch.Bunch()) self.draw_params = ParamSet.ParamSet(self.logger, params) w = self.draw_params.build_params(paramlst, orientation=self.orientation) self.draw_params.add_callback('changed', self.draw_params_changed_cb) self.w.drawvbox.add_widget(w, stretch=1) # disable edit-only controls self.w.delete_obj.set_enabled(False) self.w.scale_by.set_enabled(False) self.w.rotate_by.set_enabled(False) args, kwdargs = self.draw_params.get_params() self.logger.debug("changing params to: %s" % (str(kwdargs))) self.canvas.set_drawtype(kind, **kwdargs)
def config_autocut_params(self, method): index = self.autocut_methods.index(method) self.w.auto_method.set_index(index) # remove old params self.w.acvbox.remove_all() # Create new autocuts object of the right kind ac = AutoCuts.get_autocuts(method)(self.logger) # Build up a set of control widgets for the autocuts # algorithm tweakable parameters paramlst = ac.get_params_metadata() params = self.autocuts_cache.setdefault(method, {}) self.ac_params = ParamSet.ParamSet(self.logger, params) w = self.ac_params.build_params(paramlst, orientation=self.orientation) self.ac_params.add_callback('changed', self.autocut_params_changed_cb) self.w.acvbox.add_widget(w, stretch=1)