- moved all plugin-related classes to Eithne.Plugin namespace
[FaRetSys.git] / Plugins / ResultData / ResultData.cs
blobfe612992e84e4dfd0f47cfdadb65d30d623001ea
1 using System;
2 using System.Xml;
3 using Mono.Unix;
5 namespace Eithne
7 public class ResultDataInfo : IInfo
9 public override string Name
11 get { return Catalog.GetString("Result Data"); }
14 public override string ShortName
16 get { return "ResData"; }
19 public override string Author
21 get { return "Bartosz Taudul"; }
24 public override string Description
26 get { return Catalog.GetString("This plugin shows raw data coming to block's input socket."); }
30 public class ResultDataFactory : IFactory
32 IInfo _info = new ResultDataInfo();
33 public IInfo Info
35 get { return _info; }
38 public IType Type
40 get { return IType.Out; }
43 public void Initialize()
47 public Plugin.Base Create()
49 return new ResultDataPlugin();
53 public class ResultDataPlugin : Plugin.Out
55 Gdk.Pixbuf[] itest = null;
56 Gdk.Pixbuf[] ibase = null;
57 IResult[] res = null;
58 int[] match = null;
60 public ResultDataPlugin()
62 _info = new ResultDataInfo();
65 public override void DisplayResults()
67 if(!_workdone)
68 throw new PluginException(Catalog.GetString("Plugin is not ready to display results."));
70 new ResultData(ibase, itest, res, match);
73 public override void Work()
75 ICommResult r = _in[0] as ICommResult;
77 itest = new Gdk.Pixbuf[r.Length];
78 ibase = new Gdk.Pixbuf[r.OriginalBaseImages.Length];
80 double scale;
82 for(int i=0; i<itest.Length; i++)
84 IImage img = r.OriginalTestImages[i];
86 if(img.W > img.H)
87 scale = img.W / 32.0;
88 else
89 scale = img.H / 32.0;
91 Gdk.Pixbuf tmp = img.CreatePixbuf();
92 itest[i] = tmp.ScaleSimple(Scale(img.W, scale), Scale(img.H, scale), Gdk.InterpType.Bilinear);
95 for(int i=0; i<ibase.Length; i++)
97 IImage img = r.OriginalBaseImages[i];
99 if(img.W > img.H)
100 scale = img.W / 32.0;
101 else
102 scale = img.H / 32.0;
104 Gdk.Pixbuf tmp = img.CreatePixbuf();
105 ibase[i] = tmp.ScaleSimple(Scale(img.W, scale), Scale(img.H, scale), Gdk.InterpType.Bilinear);
108 res = new IResult[r.Length];
109 for(int i=0; i<r.Length; i++)
110 res[i] = r[i];
112 match = r.FindResultsSimple();
114 for(int i=0; i<r.Length; i++)
115 if(!r.Match[i])
116 match[i] = -1;
118 _workdone = true;
121 private int Scale(int s, double scale)
123 int val = (int)(s/scale);
125 if(val == 0)
126 return 1;
127 else
128 return val;
131 public override int NumIn { get { return 1; } }
133 public override string DescIn(int n)
135 return Catalog.GetString("Results to be displayed in raw form.");
138 private static string[] matchin = new string[] { "result" };
139 public override string[] MatchIn { get { return matchin; } }