Skip to content

Commit

Permalink
Merge pull request #175 from plantinformatics/feature/axisFinishSplit
Browse files Browse the repository at this point in the history
Split axis - tracks, for release
  • Loading branch information
Gabriel Keeble-Gagnere authored Mar 12, 2020
2 parents 1adbff2 + 79f1955 commit a566eae
Show file tree
Hide file tree
Showing 34 changed files with 658 additions and 263 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ For a quick start without installing any of the dependencies you will need docke
```
mkdir -p ~/mongodata \
&& docker run --name mongo --detach --volume ~/mongodata:/data/db --net=host mongo \
&& until $(curl --silent --fail --output /dev/null localhost:27017); do printf '.'; sleep 1; done \
&& until $(curl --silent --output /dev/null localhost:27017 || \
[ $(docker inspect -f '{{.State.Running}}' mongo) = "false" ]); do printf '.'; sleep 1; done \
&& docker run --name pretzel --detach --net=host plantinformaticscollaboration/pretzel:stable \
&& until $(curl --silent --fail --output /dev/null localhost:3000); do printf '.'; sleep 1; done \
&& until $(curl --silent --output /dev/null localhost:3000 || \
[ $(docker inspect -f '{{.State.Running}}' pretzel) = "false" ] ); do printf '.'; sleep 1; done \
&& docker logs pretzel
```

Expand Down
88 changes: 44 additions & 44 deletions frontend/app/components/axis-2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ const axisTransitionTime = 750;

export default Ember.Component.extend(Ember.Evented, AxisEvents, {
blockService: service('data/block'),
queryParams: service('query-params'),

needs: ['component:tracks'],

urlOptions : Ember.computed.alias('queryParamsService.urlOptions'),

subComponents : undefined,

targetEltId : Ember.computed('axisID', function() {
Expand All @@ -24,42 +27,14 @@ export default Ember.Component.extend(Ember.Evented, AxisEvents, {
return id;
}),

axis : Ember.computed('axisID', function() {
let axisID = this.get('axisID');
let stacks = this.get('drawMap.oa.stacks');
let axis = stacks.axesP[axisID];
return axis;
}),
axis1d : Ember.computed('axis', 'drawMap.oa.stacks.axesPCount', function() {
let axis = this.get('axis'),
axesPCount = this.get('drawMap.oa.stacks.axesPCount'),
axis1d = axis.axis1d;
console.log('axis1d', axis1d, axesPCount);
return axis1d;
}),
/** @return the blocks of this axis.
* Result type is [] of (stack.js) Block.
* For the Ember data Object blocks, @see dataBlocks().
/** Earlier versions had CP functions axis(), blocks(), dataBlocksS() based on
* stacks.js data structure for axes and blocks; these were dropped after
* version 1d6437a.
*/
blocks : Ember.computed('axis', function() {
let axis = this.get('axis');
return axis && axis.blocks;
}),
/** @return just the ("child") data blocks, skipping the ("parent") reference
* block which is block[0].
* Result type is [] of (stack.js) Block.
*/
dataBlocksS : Ember.computed('blocks.[]', function () {
let blocks = this.get('blocks'),
/** skip reference block, which has no features. */
dataBlocks = blocks.filter(function (bS) {
let b = bS.block; return b && bS.isData(); });
console.log('dataBlocks', blocks, dataBlocks);
return dataBlocks;
}),
/** The above dataBlocksS() is based on stacks.js data structure for axes and blocks;
* this function instead is based on the Ember store blocks, via the ComputedProperty axesBlocks.
* This can replace dataBlocksS(), which may be updated after a delay.

/** @return the list of data blocks of this axis. These are the Ember Data store
* blocks, collated based on the ComputedProperty axesBlocks.
*
* @return [] if there are no blocks with data in the axis.
*/
dataBlocks : Ember.computed(
Expand Down Expand Up @@ -176,9 +151,19 @@ export default Ember.Component.extend(Ember.Evented, AxisEvents, {
rectWidth() {
let
axisUse = this.get('axisUse'),
dualAxis = false, // options && options.dualAxis
/** <rect> is present iff dualAxis. Otherwise use the x translation of <path> */
rect2 = axisUse.select("g.axis-use > rect"),
width = rect2.attr('width');
console.log("rectWidth", this.get('startWidth'), this.currentWidth(), rect2.node(), width);
path = axisUse.select('g.axis-use > path'),
width;
if (/*dualAxis*/ rect2.size()) {
width = rect2.attr('width');
} else {
let transform = path.attr('transform'),
match = transform.match(/translate\(([0-9]+),/);
width = match && +match[1];
}
console.log("rectWidth", this.get('startWidth'), this.currentWidth(), rect2.node(), path.node(), width);
return width;
},
currentWidth() {
Expand Down Expand Up @@ -269,13 +254,29 @@ export default Ember.Component.extend(Ember.Evented, AxisEvents, {
/*--------------------------------------------------------------------------*/

didInsertElement() {
this._super(...arguments);

this.getUse();
},
getUse(backoffTime) {
let oa = this.get('data'),
axisUse = oa.svgContainer.selectAll("g.axis-outer#id"+this.get('axisID')),
/** <use> is present iff dualAxis */
use = axisUse.selectAll("use");
this.set('axisUse', axisUse);
this.set('use', use);
console.log("axis-2d didInsertElement", this, this.get('axisID'), axisUse.node(), use.node());
this.set('subComponents', []);
if (axisUse.empty()) {
dLog('getUse', backoffTime);
Ember.run.later(() => this.getUse(backoffTime ? backoffTime * 2 : 1000));
} else {
this.set('axisUse', axisUse);
this.set('use', use);
console.log("axis-2d didInsertElement", this, this.get('axisID'), axisUse.node(), use.node());
this.set('subComponents', []);
}
},

/** receive notification of draw-map resize. */
resized : function(prevSize, currentSize) {
dLog("resized in components/axis-2d", this, prevSize, currentSize);
},

didRender() {
Expand Down Expand Up @@ -337,9 +338,8 @@ export default Ember.Component.extend(Ember.Evented, AxisEvents, {
*/
let
axisID = me.get('axisID');
let axis = me.get('axis');
console.log('extended', axis.extended, width, axis);
axis.extended = width;
console.log('extended', this.get('axis1d.extended'), width);
this.set('width', width);
currentSize = width; // dx ?

let parentView = me.get('parentView');
Expand Down
49 changes: 45 additions & 4 deletions frontend/app/components/axis-tracks.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ export default InAxis.extend({

didInsertElement() {
this._super(...arguments);

console.log("components/axis-tracks didInsertElement()");
let
childWidths = this.get('childWidths'),
axisID = this.get('axisID'),
Expand All @@ -183,6 +185,11 @@ export default InAxis.extend({
childWidths.set(this.get('className'), [width, width]);
},

willDestroyElement() {
this._super(...arguments);
console.log("components/axis-tracks willDestroyElement()");
},

didRender() {
console.log("components/axis-tracks didRender()");
},
Expand Down Expand Up @@ -337,7 +344,7 @@ export default InAxis.extend({
let axisID = this.get('axisID'),
aS = selectAxis(axisID);
let
oa = this.get('axis').drawMap.oa, // or pass in this.get('data'),
oa = this.get('axis1d.drawMap.oa'),
axis = oa.axes[axisID];
/* if parent is un-viewed, this function may be called after axis is removed
* from stacks. */
Expand Down Expand Up @@ -379,8 +386,9 @@ export default InAxis.extend({
/** if zoomed in, tracks are not filtered by sizeThreshold.
* The logic is : if the user is zooming in, they are interested in
* features regardless of size, e.g. smaller than a pixel.
* [ sizeThreshold is disabled by setting to undefined, while we prototype how to select a sub-set of features to display ]
*/
sizeThreshold = zoomed ? undefined : pxSize * 1/*5*/,
sizeThreshold = undefined, // zoomed ? undefined : pxSize * 1/*5*/,
tracksLayout = regionOfTree(t, yDomain, sizeThreshold),
data = tracksLayout.intervals;
if (false) // actually need to sum the .layoutWidth for all blockId-s, plus the block offsets which are calculated below
Expand Down Expand Up @@ -571,6 +579,23 @@ export default InAxis.extend({

/*--------------------------------------------------------------------------*/

featuresForTrackBlocksRequestEffect : Ember.computed(
'trackBlocksR.[]',
// either axis1d.domain or yDomain is probably sufficient dependency.
'axis1d.domain', 'yDomain',
function () {
dLog('featuresForTrackBlocksRequestEffect');
let trackBlocks = this.get('trackBlocksR'),
/** featuresForAxis() uses getBlockFeaturesInterval(), which is also used by
* models/axis-brush.js */
blockFeatures = trackBlocks.map(function (b) { return b.get('featuresForAxis'); } );
/* no return value - result is displayed by showTrackBlocks() with data
* collated by tracksTree(). */
}),

/*--------------------------------------------------------------------------*/


/** Not used; can be used in .hbs for trace, for comparison against the result
* of showTrackBlocks(). */
blocksFeaturesLengths : Ember.computed(
Expand Down Expand Up @@ -641,14 +666,19 @@ export default InAxis.extend({
}),
showTrackBlocks: Ember.computed(
'tracksTree', 'yDomain.0', 'yDomain.1', 'axis1d.zoomed', 'axis1d.extended', 'axis1d.featureLength',
'featuresForTrackBlocksRequestEffect',
function() {
this.get('featuresForTrackBlocksRequestEffect');
let tracks = this.get('tracksTree');
let axis1d = this.get('axis1d'),
zoomed = this.get('axis1d.zoomed'),
isViewed = axis1d.axis.get('isViewed'),
extended = this.get('axis1d.extended'),
featureLength = this.get('axis1d.featureLength'),
yDomain = this.get('yDomain');
console.log('showTrackBlocks', this, tracks, axis1d, yDomain, 'axis1d.zoomed', zoomed, extended, featureLength);
console.log('showTrackBlocks', this, tracks, axis1d, isViewed, yDomain, 'axis1d.zoomed', zoomed, extended, featureLength);
let featuresLength;
if (isViewed) {
let blockIds = d3.keys(tracks.intervalTree);
if (false) {
let blockId = blockIds[0];
Expand All @@ -657,10 +687,21 @@ export default InAxis.extend({
}
// intersect with axis zoom region; layer the overlapping tracks; draw tracks.
this.layoutAndDrawTracks.apply(this, [undefined, tracks]);
let featuresLength = blockIds.map((blockId) => [blockId, tracks.intervalTree[blockId].intervals.length]);
featuresLength = blockIds.map((blockId) => [blockId, tracks.intervalTree[blockId].intervals.length]);
console.log('showTrackBlocks() featuresLength', featuresLength);
}
return featuresLength;
}),
resizeEffectHere : Ember.computed('resizeEffect', function () {
let result = this.get('resizeEffect');
dLog('resizeEffectHere in axis-tracks', this.get('axisID'), result);
/** @return true if rc[f] indicates a change of field f.
* if the previous size is not recorded, then treat it as a change.
*/
function isChanged(rc, f) { return rc ? rc[f] : true; }
this.showResize(isChanged(result.changed, 'viewportWidth'), isChanged(result.changed, 'viewportHeight') /* , yScaleChanged ? */);
}),


keypress: function(event) {
console.log("components/axis-tracks keypress", event);
Expand Down
Loading

0 comments on commit a566eae

Please sign in to comment.