Beispiel #1
0
        public static PSObject Save(PSObject self, string path, double width = 800, double height = 600, bool isDocument = false)
        {
            var model = (PlotModel)self.BaseObject;

            ModelExporter.Export(model, path, width, height, isDocument);

            return(AutomationNull.Value);
        }
Beispiel #2
0
        protected override bool OnFinish(BinaryReader source, BinaryWriter destination)
        {
            Model = ModelExporter.Export(_groups, _vertices, _faces, _faceGroups);

            if (!LIB3DS.lib3ds_file_save(Model, destination.BaseStream))
            {
                throw new Exception("Saving 3ds file failed");
            }

            return(true);
        }
Beispiel #3
0
        public static PSObject Save(PSObject self, string path, double width = 800, double height = 600, bool isDocument = false)
        {
            var series = (Series)self.BaseObject;

            var model = new PlotModel();

            model.Series.Add(series);

            ModelExporter.Export(model, path, width, height, isDocument);

            return(AutomationNull.Value);
        }
Beispiel #4
0
        protected void PostProcess(PlotModel model, IList <ISeriesInfo> siList, string outFile, int outWidth, int outHeight, bool svgIsDocument, bool passThru, Style style, bool asPlotView, bool show, bool reuseWindow)
        {
            var bp = MyInvocation.BoundParameters;

            var si = siList != null && siList.Count > 0 ? siList[0] : null;

            // When Ax/Ay parameters are specified, creates axis objects.

            Axis xAxis = null;
            Axis yAxis = null;
            Axis zAxis = null;

            if (si?.Series?.Count > 0)
            {
                xAxis = AxisInitializer.CreateWithPrefixedParameters(bp, AxisKind.Ax, si.Series[0], si, style);
                yAxis = AxisInitializer.CreateWithPrefixedParameters(bp, AxisKind.Ay, si.Series[0], si, style);
                zAxis = AxisInitializer.CreateWithPrefixedParameters(bp, AxisKind.Az, si.Series[0], si, style);
            }

            // Creates a model if necessary.

            if (model == null && (!string.IsNullOrEmpty(outFile) || xAxis != null || yAxis != null || zAxis != null || asPlotView || show))
            {
                model = PlotModelInitializer.Create(siList, style);
            }

            // Returns a SeriesInfo object when a model object is not necessary.

            if (model == null)
            {
                WriteObject(si);
                return;
            }

            // Adds series and axes to a model.

            if (xAxis != null)
            {
                model.Axes.Add(xAxis);
            }

            if (yAxis != null)
            {
                model.Axes.Add(yAxis);
            }

            if (zAxis != null)
            {
                model.Axes.Add(zAxis);
            }

            foreach (var si2 in siList)
            {
                foreach (var s in si2.Series)
                {
                    model.Series.Add(s);

/*
 *                  if (s is XYAxisSeries xy)
 *                  {
 *                      if (xAxis != null)
 *                          xy.XAxisKey = xAxis.Key;
 *
 *                      if (yAxis != null)
 *                          xy.YAxisKey = yAxis.Key;
 *                  }
 */
                    if (s is CandleStickAndVolumeSeries candlev)
                    {
                        if (zAxis != null)
                        {
                            candlev.VolumeAxisKey = zAxis.Key;
                        }
                    }
                    else if (s is HeatMapSeries h)
                    {
                        if (zAxis != null)
                        {
                            h.ColorAxisKey = zAxis.Key;
                        }
                    }
                    else if (s is RectangleSeries r)
                    {
                        if (zAxis != null)
                        {
                            r.ColorAxisKey = zAxis.Key;
                        }
                    }
                }
            }

            // Export a model.

            if (bp.ContainsKey("OutFile"))
            {
                ModelExporter.Export(model, outFile, outWidth, outHeight, svgIsDocument);
            }

            // Show a model in the window;

            if (show)
            {
                var window = CreateWindow(reuseWindow);

                window.Dispatcher.Invoke(() => {
                    window.Content = new OxyPlot.Wpf.PlotView()
                    {
                        Model = model
                    };
                    if (!reuseWindow && string.IsNullOrEmpty(window.Title))
                    {
                        window.Title = MyInvocation.Line;
                    }
                });
            }

            // Return a model.

            if (asPlotView)
            {
                OxyPlot.Wpf.PlotView e = null;
                PlotViewDispatcherHolder.Get().Invoke(() => {
                    e = new OxyPlot.Wpf.PlotView()
                    {
                        Model = model
                    };
                });
                WriteObject(e);
            }
            else
            {
                if (passThru || (!bp.ContainsKey("OutFile") && !show))
                {
                    WriteObject(model);
                }
            }
        }