[GRASS-SVN] r32289 - in grass/trunk/gui/wxpython: gui_modules vdigit

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jul 25 08:56:05 EDT 2008


Author: martinl
Date: 2008-07-25 08:56:05 -0400 (Fri, 25 Jul 2008)
New Revision: 32289

Modified:
   grass/trunk/gui/wxpython/gui_modules/mapdisp.py
   grass/trunk/gui/wxpython/gui_modules/preferences.py
   grass/trunk/gui/wxpython/gui_modules/toolbars.py
   grass/trunk/gui/wxpython/gui_modules/vdigit.py
   grass/trunk/gui/wxpython/vdigit/driver.cpp
   grass/trunk/gui/wxpython/vdigit/driver.h
   grass/trunk/gui/wxpython/vdigit/line.cpp
Log:
wxGUI/vdigit: update connect lines tool

Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2008-07-25 11:01:45 UTC (rev 32288)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py	2008-07-25 12:56:05 UTC (rev 32289)
@@ -1285,13 +1285,6 @@
                     begin = self.Pixel2Cell(self.mouse['begin'])
 
                     self.DrawLines(self.pdcTmp, begin, end)
-            elif digitToolbar.action == "connectLine":
-                if len(digitClass.driver.GetSelected()) > 1:
-                    # if two line selected -> reset
-                    digitClass.driver.SetSelected([])
-                digitClass.driver.SelectLineByPoint(self.Pixel2Cell(self.mouse['begin']),
-                                                    digitClass.GetSelectType())
-
         else:
             # get decoration id
             self.lastpos = self.mouse['begin']
@@ -1385,7 +1378,7 @@
             if digitToolbar.action in ["deleteLine", "moveLine", "moveVertex",
                                        "copyCats", "editLine", "flipLine",
                                        "mergeLine", "snapLine",
-                                       "queryLine", "breakLine", "typeConv"]:
+                                       "queryLine", "breakLine", "typeConv", "connectLine"]:
                 nselected = 0
                 # -> delete line || move line || move vertex
                 if digitToolbar.action in ["moveVertex", "editLine"]:
@@ -1469,11 +1462,12 @@
                     else:
                         nselected = digitClass.driver.SelectLinesByBox(pos1, pos2,
                                                                        digitClass.GetSelectType())
+                        
                         if nselected == 0:
                             if digitClass.driver.SelectLineByPoint(pos1,
                                                                    digitClass.GetSelectType()) is not None:
                                 nselected = 1
-
+                        
                 if nselected > 0:
                     if digitToolbar.action in ["moveLine", "moveVertex"]:
                         # get pseudoDC id of objects which should be redrawn
@@ -1797,7 +1791,7 @@
             elif digitToolbar.action == "snapLine":
                 digitClass.SnapLine()
             elif digitToolbar.action == "connectLine":
-                if len(digitClass.driver.GetSelected()) == 2:
+                if len(digitClass.driver.GetSelected()) > 1:
                     digitClass.ConnectLine()
             elif digitToolbar.action == "copyLine":
                 digitClass.CopyLine(self.copyIds)
@@ -2829,7 +2823,7 @@
                     self.MapWindow.mouse['box'] = 'line'
             elif self.toolbars['vdigit'].action in ['addVertex', 'removeVertex', 'splitLine',
                                          'editLine', 'displayCats', 'displayAttrs',
-                                         'copyCats', 'connectLine']:
+                                         'copyCats']:
                 self.MapWindow.mouse['box'] = 'point'
             else: # moveLine, deleteLine
                 self.MapWindow.mouse['box'] = 'box'

Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py	2008-07-25 11:01:45 UTC (rev 32288)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py	2008-07-25 12:56:05 UTC (rev 32289)
@@ -284,6 +284,10 @@
                 'saveOnExit' : {
                     'enabled' : False
                     },
+                # break lines on intersection
+                'breakLines' : {
+                    'enabled' : False,
+                    },
                 },
             'profile': {
                 'raster0' : {

Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py	2008-07-25 11:01:45 UTC (rev 32288)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py	2008-07-25 12:56:05 UTC (rev 32289)
@@ -672,7 +672,7 @@
         toolMenu.AppendItem(snap)
         self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnSnap, snap)
 
-        connect = wx.MenuItem(toolMenu, wx.ID_ANY, _('Connect two selected lines/boundaries'))
+        connect = wx.MenuItem(toolMenu, wx.ID_ANY, _('Connect selected lines/boundaries'))
         toolMenu.AppendItem(connect)
         self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnConnect, connect)
 
@@ -727,7 +727,7 @@
         """Connect selected lines/boundaries"""
         Debug.msg(2, "Digittoolbar.OnConnect():")
         self.action="connectLine"
-        self.parent.MapWindow.mouse['box'] = 'point'
+        self.parent.MapWindow.mouse['box'] = 'box'
 
     def OnQuery(self, event):
         """Query selected lines/boundaries"""

Modified: grass/trunk/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/vdigit.py	2008-07-25 11:01:45 UTC (rev 32288)
+++ grass/trunk/gui/wxpython/gui_modules/vdigit.py	2008-07-25 12:56:05 UTC (rev 32289)
@@ -1,35 +1,34 @@
 """
-MODULE: vdigit
+ at package vdigit
 
-CLASSES:
- * AbstractDigit 
- * VEdit
- * VDigit
- * AbstractDisplayDriver
- * CDisplayDriver
- * VDigitSettingsDialog
- * VDigitCategoryDialog
- * VDigitZBulkDialog
- * VDigitDuplicatesDialog
+ at brief Vector digitizer extension
 
-PURPOSE: Vector digitization tool for wxPython GUI
+Progress:
+ (1) v.edit called on the background (class VEdit)
+ (2) Reimplentation of v.digit (VDigit)
 
-         Note: Initial version under development
+Import:
 
-         Progress:
-          (1) v.edit called on the background (class VEdit)
-          (2) Reimplentation of v.digit (VDigit)
+  from vdigit import VDigit as VDigit
 
-         Import:
-          from vdigit import VDigit as VDigit
-          
-AUTHORS: The GRASS Development Team
-         Martin Landa <landa.martin gmail.com>
+Classes:
+ - AbstractDigit 
+ - VEdit
+ - VDigit
+ - AbstractDisplayDriver
+ - CDisplayDriver
+ - VDigitSettingsDialog
+ - VDigitCategoryDialog
+ - VDigitZBulkDialog
+ - VDigitDuplicatesDialog
 
-COPYRIGHT: (C) 2007-2008 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.
+(C) 2007-2008 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.
+
+ at author Martin Landa <landa.martin gmail.com>
 """
 
 import os
@@ -1576,7 +1575,8 @@
                                                 UserSettings.Get(group='vdigit', key='symbolDirection', subkey='color')[1],
                                                 UserSettings.Get(group='vdigit', key='symbolDirection', subkey='color')[2],
                                                 255).GetRGB(),
-                                       UserSettings.Get(group='vdigit', key='lineWidth', subkey='value'))
+                                       UserSettings.Get(group='vdigit', key='lineWidth', subkey='value'),
+                                       UserSettings.Get(group='vdigit', key='breakLines', subkey='enabled'))
 
 class VDigitSettingsDialog(wx.Dialog):
     """
@@ -1781,12 +1781,24 @@
         border.Add(item=sizer, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5)
 
         #
+        # digitize lines box
+        #
+        box   = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Digitize line features"))
+        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+
+        self.intersect = wx.CheckBox(parent=panel, label=_("Break lines on intersection"))
+        self.intersect.SetValue(UserSettings.Get(group='vdigit', key='breakLines', subkey='enabled'))
+        sizer.Add(item=self.intersect, proportion=0, flag=wx.ALL | wx.EXPAND, border=1)
+
+        border.Add(item=sizer, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5)
+
+        #
         # save-on-exit box
         #
         box   = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Save changes"))
         # save changes on exit?
         sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
-        self.save = wx.CheckBox(parent=panel, label=_("Save changes on exit automatically"))
+        self.save = wx.CheckBox(parent=panel, label=_("Save changes on exit"))
         self.save.SetValue(UserSettings.Get(group='vdigit', key='saveOnExit', subkey='enabled'))
         sizer.Add(item=self.save, proportion=0, flag=wx.ALL | wx.EXPAND, border=1)
         border.Add(item=sizer, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5)

Modified: grass/trunk/gui/wxpython/vdigit/driver.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/driver.cpp	2008-07-25 11:01:45 UTC (rev 32288)
+++ grass/trunk/gui/wxpython/vdigit/driver.cpp	2008-07-25 12:56:05 UTC (rev 32289)
@@ -818,7 +818,7 @@
 				   bool eVertex,      unsigned long cVertex,
 				   bool eArea,        unsigned long cArea,
 				   bool eDirection,   unsigned long cDirection,
-				   int lineWidth)
+				   int lineWidth, bool breakLines)
 {
     settings.highlight.Set(highlight);
     
@@ -865,6 +865,10 @@
     settings.direction.color.Set(cDirection);
 
     settings.lineWidth = lineWidth;
+    
+    settings.breakLines = breakLines;
+
+    return;
 }
 
 /**

Modified: grass/trunk/gui/wxpython/vdigit/driver.h
===================================================================
--- grass/trunk/gui/wxpython/vdigit/driver.h	2008-07-25 11:01:45 UTC (rev 32288)
+++ grass/trunk/gui/wxpython/vdigit/driver.h	2008-07-25 12:56:05 UTC (rev 32289)
@@ -112,6 +112,8 @@
 	symbol direction;
 
 	int lineWidth;    // screen units 
+
+	bool breakLines;
     } settings;
 
     struct _topology {
@@ -212,7 +214,7 @@
 			bool, unsigned long,
 			bool, unsigned long,
 			bool, unsigned long,
-			int);
+			int, bool);
 };
 
 int print_error(const char *, int);

Modified: grass/trunk/gui/wxpython/vdigit/line.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/line.cpp	2008-07-25 11:01:45 UTC (rev 32288)
+++ grass/trunk/gui/wxpython/vdigit/line.cpp	2008-07-25 12:56:05 UTC (rev 32289)
@@ -82,11 +82,11 @@
     Cats = Vect_new_cats_struct();
 
     if (layer > 0) {
-      Vect_cat_set(Cats, layer, cat);
-
-      if (cat > GetCategory(layer)) {
-	  SetCategory(layer, cat); /* set up max category for layer */
-      }
+	Vect_cat_set(Cats, layer, cat);
+	
+	if (cat > GetCategory(layer)) {
+	    SetCategory(layer, cat); /* set up max category for layer */
+	}
     }
 
     i = 0;
@@ -124,6 +124,11 @@
 	return -1;
     }
 
+    /* break on intersection */
+    if (settings.breakLines) {
+	// TODO
+    }
+    
     /* register changeset */
     AddActionToChangeset(changesets.size(), ADD, newline);
 
@@ -629,10 +634,9 @@
 }
 
 /**
-   \brief Connect two selected lines/boundaries
+   \brief Connect selected lines/boundaries
 
-   \return 1 lines connected
-   \return 0 lines not connected
+   \return number of modified lines
    \return -1 on error
 */
 int Digit::ConnectLines(double thresh)
@@ -644,9 +648,6 @@
 	return -1;
     }
 
-    if (display->selected->n_values != 2)
-	return 0;
-
     /* register changeset */
     changeset = changesets.size();
     for (int i = 0; i < display->selected->n_values; i++) {
@@ -658,7 +659,7 @@
     ret = Vedit_connect_lines(display->mapInfo, display->selected,
 			      thresh);
 
-    if (ret == 1) {
+    if (ret > 0) {
 	nlines_diff = Vect_get_num_lines(display->mapInfo) - nlines_diff;
 	for(int i = Vect_get_num_lines(display->mapInfo); i > nlines_diff; i--) {
 	    AddActionToChangeset(changeset, ADD, i);



More information about the grass-commit mailing list