예제 #1
0
 internal void DeleteLastShape()
 {
     if (ShapeList.Count != 0)
     {
         ShapeList.RemoveAt(ShapeList.Count - 1);
     }
 }
예제 #2
0
 private void Undo()
 {
     pictureBox1.Refresh();
     if (_shapes.Count() > 0)
     {
         _shapes.UndoItems.Add(_shapes.Items[_shapes.Count() - 1]);
         _shapes.RemoveAt(_shapes.Count() - 1);
         Draw();
     }
 }
예제 #3
0
 public void RemoveLast()
 {
     if (ShapeList.Count != 0)
     {
         foreach (var item in Selection.ToArray())
         {
             if (item == ShapeList[0])
             {
                 Selection.Remove(item);
             }
         }
         ShapeList.RemoveAt(0);
     }
 }
예제 #4
0
 /// <summary>
 /// Разгрупиране формите.
 /// </summary>
 public void UnGroup()
 {
     for (int i = 0; i < Selection.Count; i++)
     {
         if (Selection[i] is GroupShape)
         {
             var ungroupedShapes = (Selection[i] as GroupShape).SubItems;
             ShapeList.AddRange(ungroupedShapes);
             ShapeList.RemoveAt(ShapeList.IndexOf(Selection[i]));
             Selection.AddRange(ungroupedShapes);
             Selection.RemoveAt(i);
             i -= 1;
         }
     }
 }
예제 #5
0
        protected override void _GenerateToolpathsWorker()
        {
            try
            {
                base.reset_toolpaths();

                if (base.ToolDiameter.Cached == 0)
                {
                    Logger.err("tool diameter is zero");
                    base.MachineOpStatus = MachineOpStatus.Errors;
                    return;
                }

                if (_stepover.Cached == 0 || _stepover.Cached > 1)
                {
                    Logger.err("stepover should be > 0 and <= 1");
                    base.MachineOpStatus = MachineOpStatus.Errors;
                    return;
                }

                // XXX: is it needed ?
                base.UpdateGeometryExtrema(base._CADFile);
                base._CADFile.MachiningOptions.UpdateGeometryExtrema(base._CADFile);
                ShapeList shapes = new ShapeList();
                shapes.ApplyTransformations = true;
                shapes.AddEntities(base._CADFile, base.PrimitiveIds);
                shapes = shapes.DetectRegions();

                bool found_opened_polylines = false;
                for (int i = shapes.Count - 1; i >= 0; i--)
                {
                    if (shapes[i].Shape is Polyline && !((Polyline)shapes[i].Shape).Closed)
                    {
                        found_opened_polylines = true;
                        shapes.RemoveAt(i);
                    }
                }
                if (found_opened_polylines)
                {
                    Logger.warn("ignoring open polylines");
                    base.MachineOpStatus = MachineOpStatus.Warnings;
                }

                List <Sliced_path> trajectories = new List <Sliced_path>();

                foreach (ShapeListItem shape in shapes)
                {
                    Sliced_path traj = gen_pocket(shape);
                    if (traj != null)
                    {
                        trajectories.Add(traj);
                    }
                }

                if (trajectories.Count == 0)
                {
                    return;
                }

                base.insert_toolpaths(trajectories);

                if (base.MachineOpStatus == MachineOpStatus.Unknown)
                {
                    base.MachineOpStatus = MachineOpStatus.OK;
                }
            }
            catch (Exception ex)
            {
                base.MachineOpStatus = MachineOpStatus.Errors;
                ThisApplication.HandleException(ex);
            }
            finally
            {
                base._GenerateToolpathsFinal();
            }
        }