Messages from list : cormas@cirad.fr

Choose a topic among the following archives :

Re: [Fwd: Comment fixer un objet sur l'environnement de simulation et Comment changer les points de vue des agents?]

New Message Reply Date view Thread view Subject view Author view

Subject: Re: [Fwd: Comment fixer un objet sur l'environnement de simulation et Comment changer les points de vue des agents?]
From: Geraldine Abrami (Geraldine.Abrami@cirad.fr)
Date: Tue May 30 2006 - 11:58:17 CEST

Hi Romain and Abdou

* First Point :
The select: method is extracting a Collection from a Collection.
So with your iden variable is containing the collection of the cells
which y coordinate is 232.
And an ObjectLocation entity can be moved to a cell, not to a collection
of cells, which means you have to enumerate your collection.
I think the right method may be :

iden := (self theVegetations select: [:cell | cell id = 232]).
iden do: [:c |
    ressource := self newEntity: RessourceEau.
    resource isMovedTo: c].

* Second Point :
I've copied what is done in the ButorStar model to get nice images on my
cells.
It is actually cheating because it uses the spatial entity's pov, not
the object location pov. And not so practical because then you cannot
combine easily different spatial entity pov with you images.
But I think it is not so painfull!

1. First, some work has to be done on your cell class (the one that
inherits from SpatialEntityElement, and which is apprently called
Vegetation in your case)

 * define an instance variable (and its accessors) where the personal
image you want to display will be stored : for instance *objectLocationImage
** define the following method, that displays a scaled and centered
image on your cell :

*display**ObjectLocationImage*
* | scaledImage scaledImageCenter anImage scale scaleX scaleY |

    anImage := self **objectLocationImage**.
    anImage isNil ifTrue: [^nil].

"makes some calculation for resizing and recentering the image"
    scaleX := (anImage width / self image component width).
    scaleY := (anImage height / self image component height).
    scale := (scaleX max: scaleY)" max: 1".
    scale := scale/0.8.
    scaledImage := (anImage shrunkenBy: scale@scale).
    scaledImageCenter := (self image component corner translatedBy: self
center) - ((scaledImage width @ scaledImage height)).

"displays the image"
    scaledImage displayOn: self view graphicsContext at: scaledImageCenter.

** redefine the displayOn: method of SpatialEntityElement so that your
displayObjetcLocationImage is called when the grid is refreshing :
*displayOn: aGC

    super displayOn: aGC.
    self **display**ObjectLocationImage**.*

2. Now you can define images associated with your objectLocation classes
using the image editor tool of VisualWorks (Painter>ImageEditor) :
Draw your image with the editor
Install it on the class you want with the selector you want (for
instance myImage).

3. Finally play with your cell class point of views method :
If you want an image to be displayed on your cell, the
*objectLocationImage *variable of your cell must contain the image, if
not it must be empty.

So if you have defined a point of view *povEtat* on a variable *etat
*for instance, you have to add the following line to be sure the image
is not displayed :
*povEtat

self objectLocationImage: nil
^etat

*Then you can define a point view where the images associated with your
ResourceEau objects are displayed :

*povEtatWithResourceEauImage

|eaux eau|

    pov := self povEtat.
    eaux := self occupantsAt: ResourceEau.
    eaux isEmpty ifFalse: [
        eau := eau first.
        self **objectLocationImage: eau class myImage asImage].
    ^pov
*

There it is!!!
Okay maybe it is still a bit complicated but it is the simplest solution
I found!

Hope it will help,

Cheers

Geraldine

Romain Lorrilliere wrote:

> Bonjour,
>
> (je répond en anglais car cette liste héberge de nombreux
> non-francophones)
> *
> *Try this :
>
> *initRessourceEau*
> | ressource iden |
> ressource := self newEntity: RessourceEau.
> iden := (self theVegetations select: [:cell | cell id = 232]).
> ressource patch: iden.
>
> for the point of view. Pierre Bommel work on a new version. In this
> we'll be able to decorate this pov with personal image. For the
> moment, that is impossible or very hardly to put other image. But you
> change triangle for other geometric figure. When you do a right clic
> on the figure in the in the define "pov" dialog box, you have access
> to more adjustment, like the number of segment of figure (3 =
> triangle, 4 = square,...).
>
> Good luck
>
> Romain.
>
>
>
>
> -------- Original Message --------
> Subject: Comment fixer un objet sur l'environnement de simulation
> et Comment changer les points de vue des agents?
> Date: Mon, 29 May 2006 15:56:32 +0000 (GMT)
> From: Fadimata Abdou <abdoufadi@yahoo.fr>
> Reply-To: Fadimata Abdou <abdoufadi@yahoo.fr>
> To: cormas@cirad.fr
>
>
>
>
> Bonjour,
>
>
>
> J’aimerai fixer des entités objets (par des ressources en eau) à des
> endroits bien précis dans l’environnement de développement
> (c'est-à-dire sur des cellules bien précisent) de tel sorte qu’à
> chaque simulation ces entités objets ressource en eau restent aux
> mêmes endroits. Voilà la façon dont j’ai procédé mais qui ne marche pas:
>
>
>
> - j’ai créer une méthode initRessourceEau dans laquelle j’ai
> Ă©crit les instructions suivantes :
>
> *initRessourceEau*
>
> | ressource iden |
>
> ressource := (self newEntity: RessourceEau).
>
> iden := (self theVegetations select: [:y | (y id = 232)]).
>
> ressource isMovedTo: iden.
>
> * *
>
> RessourceEau est un ObjectLocation.
>
> J’utilise cette méthode initRessourceEau dans la méthode
> d’initialisation général du modèle.
>
>
>
> Mais cette procédure ne marche pas. Est-ce que vous pouvez m’indiquer
> une autre procédure ou bien m’apporter une correction à la procédure
> décrite au dessus.
>
>
>
> J’aimerai aussi changer les points de vue des agents de mon modèle
> pour mettre d’autres images au lieu d’avoir que des triangles. Est-ce
> que vous pouvez m’indiquer comment je peux procéder pour changer ces
> triangles.
>
>
>
> Cordialement,
>
> Abdou Fati.
>
>
>
>

New Message Reply Date view Thread view Subject view Author view
 

Back to home