public IObservable <int> Print(GerberMetaDataDTO metaData) { return(Observable.Create((IObserver <int> observer) => { try { var config = new Config(); messenger.Send("printStart"); var response = messenger.Receive(); var match = new Regex(@"Controller Unit:(\d+)").Match(response); config.ControllerUnit = int.Parse(match.Groups[1].Value); response = messenger.Receive(); match = new Regex(@"MotorRevolutionAverage:(\d+)").Match(response); config.MotorRevolutionAverage = int.Parse(match.Groups[1].Value); config.RatioConvert = (metaData.UnitInMicroMeters / Math.Pow(10, metaData.TrailingDigits)) * (config.PrinterAngle / 360.0 * config.MotorRevolutionAverage / config.PrinterWidth) / (config.ControllerUnit * Math.Pow(10, -6)); config.Width = (int)(metaData.Bounds.Width * config.RatioConvert); config.Height = (int)(metaData.Bounds.Height * config.RatioConvert) * -1; messenger.Send(config.Width.ToString()); messenger.Send(config.Height.ToString()); response = messenger.Receive(); } catch { observer.OnError(new Exception("Print unexpected error")); } return () => { }; })); }
/// <summary> /// Make a hole in aperture /// </summary> /// <param name="metaData">Metadata</param> /// <param name="trace">Trace to use in partial columns</param> /// <param name="aperture">Aperture with hole</param> /// <param name="layer">Layer where merge</param> protected void MakeHole(GerberMetaDataDTO metaData, GerberTraceDTO trace, GerberApertureDTO aperture, PlarityLayerDTO layer) { List <CoordinateDTO> hole = MidpointCircle(trace.AbsolutePointEnd.X / metaData.Scale, trace.AbsolutePointEnd.Y / metaData.Scale, aperture.Modifiers.Last() / metaData.Scale / 2, topRow, bottomRow); var layerHole = new PlarityLayerDTO(); layerHole.IsDarkPolarity = !layer.IsDarkPolarity; ResumePoints(hole, layerHole, trace); MergeLayers(layer, layerHole); }
public override void Create(GerberMetaDataDTO metaDataBase, GerberMetaDataDTO metaData, GerberTraceDTO trace, GerberApertureDTO aperture, int layerIndex, int rowFrom, int rowTo) { base.Create(metaDataBase, metaData, trace, aperture, layerIndex, rowFrom, rowTo); var leftColumn = trace.AbsolutePointEnd.X - aperture.Modifiers[0] / 2; var rightColumn = leftColumn + aperture.Modifiers[0]; leftColumn /= metaData.Scale; rightColumn /= metaData.Scale; var layer = new PlarityLayerDTO() { IsDarkPolarity = metaData.PolarityLayers[layerIndex].IsDarkPolarity }; for (var rowIndex = topRow; rowIndex >= bottomRow; rowIndex--) { var row = GetRow(layer, rowIndex); var columns = new List <ColumnDataDTO>(); if (rowIndex == topRow || rowIndex == bottomRow) { columns.Add( CreateColumn(leftColumn, rightColumn, new List <GerberTraceDTO> { trace }, TypeColumn.partial) ); } else { columns.Add( CreateColumn(leftColumn, leftColumn, new List <GerberTraceDTO> { trace }, TypeColumn.partial) ); columns.Add( CreateColumn(leftColumn + 1, rightColumn - 1, null, TypeColumn.fill) ); columns.Add( CreateColumn(rightColumn, rightColumn, new List <GerberTraceDTO> { trace }, TypeColumn.partial) ); } AddColumns(layer, rowIndex, columns); } if (aperture.Modifiers.Count == 3) { MakeHole(metaData, trace, aperture, layer); } MergeLayers(metaData.PolarityLayers[layerIndex], layer); }
/// <summary> /// It do metadata processing the draw /// It stablish the top and bottom row affected, wheter haven't affected row return doing nothing /// </summary> /// <param name="metaData">Meta data to update</param> /// <param name="trace">Trace data</param> /// <param name="aperture">Aperture data to draw</param> /// <param name="layerIndex">Layer Index</param> /// <param name="rowFrom">Top row index </param> /// <param name="rowTo">Bottom row index</param> virtual public void Create(GerberMetaDataDTO metaDataBase, GerberMetaDataDTO metaData, GerberTraceDTO trace, GerberApertureDTO aperture, int layerIndex, int rowFrom, int rowTo) { topRow = trace.AbsolutePointEnd.Y + aperture.Modifiers[aperture.Shape == 'R' && aperture.Modifiers.Count > 1 ? 1 : 0] / 2; bottomRow = topRow - aperture.Modifiers[aperture.Shape == 'R' && aperture.Modifiers.Count > 1 ? 1 : 0]; topRow /= metaData.Scale; bottomRow /= metaData.Scale; if (rowFrom < topRow) { topRow = rowFrom; } if (rowTo > bottomRow) { bottomRow = rowTo; } // When top and bottom are inverter means it metadata is unnecesary draw if (topRow < bottomRow) { return; } }
public override void Create(GerberMetaDataDTO metaDataBase, GerberMetaDataDTO metaData, GerberTraceDTO trace, GerberApertureDTO aperture, int layerIndex, int rowFrom, int rowTo) { base.Create(metaDataBase, metaData, trace, aperture, layerIndex, rowFrom, rowTo); var points = MidpointCircle( trace.AbsolutePointEnd.X / metaData.Scale , trace.AbsolutePointEnd.Y / metaData.Scale , aperture.Modifiers[0] / metaData.Scale / 2, topRow, bottomRow); var layer = new PlarityLayerDTO() { IsDarkPolarity = metaData.PolarityLayers[layerIndex].IsDarkPolarity }; ResumePoints(points, layer, trace); if (aperture.Modifiers.Count() == 2) { MakeHole(metaData, trace, aperture, layer); } MergeLayers(metaData.PolarityLayers[layerIndex], layer); }