Skip to content

Commit

Permalink
Blackbox stuff mostly done
Browse files Browse the repository at this point in the history
  • Loading branch information
ericx authored and ericx committed Mar 8, 2024
1 parent 9c0e17d commit fe59603
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/app/library/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ export default class Template {
const features: Array<paper.Rectangle> = [];
for (let i = 0; i < renderkeys.length; i++) {
const feature = this.render2D(params, renderkeys[i]);
feature.visible = false; //Find workaround for this
if(feature instanceof paper.PointText){
continue;
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/library/transposer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,20 @@ export default class Transposer extends Template {
position: "position"
};

this.__renderKeys = ["FLOW", "CONTROL", "INVERSE"];
this.__renderKeys = ["FLOW", "CONTROL"];

this.__mint = "TRANSPOSER";

this.__zOffsetKeys = {
FLOW: "height",
CONTROL: "height",
INVERSE: "height"
// INVERSE: "height"
};

this.__substrateOffset = {
FLOW: "0",
CONTROL: "+1",
INVERSE: "0"
// INVERSE: "0"
};
}

Expand Down
6 changes: 3 additions & 3 deletions src/app/utils/loadUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ export default class LoadUtils {

if (iscustomcomponent) {
//Grab the black box definition (Eric)
definition = CustomComponent.defaultParameterDefinitions();
definition = ComponentAPI.getBlackBoxDefinition(xspan, yspan, []);
} else {
definition = ComponentAPI.getDefinitionForMINT(entity);

Expand All @@ -611,7 +611,7 @@ export default class LoadUtils {
let type;
let value;
for (const key in json.params) {
//What does this do (Eric)?
// We check if the if the parameter (defined by key) is there inside the definition (heritable or unique)
if (Object.prototype.hasOwnProperty.call(definition.heritable, key)) {
type = definition.heritable[key];
} else if (Object.prototype.hasOwnProperty.call(definition.unique, key)) {
Expand Down Expand Up @@ -644,7 +644,7 @@ export default class LoadUtils {
params.position = [0.0, 0.0];
}

//What is this doing? (Eric)
// We need to convert here because one is Map type datastructure and the other is a simple object
const unique_map = MapUtils.toMap(definition.unique);
const heritable_map = MapUtils.toMap(definition.heritable);
//Assuming I just have to change the params to match the black box params (Eric) !!!
Expand Down
8 changes: 8 additions & 0 deletions src/app/view/render2D/componentPortRenderer2D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ export default class ComponentPortRenderer2D {
return ret;
}

/**
* Renders all the component ports for a given component
*
* @static
* @param {Component} component
* @return {*}
* @memberof ComponentPortRenderer2D
*/
static renderComponentPorts(component: Component) {
const rendersize = ComponentPortRenderer2D.getSizeforZoomLevel();
const componentports = component.ports;
Expand Down
35 changes: 35 additions & 0 deletions src/componentAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ type FeatureLibraryEntry = {
* @class ComponentAPI
*/
export class ComponentAPI {

// The blackbox entry
static blackboxEntryFlow : LibraryEntry = { object: new BlackBox(), key: "FLOW" };
static blackboxEntryControl : LibraryEntry = { object: new BlackBox(), key: "CONTROL" };
static blackboxEntryIntegration : LibraryEntry = { object: new BlackBox(), key: "INTEGRATION" };

// The library of components
static library: { [key: string]: LibraryEntry } = {
Template: { object: new Template(), key: "FLOW" },
Text: { object: new Text(), key: "FLOW" },
Expand Down Expand Up @@ -541,4 +548,32 @@ export class ComponentAPI {
}
return ret;
}


/**
* Rertuns the definition of the blackbox entry
*
* @static
* @param {*} entity
* @memberof ComponentAPI
*/
static getBlackBoxDefinition(xspan: number, yspan: number, ports: Array<any>): LibraryEntryDefinition {
// TODO: Deal with the ports later
// Create a fake definition for the blackbox

// TODO: How to pass xspan, yspan, ports to the blackbox?
let definition = ComponentAPI.blackboxEntryFlow.object;
let ret = {
unique: definition.unique,
heritable: definition.heritable,
units: definition.units,
defaults: definition.defaults,
minimum: definition.minimum,
maximum: definition.maximum,
mint: definition.mint
};
return ret;
}
}


0 comments on commit fe59603

Please sign in to comment.