Does anyone out there have a copy of d.vect
that allows the user to specify the width
of polylines (like in p.map and p.map.new)?
--Xin
Does anyone out there have a copy of d.vect
that allows the user to specify the width
of polylines (like in p.map and p.map.new)?
--Xin
Hi,
In fact I have a version of d.vect that lets you specify color and linewidth.
But, in order to achieve this you will have to change a number of things
in your source code. The modifications you make will only give results when
you use the XDRIVER for display.
I have modified the raster library, the Xdriver, and recompiled every program
that displays things on the graphics window.
This is what you have to do:
Create a file in $GISBASE/src/raster called
Linemod.c
*************************************
#include "graph.h"
R_linemode(index)
int index;
{
int i;
i = index;
_send_ident(LINEMOD) ;
_send_int(&i);
}
*************************************
This function is called by every program that wants to change the linewidth.
Then you have to add the line
R_linemode(0);
in the file $GISBASE/libes/raster/io/c.
after the lines:
default:
sync_driver(name); /* syncronize driver */
and recompile the the raster library. Don't forget to add the Linemod.c in the
Gmakefile.
Next you have to do is modifying your Xdriver.
Edit the file:
$GISBASE/src/display/devices/XDRIVER/XDRIVER/SWITCHER.c
Uncomment the line
/* Linemod(index); */
Create a file
$GISBASE/src/display/devices/XDRIVER/XDRIVER/Linemod.c
*************************************************
#include <stdio.h>
#include "includes.h"
extern Display *dpy;
extern GC gc;
Linemod(number)
int number;
{
XSetLineAttributes (dpy, gc, number, NULL, NULL, NULL );
}
***************************************************
and recompile your XDRIVER. (Don't forget to add Linemod.c in the Gmakefile)
Now the basics is done. In fact you can now use the R_linemode() call in your
programs.
For d.vect it's simple, just edit the file:
$GISBASE/src/display/d.vect/cmd/main.c:
edit the line
int i, stat ;
to be
int i, stat, width ;
edit the line
struct Option *opt1, *opt2;
to be
struct Option *opt1, *opt2, *opt3;
Insert the following lines ;
Opt3 = G_define_option() ;
opt3->key="width";
opt3->type=TYPE_INTEGER;
opt3->anser = "0" ;
opt3->description="Linewidth";
between
opt2->description="Color desired for drawing map";
and
G_gisinit(argv[0]);
The last thing you have to do is add the line:
R_linemode(width);
after the line
R_standard_color(color);
Now recompile d.vect.
If you would not recompile all other display programs, and you would interrupt
the d.vect program, any other program would draw lines in the last selected
linemode.
I have another program which uses a lookup table for setting colors and line-
widths, based on attributenumber. This program is called d.vect.lu, An older
version in the incoming directory on moon. As soon as I have time, I will
put a new version there, which also takes linewidth into account.
Ronald Wiemer