Skip to content

Commit

Permalink
[WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
mtmccrea committed Dec 27, 2022
1 parent 7b6dace commit 6160771
Showing 1 changed file with 34 additions and 21 deletions.
55 changes: 34 additions & 21 deletions SCClassLibrary/Common/GUI/PlusGUI/Math/PlotView.sc
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,10 @@ Plotter {
var modes, <interactionView;
var <editPlotIndex, <editPos;
var <>drawFunc, <>editFunc;
var tickLabelOffset, tickLabelAlign, tickLabelAnchor, tickLabelAppendString, constrainTickLabelExtents;
var tickLabelOffsetX, tickLabelAlignX, tickLabelAnchorX;
var tickLabelOffsetY, tickLabelAlignY, tickLabelAnchorY;
var tickLabelAppendStringX, constrainTickLabelExtentsX;
var tickLabelAppendStringY, constrainTickLabelExtentsY;

*new { |name, bounds, parent|
^super.newCopyArgs(name).makeWindow(parent, bounds)
Expand Down Expand Up @@ -1011,29 +1014,39 @@ Plotter {
};
}

// Convenience methods to dispatch settings shared between all plot grids
tickLabelOffset_{ |ax, pnt| this.prSetInSubplotGrid(ax, 'labelOffset_', pnt) }
tickLabelOffset { |ax| ^this.prGetInSubplotGrid(ax, 'labelOffset') }
tickLabelAlign_{ |ax, sym| this.prSetInSubplotGrid(ax, 'labelAlign_', sym) }
tickLabelAlign { |ax| ^this.prGetInSubplotGrid(ax, 'labelAlign') }
tickLabelAnchor_{ |ax, sym| this.prSetInSubplotGrid(ax, 'labelAnchor_', sym) }
tickLabelAnchor { |ax| ^this.prGetInSubplotGrid(ax, 'labelAnchor') }
tickLabelAppendString_{ |ax, str| this.prSetInSubplotGrid(ax, 'labelAppendString_', str) }
tickLabelAppendString { |ax| ^this.prGetInSubplotGrid(ax, 'labelAppendString') }
constrainTickLabelExtents_{ |ax, bool| this.prSetInSubplotGrid(ax, 'constrainLabelExtents_', bool) }
constrainTickLabelExtents { |ax| ^this.prGetInSubplotGrid(ax, 'constrainLabelExtents') }

prSetInSubplotGrid { |axis, method, val|
plots.do { |plot|
plot.drawGrid.perform(axis.asSymbol).perform(method, val)
// Convenience methods to dispatch settings shared between all plot grids.
tickLabelOffsetX_{ |pnt| this.setGridProperty('x', 'labelOffset', pnt) }
tickLabelOffsetY_{ |pnt| this.setGridProperty('y', 'labelOffset', pnt) }
tickLabelOffsetX { ^this.getGridProperty('x','labelOffset') }
tickLabelOffsetY { ^this.getGridProperty('y','labelOffset') }
tickLabelAlignX_{ |sym| this.setGridProperty('x', 'labelAlign', sym) }
tickLabelAlignY_{ |sym| this.setGridProperty('y', 'labelAlign', sym) }
tickLabelAlignX { ^this.getGridProperty('x','labelAlign') }
tickLabelAlignY { ^this.getGridProperty('y','labelAlign') }
tickLabelAnchorX_{ |sym| this.setGridProperty('x', 'labelAnchor', sym) }
tickLabelAnchorY_{ |sym| this.setGridProperty('y', 'labelAnchor', sym) }
tickLabelAnchorX { ^this.getGridProperty('x','labelAnchor') }
tickLabelAnchorY { ^this.getGridProperty('y','labelAnchor') }
tickLabelAppendStringX_{ |str| this.setGridProperty('x', 'labelAppendString', str) }
tickLabelAppendStringY_{ |str| this.setGridProperty('y', 'labelAppendString', str) }
tickLabelAppendStringX { ^this.getGridProperty('x','labelAppendString') }
tickLabelAppendStringY { ^this.getGridProperty('x','labelAppendString') }
constrainTickLabelExtentsX_{ |bool| this.setGridProperty('x', 'constrainLabelExtents', bool) }
constrainTickLabelExtentsY_{ |bool| this.setGridProperty('y', 'constrainLabelExtents', bool) }
constrainTickLabelExtentsX { this.getGridProperty('x','constrainLabelExtents') }
constrainTickLabelExtentsY { this.getGridProperty('y','constrainLabelExtents') }

// Assume all subplotplot grids have the same properties for a given axis
getGridProperty { |axis, property|
^plots[0].drawGrid.perform(axis).perform(property)
}

setGridProperty { |axis, property, val|
plots.do{ |plot|
this.axisGrid(axis).perform(property.asSetter, val)
};
this.updatePlotBounds;
}
prGetInSubplotGrid { |axis, method, val|
// assume all plot grids have the same properties
// (this is an convenience anyway)
^plots[0].drawGrid.perform(axis).perform(method);
}

// specs

Expand Down

0 comments on commit 6160771

Please sign in to comment.