Exemplo n.º 1
0
 static void InvalidateBBNodesAbove(DObject dObj)
 {
     for (BBNode node = dObj.BbNode; node != null; node = node.parent)
     {
         node.bBox.Width = -1;                 //this will make the box empty
     }
 }
Exemplo n.º 2
0
        static BBNode BuildBBHierarchyUnderDNode(DNode dNode)
        {
            var bbNode = new BBNode();

            bbNode.geometry = new Geometry(dNode);
            bbNode.bBox     = dNode.DrawingNode.BoundingBox;
            return(bbNode);
        }
Exemplo n.º 3
0
        static BBNode BuildBBHierarchyUnderDLabel(DLabel dLabel)
        {
            var bbNode = new BBNode();

            bbNode.geometry = new Geometry(dLabel);
            bbNode.bBox     = dLabel.DrawingLabel.BoundingBox;
            return(bbNode);
        }
Exemplo n.º 4
0
        static void RebuildBBHierarchyUnderObject(DObject dObj)
        {
            BBNode oldNode = dObj.BbNode;
            BBNode newNode = BuildBBHierarchyUnderDObject(dObj);

            //now copy all fields, except the parent
            oldNode.l        = newNode.l;
            oldNode.r        = newNode.r;
            oldNode.geometry = newNode.geometry;
            oldNode.bBox     = newNode.bBox;
        }
Exemplo n.º 5
0
 void UpdateBoxes(BBNode bbNode)
 {
     if (bbNode.Box.IsEmpty)
     {
         if (bbNode.geometry != null)
         {
             bbNode.bBox = bbNode.geometry.Box;
         }
         else
         {
             UpdateBoxes(bbNode.l);
             UpdateBoxes(bbNode.r);
             bbNode.bBox = bbNode.l.Box;
             bbNode.bBox.Add(bbNode.r.Box);
         }
     }
 }
Exemplo n.º 6
0
        static void RebuildBBHierarchyUnderObject(DObject dObj)
        {
            BBNode oldNode = dObj.BbNode;
            BBNode newNode = BuildBBHierarchyUnderDObject(dObj);

            if (newNode != null)
            {
                //now copy all fields, except the parent
                oldNode.left     = newNode.left;
                oldNode.right    = newNode.right;
                oldNode.geometry = newNode.geometry;
                oldNode.bBox     = newNode.bBox;
            }
            else
            {
                oldNode.bBox = Rectangle.CreateAnEmptyBox();
            }
        }
        /// <summary>
        /// first and count denine the segment  needed to be split into two groups
        /// </summary>
        /// <param name="first"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        BBNode ProcessGroup(int first, int count)
        {
            if (count > 1)
            {
                int  seed0;
                BBox b0;
                int  seed1;
                FindSeeds(first, count, out seed0, out b0, out seed1);
                BBox b1;
                int  count0;
                int  count1;
                SplitOnGroups(first, count, seed0, ref b0, seed1, out b1, out count0, out count1);
                BBNode node = new BBNode();
                node.bBox         = new BBox(b0, b1);
                node.left         = ProcessGroup(first, count0);
                node.left.parent  = node;
                node.right        = ProcessGroup(first + count0, count1);
                node.right.parent = node;
                return(node);
            }

            if (count == 1)
            {
                Geometry geom = geometries[first] as Geometry;
                if (geom != null)
                {
                    BBNode node = new BBNode();
                    node.geometry = geom;
                    return(node);
                }

                DObject dObject = geometries[first] as DObject;

                if (dObject != null)
                {
                    return(dObject.BbNode);
                }
            }

            return(null);
        }
        /// <summary>
        /// first and count denine the segment  needed to be split into two groups
        /// </summary>
        /// <param name="first"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        BBNode ProcessGroup(int first, int count) {
            if (count > 1) {
                int seed0;
                BBox b0;
                int seed1;
                FindSeeds(first, count, out seed0, out b0, out seed1);
                BBox b1;
                int count0;
                int count1;
                SplitOnGroups(first, count, seed0, ref b0, seed1, out b1, out count0, out count1);
                BBNode node=new BBNode();
                node.bBox=new BBox(b0,b1);
                node.left =  ProcessGroup(first, count0);
                node.left.parent=node;
                node.right = ProcessGroup(first + count0, count1);
                node.right.parent = node;
                return node;
            }

            if (count == 1){
                Geometry geom=geometries[first] as Geometry;
                if (geom != null){
                    BBNode node=new BBNode();
                    node.geometry = geom;
                    return node;
                }
                
                DObject dObject = geometries[first] as DObject;
                
                if (dObject != null) 
                    return dObject.BbNode;
                
            }

            return null;
        }
Exemplo n.º 9
0
 static BBNode BuildBBHierarchyUnderDNode(DNode dNode){
     var bbNode = new BBNode();
     bbNode.geometry = new Geometry(dNode);
     bbNode.bBox = dNode.DrawingNode.BoundingBox;
     return bbNode;
 }
Exemplo n.º 10
0
 static BBNode BuildBBHierarchyUnderDLabel(DLabel dLabel){
     var bbNode = new BBNode();
     bbNode.geometry = new Geometry(dLabel);
     bbNode.bBox = dLabel.DrawingLabel.BoundingBox;
     return bbNode;
 }
Exemplo n.º 11
0
 void UpdateBoxes(BBNode bbNode){
     if (bbNode != null){
         if (bbNode.Box.IsEmpty){
             if (bbNode.geometry != null)
                 bbNode.bBox = bbNode.geometry.Box;
             else{
                 UpdateBoxes(bbNode.left);
                 UpdateBoxes(bbNode.right);
                 bbNode.bBox = bbNode.left.Box;
                 bbNode.bBox.Add(bbNode.right.Box);
             }
         }
     }
 }
Exemplo n.º 12
0
 /// <summary>
 /// 
 /// </summary>
 public void ClearBoundingBoxHierarchy()
 {
     bBNode = null;
 }
Exemplo n.º 13
0
        void UnconditionalHit(MouseEventArgs args, EntityFilterDelegate filter)
        {
            System.Drawing.Point point = args != null
                                             ? new System.Drawing.Point(args.X, args.Y)
                                             : DrawingPanel.PointToClient(MousePosition);

            object old = selectedDObject;
            if (bBNode == null && DGraph != null)
                bBNode = DGraph.BBNode;
            if (bBNode != null) {
                Geometry geometry = bBNode.Hit(ScreenToSource(point), GetHitSlack(), filter);

                selectedDObject = geometry == null ? null : geometry.dObject;

                if (old != selectedDObject) {
                    SetSelectedObject(selectedDObject);
                    if (ObjectUnderMouseCursorChanged != null) {
                        var changedArgs = new ObjectUnderMouseCursorChangedEventArgs((IViewerObject) old,
                                                                                     selectedDObject);
                        ObjectUnderMouseCursorChanged(this, changedArgs);
                    }
                }
            }
        }
Exemplo n.º 14
0
        void InitiateDrawing()
        {
            transformation = null;

            CalcRects(null);

            bBNode = null; //to initiate new calculation

            panel.Invalidate();
        }
Exemplo n.º 15
0
        internal void ProcessOnPaint(Graphics g, PrintPageEventArgs printPageEvenArgs)
        {
            if (PanelHeight < minimalSizeToDraw || PanelWidth < minimalSizeToDraw || DGraph == null)
                return;
            if (wasMinimized) {
                wasMinimized = false;
                panel.Invalidate();
            }

            if (OriginalGraph != null) {
                CalcRects(printPageEvenArgs);
                HandleViewInfoList();
                if (printPageEvenArgs == null) {
                    g.FillRectangle(outsideAreaBrush, ClientRectangle);
                    g.FillRectangle(new SolidBrush(Draw.MsaglColorToDrawingColor(OriginalGraph.Attr.BackgroundColor)),
                                    destRect);
                }

                using (Matrix m = CurrentTransform()) {
                    g.Transform = m;

                    g.Clip = new Region(SrcRect);
                    if (DGraph == null)
                        return;

                    double scale = CurrentScale;
                    foreach (IViewerObject viewerObject in Entities)
                        ((DObject) viewerObject).UpdateRenderedBox();

                    DGraph.DrawGraph(g);

                    //some info is known only after the first drawing

                    if (bBNode == null && BuildHitTree
            #if TEST_MSAGL
                        && (
                               dGraph.DrawingGraph.DebugICurves == null
                           )
            #endif
                        ) {
                        DGraph.BuildBBHierarchy();
                        bBNode = DGraph.BbNode;
                    }
                }
            }
            else
                g.FillRectangle(Brushes.Gray, ClientRectangle);

            //g.Transform.Reset();
        }