Beispiel #1
0
    def __init__(self, parent, title,
                 vectorName, query=None, cats=None,
                 style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs):
        """Dialog used to display/modify categories of vector objects

        :param parent:
        :param title: dialog title
        :param query: {coordinates, qdist} - used by v.edit/v.what
        :param cats: directory of lines (layer/categories) - used by vdigit
        :param style: dialog style
        """
        self.parent = parent  # map window class instance
        self.digit = parent.digit

        # map name
        self.vectorName = vectorName

        # line : {layer: [categories]}
        self.cats = {}

        # do not display dialog if no line is found (-> self.cats)
        if cats is None:
            if self._getCategories(query[0], query[1]) == 0 or not self.line:
                Debug.msg(3, "VDigitCategoryDialog(): nothing found!")
        else:
            self.cats = cats
            for line in cats.keys():
                for layer in cats[line].keys():
                    self.cats[line][layer] = list(cats[line][layer])

            layers = []
            for layer in self.digit.GetLayers():
                layers.append(str(layer))

        # make copy of cats (used for 'reload')
        self.cats_orig = copy.deepcopy(self.cats)

        wx.Dialog.__init__(self, parent=self.parent, id=wx.ID_ANY, title=title,
                           style=style, **kwargs)

        # list of categories
        box = wx.StaticBox(
            parent=self, id=wx.ID_ANY, label=" %s " %
            _("List of categories - right-click to delete"))
        listSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        self.list = CategoryListCtrl(parent=self, id=wx.ID_ANY,
                                     style=wx.LC_REPORT |
                                     wx.BORDER_NONE |
                                     wx.LC_SORT_ASCENDING |
                                     wx.LC_HRULES |
                                     wx.LC_VRULES)
        # sorter
        self.fid = self.cats.keys()[0]
        self.itemDataMap = self.list.Populate(self.cats[self.fid])
        listmix.ColumnSorterMixin.__init__(self, 2)
        self.fidMulti = wx.Choice(parent=self, id=wx.ID_ANY,
                                  size=(150, -1))
        self.fidMulti.Bind(wx.EVT_CHOICE, self.OnFeature)
        self.fidText = wx.StaticText(parent=self, id=wx.ID_ANY)
        if len(self.cats.keys()) == 1:
            self.fidMulti.Show(False)
            self.fidText.SetLabel(str(self.fid))
        else:
            self.fidText.Show(False)
            choices = []
            for fid in self.cats.keys():
                choices.append(str(fid))
            self.fidMulti.SetItems(choices)
            self.fidMulti.SetSelection(0)

        listSizer.Add(item=self.list, proportion=1, flag=wx.EXPAND)

        # add new category
        box = wx.StaticBox(parent=self, id=wx.ID_ANY,
                           label=" %s " % _("Add new category"))
        addSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        flexSizer = wx.FlexGridSizer(cols=5, hgap=5, vgap=5)
        flexSizer.AddGrowableCol(3)

        layerNewTxt = wx.StaticText(parent=self, id=wx.ID_ANY,
                                    label="%s:" % _("Layer"))
        self.layerNew = wx.Choice(parent=self, id=wx.ID_ANY, size=(75, -1),
                                  choices=layers)
        if len(layers) > 0:
            self.layerNew.SetSelection(0)

        catNewTxt = wx.StaticText(parent=self, id=wx.ID_ANY,
                                  label="%s:" % _("Category"))

        try:
            newCat = max(self.cats[self.fid][1]) + 1
        except KeyError:
            newCat = 1
        self.catNew = SpinCtrl(parent=self, id=wx.ID_ANY, size=(75, -1),
                                  initial=newCat, min=0, max=1e9)
        btnAddCat = wx.Button(self, wx.ID_ADD)
        flexSizer.Add(item=layerNewTxt, proportion=0,
                      flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(item=self.layerNew, proportion=0,
                      flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(item=catNewTxt, proportion=0,
                      flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT,
                      border=10)
        flexSizer.Add(item=self.catNew, proportion=0,
                      flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(item=btnAddCat, proportion=0,
                      flag=wx.EXPAND | wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
        addSizer.Add(
            item=flexSizer,
            proportion=1,
            flag=wx.ALL | wx.EXPAND,
            border=5)

        # buttons
        btnApply = wx.Button(self, wx.ID_APPLY)
        btnApply.SetToolTipString(_("Apply changes"))
        btnCancel = wx.Button(self, wx.ID_CANCEL)
        btnCancel.SetToolTipString(_("Ignore changes and close dialog"))
        btnOk = wx.Button(self, wx.ID_OK)
        btnOk.SetToolTipString(_("Apply changes and close dialog"))
        btnOk.SetDefault()

        # sizers
        btnSizer = wx.StdDialogButtonSizer()
        btnSizer.AddButton(btnCancel)
        # btnSizer.AddButton(btnReload)
        # btnSizer.SetNegativeButton(btnReload)
        btnSizer.AddButton(btnApply)
        btnSizer.AddButton(btnOk)
        btnSizer.Realize()

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(item=listSizer, proportion=1,
                      flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5)
        mainSizer.Add(item=addSizer, proportion=0,
                      flag=wx.EXPAND | wx.ALIGN_CENTER |
                      wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5)
        fidSizer = wx.BoxSizer(wx.HORIZONTAL)
        fidSizer.Add(item=wx.StaticText(parent=self, id=wx.ID_ANY,
                                        label=_("Feature id:")),
                     proportion=0, border=5,
                     flag=wx.ALIGN_CENTER_VERTICAL)
        fidSizer.Add(item=self.fidMulti, proportion=0,
                     flag=wx.EXPAND | wx.ALL, border=5)
        fidSizer.Add(item=self.fidText, proportion=0,
                     flag=wx.EXPAND | wx.ALL, border=5)
        mainSizer.Add(item=fidSizer, proportion=0,
                      flag=wx.EXPAND | wx.ALL, border=5)
        mainSizer.Add(item=btnSizer, proportion=0,
                      flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5)

        self.SetSizer(mainSizer)
        mainSizer.Fit(self)
        self.SetAutoLayout(True)

        # set min size for dialog
        self.SetMinSize(self.GetBestSize())

        # bindings
        btnApply.Bind(wx.EVT_BUTTON, self.OnApply)
        btnOk.Bind(wx.EVT_BUTTON, self.OnOK)
        btnAddCat.Bind(wx.EVT_BUTTON, self.OnAddCat)
        btnCancel.Bind(wx.EVT_BUTTON, self.OnCancel)
        self.Bind(wx.EVT_CLOSE, lambda evt: self.Hide())

        # list
        self.list.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.OnRightUp)  # wxMSW
        self.list.Bind(wx.EVT_RIGHT_UP, self.OnRightUp)  # wxGTK
        self.Bind(wx.EVT_LIST_BEGIN_LABEL_EDIT, self.OnBeginEdit, self.list)
        self.Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnEndEdit, self.list)
        self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick, self.list)
Beispiel #2
0
    def _createViewPage(self, notebook):
        """Create notebook page for view settings"""
        panel = wx.Panel(parent=notebook, id=wx.ID_ANY)

        notebook.AddPage(page=panel, text=" %s " % _("View"))

        pageSizer = wx.BoxSizer(wx.VERTICAL)

        box = StaticBox(parent=panel, id=wx.ID_ANY, label=" %s " % (_("View")))
        boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        gridSizer = wx.GridBagSizer(vgap=3, hgap=3)
        row = 0
        # perspective
        pvals = UserSettings.Get(group="nviz", key="view", subkey="persp")
        ipvals = UserSettings.Get(
            group="nviz", key="view", subkey="persp", settings_type="internal"
        )
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("Perspective:")),
            pos=(row, 0),
            flag=wx.ALIGN_CENTER_VERTICAL,
        )
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("value:")),
            pos=(row, 1),
            flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT,
        )

        pval = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            size=(65, -1),
            initial=pvals["value"],
            min=ipvals["min"],
            max=ipvals["max"],
        )
        self.winId["nviz:view:persp:value"] = pval.GetId()
        gridSizer.Add(pval, pos=(row, 2), flag=wx.ALIGN_CENTER_VERTICAL)

        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("step:")),
            pos=(row, 3),
            flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT,
        )

        pstep = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            size=(65, -1),
            initial=pvals["step"],
            min=ipvals["min"],
            max=ipvals["max"] - 1,
        )
        self.winId["nviz:view:persp:step"] = pstep.GetId()
        gridSizer.Add(pstep, pos=(row, 4), flag=wx.ALIGN_CENTER_VERTICAL)
        row += 1

        # position
        posvals = UserSettings.Get(group="nviz", key="view", subkey="position")
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("Position:")),
            pos=(row, 0),
            flag=wx.ALIGN_CENTER_VERTICAL,
        )
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("x:")),
            pos=(row, 1),
            flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT,
        )

        px = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            size=(65, -1),
            initial=posvals["x"] * 100,
            min=0,
            max=100,
        )
        self.winId["nviz:view:position:x"] = px.GetId()
        gridSizer.Add(px, pos=(row, 2), flag=wx.ALIGN_CENTER_VERTICAL)

        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label="y:"),
            pos=(row, 3),
            flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT,
        )

        py = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            size=(65, -1),
            initial=posvals["y"] * 100,
            min=0,
            max=100,
        )
        self.winId["nviz:view:position:y"] = py.GetId()
        gridSizer.Add(py, pos=(row, 4), flag=wx.ALIGN_CENTER_VERTICAL)
        row += 1

        # height is computed dynamically

        # twist
        tvals = UserSettings.Get(group="nviz", key="view", subkey="twist")
        itvals = UserSettings.Get(
            group="nviz", key="view", subkey="twist", settings_type="internal"
        )
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("Twist:")),
            pos=(row, 0),
            flag=wx.ALIGN_CENTER_VERTICAL,
        )
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("value:")),
            pos=(row, 1),
            flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT,
        )

        tval = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            size=(65, -1),
            initial=tvals["value"],
            min=itvals["min"],
            max=itvals["max"],
        )
        self.winId["nviz:view:twist:value"] = tval.GetId()
        gridSizer.Add(tval, pos=(row, 2), flag=wx.ALIGN_CENTER_VERTICAL)
        row += 1

        # z-exag
        zvals = UserSettings.Get(group="nviz", key="view", subkey="z-exag")
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("Z-exag:")),
            pos=(row, 0),
            flag=wx.ALIGN_CENTER_VERTICAL,
        )
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("value:")),
            pos=(row, 1),
            flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT,
        )

        zval = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            size=(65, -1),
            initial=zvals["value"],
            min=-1e6,
            max=1e6,
        )
        self.winId["nviz:view:z-exag:value"] = zval.GetId()
        gridSizer.Add(zval, pos=(row, 2), flag=wx.ALIGN_CENTER_VERTICAL)

        boxSizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=3)
        pageSizer.Add(
            boxSizer,
            proportion=0,
            flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
            border=3,
        )

        box = StaticBox(
            parent=panel, id=wx.ID_ANY, label=" %s " % (_("Image Appearance"))
        )
        boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        gridSizer = wx.GridBagSizer(vgap=3, hgap=3)

        # background color
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("Background color:")),
            pos=(0, 0),
            flag=wx.ALIGN_CENTER_VERTICAL,
        )

        color = csel.ColourSelect(
            panel,
            id=wx.ID_ANY,
            colour=UserSettings.Get(
                group="nviz", key="view", subkey=["background", "color"]
            ),
            size=globalvar.DIALOG_COLOR_SIZE,
        )
        color.SetName("GetColour")
        self.winId["nviz:view:background:color"] = color.GetId()
        gridSizer.Add(color, pos=(0, 1))

        gridSizer.AddGrowableCol(0)
        boxSizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
        pageSizer.Add(boxSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)

        panel.SetSizer(pageSizer)

        return panel
Beispiel #3
0
class VDigitCategoryDialog(wx.Dialog, listmix.ColumnSorterMixin):
    def __init__(self,
                 parent,
                 title,
                 vectorName,
                 query=None,
                 cats=None,
                 style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
                 **kwargs):
        """Dialog used to display/modify categories of vector objects

        :param parent:
        :param title: dialog title
        :param query: {coordinates, qdist} - used by v.edit/v.what
        :param cats: directory of lines (layer/categories) - used by vdigit
        :param style: dialog style
        """
        self.parent = parent  # map window class instance
        self.digit = parent.digit

        # map name
        self.vectorName = vectorName

        # line : {layer: [categories]}
        self.cats = {}

        # do not display dialog if no line is found (-> self.cats)
        if cats is None:
            if self._getCategories(query[0], query[1]) == 0 or not self.line:
                Debug.msg(3, "VDigitCategoryDialog(): nothing found!")
        else:
            self.cats = cats
            for line in cats.keys():
                for layer in cats[line].keys():
                    self.cats[line][layer] = list(cats[line][layer])

            layers = []
            for layer in self.digit.GetLayers():
                layers.append(str(layer))

        # make copy of cats (used for 'reload')
        self.cats_orig = copy.deepcopy(self.cats)

        wx.Dialog.__init__(self,
                           parent=self.parent,
                           id=wx.ID_ANY,
                           title=title,
                           style=style,
                           **kwargs)

        # list of categories
        box = wx.StaticBox(parent=self,
                           id=wx.ID_ANY,
                           label=" %s " %
                           _("List of categories - right-click to delete"))
        listSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        self.list = CategoryListCtrl(parent=self,
                                     id=wx.ID_ANY,
                                     style=wx.LC_REPORT | wx.BORDER_NONE
                                     | wx.LC_SORT_ASCENDING | wx.LC_HRULES
                                     | wx.LC_VRULES)
        # sorter
        self.fid = self.cats.keys()[0]
        self.itemDataMap = self.list.Populate(self.cats[self.fid])
        listmix.ColumnSorterMixin.__init__(self, 2)
        self.fidMulti = wx.Choice(parent=self, id=wx.ID_ANY, size=(150, -1))
        self.fidMulti.Bind(wx.EVT_CHOICE, self.OnFeature)
        self.fidText = wx.StaticText(parent=self, id=wx.ID_ANY)
        if len(self.cats.keys()) == 1:
            self.fidMulti.Show(False)
            self.fidText.SetLabel(str(self.fid))
        else:
            self.fidText.Show(False)
            choices = []
            for fid in self.cats.keys():
                choices.append(str(fid))
            self.fidMulti.SetItems(choices)
            self.fidMulti.SetSelection(0)

        listSizer.Add(self.list, proportion=1, flag=wx.EXPAND)

        # add new category
        box = wx.StaticBox(parent=self,
                           id=wx.ID_ANY,
                           label=" %s " % _("Add new category"))
        addSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        flexSizer = wx.FlexGridSizer(cols=5, hgap=5, vgap=5)
        flexSizer.AddGrowableCol(3)

        layerNewTxt = wx.StaticText(parent=self,
                                    id=wx.ID_ANY,
                                    label="%s:" % _("Layer"))
        self.layerNew = wx.Choice(parent=self,
                                  id=wx.ID_ANY,
                                  size=(75, -1),
                                  choices=layers)
        if len(layers) > 0:
            self.layerNew.SetSelection(0)

        catNewTxt = wx.StaticText(parent=self,
                                  id=wx.ID_ANY,
                                  label="%s:" % _("Category"))

        try:
            newCat = max(self.cats[self.fid][1]) + 1
        except KeyError:
            newCat = 1
        self.catNew = SpinCtrl(parent=self,
                               id=wx.ID_ANY,
                               size=(75, -1),
                               initial=newCat,
                               min=0,
                               max=1e9)
        btnAddCat = wx.Button(self, wx.ID_ADD)
        flexSizer.Add(layerNewTxt,
                      proportion=0,
                      flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(self.layerNew,
                      proportion=0,
                      flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(catNewTxt,
                      proportion=0,
                      flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT,
                      border=10)
        flexSizer.Add(self.catNew,
                      proportion=0,
                      flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(btnAddCat,
                      proportion=0,
                      flag=wx.EXPAND | wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
        addSizer.Add(flexSizer,
                     proportion=1,
                     flag=wx.ALL | wx.EXPAND,
                     border=5)

        # buttons
        btnApply = wx.Button(self, wx.ID_APPLY)
        btnApply.SetToolTipString(_("Apply changes"))
        btnCancel = wx.Button(self, wx.ID_CANCEL)
        btnCancel.SetToolTipString(_("Ignore changes and close dialog"))
        btnOk = wx.Button(self, wx.ID_OK)
        btnOk.SetToolTipString(_("Apply changes and close dialog"))
        btnOk.SetDefault()

        # sizers
        btnSizer = wx.StdDialogButtonSizer()
        btnSizer.AddButton(btnCancel)
        # btnSizer.AddButton(btnReload)
        # btnSizer.SetNegativeButton(btnReload)
        btnSizer.AddButton(btnApply)
        btnSizer.AddButton(btnOk)
        btnSizer.Realize()

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(listSizer,
                      proportion=1,
                      flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER,
                      border=5)
        mainSizer.Add(addSizer,
                      proportion=0,
                      flag=wx.EXPAND | wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT
                      | wx.BOTTOM,
                      border=5)
        fidSizer = wx.BoxSizer(wx.HORIZONTAL)
        fidSizer.Add(wx.StaticText(parent=self,
                                   id=wx.ID_ANY,
                                   label=_("Feature id:")),
                     proportion=0,
                     border=5,
                     flag=wx.ALIGN_CENTER_VERTICAL)
        fidSizer.Add(self.fidMulti,
                     proportion=0,
                     flag=wx.EXPAND | wx.ALL,
                     border=5)
        fidSizer.Add(self.fidText,
                     proportion=0,
                     flag=wx.EXPAND | wx.ALL,
                     border=5)
        mainSizer.Add(fidSizer,
                      proportion=0,
                      flag=wx.EXPAND | wx.ALL,
                      border=5)
        mainSizer.Add(btnSizer,
                      proportion=0,
                      flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER,
                      border=5)

        self.SetSizer(mainSizer)
        mainSizer.Fit(self)
        self.SetAutoLayout(True)

        # set min size for dialog
        self.SetMinSize(self.GetBestSize())

        # bindings
        btnApply.Bind(wx.EVT_BUTTON, self.OnApply)
        btnOk.Bind(wx.EVT_BUTTON, self.OnOK)
        btnAddCat.Bind(wx.EVT_BUTTON, self.OnAddCat)
        btnCancel.Bind(wx.EVT_BUTTON, self.OnCancel)
        self.Bind(wx.EVT_CLOSE, lambda evt: self.Hide())

        # list
        self.list.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.OnRightUp)  # wxMSW
        self.list.Bind(wx.EVT_RIGHT_UP, self.OnRightUp)  # wxGTK
        self.Bind(wx.EVT_LIST_BEGIN_LABEL_EDIT, self.OnBeginEdit, self.list)
        self.Bind(wx.EVT_LIST_END_LABEL_EDIT, self.OnEndEdit, self.list)
        self.Bind(wx.EVT_LIST_COL_CLICK, self.OnColClick, self.list)

    def GetListCtrl(self):
        """Used by ColumnSorterMixin
        """
        return self.list

    def OnColClick(self, event):
        """Click on column header (order by)
        """
        event.Skip()

    def OnBeginEdit(self, event):
        """Editing of item started
        """
        event.Allow()

    def OnEndEdit(self, event):
        """Finish editing of item
        """
        itemIndex = event.GetIndex()
        layerOld = int(self.list.GetItem(itemIndex, 0).GetText())
        catOld = int(self.list.GetItem(itemIndex, 1).GetText())

        if event.GetColumn() == 0:
            layerNew = int(event.GetLabel())
            catNew = catOld
        else:
            layerNew = layerOld
            catNew = int(event.GetLabel())

        try:
            if layerNew not in self.cats[self.fid].keys():
                self.cats[self.fid][layerNew] = []
            self.cats[self.fid][layerNew].append(catNew)
            self.cats[self.fid][layerOld].remove(catOld)
        except:
            event.Veto()
            self.list.SetStringItem(itemIndex, 0, str(layerNew))
            self.list.SetStringItem(itemIndex, 1, str(catNew))
            dlg = wx.MessageDialog(
                self,
                _("Unable to add new layer/category <%(layer)s/%(category)s>.\n"
                  "Layer and category number must be integer.\n"
                  "Layer number must be greater than zero.") % {
                      'layer': self.layerNew.GetStringSelection(),
                      'category': str(self.catNew.GetValue())
                  }, _("Error"), wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            return False

    def OnRightDown(self, event):
        """Mouse right button down
        """
        x = event.GetX()
        y = event.GetY()
        item, flags = self.list.HitTest((x, y))

        if item !=  wx.NOT_FOUND and \
                flags & wx.LIST_HITTEST_ONITEM:
            self.list.Select(item)

        event.Skip()

    def OnRightUp(self, event):
        """Mouse right button up
        """
        if not hasattr(self, "popupID1"):
            self.popupID1 = wx.NewId()
            self.popupID2 = wx.NewId()
            self.popupID3 = wx.NewId()
            self.Bind(wx.EVT_MENU, self.OnItemDelete, id=self.popupID1)
            self.Bind(wx.EVT_MENU, self.OnItemDeleteAll, id=self.popupID2)
            self.Bind(wx.EVT_MENU, self.OnReload, id=self.popupID3)

        # generate popup-menu
        menu = wx.Menu()
        menu.Append(self.popupID1, _("Delete selected"))
        if self.list.GetFirstSelected() == -1:
            menu.Enable(self.popupID1, False)

        menu.Append(self.popupID2, _("Delete all"))
        menu.AppendSeparator()
        menu.Append(self.popupID3, _("Reload"))

        self.PopupMenu(menu)
        menu.Destroy()

    def OnItemSelected(self, event):
        """Item selected
        """
        event.Skip()

    def OnItemDelete(self, event):
        """Delete selected item(s) from the list (layer/category pair)
        """
        item = self.list.GetFirstSelected()
        while item != -1:
            layer = int(self.list.GetItem(item, 0).GetText())
            cat = int(self.list.GetItem(item, 1).GetText())
            self.list.DeleteItem(item)
            self.cats[self.fid][layer].remove(cat)

            item = self.list.GetFirstSelected()

        event.Skip()

    def OnItemDeleteAll(self, event):
        """Delete all items from the list
        """
        self.list.DeleteAllItems()
        self.cats[self.fid] = {}

        event.Skip()

    def OnFeature(self, event):
        """Feature id changed (on duplicates)
        """
        self.fid = int(event.GetString())

        self.itemDataMap = self.list.Populate(self.cats[self.fid], update=True)

        try:
            newCat = max(self.cats[self.fid][1]) + 1
        except KeyError:
            newCat = 1

        self.catNew.SetValue(newCat)

        event.Skip()

    def _getCategories(self, coords, qdist):
        """Get layer/category pairs for all available
        layers

        :return: True line found or False if not found
        """
        ret = RunCommand('v.what',
                         parent=self,
                         quiet=True,
                         map=self.vectorName,
                         east_north='%f,%f' %
                         (float(coords[0]), float(coords[1])),
                         distance=qdist)

        if not ret:
            return False

        for item in ret.splitlines():
            litem = item.lower()
            if "id:" in litem:  # get line id
                self.line = int(item.split(':')[1].strip())
            elif "layer:" in litem:  # add layer
                layer = int(item.split(':')[1].strip())
                if layer not in self.cats.keys():
                    self.cats[layer] = []
            elif "category:" in litem:  # add category
                self.cats[layer].append(int(item.split(':')[1].strip()))

        return True

    def OnReload(self, event):
        """Reload button pressed
        """
        # restore original list
        self.cats = copy.deepcopy(self.cats_orig)

        # polulate list
        self.itemDataMap = self.list.Populate(self.cats[self.fid], update=True)

        event.Skip()

    def OnCancel(self, event):
        """Cancel button pressed
        """
        self.parent.parent.dialogs['category'] = None
        if self.digit:
            self.digit.GetDisplay().SetSelected([])
            self.parent.UpdateMap(render=False)
        else:
            self.parent.parent.OnRender(None)

        self.Close()

    def OnApply(self, event):
        """Apply button pressed
        """
        for fid in self.cats.keys():
            newfid = self.ApplyChanges(fid)
            if fid == self.fid and newfid > 0:
                self.fid = newfid

    def ApplyChanges(self, fid):
        """Apply changes

        :param fid: feature id
        """
        cats = self.cats[fid]
        cats_orig = self.cats_orig[fid]

        # action : (catsFrom, catsTo)
        check = {'catadd': (cats, cats_orig), 'catdel': (cats_orig, cats)}

        newfid = -1

        # add/delete new category
        for action, catsCurr in check.iteritems():
            for layer in catsCurr[0].keys():
                catList = []
                for cat in catsCurr[0][layer]:
                    if layer not in catsCurr[1].keys() or \
                            cat not in catsCurr[1][layer]:
                        catList.append(cat)
                if catList != []:
                    if action == 'catadd':
                        add = True
                    else:
                        add = False

                    newfid = self.digit.SetLineCats(fid, layer, catList, add)
                    if len(self.cats.keys()) == 1:
                        self.fidText.SetLabel("%d" % newfid)
                    else:
                        choices = self.fidMulti.GetItems()
                        choices[choices.index(str(fid))] = str(newfid)
                        self.fidMulti.SetItems(choices)
                        self.fidMulti.SetStringSelection(str(newfid))

                    self.cats[newfid] = self.cats[fid]
                    del self.cats[fid]

                    fid = newfid
                    if self.fid < 0:
                        wx.MessageBox(
                            parent=self,
                            message=_("Unable to update vector map."),
                            caption=_("Error"),
                            style=wx.OK | wx.ICON_ERROR)

        self.cats_orig[fid] = copy.deepcopy(cats)

        return newfid

    def OnOK(self, event):
        """OK button pressed
        """
        self.OnApply(event)
        self.OnCancel(event)

    def OnAddCat(self, event):
        """Button 'Add' new category pressed
        """
        try:
            layer = int(self.layerNew.GetStringSelection())
            cat = int(self.catNew.GetValue())
            if layer <= 0:
                raise ValueError
        except ValueError:
            GError(
                parent=self,
                message=
                _("Unable to add new layer/category <%(layer)s/%(category)s>.\n"
                  "Layer and category number must be integer.\n"
                  "Layer number must be greater than zero.") % {
                      'layer': str(self.layerNew.GetValue()),
                      'category': str(self.catNew.GetValue())
                  })
            return False

        if layer not in self.cats[self.fid].keys():
            self.cats[self.fid][layer] = []

        self.cats[self.fid][layer].append(cat)

        # reload list
        self.itemDataMap = self.list.Populate(self.cats[self.fid], update=True)

        # update category number for add
        self.catNew.SetValue(cat + 1)

        event.Skip()

        return True

    def GetLine(self):
        """Get id of selected line of 'None' if no line is selected
        """
        return self.cats.keys()

    def UpdateDialog(self, query=None, cats=None):
        """Update dialog

        :param query: {coordinates, distance} - v.what
        :param cats:  directory layer/cats    - vdigit
        :return: True if updated otherwise False
        """
        # line: {layer: [categories]}
        self.cats = {}
        # do not display dialog if no line is found (-> self.cats)
        if cats is None:
            ret = self._getCategories(query[0], query[1])
        else:
            self.cats = cats
            for line in cats.keys():
                for layer in cats[line].keys():
                    self.cats[line][layer] = list(cats[line][layer])
            ret = 1
        if ret == 0 or len(self.cats.keys()) < 1:
            Debug.msg(3, "VDigitCategoryDialog(): nothing found!")
            return False

        # make copy of cats (used for 'reload')
        self.cats_orig = copy.deepcopy(self.cats)

        # polulate list
        self.fid = self.cats.keys()[0]
        self.itemDataMap = self.list.Populate(self.cats[self.fid], update=True)

        try:
            newCat = max(self.cats[self.fid][1]) + 1
        except KeyError:
            newCat = 1
        self.catNew.SetValue(newCat)

        if len(self.cats.keys()) == 1:
            self.fidText.Show(True)
            self.fidMulti.Show(False)
            self.fidText.SetLabel("%d" % self.fid)
        else:
            self.fidText.Show(False)
            self.fidMulti.Show(True)
            choices = []
            for fid in self.cats.keys():
                choices.append(str(fid))
            self.fidMulti.SetItems(choices)
            self.fidMulti.SetSelection(0)

        self.Layout()

        return True
Beispiel #4
0
    def _createCommentPage(self, notebook):
        """Create notebook page for comment settings"""
        panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
        notebook.AddPage(page=panel, text=_("Comment"))

        # colors
        border = wx.BoxSizer(wx.VERTICAL)
        box = StaticBox(parent=panel, id=wx.ID_ANY, label=" %s " % _("Color"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)

        gridSizer = wx.GridBagSizer(hgap=3, vgap=3)

        row = 0
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("Valid:")),
            flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
            pos=(row, 0),
        )
        vColor = csel.ColourSelect(
            parent=panel,
            id=wx.ID_ANY,
            colour=self.settings.Get(group="modeler",
                                     key="comment",
                                     subkey="color"),
            size=globalvar.DIALOG_COLOR_SIZE,
        )
        vColor.SetName("GetColour")
        self.winId["modeler:comment:color"] = vColor.GetId()

        gridSizer.Add(vColor,
                      flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL,
                      pos=(row, 1))

        gridSizer.AddGrowableCol(0)
        sizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
        border.Add(
            sizer,
            proportion=0,
            flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
            border=3,
        )

        # size
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Shape size"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)

        gridSizer = wx.GridBagSizer(hgap=3, vgap=3)

        row = 0
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("Width:")),
            flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
            pos=(row, 0),
        )

        width = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            min=0,
            max=500,
            initial=self.settings.Get(group="modeler",
                                      key="comment",
                                      subkey=("size", "width")),
        )
        width.SetName("GetValue")
        self.winId["modeler:comment:size:width"] = width.GetId()

        gridSizer.Add(width,
                      flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL,
                      pos=(row, 1))

        row += 1
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("Height:")),
            flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
            pos=(row, 0),
        )

        height = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            min=0,
            max=500,
            initial=self.settings.Get(group="modeler",
                                      key="comment",
                                      subkey=("size", "height")),
        )
        height.SetName("GetValue")
        self.winId["modeler:comment:size:height"] = height.GetId()

        gridSizer.Add(height,
                      flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL,
                      pos=(row, 1))

        gridSizer.AddGrowableCol(0)
        sizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
        border.Add(
            sizer,
            proportion=0,
            flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
            border=3,
        )

        panel.SetSizer(border)

        return panel
Beispiel #5
0
    def _createVectorPage(self, notebook):
        """Create notebook page for vector settings"""
        panel = wx.Panel(parent=notebook, id=wx.ID_ANY)

        notebook.AddPage(page=panel, text=" %s " % _("Vector"))

        pageSizer = wx.BoxSizer(wx.VERTICAL)

        # vector lines
        box = StaticBox(parent=panel, id=wx.ID_ANY, label=" %s " % (_("Vector lines")))
        boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        gridSizer = wx.GridBagSizer(vgap=3, hgap=3)

        row = 0
        # icon size
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("Width:")),
            pos=(row, 0),
            flag=wx.ALIGN_CENTER_VERTICAL,
        )

        iwidth = SpinCtrl(
            parent=panel, id=wx.ID_ANY, size=(65, -1), initial=12, min=1, max=100
        )
        self.winId["nviz:vector:lines:width"] = iwidth.GetId()
        iwidth.SetValue(
            UserSettings.Get(group="nviz", key="vector", subkey=["lines", "width"])
        )
        gridSizer.Add(iwidth, pos=(row, 1), flag=wx.ALIGN_CENTER_VERTICAL)

        # icon color
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("Color:")),
            pos=(row, 4),
            flag=wx.ALIGN_CENTER_VERTICAL,
        )
        icolor = csel.ColourSelect(
            panel, id=wx.ID_ANY, size=globalvar.DIALOG_COLOR_SIZE
        )
        icolor.SetName("GetColour")
        self.winId["nviz:vector:lines:color"] = icolor.GetId()
        icolor.SetColour(
            UserSettings.Get(group="nviz", key="vector", subkey=["lines", "color"])
        )
        gridSizer.Add(icolor, flag=wx.ALIGN_CENTER_VERTICAL, pos=(row, 5))
        boxSizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
        pageSizer.Add(
            boxSizer,
            proportion=0,
            flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
            border=5,
        )

        # vector points
        box = StaticBox(parent=panel, id=wx.ID_ANY, label=" %s " % (_("Vector points")))
        boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        gridSizer = wx.GridBagSizer(vgap=3, hgap=5)

        row = 0
        # icon size
        autosize = CheckBox(parent=panel, label=_("Automatic size"))
        autosize.SetToolTip(
            _("Icon size is set automatically based on landscape dimensions.")
        )
        gridSizer.Add(autosize, pos=(row, 0), flag=wx.ALIGN_CENTER_VERTICAL)
        self.winId["nviz:vector:points:autosize"] = autosize.GetId()
        autosize.SetValue(
            UserSettings.Get(group="nviz", key="vector", subkey=["points", "autosize"])
        )

        row += 1
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("Size:")),
            pos=(row, 0),
            flag=wx.ALIGN_CENTER_VERTICAL,
        )

        isize = SpinCtrl(
            parent=panel, id=wx.ID_ANY, size=(65, -1), initial=100, min=1, max=1e6
        )
        self.winId["nviz:vector:points:size"] = isize.GetId()
        isize.SetValue(
            UserSettings.Get(group="nviz", key="vector", subkey=["points", "size"])
        )
        gridSizer.Add(isize, pos=(row, 1), flag=wx.ALIGN_CENTER_VERTICAL)

        # icon symbol
        row += 1
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("Marker:")),
            pos=(row, 0),
            flag=wx.ALIGN_CENTER_VERTICAL,
        )
        isym = wx.Choice(
            parent=panel,
            id=wx.ID_ANY,
            size=(100, -1),
            choices=UserSettings.Get(
                group="nviz",
                key="vector",
                subkey=["points", "marker"],
                settings_type="internal",
            ),
        )
        isym.SetName("GetSelection")
        self.winId["nviz:vector:points:marker"] = isym.GetId()
        isym.SetSelection(
            UserSettings.Get(group="nviz", key="vector", subkey=["points", "marker"])
        )
        gridSizer.Add(isym, flag=wx.ALIGN_CENTER_VERTICAL, pos=(row, 1))

        # icon color
        row += 1
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("Color:")),
            pos=(row, 0),
            flag=wx.ALIGN_CENTER_VERTICAL,
        )
        icolor = csel.ColourSelect(
            panel, id=wx.ID_ANY, size=globalvar.DIALOG_COLOR_SIZE
        )
        icolor.SetName("GetColour")
        self.winId["nviz:vector:points:color"] = icolor.GetId()
        icolor.SetColour(
            UserSettings.Get(group="nviz", key="vector", subkey=["points", "color"])
        )
        gridSizer.Add(icolor, flag=wx.ALIGN_CENTER_VERTICAL, pos=(row, 1))

        boxSizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
        pageSizer.Add(
            boxSizer,
            proportion=0,
            flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
            border=5,
        )

        panel.SetSizer(pageSizer)

        return panel
Beispiel #6
0
    def __init__(
        self,
        parent,
        id,
        title,
        scatt_mgr,
        pos=wx.DefaultPosition,
        size=wx.DefaultSize,
        style=wx.DEFAULT_DIALOG_STYLE,
    ):
        """Settings dialog"""
        wx.Dialog.__init__(self, parent, id, title, pos, size, style)

        self.scatt_mgr = scatt_mgr

        maxValue = 1e8
        self.parent = parent
        self.settings = {}

        settsLabels = {}

        self.settings["show_ellips"] = wx.CheckBox(
            parent=self, id=wx.ID_ANY, label=_("Show confidence ellipses"))
        show_ellips = UserSettings.Get(group="scatt",
                                       key="ellipses",
                                       subkey="show_ellips")
        self.settings["show_ellips"].SetValue(show_ellips)

        self.colorsSetts = {
            "sel_pol": ["selection",
                        _("Selection polygon color:")],
            "sel_pol_vertex":
            ["selection", _("Color of selection polygon vertex:")],
            "sel_area": ["selection", _("Selected area color:")],
        }

        for settKey, sett in six.iteritems(self.colorsSetts):
            settsLabels[settKey] = StaticText(parent=self,
                                              id=wx.ID_ANY,
                                              label=sett[1])
            col = UserSettings.Get(group="scatt", key=sett[0], subkey=settKey)
            self.settings[settKey] = csel.ColourSelect(parent=self,
                                                       id=wx.ID_ANY,
                                                       colour=wx.Colour(
                                                           col[0], col[1],
                                                           col[2], 255))

        self.sizeSetts = {
            "snap_tresh": ["selection",
                           _("Snapping threshold in pixels:")],
            "sel_area_opacty": ["selection",
                                _("Selected area opacity:")],
        }

        for settKey, sett in six.iteritems(self.sizeSetts):
            settsLabels[settKey] = StaticText(parent=self,
                                              id=wx.ID_ANY,
                                              label=sett[1])
            self.settings[settKey] = SpinCtrl(parent=self,
                                              id=wx.ID_ANY,
                                              min=0,
                                              max=100)
            size = int(
                UserSettings.Get(group="scatt", key=sett[0], subkey=settKey))
            self.settings[settKey].SetValue(size)

        # buttons
        self.btnSave = Button(self, wx.ID_SAVE)
        self.btnApply = Button(self, wx.ID_APPLY)
        self.btnClose = Button(self, wx.ID_CLOSE)
        self.btnApply.SetDefault()

        # bindings
        self.btnApply.Bind(wx.EVT_BUTTON, self.OnApply)
        self.btnApply.SetToolTip(_("Apply changes for the current session"))
        self.btnSave.Bind(wx.EVT_BUTTON, self.OnSave)
        self.btnSave.SetToolTip(
            _("Apply and save changes to user settings file (default for next sessions)"
              ))
        self.btnClose.Bind(wx.EVT_BUTTON, self.OnClose)
        self.btnClose.SetToolTip(_("Close dialog"))

        # Layout

        # Analysis result style layout
        self.SetMinSize(self.GetBestSize())

        sizer = wx.BoxSizer(wx.VERTICAL)

        sel_pol_box = StaticBox(parent=self,
                                id=wx.ID_ANY,
                                label=" %s " % _("Selection style:"))
        selPolBoxSizer = wx.StaticBoxSizer(sel_pol_box, wx.VERTICAL)

        gridSizer = wx.GridBagSizer(vgap=1, hgap=1)

        row = 0
        setts = dict()
        setts.update(self.colorsSetts)
        setts.update(self.sizeSetts)

        settsOrder = [
            "sel_pol",
            "sel_pol_vertex",
            "sel_area",
            "sel_area_opacty",
            "snap_tresh",
        ]
        for settKey in settsOrder:
            sett = setts[settKey]
            gridSizer.Add(settsLabels[settKey],
                          flag=wx.ALIGN_CENTER_VERTICAL,
                          pos=(row, 0))
            gridSizer.Add(
                self.settings[settKey],
                flag=wx.ALIGN_RIGHT | wx.ALL,
                border=5,
                pos=(row, 1),
            )
            row += 1

        gridSizer.AddGrowableCol(1)
        selPolBoxSizer.Add(gridSizer, flag=wx.EXPAND)

        ell_box = StaticBox(parent=self,
                            id=wx.ID_ANY,
                            label=" %s " % _("Ellipses settings:"))
        ellPolBoxSizer = wx.StaticBoxSizer(ell_box, wx.VERTICAL)
        gridSizer = wx.GridBagSizer(vgap=1, hgap=1)

        sett = setts[settKey]

        row = 0
        gridSizer.Add(self.settings["show_ellips"],
                      flag=wx.ALIGN_CENTER_VERTICAL,
                      pos=(row, 0))

        gridSizer.AddGrowableCol(0)
        ellPolBoxSizer.Add(gridSizer, flag=wx.EXPAND)

        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
        btnSizer.Add(self.btnApply, flag=wx.LEFT | wx.RIGHT, border=5)
        btnSizer.Add(self.btnSave, flag=wx.LEFT | wx.RIGHT, border=5)
        btnSizer.Add(self.btnClose, flag=wx.LEFT | wx.RIGHT, border=5)

        sizer.Add(selPolBoxSizer, flag=wx.EXPAND | wx.ALL, border=5)
        sizer.Add(ellPolBoxSizer, flag=wx.EXPAND | wx.ALL, border=5)
        sizer.Add(btnSizer, flag=wx.EXPAND | wx.ALL, border=5, proportion=0)

        self.SetSizer(sizer)
        sizer.Fit(self)
Beispiel #7
0
    def __init__(self,
                 parent,
                 title,
                 data,
                 keyEditable=(-1, True),
                 id=wx.ID_ANY,
                 style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
        """Dialog for inserting/updating table record

        :param data: a list: [(column, value)]
        :param keyEditable: (id, editable?) indicates if textarea for
                            key column is editable(True) or not
        """
        # parent -> VDigitWindow
        wx.Dialog.__init__(self, parent, id, title, style=style)

        self.CenterOnParent()

        self.keyId = keyEditable[0]

        box = StaticBox(parent=self, id=wx.ID_ANY)
        box.Hide()
        self.dataPanel = scrolled.ScrolledPanel(parent=self,
                                                id=wx.ID_ANY,
                                                style=wx.TAB_TRAVERSAL)
        self.dataPanel.SetupScrolling(scroll_x=False)

        # buttons
        self.btnCancel = Button(self, wx.ID_CANCEL)
        self.btnSubmit = Button(self, wx.ID_OK, _("&Submit"))
        self.btnSubmit.SetDefault()

        # data area
        self.widgets = []
        cId = 0
        self.usebox = False
        self.cat = None
        winFocus = False

        for column, ctype, ctypeStr, value in data:
            if self.keyId == cId:
                self.cat = int(value)
                if not keyEditable[1]:
                    self.usebox = True
                    box.SetLabel(" %s %d " % (_("Category"), self.cat))
                    box.Show()
                    self.boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
                    cId += 1
                    continue
                else:
                    valueWin = SpinCtrl(parent=self.dataPanel,
                                        id=wx.ID_ANY,
                                        value=value,
                                        min=-1e9,
                                        max=1e9,
                                        size=(250, -1))
            else:
                valueWin = TextCtrl(parent=self.dataPanel,
                                    id=wx.ID_ANY,
                                    value=value,
                                    size=(250, -1))
                if ctype == int:
                    valueWin.SetValidator(IntegerValidator())
                elif ctype == float:
                    valueWin.SetValidator(FloatValidator())
                if not winFocus:
                    wx.CallAfter(valueWin.SetFocus)
                    winFocus = True

            label = StaticText(parent=self.dataPanel,
                               id=wx.ID_ANY,
                               label=column)
            ctype = StaticText(parent=self.dataPanel,
                               id=wx.ID_ANY,
                               label="[%s]:" % ctypeStr.lower())
            self.widgets.append(
                (label.GetId(), ctype.GetId(), valueWin.GetId()))

            cId += 1

        self._layout()
Beispiel #8
0
    def _createFlyPage(self, notebook):
        """Create notebook page for view settings"""
        panel = wx.Panel(parent=notebook, id=wx.ID_ANY)

        notebook.AddPage(page=panel, text=" %s " % _("Fly-through"))
        pageSizer = wx.BoxSizer(wx.VERTICAL)
        # fly throuhg mode
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % (_("Fly-through mode")))
        boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        gridSizer = wx.GridBagSizer(vgap=3, hgap=3)

        # move exag
        gridSizer.Add(StaticText(parent=panel,
                                 id=wx.ID_ANY,
                                 label=_("Move exag:")),
                      pos=(0, 0),
                      flag=wx.ALIGN_CENTER_VERTICAL)

        moveExag = SpinCtrl(panel,
                            id=wx.ID_ANY,
                            min=1,
                            max=20,
                            initial=UserSettings.Get(group='nviz',
                                                     key='fly',
                                                     subkey=['exag', 'move']),
                            size=(65, -1))
        self.winId['nviz:fly:exag:move'] = moveExag.GetId()
        gridSizer.Add(moveExag, pos=(0, 1))

        # turn exag
        gridSizer.Add(StaticText(parent=panel,
                                 id=wx.ID_ANY,
                                 label=_("Turn exag:")),
                      pos=(1, 0),
                      flag=wx.ALIGN_CENTER_VERTICAL)

        turnExag = SpinCtrl(panel,
                            id=wx.ID_ANY,
                            min=1,
                            max=20,
                            initial=UserSettings.Get(group='nviz',
                                                     key='fly',
                                                     subkey=['exag', 'turn']),
                            size=(65, -1))
        self.winId['nviz:fly:exag:turn'] = turnExag.GetId()
        gridSizer.Add(turnExag, pos=(1, 1))

        gridSizer.AddGrowableCol(0)
        boxSizer.Add(gridSizer,
                     proportion=1,
                     flag=wx.ALL | wx.EXPAND,
                     border=5)
        pageSizer.Add(boxSizer,
                      proportion=0,
                      flag=wx.EXPAND | wx.ALL,
                      border=5)

        panel.SetSizer(pageSizer)

        return panel
Beispiel #9
0
    def _createMirrorModePage(self, notebook):
        """Create notebook page for general settings"""
        panel = SP.ScrolledPanel(parent=notebook)
        panel.SetupScrolling(scroll_x=False, scroll_y=True)
        notebook.AddPage(page=panel, text=_("Mirror mode"))

        border = wx.BoxSizer(wx.VERTICAL)
        box = StaticBox(parent=panel, label=" %s " % _("Mirrored cursor"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        gridSizer = wx.GridBagSizer(hgap=3, vgap=3)

        row = 0
        gridSizer.Add(StaticText(parent=panel, label=_("Color:")),
                      flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
                      pos=(row, 0))
        color = csel.ColourSelect(parent=panel,
                                  colour=UserSettings.Get(group='mapswipe',
                                                          key='cursor',
                                                          subkey='color'),
                                  size=globalvar.DIALOG_COLOR_SIZE)
        color.SetName('GetColour')
        self.winId['mapswipe:cursor:color'] = color.GetId()

        gridSizer.Add(color, pos=(row, 1), flag=wx.ALIGN_RIGHT)

        row += 1
        gridSizer.Add(StaticText(parent=panel, label=_("Shape:")),
                      flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
                      pos=(row, 0))
        cursors = wx.Choice(parent=panel,
                            choices=self.settings.Get(
                                group='mapswipe',
                                key='cursor',
                                subkey=['type', 'choices'],
                                settings_type='internal'),
                            name="GetSelection")
        cursors.SetSelection(
            self.settings.Get(group='mapswipe',
                              key='cursor',
                              subkey=['type', 'selection']))
        self.winId['mapswipe:cursor:type:selection'] = cursors.GetId()

        gridSizer.Add(cursors,
                      flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL
                      | wx.EXPAND,
                      pos=(row, 1))

        row += 1
        gridSizer.Add(StaticText(parent=panel, label=_("Line width:")),
                      flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
                      pos=(row, 0))
        width = SpinCtrl(parent=panel,
                         min=1,
                         max=10,
                         initial=self.settings.Get(group='mapswipe',
                                                   key='cursor',
                                                   subkey='width'),
                         name="GetValue")
        self.winId['mapswipe:cursor:width'] = width.GetId()

        gridSizer.Add(width,
                      flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL
                      | wx.EXPAND,
                      pos=(row, 1))

        row += 1
        gridSizer.Add(StaticText(parent=panel, label=_("Size:")),
                      flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
                      pos=(row, 0))
        size = SpinCtrl(parent=panel,
                        min=4,
                        max=50,
                        initial=self.settings.Get(group='mapswipe',
                                                  key='cursor',
                                                  subkey='size'),
                        name="GetValue")
        self.winId['mapswipe:cursor:size'] = size.GetId()

        gridSizer.Add(size,
                      flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL
                      | wx.EXPAND,
                      pos=(row, 1))

        gridSizer.AddGrowableCol(1)
        sizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=3)
        border.Add(sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)
        panel.SetSizer(border)

        return panel
Beispiel #10
0
    def _createQueryPage(self, notebook):
        """Create notebook page for query tool"""
        panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
        notebook.AddPage(page=panel, text=_("Query tool"))

        border = wx.BoxSizer(wx.VERTICAL)

        #
        # query tool box
        #
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Choose query tool"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)

        LocUnits = self.parent.MapWindow.Map.GetProjInfo()["units"]

        self.queryBox = CheckBox(parent=panel,
                                 id=wx.ID_ANY,
                                 label=_("Select by box"))
        self.queryBox.SetValue(
            UserSettings.Get(group="vdigit", key="query", subkey="box"))

        sizer.Add(self.queryBox,
                  proportion=0,
                  flag=wx.ALL | wx.EXPAND,
                  border=1)
        sizer.Add((0, 5))

        #
        # length
        #
        self.queryLength = wx.RadioButton(parent=panel,
                                          id=wx.ID_ANY,
                                          label=_("length"))
        self.queryLength.Bind(wx.EVT_RADIOBUTTON, self.OnChangeQuery)
        sizer.Add(self.queryLength,
                  proportion=0,
                  flag=wx.ALL | wx.EXPAND,
                  border=1)
        flexSizer = wx.FlexGridSizer(cols=4, hgap=5, vgap=5)
        flexSizer.AddGrowableCol(0)
        txt = StaticText(parent=panel, id=wx.ID_ANY, label=_("Select lines"))
        self.queryLengthSL = wx.Choice(
            parent=panel,
            id=wx.ID_ANY,
            choices=[_("shorter than"), _("longer than")])
        self.queryLengthSL.SetSelection(
            UserSettings.Get(group="vdigit",
                             key="queryLength",
                             subkey="than-selection"))
        self.queryLengthValue = SpinCtrl(parent=panel,
                                         id=wx.ID_ANY,
                                         size=(100, -1),
                                         initial=1,
                                         min=0,
                                         max=1e6)
        self.queryLengthValue.SetValue(
            UserSettings.Get(group="vdigit",
                             key="queryLength",
                             subkey="thresh"))
        units = StaticText(parent=panel, id=wx.ID_ANY, label="%s" % LocUnits)
        flexSizer.Add(txt, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(self.queryLengthSL,
                      proportion=0,
                      flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
        flexSizer.Add(self.queryLengthValue,
                      proportion=0,
                      flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
        flexSizer.Add(units, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        sizer.Add(flexSizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=1)

        #
        # dangle
        #
        self.queryDangle = wx.RadioButton(parent=panel,
                                          id=wx.ID_ANY,
                                          label=_("dangle"))
        self.queryDangle.Bind(wx.EVT_RADIOBUTTON, self.OnChangeQuery)
        sizer.Add(self.queryDangle,
                  proportion=0,
                  flag=wx.ALL | wx.EXPAND,
                  border=1)
        flexSizer = wx.FlexGridSizer(cols=4, hgap=5, vgap=5)
        flexSizer.AddGrowableCol(0)
        txt = StaticText(parent=panel, id=wx.ID_ANY, label=_("Select dangles"))
        self.queryDangleSL = wx.Choice(
            parent=panel,
            id=wx.ID_ANY,
            choices=[_("shorter than"), _("longer than")])
        self.queryDangleSL.SetSelection(
            UserSettings.Get(group="vdigit",
                             key="queryDangle",
                             subkey="than-selection"))
        self.queryDangleValue = SpinCtrl(parent=panel,
                                         id=wx.ID_ANY,
                                         size=(100, -1),
                                         initial=1,
                                         min=0,
                                         max=1e6)
        self.queryDangleValue.SetValue(
            UserSettings.Get(group="vdigit",
                             key="queryDangle",
                             subkey="thresh"))
        units = StaticText(parent=panel, id=wx.ID_ANY, label="%s" % LocUnits)
        flexSizer.Add(txt, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(self.queryDangleSL,
                      proportion=0,
                      flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
        flexSizer.Add(self.queryDangleValue,
                      proportion=0,
                      flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
        flexSizer.Add(units, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        sizer.Add(flexSizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=1)

        if UserSettings.Get(group="vdigit", key="query",
                            subkey="selection") == 0:
            self.queryLength.SetValue(True)
        else:
            self.queryDangle.SetValue(True)

        # enable & disable items
        self.OnChangeQuery(None)

        border.Add(sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=5)

        panel.SetSizer(border)

        return panel
Beispiel #11
0
    def _createAttributesPage(self, notebook):
        """Create notebook page for attributes"""
        panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
        notebook.AddPage(page=panel, text=_("Attributes"))

        border = wx.BoxSizer(wx.VERTICAL)

        #
        # add new record
        #
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Digitize new feature"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)

        # checkbox
        self.addRecord = CheckBox(parent=panel,
                                  id=wx.ID_ANY,
                                  label=_("Add new record into table"))
        self.addRecord.SetValue(
            UserSettings.Get(group="vdigit", key="addRecord",
                             subkey="enabled"))
        sizer.Add(self.addRecord,
                  proportion=0,
                  flag=wx.ALL | wx.EXPAND,
                  border=1)
        # settings
        flexSizer = wx.FlexGridSizer(cols=2, hgap=3, vgap=3)
        flexSizer.AddGrowableCol(0)
        settings = ((_("Layer"), 1), (_("Category"), 1), (_("Mode"),
                                                          _("Next to use")))
        # layer
        text = StaticText(parent=panel, id=wx.ID_ANY, label=_("Layer"))
        self.layer = SpinCtrl(parent=panel,
                              id=wx.ID_ANY,
                              size=(125, -1),
                              min=1,
                              max=1e3)
        self.layer.SetValue(
            int(UserSettings.Get(group="vdigit", key="layer", subkey="value")))
        flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(self.layer,
                      proportion=0,
                      flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
        # category number
        text = StaticText(parent=panel,
                          id=wx.ID_ANY,
                          label=_("Category number"))
        self.category = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            size=(125, -1),
            initial=UserSettings.Get(group="vdigit",
                                     key="category",
                                     subkey="value"),
            min=-1e9,
            max=1e9,
        )
        if (UserSettings.Get(
                group="vdigit", key="categoryMode", subkey="selection") != 1):
            self.category.Enable(False)
        flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(
            self.category,
            proportion=0,
            flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL,
        )
        # category mode
        text = StaticText(parent=panel, id=wx.ID_ANY, label=_("Category mode"))
        self.categoryMode = wx.Choice(
            parent=panel,
            id=wx.ID_ANY,
            size=(125, -1),
            choices=[_("Next to use"),
                     _("Manual entry"),
                     _("No category")],
        )
        self.categoryMode.SetSelection(
            UserSettings.Get(group="vdigit",
                             key="categoryMode",
                             subkey="selection"))
        flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(
            self.categoryMode,
            proportion=0,
            flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL,
        )

        sizer.Add(flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=1)
        border.Add(sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=5)

        #
        # delete existing record
        #
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Delete existing feature(s)"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)

        # checkbox
        self.deleteRecord = CheckBox(parent=panel,
                                     id=wx.ID_ANY,
                                     label=_("Delete record from table"))
        self.deleteRecord.SetValue(
            UserSettings.Get(group="vdigit", key="delRecord",
                             subkey="enabled"))
        sizer.Add(self.deleteRecord,
                  proportion=0,
                  flag=wx.ALL | wx.EXPAND,
                  border=1)
        border.Add(
            sizer,
            proportion=0,
            flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
            border=5,
        )

        #
        # geometry attributes (currently only length and area are supported)
        #
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Geometry attributes"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        gridSizer = wx.GridBagSizer(hgap=3, vgap=3)
        self.geomAttrb = {
            "length": {
                "label": _("length")
            },
            "area": {
                "label": _("area")
            },
            "perimeter": {
                "label": _("perimeter")
            },
        }

        digitToolbar = self.parent.toolbars["vdigit"]
        try:
            vectorName = digitToolbar.GetLayer().GetName()
        except AttributeError:
            vectorName = None  # no vector selected for editing
        layer = UserSettings.Get(group="vdigit", key="layer", subkey="value")
        mapLayer = self.parent.toolbars["vdigit"].GetLayer()
        tree = self.parent.tree
        if tree:
            item = tree.FindItemByData("maplayer", mapLayer)
        else:
            item = None
        row = 0
        for attrb in ["length", "area", "perimeter"]:
            # checkbox
            check = CheckBox(parent=panel,
                             id=wx.ID_ANY,
                             label=self.geomAttrb[attrb]["label"])
            # self.deleteRecord.SetValue(UserSettings.Get(group='vdigit', key="delRecord", subkey='enabled'))
            check.Bind(wx.EVT_CHECKBOX, self.OnGeomAttrb)
            # column (only numeric)
            column = ColumnSelect(parent=panel, size=(200, -1))
            column.InsertColumns(
                vector=vectorName,
                layer=layer,
                excludeKey=True,
                type=["integer", "double precision"],
            )
            # units
            if attrb == "area":
                choices = Units.GetUnitsList("area")
            else:
                choices = Units.GetUnitsList("length")
            win_units = wx.Choice(parent=panel,
                                  id=wx.ID_ANY,
                                  choices=choices,
                                  size=(120, -1))

            # default values
            check.SetValue(False)
            if (item and tree.GetLayerInfo(item, key="vdigit")
                    and "geomAttr" in tree.GetLayerInfo(item, key="vdigit")
                    and attrb in tree.GetLayerInfo(item,
                                                   key="vdigit")["geomAttr"]):
                check.SetValue(True)
                column.SetStringSelection(
                    tree.GetLayerInfo(
                        item, key="vdigit")["geomAttr"][attrb]["column"])
                if attrb == "area":
                    type = "area"
                else:
                    type = "length"
                unitsIdx = Units.GetUnitsIndex(
                    type,
                    tree.GetLayerInfo(
                        item, key="vdigit")["geomAttr"][attrb]["units"],
                )
                win_units.SetSelection(unitsIdx)

            if not vectorName:
                check.Enable(False)
                column.Enable(False)

            if not check.IsChecked():
                column.Enable(False)

            self.geomAttrb[attrb]["check"] = check.GetId()
            self.geomAttrb[attrb]["column"] = column.GetId()
            self.geomAttrb[attrb]["units"] = win_units.GetId()

            gridSizer.Add(check, flag=wx.ALIGN_CENTER_VERTICAL, pos=(row, 0))
            gridSizer.Add(column, pos=(row, 1))
            gridSizer.Add(win_units, pos=(row, 2))
            row += 1

        note = "\n".join(
            textwrap.wrap(
                _("Note: These settings are stored "
                  "in the workspace not in the vector digitizer "
                  "preferences."),
                55,
            ))
        gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=note),
                      pos=(3, 0),
                      span=(1, 3))

        gridSizer.AddGrowableCol(0)
        sizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=1)
        border.Add(
            sizer,
            proportion=0,
            flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
            border=5,
        )

        # bindings
        self.Bind(wx.EVT_CHECKBOX, self.OnChangeAddRecord, self.addRecord)
        self.Bind(wx.EVT_CHOICE, self.OnChangeCategoryMode, self.categoryMode)
        self.Bind(wx.EVT_SPINCTRL, self.OnChangeLayer, self.layer)

        panel.SetSizer(border)

        return panel
Beispiel #12
0
class VDigitSettingsDialog(wx.Dialog):
    def __init__(
            self,
            parent,
            giface,
            title=_("Digitization settings"),
            style=wx.DEFAULT_DIALOG_STYLE,
    ):
        """Standard settings dialog for digitization purposes"""
        wx.Dialog.__init__(self,
                           parent=parent,
                           id=wx.ID_ANY,
                           title=title,
                           style=style)

        self._giface = giface
        self.parent = parent  # MapFrame
        self.digit = self.parent.MapWindow.digit

        # notebook
        notebook = wx.Notebook(parent=self, id=wx.ID_ANY, style=wx.BK_DEFAULT)
        self._createGeneralPage(notebook)
        self._createSymbologyPage(notebook)
        self.digit.SetCategory()
        self._createAttributesPage(notebook)
        self._createQueryPage(notebook)

        # buttons
        btnApply = Button(self, wx.ID_APPLY)
        btnCancel = Button(self, wx.ID_CLOSE)
        btnSave = Button(self, wx.ID_SAVE)
        btnSave.SetDefault()

        # bindigs
        btnApply.Bind(wx.EVT_BUTTON, self.OnApply)
        btnApply.SetToolTip(_("Apply changes for this session"))
        btnApply.SetDefault()
        btnSave.Bind(wx.EVT_BUTTON, self.OnSave)
        btnSave.SetToolTip(
            _("Close dialog and save changes to user settings file"))
        btnCancel.Bind(wx.EVT_BUTTON, self.OnCancel)
        btnCancel.SetToolTip(_("Close dialog and ignore changes"))

        # sizers
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
        btnSizer.Add(btnCancel, proportion=0, flag=wx.ALL, border=5)
        btnSizer.Add(btnApply, proportion=0, flag=wx.ALL, border=5)
        btnSizer.Add(btnSave, proportion=0, flag=wx.ALL, border=5)

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(notebook,
                      proportion=1,
                      flag=wx.EXPAND | wx.ALL,
                      border=5)
        mainSizer.Add(btnSizer, proportion=0, flag=wx.ALIGN_RIGHT, border=5)

        self.Bind(wx.EVT_CLOSE, self.OnCancel)

        self.SetSizer(mainSizer)
        mainSizer.Fit(self)

    def _createSymbologyPage(self, notebook):
        """Create notebook page concerning symbology settings"""
        panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
        notebook.AddPage(page=panel, text=_("Symbology"))

        sizer = wx.BoxSizer(wx.VERTICAL)

        flexSizer = wx.FlexGridSizer(cols=3, hgap=5, vgap=5)
        flexSizer.AddGrowableCol(0)

        self.symbology = {}
        for label, key in self._symbologyData():
            textLabel = StaticText(panel, wx.ID_ANY, label)
            color = csel.ColourSelect(
                panel,
                id=wx.ID_ANY,
                colour=UserSettings.Get(group="vdigit",
                                        key="symbol",
                                        subkey=[key, "color"]),
                size=(40, 25),
            )
            isEnabled = UserSettings.Get(group="vdigit",
                                         key="symbol",
                                         subkey=[key, "enabled"])
            if isEnabled is not None:
                enabled = CheckBox(panel, id=wx.ID_ANY, label="")
                enabled.SetValue(isEnabled)
                self.symbology[key] = (enabled, color)
            else:
                enabled = (1, 1)
                self.symbology[key] = (None, color)

            flexSizer.Add(textLabel,
                          proportion=0,
                          flag=wx.ALIGN_CENTER_VERTICAL)
            flexSizer.Add(enabled,
                          proportion=0,
                          flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
            flexSizer.Add(color,
                          proportion=0,
                          flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
            color.SetName("GetColour")

        sizer.Add(flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=10)

        panel.SetSizer(sizer)

        return panel

    def _createGeneralPage(self, notebook):
        """Create notebook page concerning general settings"""
        panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
        notebook.AddPage(page=panel, text=_("General"))

        border = wx.BoxSizer(wx.VERTICAL)

        #
        # display section
        #
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Display"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        flexSizer = wx.FlexGridSizer(cols=3, hgap=5, vgap=5)
        flexSizer.AddGrowableCol(0)
        # line width
        text = StaticText(parent=panel, id=wx.ID_ANY, label=_("Line width"))
        self.lineWidthValue = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            size=(75, -1),
            initial=UserSettings.Get(group="vdigit",
                                     key="lineWidth",
                                     subkey="value"),
            min=1,
            max=1e6,
        )
        units = StaticText(
            parent=panel,
            id=wx.ID_ANY,
            size=(115, -1),
            label=UserSettings.Get(group="vdigit",
                                   key="lineWidth",
                                   subkey="units"),
            style=wx.ALIGN_LEFT,
        )
        flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(self.lineWidthValue,
                      proportion=0,
                      flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
        flexSizer.Add(
            units,
            proportion=0,
            flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL
            | wx.LEFT,
            border=10,
        )

        sizer.Add(flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=1)
        border.Add(sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=5)

        #
        # snapping section
        #
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Snapping"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        flexSizer = wx.FlexGridSizer(cols=3, hgap=5, vgap=5)
        flexSizer.AddGrowableCol(0)

        # snapping
        text = StaticText(parent=panel,
                          id=wx.ID_ANY,
                          label=_("Snapping threshold"))
        self.snappingValue = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            size=(75, -1),
            initial=UserSettings.Get(group="vdigit",
                                     key="snapping",
                                     subkey="value"),
            min=-1,
            max=1e6,
        )
        self.snappingValue.Bind(wx.EVT_SPINCTRL, self.OnChangeSnappingValue)
        self.snappingValue.Bind(wx.EVT_TEXT, self.OnChangeSnappingValue)
        self.snappingUnit = wx.Choice(
            parent=panel,
            id=wx.ID_ANY,
            size=(125, -1),
            choices=[_("screen pixels"), _("map units")],
        )
        try:
            self.snappingUnit.SetSelection(
                UserSettings.Get(group="vdigit", key="snapping",
                                 subkey="unit"))
        except:
            self.snappingUnit.SetSelection(0)
        self.snappingUnit.Bind(wx.EVT_CHOICE, self.OnChangeSnappingUnits)
        flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(self.snappingValue,
                      proportion=0,
                      flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
        flexSizer.Add(self.snappingUnit,
                      proportion=0,
                      flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)

        vertexSizer = wx.BoxSizer(wx.VERTICAL)
        self.snapVertex = CheckBox(parent=panel,
                                   id=wx.ID_ANY,
                                   label=_("Snap also to vertex"))
        self.snapVertex.SetValue(
            UserSettings.Get(group="vdigit",
                             key="snapToVertex",
                             subkey="enabled"))
        vertexSizer.Add(self.snapVertex, proportion=0, flag=wx.EXPAND)
        self.mapUnits = self.parent.MapWindow.Map.GetProjInfo()["units"]
        self.snappingInfo = StaticText(
            parent=panel,
            id=wx.ID_ANY,
            label=_("Snapping threshold is %(value).1f %(units)s") % {
                "value": self.digit.GetDisplay().GetThreshold(),
                "units": self.mapUnits
            },
        )
        vertexSizer.Add(self.snappingInfo,
                        proportion=0,
                        flag=wx.ALL | wx.EXPAND,
                        border=1)

        sizer.Add(flexSizer, proportion=1, flag=wx.EXPAND)
        sizer.Add(vertexSizer, proportion=1, flag=wx.EXPAND)
        border.Add(
            sizer,
            proportion=0,
            flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
            border=5,
        )

        #
        # select box
        #
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Select vector features"))
        # feature type
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        inSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.selectFeature = {}
        for feature in ("point", "line", "centroid", "boundary"):
            chkbox = CheckBox(parent=panel, label=feature)
            self.selectFeature[feature] = chkbox.GetId()
            chkbox.SetValue(
                UserSettings.Get(group="vdigit",
                                 key="selectType",
                                 subkey=[feature, "enabled"]))
            inSizer.Add(chkbox,
                        proportion=0,
                        flag=wx.EXPAND | wx.ALL,
                        border=5)
        sizer.Add(inSizer, proportion=0, flag=wx.EXPAND)
        # threshold
        flexSizer = wx.FlexGridSizer(cols=3, hgap=5, vgap=5)
        flexSizer.AddGrowableCol(0)
        text = StaticText(parent=panel,
                          id=wx.ID_ANY,
                          label=_("Select threshold"))
        self.selectThreshValue = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            size=(75, -1),
            initial=UserSettings.Get(group="vdigit",
                                     key="selectThresh",
                                     subkey="value"),
            min=1,
            max=1e6,
        )
        units = StaticText(
            parent=panel,
            id=wx.ID_ANY,
            size=(115, -1),
            label=UserSettings.Get(group="vdigit",
                                   key="lineWidth",
                                   subkey="units"),
            style=wx.ALIGN_LEFT,
        )
        flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(
            self.selectThreshValue,
            proportion=0,
            flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE,
        )
        flexSizer.Add(
            units,
            proportion=0,
            flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL
            | wx.LEFT,
            border=10,
        )

        self.selectIn = CheckBox(
            parent=panel,
            id=wx.ID_ANY,
            label=_("Select only features inside of selection bounding box"),
        )
        self.selectIn.SetValue(
            UserSettings.Get(group="vdigit",
                             key="selectInside",
                             subkey="enabled"))
        self.selectIn.SetToolTip(
            _("By default are selected all features overlapping selection bounding box "
              ))

        self.checkForDupl = CheckBox(parent=panel,
                                     id=wx.ID_ANY,
                                     label=_("Check for duplicates"))
        self.checkForDupl.SetValue(
            UserSettings.Get(group="vdigit",
                             key="checkForDupl",
                             subkey="enabled"))

        sizer.Add(flexSizer, proportion=0, flag=wx.EXPAND)
        sizer.Add(self.selectIn,
                  proportion=0,
                  flag=wx.EXPAND | wx.ALL,
                  border=1)
        sizer.Add(self.checkForDupl,
                  proportion=0,
                  flag=wx.EXPAND | wx.ALL,
                  border=1)
        border.Add(
            sizer,
            proportion=0,
            flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
            border=5,
        )

        #
        # digitize lines box
        #
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Digitize lines/boundaries"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)

        self.intersect = CheckBox(parent=panel,
                                  label=_("Break lines at intersection"))
        self.intersect.SetValue(
            UserSettings.Get(group="vdigit",
                             key="breakLines",
                             subkey="enabled"))

        sizer.Add(self.intersect,
                  proportion=0,
                  flag=wx.ALL | wx.EXPAND,
                  border=1)

        border.Add(
            sizer,
            proportion=0,
            flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
            border=5,
        )

        #
        # digitize areas box
        #
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Digitize areas"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)

        self.closeBoundary = CheckBox(
            parent=panel, label=_("Close boundary (snap to the start node)"))
        self.closeBoundary.SetValue(
            UserSettings.Get(group="vdigit",
                             key="closeBoundary",
                             subkey="enabled"))

        sizer.Add(self.closeBoundary,
                  proportion=0,
                  flag=wx.ALL | wx.EXPAND,
                  border=1)

        border.Add(
            sizer,
            proportion=0,
            flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
            border=5,
        )

        #
        # save-on-exit box
        #
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Save changes"))
        # save changes on exit?
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        self.save = CheckBox(parent=panel, label=_("Save changes on exit"))
        self.save.SetValue(
            UserSettings.Get(group="vdigit",
                             key="saveOnExit",
                             subkey="enabled"))
        sizer.Add(self.save, proportion=0, flag=wx.ALL | wx.EXPAND, border=1)
        border.Add(
            sizer,
            proportion=0,
            flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
            border=5,
        )

        panel.SetSizer(border)

        return panel

    def _createQueryPage(self, notebook):
        """Create notebook page for query tool"""
        panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
        notebook.AddPage(page=panel, text=_("Query tool"))

        border = wx.BoxSizer(wx.VERTICAL)

        #
        # query tool box
        #
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Choose query tool"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)

        LocUnits = self.parent.MapWindow.Map.GetProjInfo()["units"]

        self.queryBox = CheckBox(parent=panel,
                                 id=wx.ID_ANY,
                                 label=_("Select by box"))
        self.queryBox.SetValue(
            UserSettings.Get(group="vdigit", key="query", subkey="box"))

        sizer.Add(self.queryBox,
                  proportion=0,
                  flag=wx.ALL | wx.EXPAND,
                  border=1)
        sizer.Add((0, 5))

        #
        # length
        #
        self.queryLength = wx.RadioButton(parent=panel,
                                          id=wx.ID_ANY,
                                          label=_("length"))
        self.queryLength.Bind(wx.EVT_RADIOBUTTON, self.OnChangeQuery)
        sizer.Add(self.queryLength,
                  proportion=0,
                  flag=wx.ALL | wx.EXPAND,
                  border=1)
        flexSizer = wx.FlexGridSizer(cols=4, hgap=5, vgap=5)
        flexSizer.AddGrowableCol(0)
        txt = StaticText(parent=panel, id=wx.ID_ANY, label=_("Select lines"))
        self.queryLengthSL = wx.Choice(
            parent=panel,
            id=wx.ID_ANY,
            choices=[_("shorter than"), _("longer than")])
        self.queryLengthSL.SetSelection(
            UserSettings.Get(group="vdigit",
                             key="queryLength",
                             subkey="than-selection"))
        self.queryLengthValue = SpinCtrl(parent=panel,
                                         id=wx.ID_ANY,
                                         size=(100, -1),
                                         initial=1,
                                         min=0,
                                         max=1e6)
        self.queryLengthValue.SetValue(
            UserSettings.Get(group="vdigit",
                             key="queryLength",
                             subkey="thresh"))
        units = StaticText(parent=panel, id=wx.ID_ANY, label="%s" % LocUnits)
        flexSizer.Add(txt, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(self.queryLengthSL,
                      proportion=0,
                      flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
        flexSizer.Add(self.queryLengthValue,
                      proportion=0,
                      flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
        flexSizer.Add(units, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        sizer.Add(flexSizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=1)

        #
        # dangle
        #
        self.queryDangle = wx.RadioButton(parent=panel,
                                          id=wx.ID_ANY,
                                          label=_("dangle"))
        self.queryDangle.Bind(wx.EVT_RADIOBUTTON, self.OnChangeQuery)
        sizer.Add(self.queryDangle,
                  proportion=0,
                  flag=wx.ALL | wx.EXPAND,
                  border=1)
        flexSizer = wx.FlexGridSizer(cols=4, hgap=5, vgap=5)
        flexSizer.AddGrowableCol(0)
        txt = StaticText(parent=panel, id=wx.ID_ANY, label=_("Select dangles"))
        self.queryDangleSL = wx.Choice(
            parent=panel,
            id=wx.ID_ANY,
            choices=[_("shorter than"), _("longer than")])
        self.queryDangleSL.SetSelection(
            UserSettings.Get(group="vdigit",
                             key="queryDangle",
                             subkey="than-selection"))
        self.queryDangleValue = SpinCtrl(parent=panel,
                                         id=wx.ID_ANY,
                                         size=(100, -1),
                                         initial=1,
                                         min=0,
                                         max=1e6)
        self.queryDangleValue.SetValue(
            UserSettings.Get(group="vdigit",
                             key="queryDangle",
                             subkey="thresh"))
        units = StaticText(parent=panel, id=wx.ID_ANY, label="%s" % LocUnits)
        flexSizer.Add(txt, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(self.queryDangleSL,
                      proportion=0,
                      flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
        flexSizer.Add(self.queryDangleValue,
                      proportion=0,
                      flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
        flexSizer.Add(units, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        sizer.Add(flexSizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=1)

        if UserSettings.Get(group="vdigit", key="query",
                            subkey="selection") == 0:
            self.queryLength.SetValue(True)
        else:
            self.queryDangle.SetValue(True)

        # enable & disable items
        self.OnChangeQuery(None)

        border.Add(sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=5)

        panel.SetSizer(border)

        return panel

    def _createAttributesPage(self, notebook):
        """Create notebook page for attributes"""
        panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
        notebook.AddPage(page=panel, text=_("Attributes"))

        border = wx.BoxSizer(wx.VERTICAL)

        #
        # add new record
        #
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Digitize new feature"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)

        # checkbox
        self.addRecord = CheckBox(parent=panel,
                                  id=wx.ID_ANY,
                                  label=_("Add new record into table"))
        self.addRecord.SetValue(
            UserSettings.Get(group="vdigit", key="addRecord",
                             subkey="enabled"))
        sizer.Add(self.addRecord,
                  proportion=0,
                  flag=wx.ALL | wx.EXPAND,
                  border=1)
        # settings
        flexSizer = wx.FlexGridSizer(cols=2, hgap=3, vgap=3)
        flexSizer.AddGrowableCol(0)
        settings = ((_("Layer"), 1), (_("Category"), 1), (_("Mode"),
                                                          _("Next to use")))
        # layer
        text = StaticText(parent=panel, id=wx.ID_ANY, label=_("Layer"))
        self.layer = SpinCtrl(parent=panel,
                              id=wx.ID_ANY,
                              size=(125, -1),
                              min=1,
                              max=1e3)
        self.layer.SetValue(
            int(UserSettings.Get(group="vdigit", key="layer", subkey="value")))
        flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(self.layer,
                      proportion=0,
                      flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL)
        # category number
        text = StaticText(parent=panel,
                          id=wx.ID_ANY,
                          label=_("Category number"))
        self.category = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            size=(125, -1),
            initial=UserSettings.Get(group="vdigit",
                                     key="category",
                                     subkey="value"),
            min=-1e9,
            max=1e9,
        )
        if (UserSettings.Get(
                group="vdigit", key="categoryMode", subkey="selection") != 1):
            self.category.Enable(False)
        flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(
            self.category,
            proportion=0,
            flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL,
        )
        # category mode
        text = StaticText(parent=panel, id=wx.ID_ANY, label=_("Category mode"))
        self.categoryMode = wx.Choice(
            parent=panel,
            id=wx.ID_ANY,
            size=(125, -1),
            choices=[_("Next to use"),
                     _("Manual entry"),
                     _("No category")],
        )
        self.categoryMode.SetSelection(
            UserSettings.Get(group="vdigit",
                             key="categoryMode",
                             subkey="selection"))
        flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(
            self.categoryMode,
            proportion=0,
            flag=wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL,
        )

        sizer.Add(flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=1)
        border.Add(sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=5)

        #
        # delete existing record
        #
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Delete existing feature(s)"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)

        # checkbox
        self.deleteRecord = CheckBox(parent=panel,
                                     id=wx.ID_ANY,
                                     label=_("Delete record from table"))
        self.deleteRecord.SetValue(
            UserSettings.Get(group="vdigit", key="delRecord",
                             subkey="enabled"))
        sizer.Add(self.deleteRecord,
                  proportion=0,
                  flag=wx.ALL | wx.EXPAND,
                  border=1)
        border.Add(
            sizer,
            proportion=0,
            flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
            border=5,
        )

        #
        # geometry attributes (currently only length and area are supported)
        #
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Geometry attributes"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        gridSizer = wx.GridBagSizer(hgap=3, vgap=3)
        self.geomAttrb = {
            "length": {
                "label": _("length")
            },
            "area": {
                "label": _("area")
            },
            "perimeter": {
                "label": _("perimeter")
            },
        }

        digitToolbar = self.parent.toolbars["vdigit"]
        try:
            vectorName = digitToolbar.GetLayer().GetName()
        except AttributeError:
            vectorName = None  # no vector selected for editing
        layer = UserSettings.Get(group="vdigit", key="layer", subkey="value")
        mapLayer = self.parent.toolbars["vdigit"].GetLayer()
        tree = self.parent.tree
        if tree:
            item = tree.FindItemByData("maplayer", mapLayer)
        else:
            item = None
        row = 0
        for attrb in ["length", "area", "perimeter"]:
            # checkbox
            check = CheckBox(parent=panel,
                             id=wx.ID_ANY,
                             label=self.geomAttrb[attrb]["label"])
            # self.deleteRecord.SetValue(UserSettings.Get(group='vdigit', key="delRecord", subkey='enabled'))
            check.Bind(wx.EVT_CHECKBOX, self.OnGeomAttrb)
            # column (only numeric)
            column = ColumnSelect(parent=panel, size=(200, -1))
            column.InsertColumns(
                vector=vectorName,
                layer=layer,
                excludeKey=True,
                type=["integer", "double precision"],
            )
            # units
            if attrb == "area":
                choices = Units.GetUnitsList("area")
            else:
                choices = Units.GetUnitsList("length")
            win_units = wx.Choice(parent=panel,
                                  id=wx.ID_ANY,
                                  choices=choices,
                                  size=(120, -1))

            # default values
            check.SetValue(False)
            if (item and tree.GetLayerInfo(item, key="vdigit")
                    and "geomAttr" in tree.GetLayerInfo(item, key="vdigit")
                    and attrb in tree.GetLayerInfo(item,
                                                   key="vdigit")["geomAttr"]):
                check.SetValue(True)
                column.SetStringSelection(
                    tree.GetLayerInfo(
                        item, key="vdigit")["geomAttr"][attrb]["column"])
                if attrb == "area":
                    type = "area"
                else:
                    type = "length"
                unitsIdx = Units.GetUnitsIndex(
                    type,
                    tree.GetLayerInfo(
                        item, key="vdigit")["geomAttr"][attrb]["units"],
                )
                win_units.SetSelection(unitsIdx)

            if not vectorName:
                check.Enable(False)
                column.Enable(False)

            if not check.IsChecked():
                column.Enable(False)

            self.geomAttrb[attrb]["check"] = check.GetId()
            self.geomAttrb[attrb]["column"] = column.GetId()
            self.geomAttrb[attrb]["units"] = win_units.GetId()

            gridSizer.Add(check, flag=wx.ALIGN_CENTER_VERTICAL, pos=(row, 0))
            gridSizer.Add(column, pos=(row, 1))
            gridSizer.Add(win_units, pos=(row, 2))
            row += 1

        note = "\n".join(
            textwrap.wrap(
                _("Note: These settings are stored "
                  "in the workspace not in the vector digitizer "
                  "preferences."),
                55,
            ))
        gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY, label=note),
                      pos=(3, 0),
                      span=(1, 3))

        gridSizer.AddGrowableCol(0)
        sizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=1)
        border.Add(
            sizer,
            proportion=0,
            flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
            border=5,
        )

        # bindings
        self.Bind(wx.EVT_CHECKBOX, self.OnChangeAddRecord, self.addRecord)
        self.Bind(wx.EVT_CHOICE, self.OnChangeCategoryMode, self.categoryMode)
        self.Bind(wx.EVT_SPINCTRL, self.OnChangeLayer, self.layer)

        panel.SetSizer(border)

        return panel

    def _symbologyData(self):
        """Data for _createSymbologyPage()

        label | checkbox | color
        """

        return (
            (_("Digitize new line segment"), "newSegment"),
            (_("Digitize new line/boundary"), "newLine"),
            (_("Highlight"), "highlight"),
            (_("Highlight (duplicates)"), "highlightDupl"),
            (_("Point"), "point"),
            (_("Line"), "line"),
            (_("Boundary (no area)"), "boundaryNo"),
            (_("Boundary (one area)"), "boundaryOne"),
            (_("Boundary (two areas)"), "boundaryTwo"),
            (_("Centroid (in area)"), "centroidIn"),
            (_("Centroid (outside area)"), "centroidOut"),
            (_("Centroid (duplicate in area)"), "centroidDup"),
            (_("Node (one line)"), "nodeOne"),
            (_("Node (two lines)"), "nodeTwo"),
            (_("Vertex"), "vertex"),
            (_("Area (closed boundary + centroid)"), "area"),
            (_("Direction"), "direction"),
        )

    def OnGeomAttrb(self, event):
        """Register geometry attributes (enable/disable)"""
        checked = event.IsChecked()
        id = event.GetId()
        key = None
        for attrb, val in six.iteritems(self.geomAttrb):
            if val["check"] == id:
                key = attrb
                break

        column = self.FindWindowById(self.geomAttrb[key]["column"])
        if checked:
            column.Enable()
        else:
            column.Enable(False)

    def OnChangeCategoryMode(self, event):
        """Change category mode"""
        mode = event.GetSelection()
        UserSettings.Set(group="vdigit",
                         key="categoryMode",
                         subkey="selection",
                         value=mode)
        if mode == 1:  # manual entry
            self.category.Enable(True)
        elif self.category.IsEnabled():  # disable
            self.category.Enable(False)

        if mode == 2 and self.addRecord.IsChecked():  # no category
            self.addRecord.SetValue(False)

        self.digit.SetCategory()
        self.category.SetValue(
            UserSettings.Get(group="vdigit", key="category", subkey="value"))

    def OnChangeLayer(self, event):
        """Layer changed"""
        layer = event.GetInt()
        if layer > 0:
            UserSettings.Set(group="vdigit",
                             key="layer",
                             subkey="value",
                             value=layer)
            self.digit.SetCategory()
            self.category.SetValue(
                UserSettings.Get(group="vdigit",
                                 key="category",
                                 subkey="value"))

        event.Skip()

    def OnChangeAddRecord(self, event):
        """Checkbox 'Add new record' status changed"""
        pass
        # self.category.SetValue(self.digit.SetCategory())

    def OnChangeSnappingValue(self, event):
        """Change snapping value - update static text"""
        value = self.snappingValue.GetValue()

        if value < 0:
            region = self.parent.MapWindow.Map.GetRegion()
            res = (region["nsres"] + region["ewres"]) / 2.0
            threshold = self.digit.GetDisplay().GetThreshold(value=res)
        else:
            if self.snappingUnit.GetSelection() == 1:  # map units
                threshold = value
            else:
                threshold = self.digit.GetDisplay().GetThreshold(value=value)

        if value == 0:
            self.snappingInfo.SetLabel(_("Snapping disabled"))
        elif value < 0:
            self.snappingInfo.SetLabel(
                _("Snapping threshold is %(value).1f %(units)s "
                  "(based on comp. resolution)") % {
                      "value": threshold,
                      "units": self.mapUnits.lower()
                  })
        else:
            self.snappingInfo.SetLabel(
                _("Snapping threshold is %(value).1f %(units)s") % {
                    "value": threshold,
                    "units": self.mapUnits.lower()
                })

        event.Skip()

    def OnChangeSnappingUnits(self, event):
        """Snapping units change -> update static text"""
        value = self.snappingValue.GetValue()
        units = self.snappingUnit.GetSelection()
        threshold = self.digit.GetDisplay().GetThreshold(value=value,
                                                         units=units)

        if units == 1:  # map units
            self.snappingInfo.SetLabel(
                _("Snapping threshold is %(value).1f %(units)s") % {
                    "value": value,
                    "units": self.mapUnits
                })
        else:
            self.snappingInfo.SetLabel(
                _("Snapping threshold is %(value).1f %(units)s") % {
                    "value": threshold,
                    "units": self.mapUnits
                })

        event.Skip()

    def OnChangeQuery(self, event):
        """Change query"""
        if self.queryLength.GetValue():
            # length
            self.queryLengthSL.Enable(True)
            self.queryLengthValue.Enable(True)
            self.queryDangleSL.Enable(False)
            self.queryDangleValue.Enable(False)
        else:
            # dangle
            self.queryLengthSL.Enable(False)
            self.queryLengthValue.Enable(False)
            self.queryDangleSL.Enable(True)
            self.queryDangleValue.Enable(True)

    def OnSave(self, event):
        """Button 'Save' pressed"""
        self.UpdateSettings()
        self.parent.toolbars["vdigit"].settingsDialog = None

        fileSettings = {}
        UserSettings.ReadSettingsFile(settings=fileSettings)
        fileSettings["vdigit"] = UserSettings.Get(group="vdigit")

        sfile = UserSettings.SaveToFile(fileSettings)
        self._giface.WriteLog(
            _("Vector digitizer settings saved to file <%s>.") % sfile)

        self.Destroy()

        event.Skip()

    def OnApply(self, event):
        """Button 'Apply' pressed"""
        self.UpdateSettings()

    def OnCancel(self, event):
        """Button 'Cancel' pressed"""
        self.parent.toolbars["vdigit"].settingsDialog = None
        self.Destroy()

        if event:
            event.Skip()

    def UpdateSettings(self):
        """Update digitizer settings

        .. todo::
            Needs refactoring
        """
        if self.parent.GetLayerManager():
            self._giface.workspaceChanged.emit()
        # symbology
        for key, (enabled, color) in six.iteritems(self.symbology):
            if enabled:
                UserSettings.Set(
                    group="vdigit",
                    key="symbol",
                    subkey=[key, "enabled"],
                    value=enabled.IsChecked(),
                )
                UserSettings.Set(
                    group="vdigit",
                    key="symbol",
                    subkey=[key, "color"],
                    value=tuple(color.GetColour()),
                )
            else:
                UserSettings.Set(
                    group="vdigit",
                    key="symbol",
                    subkey=[key, "color"],
                    value=tuple(color.GetColour()),
                )
        # display
        UserSettings.Set(
            group="vdigit",
            key="lineWidth",
            subkey="value",
            value=int(self.lineWidthValue.GetValue()),
        )

        # snapping
        UserSettings.Set(
            group="vdigit",
            key="snapping",
            subkey="value",
            value=int(self.snappingValue.GetValue()),
        )
        UserSettings.Set(
            group="vdigit",
            key="snapping",
            subkey="unit",
            value=self.snappingUnit.GetSelection(),
        )
        UserSettings.Set(
            group="vdigit",
            key="snapToVertex",
            subkey="enabled",
            value=self.snapVertex.IsChecked(),
        )

        # digitize new feature
        UserSettings.Set(
            group="vdigit",
            key="addRecord",
            subkey="enabled",
            value=self.addRecord.IsChecked(),
        )
        UserSettings.Set(
            group="vdigit",
            key="layer",
            subkey="value",
            value=int(self.layer.GetValue()),
        )
        UserSettings.Set(
            group="vdigit",
            key="category",
            subkey="value",
            value=int(self.category.GetValue()),
        )
        UserSettings.Set(
            group="vdigit",
            key="categoryMode",
            subkey="selection",
            value=self.categoryMode.GetSelection(),
        )

        # delete existing feature
        UserSettings.Set(
            group="vdigit",
            key="delRecord",
            subkey="enabled",
            value=self.deleteRecord.IsChecked(),
        )

        # geometry attributes (workspace)
        mapLayer = self.parent.toolbars["vdigit"].GetLayer()
        tree = self._giface.GetLayerTree()
        if tree:
            item = tree.FindItemByData("maplayer", mapLayer)
        else:
            item = None
        for key, val in six.iteritems(self.geomAttrb):
            checked = self.FindWindowById(val["check"]).IsChecked()
            column = self.FindWindowById(val["column"]).GetValue()
            unitsIdx = self.FindWindowById(val["units"]).GetSelection()
            if item and not tree.GetLayerInfo(item, key="vdigit"):
                tree.SetLayerInfo(item,
                                  key="vdigit",
                                  value={"geomAttr": dict()})

            if checked:  # enable
                if key == "area":
                    type = key
                else:
                    type = "length"
                unitsKey = Units.GetUnitsKey(type, unitsIdx)
                tree.GetLayerInfo(item, key="vdigit")["geomAttr"][key] = {
                    "column": column,
                    "units": unitsKey,
                }
            else:
                if (item and tree.GetLayerInfo(item, key="vdigit") and key
                        in tree.GetLayerInfo(item, key="vdigit")["geomAttr"]):
                    del tree.GetLayerInfo(item, key="vdigit")["geomAttr"][key]

        # query tool
        if self.queryLength.GetValue():
            UserSettings.Set(group="vdigit",
                             key="query",
                             subkey="selection",
                             value=0)
        else:
            UserSettings.Set(group="vdigit",
                             key="query",
                             subkey="type",
                             value=1)
        UserSettings.Set(group="vdigit",
                         key="query",
                         subkey="box",
                         value=self.queryBox.IsChecked())
        UserSettings.Set(
            group="vdigit",
            key="queryLength",
            subkey="than-selection",
            value=self.queryLengthSL.GetSelection(),
        )
        UserSettings.Set(
            group="vdigit",
            key="queryLength",
            subkey="thresh",
            value=int(self.queryLengthValue.GetValue()),
        )
        UserSettings.Set(
            group="vdigit",
            key="queryDangle",
            subkey="than-selection",
            value=self.queryDangleSL.GetSelection(),
        )
        UserSettings.Set(
            group="vdigit",
            key="queryDangle",
            subkey="thresh",
            value=int(self.queryDangleValue.GetValue()),
        )

        # select features
        for feature in ("point", "line", "centroid", "boundary"):
            UserSettings.Set(
                group="vdigit",
                key="selectType",
                subkey=[feature, "enabled"],
                value=self.FindWindowById(
                    self.selectFeature[feature]).IsChecked(),
            )
        UserSettings.Set(
            group="vdigit",
            key="selectThresh",
            subkey="value",
            value=int(self.selectThreshValue.GetValue()),
        )
        UserSettings.Set(
            group="vdigit",
            key="checkForDupl",
            subkey="enabled",
            value=self.checkForDupl.IsChecked(),
        )
        UserSettings.Set(
            group="vdigit",
            key="selectInside",
            subkey="enabled",
            value=self.selectIn.IsChecked(),
        )

        # on-exit
        UserSettings.Set(
            group="vdigit",
            key="saveOnExit",
            subkey="enabled",
            value=self.save.IsChecked(),
        )

        # break lines
        UserSettings.Set(
            group="vdigit",
            key="breakLines",
            subkey="enabled",
            value=self.intersect.IsChecked(),
        )

        # close boundary
        UserSettings.Set(
            group="vdigit",
            key="closeBoundary",
            subkey="enabled",
            value=self.closeBoundary.IsChecked(),
        )

        self.digit.UpdateSettings()

        # redraw map if auto-rendering is enabled
        if self.parent.IsAutoRendered():
            self.parent.OnRender(None)
Beispiel #13
0
    def _createGeneralPage(self, notebook):
        """Create notebook page concerning general settings"""
        panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
        notebook.AddPage(page=panel, text=_("General"))

        border = wx.BoxSizer(wx.VERTICAL)

        #
        # display section
        #
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Display"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        flexSizer = wx.FlexGridSizer(cols=3, hgap=5, vgap=5)
        flexSizer.AddGrowableCol(0)
        # line width
        text = StaticText(parent=panel, id=wx.ID_ANY, label=_("Line width"))
        self.lineWidthValue = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            size=(75, -1),
            initial=UserSettings.Get(group="vdigit",
                                     key="lineWidth",
                                     subkey="value"),
            min=1,
            max=1e6,
        )
        units = StaticText(
            parent=panel,
            id=wx.ID_ANY,
            size=(115, -1),
            label=UserSettings.Get(group="vdigit",
                                   key="lineWidth",
                                   subkey="units"),
            style=wx.ALIGN_LEFT,
        )
        flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(self.lineWidthValue,
                      proportion=0,
                      flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
        flexSizer.Add(
            units,
            proportion=0,
            flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL
            | wx.LEFT,
            border=10,
        )

        sizer.Add(flexSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=1)
        border.Add(sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=5)

        #
        # snapping section
        #
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Snapping"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        flexSizer = wx.FlexGridSizer(cols=3, hgap=5, vgap=5)
        flexSizer.AddGrowableCol(0)

        # snapping
        text = StaticText(parent=panel,
                          id=wx.ID_ANY,
                          label=_("Snapping threshold"))
        self.snappingValue = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            size=(75, -1),
            initial=UserSettings.Get(group="vdigit",
                                     key="snapping",
                                     subkey="value"),
            min=-1,
            max=1e6,
        )
        self.snappingValue.Bind(wx.EVT_SPINCTRL, self.OnChangeSnappingValue)
        self.snappingValue.Bind(wx.EVT_TEXT, self.OnChangeSnappingValue)
        self.snappingUnit = wx.Choice(
            parent=panel,
            id=wx.ID_ANY,
            size=(125, -1),
            choices=[_("screen pixels"), _("map units")],
        )
        try:
            self.snappingUnit.SetSelection(
                UserSettings.Get(group="vdigit", key="snapping",
                                 subkey="unit"))
        except:
            self.snappingUnit.SetSelection(0)
        self.snappingUnit.Bind(wx.EVT_CHOICE, self.OnChangeSnappingUnits)
        flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(self.snappingValue,
                      proportion=0,
                      flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
        flexSizer.Add(self.snappingUnit,
                      proportion=0,
                      flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)

        vertexSizer = wx.BoxSizer(wx.VERTICAL)
        self.snapVertex = CheckBox(parent=panel,
                                   id=wx.ID_ANY,
                                   label=_("Snap also to vertex"))
        self.snapVertex.SetValue(
            UserSettings.Get(group="vdigit",
                             key="snapToVertex",
                             subkey="enabled"))
        vertexSizer.Add(self.snapVertex, proportion=0, flag=wx.EXPAND)
        self.mapUnits = self.parent.MapWindow.Map.GetProjInfo()["units"]
        self.snappingInfo = StaticText(
            parent=panel,
            id=wx.ID_ANY,
            label=_("Snapping threshold is %(value).1f %(units)s") % {
                "value": self.digit.GetDisplay().GetThreshold(),
                "units": self.mapUnits
            },
        )
        vertexSizer.Add(self.snappingInfo,
                        proportion=0,
                        flag=wx.ALL | wx.EXPAND,
                        border=1)

        sizer.Add(flexSizer, proportion=1, flag=wx.EXPAND)
        sizer.Add(vertexSizer, proportion=1, flag=wx.EXPAND)
        border.Add(
            sizer,
            proportion=0,
            flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
            border=5,
        )

        #
        # select box
        #
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Select vector features"))
        # feature type
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        inSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.selectFeature = {}
        for feature in ("point", "line", "centroid", "boundary"):
            chkbox = CheckBox(parent=panel, label=feature)
            self.selectFeature[feature] = chkbox.GetId()
            chkbox.SetValue(
                UserSettings.Get(group="vdigit",
                                 key="selectType",
                                 subkey=[feature, "enabled"]))
            inSizer.Add(chkbox,
                        proportion=0,
                        flag=wx.EXPAND | wx.ALL,
                        border=5)
        sizer.Add(inSizer, proportion=0, flag=wx.EXPAND)
        # threshold
        flexSizer = wx.FlexGridSizer(cols=3, hgap=5, vgap=5)
        flexSizer.AddGrowableCol(0)
        text = StaticText(parent=panel,
                          id=wx.ID_ANY,
                          label=_("Select threshold"))
        self.selectThreshValue = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            size=(75, -1),
            initial=UserSettings.Get(group="vdigit",
                                     key="selectThresh",
                                     subkey="value"),
            min=1,
            max=1e6,
        )
        units = StaticText(
            parent=panel,
            id=wx.ID_ANY,
            size=(115, -1),
            label=UserSettings.Get(group="vdigit",
                                   key="lineWidth",
                                   subkey="units"),
            style=wx.ALIGN_LEFT,
        )
        flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(
            self.selectThreshValue,
            proportion=0,
            flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE,
        )
        flexSizer.Add(
            units,
            proportion=0,
            flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL
            | wx.LEFT,
            border=10,
        )

        self.selectIn = CheckBox(
            parent=panel,
            id=wx.ID_ANY,
            label=_("Select only features inside of selection bounding box"),
        )
        self.selectIn.SetValue(
            UserSettings.Get(group="vdigit",
                             key="selectInside",
                             subkey="enabled"))
        self.selectIn.SetToolTip(
            _("By default are selected all features overlapping selection bounding box "
              ))

        self.checkForDupl = CheckBox(parent=panel,
                                     id=wx.ID_ANY,
                                     label=_("Check for duplicates"))
        self.checkForDupl.SetValue(
            UserSettings.Get(group="vdigit",
                             key="checkForDupl",
                             subkey="enabled"))

        sizer.Add(flexSizer, proportion=0, flag=wx.EXPAND)
        sizer.Add(self.selectIn,
                  proportion=0,
                  flag=wx.EXPAND | wx.ALL,
                  border=1)
        sizer.Add(self.checkForDupl,
                  proportion=0,
                  flag=wx.EXPAND | wx.ALL,
                  border=1)
        border.Add(
            sizer,
            proportion=0,
            flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
            border=5,
        )

        #
        # digitize lines box
        #
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Digitize lines/boundaries"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)

        self.intersect = CheckBox(parent=panel,
                                  label=_("Break lines at intersection"))
        self.intersect.SetValue(
            UserSettings.Get(group="vdigit",
                             key="breakLines",
                             subkey="enabled"))

        sizer.Add(self.intersect,
                  proportion=0,
                  flag=wx.ALL | wx.EXPAND,
                  border=1)

        border.Add(
            sizer,
            proportion=0,
            flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
            border=5,
        )

        #
        # digitize areas box
        #
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Digitize areas"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)

        self.closeBoundary = CheckBox(
            parent=panel, label=_("Close boundary (snap to the start node)"))
        self.closeBoundary.SetValue(
            UserSettings.Get(group="vdigit",
                             key="closeBoundary",
                             subkey="enabled"))

        sizer.Add(self.closeBoundary,
                  proportion=0,
                  flag=wx.ALL | wx.EXPAND,
                  border=1)

        border.Add(
            sizer,
            proportion=0,
            flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
            border=5,
        )

        #
        # save-on-exit box
        #
        box = StaticBox(parent=panel,
                        id=wx.ID_ANY,
                        label=" %s " % _("Save changes"))
        # save changes on exit?
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        self.save = CheckBox(parent=panel, label=_("Save changes on exit"))
        self.save.SetValue(
            UserSettings.Get(group="vdigit",
                             key="saveOnExit",
                             subkey="enabled"))
        sizer.Add(self.save, proportion=0, flag=wx.ALL | wx.EXPAND, border=1)
        border.Add(
            sizer,
            proportion=0,
            flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
            border=5,
        )

        panel.SetSizer(border)

        return panel
Beispiel #14
0
    def __init__(self, parent, *args, **kwargs):
        wx.Panel.__init__(self, parent, *args, **kwargs)

        self.parent = parent

        self.VariogramSizer = wx.StaticBoxSizer(
            wx.StaticBox(self, id=wx.ID_ANY, label=_("Variogram fitting")),
            wx.HORIZONTAL,
        )
        self.LeftSizer = wx.BoxSizer(wx.VERTICAL)
        self.RightSizer = wx.BoxSizer(wx.VERTICAL)
        self.ParametersSizer = wx.GridBagSizer(vgap=5, hgap=5)

        self.VariogramSizer.Add(self.LeftSizer,
                                proportion=0,
                                flag=wx.EXPAND | wx.ALL,
                                border=parent.border)
        self.VariogramSizer.Add(self.RightSizer,
                                proportion=0,
                                flag=wx.EXPAND | wx.ALL,
                                border=parent.border)

        # left side of Variogram fitting. The checkboxes and spinctrls.
        # no stock ID for Run button..
        self.PlotButton = wx.Button(self,
                                    id=wx.ID_ANY,
                                    label=_("Plot/refresh variogram"))
        self.PlotButton.Bind(wx.EVT_BUTTON, self.OnPlotButton)
        # grey it out until a suitable layer is available
        self.PlotButton.Enable(False)
        self.LeftSizer.Add(self.PlotButton,
                           proportion=0,
                           flag=wx.ALL,
                           border=parent.border)
        self.LeftSizer.Add(
            self.ParametersSizer,
            proportion=0,
            flag=wx.EXPAND | wx.ALL,
            border=parent.border,
        )

        self.ParametersList = ["Psill", "Nugget", "Range", "Kappa"]
        MinValues = [0, 0, 0.01, 0.01]
        InitialValues = [1, 0, 1, 0.5]
        for n in self.ParametersList:
            setattr(
                self,
                n + "ChextBox",
                wx.CheckBox(self,
                            id=self.ParametersList.index(n),
                            label=_(n + ":")),
            )
            setattr(
                self,
                n + "Ctrl",
                (wx.SpinCtrlDouble(
                    self,
                    id=wx.ID_ANY,
                    min=MinValues[self.ParametersList.index(n)],
                    max=maxint,
                    inc=0.1,
                    initial=InitialValues[self.ParametersList.index(n)],
                )),
            )
            getattr(self, n + "ChextBox").Bind(wx.EVT_CHECKBOX,
                                               self.UseValue,
                                               id=self.ParametersList.index(n))
            setattr(self, n + "Sizer", (wx.BoxSizer(wx.HORIZONTAL)))
            self.ParametersSizer.Add(
                getattr(self, n + "ChextBox"),
                flag=wx.ALIGN_CENTER_VERTICAL,
                pos=(self.ParametersList.index(n), 0),
            )
            self.ParametersSizer.Add(
                getattr(self, n + "Ctrl"),
                flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL,
                pos=(self.ParametersList.index(n), 1),
            )

        # right side of the Variogram fitting. The plot area.
        # Plot = wx.StaticText(self, id= wx.ID_ANY, label = "Check Plot Variogram to interactively fit model.")
        # PlotPanel = wx.Panel(self)
        # self.PlotArea = plot.PlotCanvas(PlotPanel)
        # self.PlotArea.SetInitialSize(size = (250,250))
        # self.RightSizer.Add(PlotPanel, proportion=0, flag= wx.EXPAND|wx.ALL, border=parent.border)

        self.KrigingSizer = wx.StaticBoxSizer(
            wx.StaticBox(self, id=wx.ID_ANY, label=_("Kriging techniques")),
            wx.VERTICAL)

        # , "Universal kriging"] #@FIXME: i18n on the list?
        KrigingList = ["Ordinary kriging", "Block kriging"]
        self.KrigingRadioBox = wx.RadioBox(
            self,
            id=wx.ID_ANY,
            choices=KrigingList,
            majorDimension=1,
            style=wx.RA_SPECIFY_COLS,
        )
        self.KrigingRadioBox.Bind(wx.EVT_RADIOBOX, self.HideBlockOptions)
        self.KrigingSizer.Add(
            self.KrigingRadioBox,
            proportion=0,
            flag=wx.EXPAND | wx.ALL,
            border=parent.border,
        )

        # block kriging parameters. Size.
        BlockSizer = wx.BoxSizer(wx.HORIZONTAL)
        BlockLabel = wx.StaticText(self, id=wx.ID_ANY, label=_("Block size:"))
        self.BlockSpinBox = SpinCtrl(self, id=wx.ID_ANY, min=1, max=maxint)
        # default choice is Ordinary kriging so block param is disabled
        self.BlockSpinBox.Enable(False)
        BlockSizer.Add(BlockLabel,
                       flag=wx.ALIGN_CENTER_VERTICAL | wx.ALL,
                       border=parent.border)
        BlockSizer.Add(
            self.BlockSpinBox,
            flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
            border=parent.border,
        )
        self.KrigingSizer.Add(
            BlockSizer,
            flag=wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
            border=parent.border,
        )

        self.Sizer = wx.BoxSizer(wx.VERTICAL)
        self.Sizer.Add(
            self.VariogramSizer,
            proportion=0,
            flag=wx.EXPAND | wx.ALL,
            border=parent.border,
        )
        self.Sizer.Add(
            self.KrigingSizer,
            proportion=0,
            flag=wx.EXPAND | wx.ALL,
            border=parent.border,
        )
Beispiel #15
0
    def __init__(self, parent, title, nselected,
                 style=wx.DEFAULT_DIALOG_STYLE):
        """Dialog used for Z bulk-labeling tool
        """
        wx.Dialog.__init__(
            self,
            parent=parent,
            id=wx.ID_ANY,
            title=title,
            style=style)

        self.parent = parent  # map window class instance

        # panel  = wx.Panel(parent=self, id=wx.ID_ANY)

        border = wx.BoxSizer(wx.VERTICAL)

        txt = wx.StaticText(
            parent=self,
            label=_("%d lines selected for z bulk-labeling") %
            nselected)
        border.Add(item=txt, proportion=0, flag=wx.ALL | wx.EXPAND, border=5)

        box = wx.StaticBox(
            parent=self,
            id=wx.ID_ANY,
            label=" %s " %
            _("Set value"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        flexSizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
        flexSizer.AddGrowableCol(0)

        # starting value
        txt = wx.StaticText(parent=self,
                            label=_("Starting value"))
        self.value = SpinCtrl(parent=self, id=wx.ID_ANY, size=(150, -1),
                                 initial=0,
                                 min=-1e6, max=1e6)
        flexSizer.Add(txt, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(
            self.value,
            proportion=0,
            flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)

        # step
        txt = wx.StaticText(parent=self,
                            label=_("Step"))
        self.step = SpinCtrl(parent=self, id=wx.ID_ANY, size=(150, -1),
                                initial=0,
                                min=0, max=1e6)
        flexSizer.Add(txt, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
        flexSizer.Add(
            self.step,
            proportion=0,
            flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)

        sizer.Add(
            item=flexSizer,
            proportion=1,
            flag=wx.ALL | wx.EXPAND,
            border=1)
        border.Add(item=sizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=0)

        # buttons
        btnCancel = wx.Button(self, wx.ID_CANCEL)
        btnOk = wx.Button(self, wx.ID_OK)
        btnOk.SetDefault()

        # sizers
        btnSizer = wx.StdDialogButtonSizer()
        btnSizer.AddButton(btnCancel)
        btnSizer.AddButton(btnOk)
        btnSizer.Realize()

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(
            item=border,
            proportion=1,
            flag=wx.EXPAND | wx.ALL,
            border=5)
        mainSizer.Add(item=btnSizer, proportion=0,
                      flag=wx.EXPAND | wx.ALL | wx.ALIGN_CENTER, border=5)

        self.SetSizer(mainSizer)
        mainSizer.Fit(self)
Beispiel #16
0
    def _createViewPage(self, notebook):
        """Create notebook page for view settings"""
        panel = wx.Panel(parent=notebook, id=wx.ID_ANY)

        notebook.AddPage(page=panel,
                         text=" %s " % _("View"))

        pageSizer = wx.BoxSizer(wx.VERTICAL)

        box = wx.StaticBox(parent=panel, id=wx.ID_ANY,
                           label=" %s " % (_("View")))
        boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        gridSizer = wx.GridBagSizer(vgap=3, hgap=3)
        row = 0
        # perspective
        pvals = UserSettings.Get(group='nviz', key='view', subkey='persp')
        ipvals = UserSettings.Get(
            group='nviz',
            key='view',
            subkey='persp',
            settings_type='internal')
        gridSizer.Add(wx.StaticText(parent=panel, id=wx.ID_ANY,
                                    label=_("Perspective:")),
                      pos=(row, 0), flag=wx.ALIGN_CENTER_VERTICAL)
        gridSizer.Add(
            wx.StaticText(
                parent=panel, id=wx.ID_ANY, label=_("value:")), pos=(
                row, 1), flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)

        pval = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
                        initial=pvals['value'],
                        min=ipvals['min'],
                        max=ipvals['max'])
        self.winId['nviz:view:persp:value'] = pval.GetId()
        gridSizer.Add(pval, pos=(row, 2),
                      flag=wx.ALIGN_CENTER_VERTICAL)

        gridSizer.Add(
            wx.StaticText(
                parent=panel, id=wx.ID_ANY, label=_("step:")), pos=(
                row, 3), flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)

        pstep = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
                         initial=pvals['step'],
                         min=ipvals['min'],
                         max=ipvals['max'] - 1)
        self.winId['nviz:view:persp:step'] = pstep.GetId()
        gridSizer.Add(pstep, pos=(row, 4),
                      flag=wx.ALIGN_CENTER_VERTICAL)
        row += 1

        # position
        posvals = UserSettings.Get(group='nviz', key='view', subkey='position')
        gridSizer.Add(wx.StaticText(parent=panel, id=wx.ID_ANY,
                                    label=_("Position:")),
                      pos=(row, 0), flag=wx.ALIGN_CENTER_VERTICAL)
        gridSizer.Add(
            wx.StaticText(
                parent=panel, id=wx.ID_ANY, label=_("x:")), pos=(
                row, 1), flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)

        px = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
                      initial=posvals['x'] * 100,
                      min=0,
                      max=100)
        self.winId['nviz:view:position:x'] = px.GetId()
        gridSizer.Add(px, pos=(row, 2),
                      flag=wx.ALIGN_CENTER_VERTICAL)

        gridSizer.Add(
            wx.StaticText(
                parent=panel, id=wx.ID_ANY, label="y:"), pos=(
                row, 3), flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)

        py = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
                      initial=posvals['y'] * 100,
                      min=0,
                      max=100)
        self.winId['nviz:view:position:y'] = py.GetId()
        gridSizer.Add(py, pos=(row, 4),
                      flag=wx.ALIGN_CENTER_VERTICAL)
        row += 1

        # height is computed dynamically

        # twist
        tvals = UserSettings.Get(group='nviz', key='view', subkey='twist')
        itvals = UserSettings.Get(
            group='nviz',
            key='view',
            subkey='twist',
            settings_type='internal')
        gridSizer.Add(wx.StaticText(parent=panel, id=wx.ID_ANY,
                                    label=_("Twist:")),
                      pos=(row, 0), flag=wx.ALIGN_CENTER_VERTICAL)
        gridSizer.Add(
            wx.StaticText(
                parent=panel, id=wx.ID_ANY, label=_("value:")), pos=(
                row, 1), flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)

        tval = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
                        initial=tvals['value'],
                        min=itvals['min'],
                        max=itvals['max'])
        self.winId['nviz:view:twist:value'] = tval.GetId()
        gridSizer.Add(tval, pos=(row, 2),
                      flag=wx.ALIGN_CENTER_VERTICAL)
        row += 1

        # z-exag
        zvals = UserSettings.Get(group='nviz', key='view', subkey='z-exag')
        gridSizer.Add(wx.StaticText(parent=panel, id=wx.ID_ANY,
                                    label=_("Z-exag:")),
                      pos=(row, 0), flag=wx.ALIGN_CENTER_VERTICAL)
        gridSizer.Add(
            wx.StaticText(
                parent=panel, id=wx.ID_ANY, label=_("value:")), pos=(
                row, 1), flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)

        zval = SpinCtrl(parent=panel, id=wx.ID_ANY, size=(65, -1),
                        initial=zvals['value'],
                        min=-1e6,
                        max=1e6)
        self.winId['nviz:view:z-exag:value'] = zval.GetId()
        gridSizer.Add(zval, pos=(row, 2),
                      flag=wx.ALIGN_CENTER_VERTICAL)

        boxSizer.Add(gridSizer, proportion=1,
                     flag=wx.ALL | wx.EXPAND, border=3)
        pageSizer.Add(boxSizer, proportion=0,
                      flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
                      border=3)

        box = wx.StaticBox(parent=panel, id=wx.ID_ANY,
                           label=" %s " % (_("Image Appearance")))
        boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        gridSizer = wx.GridBagSizer(vgap=3, hgap=3)

        # background color
        gridSizer.Add(wx.StaticText(parent=panel, id=wx.ID_ANY,
                                    label=_("Background color:")),
                      pos=(0, 0), flag=wx.ALIGN_CENTER_VERTICAL)

        color = csel.ColourSelect(
            panel,
            id=wx.ID_ANY,
            colour=UserSettings.Get(
                group='nviz',
                key='view',
                subkey=[
                    'background',
                    'color']),
            size=globalvar.DIALOG_COLOR_SIZE)
        color.SetName('GetColour')
        self.winId['nviz:view:background:color'] = color.GetId()
        gridSizer.Add(color, pos=(0, 1))

        gridSizer.AddGrowableCol(0)
        boxSizer.Add(gridSizer, proportion=1,
                     flag=wx.ALL | wx.EXPAND, border=5)
        pageSizer.Add(boxSizer, proportion=0,
                      flag=wx.EXPAND | wx.ALL,
                      border=5)

        panel.SetSizer(pageSizer)

        return panel
Beispiel #17
0
    def _advancedSettsPage(self):
        """Create advanced settings page
        """
        # TODO parse maxcol, maxrow, settings from d.wms module?
        # TODO OnEarth driver - add selection of time
        adv_setts_panel = wx.Panel(parent=self, id=wx.ID_ANY)
        self.notebook.AddPage(page=adv_setts_panel,
                              text=_('Advanced request settings'),
                              name='adv_req_setts')

        labels = {}
        self.l_odrder_list = None
        if 'WMS' in self.ws:
            labels['l_order'] = StaticBox(parent=adv_setts_panel,
                                          id=wx.ID_ANY,
                                          label=_("Order of layers in raster"))
            self.l_odrder_list = wx.ListBox(adv_setts_panel,
                                            id=wx.ID_ANY,
                                            choices=[],
                                            style=wx.LB_SINGLE
                                            | wx.LB_NEEDED_SB)
            self.btnUp = Button(adv_setts_panel, id=wx.ID_ANY, label=_("Up"))
            self.btnDown = Button(adv_setts_panel,
                                  id=wx.ID_ANY,
                                  label=_("Down"))

            self.btnUp.Bind(wx.EVT_BUTTON, self.OnUp)
            self.btnDown.Bind(wx.EVT_BUTTON, self.OnDown)

        labels['method'] = StaticText(parent=adv_setts_panel,
                                      id=wx.ID_ANY,
                                      label=_("Reprojection method:"))

        self.reproj_methods = ['nearest', 'linear', 'cubic', 'cubicspline']
        self.params['method'] = wx.Choice(parent=adv_setts_panel,
                                          id=wx.ID_ANY,
                                          choices=[
                                              _('Nearest neighbor'),
                                              _('Linear interpolation'),
                                              _('Cubic interpolation'),
                                              _('Cubic spline interpolation')
                                          ])

        labels['maxcols'] = StaticText(
            parent=adv_setts_panel,
            id=wx.ID_ANY,
            label=_("Maximum columns to request from server at time:"))
        self.params['maxcols'] = SpinCtrl(parent=adv_setts_panel,
                                          id=wx.ID_ANY,
                                          size=(100, -1))

        labels['maxrows'] = StaticText(
            parent=adv_setts_panel,
            id=wx.ID_ANY,
            label=_("Maximum rows to request from server at time:"))
        self.params['maxrows'] = SpinCtrl(parent=adv_setts_panel,
                                          id=wx.ID_ANY,
                                          size=(100, -1))

        min = 100
        max = 10000
        self.params['maxcols'].SetRange(min, max)
        self.params['maxrows'].SetRange(min, max)

        val = 500
        self.params['maxcols'].SetValue(val)
        self.params['maxrows'].SetValue(val)

        self.flags['o'] = self.params['bgcolor'] = None
        if not 'o' in self.drv_props['ignored_flags']:
            self.flags['o'] = wx.CheckBox(
                parent=adv_setts_panel,
                id=wx.ID_ANY,
                label=_("Do not request transparent data"))

            self.flags['o'].Bind(wx.EVT_CHECKBOX, self.OnTransparent)
            labels['bgcolor'] = StaticText(parent=adv_setts_panel,
                                           id=wx.ID_ANY,
                                           label=_("Background color:"))
            self.params['bgcolor'] = csel.ColourSelect(
                parent=adv_setts_panel,
                id=wx.ID_ANY,
                colour=(255, 255, 255),
                size=globalvar.DIALOG_COLOR_SIZE)
            self.params['bgcolor'].Enable(False)

        self.params['urlparams'] = None
        if self.params['urlparams'] not in self.drv_props['ignored_params']:
            labels['urlparams'] = StaticText(
                parent=adv_setts_panel,
                id=wx.ID_ANY,
                label=_("Additional query parameters for server:"))
            self.params['urlparams'] = TextCtrl(parent=adv_setts_panel,
                                                id=wx.ID_ANY)

        # layout

        border = wx.BoxSizer(wx.VERTICAL)

        if 'WMS' in self.ws:

            boxSizer = wx.StaticBoxSizer(labels['l_order'], wx.VERTICAL)
            gridSizer = wx.GridBagSizer(hgap=3, vgap=3)

            gridSizer.Add(self.l_odrder_list,
                          pos=(0, 0),
                          span=(4, 1),
                          flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
                          border=0)

            gridSizer.Add(self.btnUp,
                          pos=(0, 1),
                          flag=wx.ALIGN_CENTER_VERTICAL,
                          border=0)

            gridSizer.Add(self.btnDown,
                          pos=(1, 1),
                          flag=wx.ALIGN_CENTER_VERTICAL,
                          border=0)

            gridSizer.AddGrowableCol(0)
            boxSizer.Add(gridSizer, flag=wx.EXPAND | wx.ALL, border=5)

            border.Add(boxSizer,
                       flag=wx.LEFT | wx.RIGHT | wx.UP | wx.EXPAND,
                       border=5)

        gridSizer = wx.GridBagSizer(hgap=3, vgap=3)

        row = 0
        for k in ['method', 'maxcols', 'maxrows', 'o', 'bgcolor']:

            if k in self.params:
                param = self.params[k]
            elif k in self.flags:
                param = self.flags[k]

            if param is None:
                continue

            if k in labels or k == 'o':
                if k != 'o':
                    label = labels[k]
                else:
                    label = param

                gridSizer.Add(label,
                              flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
                              pos=(row, 0))

            if k != 'o':
                gridSizer.Add(param,
                              flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL,
                              pos=(row, 1))
            row += 1

        gridSizer.AddGrowableCol(0)
        border.Add(gridSizer,
                   flag=wx.LEFT | wx.RIGHT | wx.TOP | wx.EXPAND,
                   border=5)

        if self.params['urlparams']:
            gridSizer = wx.GridBagSizer(hgap=3, vgap=3)

            row = 0
            gridSizer.Add(labels['urlparams'],
                          flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
                          pos=(row, 0))

            gridSizer.Add(self.params['urlparams'],
                          flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL
                          | wx.EXPAND,
                          pos=(row, 1))

            gridSizer.AddGrowableCol(1)

            border.Add(gridSizer,
                       flag=wx.LEFT | wx.RIGHT | wx.TOP | wx.EXPAND,
                       border=5)

        adv_setts_panel.SetSizer(border)
Beispiel #18
0
    def _createLightPage(self, notebook):
        """Create notebook page for light settings"""
        panel = wx.Panel(parent=notebook, id=wx.ID_ANY)

        notebook.AddPage(page=panel, text=" %s " % _("Lighting"))

        pageSizer = wx.BoxSizer(wx.VERTICAL)

        box = StaticBox(parent=panel, id=wx.ID_ANY, label=" %s " % (_("Light")))
        boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        gridSizer = wx.GridBagSizer(vgap=3, hgap=3)

        # position
        posvals = UserSettings.Get(group="nviz", key="light", subkey="position")
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("Position:")),
            pos=(0, 0),
            flag=wx.ALIGN_CENTER_VERTICAL,
        )
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("x:")),
            pos=(0, 1),
            flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT,
        )

        px = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            size=(65, -1),
            initial=posvals["x"] * 100,
            min=-100,
            max=100,
        )
        self.winId["nviz:light:position:x"] = px.GetId()
        gridSizer.Add(px, pos=(0, 2), flag=wx.ALIGN_CENTER_VERTICAL)

        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label="y:"),
            pos=(0, 3),
            flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT,
        )

        py = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            size=(65, -1),
            initial=posvals["y"] * 100,
            min=-100,
            max=100,
        )
        self.winId["nviz:light:position:y"] = py.GetId()
        gridSizer.Add(py, pos=(0, 4), flag=wx.ALIGN_CENTER_VERTICAL)

        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("z:")),
            pos=(0, 5),
            flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT,
        )

        pz = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            size=(65, -1),
            initial=posvals["z"],
            min=0,
            max=100,
        )
        self.winId["nviz:light:position:z"] = pz.GetId()
        gridSizer.Add(pz, pos=(0, 6), flag=wx.ALIGN_CENTER_VERTICAL)

        # brightness
        brightval = UserSettings.Get(group="nviz", key="light", subkey="bright")
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("Brightness:")),
            pos=(1, 0),
            flag=wx.ALIGN_CENTER_VERTICAL,
        )

        bright = SpinCtrl(
            parent=panel, id=wx.ID_ANY, size=(65, -1), initial=brightval, min=0, max=100
        )
        self.winId["nviz:light:bright"] = bright.GetId()
        gridSizer.Add(bright, pos=(1, 2), flag=wx.ALIGN_CENTER_VERTICAL)

        # ambient
        ambval = UserSettings.Get(group="nviz", key="light", subkey="ambient")
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("Ambient:")),
            pos=(2, 0),
            flag=wx.ALIGN_CENTER_VERTICAL,
        )

        amb = SpinCtrl(
            parent=panel, id=wx.ID_ANY, size=(65, -1), initial=ambval, min=0, max=100
        )
        self.winId["nviz:light:ambient"] = amb.GetId()
        gridSizer.Add(amb, pos=(2, 2), flag=wx.ALIGN_CENTER_VERTICAL)

        # light color
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("Color:")),
            pos=(3, 0),
            flag=wx.ALIGN_CENTER_VERTICAL,
        )

        color = csel.ColourSelect(
            panel,
            id=wx.ID_ANY,
            colour=UserSettings.Get(group="nviz", key="light", subkey="color"),
            size=globalvar.DIALOG_COLOR_SIZE,
        )
        color.SetName("GetColour")
        self.winId["nviz:light:color"] = color.GetId()
        gridSizer.Add(color, pos=(3, 2))

        boxSizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
        pageSizer.Add(boxSizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)

        panel.SetSizer(pageSizer)

        return panel
Beispiel #19
0
class SbGoToGCP(SbItem):
    """SpinCtrl to select GCP to focus on

    Requires MapFrame.GetSrcWindow, MapFrame.GetTgtWindow,
    MapFrame.GetListCtrl, MapFrame.GetMapCoordList.
    """
    def __init__(self, mapframe, statusbar, position=0):
        SbItem.__init__(self, mapframe, statusbar, position)
        self.name = 'gotoGCP'
        self.label = _("Go to GCP No.")

        self.widget = SpinCtrl(parent=self.statusbar,
                               id=wx.ID_ANY,
                               value="",
                               min=0)
        self.widget.Hide()

        self.widget.Bind(wx.EVT_TEXT_ENTER, self.OnGoToGCP)
        self.widget.Bind(wx.EVT_SPINCTRL, self.OnGoToGCP)

    def OnGoToGCP(self, event):
        """Zooms to given GCP."""
        gcpNumber = self.GetValue()
        mapCoords = self.mapFrame.GetMapCoordList()

        # always false, spin checks it
        if gcpNumber < 0 or gcpNumber > len(mapCoords):
            GMessage(parent=self,
                     message="%s 1 - %s." %
                     (_("Valid Range:"), len(mapCoords)))
            return

        if gcpNumber == 0:
            return

        listCtrl = self.mapFrame.GetListCtrl()

        listCtrl.selectedkey = gcpNumber
        listCtrl.selected = listCtrl.FindItemData(-1, gcpNumber)
        listCtrl.render = False
        listCtrl.SetItemState(listCtrl.selected, wx.LIST_STATE_SELECTED,
                              wx.LIST_STATE_SELECTED)
        listCtrl.render = True

        listCtrl.EnsureVisible(listCtrl.selected)

        srcWin = self.mapFrame.GetSrcWindow()
        tgtWin = self.mapFrame.GetTgtWindow()

        # Source MapWindow:
        begin = (mapCoords[gcpNumber][1], mapCoords[gcpNumber][2])
        begin = srcWin.Cell2Pixel(begin)
        end = begin
        srcWin.Zoom(begin, end, 0)

        # redraw map
        srcWin.UpdateMap()

        if self.mapFrame.GetShowTarget():
            # Target MapWindow:
            begin = (mapCoords[gcpNumber][3], mapCoords[gcpNumber][4])
            begin = tgtWin.Cell2Pixel(begin)
            end = begin
            tgtWin.Zoom(begin, end, 0)

            # redraw map
            tgtWin.UpdateMap()

        self.GetWidget().SetFocus()

    def Update(self):
        """Checks the number of items in the gcp list
        and sets the spin limits accordingly."""
        self.statusbar.SetStatusText("")
        maximum = self.mapFrame.GetListCtrl().GetItemCount()
        if maximum < 1:
            maximum = 1
        self.widget.SetRange(0, maximum)
        self.Show()

        # disable long help
        self.mapFrame.StatusbarEnableLongHelp(False)
Beispiel #20
0
    def _createSurfacePage(self, notebook):
        """Create notebook page for surface settings"""
        panel = wx.Panel(parent=notebook, id=wx.ID_ANY)

        notebook.AddPage(page=panel, text=" %s " % _("Surface"))

        pageSizer = wx.BoxSizer(wx.VERTICAL)

        # draw

        box = StaticBox(parent=panel, id=wx.ID_ANY, label=" %s " % (_("Draw")))
        boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
        gridSizer = wx.GridBagSizer(vgap=3, hgap=3)

        # mode
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("Mode:")),
            flag=wx.ALIGN_CENTER_VERTICAL,
            pos=(0, 0),
        )
        mode = wx.Choice(
            parent=panel,
            id=wx.ID_ANY,
            size=(-1, -1),
            choices=[_("coarse"), _("fine"), _("both")],
        )
        self.winId["nviz:surface:draw:mode"] = mode.GetId()
        mode.SetName("GetSelection")
        mode.SetSelection(
            UserSettings.Get(group="nviz", key="surface", subkey=["draw", "mode"])
        )
        gridSizer.Add(mode, flag=wx.ALIGN_CENTER_VERTICAL, pos=(0, 1))

        # fine
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("Fine mode:")),
            flag=wx.ALIGN_CENTER_VERTICAL,
            pos=(1, 0),
        )
        res = UserSettings.Get(group="nviz", key="surface", subkey=["draw", "res-fine"])
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("resolution:")),
            flag=wx.ALIGN_CENTER_VERTICAL,
            pos=(1, 1),
        )
        fine = SpinCtrl(
            parent=panel, id=wx.ID_ANY, size=(65, -1), initial=res, min=1, max=100
        )
        self.winId["nviz:surface:draw:res-fine"] = fine.GetId()

        gridSizer.Add(fine, flag=wx.ALIGN_CENTER_VERTICAL, pos=(1, 2))

        # coarse
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("Coarse mode:")),
            flag=wx.ALIGN_CENTER_VERTICAL,
            pos=(2, 0),
        )
        res = UserSettings.Get(
            group="nviz", key="surface", subkey=["draw", "res-coarse"]
        )
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("resolution:")),
            flag=wx.ALIGN_CENTER_VERTICAL,
            pos=(2, 1),
        )
        coarse = SpinCtrl(
            parent=panel, id=wx.ID_ANY, size=(65, -1), initial=res, min=1, max=100
        )
        self.winId["nviz:surface:draw:res-coarse"] = coarse.GetId()

        gridSizer.Add(coarse, flag=wx.ALIGN_CENTER_VERTICAL, pos=(2, 2))
        # style
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("style:")),
            flag=wx.ALIGN_CENTER_VERTICAL,
            pos=(3, 1),
        )
        style = wx.Choice(
            parent=panel, id=wx.ID_ANY, size=(-1, -1), choices=[_("wire"), _("surface")]
        )
        self.winId["nviz:surface:draw:style"] = style.GetId()
        style.SetName("GetSelection")
        style.SetSelection(
            UserSettings.Get(group="nviz", key="surface", subkey=["draw", "style"])
        )
        self.winId["nviz:surface:draw:style"] = style.GetId()

        gridSizer.Add(style, flag=wx.ALIGN_CENTER_VERTICAL, pos=(3, 2))
        # wire color
        gridSizer.Add(
            StaticText(parent=panel, id=wx.ID_ANY, label=_("wire color:")),
            flag=wx.ALIGN_CENTER_VERTICAL,
            pos=(4, 1),
        )
        color = csel.ColourSelect(
            panel,
            id=wx.ID_ANY,
            colour=UserSettings.Get(
                group="nviz", key="surface", subkey=["draw", "wire-color"]
            ),
            size=globalvar.DIALOG_COLOR_SIZE,
        )
        color.SetName("GetColour")
        self.winId["nviz:surface:draw:wire-color"] = color.GetId()
        gridSizer.Add(color, flag=wx.ALIGN_CENTER_VERTICAL, pos=(4, 2))

        boxSizer.Add(gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
        pageSizer.Add(
            boxSizer,
            proportion=0,
            flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
            border=5,
        )

        panel.SetSizer(pageSizer)

        return panel
Beispiel #21
0
    def _createActionPage(self, notebook):
        """Create notebook page for action settings"""
        panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
        notebook.AddPage(page=panel, text=_("Command"))

        # colors
        border = wx.BoxSizer(wx.VERTICAL)
        box = StaticBox(parent=panel, id=wx.ID_ANY,
                        label=" %s " % _("Color"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)

        gridSizer = wx.GridBagSizer(hgap=3, vgap=3)

        row = 0
        gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY,
                                 label=_("Valid:")),
                      flag=wx.ALIGN_LEFT |
                      wx.ALIGN_CENTER_VERTICAL,
                      pos=(row, 0))
        vColor = csel.ColourSelect(
            parent=panel, id=wx.ID_ANY, colour=self.settings.Get(
                group='modeler', key='action', subkey=(
                    'color', 'valid')), size=globalvar.DIALOG_COLOR_SIZE)
        vColor.SetName('GetColour')
        self.winId['modeler:action:color:valid'] = vColor.GetId()

        gridSizer.Add(vColor,
                      flag=wx.ALIGN_RIGHT |
                      wx.ALIGN_CENTER_VERTICAL,
                      pos=(row, 1))

        row += 1
        gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY,
                                 label=_("Invalid:")),
                      flag=wx.ALIGN_LEFT |
                      wx.ALIGN_CENTER_VERTICAL,
                      pos=(row, 0))
        iColor = csel.ColourSelect(
            parent=panel, id=wx.ID_ANY, colour=self.settings.Get(
                group='modeler', key='action', subkey=(
                    'color', 'invalid')), size=globalvar.DIALOG_COLOR_SIZE)
        iColor.SetName('GetColour')
        self.winId['modeler:action:color:invalid'] = iColor.GetId()

        gridSizer.Add(iColor,
                      flag=wx.ALIGN_RIGHT |
                      wx.ALIGN_CENTER_VERTICAL,
                      pos=(row, 1))

        row += 1
        gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY,
                                 label=_("Running:")),
                      flag=wx.ALIGN_LEFT |
                      wx.ALIGN_CENTER_VERTICAL,
                      pos=(row, 0))
        rColor = csel.ColourSelect(
            parent=panel, id=wx.ID_ANY, colour=self.settings.Get(
                group='modeler', key='action', subkey=(
                    'color', 'running')), size=globalvar.DIALOG_COLOR_SIZE)
        rColor.SetName('GetColour')
        self.winId['modeler:action:color:running'] = rColor.GetId()

        gridSizer.Add(rColor,
                      flag=wx.ALIGN_RIGHT |
                      wx.ALIGN_CENTER_VERTICAL,
                      pos=(row, 1))

        gridSizer.AddGrowableCol(0)
        sizer.Add(
            gridSizer,
            proportion=1,
            flag=wx.ALL | wx.EXPAND,
            border=5)
        border.Add(sizer, proportion=0, flag=wx.LEFT |
                   wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)

        # size
        box = StaticBox(parent=panel, id=wx.ID_ANY,
                        label=" %s " % _("Shape size"))
        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)

        gridSizer = wx.GridBagSizer(hgap=3, vgap=3)

        row = 0
        gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY,
                                 label=_("Width:")),
                      flag=wx.ALIGN_LEFT |
                      wx.ALIGN_CENTER_VERTICAL,
                      pos=(row, 0))

        width = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            min=0,
            max=500,
            initial=self.settings.Get(
                group='modeler',
                key='action',
                subkey=(
                    'size',
                    'width')))
        width.SetName('GetValue')
        self.winId['modeler:action:size:width'] = width.GetId()

        gridSizer.Add(width,
                      flag=wx.ALIGN_RIGHT |
                      wx.ALIGN_CENTER_VERTICAL,
                      pos=(row, 1))

        row += 1
        gridSizer.Add(StaticText(parent=panel, id=wx.ID_ANY,
                                 label=_("Height:")),
                      flag=wx.ALIGN_LEFT |
                      wx.ALIGN_CENTER_VERTICAL,
                      pos=(row, 0))

        height = SpinCtrl(
            parent=panel,
            id=wx.ID_ANY,
            min=0,
            max=500,
            initial=self.settings.Get(
                group='modeler',
                key='action',
                subkey=(
                    'size',
                    'height')))
        height.SetName('GetValue')
        self.winId['modeler:action:size:height'] = height.GetId()

        gridSizer.Add(height,
                      flag=wx.ALIGN_RIGHT |
                      wx.ALIGN_CENTER_VERTICAL,
                      pos=(row, 1))

        gridSizer.AddGrowableCol(0)
        sizer.Add(
            gridSizer,
            proportion=1,
            flag=wx.ALL | wx.EXPAND,
            border=5)
        border.Add(sizer, proportion=0, flag=wx.LEFT |
                   wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)

        panel.SetSizer(border)

        return panel
Beispiel #22
0
    def _advancedSettsPage(self):
        """Create advanced settings page"""
        # TODO parse maxcol, maxrow, settings from d.wms module?
        # TODO OnEarth driver - add selection of time
        adv_setts_panel = ScrolledPanel(
            parent=self, id=wx.ID_ANY, style=wx.TAB_TRAVERSAL | wx.SUNKEN_BORDER
        )
        self.notebook.AddPage(
            page=adv_setts_panel,
            text=_("Advanced request settings"),
            name="adv_req_setts",
        )

        labels = {}
        self.l_odrder_list = None
        if "WMS" in self.ws:
            labels["l_order"] = StaticBox(
                parent=adv_setts_panel,
                id=wx.ID_ANY,
                label=_("Order of layers in raster"),
            )
            self.l_odrder_list = wx.ListBox(
                adv_setts_panel,
                id=wx.ID_ANY,
                choices=[],
                style=wx.LB_SINGLE | wx.LB_NEEDED_SB,
            )
            self.btnUp = Button(adv_setts_panel, id=wx.ID_ANY, label=_("Up"))
            self.btnDown = Button(adv_setts_panel, id=wx.ID_ANY, label=_("Down"))

            self.btnUp.Bind(wx.EVT_BUTTON, self.OnUp)
            self.btnDown.Bind(wx.EVT_BUTTON, self.OnDown)

        labels["method"] = StaticText(
            parent=adv_setts_panel, id=wx.ID_ANY, label=_("Reprojection method:")
        )

        self.reproj_methods = ["nearest", "linear", "cubic", "cubicspline"]
        self.params["method"] = wx.Choice(
            parent=adv_setts_panel,
            id=wx.ID_ANY,
            choices=[
                _("Nearest neighbor"),
                _("Linear interpolation"),
                _("Cubic interpolation"),
                _("Cubic spline interpolation"),
            ],
        )

        labels["maxcols"] = StaticText(
            parent=adv_setts_panel,
            id=wx.ID_ANY,
            label=_("Maximum columns to request from server at time:"),
        )
        self.params["maxcols"] = SpinCtrl(
            parent=adv_setts_panel, id=wx.ID_ANY, size=(100, -1)
        )

        labels["maxrows"] = StaticText(
            parent=adv_setts_panel,
            id=wx.ID_ANY,
            label=_("Maximum rows to request from server at time:"),
        )
        self.params["maxrows"] = SpinCtrl(
            parent=adv_setts_panel, id=wx.ID_ANY, size=(100, -1)
        )

        min = 100
        max = 10000
        self.params["maxcols"].SetRange(min, max)
        self.params["maxrows"].SetRange(min, max)

        val = 500
        self.params["maxcols"].SetValue(val)
        self.params["maxrows"].SetValue(val)

        self.flags["o"] = self.params["bgcolor"] = None
        if "o" not in self.drv_props["ignored_flags"]:
            self.flags["o"] = wx.CheckBox(
                parent=adv_setts_panel,
                id=wx.ID_ANY,
                label=_("Do not request transparent data"),
            )

            self.flags["o"].Bind(wx.EVT_CHECKBOX, self.OnTransparent)
            labels["bgcolor"] = StaticText(
                parent=adv_setts_panel, id=wx.ID_ANY, label=_("Background color:")
            )
            self.params["bgcolor"] = csel.ColourSelect(
                parent=adv_setts_panel,
                id=wx.ID_ANY,
                colour=(255, 255, 255),
                size=globalvar.DIALOG_COLOR_SIZE,
            )
            self.params["bgcolor"].Enable(False)

        self.params["urlparams"] = None
        if self.params["urlparams"] not in self.drv_props["ignored_params"]:
            labels["urlparams"] = StaticText(
                parent=adv_setts_panel,
                id=wx.ID_ANY,
                label=_("Additional query parameters for server:"),
            )
            self.params["urlparams"] = TextCtrl(parent=adv_setts_panel, id=wx.ID_ANY)

        # layout

        border = wx.BoxSizer(wx.VERTICAL)

        if "WMS" in self.ws:

            boxSizer = wx.StaticBoxSizer(labels["l_order"], wx.VERTICAL)
            gridSizer = wx.GridBagSizer(hgap=3, vgap=3)

            gridSizer.Add(
                self.l_odrder_list,
                pos=(0, 0),
                span=(4, 1),
                flag=wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
                border=0,
            )

            gridSizer.Add(
                self.btnUp, pos=(0, 1), flag=wx.ALIGN_CENTER_VERTICAL, border=0
            )

            gridSizer.Add(
                self.btnDown, pos=(1, 1), flag=wx.ALIGN_CENTER_VERTICAL, border=0
            )

            gridSizer.AddGrowableCol(0)
            boxSizer.Add(gridSizer, flag=wx.EXPAND | wx.ALL, border=5)

            border.Add(boxSizer, flag=wx.LEFT | wx.RIGHT | wx.UP | wx.EXPAND, border=5)

        gridSizer = wx.GridBagSizer(hgap=3, vgap=3)

        row = 0
        for k in ["method", "maxcols", "maxrows", "o", "bgcolor"]:

            if k in self.params:
                param = self.params[k]
            elif k in self.flags:
                param = self.flags[k]

            if param is None:
                continue

            if k in labels or k == "o":
                if k != "o":
                    label = labels[k]
                else:
                    label = param

                gridSizer.Add(
                    label, flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, pos=(row, 0)
                )

            if k != "o":
                gridSizer.Add(
                    param, flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, pos=(row, 1)
                )
            row += 1

        gridSizer.AddGrowableCol(0)
        border.Add(gridSizer, flag=wx.LEFT | wx.RIGHT | wx.TOP | wx.EXPAND, border=5)

        if self.params["urlparams"]:
            gridSizer = wx.GridBagSizer(hgap=3, vgap=3)

            row = 0
            gridSizer.Add(
                labels["urlparams"],
                flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
                pos=(row, 0),
            )

            gridSizer.Add(
                self.params["urlparams"],
                flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND,
                pos=(row, 1),
            )

            gridSizer.AddGrowableCol(1)

            border.Add(
                gridSizer, flag=wx.LEFT | wx.RIGHT | wx.TOP | wx.EXPAND, border=5
            )

        adv_setts_panel.SetSizer(border)
        adv_setts_panel.SetAutoLayout(True)
        adv_setts_panel.SetupScrolling()