Ejemplo n.º 1
0
        protected override void Draw2D(Pi2PictureBox box, Graphics g, Graphics pickGraphics)
        {
            if (ControlPoints.Count >= 2)
            {
                Vec2 p1 = box.PictureToScreen(ControlPoints[0].GetXY());
                Vec2 p2 = box.PictureToScreen(ControlPoints[1].GetXY());

                float x = (float)Math.Min(p1.X, p2.X);
                float y = (float)Math.Min(p1.Y, p2.Y);
                float w = (float)Math.Abs(p2.X - p1.X);
                float h = (float)Math.Abs(p2.Y - p1.Y);

                using (Pen pen = new Pen(Color, (float)LineWidth))
                {
                    g.DrawRectangle(pen, x, y, w, h);

                    if (DrawCenterCross)
                    {
                        float s  = 20;
                        float cx = x + w / 2.0f;
                        float cy = y + h / 2.0f;
                        pen.DashStyle = CenterCrossStyle;
                        g.DrawLine(pen, cx, y - s, cx, y + h + s);
                        g.DrawLine(pen, x - s, cy, x + w + s, cy);
                    }
                }



                using (Pen pen = box.GetPickPen(this))
                    pickGraphics.DrawRectangle(pen, x, y, w, h);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Draws control points if DrawControlPoints is set.
 /// </summary>
 protected void DoDrawControlPoints(Pi2PictureBox box, Graphics g, Graphics pickGraphics, int currZ)
 {
     for (int n = 0; n < ControlPoints.Count; n++)
     {
         DrawControlPoint(box, g, pickGraphics, n, currZ);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="picture">Picture box whose histogram is to be shown.</param>
        public HistogramDialog(Pi2PictureBox picture)
        {
            InitializeComponent();

            Histogram      = new HistogramBox(picture);
            Histogram.Dock = DockStyle.Fill;
            Controls.Add(Histogram);
        }
Ejemplo n.º 4
0
 public override void Draw(Pi2PictureBox box, Graphics g, Graphics pickGraphics, int currZ)
 {
     if ((ControlPoints.Count > 0 && (Math.Abs(ControlPoints[0].Z - currZ) < 0.5 || DrawToAllSlices)) ||
         RequiredPointCount <= 0)
     {
         Draw2D(box, g, pickGraphics);
         for (int n = 0; n < ControlPoints.Count; n++)
         {
             DrawControlPoint(box, g, pickGraphics, n, (int)Math.Round(ControlPoints[n].Z));
         }
     }
 }
Ejemplo n.º 5
0
        protected override void Draw2D(Pi2PictureBox box, Graphics g, Graphics pickGraphics)
        {
            if (ControlPoints.Count >= 2)
            {
                Vec2 p1 = box.PictureToScreen(ControlPoints[0].GetXY());
                Vec2 p2 = box.PictureToScreen(ControlPoints[1].GetXY());

                using (Pen pen = new Pen(Color, (float)LineWidth))
                    g.DrawLine(pen, p1.ToPointF(), p2.ToPointF());

                using (Pen pen = box.GetPickPen(this))
                    pickGraphics.DrawLine(pen, p1.ToPointF(), p2.ToPointF());
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="pictureBox"></param>
        public HistogramBox(Pi2PictureBox pictureBox)
        {
            InitializeComponent();
            chartHist = new Chart();
            chartHist.NewSeries();
            chartHist.NewSeries();
            chartHist.NewSeries();
            chartHist.XAxis.Label = "Gray value";
            chartHist.YAxis.Label = "Count";
            chartHist.Dock        = DockStyle.Fill;
            Controls.Add(chartHist);
            chartHist.BringToFront();

            PictureBox = pictureBox;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Gets line width adjusted for highlighting.
        /// </summary>
        /// <returns></returns>
        //protected double GetLineWidthAdjustedForHighlighting()
        //{
        //    if (!IsHighlighted)
        //        return LineWidth;
        //    else
        //        return 2 * LineWidth;
        //}


        protected void DrawControlPoint(Pi2PictureBox box, Graphics g, Graphics pickGraphics, int pi, int currZ)
        {
            Vec3 p = ControlPoints[pi];

            if (Math.Abs(p.Z - currZ) < 0.5f)
            {
                const float R    = 3;
                Vec2        pos  = box.PictureToScreen(p.GetXY());
                RectangleF  rect = new RectangleF((float)(pos.X - R), (float)(pos.Y - R), 2 * R, 2 * R);
                g.FillRectangle(Brushes.WhiteSmoke, rect);
                g.DrawRectangle(Pens.Black, rect.X, rect.Y, rect.Width, rect.Height);

                using (Brush b = box.GetPickBrush(this, pi))
                    pickGraphics.FillRectangle(b, rect.X, rect.Y, rect.Width, rect.Height);
            }
        }
Ejemplo n.º 8
0
        protected override void Draw2D(Pi2PictureBox box, Graphics g, Graphics pickGraphics)
        {
            Vec2 p1 = box.PictureToScreen(new Vec2(box.OriginalWidth / 2.0, 0));
            Vec2 p2 = box.PictureToScreen(new Vec2(box.OriginalWidth / 2.0, box.OriginalHeight));

            Vec2 p3 = box.PictureToScreen(new Vec2(0, box.OriginalHeight / 2.0));
            Vec2 p4 = box.PictureToScreen(new Vec2(box.OriginalWidth, box.OriginalHeight / 2.0));

            using (Pen pen = new Pen(Color, (float)LineWidth))
            {
                g.DrawLine(pen, p1.ToPointF(), p2.ToPointF());
                g.DrawLine(pen, p3.ToPointF(), p4.ToPointF());
            }

            using (Pen pen = box.GetPickPen(this))
            {
                pickGraphics.DrawLine(pen, p1.ToPointF(), p2.ToPointF());
                pickGraphics.DrawLine(pen, p3.ToPointF(), p4.ToPointF());
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Pi2PictureViewer()
        {
            InitializeComponent();

            labelPixelValue.Text   = String.Empty;
            labelSliceNumber.Text  = String.Empty;
            scrollBarSlice.Visible = false;

            PictureBox              = new Pi2PictureBox();
            PictureBox.AutoResize   = false;
            PictureBox.Dock         = DockStyle.Fill;
            PictureBox.MouseDown   += PictureBox_MouseDown;
            PictureBox.MouseMove   += PictureBox_MouseMove;
            PictureBox.MouseUp     += PictureBox_MouseUp;
            PictureBox.MouseWheel  += PictureBox_MouseWheel;
            PictureBox.ImageLoaded += PictureBox_ImageLoaded;
            Controls.Add(PictureBox);

            //Mode = MouseMode.AddAnnotation;
            Mode = MouseMode.Pan;

            Profile = new ProfileDialog(this);


            // DEBUG: Test annotations
            //NewAnnotationName = "Line segment";
            NewAnnotationName = "Horizontal line";

            //HLineAnnotation ann = new HLineAnnotation();
            //ann.ControlPoints.Add(new Vec3(0, 60, 0));
            //PictureBox.Annotations.Add(ann);

            //LineSegmentAnnotation ann2 = new LineSegmentAnnotation();
            //ann2.ControlPoints.Add(new Vec3(10, 20, 0));
            //ann2.ControlPoints.Add(new Vec3(200, 180, 0));
            //ann2.LineWidth = 2;
            //ann2.DrawToAllSlices = true;
            //ann2.Color = Color.Red;
            //PictureBox.Annotations.Add(ann2);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Method that draws the 2D annotation, discarding all Z coordinates of control points.
 /// </summary>
 /// <param name="box">Picture box that owns the annotation.</param>
 /// <param name="g">Graphics where to draw to.</param>
 /// <param name="pickGraphics">Graphics where pick info is going to be drawn to.</param>
 protected abstract void Draw2D(Pi2PictureBox box, Graphics g, Graphics pickGraphics);
Ejemplo n.º 11
0
 /// <summary>
 /// Draw this object to the given renderer.
 /// This version of Draw method is called if no data is required by the drawing object.
 /// The default implementation draws control points if appropriate.
 /// </summary>
 public virtual void Draw(Pi2PictureBox box, Graphics g, Graphics pickGraphics, int currZ)
 {
     DoDrawControlPoints(box, g, pickGraphics, currZ);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="pictureBox"></param>
 public HistogramBox(Pi2PictureBox pictureBox)
 {
     InitializeComponent();
     this.PictureBox = pictureBox;
 }