Пример #1
0
 private void button4_Click(object sender, EventArgs e)
 {
     AutoRescale = false;
     try
     {
         YMax = Double.Parse(textBox2.Text);
     }
     catch (System.FormatException) { textBox2.Text = YMax.ToString("F0"); }
     try
     {
         YMin = Double.Parse(textBox3.Text);
     }
     catch (System.FormatException) { textBox3.Text = YMin.ToString("F0"); }
     try
     {
         XMin = Double.Parse(textBox4.Text);
     }
     catch (System.FormatException) { textBox4.Text = XMin.ToString("F0"); }
     try
     {
         XMax = Double.Parse(textBox5.Text);
     }
     catch (System.FormatException) { textBox5.Text = XMax.ToString("F0"); }
     PlotRescale();
 }
Пример #2
0
        /// <summary>
        /// Map 분석(Harzard와 맵크기를 찾아냄)
        /// </summary>
        private void MapAnalysis()
        {
            XMax      = map.Size.Width;
            YMax      = map.Size.Height;
            HazardCnt = 0;

            for (int x = 0; x < XMax; x++)
            {
                for (int y = 0; y < YMax; y++)
                {
                    // y가 0베이스
                    Color col = map.GetPixel(x, YMax - y - 1);
                    if (col.R > 240 &&
                        col.G < 60 &&
                        col.B < 60)
                    {
                        HazardCnt++;
                        LoadedHazardList.Add(new Spot(x, y));
                    }

                    else if (col.G > 240 &&
                             col.R < 60 &&
                             col.B < 60)
                    {
                        SearchCnt++;
                        LoadedSearchSpotList.Add(new Spot(x, y));
                    }
                }
            }

            HazardTBox.Text = HazardCnt.ToString();
            SearchTBox.Text = SearchCnt.ToString();
            XTbox.Text      = XMax.ToString();
            YTBox.Text      = YMax.ToString();
        }
Пример #3
0
    // Start is called before the first frame update
    void Start()
    {
        Camera myCamera = Camera.main;

        XMin = myCamera.ViewportToWorldPoint(new Vector3(0, 0, 0)).x + padding;
        Debug.Log("XMin: " + XMin.ToString());
        XMax = myCamera.ViewportToWorldPoint(new Vector3(1, 0, 0)).x - padding;
        Debug.Log("XMax: " + XMax.ToString());
        YMin = myCamera.ViewportToWorldPoint(new Vector3(0, 0, 0)).y + padding;
        Debug.Log("YMin: " + YMin.ToString());
        YMax = myCamera.ViewportToWorldPoint(new Vector3(0, 1, 0)).y - padding;
        Debug.Log("YMax: " + YMax.ToString());

        // myCirclePrefab = (GameObject)Resources.Load("Circle");
        Instantiate(myCirclePrefab, new Vector3(XMin, YMin, 0), Quaternion.identity);
        Instantiate(myCirclePrefab, new Vector3(XMin, YMax, 0), Quaternion.identity);
        Instantiate(myCirclePrefab, new Vector3(XMax, YMin, 0), Quaternion.identity);
        Instantiate(myCirclePrefab, new Vector3(XMax, YMax, 0), Quaternion.identity);
    }
Пример #4
0
    // Start is called before the first frame update
    void Start()
    {
        Camera gameCamera = Camera.main;

        XMin = gameCamera.ViewportToWorldPoint(new Vector3(0, 0, 0)).x + padding;
        Debug.Log("XMin: " + XMin.ToString());
        XMax = gameCamera.ViewportToWorldPoint(new Vector3(1, 0, 0)).x - padding;
        Debug.Log("XMax: " + XMax.ToString());
        YMin = gameCamera.ViewportToWorldPoint(new Vector3(0, 0, 0)).y + padding;
        Debug.Log("YMin: " + XMin.ToString());
        YMax = gameCamera.ViewportToWorldPoint(new Vector3(0, 1, 0)).y - padding;
        Debug.Log("YMax: " + XMin.ToString());



        Instantiate(mycirclePrefab, new Vector3(XMin, YMin, 0), Quaternion.identity);
        Instantiate(mycirclePrefab, new Vector3(XMin, YMax, 0), Quaternion.identity);
        Instantiate(mycirclePrefab, new Vector3(XMax, YMin, 0), Quaternion.identity);
        Instantiate(mycirclePrefab, new Vector3(XMax, YMax, 0), Quaternion.identity);
    }
Пример #5
0
 public override string ToString()
 {
     return($"{XMin.ToString(CultureInfo.InvariantCulture)},{YMin.ToString(CultureInfo.InvariantCulture)},{ZMin.ToString(CultureInfo.InvariantCulture)},{XMax.ToString((CultureInfo.InvariantCulture))},{YMax.ToString((CultureInfo.InvariantCulture))},{ZMax.ToString((CultureInfo.InvariantCulture))}");
 }
Пример #6
0
 public override string ToString()
 {
     return(XMin.ToString() + "," + YMin.ToString() + "," + XMax.ToString() + "," + YMax.ToString());
 }
Пример #7
0
        private void ChangeOperationMode(int NewMode)
        {
            if (OperationMode == NewMode)
            {
                return;
            }
            if (NewMode == MODE_IDLE)
            {
                if (OutputFile != null)
                {
                    OutputFile.Close();
                }
                button2.Enabled  = false;
                button3.Enabled  = false;
                textBox1.Enabled = true;
                timer1.Enabled   = false;
                OperationMode    = MODE_IDLE;
            }
            if (NewMode == MODE_MAIN)
            {
                SerialWriteBuffer[0] = 'm';
                StartExperiment      = DateTime.Now;
                FileName             = String.Format("polar{0,4:0000}_{1,2:00}_{2,2:00}-{3,2:00}_{4,2:00}_{5,2:00}.out",
                                                     StartExperiment.Year,
                                                     StartExperiment.Month,
                                                     StartExperiment.Day,
                                                     StartExperiment.Hour,
                                                     StartExperiment.Minute,
                                                     StartExperiment.Second);
                if (OutputFile != null)
                {
                    OutputFile.Close();
                }

                OutputFile = new StreamWriter(FileName);        // create file
                OutputFile.Close();

                label1.Text         = FileName;
                YMIN                = 0; YMAX = 0;
                NPlot1              = new LinePlot();
                NPoints             = 0;
                AutoRescale         = true;
                XX                  = new double[1];
                YY                  = new double[1];
                NPlot1.AbscissaData = XX;
                NPlot1.DataSource   = YY;
                plotSurface2D1.Clear();
                plotSurface2D1.Add(NPlot1);
                button2.Enabled  = true;
                button3.Enabled  = true;
                button3.Text     = "Scan";
                timer1.Interval  = 100;
                timer1.Enabled   = true;
                textBox1.Enabled = false;
                OperationMode    = MODE_MAIN;
                TakeEachPoint    = 1;
                TakeEachPointNow = 0;
            }
            if (NewMode == SCAN_CELL)
            {
                //SerialWriteBuffer[0] = 'm';
                StartExperiment = DateTime.Now;
                AutoRescale     = true;
                FileName        = String.Format("scan{0,4:0000}_{1,2:00}_{2,2:00}-{3,2:00}_{4,2:00}_{5,2:00}.out",
                                                StartExperiment.Year,
                                                StartExperiment.Month,
                                                StartExperiment.Day,
                                                StartExperiment.Hour,
                                                StartExperiment.Minute,
                                                StartExperiment.Second);
                if (OutputFile != null)
                {
                    OutputFile.Close();
                }
                OutputFile = new StreamWriter(FileName);
                OutputFile.Close();

                label1.Text         = FileName;
                YMIN                = -3.0; YMAX = 3.0;
                NPlot1              = new LinePlot();
                NPoints             = 0;
                XX                  = new double[1];
                YY                  = new double[1];
                NPlot1.AbscissaData = XX;
                NPlot1.DataSource   = YY;
                plotSurface2D1.Clear();
                plotSurface2D1.Add(NPlot1);

                plotSurface2D1.XAxis1.WorldMin = -0.5;
                plotSurface2D1.XAxis1.WorldMax = 10.5;
                plotSurface2D1.YAxis1.WorldMin = -3.0;
                plotSurface2D1.YAxis1.WorldMax = 0.5;

                XMin = -0.5;
                XMax = 10.5;
                YMin = -2.5;
                YMax = 0.5;

                textBox2.Text = YMax.ToString();
                textBox3.Text = YMin.ToString();
                textBox4.Text = XMin.ToString();
                textBox5.Text = XMax.ToString();

                plotSurface2D1.Refresh();

                button2.Enabled  = true;
                button3.Enabled  = true;
                button3.Text     = "Stop Scan";
                timer1.Interval  = 100;
                timer1.Enabled   = true;
                textBox1.Enabled = false;
                OperationMode    = SCAN_CELL;
            }
        }
Пример #8
0
        private void PlotRescale()
        {
            if (AutoRescale)
            {
                if (OperationMode == MODE_MAIN)
                {
                    plotSurface2D1.XAxis1.WorldMin = 0;
                    plotSurface2D1.XAxis1.WorldMax = time;
                    plotSurface2D1.YAxis1.WorldMin = YMIN;
                    plotSurface2D1.YAxis1.WorldMax = YMAX;

                    plotSurface2D1.XAxis1.WorldMin -= plotSurface2D1.XAxis1.WorldLength * 0.1;
                    plotSurface2D1.XAxis1.WorldMax += plotSurface2D1.XAxis1.WorldLength * 0.5;
                    plotSurface2D1.YAxis1.WorldMin -= plotSurface2D1.YAxis1.WorldLength * 0.1;
                    plotSurface2D1.YAxis1.WorldMax += plotSurface2D1.YAxis1.WorldLength * 0.1;

                    textBox2.Text = plotSurface2D1.YAxis1.WorldMax.ToString("F0");
                    textBox3.Text = plotSurface2D1.YAxis1.WorldMin.ToString("F0");
                    textBox4.Text = plotSurface2D1.XAxis1.WorldMin.ToString("F0");
                    textBox5.Text = plotSurface2D1.XAxis1.WorldMax.ToString("F0");

                    XMin = plotSurface2D1.XAxis1.WorldMin;
                    XMax = plotSurface2D1.XAxis1.WorldMax;
                    YMin = plotSurface2D1.YAxis1.WorldMin;
                    YMax = plotSurface2D1.YAxis1.WorldMax;

                    textBox2.BackColor = SystemColors.Menu;
                    textBox3.BackColor = SystemColors.Menu;
                    textBox4.BackColor = SystemColors.Menu;
                    textBox5.BackColor = SystemColors.Menu;

                    plotSurface2D1.Refresh();
                }
                if (OperationMode == SCAN_CELL)
                {
                    plotSurface2D1.XAxis1.WorldMin = 0;
                    plotSurface2D1.XAxis1.WorldMax = time;
                    plotSurface2D1.YAxis1.WorldMin = YMIN;
                    plotSurface2D1.YAxis1.WorldMax = YMAX;

                    plotSurface2D1.XAxis1.WorldMin -= plotSurface2D1.XAxis1.WorldLength * 0.1;
                    plotSurface2D1.XAxis1.WorldMax += plotSurface2D1.XAxis1.WorldLength * 0.5;
                    plotSurface2D1.YAxis1.WorldMin -= plotSurface2D1.YAxis1.WorldLength * 0.1;
                    plotSurface2D1.YAxis1.WorldMax += plotSurface2D1.YAxis1.WorldLength * 0.1;

                    plotSurface2D1.XAxis1.WorldMin -= plotSurface2D1.XAxis1.WorldLength * 0.1;
                    plotSurface2D1.XAxis1.WorldMax += plotSurface2D1.XAxis1.WorldLength * 0.5;
                    plotSurface2D1.YAxis1.WorldMin -= plotSurface2D1.YAxis1.WorldLength * 0.1;
                    plotSurface2D1.YAxis1.WorldMax += plotSurface2D1.YAxis1.WorldLength * 0.1;

                    textBox2.Text = YMax.ToString("F0");
                    textBox3.Text = YMin.ToString("F0");
                    textBox4.Text = XMin.ToString("F0");
                    textBox5.Text = XMax.ToString("F0");

                    textBox2.BackColor = SystemColors.Menu;
                    textBox3.BackColor = SystemColors.Menu;
                    textBox4.BackColor = SystemColors.Menu;
                    textBox5.BackColor = SystemColors.Menu;

                    plotSurface2D1.Refresh();
                }
            }
            else
            {
                plotSurface2D1.XAxis1.WorldMin = XMin;
                plotSurface2D1.XAxis1.WorldMax = XMax;
                plotSurface2D1.YAxis1.WorldMin = YMin;
                plotSurface2D1.YAxis1.WorldMax = YMax;

                textBox2.BackColor = SystemColors.Window;
                textBox3.BackColor = SystemColors.Window;
                textBox4.BackColor = SystemColors.Window;
                textBox5.BackColor = SystemColors.Window;

                plotSurface2D1.Refresh();
            }
        }