Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZigZag Mixer #250

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@

<span class="mdl-layout-title">Select Layer</span>

<nav class="mdl-navigation" id="Mixer">
...
<div class="button_row">
<a id="ZigZagMixer_button" class="mdl-button mdl-js-button
mdl-js-ripple-effect mdl-button--raised feature-button">Mixer</a>
<button id="ZigZagMixer_params_button" class="params-button
mdl-button mdl-js-button mdl-button--icon">
<i class="material-icons">settings</i>
</button>


<nav class="mdl-navigation" id="layer-controls">
Expand Down
6 changes: 5 additions & 1 deletion src/app/featureSets/featureSet.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Device from "../core/device";


import Port from "../library/port";
import Anode from "../library/anode"; //new from CK
import Cathode from "../library/cathode"; //new from CK
Expand Down Expand Up @@ -29,6 +30,7 @@ import YTree from "../library/ytree";
import LLChamber from "../library/llChamber";
import ThreeDMixer from "../library/threeDMixer";
import Via from "../library/via";
import ZigZagMixer from "../ZigZagMixer";

//new

Expand Down Expand Up @@ -123,7 +125,9 @@ export default class FeatureSet {
DropletGenFlow: { object: new DropletGeneratorFlowFocus(), key: null },
LogicArray: { object: new LogicArray(), key: "FLOW" },
LogicArray_control: { object: new LogicArray(), key: "CONTROL" },
LogicArray_cell: { object: new LogicArray(), key: "CELL" }
LogicArray_cell: { object: new LogicArray(), key: "CELL" },
ZigZagMixer: { object: new ZigZagMixer(), key: "FLOW"},
ZigZagMixer_control: {object: new ZigZagMixer(), key: "CONTROL"}
};

// this.__checkDefinitions();
Expand Down
199 changes: 199 additions & 0 deletions src/app/library/ZigZagMixer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
import Template from "./template";
import paper from "paper";
import ComponentPort from "../core/componentPort";

export default class extends Template {
constructor() {
super();
}

__setupDefinitions() {
this.__unique = {
position: "Point"
};

this.__heritable = {
componentSpacing: "Float",
rotation: "Float",
bendSpacing: "Float",
numberofZigZags: "Float",
numberOfBends: "Float",
channelWidth: "Float",
bendLength: "Float",
rotation: "Float",
height: "Float"
};

this.__defaults = {
componentSpacing: 1000,
rotation: 0,
channelWidth: 0.8 * 1000,
bendSpacing: 1.23 * 1000,
numberOfBends: 1,
numberofZigZags: 1,
rotation: 0,
bendLength: 2.46 * 1000,
height: 250
};

this.__units = {
componentSpacing: "&mu;m",
rotation: "&deg;",
bendSpacing: "&mu;m",
numberOfBends: "",
numberofZigZags: "",
channelWidth: "&mu;m",
bendLength: "&mu;m",
height: "&mu;m"
};

this.__minimum = {
componentSpacing: 0,
rotation: 0,
channelWidth: 10,
bendSpacing: 10,
numberOfBends: 1,
numberofZigZags:1,
rotation: 0,
bendLength: 10,
height: 10
};

this.__maximum = {
componentSpacing: 10000,
rotation: 360,
channelWidth: 2000,
bendSpacing: 6000,
numberOfBends: 20,
numberofZigZags: 20,
rotation: 360,
bendLength: 12 * 1000,
height: 1200
};

this.__featureParams = {
componentSpacing: "componentSpacing",
position: "position",
channelWidth: "channelWidth",
bendSpacing: "bendSpacing",
numberOfBends: "numberOfBends",
numberofZigZags: "numberofZigZags",
rotation: "rotation",
bendLength: "bendLength"
};

this.__targetParams = {
componentSpacing: "componentSpacing",
channelWidth: "channelWidth",
bendSpacing: "bendSpacing",
numberOfBends: "numberOfBends",
numberofZigZags: "numberofZigZags",
rotation: "rotation",
bendLength: "bendLength"
};

this.__placementTool = "componentPositionTool";

this.__toolParams = {
position: "position"
};

this.__renderKeys = ["FLOW"];

this.__mint = "CURVED MIXER";
}

getPorts(params) {
let channelWidth = params["channelWidth"];
let bendLength = params["bendLength"];
let bendSpacing = params["bendSpacing"];
let numberOfBends = params["numberOfBends"];

let ports = [];

ports.push(new ComponentPort(bendLength / 2 + channelWidth, 0, "1", "FLOW"));

ports.push(new ComponentPort(bendLength / 2 + channelWidth, (2 * numberOfBends + 1) * channelWidth + 2 * numberOfBends * bendSpacing, "2", "FLOW"));

return ports;
}

render2D(params, key) {
let channelWidth = params["channelWidth"];
let bendLength = params["bendLength"];
let bendSpacing = params["bendSpacing"];
let rotation = params["rotation"];
let numBends = params["numberOfBends"];
let x = params["position"][0];
let y = params["position"][1];
let color = params["color"];
let segHalf = bendLength / 2 + channelWidth;
let segLength = bendLength + 2 * channelWidth;
let segBend = bendSpacing + 2 * channelWidth;
let vRepeat = 2 * bendSpacing + 2 * channelWidth;
let vOffset = bendSpacing + channelWidth;
let hOffset = bendLength / 2 + channelWidth / 2;
let serp = new paper.CompoundPath();

//draw first segment
let toprect = new paper.Path.Rectangle(x + channelWidth - 1, y, bendLength / 2 + channelWidth / 2 + 1, channelWidth);
toprect.closed = true;
for (let i = 0; i < numBends; i++) {
//draw left curved segment
let leftCurve = new paper.Path.Arc({
from: [x + channelWidth, y + vRepeat * i],
through: [x + channelWidth - (channelWidth + bendSpacing / 2), y + vRepeat * i + bendSpacing / 2 + channelWidth],
to: [x + channelWidth, y + vRepeat * i + bendSpacing + 2 * channelWidth]
});
leftCurve.closed = true;
let leftCurveSmall = new paper.Path.Arc({
from: [x + channelWidth, y + vRepeat * i + bendSpacing + channelWidth],
through: [x + channelWidth - bendSpacing / 2, y + vRepeat * i + bendSpacing / 2 + channelWidth],
to: [x + channelWidth, y + vRepeat * i + channelWidth]
});
leftCurveSmall.closed = true;
leftCurve = leftCurve.subtract(leftCurveSmall);
toprect = toprect.unite(leftCurve);
// serp.addChild(leftCurve);
//draw horizontal segment
let hseg = new paper.Path.Rectangle(x + channelWidth - 1, y + vOffset + vRepeat * i, bendLength + 2, channelWidth);
toprect = toprect.unite(hseg);
//draw right curved segment
let rightCurve = new paper.Path.Arc({
from: [x + channelWidth + bendLength, y + vOffset + vRepeat * i],
through: [x + channelWidth + bendLength + (channelWidth + bendSpacing / 2), y + vOffset + vRepeat * i + bendSpacing / 2 + channelWidth],
to: [x + channelWidth + bendLength, y + vOffset + vRepeat * i + bendSpacing + 2 * channelWidth]
});
rightCurve.closed = true;
let rightCurveSmall = new paper.Path.Arc({
from: [x + channelWidth + bendLength, y + vOffset + vRepeat * i + bendSpacing + channelWidth],
through: [x + channelWidth + bendLength + bendSpacing / 2, y + vOffset + vRepeat * i + bendSpacing / 2 + channelWidth],
to: [x + channelWidth + bendLength, y + vOffset + vRepeat * i + channelWidth]
});
rightCurveSmall.closed = true;
rightCurve = rightCurve.subtract(rightCurveSmall);
toprect = toprect.unite(rightCurve);

if (i == numBends - 1) {
//draw half segment to close
hseg = new paper.Path.Rectangle(x + channelWidth / 2 + bendLength / 2, y + vRepeat * (i + 1), (bendLength + channelWidth) / 2 + 1, channelWidth);
toprect = toprect.unite(hseg);
} else {
//draw full segment
hseg = new paper.Path.Rectangle(x + channelWidth - 1, y + vRepeat * (i + 1), bendLength + 2, channelWidth);
toprect = toprect.unite(hseg);
}
toprect = toprect.unite(hseg);
}
serp.addChild(toprect);

serp.fillColor = color;
return serp.rotate(rotation, x, y);;
}

render2DTarget(key, params) {
let render = this.render2D(params, key);
render.fillColor.alpha = 0.5;
return render;
}
}
18 changes: 16 additions & 2 deletions src/app/view/ui/componentToolBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import InsertTextDialog from "./insertTextDialog";
import * as Colors from "../colors";
import * as ParameterMenu from "./parameterMenu";
import * as Registry from "../../core/registry";
import ZigZagMixer from "../../library/ZigZagMixer";

const inactiveBackground = GREY_200;
const inactiveText = BLACK;
Expand Down Expand Up @@ -64,7 +65,7 @@ export default class ComponentToolBar {
this.__dropletgenTButton = document.getElementById("dropletgenT_button");
this.__dropletgenFlowButton = document.getElementById("dropletgenFlow_button");
this.__logicarrayButton = document.getElementById("logicarray_button");

this.__ZigZagMixerButton = document.getElementById("ZigZagMixer_button")
//Create all the parameter menu buttons

this.__channelParams = document.getElementById("channel_params_button");
Expand Down Expand Up @@ -98,6 +99,7 @@ export default class ComponentToolBar {
this.__alignmentMarksParams = document.getElementById("alignmentmarks_params_button");
this.__llChamberParams = document.getElementById("llchamber_params_button");
this.__threeDMixerParams = document.getElementById("3dmixer_params_button");
this.__ZigZagMixerParams = document.getElementById("ZigZagMixer_params_button");

this.__insertTextDialog = new InsertTextDialog();

Expand Down Expand Up @@ -164,7 +166,8 @@ export default class ComponentToolBar {
CapacitanceSensor: this.__capacitancesensorButton,
DropletGenT: this.__dropletgenTButton,
DropletGenFlow: this.__dropletgenFlowButton,
LogicArray: this.__logicarrayButton
LogicArray: this.__logicarrayButton,
ZigZagMixer: this.__ZigZagMixerButton
};


Expand Down Expand Up @@ -474,6 +477,16 @@ export default class ComponentToolBar {

ref.setActiveButton("LogicArray");
ref.__viewManagerDelegate.switchTo2D();

this.__ZigZagMixerButton.onclick =function () {
Registry.viewManager.activateTool("ZigZagMixer");

ref.setActiveButton("ZigZagMixer");
ref.__viewManagerDelegate.switchTo2D();

}


};
}

Expand Down Expand Up @@ -541,6 +554,7 @@ export default class ComponentToolBar {
this.__dropletgenTParams.onclick = ComponentToolBar.getParamsWindowCallbackFunction("DropletGenT", "Basic");
this.__dropletgenFlowParams.onclick = ComponentToolBar.getParamsWindowCallbackFunction("DropletGenFlow", "Basic");
this.__logicarrayParams.onclick = ComponentToolBar.getParamsWindowCallbackFunction("LogicArray", "Basic");
this.__ZigZagMixerParams.onclick = ComponentToolBar.getParamsWindowCallbackFunction("ZigZagMixer","Basic");
}

static getParamsWindowCallbackFunction(typeString, setString, isTranslucent = false) {
Expand Down
1 change: 1 addition & 0 deletions src/app/view/viewManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,7 @@ export default class ViewManager {
this.tools["DropletGenT"] = new ComponentPositionTool("DropletGenT", "Basic");
this.tools["DropletGenFlow"] = new ComponentPositionTool("DropletGenFlow", "Basic");
this.tools["LogicArray"] = new ControlCellPositionTool("LogicArray", "Basic");
this.tools["ZigZagMixer"] = new ComponentPositionTool ("ZigZagMixer", "Basic");
}

/**
Expand Down