Пример #1
0
 def _name_set(self, layer_id):
     """Name is changed"""
     if self.update_region_data:
         return
     data = cfg.diagram.regions
     region_id = self.regions[layer_id].currentData()
     region = data.regions[region_id]
     error = None
     for reg in data.regions.values():
         if reg != region:
             if self.name[layer_id].text() == reg.name:
                 error = "Region name already exist"
                 break
         else:
             if self.name[layer_id].text() == reg.name:
                 return
     if len(self.name[layer_id].text())==0 or self.name[layer_id].text().isspace():
         error = "Region name is empty"
     if error is not None:
         err_dialog = GMErrorDialog(self)
         err_dialog.open_error_dialog(error)
         self.name[layer_id].selectAll()
     else:
         data.set_region_name([key for key, item in data.regions.items() if item == region][0],
             self.name[layer_id].text(), True, "Set region name")
         combo_text = self.name[layer_id].text()+" ("+str(data.regions[region_id].dim.value)+"D)"
         self.regions[layer_id].setItemText(
             self.regions[layer_id].currentIndex(), combo_text)
Пример #2
0
 def _report_error(cls, mess, err=None):
     """Report an error with dialog."""
     from gm_base.geomop_dialogs import GMErrorDialog
     if cls.main_window is not None:
         err_dialog = GMErrorDialog(cls.main_window)
         err_dialog.open_error_dialog(mess, err)
     else:
         raise Exception(mess)
Пример #3
0
 def on_unhandled_exception(type_, exception, tback):
     """Unhandled exception callback."""
     # pylint: disable=unused-argument
     from gm_base.geomop_dialogs import GMErrorDialog
     err_dialog = GMErrorDialog(layer_editor.mainwindow)
     err_dialog.open_error_dialog("Unhandled Exception!",
                                  error=exception)
     sys.exit(1)
Пример #4
0
 def on_unhandled_exception(type_, exception, tback):
     """Unhandled exception callback."""
     # pylint: disable=unused-argument
     from gm_base.geomop_dialogs import GMErrorDialog
     # display message box with the exception
     if job_panel is not None and job_panel.mainwindow is not None:
         err_dialog = GMErrorDialog(job_panel.mainwindow)
         err_dialog.open_error_dialog(
             "Application performed invalid operation!",
             error=exception)
     sys.exit(1)
Пример #5
0
 def _load_file(self, surface_data):
     file, pattern = QtWidgets.QFileDialog.getOpenFileName(
         self, "Choose grid file", self.home_dir, "File (*.*)")
     if not file:
         return
     try:
         return surface_data.init_from_file(file)
     except Exception as e:
         err_dialog = GMErrorDialog(self)
         err_dialog.open_error_dialog("Wrong grid file structure!", error=e)
         return None
Пример #6
0
 def accept(self):
     """
     Accepts the form if file data fields are valid
     and inicialize dialog
     :return: None
     """
     ret = True
     
     if self.coordinates.isChecked():
         try:
             x1 = float(self.x.text())
             x2 = x1 + float(self.dx.text())
             y1= float(self.y.text())
             y2 = y1 + float(self.dy.text())
         except:
             err_dialog = GMErrorDialog(self)
             err_dialog.open_error_dialog("Bad coordinates format")
             ret = False
         cfg.diagram.area.set_area([x1, x1, x2, x2], [y1, y2, y2, y1])  
     else:
         if cfg.open_shape_file(self.shp_file_name.text()):
             if cfg.main_window is not None:
                 cfg.main_window.refresh_diagram_shp()
             rect = cfg.diagram.shp.boundrect
             cfg.diagram.area.set_area([rect.left(), rect.left(), rect.right(), rect.right()], [-rect.top(), -rect.bottom(), -rect.bottom(), -rect.top()])
         else:
             err_dialog = GMErrorDialog(self)
             err_dialog.open_error_dialog("Bad shape file format")
             ret = False 
     if ret:
         super(SetDiagramDlg, self).accept()
Пример #7
0
    def rm_surface(self):
        assert self.data._idx != -1
        idx = self.wg_surf_combo.currentData()
        assert self.data._idx == idx
        assert idx >= 0
        assert idx < len(self.layers.surfaces)
        if not self.layers.delete_surface(idx):
            err_dialog = GMErrorDialog(self)
            err_dialog.open_error_dialog("Surface in use. Can not remove it.")
            return None

        # propose new idx
        new_idx = min(idx, len(self.layers.surfaces) - 1)
        self.data.init_from_surface(self.wg_surf_combo.get_surface(new_idx), new_idx)
        self._fill_forms()
Пример #8
0
 def validate_depth(edit, validator, dialog):
     """
     Try validate elevation parameter. If problem occured,
     display error and return False
     """
     pos = 0
     text = edit.text()
     state = validator.validate(text, pos)[0]
     if state == QtGui.QValidator.Acceptable:
         return True
     elif state == QtGui.QValidator.Intermediate:
         error = "Elevation value out of range (%f, %f)." % (
             validator.bottom(), validator.top())
     else:
         error = "Bad elevation value format"
     err_dialog = GMErrorDialog(dialog)
     err_dialog.open_error_dialog(error)
Пример #9
0
 def accept(self):
     """
     Accepts the form if region data is valid.
     :return: None
     """
     error = None
     for region in cfg.diagram.regions.regions.values():
         if self.region_name.text() == region.name:
             error = "Region name already exist"
             break
     if len(self.region_name.text()) == 0 or self.region_name.text(
     ).isspace():
         error = "Region name is empty"
     if error is not None:
         err_dialog = GMErrorDialog(self)
         err_dialog.open_error_dialog(error)
     else:
         super(AddRegionDlg, self).accept()
Пример #10
0
    def open_recent_file(cls, file_name):
        """
        read file from recent files

        return: if file have good format (boolean)
        """
        try:
            cls.open_file(file_name)
            cls.config.update_current_workdir(file_name)
            cls.config.add_recent_file(file_name)
            return True
        except (RuntimeError, IOError) as err:
            if cls.main_window is not None:
                err_dialog = GMErrorDialog(cls.main_window)
                err_dialog.open_error_dialog("Can't open file", err)
            else:
                raise err
        return False
Пример #11
0
    def accept(self):
        """Handles a confirmation."""
        if self.workspace_selector.value is None:
            from gm_base.geomop_dialogs import GMErrorDialog
            err_dialog = GMErrorDialog(self)
            err_dialog.open_error_dialog(
                "", Exception("Workspace is not selected."))
            return
        self.data.reload_workspace(self.workspace_selector.value)
        if not Analysis.exists(self.data.workspaces.get_path(),
                               self.data.config.analysis):
            self.data.config.analysis = None
        #self.data.config.local_env = self.envPresetComboBox.currentData()
        self.data.config.save()

        # todo: vyresit lepe
        self.parent().close()

        super(OptionsDialog, self).accept()
Пример #12
0
 def open_shape_file(cls, file):
     """Open and add shape file"""
     if cls.diagram is not None:
         if not cls.diagram.shp.is_file_open(file):
             try:
                 disp = cls.diagram.add_file(file)
                 if len(disp.errors) > 0:
                     err_dialog = GMErrorDialog(cls.main_window)
                     err_dialog.open_error_report_dialog(
                         disp.errors,
                         msg="Shape file parsing errors:",
                         title=file)
                 return True
             except Exception as err:
                 err_dialog = GMErrorDialog(cls.main_window)
                 err_dialog.open_error_dialog("Can't open shapefile", err)
     return False
Пример #13
0
        def on_unhandled_exception(type_, exception, tback):
            """Unhandled exception callback."""
            # pylint: disable=unused-argument
            from gm_base.geomop_dialogs import GMErrorDialog
            if model_editor is not None:
                err_dialog = None
                # display message box with the exception
                if model_editor.mainwindow is not None:
                    err_dialog = GMErrorDialog(model_editor.mainwindow)

                # try to reload editor to avoid inconsistent state
                if callable(model_editor.mainwindow.reload):
                    try:
                        model_editor.mainwindow.reload()
                    except:
                        if err_dialog is not None:
                            err_dialog.open_error_dialog("Application performed invalid operation!",
                                                         error=exception)
                            sys.exit(1)

                if err_dialog is not None:
                    err_dialog.open_error_dialog("Unhandled Exception!", error=exception)
Пример #14
0
 def report_error(self, msg, err=None):
     """Report an error with dialog."""
     from gm_base.geomop_dialogs import GMErrorDialog
     err_dialog = GMErrorDialog(self)
     err_dialog.open_error_dialog(msg, err)
Пример #15
0
 def _report_notify(cls, errs):
     """Report an error with dialog."""
     from gm_base.geomop_dialogs import GMErrorDialog
     err_dialog = GMErrorDialog(cls.main_window)
     err_dialog.open_error_report_dialog(errs)