[GRASSLIST:10054] Re: v.digit additions
Ralf Gerlich
ralf.gerlich at bsse.biz
Mon Jan 30 13:38:54 EST 2006
Hi Eric,
> Can your tarfile overwrite existing programs? And in what directory does the
> v.digit tarfile need to be extracted from?
You should extract that tarfile outside of the GRASS sourcetree in a new
directory. It contains three diffs which you need to apply from the root
of the GRASS sourcetree using
patch -p0 < {patchfile}
The tarfile also contains two gif-files which need to be placed in
vector/v.digit/icons
However, I had to add a little fix to the copy-cats.diff. I have
attached the replacement. Ignore the copy-cats.diff from the tar-file
and use the one attached to this mail.
Best regards,
Ralf
-------------- next part --------------
? vector/v.digit/OBJ.i486-pc-linux-gnu
? vector/v.digit/icons/copy.cats.gif
? vector/v.digit/icons/edit.line.gif
Index: vector/v.digit/attr.c
===================================================================
RCS file: /home/grass/grassrepository/grass6/vector/v.digit/attr.c,v
retrieving revision 1.6
diff -u -r1.6 attr.c
--- vector/v.digit/attr.c 14 Jan 2005 11:20:36 -0000 1.6
+++ vector/v.digit/attr.c 30 Jan 2006 18:15:17 -0000
@@ -241,6 +241,132 @@
return 1;
}
+
+/* Copy categories from one feature to another */
+int copy_cats (void)
+{
+ int line, src_line, dest_line, new_line, type, i;
+ int sxn, syn, button;
+ double x,y,thresh;
+ struct line_pnts* Points;
+ struct line_cats *Src_Cats,*Dest_Cats;
+
+ G_debug (2, "copy_cats()");
+
+ Points = Vect_new_line_struct ();
+ Src_Cats = Vect_new_cats_struct ();
+ Dest_Cats = Vect_new_cats_struct ();
+
+ i_prompt ( "Copy attributes:");
+ i_prompt_buttons ( "Select source object", "", "Quit tool");
+
+ driver_open();
+
+ /* TODO: use some better threshold */
+ thresh = fabs ( D_d_to_u_col ( 10 ) - D_d_to_u_col ( 0 ) ) ;
+ G_debug (2, "thresh = %f", thresh );
+
+ line = 0;
+ src_line = 0;
+ dest_line = 0;
+ sxn = COOR_NULL; syn = COOR_NULL;
+ while ( 1 ) {
+ /* Get next coordinate */
+ R_set_update_function ( update );
+ R_get_location_with_pointer ( &sxn, &syn, &button);
+
+ if (button==0 || button==3) break; /* Quit tool */
+
+ x = D_d_to_u_col ( sxn );
+ y = D_d_to_u_row ( syn );
+ G_debug (3, "button = %d x = %d = %f y = %d = %f", button, sxn, x, syn, y);
+
+ if (src_line>0)
+ display_line (src_line, SYMB_DEFAULT, 1);
+ if (dest_line>0)
+ display_line (dest_line, SYMB_DEFAULT, 1);
+ if (button==1) {
+ line = Vect_find_line (&Map, x, y, 0, GV_LINES|GV_POINTS, thresh, 0, 0);
+ G_debug (3, "before: src_line=%d dest_line=%d line=%d",src_line,dest_line,line);
+ if (dest_line>0) {
+ /* We have a source- and a destination-object
+ * => copy categories */
+ type = Vect_read_line (&Map, Points, Dest_Cats, dest_line);
+ new_line = Vect_rewrite_line (&Map, dest_line, type, Points, Src_Cats);
+ if (line==dest_line)
+ line = new_line;
+ dest_line = new_line;
+
+ for (i=0; i<Dest_Cats->n_cats; i++) {
+ check_record (Dest_Cats->field[i], Dest_Cats->cat[i]);
+ }
+
+ updated_lines_and_nodes_erase_refresh_display ();
+
+ /* move the selections on */
+ src_line = dest_line;
+ dest_line = line;
+ } else if (src_line>0) {
+ /* We have a source-object and possibly a destination object
+ * was selected */
+ if (line<=0)
+ src_line = 0;
+ else if (line!=src_line)
+ dest_line = line;
+ } else {
+ /* We have no object selected and possible a source-object
+ * was selected => read its categories into Src_Cats */
+ src_line = line;
+ if (src_line>0)
+ Vect_read_line (&Map, Points, Src_Cats, src_line);
+ }
+ G_debug (3, "after: src_line=%d dest_line=%d line=%d",src_line,dest_line,line);
+ } else if (button==2) {
+ /* We need to deselect the last line selected */
+ if (dest_line>0) {
+ display_line (dest_line, SYMB_DEFAULT, 1);
+ dest_line = 0;
+ } else if (src_line>0) {
+ display_line (src_line, SYMB_DEFAULT, 1);
+ src_line = 0;
+ }
+ }
+
+ /* Display the selected lines accordingly and set the button prompts */
+ if (dest_line>0) {
+ display_line (dest_line, SYMB_HIGHLIGHT, 1);
+ display_line (src_line, SYMB_HIGHLIGHT, 1);
+ i_prompt("Select the target object");
+ i_prompt_buttons("Conform and select next","Deselect Target","Quit tool");
+ } else if (src_line>0) {
+ display_line (src_line, SYMB_HIGHLIGHT, 1);
+ i_prompt("Select the target object");
+ i_prompt_buttons("Select","Deselect Source","Quit tool");
+ } else {
+ i_prompt ( "Copy attributes:");
+ i_prompt_buttons ( "Select source object", "", "Quit tool");
+ }
+ }
+ if (dest_line>0)
+ display_line (dest_line, SYMB_DEFAULT, 1);
+ if (src_line>0)
+ display_line (src_line, SYMB_DEFAULT, 1);
+
+ driver_close();
+
+ i_prompt ("");
+ i_prompt_buttons ( "", "", "");
+ i_coor ( COOR_NULL, COOR_NULL);
+
+ Vect_destroy_line_struct (Points);
+ Vect_destroy_cats_struct (Src_Cats);
+ Vect_destroy_cats_struct (Dest_Cats);
+
+ G_debug (3, "copy_cats(): End");
+
+ return 1;
+}
+
/* Display attributes */
int display_attributes (void)
{
Index: vector/v.digit/c_face.c
===================================================================
RCS file: /home/grass/grassrepository/grass6/vector/v.digit/c_face.c,v
retrieving revision 1.13
diff -u -r1.13 c_face.c
--- vector/v.digit/c_face.c 25 Jan 2005 21:42:05 -0000 1.13
+++ vector/v.digit/c_face.c 30 Jan 2006 18:15:17 -0000
@@ -60,6 +60,8 @@
Tool_next = TOOL_DELETE_LINE;
else if ( strcmp ( tl, "display_cats" ) == 0 )
Tool_next = TOOL_DISPLAY_CATS;
+ else if ( strcmp ( tl, "copy_cats" ) == 0 )
+ Tool_next = TOOL_COPY_CATS;
else if ( strcmp ( tl, "display_attributes" ) == 0 )
Tool_next = TOOL_DISPLAY_ATTRIBUTES;
else if ( strcmp ( tl, "exit" ) == 0 )
Index: vector/v.digit/centre.c
===================================================================
RCS file: /home/grass/grassrepository/grass6/vector/v.digit/centre.c,v
retrieving revision 1.10
diff -u -r1.10 centre.c
--- vector/v.digit/centre.c 30 Sep 2003 14:58:36 -0000 1.10
+++ vector/v.digit/centre.c 30 Jan 2006 18:15:17 -0000
@@ -81,6 +81,10 @@
Tool_next = TOOL_NOTHING;
display_cats ();
break;
+ case TOOL_COPY_CATS :
+ Tool_next = TOOL_NOTHING;
+ copy_cats ();
+ break;
case TOOL_DISPLAY_ATTRIBUTES :
Tool_next = TOOL_NOTHING;
display_attributes ();
Index: vector/v.digit/global.h
===================================================================
RCS file: /home/grass/grassrepository/grass6/vector/v.digit/global.h,v
retrieving revision 1.11
diff -u -r1.11 global.h
--- vector/v.digit/global.h 18 Nov 2004 14:10:33 -0000 1.11
+++ vector/v.digit/global.h 30 Jan 2006 18:15:17 -0000
@@ -24,6 +24,7 @@
TOOL_MOVE_LINE,
TOOL_DELETE_LINE,
TOOL_DISPLAY_CATS,
+ TOOL_COPY_CATS,
TOOL_DISPLAY_ATTRIBUTES,
TOOL_ZOOM_WINDOW, /* zoom by window */
TOOL_ZOOM_OUT_CENTRE,
Index: vector/v.digit/toolbox.tcl
===================================================================
RCS file: /home/grass/grassrepository/grass6/vector/v.digit/toolbox.tcl,v
retrieving revision 1.15
diff -u -r1.15 toolbox.tcl
--- vector/v.digit/toolbox.tcl 3 May 2005 18:29:01 -0000 1.15
+++ vector/v.digit/toolbox.tcl 30 Jan 2006 18:15:18 -0000
@@ -168,6 +168,11 @@
-highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
-helptext [G_msg "Display categories"]
+$bbox add -image [image create photo -file "$vdpath/copy.cats.gif"] \
+ -command "c_next_tool copy_cats" \
+ -highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
+ -helptext [G_msg "Copy categories"]
+
$bbox add -image [image create photo -file "$vdpath/display.attributes.gif"] \
-command "c_next_tool display_attributes" \
-highlightthickness 0 -takefocus 0 -relief raised -borderwidth 1 \
More information about the grass-user
mailing list