示例#1
0
 def do_jump(self, evt):
     x, ok = QInputDialog.getDouble(self._main_window, _("Coordinate"), _("Enter the longitude"), decimals=config().presentation.coordinate_decimal_places, minValue=-180, maxValue=180, value=self._person.position.lon)
     if not ok:
         return
     y, ok = QInputDialog.getDouble(self._main_window, _("Coordinate"), _("Enter the latitude"), decimals=config().presentation.coordinate_decimal_places, minValue=-90, maxValue=90, value=self._person.position.lat)
     if not ok:
         return
     self._person.move_to(LatLon(y, x), force=True)
示例#2
0
    def on_action_save_imageseries_triggered(self):
        if not HexrdConfig().has_images():
            msg = ('No ImageSeries available for saving.')
            QMessageBox.warning(self.ui, 'HEXRD', msg)
            return

        if ImageLoadManager().unaggregated_images:
            ims_dict = ImageLoadManager().unaggregated_images
        else:
            ims_dict = HexrdConfig().imageseries_dict

        if len(ims_dict) > 1:
            # Have the user choose an imageseries to save
            names = list(ims_dict.keys())
            name, ok = QInputDialog.getItem(self.ui, 'HEXRD',
                                            'Select ImageSeries', names, 0,
                                            False)
            if not ok:
                # User canceled...
                return
        else:
            name = list(ims_dict.keys())[0]

        selected_file, selected_filter = QFileDialog.getSaveFileName(
            self.ui, 'Save ImageSeries',
            HexrdConfig().working_dir,
            'HDF5 files (*.h5 *.hdf5);; NPZ files (*.npz)')

        if selected_file:
            HexrdConfig().working_dir = os.path.dirname(selected_file)
            if selected_filter.startswith('HDF5'):
                selected_format = 'hdf5'
            elif selected_filter.startswith('NPZ'):
                selected_format = 'frame-cache'

            kwargs = {}
            if selected_format == 'hdf5':
                # A path must be specified. Set it ourselves for now.
                kwargs['path'] = 'imageseries'
            elif selected_format == 'frame-cache':
                # Get the user to pick a threshold
                result, ok = QInputDialog.getDouble(self.ui, 'HEXRD',
                                                    'Choose Threshold', 10, 0,
                                                    1e12, 3)
                if not ok:
                    # User canceled...
                    return

                kwargs['threshold'] = result

                # This needs to be specified, but I think it just needs
                # to be the same as the file name...
                kwargs['cache_file'] = selected_file

            HexrdConfig().save_imageseries(ims_dict.get(name), name,
                                           selected_file, selected_format,
                                           **kwargs)
示例#3
0
def getDouble(parentWindow=None,
              title="Double Input",
              label="Double:",
              value=0,
              minValue=-2147483647,
              maxValue=2147483647,
              decimals=1):
    return QInputDialog.getDouble(parentWindow, title, label, value, minValue,
                                  maxValue, decimals)
示例#4
0
 def setThreshold(self):
     t, ok = QInputDialog.getDouble(self,
                                    'New threshold',
                                    '',
                                    self.thresh,
                                    minValue=0.,
                                    maxValue=1.)
     if not ok: return
     self.thresh = t
     if hasattr(self, 'raw') and self.raw:
         self.ui.tblDiag.thresh = t
         self.counter.allInOne(t)
         self.showStatistic()
示例#5
0
    def save_images(self):
        if self.ui.ignore_agg.isChecked():
            ims_dict = HexrdConfig().unagg_images
        else:
            ims_dict = HexrdConfig().imageseries_dict
        dets = HexrdConfig().detector_names
        if self.ui.single_detector.isChecked():
            dets = [self.ui.detectors.currentText()]
        for det in dets:
            selected_format = self.ui.format.currentText().lower()
            filename = f'{self.ui.file_stem.text()}_{det}.{selected_format}'
            path = f'{self.parent_dir}/{filename}'
            if selected_format.startswith('hdf5'):
                selected_format = 'hdf5'
            elif selected_format.startswith('npz'):
                selected_format = 'frame-cache'

            kwargs = {}
            if selected_format == 'hdf5':
                # A path must be specified. Set it ourselves for now.
                kwargs['path'] = 'imageseries'
            elif selected_format == 'frame-cache':
                # Get the user to pick a threshold
                result, ok = QInputDialog.getDouble(self.ui, 'HEXRD',
                                                    'Choose Threshold', 10, 0,
                                                    1e12, 3)
                if not ok:
                    # User canceled...
                    return

                kwargs['threshold'] = result

                # This needs to be specified, but I think it just needs
                # to be the same as the file name...
                kwargs['cache_file'] = path

            worker = AsyncWorker(HexrdConfig().save_imageseries,
                                 ims_dict.get(det), det, path, selected_format,
                                 **kwargs)
            self.thread_pool.start(worker)
            self.progress_dialog.setWindowTitle(f'Saving {filename}')
            self.progress_dialog.setRange(0, 0)
            worker.signals.finished.connect(self.progress_dialog.accept)
            self.progress_dialog.exec_()
示例#6
0
 def calib_size(self):
     """ 
     map pixels to mm 
     
     - place object with known size at default distance from camera
     - call this fcn
     - enter size of object
     - fcn calculates scale factor and saves it to droplet object
     """
     # do oneshot eval and extract height from droplet, then calc scale and set in droplet
     res, ok = QInputDialog.getDouble(
         self, "Size of calib element",
         "Please enter the height of the test subject in mm:", 0, 0, 100)
     if not ok or res == 0.0:
         return
     self._oneshot_eval = True
     droplt = Droplet()  # singleton
     self.cam.snapshot()
     droplt.set_scale(res / droplt._height)
     logging.info(f"set image to real scae to {res / droplt._height}")
示例#7
0
 def rotate_by(self, evt):
     amount, ok = QInputDialog.getDouble(self._main_window, _("Data"), _("Enter the angle"), minValue=-360, maxValue=360)
     if not ok:
         return
     self._person.rotate(float(amount))
示例#8
0
    def subdivide_network():
        val, ok = QInputDialog.getDouble(
            QApplication.activeWindow(),
            "Parallel cutoff",
            "Input cutoff value for unproven parallel linkages",
            0.25,
            0.0,
            1.0,
            decimals=3,
            step=0.01)
        if ok:
            NetworkTabController.ui.log_plainTextEdit.appendPlainText(
                f"Testing network for linear structure...")

            linear_net, excluded = Data.network.makeLinearContigClusters(
                bExcludeNodesCausingNonLinearClusters=True,
                cutoff=float(
                    NetworkTabController.ui.cutoff_textfield.toPlainText()),
                cutoffParallel=float(val))

            if len(excluded) != 0:
                NetworkTabController.ui.log_plainTextEdit.appendPlainText(
                    f"{len(Data.network.nodes) - len(linear_net.nodes)} nodes were removed:"
                )

                excluded = [
                    str(str(id) + "\t" + Data.network.nodes[id].caption)
                    for id in excluded
                ]
                for ex in excluded:
                    NetworkTabController.ui.log_plainTextEdit.appendPlainText(
                        ex)

                pajek_path = os.getcwd() + '\Pajek64\Pajek.exe'
                try:
                    path, _ = QFileDialog().getSaveFileName(
                        QApplication.activeWindow(), filter='*.net')
                    Network.print_pajek_network(plot_net=linear_net,
                                                sFileName=path)
                    QMessageBox.information(
                        NetworkTabController.ui, "Info", "Save Success\nMap "
                        "was successfully saved to path")
                except ():
                    QMessageBox.information(
                        NetworkTabController.ui, "Warning",
                        "Save Failed\nAn error has occurred!")
                NetworkTabController.ui.log_plainTextEdit.appendPlainText(
                    f"Linear structure network was built successfully!"
                    f"\n\t#Nodes: {len(linear_net.nodes)}"
                    f"\n\t#Edges: {len(linear_net.edges)}\n")

                QMessageBox.information(
                    NetworkTabController.ui, "Notice",
                    "Network was subdivided into linear components successfully!"
                )
                subprocess.Popen([pajek_path, path])
            else:
                QMessageBox.information(
                    NetworkTabController.ui, "Notice",
                    "Network is already linearly structured!")
                NetworkTabController.ui.log_plainTextEdit.appendPlainText(
                    "\tNetwork is already linearly structured!\n")
示例#9
0
 def addPKa(self):
     pKa, ok = QInputDialog.getDouble(self, "Add pKa value", "pK<sub>a</sub> value:", decimals=2)
     if ok:
         self.pKaModel.addValue(pKa)