[GRASS-SVN] r29963 - in grass/trunk/gui/wxpython: gui_modules vdigit
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Feb 5 18:42:45 EST 2008
Author: martinl
Date: 2008-02-05 18:42:44 -0500 (Tue, 05 Feb 2008)
New Revision: 29963
Modified:
grass/trunk/gui/wxpython/gui_modules/digit.py
grass/trunk/gui/wxpython/vdigit/digit.h
grass/trunk/gui/wxpython/vdigit/grass6_wxvdigit_wrap.cpp
grass/trunk/gui/wxpython/vdigit/line.cpp
grass/trunk/gui/wxpython/vdigit/vertex.cpp
Log:
wxGUI/vdigit: fixed support for snapping to background map objects in vdigit interface.
Modified: grass/trunk/gui/wxpython/gui_modules/digit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/digit.py 2008-02-05 21:39:40 UTC (rev 29962)
+++ grass/trunk/gui/wxpython/gui_modules/digit.py 2008-02-05 23:42:44 UTC (rev 29963)
@@ -59,7 +59,7 @@
#
# Use v.edit on background or experimental C++ interface (not yet completed)
#
-USEVEDIT = True
+USEVEDIT = False
if USEVEDIT is True and GV_LINES is not None:
print >> sys.stderr, "%sWARNING: Digitization tool uses v.edit interface by default. " \
"This can significantly slow down some operations especially for " \
@@ -467,7 +467,10 @@
if tool == "vertexmove":
command.append("coords=%f,%f" % (float(coords[0]), float(coords[1])))
command.append("-1") # modify only first selected
-
+
+ if self.settings['backgroundMap'] != '':
+ command.append("bgmap=%s" % self.settings['backgroundMap'])
+
# run the command
vedit = gcmd.Command(cmd=command, stderr=None)
@@ -862,7 +865,7 @@
snap, thresh = self.__getSnapThreshold()
nlines = self.digit.MoveLines(move[0], move[1], 0.0, # TODO 3D
- snap, thresh)
+ str(self.settings["backgroundMap"]), snap, thresh)
return nlines
@@ -879,7 +882,7 @@
return self.digit.MoveVertex(coords[0], coords[1], 0.0, # TODO 3D
move[0], move[1], 0.0,
- snap, thresh)
+ str(self.settings["backgroundMap"]), snap, thresh)
def AddVertex(self, coords):
"""Add new vertex to the selected line/boundary on position 'coords'
Modified: grass/trunk/gui/wxpython/vdigit/digit.h
===================================================================
--- grass/trunk/gui/wxpython/vdigit/digit.h 2008-02-05 21:39:40 UTC (rev 29962)
+++ grass/trunk/gui/wxpython/vdigit/digit.h 2008-02-05 23:42:44 UTC (rev 29963)
@@ -14,6 +14,7 @@
DisplayDriver *display;
int SetCategory(int, int);
+ struct Map_info** OpenBackgroundVectorMap(const char *);
public:
Digit(DisplayDriver *);
@@ -28,7 +29,7 @@
int DeleteLines(bool);
int MoveLines(double, double, double,
- int, double);
+ const char*, int, double);
int FlipLines();
int MergeLines();
int BreakLines();
@@ -40,7 +41,7 @@
int MoveVertex(double, double, double,
double, double, double,
- int, double);
+ const char*, int, double);
int ModifyLineVertex(int, double, double, double,
double);
Modified: grass/trunk/gui/wxpython/vdigit/grass6_wxvdigit_wrap.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/grass6_wxvdigit_wrap.cpp 2008-02-05 21:39:40 UTC (rev 29962)
+++ grass/trunk/gui/wxpython/vdigit/grass6_wxvdigit_wrap.cpp 2008-02-05 23:42:44 UTC (rev 29963)
@@ -11044,8 +11044,9 @@
double arg2 ;
double arg3 ;
double arg4 ;
- int arg5 ;
- double arg6 ;
+ char *arg5 = (char *) 0 ;
+ int arg6 ;
+ double arg7 ;
int result;
void *argp1 = 0 ;
int res1 = 0 ;
@@ -11055,18 +11056,22 @@
int ecode3 = 0 ;
double val4 ;
int ecode4 = 0 ;
- int val5 ;
- int ecode5 = 0 ;
- double val6 ;
+ int res5 ;
+ char *buf5 = 0 ;
+ int alloc5 = 0 ;
+ int val6 ;
int ecode6 = 0 ;
+ double val7 ;
+ int ecode7 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
PyObject * obj3 = 0 ;
PyObject * obj4 = 0 ;
PyObject * obj5 = 0 ;
+ PyObject * obj6 = 0 ;
- if (!PyArg_ParseTuple(args,(char *)"OOOOOO:Digit_MoveLines",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail;
+ if (!PyArg_ParseTuple(args,(char *)"OOOOOOO:Digit_MoveLines",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6)) 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_MoveLines" "', argument " "1"" of type '" "Digit *""'");
@@ -11087,20 +11092,27 @@
SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "Digit_MoveLines" "', argument " "4"" of type '" "double""'");
}
arg4 = static_cast< double >(val4);
- ecode5 = SWIG_AsVal_int(obj4, &val5);
- if (!SWIG_IsOK(ecode5)) {
- SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "Digit_MoveLines" "', argument " "5"" of type '" "int""'");
- }
- arg5 = static_cast< int >(val5);
- ecode6 = SWIG_AsVal_double(obj5, &val6);
+ res5 = SWIG_AsCharPtrAndSize(obj4, &buf5, NULL, &alloc5);
+ if (!SWIG_IsOK(res5)) {
+ SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "Digit_MoveLines" "', argument " "5"" of type '" "char const *""'");
+ }
+ arg5 = reinterpret_cast< char * >(buf5);
+ ecode6 = SWIG_AsVal_int(obj5, &val6);
if (!SWIG_IsOK(ecode6)) {
- SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "Digit_MoveLines" "', argument " "6"" of type '" "double""'");
+ SWIG_exception_fail(SWIG_ArgError(ecode6), "in method '" "Digit_MoveLines" "', argument " "6"" of type '" "int""'");
}
- arg6 = static_cast< double >(val6);
- result = (int)(arg1)->MoveLines(arg2,arg3,arg4,arg5,arg6);
+ arg6 = static_cast< int >(val6);
+ ecode7 = SWIG_AsVal_double(obj6, &val7);
+ if (!SWIG_IsOK(ecode7)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "Digit_MoveLines" "', argument " "7"" of type '" "double""'");
+ }
+ arg7 = static_cast< double >(val7);
+ result = (int)(arg1)->MoveLines(arg2,arg3,arg4,(char const *)arg5,arg6,arg7);
resultobj = SWIG_From_int(static_cast< int >(result));
+ if (alloc5 == SWIG_NEWOBJ) delete[] buf5;
return resultobj;
fail:
+ if (alloc5 == SWIG_NEWOBJ) delete[] buf5;
return NULL;
}
@@ -11363,8 +11375,9 @@
double arg5 ;
double arg6 ;
double arg7 ;
- int arg8 ;
- double arg9 ;
+ char *arg8 = (char *) 0 ;
+ int arg9 ;
+ double arg10 ;
int result;
void *argp1 = 0 ;
int res1 = 0 ;
@@ -11380,10 +11393,13 @@
int ecode6 = 0 ;
double val7 ;
int ecode7 = 0 ;
- int val8 ;
- int ecode8 = 0 ;
- double val9 ;
+ int res8 ;
+ char *buf8 = 0 ;
+ int alloc8 = 0 ;
+ int val9 ;
int ecode9 = 0 ;
+ double val10 ;
+ int ecode10 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
@@ -11393,8 +11409,9 @@
PyObject * obj6 = 0 ;
PyObject * obj7 = 0 ;
PyObject * obj8 = 0 ;
+ PyObject * obj9 = 0 ;
- if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOO:Digit_MoveVertex",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8)) SWIG_fail;
+ if (!PyArg_ParseTuple(args,(char *)"OOOOOOOOOO:Digit_MoveVertex",&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7,&obj8,&obj9)) 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_MoveVertex" "', argument " "1"" of type '" "Digit *""'");
@@ -11430,20 +11447,27 @@
SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "Digit_MoveVertex" "', argument " "7"" of type '" "double""'");
}
arg7 = static_cast< double >(val7);
- ecode8 = SWIG_AsVal_int(obj7, &val8);
- if (!SWIG_IsOK(ecode8)) {
- SWIG_exception_fail(SWIG_ArgError(ecode8), "in method '" "Digit_MoveVertex" "', argument " "8"" of type '" "int""'");
- }
- arg8 = static_cast< int >(val8);
- ecode9 = SWIG_AsVal_double(obj8, &val9);
+ res8 = SWIG_AsCharPtrAndSize(obj7, &buf8, NULL, &alloc8);
+ if (!SWIG_IsOK(res8)) {
+ SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "Digit_MoveVertex" "', argument " "8"" of type '" "char const *""'");
+ }
+ arg8 = reinterpret_cast< char * >(buf8);
+ ecode9 = SWIG_AsVal_int(obj8, &val9);
if (!SWIG_IsOK(ecode9)) {
- SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "Digit_MoveVertex" "', argument " "9"" of type '" "double""'");
+ SWIG_exception_fail(SWIG_ArgError(ecode9), "in method '" "Digit_MoveVertex" "', argument " "9"" of type '" "int""'");
}
- arg9 = static_cast< double >(val9);
- result = (int)(arg1)->MoveVertex(arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9);
+ arg9 = static_cast< int >(val9);
+ ecode10 = SWIG_AsVal_double(obj9, &val10);
+ if (!SWIG_IsOK(ecode10)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode10), "in method '" "Digit_MoveVertex" "', argument " "10"" of type '" "double""'");
+ }
+ arg10 = static_cast< double >(val10);
+ result = (int)(arg1)->MoveVertex(arg2,arg3,arg4,arg5,arg6,arg7,(char const *)arg8,arg9,arg10);
resultobj = SWIG_From_int(static_cast< int >(result));
+ if (alloc8 == SWIG_NEWOBJ) delete[] buf8;
return resultobj;
fail:
+ if (alloc8 == SWIG_NEWOBJ) delete[] buf8;
return NULL;
}
Modified: grass/trunk/gui/wxpython/vdigit/line.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/line.cpp 2008-02-05 21:39:40 UTC (rev 29962)
+++ grass/trunk/gui/wxpython/vdigit/line.cpp 2008-02-05 23:42:44 UTC (rev 29963)
@@ -70,28 +70,13 @@
BgMap = NULL;
nbgmaps = 0;
-
if (bgmap && strlen(bgmap) > 0) {
- char name[GNAME_MAX];
- char mapset[GMAPSET_MAX];
- if (G_find_vector2 (bgmap, "") == NULL) {
+ BgMap = OpenBackgroundVectorMap(bgmap);
+ if (!BgMap) {
return -1;
}
-
- G__name_is_fully_qualified(bgmap, name, mapset);
- if (strcmp(G_fully_qualified_name((const char*) display->mapInfo->name, (const char*) G_mapset()),
- G_fully_qualified_name((const char*) bgmap, (const char*) mapset))) {
+ else {
nbgmaps = 1;
- BgMap = (struct Map_info**) G_malloc (nbgmaps * sizeof(struct Map_info*));
- BgMap[nbgmaps-1] = (struct Map_info *) G_malloc (sizeof(struct Map_info));
-
- // avoid GUI crash
- Vect_set_fatal_error(GV_FATAL_PRINT);
-
- if (Vect_open_old(BgMap[nbgmaps-1], name, mapset) == -1) {
- G_free ((void *) BgMap[nbgmaps-1]);
- return -1;
- }
}
}
@@ -345,6 +330,7 @@
\brief Move selected vector features
\param move_x,move_y,move_z move direction (move_z is used only if map is 3D)
+ \param bgmap map of background map or NULL
\param snap snapping move (see vedit.h)
\param thresh threshold value for snapping
@@ -352,17 +338,36 @@
\return -1 on error
*/
int Digit::MoveLines(double move_x, double move_y, double move_z,
- int snap, double thresh)
+ const char *bgmap, int snap, double thresh)
{
int ret;
+ struct Map_info **BgMap; /* backgroud vector maps */
+ int nbgmaps; /* number of registrated background maps */
if (!display->mapInfo)
return -1;
- ret = Vedit_move_lines(display->mapInfo, display->selected,
+ BgMap = NULL;
+ nbgmaps = 0;
+ if (bgmap && strlen(bgmap) > 0) {
+ BgMap = OpenBackgroundVectorMap(bgmap);
+ if (!BgMap) {
+ return -1;
+ }
+ else {
+ nbgmaps = 1;
+ }
+ }
+
+ ret = Vedit_move_lines(display->mapInfo, BgMap, nbgmaps,
+ display->selected,
move_x, move_y, move_z,
snap, thresh);
+ if (BgMap && BgMap[0]) {
+ Vect_close(BgMap[0]);
+ }
+
return ret;
}
@@ -551,3 +556,52 @@
return ret;
}
+
+/**
+ \brief Open background vector map
+
+ @todo support more background maps then only one
+
+ \param bgmap pointer to vector map name
+
+ \return vector map array
+ \return NULL on error
+*/
+struct Map_info** Digit::OpenBackgroundVectorMap(const char *bgmap)
+{
+ char name[GNAME_MAX];
+ char mapset[GMAPSET_MAX];
+ int nbgmaps;
+ struct Map_info** BgMap;
+
+ if (!display->mapInfo) {
+ return NULL;
+ }
+
+ if (G_find_vector2 (bgmap, "") == NULL) {
+ return NULL;
+ }
+
+ nbgmaps = 0;
+
+ if (!G__name_is_fully_qualified(bgmap, name, mapset)) {
+ G_strncpy(name, bgmap, GNAME_MAX);
+ mapset[0] = '\0';
+ }
+ if (strcmp(G_fully_qualified_name((const char*) display->mapInfo->name, (const char*) G_mapset()),
+ G_fully_qualified_name((const char*) bgmap, (const char*) mapset))) {
+ nbgmaps = 1;
+ BgMap = (struct Map_info**) G_malloc (nbgmaps * sizeof(struct Map_info*));
+ BgMap[nbgmaps-1] = (struct Map_info *) G_malloc (sizeof(struct Map_info));
+
+ // avoid GUI crash
+ Vect_set_fatal_error(GV_FATAL_PRINT);
+
+ if (Vect_open_old(BgMap[nbgmaps-1], name, mapset) == -1) {
+ G_free ((void *) BgMap[nbgmaps-1]);
+ BgMap = NULL;
+ }
+ }
+
+ return BgMap;
+}
Modified: grass/trunk/gui/wxpython/vdigit/vertex.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/vertex.cpp 2008-02-05 21:39:40 UTC (rev 29962)
+++ grass/trunk/gui/wxpython/vdigit/vertex.cpp 2008-02-05 23:42:44 UTC (rev 29963)
@@ -25,6 +25,7 @@
\param x,y,z coordinates (z is used only if map is 3d)
\param move_x,move_y,move_z direction for moving vertex
+ \param bgmap map of background map or NULL
\param snap snap mode (see vector/v.edit/lib/vedit.h)
\param thresh threshold value to identify vertex position
@@ -34,24 +35,42 @@
*/
int Digit::MoveVertex(double x, double y, double z,
double move_x, double move_y, double move_z,
- int snap, double thresh) {
+ const char *bgmap, int snap, double thresh) {
int ret;
struct line_pnts *point;
+ struct Map_info **BgMap; /* backgroud vector maps */
+ int nbgmaps; /* number of registrated background maps */
if (!display->mapInfo)
return -1;
+ BgMap = NULL;
+ nbgmaps = 0;
+ if (bgmap && strlen(bgmap) > 0) {
+ BgMap = OpenBackgroundVectorMap(bgmap);
+ if (!BgMap) {
+ return -1;
+ }
+ else {
+ nbgmaps = 1;
+ }
+ }
+
point = Vect_new_line_struct();
Vect_append_point(point, x, y, z);
/* move only first found vertex in bbox */
- ret = Vedit_move_vertex(display->mapInfo, NULL, 0, /* TODO: BG */
+ ret = Vedit_move_vertex(display->mapInfo, BgMap, nbgmaps,
display->selected,
point, thresh,
move_x, move_y, move_z,
1, snap);
+ if (BgMap && BgMap[0]) {
+ Vect_close(BgMap[0]);
+ }
+
Vect_destroy_line_struct(point);
return ret;
More information about the grass-commit
mailing list