[GRASS5] embedding GRASS display into my app

Thierry Laronde tlaronde at polynum.com
Tue Apr 6 19:17:12 EDT 2004


Hello,

On Tue, Apr 06, 2004 at 02:15:36PM -0700, David Piasecki wrote:
> I want to write an application that uses GRASS as the back end to an 
> application I plan to write. I need to embed the GRASS display into my 
> application. I haven't started yet, though C++ would be easiest for me. 
> If I have to learn Tcl/Tk, that's fine too. From what I understand, I 
> should be able to modify the XDRIVER in GRASS to handle events in my 
> application's main window, and I should be able to use TkSteal to 
> actually embed the graphics display for GRASS into my application's 
> main window. I'm not exactly clear on how to do all this considering 
> I'm new to GRASS and Tcl/Tk. I found a paper online saying it has been 
> done, but I haven't heard of anyone else that's done it, and I haven't 
> seen any documentation on how to do it. Any help you could provide 
> would be greatly appreciated.

Since you do not specify which paper you've found, I answer since I have
written that I was rewriting XDRIVER and I don't know if you refer to
this.

I don't know either what is the status with Tcl/Tk but I will give you
some tips about the display stuff.

The XDRIVER by itself does _just_ the display. Commands are passed from
the applications to the driver (IPC) using a GRASS defined protocol 
requesting for drawing on the hardware (for X). The commands are
"interpreted" by a SWITCHER (SWITCHER.c) which calls the matching
commands implemented to drive the hardware (here hardware is indeed X11
server, a small Xlib only client being part of XDRIVER).

For the most important, the applications don't deal directly with the
X11 colormap, but with a GRASS colormap which indirectly points to
entries in X11 colormap (a GRASS colormap index gives a X11 pixel which
is itself an index in the X11 colormap).

The X11 color accepts 2^48 colors. A X11 colormap can handle a
number of colors depending on the depth, red, green and blue being
not automatically evenly treated (with a 8 bits depth on a visual class
that is TrueColor or DirectColor, you have 8 shades of red, 8 shades 
of green but 4 shades of blue). And the "hard" hardware (the monitor)
handles another plage of colors (a subset of the theorical 2^48).

XDRIVER and the GRASS "internal" colormap accept 2^24 colors evenly 
distributed. (as of the original code; may have changed now).

To extend further the XDRIVER (and treat it more like a classic X11
client) you have to throw upon it a widget (there comes the decision
about what toolkit to use).

FWIW, I have rewritten the XDRIVER (in CWEB --- this is NOT, for the
ones who don't know what it is, a kind of Internet, C#, .NET, Java...; 
nothing to do with "the Web" or other. This is pure C (could be C++, 
but I stick to C since it's God's own programming language) + TeX for 
the documentation  --- and this is simply great!).

And I have changed the colors handling in (KerGIS), and the default
colors (to match ISO 6429 extensions in xterm) etc... 
And the toolkit chosen is Motif (for the future). 

But since it's not what you are looking for, I hope the explanations 
above will give you some hints.


Cheers,
-- 
Thierry Laronde (Alceste) <tlaronde at polynum.org>
http://www.kergis.org/  |  http://www.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C




More information about the grass-dev mailing list