[147] | 1 | #include "canvasutil.h" |
---|
| 2 | |
---|
| 3 | static int std_unknown_symbol[]={12, 1,4, 25,25, 75,25, 75,75, 25,75, 25,25}; |
---|
| 4 | static int std_neuron_symbol[]={12, 1,4, 75,50, 25,0, 25,99, 75,50, 100,50}; |
---|
| 5 | static int std_inputonly_symbol[]={14, 1,5, 25,40, 35,40, 45,50, 35,60, 25,60, 25,40}; |
---|
| 6 | static int std_outputonly_symbol[]={18, 1,7, 75,50, 75,60, 55,60, 65,50, 55,40, 75,40, 75,50, 100,50}; |
---|
| 7 | |
---|
| 8 | int* drawNeuroSymbol(CanvasDrawing* c,NeuroClass* cl,int x,int y,int w,int h) |
---|
| 9 | { |
---|
| 10 | int *data=std_unknown_symbol; |
---|
| 11 | if (cl) |
---|
| 12 | { |
---|
| 13 | data=cl->getSymbolGlyph(); |
---|
| 14 | if (!data) |
---|
| 15 | { |
---|
| 16 | if (cl->getPreferredInputs()==0) |
---|
| 17 | data=std_outputonly_symbol; |
---|
| 18 | else if (cl->getPreferredOutput()==0) |
---|
| 19 | data=std_inputonly_symbol; |
---|
| 20 | else data=std_neuron_symbol; |
---|
| 21 | } |
---|
| 22 | } |
---|
| 23 | drawVector(c,data,x,y,w,h); |
---|
| 24 | return data; |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | void drawVector(CanvasDrawing* c,int data[],int x,int y,int w,int h) |
---|
| 28 | { |
---|
| 29 | if (!data) return; |
---|
| 30 | Pixel p; |
---|
| 31 | data++; |
---|
| 32 | for (int NL=*(data++);NL>0;NL--) |
---|
| 33 | { |
---|
| 34 | int NS=*(data++); |
---|
| 35 | p.x=x+(*(data++)*w)/100; |
---|
| 36 | p.y=y+(*(data++)*h)/100; |
---|
| 37 | c->moveTo(p); |
---|
| 38 | for (;NS>0;NS--) |
---|
| 39 | { |
---|
| 40 | p.x=x+(*(data++)*w)/100; |
---|
| 41 | p.y=y+(*(data++)*h)/100; |
---|
| 42 | c->lineTo(p); |
---|
| 43 | } |
---|
| 44 | } |
---|
| 45 | } |
---|