示例#1
0
    def openStrandSequenceFile(self):
        """
        Open (read) the user specified Strand sequence file and enter the
        sequence in the Strand sequence Text edit. Note that it ONLY reads the
        FIRST line of the file.
        @TODO: It only reads in the first line of the file. Also, it doesn't
               handle any special cases. (Once the special cases are clearly
               defined, that functionality will be added.
        """

        if self.parentWidget.assy.filename:
            odir = os.path.dirname(self.parentWidget.assy.filename)
        else:
            odir = env.prefs[workingDirectory_prefs_key]
        self.sequenceFileName = \
            str(QFileDialog.getOpenFileName(
                self,
                "Load Strand Sequence",
                odir,
                "Strand Sequnce file (*.txt);;All Files (*.*);;"))
        lines = self.sequenceFileName
        try:
            lines = open(self.sequenceFileName, "rU").readlines()
        except:
            print "Exception occurred to open file: ", self.sequenceFileName
            return

        sequence = lines[0]
        sequence = QString(sequence)
        sequence = sequence.toUpper()
        self._updateSequenceAndItsComplement(sequence)
        return
示例#2
0
    def updateSequence(self):
        """
        Update the sequence string in the sequence editor
        @see: DnaSequenceEditor.setSequence()
        @see DnaSequenceEditor._determine_complementSequence()
        @see: DnaSequenceEditor.setComplementSequence()
        @see: DnaStrand.getStrandSequenceAndItsComplement()
        """
        #Read in the strand sequence of the selected strand and
        #show it in the text edit in the sequence editor.
        ##strand = self.strandListWidget.getPickedItem()

        if not self.editCommand.hasValidStructure():
            return

        strand = self.editCommand.struct

        titleString = 'Sequence Editor for ' + strand.name

        self.sequenceEditor.setWindowTitle(titleString)
        sequenceString, complementSequenceString = strand.getStrandSequenceAndItsComplement(
        )
        if sequenceString:
            sequenceString = QString(sequenceString)
            sequenceString = sequenceString.toUpper()
            #Set the initial sequence (read in from the file)
            self.sequenceEditor.setSequence(sequenceString)

            #Set the initial complement sequence for DnaSequence editor.
            #do this independently because 'complementSequenceString' may have
            #some characters (such as * ) that denote a missing base on the
            #complementary strand. this information is used by the sequence
            #editor. See DnaSequenceEditor._determine_complementSequence()
            #for more details. See also bug 2787
            self.sequenceEditor.setComplementSequence(complementSequenceString)
示例#3
0
    def slotEditUser(self, item=None):
        if not item:
            item = self.ui.userList.currentItem()
        self.ui.userList.setCurrentItem(item)
        user = item.getUser()
        if user.uid > -1:
            self.ui.userIDCheck.setChecked(True)
            self.ui.userID.setValue(user.uid)
        self.ui.username.setText(QString(user.username))
        self.ui.realname.setText(QString(user.realname))
        self.ui.pass1.setText(QString(user.passwd))
        self.ui.pass2.setText(QString(user.passwd))

        if "wheel" in user.groups:
            self.ui.admin.setChecked(True)
        else:
            self.ui.admin.setChecked(False)

        self.ui.noPass.setChecked(user.no_password)

        self.edititemindex = self.ui.userList.currentRow()
        self.ui.createButton.setText(_("Update"))
        icon = QIcon()
        icon.addPixmap(QPixmap(":/gui/pics/tick.png"), QIcon.Normal, QIcon.Off)
        self.ui.createButton.setIcon(icon)
        self.ui.cancelButton.setVisible(self.ui.createButton.isVisible())
示例#4
0
 def setText(self, text):
     if len(text) == 0: return
     lines = text.split('\n')
     qf = QFontMetrics(self.font)
     fmw = max(qf.maxWidth(), 10)
     nlines = []
     w = self.width - 2 * self.margin
     for line in lines:
         if qf.width(line) > w:
             while qf.width(line) > w:
                 for i in xrange(w / fmw, len(line)):
                     if qf.width(line, i) > w:
                         if line[i].isalnum() and line[i - 1].isalnum():
                             nlines.append(line[0:i - 1] + (
                                 '-' if line[i - 2].isalnum() else ''))
                             line = line[i - 1:]
                         else:
                             nlines.append(line[0:i])
                             line = line[i:]
                         break
             nlines.append(QString(line))
         else:
             nlines.append(QString(line))
     self.__text = nlines
     self.__computeTextPosition()
    def _open_FASTA_File(self):
        """
        Open (read) the user specified FASTA sequence file and load it into
        the sequence field.

        @TODO: It only reads in the first line of the file. Also, it doesn't
               handle any special cases. (Once the special cases are clearly
               defined, that functionality will be added.

        @attention: This is not implemented yet.
        """
        #Urmi 20080714: should not this be only fasta file, for both load and save
        if self.parentWidget.assy.filename:
            odir = os.path.dirname(self.parentWidget.assy.filename)
        else:
            odir = env.prefs[workingDirectory_prefs_key]
        self.sequenceFileName = \
            str(QFileDialog.getOpenFileName(
                self,
                "Load FASTA sequence for " + self.current_protein.name,
                odir,
                "FASTA file (*.txt);;All Files (*.*);;"))
        lines = self.sequenceFileName
        try:
            lines = open(self.sequenceFileName, "rU").readlines()
        except:
            print "Exception occurred to open file: ", self.sequenceFileName
            return

        sequence = lines[0]
        sequence = QString(sequence)
        sequence = sequence.toUpper()
        self._setSequence(sequence)
        return
示例#6
0
 def openStrandSequenceFile(self):
     """
     Open (read) the user specified Strand sequence file and enter the 
     sequence in the Strand sequence Text edit. Note that it ONLY reads the 
     FIRST line of the file.
     @TODO: It only reads in the first line of the file. Also, it doesn't
            handle any special cases. (Once the special cases are clearly 
            defined, that functionality will be added. 
     """
     
     if self.parentWidget.assy.filename: 
         odir = os.path.dirname(self.parentWidget.assy.filename)
     else: 
         odir = env.prefs[workingDirectory_prefs_key]
     self.sequenceFileName = \
         str(QFileDialog.getOpenFileName( 
             self,
             "Load Strand Sequence",
             odir,
             "Strand Sequnce file (*.txt);;All Files (*.*);;"))  
     lines = self.sequenceFileName
     try:
         lines = open(self.sequenceFileName, "rU").readlines()         
     except:
         print "Exception occurred to open file: ", self.sequenceFileName
         return 
     
     sequence = lines[0]
     sequence = QString(sequence) 
     sequence = sequence.toUpper()
     self._updateSequenceAndItsComplement(sequence)
     return
 def updateSequence(self):
     """
     Update the sequence string in the sequence editor
     @see: DnaSequenceEditor.setSequence()
     @see DnaSequenceEditor._determine_complementSequence()
     @see: DnaSequenceEditor.setComplementSequence()
     @see: DnaStrand.getStrandSequenceAndItsComplement()
     """
     #Read in the strand sequence of the selected strand and 
     #show it in the text edit in the sequence editor.
     ##strand = self.strandListWidget.getPickedItem()
     
     if not self.editCommand.hasValidStructure():
         return
     
     strand = self.editCommand.struct
     
     titleString = 'Sequence Editor for ' + strand.name
                        
     self.sequenceEditor.setWindowTitle(titleString)
     sequenceString, complementSequenceString = strand.getStrandSequenceAndItsComplement()
     if sequenceString:
         sequenceString = QString(sequenceString) 
         sequenceString = sequenceString.toUpper()
         #Set the initial sequence (read in from the file)
         self.sequenceEditor.setSequence(sequenceString)
         
         #Set the initial complement sequence for DnaSequence editor. 
         #do this independently because 'complementSequenceString' may have
         #some characters (such as * ) that denote a missing base on the 
         #complementary strand. this information is used by the sequence
         #editor. See DnaSequenceEditor._determine_complementSequence() 
         #for more details. See also bug 2787
         self.sequenceEditor.setComplementSequence(complementSequenceString)
示例#8
0
def getComplementSequence(inSequence):
    """
    Returns the complement of the DNA sequence I{inSequence}.
    
    @param inSequence: The original DNA sequence.
    @type  inSequence: str (possible error: the code looks more like it
                       requires a QString [bruce 080101 comment])
    
    @return: The complement DNA sequence.
    @rtype:  str (possible error: the code looks more like it
                  might return a QString [bruce 080101 comment])
    """
    #If user enters an empty 'space' or 'tab key', treat it as an empty space
    #in the complement sequence. (don't convert it to 'N' base)
    #This is needed in B{DnaSequenceEditor} where , if user enters an empty space
    #in the 'Strand' Sequence, its 'Mate' also enters an empty space.
    validSpaceSymbol = QString(' ')
    validTabSymbol = QString('\t')
    assert isinstance(inSequence, str)
    outSequence = ""
    for baseLetter in inSequence:
        if baseLetter not in basesDict.keys():
            if baseLetter in validSpaceSymbol:
                pass
            elif baseLetter in validTabSymbol:
                baseLetter = '\t'
            else:
                baseLetter = "N"
        else:
            baseLetter = basesDict[baseLetter]['Complement']
        outSequence += baseLetter
    return outSequence
    def draw_glpane_label_text(self, text):
        """
        Draw a text label for the glpane as a whole.
        
        @note: called indirectly from GLPane.paintGL shortly after
               it calls _do_graphicsMode_Draw(), via GraphicsMode.draw_glpane_label
        """
        #bruce 090219 moved this here from part of Part.draw_text_label
        # (after a temporary stop in the short-lived class PartDrawer);
        # the other part is now our caller GraphicsMode.draw_glpane_label.

        # (note: caller catches exceptions, so we don't have to bother)
        
        glDisable(GL_LIGHTING)
        glDisable(GL_DEPTH_TEST)
            # Note: disabling GL_DEPTH_TEST properly affects 2d renderText
            # (as used here), but not 3d renderText. For more info see
            # today's comments in Guides.py. [bruce 081204 comment]
        glPushMatrix() # REVIEW: needed? [bruce 081204 question]
        font = QFont(QString("Helvetica"), 24, QFont.Bold)
        self.qglColor(Qt.red) # this needs to be impossible to miss -- not nice-looking!
            #e tho it might be better to pick one of several bright colors
            # by hashing the partname, so as to change the color when the part changes.
        # this version of renderText uses window coords (0,0 at upper left)
        # rather than model coords (but I'm not sure what point on the string-image
        # we're setting the location of here -- guessing it's bottom-left corner):
        self.renderText(25,40, QString(text), font)
        glPopMatrix()
        glEnable(GL_DEPTH_TEST)
        glEnable(GL_LIGHTING)
        return
示例#10
0
    def handleSelectWorkspace(self):
        file_dialog = QtGui.QFileDialog()
        select_ws = file_dialog.getExistingDirectory(parent=None,
                                                     directory=QString(expanduser("~")),
                                                     caption=QString("Select Workspace Folder"))

        self.selected_ws.setText(select_ws)
        self.selected_path = str(select_ws)
示例#11
0
 def _populate_combo_box(self):
     # diagnostic datasets can have only diagnostic outcomes
     if self.is_diag:
         self.datatype_cbo_box.addItem(QString("Diagnostic"),
                                       QVariant(DIAGNOSTIC))
     else:
         for name, type_id in zip(
             [QString(s) for s in ["Binary", "Continuous"]],
             [QVariant(i) for i in range(2)]):
             self.datatype_cbo_box.addItem(name, type_id)
示例#12
0
    def testUrlEncode(self):

        qs = QString("Hello World")
        s = str(qs)
        quoted = urllib.quote(str(s))
        self.assertEquals("Hello%20World", quoted)

        qs = QString(unicode("§A ¦n", 'big5'))
        u = unicode(qs.toUtf8(),'utf8').encode('utf8')
        s = str(u)
        quoted = urllib.quote(str(s))
        self.assertEquals('%E4%BD%A0%20%E5%A5%BD', quoted)
示例#13
0
 def setThemeFromGtk():
     f = QFile(QDir.homePath() + "/.gtkrc-2.0");
     if not f.open(QIODevice.ReadOnly | QIODevice.Text):
         return
     while not f.atEnd():
         l = f.readLine().trimmed();
         if l.startsWith("gtk-icon-theme-name="):
             s = QString(l.split('=')[-1]);
             syslog.syslog( syslog.LOG_DEBUG,
                            "DEBUG  setting gtk theme %s" % str(s));
             QIcon.setThemeName(s.remove('"'));
             break
示例#14
0
def _old_code_for_drawing_text(glpane):
    self = glpane
    glDisable(GL_LIGHTING)
    glDisable(GL_DEPTH_TEST)
    self.qglColor(QColor(0, 0, 0))
    font = QFont(QString("Times"), 10)
    text = QString('Rvdw = ' + str(self.rad))
    fontMecs = QFontMetrics(font)
    strWd = fontMecs.width(text)
    strHt = fontMecs.height()
    w = self.width / 2 - strWd / 2
    h = self.height - strHt / 2
    self.renderText(w, h, text, font)
    glEnable(GL_DEPTH_TEST)
    glEnable(GL_LIGHTING)
    def saveFavorite(self):
        """
        Writes the current favorite (selected in the combobox) to a file, any 
        where in the disk that 
        can be given to another NE1 user (i.e. as an email attachment).
        """

        cmd = greenmsg("Save Favorite File: ")
        env.history.message(greenmsg("Save Favorite File:"))
        current_favorite = self.favoritesComboBox.currentText()
        favfilepath = getFavoritePathFromBasename(current_favorite)

        formats = \
                    "Favorite (*.txt);;"\
                    "All Files (*.*)"

        fn = QFileDialog.getSaveFileName(
            self,
            "Save Favorite As",  # caption
            favfilepath,  #where to save
            formats,  # file format options
            QString("Favorite (*.txt)")  # selectedFilter
        )
        if not fn:
            env.history.message(cmd + "Cancelled")

        else:
            saveFavoriteFile(str(fn), favfilepath)
        return
示例#16
0
 def updatePixmap(self):
     self.__m_nIndex += 1
     if self.__m_nIndex > 8:
         self.__m_nIndex = 1
     pixmap = QtGui.QPixmap(
         QString(":/images/loading%1").arg(self.__m_nIndex))
     self.label_3.setPixmap(pixmap)
示例#17
0
 def show_dialog(self):
     fd = QtGui.QFileDialog(self)
     fd.resize(QSize(640, 480))
     self.__dir = fd.getExistingDirectory(
         fd, QString(u"Открыть папку с изображениями:"),
         os.getcwd().replace("\\", "/"),
         QtGui.QFileDialog.DontResolveSymlinks)
示例#18
0
    def _initGui(self):
        layout = QVBoxLayout()
        self.setLayout(layout)

        self.cb_step_type = QComboBox()
        self.widgets = QStackedWidget()
        layout.addWidget(self.cb_step_type)
        layout.addWidget(self.widgets)

        if self._step is None:
            for step_class in Step.REGISTERED_STEPS.values():
                self.cb_step_type.addItem(step_class.NAME)
                w = step_class.GET_WIDGET()
                self.widgets.addWidget(w)
            self.cb_step_type.currentIndexChanged.connect(
                self._stepTypeChanged)
        else:
            self.cb_step_type.addItems(Step.REGISTERED_STEPS.keys())
            self.cb_step_type.setEnabled(False)
            index = self.cb_step_type.findText(QString(str(self._step.NAME)))
            self.cb_step_type.setCurrentIndex(index)
            w = self._step.getWidget()
            self.widgets.addWidget(w)

        self._showStepProperties()

        ###################
        # Action Buttons: #
        ###################
        buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self)
        buttons.accepted.connect(self.accept)
        buttons.rejected.connect(self.reject)
        layout.addWidget(buttons)
示例#19
0
def ensure_QDir(arg):
    if type(arg) == type(""):
        arg = QString(arg)
    if isinstance(arg, QString):
        arg = QDir(arg)
    assert isinstance(arg, QDir)  # fails if caller passes the wrong thing
    return arg
示例#20
0
 def export_key(self):
     if not self.listy.currentItem():
         errmsg = u"No keyfile selected to export. Highlight a keyfile first."
         r = error_dialog(None,
                          "{0} {1}".format(PLUGIN_NAME, PLUGIN_VERSION),
                          _(errmsg),
                          show=True,
                          show_copy_button=False)
         return
     filter = QString(u"{0} Files (*.{1})".format(self.key_type_name,
                                                  self.keyfile_ext))
     keyname = unicode(self.listy.currentItem().text().toUtf8(), 'utf8')
     if dynamic.get(PLUGIN_NAME + 'save_dir'):
         defaultname = os.path.join(
             dynamic.get(PLUGIN_NAME + 'save_dir'),
             u"{0}.{1}".format(keyname, self.keyfile_ext))
     else:
         defaultname = os.path.join(
             os.path.expanduser('~'),
             u"{0}.{1}".format(keyname, self.keyfile_ext))
     filename = unicode(
         QtGui.QFileDialog.getSaveFileName(
             self, u"Save {0} File as...".format(self.key_type_name),
             defaultname,
             u"{0} Files (*.{1})".format(self.key_type_name,
                                         self.keyfile_ext), filter))
     if filename:
         dynamic[PLUGIN_NAME + 'save_dir'] = os.path.split(filename)[0]
         with file(filename, 'w') as fname:
             if self.binary_file:
                 fname.write(self.plugin_keys[keyname].decode('hex'))
             elif self.json_file:
                 fname.write(json.dumps(self.plugin_keys[keyname]))
             else:
                 fname.write(self.plugin_keys[keyname])
    def saveFavorite(self):

        cmd = greenmsg("Save Favorite File: ")
        env.history.message(greenmsg("Save Favorite File:"))
        current_favorite = self.favoritesComboBox.currentText()
        favfilepath = getFavoritePathFromBasename(current_favorite)

        formats = \
                "Favorite (*.txt);;"\
                "All Files (*.*)"

        directory = self.currentWorkingDirectory
        saveLocation = directory + "/" + current_favorite + ".txt"

        fn = QFileDialog.getSaveFileName(
            self,
            "Save Favorite As",  # caption
            favfilepath,  #where to save
            formats,  # file format options
            QString("Favorite (*.txt)")  # selectedFilter
        )
        if not fn:
            env.history.message(cmd + "Cancelled")

        else:
            dir, fil = os.path.split(str(fn))
            self.setCurrentWorkingDirectory(dir)
            saveFavoriteFile(str(fn), favfilepath)
        return
 def get_sequence_qtable_from_array(self, array, qtable, rowcount):
     qtable.setRowCount(rowcount)
     for row in range(rowcount):
         for column in range(0,2):
             item = QtGui.QTableWidgetItem(QString("%1").arg(str(array[column][row])))
             qtable.setItem(row,column, item)
     qtable.resizeColumnsToContents()
示例#23
0
    def addLayer(self):
        self.addLayerButton.setEnabled(False)
        layerId = self.command.addLayer()

        self.currentLayerComboBox.addItem(QString(str(layerId)))
        self.currentLayerComboBox.setCurrentIndex(layerId - 1)

        self.w.glpane.gl_update()
示例#24
0
def getstring(text):

    if sys.version_info.major == 2:
        textout = QString.fromUtf8(text)
    elif sys.version_info.major == 3:
        textout = str(text)

    return textout
示例#25
0
    def select_folder(self):
        file_dialog = QtGui.QFileDialog()
        select_ws = file_dialog.getExistingDirectory(
            parent=None, caption=QString("Select Workspace Folder"))

        self._update_treeview_info(str(select_ws))
        if self.biiIdeWorkspace.path:
            self._update_gui_config_file(self.biiIdeWorkspace.path)
示例#26
0
    def get_sim_id(self):
        """
        Return the simulation id (name) from the dialog's Name widget.
        If it is empty, return "Untitled" as the sim_name.
        """
        name = QString(self.name_linedit.text())
        bname = name.stripWhiteSpace() # make sure suffix is not just whitespaces

        if bname:
            sim_name = str(bname)
            # Brian H. says that "name" cannot have any whitespace characters.
            # He suggests that we replace whitespace chars with underscores.
            # It is late and I don't have time to look up the Python function for this.
            # DON'T FORGET.  Mark 050915 at 11:45PM.  ZZZ.
        else:
            sim_name = "Untitled"

        return sim_name
示例#27
0
    def drawText(self, text, origin):
        """
        Draws ruler text.
        """       
        if not text:
            return

        self.glpane.renderText(origin[0], origin[1], origin[2], \
                          QString(text), self.rulerFont)
        return
示例#28
0
 def createWorkspace(self):
     file_dialog = QtGui.QFileDialog()
     select_path = file_dialog.getExistingDirectory(
         parent=None,
         caption=QString("Select the folder where create the workspace"))
     if not str(select_path) == "":
         if not os.path.exists(str(select_path)):
             os.mkdir(str(select_path))
         self._update_treeview_info(str(select_path))
         if self.biiIdeWorkspace.path:
             self._update_gui_config_file(self.biiIdeWorkspace.path)
示例#29
0
 def wrapToolButtonText(self, text):
     """
     Add a newline character at the end of each word in the toolbutton text
     """
     #ninad 070126 QToolButton lacks this method. This is not really a 
     #'word wrap' but OK for now. 
     
     #@@@ ninad 070126. Not calling this method as it is creating an annoying
     #resizing problem in the Command toolbar layout. Possible solution is 
     #to add a spacer item in a vbox layout to the command toolbar layout
     
     stringlist = text.split(" ", QString.SkipEmptyParts)
     text2 = QString()
     if len(stringlist) > 1:
         for l in stringlist:
             text2.append(l)
             text2.append("\n")
         return text2
             
     return None
示例#30
0
文件: tools.py 项目: kobolabs/calibre
 def __init__(self, parent, book_ids, output_format, queue, db, user_recs,
         args, use_saved_single_settings=True):
     QProgressDialog.__init__(self, '',
             QString(), 0, len(book_ids), parent)
     self.setWindowTitle(_('Queueing books for bulk conversion'))
     self.book_ids, self.output_format, self.queue, self.db, self.args, self.user_recs = \
             book_ids, output_format, queue, db, args, user_recs
     self.parent = parent
     self.use_saved_single_settings = use_saved_single_settings
     self.i, self.bad, self.jobs, self.changed = 0, [], [], False
     QTimer.singleShot(0, self.do_book)
     self.exec_()
示例#31
0
def drawtext(text, color, origin, point_size, glpane):
    """
    """
    # see also: _old_code_for_drawing_text()

    if not text:
        return

    glDisable(GL_LIGHTING)
    glDisable(GL_DEPTH_TEST)

    from PyQt4.Qt import QFont, QString  ##, QColor
    font = QFont(QString("Helvetica"), point_size)
    #glpane.qglColor(QColor(75, 75, 75))
    from widgets.widget_helpers import RGBf_to_QColor
    glpane.qglColor(RGBf_to_QColor(color))
    glpane.renderText(origin[0], origin[1], origin[2], QString(text), font)

    glEnable(GL_DEPTH_TEST)
    glEnable(GL_LIGHTING)
    return
示例#32
0
文件: jobs.py 项目: sss/calibre
 def paint(self, painter, option, index):
     opts = QStyleOptionProgressBarV2()
     opts.rect = option.rect
     opts.minimum = 1
     opts.maximum = 100
     opts.textVisible = True
     percent, ok = index.model().data(index, Qt.DisplayRole).toInt()
     if not ok:
         percent = 0
     opts.progress = percent
     opts.text = QString(
         _('Unavailable') if percent == 0 else '%d%%' % percent)
     QApplication.style().drawControl(QStyle.CE_ProgressBar, opts, painter)
示例#33
0
 def get_qtable_from_array(self, array, qtable):
     qtable.setRowCount(self.length())
     for row in range(self.length()):
         for column in range(0, 6):
             if column == 1:
                 # adds last time to current time so it accumilates in the chart
                 sampletime_ms = int(self.get_sample_time_ms(row))
                 sampletime = self.format_time(sampletime_ms)
                 item = QtGui.QTableWidgetItem(sampletime)
             else:
                 item = QtGui.QTableWidgetItem(
                     QString("%1").arg(str(array[column][row])))
             qtable.setItem(row, column, item)
     qtable.resizeColumnsToContents()
示例#34
0
def double_fixup(validator, text, prevtext):
    """
    Returns a string that represents a float which meets the requirements of validator.
    text is the input string to be checked, prevtext is returned if text is not valid.
    """
    r, c = validator.validate(QString(text), 0)

    if r == QValidator.Invalid:
        return prevtext
    elif r == QValidator.Intermediate:
        if len(text) == 0:
            return ""
        return prevtext
    else:
        return text
示例#35
0
 def shown(self):
     self.ui.cancelButton.hide()
     self.ui.realname.setFocus()
     if len(yali.users.PENDING_USERS) > 0 and self.ui.userList.count() == 0:
         for u in yali.users.PENDING_USERS:
             pix = self.normal_user_icon
             if "wheel" in u.groups:
                 pix = self.super_user_icon
             UserItem(self.ui.userList, pix, user = u)
             self.ui.autoLogin.addItem(QString(u.username))
     if len(yali.users.PENDING_USERS) == 1:
         self.slotEditUser(self.ui.userList.item(0))
     elif len(yali.users.PENDING_USERS) > 1:
         self.ui.addMoreUsers.setChecked(True)
     self.checkUsers()
     self.checkCapsLock()
示例#36
0
    def __init__(self, glpane):
        """
        @param glpane: typically a QGLWidget; used only for its methods
                       glpane.qglColor and glpane.renderText.
        
        @warning: the right OpenGL display list context must be current
                  when this constructor is called.
        """
        self.glpane = glpane
        self._compass_dl = glGenLists(1)
        #glNewList(self._compass_dl, GL_COMPILE)
        #_draw_compass_geometry()
        #glEndList()

        self._font = QFont(QString("Helvetica"), 12)

        return
示例#37
0
 def data(self, index, role=Qt.DisplayRole):
     '''Returns the data stored under the given role
     for the item referred to by the index.'''
     if not index.isValid():
         return QVariant()
     if role != Qt.DisplayRole and role != Qt.EditRole:
         return QVariant()
     nodePref = self.index2Pref(index)
     data = nodePref.qt_get_data(index.column())
     var = QVariant(data)
     #print('--- data() ---')
     #print('role = %r' % role)
     #print('data = %r' % data)
     #print('type(data) = %r' % type(data))
     if isinstance(data, float):
         var = QVariant(QString.number(data, format='g', precision=6))
     if isinstance(data, bool):
         var = QVariant(data).toString()
     if isinstance(data, int):
         var = QVariant(data).toString()
     #print('var= %r' % var)
     #print('type(var)= %r' % type(var))
     return var
示例#38
0
    def fillContent(self):
        subject = "<p><li><b>%s</b></li><ul>"
        item    = "<li>%s</li>"
        end     = "</ul></p>"
        content = QString("")

        content.append("""<html><body><ul>""")

        # Keyboard Layout
        if ctx.installData.keyData:
            content.append(subject % _("Keyboard Settings"))
            content.append(item %
                           _("Selected keyboard layout is <b>%s</b>") %
                           ctx.installData.keyData["name"])
            content.append(end)

        # TimeZone
        if ctx.installData.timezone:
            content.append(subject % _("Date/Time Settings"))
            content.append(item %
                           _("Selected TimeZone is <b>%s</b>") %
                           ctx.installData.timezone)
            content.append(end)

        # Users
        if len(yali.users.PENDING_USERS) > 0:
            content.append(subject % _("User Settings"))
            for user in yali.users.PENDING_USERS:
                state = _("User %(username)s (<b>%(realname)s</b>) added.")
                if "wheel" in user.groups:
                    state = _("User %(username)s (<b>%(realname)s</b>) added with <u>administrator privileges</u>.")
                content.append(item % state % {"username":user.realname, "realname":user.username})
            content.append(end)

        # HostName
        if ctx.installData.hostName:
            content.append(subject % _("Hostname Settings"))
            content.append(item %
                           _("Hostname is set as <b>%s</b>") %
                           ctx.installData.hostName)
            content.append(end)

        # Partition
        if ctx.storage.clearPartType is not None:
            content.append(subject % _("Partition Settings"))
            devices = ""
            for disk in ctx.storage.clearPartDisks:
                device = ctx.storage.devicetree.getDeviceByName(disk)
                devices += "(%s on %s)" % (device.model, device.name)

            if ctx.storage.doAutoPart:
                content.append(item % _("Automatic Partitioning selected."))
                if ctx.storage.clearPartType == CLEARPART_TYPE_ALL:
                    content.append(item % _("Use All Space"))
                    content.append(item % _("Removes all partitions on the selected "\
                                            "%s device(s). <b><u>This includes partitions "\
                                            "created by other operating systems.</u></b>") % devices)
                elif ctx.storage.clearPartType == CLEARPART_TYPE_LINUX:
                    content.append(item % _("Replace Existing Linux System(s)"))
                    content.append(item % _("Removes all Linux partitions on the selected" \
                                            "%s device(s). This does not remove "\
                                            "other partitions you may have on your " \
                                            "storage device(s) (such as VFAT or FAT32)") % devices)
                elif ctx.storage.clearPartType == CLEARPART_TYPE_NONE:
                    content.append(item % _("Use Free Space"))
                    content.append(item % _("Retains your current data and partitions" \
                                            " and uses only the unpartitioned space on " \
                                            "the selected %s device(s), assuming you have "\
                                            "enough free space available.") % devices)

            else:
                content.append(item % _("Manual Partitioning selected."))
                for operation in ctx.storage.devicetree.operations:
                    content.append(item % operation)

            content.append(end)

        # Bootloader
        if ctx.bootloader.stage1Device:
            content.append(subject % _("Bootloader Settings"))
            grubstr = _("GRUB will be installed to <b>%s</b>.")
            if ctx.bootloader.bootType == BOOT_TYPE_NONE:
                content.append(item % _("GRUB will not be installed."))
            else:
                content.append(item % grubstr % ctx.bootloader.stage1Device)

            content.append(end)

        if ctx.flags.collection and ctx.installData.autoCollection:
            content.append(subject % _("Package Installation Settings"))
            content.append(item % _("Collection <b>%s</b> selected") %
                           ctx.installData.autoCollection.title)

            content.append(end)

        content.append("""</ul></body></html>""")

        self.ui.content.setHtml(content)
    def initUI(self):
        cw = QWidget()
        self.setCentralWidget(cw)
        grid = QGridLayout()
        grid.setSpacing(15)

        # status bar
        self.statusBar().showMessage('Ready')

        font_label = QFont()
        font_label.setBold(True)
        font_info = QFont()
        font_info.setItalic(True)
        font_info.setPixelSize(10)

        #############

        lisa_title = QLabel('Organ Segmentation with Random Walker')
        info = QLabel('Developed by:\n' +
                      'University of West Bohemia\n' +
                      'Faculty of Applied Sciences\n' +
                      QString.fromUtf8('M. Jirik, V. Lukes, T. Ryba - 2013')
                      )
        info.setFont(font_info)
        lisa_title.setFont(font_label)
        lisa_logo = QLabel()
        logopath = os.path.join(path_to_script, 'kky_small.png')
        logo = QPixmap(logopath)
        lisa_logo.setPixmap(logo)
        grid.addWidget(lisa_title, 0, 1)
        grid.addWidget(info, 1, 1)
        grid.addWidget(lisa_logo, 0, 2, 2, 1)
        grid.setColumnMinimumWidth(1, logo.width())

        ### dicom reader
        rstart = 2
        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        text_dcm = QLabel('DICOM reader')
        text_dcm.setFont(font_label)
        btn_dcmdir = QPushButton("Load DICOM", self)
        btn_dcmdir.clicked.connect(self.loadDcmDir)
        btn_dcmcrop = QPushButton("Crop", self)
        btn_dcmcrop.clicked.connect(self.cropDcm)

        self.text_dcm_dir = QLabel('DICOM dir:')
        self.text_dcm_data = QLabel('DICOM data:')
        grid.addWidget(hr, rstart + 0, 0, 1, 4)
        grid.addWidget(text_dcm, rstart + 1, 1, 1, 2)
        grid.addWidget(btn_dcmdir, rstart + 2, 1)
        grid.addWidget(btn_dcmcrop, rstart + 2, 2)
        grid.addWidget(self.text_dcm_dir, rstart + 5, 1, 1, 2)
        grid.addWidget(self.text_dcm_data, rstart + 6, 1, 1, 2)
        rstart += 8

        # ################ segmentation
        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        text_seg = QLabel('Segmentation')
        text_seg.setFont(font_label)
        btn_segauto = QPushButton("Automatic seg.", self)
        btn_segauto.clicked.connect(self.autoSeg)
        btn_segman = QPushButton("Manual seg.", self)
        btn_segman.clicked.connect(self.manualSeg)
        self.text_seg_data = QLabel('segmented data:')
        grid.addWidget(hr, rstart + 0, 0, 1, 4)
        grid.addWidget(text_seg, rstart + 1, 1)
        grid.addWidget(btn_segauto, rstart + 2, 1)
        grid.addWidget(btn_segman, rstart + 2, 2)
        grid.addWidget(self.text_seg_data, rstart + 3, 1, 1, 2)
        rstart += 4

        # ################ save/view
        btn_segsave = QPushButton("Save", self)
        btn_segsave.clicked.connect(self.saveOut)
        btn_segsavedcm = QPushButton("Save Dicom", self)
        btn_segsavedcm.clicked.connect(self.saveOutDcm)
        btn_segview = QPushButton("View3D", self)
        if viewer3D_available:
            btn_segview.clicked.connect(self.view3D)

        else:
            btn_segview.setEnabled(False)

        grid.addWidget(btn_segsave, rstart + 0, 1)
        grid.addWidget(btn_segview, rstart + 0, 2)
        grid.addWidget(btn_segsavedcm, rstart + 1, 1)
        rstart += 2

        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        grid.addWidget(hr, rstart + 0, 0, 1, 4)

        # quit
        btn_quit = QPushButton("Quit", self)
        btn_quit.clicked.connect(self.quit)
        grid.addWidget(btn_quit, rstart + 1, 1, 1, 2)

        cw.setLayout(grid)
        self.setWindowTitle('Organ Segmentation with Random Walker')
        self.show()
示例#40
0
    def _initUI(self):
        cw = QWidget()
        self.setCentralWidget(cw)
        grid = QGridLayout()
        grid.setSpacing(10)
        self.uiw = {}

        # status bar
        self.statusBar().showMessage('Ready')

        # menubar
        self._initMenu()

        font_label = QFont()
        font_label.setBold(True)
        font_info = QFont()
        font_info.setItalic(True)
        font_info.setPixelSize(10)

        # # # # # # #
        # #  LISA logo
        # font_title = QFont()
        # font_title.setBold(True)
        # font_title.setSize(24)

        lisa_title = QLabel('LIver Surgery Analyser')
        info = QLabel('Developed by:\n' +
                      'University of West Bohemia\n' +
                      'Faculty of Applied Sciences\n' +
                      QString.fromUtf8('M. Jiřík, V. Lukeš - 2013') +
                      '\n\nVersion: ' + self.oseg.version
                      )
        info.setFont(font_info)
        lisa_title.setFont(font_label)
        lisa_logo = QLabel()
        logopath = find_logo()
        logo = QPixmap(logopath)
        lisa_logo.setPixmap(logo)  # scaledToWidth(128))
        grid.addWidget(lisa_title, 0, 1)
        grid.addWidget(info, 1, 1)

        btn_config = QPushButton("Configuration", self)
        btn_config.clicked.connect(self.btnConfig)
        self.uiw['config'] = btn_config
        grid.addWidget(btn_config, 2, 1)

        btn_update = QPushButton("Update", self)
        btn_update.clicked.connect(self.btnUpdate)
        self.uiw['btn_update'] = btn_update
        grid.addWidget(btn_update, 3, 1)
        grid.addWidget(lisa_logo, 0, 2, 5, 2)

        # combo = QtGui.QComboBox(self)
        # for text in self.oseg.segmentation_alternative_params.keys():
        #     combo.addItem(text)
        # combo.activated[str].connect(self.onAlternativeSegmentationParams)
        # grid.addWidget(combo, 4, 1)

        # right from logo
        rstart = 0

        btn_sync = QPushButton("Sync", self)
        btn_sync.clicked.connect(self.sync_lisa_data)
        self.uiw['sync'] = btn_sync
        grid.addWidget(btn_sync, rstart + 2, 4)

        grid.addWidget(
            self._add_button("Log", self.btnLog, 'Log',
                             "See log file", QStyle.SP_FileDialogContentsView),
            rstart + 3, 4)

        # # dicom reader
        rstart = 5
        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        text_dcm = QLabel('DICOM reader')
        text_dcm.setFont(font_label)

        # btn_dcmdir = QPushButton("Load DICOM", self)
        # btn_dcmdir.clicked.connect(self.loadDataDir)
        # btn_dcmdir.setIcon(btn_dcmdir.style().standardIcon(QStyle.SP_DirOpenIcon))
        # self.uiw['dcmdir'] = btn_dcmdir
        # btn_datafile = QPushButton("Load file", self)
        # btn_datafile.clicked.connect(self.loadDataFile)
        # btn_datafile.setToolTip("Load data from pkl file, 3D Dicom, tiff, ...")

        btn_dcmcrop = QPushButton("Crop", self)
        btn_dcmcrop.clicked.connect(self.cropDcm)

        # voxelsize gui comment
        # elf.scaling_mode = 'original'
        # ombo_vs = QComboBox(self)
        # ombo_vs.activated[str].connect(self.changeVoxelSize)
        # eys = scaling_modes.keys()
        # eys.sort()
        # ombo_vs.addItems(keys)
        # ombo_vs.setCurrentIndex(keys.index(self.scaling_mode))
        # elf.text_vs = QLabel('Voxel size:')
        # end-- voxelsize gui
        self.text_dcm_dir = QLabel('DICOM dir:')
        self.text_dcm_data = QLabel('DICOM data:')
        grid.addWidget(hr, rstart + 0, 2, 1, 4)
        grid.addWidget(text_dcm, rstart + 0, 1, 1, 3)
        grid.addWidget(
            self._add_button("Load dir", self.loadDataDir, 'dcmdir',
                             "Load data from directory (DICOM, png, jpg...)", QStyle.SP_DirOpenIcon),
            rstart + 1, 1)
        grid.addWidget(
            self._add_button("Load file", self.loadDataFile, 'load_file',
                             "Load data from pkl file, 3D Dicom, tiff, ...", QStyle.SP_FileIcon),
            rstart + 1, 2)
        # grid.addWidget(btn_datafile, rstart + 1, 2)
        grid.addWidget(btn_dcmcrop, rstart + 1, 3)
        # voxelsize gui comment
        # grid.addWidget(self.text_vs, rstart + 3, 1)
        # grid.addWidget(combo_vs, rstart + 4, 1)
        grid.addWidget(self.text_dcm_dir, rstart + 6, 1, 1, 4)
        grid.addWidget(self.text_dcm_data, rstart + 7, 1, 1, 4)
        rstart += 9

        # # # # # # # # #  segmentation
        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        text_seg = QLabel('Segmentation')
        text_seg.setFont(font_label)

        btn_segfile = QPushButton("Seg. from file", self)
        btn_segfile.clicked.connect(self.loadSegmentationFromFile)
        btn_segfile.setToolTip("Load segmentation from pkl file, raw, ...")

        btn_segcompare = QPushButton("Compare", self)
        btn_segcompare.clicked.connect(self.compareSegmentationWithFile)
        btn_segcompare.setToolTip(
            "Compare data with segmentation from pkl file, raw, ...")

        btn_mask = QPushButton("Mask region", self)
        btn_mask.clicked.connect(self.maskRegion)
        btn_segliver = QPushButton("Liver seg.", self)
        btn_segliver.clicked.connect(self.liverSeg)
        self.btn_segauto = QPushButton("Auto seg.", self)
        self.btn_segauto.clicked.connect(self.autoSeg)
        btn_segman = QPushButton("Viewer", self)
        btn_segman.clicked.connect(self.manualSeg)
        self.text_seg_data = QLabel('segmented data:')
        grid.addWidget(hr, rstart + 0, 2, 1, 4)
        grid.addWidget(text_seg, rstart + 0, 1)
        grid.addWidget(btn_segfile, rstart + 1, 1)
        grid.addWidget(btn_segcompare, rstart + 1, 3)
        grid.addWidget(btn_mask, rstart + 2, 1)
        grid.addWidget(btn_segliver, rstart + 2, 2)
        grid.addWidget(self.btn_segauto, rstart + 1, 2)
        grid.addWidget(btn_segman, rstart + 2, 3)
        grid.addWidget(self.text_seg_data, rstart + 3, 1, 1, 3)
        rstart += 4

        # # # # # # # # #  save/view
        # hr = QFrame()
        # hr.setFrameShape(QFrame.HLine)
        grid.addWidget(
            self._add_button(
                "Save",
                self.saveOut,
                'save',
                "Save data with segmentation. Use filename 'slice{:04d}.tiff' to store slices",
                QStyle.SP_DialogSaveButton),
            rstart + 0, 1)
        # btn_segsave = QPushButton("Save", self)
        # btn_segsave.clicked.connect(self.saveOut)
        btn_segsavedcmoverlay = QPushButton("Save Dicom Overlay", self)
        btn_segsavedcmoverlay.clicked.connect(self.btnSaveOutDcmOverlay)
        btn_segsavedcm = QPushButton("Save Dicom", self)
        btn_segsavedcm.clicked.connect(self.btnSaveOutDcm)
        btn_segview = QPushButton("View3D", self)
        if viewer3D_available:
            btn_segview.clicked.connect(self.view3D)

        else:
            btn_segview.setEnabled(False)

        grid.addWidget(btn_segsavedcm, rstart + 0, 2)
        grid.addWidget(btn_segsavedcmoverlay, rstart + 0, 3)
        grid.addWidget(btn_segview, rstart + 0, 4)
        rstart += 1

        # # # # Virtual resection

        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        rstart += 1

        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        text_resection = QLabel('Virtual resection')
        text_resection.setFont(font_label)

        btn_pvseg = QPushButton("Portal vein seg.", self)
        btn_pvseg.clicked.connect(self.btnPortalVeinSegmentation)
        btn_svpv = QPushButton("Save PV tree", self)
        btn_svpv.clicked.connect(self.btnSavePortalVeinTree)
        btn_svpv.setToolTip("Save Portal Vein 1D model into vessel_tree.yaml")
        # btn_svpv.setEnabled(False)
        btn_svpv.setEnabled(True)

        btn_hvseg = QPushButton("Hepatic veins seg.", self)
        btn_hvseg.clicked.connect(self.btnHepaticVeinsSegmentation)
        btn_svhv = QPushButton("Save HV tree", self)
        btn_svhv.clicked.connect(self.btnSaveHepaticVeinsTree)
        btn_svhv.setToolTip(
            "Save Hepatic Veins 1D model into vessel_tree.yaml")
        btn_svhv.setEnabled(True)
        # btn_svhv.setEnabled(False)

        btn_lesions = QPushButton("Lesions localization", self)
        btn_lesions.clicked.connect(self.btnLesionLocalization)
        # btn_lesions.setEnabled(False)

        grid.addWidget(
            self._add_button("Resection (PV)", self.btnVirtualResectionPV, 'btn_resection_pv',
                             "Portal Vein based virtual resection"),
            rstart + 2, 3)
        grid.addWidget(
            self._add_button("Resection (planar)", self.btnVirtualResectionPlanar, 'btn_resection_planar',
                             "Plane based virtual resection"),
            rstart + 1, 3)
        # btn_resection_pv = QPushButton("Resection (PV)", self)
        # btn_resection_pv.clicked.connect(self.btnVirtualResectionPV)
        # btn_resection_planar = QPushButton("Resection (planar)", self)
        # btn_resection_planar.clicked.connect(self.btnVirtualResectionPV)

        grid.addWidget(hr, rstart + 0, 2, 1, 4)
        grid.addWidget(text_resection, rstart + 0, 1)
        grid.addWidget(btn_pvseg, rstart + 1, 1)
        grid.addWidget(btn_hvseg, rstart + 1, 2)
        # grid.addWidget(btn_resection_planar, rstart + 1, 3)
        # grid.addWidget(btn_resection_pv, rstart + 2, 3)
        grid.addWidget(btn_lesions, rstart + 1, 4)
        grid.addWidget(btn_svpv, rstart + 2, 1)
        grid.addWidget(btn_svhv, rstart + 2, 2)

        # # # # # # #

        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        # rid.addWidget(hr, rstart + 0, 0, 1, 4)

        rstart += 3
        # quit
        btn_quit = QPushButton("Quit", self)
        btn_quit.clicked.connect(self.quit)
        grid.addWidget(btn_quit, rstart + -1, 4, 1, 1)
        self.uiw['quit'] = btn_quit

        if self.oseg.debug_mode:
            btn_debug = QPushButton("Debug", self)
            btn_debug.clicked.connect(self.run_debug)
            grid.addWidget(btn_debug, rstart - 2, 4)

        cw.setLayout(grid)
        self.cw = cw
        self.grid = grid

        self.setWindowTitle('LISA')

        self.show()
示例#41
0
    def initUI(self):
        import os.path as op
        path_to_script = op.dirname(os.path.abspath(__file__))

        cw = QWidget()
        self.setCentralWidget(cw)
        vbox = QVBoxLayout()
        vbox.setSpacing(10)

        # status bar
        self.statusBar().showMessage('Ready')

        # info panel
        font_label = QFont()
        font_label.setBold(True)
        font_info = QFont()
        font_info.setItalic(True)
        font_info.setPixelSize(10)

        dicom2fem_title = QLabel('DICOM2FEM')
        info = QLabel('Version: 0.9\n\n' +
                      'Developed by:\n' +
                      'University of West Bohemia\n' +
                      'Faculty of Applied Sciences\n' +
                      QString.fromUtf8('V. Lukeš - 2014') +
                      '\n\nBased on PYSEG_BASE project'
                      )
        info.setFont(font_info)
        dicom2fem_title.setFont(font_label)
        dicom2fem_logo = QLabel()
        logopath = os.path.join(path_to_script, "../src/brain.png")
        logo = QPixmap(logopath)
        dicom2fem_logo.setPixmap(logo)
        vbox1 = QVBoxLayout()
        vbox1.addWidget(dicom2fem_title)
        vbox1.addWidget(info)
        vbox1.addStretch(1)

        vbox2 = QVBoxLayout()
        vbox2.addWidget(dicom2fem_logo)

        hbox = QHBoxLayout()
        hbox.addStretch(1)
        hbox.addLayout(vbox1)
        hbox.addStretch(1)
        hbox.addLayout(vbox2)
        hbox.addStretch(1)
        vbox.addLayout(hbox)

        tabs = QTabWidget()
        tab1 = QWidget()
        tab2 = QWidget()
        tab3 = QWidget()

        tab1.setLayout(self.init_ReaderTab())
        tab2.setLayout(self.init_SegmentationTab())
        tab3.setLayout(self.init_MeshGenTab())
        tabs.addTab(tab1,"DICOM Reader")
        tabs.addTab(tab2,"Segmentation")
        tabs.addTab(tab3,"Mesh generator")

        vbox.addWidget(tabs)

        # clear, quit
        hbox = QHBoxLayout()
        hbox.addStretch(1)
        btn_clear = QPushButton("Clear", self)
        btn_clear.clicked.connect(self.clearall)
        hbox.addWidget(btn_clear)
        btn_quit = QPushButton("Quit", self)
        btn_quit.clicked.connect(self.quit)
        hbox.addWidget(btn_quit)
        hbox.addStretch(1)

        vbox.addLayout(hbox)

        cw.setLayout(vbox)
        self.setWindowTitle('DICOM2FEM')
        self.show()
示例#42
0
    def initUI(self):
        cw = QWidget()
        self.setCentralWidget(cw)
        grid = QGridLayout()
        grid.setSpacing(10)
        self.uiw = {}

        # status bar
        self.statusBar().showMessage("Ready")

        font_label = QFont()
        font_label.setBold(True)
        font_info = QFont()
        font_info.setItalic(True)
        font_info.setPixelSize(10)

        # # # # # # #
        # #  LISA logo
        # font_title = QFont()
        # font_title.setBold(True)
        # font_title.setSize(24)

        lisa_title = QLabel("LIver Surgery Analyser")
        info = QLabel(
            "Developed by:\n"
            + "University of West Bohemia\n"
            + "Faculty of Applied Sciences\n"
            + QString.fromUtf8("M. Jiřík, V. Lukeš - 2013")
            + "\n\nVersion: "
            + self.oseg.version
        )
        info.setFont(font_info)
        lisa_title.setFont(font_label)
        lisa_logo = QLabel()
        logopath = os.path.join(path_to_script, "../applications/LISA256.png")
        logo = QPixmap(logopath)
        lisa_logo.setPixmap(logo)  # scaledToWidth(128))
        grid.addWidget(lisa_title, 0, 1)
        grid.addWidget(info, 1, 1)

        btn_config = QPushButton("Configuration", self)
        btn_config.clicked.connect(self.btnConfig)
        self.uiw["dcmdir"] = btn_config
        grid.addWidget(btn_config, 2, 1)

        grid.addWidget(lisa_logo, 0, 2, 3, 2)

        # rid.setColumnMinimumWidth(1, logo.width()/2)
        # rid.setColumnMinimumWidth(2, logo.width()/2)
        # rid.setColumnMinimumWidth(3, logo.width()/2)

        # # dicom reader
        rstart = 3
        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        text_dcm = QLabel("DICOM reader")
        text_dcm.setFont(font_label)
        btn_dcmdir = QPushButton("Load DICOM", self)
        btn_dcmdir.clicked.connect(self.loadDataDir)
        self.uiw["dcmdir"] = btn_dcmdir

        btn_datafile = QPushButton("Load file", self)
        btn_datafile.clicked.connect(self.loadDataFile)
        btn_datafile.setToolTip("Load data from pkl file, 3D Dicom, tiff, ...")

        btn_dcmcrop = QPushButton("Crop", self)
        btn_dcmcrop.clicked.connect(self.cropDcm)

        # voxelsize gui comment
        # elf.scaling_mode = 'original'
        # ombo_vs = QComboBox(self)
        # ombo_vs.activated[str].connect(self.changeVoxelSize)
        # eys = scaling_modes.keys()
        # eys.sort()
        # ombo_vs.addItems(keys)
        # ombo_vs.setCurrentIndex(keys.index(self.scaling_mode))
        # elf.text_vs = QLabel('Voxel size:')
        # end-- voxelsize gui
        self.text_dcm_dir = QLabel("DICOM dir:")
        self.text_dcm_data = QLabel("DICOM data:")
        grid.addWidget(hr, rstart + 0, 2, 1, 4)
        grid.addWidget(text_dcm, rstart + 0, 1, 1, 3)
        grid.addWidget(btn_dcmdir, rstart + 1, 1)
        grid.addWidget(btn_datafile, rstart + 1, 2)
        grid.addWidget(btn_dcmcrop, rstart + 1, 3)
        # voxelsize gui comment
        # grid.addWidget(self.text_vs, rstart + 3, 1)
        # grid.addWidget(combo_vs, rstart + 4, 1)
        grid.addWidget(self.text_dcm_dir, rstart + 6, 1, 1, 3)
        grid.addWidget(self.text_dcm_data, rstart + 7, 1, 1, 3)
        rstart += 9

        # # # # # # # # #  segmentation
        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        text_seg = QLabel("Segmentation")
        text_seg.setFont(font_label)

        btn_segfile = QPushButton("Seg. from file", self)
        btn_segfile.clicked.connect(self.loadSegmentationFromFile)
        btn_segfile.setToolTip("Load segmentation from pkl file, raw, ...")

        btn_segcompare = QPushButton("Compare", self)
        btn_segcompare.clicked.connect(self.compareSegmentationWithFile)
        btn_segcompare.setToolTip("Compare data with segmentation from pkl file, raw, ...")

        btn_mask = QPushButton("Mask region", self)
        btn_mask.clicked.connect(self.maskRegion)
        btn_segliver = QPushButton("Liver seg.", self)
        btn_segliver.clicked.connect(self.liverSeg)
        self.btn_segauto = QPushButton("Auto seg.", self)
        self.btn_segauto.clicked.connect(self.autoSeg)
        btn_segman = QPushButton("Manual seg.", self)
        btn_segman.clicked.connect(self.manualSeg)
        self.text_seg_data = QLabel("segmented data:")
        grid.addWidget(hr, rstart + 0, 2, 1, 4)
        grid.addWidget(text_seg, rstart + 0, 1)
        grid.addWidget(btn_segfile, rstart + 1, 1)
        grid.addWidget(btn_segcompare, rstart + 1, 3)
        grid.addWidget(btn_mask, rstart + 2, 1)
        grid.addWidget(btn_segliver, rstart + 2, 2)
        grid.addWidget(self.btn_segauto, rstart + 1, 2)
        grid.addWidget(btn_segman, rstart + 2, 3)
        grid.addWidget(self.text_seg_data, rstart + 3, 1, 1, 3)
        rstart += 4

        # # # # # # # # #  save/view
        # hr = QFrame()
        # hr.setFrameShape(QFrame.HLine)
        btn_segsave = QPushButton("Save", self)
        btn_segsave.clicked.connect(self.saveOut)
        btn_segsavedcmoverlay = QPushButton("Save Dicom Overlay", self)
        btn_segsavedcmoverlay.clicked.connect(self.btnSaveOutDcmOverlay)
        btn_segsavedcm = QPushButton("Save Dicom", self)
        btn_segsavedcm.clicked.connect(self.btnSaveOutDcm)
        btn_segview = QPushButton("View3D", self)
        if viewer3D_available:
            btn_segview.clicked.connect(self.view3D)

        else:
            btn_segview.setEnabled(False)

        grid.addWidget(btn_segsave, rstart + 0, 1)
        grid.addWidget(btn_segview, rstart + 0, 3)
        grid.addWidget(btn_segsavedcm, rstart + 0, 2)
        grid.addWidget(btn_segsavedcmoverlay, rstart + 1, 2)
        rstart += 2

        # # # # Virtual resection

        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        rstart += 1

        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        text_resection = QLabel("Virtual resection")
        text_resection.setFont(font_label)

        btn_pvseg = QPushButton("Portal vein seg.", self)
        btn_pvseg.clicked.connect(self.btnPortalVeinSegmentation)
        btn_svpv = QPushButton("Save PV tree", self)
        btn_svpv.clicked.connect(self.btnSavePortalVeinTree)
        btn_svpv.setToolTip("Save Portal Vein 1D model into vessel_tree.yaml")
        btn_svpv.setEnabled(False)

        btn_hvseg = QPushButton("Hepatic veins seg.", self)
        btn_hvseg.clicked.connect(self.btnHepaticVeinsSegmentation)
        btn_svhv = QPushButton("Save HV tree", self)
        btn_svhv.clicked.connect(self.btnSaveHepaticVeinsTree)
        btn_svhv.setToolTip("Save Hepatic Veins 1D model into vessel_tree.yaml")
        btn_svhv.setEnabled(False)

        btn_lesions = QPushButton("Lesions localization", self)
        btn_lesions.clicked.connect(self.btnLesionLocalization)
        # @TODO make button active by removing next line
        btn_lesions.setEnabled(False)

        btn_resection = QPushButton("Virtual resection", self)
        btn_resection.clicked.connect(self.btnVirtualResection)

        grid.addWidget(hr, rstart + 0, 2, 1, 4)
        grid.addWidget(text_resection, rstart + 0, 1)
        grid.addWidget(btn_pvseg, rstart + 1, 1)
        grid.addWidget(btn_hvseg, rstart + 1, 2)
        grid.addWidget(btn_lesions, rstart + 1, 3)
        grid.addWidget(btn_resection, rstart + 2, 3)
        grid.addWidget(btn_svpv, rstart + 2, 1)
        grid.addWidget(btn_svhv, rstart + 2, 2)

        # # # # # # #

        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        # rid.addWidget(hr, rstart + 0, 0, 1, 4)

        rstart += 3
        # quit
        btn_quit = QPushButton("Quit", self)
        btn_quit.clicked.connect(self.quit)
        grid.addWidget(btn_quit, rstart + 1, 1, 1, 2)
        self.uiw["quit"] = btn_quit

        if self.oseg.debug_mode:
            btn_debug = QPushButton("Debug", self)
            btn_debug.clicked.connect(self.run_debug)
            grid.addWidget(btn_debug, rstart + 1, 3)

        cw.setLayout(grid)
        self.cw = cw
        self.grid = grid

        self.setWindowTitle("LISA")
        self.show()
示例#43
0
 def updateSequence(self, strand = None, cursorPos = -1):
     """
     Updates and shows the sequence editor with the sequence of I{strand}. 
     
     This is the main (public) method to call to update the sequence editor.
     
     @param strand: the strand. If strand is None (default), update the
                    sequence of the current strand (i.e. self.current_strand).
     @type  strand: DnaStrand
     
     @param cursorPos: the position in the sequence in which to place the
                       cursor. If cursorPos is negative, the cursor position
                       is placed at the end of the sequence (default).
     @type  cursorPos: int
     """
     if strand == " ":
         self.current_strand = None
         self.clear()
         return
         
     if strand:
         assert isinstance(strand, self.win.assy.DnaStrand)
         self.current_strand = strand
     else: 
         # Use self.current_strand. Make sure it's not None (as a precaution).
         assert isinstance(self.current_strand, self.win.assy.DnaStrand)
     
     sequence, complementSequence = \
             self.current_strand.getStrandSequenceAndItsComplement()
     
     if sequence:
         sequence = QString(sequence) 
         sequence = sequence.toUpper()
         #Set the initial sequence (read in from the file)
         self._setSequence(sequence)
         
         #Set the initial complement sequence for DnaSequence editor. 
         #do this independently because 'complementSequenceString' may have
         #some characters (such as * ) that denote a missing base on the 
         #complementary strand. This information is used by the sequence
         #editor. See DnaSequenceEditor._determine_complementSequence() 
         #for more details. See also bug 2787
         self._setComplementSequence(complementSequence)
     else:
         msg = "DnaStrand '%s' has no sequence." % self.current_strand.name
         print_compact_traceback(msg)
         self._setSequence(msg)
         self._setComplementSequence("")
     
     # Set cursor position.
     self.setCursorPosition(cursorPos)
     
     # Update the bg color to white.
     self._sequence_changed = False
     self._previousSequence = sequence
     self._updateSequenceBgColor()
     
     # Update window title with name of current protein.
     titleString = 'Sequence Editor for ' + self.current_strand.name
     self.setWindowTitle(titleString)
     
     if not self.isVisible():
         #Show the sequence editor if it isn't visible.
         #ATTENTION: the sequence editor will (temporarily) close the
         #Reports dockwidget (if it is visible). The Reports dockwidget
         #is restored when the sequence Editor is closed.  
         self.show()
     return
示例#44
0
文件: lisaWindow.py 项目: vlukes/lisa
    def initUI(self):
        cw = QWidget()
        self.setCentralWidget(cw)
        grid = QGridLayout()
        grid.setSpacing(10)

        # status bar
        self.statusBar().showMessage('Ready')

        font_label = QFont()
        font_label.setBold(True)
        font_info = QFont()
        font_info.setItalic(True)
        font_info.setPixelSize(10)

        # # # # # # #
        # #  LISA logo
        # font_title = QFont()
        # font_title.setBold(True)
        # font_title.setSize(24)

        lisa_title = QLabel('LIver Surgery Analyser')
        info = QLabel('Developed by:\n' +
                      'University of West Bohemia\n' +
                      'Faculty of Applied Sciences\n' +
                      QString.fromUtf8('M. Jiřík, V. Lukeš - 2013') +
                      '\n\nVersion: ' + self.oseg.version
                      )
        info.setFont(font_info)
        lisa_title.setFont(font_label)
        lisa_logo = QLabel()
        logopath = os.path.join(path_to_script, "../applications/LISA256.png")
        logo = QPixmap(logopath)
        lisa_logo.setPixmap(logo)  # scaledToWidth(128))
        grid.addWidget(lisa_title, 0, 1)
        grid.addWidget(info, 1, 1)
        grid.addWidget(lisa_logo, 0, 2, 2, 2)
        # rid.setColumnMinimumWidth(1, logo.width()/2)
        # rid.setColumnMinimumWidth(2, logo.width()/2)
        # rid.setColumnMinimumWidth(3, logo.width()/2)

        # # dicom reader
        rstart = 2
        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        text_dcm = QLabel('DICOM reader')
        text_dcm.setFont(font_label)
        btn_dcmdir = QPushButton("Load DICOM", self)
        btn_dcmdir.clicked.connect(self.loadDataDir)

        btn_datafile = QPushButton("Load file", self)
        btn_datafile.clicked.connect(self.loadDataFile)

        btn_dcmcrop = QPushButton("Crop", self)
        btn_dcmcrop.clicked.connect(self.cropDcm)

        # voxelsize gui comment
        # elf.scaling_mode = 'original'
        # ombo_vs = QComboBox(self)
        # ombo_vs.activated[str].connect(self.changeVoxelSize)
        # eys = scaling_modes.keys()
        # eys.sort()
        # ombo_vs.addItems(keys)
        # ombo_vs.setCurrentIndex(keys.index(self.scaling_mode))
        # elf.text_vs = QLabel('Voxel size:')
        # end-- voxelsize gui
        self.text_dcm_dir = QLabel('DICOM dir:')
        self.text_dcm_data = QLabel('DICOM data:')
        grid.addWidget(hr, rstart + 0, 2, 1, 4)
        grid.addWidget(text_dcm, rstart + 0, 1, 1, 3)
        grid.addWidget(btn_dcmdir, rstart + 1, 1)
        grid.addWidget(btn_datafile, rstart + 1, 2)
        grid.addWidget(btn_dcmcrop, rstart + 1, 3)
        # voxelsize gui comment
        # grid.addWidget(self.text_vs, rstart + 3, 1)
        # grid.addWidget(combo_vs, rstart + 4, 1)
        grid.addWidget(self.text_dcm_dir, rstart + 6, 1, 1, 3)
        grid.addWidget(self.text_dcm_data, rstart + 7, 1, 1, 3)
        rstart += 9

        # # # # # # # # #  segmentation
        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        text_seg = QLabel('Segmentation')
        text_seg.setFont(font_label)
        btn_mask = QPushButton("Mask region", self)
        btn_mask.clicked.connect(self.maskRegion)
        btn_segauto = QPushButton("Automatic seg.", self)
        btn_segauto.clicked.connect(self.autoSeg)
        btn_segman = QPushButton("Manual seg.", self)
        btn_segman.clicked.connect(self.manualSeg)
        self.text_seg_data = QLabel('segmented data:')
        grid.addWidget(hr, rstart + 0, 2, 1, 4)
        grid.addWidget(text_seg, rstart + 0, 1)
        grid.addWidget(btn_mask, rstart + 1, 1)
        grid.addWidget(btn_segauto, rstart + 1, 2)
        grid.addWidget(btn_segman, rstart + 1, 3)
        grid.addWidget(self.text_seg_data, rstart + 2, 1, 1, 3)
        rstart += 3

        # # # # # # # # #  save/view
        # hr = QFrame()
        # hr.setFrameShape(QFrame.HLine)
        btn_segsave = QPushButton("Save", self)
        btn_segsave.clicked.connect(self.saveOut)
        btn_segsavedcm = QPushButton("Save Dicom", self)
        btn_segsavedcm.clicked.connect(self.saveOutDcm)
        btn_segview = QPushButton("View3D", self)
        if viewer3D_available:
            btn_segview.clicked.connect(self.view3D)

        else:
            btn_segview.setEnabled(False)

        grid.addWidget(btn_segsave, rstart + 0, 1)
        grid.addWidget(btn_segview, rstart + 0, 3)
        grid.addWidget(btn_segsavedcm, rstart + 0, 2)
        rstart += 2

        # # # # Virtual resection

        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        rstart += 1

        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        text_resection = QLabel('Virtual resection')
        text_resection.setFont(font_label)

        btn_vesselseg = QPushButton("Vessel segmentation", self)
        btn_vesselseg.clicked.connect(self.btnVesselSegmentation)

        btn_lesions = QPushButton("Lesions localization", self)
        btn_lesions.clicked.connect(self.btnLesionLocalization)

        btn_resection = QPushButton("Virtual resection", self)
        btn_resection.clicked.connect(self.btnVirtualResection)

        grid.addWidget(hr, rstart + 0, 2, 1, 4)
        grid.addWidget(text_resection, rstart + 0, 1)
        grid.addWidget(btn_vesselseg, rstart + 1, 1)
        grid.addWidget(btn_lesions, rstart + 1, 2)
        grid.addWidget(btn_resection, rstart + 1, 3)

        # # # # # # #

        hr = QFrame()
        hr.setFrameShape(QFrame.HLine)
        # rid.addWidget(hr, rstart + 0, 0, 1, 4)

        rstart += 3
        # quit
        btn_quit = QPushButton("Quit", self)
        btn_quit.clicked.connect(self.quit)
        grid.addWidget(btn_quit, rstart + 1, 1, 1, 2)

        cw.setLayout(grid)
        self.setWindowTitle('LISA')
        self.show()