[GRASS-SVN] r32387 - in grass/trunk/gui/wxpython: gui_modules vdigit
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jul 30 11:28:03 EDT 2008
Author: martinl
Date: 2008-07-30 11:28:03 -0400 (Wed, 30 Jul 2008)
New Revision: 32387
Modified:
grass/trunk/gui/wxpython/gui_modules/vdigit.py
grass/trunk/gui/wxpython/vdigit/line.cpp
Log:
wxGUI: optionally break added lines at each intersection
Modified: grass/trunk/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/vdigit.py 2008-07-30 15:04:32 UTC (rev 32386)
+++ grass/trunk/gui/wxpython/gui_modules/vdigit.py 2008-07-30 15:28:03 UTC (rev 32387)
@@ -764,6 +764,10 @@
"Use vdigit instead."),
caption=_("Message"), style=wx.ID_OK | wx.ICON_INFORMATION | wx.CENTRE)
+ def UpdateSettings(self):
+ """Update digit settigs"""
+ pass
+
class VDigit(AbstractDigit):
"""
Prototype of digitization class based on v.digit reimplementation
@@ -785,6 +789,8 @@
self.toolbar = mapwindow.parent.toolbars['vdigit']
+ self.UpdateSettings()
+
def __del__(self):
del self.digit
@@ -1189,6 +1195,11 @@
def GetUndoLevel(self):
"""Get undo level (number of active changesets)"""
return self.digit.GetUndoLevel()
+
+ def UpdateSettings(self):
+ """Update digit settigs"""
+ self.digit.UpdateSettings(UserSettings.Get(group='vdigit', key='breakLines',
+ subkey='enabled'))
def __getSnapThreshold(self):
"""Get snap mode and threshold value
@@ -1788,6 +1799,9 @@
self.intersect = wx.CheckBox(parent=panel, label=_("Break lines on intersection"))
self.intersect.SetValue(UserSettings.Get(group='vdigit', key='breakLines', subkey='enabled'))
+ if UserSettings.Get(group='advanced', key='digitInterface', subkey='type') == 'vedit':
+ self.intersect.Enable(False)
+
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)
@@ -2176,10 +2190,17 @@
# 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())
# update driver settings
self.parent.digit.driver.UpdateSettings()
+ # update digit settings
+ self.parent.digit.UpdateSettings()
+
# redraw map if auto-rendering is enabled
if self.parent.autoRender.GetValue():
self.parent.OnRender(None)
Modified: grass/trunk/gui/wxpython/vdigit/line.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/line.cpp 2008-07-30 15:04:32 UTC (rev 32386)
+++ grass/trunk/gui/wxpython/vdigit/line.cpp 2008-07-30 15:28:03 UTC (rev 32387)
@@ -126,7 +126,46 @@
/* break on intersection */
if (settings.breakLines) {
- // TODO
+ int lineBreak;
+ BOUND_BOX lineBox;
+ struct ilist *list, *listBreak, *listRef;
+ struct line_pnts *points_check;
+
+ list = Vect_new_list();
+ listRef = Vect_new_list();
+ listBreak = Vect_new_list();
+
+ points_check = Vect_new_line_struct();
+
+ /* find all relevant lines */
+ Vect_get_line_box(display->mapInfo, newline, &lineBox);
+ Vect_select_lines_by_box(display->mapInfo, &lineBox,
+ GV_LINES, list);
+
+ /* check for intersection */
+ Vect_list_append(listBreak, newline);
+ Vect_list_append(listRef, newline);
+ for (int i = 0; i < list->n_values; i++) {
+ lineBreak = list->value[i];
+ if (lineBreak == newline)
+ continue;
+
+ type = Vect_read_line(display->mapInfo, points_check, NULL, lineBreak);
+ if (!(type & GV_LINES))
+ continue;
+
+ if (Vect_line_check_intersection(Points, points_check,
+ WITHOUT_Z))
+ Vect_list_append(listBreak, lineBreak);
+ }
+
+ Vect_break_lines_list(display->mapInfo, listBreak, listRef,
+ GV_LINES, NULL, NULL);
+
+ Vect_destroy_line_struct(points_check);
+ Vect_destroy_list(list);
+ Vect_destroy_list(listBreak);
+ Vect_destroy_list(listRef);
}
/* register changeset */
@@ -586,7 +625,7 @@
AddActionToChangeset(changeset, DELETE, display->selected->value[i]);
}
- ret = Vect_break_lines_list(display->mapInfo, display->selected,
+ ret = Vect_break_lines_list(display->mapInfo, display->selected, NULL,
GV_LINES, NULL, NULL);
if (ret > 0) {
More information about the grass-commit
mailing list