Example #1
0
        private void AddDocument(DocumentViewModel documentViewModel)
        {
            GraphDocument document = new GraphDocument(documentViewModel);

            document.Closing += Document_Closing;
            LayoutDocumentPane.Children.Add(document);
        }
Example #2
0
        public AxisLabelStyle(CSAxisSide?labelSide, Altaxo.Main.Properties.IReadOnlyPropertyBag context)
        {
            if (null == context)
            {
                context = PropertyExtensions.GetPropertyContextOfProject();
            }

            _labelSide = labelSide;

            _font = GraphDocument.GetDefaultFont(context);
            var foreColor = GraphDocument.GetDefaultForeColor(context);

            _brush = Materials.GetSolidMaterial(foreColor);

            _automaticRotationShift = true;
            _rotationX        = 90;
            _suppressedLabels = new SuppressedTicks()
            {
                ParentObject = this
            };
            _labelFormatting = new LabelFormatting.NumericLabelFormattingAuto()
            {
                ParentObject = this
            };
        }
Example #3
0
        /// <summary>
        /// Creates a default axis style.
        /// </summary>
        public AxisLineStyle(bool showTicks, CSAxisSide preferredTickSide, Main.Properties.IReadOnlyPropertyBag context)
        {
            double penWidth        = GraphDocument.GetDefaultPenWidth(context);
            double majorTickLength = GraphDocument.GetDefaultMajorTickLength(context);
            var    color           = GraphDocument.GetDefaultForeColor(context);

            _axisPen         = new PenX3D(color, penWidth);
            _majorTickPen    = new PenX3D(color, penWidth);
            _minorTickPen    = new PenX3D(color, penWidth);
            _majorTickLength = majorTickLength;
            _minorTickLength = majorTickLength / 2;

            if (showTicks)
            {
                _showFirstUpMajorTicks    = preferredTickSide == CSAxisSide.FirstUp;
                _showFirstDownMajorTicks  = preferredTickSide == CSAxisSide.FirstDown;
                _showSecondUpMajorTicks   = preferredTickSide == CSAxisSide.SecondUp;
                _showSecondDownMajorTicks = preferredTickSide == CSAxisSide.SecondDown;

                _showFirstUpMinorTicks    = preferredTickSide == CSAxisSide.FirstUp;
                _showFirstDownMinorTicks  = preferredTickSide == CSAxisSide.FirstDown;
                _showSecondUpMinorTicks   = preferredTickSide == CSAxisSide.SecondUp;
                _showSecondDownMinorTicks = preferredTickSide == CSAxisSide.SecondDown;
            }
        }
Example #4
0
        public override void Run(Altaxo.Graph.GUI.GraphController ctrl)
        {
            GraphDocument newDoc = new GraphDocument(ctrl.Doc);

            Current.Project.GraphDocumentCollection.Add(newDoc);
            Current.ProjectService.CreateNewGraph(newDoc);
        }
Example #5
0
        /// <summary>
        /// Saves the graph as an bitmap file and returns the bitmap.
        /// </summary>
        /// <param name="doc">The graph document to export.</param>
        /// <param name="dpiResolution">Resolution of the bitmap in dpi. Determines the pixel size of the bitmap.</param>
        /// <param name="backbrush">Brush used to fill the background of the image. Can be <c>null</c>.</param>
        /// <param name="pixelformat">Specify the pixelformat here.</param>
        /// <returns>The saved bitmap. You should call Dispose when you no longer need the bitmap.</returns>
        public static System.Drawing.Bitmap SaveAsBitmap(GraphDocument doc, int dpiResolution, Brush backbrush, PixelFormat pixelformat)
        {
            double scale = dpiResolution / 72.0;
            // Code to write the stream goes here.

            // round the pixels to multiples of 4, many programs rely on this
            int width  = (int)(4 * Math.Ceiling(0.25 * doc.PageBounds.Width * scale));
            int height = (int)(4 * Math.Ceiling(0.25 * doc.PageBounds.Height * scale));

            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(width, height, pixelformat);
            bitmap.SetResolution(dpiResolution, dpiResolution);

            Graphics grfx = Graphics.FromImage(bitmap);

            if (null != backbrush)
            {
                grfx.FillRectangle(backbrush, new Rectangle(0, 0, width, height));
            }

            grfx.PageUnit = GraphicsUnit.Point;
            grfx.TranslateTransform(doc.PrintableBounds.X, doc.PrintableBounds.Y);
            grfx.PageScale = 1; // (float)scale;


            doc.DoPaint(grfx, true);

            grfx.Dispose();

            return(bitmap);
        }
Example #6
0
        public static void ShowFileExportMetafileDialog(this GraphDocument doc)
        {
            var opt = new GraphExportOptions();

            opt.TrySetImageAndPixelFormat(ImageFormat.Emf, PixelFormat.Format32bppArgb);
            ShowFileExportDialog(doc, opt);
        }
        public static bool IsGraphTemplateSuitable(GraphDocument graphTemplate, out string problemDescription)
        {
            // Make sure that the graph contains an XYPlotLayer

            if (0 == graphTemplate.RootLayer.Layers.Count)
            {
                problemDescription = "The graph does not contain any layers besides the root layer.";
                return(false);
            }

            var xyzlayer = (XYZPlotLayer)TreeNodeExtensions.AnyBetweenHereAndLeaves <HostLayer>(graphTemplate.RootLayer, x => x is XYZPlotLayer);

            if (null == xyzlayer)
            {
                problemDescription = "The graph does not contain any x-y-z plot layer.";
                return(false);
            }

            if (!(xyzlayer.CoordinateSystem is CS.G3DCartesicCoordinateSystem))
            {
                problemDescription = "The first x-y-z plot layer found does not contain a cartesic coordinate system.";
                return(false);
            }

            problemDescription = null;
            return(true);
        }
        /// <summary>
        /// Creates a brand new graph which has an x-y plot layer. The graph is not named, nor is it already part of the project.
        /// </summary>
        /// <param name="propertyContext">The property context. Can be retrieved for instance from the table the plot is initiated or the folder.</param>
        /// <param name="folderName">Name of the folder.</param>
        /// <returns>The created graph.</returns>
        private static GraphDocument CreateBuiltinGraph(IReadOnlyPropertyBag propertyContext, string folderName)
        {
            if (null == propertyContext)
            {
                if (null != folderName)
                {
                    propertyContext = Altaxo.PropertyExtensions.GetPropertyContextOfProjectFolder(folderName);
                }
                else
                {
                    propertyContext = PropertyExtensions.GetPropertyContextOfProject();
                }
            }

            var graph = new GraphDocument();

            TemplateBase.AddStandardPropertiesToGraph(graph, propertyContext);

            // apply the default location from the property in the path
            graph.RootLayer.Location.CopyFrom(propertyContext.GetValue(GraphDocument.PropertyKeyDefaultRootLayerSize));
            var layer = new XYZPlotLayer(graph.RootLayer, new CS.G3DCartesicCoordinateSystem());

            graph.RootLayer.Layers.Add(layer);
            layer.CreateDefaultAxes(propertyContext);
            graph.ViewToRootLayerCenter(new VectorD3D(-1, -2, 1), new VectorD3D(0, 0, 1), 1);

            return(graph);
        }
Example #9
0
        /// <summary>
        /// Creates a default axis style.
        /// </summary>
        public AxisLineStyle(Main.Properties.IReadOnlyPropertyBag context)
        {
            double penWidth        = GraphDocument.GetDefaultPenWidth(context);
            double majorTickLength = GraphDocument.GetDefaultMajorTickLength(context);
            var    color           = GraphDocument.GetDefaultForeColor(context);

            _axisPen = new PenX(color, penWidth)
            {
                ParentObject = this
            };
            _majorTickPen = new PenX(color, penWidth)
            {
                ParentObject = this
            };
            _minorTickPen = new PenX(color, penWidth)
            {
                ParentObject = this
            };
            _majorTickLength         = majorTickLength;
            _minorTickLength         = majorTickLength / 2;
            _showFirstUpMajorTicks   = true; // true if right major ticks should be visible
            _showFirstDownMajorTicks = true; // true if left major ticks should be visible
            _showFirstUpMinorTicks   = true; // true if right minor ticks should be visible
            _showFirstDownMinorTicks = true; // true if left minor ticks should be visible
        }
Example #10
0
        /// <summary>
        /// Saves the graph as an bitmap file into the stream <paramref name="stream"/>.
        /// </summary>
        /// <param name="doc">The graph document to export.</param>
        /// <param name="stream">The stream to save the metafile into.</param>
        /// <param name="dpiResolution">Resolution of the bitmap in dpi. Determines the pixel size of the bitmap.</param>
        /// <param name="imageFormat">The format of the destination image.</param>
        /// <param name="backbrush">Brush used to fill the background of the image. Can be <c>null</c>.</param>
        /// <param name="pixelformat">Specify the pixelformat here.</param>
        public static void SaveAsBitmap(GraphDocument doc, System.IO.Stream stream, int dpiResolution, System.Drawing.Imaging.ImageFormat imageFormat, Brush backbrush, PixelFormat pixelformat)
        {
            System.Drawing.Bitmap bitmap = SaveAsBitmap(doc, dpiResolution, backbrush, pixelformat);

            bitmap.Save(stream, imageFormat);

            bitmap.Dispose();
        }
Example #11
0
 /// <summary>
 /// Saves the graph as an bitmap file into the file <paramref name="filename"/>.
 /// </summary>
 /// <param name="doc">The graph document to export.</param>
 /// <param name="filename">The filename of the file to save the bitmap into.</param>
 /// <param name="dpiResolution">Resolution of the bitmap in dpi. Determines the pixel size of the bitmap.</param>
 /// <param name="imageFormat">The format of the destination image.</param>
 /// <param name="backbrush">Brush used to fill the background of the image. Can be <c>null</c>.</param>
 /// <param name="pixelformat">Specify the pixelformat here.</param>
 public static void SaveAsBitmap(GraphDocument doc, string filename, int dpiResolution, System.Drawing.Imaging.ImageFormat imageFormat, Brush backbrush, PixelFormat pixelformat)
 {
     using (System.IO.Stream str = new System.IO.FileStream(filename, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write, System.IO.FileShare.Read))
     {
         SaveAsBitmap(doc, str, dpiResolution, imageFormat, backbrush, pixelformat);
         str.Close();
     }
 }
Example #12
0
 /// <summary>
 /// Saves the graph as an bitmap file into the file <paramref name="filename"/>.
 /// </summary>
 /// <param name="doc">The graph document to export.</param>
 /// <param name="filename">The filename of the file to save the bitmap into.</param>
 /// <param name="dpiResolution">Resolution of the bitmap in dpi. Determines the pixel size of the bitmap.</param>
 /// <param name="imageFormat">The format of the destination image.</param>
 /// <param name="backbrush">Brush used to fill the background of the image. Can be <c>null</c>.</param>
 /// <param name="pixelformat">Specify the pixelformat here.</param>
 public static void SaveAsBitmap(GraphDocument doc, string filename, int dpiResolution, System.Drawing.Imaging.ImageFormat imageFormat, Brush backbrush, PixelFormat pixelformat)
 {
   using (System.IO.Stream str = new System.IO.FileStream(filename, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write, System.IO.FileShare.Read))
   {
     SaveAsBitmap(doc, str, dpiResolution, imageFormat, backbrush, pixelformat);
     str.Close();
   }
 }
Example #13
0
        public Altaxo.Graph.Gdi.GraphDocument CreateNewGraphDocument()
        {
            GraphDocument doc = new GraphDocument();

            GraphDocumentCollection.Add(doc);

            return(doc);
        }
Example #14
0
        public LinePlotStyle(Altaxo.Main.Properties.IReadOnlyPropertyBag context)
        {
            var penWidth = GraphDocument.GetDefaultPenWidth(context);
            var color    = GraphDocument.GetDefaultPlotColor(context);

            _linePen         = new PenX3D(color, penWidth).WithLineJoin(PenLineJoin.Bevel);
            _connectionStyle = new LineConnectionStyles.StraightConnection();
        }
Example #15
0
        public static void ShowFileExportTiffDialog(this GraphDocument doc)
        {
            var opt = new GraphExportOptions();

            opt.TrySetImageAndPixelFormat(ImageFormat.Tiff, PixelFormat.Format32bppArgb);
            opt.SourceDpiResolution      = 300;
            opt.DestinationDpiResolution = 300;
            ShowFileExportDialog(doc, opt);
        }
Example #16
0
        public override void Run(Graph3DController ctrl)
        {
            var    newDoc      = new GraphDocument(ctrl.Doc);
            string newnamebase = Altaxo.Main.ProjectFolder.CreateFullName(ctrl.Doc.Name, "GRAPH");

            newDoc.Name = Current.Project.GraphDocumentCollection.FindNewItemName(newnamebase);
            Current.Project.Graph3DDocumentCollection.Add(newDoc);
            Current.ProjectService.CreateNewGraph3D(newDoc);
        }
Example #17
0
        public static Metafile GetMetafile(GraphDocument doc)
        {
            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            Metafile mf = SaveAsMetafile(doc, stream, 300);

            stream.Flush();
            stream.Close();
            return(mf);
        }
Example #18
0
        /// <summary>
        /// Creates a new graph, which has an x-y plot layer with an polar coordinate system. The name of the graph will be prepared, so that it is ready to be included in the project. However, it is not already included in the project.
        /// </summary>
        /// <param name="propertyContext">The property context. Can be retrieved for instance from the table the plot is initiated from or the folder.</param>
        /// <param name="preferredGraphName">The name that is preferred for the new graph.</param>
        /// <param name="anyNameInSameFolder">Any name of an item in the same folder. This name is used to determine the destination folder of the graph.</param>
        /// <param name="includeInProject">If <c>true</c>, the graph is also included into the current project.</param>
        /// <returns>The created graph. The graph is already part of the project. (But no view is created for the graph).</returns>
        public static GraphDocument CreateGraph(IReadOnlyPropertyBag propertyContext, string preferredGraphName, string anyNameInSameFolder, bool includeInProject)
        {
            if (null == propertyContext)
            {
                propertyContext = PropertyExtensions.GetPropertyContextOfProject();
            }

            GraphDocument graph;
            var           graphTemplate = propertyContext.GetValue <GraphDocument>(PropertyKeyDefaultTemplate);
            bool          isBuiltinPolarPlotTemplate = object.ReferenceEquals(graphTemplate, Current.PropertyService.BuiltinSettings.GetValue <GraphDocument>(PropertyKeyDefaultTemplate));

            GraphDocument graphTemplateCartesic        = null;
            bool          isLineScatterTemplateBuiltin = false;

            if (isBuiltinPolarPlotTemplate)
            {
                graphTemplateCartesic        = propertyContext.GetValue <GraphDocument>(TemplateWithXYPlotLayerWithG2DCartesicCoordinateSystem.PropertyKeyDefaultTemplate);
                isLineScatterTemplateBuiltin = object.ReferenceEquals(graphTemplateCartesic, Current.PropertyService.BuiltinSettings.GetValue <GraphDocument>(TemplateWithXYPlotLayerWithG2DCartesicCoordinateSystem.PropertyKeyDefaultTemplate));
            }

            if (!isLineScatterTemplateBuiltin && isBuiltinPolarPlotTemplate)
            {
                graph = (GraphDocument)graphTemplateCartesic.Clone();
                // because we use the template with cartesic coordinate system here, we have to replace it by a polar coordinate systen
                var layer = graph.RootLayer.Layers.OfType <XYPlotLayer>().First();

                layer.CoordinateSystem = new CS.G2DPolarCoordinateSystem();
                layer.AxisStyles.Clear();
                layer.CreateDefaultAxes(graph.GetPropertyContext());
            }
            else if (!isBuiltinPolarPlotTemplate)
            {
                graph = (GraphDocument)graphTemplate.Clone();
            }
            else
            {
                graph = CreateBuiltinGraph(null);
            }

            if (string.IsNullOrEmpty(preferredGraphName))
            {
                string newnamebase = Altaxo.Main.ProjectFolder.CreateFullName(anyNameInSameFolder, "GRAPH");
                graph.Name = Current.Project.GraphDocumentCollection.FindNewItemName(newnamebase);
            }
            else
            {
                graph.Name = preferredGraphName;
            }

            if (includeInProject)
            {
                Current.Project.GraphDocumentCollection.Add(graph);
            }

            return(graph);
        }
Example #19
0
        /// <summary>
        /// Saves the graph as an bitmap file into the file <paramref name="filename"/>.
        /// </summary>
        /// <param name="doc">The graph document to export.</param>
        /// <param name="filename">The filename of the file to save the bitmap into.</param>
        /// <param name="dpiResolution">Resolution of the bitmap in dpi. Determines the pixel size of the bitmap.</param>
        /// <param name="backbrush">Brush used to fill the background of the image. Can be <c>null</c>.</param>
        /// <param name="pixelformat">Specify the pixelformat here.</param>
        public static Metafile SaveAsMetafile(GraphDocument doc, string filename, int dpiResolution, Brush backbrush, PixelFormat pixelformat)
        {
            Metafile mf;

            using (System.IO.Stream str = new System.IO.FileStream(filename, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write, System.IO.FileShare.Read))
            {
                mf = SaveAsMetafile(doc, str, dpiResolution, backbrush, pixelformat);
                str.Close();
            }
            return(mf);
        }
Example #20
0
        public TextGraphic(Altaxo.Main.Properties.IReadOnlyPropertyBag context)
            : base(new ItemLocationDirectAutoSize())
        {
            if (null == context)
            {
                context = PropertyExtensions.GetPropertyContextOfProject();
            }

            _font      = GraphDocument.GetDefaultFont(context);
            _textBrush = Materials.GetSolidMaterial(GraphDocument.GetDefaultForeColor(context));
        }
Example #21
0
        public ScatterPlotStyle(Altaxo.Main.Properties.IReadOnlyPropertyBag context)
        {
            double penWidth   = GraphDocument.GetDefaultPenWidth(context);
            double symbolSize = GraphDocument.GetDefaultSymbolSize(context);
            var    color      = GraphDocument.GetDefaultPlotColor(context);

            _scatterSymbol    = ScatterSymbolListManager.Instance.BuiltinDefault[0];
            _color            = color;
            _independentColor = false;
            _symbolSize       = symbolSize;
            _skipFreq         = 1;
        }
        public static void ShowRenameDialog(this GraphDocument doc)
        {
            var tvctrl = new Altaxo.Gui.Common.TextValueInputController(doc.Name, "Enter a name for the graph:")
            {
                Validator = new GraphRenameValidator(doc)
            };

            if (Current.Gui.ShowDialog(tvctrl, "Rename graph", false))
            {
                doc.Name = tvctrl.InputText.Trim();
            }
        }
 /// <summary>
 /// This command will rescale all axes in all layers
 /// </summary>
 public static void OnUserRescaledAxes(this GraphDocument doc)
 {
     doc.RootLayer.ExecuteFromTopmostChildToRoot(
         (layer) =>
     {
         var xylayer = layer as XYZPlotLayer;
         if (null != xylayer)
         {
             xylayer.OnUserRescaledAxes();
         }
     });
 }
Example #24
0
        public VectorCartesicPlotStyle(Altaxo.Main.Properties.IReadOnlyPropertyBag context)
        {
            var penWidth = GraphDocument.GetDefaultPenWidth(context);
            var color    = GraphDocument.GetDefaultPlotColor(context);

            _lineWidth1Offset = penWidth;
            _lineWidth1Factor = 0;
            _lineWidth2Offset = penWidth;
            _lineWidth2Factor = 0;

            _strokePen = new PenX3D(color, penWidth).WithLineEndCap(new ContourArrow05());
        }
Example #25
0
        public static void ShowMasterCurveCreationDialog(GraphDocument doc)
        {
            string error;
            var    opt = new Data.MasterCurveCreation.Options();

            if (null != (error = FillDataListFromGraphDocument(doc, opt.ColumnGroups)))
            {
                Current.Gui.ErrorMessageBox(error);
                return;
            }

            Current.Gui.ShowDialog(ref opt, "Create master curve", false);
        }
Example #26
0
        public VectorCartesicPlotStyle(Altaxo.Main.Properties.IReadOnlyPropertyBag context)
        {
            var penWidth = GraphDocument.GetDefaultPenWidth(context);
            var color    = GraphDocument.GetDefaultPlotColor(context);

            _lineWidth1Offset = penWidth;
            _lineWidth1Factor = 0;

            ChildSetMember(ref _strokePen, new PenX(color, penWidth)
            {
                EndCap = new LineCaps.ArrowF10LineCap()
            });
        }
Example #27
0
        protected OpenPathShapeBase(ItemLocationDirect location, Altaxo.Main.Properties.IReadOnlyPropertyBag context)
            : base(location)
        {
            if (null == context)
            {
                context = PropertyExtensions.GetPropertyContextOfProject();
            }

            var penWidth  = GraphDocument.GetDefaultPenWidth(context);
            var foreColor = context.GetValue(GraphDocument.PropertyKeyDefaultForeColor);

            Pen = new PenX(foreColor, penWidth);
        }
Example #28
0
        public DropAreaPlotStyle(Altaxo.Main.Properties.IReadOnlyPropertyBag context)
        {
            var penWidth = GraphDocument.GetDefaultPenWidth(context);
            var color    = GraphDocument.GetDefaultPlotColor(context);

            ChildSetMember(ref _framePen, new PenX(NamedColors.Transparent, penWidth)
            {
                LineJoin = LineJoin.Bevel
            });
            _ignoreMissingDataPoints = false;
            ChildSetMember(ref _fillBrush, new BrushX(color));
            _fillDirection   = new CSPlaneID(1, 0);
            _connectionStyle = LineConnectionStyles.StraightConnection.Instance;
        }
        /// <summary>
        /// Deletes the layer specified by index <paramref name="layerNumber"/>.
        /// </summary>
        /// <param name="doc">Graph document.</param>
        /// <param name="layerNumber">Number of the layer to delete.</param>
        /// <param name="withGui">If true, a message box will ask the user for approval.</param>
        public static void DeleteLayer(this GraphDocument doc, IList <int> layerNumber, bool withGui)
        {
            if (!doc.RootLayer.IsValidIndex(layerNumber, out var layer))
            {
                return;
            }

            if (withGui && false == Current.Gui.YesNoMessageBox("This will delete the active layer. Are you sure?", "Attention", false))
            {
                return;
            }

            layer.SiblingLayers.Remove(layer);
        }
Example #30
0
        public static void ShowFileExportSpecificDialog(GraphDocument doc)
        {
            object resopt = _graphExportOptionsToFile;

            if (Current.Gui.ShowDialog(ref resopt, "Choose export options"))
            {
                _graphExportOptionsToFile = (Graph.Gdi.GraphExportOptions)resopt;
            }
            else
            {
                return;
            }
            ShowFileExportDialog(doc, _graphExportOptionsToFile);
        }
 public static void ShowLayerDialog(this GraphDocument doc, IList <int> layerNumber)
 {
     if (doc.RootLayer.IsValidIndex(layerNumber, out var layer))
     {
         if (layer is XYZPlotLayer)
         {
             XYPlotLayerController.ShowDialog((XYZPlotLayer)layer);
         }
         else
         {
             HostLayerController.ShowDialog(layer);
         }
     }
 }
		/// <summary>
		/// Creates a brand new graph which has an x-y plot layer. The graph is not named, nor is it already part of the project.
		/// </summary>
		/// <param name="propertyContext">The property context. Can be retrieved for instance from the table the plot is initiated or the folder.</param>
		/// <returns>The created graph.</returns>
		private static GraphDocument CreateBuiltinGraph(IReadOnlyPropertyBag propertyContext)
		{
			if (null == propertyContext)
				propertyContext = PropertyExtensions.GetPropertyContextOfProject();

			var graph = new GraphDocument();
			TemplateBase.AddStandardPropertiesToGraph(graph, propertyContext);

			// apply the default location from the property in the path
			graph.RootLayer.Location.CopyFrom(propertyContext.GetValue(Altaxo.Graph.Gdi.GraphDocument.PropertyKeyDefaultRootLayerSize));
			Altaxo.Graph.Gdi.XYPlotLayer layer = new Altaxo.Graph.Gdi.XYPlotLayer(graph.RootLayer);
			layer.CreateDefaultAxes(propertyContext);
			layer.AxisStyles[CSLineID.X0].AxisLineStyle.FirstUpMajorTicks = false;
			layer.AxisStyles[CSLineID.X0].AxisLineStyle.FirstUpMinorTicks = false;
			layer.AxisStyles[CSLineID.Y0].AxisLineStyle.FirstUpMajorTicks = false;
			layer.AxisStyles[CSLineID.Y0].AxisLineStyle.FirstUpMinorTicks = false;
			graph.RootLayer.Layers.Add(layer);

			return graph;
		}
		/// <summary>
		/// Creates a brand new graph which has an x-y plot layer. The graph is not named, nor is it already part of the project.
		/// </summary>
		/// <param name="propertyContext">The property context. Can be retrieved for instance from the table the plot is initiated or the folder.</param>
		/// <param name="folderName">Name of the folder.</param>
		/// <returns>The created graph.</returns>
		private static GraphDocument CreateBuiltinGraph(IReadOnlyPropertyBag propertyContext, string folderName)
		{
			if (null == propertyContext)
			{
				if (null != folderName)
					propertyContext = Altaxo.PropertyExtensions.GetPropertyContextOfProjectFolder(folderName);
				else
					propertyContext = PropertyExtensions.GetPropertyContextOfProject();
			}

			var graph = new GraphDocument();
			TemplateBase.AddStandardPropertiesToGraph(graph, propertyContext);

			// apply the default location from the property in the path
			graph.RootLayer.Location.CopyFrom(propertyContext.GetValue(GraphDocument.PropertyKeyDefaultRootLayerSize));
			var layer = new XYZPlotLayer(graph.RootLayer, new CS.G3DCartesicCoordinateSystem());
			graph.RootLayer.Layers.Add(layer);
			layer.CreateDefaultAxes(propertyContext);
			graph.ViewToRootLayerCenter(new VectorD3D(-1, -2, 1), new VectorD3D(0, 0, 1), 1);

			return graph;
		}
Example #34
0
 /// <summary>
 /// Saves the graph as an bitmap file into the file <paramref name="filename"/> using the default
 /// pixel format 32bppArgb.
 /// </summary>
 /// <param name="doc">The graph document to export.</param>
 /// <param name="filename">The filename of the file to save the bitmap into.</param>
 /// <param name="dpiResolution">Resolution of the bitmap in dpi. Determines the pixel size of the bitmap.</param>
 /// <param name="backbrush">Brush used to fill the background of the image. Can be <c>null</c>.</param>
 public static Metafile SaveAsMetafile(GraphDocument doc, string filename, int dpiResolution, Brush backbrush)
 {
   return SaveAsMetafile(doc, filename, dpiResolution, backbrush, PixelFormat.Format32bppArgb);
 }
Example #35
0
 /// <summary>
 /// Saves the graph as an bitmap file into the file <paramref name="filename"/> using the default
 /// pixel format 32bppArgb and no background brush.
 /// </summary>
 /// <param name="doc">The graph document to export.</param>
 /// <param name="filename">The filename of the file to save the bitmap into.</param>
 /// <param name="dpiResolution">Resolution of the bitmap in dpi. Determines the pixel size of the bitmap.</param>
 public static Metafile SaveAsMetafile(GraphDocument doc, string filename, int dpiResolution)
 {
   return SaveAsMetafile(doc, filename, dpiResolution, null);
 }
Example #36
0
 public static Metafile GetMetafile(GraphDocument doc)
 {
   System.IO.MemoryStream stream = new System.IO.MemoryStream();
   Metafile mf = SaveAsMetafile(doc, stream,300);
   stream.Flush();
   stream.Close();
   return mf;
 }
Example #37
0
        /// <summary>
    /// Saves the graph as an bitmap file and returns the bitmap.
    /// </summary>
    /// <param name="doc">The graph document to export.</param>
    /// <param name="dpiResolution">Resolution of the bitmap in dpi. Determines the pixel size of the bitmap.</param>
    /// <param name="backbrush">Brush used to fill the background of the image. Can be <c>null</c>.</param>
    /// <param name="pixelformat">Specify the pixelformat here.</param>
    /// <returns>The saved bitmap. You should call Dispose when you no longer need the bitmap.</returns>
    public static System.Drawing.Bitmap SaveAsBitmap(GraphDocument doc, int dpiResolution, Brush backbrush, PixelFormat pixelformat)
    {
      double scale = dpiResolution / 72.0;
      // Code to write the stream goes here.

      // round the pixels to multiples of 4, many programs rely on this
      int width = (int)(4 * Math.Ceiling(0.25 * doc.PageBounds.Width * scale));
      int height = (int)(4 * Math.Ceiling(0.25 * doc.PageBounds.Height * scale));
      System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(width, height, pixelformat);
      bitmap.SetResolution(dpiResolution, dpiResolution);

      Graphics grfx = Graphics.FromImage(bitmap);
      if (null != backbrush)
        grfx.FillRectangle(backbrush, new Rectangle(0, 0, width, height));

      grfx.PageUnit = GraphicsUnit.Point;
      grfx.TranslateTransform(doc.PrintableBounds.X, doc.PrintableBounds.Y);
      grfx.PageScale = 1; // (float)scale;


      doc.DoPaint(grfx, true);

      grfx.Dispose();

      return bitmap;
    }
Example #38
0
		/// <summary>
		/// Creates a GraphController which shows the <see cref="GraphDocument"/> <paramref name="graphdoc"/>.
		/// </summary>
		/// <param name="graphdoc">The graph which holds the graphical elements.</param>
		protected Graph3DController(GraphDocument graphdoc)
		{
			if (null == graphdoc)
				throw new ArgumentNullException("Leaving the graphdoc null in constructor is not supported here");

			InitTriggerBasedUpdate();
			InternalInitializeGraphDocument(graphdoc); // Using DataTable here wires the event chain also
		}
Example #39
0
		public override void Run(Graph3DController ctrl)
		{
			GraphDocument newDoc = new GraphDocument(ctrl.Doc);
			string newnamebase = Altaxo.Main.ProjectFolder.CreateFullName(ctrl.Doc.Name, "GRAPH");
			newDoc.Name = Current.Project.GraphDocumentCollection.FindNewName(newnamebase);
			Current.Project.Graph3DDocumentCollection.Add(newDoc);
			Current.ProjectService.CreateNewGraph3D(newDoc);
		}
Example #40
0
    /// <summary>
    /// Saves the graph as an enhanced windows metafile into the stream <paramref name="stream"/>.
    /// </summary>
    /// <param name="doc">The graph document used.</param>
    /// <param name="stream">The stream to save the metafile into.</param>
    /// <param name="dpiResolution">Resolution of the bitmap in dpi. Determines the pixel size of the bitmap.</param>
    /// <param name="backbrush">Brush used to fill the background of the image. Can be <c>null</c>.</param>
    /// <param name="pixelformat">The pixel format to use.</param>
    /// <returns>The metafile that was created using the stream.</returns>
    public static Metafile SaveAsMetafile(GraphDocument doc, System.IO.Stream stream, int dpiResolution, Brush backbrush, PixelFormat pixelformat)
    {
      // Create a bitmap just to have a graphics context
      System.Drawing.Bitmap helperbitmap = new System.Drawing.Bitmap(4, 4, pixelformat);
      helperbitmap.SetResolution(dpiResolution, dpiResolution);
      Graphics grfx = Graphics.FromImage(helperbitmap);
      // Code to write the stream goes here.
      IntPtr ipHdc = grfx.GetHdc();
      System.Drawing.Imaging.Metafile mf = new System.Drawing.Imaging.Metafile(stream, ipHdc, doc.PageBounds, MetafileFrameUnit.Point);
      grfx.ReleaseHdc(ipHdc);
      grfx.Dispose();
      grfx = Graphics.FromImage(mf);
      grfx.PageUnit = GraphicsUnit.Point;
      grfx.PageScale = 1;
      grfx.TranslateTransform(doc.PrintableBounds.X, doc.PrintableBounds.Y);

      doc.DoPaint(grfx, true);

      grfx.Dispose();
      helperbitmap.Dispose();
      return mf;
    }
Example #41
0
 /// <summary>
 /// Saves the graph as an bitmap file into the file <paramref name="filename"/> using the default
 /// pixel format 32bppArgb.
 /// </summary>
 /// <param name="doc">The graph document to export.</param>
 /// <param name="filename">The filename of the file to save the bitmap into.</param>
 /// <param name="dpiResolution">Resolution of the bitmap in dpi. Determines the pixel size of the bitmap.</param>
 /// <param name="imageFormat">The format of the destination image.</param>
 /// <param name="backbrush">Brush used to fill the background of the image. Can be <c>null</c>.</param>
 public static void SaveAsBitmap(GraphDocument doc, string filename, int dpiResolution, System.Drawing.Imaging.ImageFormat imageFormat, Brush backbrush)
 {
   SaveAsBitmap(doc, filename, dpiResolution, imageFormat, backbrush, PixelFormat.Format32bppArgb);
 }
		public static void PasteFromClipboardAsTemplateForLayer(GraphDocument doc, IEnumerable<int> layerNumber, GraphCopyOptions options)
		{
			object o = ClipboardSerialization.GetObjectFromClipboard("Altaxo.Graph.Graph3D.GraphLayerAsXml");
			if (null == o)
				return;
			XYZPlotLayer layer = o as XYZPlotLayer;
			if (null != layer)
			{
				doc.RootLayer.ElementAt(layerNumber).CopyFrom(layer, options);
			}
		}
Example #43
0
		public static void ShowFileExportDialog(GraphDocument doc, Altaxo.Graph.Gdi.GraphExportOptions graphExportOptions)
		{
			var saveOptions = new Altaxo.Gui.SaveFileOptions();
			var list = GetFileFilterString(graphExportOptions.ImageFormat);
			foreach (var entry in list)
				saveOptions.AddFilter(entry.Key, entry.Value);
			saveOptions.FilterIndex = 0;
			saveOptions.RestoreDirectory = true;

			if (Current.Gui.ShowSaveFileDialog(saveOptions))
			{
				using (Stream myStream = new FileStream(saveOptions.FileName, FileMode.Create, FileAccess.Write, FileShare.Read))
				{
					new Gui.Graph.Graph3D.Common.D3D10BitmapExporter().ExportAsImageToStream(doc, graphExportOptions, myStream);
					myStream.Close();
				} // end openfile ok
			} // end dlgresult ok
		}
		public static bool IsGraphTemplateSuitable(GraphDocument graphTemplate, out string problemDescription)
		{
			// Make sure that the graph contains an XYPlotLayer

			if (0 == graphTemplate.RootLayer.Layers.Count)
			{
				problemDescription = "The graph does not contain any layers besides the root layer.";
				return false;
			}

			var xyzlayer = (XYZPlotLayer)TreeNodeExtensions.AnyBetweenHereAndLeaves<HostLayer>(graphTemplate.RootLayer, x => x is XYZPlotLayer);

			if (null == xyzlayer)
			{
				problemDescription = "The graph does not contain any x-y-z plot layer.";
				return false;
			}

			if (!(xyzlayer.CoordinateSystem is CS.G3DCartesicCoordinateSystem))
			{
				problemDescription = "The first x-y-z plot layer found does not contain a cartesic coordinate system.";
				return false;
			}

			problemDescription = null;
			return true;
		}
Example #45
0
		/// <summary>
		/// Plots selected data columns of a table.
		/// </summary>
		/// <param name="table">The source table.</param>
		/// <param name="selectedColumns">The data columns of the table that should be plotted.</param>
		/// <param name="graph">The graph document to plot into.</param>
		/// <param name="templatePlotStyle">The plot style which is the template for all plot items.</param>
		/// <param name="groupStyles">The group styles for the newly built plot item collection.</param>
		public static IGraphController Plot(
			DataTable table,
			IAscendingIntegerCollection selectedColumns,
			GraphDocument graph,
			G3DPlotStyleCollection templatePlotStyle,
			PlotGroupStyleCollection groupStyles)
		{
			List<IGPlotItem> pilist = CreatePlotItems(table, selectedColumns, templatePlotStyle);
			// now create a new Graph with this plot associations
			var gc = Current.ProjectService.CreateNewGraph3D(graph);
			var layer = gc.Doc.RootLayer.Layers.OfType<XYZPlotLayer>().First();

			// Set x and y axes according to the first plot item in the list
			if (pilist.Count > 0 && (pilist[0] is XYZColumnPlotItem))
			{
				var firstitem = (XYZColumnPlotItem)pilist[0];
				if (firstitem.Data.XColumn is TextColumn)
					layer.Scales[0] = new TextScale();
				else if (firstitem.Data.XColumn is DateTimeColumn)
					layer.Scales[0] = new DateTimeScale();

				if (firstitem.Data.YColumn is TextColumn)
					layer.Scales[1] = new TextScale();
				else if (firstitem.Data.YColumn is DateTimeColumn)
					layer.Scales[1] = new DateTimeScale();

				if (firstitem.Data.ZColumn is TextColumn)
					layer.Scales[2] = new TextScale();
				else if (firstitem.Data.ZColumn is DateTimeColumn)
					layer.Scales[2] = new DateTimeScale();
			}

			PlotItemCollection newPlotGroup = new PlotItemCollection(layer.PlotItems);
			foreach (IGPlotItem pi in pilist)
			{
				newPlotGroup.Add(pi);
			}
			if (groupStyles != null)
				newPlotGroup.GroupStyles = groupStyles;
			else
				newPlotGroup.CollectStyles(newPlotGroup.GroupStyles);

			layer.PlotItems.Add(newPlotGroup);

			return gc;
		}
Example #46
0
		/// <summary>
		/// Creates a GraphController which shows the <see cref="GraphDocument"/> <paramref name="graphdoc"/>.
		/// </summary>
		/// <param name="graphdoc">The graph which holds the graphical elements.</param>
		public SDGraph3DViewContent(GraphDocument graphdoc)
			: this(graphdoc, false)
		{
		}
Example #47
0
		/// <summary>
		/// Creates a GraphController which shows the <see cref="GraphDocument"/> <paramref name="graphdoc"/>.
		/// </summary>
		/// <param name="graphdoc">The graph which holds the graphical elements.</param>
		/// <param name="bDeserializationConstructor">If true, this is a special constructor used only for deserialization, where no graphdoc needs to be supplied.</param>
		protected SDGraph3DViewContent(GraphDocument graphdoc, bool bDeserializationConstructor)
			: this(new Altaxo.Gui.Graph.Graph3D.Viewing.Graph3DControllerWpf(graphdoc))
		{
		}
Example #48
0
 /// <summary>
 /// Saves the graph as an bitmap file into the file <paramref name="filename"/>.
 /// </summary>
 /// <param name="doc">The graph document to export.</param>
 /// <param name="filename">The filename of the file to save the bitmap into.</param>
 /// <param name="dpiResolution">Resolution of the bitmap in dpi. Determines the pixel size of the bitmap.</param>
 /// <param name="backbrush">Brush used to fill the background of the image. Can be <c>null</c>.</param>
 /// <param name="pixelformat">Specify the pixelformat here.</param>
 public static Metafile SaveAsMetafile(GraphDocument doc, string filename, int dpiResolution,  Brush backbrush, PixelFormat pixelformat)
 {
   Metafile mf;
   using (System.IO.Stream str = new System.IO.FileStream(filename, System.IO.FileMode.CreateNew, System.IO.FileAccess.Write, System.IO.FileShare.Read))
   {
     mf = SaveAsMetafile(doc, str, dpiResolution, backbrush, pixelformat);
     str.Close();
   }
   return mf;
 }
Example #49
0
 /// <summary>
 /// Saves the graph as an bitmap file into the stream using the default pixelformat 32bppArgb.<paramref name="stream"/>.
 /// </summary>
 /// <param name="doc">The graph document to export.</param>
 /// <param name="stream">The stream to save the metafile into.</param>
 /// <param name="dpiResolution">Resolution of the bitmap in dpi. Determines the pixel size of the bitmap.</param>
 /// <param name="backbrush">Brush used to fill the background of the image. Can be <c>null</c>.</param>
 public static Metafile SaveAsMetafile(GraphDocument doc, System.IO.Stream stream, int dpiResolution,  Brush backbrush)
 {
   return SaveAsMetafile(doc, stream, dpiResolution, backbrush, PixelFormat.Format32bppArgb);
 }
Example #50
0
 /// <summary>
 /// Saves the graph as an bitmap file into the stream using the default pixelformat 32bppArgb and no background brush.<paramref name="stream"/>.
 /// </summary>
 /// <param name="doc">The graph document to export.</param>
 /// <param name="stream">The stream to save the metafile into.</param>
 /// <param name="dpiResolution">Resolution of the bitmap in dpi. Determines the pixel size of the bitmap.</param>
 /// <param name="imageFormat">The format of the destination image.</param>
 public static void SaveAsBitmap(GraphDocument doc, System.IO.Stream stream, int dpiResolution, System.Drawing.Imaging.ImageFormat imageFormat)
 {
   SaveAsBitmap(doc, stream, dpiResolution, imageFormat, null, PixelFormat.Format32bppArgb);
 }
Example #51
0
 /// <summary>
 /// Saves the graph as an bitmap file into the file <paramref name="filename"/> using the default
 /// pixel format 32bppArgb and no background brush.
 /// </summary>
 /// <param name="doc">The graph document to export.</param>
 /// <param name="filename">The filename of the file to save the bitmap into.</param>
 /// <param name="dpiResolution">Resolution of the bitmap in dpi. Determines the pixel size of the bitmap.</param>
 /// <param name="imageFormat">The format of the destination image.</param>
 public static void SaveAsBitmap(GraphDocument doc, string filename, int dpiResolution, System.Drawing.Imaging.ImageFormat imageFormat)
 {
   SaveAsBitmap(doc, filename, dpiResolution, imageFormat, null);
 }
Example #52
0
		private void InternalUninitializeGraphDocument()
		{
			// remove the weak event handlers from doc
			var wev = _weakEventHandlersForDoc;
			if (null != wev)
			{
				foreach (var ev in wev)
					ev.Remove();
				_weakEventHandlersForDoc = null;
			}

			_doc = null;
		}
Example #53
0
		public static void ShowFileExportSpecificDialog(GraphDocument doc)
		{
			object resopt = _graphExportOptionsToFile;
			if (Current.Gui.ShowDialog(ref resopt, "Choose export options"))
			{
				_graphExportOptionsToFile = (Graph.Gdi.GraphExportOptions)resopt;
			}
			else
			{
				return;
			}
			ShowFileExportDialog(doc, _graphExportOptionsToFile);
		}
			public GraphRenameValidator(GraphDocument graphdoc)
				: base("The graph's name must not be empty! Please enter a valid name.")
			{
				_doc = graphdoc;
			}
Example #55
0
		public Graph3DControllerWpf(GraphDocument graphdoc)
			: base(graphdoc)
		{
			_mouseState = new GraphControllerMouseHandlers.ObjectPointerMouseHandler(this);
		}
Example #56
0
    /// <summary>
    /// Saves the graph as an bitmap file into the stream <paramref name="stream"/>.
    /// </summary>
    /// <param name="doc">The graph document to export.</param>
    /// <param name="stream">The stream to save the metafile into.</param>
    /// <param name="dpiResolution">Resolution of the bitmap in dpi. Determines the pixel size of the bitmap.</param>
    /// <param name="imageFormat">The format of the destination image.</param>
    /// <param name="backbrush">Brush used to fill the background of the image. Can be <c>null</c>.</param>
    /// <param name="pixelformat">Specify the pixelformat here.</param>
    public static void SaveAsBitmap(GraphDocument doc, System.IO.Stream stream, int dpiResolution, System.Drawing.Imaging.ImageFormat imageFormat, Brush backbrush, PixelFormat pixelformat)
    {
      System.Drawing.Bitmap bitmap = SaveAsBitmap(doc, dpiResolution, backbrush, pixelformat);

      bitmap.Save(stream, imageFormat);

      bitmap.Dispose();
    }
Example #57
0
		private void InternalInitializeGraphDocument(GraphDocument doc)
		{
			if (_doc != null)
				throw new ApplicationException(nameof(_doc) + " is already initialized");
			if (doc == null)
				throw new ArgumentNullException(nameof(doc));

			_doc = doc;

			{
				// we are using weak events here, to avoid that _doc will maintain strong references to the controller
				// Attention: use local variable doc instead of member _doc for the anonymous methods below!
				var rootLayer = doc.RootLayer; // local variable for rootLayer
				_weakEventHandlersForDoc = new WeakEventHandler[3]; // storage for WeakEventhandlers for later removal
				doc.Changed += (_weakEventHandlersForDoc[0] = new WeakEventHandler(this.EhGraph_Changed, x => doc.Changed -= x));
				rootLayer.LayerCollectionChanged += (_weakEventHandlersForDoc[1] = new WeakEventHandler(this.EhGraph_LayerCollectionChanged, x => rootLayer.LayerCollectionChanged -= x));
				doc.SizeChanged += (_weakEventHandlersForDoc[2] = new WeakEventHandler(this.EhGraph_SizeChanged, x => doc.SizeChanged -= x));
			}
			// if the host layer has at least one child, we set the active layer to the first child of the host layer
			if (_doc.RootLayer.Layers.Count >= 1)
				_currentLayerNumber = new List<int>() { 0 };

			// Ensure the current layer and plot numbers are valid
			this.EnsureValidityOfCurrentLayerNumber();
			this.EnsureValidityOfCurrentPlotNumber();

			OnTitleNameChanged(EventArgs.Empty);
		}
Example #58
0
		/// <summary>
		/// Duplicates the Graph and the Graph view to a new one.
		/// </summary>
		/// <param name="sender">Not used.</param>
		/// <param name="e">Not used.</param>
		private void EhMenuGraphDuplicate_OnClick(object sender, System.EventArgs e)
		{
			GraphDocument newDoc = new GraphDocument(this.Doc);
			Current.ProjectService.CreateNewGraph(newDoc);
		}
Example #59
0
		public static void AddStandardPropertiesToGraph(GraphDocument graph, IReadOnlyPropertyBag propertyContext)
		{
			// Set default font property exclusively for the graph
			graph.PropertyBagNotNull.SetValue<FontX3D>(GraphDocument.PropertyKeyDefaultFont, propertyContext.GetValue<FontX3D>(GraphDocument.PropertyKeyDefaultFont));
		}
Example #60
0
		/// <summary>
		/// Gets the hit point on that plane of the active layer rectangle, that is facing the camera.
		/// </summary>
		/// <param name="doc">The graph document containing the active layer.</param>
		/// <param name="activeLayer">The active layer of the graph document.</param>
		/// <param name="hitposition">Hit point in relative screen coordinates. The z-component is the aspect ratio of the screen (y/x).</param>
		/// <param name="hitPointOnPlaneInActiveLayerCoordinates">Output: The hit point on the plane of the active layer that faces the camera. The hit point is returned in active layer coordinates.</param>
		/// <param name="rotationsRadian">The rotation angles that can be used e.g. to orient text so that the text is most readable from the current camera setting. Rotation angle around x is the x-component of the returned vector, and so on.</param>
		/// <exception cref="InvalidProgramException">There should always be a plane of a rectangle that can be hit!</exception>
		public static void GetHitPointOnActiveLayerPlaneFacingTheCamera(GraphDocument doc, HostLayer activeLayer, PointD3D hitposition, out PointD3D hitPointOnPlaneInActiveLayerCoordinates, out VectorD3D rotationsRadian)
		{
			var activeLayerTransformation = activeLayer.TransformationFromRootToHere();
			var camera = doc.Camera;
			var hitData = new HitTestPointData(camera.GetHitRayMatrix(hitposition));
			hitData = hitData.NewFromAdditionalTransformation(activeLayerTransformation); // now hitdata are in layer cos

			var targetToEye = hitData.WorldTransformation.Transform(camera.TargetToEyeVectorNormalized); // targetToEye in layer coordinates
			var upEye = hitData.WorldTransformation.Transform(camera.UpVectorPerpendicularToEyeVectorNormalized); // camera up vector in layer coordinates

			// get the face which has the best dot product between the eye vector of the camera and the plane's normal
			var layerRect = new RectangleD3D(PointD3D.Empty, activeLayer.Size);
			double maxval = double.MinValue;
			PlaneD3D maxPlane = PlaneD3D.Empty;
			foreach (var plane in layerRect.Planes)
			{
				double val = VectorD3D.DotProduct(plane.Normal, targetToEye);
				if (val > maxval)
				{
					maxval = val;
					maxPlane = plane;
				}
			}

			bool isHit = hitData.IsPlaneHitByRay(maxPlane, out hitPointOnPlaneInActiveLayerCoordinates); // hitPointOnPlane is in layer coordinates too

			if (!isHit)
				throw new InvalidProgramException("There should always be a plane of a rectangle that can be hit!");

			VectorD3D zaxis = maxPlane.Normal;
			VectorD3D yaxis = upEye;

			// Find y axis perpendicular to zaxis
			maxval = double.MinValue;
			foreach (var plane in layerRect.Planes)
			{
				double val = VectorD3D.DotProduct(plane.Normal, upEye);
				if (val > maxval && 0 == VectorD3D.DotProduct(plane.Normal, zaxis))
				{
					maxval = val;
					yaxis = plane.Normal;
				}
			}
			var xaxis = VectorD3D.CrossProduct(yaxis, zaxis);

			// now we have all information about the spatial position and orientation of the text:
			// hitPointOnPlane is the position of the text
			// maxPlane.Normal is the face orientation of the text
			// maxUpVector is the up orientation of the text

			double cx, sx, cy, sy, cz, sz;

			sy = xaxis.Z;
			if (1 != Math.Abs(sy))
			{
				cy = Math.Sqrt(1 - sy * sy);
				cz = xaxis.X / cy;
				sz = xaxis.Y / cy;
				sx = yaxis.Z / cy;
				cx = zaxis.Z / cy;
			}
			else // sy is +1, thus cy is zero
			{
				// we set x-rotation to zero, i.e. cx==1 and sx==0
				cy = 0;
				cx = 1;
				sx = 0;
				cz = yaxis.Y;
				sz = -yaxis.X;
			}

			rotationsRadian = new VectorD3D(Math.Atan2(sx, cx), Math.Atan2(sy, cy), Math.Atan2(sz, cz));
		}