[GRASS-SVN] r44911 - in grass/trunk: gui/wxpython/gui_modules lib/vector/vedit

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jan 9 07:14:15 EST 2011


Author: martinl
Date: 2011-01-09 04:14:15 -0800 (Sun, 09 Jan 2011)
New Revision: 44911

Modified:
   grass/trunk/gui/wxpython/gui_modules/wxvdigit.py
   grass/trunk/gui/wxpython/gui_modules/wxvdriver.py
   grass/trunk/lib/vector/vedit/render.c
Log:
wxGUI/vdigit pythonization: dir enabled & flip lines


Modified: grass/trunk/gui/wxpython/gui_modules/wxvdigit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxvdigit.py	2011-01-09 02:49:05 UTC (rev 44910)
+++ grass/trunk/gui/wxpython/gui_modules/wxvdigit.py	2011-01-09 12:14:15 UTC (rev 44911)
@@ -633,11 +633,24 @@
         @return number of modified lines
         @return -1 on error
         """
-        ret = self.digit.FlipLines()
-
+        if not self._checkMap():
+            return -1
+        
+        nlines = Vect_get_num_lines(self.poMapInfo)
+        
+        # register changeset
+        changeset = self._addActionsBefore()
+        
+        poList = self._listToIList(self._display.selected['ids'])
+        ret = Vedit_flip_lines(self.poMapInfo, poList)
+        Vect_destroy_list(poList)
+        
         if ret > 0:
+            self._addActionsAfter(changeset, nlines)
             self.toolbar.EnableUndo()
-
+        else:
+            changesets.remove(changeset)
+        
         return ret
 
     def MergeLine(self):

Modified: grass/trunk/gui/wxpython/gui_modules/wxvdriver.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/wxvdriver.py	2011-01-09 02:49:05 UTC (rev 44910)
+++ grass/trunk/gui/wxpython/gui_modules/wxvdriver.py	2011-01-09 12:14:15 UTC (rev 44911)
@@ -133,20 +133,7 @@
             }
         
         # topology
-        self.topology = {
-            'highlight'   : 0,
-            'point'       : 0,
-            'line'        : 0,
-            'boundaryNo'  : 0,
-            'boundaryOne' : 0,
-            'boundaryTwo' : 0,
-            'centroidIn'  : 0,
-            'centroidOut' : 0,
-            'centroidDup' : 0,
-            'nodeOne'     : 0,
-            'nodeTwo'     : 0,
-            'vertex'      : 0,
-            }
+        self._resetTopology()
         
         self.drawSelected = False
         self.drawSegments = False
@@ -165,6 +152,24 @@
         
         Vect_destroy_line_struct(self.poPoints)
         Vect_destroy_cats_struct(self.poCats)
+
+    def _resetTopology(self):
+        """!Reset topology dict
+        """
+        self.topology = {
+            'highlight'   : 0,
+            'point'       : 0,
+            'line'        : 0,
+            'boundaryNo'  : 0,
+            'boundaryOne' : 0,
+            'boundaryTwo' : 0,
+            'centroidIn'  : 0,
+            'centroidOut' : 0,
+            'centroidDup' : 0,
+            'nodeOne'     : 0,
+            'nodeTwo'     : 0,
+            'vertex'      : 0,
+            }
         
     def _cell2Pixel(self, east, north, elev):
         """!Conversion from geographic coordinates (east, north)
@@ -324,38 +329,38 @@
         
     def _getDrawFlag(self):
         """!Get draw flag from the settings
-
+        
         See vedit.h for list of draw flags.
         
         @return draw flag (int)
         """
         ret = 0
         if self.settings['point']['enabled']:
-            ret |= TYPE_POINT
+            ret |= DRAW_POINT
         if self.settings['line']['enabled']:
-            ret |= TYPE_LINE
+            ret |= DRAW_LINE
         if self.settings['boundaryNo']['enabled']:
-            ret |= TYPE_BOUNDARYNO
+            ret |= DRAW_BOUNDARYNO
         if self.settings['boundaryTwo']['enabled']:
-            ret |= TYPE_BOUNDARYTWO
+            ret |= DRAW_BOUNDARYTWO
         if self.settings['boundaryOne']['enabled']:
-            ret |= TYPE_BOUNDARYONE
+            ret |= DRAW_BOUNDARYONE
         if self.settings['centroidIn']['enabled']:
-            ret |= TYPE_CENTROIDIN
+            ret |= DRAW_CENTROIDIN
         if self.settings['centroidOut']['enabled']:
-            ret |= TYPE_CENTROIDOUT
+            ret |= DRAW_CENTROIDOUT
         if self.settings['centroidDup']['enabled']:
-            ret |= TYPE_CENTROIDDUP
+            ret |= DRAW_CENTROIDDUP
         if self.settings['nodeOne']['enabled']:
-            ret |= TYPE_NODEONE
+            ret |= DRAW_NODEONE
         if self.settings['nodeTwo']['enabled']:
-            ret |= TYPE_NODETWO
+            ret |= DRAW_NODETWO
         if self.settings['vertex']['enabled']:
-            ret |= TYPE_VERTEX
+            ret |= DRAW_VERTEX
         if self.settings['area']['enabled']:
-            ret |= TYPE_AREA
+            ret |= DRAW_AREA
         if self.settings['direction']['enabled']:
-            ret |= TYPE_DIRECTION
+            ret |= DRAW_DIRECTION
         
         return ret
         
@@ -391,9 +396,6 @@
     def _isDuplicated(self, featId):
         return False
 
-    def _resetTopology(self):
-        pass
-
     def _getRegionBox(self):
         """!Get bound_box() from current region
 
@@ -426,18 +428,19 @@
                                  self.region['center_easting'], self.region['center_northing'],
                                  self.mapObj.width, self.mapObj.height,
                                  max(self.region['nsres'], self.region['ewres'])).contents
-        # ResetTopology()
         
-        #self.dc.BeginDrawing()
-        #self.dcTmp.BeginDrawing()
+        self._resetTopology()
         
+        self.dc.BeginDrawing()
+        self.dcTmp.BeginDrawing()
+        
         # draw objects
         for i in range(rlist.nitems):
             robj = rlist.item[i].contents
             self._drawObject(robj)
         
-        #self.dc.EndDrawing()
-        #self.dcTmp.EndDrawing()
+        self.dc.EndDrawing()
+        self.dcTmp.EndDrawing()
         
         # reset list of selected features by cat 
         # list of ids - see IsSelected()
@@ -740,6 +743,7 @@
         
         # open existing map
         if update:
+            print >> sys.stderr, name, mapset
             ret = Vect_open_update(self.poMapInfo, name, mapset)
         else:
             ret = Vect_open_old(self.poMapInfo, name, mapset)

Modified: grass/trunk/lib/vector/vedit/render.c
===================================================================
--- grass/trunk/lib/vector/vedit/render.c	2011-01-09 02:49:05 UTC (rev 44910)
+++ grass/trunk/lib/vector/vedit/render.c	2011-01-09 12:14:15 UTC (rev 44911)
@@ -345,7 +345,8 @@
     limit = 5;			// 5px for line segment
 
     dist = Vect_line_length(state.Points);
-
+    G_debug(5, "  draw_line_dir() line=%d", line);
+						  
     if (dist_in_px(dist) >= limit) {
 	while (1) {
 	    pos = (narrows + 1) * 8 * limit * region.map_res;



More information about the grass-commit mailing list