Beispiel #1
0
        private void AddStep(float fromX, float fromY, float fromZ, float toX, float toY, float toZ)
        {
            ViewerStep op = new ViewerStep(
                fromX * mDeviceScale,
                fromY * mDeviceScale,
                fromZ,
                toX * mDeviceScale,
                toY * mDeviceScale,
                toZ);

            string line = GCodeParser.Line;

            op.GCodeLine = line;

            if (mLastCodeLine != line)
            {
                mCurrentLine  = new ViewerLine(line);
                mLastCodeLine = line;
                mCodeLines.Add(mCurrentLine);
            }

            mCurrentLine.Steps.Add(op);
            mSteps.Add(op);

            if (CodeChanged != null)
            {
                CodeChanged(this, EventArgs.Empty);
            }
        }
Beispiel #2
0
        private void DrawCodeLine(int index)
        {
            ViewerStep head = null;

            foreach (ViewerStep step in mCodeLines[index].Steps)
            {
                DrawStep(step, ref head, (mCurrentLineIndex > index));
            }
        }
Beispiel #3
0
        private void PaintStep(ViewerStep op, GlPen pen)
        {
            SetPen(pen);

            Gl.glBegin(Gl.GL_LINES);
            Gl.glVertex3f(op.Start.X, op.Start.Y, op.Start.Z);
            Gl.glVertex3f(op.End.X, op.End.Y, op.End.Z);
            Gl.glEnd();
        }
Beispiel #4
0
        private void PaintStep(ViewerStep op, Graphics g, Pen p)
        {
            float xx = Math.Abs(op.Start.X - op.End.X);
            float yy = Math.Abs(op.Start.Y - op.End.Y);

            if (xx < 0.00001 && yy < 0.00001)
            {
                return;
            }

            p = op.IsCuttingOp ? p : MovePen;

            g.DrawLine(p, op.Start.X, op.Start.Y, op.End.X, op.End.Y);
        }
Beispiel #5
0
        internal void Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            g.Clear(mParentControl.BackColor);

            g.TranslateTransform(0, mParentControl.Height - 40);
            g.ScaleTransform(mVisualScale, -mVisualScale);
            g.TranslateTransform(5, 5);

            g.SmoothingMode = SmoothingMode.AntiAlias;

            DrawGrid(g);

            ViewerStep op   = null;
            ViewerStep head = null;

            mCurrentDistance = 0f;

            for (int i = 0; i < mSteps.Count; ++i)
            {
                op = mSteps[i];

                if (i <= mCurrentStep)
                {
                    PaintStep(op, g, DonePen);

                    mCurrentDistance += op.Distance;
                    head              = op;
                }
                else
                {
                    PaintStep(op, g);
                }
            }

            if (head != null)
            {
                if (mToolPen == null)
                {
                    ToolDiameter = ToolDiameter;
                }

                g.DrawEllipse(mToolPen, GetRect(head.End.X, head.End.Y, mToolDiameter / 4));
                //g.DrawString(
                ////string.Format("{0}, {1}", op.End.X, op.End.Y),
                //string.Format("{0}", mCurrentStep),
                //mParentControl.Font, Brushes.Red, op.End);
            }
        }
Beispiel #6
0
        private void DrawStep(ViewerStep op, ref ViewerStep head, bool alreadyCut)
        {
            GlPen pen = (op.IsCuttingOp) ? GlCutPen : GlMovePen;

            if (pen == GlCutPen && !alreadyCut)
            {
                pen = GlCutPendingPen;
            }

            PaintStep(op, pen);

            mCurrentDistance += op.Distance;
            head              = op;
        }
Beispiel #7
0
        private void PaintStep(ViewerStep op, Graphics g)
        {
            Pen p = op.IsCuttingOp ? CutPen : MovePen;

            PaintStep(op, g, p);
        }
Beispiel #8
0
 private void CheckOpBoundingBox(ViewerStep op)
 {
     CheckPointBoundingBox(op.Start);
     CheckPointBoundingBox(op.End);
 }