[GRASS-SVN] r38929 - in grass/branches/releasebranch_6_4/gui/wxpython: gui_modules vdigit

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Aug 31 03:37:07 EDT 2009


Author: martinl
Date: 2009-08-31 03:37:05 -0400 (Mon, 31 Aug 2009)
New Revision: 38929

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/toolbars.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/vdigit.py
   grass/branches/releasebranch_6_4/gui/wxpython/vdigit/driver.cpp
   grass/branches/releasebranch_6_4/gui/wxpython/vdigit/driver.h
Log:
wxGUI: ZBulk-labeling fixed (trac #737)


Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py	2009-08-30 22:14:55 UTC (rev 38928)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/mapdisp.py	2009-08-31 07:37:05 UTC (rev 38929)
@@ -1417,7 +1417,7 @@
                     end   = self.Pixel2Cell(self.polycoords[-1])
                     begin = self.Pixel2Cell(self.mouse['begin'])
 
-                    self.DrawLines(self.pdcTmp, begin, end)
+                    self.DrawLines(self.pdcTmp, polycoords = [begin, end])
         elif self.mouse['use'] == 'pointer':
             # get decoration or text id
             self.idlist = []
@@ -1968,7 +1968,7 @@
                 dlg = VDigitZBulkDialog(parent=self, title=_("Z bulk-labeling dialog"),
                                         nselected=len(selected))
                 if dlg.ShowModal() == wx.ID_OK:
-                    if digitClass.ZBulkLine(pos1, pos2, dlg.value.GetValue(),
+                    if digitClass.ZBulkLines(pos1, pos2, dlg.value.GetValue(),
                                             dlg.step.GetValue()) < 0:
                         return
                 self.UpdateMap(render=False, renderVector=True)

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/toolbars.py	2009-08-30 22:14:55 UTC (rev 38928)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/toolbars.py	2009-08-31 07:37:05 UTC (rev 38929)
@@ -994,6 +994,12 @@
 
     def OnZBulk(self, event):
         """Z bulk-labeling selected lines/boundaries"""
+        if not self.parent.digit.driver.Is3D():
+            wx.MessageBox(parent=self.parent,
+                          message=_("Vector map is not 3D. Operation canceled."),
+                          caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
+            return
+        
         if self.action['desc'] == 'zbulkLine': # select previous action
             self.toolbar[0].ToggleTool(self.addPoint, True)
             self.toolbar[0].ToggleTool(self.additionalTools, False)

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/vdigit.py	2009-08-30 22:14:55 UTC (rev 38928)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/vdigit.py	2009-08-31 07:37:05 UTC (rev 38929)
@@ -661,7 +661,26 @@
         if self.digit:
             self.digit.UpdateSettings(UserSettings.Get(group='vdigit', key='breakLines',
                                                        subkey='enabled'))
+
+    def ZBulkLines(self, pos1, pos2, start, step):
+        """!Z-bulk labeling
+
+        @param pos1 reference line (start point)
+        @param pos1 reference line (end point)
+        @param start starting value
+        @param step step value
+
+        @return number of modified lines
+        @return -1 on error
+        """
+        ret = self.digit.ZBulkLabeling(pos1[0], pos1[1], pos2[0], pos2[1],
+                                       start, step)
         
+        if ret > 0:
+            self.toolbar.EnableUndo()
+
+        return ret
+    
     def __getSnapThreshold(self):
         """Get snap mode and threshold value
 
@@ -963,6 +982,13 @@
 
         return self.__display.GetMapBoundingBox()
 
+    def Is3D(self):
+        """!Check if open vector map is 3D
+
+        @return True if 3D
+        @return False if not 3D"""
+        return self.__display.Is3D()
+    
     def DrawSelected(self, draw=True):
         """Show/hide selected features"""
         self.__display.DrawSelected(draw)
@@ -2253,7 +2279,7 @@
         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=5)
+        border.Add(item=sizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=0)
 
         # buttons
         btnCancel = wx.Button(self, wx.ID_CANCEL)

Modified: grass/branches/releasebranch_6_4/gui/wxpython/vdigit/driver.cpp
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/vdigit/driver.cpp	2009-08-30 22:14:55 UTC (rev 38928)
+++ grass/branches/releasebranch_6_4/gui/wxpython/vdigit/driver.cpp	2009-08-31 07:37:05 UTC (rev 38929)
@@ -516,3 +516,13 @@
     
     return 0;
 }
+
+/**
+   \brief Check if vector map is 3D
+
+   \return True for 3D otherwise False
+*/
+bool DisplayDriver::Is3D()
+{
+    return (bool) Vect_is_3d(mapInfo);
+}

Modified: grass/branches/releasebranch_6_4/gui/wxpython/vdigit/driver.h
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/vdigit/driver.h	2009-08-30 22:14:55 UTC (rev 38928)
+++ grass/branches/releasebranch_6_4/gui/wxpython/vdigit/driver.h	2009-08-31 07:37:05 UTC (rev 38929)
@@ -206,6 +206,7 @@
 
     /* misc */
     std::vector<double> GetMapBoundingBox();
+    bool Is3D();
 
     /* set */
     void SetRegion(double, double, double, double,



More information about the grass-commit mailing list