예제 #1
0
        public void DrawDangerCircle(Graphics g, GraphStyle graphStyle)
        {
            if (!graphStyle.drawCircle)
            {
                return;
            }
            // Draw circle
            int   cellSize = graphStyle.cellSize;
            float xCen     = TransX(centreX, cellSize);
            float yCen     = TransY(centreY, cellSize);

            DrawCircle(g, xCen, yCen, TransScale(radius, cellSize));
            DrawCircle(g, xCen, yCen, 2);
        }
예제 #2
0
        void DrawGrid(Graphics g, GraphStyle graphStyle)
        {
            int cellSize    = graphStyle.cellSize;
            int graphHeight = height * cellSize;
            int graphWidth  = width * cellSize;

            for (int count = 0; count <= width; count += graphStyle.graphLineSpacing)                   // vertical graph lines
            {
                int xPos = count * cellSize + xIndent;
                g.DrawLine(Pens.LightBlue, xPos, yIndent, xPos, graphHeight + yIndent);
            }
            for (int count = 0; count <= height; count += graphStyle.graphLineSpacing)                  // horizontal graph lines
            {
                int yPos = yIndent + graphHeight - (count * cellSize);
                g.DrawLine(Pens.LightBlue, xIndent, yPos, graphWidth + xIndent, yPos);
            }
        }
예제 #3
0
        public void DrawWaterTable(Graphics g, GraphStyle graphStyle)
        {
            if (!graphStyle.drawWaterTable)
            {
                return;
            }

            int            cellSize = graphStyle.cellSize;
            List <LineSeg> lines    = Vectorize(0.0f);
            Pen            p        = new Pen(Color.DarkBlue, 2.0f);

            foreach (LineSeg l in lines)
            {
                l.a.x = TransX(l.a.x, cellSize);
                l.a.y = TransY(l.a.y, cellSize);
                l.b.x = TransX(l.b.x, cellSize);
                l.b.y = TransY(l.b.y, cellSize);
                g.DrawLine(p, l.a.x, l.a.y, l.b.x, l.b.y);
            }
            p.Dispose();
        }
예제 #4
0
        void DrawGraphLines(Graphics g, GraphStyle graphStyle)
        {
            int cellSize = graphStyle.cellSize;
            // draw grid lines
            int graphHeight = height * cellSize;
            int graphWidth  = width * cellSize;

            g.DrawLine(Pens.Gray, 16, yIndent, 16, graphHeight + 32 + 32 - yIndent);
            g.DrawLine(Pens.Gray, xIndent, graphHeight + yIndent + 16, graphWidth + xIndent, graphHeight + yIndent + 16);
            int index = 0;

            for (int count = 0; count < width; count += 10)             // ticks on X axis
            {
                int xPos = count * cellSize + xIndent;
                int yPos = graphHeight + yIndent + 8;
                g.DrawLine(Pens.Gray, xPos, yPos,
                           xPos, graphHeight + yIndent + 24);
                if (cellSize <= 3)
                {
                    int jitter = (index & 1) * 14;
                    DrawString(g, count.ToString(), xPos - 1, yPos + 8 - jitter, Color.Black, "Arial", 8.0f);
                }
                else
                {
                    DrawString(g, count.ToString(), xPos, yPos + 8, Color.Black);
                }
                index++;
            }
            for (int count = 0; count < height; count += 10)                    // ticks along Y axis
            {
                int xPos = 7;
                int yPos = (graphHeight - count * cellSize) + yIndent;
                g.DrawLine(Pens.Gray, xPos, yPos,
                           24, (graphHeight - count * cellSize) + xIndent);
                DrawString(g, count.ToString(), xPos, yPos, Color.Black);
            }
        }
예제 #5
0
        public void DrawSoilType(Graphics g, GraphStyle graphStyle)
        {
            int cellSize    = graphStyle.cellSize;
            int cellSpacing = -1;

            if (graphStyle.spacing)
            {
                cellSpacing = 0;
            }
            DrawStringBold(g, "Soil Type", xIndent, 0, Color.Black);
            Color[] soilPalette = new Color[6];
            soilPalette[0] = Color.FromArgb(220, 195, 110);             // as defined by CHASM_notes1.doc from Liz
            soilPalette[1] = Color.FromArgb(195, 160, 94);
            soilPalette[2] = Color.FromArgb(140, 90, 30);
            soilPalette[3] = Color.FromArgb(88, 29, 0);
            soilPalette[4] = Color.FromArgb(140, 140, 140);
            soilPalette[5] = Color.FromArgb(51, 51, 51);
            //soilPalette[0] = Color.FromArgb(51, 51, 51);	// as defined by CHASM_notes1.doc from Liz
            //soilPalette[1] = Color.FromArgb(140, 140, 140);
            //soilPalette[2] = Color.FromArgb(88, 29, 0);
            //soilPalette[3] = Color.FromArgb(110, 82, 44);
            //soilPalette[4] = Color.FromArgb(150, 111, 60);
            //soilPalette[5] = Color.FromArgb(255, 159, 63);
            if (graphStyle.renderGrid && !graphStyle.gridInFront)
            {
                DrawGrid(g, graphStyle);
            }
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    int soilType = cells[x, y].soilType;
                    if (soilType < 9999)
                    {
                        Brush b = new SolidBrush(soilPalette[soilType]);
                        g.FillRectangle(b, x * cellSize + xIndent, ((height - 1) - y) * cellSize + yIndent,
                                        (cellSize + cellSpacing), (cellSize + cellSpacing));
                    }
                }
            }
            if (graphStyle.renderGrid && graphStyle.gridInFront)
            {
                DrawGrid(g, graphStyle);
            }
            DrawGraphLines(g, graphStyle);
            for (int index = 0; index < 6; index++)
            {
                int   palIndex  = index;
                Brush b         = new SolidBrush(soilPalette[palIndex]);
                int   cellSizeY = Math.Min(cellSize, 4);
                int   yBig      = (int)(height * cellSizeY * 0.1f * 0.75f);
                yBig = Math.Min(yBig, 16);
                int xPos = cellSize * width + 16 + xIndent;
                int yPos = (int)(index * (height * cellSizeY * 0.1f)) + yIndent;
                g.FillRectangle(b, xPos, yPos, yBig, yBig);
                DrawString(g, "soil " + index, xPos + yBig, yPos - yBig / 3, Color.Black, "Courier New", Math.Max(yBig, 6));
            }
            DrawDangerCircle(g, graphStyle);
            DrawWaterTable(g, graphStyle);
            if (Globals.G.selectedGraph == FrameControl.GraphTypeEnum.Soil)
            {
                g.DrawRectangle(Pens.White, TransX(Globals.G.selectedCellX, cellSize),
                                TransY(Globals.G.selectedCellY, cellSize) - cellSize, cellSize, cellSize);
            }
            else
            {
                g.DrawRectangle(Pens.Gray, TransX(Globals.G.selectedCellX, cellSize),
                                TransY(Globals.G.selectedCellY, cellSize) - cellSize, cellSize, cellSize);
            }
        }
예제 #6
0
        public void DrawMoisture(Graphics g, GraphStyle graphStyle)
        {
            int cellSize    = graphStyle.cellSize;
            int cellSpacing = -1;

            if (graphStyle.spacing)
            {
                cellSpacing = 0;
            }
            DrawStringBold(g, "Moisture Content", xIndent, 0, Color.Black);
            if (graphStyle.renderGrid && !graphStyle.gridInFront)
            {
                DrawGrid(g, graphStyle);
            }
            float minMoisture   = float.MaxValue;
            float maxMoisture   = float.MinValue;
            int   rainbowScale  = 3;
            int   rainbowOffset = 80;

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    float moisture = cells[x, y].moisture;
                    if (moisture < 9999)
                    {
                        minMoisture = Math.Min(minMoisture, moisture);
                        maxMoisture = Math.Max(maxMoisture, moisture);
                        int palIndex = (int)((1.0f - moisture) * 255 * rainbowScale + rainbowOffset);                           // this number is arbitrary.
                        palIndex &= 0xff;
                        Brush b = new SolidBrush(Color.FromArgb(palette[palIndex]));
                        g.FillRectangle(b, x * cellSize + xIndent, ((height - 1) - y) * cellSize + yIndent,
                                        cellSize + cellSpacing, cellSize + cellSpacing);
                    }
                }
            }
            if (graphStyle.renderGrid && graphStyle.gridInFront)
            {
                DrawGrid(g, graphStyle);
            }
            DrawGraphLines(g, graphStyle);
            // Draw color legend
            //int index = 0;
            float normalizeMin = minMoisture;
            float normalizeMax = maxMoisture;
            float count        = normalizeMin;

//			for (float count = normalizeMin; count < normalizeMax; count += ((normalizeMax - normalizeMin) / 10.0f))
            for (int index = 0; index <= 10; index++)
            {
                float pressure = count;
                int   palIndex = (int)((1.0f - pressure) * 255 * rainbowScale + rainbowOffset);                 // this number is arbitrary.
                palIndex &= 0xff;
                Brush b         = new SolidBrush(Color.FromArgb(palette[palIndex]));
                int   cellSizeY = Math.Min(cellSize, 4);
                int   yBig      = (int)(height * cellSizeY * 0.1f * 0.75f);
                yBig = Math.Min(yBig, 16);
                int xPos = cellSize * width + 16 + xIndent;
                //int yPos = ((height*cellSize)) - index * 20;
                int yPos = ((height * cellSizeY)) - (int)(index * (height * cellSizeY * 0.1f)) + yIndent - yBig;
                g.FillRectangle(b, xPos, yPos, yBig, yBig);
                //DrawString(g, count.ToString("F4"), xPos + 20, yPos, Color.Black);
                DrawString(g, count.ToString("F4"), xPos + yBig, yPos - yBig / 3, Color.Black, "Courier New", Math.Max(yBig, 6));
                count += ((normalizeMax - normalizeMin) / 10.0f);
//				index++;
            }
            DrawDangerCircle(g, graphStyle);
            DrawWaterTable(g, graphStyle);
            if (Globals.G.selectedGraph == FrameControl.GraphTypeEnum.Moisture)
            {
                g.DrawRectangle(Pens.White, TransX(Globals.G.selectedCellX, cellSize),
                                TransY(Globals.G.selectedCellY, cellSize) - cellSize, cellSize, cellSize);
            }
            else
            {
                g.DrawRectangle(Pens.Gray, TransX(Globals.G.selectedCellX, cellSize),
                                TransY(Globals.G.selectedCellY, cellSize) - cellSize, cellSize, cellSize);
            }
        }
예제 #7
0
        public void DrawPressure(Graphics g, float normalizeMin, float normalizeMax, GraphStyle graphStyle)
        {
            int cellSpacing = -1;

            if (graphStyle.spacing)
            {
                cellSpacing = 0;
            }
            int cellSize = graphStyle.cellSize;

            DrawStringBold(g, "Pore Water Pressure", xIndent, 0, Color.Black);
            if (graphStyle.renderGrid && !graphStyle.gridInFront)
            {
                DrawGrid(g, graphStyle);
            }
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    float pressure = cells[x, y].poreWaterPressure;
                    if (pressure < 9999)
                    {
                        float pressureNorm = (pressure - normalizeMin) / (normalizeMax - normalizeMin);
                        int   palIndex     = (int)(pressureNorm * 255);
                        palIndex = Math.Min(palIndex, 255);
                        palIndex = Math.Max(palIndex, 0);
                        Brush b = new SolidBrush(Color.FromArgb(palette[palIndex]));
                        //if (pressure < 0) b = new SolidBrush(Color.FromArgb(palette[palIndex] | 0x00808080));
                        g.FillRectangle(b, x * cellSize + xIndent,
                                        ((height - 1) - y) * cellSize + yIndent, cellSize + cellSpacing, cellSize + cellSpacing);
                        b.Dispose();
                    }
                }
            }
            if (graphStyle.renderGrid && graphStyle.gridInFront)
            {
                DrawGrid(g, graphStyle);
            }
            DrawGraphLines(g, graphStyle);
            // Draw color legend
            int index = 0;

            for (float count = normalizeMin; count < normalizeMax; count += ((normalizeMax - normalizeMin) / 10.0f))
            {
                float pressure = (count - normalizeMin) / (normalizeMax - normalizeMin);
                int   palIndex = (int)(pressure * 255);
                palIndex = Math.Min(palIndex, 255);
                palIndex = Math.Max(palIndex, 0);
                Brush b         = new SolidBrush(Color.FromArgb(palette[palIndex]));
                int   cellSizeY = Math.Min(cellSize, 4);
                int   yBig      = (int)(height * cellSizeY * 0.1f * 0.75f);
                yBig = Math.Min(yBig, 16);
                int xPos = cellSize * width + 16 + xIndent;
                int yPos = ((height * cellSizeY)) - (int)(index * (height * cellSizeY * 0.1f)) + yIndent - yBig;
                g.FillRectangle(b, xPos, yPos, yBig, yBig);
                DrawString(g, count.ToString("F4"), xPos + yBig, yPos - yBig / 3, Color.Black, "Courier New", Math.Max(yBig, 6));
                index++;
            }
            DrawDangerCircle(g, graphStyle);
            DrawWaterTable(g, graphStyle);
            if (Globals.G.selectedGraph == FrameControl.GraphTypeEnum.Pressure)
            {
                g.DrawRectangle(Pens.White, TransX(Globals.G.selectedCellX, cellSize),
                                TransY(Globals.G.selectedCellY, cellSize) - cellSize, cellSize, cellSize);
            }
            else
            {
                g.DrawRectangle(Pens.Gray, TransX(Globals.G.selectedCellX, cellSize),
                                TransY(Globals.G.selectedCellY, cellSize) - cellSize, cellSize, cellSize);
            }
        }
예제 #8
0
 public void DrawMoisture(Graphics g, GraphStyle graphStyle)
 {
     allHours[currentTime].DrawMoisture(g, graphStyle);
 }
예제 #9
0
 public void DrawPressure(Graphics g, GraphStyle graphStyle)
 {
     allHours[currentTime].DrawPressure(g, normalizeMin, normalizeMax, graphStyle);
 }
예제 #10
0
        public void DrawSoilType(Graphics g, GraphStyle graphStyle)
        {
            GridData currentGrid = allHours[currentTime];

            currentGrid.DrawSoilType(g, graphStyle);
        }