private static PositionsProvider InitProvider(ref PositionsProvider positionsProvider, BGCcVisualizationLineRenderer cc) { //assign positions provider if needed var mode = cc.splitMode; if (positionsProvider == null || !positionsProvider.Comply(mode)) { switch (mode) { case SplitModeEnum.PartsTotal: positionsProvider = new PositionsProviderTotalParts(); break; case SplitModeEnum.PartsPerSection: positionsProvider = new PositionsProviderPartsPerSection(); break; default: // case SplitModeEnum.UseMathData: positionsProvider = new PositionsProviderMath(); break; } } //init provider positionsProvider.Init(cc); return(positionsProvider); }
//init required provider. Each mode has it's own provider private static PositionsProvider InitProvider(ref PositionsProvider positionsProvider, BGCcSplitterPolyline cc) { //assign positions provider if needed var mode = cc.splitMode; var providerObsolete = positionsProvider == null || !positionsProvider.Comply(mode); switch (mode) { case SplitModeEnum.PartsTotal: if (providerObsolete) { positionsProvider = new PositionsProviderTotalParts(); } ((PositionsProviderTotalParts)positionsProvider).Init(cc.Math, cc.PartsTotal); break; case SplitModeEnum.PartsPerSection: if (providerObsolete) { positionsProvider = new PositionsProviderPartsPerSection(); } ((PositionsProviderPartsPerSection)positionsProvider).Init(cc.Math, cc.PartsPerSection); break; default: // case SplitModeEnum.UseMathData: if (providerObsolete) { positionsProvider = new PositionsProviderMath(); } ((PositionsProviderMath)positionsProvider).Init(cc.Math); break; } return(positionsProvider); }
//=============================================================================================== // private methods //=============================================================================================== //init required provider. Each mode has it's own provider private PositionsProvider InitProvider(ref PositionsProvider positionsProvider, BGCcMath math, Config config) { //assign positions provider if needed var mode = config.SplitMode; var providerObsolete = positionsProvider == null || !positionsProvider.Comply(mode); switch (mode) { case BGCcSplitterPolyline.SplitModeEnum.PartsTotal: if (providerObsolete) { if (providerTotalParts == null) { providerTotalParts = new PositionsProviderTotalParts(); } positionsProvider = providerTotalParts; } providerTotalParts.Init(math, config.PartsTotal); break; case BGCcSplitterPolyline.SplitModeEnum.PartsPerSection: if (providerObsolete) { if (providerPartsPerSection == null) { providerPartsPerSection = new PositionsProviderPartsPerSection(); } positionsProvider = providerPartsPerSection; } providerPartsPerSection.Init(math, config.PartsPerSection); break; default: // case SplitModeEnum.UseMathData: if (providerObsolete) { if (providerMath == null) { providerMath = new PositionsProviderMath(); } positionsProvider = providerMath; } providerMath.Init(math); break; } if (config.DistanceMin > 0 || config.DistanceMax > 0) { //currently DistanceMin and DistanceMax supported by SplitModeEnum.UseMathData only if (mode != BGCcSplitterPolyline.SplitModeEnum.UseMathData) { throw new Exception("DistanceMin and DistanceMax supported by SplitModeEnum.UseMathData mode only"); } positionsProvider.DistanceMin = config.DistanceMin; positionsProvider.DistanceMax = config.DistanceMax; } return(positionsProvider); }