swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Colormap/Zoomraster problem (?)


From: Ken Cline
Subject: Re: Colormap/Zoomraster problem (?)
Date: Thu, 31 Jan 2002 22:12:47 -0800 (PST)

--- "William T. Stockhausen" <address@hidden> wrote:
> I'm using the Swarm 2.2 pre-release (version 2, I think).
> I've run into a problem when assigning a colormap to a
> zooomraster.  I create 2 colormaps and 3 zoomrasters in
> a GUI ObserverSwarm using the code snippet:
    [snip]
> When the third zoomraster (zrBenthicDensity) is created,
> I get the following error when the program attempts the
> line "zrT.setColormap (cmO);" in
> CreateZoomRaster:
>   *** event raised for error: InvalidArgument
>   *** function: _i_Colormap__setColor_ToName_(), file:
>     /src/Swarm/swarm/src/tkobjc/Colormap.m, line: 64
>     attempted to set color 255 twice
>   *** execution terminating due to error
   [snip]
> As far as I can tell, I'm not changing the colormap
> (cmDensity) at all--I'm just assigning it to the new
> zoomraster. Any ideas?

(Note: see disclaimer below)

One of the steps that is performed when a raster's
setColormap method is called is assignment of the "erase"
color.  The erase color is always black and it stored in
the next free (unassigned) slot in the colormap.

With your cmDensity colormap there is only 1 free slot for
the erase color, ie color 255. The first time setColormap
is called with cmDensity, color 255 is set to black. Then,
when zrBenthicDensity is created and cmDensity is used
again, the internal swarm code tries to assign black to
color 255 again which is not allowed.

> 1. Do I need to create another colormap, so that each
>     zoomraster uses a unique colormap?
The swarm libraries can probably be changed to allow
colormap sharing (see suggestion changes below) assuming
that there aren't other side-effects...

In the meantime, here are some possible workarounds:
  1. Using a unique colormap for each raster, as you
       already guessed, should work.  (It doesn't look
       like Colormap supports the 'copy' method so you'll
       need to build it from scratch.)
  2. Unset color 255 before trying to create the third
       zoomraster.  (Yes, its a hack, and a rather fragile
       one at that... whatever works eh?)

> 2. Or should I only be creating one colormap and using
>      it for each zoomraster?
Nope.

> [Previously, the code ran fine when I (accidentally, as
> it happens) assigned just one colormap (cmHabitat) to
> all three zoomrasters--although the colors weren't what
> I expected for the two Density zoomrasters.]

The cmHabitat colormap only uses the first to slots in the
map so you would not get an error unless you tried to use
it with more that 253 rasters. =8-)

Hope that helps.

[Disclaimer: I haven't used swarm in a while and the advise
 given should be taken with a (proverbial) grain of salt.
=8-]


Marcus,

In the internal.m file, what do you think about adding a
check to see if eraseColor is set before setting it?  That
is:
  if ( [colormap colorIsSet: raster->eraseColor] ) {
    // Check that raster->eraseColor == "black",
    // if not raise error...  Or, do we care?
  } else {
    raster->eraseColor = [colormap nextFreeColor];
    [colormap setColor: raster->eraseColor
                ToName: "black"];
  }
Would this introduce a potential for other conflicts?

Also, in the Colormap.m file, the nextFreeColor method
assumes that color MAXCOLORS -1 (ie 255) is not set. How
about changing the the if statement from:
    if (isSet[i - 1])
       return i;
to:
    if ( isSet[i - 1] && ! isSet[i] )
       return i;

Ken.


=====
end
_________________________________________________________
 Ken Cline                             W: (410) 897-1211
 address@hidden

__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions! 
http://auctions.yahoo.com

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]