Example #1
0
        public void addMacroEntryTest_index()
        {
            Macro_Accessor target = new Macro_Accessor();
            MacroEntry child = new MacroEntry("testPlugin", PluginType.IFilterOqat, "testmemento");
            int index = 1;
            MacroEntry father = target.rootEntry;
            target.addMacroEntry(new MacroEntry("testPlugin2", PluginType.IFilterOqat, "testmementoX"), father);
            target.addMacroEntry(new MacroEntry("testPlugin2", PluginType.IFilterOqat, "testmementoY"), father);
            target.addMacroEntry(child, father, index);

            Assert.IsTrue(target.rootEntry.macroEntries.Contains(child), "Filter was not added to macro.");
            Assert.AreEqual<MacroEntry>(target.rootEntry.macroEntries[index], child, "Filter was not added at correct index.");
        }
Example #2
0
        public void removeMacroEntryTest_ok()
        {
            Macro_Accessor target = new Macro_Accessor();
            MacroEntry child = new MacroEntry("testplugin", PluginType.IFilterOqat, "testmemento");
            target.addMacroEntry(child, target.rootEntry);

            target.removeMacroEntry(child);

            Assert.IsFalse(target.rootEntry.macroEntries.Contains(child), "Entry was not removed.");
        }
Example #3
0
        public void removeMacroEntryTest_nonexistent()
        {
            Macro_Accessor target = new Macro_Accessor();
            MacroEntry child = new MacroEntry("testplugin", PluginType.IFilterOqat, "testmemento");
            target.addMacroEntry(child, target.rootEntry);

            MacroEntry rem = new MacroEntry("blaplugin", PluginType.IFilterOqat, "blamemento");
            target.removeMacroEntry(rem);

            Assert.IsTrue(target.rootEntry.macroEntries.Contains(child), "Entry was unexpectedly removed.");
        }
Example #4
0
        public void moveMacroEntryTest()
        {
            Macro_Accessor target = new Macro_Accessor();
            MacroEntry child = new MacroEntry("testplugin", PluginType.IFilterOqat, "testmemento");
            target.addMacroEntry(child, target.rootEntry);
            MacroEntry child2 = new MacroEntry("testpluginmacro", PluginType.IMacro, "testmemento2");
            target.addMacroEntry(child2, target.rootEntry);

            MacroEntry toMoveMacro = child;
            MacroEntry target1 = child2;
            int index = 0;
            target.moveMacroEntry(toMoveMacro, target1, index);

            Assert.AreEqual(1, target.rootEntry.macroEntries.Count, "Entry was not moved away.");
            Assert.IsTrue(target.rootEntry.macroEntries[0].macroEntries.Contains(child), "Entry was not moved to new parent.");
        }
Example #5
0
        public void getMementoTest()
        {
            Macro_Accessor target = new Macro_Accessor();

            string mementoname = "setmementotestmemento";
            MacroEntry macroentry = new MacroEntry("testPlugin", PluginType.IFilterOqat, "testMemento");
            MacroEntry subentry = new MacroEntry("testPlugin2", PluginType.IFilterOqat, "testMemento2");
            macroentry.macroEntries.Add(subentry);
            Memento memento = new Memento(mementoname, macroentry);
            target.setMemento(memento);

            Memento actual;
            actual = target.getMemento();
            Assert.IsNotNull(actual, "Memento not returned.");
            Assert.AreEqual(mementoname, actual.name);
            Assert.IsNotNull(actual.state, "Memento is empty");
            Assert.AreEqual(subentry, ((MacroEntry)actual.state).macroEntries[0]);
        }
Example #6
0
        private void addMacroEntry(MementoEventArgs e, MacroEntry father, int index = -1)
        {
            var entryToAdd = constructMacroFromMementoArg(e);

            if ((entryToAdd.type == PluginType.IMacro) && (this.rootEntry.macroEntries.Count() == 0))
                addMacroEntry(entryToAdd, null);

            else
                addMacroEntry(entryToAdd, father, index);
        }
Example #7
0
        public void setVideoTest_emptyData()
        {
            Diagramm target = new Diagramm();
            bool isAnalysis = true;
            string vidPath = "";
            IVideoInfo vinfo = null;
            List<IMacroEntry> processedBy = new List<IMacroEntry>();
            MacroEntry macroEntry = new MacroEntry("TestPlugin", PluginType.IMetricOqat, "TestMemento");
            processedBy.Add(macroEntry);
            Video video = new Video(isAnalysis, vidPath, vinfo, processedBy);

            float[][] data = new float[2][];
            data[0] = new float[5];
            data[1] = new float[5];
            video.frameMetricValue = data;

            target.setVideo(video);
            //assert: no exception
        }
Example #8
0
        public void addMacroEntryTest_notRootentry()
        {
            Macro_Accessor target = new Macro_Accessor();
            MacroEntry child = new MacroEntry("testPlugin", PluginType.IFilterOqat, "testmemento");
            MacroEntry father = null;
            target.addMacroEntry(child, father);

            //expect filter not to be set as root but rather added as child
            Assert.AreNotEqual(child.mementoName, target.rootEntry.mementoName, "Filter was set as rootentry.");
            Assert.IsTrue(target.rootEntry.macroEntries.Contains(child), "Filter was not added to macro.");
        }
Example #9
0
        private void removeMacroEntry(MacroEntry entry)
        {
            lock (this.rootEntry)
            {
                if (rootEntry.macroEntries.Contains(entry))
                {
                    rootEntry.macroEntries.Remove(entry);

                }
                else
                {
                    List<MacroEntry> seqMacroEntryList = new List<MacroEntry>();
                    recursiveFilterExplorer(this.rootEntry, seqMacroEntryList);

                    foreach (var listEntry in seqMacroEntryList)
                    {
                        if (listEntry.macroEntries.Contains(entry))
                        {
                            listEntry.macroEntries.Remove(entry);
                            break;
                        }
                    }
                }
            }
        }
Example #10
0
        private void recursiveMetricExplorer(MacroEntry entry, List<metricResultContext> seqMacroEntryList)
        {
            if(seqMacroEntryList == null)
                throw new ArgumentNullException("Given seqMacroEntryList is null.");

            foreach (var subEntry in entry.macroEntries)
            {
                if (subEntry.type != PluginType.IMacro)
                {
                    metricResultContext metResContext;

                    string path;

                    if (subEntry.path != null)
                        path = subEntry.path;
                    else
                    {
                        path = findValidVidPath(handProc.readPath, subEntry.pluginName);

                    }

                    var tmpEntryList = new List<IMacroEntry>();
                    var newEntry = new MacroEntry(subEntry.pluginName, subEntry.type, subEntry.mementoName);

                    metResContext.entry = newEntry;
                    metResContext.entry._endFrameRelative = subEntry._endFrameRelative;
                    metResContext.entry._startFrameRelative = subEntry._startFrameRelative;
                    metResContext.entry.frameCount = subEntry.frameCount;
                    metResContext.entry.mementoName = subEntry.mementoName;

                    tmpEntryList.Add(newEntry);

                    var tmpVidInfo = handProc.readVidInfo.Clone() as IVideoInfo;

                    tmpVidInfo.path = path;

                    tmpVidInfo.frameCount = (int)(subEntry.endFrameAbs - subEntry.startFrameAbs);

                    metResContext.vidRes = new Video(isAnalysis: true,
                                                    vidPath: path,
                                                    vidInfo: tmpVidInfo,
                                                    processedBy: tmpEntryList);

                    (metResContext.vidRes as Video).frameMetricValue = new float[metResContext.vidRes.vidInfo.frameCount][];
                    metResContext.handRes = metResContext.vidRes.getExtraHandler();
                    metResContext.handRes.setWriteContext(metResContext.vidRes.vidPath, metResContext.vidRes.vidInfo);
                    seqMacroEntryList.Add(metResContext);
                }
                else
                {
                    // go down to first found non macro
                    recursiveMetricExplorer(subEntry, seqMacroEntryList);
                }
            }
        }
Example #11
0
        private void recursiveFilterExplorer(MacroEntry entry, List<MacroEntry> seqMacroList)
        {
            Debug.Assert(seqMacroList != null, "seqMacroList is null");
            foreach (var subEntry in entry.macroEntries)
            {
                if (subEntry.type != PluginType.IMacro)
                {
                    var newEntry = new MacroEntry(subEntry.pluginName, subEntry.type, subEntry.mementoName);

                    newEntry._endFrameRelative = subEntry._endFrameRelative;
                    newEntry._startFrameRelative = subEntry._startFrameRelative;
                    newEntry.frameCount = subEntry.frameCount;
                    newEntry.mementoName = subEntry.mementoName;
                    seqMacroList.Add(newEntry);
                }
                else
                {
                    // go down to first found filter
                    recursiveFilterExplorer(subEntry, seqMacroList);
                }
            }
        }
Example #12
0
        private void moveMacroEntry(MacroEntry toMoveMacro, MacroEntry target, int index = -1)
        {
            removeMacroEntry(toMoveMacro);

            addMacroEntry(toMoveMacro, target, index);
        }
Example #13
0
        private void doDeepCopy(MacroEntry entryToCopy, ref MacroEntry copy)
        {
            foreach (var entry in entryToCopy.macroEntries)
            {
                if(entry.macroEntries != null) {

                    var macroEntryCopy = new MacroEntry(entry.pluginName, entry.type, entry.mementoName);
                    macroEntryCopy.startFrameRelative = entry.startFrameRelative;
                    macroEntryCopy.endFrameRelative = entry.endFrameRelative;
                    macroEntryCopy.path = entry.path;

                    copy.macroEntries.Add(macroEntryCopy);

                    if (entry.macroEntries.Count() > 0)
                    {
                        macroEntryCopy.macroEntries = new ObservableCollection<MacroEntry>();
                        doDeepCopy(entry, ref macroEntryCopy);
                    }
                }
            }
        }
Example #14
0
        private MacroEntry constructMacroFromMementoArg(MementoEventArgs e)
        {
            IPlugin plToConstrFrom = PluginManager.pluginManager.getPlugin<IPlugin>(e.pluginKey);
            if (plToConstrFrom == null)
                throw new ArgumentException("Given plugin name either does not refer to a existing plugin or is blacklisted.");

            PluginType entryType = PluginManager.pluginManager.getPlugin<IPlugin>(e.pluginKey).type;
            MacroEntry entryToAdd = null;
            if (entryType != PluginType.IMacro)
            {
                entryToAdd = new MacroEntry(e.pluginKey, entryType, e.mementoName);
                entryToAdd.frameCount = this.rootEntry.frameCount;
            }
            else
            {
                var tmpMem = PluginManager.pluginManager.getMemento(e.pluginKey, e.mementoName);
                if (tmpMem == null)
                    throw new ArgumentException("Given parameters do not refer to a existing memento.");
                if(tmpMem.state != rootEntry)
                    entryToAdd = tmpMem.state as MacroEntry;
            }

            return entryToAdd;
        }
Example #15
0
        private void addMacroEntry(MacroEntry child, MacroEntry father, int index = -1)
        {
            lock (this.rootEntry)
            {
                if (this.handRef != null)
                    child.frameCount = handRef.readVidInfo.frameCount;
                else if (this.handProc != null)
                    child.frameCount = handProc.readVidInfo.frameCount;

                if (father == null) // child is new TL macro
                {
                    rootEntry.mementoName = child.mementoName;
                    originallTlMacroName = rootEntry.mementoName;
                    _propertyView.rootEntryMem_TextBox.Text = rootEntry.mementoName;
                    clearMacroEntryList();
                    concatObsCollInplace(rootEntry.macroEntries, child.macroEntries);
                }
                else
                {
                    if (index < 0)
                    {
                        father.macroEntries.Add(child);
                    }
                    else
                    {
                        father.macroEntries.Insert(index, child);
                    }
                }
            }
            // triggers reinitialization
            this._propertyView.readOnly = this._propertyView.readOnly;
        }
Example #16
0
        public void setMementoTest_ok()
        {
            Macro_Accessor target = new Macro_Accessor();

            string mementoname = "setmementotestmemento";
            string entrymementoname = "settestMemento";
            MacroEntry macroentry = new MacroEntry("testPlugin", PluginType.IMacro, entrymementoname);
            MacroEntry subentry = new MacroEntry("testPlugin2", PluginType.IFilterOqat, "testMemento2");
            macroentry.macroEntries.Add(subentry);
            Memento memento = new Memento(mementoname, macroentry);

            target.setMemento(memento);

            Assert.AreEqual<string>(entrymementoname, target.rootEntry.mementoName, "The memento's state was not loaded.");
            Assert.AreEqual(subentry, macroentry.macroEntries[0]);
        }
Example #17
0
        public void addMacroEntryTest_rootentry()
        {
            Macro_Accessor target = new Macro_Accessor();
            MacroEntry child = new MacroEntry("testPlugin", PluginType.IMacro, "testmemento");
            child.macroEntries.Add(new MacroEntry("testplugin2", PluginType.IFilterOqat, "testmemento2"));
            MacroEntry father = null;
            target.addMacroEntry(child, father);

            Assert.AreEqual(child.mementoName, target.rootEntry.mementoName, "Rootentry was not set correctly.");
            Assert.AreEqual(1, target.rootEntry.macroEntries.Count, "Rootentry children were not set.");
        }
Example #18
0
        public void addMacroEntryTest_self()
        {
            Macro_Accessor target = new Macro_Accessor();
            MacroEntry child = new MacroEntry("testPlugin", PluginType.IMacro, "testmemento");
            MacroEntry father = target.rootEntry;
            target.addMacroEntry(child, father);
            target.addMacroEntry(child, child);

            Assert.IsTrue(target.rootEntry.macroEntries.Contains(child), "Entry was not added to macro.");
            Assert.AreEqual(0, target.rootEntry.macroEntries[0].macroEntries.Count, "Macro was unexpectedly added to itself.");
        }
Example #19
0
        public void setVideoTest_data()
        {
            Diagramm target = new Diagramm();
            bool isAnalysis = true;
            string vidPath = "";
            IVideoInfo vinfo = null;
            List<IMacroEntry> processedBy = new List<IMacroEntry>();
            MacroEntry macroEntry = new MacroEntry("TestPlugin", PluginType.IMetricOqat, "TestMemento");
            processedBy.Add(macroEntry);
            Video video = new Video(isAnalysis, vidPath, vinfo, processedBy);

            float[][] data = new float[2][];
            data[0] = new float[5] { 1, 2, 3, 4, 5 };
            data[1] = new float[5] { 1, 2, 3, 4, 5 };
            video.frameMetricValue = data;

            target.setVideo(video);
            //assert: no exception
            //GUI should show the diagram now >> (automated?) UI test

            target.flush();
            //assert: no exception
            //GUI should be flushed now >> (automated?) UI test
        }
Example #20
0
        public void addMacroEntryTest_twice()
        {
            Macro_Accessor target = new Macro_Accessor();
            MacroEntry child = new MacroEntry("testPlugin", PluginType.IFilterOqat, "testmemento");
            MacroEntry father = target.rootEntry;
            target.addMacroEntry(child, father);
            target.addMacroEntry(child, father);

            Assert.IsTrue(target.rootEntry.macroEntries.Contains(child), "Filter was not added to macro.");
            Assert.AreEqual(2, target.rootEntry.macroEntries.Count);
        }
Example #21
0
        public void setVideoTest_nulldata()
        {
            Diagramm target = new Diagramm();
            bool isAnalysis = true;
            string vidPath = "";
            IVideoInfo vinfo = null;
            List<IMacroEntry> processedBy = new List<IMacroEntry>();
            MacroEntry macroEntry = new Oqat.ViewModel.MacroPlugin.MacroEntry("TestPlugin", PluginType.IMetricOqat, "TestMemento");
            processedBy.Add(macroEntry);
            Video video = new Video(isAnalysis, vidPath, vinfo, processedBy);

            target.setVideo(video);
            //assert: no exception
        }
Example #22
0
        public Memento getMemento()
        {
            Memento memToReturn;
            if (originallTlMacroName.Equals(rootEntry.mementoName))
                originallTlMacroName = "";

            MacroEntry rootEntryCopy = new MacroEntry(rootEntry.pluginName, rootEntry.type, rootEntry.mementoName);

            rootEntryCopy.startFrameRelative = rootEntry.startFrameRelative;
            rootEntryCopy.endFrameRelative = rootEntry.endFrameRelative;
            rootEntryCopy.path = rootEntry.path;

            doDeepCopy(rootEntry, ref rootEntryCopy);
            if (rootEntryCopy.mementoName.Equals(""))
                memToReturn = new Memento(rootEntryCopy.mementoName, new object());
            else if (rootEntryCopy.macroEntries.Count > 0)
                memToReturn = new Memento(rootEntryCopy.mementoName, rootEntryCopy as IMacroEntry);
            else
                memToReturn = new Memento(rootEntryCopy.mementoName, null);

            return memToReturn;
        }