Exemplo n.º 1
0
    public AnalysisGraph getAnalysisGraph()
    {
        AnalysisGraph toReturn = new AnalysisGraph();

        Dictionary <Vector3, AnalysisNode> tempIndex = new Dictionary <Vector3, AnalysisNode>();

        foreach (VoronoiNode node in workingVoronoi)
        {
            AnalysisNode temp = new AnalysisNode(node.getPosition(), node.getRadius());
            toReturn.addNode(temp);
            tempIndex.Add(node.getPosition(), temp);
        }

        foreach (VoronoiNode node in workingVoronoi)
        {
            AnalysisNode temp = tempIndex[node.getPosition()];

            foreach (VoronoiNode neighbour in node.getNeighbours())
            {
                if (tempIndex.ContainsKey(neighbour.getPosition()))
                {
                    temp.addNeighbour(tempIndex[neighbour.getPosition()]);
                }
            }
        }

        return(toReturn);
    }
Exemplo n.º 2
0
        /// <summary>
        /// Loads previously stored projects and existing commands
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Home_Load(object sender, EventArgs e)
        {
            this.Text = Constants.FORM_TITLE;

            if (File.Exists(Constants.PROJECT_LIST))
            {
                // try loading each project
                foreach (string proj in File.ReadAllLines(Constants.PROJECT_LIST))
                {
                    try
                    {
                        Analysis     analysis     = Analysis.Load(proj);
                        AnalysisNode analysisNode = new AnalysisNode(analysis);
                        analysisNode.Control = new AnalysisOverview(analysisNode);
                        tree.Nodes.Add(analysisNode);

                        // try loading all commands
                        string memoryImage = analysis.MemoryImage;
                        foreach (string file in Directory.GetFiles(Path.GetDirectoryName(memoryImage), Path.GetFileName(memoryImage) + "-*.command"))
                        {
                            Command     cmd         = Command.Load(file);
                            CommandNode commandNode = new CommandNode(analysisNode, cmd);
                            commandNode.Control = new AnalysisCommand(commandNode);
                            analysisNode.Nodes.Add(commandNode);
                        }

                        analysisNode.ExpandAll();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Failed to open project:" + Environment.NewLine + ex.Message, Constants.MEMORY_ANALYZER_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void addProject(Analysis analysis)
        {
            AnalysisNode node = new AnalysisNode(analysis);

            node.Control = new AnalysisOverview(node);
            tree.Nodes.Add(node);
            tree.SelectedNode = node;
        }
Exemplo n.º 4
0
        public void and_no_operations_forwards_data_from_data_source()
        {
            var analysisNode = new AnalysisNode();
            var dataSource   = new DataSource();
            var expected     = dataSource.Data;

            analysisNode.AddSource(dataSource);

            analysisNode.Data.ShouldBe(expected);
        }
Exemplo n.º 5
0
        public AnalysisOverview(AnalysisNode node)
        {
            InitializeComponent();
            this.node     = node;
            this.color    = txtProjectName.BackColor;
            this.analysis = node.Analysis;
            this.Dock     = DockStyle.Fill;

            cmbBinary.Items.AddRange(Enum.GetValues(typeof(BinaryFormat)).Cast <Enum>().ToArray());
            loadAnalysis();
        }
Exemplo n.º 6
0
        public void where_all_sources_are_empty_exposes_empty_data_source()
        {
            var analysisNode = new AnalysisNode();
            var dataSource1  = new DataSource();
            var dataSource2  = new DataSource();

            analysisNode.AddSource(dataSource1);
            analysisNode.AddSource(dataSource2);

            analysisNode.Data.IsEmpty.ShouldBeTrue();
        }
Exemplo n.º 7
0
        public void leaves_original_data_unchanged()
        {
            var points     = new Point[] { (1, 1), (2, 2) };
            var dataSource = new DataSource(points);

            var node = new AnalysisNode();
            var operationUnderTest = DataModifyingOperation();

            node.AddSource(dataSource);

            node.Set(operationUnderTest);

            dataSource.Data.PointSets.Single().ShouldBe(new Point[] { (1, 1), (2, 2) });
Exemplo n.º 8
0
        private void currentProjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string ret = "";

            AnalysisNode project = (tree.SelectedNode as INode).Project;

            foreach (CommandNode node in project.Nodes)
            {
                ret += node.Control.Export();
            }

            CopyToClipboard(ret);
        }
Exemplo n.º 9
0
    public void calculate(AnalysisNode toCalculate)
    {
        float surrowndRadius = 0;

        foreach (AnalysisNode node in toCalculate.getNeighbours())
        {
            surrowndRadius += node.getRadius();
        }

        surrowndRadius += toCalculate.getRadius();

        value = 1 - (toCalculate.getRadius() / surrowndRadius);
    }
Exemplo n.º 10
0
        public void and_an_operation_exposes_operation_result()
        {
            var analysisNode    = new AnalysisNode();
            var dataSource      = new DataSource();
            var operation       = Substitute.For <IAnalysisOperation>();
            var operationResult = Substitute.For <IAnalysisData>();

            operation.Perform(dataSource.Data).Returns(operationResult);

            analysisNode.AddSource(dataSource);
            analysisNode.Set(operation);

            analysisNode.Data.ShouldBe(operationResult);
        }
Exemplo n.º 11
0
        public void preserves_units_from_from_sources()
        {
            const string xUnit = "x";
            const string yUnit = "y";

            var analysisNode = new AnalysisNode();
            var dataSource1  = new DataSource(xUnit, yUnit);
            var dataSource2  = new DataSource(xUnit, yUnit);

            analysisNode.AddSource(dataSource1);
            analysisNode.AddSource(dataSource2);

            analysisNode.Data.XUnit.ShouldBe(xUnit);
            analysisNode.Data.YUnit.ShouldBe(yUnit);
        }
Exemplo n.º 12
0
        public void multiplies_all_x_values_by_x_stretch_value()
        {
            var points     = new Point[] { (1, 1), (2, 2) };
            var dataSource = new DataSource(points);

            var node    = new AnalysisNode();
            var stretch = new StretchOperation {
                XStretch = 5
            };

            node.AddSource(dataSource);

            node.Set(stretch);

            node.Data.PointSets.Single().ShouldBe(new Point[] { (5, 1), (10, 2) });
Exemplo n.º 13
0
        public void shifts_all_x_data_values_by_x_shift()
        {
            var points     = new Point[] { (1, 1), (2, 2) };
            var dataSource = new DataSource(points);

            var node  = new AnalysisNode();
            var shift = new ShiftOperation {
                XShift = 5
            };

            node.AddSource(dataSource);

            node.Set(shift);

            node.Data.PointSets.Single().ShouldBe(new Point[] { (6, 1), (7, 2) });
Exemplo n.º 14
0
        public void exposes_accumulated_data_from_all_data_sources()
        {
            var analysisNode = new AnalysisNode();

            var points1     = new Point[] { (0, 0), (1, 1) };
            var points2     = new Point[] { (2, 2), (3, 3) };
            var dataSource1 = new DataSource(points1);
            var dataSource2 = new DataSource(points2);


            analysisNode.AddSource(dataSource1);
            analysisNode.AddSource(dataSource2);

            analysisNode.Data.PointSets[0].ShouldBe(points1);
            analysisNode.Data.PointSets[1].ShouldBe(points2);
            analysisNode.Data.PointSets.Count.ShouldBe(2);
        }
Exemplo n.º 15
0
    public void calculate(AnalysisNode toCalculate)
    {
        float heightDifference = 0;
        float currentHeight    = calculator.calculateHeight(toCalculate.getPosition());

        foreach (AnalysisNode node in toCalculate.getNeighbours())
        {
            float difference = currentHeight - calculator.calculateHeight(node.getPosition());

            if (heightDifference < difference)
            {
                heightDifference = difference;
            }
        }

        value = heightDifference / calculator.getMaxHeight();
    }
Exemplo n.º 16
0
        /// <summary>
        /// Store current view
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Home_FormClosing(object sender, FormClosingEventArgs e)
        {
            List <string> projects = new List <string>();

            foreach (TreeNode node in tree.Nodes)
            {
                if (node.GetType() == typeof(AnalysisNode))
                {
                    AnalysisNode an = (node as AnalysisNode);
                    projects.Add(an.Analysis.ProjectFile);
                }
            }

            Directory.CreateDirectory(Path.GetDirectoryName(Constants.PROJECT_LIST));
            using (TextWriter tw = new StreamWriter(Constants.PROJECT_LIST))
            {
                foreach (String s in projects)
                {
                    tw.WriteLine(s);
                }
            }
        }
Exemplo n.º 17
0
        internal Command CreateCommand(string cmd, params Action[] action)
        {
            if (tree.SelectedNode == null)
            {
                ShowError("Create/Open a project first");
                return(null);
            }

            AnalysisNode parent  = (tree.SelectedNode as INode).Project;
            Command      command = new Command(parent.Analysis, cmd, action);
            CommandNode  node    = new CommandNode(parent, command);

            node.Control   = new AnalysisCommand(node);
            command.Node   = node;
            command.Status = Command.CommandStatus.CREATED;

            parent.Nodes.Add(node);
            parent.ExpandAll();

            commandQueue.Add(command);
            return(command);
        }
Exemplo n.º 18
0
        public void new_instance_has_empty_data()
        {
            var analysisNode = new AnalysisNode();

            analysisNode.Data.IsEmpty.ShouldBeTrue();
        }
Exemplo n.º 19
0
        public void new_instance_returns_same_empty_data_for_multiple_requests()
        {
            var analysisNode = new AnalysisNode();

            analysisNode.Data.ShouldBe(analysisNode.Data);
        }
Exemplo n.º 20
0
 public void addNode(AnalysisNode node)
 {
     graph.Add(node);
 }
Exemplo n.º 21
0
 public void addNeighbour(AnalysisNode neighbour)
 {
     neighbours.Add(neighbour);
 }