소스 검색

Improvement: import is able to parse comma separated definitions of variables

Improvement: import ignores lines which start with an known type but ends not with an ";"
Tidy up: deleted the "resources" folder, all static data is in the index.html file
Prepared: Looking for a solution to semi-automatic arrange imported nodes without coordinates
dds
Manfred Müller-Späth 9 년 전
부모
커밋
1c522d1be2
3개의 변경된 파일55개의 추가작업 그리고 64개의 파일을 삭제
  1. +46
    -19
      gui/red/nodes.js
  2. +9
    -2
      gui/red/ui/view.js
  3. +0
    -43
      gui/resources/nodes_def.json

+ 46
- 19
gui/red/nodes.js 파일 보기

@@ -321,11 +321,13 @@ RED.nodes = (function() {
var skipped = [];
var cables = [];
var words = [];
var lastY = 0;

const NODE_COMMENT = "//";
const NODE_AC = "AudioConnection";

var parseLine = function(line) {

var parts = line.match(/^(\S+)\s(.*)/);
if (parts == null) {
return
@@ -337,7 +339,7 @@ RED.nodes = (function() {
var type = $.trim(parts[0]);
line = $.trim(parts[1]) + " ";

var description = "";
var name = "";
var coords = [0, 0];
var conn = [];

@@ -345,7 +347,7 @@ RED.nodes = (function() {
if (parts && parts.length >= 2) {
parts = parts.slice(1);
if (parts && parts.length >= 1) {
description = $.trim(parts[0]);
name = $.trim(parts[0]);
coords = $.trim(parts[1]);
parts = coords.match(/^([^\/]{0,})\/\/xy=(.*)/);
if (parts) {
@@ -356,7 +358,7 @@ RED.nodes = (function() {
}

if (type == NODE_AC) {
parts = description.match(/^([^\(]*\()([^\)]*)(.*)/);
parts = name.match(/^([^\(]*\()([^\)]*)(.*)/);
if (parts && parts.length > 1) {
conn = $.trim(parts[2]).split(",");
cables.push(conn);
@@ -364,19 +366,30 @@ RED.nodes = (function() {
} else if (type == NODE_COMMENT) {
// do nothing
} else {
var node = new Object({
"id": description,
"type": type,
"x": parseInt(coords ? coords[0] : 0),
"y": parseInt(coords ? coords[1] : 0),
"z": 0,
"wires": []
});
// first solution: skip existing id
if (RED.nodes.node(node.id) !== null) {
skipped.push(node.id);
var names = [];
var yPos = [];
if (name.indexOf(",") >= 0) {
names = name.split(",");
} else {
newNodes.push(node);
names.push(name);
}
for (var n = 0; n < names.length; n++) {
name = names[n].trim();
var gap = 10;
var def = node_defs[type];
var dW = Math.max(RED.view.defaults.width, RED.view.calculateTextWidth(name) + (def.inputs > 0 ? 7 : 0));
var dH = Math.max(RED.view.defaults.height,(Math.max(def.outputs, def.inputs)||0) * 15);
var newX = parseInt(coords ? coords[0] : 0);
var newY = parseInt(coords ? coords[1] : 0);
//newY = newY == 0 ? lastY + (dH * n) + gap : newY;
//lastY = Math.max(lastY, newY);
var node = new Object({"order": n, "id": name, "type": type, "x": newX, "y": newY, "z": 0, "wires": []});
// first solution: skip existing id
if (RED.nodes.node(node.id) !== null) {
skipped.push(node.id);
} else {
newNodes.push(node);
}
}
}
};
@@ -419,14 +432,28 @@ RED.nodes = (function() {
var traverseLines = function(raw) {
var lines = raw.split("\n");
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
var line = lines[i].trim();

// we reached the setup or loop part ...
var pattSu = new RegExp(/\s*void\s*setup\s*\(\s*\).*/);
var pattLo = new RegExp(/\s*void\s*loop\s*\(\s*\).*/);
if (pattSu.test(line) || pattLo.test(line)) {
break;
}

// we need at least two parts to examine
var parts = line.match(/^(\S+)\s(.*)/);
if (parts == null || parts.length == 1) {
continue;
}
var word = parts[1].trim();
if (words.indexOf(word) >= 0) {
parseLine(line);

// ... and it has to end with an semikolon ...
var pattSe = new RegExp(/.*;$/);
if (pattSe.test(line)) {
var word = parts[1].trim();
if (words.indexOf(word) >= 0) {
parseLine(line);
}
}
}
};

+ 9
- 2
gui/red/ui/view.js 파일 보기

@@ -990,6 +990,7 @@ RED.view = (function() {
RED.touch.radialMenu.show(obj,pos,options);
resetMouseVars();
}

function redraw() {
vis.attr("transform","scale("+scaleFactor+")");
outer.attr("width", space_width*scaleFactor).attr("height", space_height*scaleFactor);
@@ -1377,6 +1378,7 @@ RED.view = (function() {
d.dirty = false;
}
});

}

var link = vis.selectAll(".link").data(RED.nodes.links.filter(function(d) { return d.source.z == activeWorkspace && d.target.z == activeWorkspace }),function(d) { return d.source.id+":"+d.sourcePort+":"+d.target.id+":"+d.targetPort;});
@@ -1453,7 +1455,7 @@ RED.view = (function() {
}

function arrangeAll() {
// TODO: arange all nodes optimized without collision
// TODO: arrange imported nodes without coordinates
}

RED.keyboard.add(/* z */ 90,{ctrl:true},function(){RED.history.pop();});
@@ -1778,6 +1780,11 @@ RED.view = (function() {
//TODO: subscribe/unsubscribe here
redraw();
},
getForm: getForm
getForm: getForm,
calculateTextWidth: calculateTextWidth,
defaults: {
width: node_width,
height: node_height
}
};
})();

+ 0
- 43
gui/resources/nodes_def.json 파일 보기

@@ -1,43 +0,0 @@
{"nodes":[
{"type":"AudioInputI2S","data":{"defaults":{"name":{"value":"new"}},"shortName":"i2s","inputs":0,"outputs":2,"category":"input-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioInputAnalog","data":{"defaults":{"name":{"value":"new"}},"shortName":"adc","inputs":0,"outputs":1,"category":"input-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioInputI2Sslave","data":{"defaults":{"name":{"value":"new"}},"shortName":"i2ss","inputs":0,"outputs":2,"category":"input-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioOutputI2S","data":{"defaults":{"name":{"value":"new"}},"shortName":"i2s","inputs":2,"outputs":0,"category":"output-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioOutputSPDIF","data":{"defaults":{"name":{"value":"new"}},"shortName":"spdif","inputs":2,"outputs":0,"category":"output-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioOutputAnalog","data":{"defaults":{"name":{"value":"new"}},"shortName":"dac","inputs":1,"outputs":0,"category":"output-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioOutputPWM","data":{"defaults":{"name":{"value":"new"}},"shortName":"pwm","inputs":1,"outputs":0,"category":"output-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioOutputI2Sslave","data":{"defaults":{"name":{"value":"new"}},"shortName":"i2ss","inputs":2,"outputs":0,"category":"output-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioMixer4","data":{"defaults":{"name":{"value":"new"}},"shortName":"mixer","inputs":4,"outputs":1,"category":"mixer-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioPlayMemory","data":{"defaults":{"name":{"value":"new"}},"shortName":"playMem","inputs":0,"outputs":1,"category":"play-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioPlaySdWav","data":{"defaults":{"name":{"value":"new"}},"shortName":"playSdWav","inputs":0,"outputs":2,"category":"play-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioPlaySdRaw","data":{"defaults":{"name":{"value":"new"}},"shortName":"playSdRaw","inputs":0,"outputs":1,"category":"play-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioPlaySerialflashRaw","data":{"defaults":{"name":{"value":"new"}},"shortName":"playFlashRaw","inputs":0,"outputs":1,"category":"play-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioPlayQueue","data":{"defaults":{"name":{"value":"new"}},"shortName":"queue","inputs":0,"outputs":1,"category":"play-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioRecordQueue","data":{"defaults":{"name":{"value":"new"}},"shortName":"queue","inputs":1,"outputs":0,"category":"record-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioSynthWaveformSine","data":{"defaults":{"name":{"value":"new"}},"shortName":"sine","inputs":0,"outputs":1,"category":"synth-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioSynthWaveformSineModulated","data":{"defaults":{"name":{"value":"new"}},"shortName":"sine_fm","inputs":1,"outputs":1,"category":"synth-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioSynthWaveform","data":{"defaults":{"name":{"value":"new"}},"shortName":"waveform","inputs":0,"outputs":1,"category":"synth-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioSynthToneSweep","data":{"defaults":{"name":{"value":"new"}},"shortName":"tonesweep","inputs":0,"outputs":1,"category":"synth-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioSynthWaveformDc","data":{"defaults":{"name":{"value":"new"}},"shortName":"dc","inputs":0,"outputs":1,"category":"synth-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioSynthNoiseWhite","data":{"defaults":{"name":{"value":"new"}},"shortName":"noise","inputs":0,"outputs":1,"category":"synth-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioSynthNoisePink","data":{"defaults":{"name":{"value":"new"}},"shortName":"pink","inputs":0,"outputs":1,"category":"synth-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioEffectFade","data":{"defaults":{"name":{"value":"new"}},"shortName":"fade","inputs":1,"outputs":1,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioEffectChorus","data":{"defaults":{"name":{"value":"new"}},"shortName":"chorus","inputs":1,"outputs":1,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioEffectFlange","data":{"defaults":{"name":{"value":"new"}},"shortName":"flange","inputs":1,"outputs":1,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioEffectEnvelope","data":{"defaults":{"name":{"value":"new"}},"shortName":"envelope","inputs":1,"outputs":1,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioEffectMultiply","data":{"defaults":{"name":{"value":"new"}},"shortName":"multiply","inputs":2,"outputs":1,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioEffectDelay","data":{"defaults":{"name":{"value":"new"}},"shortName":"delay","inputs":1,"outputs":8,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioEffectDelayExternal","data":{"defaults":{"name":{"value":"new"}},"shortName":"delayExt","inputs":1,"outputs":8,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioEffectBitcrusher","data":{"shortName":"bitcrusher","inputs":1,"outputs":1,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioFilterBiquad","data":{"defaults":{"name":{"value":"new"}},"shortName":"biquad","inputs":1,"outputs":1,"category":"filter-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioFilterFIR","data":{"defaults":{"name":{"value":"new"}},"shortName":"fir","inputs":1,"outputs":1,"category":"filter-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioFilterStateVariable","data":{"defaults":{"name":{"value":"new"}},"shortName":"filter","inputs":2,"outputs":3,"category":"filter-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioAnalyzePeak","data":{"defaults":{"name":{"value":"new"}},"shortName":"peak","inputs":1,"outputs":0,"category":"analyze-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioAnalyzeFFT256","data":{"defaults":{"name":{"value":"new"}},"shortName":"fft256","inputs":1,"outputs":0,"category":"analyze-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioAnalyzeFFT1024","data":{"defaults":{"name":{"value":"new"}},"shortName":"fft1024","inputs":1,"outputs":0,"category":"analyze-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioAnalyzeToneDetect","data":{"defaults":{"name":{"value":"new"}},"shortName":"tone","inputs":1,"outputs":0,"category":"analyze-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioAnalyzePrint","data":{"defaults":{"name":{"value":"new"}},"shortName":"print","inputs":1,"outputs":0,"category":"analyze-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioControlSGTL5000","data":{"defaults":{"name":{"value":"new"}},"shortName":"sgtl5000","inputs":0,"outputs":0,"category":"control-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioControlWM8731","data":{"defaults":{"name":{"value":"new"}},"shortName":"wm8731","inputs":0,"outputs":0,"category":"control-function","color":"#E6E0F8","icon":"arrow-in.png"}},
{"type":"AudioControlWM8731master","data":{"defaults":{"name":{"value":"new"}},"shortName":"wm8731m","inputs":0,"outputs":0,"category":"control-function","color":"#E6E0F8","icon":"arrow-in.png"}}
]}

Loading…
취소
저장