Ejemplo n.º 1
0
        private void skeletonFittingCanvas_MouseDown(object sender, MouseEventArgs e)
        {
            SkeletonAnnotation an = GetEditingAnnotation();

            if (an == null)
            {
                return;
            }

            PointF convLocation = InvertCoordinate(e.Location, skeletonFittingCanvasTransform);

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                // joint
                if (jointAddRadioButton.Checked)
                {
                    AssignJointAnnotation(an, new JointAnnotation(jointNameTextBox.Text, convLocation));
                }

                if (jointSelectRadioButton.Checked)
                {
                    JointAnnotation joint = an.GetNearestJoint(e.Location, 20, skeletonFittingCanvasTransform);
                    SelectJointAnnotation(an, joint);
                    if (joint != null)
                    {
                        jointNameTextBox.Text = joint.name;
                    }
                }

                // bone
                if (boneAddRadioButton.Checked)
                {
                    var joint = an.GetNearestJoint(e.Location, 20, skeletonFittingCanvasTransform);
                    if (joint != null)
                    {
                        CreateOrCompleteEditingBone(an, joint);
                    }
                    else
                    {
                        DeleteEditingBone();
                    }
                }

                if (boneSelectRadioButton.Checked)
                {
                    SelectBoneAnnotation(an, an.GetNearestBone(e.Location, 20, skeletonFittingCanvasTransform));
                }

                skeletonFittingCanvas.Invalidate();
            }

            // 画像をずらす
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                if (tabControl.SelectedTab.Name == "tabSkeletonFitting")
                {
                    skeletonFittingCanvasPrevMousePos = e.Location;
                }
            }
        }
Ejemplo n.º 2
0
 private void skeletonFittingCanvas_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Right)
     {
         SkeletonAnnotation an = GetEditingAnnotation();
         if (jointSelectRadioButton.Checked || jointAddRadioButton.Checked)
         {
             DeleteJointAnnotation(an, an.GetNearestJoint(e.Location, 20, skeletonFittingCanvasTransform));
         }
         if (boneSelectRadioButton.Checked || boneAddRadioButton.Checked)
         {
             DeleteBoneAnnotation(an, an.GetNearestBone(e.Location, 20, skeletonFittingCanvasTransform));
         }
     }
 }
Ejemplo n.º 3
0
        private void skeletonFittingCanvas_MouseMove(object sender, MouseEventArgs e)
        {
            SkeletonAnnotation an = GetEditingAnnotation();

            if (an == null)
            {
                return;
            }

            if (jointSelectRadioButton.Checked || jointAddRadioButton.Checked || boneAddRadioButton.Checked)
            {
                nearestJoint = an.GetNearestJoint(e.Location, 20, skeletonFittingCanvasTransform);
            }
            if (boneSelectRadioButton.Checked || boneAddRadioButton.Checked)
            {
                nearestBone = an.GetNearestBone(e.Location, 20, skeletonFittingCanvasTransform);
            }

            PointF convLocation = InvertCoordinate(e.Location, skeletonFittingCanvasTransform);

            if (addingBone != null)
            {
                UpdateEditingBone(an, new JointAnnotation("[dummy]", convLocation));
            }

            skeletonFittingCanvas.Invalidate();

            // 画像をずらす
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                if (tabControl.SelectedTab.Name == "tabSkeletonFitting")
                {
                    PointF pos = e.Location;
                    skeletonFittingCanvasPan(pos.X - skeletonFittingCanvasPrevMousePos.X, pos.Y - skeletonFittingCanvasPrevMousePos.Y);
                    skeletonFittingCanvasPrevMousePos = pos;
                }
            }
        }