DrGeoII object model: Factory / DrGMathItemFactory

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

DrGeoII object model: Factory / DrGMathItemFactory

HJH
Hello Hilaire

There is a DrGMathItemFactory which keeps in its 'pool' variable the description of geometric objects (as objects to type DrGMathItem) in the order  they have been created.

I assume this pool is an important part of the object model. It probably may used in running a query on the construction, see my question here:  

http://forum.drgeo.eu/How-do-I-query-the-geometry-model-td4025479.html

Some of the objects (e.g. points) are hard coded in the construction script, some others are calculated.

What are the typcial uses of the DrGMathItemFactory object and its pool?

Best
--Hannes
HJH
Reply | Threaded
Open this post in threaded view
|

Re: DrGeoII object model: Factory / DrGMathItemFactory

HJH
A general benefit of having an understanding how the factory works would be that it would allow me to also create an SVG representation of the geometry model as the objects are constructed. The effort for this would probably be quite low.
HJH
Reply | Threaded
Open this post in threaded view
|

Re: DrGeoII object model: Factory / DrGMathItemFactory

HJH
An illustration:

I have the script

| c ptM circle |
c := DrGeoSketch minimal.
ptM := c point: 0@0.
ptM name: 'M'.
circle := c circleCenter: ptM radius: 5.

"DrGeoSketch is a used here as synonym for DrGeoCanvas"

Circle - the result of the script

Exploring the DrGeoSketch object, It has a view (not used) but the view uses an area which is a DrGDrawable with submorphs. This is what you see.



The DrGeoSketch object also has a domain object and this is the place where the factory is. The pool of the factory contains three objects, aDrGPointFreeItem object, aDrGValueValueItem for the radius value of 5 and  a DrGCircleRadiusItem.

The domain object contains the factory

Reply | Threaded
Open this post in threaded view
|

Re: DrGeoII object model: Factory / DrGMathItemFactory

Hliaire Fernandes
Administrator
In reply to this post by HJH
The factory is the object capable to access the models constituting the whole sketch.
The factory receive order to construct, move, delete any items of the model.

When the user action result in the creation of a new item, then the factory effectively specific build command to make the construction happen.

When the user action result in moving an item, then the factory effectively issue a specific move command to move the object.

Same when the user delete an object, the factory issue a delete command.


More over, when building an item, the factory first check if there is not already sibling in the construction, and in this case just return the sibling and does not construct.

Hilaire