|
From: <ma...@us...> - 2011-01-14 23:51:04
|
Revision: 248
http://openautomation.svn.sourceforge.net/openautomation/?rev=248&view=rev
Author: mayerch
Date: 2011-01-14 23:50:58 +0000 (Fri, 14 Jan 2011)
Log Message:
-----------
Inital support for bigger target areas (inkl. preparation for non square blocks)
Modified Paths:
--------------
PyWireGate/trunk/logic_editor/backendCommunication.js
PyWireGate/trunk/logic_editor/gle/gle.block.js
PyWireGate/trunk/logic_editor/gle/gle.connection.js
PyWireGate/trunk/logic_editor/logicEditor.js
Modified: PyWireGate/trunk/logic_editor/backendCommunication.js
===================================================================
--- PyWireGate/trunk/logic_editor/backendCommunication.js 2011-01-14 22:39:21 UTC (rev 247)
+++ PyWireGate/trunk/logic_editor/backendCommunication.js 2011-01-14 23:50:58 UTC (rev 248)
@@ -54,6 +54,34 @@
],
'outPorts': [],
'parameters':{}
+ },
+ 'sink2': {
+ 'width': 100,
+ 'height': 100,
+ 'rotation': 0,
+ 'flip': false,
+ 'color': [0.0, 0.0, 0.0],
+ 'background': [1.0, 1.0, 1.0],
+ 'inPorts': [
+ {
+ 'name': 'in',
+ 'type': 'event'
+ },
+ {
+ 'name': 'in',
+ 'type': 'event'
+ },
+ {
+ 'name': 'in',
+ 'type': 'event'
+ },
+ {
+ 'name': 'in',
+ 'type': 'event'
+ }
+ ],
+ 'outPorts': [],
+ 'parameters':{}
}
},
'mathLib': {
Modified: PyWireGate/trunk/logic_editor/gle/gle.block.js
===================================================================
--- PyWireGate/trunk/logic_editor/gle/gle.block.js 2011-01-14 22:39:21 UTC (rev 247)
+++ PyWireGate/trunk/logic_editor/gle/gle.block.js 2011-01-14 23:50:58 UTC (rev 248)
@@ -103,6 +103,7 @@
} else {
canvas.rect( body, 0, 0, width, height, style );
}
+ if( addEvent ) editorConnectionPointCreate( body, undefined, undefined );
// extend the style for the ports...
style.cursor = 'crosshair';
@@ -297,10 +298,13 @@
////////////////
function editorConnectionPointCreate( obj, portType, portNumber )
{
- $(obj).bind( 'mousedown', {
- portType :portType,
- portNumber:portNumber
- }, editorConnectionPointDrag );
+ if( portType !== undefined && portNumber !== undefined )
+ {
+ $(obj).bind( 'mousedown', {
+ portType :portType,
+ portNumber:portNumber
+ }, editorConnectionPointDrag );
+ }
$(obj).bind( 'mouseover', {
portType :portType,
portNumber:portNumber
@@ -352,11 +356,42 @@
function editorConnectionPointOverPort( event )
{
console.log( 'eCPOP', event.data.portType );
- overPort = {
- block : that,
- type : event.data.portType,
- number: event.data.portNumber
- };
+ if( event.data.portType !== undefined && event.data.portNumber !== undefined )
+ {
+ overPort = {
+ block : that,
+ type : event.data.portType,
+ number: event.data.portNumber
+ };
+ } else {
+ var ex = event.pageX - $('#editor')[0].offsetLeft;
+ var ey = event.pageY - $('#editor')[0].offsetTop;
+ var distance = function( pos )
+ {
+ return (ex-pos[0])*(ex-pos[0]) + (ey-pos[1])*(ey-pos[1]);
+ }
+ if( connectionLookingForInPort )
+ {
+ var smallestDistance = 1e99;
+ var smallestDistancePort = -1;
+ for( var i = 0; i < inPorts.length; i++ )
+ {
+ var dist = distance( that.inPortPos(i) );
+ if( dist < smallestDistance )
+ {
+ smallestDistance = dist;
+ smallestDistancePort = i;
+ }
+ }
+ overPort = {
+ block : that,
+ type : 'inPort',
+ number: smallestDistancePort
+ };
+ } else {
+ // FIXME ADD outPort
+ }
+ }
}
function editorConnectionPointOverPortOut( event )
Modified: PyWireGate/trunk/logic_editor/gle/gle.connection.js
===================================================================
--- PyWireGate/trunk/logic_editor/gle/gle.connection.js 2011-01-14 22:39:21 UTC (rev 247)
+++ PyWireGate/trunk/logic_editor/gle/gle.connection.js 2011-01-14 23:50:58 UTC (rev 248)
@@ -130,7 +130,7 @@
function editorDragMouseMove( event )
{
var ed = event.data;
- console.log('cDMM', ed );
+ //console.log('cDMM', ed );
if( ed.extend )
{
that.lastMove( [ed.origx - ed.startx + event.pageX, ed.origy - ed.starty + event.pageY], false );
@@ -139,30 +139,6 @@
paths[ed.obj[1]].path[ed.obj[2]][1] = ed.origy - ed.starty + event.pageY;
draw();
}
- /*
- if( 'move' == event.data.type )
- {
- relocate(); // shortcut
- } else {
- if( width < 10 ) width = 10; // sanity...
- if( height < 10 ) height = 10; // sanity...
- draw();
- }
-
- $.each( inPorts, function(i){
- if( 'connection' in this )
- {
- this.connection.lastMove( that.inPortPos( i ), true );
- }
- });
-
- $.each( outPorts, function(i){
- if( 'connection' in this )
- {
- this.connection.firstMove( that.outPortPos( i ) );
- }
- });
- */
}
function editorDragMouseUp( event )
Modified: PyWireGate/trunk/logic_editor/logicEditor.js
===================================================================
--- PyWireGate/trunk/logic_editor/logicEditor.js 2011-01-14 22:39:21 UTC (rev 247)
+++ PyWireGate/trunk/logic_editor/logicEditor.js 2011-01-14 23:50:58 UTC (rev 248)
@@ -19,6 +19,7 @@
// global variables
var overPort = false;
+var connectionLookingForInPort = true; // only relevant in connection drawing mode
var maxX = 500; // the biggest x value of the current view
var maxY = 0; // the biggest y value of the current view
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|