private void Panel_PreviewMouseDown(object sender, MouseButtonEventArgs e) { Debug.WriteLine(sender); // If the conversion fails, we didn't select a panel PanelDisplay selectedPanel = sender as PanelDisplay; // if (e.LeftButton == MouseButtonState.Pressed) { if (selectedPanel != null) { // Unselect all panels foreach (PanelDisplay panel in m_displayPanels) { panel.Foreground = DEFAULT_FOREGROUND; } m_selectedPanel = selectedPanel; m_selectedPanel.Foreground = SELECTED_FOREGROUND; m_dragLoc = e.GetPosition(canvas); } Debug.WriteLine("MouseDown 1 {0} {1}", m_dragging, m_rotating); if (m_selectedPanel != null && selectedPanel == m_selectedPanel) { m_dragging = true; } else if (m_selectedPanel != null) { m_rotating = true; } Debug.WriteLine("MouseDown 2 {0} {1}", m_dragging, m_rotating); } }
public SerializablePanelDisplay(PanelDisplay display) { scale = display.scale; panel = new Panel.SerializablePanel(display.m_panel); X = display.X; Y = display.Y; }
public PanelDisplay Copy() { PanelDisplay newDisplay = new PanelDisplay(m_panel.Copy(), scale); newDisplay.X = this.X; newDisplay.Y = this.Y; newDisplay.scale = this.scale; newDisplay.OutputFormat = this.OutputFormat; return(newDisplay); }
public void Write(PanelDisplay panel) { PointCollection points = panel.GetPoints(); svgFile.Write("<polyline points=\""); foreach (Point p in points) { svgFile.Write(" " + p.X + "," + p.Y + " "); } svgFile.WriteLine("\" style=\"fill:none;stroke:black;stroke-width:1\" />"); }
public void DisplayPanel(Panel p, double x, double y) { PanelDisplay panel = new PanelDisplay(p, m_overallScale); panel.Background = DEFAULT_BACKGROUND; panel.Foreground = DEFAULT_FOREGROUND; panel.X = x; panel.Y = y; DisplayPanel(panel); }
private void CopyClick(object sender, RoutedEventArgs e) { if (m_selectedPanel != null) { PanelDisplay panel = m_selectedPanel.Copy(); DisplayPanel(panel); m_selectedPanel.Foreground = DEFAULT_FOREGROUND; panel.Foreground = SELECTED_FOREGROUND; m_selectedPanel = panel; } }
public void Write(PanelDisplay panel) { Point lastPoint = new Point(0, 0); Point firstPoint = new Point(0, 0); PointCollection points = panel.GetPoints(); Boolean first = true; foreach (Point p in points) { if (first) { lastPoint = p; firstPoint = p; first = false; } else { stlFile.WriteLine("facet normal 0.0E1 0.0E1 0.0E1"); // normal vector stlFile.WriteLine("outer loop"); stlFile.WriteLine("vertex {0:E} {1:E} {2:E}", lastPoint.X, lastPoint.Y, -m_depth); stlFile.WriteLine("vertex {0:E} {1:E} {2:E}", lastPoint.X, lastPoint.Y, 0); stlFile.WriteLine("vertex {0:E} {1:E} {2:E}", p.X, p.Y, 0); stlFile.WriteLine("endloop"); stlFile.WriteLine("endfacet"); stlFile.WriteLine("facet normal ni nj nk"); // normal vector stlFile.WriteLine("outer loop"); stlFile.WriteLine("vertex {0:E} {1:E} {2:E}", lastPoint.X, lastPoint.Y, -m_depth); stlFile.WriteLine("vertex {0:E} {1:E} {2:E}", p.X, p.Y, 0); stlFile.WriteLine("vertex {0:E} {1:E} {2:E}", p.X, p.Y, -m_depth); stlFile.WriteLine("endloop"); stlFile.WriteLine("endfacet"); lastPoint = p; } } // go back to first point stlFile.WriteLine("facet normal 0.0E1 0.0E1 0.0E1"); // normal vector stlFile.WriteLine("outer loop"); stlFile.WriteLine("vertex {0:E} {1:E} {2:E}", lastPoint.X, lastPoint.Y, -m_depth); stlFile.WriteLine("vertex {0:E} {1:E} {2:E}", lastPoint.X, lastPoint.Y, 0); stlFile.WriteLine("vertex {0:E} {1:E} {2:E}", firstPoint.X, firstPoint.Y, 0); stlFile.WriteLine("endloop"); stlFile.WriteLine("endfacet"); stlFile.WriteLine("facet normal ni nj nk"); // normal vector stlFile.WriteLine("outer loop"); stlFile.WriteLine("vertex {0:E} {1:E} {2:E}", lastPoint.X, lastPoint.Y, -m_depth); stlFile.WriteLine("vertex {0:E} {1:E} {2:E}", firstPoint.X, firstPoint.Y, 0); stlFile.WriteLine("vertex {0:E} {1:E} {2:E}", firstPoint.X, firstPoint.Y, -m_depth); stlFile.WriteLine("endloop"); stlFile.WriteLine("endfacet"); }
public void Write(PanelDisplay panel, Point origin) { double offset = parameters.CutterDiameter / 2; PointCollection points = panel.GetPoints(); Boolean first = true; Point firstPoint = new Point(0, 0); // Get the tool path, which is an offset from the panel points PointCollection path; if (offset != 0) { path = Geometry.ParallelShape(points, offset, parameters.OffsetInside); } else { path = points; } double currentDepth = 0; while (currentDepth < parameters.MaterialThickness) { currentDepth += parameters.DepthPerCut; if (currentDepth > parameters.MaterialThickness) { currentDepth = parameters.MaterialThickness + parameters.CutthroughDepth; } foreach (Point p in path) { Point spot = new Point(p.X - origin.X, -(p.Y - origin.Y)); if (first) { firstPoint = spot; gCodeFile.WriteLine("G01 Z0.25 F{0}", parameters.PlungeSpeed); // Lift cutter gCodeFile.WriteLine("G00 X{0} Y{1}", spot.X, spot.Y); // Go to start point gCodeFile.WriteLine("G01 Z-{0} F{1}", currentDepth, parameters.PlungeSpeed); // cut into surface gCodeFile.WriteLine("G01 X{0} Y{1} F{2}", spot.X, spot.Y, parameters.CutSpeed); // set cutspeed first = false; } else { gCodeFile.WriteLine("G01 X{0} Y{1}", spot.X, spot.Y); } } first = true; } gCodeFile.WriteLine("G01 X{0} Y{1}", firstPoint.X, firstPoint.Y); gCodeFile.WriteLine("G01 Z0.25 F{0}", parameters.PlungeSpeed); // Lift cutter }
public void DisplayPanel(PanelDisplay panel) { panel.Background = DEFAULT_BACKGROUND; panel.Foreground = DEFAULT_FOREGROUND; panel.PreviewMouseDown += Panel_PreviewMouseDown; panel.PreviewMouseMove += Panel_PreviewMouseMove; ContextMenu menu = (ContextMenu)this.FindResource("EditMenu"); if (menu != null) { panel.ContextMenu = menu; } m_displayPanels.Add(panel); canvas.Children.Add(panel); Canvas.SetLeft(panel, panel.X); Canvas.SetTop(panel, panel.Y); }
private void SplitClick(object sender, RoutedEventArgs e) { if (m_selectedPanel != null) { PanelSnipWindow snip = new PanelSnipWindow(); snip.ShowDialog(); if (snip.OK) { Panel panel_1, panel_2; if (m_selectedPanel.Split(snip.start, snip.numTongues, snip.depth, out panel_1, out panel_2)) { DisplayPanel(panel_1, m_selectedPanel.X, m_selectedPanel.Y); DisplayPanel(panel_2, m_selectedPanel.X + snip.start, m_selectedPanel.Y); canvas.Children.Remove(m_selectedPanel); m_displayPanels.Remove(m_selectedPanel); m_selectedPanel = null; } } } }