[GRASS-SVN] r30018 - in grass/trunk/gui/wxpython: gui_modules vdigit
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Feb 8 12:57:10 EST 2008
Author: martinl
Date: 2008-02-08 12:57:10 -0500 (Fri, 08 Feb 2008)
New Revision: 30018
Modified:
grass/trunk/gui/wxpython/gui_modules/digit.py
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
grass/trunk/gui/wxpython/gui_modules/toolbars.py
grass/trunk/gui/wxpython/vdigit/digit.h
grass/trunk/gui/wxpython/vdigit/digit.i
grass/trunk/gui/wxpython/vdigit/grass6_wxvdigit_wrap.cpp
grass/trunk/gui/wxpython/vdigit/line.cpp
Log:
wxGUI/vdigit: new feature implemented (change type of selected features, point<->centroid, line<->boundary). Currently only in vdigit component.
Modified: grass/trunk/gui/wxpython/gui_modules/digit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/digit.py 2008-02-08 17:33:17 UTC (rev 30017)
+++ grass/trunk/gui/wxpython/gui_modules/digit.py 2008-02-08 17:57:10 UTC (rev 30018)
@@ -1014,6 +1014,18 @@
"""Get list of layers"""
return self.digit.GetLayers()
+ def TypeConvForSelectedLines(self):
+ """Feature type conversion for selected objects.
+
+ Supported conversions:
+ - point <-> centroid
+ - line <-> boundary
+
+ @return number of modified features
+ @return -1 on error
+ """
+ return self.digit.TypeConvLines()
+
def __getSnapThreshold(self):
"""Get snap mode and threshold value
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-02-08 17:33:17 UTC (rev 30017)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2008-02-08 17:57:10 UTC (rev 30018)
@@ -1176,7 +1176,7 @@
if digitToolbar.action in ["deleteLine", "moveLine", "moveVertex",
"copyCats", "editLine", "flipLine",
"mergeLine", "snapLine",
- "queryLine", "breakLine"]:
+ "queryLine", "breakLine", "typeConv"]:
nselected = 0
# -> delete line || move line || move vertex
if digitToolbar.action in ["moveVertex", "editLine"]:
@@ -1554,6 +1554,11 @@
digitClass.ZBulkLine(pos1, pos2, dlg.value.GetValue(), dlg.step.GetValue())
self.UpdateMap(render=False, renderVector=True)
+ elif digitToolbar.action == "typeConv":
+ # -> feature type conversion
+ # - point <-> centroid
+ # - line <-> boundary
+ digitClass.TypeConvForSelectedLines()
if digitToolbar.action != "addLine":
# unselect and re-render
@@ -1588,10 +1593,10 @@
self.UpdateMap(render=False, renderVector=False)
elif digitToolbar.action in ["deleteLine", "moveLine", "splitLine",
- "addVertex", "removeVertex", "moveVertex",
- "copyCats", "flipLine", "mergeLine",
- "snapLine", "connectLine", "copyLine",
- "queryLine", "breakLine"]:
+ "addVertex", "removeVertex", "moveVertex",
+ "copyCats", "flipLine", "mergeLine",
+ "snapLine", "connectLine", "copyLine",
+ "queryLine", "breakLine", "typeConv"]:
# varios tools -> unselected selected features
digitClass.driver.SetSelected([])
if digitToolbar.action in ["moveLine", "moveVertex", "editLine"] and \
Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py 2008-02-08 17:33:17 UTC (rev 30017)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py 2008-02-08 17:57:10 UTC (rev 30018)
@@ -514,6 +514,10 @@
toolMenu.AppendItem(zbulk)
self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnZBulk, zbulk)
+ typeconv = wx.MenuItem(toolMenu, wx.ID_ANY, 'Feature type conversion')
+ toolMenu.AppendItem(typeconv)
+ self.parent.MapWindow.Bind(wx.EVT_MENU, self.OnTypeConversion, typeconv)
+
# Popup the menu. If an item is selected then its handler
# will be called before PopupMenu returns.
self.parent.MapWindow.PopupMenu(toolMenu)
@@ -567,6 +571,17 @@
self.action="zbulkLine"
self.parent.MapWindow.mouse['box'] = 'line'
+ def OnTypeConversion(self, event):
+ """Feature type conversion
+
+ Supported conversions:
+ - point <-> centroid
+ - line <-> boundary
+ """
+ Debug.msg(2, "Digittoolbar.OnTypeConversion():")
+ self.action="typeConv"
+ self.parent.MapWindow.mouse['box'] = 'box'
+
def OnSelectMap (self, event):
"""
Select vector map layer for editing
Modified: grass/trunk/gui/wxpython/vdigit/digit.h
===================================================================
--- grass/trunk/gui/wxpython/vdigit/digit.h 2008-02-08 17:33:17 UTC (rev 30017)
+++ grass/trunk/gui/wxpython/vdigit/digit.h 2008-02-08 17:57:10 UTC (rev 30018)
@@ -35,6 +35,7 @@
int BreakLines();
int SnapLines(double);
int ConnectLines(double);
+ int TypeConvLines();
int ZBulkLabeling(double, double, double, double,
double, double);
int CopyLines(std::vector<int>, const char*);
Modified: grass/trunk/gui/wxpython/vdigit/digit.i
===================================================================
--- grass/trunk/gui/wxpython/vdigit/digit.i 2008-02-08 17:33:17 UTC (rev 30017)
+++ grass/trunk/gui/wxpython/vdigit/digit.i 2008-02-08 17:57:10 UTC (rev 30018)
@@ -19,3 +19,5 @@
namespace std {
%template(IntVecIntMap) map<int, vector<int> >;
}
+%include "driver.h"
+%include "digit.h"
\ No newline at end of file
Modified: grass/trunk/gui/wxpython/vdigit/grass6_wxvdigit_wrap.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/grass6_wxvdigit_wrap.cpp 2008-02-08 17:33:17 UTC (rev 30017)
+++ grass/trunk/gui/wxpython/vdigit/grass6_wxvdigit_wrap.cpp 2008-02-08 17:57:10 UTC (rev 30018)
@@ -11245,6 +11245,28 @@
}
+SWIGINTERN PyObject *_wrap_Digit_TypeConvLines(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+ PyObject *resultobj = 0;
+ Digit *arg1 = (Digit *) 0 ;
+ int result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ PyObject * obj0 = 0 ;
+
+ if (!PyArg_ParseTuple(args,(char *)"O:Digit_TypeConvLines",&obj0)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Digit, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Digit_TypeConvLines" "', argument " "1"" of type '" "Digit *""'");
+ }
+ arg1 = reinterpret_cast< Digit * >(argp1);
+ result = (int)(arg1)->TypeConvLines();
+ resultobj = SWIG_From_int(static_cast< int >(result));
+ return resultobj;
+fail:
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_Digit_ZBulkLabeling(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
Digit *arg1 = (Digit *) 0 ;
@@ -12016,6 +12038,7 @@
{ (char *)"Digit_BreakLines", _wrap_Digit_BreakLines, METH_VARARGS, NULL},
{ (char *)"Digit_SnapLines", _wrap_Digit_SnapLines, METH_VARARGS, NULL},
{ (char *)"Digit_ConnectLines", _wrap_Digit_ConnectLines, METH_VARARGS, NULL},
+ { (char *)"Digit_TypeConvLines", _wrap_Digit_TypeConvLines, METH_VARARGS, NULL},
{ (char *)"Digit_ZBulkLabeling", _wrap_Digit_ZBulkLabeling, METH_VARARGS, NULL},
{ (char *)"Digit_CopyLines", _wrap_Digit_CopyLines, METH_VARARGS, NULL},
{ (char *)"Digit_MoveVertex", _wrap_Digit_MoveVertex, METH_VARARGS, NULL},
@@ -12640,6 +12663,7 @@
SWIG_InstallConstants(d,swig_const_table);
+ SWIG_Python_SetConstant(d, "GSQL_MAX",SWIG_From_int(static_cast< int >(4000)));
SWIG_Python_SetConstant(d, "GV_POINT",SWIG_From_int(static_cast< int >(0x01)));
SWIG_Python_SetConstant(d, "GV_LINE",SWIG_From_int(static_cast< int >(0x02)));
SWIG_Python_SetConstant(d, "GV_BOUNDARY",SWIG_From_int(static_cast< int >(0x04)));
@@ -12657,6 +12681,5 @@
SWIG_Python_SetConstant(d, "QUERY_UNKNOWN",SWIG_From_int(static_cast< int >(-1)));
SWIG_Python_SetConstant(d, "QUERY_LENGTH",SWIG_From_int(static_cast< int >(0)));
SWIG_Python_SetConstant(d, "QUERY_DANGLE",SWIG_From_int(static_cast< int >(1)));
- SWIG_Python_SetConstant(d, "GSQL_MAX",SWIG_From_int(static_cast< int >(4000)));
}
Modified: grass/trunk/gui/wxpython/vdigit/line.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/line.cpp 2008-02-08 17:33:17 UTC (rev 30017)
+++ grass/trunk/gui/wxpython/vdigit/line.cpp 2008-02-08 17:57:10 UTC (rev 30018)
@@ -633,3 +633,72 @@
return BgMap;
}
+
+/**
+ \brief Type conversion of selected features
+
+ Supported conversions:
+ - point <-> centroid
+ - line <-> boundary
+
+ \return number of modified features
+ \return -1 on error
+*/
+int Digit::TypeConvLines()
+{
+ int nlines, line;
+ int type, newtype;
+ struct line_pnts *Points;
+ struct line_cats *Cats;
+
+ if (!display->mapInfo) {
+ return -1;
+ }
+
+ nlines = 0;
+
+ Points = Vect_new_line_struct();
+ Cats = Vect_new_cats_struct();
+
+ for (int i = 0; i < display->selected->n_values; i++) {
+ line = display->selected->value[i];
+ if (!Vect_line_alive(display->mapInfo, line))
+ continue;
+ type = Vect_read_line(display->mapInfo, Points, Cats, line);
+ if (type < 0) {
+ return -1;
+ }
+ switch (type) {
+ case GV_POINT:
+ newtype = GV_CENTROID;
+ break;
+ case GV_CENTROID:
+ newtype = GV_POINT;
+ break;
+ case GV_LINE:
+ newtype = GV_BOUNDARY;
+ break;
+ case GV_BOUNDARY:
+ newtype = GV_LINE;
+ break;
+ default:
+ newtype = -1;
+ break;
+ }
+
+ G_debug(3, "Digit.TypeConvLines(): line=%d, from_type=%d, to_type=%d",
+ line, type, newtype);
+
+ if (newtype > 0) {
+ if (Vect_rewrite_line(display->mapInfo, line, newtype, Points, Cats) < 0) {
+ return -1;
+ }
+ nlines++;
+ }
+ }
+
+ Vect_destroy_line_struct(Points);
+ Vect_destroy_cats_struct(Cats);
+
+ return nlines;
+}
More information about the grass-commit
mailing list