public void AddMotion(GCodeMotion old)
 {
     if (old is GCodeLine)
     {
         Add(old.MoveTo, old.Depth, old.Angle);
     }
     else
     {
         AddArc(((GCodeArc)old).MoveTo, ((GCodeArc)old).CenterIJ, ((GCodeArc)old).IsCW, 0, ((GCodeArc)old).AngleStart, ((GCodeArc)old).Angle);
     }
 }
Exemplo n.º 2
0
 private static double getDragRadius(GCodeMotion entity)
 {
     if (!Properties.Settings.Default.importGCDragKnifePercentEnable)
     {
         return((double)Properties.Settings.Default.importGCDragKnifeLength);
     }
     else
     {
         double useZ = (double)Properties.Settings.Default.importGCZDown;
         if (graphicInformation.OptionZFromWidth)
         {
             useZ = Graphic2GCode.calculateZFromRange(graphicInformation.PenWidthMin, graphicInformation.PenWidthMax, entity.Depth);
         }
         return(Math.Abs(useZ * (double)Properties.Settings.Default.importGCDragKnifePercent / 100));
     }
 }
Exemplo n.º 3
0
//convert graphic to gcode ##################################################################
        private static void ProcessPathObject(PathObject pathObject, Graphic.GraphicInformation graphicInfo)
        {
            if (logDetailed)
            {
                Logger.Trace("ProcessPathObject start");
            }
            figureEnable = graphicInfo.FigureEnable;
            float origZ = gcode.gcodeZDown;

/* Create Dot */
            if (pathObject is ItemDot)
            {
                ItemDot DotData = (ItemDot)pathObject;
                if (DotData.UseZ)
                {
                    double setZ = calculateZFromRange(graphicInfo.DotZMin, graphicInfo.DotZMax, DotData.Z);//-Math.Abs(DotData.Z);      // be sure for right sign
                    if (logEnable)
                    {
                        Logger.Trace("---Dot DotData.UseZ: RangeMin:{0:0.00}  RangeMax:{1:0.00}  DotData.Z:{2:0.00}  -> setZ:{3:0.00}", graphicInfo.DotZMin, graphicInfo.DotZMax, DotData.Z, setZ);
                    }
                    setZ = Math.Max(origZ, setZ);    // don't go deeper than set Z
                    if (logCoordinates)
                    {
                        Logger.Trace("  PenDownWithZ z:{0:0.00}  setZ:{1:0.00}  gcodeZDown:{2:0.00}", DotData.Z, setZ, origZ);
                    }
                    gcode.gcodeZDown = (float)setZ;
                    penIsDown        = false;
                }

                else if (graphicInfo.OptionZFromWidth)
                {
                    double newZ = calculateZFromRange(graphicInfo.PenWidthMin, graphicInfo.PenWidthMax, DotData.Z);
                    if (logEnable)
                    {
                        Logger.Trace("---Dot OptionZFromWidth: RangeMin:{0:0.00}  RangeMax:{1:0.00}  DotData.Z:{2:0.00}  -> setZ:{3:0.00}", graphicInfo.PenWidthMin, graphicInfo.PenWidthMax, DotData.Z, newZ);
                    }
                    newZ             = Math.Max(origZ, newZ); // don't go deeper than set Z
                    gcode.gcodeZDown = (float)newZ;
                    penIsDown        = false;
                }

                pathObject.FigureId = StartPath(DotData);
                PenDown();
                StopPath();
                gcode.gcodeZDown = origZ;
            }
            else
            {
                if (graphicInfo.OptionZFromWidth)
                {
                    gcode.gcodeZDown = 0;
                }

                ItemPath PathData = (ItemPath)pathObject;
                if (logDetailed)
                {
                    Logger.Trace(" {0}  cnt:{1}", PathData.Info.List(), PathData.path.Count);
                }

                if (PathData.path.Count == 0)
                {
                    if (logEnable)
                    {
                        Logger.Trace("--ProcessPathObject: Empty path ID:{0}", PathData.Info.id);
                    }
                    return;
                }
                pathObject.FigureId = StartPath(PathData);
                PathDashArray       = PathData.dashArray;

                double newZ = gcode.gcodeZDown;                           // default

                for (int index = 1; index < PathData.path.Count; index++) // 0 was already processed in StartPath
                {
                    GCodeMotion entity = PathData.path[index];
                    if (graphicInfo.OptionZFromWidth)
                    {
                        newZ             = calculateZFromRange(graphicInfo.PenWidthMin, graphicInfo.PenWidthMax, entity.Depth);
                        newZ             = Math.Max(origZ, newZ); // don't go deeper than set Z
                        gcode.gcodeZDown = (float)newZ;
                        if (!Properties.Settings.Default.importDepthFromWidthRamp)
                        {
                            penIsDown = false;
                        }
                        if (logEnable)
                        {
                            Logger.Trace("--ProcessPathObject: penWidth:{0:0.00}  -> setZ:{1:0.00}", entity.Depth, newZ);
                        }
                    }

/* Create Line */
                    if (entity is GCodeLine)
                    {
                        MoveTo(entity.MoveTo, newZ, entity.Angle, "");
                    }
                    else if (entity is GCodeArc)
                    {
/* Create Arc */
                        GCodeArc ArcData = (GCodeArc)entity;
                        Arc(ArcData.IsCW, ArcData.MoveTo, ArcData.CenterIJ, newZ, ArcData.AngleStart, ArcData.Angle, "");                        // entity.comment);
                    }
                }
                StopPath("");
            }
            gcode.gcodeZDown = origZ;
            if (logDetailed)
            {
                Logger.Trace("ProcessPathObject end");
            }
        }
 public GCodeMotion(GCodeMotion old)
 {
     moveTo = new Point(old.moveTo.X, old.moveTo.Y);
     depth  = old.depth;
     angle  = old.angle;
 }