Beispiel #1
0
        protected override List <PolyLine> getInsideLines()
        {
            List <PolyLine> polyLines = new List <PolyLine>();

            foreach (System.Windows.Rect r in insideCuts_)
            {
                polyLines.AddRange(PolyLine.convertRectangleToPolyLines(new System.Windows.Rect(r.Location, r.Size), true));
            }

            return(polyLines);
        }
Beispiel #2
0
        protected override List <PolyLine> getInsideLines()
        {
            if (inside_.Width == 0 || inside_.Height == 0)
            {
                return(new List <PolyLine>());
            }
            System.Windows.Point pos = new System.Windows.Point(
                (outside_.Width - inside_.Width) / 2,
                (outside_.Height - inside_.Height) / 2);
            List <PolyLine> l = PolyLine.convertRectangleToPolyLines(new System.Windows.Rect(pos, inside_), true);

            return(l);
        }
Beispiel #3
0
 private void updateFromFileCut(
     string fileName, double leftPad, double rightPad, double topPad, double bottomPad, bool isReverse)
 {
     leftPad_   = leftPad;
     rightPad_  = rightPad;
     topPad_    = topPad;
     bottomPad_ = bottomPad;
     isReverse_ = isReverse;
     if (fileName != currentPath_)
     {
         currentPath_   = fileName;
         basePolylines_ = PolyLine.getPolylinesFromFile(currentPath_);
     }
 }
        private void runTurtle()
        {
            Turtle.Dispose();
            float minX, minY, maxX, maxY;

            minX = -400;
            minY = -250;
            maxX = 500;
            maxY = 250;
            System.Windows.Size  size     = PolyLine.getSize(polylines);
            System.Windows.Point position = PolyLine.getPosition(polylines);
            float scale;

            Turtle.Delay = (int)(Math.Pow(2.0, 10 - ((double)(trackBar1.Value))));
            if (size.Width / size.Height > (maxX - minX) / (maxY - minY))
            {
                scale = (float)size.Width / (maxX - minX);
            }
            else
            {
                scale = (float)size.Height / (maxY - minY);
            }
            Turtle.PenSize  = 2;
            Turtle.PenColor = Color.Green;
            Turtle.PenUp();
            Turtle.ShowTurtle = true;
            try
            {
                foreach (PolyLine polyline in polylines)
                {
                    List <Line> lines = polyline.getLines();
                    Turtle.MoveTo(maxX - (float)lines[0].X1 / scale + (float)position.X * scale, (float)lines[0].Y1 / scale + (float)position.Y * scale + minY);
                    Turtle.PenDown();
                    foreach (Line l in lines)
                    {
                        //Turtle.MoveTo((float)l.X1 / scale + (float)position.X * scale + minX, (float)l.Y1 / scale + (float)position.Y * scale +minY);
                        Turtle.MoveTo(maxX - (float)l.X2 / scale + (float)position.X * scale, (float)l.Y2 / scale + (float)position.Y * scale + minY);
                    }
                    Turtle.PenUp();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #5
0
        protected override List <PolyLine> getInsideLines()
        {
            if (string.IsNullOrWhiteSpace(currentPath_) || string.IsNullOrWhiteSpace(currentPath_))
            {
                return(new List <PolyLine>());
            }

            System.Windows.Size insideSize = new System.Windows.Size(outside_.Width - leftPad_ - rightPad_, outside_.Height - topPad_ - bottomPad_);

            PolyLine.setSize(basePolylines_, insideSize);
            PolyLine.moveTo(basePolylines_, new System.Windows.Point(rightPad_, bottomPad_));

            if (isReverse_)
            {
                basePolylines_ = PolyLine.getReversedPolylines(basePolylines_);
            }

            return(basePolylines_);
        }
 private void updatePicture(PaintEventArgs e)
 {
     try
     {
         updateCut();
         pictureBox1.Height = (int)(pictureBox1.Width * Machine.TOTAL_HEIGHT / Machine.TOTAL_WIDTH);
         e.Graphics.Clear(Color.White);
         Pen p = new Pen(Color.Black);
         foreach (System.Windows.Shapes.Line line in PolyLine.getAllLines(cut.getAllLines()))
         {
             System.Drawing.Point p1 = Utility.CONVERT_XY_REAL_TO_POINT(line.X1, line.Y1, pictureBox1.Size);
             System.Drawing.Point p2 = Utility.CONVERT_XY_REAL_TO_POINT(line.X2, line.Y2, pictureBox1.Size);
             e.Graphics.DrawLine(p, p1, p2);
         }
     }
     catch (Exception ex)
     {
         clearCanvas();
         assignCutter();
         System.Windows.MessageBox.Show("Failed to update painting \n" + ex.Message);
     }
 }
Beispiel #7
0
        public List <PolyLine> getOutsideLines()
        {
            List <System.Windows.Shapes.Line> lines = new List <System.Windows.Shapes.Line>();

            if (!cutOutside_)
            {
                return(PolyLine.convertLinesToPolyLines(lines));
            }

            bool top  = qtyX_ % 2 == 1;
            bool left = qtyY_ % 2 == 0;

            for (int i = left ? 1 : qtyX_ - 1; left?i < qtyX_ : i > 0; i += left ? 1 : -1)
            {
                System.Windows.Shapes.Line newLine = new System.Windows.Shapes.Line();
                newLine.X1 = newLine.X2 = i * outside_.Width;
                if (top)
                {
                    newLine.Y1 = 0;
                    newLine.Y2 = outside_.Height * qtyY_;
                }
                else
                {
                    newLine.Y2 = 0;
                    newLine.Y1 = outside_.Height * qtyY_;
                }

                lines.Add(newLine);
                top = !top;
            }


            for (int j = 1; j < qtyY_; j++)
            {
                System.Windows.Shapes.Line newLine = new System.Windows.Shapes.Line();
                newLine.Y1 = newLine.Y2 = j * outside_.Height;
                if (left)
                {
                    newLine.X1 = outside_.Width * qtyX_;
                    newLine.X2 = 0;
                }
                else
                {
                    newLine.X1 = 0;
                    newLine.X2 = outside_.Width * qtyX_;
                }
                lines.Add(newLine);
                left = !left;
            }
            System.Windows.Shapes.Line topLine    = new System.Windows.Shapes.Line();
            System.Windows.Shapes.Line rightLine  = new System.Windows.Shapes.Line();
            System.Windows.Shapes.Line bottomLine = new System.Windows.Shapes.Line();
            System.Windows.Shapes.Line leftLine   = new System.Windows.Shapes.Line();
            topLine.X2 = rightLine.X1 = rightLine.X2 = bottomLine.X1 = 0;

            topLine.X1   = bottomLine.X2 = leftLine.X1 = leftLine.X2 = outside_.Width * qtyX_;
            topLine.Y1   = topLine.Y2 = rightLine.Y1 = leftLine.Y2 = outside_.Height * qtyY_;
            rightLine.Y2 = bottomLine.Y1 = bottomLine.Y2 = leftLine.Y1;
            lines.AddRange(
                new List <System.Windows.Shapes.Line> {
                rightLine, bottomLine, leftLine, topLine,
            });
            return(PolyLine.convertLinesToPolyLines(lines));
        }
Beispiel #8
0
        public static System.Windows.Size getPLTSize(string filePath)
        {
            List <PolyLine> polyLines = PolyLine.getPolylinesFromFile(filePath);

            return(PolyLine.getSize(polyLines));
        }