Esempio n. 1
0
        ax.yaxis.label.set_fontsize(toset[1])
        for t in ax.xaxis.get_major_ticks():
            t.label.set_fontsize(toset[2])
        for t in ax.yaxis.get_major_ticks():
            t.label.set_fontsize(toset[2])
        if (ax.legend_):
            for t in ax.legend_.texts:
                t.set_fontsize(toset[1])
        self.canvas.plotter.draw()

    def addBZ(self):
        """ Experimental: add brilluin zone. Only Body centered tetragonal now supported. """

        # check by vectors
        self.readVectors()
        myplane = np.cross(self.v1, self.v2)
        # TODO: generate gamma point dynamically
        gpts = np.array([[0, 0], [0, 2], [1, 1], [2, 0], [2, 2]])

        # TODO: read lattice parameters from file
        bzc = bp.BZCreator(gpts, a = 4.33148, c = 10.83387, plane = myplane)
        bzc.doPlot(self.canvas.plotter.axes)
        self.canvas.plotter.draw()


# Run the gui if not imported
if __name__ == "__main__":
    app = QApplication(sys.argv)
    win = ReciprocalViewer()
    sys.exit(app.exec_())
Esempio n. 2
0
def main():
    app = QApplication([])
    app.setOrganizationName('ufit')
    app.setApplicationName('gui')

    pixmap = QPixmap(':/splash.png')
    splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint)
    splash.showMessage(u'Loading...' + u'\xa0' * 10 + '\n\n',
                       Qt.AlignRight | Qt.AlignBottom)
    splash.show()
    time.sleep(0.1)
    with SettingGroup('main') as settings:
        if settings.value('current_version', '') != __version__:
            settings.setValue('current_version', __version__)
            # Execute here the actions to be performed only once after
            # each update (there is nothing there for now, but it could
            # be useful some day...)
            logger.info('Upgrade to version %s finished' % __version__)
    app.processEvents()

    def log_unhandled(*exc_info):
        logger.error('Unhandled exception in Qt callback', exc_info=exc_info)

    sys.excepthook = log_unhandled

    t1 = time.time()
    logger.info('Startup: import finished (%.3f s), starting GUI...' %
                (t1 - t0))

    mainwindow = UFitMain()

    parser = optparse.OptionParser(usage='''\
    Usage: %prog [-b directory] [.ufit file | data file]
    ''')
    parser.add_option('-b',
                      '--browse',
                      action='store',
                      metavar='DIR',
                      help='open browse window in specified directory')

    opts, args = parser.parse_args()

    if len(args) >= 1:
        datafile = path.abspath(args[0])
        if path.isdir(datafile):
            # directory given, treat it as -b argument (browse)
            opts.browse = datafile
        elif datafile.endswith('.ufit'):
            try:
                mainwindow.filename = datafile
                mainwindow.load_session(datafile)
            except Exception as err:
                QMessageBox.warning(mainwindow, 'Error',
                                    'Loading failed: %s' % err)
                mainwindow.filename = None
        else:
            dtempl, numor = extract_template(datafile)
            mainwindow.dloader.set_template(dtempl, numor, silent=False)
    mainwindow.show()
    if opts.browse:
        mainwindow.dloader.open_browser(opts.browse)

    t2 = time.time()
    logger.info('Startup: loading finished (%.3f s), main window opened' %
                (t2 - t1))
    splash.deleteLater()
    app.exec_()
Esempio n. 3
0
def start(model, data, fit=True, **fit_kws):
    app = QApplication([])
    win = FitterMain(model, data, fit, fit_kws)
    win.show()
    app.exec_()
    return win.fitter.last_result
Esempio n. 4
0
def start():
    app = QApplication([])
    win = DataLoaderMain()
    win.show()
    app.exec_()
    return win.dloader.last_data