private void update_GCode_Depending_Controls()
        {
            lbDimension.Text = VisuGCode.xyzSize.getMinMaxString() + "\r\n" + VisuGCode.getProcessingTime(); //String.Format("X:[ {0:0.0} | {1:0.0} ];    Y:[ {2:0.0} | {3:0.0} ];    Z:[ {4:0.0} | {5:0.0} ]", visuGCode.xyzSize.minx, visuGCode.xyzSize.maxx, visuGCode.xyzSize.miny, visuGCode.xyzSize.maxy, visuGCode.xyzSize.minz, visuGCode.xyzSize.maxz);
            lbDimension.Select(0, 0);
//            toolTip1.SetToolTip(lbDimension, visuGCode.getProcessingTime());
            checkMachineLimit();
            toolStrip_tb_XY_X_scale.Text = string.Format("{0:0.000}", VisuGCode.xyzSize.dimx);
            toolStrip_tb_X_X_scale.Text  = string.Format("{0:0.000}", VisuGCode.xyzSize.dimx);
            toolStrip_tb_XY_Y_scale.Text = string.Format("{0:0.000}", VisuGCode.xyzSize.dimy);
            toolStrip_tb_Y_Y_scale.Text  = string.Format("{0:0.000}", VisuGCode.xyzSize.dimy);
            btnSimulate.Enabled          = true;
            setGcodeVariables();

            if (VisuGCode.containsG2G3Command())                        // disable X/Y independend scaling if G2 or G3 GCode is in use
            {                                                           // because it's not possible to stretch (convert 1st to G1 GCode)                skaliereXUmToolStripMenuItem.Enabled = false;
                skaliereXUmToolStripMenuItem.Enabled            = false;
                skaliereYUmToolStripMenuItem.Enabled            = false;
                skaliereAufXUnitsToolStripMenuItem.Enabled      = false;
                skaliereAufYUnitsToolStripMenuItem.Enabled      = false;
                skaliereXAufDrehachseToolStripMenuItem.Enabled  = false;
                skaliereYAufDrehachseToolStripMenuItem.Enabled  = false;
                ersetzteG23DurchLinienToolStripMenuItem.Enabled = true;
            }
            else
            {
                skaliereXUmToolStripMenuItem.Enabled            = true;     // enable X/Y independend scaling because no G2 or G3 GCode
                skaliereYUmToolStripMenuItem.Enabled            = true;
                skaliereAufXUnitsToolStripMenuItem.Enabled      = true;
                skaliereAufYUnitsToolStripMenuItem.Enabled      = true;
                skaliereXAufDrehachseToolStripMenuItem.Enabled  = true;
                skaliereYAufDrehachseToolStripMenuItem.Enabled  = true;
                ersetzteG23DurchLinienToolStripMenuItem.Enabled = false;
            }
        }
        private void toolStrip_tBRadiusCompValue_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == (char)13)
            {
                double radius = Properties.Settings.Default.crcValue;
                if (Double.TryParse(toolStrip_tBRadiusCompValue.Text.Replace(',', '.'), System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out radius))
                {
                    Properties.Settings.Default.crcValue          = radius;
                    Properties.Settings.Default.guiBackgroundShow = toolStripViewBackground.Checked = true;
                    {
                        //transformStart();
                        Cursor.Current = Cursors.WaitCursor;
                        unDo.setCode(fCTBCode.Text, string.Format("Radius compensation {0:0.00}", radius), this);
                        showPicBoxBgImage           = false;        // don't show background image anymore
                        pictureBox1.BackgroundImage = null;
                        pBoxTransform.Reset();
                        grbl.posMarker = new xyPoint(0, 0);

                        fCTBCode.Text = VisuGCode.transformGCodeRadiusCorrection(radius);
//                        showMessageForm(log.get());
                        transformEnd();
                    }
                }
                else
                {
                    MessageBox.Show(Localization.getString("mainParseError"), Localization.getString("mainAttention"));
                    toolStrip_tBRadiusCompValue.Text = string.Format("{0:0.000}", radius);
                }
                e.SuppressKeyPress = true;
                gCodeToolStripMenuItem.HideDropDown();
            }
        }
Пример #3
0
        private void fCTBCode_TextChanged(object sender, FastColoredTextBoxNS.TextChangedEventArgs e)
        {
            e.ChangedRange.ClearStyle(StyleComment);
            e.ChangedRange.SetStyle(StyleComment, "(\\(.*\\))", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleCommentxml, "(\\(<.*\\))", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleGWord, "(G\\d{1,2})", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleMWord, "(M\\d{1,2})", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleFWord, "(F\\d+)", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleSWord, "(S\\d+)", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleLineN, "(N\\d+)", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleTool, "(T\\d{1,2})", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleXAxis, "[XIxi]{1}-?\\d+(.\\d+)?", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleYAxis, "[YJyj]{1}-?\\d+(.\\d+)?", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleZAxis, "[Zz]{1}-?\\d+(.\\d+)?", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleAAxis, "[AaBbCcUuVvWw]{1}-?\\d+(.\\d+)?", System.Text.RegularExpressions.RegexOptions.Compiled);

            e.ChangedRange.ClearFoldingMarkers();
            e.ChangedRange.SetFoldingMarkers(xmlMarker.fillStart, xmlMarker.fillEnd);
            e.ChangedRange.SetFoldingMarkers(xmlMarker.contourStart, xmlMarker.contourEnd);
            e.ChangedRange.SetFoldingMarkers(xmlMarker.clearanceStart, xmlMarker.clearanceEnd);
            e.ChangedRange.SetFoldingMarkers(xmlMarker.revolutionStart, xmlMarker.revolutionEnd);
            e.ChangedRange.SetFoldingMarkers(xmlMarker.passStart, xmlMarker.passEnd);
            e.ChangedRange.SetFoldingMarkers(xmlMarker.figureStart, xmlMarker.figureEnd);
            e.ChangedRange.SetFoldingMarkers(xmlMarker.groupStart, xmlMarker.groupEnd);
            if (Properties.Settings.Default.importCodeFold)
            {
                fCTBCode.CollapseAllFoldingBlocks();
            }

            codeBlocksToolStripMenuItem.Enabled = VisuGCode.codeBlocksAvailable();
            codeSelection.setFCTB = fCTBCode;
        }
Пример #4
0
        public static void sortByDistance()
        {
            List <BlockData> result = new List <BlockData>();
            xyPoint          first  = new xyPoint();
            double           distanceReverse;
            BlockData        tmp;
            bool             allowReverse = !VisuGCode.containsG2G3Command() && !VisuGCode.containsG91Command() && !VisuGCode.containsTangential();

            while (listFigures.Count > 0)
            {
                for (int i = 0; i < listFigures.Count; i++)
                {
                    tmp             = listFigures[i];
                    tmp.distance    = first.DistanceTo(tmp.posStart);
                    distanceReverse = first.DistanceTo(tmp.posEnd);
                    if (allowReverse && (distanceReverse < tmp.distance))
                    {
                        tmp.distance = distanceReverse;
                        tmp.reverse  = true;
                    }
                    listFigures[i] = tmp;
                }
                listFigures.Sort((x, y) => x.distance.CompareTo(y.distance));

                result.Add(listFigures[0]);
                first = listFigures[0].posEnd;
                listFigures.RemoveAt(0);
            }

            listFigures.Clear();
            foreach (BlockData item in result)
            {
                listFigures.Add(item);
            }
        }
Пример #5
0
        private void fCTBCodeMarkLine(bool select = true)     // after click on gcode line, mark text and graphics
        {
            if ((fCTBCodeClickedLineNow <= fCTBCode.LinesCount) && (fCTBCodeClickedLineNow >= 0))
            {
                fCTBBookmark = new Bookmark(fCTBCode, "marked", fCTBCodeClickedLineNow);
                if (fCTBCodeClickedLineNow != fCTBCodeClickedLineLast)
                {
                    fCTBCode.UnbookmarkLine(fCTBCodeClickedLineLast);
                    fCTBCode.BookmarkLine(fCTBCodeClickedLineNow);
                    fCTBCodeClickedLineLast = fCTBCodeClickedLineNow;

                    // Set marker in drawing
                    Place tst = fCTBCode.Selection.Start;
                    VisuGCode.setPosMarkerLine(fCTBCodeClickedLineNow, !isStreaming);

                    if ((fCTBCode.Lines[tst.iLine].Contains(xmlMarker.groupStart)) || (fCTBCode.Lines[tst.iLine].Contains(xmlMarker.groupEnd)))
                    {
                        VisuGCode.markSelectedGroup(tst.iLine);
                    }

                    if (select && codeSelection.checkClicked(fCTBCodeClickedLineNow))
                    {
                        setFigureIsMarked(true);
                        fCTBCode.DoCaretVisible();
                    }
                    else
                    {
                        setFigureIsMarked(false);
                    }

                    pictureBox1.Invalidate(); // avoid too much events
                    toolStrip_tb_StreamLine.Text = fCTBCodeClickedLineNow.ToString();
                }
            }
        }
 private void applyHeightMap(object sender, EventArgs e)
 {
     Cursor.Current = Cursors.WaitCursor;
     if (!isHeightMapApplied)
     {
         loadHeightMap(sender, e);
         codeBeforeHeightMap.Clear();
         foreach (string codeline in fCTBCode.Lines)
         {
             if (codeline.Length > 0)
             {
                 codeBeforeHeightMap.AppendLine(codeline);
             }
         }
         VisuGCode.getGCodeLines(fCTBCode.Lines);
         fCTBCode.Text = VisuGCode.applyHeightMap(fCTBCode.Lines, _heightmap_form.Map);
         update_GCode_Depending_Controls();
         _heightmap_form.setBtnApply(isHeightMapApplied);
         isHeightMapApplied = true;
     }
     else
     {
         fCTBCode.Text = codeBeforeHeightMap.ToString();
         update_GCode_Depending_Controls();
         _heightmap_form.setBtnApply(isHeightMapApplied);
         isHeightMapApplied = false;
     }
     Cursor.Current = Cursors.Default;
 }
Пример #7
0
 private void formClosed_SetupForm(object sender, FormClosedEventArgs e)
 {
     loadSettings(sender, e);
     _setup_form = null;
     VisuGCode.drawMachineLimit(toolTable.getToolCordinates());
     pictureBox1.Invalidate();                                   // resfresh view
     gamePadTimer.Enabled = Properties.Settings.Default.gamePadEnable;
 }
Пример #8
0
 private void btnGetAngleEF_Click(object sender, EventArgs e)
 {
     if ((VisuGCode.xyzSize.dimx > 0) && (VisuGCode.xyzSize.dimy > 0))
     {
         transformStart("Rotate");
         fCTBCode.Text = VisuGCode.transformGCodeRotate(_probing_form.getAngle, 1, new xyPoint(0, 0), false);    // use given center
         transformEnd();
     }
 }
 private void moveSelectedPathToolStripMenuItem_Click(object sender, EventArgs e)
 {
     transformStart("Apply Offset");
     zoomFactor              = 1;
     fCTBCode.Text           = VisuGCode.transformGCodeOffset(-(posMoveEnd.X - posMoveStart.X), -(posMoveEnd.Y - posMoveStart.Y), VisuGCode.translate.None);
     fCTBCodeClickedLineNow  = fCTBCodeClickedLineLast;
     fCTBCodeClickedLineLast = 0;
     transformEnd();
 }
Пример #10
0
 private void cmsPicBoxMoveGraphicsOrigin_Click(object sender, EventArgs e)
 {
     unDo.setCode(fCTBCode.Text, cmsPicBoxMoveGraphicsOrigin.Text, this);
     clearTextSelection(fCTBCodeClickedLineNow);
     VisuGCode.markSelectedFigure(-1);
     fCTBCode.Text = VisuGCode.transformGCodeOffset(grbl.posMarker.X, grbl.posMarker.Y, VisuGCode.translate.None);
     transformEnd();
     grbl.posMarker = new xyPoint(0, 0);
 }
 private void transformEnd()
 {
     VisuGCode.getGCodeLines(fCTBCode.Lines);                    // get code path
     VisuGCode.calcDrawingArea();                                // calc ruler dimension
     VisuGCode.drawMachineLimit(toolTable.getToolCordinates());
     pictureBox1.Invalidate();                                   // resfresh view
     update_GCode_Depending_Controls();                          // update GUI controls
     updateControls();                                           // update control enable
     this.Cursor = Cursors.Default;
 }
Пример #12
0
      private void createFrom2DView(float step)
      {
          scanCNCPos.Clear();
          Logger.Trace("createFrom2DView G2G3:{0}", VisuGCode.containsG2G3Command());

          // Export from VisuGCode.
          if (!VisuGCode.getPathCordinates(scanCNCPos, step))
          {
          }
      }
Пример #13
0
        private void createGridView()
        {
            drawingProperties tmp = new drawingProperties();
            PointF            ul  = getGraphicCoordinateFromPictureBox(new Point(0, 0));
            PointF            lr  = getGraphicCoordinateFromPictureBox(new Point(pictureBox1.Width, pictureBox1.Height));

            tmp.setX((float)Math.Round(ul.X), (float)Math.Round(lr.X));
            tmp.setY((float)Math.Round(ul.Y), (float)Math.Round(lr.Y));
            VisuGCode.createRuler(ruler, tmp);
            createGrid(grid, tmp, (float)nUDRaster.Value);
        }
Пример #14
0
 private void getGCodeFromHeightMap(object sender, EventArgs e)
 {
     if (!isStreaming)
     {
         simuStop();
         VisuGCode.clearHeightMap();
         newCodeStart();
         setfCTBCodeText(_heightmap_form.scanCode.ToString().Replace(',', '.'));
         setLastLoadedFile("from height map", "");
         newCodeEnd();
     }
 }
Пример #15
0
 private void cmsPicBoxMoveSelectedPathInCode_Click(object sender, EventArgs e)
 {
     transformStart(cmsPicBoxMoveSelectedPathInCode.Text);
     zoomFactor              = 1;
     fCTBCode.Text           = VisuGCode.transformGCodeOffset(-(posMoveEnd.X - posMoveStart.X), -(posMoveEnd.Y - posMoveStart.Y), VisuGCode.translate.None);
     fCTBCodeClickedLineNow  = fCTBCodeClickedLineLast;
     fCTBCodeClickedLineLast = 0;
     transformEnd();
     statusStripClear(2);
     cmsPicBoxMoveSelectedPathInCode.Enabled   = false;
     cmsPicBoxMoveSelectedPathInCode.BackColor = SystemColors.Control;
 }
Пример #16
0
 private void transformEnd()
 {
     VisuGCode.getGCodeLines(fCTBCode.Lines, null, null);        // get code path
     VisuGCode.calcDrawingArea();                                // calc ruler dimension
     VisuGCode.drawMachineLimit(toolTable.getToolCordinates());
     pictureBox1.Invalidate();                                   // resfresh view
     update_GCode_Depending_Controls();                          // update GUI controls
     timerUpdateControlSource = "transformEnd";
     updateControls();                                           // update control enable
     enableCmsCodeBlocks(VisuGCode.codeBlocksAvailable());
     this.Cursor = Cursors.Default;
     setEditMode(false);
 }
 private void loadHeightMap(object sender, EventArgs e)
 {
     if (_heightmap_form.mapIsLoaded)
     {
         VisuGCode.drawHeightMap(_heightmap_form.Map);
         VisuGCode.createMarkerPath();
         VisuGCode.calcDrawingArea();
         pictureBox1.BackgroundImage = null;
         pictureBox1.Invalidate();
         isHeightMapApplied          = false;
         _heightmap_form.mapIsLoaded = false;
     }
 }
Пример #18
0
        // find closest coordinate in GCode and mark
        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            if (logDetailed)
            {
                Logger.Trace("pictureBox1_MouseDown e.x:{0} y:{1}  absPos-x:{2:0.00} y:{3:0.00}", e.X, e.Y, picAbsPos.X, picAbsPos.Y);
            }
            pictureBox1.Focus();
            moveTranslationOld = new xyPoint(e.X, e.Y);
            allowZoom          = false;
            if (e.Button == MouseButtons.Left)
            {
                if ((fCTBCode.LinesCount > 2) && !posIsMoving)
                {
                    int line = 0;
                    posMoveStart = picAbsPos;
                    posMoveTmp   = posMoveStart;
                    posMoveEnd   = posMoveStart;

                    if (manualEdit)
                    {
                        newCodeEnd();
                    }
                    if (Panel.ModifierKeys == Keys.Alt)
                    {
                        line = VisuGCode.setPosMarkerNearBy(picAbsPos, false);         // find line with coord nearby, mark / unmark figure
                        fCTBCodeClickedLineNow = line;
                        findFigureMarkSelection(xmlMarkerType.Line, line, (foldLevel > 0));
                    }
                    else if (Panel.ModifierKeys == Keys.Control)               //Keys.Alt)
                    {
                        line = VisuGCode.setPosMarkerNearBy(picAbsPos, false); // find line with coord nearby, mark / unmark figure
                        fCTBCodeClickedLineNow = line;
                        findFigureMarkSelection(xmlMarkerType.Group, line, (foldLevel > 0));
                    }
                    else
                    {
                        line = VisuGCode.setPosMarkerNearBy(picAbsPos);         // find line with coord nearby, mark / unmark figure
                        fCTBCodeClickedLineNow = line;
                        findFigureMarkSelection(xmlMarkerType.Figure, line, (foldLevel > 0));
                    }

                    cmsPicBoxMoveToMarkedPosition.ToolTipText = "Work X: " + grbl.posMarker.X.ToString() + "   Y: " + grbl.posMarker.Y.ToString();
                    enableBlockCommands(VisuGCode.getHighlightStatus() > 0);
                    if (VisuGCode.codeBlocksAvailable())
                    {
                        statusStripSet(1, Localization.getString("statusStripeClickKeys2"), Color.LightGreen);
                    }
                    posIsMoving = false;
                }
            }
        }
Пример #19
0
        private void OnRaiseCameraClickEvent(object sender, XYEventArgs e)
        {
            if (e.Command == "a")
            {
                if (fCTBCode.LinesCount > 1)
                {
                    VisuGCode.markSelectedFigure(-1);                                                 // rotate all figures
                    transformStart(string.Format("Rotate {0:0.00}", e.Angle));
                    fCTBCode.Text = VisuGCode.transformGCodeRotate(e.Angle, e.Scale, e.Point, false); // use given center
                    transformEnd();
                }
            }
            else
            {
                double   realStepX = Math.Round(e.Point.X, 3);
                double   realStepY = Math.Round(e.Point.Y, 3);
                int      speed     = 1000;
                string   s         = "";
                string[] line      = e.Command.Split(';');
                foreach (string cmd in line)
                {
                    if (cmd.Trim() == "G92")
                    {
                        s = String.Format(cmd + " X{0} Y{1}", realStepX, realStepY).Replace(',', '.');
                        sendCommand(s);
                    }
                    else if ((cmd.Trim().IndexOf("G0") >= 0) || (cmd.Trim().IndexOf("G1") >= 0))        // no jogging
                    {
                        s = String.Format(cmd + " X{0} Y{1}", realStepX, realStepY).Replace(',', '.');
                        sendCommand(s);
                    }
                    else if ((cmd.Trim().IndexOf("G90") == 0) || (cmd.Trim().IndexOf("G91") == 0))      // no G0 G1, then jogging
                    {
                        speed = 100 + (int)Math.Sqrt(realStepX * realStepX + realStepY * realStepY) * 120;
                        s     = String.Format("{0} X{1} Y{2} F{3}", cmd, realStepX, realStepY, speed).Replace(',', '.');
                        if (grbl.isMarlin)
                        {
                            s = String.Format("{0}; G1 X{1} Y{2} F{3}", cmd, realStepX, realStepY, speed).Replace(',', '.');
                        }

                        sendCommands(s, true);
                    }
                    else
                    {
                        sendCommand(cmd.Trim());
                    }
                }
            }
        }
Пример #20
0
 private void fCTBCodeMarkLine(bool markAnyway = false)     // after click on gcode line, mark text and graphics
 {
     if ((fCTBCodeClickedLineNow <= fCTBCode.LinesCount) && (fCTBCodeClickedLineNow >= 0))
     {
         if ((fCTBCodeClickedLineNow != fCTBCodeClickedLineLast) || markAnyway)
         {
             fCTBCode.UnbookmarkLine(fCTBCodeClickedLineLast);           // remove marker from old line
             fCTBCode.BookmarkLine(fCTBCodeClickedLineNow);              // set new marker
             fCTBCodeClickedLineLast = fCTBCodeClickedLineNow;
             VisuGCode.setPosMarkerLine(fCTBCodeClickedLineNow, !isStreaming);
             pictureBox1.Invalidate(); // avoid too much events
             toolStrip_tb_StreamLine.Text = fCTBCodeClickedLineNow.ToString();
         }
     }
 }
Пример #21
0
      private void simuStart(Color col)
      {
          label_wx.ForeColor = col;
          label_wy.ForeColor = col;
          label_wz.ForeColor = col;
          label_wa.ForeColor = col;
          label_wb.ForeColor = col;
          label_wc.ForeColor = col;

          Color invers = ContrastColor(col);

          label_wx.BackColor = invers;
          label_wy.BackColor = invers;
          label_wz.BackColor = invers;
          label_wa.BackColor = invers;
          label_wb.BackColor = invers;
          label_wc.BackColor = invers;

          simulateA = VisuGCode.containsTangential();
          if (simulateA)
          {
              updateLayout();
          }

          pbFile.Maximum = fCTBCode.LinesCount;
          fCTBCode.UnbookmarkLine(fCTBCodeClickedLineLast);
          btnSimulate.Text        = Localization.getString("mainSimuStop");
          simuLine                = 0;
          fCTBCodeClickedLineNow  = simuLine;
          fCTBCodeClickedLineLast = simuLine;
          simuEnabled             = true;
          simulationTimer.Enabled = true;
          //         VisuGCode.markSelectedFigure(-1);
          //         VisuGCode.setPosMarkerLine(simuLine, false);
          btnStreamStart.Enabled    = false;
          btnStreamStop.Enabled     = false;
          btnStreamCheck.Enabled    = false;
          btnSimulateFaster.Enabled = true;
          btnSimulateSlower.Enabled = true;
          VisuGCode.Simulation.Reset();

          double factor = 100 * VisuGCode.Simulation.dt / 50;

          lblElapsed.Text          = string.Format("{0} {1:0}%", Localization.getString("mainSimuSpeed"), factor);
          btnSimulatePause.Visible = true;
          lbInfo.BackColor         = System.Drawing.Color.LightGreen;
      }
Пример #22
0
        private int findFigureMarkSelection(Color selectionColor)   // called by click on figure in 2D view
        {
            setFigureIsMarked(false);
            int start = VisuGCode.getLineOfFirstPointInFigure();

            if (codeSelection.checkClicked(start))
            {
                setFigureIsMarked(true);
                fCTBCode.DoCaretVisible();
            }
            else
            {
                setFigureIsMarked(false);
            }

            return(start);
        }
Пример #23
0
        private void ControlJogPathCreator_Load(object sender, EventArgs e)
        {
            //            Logger.Trace("++++++ ControlJogPathCreator START ++++++");
            this.Icon           = Properties.Resources.Icon;
            penjogPath.StartCap = LineCap.Round;
            penjogPath.EndCap   = LineCap.Triangle;
            drawingSize.setX(-10, 100);
            drawingSize.setY(-10, 100);
            jogPath.StartFigure();
            jogPath.AddLine(10, 10, 10, 30);
            jogPath.AddLine(10, 30, 30, 30);
            jogPath.AddLine(30, 30, 30, 10);
            jogPath.AddLine(30, 10, 10, 10);
            lastSet = new PointF(10, 10);

            VisuGCode.createRuler(ruler, drawingSize);
            createGrid(grid, drawingSize, (float)nUDRaster.Value);
        }
 private void toolStrip_tb_rotate_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyValue == (char)13)
     {
         double anglenew;
         if (Double.TryParse(toolStrip_tb_rotate.Text.Replace(',', '.'), System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out anglenew))
         {
             transformStart(string.Format("Rotate {0:0.00}", anglenew));
             fCTBCode.Text = VisuGCode.transformGCodeRotate(anglenew, 1, new xyPoint(0, 0));
             transformEnd();
         }
         else
         {
             MessageBox.Show(Localization.getString("mainParseError"), Localization.getString("mainAttention"));
             toolStrip_tb_rotate.Text = "0.0";
         }
         e.SuppressKeyPress = true;
     }
 }
 private void toolStrip_tb_Y_scale_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyValue == (char)13)
     {
         double size;
         if (Double.TryParse(toolStrip_tb_Y_scale.Text.Replace(',', '.'), System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out size))
         {
             transformStart("Scale");
             fCTBCode.Text = VisuGCode.transformGCodeScale(100, size);
             transformEnd();
         }
         else
         {
             MessageBox.Show(Localization.getString("mainParseError"), Localization.getString("mainAttention"));
             toolStrip_tb_Y_scale.Text = "100.00";
         }
         e.SuppressKeyPress = true;
         gCodeToolStripMenuItem.HideDropDown();
     }
 }
Пример #26
0
        private void fCTBCode_Click(object sender, EventArgs e)         // click into FCTB with mouse
        {
//            if (gcode.loggerTrace && logMain) Logger.Trace("Event  fCTBCode_Click");
            fCTBCodeClickedLineNow = fCTBCode.Selection.ToLine;
//            statusStripSet2(string.Format("Clicked: {0}", fCTBCodeClickedLineNow),SystemColors.Control);
            markedBlockType = xmlMarkerType.none;
            if (manualEdit)
            {
                return;
            }

            enableBlockCommands(false);       // disable CMS-Menu block-move items
            fCTBCode.DoCaretVisible();

            if (Panel.ModifierKeys == Keys.Alt)
            {
                findFigureMarkSelection(xmlMarkerType.Group, fCTBCodeClickedLineNow);
            }
            else if (Panel.ModifierKeys == Keys.Control)
            {
                findFigureMarkSelection(xmlMarkerType.Figure, fCTBCodeClickedLineNow);
            }

            else if (xmlMarker.isFoldingMarkerFigure(fCTBCodeClickedLineNow))
            {
                findFigureMarkSelection(xmlMarkerType.Figure, fCTBCodeClickedLineNow, (foldLevel > 0));
            }                                                                                           // 2020-08-21 add , (foldLevel>0)
            else if (xmlMarker.isFoldingMarkerGroup(fCTBCodeClickedLineNow))
            {
                findFigureMarkSelection(xmlMarkerType.Group, fCTBCodeClickedLineNow, (foldLevel > 0));
            }                                                                                           // 2020-08-21 add , (foldLevel>0)

            if (VisuGCode.codeBlocksAvailable())
            {
                statusStripSet(1, Localization.getString("statusStripeClickKeys"), Color.LightGreen);
                //             statusStripSet(2, fCTBCode.Lines[fCTBCodeClickedLineNow], Color.Orange);
            }

            fCTBCodeMarkLine(true);             // set Bookmark and marker in 2D-View
            //          statusStripSet(2, fCTBCode.Lines[fCTBCodeClickedLineNow], Color.Orange);
        }
Пример #27
0
        private void cmsPicBoxCropSelectedPath_Click(object sender, EventArgs e)
        {
            if (manualEdit)
            {
                return;
            }
            transformStart(cmsPicBoxCropSelectedPath.Text, false);

            if ((xmlMarker.GetGroupCount() > 0) && (markedBlockType == xmlMarkerType.Group))
            {
                if (xmlMarker.GetGroup(fCTBCodeClickedLineNow, 10))    // get range group+1-start to group+n-end
                {
                    setTextSelection(xmlMarker.lastGroup.lineStart, xmlMarker.lastGroup.lineEnd);
                    fCTBCode.SelectedText = "";
                }
                if (xmlMarker.GetGroup(fCTBCodeClickedLineNow, -10))    // get range group0-start to group-1-end
                {
                    setTextSelection(xmlMarker.lastGroup.lineStart, xmlMarker.lastGroup.lineEnd);
                    fCTBCode.SelectedText = "";
                }
            }
            else if ((xmlMarker.GetFigureCount() > 0) && (markedBlockType == xmlMarkerType.Figure))
            {
                if (xmlMarker.GetFigure(fCTBCodeClickedLineNow, 10))    // get range group+1-start to group+n-end
                {
                    setTextSelection(xmlMarker.lastGroup.lineStart, xmlMarker.lastGroup.lineEnd);
                    fCTBCode.SelectedText = "";
                }
                if (xmlMarker.GetFigure(fCTBCodeClickedLineNow, -10))    // get range group0-start to group-1-end
                {
                    setTextSelection(xmlMarker.lastGroup.lineStart, xmlMarker.lastGroup.lineEnd);
                    fCTBCode.SelectedText = "";
                }
            }
            else
            {
                fCTBCode.Text = VisuGCode.cutOutFigure();
            }
            transformEnd();
        }
Пример #28
0
        private void fCTBCode_TextChanged(object sender, FastColoredTextBoxNS.TextChangedEventArgs e)
        {
            if (gcode.loggerTrace)
            {
                Logger.Trace("Event  fCTBCode_TextChanged  manualEdit:{0}", manualEdit);
            }
            e.ChangedRange.ClearStyle(StyleComment);
            e.ChangedRange.SetStyle(StyleComment, "(\\(.*\\))", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleCommentxml, "(\\(<.*\\))", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleGWord, "(G\\d{1,2})", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleMWord, "(M\\d{1,2})", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleFWord, "(F\\d+)", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleSWord, "(S\\d+)", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleLineN, "(N\\d+)", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleTool, "(T\\d{1,2})", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleXAxis, "[XIxi]{1}-?\\d+(.\\d+)?", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleYAxis, "[YJyj]{1}-?\\d+(.\\d+)?", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleZAxis, "[Zz]{1}-?\\d+(.\\d+)?", System.Text.RegularExpressions.RegexOptions.Compiled);
            e.ChangedRange.SetStyle(StyleAAxis, "[AaBbCcUuVvWw]{1}-?\\d+(.\\d+)?", System.Text.RegularExpressions.RegexOptions.Compiled);

            e.ChangedRange.ClearFoldingMarkers();
            e.ChangedRange.SetFoldingMarkers(xmlMarker.headerStart, xmlMarker.headerEnd);
            e.ChangedRange.SetFoldingMarkers(xmlMarker.fillStart, xmlMarker.fillEnd);
            e.ChangedRange.SetFoldingMarkers(xmlMarker.contourStart, xmlMarker.contourEnd);
            e.ChangedRange.SetFoldingMarkers(xmlMarker.clearanceStart, xmlMarker.clearanceEnd);
            e.ChangedRange.SetFoldingMarkers(xmlMarker.revolutionStart, xmlMarker.revolutionEnd);
            e.ChangedRange.SetFoldingMarkers(xmlMarker.passStart, xmlMarker.passEnd);
            e.ChangedRange.SetFoldingMarkers(xmlMarker.figureStart, xmlMarker.figureEnd);
            e.ChangedRange.SetFoldingMarkers(xmlMarker.groupStart, xmlMarker.groupEnd);

            if (!manualEdit)
            {
                if (Properties.Settings.Default.importCodeFold)
                {
                    foldBlocks2(); fCTBCode.CollapseAllFoldingBlocks(); foldLevel = 1;
                }

                enableCmsCodeBlocks(VisuGCode.codeBlocksAvailable());
            }
        }
 // handle event from create Height Map form
 private void getGCodeScanHeightMap(object sender, EventArgs e)
 {
     if (!isStreaming && _serial_form.serialPortOpen)
     {
         if (_heightmap_form.scanStarted)
         {
             string[] commands = _heightmap_form.getCode.ToString().Split('\r');
             _serial_form.isHeightProbing = true;
             foreach (string cmd in commands)            // fill up send queue
             {
                 if (machineStatus == grblState.alarm)
                 {
                     break;
                 }
                 sendCommand(cmd);
             }
             VisuGCode.drawHeightMap(_heightmap_form.Map);
             VisuGCode.createMarkerPath();
             VisuGCode.calcDrawingArea();
             pictureBox1.BackgroundImage = null;
             pictureBox1.Invalidate();
             if (_diyControlPad != null)
             {
                 _diyControlPad.isHeightProbing = true;
             }
             Properties.Settings.Default.counterUseHeightMap += 1;
         }
         else
         {
             _serial_form.stopStreaming();
             if (_diyControlPad != null)
             {
                 _diyControlPad.isHeightProbing = false;
             }
         }
         isHeightMapApplied = false;
     }
 }
Пример #30
0
        // find closest coordinate in GCode and mark
        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {   // MessageBox.Show(picAbsPosX + "  " + picAbsPosY);
            pictureBox1.Focus();
            moveTranslationOld = new xyPoint(e.X, e.Y);
            allowZoom          = false;
            if (e.Button == MouseButtons.Left)
            {
                if ((fCTBCode.LinesCount > 2) && !posIsMoving)
                {
                    int line = VisuGCode.setPosMarkerNearBy(picAbsPos);
                    posMoveStart = picAbsPos;
                    posMoveTmp   = posMoveStart;
                    posMoveEnd   = posMoveStart;

                    moveToMarkedPositionToolStripMenuItem.ToolTipText = "Work X: " + grbl.posMarker.X.ToString() + "   Y: " + grbl.posMarker.Y.ToString();

                    fCTBCodeClickedLineNow = line;
                    fCTBCodeMarkLine();
                    fCTBBookmark.DoVisible();
                    findFigureMarkSelection(Color.OrangeRed);
                    posIsMoving = false;
                }
            }
        }