예제 #1
0
파일: Model1.cs 프로젝트: ming91915/SDSS
        public override StationGeometry GetStationGeometry()
        {
            SoilFrameGeometry sfg = null;

            if (Frame != null)
            {
                sfg = new SoilFrameGeometry(
                    soilWidth: Frame.SpanWidths.Sum() * 3.0f,
                    soilHeight: SoilLayers.Select(r => r.Top - r.Bottom).ToArray(),
                    overlyingSoilHeight: MethodProperty.OverLayingSoilHeight,
                    stationFloors: Frame.LayerHeights.Select(r => (float)r).Reverse().ToArray(),
                    stationSegments: Frame.SpanWidths.Select(r => (float)r).ToArray());
            }

            // ssg = new SoilFrameGeometry(60, new float[] { 3, 6, 5, 4, 6, 6 }, 3, new float[] { 3, 3, 3 }, new float[] { 6, 6 });
            return(sfg);
        }
예제 #2
0
        //画图
        public void DrawSoilFrameModel(SoilFrameGeometry sfg, Graphics g = null)
        {
            g = g ?? CreateGraphics();
            g.Clear(BackColor);
            //
            float  soilHeight = 0;
            double rx, ry, r;

            soilHeight = sfg.SoilHeight.Sum();
            if (this.Width != 0 && this.Height != 0 && sfg.SoilWidth > 0)
            {
                rx = (float)this.Width / sfg.SoilWidth;
                ry = (float)this.Height / soilHeight;
                r  = Math.Min(rx, ry); // r 值越小,则模型缩得越多
            }
            else
            {
                r = 10;
            }

            modelScale = (float)(r * 0.8);

            float translatex = (this.Width - sfg.SoilWidth * modelScale) / 2;
            float translatey = (this.Height - soilHeight * modelScale) / 2;

            //图形平移
            g.TranslateTransform(translatex, translatey);
            //图形缩放
            g.ScaleTransform(modelScale, modelScale);

            //结构的整体宽度和高度
            float structureWidth = 0;

            foreach (float i in sfg.StationSegments)
            {
                structureWidth += i;
            }
            float structureHeight = 0;

            foreach (float i in sfg.StationFloors)
            {
                structureHeight += i;
            }
            //结构左上角点的横坐标
            float sLeftUp = sfg.SoilWidth / 2 - structureWidth / 2;

            #region ---    画土层
            Pen soilPen = new Pen(Color.Black, 1);
            var colors  = sdUtils.ClassicalColorsExpand(sfg.SoilHeight.Length);
            for (int i = 0; i < sfg.SoilHeight.Length; i++)
            {
                float[] SoilHeighti = new float[i];
                Array.Copy(sfg.SoilHeight, 0, SoilHeighti, 0, i);
                float soilHeighti = 0;
                foreach (float f in SoilHeighti)
                {
                    soilHeighti += f;
                }
                //g.DrawLine(soilPen, 0, soilHeighti, sfg.SoilWidth, soilHeighti);
                try
                {
                    // SolidBrush soil = new SolidBrush(Color.FromArgb(25 * (int)i + 50, 225 - 25 * (int)i, 25 * (int)i, 225 - 25 * (int)i));
                    SolidBrush soil = new SolidBrush(colors[i]);
                    g.FillRectangle(soil, 0, soilHeighti, sfg.SoilWidth, sfg.SoilHeight[i]);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            #endregion

            #region ---    画结构
            Pen        structurePen1 = new Pen(Color.Black, 2f / modelScale);
            Pen        structurePen2 = new Pen(Color.Black, 1f / modelScale);
            SolidBrush structure     = new SolidBrush(Color.White);
            g.FillRectangle(structure, sLeftUp, sfg.OverlyingSoilHeight, structureWidth, structureHeight);

            RectangleF recStructure = new RectangleF(sLeftUp, sfg.OverlyingSoilHeight, sLeftUp + structureWidth, sfg.OverlyingSoilHeight + structureHeight);
            g.DrawRectangle(structurePen1, sLeftUp, sfg.OverlyingSoilHeight, structureWidth, structureHeight);

            for (int i = 0; i < sfg.StationSegments.Length; i++)
            {
                float[] StationSegmenti = new float[i];
                Array.Copy(sfg.StationSegments, 0, StationSegmenti, 0, i);
                float stationSegmenti = 0;
                foreach (float f in StationSegmenti)
                {
                    stationSegmenti += f;
                }
                g.DrawLine(structurePen2, sLeftUp + stationSegmenti, sfg.OverlyingSoilHeight,
                           sLeftUp + stationSegmenti, sfg.OverlyingSoilHeight + structureHeight);
            }
            for (int i = 0; i < sfg.StationFloors.Length; i++)
            {
                float[] StationFloori = new float[i];
                Array.Copy(sfg.StationFloors, 0, StationFloori, 0, i);
                float stationFloori = 0;
                foreach (float f in StationFloori)
                {
                    stationFloori += f;
                }
                g.DrawLine(structurePen2, sLeftUp, sfg.OverlyingSoilHeight + stationFloori,
                           sLeftUp + structureWidth, sfg.OverlyingSoilHeight + stationFloori);
            }
            #endregion
        }
예제 #3
0
파일: Model2.cs 프로젝트: ming91915/SDSS
        public override StationGeometry GetStationGeometry()
        {
            SoilFrameGeometry ssg = null;

            return(ssg);
        }