Exemplo n.º 1
0
    def __init__(self, app):
        self.app = app
        QtGui.QWidget.__init__(self, None)

        self.synthplot = EMPlot2DWidget(self.app)
        self.synthplot.show()

        # overall layout
        self.vbl1 = QtGui.QVBoxLayout()
        self.setLayout(self.vbl1)

        # First row contains general purpose controls
        self.hbl1 = QtGui.QHBoxLayout()
        self.vbl1.addLayout(self.hbl1)

        self.vcell = ValBox(self, (0, 128.0), "Cell:", 64)
        self.hbl1.addWidget(self.vcell)

        self.vncells = ValBox(self, (0, 128.0), "n Cells:", 1)
        self.hbl1.addWidget(self.vncells)

        self.voversamp = ValBox(self, (0, 128.0), "Oversample:", 1)
        self.hbl1.addWidget(self.voversamp)

        self.targfn = None

        self.vnsin = ValBox(self, (1, 64), "# Sin:", 16)
        self.vnsin.intonly = 1
        self.hbl1.addWidget(self.vnsin)

        self.cbshowall = QtGui.QCheckBox("Show All")
        self.hbl1.addWidget(self.cbshowall)

        self.cbshifted = QtGui.QCheckBox("Shifted")
        self.hbl1.addWidget(self.cbshifted)

        self.cbtargfn = QtGui.QComboBox(self)
        self.cbtargfn.addItem("None")
        self.cbtargfn.addItem("triangle")
        self.cbtargfn.addItem("square")
        self.cbtargfn.addItem("square imp")
        self.cbtargfn.addItem("delta")
        self.cbtargfn.addItem("noise")
        self.cbtargfn.addItem("saw")
        self.cbtargfn.addItem("sin")
        self.cbtargfn.addItem("modsin")
        self.cbtargfn.addItem("modsin2")
        self.cbtargfn.addItem("modsin3")
        self.cbtargfn.addItem("sin low")
        self.cbtargfn.addItem("doubledelta")
        self.cbtargfn.addItem("sin bad f")
        self.cbtargfn.addItem("sin bad f2")
        self.hbl1.addWidget(self.cbtargfn)

        # Widget containing valsliders
        self.wapsliders = QtGui.QWidget(self)
        #		self.wapsliders.setMinimumSize(800,640)
        self.gblap = QtGui.QGridLayout()
        self.gblap.setSizeConstraint(QtGui.QLayout.SetMinAndMaxSize)
        self.gblap.setColumnMinimumWidth(0, 250)
        self.gblap.setColumnMinimumWidth(1, 250)
        self.wapsliders.setLayout(self.gblap)

        # ScrollArea providing view on slider container widget
        self.wapsarea = QtGui.QScrollArea(self)
        self.wapsarea.setWidgetResizable(True)
        self.wapsarea.setWidget(self.wapsliders)
        self.vbl1.addWidget(self.wapsarea)

        QtCore.QObject.connect(self.vcell, QtCore.SIGNAL("valueChanged"),
                               self.recompute)
        QtCore.QObject.connect(self.vncells, QtCore.SIGNAL("valueChanged"),
                               self.recompute)
        QtCore.QObject.connect(self.voversamp, QtCore.SIGNAL("valueChanged"),
                               self.recompute)
        QtCore.QObject.connect(self.vnsin, QtCore.SIGNAL("valueChanged"),
                               self.nsinchange)
        QtCore.QObject.connect(self.cbshowall,
                               QtCore.SIGNAL("stateChanged(int)"),
                               self.recompute)
        QtCore.QObject.connect(self.cbshifted,
                               QtCore.SIGNAL("stateChanged(int)"),
                               self.recompute)
        QtCore.QObject.connect(self.cbtargfn, QtCore.SIGNAL("activated(int)"),
                               self.newtargfn)

        self.wamp = []
        self.wpha = []
        self.curves = []
        self.xvals = []
        for i in range(65):
            self.wamp.append(ValSlider(self, (0.0, 1.0), "%2d:" % i, 0.0))
            self.gblap.addWidget(self.wamp[-1], i, 0)
            QtCore.QObject.connect(self.wamp[-1],
                                   QtCore.SIGNAL("valueChanged"),
                                   self.recompute)

            self.wpha.append(ValSlider(self, (-180.0, 180.0), "%2d:" % i, 0.0))
            self.gblap.addWidget(self.wpha[-1], i, 1)
            QtCore.QObject.connect(self.wpha[-1],
                                   QtCore.SIGNAL("valueChanged"),
                                   self.recompute)

            self.curves.append(EMData(64, 1))

            if self.cbshowall.isChecked():
                self.synthplot
        self.total = EMData(64, 1)

        self.nsinchange()
Exemplo n.º 2
0
    def __init__(self,
                 imagenames,
                 voltage=None,
                 apix=None,
                 cs=None,
                 ac=10.0,
                 box=256,
                 ptcl=200):
        """The 'new' e2boxer interface.
		"""

        QtGui.QWidget.__init__(self, None)
        #		self.setWindowIcon(QtGui.QIcon(get_image_directory() + "ctf.png"))

        self.data = None
        self.curfilename = None  # current selected file for boxing
        self.filenames = imagenames  # list of available filenames
        self.micrograph = None
        self.boxes = None

        self.defaultvoltage = voltage
        self.defaultapix = apix
        self.defaultcs = cs
        self.defaultac = ac

        self.db = None  # open JSON file for current image

        self.wimage = EMImage2DWidget()
        self.wimage.setWindowTitle("Micrograph")

        self.wparticles = EMImageMXWidget()
        self.wparticles.setWindowTitle("Particles")

        self.wrefs = EMImageMXWidget()
        self.wrefs.setWindowTitle("Box Refs")

        self.wbadrefs = EMImageMXWidget()
        self.wbadrefs.setWindowTitle("Bad Box Refs")

        #self.wfft=EMImage2DWidget()
        #self.wfft.setWindowTitle("e2evalimage - 2D FFT")

        #self.wplot=EMPlot2DWidget()
        #self.wplot.setWindowTitle("e2evalimage - Plot")

        self.wimage.connect(self.wimage, QtCore.SIGNAL("mousedown"),
                            self.imgmousedown)
        self.wimage.connect(self.wimage, QtCore.SIGNAL("mousedrag"),
                            self.imgmousedrag)
        self.wimage.connect(self.wimage, QtCore.SIGNAL("mouseup"),
                            self.imgmouseup)
        self.wparticles.connect(self.wparticles, QtCore.SIGNAL("mousedown"),
                                self.ptclmousedown)
        self.wparticles.connect(self.wparticles, QtCore.SIGNAL("mousedrag"),
                                self.ptclmousedrag)
        self.wparticles.connect(self.wparticles, QtCore.SIGNAL("mouseup"),
                                self.ptclmouseup)
        self.wrefs.connect(self.wparticles, QtCore.SIGNAL("mousedown"),
                           self.refmousedown)
        self.wrefs.connect(self.wparticles, QtCore.SIGNAL("mousedrag"),
                           self.refmousedrag)
        self.wrefs.connect(self.wparticles, QtCore.SIGNAL("mouseup"),
                           self.refmouseup)

        self.wimage.mmode = "app"
        self.wparticles.mmode = "app"

        # This object is itself a widget we need to set up
        self.gbl = QtGui.QGridLayout(self)
        self.gbl.setMargin(8)
        self.gbl.setSpacing(6)

        # Micrograph list
        self.setlist = QtGui.QListWidget(self)
        self.setlist.setSizePolicy(QtGui.QSizePolicy.Preferred,
                                   QtGui.QSizePolicy.Expanding)
        for i in imagenames:
            self.setlist.addItem(i)
        self.gbl.addWidget(self.setlist, 0, 0, 12, 2)

        self.setlist.connect(self.setlist,
                             QtCore.SIGNAL("currentRowChanged(int)"),
                             self.newSet)
        self.setlist.connect(self.setlist, QtCore.SIGNAL("keypress"),
                             self.listKey)

        # Mouse Modes
        self.mmode = "manual"
        self.boxmm = QtGui.QGroupBox("Mouse Mode", self)
        self.boxmm.setFlat(False)
        self.gbl.addWidget(self.boxmm, 0, 2, 3, 2)

        self.hbl0 = QtGui.QHBoxLayout(self.boxmm)

        self.bmmanual = QtGui.QPushButton("Manual")
        self.bmmanual.setToolTip(
            "Manual selection of particles. No impact on autoselection.")
        self.bmmanual.setAutoExclusive(True)
        self.bmmanual.setCheckable(True)
        self.bmmanual.setChecked(True)
        self.hbl0.addWidget(self.bmmanual)

        self.bmdel = QtGui.QPushButton("Delete")
        self.bmdel.setToolTip(
            "Delete particles from any mode. Can also shift-click in other mouse modes."
        )
        self.bmdel.setAutoExclusive(True)
        self.bmdel.setCheckable(True)
        self.hbl0.addWidget(self.bmdel)

        self.bmgref = QtGui.QPushButton("Good Refs")
        self.bmgref.setToolTip(
            "Identify some good particles. Available to all autoboxers.")
        self.bmgref.setAutoExclusive(True)
        self.bmgref.setCheckable(True)
        self.hbl0.addWidget(self.bmgref)

        self.bmbref = QtGui.QPushButton("Bad Refs")
        self.bmbref.setToolTip(
            "Identify regions which should not be selected as particles.")
        self.bmbref.setAutoExclusive(True)
        self.bmbref.setCheckable(True)
        self.hbl0.addWidget(self.bmbref)

        QtCore.QObject.connect(self.bmmanual, QtCore.SIGNAL("clicked(bool)"),
                               self.setMouseManual)
        QtCore.QObject.connect(self.bmdel, QtCore.SIGNAL("clicked(bool)"),
                               self.setMouseDel)
        QtCore.QObject.connect(self.bmgref, QtCore.SIGNAL("clicked(bool)"),
                               self.setMouseGoodRef)
        QtCore.QObject.connect(self.bmbref, QtCore.SIGNAL("clicked(bool)"),
                               self.setMouseBadRef)

        # Global parameters
        self.boxparm = QtGui.QGroupBox("Parameters", self)
        self.boxparm.setFlat(False)
        self.gbl.addWidget(self.boxparm, 3, 2, 3, 3)

        self.gbl1 = QtGui.QGridLayout(self.boxparm)
        self.gbl1.setMargin(8)
        self.gbl1.setSpacing(6)

        self.vbbsize = ValBox(label="Box Size:", value=box)
        self.gbl1.addWidget(self.vbbsize, 0, 0)

        self.vbbpsize = ValBox(label="Ptcl Size:", value=ptcl)
        self.gbl1.addWidget(self.vbbpsize, 0, 1)

        self.vbbapix = ValBox(label="A/pix:", value=apix)
        self.gbl1.addWidget(self.vbbapix, 0, 2)

        self.vbvoltage = ValBox(label="Voltage:", value=voltage)
        self.gbl1.addWidget(self.vbvoltage, 1, 0)

        self.vbbac = ValBox(label="% AC:", value=ac)
        self.gbl1.addWidget(self.vbbac, 1, 1)

        self.vbcs = ValBox(label="Cs:", value=cs)
        self.gbl1.addWidget(self.vbcs, 1, 2)

        # Autoboxing Tabs
        self.autolbl = QtGui.QLabel("Autoboxing Methods:")
        self.gbl.addWidget(self.autolbl, 7, 2)
        self.autotab = QtGui.QTabWidget()
        self.gbl.addWidget(self.autotab, 8, 2, 6, 3)

        self.bautobox = QtGui.QPushButton("Autobox")
        self.gbl.addWidget(self.bautobox, 7, 4)

        QtCore.QObject.connect(self.bautobox, QtCore.SIGNAL("clicked(bool)"),
                               self.doAutoBox)

        # Individual tabs from Dictionary
        self.abwid = []
        for name, bname, cls in GUIBoxer.aboxmodes:
            w = QtGui.QWidget()
            gl = QtGui.QGridLayout(w)
            self.abwid.append((w, gl))
            cls.setup_gui(gl)
            self.autotab.addTab(w, name)

        self.setWindowTitle("e2boxer21 - Control Panel")

        self.wimage.show()
        #		self.wfft.show()
        #		self.wplot.show()
        E2loadappwin("e2boxer21", "main", self)
        E2loadappwin("e2boxer21", "image", self.wimage.qt_parent)
        E2loadappwin("e2boxer21", "particles", self.wparticles.qt_parent)
        E2loadappwin("e2boxer21", "refs", self.wrefs.qt_parent)
        E2loadappwin("e2boxer21", "badrefs", self.wbadrefs.qt_parent)

        self.newSet(0)