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

Add Memory block #233

Merged
merged 30 commits into from
May 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c28050e
Add Memory block in the menu
Jesus89 Apr 13, 2018
313c0a0
Remove unused initial blocks position
Jesus89 Apr 13, 2018
b8acb7f
Add Memory block
Jesus89 Apr 14, 2018
85f94b3
Save/Load Memory block data
Jesus89 Apr 14, 2018
7b08b99
Merge branch 'develop' into memory-block
Jesus89 Apr 14, 2018
d56665c
Improve Memory block style
Jesus89 Apr 14, 2018
ab387f2
Merge branch 'develop' into memory-block
Jesus89 Apr 16, 2018
35b5452
Include Memory block in the compiler
Jesus89 Apr 16, 2018
1236b9e
Refactor compiler.generate function
Jesus89 Apr 16, 2018
2a81cfe
Add listCompiler function
Jesus89 Apr 16, 2018
51a18bd
Load only external resources. Skip loading internal resources
Jesus89 Apr 16, 2018
71229de
Reconnect memory-block connections when code-block interface changes
Jesus89 Apr 16, 2018
3d130d0
Improve blocks replacement. Add Constant <-> Memory blocks replacement
Jesus89 Apr 17, 2018
0023346
Add name and local to the Memory block
Jesus89 Apr 17, 2018
0b2b6c2
Load Memory blocks as Generic block parameters
Jesus89 Apr 17, 2018
a5c7856
Fix replace blocks: skip wires
Jesus89 Apr 17, 2018
9157f38
Reconnect replaced Constant/Memory blocks
Jesus89 Apr 17, 2018
f90c618
Rotate constant port labels
Jesus89 May 5, 2018
3f6fc54
Wires avoid port labels
Jesus89 May 5, 2018
dd6bbd8
Using modelId in port SVG IDs
Jesus89 May 13, 2018
e5ae346
Fix wires rendering on start
Jesus89 May 13, 2018
134daba
Merge branch 'develop' into memory-block
Jesus89 May 14, 2018
5d6b1e6
Use a Lock svg to represent local parameters
Jesus89 May 14, 2018
4190ab7
Update default size for Memory blocks
Jesus89 May 14, 2018
56d4d9f
Improve font for constant blocks and ace editors
Jesus89 May 14, 2018
67b1111
Enable same-block replacements
Jesus89 May 15, 2018
5244fe5
Implement zoom for Memory block
Jesus89 May 15, 2018
27a4d57
Improve zoom for Code block
Jesus89 May 15, 2018
3dfade4
Improve zoom for Info block
Jesus89 May 15, 2018
f4c3be3
Unify getCSSRule function
Jesus89 May 15, 2018
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
3 changes: 2 additions & 1 deletion app/scripts/controllers/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,10 @@ angular.module('icestudio')
function exportFromCompiler(id, name, ext) {
checkGraph()
.then(function() {
// TODO: export list files
utils.saveDialog('#input-export-' + id, ext, function(filepath) {
// Save the compiler result
var data = project.compile(id);
var data = project.compile(id)[0].content;
utils.saveFile(filepath, data)
.then(function() {
alertify.success(gettextCatalog.getString('{{name}} exported', { name: name }));
Expand Down
27 changes: 22 additions & 5 deletions app/scripts/graphics/joint.routers.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ joint.routers.ice = (function(g, _, joint) {
// padding applied on the element bounding boxes
paddingBox: function() {

var step = 1;
var step = 2;

return {
x: -step,
Expand Down Expand Up @@ -95,10 +95,11 @@ joint.routers.ice = (function(g, _, joint) {

// Map of obstacles
// Helper structure to identify whether a point lies in an obstacle.
function ObstacleMap(opt) {
function ObstacleMap(opt, paper) {

this.map = {};
this.options = opt;
this.paper = paper;
// tells how to divide the paper when creating the elements map
this.mapGridSize = 100;
}
Expand Down Expand Up @@ -133,7 +134,8 @@ joint.routers.ice = (function(g, _, joint) {
// to go through all obstacles, we check only those in a particular cell.
var mapGridSize = this.mapGridSize;

_.chain(graph.getElements())
// Compute rectangles from all the blocks
var blockRectangles =_.chain(graph.getElements())
// remove source and target element if required
.difference(excludedEnds)
// remove all elements whose type is listed in excludedTypes array
Expand All @@ -142,7 +144,22 @@ joint.routers.ice = (function(g, _, joint) {
return _.contains(opt.excludeTypes, element.get('type')) || _.contains(excludedAncestors, element.id);
})
// change elements (models) to their bounding boxes
.invoke('getBBox')
.invoke('getBBox').value();

// Compute rectangles from all the port labels
var state = this.paper.options.getState();
var labelRectangles = $('.port-label').map(function(index, node) {
var rect = V(node).bbox();
return g.rect({
x: (rect.x - state.pan.x) / state.zoom,
y: (rect.y - state.pan.y) / state.zoom,
width: rect.width / state.zoom,
height: rect.height / state.zoom
});
}).toArray();

// Add all rectangles to the map's grid
_.chain(blockRectangles.concat(labelRectangles))
// expand their boxes by specific padding
.invoke('moveAndExpand', opt.paddingBox)
// build the map
Expand Down Expand Up @@ -472,7 +489,7 @@ joint.routers.ice = (function(g, _, joint) {
var targetBBox = g.rect(this.targetBBox);

// pathfinding
var map = (new ObstacleMap(opt)).build(this.paper.model, this.model);
var map = (new ObstacleMap(opt, this.paper)).build(this.paper.model, this.model);
var oldVertices = _.map(vertices, g.point);
var newVertices = [];
var tailPoint = sourceBBox.center().snapToGrid(opt.step);
Expand Down
Loading