コード例 #1
0
        /// <summary>
        /// Calculate the dimension reference points.
        /// </summary>
        protected override void CalculteReferencePoints()
        {
            DimensionStyleOverride styleOverride;

            double  measure     = this.Measurement;
            Vector2 ref1        = this.firstRefPoint;
            Vector2 ref2        = this.secondRefPoint;
            Vector2 midRef      = Vector2.MidPoint(ref1, ref2);
            double  dimRotation = this.Rotation * MathHelper.DegToRad;

            Vector2 vec        = Vector2.Normalize(Vector2.Rotate(Vector2.UnitY, dimRotation));
            Vector2 midDimLine = midRef + this.offset * vec;
            double  cross      = Vector2.CrossProduct(ref2 - ref1, vec);

            if (cross < 0)
            {
                this.firstRefPoint  = ref2;
                this.secondRefPoint = ref1;
            }
            this.defPoint = midDimLine - measure * 0.5 * Vector2.Perpendicular(vec);

            if (this.TextPositionManuallySet)
            {
                DimensionStyleFitTextMove moveText = this.Style.FitTextMove;
                if (this.StyleOverrides.TryGetValue(DimensionStyleOverrideType.FitTextMove, out styleOverride))
                {
                    moveText = (DimensionStyleFitTextMove)styleOverride.Value;
                }

                if (moveText == DimensionStyleFitTextMove.BesideDimLine)
                {
                    this.SetDimensionLinePosition(this.textRefPoint);
                }
            }
            else
            {
                double textGap = this.Style.TextOffset;
                if (this.StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextOffset, out styleOverride))
                {
                    textGap = (double)styleOverride.Value;
                }
                double scale = this.Style.DimScaleOverall;
                if (this.StyleOverrides.TryGetValue(DimensionStyleOverrideType.DimScaleOverall, out styleOverride))
                {
                    scale = (double)styleOverride.Value;
                }

                double gap = textGap * scale;
                if (dimRotation > MathHelper.HalfPI && dimRotation <= MathHelper.ThreeHalfPI)
                {
                    gap = -gap;
                }

                this.textRefPoint = midDimLine + gap * vec;
            }
        }
コード例 #2
0
        /// <summary>
        /// Calculate the dimension reference points.
        /// </summary>
        protected override void CalculteReferencePoints()
        {
            Vector2 dir1 = this.endFirstLine - this.startFirstLine;
            Vector2 dir2 = this.endSecondLine - this.startSecondLine;

            if (Vector2.AreParallel(dir1, dir2))
            {
                throw new ArgumentException("The two lines that define the dimension are parallel.");
            }

            DimensionStyleOverride styleOverride;

            double  measure = this.Measurement * MathHelper.DegToRad;
            Vector2 center  = this.CenterPoint;

            double  startAngle = Vector2.Angle(center, this.endFirstLine);
            double  midRot     = startAngle + measure * 0.5;
            Vector2 midDim     = Vector2.Polar(center, this.offset, midRot);

            this.defPoint           = this.endSecondLine;
            this.arcDefinitionPoint = midDim;

            if (this.TextPositionManuallySet)
            {
                DimensionStyleFitTextMove moveText = this.Style.FitTextMove;
                if (this.StyleOverrides.TryGetValue(DimensionStyleOverrideType.FitTextMove, out styleOverride))
                {
                    moveText = (DimensionStyleFitTextMove)styleOverride.Value;
                }

                if (moveText == DimensionStyleFitTextMove.BesideDimLine)
                {
                    this.SetDimensionLinePosition(this.textRefPoint, false);
                }
            }
            else
            {
                double textGap = this.Style.TextOffset;
                if (this.StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextOffset, out styleOverride))
                {
                    textGap = (double)styleOverride.Value;
                }
                double scale = this.Style.DimScaleOverall;
                if (this.StyleOverrides.TryGetValue(DimensionStyleOverrideType.DimScaleOverall, out styleOverride))
                {
                    scale = (double)styleOverride.Value;
                }

                double gap = textGap * scale;
                this.textRefPoint = midDim + gap * Vector2.Normalize(midDim - center);
            }
        }
コード例 #3
0
ファイル: AlignedDimension.cs プロジェクト: yiidot/netDxf
        /// <summary>
        /// Calculate the dimension reference points.
        /// </summary>
        protected override void CalculteReferencePoints()
        {
            DimensionStyleOverride styleOverride;

            Vector2 ref1    = this.FirstReferencePoint;
            Vector2 ref2    = this.SecondReferencePoint;
            Vector2 dirRef  = ref2 - ref1;
            Vector2 dirDesp = Vector2.Normalize(Vector2.Perpendicular(dirRef));
            Vector2 vec     = this.offset * dirDesp;
            Vector2 dimRef1 = ref1 + vec;
            Vector2 dimRef2 = ref2 + vec;

            this.defPoint = dimRef2;

            if (this.TextPositionManuallySet)
            {
                DimensionStyleFitTextMove moveText = this.Style.FitTextMove;
                if (this.StyleOverrides.TryGetValue(DimensionStyleOverrideType.FitTextMove, out styleOverride))
                {
                    moveText = (DimensionStyleFitTextMove)styleOverride.Value;
                }

                if (moveText == DimensionStyleFitTextMove.BesideDimLine)
                {
                    this.SetDimensionLinePosition(this.textRefPoint);
                }
            }
            else
            {
                double textGap = this.Style.TextOffset;
                if (this.StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextOffset, out styleOverride))
                {
                    textGap = (double)styleOverride.Value;
                }
                double scale = this.Style.DimScaleOverall;
                if (this.StyleOverrides.TryGetValue(DimensionStyleOverrideType.DimScaleOverall, out styleOverride))
                {
                    scale = (double)styleOverride.Value;
                }

                double gap = textGap * scale;
                this.textRefPoint = Vector2.MidPoint(dimRef1, dimRef2) + gap * dirDesp;
            }
        }
コード例 #4
0
        /// <summary>
        /// Calculate the dimension reference points.
        /// </summary>
        protected override void CalculteReferencePoints()
        {
            DimensionStyleOverride styleOverride;

            double  measure    = this.Measurement;
            double  startAngle = Vector2.Angle(this.center, this.start);
            double  midRot     = startAngle + measure * MathHelper.DegToRad * 0.5;
            Vector2 midDim     = Vector2.Polar(this.center, this.offset, midRot);

            this.defPoint = midDim;

            if (this.TextPositionManuallySet)
            {
                DimensionStyleFitTextMove moveText = this.Style.FitTextMove;
                if (this.StyleOverrides.TryGetValue(DimensionStyleOverrideType.FitTextMove, out styleOverride))
                {
                    moveText = (DimensionStyleFitTextMove)styleOverride.Value;
                }

                if (moveText == DimensionStyleFitTextMove.BesideDimLine)
                {
                    this.SetDimensionLinePosition(this.textRefPoint, false);
                }
            }
            else
            {
                double textGap = this.Style.TextOffset;
                if (this.StyleOverrides.TryGetValue(DimensionStyleOverrideType.TextOffset, out styleOverride))
                {
                    textGap = (double)styleOverride.Value;
                }
                double scale = this.Style.DimScaleOverall;
                if (this.StyleOverrides.TryGetValue(DimensionStyleOverrideType.DimScaleOverall, out styleOverride))
                {
                    scale = (double)styleOverride.Value;
                }

                double gap = textGap * scale;
                this.textRefPoint = midDim + gap * Vector2.Normalize(midDim - this.center);
            }
        }
コード例 #5
0
        /// <summary>
        /// Calculate the dimension reference points.
        /// </summary>
        protected override void CalculateReferencePoints()
        {
            if (this.TextPositionManuallySet)
            {
                DimensionStyleFitTextMove moveText = this.Style.FitTextMove;
                DimensionStyleOverride    styleOverride;
                if (this.StyleOverrides.TryGetValue(DimensionStyleOverrideType.FitTextMove, out styleOverride))
                {
                    moveText = (DimensionStyleFitTextMove)styleOverride.Value;
                }

                if (moveText != DimensionStyleFitTextMove.OverDimLineWithoutLeader)
                {
                    this.secondPoint = this.textRefPoint;
                }
            }
            else
            {
                this.textRefPoint = this.secondPoint;
            }
        }
コード例 #6
0
        internal DimensionStyle(string name, bool checkName)
            : base(name, DxfObjectCode.DimStyle, checkName)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name", "The dimension style name should be at least one character long.");
            }

            this.IsReserved = name.Equals(DefaultName, StringComparison.OrdinalIgnoreCase);

            // dimension and extension lines
            this.dimclrd  = AciColor.ByBlock;
            this.dimltype = Linetype.ByBlock;
            this.dimlwd   = Lineweight.ByBlock;
            this.dimdle   = 0.0;
            this.dimdli   = 0.38;
            this.dimsd1   = false;
            this.dimsd2   = false;

            this.dimclre  = AciColor.ByBlock;
            this.dimltex1 = Linetype.ByBlock;
            this.dimltex2 = Linetype.ByBlock;
            this.dimlwe   = Lineweight.ByBlock;
            this.dimse1   = false;
            this.dimse2   = false;
            this.dimexo   = 0.0625;
            this.dimexe   = 0.18;
            this.dimfxlon = false;
            this.dimfxl   = 1.0;

            // symbols and arrows
            this.dimldrblk = null;
            this.dimblk1   = null;
            this.dimblk2   = null;
            this.dimasz    = 0.18;
            this.dimcen    = 0.09;

            // text
            this.dimtxsty        = TextStyle.Default;
            this.dimclrt         = AciColor.ByBlock;
            this.dimtfillclr     = null;
            this.dimtxt          = 0.18;
            this.dimtad          = DimensionStyleTextVerticalPlacement.Centered;
            this.dimjust         = DimensionStyleTextHorizontalPlacement.Centered;
            this.dimgap          = 0.09;
            this.dimtih          = false;
            this.dimtoh          = false;
            this.dimtxtdirection = DimensionStyleTextDirection.LeftToRight;
            this.dimtfac         = 1.0;

            // fit
            this.dimtofl  = false;
            this.dimsoxd  = true;
            this.dimscale = 1.0;
            this.dimatfit = DimensionStyleFitOptions.BestFit;
            this.dimtix   = false;
            this.dimtmove = DimensionStyleFitTextMove.BesideDimLine;

            // primary units
            this.dimdec    = 4;
            this.dimadec   = 0;
            this.dimPrefix = string.Empty;
            this.dimSuffix = string.Empty;
            this.dimdsep   = '.';
            this.dimlfac   = 1.0;
            this.dimaunit  = AngleUnitType.DecimalDegrees;
            this.dimlunit  = LinearUnitType.Decimal;
            this.dimfrac   = FractionFormatType.Horizontal;
            this.suppressLinearLeadingZeros   = false;
            this.suppressLinearTrailingZeros  = false;
            this.suppressZeroFeet             = true;
            this.suppressZeroInches           = true;
            this.suppressAngularLeadingZeros  = false;
            this.suppressAngularTrailingZeros = false;
            this.dimrnd = 0.0;

            // alternate units
            this.alternateUnits = new DimensionStyleAlternateUnits();

            // tolerances
            this.tolerances = new DimensionStyleTolerances();
        }