Serialization of ApertureMacro. Change scale, offset and mirror in Gerber to act only upon its resulting geometry, not its source data.

This commit is contained in:
Juan Pablo Caram
2014-03-13 22:37:59 -04:00
parent 21da78d654
commit 9d9c3f819d
10 changed files with 220 additions and 65 deletions

Binary file not shown.

View File

@@ -103,6 +103,7 @@
</li>
<li class="toctree-l1"><a class="reference internal" href="devman.html">FlatCAM Developer Manual</a><ul>
<li class="toctree-l2"><a class="reference internal" href="devman.html#options">Options</a></li>
<li class="toctree-l2"><a class="reference internal" href="devman.html#serialization">Serialization</a></li>
</ul>
</li>
</ul>

View File

@@ -103,6 +103,7 @@
</li>
<li class="toctree-l1"><a class="reference internal" href="devman.html">FlatCAM Developer Manual</a><ul>
<li class="toctree-l2"><a class="reference internal" href="devman.html#options">Options</a></li>
<li class="toctree-l2"><a class="reference internal" href="devman.html#serialization">Serialization</a></li>
</ul>
</li>
</ul>
@@ -167,6 +168,7 @@
</li>
<li class="toctree-l1"><a class="reference internal" href="devman.html">FlatCAM Developer Manual</a><ul>
<li class="toctree-l2"><a class="reference internal" href="devman.html#options">Options</a></li>
<li class="toctree-l2"><a class="reference internal" href="devman.html#serialization">Serialization</a></li>
</ul>
</li>
</ul>

BIN
doc/build/objects.inv vendored

Binary file not shown.

View File

@@ -109,6 +109,7 @@
</li>
<li class="toctree-l1"><a class="reference internal" href="devman.html">FlatCAM Developer Manual</a><ul>
<li class="toctree-l2"><a class="reference internal" href="devman.html#options">Options</a></li>
<li class="toctree-l2"><a class="reference internal" href="devman.html#serialization">Serialization</a></li>
</ul>
</li>
</ul>

View File

@@ -110,6 +110,7 @@
</li>
<li class="toctree-l1"><a class="reference internal" href="devman.html">FlatCAM Developer Manual</a><ul>
<li class="toctree-l2"><a class="reference internal" href="devman.html#options">Options</a></li>
<li class="toctree-l2"><a class="reference internal" href="devman.html#serialization">Serialization</a></li>
</ul>
</li>
</ul>

File diff suppressed because one or more lines are too long

View File

@@ -12,4 +12,47 @@ There are **Application Defaults**, **Project Options** and **Object Options** i
**Object Options** for each object are inherited from Project Options upon creation of each new object. They can be modified independently from the Project's options thereafter through the UI, where the widget containing the option is identified by name: ``type + kind + "_" + option``. They are stored in ``object.options``. They are saved along the Project options when saving the project.
The syntax of UI widget names contain a ``type``, which identifies what *type of widget* it is and how its value is supposed to be fetched, and a ``kind``, which refer to what *kind of FlatCAM Object* it is for.
The syntax of UI widget names contain a ``type``, which identifies what *type of widget* it is and how its value is supposed to be fetched, and a ``kind``, which refer to what *kind of FlatCAM Object* it is for.
Serialization
~~~~~~~~~~~~~
Serialization refers to converting objects into a form that can be saved in a text file and recontructing objects from a text file.
Saving and loading projects require serialization. These are done in ``App.save_project(filename)`` and ``App.open_project(filename)``.
Serialization in FlatCAM takes 2 forms. The first is calling objects' ``to_dict()`` method, which is inherited from ``Geometry.to_dict()``::
def to_dict(self):
"""
Returns a respresentation of the object as a dictionary.
Attributes to include are listed in ``self.ser_attrs``.
:return: A dictionary-encoded copy of the object.
:rtype: dict
"""
d = {}
for attr in self.ser_attrs:
d[attr] = getattr(self, attr)
return d
This creates a dictionary with attributes specified in the object's ``ser_attrs`` list. If these are not in a serialized form, they will be processed later by the function ``to_dict()``::
def to_dict(geo):
"""
Makes a Shapely geometry object into serializeable form.
:param geo: Shapely geometry.
:type geo: BaseGeometry
:return: Dictionary with serializable form if ``geo`` was
BaseGeometry, otherwise returns ``geo``.
"""
if isinstance(geo, BaseGeometry):
return {
"__class__": "Shply",
"__inst__": sdumps(geo)
}
return geo
This is used in ``json.dump(d, f, default=to_dict)`` and is applied to objects that json encounters to be in a non-serialized form.