Пример #1
0
        void OnPosChange(GCode act, float x, float y, float z)
        {
            bool isLastPos = Math.Abs(x - lastx) + Math.Abs(y - lasty) + Math.Abs(z - lastz) < 0.00001;

            if (!act.hasG || (act.G > 1 && act.G != 28))
            {
                return;
            }
            if (segments.Count == 0 || laste >= ana.e) // start new segment
            {
                if (!isLastPos)                        // no move, no action
                {
                    GCodePath p = new GCodePath();
                    p.Add(new Vector3(x, y, z));
                    if (segments.Count > 0 && segments.Last.Value.points.Count == 1)
                    {
                        segments.RemoveLast();
                    }
                    segments.AddLast(p);
                    changed = true;
                }
            }
            else
            {
                if (!isLastPos)
                {
                    segments.Last.Value.Add(new Vector3(x, y, z));
                    changed = true;
                }
            }
            lastx = x;
            lasty = y;
            lastz = z;
            laste = ana.emax;
        }
Пример #2
0
        void OnPosChange(GCode act, float x, float y, float z)
        {
            float locDist   = (float)Math.Sqrt((x - lastx) * (x - lastx) + (y - lasty) * (y - lasty) + (z - lastz) * (z - lastz));
            bool  isLastPos = locDist < 0.00001;

            if (!act.hasG || (act.G > 1 && act.G != 28))
            {
                return;
            }
            if (segments.Count == 0 || laste >= ana.e) // start new segment
            {
                if (!isLastPos)                        // no move, no action
                {
                    GCodePath p = new GCodePath();
                    p.Add(new Vector3(x, y, z), ana.emax, totalDist);
                    if (segments.Count > 0 && segments.Last.Value.pointsLists.Last.Value.Count == 1)
                    {
                        segments.RemoveLast();
                    }
                    segments.AddLast(p);
                    changed = true;
                }
            }
            else
            {
                if (!isLastPos)
                {
                    totalDist += locDist;
                    segments.Last.Value.Add(new Vector3(x, y, z), ana.emax, totalDist);
                    changed = true;
                }
            }
            lastx = x;
            lasty = y;
            lastz = z;
            laste = ana.emax;
        }
Пример #3
0
        void OnPosChangeFast(float x, float y, float z, float e)
        {
            if (!ana.drawing || ana.layer < minLayer || ana.layer > maxLayer)
            {
                lastx = x;
                lasty = y;
                lastz = z;
                laste = ana.emax;
                lastLayer = ana.layer;
                return;
            }
            float locDist = (float)Math.Sqrt((x - lastx) * (x - lastx) + (y - lasty) * (y - lasty) + (z - lastz) * (z - lastz));
            bool isLastPos = locDist < 0.00001;
            int segpos = ana.activeExtruder;
            if (segpos < 0 || segpos >= MaxExtruder) segpos = 0;
            LinkedList<GCodePath> seg = segments[segpos];
            //if (!act.hasG || (act.G > 1 && act.G != 28)) return;
            if (lastLayer == minLayer - 1 && laste < e)
            {
                GCodePath p = new GCodePath();
                p.Add(new Vector3(lastx, lasty, lastz), laste, totalDist, GCodePoint.toFileLine(fileid, actLine));

                if (seg.Count > 0 && seg.Last.Value.pointsLists.Last.Value.Count == 1)
                {
                    seg.RemoveLast();
                }
                seg.AddLast(p);
            }

            if (seg.Count == 0 || laste >= ana.e) // start new segment
            {
                if (!isLastPos) // no move, no action
                {
                    GCodePath p = new GCodePath();
                    p.Add(new Vector3(x, y, z), ana.emax, totalDist, GCodePoint.toFileLine(fileid, actLine));
                    if (seg.Count > 0 && seg.Last.Value.pointsLists.Last.Value.Count == 1)
                    {
                        seg.RemoveLast();
                    }
                    seg.AddLast(p);
                    //changed = true;
                }
            }
            else
            {
                if (!isLastPos)
                {
                    totalDist += locDist;
                    seg.Last.Value.Add(new Vector3(x, y, z), ana.emax, totalDist, GCodePoint.toFileLine(fileid, actLine));
                    //changed = true;
                }
            }
            lastx = x;
            lasty = y;
            lastz = z;
            laste = ana.emax;
            lastLayer = ana.layer;
        }
Пример #4
0
 void OnPosChange(GCode act, float x, float y, float z)
 {
     if (!ana.drawing)
     {
         lastx = x;
         lasty = y;
         lastz = z;
         laste = ana.emax;
         return;
     }
     float locDist = (float)Math.Sqrt((x - lastx) * (x - lastx) + (y - lasty) * (y - lasty) + (z - lastz) * (z - lastz));
     bool isLastPos = locDist < 0.00001;
     if (!act.hasG || (act.G > 1 && act.G != 28)) return;
     if (segments.Count == 0 || laste >= ana.e) // start new segment
     {
         if (!isLastPos) // no move, no action
         {
             GCodePath p = new GCodePath();
             p.Add(new Vector3(x, y, z), ana.emax, totalDist);
             if (segments.Count > 0 && segments.Last.Value.pointsLists.Last.Value.Count == 1)
             {
                 segments.RemoveLast();
             }
             segments.AddLast(p);
             changed = true;
         }
     }
     else
     {
         if (!isLastPos)
         {
             totalDist += locDist;
             segments.Last.Value.Add(new Vector3(x, y, z), ana.emax, totalDist);
             changed = true;
         }
     }
     lastx = x;
     lasty = y;
     lastz = z;
     laste = ana.emax;
 }
Пример #5
0
        void OnPosChangeFast(float x, float y, float z, float e)
        {
            if (!ana.drawing || ana.layer < minLayer || ana.layer > maxLayer)
            {
                lastx = x;
                lasty = y;
                lastz = z;
                laste = ana.activeExtruder.emax;
                lastLayer = ana.layer;
                return;
            }
            float locDist = (float)Math.Sqrt((x - lastx) * (x - lastx) + (y - lasty) * (y - lasty) + (z - lastz) * (z - lastz));
            bool isLastPos = locDist < 0.00001;
            int segpos = ana.activeExtruderId;
            bool isTravel = (FormPrinterSettings.ps.printerType == 3 ? Math.Max(z,lastz) - ana.zOffset >= FormPrinterSettings.ps.cncZTop : !ana.eChanged);
            if (segpos < 0 || segpos >= MaxExtruder) segpos = 0;
            LinkedList<GCodePath> seg = segments[segpos];
            if (isTravel)
            {
                GCodeTravel travel = new GCodeTravel();
                travel.fline = GCodePoint.toFileLine(fileid, actLine);
                travel.p1.X = lastx;
                travel.p1.Y = lasty;
                travel.p1.Z = lastz;
                travel.p2.X = x;
                travel.p2.Y = y;
                travel.p2.Z = z;
                travelMoves.Add(travel);
                if (FormPrinterSettings.ps.printerType == 3 && z - ana.zOffset < FormPrinterSettings.ps.cncZTop) // End od travel moves
                { // Start new milling move sequence
                    GCodePath p = new GCodePath();
                    p.Add(new Vector3(x, y, z), ana.activeExtruder.emax, totalDist, GCodePoint.toFileLine(fileid, actLine));
                    if (seg.Count > 0 && seg.Last.Value.pointsLists.Last.Value.Count == 1)
                    {
                        seg.RemoveLast();
                    }
                    seg.AddLast(p);
                }
            }

            //if (!act.hasG || (act.G > 1 && act.G != 28)) return;
            if (lastLayer == minLayer - 1 && (laste < e || FormPrinterSettings.ps.printerType == 3))
            {
                GCodePath p = new GCodePath();
                p.Add(new Vector3(lastx, lasty, lastz), laste, totalDist, GCodePoint.toFileLine(fileid, actLine));

                if (seg.Count > 0 && seg.Last.Value.pointsLists.Last.Value.Count == 1)
                {
                    seg.RemoveLast();
                }
                seg.AddLast(p);
            }

            if (seg.Count == 0 || (laste >= ana.activeExtruder.e && FormPrinterSettings.ps.printerType != 3)) // start new segment
            {
                if (!isLastPos) // no move, no action
                {
                    GCodePath p = new GCodePath();
                    p.Add(new Vector3(x, y, z), ana.activeExtruder.emax, totalDist, GCodePoint.toFileLine(fileid, actLine));
                    if (seg.Count > 0 && seg.Last.Value.pointsLists.Count>0 && seg.Last.Value.pointsLists.Last.Value.Count == 1)
                    {
                        seg.RemoveLast();
                    }
                    seg.AddLast(p);
                    //changed = true;
                }
            }
            else
            {
                if (!isLastPos && (FormPrinterSettings.ps.printerType != 3 || !isTravel))
                {
                    totalDist += locDist;
                    seg.Last.Value.Add(new Vector3(x, y, z), ana.activeExtruder.emax, totalDist, GCodePoint.toFileLine(fileid, actLine));
                    //changed = true;
                }
            }
            lastx = x;
            lasty = y;
            lastz = z;
            laste = ana.activeExtruder.emax;
            lastLayer = ana.layer;
        }
Пример #6
0
 void OnPosChange(GCode act,float x, float y, float z)
 {
     bool isLastPos = Math.Abs(x-lastx)+Math.Abs(y-lasty)+Math.Abs(z-lastz)<0.00001;
     if (!act.hasG || (act.G > 1 && act.G!=28)) return;
     if (segments.Count == 0 || laste >= ana.e) // start new segment
     {
         if (!isLastPos) // no move, no action
         {
             GCodePath p = new GCodePath();
             p.Add(new Vector3(x, y, z));
             if (segments.Count > 0 && segments.Last.Value.points.Count == 1)
             {
                 segments.RemoveLast();
             }
             segments.AddLast(p);
             changed = true;
         }
     }
     else
     {
         if (!isLastPos)
         {
             segments.Last.Value.Add(new Vector3(x, y, z));
             changed = true;
         }
     }
     lastx = x;
     lasty = y;
     lastz = z;
     laste = ana.emax;
 }
Пример #7
0
 void OnPosChange(GCode act, float x, float y, float z)
 {
     if (!ana.drawing)
     {
         lastx = x;
         lasty = y;
         lastz = z;
         laste = ana.emax;
         return;
     }
     float locDist = (float)Math.Sqrt((x - lastx) * (x - lastx) + (y - lasty) * (y - lasty) + (z - lastz) * (z - lastz));
     bool isLastPos = locDist < 0.00001;
     if (!act.hasG || (act.G > 1 && act.G != 28)) return;
     int segpos = ana.activeExtruder;
     if (ana.eChanged == false)
     {
         GCodeTravel travel = new GCodeTravel();
         travel.fline = GCodePoint.toFileLine(fileid, actLine);
         travel.p1.X = lastx;
         travel.p1.Y = lasty;
         travel.p1.Z = lastz;
         travel.p2.X = x;
         travel.p2.Y = y;
         travel.p2.Z = z;
         travelMoves.Add(travel);
     }
     if (segpos < 0 || segpos >= MaxExtruder) segpos = 0;
     LinkedList<GCodePath> seg = segments[segpos];
     if (seg.Count == 0 || laste >= ana.e) // start new segment
     {
         if (!isLastPos) // no move, no action
         {
             GCodePath p = new GCodePath();
             p.Add(new Vector3(x, y, z), ana.emax, totalDist, GCodePoint.toFileLine(fileid, actLine));
             if (seg.Count > 0 && seg.Last.Value.pointsLists.Last.Value.Count == 1)
             {
                 seg.RemoveLast();
             }
             seg.AddLast(p);
             changed = true;
         }
     }
     else
     {
         if (!isLastPos)
         {
             totalDist += locDist;
             seg.Last.Value.Add(new Vector3(x, y, z), ana.emax, totalDist, GCodePoint.toFileLine(fileid, actLine));
             changed = true;
         }
     }
     lastx = x;
     lasty = y;
     lastz = z;
     laste = ana.emax;
 }