public void Setup(DataProfile dataProfile, DataProfile.SubProfile dataSubProfile)
        {
            profile    = dataProfile;
            subProfile = dataSubProfile;

            RedrawPreviewImg();
        }
Пример #2
0
        private void uiComboBox2_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (uiComboBox2.SelectedItem != null && uiComboBox1.SelectedItem != null)
            {
                selectedSubProfile = (DataProfile.SubProfile)uiComboBox2.SelectedItem.Value;
                textBox2.Text      = selectedSubProfile.Desc;

                dataProfilePreviewControl1.Setup((DataProfile)uiComboBox1.SelectedItem.Value, selectedSubProfile);
            }
            else
            {
                textBox2.Text = "";
            }
        }
Пример #3
0
        public void LoadVisualization(DataProfile dataProfile, DataProfile.SubProfile subProfile,
                                      IDataSourceReader dataSrcReader, DataSourceInfo dataSrcInfo)
        {
            renderFrame = true;
            renderingThread.Start();

            controlStatus = ControlStatus.Loading;
            rContext.LoadingLayer.SetProgress(0);
            rContext.LoadingLayer.SetText("Loading... DEM Geometry");
            rContext.LoadingLayer.Visible = true;
            Render();

            // load data from dlg into database
            database = new RasterDatabase.RasterDatabase();
            object filteredData = subProfile.Filter.FilterData(dataSrcReader);

            if (filteredData is byte[])
            {
                DataLayer dataLayer = new DataLayer("DEM", 8, "byte");
                dataLayer.AddArea(new ByteArea(new Rectangle(new Point(), dataSrcReader.Info.Resolution),
                                               new RectangleF(0, 0, 1, 1),
                                               (byte[])filteredData, dataSrcReader.Info.Resolution));
                database.AddLayer(dataLayer);
            }
            else if (filteredData is float[])
            {
                DataLayer dataLayer = new DataLayer("DEM", 32, "float");
                dataLayer.AddArea(new FloatArea(new Rectangle(new Point(), dataSrcReader.Info.Resolution),
                                                new RectangleF(0, 0, 1, 1),
                                                (float[])filteredData, dataSrcReader.Info.Resolution));
                database.AddLayer(dataLayer);
            }

            // load data source(s)
            DataSourceItem item = new DataSourceItem(dataSrcInfo.BppType,
                                                     (Bitmap)PreviewRasterizer.DrawRotatedBandPreview(dataSrcInfo.Bands,
                                                                                                      64, dataSrcInfo));

            heightDataSrcs.Add(item);

            // load diffuse sources
            // grey-scale for height
            GreyScaleDEMSampler srcImgSampler = new GreyScaleDEMSampler();
            Bitmap srcImg = srcImgSampler.GenerateBitmap(new Size(64, 64), database.Layers[0].Areas[0]);

            item            = new DataSourceItem("Height", srcImg);
            item.DEMSampler = srcImgSampler;
            //(Bitmap)PreviewRasterizer.DrawRotatedBandPreview(new DataSourceInfo.DataBandInfo[] { new DataSourceInfo.DataBandInfo("Source", srcImg) },
            //64, null));
            diffuseDataSrcs.Add(item);

            // load colour image if possible as other source (i.e the original if an RGB img)
            if (dataSrcReader.Info.SupportsRGB())
            {
                item = new DataSourceItem("SourceRGB",
                                          SourceDataDiffuseSampler.SampleRGBDiffuseMap((GDALReader)dataSrcReader,
                                                                                       new Size(64, 64)));
                diffuseDataSrcs.Add(item);
                reader = (GDALReader)dataSrcReader;
            }

            // height band range
            HeightBandRange hbr = new HeightBandRange();

            hbr.AddBand(0, Color.DarkGreen);
            hbr.AddBand(0.25f, Color.Blue);
            hbr.AddBand(0.4f, Color.DarkGreen);
            hbr.AddBand(0.5f, Color.Green);
            hbr.AddBand(0.8f, Color.Gray);
            hbr.AddBand(1, Color.White);
            HeightBandDEMSampler hBandSampler = new HeightBandDEMSampler(hbr);

            item = new DataSourceItem("HeightBands",
                                      hBandSampler.GenerateBitmap(new Size(64, 64), database.Layers[0].Areas[0]));
            item.DEMSampler = hBandSampler;
            diffuseDataSrcs.Add(item);

            // load database into visualization
            dem = new DigitalElevationMap(database.Area.Size, database, rContext.DevIf, (GDALReader)dataSrcReader/*,
                                                                                                                  * hBandSampler.GenerateBitmap(new Size(512, 512),
                                                                                                                  * database.Layers[0].Areas[0])*/
                                          );
            rContext.SetDEM(dem);

            // setup geometry layers
            geometryLayers.Add(new GeometryVisLayer("Diffuse", item.Thumbnail, true));
            geometryLayers.Add(new GeometryVisLayer("Overlay Grid", null, true));

            rContext.DevIf.LocalSettings["GeometryVisLayer.Diffuse"] = geometryLayers[0];
            rContext.DevIf.LocalSettings["GeometryVisLayer.Overlay"] = geometryLayers[1];

            // now load default texture
            SetDiffuseSource(0);

            rContext.LoadingLayer.SetProgress(100);
            Render();
            Thread.Sleep(500);

            rContext.LoadingLayer.Visible = false;
            controlStatus = ControlStatus.Idle;
            Render();
        }