示例#1
0
        public void Paint(IGraphicsContext3D g, Altaxo.Graph.IPaintContext paintContext, bool bForPreview)
        {
            //_isStructureInSync = false;
            _isMeasureInSync = false; // Change: interpret text every time in order to update plot items and \ID

            if (!_isStructureInSync)
            {
                // this.Interpret(g);
                InterpretText();

                _isStructureInSync = true;
                _isMeasureInSync   = false;
            }

            using (var fontCache = new FontCache())
            {
                if (!_isMeasureInSync)
                {
                    // this.MeasureStructure(g, obj);
                    MeasureGlyphs(g, fontCache, paintContext);

                    MeasureBackground(g, _rootNode.SizeX, _rootNode.SizeY, _rootNode.SizeZ);

                    _isMeasureInSync = true;
                }

                _cachedSymbolPositions.Clear();

                var gs = g.SaveGraphicsState();

                var bounds = Bounds;

                var transformmatrix = Matrix4x3.NewScalingShearingRotationDegreesTranslation(
                    ScaleX, ScaleY, ScaleZ,
                    ShearX, ShearY, ShearZ,
                    RotationX, RotationY, RotationZ,
                    _location.AbsolutePivotPositionX, _location.AbsolutePivotPositionY, _location.AbsolutePivotPositionZ);
                transformmatrix.TranslatePrepend(bounds.X, bounds.Y, bounds.Z);

                if (!bForPreview)
                {
                    TransformGraphics(g);
                    g.TranslateTransform(bounds.X, bounds.Y, bounds.Z);
                }

                // first of all paint the background
                PaintBackground(g);

                var dc = new DrawContext
                {
                    FontCache              = fontCache,
                    bForPreview            = bForPreview,
                    LinkedObject           = Altaxo.Main.AbsoluteDocumentPath.GetRootNodeImplementing <HostLayer>(this),
                    transformMatrix        = transformmatrix,
                    _cachedSymbolPositions = _cachedSymbolPositions
                };
                DrawGlyphs(g, dc, _cachedTextOffset.X, _cachedTextOffset.Y, _cachedTextOffset.Z);
                g.RestoreGraphicsState(gs);
            }
        }
示例#2
0
 /// <summary>
 /// Updates the internal transformation matrix to reflect the settings for position, rotation, scaleX, scaleY and shear. It is designed here by default so that
 /// the local anchor point of the object is located at the world coordinates (0,0). The transformation matrix update can be overridden in derived classes so
 /// that for instance the left upper corner of the object is located at (0,0).
 /// </summary>
 protected virtual void UpdateTransformationMatrix()
 {
     _transformation = Matrix4x3.NewScalingShearingRotationDegreesTranslation(
         ScaleX, ScaleY, ScaleZ,
         ShearX, ShearY, ShearZ,
         RotationX, RotationY, RotationZ,
         _location.AbsolutePivotPositionX, _location.AbsolutePivotPositionY, _location.AbsolutePivotPositionZ);
 }
示例#3
0
        /// <summary>
        /// Gets the absolute enclosing rectangle, taking into account ScaleX, ScaleY, Rotation and Shear (SSRS).
        /// </summary>
        /// <returns>The enclosing rectangle in absolute values.</returns>
        public RectangleD3D GetAbsoluteEnclosingRectangle()
        {
            var m = Matrix4x3.NewScalingShearingRotationDegreesTranslation(
                ScaleX, ScaleY, ScaleZ,
                ShearX, ShearY, ShearZ,
                RotationX, RotationY, RotationZ,
                AbsolutePivotPositionX, AbsolutePivotPositionY, AbsolutePivotPositionZ);

            m.TranslatePrepend(AbsoluteVectorPivotToLeftUpper.X, AbsoluteVectorPivotToLeftUpper.Y, AbsoluteVectorPivotToLeftUpper.Z);

            var r = new RectangleD3D(PointD3D.Empty, AbsoluteSize);

            return(RectangleD3D.NewRectangleIncludingAllPoints(r.Vertices.Select(p => m.Transform(p))));
        }
示例#4
0
 /// <summary>
 /// Transforms the graphics context is such a way, that the object can be drawn in local coordinates.
 /// </summary>
 /// <param name="g">Graphics context (should be saved beforehand).</param>
 protected virtual void TransformGraphics(IGraphicsContext3D g)
 {
     if (RotationX != 0 || RotationY != 0 || RotationZ != 0 || ScaleX != 1 || ScaleY != 1 || ScaleZ != 1 || ShearX != 0 || ShearY != 0 || ShearZ != 0)
     {
         g.PrependTransform(Matrix4x3.NewScalingShearingRotationDegreesTranslation(
                                _location.ScaleX, _location.ScaleY, _location.ScaleY
                                ,
                                _location.ShearX, _location.ShearY, _location.ShearZ,
                                _location.RotationX, _location.RotationY, _location.RotationZ,
                                _location.AbsolutePivotPosition.X, _location.AbsolutePivotPositionY, _location.AbsolutePivotPositionZ));
     }
     else
     {
         var p = _location.AbsolutePivotPosition;
         g.TranslateTransform(p.X, p.Y, p.Z);
     }
 }
示例#5
0
        /// <summary>
        /// Gets the object outline for arrangements.
        /// </summary>
        /// <param name="localToWorldTransformation">The local to world transformation.</param>
        /// <returns></returns>
        public override IObjectOutlineForArrangements GetObjectOutlineForArrangements(Matrix4x3 localToWorldTransformation)
        {
            var bounds = Bounds;

            double sx = Bounds.SizeX / 2;
            double sy = Bounds.SizeY / 2;
            double sz = Bounds.SizeZ / 2;

            var dx = Bounds.X + sx;
            var dy = Bounds.Y + sy;
            var dz = Bounds.Z + sz;

            var transformation = Matrix4x3.NewScalingShearingRotationDegreesTranslation(sx, sy, sz, 0, 0, 0, 0, 0, 0, dx, dy, dz); // represents a transformation from a unit sphere to the real sphere

            transformation.AppendTransform(_transformation);                                                                       // additional transformations of the ellipsoid
            transformation.AppendTransform(localToWorldTransformation);                                                            // local to global transformation

            return(new SphericalObjectOutline(transformation));
        }
示例#6
0
        public override void Paint(IGraphicsContext3D g, IPaintContext context)
        {
            var buffers = g.GetPositionNormalIndexedTriangleBuffer(_material);

            if (null != buffers.PositionNormalIndexedTriangleBuffer)
            {
                var buffer = buffers.PositionNormalIndexedTriangleBuffer;

                var offs = buffer.VertexCount;

                var sphere = new SolidIcoSphere(3); // gives a sphere with radius = 1

                var bounds = Bounds;

                double sx = Bounds.SizeX / 2;
                double sy = Bounds.SizeY / 2;
                double sz = Bounds.SizeZ / 2;

                var dx = Bounds.X + sx;
                var dy = Bounds.Y + sy;
                var dz = Bounds.Z + sz;

                var transformation = Matrix4x3.NewScalingShearingRotationDegreesTranslation(sx, sy, sz, 0, 0, 0, 0, 0, 0, dx, dy, dz);
                transformation.AppendTransform(_transformation);

                var normalTransform = transformation.GetTransposedInverseMatrix3x3();

                foreach (var entry in sphere.VerticesAndNormalsForSphere)
                {
                    var pt = transformation.Transform(entry.Item1);
                    var nm = normalTransform.Transform(entry.Item2).Normalized;
                    buffer.AddTriangleVertex(pt.X, pt.Y, pt.Z, nm.X, nm.Y, nm.Z);
                }
                foreach (var idx in sphere.TriangleIndicesForSphere)
                {
                    buffer.AddTriangleIndices(idx.Item1 + offs, idx.Item2 + offs, idx.Item3 + offs);
                }
            }
        }