Skip to content

Commit

Permalink
Prevent groups connected to an interface vertex from moving, see #113
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Jun 14, 2016
1 parent d2d4777 commit 5a93e4d
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions js/blackbox/view/BlackBoxSceneView.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,33 @@ define( function( require ) {
// Find all the vertices that must be translated into the box, translating wires
(function() {
var vertices = blackBoxSceneModel.circuit.findAllConnectedVertices( vertex );
for ( var i = 0; i < vertices.length; i++ ) {
var vertexInGroup = vertices[ i ];
var connectedToBlackBox = vertices.filter( function( v ) {return v.blackBoxInterface;} ).length > 0;
if ( !connectedToBlackBox ) {
for ( var i = 0; i < vertices.length; i++ ) {
var vertexInGroup = vertices[ i ];

var closestPoint = blackBoxNode.bounds.closestPointTo( vertexInGroup.position );
var delta = closestPoint.minus( vertexInGroup.position );
var closestPoint = blackBoxNode.bounds.closestPointTo( vertexInGroup.position );
var delta = closestPoint.minus( vertexInGroup.position );

blackBoxSceneView.circuitNode.translateVertexGroup( vertexInGroup, vertices, delta, null, [] );
blackBoxSceneView.circuitNode.translateVertexGroup( vertexInGroup, vertices, delta, null, [] );
}
}
})();

// Find all the vertices that must be translated into the box, shrinking wires
// TODO: Factor out
(function() {
var vertices = blackBoxSceneModel.circuit.findAllFixedVertices( vertex );
for ( var i = 0; i < vertices.length; i++ ) {
var vertexInGroup = vertices[ i ];
var connectedToBlackBox = vertices.filter( function( v ) {return v.blackBoxInterface;} ).length > 0;
if ( !connectedToBlackBox ) {
for ( var i = 0; i < vertices.length; i++ ) {
var vertexInGroup = vertices[ i ];

var closestPoint = blackBoxNode.bounds.closestPointTo( vertexInGroup.position );
var delta = closestPoint.minus( vertexInGroup.position );
var closestPoint = blackBoxNode.bounds.closestPointTo( vertexInGroup.position );
var delta = closestPoint.minus( vertexInGroup.position );

blackBoxSceneView.circuitNode.translateVertexGroup( vertexInGroup, vertices, delta, null, [] );
blackBoxSceneView.circuitNode.translateVertexGroup( vertexInGroup, vertices, delta, null, [] );
}
}
})();
}
Expand Down

0 comments on commit 5a93e4d

Please sign in to comment.