Points do not show. Wrapped point?

classic Classic list List threaded Threaded
7 messages Options
HJH
Reply | Threaded
Open this post in threaded view
|

Points do not show. Wrapped point?

HJH
This post was updated on .
Hello Hilaire

I have the following sketch

    | c pointA pointB |
    c := DrGeoCanvas new.
    pointA := 1@0.
    pointB := 5@0.
    c point: pointA.
    c point: pointB.
    c ray: pointA to: pointB.

The ray is drawn but the points do not show.

The #ray:to: [1] is implemented as

   ray: wrpPt1 to: wrpPt2
        self preProcessing.
        ^ self
                finalizeCurve: (DrGRay2ptsItem newWith: {
                        (self wrappedPoint: wrpPt1) mathItem.
                        (self wrappedPoint: wrpPt2) mathItem })

I assume wrpPt1 means 'wrapped point 1'. What is a 'wrapped point'. Wrapped with what?

Regards
Hannes

[1]
https://www.gnu.org/software/dr-geo/doc/en/Index.html#Method-index

#ray:to:
https://www.gnu.org/software/dr-geo/doc/en/Smalltalk-sketch.html#index-ray_003ato_003a-on-DrGeoCanvas
HJH
Reply | Threaded
Open this post in threaded view
|

Re: Points do not show. Wrapped point?

HJH
There is also a DrGeoCanvas method


   wrappedPoint: aPointOrWrappedPointItem
   "ensure a wrapped point"
          ^ aPointOrWrappedPointItem isPoint
                   ifTrue: [(self point: aPointOrWrappedPointItem) hide]
  ifFalse:   [aPointOrWrappedPointItem]

When do I want to make sure I deal with a wrapped point?
HJH
Reply | Threaded
Open this post in threaded view
|

Re: Points do not show. Wrapped point?

HJH
Or put the question another way. Do I need to know as a user if a point is wrapped or not.
Reply | Threaded
Open this post in threaded view
|

Re: Points do not show. Wrapped point?

Hilaire Fernandes
Administrator
Le 01/10/2018 à 15:41, HJH [via Dr. Geo Forum] a écrit :
Or put the question another way. Do I need to know as a user if a point is wrapped or not.

You don't need to know about wrapped point. Its goal is to encapsulate for convenience  a geometric Item, its costume and its style objects into one object, the wrapped point for example.

Hilaire

Was this message helpful?
Tell us!
Reply | Threaded
Open this post in threaded view
|

Re: Points do not show. Wrapped point?

Hilaire Fernandes
Administrator
In reply to this post by HJH
Le 01/10/2018 à 14:00, HJH [via Dr. Geo Forum] a écrit :
    | c pointA pointB |
    c := DrGeoCanvas new.
    pointA := 1@0.
    pointB := 5@0.
    c point: pointA.
    c point: pointB.
    c ray: pointA to: pointB.

The ray is drawn but the points do not show.

Hello,

Interesting situation. You hit the wall of a feature.

In short, it is because your are passing Point instances to DrGeo, which are not geometric item for Dr.Geo.

But still DrGeo is kind enough to instantiate for your the necessary DrGeo's point item.

Alternate way to write the code to get the points visible:


| c pointA pointB |
    c := DrGeoCanvas new.
    pointA := c point:
1@0.
    pointB := c point: 5@0.
    c ray: pointA to: pointB.


Or:

  | c pointA pointB |
    c := DrGeoCanvas new.
    pointA := 1@0.
    pointB := 5@0.
    c ray: (c point: pointA)  to: (c point: pointB).


In short, if you pass as argument Point instance, DrGeo will instantiate the intermediate necessary DrGeo point but it will hide these points.

You can also request later the instantiated point because DrGeo use a factory to be smart when building new object: it can search for sibling, then decide to return this one and not create a new instance.

So you can also write:

  | c pointA pointB |
    c := DrGeoCanvas new.
    pointA := 1@0.
    pointB := 5@0.
    c ray: pointA  to: pointB.
    "no new point instances created, DrGeo is smart enough to know these points already exist"
    (c point: pointA) show.
    (c point: pointB) show.


Hope it clarify.

Hilaire







Was this message helpful?
Tell us!
HJH
Reply | Threaded
Open this post in threaded view
|

Re: Points do not show. Wrapped point?

HJH
Hello Hilaire

The script you give works

    | c pointA pointB |
    c := DrGeoCanvas new.
    pointA := c point: 1@0.
    pointB := c point: 5@0.
    c ray: pointA to: pointB.

However it actually also means that I need to be aware that the result

     pointA := c point: 1@0.

is a wrapped point and that

    c ray: pointA to: pointB.

needs wrapped points.
Reply | Threaded
Open this post in threaded view
|

Re: Points do not show. Wrapped point?

Hilaire Fernandes
Administrator
All the objects are manipulated by the mean of wrapped object, but you
don't need to be aware. The handling of Point instance is just a facility.

If you browser the DrGWrappedItem hierarchy you can have a better picture.

Hilaire

Le 01/10/2018 à 20:28, HJH [via Dr. Geo Forum] a écrit :

> Hello Hilaire
>
> The script you give works
>
>     | c pointA pointB |
>     c := DrGeoCanvas new.
>     pointA := c point: 1@0.
>     pointB := c point: 5@0.
>     c ray: pointA to: pointB.
>
> However it actually also means that I need to be aware that the result
>
>      pointA := c point: 1@0.
>
> is a wrapped point and that
>
>     c ray: pointA to: pointB.
>
> needs wrapped points.


Was this message helpful?
Tell us!