Exemple #1
0
        private void menuFeatureClassIndex_Click(object sender, EventArgs e)
        {
            myTreeNode    selectNode = this.tv_CatalogTree.SelectedNode as myTreeNode;
            IFeatureClass fc         = selectNode.Tag as IFeatureClass;

            myTreeNode  dsTreeNode     = selectNode.Parent.Parent as myTreeNode;
            IDataSource myDs           = dsTreeNode.Tag as IDataSource;
            bool        hasDelFieldCap = myDs.HasCapability(gviFdbCapability.gviFdbCapDeleteField);
            bool        hasMdiFieldCap = myDs.HasCapability(gviFdbCapability.gviFdbCapModifyField);

            if (layers.Count > 0)
            {
                MessageBox.Show("请先移除RenderControl中的图层");
                return;
            }

            FeatureClassIndexDlg myDlg = new FeatureClassIndexDlg(fc);

            if (myDlg.ShowDialog() == DialogResult.OK)
            {
            }
        }
Exemple #2
0
 private void tv_CatalogTree_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         myTreeNode selectNode = this.tv_CatalogTree.GetNodeAt(e.X, e.Y) as myTreeNode;
         this.tv_CatalogTree.SelectedNode = selectNode;
         if (selectNode.nodeType == NodeObjectType.FeatureClass)
         {
             cMenuCatalog.Items.Clear();
             ToolStripMenuItem menuFeatureClassIndex = new ToolStripMenuItem("索引");
             menuFeatureClassIndex.Click += new EventHandler(menuFeatureClassIndex_Click);
             cMenuCatalog.Items.Add(menuFeatureClassIndex);
             cMenuCatalog.Show(Cursor.Position);
         }
         if (selectNode.nodeType == NodeObjectType.DataSet)
         {
             cMenuCatalog.Items.Clear();
             ToolStripMenuItem menuLoadData = new ToolStripMenuItem("加载数据");
             menuLoadData.Click += new EventHandler(menuLoadData_Click);
             cMenuCatalog.Items.Add(menuLoadData);
             cMenuCatalog.Show(Cursor.Position);
         }
     }
 }
Exemple #3
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);
            this.axRenderControl1.Camera.FlyTime = 1;

            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;
            }

            // 加载FDB场景
            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);
                //设置资源目录树DataSource节点
                myTreeNode catalogDsNode = new myTreeNode(System.IO.Path.GetFileNameWithoutExtension(tmpFDBPath), NodeObjectType.DataSource, ds);
                this.tv_CatalogTree.Nodes.Add(catalogDsNode);

                string[] setnames = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return;
                }
                IFeatureDataSet dataset = ds.OpenFeatureDataset(setnames[0]);

                //设置资源目录树DataSet节点
                myTreeNode catalogFdsNode = new myTreeNode(setnames[0], NodeObjectType.DataSet, dataset);
                catalogDsNode.Nodes.Add(catalogFdsNode);

                //遍历FeatureClass
                string[] fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                if (fcnames.Length == 0)
                {
                    return;
                }
                fcMap    = new Hashtable(fcnames.Length);
                fcuidMap = 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);
                    fcuidMap.Add(fc.Guid, fc);
                    //设置资源目录FeatureClass节点
                    myTreeNode catalogFcNode = new myTreeNode(name, NodeObjectType.FeatureClass, fc);
                    catalogFdsNode.Nodes.Add(catalogFcNode);
                    this.tv_CatalogTree.ExpandAll();
                }
            }
            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);
                    layers.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, -20, 0);
                        this.axRenderControl1.Camera.LookAt(env.Center, 1000, angle);
                    }
                    hasfly = true;
                }
            }

            this.axRenderControl1.MouseSelectObjectMask = gviMouseSelectObjectMask.gviSelectAll;
            this.axRenderControl1.MouseSelectMode       = gviMouseSelectMode.gviMouseSelectClick;
            this.axRenderControl1.RcMouseClickSelect   += new _IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect);


            {
                this.helpProvider1.SetShowHelp(this.axRenderControl1, true);
                this.helpProvider1.SetHelpString(this.axRenderControl1, "");
                this.helpProvider1.HelpNamespace = "DataIndex.html";
            }
        }