Skip to content

Commit 163f1f1

Browse files
authored
Merge pull request #1381 from mathics/TicksStyle-3D
TicksStyle 3D
2 parents a619ef8 + a80c9d4 commit 163f1f1

1 file changed

Lines changed: 24 additions & 12 deletions

File tree

mathics/builtin/drawing/graphics3d.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -429,17 +429,17 @@ def calc_dimensions(final_pass=True):
429429

430430
xmin, xmax, ymin, ymax, zmin, zmax, boxscale = calc_dimensions(final_pass=False)
431431

432-
axes, ticks = self.create_axes(
432+
axes, ticks, ticks_style = self.create_axes(
433433
elements, graphics_options, xmin, xmax, ymin, ymax, zmin, zmax, boxscale
434434
)
435435

436-
return elements, axes, ticks, calc_dimensions, boxscale
436+
return elements, axes, ticks, ticks_style, calc_dimensions, boxscale
437437

438438
def boxes_to_tex(self, leaves=None, **options):
439439
if not leaves:
440440
leaves = self._leaves
441441

442-
elements, axes, ticks, calc_dimensions, boxscale = self._prepare_elements(
442+
elements, axes, ticks, ticks_style, calc_dimensions, boxscale = self._prepare_elements(
443443
leaves, options, max_width=450
444444
)
445445

@@ -635,10 +635,12 @@ def boxes_to_mathml(self, leaves=None, **options):
635635
if not leaves:
636636
leaves = self._leaves
637637

638-
elements, axes, ticks, calc_dimensions, boxscale = self._prepare_elements(
638+
elements, axes, ticks, ticks_style, calc_dimensions, boxscale = self._prepare_elements(
639639
leaves, options
640640
)
641641

642+
js_ticks_style = [s.to_js() for s in ticks_style]
643+
642644
elements._apply_boxscaling(boxscale)
643645

644646
# FIXME: json is the only thing we can convert MathML into.
@@ -655,7 +657,7 @@ def boxes_to_mathml(self, leaves=None, **options):
655657
json_repr = json.dumps(
656658
{
657659
"elements": json_repr,
658-
"axes": {"hasaxes": axes, "ticks": ticks},
660+
"axes": {"hasaxes": axes, "ticks": ticks, "ticks_style": js_ticks_style},
659661
"extent": {
660662
"xmin": xmin,
661663
"xmax": xmax,
@@ -691,20 +693,30 @@ def create_axes(
691693
ticks_style = graphics_options.get("System`TicksStyle")
692694
axes_style = graphics_options.get("System`AxesStyle")
693695
label_style = graphics_options.get("System`LabelStyle")
694-
if ticks_style.has_form("List", 3):
696+
697+
# FIXME: Doesn't handle GrayScale
698+
if ticks_style.has_form("List", 1, 2, 3):
695699
ticks_style = ticks_style.leaves
696-
else:
700+
elif ticks_style.has_form("RGBColor", None):
697701
ticks_style = [ticks_style] * 3
698-
if axes_style.has_form("List", 3):
702+
else:
703+
ticks_style = []
704+
705+
if axes_style.has_form("List", 1, 2, 3):
699706
axes_style = axes_style.leaves
700707
else:
701708
axes_style = [axes_style] * 3
702709

703-
ticks_style = [elements.create_style(s) for s in ticks_style]
710+
# FIXME: Not quite right. We only handle color
711+
ticks_style = [elements.create_style(s).get_style(_Color, face_element=False)[0] for s in ticks_style]
712+
704713
axes_style = [elements.create_style(s) for s in axes_style]
705714
label_style = elements.create_style(label_style)
706-
ticks_style[0].extend(axes_style[0])
707-
ticks_style[1].extend(axes_style[1])
715+
716+
# For later
717+
# ticks_style[0].extend(axes_style[0])
718+
# ticks_style[1].extend(axes_style[1])
719+
# ticks_style[2].extend(axes_style[2])
708720

709721
ticks = [
710722
self.axis_ticks(xmin, xmax),
@@ -734,7 +746,7 @@ def create_axes(
734746
for i, t in enumerate(ticks)
735747
]
736748

737-
return axes, ticks
749+
return axes, ticks, ticks_style
738750

739751
def get_boundbox_lines(self, xmin, xmax, ymin, ymax, zmin, zmax):
740752
return [

0 commit comments

Comments
 (0)