[GRASS-SVN] r32646 - in grass/trunk/gui/wxpython: gui_modules vdigit
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Aug 8 10:25:18 EDT 2008
Author: martinl
Date: 2008-08-08 10:25:18 -0400 (Fri, 08 Aug 2008)
New Revision: 32646
Modified:
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/select.cpp
Log:
wxGUI/vdigit: optionally select only features inside of selection bounding box (by default are selected all features overlapping bounding box)
* settings dialog layout cosmetics
(merge from devbr6, r32645)
Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py 2008-08-08 14:23:30 UTC (rev 32645)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py 2008-08-08 14:25:18 UTC (rev 32646)
@@ -291,6 +291,9 @@
'checkForDupl' : {
'enabled' : False
},
+ 'selectInside' : {
+ 'enabled' : False
+ },
# exit
'saveOnExit' : {
'enabled' : False
Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py 2008-08-08 14:23:30 UTC (rev 32645)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py 2008-08-08 14:25:18 UTC (rev 32646)
@@ -734,7 +734,7 @@
def OnQuery(self, event):
"""Query selected lines/boundaries"""
Debug.msg(2, "Digittoolbar.OnQuery(): %s" % \
- UserSettings.Get(group='vdigit', key='query', subkey='type'))
+ UserSettings.Get(group='vdigit', key='query', subkey='selection'))
self.action="queryLine"
self.parent.MapWindow.mouse['box'] = 'box'
Modified: grass/trunk/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/vdigit.py 2008-08-08 14:23:30 UTC (rev 32645)
+++ grass/trunk/gui/wxpython/gui_modules/vdigit.py 2008-08-08 14:25:18 UTC (rev 32646)
@@ -1375,7 +1375,7 @@
nselected = self.__display.SelectLinesByBox(x1, y1, -1.0 * wxvdigit.PORT_DOUBLE_MAX,
x2, y2, wxvdigit.PORT_DOUBLE_MAX,
- type)
+ type, UserSettings.Get(group='vdigit', key='selectInside', subkey='enabled'))
Debug.msg(4, "CDisplayDriver.SelectLinesByBox(): selected=%d" % \
nselected)
@@ -1718,10 +1718,9 @@
#
box = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Snapping"))
sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
- flexSizer1 = wx.FlexGridSizer (cols=3, hgap=5, vgap=5)
- flexSizer1.AddGrowableCol(0)
- flexSizer2 = wx.FlexGridSizer (cols=2, hgap=5, vgap=5)
- flexSizer2.AddGrowableCol(0)
+ flexSizer = wx.FlexGridSizer (cols=3, hgap=5, vgap=5)
+ flexSizer.AddGrowableCol(0)
+
# snapping
text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Snapping threshold"))
self.snappingValue = wx.SpinCtrl(parent=panel, id=wx.ID_ANY, size=(75, -1),
@@ -1732,18 +1731,9 @@
choices=["screen pixels", "map units"])
self.snappingUnit.SetStringSelection(UserSettings.Get(group='vdigit', key="snapping", subkey='units'))
self.snappingUnit.Bind(wx.EVT_CHOICE, self.OnChangeSnappingUnits)
- flexSizer1.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
- flexSizer1.Add(self.snappingValue, proportion=0, flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
- flexSizer1.Add(self.snappingUnit, proportion=0, flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
- # background map
- text = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Background vector map"))
- self.backgroundMap = gselect.Select(parent=panel, id=wx.ID_ANY, size=(200,-1),
- type="vector", exceptOf=[self.parent.digit.map])
- self.backgroundMap.SetValue(UserSettings.Get(group='vdigit', key="backgroundMap", subkey='value'))
- self.backgroundMap.Bind(wx.EVT_TEXT, self.OnChangeBackgroundMap)
- flexSizer2.Add(text, proportion=1, flag=wx.ALIGN_CENTER_VERTICAL)
- flexSizer2.Add(self.backgroundMap, proportion=1, flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
- #flexSizer.Add(self.snappingUnit, proportion=0, flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
+ flexSizer.Add(text, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
+ flexSizer.Add(self.snappingValue, proportion=0, flag=wx.ALIGN_CENTER | wx.FIXED_MINSIZE)
+ flexSizer.Add(self.snappingUnit, proportion=0, flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
vertexSizer = wx.BoxSizer(wx.VERTICAL)
self.snapVertex = wx.CheckBox(parent=panel, id=wx.ID_ANY,
@@ -1758,12 +1748,33 @@
vertexSizer.Add(item=self.snappingInfo, proportion=0,
flag=wx.ALL | wx.EXPAND, border=1)
- sizer.Add(item=flexSizer1, proportion=1, flag=wx.TOP | wx.LEFT | wx.EXPAND, border=1)
- sizer.Add(item=flexSizer2, proportion=1, flag=wx.TOP | wx.LEFT | wx.EXPAND, border=1)
- sizer.Add(item=vertexSizer, proportion=1, flag=wx.BOTTOM | wx.LEFT | wx.EXPAND, border=1)
+ sizer.Add(item=flexSizer, proportion=1, flag=wx.EXPAND)
+ sizer.Add(item=vertexSizer, proportion=1, flag=wx.EXPAND)
border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5)
#
+ # background vector map
+ #
+ box = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Background vector map"))
+ sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+
+ boxSizer = wx.BoxSizer(wx.VERTICAL)
+
+ self.backgroundMap = gselect.Select(parent=panel, id=wx.ID_ANY, size=globalvar.DIALOG_GSELECT_SIZE,
+ type="vector", exceptOf=[self.parent.digit.map])
+ self.backgroundMap.SetValue(UserSettings.Get(group='vdigit', key="backgroundMap", subkey='value'))
+ self.backgroundMap.Bind(wx.EVT_TEXT, self.OnChangeBackgroundMap)
+ boxSizer.Add(item=self.backgroundMap, proportion=0,
+ flag=wx.EXPAND | wx.ALL, border=5)
+ boxSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
+ label=_("This vector map is used for snapping and copying features.")),
+ proportion=0,
+ flag=wx.EXPAND | wx.ALL, border=5)
+
+ sizer.Add(item=boxSizer, proportion=1, flag=wx.TOP | wx.LEFT | wx.EXPAND, border=1)
+ border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=5)
+
+ #
# select box
#
box = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Select vector features"))
@@ -1794,12 +1805,19 @@
flexSizer.Add(units, proportion=0, flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL | wx.LEFT,
border=10)
+ self.selectIn = wx.CheckBox(parent=panel, id=wx.ID_ANY,
+ label=_("Select only features inside of selection bounding box"))
+ self.selectIn.SetValue(UserSettings.Get(group='vdigit', key="selectInside", subkey='enabled'))
+ self.selectIn.SetToolTipString(_("By default are selected all features overlapping selection bounding box "))
+
self.checkForDupl = wx.CheckBox(parent=panel, id=wx.ID_ANY,
label=_("Check for duplicates"))
self.checkForDupl.SetValue(UserSettings.Get(group='vdigit', key="checkForDupl", subkey='enabled'))
- flexSizer.Add(item=self.checkForDupl, proportion=0, flag=wx.EXPAND)
+
sizer.Add(item=flexSizer, proportion=0, flag=wx.EXPAND)
+ sizer.Add(item=self.selectIn, proportion=0, flag=wx.EXPAND | wx.ALL, border=1)
+ sizer.Add(item=self.checkForDupl, proportion=0, flag=wx.EXPAND | wx.ALL, border=1)
border.Add(item=sizer, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5)
#
@@ -2200,6 +2218,8 @@
value=int(self.selectThreshValue.GetValue()))
UserSettings.Set(group='vdigit', key="checkForDupl", subkey='enabled',
value=self.checkForDupl.IsChecked())
+ UserSettings.Set(group='vdigit', key="selectInside", subkey='enabled',
+ value=self.selectIn.IsChecked())
# on-exit
UserSettings.Set(group='vdigit', key="saveOnExit", subkey='enabled',
Modified: grass/trunk/gui/wxpython/vdigit/driver.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/driver.cpp 2008-08-08 14:23:30 UTC (rev 32645)
+++ grass/trunk/gui/wxpython/vdigit/driver.cpp 2008-08-08 14:25:18 UTC (rev 32646)
@@ -930,13 +930,15 @@
\param[in] x1,y1,z1,x2,y2,z3 bounding box definition
\param[in] type feature type
+ \param[in] onlyInside if true select only features inside
+ of bounding box (not overlapping)
\return number of selected features
\return -1 on error
*/
int DisplayDriver::SelectLinesByBox(double x1, double y1, double z1,
double x2, double y2, double z2,
- int type)
+ int type, bool onlyInside)
{
if (!mapInfo)
return -1;
@@ -964,6 +966,21 @@
for (int i = 0; i < list->n_values; i++) {
line = list->value[i];
+ if (onlyInside) {
+ bool inside;
+ inside = true;
+ Vect_read_line(mapInfo, points, cats, line);
+ for (int p = 0; p < points->n_points; p++) {
+ if (!Vect_point_in_poly(points->x[p], points->y[p],
+ bbox)) {
+ inside = false;
+ break;
+ }
+ }
+ if (!inside)
+ continue; /* skip lines just overlapping bbox */
+ }
+
if (!IsSelected(line)) {
Vect_list_append(selected, line);
}
Modified: grass/trunk/gui/wxpython/vdigit/driver.h
===================================================================
--- grass/trunk/gui/wxpython/vdigit/driver.h 2008-08-08 14:23:30 UTC (rev 32645)
+++ grass/trunk/gui/wxpython/vdigit/driver.h 2008-08-08 14:25:18 UTC (rev 32646)
@@ -171,7 +171,8 @@
int DrawMap(bool);
/* select */
- int SelectLinesByBox(double, double, double, double, double, double, int);
+ int SelectLinesByBox(double, double, double, double,
+ double, double, int, bool);
std::vector<double> SelectLineByPoint(double, double, double,
double, int, int);
Modified: grass/trunk/gui/wxpython/vdigit/select.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/select.cpp 2008-08-08 14:23:30 UTC (rev 32645)
+++ grass/trunk/gui/wxpython/vdigit/select.cpp 2008-08-08 14:25:18 UTC (rev 32646)
@@ -58,26 +58,26 @@
List = Vect_new_list();
if (box) {
- bbox = Vect_new_line_struct();
-
- Vect_append_point(bbox, x1, y1, z1);
- Vect_append_point(bbox, x2, y1, z2);
- Vect_append_point(bbox, x2, y2, z1);
- Vect_append_point(bbox, x1, y2, z2);
- Vect_append_point(bbox, x1, y1, z1);
-
- Vect_select_lines_by_polygon (display->mapInfo, bbox, 0, NULL, type, List);
- if (List->n_values == 0) {
- return ids;
- }
+ bbox = Vect_new_line_struct();
+
+ Vect_append_point(bbox, x1, y1, z1);
+ Vect_append_point(bbox, x2, y1, z2);
+ Vect_append_point(bbox, x2, y2, z1);
+ Vect_append_point(bbox, x1, y2, z2);
+ Vect_append_point(bbox, x1, y1, z1);
+
+ Vect_select_lines_by_polygon (display->mapInfo, bbox, 0, NULL, type, List);
+ if (List->n_values == 0) {
+ return ids;
+ }
}
-
+
G_debug(3, "wxDigit.SelectLinesByQuery(): lines=%d", List->n_values);
Vedit_select_by_query(display->mapInfo,
type, layer, thresh, query,
List);
-
+
ids = display->ListToVector(List); // TODO
G_debug(3, "wxDigit.SelectLinesByQuery(): lines=%d", List->n_values);
More information about the grass-commit
mailing list