Esempio n. 1
0
    def run_form(self):
        from emform import EMTableFormWidget
        self.form = EMTableFormWidget(self.get_params())
        self.form.resize(*self.preferred_size)
        self.form.setWindowTitle(self.window_title)
        get_application().show_specific(self.form)

        from PyQt4 import QtCore
        QtCore.QObject.connect(self.form, QtCore.SIGNAL("emform_ok"),
                               self.on_form_ok)
        QtCore.QObject.connect(self.form, QtCore.SIGNAL("emform_cancel"),
                               self.on_form_cancel)
        QtCore.QObject.connect(self.form, QtCore.SIGNAL("emform_close"),
                               self.on_form_close)
Esempio n. 2
0
	def run_form(self):
		from emform import EMTableFormWidget
		self.form = EMTableFormWidget(self.get_params())
		self.form.resize(*self.preferred_size)
		self.form.setWindowTitle(self.window_title)
		get_application().show_specific(self.form)
		
		from PyQt4 import QtCore
		QtCore.QObject.connect(self.form,QtCore.SIGNAL("emform_ok"),self.on_form_ok)
		QtCore.QObject.connect(self.form,QtCore.SIGNAL("emform_cancel"),self.on_form_cancel)
		QtCore.QObject.connect(self.form,QtCore.SIGNAL("emform_close"),self.on_form_close)
Esempio n. 3
0
class EMPreferencesTask(WorkFlowTask):
	def __init__(self,application=None):
		WorkFlowTask.__init__(self)
		self.preferred_size = [240,240]
		self.window_title = "EMAN2 preferences"
		
	def get_params(self):
		params = []
		params.append(["e2display",self.__get_display_preference_params()])
		params.append(["e2spt_boxer",self.__get_tomoboxer_preference_params()])
		return params
		
	def __get_display_preference_params(self):
		HOMEDB.open_dict("display_preferences")
		db = HOMEDB.display_preferences
		p2d_auto_contrast = ParamDef(name="display_2d_auto_contrast",vartype="boolean",desc_short="2D image auto contrast",desc_long="Should the 2D image display module adjust contrast settings automatically?",property=None,defaultunits=db.get("display_2d_auto_contrast",dfl=True),choices=None)
		p2d_stack_auto_contrast = ParamDef(name="display_stack_auto_contrast",vartype="boolean",desc_short="Stack (2D) - auto contrast",desc_long="Should the stack display module adjust contrast settings automatically?",property=None,defaultunits=db.get("display_stack_auto_contrast",dfl=True),choices=None)
		p2d_stack_n = ParamDef(name="display_stack_np_for_auto",vartype="int",desc_short="Stack (2D) - # particles used for contrast settings",desc_long="When the stack viewer starts up it investigates the parameters of the first n particles to determine contrast settings. Specify -1 to force the stack viewer to investigate all particles.",property=None,defaultunits=db.get("display_stack_np_for_auto",dfl=5),choices=None)

		params = []
		params.append(p2d_auto_contrast)
		params.append(p2d_stack_auto_contrast)
		params.append(p2d_stack_n)
		
		self.__display_entries = ["display_2d_auto_contrast","display_stack_auto_contrast","display_stack_np_for_auto"]
		
		return params
	
	def __get_tomoboxer_preference_params(self):
		HOMEDB.open_dict("e2tomoboxer_preferences")
		db = HOMEDB.e2tomoboxer_preferences
		plargest_dim = ParamDef(name="largest_allowable_dimension",vartype="int",desc_short="Shrink to this",desc_long="The largest permissible image dimension of a tomogram after shrinking",property=None,defaultunits=db.get("largest_allowable_dimension",dfl=1024),choices=None)

		params = []
		params.append(plargest_dim)
		
		self.__tomoboxer_entries = ["largest_allowable_dimension"]
		return params

	def on_form_ok(self, params):
		self.write_db_entries(params)
		self.form.close()
		self.form = None
		from PyQt4 import QtCore
		self.emit(QtCore.SIGNAL("task_idle"))
	
	def run_form(self):
		from emform import EMTableFormWidget
		self.form = EMTableFormWidget(self.get_params())
		self.form.resize(*self.preferred_size)
		self.form.setWindowTitle(self.window_title)
		get_application().show_specific(self.form)
		
		from PyQt4 import QtCore
		QtCore.QObject.connect(self.form,QtCore.SIGNAL("emform_ok"),self.on_form_ok)
		QtCore.QObject.connect(self.form,QtCore.SIGNAL("emform_cancel"),self.on_form_cancel)
		QtCore.QObject.connect(self.form,QtCore.SIGNAL("emform_close"),self.on_form_close)
		
	def write_db_entries(self,params):
		HOMEDB.open_dict("display_preferences")
		db_display = HOMEDB.display_preferences
		HOMEDB.open_dict("e2tomoboxer_preferences")
		db_tomo = HOMEDB.e2tomoboxer_preferences
		tmp_db = None
		for key,value in params.items():
			if key in self.__tomoboxer_entries:
				tmp_db = db_tomo
			elif key in self.__display_entries:
				tmp_db = db_display
			else: raise NotImplementedError("A developer has probably forgotten something")
			tmp_db[key] = value
Esempio n. 4
0
class EMPreferencesTask(WorkFlowTask):
    def __init__(self, application=None):
        WorkFlowTask.__init__(self)
        self.preferred_size = [240, 240]
        self.window_title = "EMAN2 preferences"

    def get_params(self):
        params = []
        params.append(["e2display", self.__get_display_preference_params()])
        params.append(
            ["e2spt_boxer",
             self.__get_tomoboxer_preference_params()])
        return params

    def __get_display_preference_params(self):
        HOMEDB.open_dict("display_preferences")
        db = HOMEDB.display_preferences
        p2d_auto_contrast = ParamDef(
            name="display_2d_auto_contrast",
            vartype="boolean",
            desc_short="2D image auto contrast",
            desc_long=
            "Should the 2D image display module adjust contrast settings automatically?",
            property=None,
            defaultunits=db.get("display_2d_auto_contrast", dfl=True),
            choices=None)
        p2d_stack_auto_contrast = ParamDef(
            name="display_stack_auto_contrast",
            vartype="boolean",
            desc_short="Stack (2D) - auto contrast",
            desc_long=
            "Should the stack display module adjust contrast settings automatically?",
            property=None,
            defaultunits=db.get("display_stack_auto_contrast", dfl=True),
            choices=None)
        p2d_stack_n = ParamDef(
            name="display_stack_np_for_auto",
            vartype="int",
            desc_short="Stack (2D) - # particles used for contrast settings",
            desc_long=
            "When the stack viewer starts up it investigates the parameters of the first n particles to determine contrast settings. Specify -1 to force the stack viewer to investigate all particles.",
            property=None,
            defaultunits=db.get("display_stack_np_for_auto", dfl=5),
            choices=None)

        params = []
        params.append(p2d_auto_contrast)
        params.append(p2d_stack_auto_contrast)
        params.append(p2d_stack_n)

        self.__display_entries = [
            "display_2d_auto_contrast", "display_stack_auto_contrast",
            "display_stack_np_for_auto"
        ]

        return params

    def __get_tomoboxer_preference_params(self):
        HOMEDB.open_dict("e2tomoboxer_preferences")
        db = HOMEDB.e2tomoboxer_preferences
        plargest_dim = ParamDef(
            name="largest_allowable_dimension",
            vartype="int",
            desc_short="Shrink to this",
            desc_long=
            "The largest permissible image dimension of a tomogram after shrinking",
            property=None,
            defaultunits=db.get("largest_allowable_dimension", dfl=1024),
            choices=None)

        params = []
        params.append(plargest_dim)

        self.__tomoboxer_entries = ["largest_allowable_dimension"]
        return params

    def on_form_ok(self, params):
        self.write_db_entries(params)
        self.form.close()
        self.form = None
        from PyQt4 import QtCore
        self.emit(QtCore.SIGNAL("task_idle"))

    def run_form(self):
        from emform import EMTableFormWidget
        self.form = EMTableFormWidget(self.get_params())
        self.form.resize(*self.preferred_size)
        self.form.setWindowTitle(self.window_title)
        get_application().show_specific(self.form)

        from PyQt4 import QtCore
        QtCore.QObject.connect(self.form, QtCore.SIGNAL("emform_ok"),
                               self.on_form_ok)
        QtCore.QObject.connect(self.form, QtCore.SIGNAL("emform_cancel"),
                               self.on_form_cancel)
        QtCore.QObject.connect(self.form, QtCore.SIGNAL("emform_close"),
                               self.on_form_close)

    def write_db_entries(self, params):
        HOMEDB.open_dict("display_preferences")
        db_display = HOMEDB.display_preferences
        HOMEDB.open_dict("e2tomoboxer_preferences")
        db_tomo = HOMEDB.e2tomoboxer_preferences
        tmp_db = None
        for key, value in params.items():
            if key in self.__tomoboxer_entries:
                tmp_db = db_tomo
            elif key in self.__display_entries:
                tmp_db = db_display
            else:
                raise NotImplementedError(
                    "A developer has probably forgotten something")
            tmp_db[key] = value