Пример #1
0
        private IView _view = null; // the view using this drawing model

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="model">The tree model to draw.</param>
        /// <param name="view">The view using this drawing model.</param>
        public Renderer(Model model, IView view)
        {
            // initialize mapping
            _nodeViewMap = new Dictionary<INode, NodeView>();

            _view = view;
            _model = model;

            _screenPlaneOrigin = new ScreenVector();
            _screenPlaneMaxPoint = new ScreenVector();

            _ray = new double[4];
            _ray[0] = model.Length;

            for (int i = 1; i < _ray.Length; i++)
            {
                _ray[i] = (_ray[0] + _ray[i - 1]) / (1 + (_ray[0] * _ray[i - 1]));
            }

            NodeModel __rootNodeModel = model.Root;
            if (__rootNodeModel.IsLeaf)
            {
                _rootNodeView = new NodeView(null, __rootNodeModel, this);
            }
            else
            {
                _rootNodeView = new CompositeNodeView(null, (CompositeNodeModel)__rootNodeModel, this);
            }

            this.Background = new LinearGradientBrush(Colors.Black, Colors.DarkBlue, 90);

            CompositionTarget.Rendering += UpdatePosition;
        }
Пример #2
0
        /// <summary> Constructor.     
        /// </summary>
        /// <param name="node">The encapsulated INode.</param>
        /// <param name="parent">The parent node.</param>
        /// <param name="model">The tree model using this NodeModel.</param>
        public NodeModel(INode node, CompositeNodeModel parent, Model model)
        {
            _node = node;
            _parent = parent;
            _model = model;
            model.IncrementNumberOfNodes();

            _z = new EuclidianVector();
        }
Пример #3
0
        /// <summary> Constructor. 
        /// </summary>
        /// <param name="model">The tree model to view.</param>
        public View(Model model, IAddChild visualRoot)
        {
            _model = model;
            _visualRoot = visualRoot;

            _renderer = new Renderer(_model, this);
            _controller = new Controller(_renderer);

            _visualRoot.AddChild(_renderer);

            this.StartMouseListening();
        }
        /// <summary>Connstructor.
        /// </summary>
        /// <param name="node">The encapsulated INode.</param>
        /// <param name="parent">The parent node.</param>
        /// <param name="model">The tree model using this NodeModel.</param>
        public CompositeNodeModel(INode node, CompositeNodeModel parent, Model model)
            : base(node, parent, model)
        {
            _children = new List<NodeModel>();

            NodeModel __child = null;
            foreach (INode childNode in node.ChildNodes)
            {
                if (childNode.IsLeaf)
                {
                    __child = new NodeModel(childNode, this, model);
                }
                else
                {
                    __child = new CompositeNodeModel(childNode, this, model);
                }
                this.AddChild(__child);
            }

            // here the down of the tree is built, so we can compute the weight
            this.ComputeWeight();
        }
Пример #5
0
        private EuclidianVector _z = null; // Euclidian coordinates

        #endregion Fields

        #region Constructors

        /// <summary> Constructor for root node.
        /// </summary>
        /// <param name="node">The encapsulated <see cref="INode"/>.</param>
        /// <param name="model">The tree model using this <see cref="NodeModel"/>.</param>
        public NodeModel(INode node, Model model)
            : this(node, null, model)
        {
        }
        private double _globalWeight = 0.0; // sum of children weight

        #endregion Fields

        #region Constructors

        /// <summary>Constructor for root node.
        /// </summary>
        /// <param name="node">The encapsulated INode.</param>
        /// <param name="model">The tree model using this NodeModel.</param>
        public CompositeNodeModel(INode node, Model model)
            : this(node, null, model)
        {
        }
Пример #7
0
        private void SetUp()
        {
            _root = new TestNode("root", false);
            _r1 = new TestNode("r1", false);
            _f = new TestNode("f");
            _r1f = new TestNode("r1f");
            _r1r1 = new TestNode("r1r1", false);
            _r1r2 = new TestNode("r1r2", false);
            _r1r2r1 = new TestNode("r1r2r1", false);
            _r1r1f = new TestNode("r1r1f");

            _r2 = new TestNode("r2", false);
            _r3 = new TestNode("r3", false);

            _root.Add(_r1);
            _root.Add(_f);
            _root.Add(_r1r2);
            _root.Add(_r2);
            _root.Add(_r3);

            _r2.Add(_r1r2r1);
            _r1r2.Add(new TestNode("bug1", false));
            _r1r2.Add(new TestNode("bug2", false));
            _r1r2.Add(new TestNode("bug3", false));
            _r1r2.Add(new TestNode("bug4", false));

            _r1.Add(_r1f);
            _r1.Add(_r1r1);

            _r1r1.Add(_r1r1f);

            _model = new Model(_root);
        }