diff --git a/Frontend Angular 4/src/app/layout/plotter/graph2D/graph2D.component.ts b/Frontend Angular 4/src/app/layout/plotter/graph2D/graph2D.component.ts index 25e86cc76b44826437f07fce153ce2e777eba340..cb50b9e22dc03f2286353279d63cac90b73f3af4 100755 --- a/Frontend Angular 4/src/app/layout/plotter/graph2D/graph2D.component.ts +++ b/Frontend Angular 4/src/app/layout/plotter/graph2D/graph2D.component.ts @@ -13,6 +13,8 @@ import { Animation } from './graph2D.helper'; }) export class Graph2DComponent { + private ghciServiceSub: any; + private instance: null; private animation: Animation = { @@ -25,7 +27,7 @@ export class Graph2DComponent { }; public constructor(private ghciService: GHCIService) { - ghciService.messages.subscribe( + this.ghciServiceSub = ghciService.messages.subscribe( canvas => { switch(canvas.tipo) { case 'graph': { @@ -251,7 +253,7 @@ export class Graph2DComponent { return $circleNormalized; } - /** + /** * @name normalizeTextData * @desc Normalize Text data for Function Plot Library * @param {Object} textData Data of Text to be normalized @@ -273,6 +275,49 @@ export class Graph2DComponent { return $textNormalized; } + /** + * @name normalizeTextData + * @desc Normalize Text data for Function Plot Library + * @param {Object} textData Data of Text to be normalized + * @returns {Object} + */ + // public normalizeLineData = function ($lineData) { + // var $lineNormalized:any = {}; + // var $points = [] + // for (var p of $lineData.pts) { + // $points.push([p[0],p[1]]); + // } + // $lineNormalized.points = $points; + // $lineNormalized.color = $lineData.color; + // $lineNormalized.rotation = $lineData.rot; + // $lineNormalized.fnType = 'points'; + // $lineNormalized.polylineType = 'line'; + // $lineNormalized.graphType = 'polyline'; + + // return $lineNormalized; + // } + /** + * @name normalizeTextData + * @desc Normalize Text data for Function Plot Library + * @param {Object} textData Data of Text to be normalized + * @returns {Object} + */ + // public normalizePolygonData = function ($textData) { + // var $PoligonNormalized:any = {}; + // var $shape:any = {}; + // $shape.text = $textData.text; + // $shape.size = $textData.size; + // $shape.x = $textData.x; + // $shape.y = $textData.y; + // $textData.color && ($shape.fill = $textData.color); + // $textData.rot !== 'undefined' && ($shape.rotation = $textData.rot); + + // $textNormalized.shape = $shape; + // $textNormalized.graphType = 'shape'; + // $textNormalized.shapeType = 'text'; + + // return $textNormalized; + // } /** * @name normalizeShapesData @@ -295,7 +340,15 @@ export class Graph2DComponent { case 'text': { normalized.push(this.normalizeTextData(shape)); break; - } + } + // case 'line': { + // normalized.push(this.normalizeLineData(shape)); + // break; + // } + // case 'polygon': { + // normalized.push(this.normalizePolygonData(shape)); + // break; + // } } } return normalized; @@ -518,5 +571,11 @@ export class Graph2DComponent { return funcionString; } + ngOnDestroy() { + if (this.ghciServiceSub) { + this.ghciServiceSub.unsubscribe(); + } + } + } diff --git a/Frontend Angular 4/src/app/layout/plotter/graph2D/graph2D.helper.ts b/Frontend Angular 4/src/app/layout/plotter/graph2D/graph2D.helper.ts index 9eb99ba7fbdcd4e8813d97d6a9ca31f83cd3e34a..18bd27ed64dea088251ead2155f44a8a72f4a410 100644 --- a/Frontend Angular 4/src/app/layout/plotter/graph2D/graph2D.helper.ts +++ b/Frontend Angular 4/src/app/layout/plotter/graph2D/graph2D.helper.ts @@ -6,3 +6,28 @@ export interface Animation { playing: boolean, init: boolean } + + +// export function toJSON(data: any) : string { +// var $points = data.pts; +// var $pointsJson = []; +// for (var p of $points) { +// $pointsJson.push([p[0],p[1]]); +// } + +// var dataJson = data; +// dataJson.pts +// } + +// return jsonString +// .replace( +// regexRot, (match, x, y, z) => { +// return `"rot": { "x": ${x}, "y": ${y}, "z": ${z} }` +// } +// ) +// .replace( +// regexPts, (match, x1, y1, z1, x2, y2, z2) => { +// return `"pts": [{ "x": ${x1}, "y": ${y1}, "z": ${z1} },{ "x": ${x2}, "y": ${y2}, "z": ${z2} }]` +// } +// ) +// } \ No newline at end of file