12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- """!
- @package iclass::digit
- @brief wxIClass digitizer classes
- Classes:
- - digit::IClassVDigit
- - digit::IClassVDigitWindow
- (C) 2006-2011 by the GRASS Development Team
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
- @author Vaclav Petras <wenzeslaus gmail.com>
- @author Anna Kratochvilova <kratochanna gmail.com>
- """
- import wx
- from vdigit.mapwindow import VDigitWindow
- from vdigit.wxdigit import IVDigit
- class IClassVDigitWindow(VDigitWindow):
- """! Class similar to VDigitWindow but specialized for wxIClass."""
- def __init__(self, parent, map):
- """!
-
- @a parent should has toolbar providing current class (category).
-
- @param parent gui parent
- @param map map renderer instance
- """
- VDigitWindow.__init__(self, parent = parent, Map = map)
-
- def _onLeftDown(self, event):
- action = self.toolbar.GetAction()
- if not action:
- return
-
- cat = self.GetCurrentCategory()
-
- if cat is None and action == "addLine":
- dlg = wx.MessageDialog(parent = self.parent,
- message = _("In order to create a training area, "
- "you have to select class first.\n\n"
- "There is no class yet, "
- "do you want to create one?"),
- caption = _("No class selected"),
- style = wx.YES_NO)
- if dlg.ShowModal() == wx.ID_YES:
- self.parent.OnCategoryManager(None)
-
- dlg.Destroy()
- event.Skip()
- return
-
- super(IClassVDigitWindow, self)._onLeftDown(event)
-
- def _addRecord(self):
- return False
-
- def GetCurrentCategory(self):
- """!Returns current category (class).
-
- Category should be assigned to new features (areas).
- It is taken from parent's toolbar.
- """
- return self.parent.GetToolbar("iClass").GetSelectedCategoryIdx()
-
- class IClassIVDigit(IVDigit):
- """! Class similar to IVDigit but specialized for wxIClass."""
- def __init__(self, mapwindow):
- IVDigit.__init__(self, mapwindow)
-
- def _getNewFeaturesLayer(self):
- return 1
-
- def _getNewFeaturesCat(self):
- cat = self.mapWindow.GetCurrentCategory()
- return cat
|