Skip to content

Commit

Permalink
Fix/valveinsertion (#471)
Browse files Browse the repository at this point in the history
* Cleaning up the getPostion, getTarget pipeline

* Cleaning up the getPostion, getTarget pipeline. Fixed the connection tool.

* Updated the valveinsertiontool

* removed some more of the `any` s

* Temporarily storing infor for valve insertion fixes

* Fixed the feature addition section

* Added documentation and fixed error types for incorrect datatypes being passed for mouse events.

* Cleaned up the viewManagerDelegate references.

* Added more missing documentations

* Removed the call for the older update connection rendering.

* Cleaned up the Feature to not hold the RenderLayer refernce since its breaking the rules of core packages being able to live without other packages.

* Fixed issue where macro was swapped with type. Type is the geometric operation that is allowed

macro is the name of the drawing subroutine.

* Finished implementing 1 pass of the features

* Modified Manufacturing info keys to be syntactic so that typescript checker can catch them.

* Added the templates for the newer features and geometric elements. First test is for making sure that the valve features are getting rendered.
  • Loading branch information
rkrishnasanka authored Mar 9, 2023
1 parent 43cf9fc commit e2443b8
Show file tree
Hide file tree
Showing 45 changed files with 1,015 additions and 196 deletions.
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"eamodio.gitlens",
"firefox-devtools.vscode-firefox-debug",
"jcbuisson.vue",
"dbaeumer.vscode-eslint"
"dbaeumer.vscode-eslint",
"salbert.comment-ts"
]
}
11 changes: 10 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@
"name": "vuejs: firefox",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}/src",
"pathMappings": [{ "url": "webpack:///src/", "path": "${webRoot}/" }]
"pathMappings": [
{
"url": "webpack:///src/services/theme/utils.ts",
"path": "git:/Users/krishna/CIDAR/3duf-vue-port/src/cc/hardware/utils.ts?%7B%22path%22%3A%22%2FUsers%2Fkrishna%2FCIDAR%2F3duf-vue-port%2Fsrc%2Fcc%2Fhardware%2Futils.ts%22%2C%22ref%22%3A%22%22%7D"
},
{
"url": "webpack:///src/",
"path": "${webRoot}/"
}
]
}
]
}
19 changes: 19 additions & 0 deletions notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Layers structure

Rendering KEY DATA:
- UNIQUE KEY
- HEIGHT OF THE FEATURE (Z)
- FABTYPE OPERATION(S): This means that we can have multiple operations per feature.
- XY
- UNION
- SUBTRACT
- INTERSECT
- XYZ
- UNION
- SUBTRACT
- INTERSECT
- Z
- UNION
- SUBTRACT
- INTERSECT
- Relative layer assignment ?
2 changes: 1 addition & 1 deletion src/app/core/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ export default class Component {
return 270;
}
} else {
console.warn("No rotation was found for component: ", this);
console.warn("Returning rotation = 0 since no rotation was found for component: ", this);
return 0;
}
}
Expand Down
28 changes: 27 additions & 1 deletion src/app/core/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ConnectionUtils from "../utils/connectionUtils";
import { ComponentAPI } from "@/componentAPI";
import MapUtils from "../utils/mapUtils";
import ExportUtils from "../utils/exportUtils";
import Feature from "./feature";

/**
* This class contains the connection abstraction used in the interchange format and the
Expand All @@ -33,6 +34,8 @@ export default class Connection {
protected _routed: boolean;
protected _layer: Layer;

features: Array<Feature> = [];

/**
* Default Connection Constructor
* @param {String} type
Expand Down Expand Up @@ -177,7 +180,9 @@ export default class Connection {
const outputpath: ConnectionPathInterchangeV1_2 = {
source: this._source !== null ? this._source.toJSON() : null,
sink: this.sinks.length > i ? this._sinks[i].toJSON() : null,
wayPoints: path
wayPoints: path,
// Get the id's of the features
features: this.features.map(feature => {return feature.id;})
};
outputpaths.push(outputpath);
}
Expand Down Expand Up @@ -683,4 +688,25 @@ export default class Connection {
let target = ConnectionTarget.fromJSON(device, json);
this._sinks.push(target);
}

/**
* Adds a feature to the connection
*
* @param {Feature} feature
* @memberof Connection
*/
addFeature(feature: Feature): void {
this.features.push(feature);
}

/**
* Removes a feature from the connection
*
* @param {Feature} feature
* @memberof Connection
*/
removeFeature(feature: Feature): void {
this.features.splice(this.features.indexOf(feature), 1);
}

}
9 changes: 9 additions & 0 deletions src/app/core/device.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference types="node" />

import Params from "./params";
import GeometryElement from "./geometryElement";

import Feature from "./feature";
import { DeviceInterchangeV1, DeviceInterchangeV1_1, LogicalLayerType, Point, ValveInterchangeV1_2, ValveType } from "./init";
Expand Down Expand Up @@ -34,6 +35,7 @@ export default class Device {
private __valveMap: Map<string, string>;
private __valveTypeMap: Map<string, ValveType>;
private __groups: Array<string>;
private __parchmintFeatures: Array<GeometryElement>;

/**
* Default Constructor
Expand All @@ -57,6 +59,9 @@ export default class Device {
//Map to store <componentID, connectionID>
this.__valveMap = new Map();
this.__valveTypeMap = new Map();

// Initilize the Features array that would be used to store the Parchmint Features
this.__parchmintFeatures = [];
}

/**
Expand Down Expand Up @@ -100,6 +105,10 @@ export default class Device {
return this.__layers;
}

get parchmintFeatures(): Array<GeometryElement> {
return this.__parchmintFeatures;
}

/**
* Adds a connection to the device
* @param {Connection} connection
Expand Down
15 changes: 10 additions & 5 deletions src/app/core/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class Feature {
protected _fabtype: DFMType;
protected _dxfObjects: Array<DXFObject>;
protected _referenceID: string | null;
public layer: RenderLayer | Layer | null;
public layer: Layer | null;
protected _manufacturingInfo: ManufacturingInfo;

/**
Expand Down Expand Up @@ -55,14 +55,18 @@ export default class Feature {
fabtype: fabtype,
layertype: null,
rendername: tempRenderName,
"z-offset-key": ComponentAPI.library[this.type].object.zOffsetKey(tempRenderName),
z_offset_key: ComponentAPI.library[this.type].object.zOffsetKey(tempRenderName),
depth: this.getValue(ComponentAPI.library[this.type].object.zOffsetKey(tempRenderName)),
"substrate-offset": ComponentAPI.library[this.type].object.substrateOffset(tempRenderName),
substrate_offset: ComponentAPI.library[this.type].object.substrateOffset(tempRenderName),
substrate: null,
modifier: modifierName
};
}

get id(): string {
return this._id;
}

get type(): string {
return this._type;
}
Expand Down Expand Up @@ -125,7 +129,7 @@ export default class Feature {
this._manufacturingInfo.depth = this.getValue(ComponentAPI.library[this.type].object.zOffsetKey(this.deriveRenderName()));
if (this.layer !== null) {
this._manufacturingInfo.layertype = this.layer.type;
this._manufacturingInfo.substrate = FeatureUtils.setSubstrate(this, this._manufacturingInfo["substrate-offset"]);
this._manufacturingInfo.substrate = FeatureUtils.setSubstrate(this, this._manufacturingInfo.substrate_offset);
} else {
throw new Error("Layer not set in feature " + this.ID + " so manufacturingInfo cannot be set");
}
Expand Down Expand Up @@ -175,7 +179,8 @@ export default class Feature {
referenceID: this._referenceID,
dxfData: this._dxfObjects.map(function(dxfObject) {
return dxfObject.toJSON();
})
}),
layerID: this.layer?.id ?? "",
};
return output;
}
Expand Down
54 changes: 54 additions & 0 deletions src/app/core/geometryElement.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { ComponentAPI } from "@/componentAPI";
import { GeometricOperationType, GeometryElementInterchangeV1_2 } from "./init";
import Layer from "./layer";
import Params from "./params";

export default class GeometryElement {

private _id: string;
private _macro: string;
private _geometricOperation: GeometricOperationType;
private _layer: Layer;

private _params: Params;

constructor(id: string = ComponentAPI.generateID(), macro:string, geometricOperation: GeometricOperationType, layer: Layer, params: { [k: string]: any } = {}) {
this._id = id;
this._macro = macro;
this._geometricOperation = geometricOperation;
this._layer = layer;

// Initilize the params
this._params = new Params(params, new Map<string, string>(), new Map<string, string>());
}

get id(): string {
return this._id;
}

get type(): string {
return this._macro;
}

get geometricOperation(): GeometricOperationType {
return this._geometricOperation;
}

get layer(): Layer {
return this._layer;
}

get params(): Params {
return this._params;
}

toInterchageV1_2(): GeometryElementInterchangeV1_2 {
return {
id: this._id,
macro: this._macro,
params: this._params.toJSON(),
geometricOperation: this._geometricOperation,
mgflayerID: this._layer.id
};
}
}
22 changes: 20 additions & 2 deletions src/app/core/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type InterchangeV1_2 = {
valves: Array<ValveInterchangeV1_2>;
version: string;
renderLayers: Array<RenderLayerInterchangeV1_2>;
features: Array<GeometryElementInterchangeV1_2>;
};

export enum LogicalLayerType {
Expand All @@ -29,6 +30,13 @@ export enum ValveType {
NORMALLY_CLOSED = "NORMALLY_CLOSED",
}

export enum GeometricOperationType{
UNION = "UNION",
INTERSECTION = "INTERSECTION",
DIFFERENCE = "SUBTRACTION",
XOR = "XOR",
}

export type DeviceInterchangeV1 = {
name: string;
params: ParamsInterchangeType;
Expand Down Expand Up @@ -101,12 +109,21 @@ export type FeatureInterchangeV1_2 = {
id: string;
name: string;
macro: string;
referenceID: string | null;
layerID: string | null;
referenceID: string | null; // Delete this in the future
params: ParamsInterchangeType;
dxfData: any;
dxfData: any; // 3DuF specific data for raw import/export of DXF objects
type: string;
};

export type GeometryElementInterchangeV1_2 = {
id: string;
macro: string;
params: ParamsInterchangeType;
geometricOperation: string;
mgflayerID: string;
}

export type ComponentPortInterchangeV1 = {
x: number;
y: number;
Expand All @@ -123,4 +140,5 @@ export type ConnectionPathInterchangeV1_2 = {
wayPoints: Array<Point>;
source: ConnectionTargetInterchangeV1 | null;
sink: ConnectionTargetInterchangeV1 | null;
features: Array<string>;
};
1 change: 0 additions & 1 deletion src/app/core/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class Registry {

public currentDevice: Device | null = null;
canvasManager = null;
currentLayer: RenderLayer | null = null;
currentTextLayer: Layer | null = null;
currentGrid: AdaptiveGrid | null = null;
view = null;
Expand Down
Loading

0 comments on commit e2443b8

Please sign in to comment.