[GRASS-dev] random colors in d.vect

Hi all,

I have tried to implement *random* colouring based on category number
(according to layer number can be implemented later before CVS
committing...), see the attached patch.

I do not completely understand why you need to use in level 2
Vect_line_alive() + Vect_read_line() in contrast with level 1 and
function Vect_read_next_line (). In any case the functions
Vect_read_line () and Vect_read_next_line behave in the same way -
they may return 'line number', -1 or -2. So I do not know why
variable 'ltype' is tested only (switch (ltype)) in level 1.

Best regards, Martin

PS: Temporarily I have no GNU/Linux PC with Internet connection, so
this patch is against CVS snapshot from 2006/05/27.

(attachments)

d_vect_random_cols-2006-05-31.diff.gz (1.82 KB)

Hi,

What's different between 'd.vect -c' and your patch? The -c flag also
implements random colors based on category/layer number.

Huidae Cho

On Wed, May 31, 2006 at 11:36:10AM +0200, Martin Landa wrote:

Hi all,

I have tried to implement *random* colouring based on category number
(according to layer number can be implemented later before CVS
committing...), see the attached patch.

I do not completely understand why you need to use in level 2
Vect_line_alive() + Vect_read_line() in contrast with level 1 and
function Vect_read_next_line (). In any case the functions
Vect_read_line () and Vect_read_next_line behave in the same way -
they may return 'line number', -1 or -2. So I do not know why
variable 'ltype' is tested only (switch (ltype)) in level 1.

Best regards, Martin

PS: Temporarily I have no GNU/Linux PC with Internet connection, so
this patch is against CVS snapshot from 2006/05/27.

_______________________________________________
grass-dev mailing list
grass-dev@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev

Hi,

the difference is that the current implementation use 'pseudo random'
colors (e.g. cat % palette_ncolors), i.e. the color composition is
always the same. The patch changes this behaviour, it means, you will
not get the same colours by d.vect -c (it is useful if you do not like
the current colors).

Best, Martin

2006/5/31, Huidae Cho <grass4u@gmail.com>:

Hi,

What's different between 'd.vect -c' and your patch? The -c flag also
implements random colors based on category/layer number.

Huidae Cho

On Wed, May 31, 2006 at 11:36:10AM +0200, Martin Landa wrote:
> Hi all,
>
> I have tried to implement *random* colouring based on category number
> (according to layer number can be implemented later before CVS
> committing...), see the attached patch.
>
> I do not completely understand why you need to use in level 2
> Vect_line_alive() + Vect_read_line() in contrast with level 1 and
> function Vect_read_next_line (). In any case the functions
> Vect_read_line () and Vect_read_next_line behave in the same way -
> they may return 'line number', -1 or -2. So I do not know why
> variable 'ltype' is tested only (switch (ltype)) in level 1.
>
> Best regards, Martin
>
> PS: Temporarily I have no GNU/Linux PC with Internet connection, so
> this patch is against CVS snapshot from 2006/05/27.

> _______________________________________________
> grass-dev mailing list
> grass-dev@grass.itc.it
> http://grass.itc.it/mailman/listinfo/grass-dev

Hi all,

I have rewritten the previous patch. I have separated the added code
to a function random_color() and tried to clean the code. Now it works
also for layer=-1 (i.e. according to layer number). There is also a
small bug in the current d.vect. Flag -c does not work (in connection
with layer=-1) for areas. It should be also solved. Please test it if
you like, I have no access to the CVS...

Best, Martin

PS: I think that default value for parameter 'layer' should be -1
instead of 1. Generally, I want to display all objects no matter which
layer they are stored in.

2006/5/31, Martin Landa <landa.martin@gmail.com>:

Hi,

the difference is that the current implementation use 'pseudo random'
colors (e.g. cat % palette_ncolors), i.e. the color composition is
always the same. The patch changes this behaviour, it means, you will
not get the same colours by d.vect -c (it is useful if you do not like
the current colors).

Best, Martin

2006/5/31, Huidae Cho <grass4u@gmail.com>:
> Hi,
>
> What's different between 'd.vect -c' and your patch? The -c flag also
> implements random colors based on category/layer number.
>
> Huidae Cho
>
> On Wed, May 31, 2006 at 11:36:10AM +0200, Martin Landa wrote:
> > Hi all,
> >
> > I have tried to implement *random* colouring based on category number
> > (according to layer number can be implemented later before CVS
> > committing...), see the attached patch.
> >
> > I do not completely understand why you need to use in level 2
> > Vect_line_alive() + Vect_read_line() in contrast with level 1 and
> > function Vect_read_next_line (). In any case the functions
> > Vect_read_line () and Vect_read_next_line behave in the same way -
> > they may return 'line number', -1 or -2. So I do not know why
> > variable 'ltype' is tested only (switch (ltype)) in level 1.
> >
> > Best regards, Martin
> >
> > PS: Temporarily I have no GNU/Linux PC with Internet connection, so
> > this patch is against CVS snapshot from 2006/05/27.
>
> > _______________________________________________
> > grass-dev mailing list
> > grass-dev@grass.itc.it
> > http://grass.itc.it/mailman/listinfo/grass-dev
>

(attachments)

d_vect_random_cols-2006-06-01.diff.gz (2.29 KB)

Martin Landa wrote:

Hi all,

I have rewritten the previous patch. I have separated the added code
to a function random_color() and tried to clean the code. Now it works
also for layer=-1 (i.e. according to layer number). There is also a
small bug in the current d.vect. Flag -c does not work (in connection
with layer=-1) for areas. It should be also solved. Please test it if
you like, I have no access to the CVS...

Any chance of allowing random colors according to an attribute column instead of cat ?

Moritz

Hi,

good idea, I will try to add it...

Best, Martin

2006/6/2, Moritz Lennert <mlennert@club.worldonline.be>:

Martin Landa wrote:
> Hi all,
>
> I have rewritten the previous patch. I have separated the added code
> to a function random_color() and tried to clean the code. Now it works
> also for layer=-1 (i.e. according to layer number). There is also a
> small bug in the current d.vect. Flag -c does not work (in connection
> with layer=-1) for areas. It should be also solved. Please test it if
> you like, I have no access to the CVS...

Any chance of allowing random colors according to an attribute column
instead of cat ?

Moritz