swarm-support
[Top][All Lists]
Advanced

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

Re: Mapping float values to colors.


From: Fabio Mascelloni
Subject: Re: Mapping float values to colors.
Date: Thu, 29 Jul 1999 15:31:04 +0200

"Marcus G. Daniels" wrote:
> 
> 
> I'll test your code with 2.0 (and 1.4.1) if you send me a
> self-contained example.  I can't guess what the problem is from the
> information you provided.

Thank you for your interest,but finally I've gived up this way
because,after having tried the solution provided by Ken (subclassing
Colormap and overriding colorIsSet: method) the Raster
had an awful aspect (big squares of different colours with no shades)
because of the small dimension of the matrix I've to display (8*8).I
also thought that I could set the 
Raster's size to 80*80 and then map each mean matrix's element to a
10*10 sub-raster,but the result isn't better (by the way ,why does the
raster gets updated only when i resize the window?).
Then I tried to use a Diffuse2d - taking example from RepeatingHeatBugs
-,this time binding colors to the sum of values and not to the mean,in
this way:

In the OberverSwarm I've built the Raster (dsplRaster) and a a
Value2dDisplay object:
 
  cDisplay = [Value2dDisplay createBegin: self];
//The colormap has been initialized as in "RepeatingHeatBugs"
  [cDisplay setDisplayWidget: dsplRaster colormap: initCmap];
// "handler" is the name of the ModelSwarm,"getSpace" returns the
Diffuse2d object
  [cDisplay setDiscrete2dToDisplay: [handler getSpace]];
  [cDisplay setDisplayMappingM: 512 C: 0];        
  cDisplay = [cDisplay createEnd];

In the modelSwarm I've put the Diffuse2d object:
    
  diffuseSpace=[Diffuse2d createBegin:[self getZone]];
        //Tipically: diffWidth==diffHeight==80
        [diffuseSpace setSizeX: diffWidth Y: diffHeight];
        [diffuseSpace setDiffusionConstant: diffuseConstant];
        [diffuseSpace setEvaporationRate: evaporationRate];
 diffuseSpace = [diffuseSpace createEnd];

       
 The ModelSwarm's schedule is:
        
        [handlActions createActionTo: diffuseSpace message:
M(stepRule)];
        [handlActions createActionTo: self message: M(updateStructure)];
        [handlActions createActionTo: diffuseSpace message: M(updateLattice)];  

where

- updateStructure
{
        
        unsigned i,j,start_row=0,start_col=0;
        unsigned subrow,subcol;
        
        for (i=0;i<matrixDim;i++)
         {      
                for (j=0;j<matrixDim;j++)
                {
                
                *(data_sum+matrixDim*i+j) +=[uniformUnsRand getUnsignedWithMin:0
withMax:1];
                
                //Sets each 10*10 sub-area's color 
                for (subrow = start_row ; subrow < (start_row+10) ;
subrow++)
                  for (subcol = start_col ; subcol <(start_col+10) ; subcol++)  
        
                     
                        [diffuseSpace putValue:*(data_sum+matrixDim*i+j) atX: 
subrow Y:
subcol];                
                     start_col +=10;
                 }
         start_row+=10;
         }
                        
                return self;
}

while the ObserverSwarm schedule is:
[dsplActions createActionTo: self message: M(update)];
[dsplActions createActionTo: probeDisplayManager message: M(update)];
[dsplActions createActionTo: actionCache message: M(doTkEvents)];

where

- update
{
        [cDisplay display];
        [dsplRaster drawSelf];
        return self;
}

But this hasn't led to a result,too.The raster remains black and nothing
seems to happen.I can't really figure out what's missing though I've
tried to be as closer as possible to the graphical structure of
RHeatBugs.
Fabio.

                  ==================================
   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]