Пример #1
0
 //
 //**********************************************************************************************
 //
 // Class TPlot
 //   Part of  : TDRFree
 //   Function : Routines and data to draw moisture contents and derived properties of a plot
 //   Author   : Jan G. Wesseling
 //   Date     : April 9th, 2013
 //
 //**********************************************************************************************
 //
 public TPlot(Int32 aId)
 {
     FirstNode = -1;
       LastNode = -1;
       PlotHeight = 0;
       PlotWidth = 0;
       Id = aId;
       Description = "";
       Top = new List<TPoint>();
       Bottom = new List<TPoint>();
       Left = new List<TPoint>();
       Right = new List<TPoint>();
       MoistureDrawing = new TDrawing(Color.Black, Color.White);
       DerivedDrawing = new TDrawing(Color.Black, Color.White);
       Node = new List<TNode>();
       Element = new List<TElement>();
       VirtualNode = new List<TVirtualNode>();
       NumberOfNodes = -1;
       DerivationLimits = new List<TDerivationLimits>();
       ValuesForDerivation = new List<Double>();
 }
Пример #2
0
 //
 //**********************************************************************************************
 //
 // Class TLegend
 //   Part of  : TDRFree
 //   Function : Contains the legend of the contourplots
 //   Author   : Jan G. Wesseling
 //   Date     : April 9th, 2013
 //
 //**********************************************************************************************
 //
 public TLegend(Color aBackColor, Color aForeColor)
 {
     BackgroundColor = aBackColor;
       ForegroundColor = aForeColor;
       Drawing = new TDrawing(aBackColor, aForeColor);
 }
Пример #3
0
        //
        //**********************************************************************************************
        //
        public Boolean InitializeControl(System.Windows.Forms.PictureBox aPicture,
                    System.Windows.Forms.RichTextBox aLog,
                    System.Windows.Forms.ProgressBar aTimeBar,
                    System.Windows.Forms.ProgressBar aPointBar,
                    System.Windows.Forms.Button aBackgroundButton,
                    System.Windows.Forms.Button aTextButton,
                    System.Windows.Forms.Button aPrecipitationButton,
                    System.Windows.Forms.Button aIrrigationButton,
                    String aFile,
                    String aPrecipitationFile,
                    Boolean aIrrigationRequired,
                    String aIrrigationFile,
                    String aPPTFile,
                    Boolean aPPTRequired,
                    String aOutputDir,
                    Steema.TeeChart.TChart achrtPrec1)
        {
            Boolean success = false;
              if (!Directory.Exists(aOutputDir))
              {
            if (MessageBox.Show("Output dir " + aOutputDir + " does not exist. Create it?", "Error", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
              Directory.CreateDirectory(aOutputDir);
            }
              }
              if (Directory.Exists(aOutputDir))
              {
            try
            {
              Running = false;
              brTimes = aTimeBar;
              PrecipitationFile = aPrecipitationFile;
              brPoints = aPointBar;
              LogBox = aLog;
              OutputDir = aOutputDir;
              LogBox.Clear();
              LogBox.AppendText("Started at " + DateTime.Now.ToString() + "\n");
              Top = new List<TPoint>();
              Bottom = new List<TPoint>();
              Left = new List<TPoint>();
              Right = new List<TPoint>();
              IrrigationRequired = aIrrigationRequired;
              IrrigationFile = aIrrigationFile;
              PPTFile = aPPTFile;
              PPTRequired = aPPTRequired;
              chrtPrec1 = achrtPrec1;
              PlotToShow = new List<TPlotToShow>();

              if (PPTRequired)
              {
            PPT = new TPPT();
              }

              DataManager.SaveToIniFile(aFile, aPrecipitationFile, aIrrigationFile, aOutputDir, aIrrigationRequired, aPPTRequired, aPPTFile);
              DataManager.ReadExcelFile(aFile);

              if (DataManager.ExcelIsAvailable)
              {

            SetDateFormat();

            TotalBitmap = new Bitmap(800, 600);
            //        TotalBitmap.SetResolution(300, 300);
            DataManager.ReadContourSheet(Top, Right, Bottom, Left);
            MyDrawing = new TDrawing(BackgroundColor, TextColor);
            //      MyDrawing.DrawContours(Top, Right, Bottom, Left);
            MyGraph = Graphics.FromImage(TotalBitmap);

            Int32 NumberOfPlots = DataManager.ReadNumberOfPlots();

            AssignmentMethod = DataManager.ReadAssignmentMethod();

            Plot = new List<TPlot>();
            for (Int32 i = 0; i < NumberOfPlots; i++)
            {
              TPlot MyPlot = new TPlot(i);
              MyPlot.AddBoundaries(Top, Bottom, Left, Right);
              MyPlot.AssignmentMethod = AssignmentMethod;

              Plot.Add(MyPlot);
            }

            DataManager.ReadPlotDescription(Plot);
            DataManager.ReadVisualization(PlotToShow);

            DistributePlots();

            for (Int32 i = 0; i < NumberOfPlots; i++)
            {
              DataManager.ReadNodes(Plot[i].Node, i);
              DataManager.ReadElements(Plot[i].Node, Plot[i].Element, i);
              DataManager.ReadVirtualNodes(Plot[i].VirtualNode, i);
            }

            foreach (TPlotToShow MyPlot in PlotToShow)
            {
              Plot[MyPlot.PlotId].PrepareAndDrawGrid(MyPlot.ItemToVisualize);
            }

            DefineFirstAndLastNode();

            CreateTotalBitmap(false);

            SaveGraph(OutputDir, -100);

            MoistureClass = new List<TMoistureClass>();
            DerivedClass = new List<TDerivedClass>();
            DataManager.ReadDerivativeTables(Plot);
            DataManager.ReadMoistureClasses(MoistureClass, DerivedClass);

            MyMoistureLegend = new TLegend(Color.Black, Color.White);
            MyMoistureLegend.SetDrawingArea(800, 600);
            MyMoistureLegend.DrawLegend(MoistureClass);

            MyDerivedLegend = new TLegend(Color.Black, Color.White);
            MyDerivedLegend.SetDrawingArea(800, 600);
            MyDerivedLegend.DrawDerivedLegend(DerivedClass);

            String FileName = SaveGraph(OutputDir, -10);
            if (PPTRequired)
            {
              PPT.AddPictureToSlide(FileName);
            }
            FileName = SaveGraph(OutputDir, -11);
            if (PPTRequired)
            {
              PPT.AddPictureToSlide(FileName);
            }

            MoistureContent = DataManager.ReadMoistureContents();

            FindFirstAndLastDay();

            PrecipitationInterval = DataManager.ReadPInterval();

            ReadColors(aBackgroundButton, aTextButton, aPrecipitationButton, aIrrigationButton);

            DataManager.CloseExcelFile();

            Precipitation = DataManager.ReadPrecipitation(PrecipitationFile, FirstDay, LastDay);
            if (IrrigationRequired)
            {
              Irrigation = DataManager.ReadIrrigation(IrrigationFile);
            }

            DataManager.QuitExcel();

            chrtPrec2 = new Steema.TeeChart.TChart();

            // precipitation
            Steema.TeeChart.Styles.Bar NewSeries = new Steema.TeeChart.Styles.Bar();
            NewSeries.XValues.DateTime = true;
            NewSeries.Color = PrecipitationColor;
            NewSeries.Marks.Visible = false;
            NewSeries.Pen.Visible = false;
            chrtPrec2.Series.Add(NewSeries);

            // irrigation
            NewSeries = new Steema.TeeChart.Styles.Bar();
            NewSeries.XValues.DateTime = true;
            NewSeries.Color = IrrigationColor;
            NewSeries.Marks.Visible = false;
            NewSeries.Pen.Visible = false;
            chrtPrec2.Series.Add(NewSeries);

            // line
            Steema.TeeChart.Styles.Line Line = new Steema.TeeChart.Styles.Line();
            Line.Color = Color.Red;
            Line.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Right;
            Line.XValues.DateTime = true;
            chrtPrec2.Axes.Right.Automatic = false;
            chrtPrec2.Axes.Right.Minimum = 0.0;
            chrtPrec2.Axes.Right.Maximum = 1.0;
            chrtPrec2.Axes.Right.Visible = false;
            chrtPrec2.Series.Add(Line);

            // clear
            chrtPrec1.Series[0].Clear();
            chrtPrec1.Series[1].Clear();
            chrtPrec1.Series[2].Clear();
            chrtPrec2.Series[0].Clear();
            chrtPrec2.Series[1].Clear();
            chrtPrec2.Series[2].Clear();

            ShowPrecipitation(1);
            ShowPrecipitation(2);

            //      MyDrawing.SaveGraph(OutputDir, -1);
              }
              LogBox.AppendText(@"Data read at " + DateTime.Now.ToString());
              success = true;
            }
            catch (Exception e)
            {
              String ErrorMessage = @"Error in input data : " + e.Message;
              MessageBox.Show(ErrorMessage);
              LogBox.AppendText(ErrorMessage);
            }
              }
              return success;
        }