[GRASS5] D_color

Hallo developers,
according to d.vect.thematic, I try to modify d.legend slightly, so it is
useable for vector maps too.

Now I created structure

struct vector_color { /* color of vector files */
            char *vcat;
            int red;
            int blue;
            int green;
        } vcolors[100];

which is able to save color values in R:G:B and category value for 100
categories in the vector file.

d.legend uses

    int D_color(int color)

but how to set the (int color) value for it from R:G:B colors?

I don't know, if I can make d.legend work with vector files, but I try it :slight_smile:

Jachym
--
Jachym Cepicky
e-mail: jachym.cepicky@centrum.cz
URL: http://les-ejk.cz
GPG: http://www.fle.czu.cz/~jachym/gnupg_public_key/

according to d.vect.thematic, I try to modify d.legend slightly, so it
is useable for vector maps too.

..

d.legend uses

    int D_color(int color)

but how to set the (int color) value for it from R:G:B colors?

Not looking at the code but as a general comment, d.legend has the
color= option which does not handle R:G:B input. It does use R:G:B
values to match the raster value's color. Keep in mind there are
multiple "color tables" in play, on the display driver level as well as
the map level.

see here for how to change the color for drawing, either by R:G:B or by
name:

http://freegis.org/cgi-bin/viewcvs.cgi/grass6/display/d.mapgraph/do_graph.c.diff?r1=2.0&r2=2.1

I don't know, if I can make d.legend work with vector files, but I try
it :slight_smile:

the structure for d.legend is *cough* rather intricate, and not broken
down into functions easily. Most of the structure exists somewhere in
the back of my head though. Please put the vector code in a function, a)
so I can quickly review it, and b) so the mess doesn't get worse (I want
to continue to understand how the module works).

Hamish

How to draw text to GRASS monitor?

I try this with

R_color(black);
R_set_window(t, b, l, r) ;
D_get_screen_window(&t, &b, &l, &r) ;

R_text_size(txsiz, txsiz);
R_move_abs(x0,y0);
strcpy(buff, "hallo world\n");
R_text(buff);

D_add_to_list(G_recreate_command());

but nothing is showen :frowning:

Thanks

Jachym

On Mon, May 16, 2005 at 05:01:55PM +0200, Jachym Cepicky wrote:

Hallo developers,
according to d.vect.thematic, I try to modify d.legend slightly, so it is
useable for vector maps too.

Now I created structure

struct vector_color { /* color of vector files */
            char *vcat;
            int red;
            int blue;
            int green;
        } vcolors[100];

which is able to save color values in R:G:B and category value for 100
categories in the vector file.

d.legend uses

    int D_color(int color)

but how to set the (int color) value for it from R:G:B colors?

I don't know, if I can make d.legend work with vector files, but I try it :slight_smile:

Jachym

--
Jachym Cepicky
e-mail: jachym.cepicky@centrum.cz
URL: http://les-ejk.cz
GPG: http://www.fle.czu.cz/~jachym/gnupg_public_key/

Jachym Cepicky wrote:

How to draw text to GRASS monitor?

I try this with

R_color(black);
R_set_window(t, b, l, r) ;
D_get_screen_window(&t, &b, &l, &r) ;

R_text_size(txsiz, txsiz);
R_move_abs(x0,y0);
strcpy(buff, "hallo world\n");
R_text(buff);

D_add_to_list(G_recreate_command());

but nothing is showen :frowning:

It's hard to say what's wrong without seeing the rest of the program.
However, the following simple test program works.

#include <stdio.h>
#include <stdlib.h>
#include <gis.h>
#include <raster.h>
#include <colors.h>

int main(int argc, char **argv)
{
  struct GModule *module;

  G_gisinit(argv[0]);

  module = G_define_module();
  module->description = "Draws text";

  if (argc > 1 && G_parser(argc, argv))
    exit(1);

  if (R_open_driver() != 0)
    G_fatal_error ("No graphics device selected");

  R_standard_color(BLACK);
  R_text_size(12, 12);
  R_move_abs(20, 20);
  R_text("hello, world");

  R_close_driver();

  return 0;
}

--
Glynn Clements <glynn@gclements.plus.com>