Beispiel #1
0
        protected override void OnDrawBone(GlyphBone bone, int boneIndex)
        {
            float          pxscale = this._pxscale;
            GlyphBoneJoint jointA  = bone.JointA;
            GlyphBoneJoint jointB  = bone.JointB;

            bool valid = false;

            if (jointA != null && jointB != null)
            {
                Vector2 jointAPoint = jointA.OriginalJointPos;
                Vector2 jointBPoint = jointB.OriginalJointPos;

                painter.Line(
                    jointAPoint.X * pxscale, jointAPoint.Y * pxscale,
                    jointBPoint.X * pxscale, jointBPoint.Y * pxscale,
                    bone.IsLongBone ? PixelFarm.Drawing.Color.Yellow : PixelFarm.Drawing.Color.Magenta);

                if (this.DrawDynamicOutline)
                {
                    //****
                    painter.Line(
                        jointA.FitX * pxscale, jointA.FitY * pxscale,
                        jointB.FitX * pxscale, jointB.FitY * pxscale,
                        PixelFarm.Drawing.Color.White);
                }

                valid = true;

                _infoView.ShowBone(bone, jointA, jointB);
            }
            if (jointA != null && bone.TipEdge != null)
            {
                Vector2 jointAPoint = jointA.OriginalJointPos;
                Vector2 mid         = bone.TipEdge.GetMidPoint();

                painter.Line(
                    jointAPoint.X * pxscale, jointAPoint.Y * pxscale,
                    mid.X * pxscale, mid.Y * pxscale,
                    bone.IsLongBone ? PixelFarm.Drawing.Color.Yellow : PixelFarm.Drawing.Color.Magenta);

                valid = true;
                _infoView.ShowBone(bone, jointA, bone.TipEdge);
            }

            if (boneIndex == 0)
            {
                //for first bone
                painter.FillRect(_branchHeadPos.X * pxscale, _branchHeadPos.Y * pxscale, 5, 5, PixelFarm.Drawing.Color.DeepPink);
            }
            if (!valid)
            {
                throw new NotSupportedException();
            }
        }
Beispiel #2
0
        public void ShowBone(GlyphBone bone, GlyphBoneJoint jointA, EdgeLine tipEdge)
        {
            if (!_clearInfoView)
            {
                return;
            }
            _treeView.SuspendLayout();
            TreeNode jointNode = new TreeNode()
            {
                Text = bone.ToString(), Tag = new NodeInfo(bone, jointA, tipEdge)
            };

            _bonesNode.Nodes.Add(jointNode);

            _treeView.ResumeLayout();
        }
Beispiel #3
0
 public NodeInfo(GlyphBone bone, GlyphBoneJoint a, EdgeLine tipEdge)
 {
     this.bone     = bone;
     this.NodeKind = NodeInfoKind.Bone;
 }
Beispiel #4
0
 public NodeInfo(GlyphBone bone, GlyphBoneJoint a, GlyphBoneJoint b)
 {
     this.bone     = bone;
     this.NodeKind = NodeInfoKind.Bone;
 }
Beispiel #5
0
        void DrawMarkedNode(TreeNode node)
        {
            NodeInfo nodeinfo = node.Tag as NodeInfo;

            if (nodeinfo == null)
            {
                return;
            }
            //---------------
            //what kind of nodeinfo
            //---------------

            switch (nodeinfo.NodeKind)
            {
            default: throw new NotSupportedException();

            case NodeInfoKind.Bone:
            {
                if (RequestGlyphRender != null)
                {
                    _clearInfoView = false;
                    RequestGlyphRender(this, EventArgs.Empty);

                    GlyphBone bone     = nodeinfo.Bone;
                    var       midPoint = bone.GetMidPoint() * PxScale;
                    Owner.DrawMarker(midPoint.X, midPoint.Y, PixelFarm.Drawing.Color.Yellow);
                    if (_flushOutput != null)
                    {
                        //TODO: review here
                        _flushOutput();
                    }
                    _clearInfoView = true;
                }
            }
            break;

            case NodeInfoKind.Tri:
            {
                //draw glyph triangle
                if (RequestGlyphRender != null)
                {
                    _clearInfoView = false;
                    RequestGlyphRender(this, EventArgs.Empty);

                    GlyphTriangleInfo tri = nodeinfo.GlyphTri;
                    var cen_x             = (float)(tri.CentroidX * PxScale);
                    var cen_y             = (float)(tri.CentroidY * PxScale);

                    Owner.DrawMarker(cen_x, cen_y, PixelFarm.Drawing.Color.Yellow);
                    if (_flushOutput != null)
                    {
                        //TODO: review here
                        _flushOutput();
                    }
                    _clearInfoView = true;
                }
            }
            break;

            case NodeInfoKind.RibEndPoint:
            case NodeInfoKind.Joint:
            case NodeInfoKind.GlyphEdge:
            {
                if (RequestGlyphRender != null)
                {
                    _clearInfoView = false;
                    RequestGlyphRender(this, EventArgs.Empty);

                    var pos = nodeinfo.Pos * PxScale;
                    Owner.DrawMarker(pos.X, pos.Y, PixelFarm.Drawing.Color.Red);
                    if (_flushOutput != null)
                    {
                        //TODO: review here
                        _flushOutput();
                    }
                    _clearInfoView = true;
                }
            }
            break;

            case NodeInfoKind.TessEdge:
            {
                _addDebugMarkOnEdgeNo = nodeinfo.TessEdgeNo;
                if (RequestGlyphRender != null)
                {
                    _clearInfoView = false;
                    RequestGlyphRender(this, EventArgs.Empty);
                    if (_flushOutput != null)
                    {
                        //TODO: review here
                        _flushOutput();
                    }
                    _clearInfoView = true;
                }
            }
            break;

            case NodeInfoKind.FlattenVertexCommand:
            {
                _addDebugVertexCmd = nodeinfo.VertexCommandNo;
                if (RequestGlyphRender != null)
                {
                    _clearInfoView = false;
                    RequestGlyphRender(this, EventArgs.Empty);
                    //

                    if (_flushOutput != null)
                    {
                        //TODO: review here
                        _flushOutput();
                    }
                    _clearInfoView = true;
                }
            }
            break;

            case NodeInfoKind.OrgVertexCommand:
            {
                if (RequestGlyphRender != null)
                {
                    _clearInfoView = false;
                    RequestGlyphRender(this, EventArgs.Empty);
                    //
                    double x, y;
                    _orgVxs.GetVertex(nodeinfo.VertexCommandNo, out x, out y);
                    Owner.DrawMarker((float)x, (float)y, PixelFarm.Drawing.Color.Red);
                    if (_flushOutput != null)
                    {
                        //TODO: review here
                        _flushOutput();
                    }
                    _clearInfoView = true;
                }
            }
            break;
            }
        }
Beispiel #6
0
        void debugDrawTriangulatedGlyph(GlyphFitOutline glyphFitOutline, float pixelScale)
        {
            p.StrokeColor = PixelFarm.Drawing.Color.Magenta;
            List <GlyphTriangle> triAngles = glyphFitOutline.dbugGetTriangles();
            int j = triAngles.Count;
            //
            double prev_cx = 0, prev_cy = 0;
            //
            bool drawBone = this.chkDrawBone.Checked;

            for (int i = 0; i < j; ++i)
            {
                //---------------
                GlyphTriangle tri = triAngles[i];
                EdgeLine      e0  = tri.e0;
                EdgeLine      e1  = tri.e1;
                EdgeLine      e2  = tri.e2;
                //---------------
                //draw each triangles
                DrawEdge(p, e0, pixelScale);
                DrawEdge(p, e1, pixelScale);
                DrawEdge(p, e2, pixelScale);
                //---------------
                //draw centroid
                double cen_x = tri.CentroidX;
                double cen_y = tri.CentroidY;
                //---------------
                p.FillColor = PixelFarm.Drawing.Color.Yellow;
                p.FillRectLBWH(cen_x * pixelScale, cen_y * pixelScale, 2, 2);
                if (!drawBone)
                {
                    //if not draw bone then draw connected lines
                    if (i == 0)
                    {
                        //start mark
                        p.FillColor = PixelFarm.Drawing.Color.Yellow;
                        p.FillRectLBWH(cen_x * pixelScale, cen_y * pixelScale, 7, 7);
                    }
                    else
                    {
                        p.StrokeColor = PixelFarm.Drawing.Color.Red;
                        p.Line(
                            prev_cx * pixelScale, prev_cy * pixelScale,
                            cen_x * pixelScale, cen_y * pixelScale);
                    }
                    prev_cx = cen_x;
                    prev_cy = cen_y;
                }
            }
            //---------------
            //draw bone
            if (drawBone)
            {
                List <GlyphBone> bones = glyphFitOutline.dbugGetBones();
                j = bones.Count;
                for (int i = 0; i < j; ++i)
                {
                    GlyphBone b = bones[i];
                    if (i == 0)
                    {
                        //start mark
                        p.FillColor = PixelFarm.Drawing.Color.Yellow;
                        p.FillRectLBWH(b.p.CentroidX * pixelScale, b.p.CentroidY * pixelScale, 7, 7);
                    }
                    //draw each bone
                    p.StrokeColor = PixelFarm.Drawing.Color.Red;
                    p.Line(
                        b.p.CentroidX * pixelScale, b.p.CentroidY * pixelScale,
                        b.q.CentroidX * pixelScale, b.q.CentroidY * pixelScale);
                }
            }
            //---------------
        }