Example #1
0
        public override LoadContainer GetLoadTopology()
        {
            IHeatMap heatMap = this.heatMaps.FirstOrDefault((IHeatMap map) => map.IsReady);

            if (heatMap == null)
            {
                throw new HeatMapNotBuiltException();
            }
            return(heatMap.GetLoadTopology());
        }
Example #2
0
        void ShowNodeActivity()
        {
            if (listView1.SelectedIndices.Count <= 0)
            {
                return;
            }

            string opName = listView1.SelectedItems[0].SubItems[0].Text;
            string opType = listView1.SelectedItems[0].SubItems[1].Text;

            if (opType == "ConstStr")
            {
                string strValue = liveModel.ReadString(opName);
                MessageBox.Show(strValue, "String Constant");
                return;
            }

            var app    = DataModeling.App.ScriptApp;
            var values = liveModel.EvalVariable((double[][])numTable.Matrix, opName, true);
            var act    = app.New.NumberTable(values);

            if (numTable.Rows == act.Rows)
            {
                for (int row = 0; row < numTable.Rows; row++)
                {
                    act.RowSpecList[row].CopyFrom(numTable.RowSpecList[row]);
                }
            }

            if ((heatMap == null) || heatMap.TheForm.IsDisposed)
            {
                heatMap = app.New.HeatMap(act);
                heatMap.Show();
            }
            else
            {
                heatMap.GetNumberTable().Copy(act);
                heatMap.Redraw();
            }
        }
Example #3
0
 public HeatMapDatabaseSelector(IHeatMap heatMap, ILogger logger) : base(logger)
 {
     this.heatMap = heatMap;
 }
Example #4
0
        private void MainForm_Load(object sender, System.EventArgs e)
        {
            // 初始化RenderControl控件
            IPropertySet ps = new PropertySet();

            ps.SetProperty("RenderSystem", gviRenderSystem.gviRenderOpenGL);
            this.axRenderControl1.Initialize(true, ps);

            rootId = this.axRenderControl1.ObjectManager.GetProjectTree().RootID;

            // 设置天空盒

            if (System.IO.Directory.Exists(strMediaPath))
            {
                string  tmpSkyboxPath = strMediaPath + @"\skybox";
                ISkyBox skybox        = this.axRenderControl1.ObjectManager.GetSkyBox(0);
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBack, tmpSkyboxPath + "\\1_BK.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBottom, tmpSkyboxPath + "\\1_DN.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageFront, tmpSkyboxPath + "\\1_FR.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageLeft, tmpSkyboxPath + "\\1_LF.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageRight, tmpSkyboxPath + "\\1_RT.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageTop, tmpSkyboxPath + "\\1_UP.jpg");
            }
            else
            {
                MessageBox.Show("请不要随意更改SDK目录名");
                return;
            }

            this.axRenderControl1.Camera.FlyTime = 1;

            #region 加载SDKDEMO场景
            try
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\SDKDEMO.FDB");
                ci.Database = tmpFDBPath;
                IDataSourceFactory dsFactory = new DataSourceFactory();
                IDataSource        ds        = dsFactory.OpenDataSource(ci);
                string[]           setnames  = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return;
                }
                IFeatureDataSet dataset = ds.OpenFeatureDataset(setnames[0]);
                //遍历FeatureClass
                string[] fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                if (fcnames.Length == 0)
                {
                    return;
                }
                fcMap = new Hashtable(fcnames.Length);
                foreach (string name in fcnames)
                {
                    IFeatureClass fc = dataset.OpenFeatureClass(name);
                    // 找到空间列字段
                    List <string>        geoNames   = new List <string>();
                    IFieldInfoCollection fieldinfos = fc.GetFields();
                    for (int i = 0; i < fieldinfos.Count; i++)
                    {
                        IFieldInfo fieldinfo = fieldinfos.Get(i);
                        if (null == fieldinfo)
                        {
                            continue;
                        }
                        IGeometryDef geometryDef = fieldinfo.GeometryDef;
                        if (null == geometryDef)
                        {
                            continue;
                        }
                        geoNames.Add(fieldinfo.Name);
                    }
                    fcMap.Add(fc, geoNames);
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
                return;
            }

            // CreateFeautureLayer
            bool hasfly = false;
            foreach (IFeatureClass fc in fcMap.Keys)
            {
                List <string> geoNames = (List <string>)fcMap[fc];
                foreach (string geoName in geoNames)
                {
                    if (!geoName.Equals("Geometry"))
                    {
                        continue;
                    }

                    IFeatureLayer featureLayer = this.axRenderControl1.ObjectManager.CreateFeatureLayer(
                        fc, geoName, null, null, rootId);
                    flayerList.Add(featureLayer);

                    if (!hasfly)
                    {
                        IFieldInfoCollection fieldinfos  = fc.GetFields();
                        IFieldInfo           fieldinfo   = fieldinfos.Get(fieldinfos.IndexOf(geoName));
                        IGeometryDef         geometryDef = fieldinfo.GeometryDef;
                        IEnvelope            env         = geometryDef.Envelope;
                        if (env == null || (env.MaxX == 0.0 && env.MaxY == 0.0 && env.MaxZ == 0.0 &&
                                            env.MinX == 0.0 && env.MinY == 0.0 && env.MinZ == 0.0))
                        {
                            continue;
                        }
                        IEulerAngle angle = new EulerAngle();
                        angle.Set(0, -90, 0);
                        this.axRenderControl1.Camera.LookAt(env.Center, 1000, angle);
                    }
                    hasfly = true;
                }
            }
            #endregion

            //注册地形
            string tmpTedPath = (strMediaPath + @"\terrain\SingaporePlanarTerrain.ted");
            this.axRenderControl1.Terrain.RegisterTerrain(tmpTedPath, "");

            if (player == null)
            {
                player = this.axRenderControl1.HeatMapPlayer;
            }

            // 加载FDB场景
            try
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\HeatMap.FDB");
                ci.Database = tmpFDBPath;
                IDataSourceFactory dsFactory = new DataSourceFactory();
                IDataSource        ds        = dsFactory.OpenDataSource(ci);
                string[]           setnames  = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return;
                }
                IFeatureDataSet dataset = ds.OpenFeatureDataset(setnames[0]);
                string[]        fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                if (fcnames.Length == 0)
                {
                    return;
                }
                fcMap = new Hashtable(fcnames.Length);
                foreach (string name in fcnames)
                {
                    IFeatureClass fc = dataset.OpenFeatureClass(name);
                    // 找到空间列字段
                    List <string>        geoNames   = new List <string>();
                    IFieldInfoCollection fieldinfos = fc.GetFields();
                    for (int i = 0; i < fieldinfos.Count; i++)
                    {
                        IFieldInfo fieldinfo = fieldinfos.Get(i);
                        if (null == fieldinfo)
                        {
                            continue;
                        }
                        IGeometryDef geometryDef = fieldinfo.GeometryDef;
                        if (null == geometryDef)
                        {
                            continue;
                        }
                        geoNames.Add(fieldinfo.Name);
                    }
                    fcMap.Add(fc, geoNames);

                    if (fc.HasTemporal())
                    {
                        ITemporalManager tm    = fc.TemporalManager;
                        DateTime[]       times = tm.GetKeyDatetimes();
                        for (int i = 0; i < times.Length; i++)
                        {
                            if (keyDatetimesList.Contains(times[i]))
                            {
                                continue;
                            }
                            keyDatetimesList.Add(times[i]);
                        }
                    }
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
                return;
            }

            // 设置时间轴
            if (keyDatetimesList.Count == 0)
            {
                this.cbKeyTimes.Enabled = false;
                this.btnPlay.Enabled    = false;
                this.btnPause.Enabled   = false;
                this.btnStop.Enabled    = false;
            }
            else
            {
                keyDatetimesList.Sort();
                for (int t = 0; t < keyDatetimesList.Count; t++)
                {
                    DateTime d = keyDatetimesList[t];
                    cbKeyTimes.Items.Add(d);
                }
            }

            // CreateFeautureLayer
            foreach (IFeatureClass fc in fcMap.Keys)
            {
                List <string> geoNames = (List <string>)fcMap[fc];
                foreach (string geoName in geoNames)
                {
                    heatmap = this.axRenderControl1.ObjectManager.CreateHeatMap(
                        fc, geoName, "HotValue", rootId);
                    if (heatmap == null)
                    {
                        continue;
                    }
                    this.txtMinValue.Text = heatmap.MinHeatValue.ToString();
                    this.txtMaxValue.Text = heatmap.MaxHeatValue.ToString();
                }
            }

            //设置curLayer的时刻为最新时刻
            if (keyDatetimesList.Count > 0)
            {
                DateTime dmax = (keyDatetimesList[keyDatetimesList.Count - 1]);
                player.SetTime(dmax);

                //设置时间轴为最小
                cbKeyTimes.SelectedIndex = keyDatetimesList.Count - 1;
            }

            //测试自定义颜色
            //System.Drawing.Color[] colors = new System.Drawing.Color[2];
            //colors[0] = System.Drawing.Color.White;
            //colors[1] = System.Drawing.Color.Gray;
            //bool suc = player.SetColor(colors, 2);
            //if(suc)
            //{
            //    System.Drawing.Color[] colorvec;
            //    byte c;
            //    bool suc2 = player.GetColor(out colorvec, out c);
            //    if (suc2)
            //        this.Text = c.ToString();
            //}

            this.cbShowHeatMap.Checked      = true;
            this.cbShowFeatureLayer.Checked = true;

            {
                this.helpProvider1.SetShowHelp(this.axRenderControl1, true);
                this.helpProvider1.SetHelpString(this.axRenderControl1, "");
                this.helpProvider1.HelpNamespace = "Temporal.html";
            }
        }
Example #5
0
        public IHeatMap CalculateCurvature(IHeatMap hm, string rowId, short rowType, IList <IBody> bodyList, int scansPerNode, int skipSize)
        {
            var           b      = bodyList;
            int           N      = scansPerNode;
            List <double> cv     = new List <double>();
            List <string> idList = new List <string>();

            for (var i = 0; i < (b.Count - 2 * N - 1); i += skipSize)
            {
                var iN  = i + N;
                var iN2 = i + 2 * N;

                var x0 = b[iN].X - b[i].X;
                var y0 = b[iN].Y - b[i].Y;
                var z0 = b[iN].Z - b[i].Z;

                var x1 = b[iN2].X - b[iN].X;
                var y1 = b[iN2].Y - b[iN].Y;
                var z1 = b[iN2].Z - b[iN].Z;


                var x2 = x0 + x1;
                var y2 = y0 + y1;
                var z2 = z0 + z1;

                // K = 2*sin(A)/s,
                // where A is the angle between B[k+1]-B[k] and B[k+2]-B[k+1],
                // s is the length of B[k+2]-B[k].

                var n0 = x0 * x0 + y0 * y0 + z0 * z0;
                var n1 = x1 * x1 + y1 * y1 + z1 * z1;
                var n2 = x2 * x2 + y2 * y2 + z2 * z2;
                if ((n0 > 0) && (n1 > 0) && (n2 > 0))
                {
                    var dot   = x0 * x1 + y0 * y1 + z0 * z1;
                    var sinA2 = 1 - (dot * dot) / (n0 * n1);         // sinA2 = sin(A)^2.
                    if (sinA2 > 0)
                    {
                        cv.Add(2 * Math.Sqrt(sinA2 / n2));
                    }
                }
                else
                {
                    cv.Add(0);
                }
                idList.Add(b[iN].Id);
            }

            var app = GeneticAnalysis.App.ScriptApp;

            if (hm == null)
            {
                var fs = app.FindFormList("HeatMap");
                if (fs.Count > 0)
                {
                    hm = fs[0] as IHeatMap;
                }
            }

            if (hm == null)
            {
                var tb = app.New.NumberTable(cv.ToArray());
                for (var col = 0; col < tb.Columns; col++)
                {
                    tb.ColumnSpecList[col].Id = idList[col];
                }
                tb.RowSpecList[0].Type = rowType;
                if (rowId != null)
                {
                    tb.RowSpecList[0].Id = rowId;
                }
                hm              = tb.ShowHeatMap();
                hm.ReadOnly     = true;
                hm.SpectrumType = 2;
            }
            else
            {
                var tb = hm.GetNumberTable();
                if (tb.Columns < cv.Count)
                {
                    int newColumns = cv.Count - tb.Columns;
                    tb.AddColumns(newColumns);
                    for (var i = 0; i < newColumns; i++)
                    {
                        int col = cv.Count - newColumns + i;
                        tb.ColumnSpecList[col].Id = idList[col];
                    }
                }
                var uf = (rowId != null) ? new UniqueNameFinder(tb.RowSpecList.Select(rs => rs.Id)) : null;

                tb.AddRows(1);
                for (var col = 0; col < cv.Count; col++)
                {
                    tb.Matrix[tb.Rows - 1][col] = cv[col];
                }
                tb.RowSpecList[tb.Rows - 1].Type = rowType;
                if (rowId != null)
                {
                    tb.RowSpecList[tb.Rows - 1].Id = uf.LookupName(rowId);
                }
                hm.Title = "N: " + tb.Rows;
                hm.Redraw();
            }
            hm.CentralizeColorSpectrum();
            return(hm);
        }