Skip to content

Commit

Permalink
Fix wrong IO render in copy paste
Browse files Browse the repository at this point in the history
  • Loading branch information
cavearr committed Feb 2, 2025
1 parent e5d31c1 commit e738094
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 15 deletions.
8 changes: 7 additions & 1 deletion app/scripts/graphics/joint.shapes.js
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,13 @@ joint.shapes.ice.GenericView = joint.shapes.ice.ModelView.extend({
const leftPorts = this.model.get('leftPorts');
const rightPorts = this.model.get('rightPorts');
const modelId = this.model.id;
if (state.mutateZoom || state.forceMutate || this.initialized===false) {

//-- temporalBypass permit for the momment bypass the optimal filter,
//-- In the first render state not work properly and the render not works
//-- correctly, until this is fixed, bypass the optimization
//--
let temporalBypass=true;
if (temporalBypass || state.mutateZoom || state.forceMutate || this.initialized===false) {
this.initialized=true;
// Render ports width
let width = WIRE_WIDTH * state.zoom;
Expand Down
2 changes: 0 additions & 2 deletions app/scripts/services/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ angular

for (w in graph.wires) {
var wire = graph.wires[w];
console.log('WIRE', wire);
if (
wire.source.port === 'constant-out' ||
wire.source.port === 'memory-out'
Expand All @@ -456,7 +455,6 @@ angular
var block = graph.blocks[i];
if (block.type === blocks.BASIC_INPUT) {
if (wire.source.block === block.id) {
console.log('ASSIGN', block);
connections.assign.push(
'assign w' + w + ' = ' + utils.digestId(block.id) + ';'
);
Expand Down
83 changes: 72 additions & 11 deletions app/scripts/services/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,34 @@ angular.module('icestudio').service(
let autorouting = false;
let isRouting = false;

let mousePosition = { x: 0, y: 0 };

/*-- This event flood the task queue,and throttle techniches not work accurate as needed,for this
* i replace this capture method for on demand capture function based on non blocking promise
*
* $('body').mousemove(function (event) {
mousePosition = {
x: event.pageX,
y: event.pageY,
};
});
--*/


let needsUpdate = true;

document.addEventListener("mousemove", (event) => {
if (needsUpdate) {
needsUpdate = false;
requestAnimationFrame(() => {
mousePosition.x = event.pageX;
mousePosition.y = event.pageY;
needsUpdate = true; // Permitimos la siguiente actualización
});
}
});


this.route = function () {
if (!isRouting) {
isRouting = true;
Expand All @@ -42,7 +70,7 @@ angular.module('icestudio').service(
if (autorouting === false) {
autorouting = true;
$('body').on('Graph::updateWires', function () {
// _this.route();
_this.route();
});
}
};
Expand Down Expand Up @@ -99,7 +127,6 @@ angular.module('icestudio').service(
let selection = null;
let selectionView = null;
let commandManager = null;
let mousePosition = { x: 0, y: 0 };
let gridsize = 8;

let self = this;
Expand Down Expand Up @@ -525,14 +552,8 @@ function isElementInViewport(elementBBox, viewport) {
}
});

/* $('body').mousemove(function (event) {
mousePosition = {
x: event.pageX,
y: event.pageY,
};
});
*/
selectionView.on('selection-box:pointerdown', function (/*evt*/) {

selectionView.on('selection-box:pointerdown', function (/*evt*/) {
// Move selection to top view
if (hasSelection()) {
selection.each(function (cell) {
Expand Down Expand Up @@ -1187,6 +1208,8 @@ function isElementInViewport(elementBBox, viewport) {
this.addDraggableCell = function (cell) {
this.addingDraggableBlock = true;
let menuHeight = $('#menu').height();


cell.set('position', {
x:
Math.round(
Expand All @@ -1211,12 +1234,18 @@ function isElementInViewport(elementBBox, viewport) {
clientX: mousePosition.x,
clientY: mousePosition.y,
});



};

this.addDraggableCells = function (cells) {
this.addingDraggableBlock = true;
let menuHeight = $('#menu').height();
if (cells.length > 0) {



let firstCell = cells[0];
let offset = {
x:
Expand Down Expand Up @@ -1255,6 +1284,8 @@ function isElementInViewport(elementBBox, viewport) {
clientX: mousePosition.x,
clientY: mousePosition.y,
});


}
};

Expand Down Expand Up @@ -1848,6 +1879,32 @@ function isElementInViewport(elementBBox, viewport) {
return cells;
}

this.isTopLevel=function(){

return (this.breadcrumbs.length<2);
};

this.convertIOtoTop = function (design) {
if (this.isTopLevel()) {
design.graph.blocks = design.graph.blocks
.filter((block) => {
if (block.type === "basic.input" || block.type === "basic.output") {
if (block.data.clock === true) { return false;}

block.virtual = false;
block.data.pins = block.data.pins ??
Array.from({ length: block.data.size ?? 1 }, (_, p) => ({
index: `${p}`,
name: "NULL",
value: "NULL",
}));
}
return true;
});
}
design.board=common.selectedBoard.name;
return design;
};
this.appendDesign = function (design, dependencies) {
if (
design &&
Expand All @@ -1856,13 +1913,16 @@ function isElementInViewport(elementBBox, viewport) {
design.graph.blocks &&
design.graph.wires
) {

selectionView.cancelSelection();
// Merge dependencies
for (let type in dependencies) {
if (!(type in common.allDependencies)) {
common.allDependencies[type] = dependencies[type];
}
}

design=this.convertIOtoTop(design);

// Append graph cells: blocks and wires
// - assign new UUIDs to the cells
Expand Down Expand Up @@ -1902,7 +1962,8 @@ function isElementInViewport(elementBBox, viewport) {
cellView.updateBox(true);
}
});
}

}
};

function graphOrigin(graph) {
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/services/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ angular
if (result === 'cancel') {
return;
}

console.log(callback,block);
callback(block);
});
} else {
Expand Down

0 comments on commit e738094

Please sign in to comment.