Fix multiple problems with the merge. There are still errors, but I will intentionally leave them because future merges might resolve them
This commit is contained in:
parent
8cd842a41a
commit
8d5e782ccf
7 changed files with 39 additions and 13 deletions
|
|
@ -1015,11 +1015,10 @@ class AMLowerLeftLinePrimitive(AMPrimitive):
|
|||
def to_primitive(self, units):
|
||||
# TODO I think I have merged this wrong
|
||||
# Offset the primitive from macro position
|
||||
position = tuple([a + b for a , b in zip (position, self.lower_left)])
|
||||
position = tuple([pos + offset for pos, offset in
|
||||
zip(position, (self.width/2, self.height/2))])
|
||||
zip(self.lower_left, (self.width/2, self.height/2))])
|
||||
# Return a renderable primitive
|
||||
return Rectangle(self.position, self.width, self.height,
|
||||
return Rectangle(position, self.width, self.height,
|
||||
level_polarity=self._level_polarity, units=units)
|
||||
|
||||
def to_gerber(self, settings=None):
|
||||
|
|
|
|||
|
|
@ -16,12 +16,14 @@
|
|||
# limitations under the License.
|
||||
|
||||
|
||||
from itertools import combinations
|
||||
import math
|
||||
from operator import add
|
||||
from itertools import combinations
|
||||
|
||||
from .utils import validate_coordinates, inch, metric, convex_hull, rotate_point, nearly_equal
|
||||
|
||||
from .utils import validate_coordinates, inch, metric, convex_hull, rotate_point, nearly_equal
|
||||
|
||||
|
||||
|
||||
|
||||
class Primitive(object):
|
||||
""" Base class for all Cam file primitives
|
||||
|
|
@ -721,7 +723,8 @@ class Rectangle(Primitive):
|
|||
def _abs_height(self):
|
||||
return (math.cos(math.radians(self.rotation)) * self.height +
|
||||
math.sin(math.radians(self.rotation)) * self.width)
|
||||
|
||||
|
||||
@property
|
||||
def axis_aligned_height(self):
|
||||
return (self._cos_theta * self.height + self._sin_theta * self.width)
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ except ImportError:
|
|||
import cairocffi as cairo
|
||||
|
||||
import math
|
||||
from operator import mul, di
|
||||
from operator import mul, div
|
||||
|
||||
import tempfile
|
||||
|
||||
|
|
|
|||
|
|
@ -476,6 +476,14 @@ class Rs274xContext(GerberContext):
|
|||
def _render_inverted_layer(self):
|
||||
pass
|
||||
|
||||
def _new_render_layer(self):
|
||||
# TODO Might need to implement this
|
||||
pass
|
||||
|
||||
def _flatten(self):
|
||||
# TODO Might need to implement this
|
||||
pass
|
||||
|
||||
def dump(self):
|
||||
"""Write the rendered file to a StringIO steam"""
|
||||
statements = map(lambda stmt: stmt.to_gerber(self.settings), self.statements)
|
||||
|
|
|
|||
16
gerber/tests/golden/example_single_quadrant.gbr
Normal file
16
gerber/tests/golden/example_single_quadrant.gbr
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
%FSLAX23Y23*%
|
||||
%MOIN*%
|
||||
%ADD10C,0.01*%
|
||||
G74*
|
||||
D10*
|
||||
%LPD*%
|
||||
G01X1100Y600D02*
|
||||
G03X700Y1000I-400J0D01*
|
||||
G03X300Y600I0J-400D01*
|
||||
G03X700Y200I400J0D01*
|
||||
G03X1100Y600I0J400D01*
|
||||
G01X300D02*
|
||||
X1100D01*
|
||||
X700Y200D02*
|
||||
Y1000D01*
|
||||
M02*
|
||||
|
|
@ -182,6 +182,8 @@ def _test_render(gerber_path, png_expected_path, create_output_path = None):
|
|||
with open(png_expected_path, 'rb') as expected_file:
|
||||
expected_bytes = expected_file.read()
|
||||
|
||||
assert_equal(expected_bytes, actual_bytes)
|
||||
|
||||
# Don't directly use assert_equal otherwise any failure pollutes the test results
|
||||
equal = (expected_bytes == actual_bytes)
|
||||
assert_true(equal)
|
||||
|
||||
return gerber
|
||||
|
|
|
|||
|
|
@ -10,15 +10,13 @@ from .tests import *
|
|||
|
||||
def test_primitive_smoketest():
|
||||
p = Primitive()
|
||||
<<<<<<< HEAD
|
||||
try:
|
||||
p.bounding_box
|
||||
assert_false(True, 'should have thrown the exception')
|
||||
except NotImplementedError:
|
||||
pass
|
||||
=======
|
||||
#assert_raises(NotImplementedError, p.bounding_box)
|
||||
>>>>>>> 5476da8... Fix a bunch of rendering bugs.
|
||||
|
||||
p.to_metric()
|
||||
p.to_inch()
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue