Skip to content

Commit

Permalink
Merge pull request #213 from frg-fossee/develop
Browse files Browse the repository at this point in the history
Merge develop to master
  • Loading branch information
fresearchgroup committed Apr 16, 2021
2 parents 6ad3a8d + c9cd369 commit d2aaabd
Show file tree
Hide file tree
Showing 41 changed files with 5,185 additions and 249 deletions.
3 changes: 3 additions & 0 deletions ArduinoFrontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"chroma-js": "^1.3.5",
"core-js": "^2.5.4",
"is-promise": "2.2.2",
"lodash": "^4.17.19",
"lodash-transpose": "^0.2.1",
"ngx-monaco-editor": "^7.0.0",
"rxjs": "~6.3.3",
"tslib": "^1.9.0",
Expand Down
64 changes: 34 additions & 30 deletions ArduinoFrontend/src/app/Libs/CircuitElement.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Point } from './Point';
import { Wire } from './Wire';
import { isNull } from 'util';
import { BoundingBox } from './Geometry';

/**
* Abstract Class Circuit Elements
Expand Down Expand Up @@ -110,6 +111,14 @@ export abstract class CircuitElement {
});
}
}

/**
* Returns bounding box of the circuit element
*/
getBoundingBox(): BoundingBox {
return BoundingBox.loadFromRaphaelBbox(this.elements.getBBox());
}

/**
* Draws circuit nodes
* @param canvas Raphael Canvas
Expand All @@ -136,26 +145,23 @@ export abstract class CircuitElement {
* @param drawData Draw Data
*/
DrawElement(canvas: any, drawData: any) {
const elementsDrawn = [];
for (const item of drawData) {
let element;
// Draw image
if (item.type === 'image') {
this.elements.push(
canvas.image(
element = canvas.image(
item.url,
this.x + item.x,
this.y + item.y,
item.width,
item.height
)
);
);
} else if (item.type === 'path') {
this.elements.push(
this.DrawPath(canvas, item)
);
element = this.DrawPath(canvas, item);
} else if (item.type === 'rectangle') {
// Draw rectangle
this.elements.push(
canvas.rect(
element = canvas.rect(
this.x + item.x,
this.y + item.y,
item.width,
Expand All @@ -164,24 +170,24 @@ export abstract class CircuitElement {
).attr({
fill: item.fill || 'none',
stroke: item.stroke || 'none'
})
);
});
} else if (item.type === 'circle') {
// Draw a circle
this.elements.push(
canvas.circle(
element = canvas.circle(
this.x + item.x,
this.y + item.y,
item.radius,
).attr({
fill: item.fill || 'none',
stroke: item.stroke || 'none'
})
);
});
} else if (item.type === 'polygon') {
this.DrawPolygon(canvas, item);
element = this.DrawPolygon(canvas, item);
}
this.elements.push(element);
elementsDrawn.push(element);
}
return elementsDrawn;
}
/**
* Draws an Polygon
Expand All @@ -198,13 +204,11 @@ export abstract class CircuitElement {
tmp += `${this.x + point[0]},${this.y + point[1]}L`;
}
tmp = tmp.substr(0, tmp.length - 1) + 'z';
this.elements.push(
canvas.path(tmp)
.attr({
fill: item.fill || 'none',
stroke: item.stroke || 'none'
})
);
return canvas.path(tmp)
.attr({
fill: item.fill || 'none',
stroke: item.stroke || 'none'
});
}
/**
* Draw a Path
Expand All @@ -227,13 +231,11 @@ export abstract class CircuitElement {
str = this.calcRelative(str, horizontal, canvas);
str = this.calcRelative(str, vertical, canvas);
str = this.calcRelative(str, sCurve, canvas);
this.elements.push(
canvas.path(str)
.attr({
fill: item.fill || 'none',
stroke: item.stroke || 'none'
})
);
return canvas.path(str)
.attr({
fill: item.fill || 'none',
stroke: item.stroke || 'none'
});
}
/**
* Draw path relative to the component
Expand Down Expand Up @@ -291,6 +293,7 @@ export abstract class CircuitElement {
for (let i = 0; i < this.nodes.length; ++i) {
this.nodes[i].move(tmpar[i][0] + dx, tmpar[i][1] + dy);
}
window['onDragEvent'](this);
}, () => {
fdx = 0;
fdy = 0;
Expand All @@ -308,6 +311,7 @@ export abstract class CircuitElement {
// }
this.tx += fdx;
this.ty += fdy;
window['onDragStopEvent'](this);
});
}
/**
Expand Down
Loading

0 comments on commit d2aaabd

Please sign in to comment.