예제 #1
0
        private void makeBuffer(GSOFeature feature)
        {
            double radius        = (double)numericUpDownRadius.Value;  //缓冲区宽度
            double value         = (double)numericUpDownFenDuan.Value; //圆角角度
            bool   isRoundCorner = CBRoundCorner.Checked;              //拐角是否圆滑
            bool   isRoundEnds   = CBRoundEnds.Checked;                //两端是否圆滑

            GSOGeoPolygon3D buffer = null;                             //创建缓冲面

            if (feature.Geometry.Type == EnumGeometryType.GeoMarker)   //如果要素为点
            {
                GSOGeoMarker marker = feature.Geometry as GSOGeoMarker;
                buffer = marker.CreateBuffer(radius, value, false);
                //创建点的缓冲面(宽度,角度,false)
            }
            else if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
            {
                GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D;
                buffer = line.CreateBuffer(radius, isRoundCorner, value, isRoundEnds, false);
                //创建线的缓冲面(宽度,拐角圆滑,角度,两端圆滑,false)
            }
            else if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D)
            {
                GSOGeoPolygon3D polygon = feature.Geometry as GSOGeoPolygon3D;
                buffer = polygon.CreateBuffer(radius, isRoundCorner, value, isRoundEnds, false);
                //创建面的缓冲面(宽度,拐角圆滑,角度,两端圆滑,false)
            }

            if (buffer != null)
            {
                //缓冲面颜色
                GSOSimplePolygonStyle3D style = new GSOSimplePolygonStyle3D();
                style.FillColor = Color.FromArgb(122, Color.Yellow);
                //缓冲线颜色
                GSOSimpleLineStyle3D outlineStyle = new GSOSimpleLineStyle3D();
                outlineStyle.LineColor = Color.Red;
                style.OutlineStyle     = outlineStyle;
                buffer.Style           = style;
                GSOFeature featureBuffer = new GSOFeature();
                featureBuffer.Geometry = buffer;
                featureBuffer.Name     = feature.Name + "_" + radius + "米_Buffer";
                globeControl1.Globe.MemoryLayer.AddFeature(featureBuffer);

                //重新创建原有要素,使得要素在缓冲面上方,可选择
                if (feature != null && feature.Dataset.Type == EnumDatasetType.Memory && feature.Dataset.Caption == "" && feature.Dataset.Name == "")
                {
                    GSOFeature featureSelectCopy = feature.Clone();
                    globeControl1.Globe.MemoryLayer.AddFeature(featureSelectCopy);
                    feature.Delete();
                }
                globeControl1.Refresh();
            }
        }
예제 #2
0
 public FrmFeatureInfo(GSOFeature feature, GSOLayer layer, GSOGlobeControl globeControl)
 {
     InitializeComponent();
     if (layer != null)
     {
         mlayer = layer;
     }
     m_Feature = feature;
     // 先备份一个
     if (feature != null)
     {
         m_OldFeture = feature.Clone();
     }
     m_GlobeControl = globeControl;
 }
예제 #3
0
 public FrmFeatureInfo(GSOFeature feature, GSOLayer layer, GSOGlobeControl globeControl)
 {
     InitializeComponent();
     if (layer != null)
     {
         mlayer = layer;
     }
     m_Feature = feature;
     // 先备份一个
     if (feature != null)
     {
         m_OldFeture = feature.Clone();
     }
     m_GlobeControl = globeControl;
 }
        private void Set()
        {
            if (listBoxCopyLayerList.SelectedItems.Count <= 0)
            {
                MessageBox.Show("请选择要复制的数据集!", "提示");
                return;
            }
            if (comboBoxTargetDataSource.SelectedItem == null)
            {
                MessageBox.Show("请选择目标数据源!", "提示");
                return;
            }
            if (checkBoxCopyOne.Checked == true && textboxNewLayerName.Text.Trim() == "")
            {
                MessageBox.Show("请给要复制的数据集命名!", "提示");
                return;
            }
            if (checkBoxCopyOne.Checked == true)
            {
                GSODataSource dsTarget = Utility.getDataSourceByFullName(globeControl1, comboBoxTargetDataSource.SelectedItem.ToString().Trim());
                if (dsTarget != null)
                {
                    GSODataset newDataset = dsTarget.GetDatasetByName(textboxNewLayerName.Text.Trim());
                    if (newDataset != null)
                    {
                        MessageBox.Show("输入的新的数据集的名称已存在目标数据源中!", "提示");
                        return;
                    }
                    GSOFeatureDataset newFeatureDataset = dsTarget.CreateFeatureDataset(textboxNewLayerName.Text.Trim());
                    if (newFeatureDataset == null)
                    {
                        MessageBox.Show("输入的新数据集的名称不符合要求!", "提示");
                        return;
                    }
                    GSODataSource ds = Utility.getDataSourceByFullName(globeControl1, comboBoxDataSourceList.SelectedItem.ToString().Trim());
                    if (ds != null)
                    {
                        GSODataset        dataset        = ds.GetDatasetByName(listBoxCopyLayerList.SelectedItem.ToString().Trim());
                        GSOFeatureDataset featureDataset = dataset as GSOFeatureDataset;
                        if (featureDataset != null)
                        {
                            try
                            {
                                featureDataset.Open();
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "提示");
                                if (featureDataset.IsOpened == true)
                                {
                                    featureDataset.Close();
                                }
                                return;
                            }
                            //向新数据集写入字段
                            for (int i = 0; i < featureDataset.FieldCount; i++)
                            {
                                GSOFieldAttr fieldFromDs = featureDataset.GetField(i);
                                newFeatureDataset.AddField(fieldFromDs);
                            }

                            //向新的要素集写入数据
                            for (int i = 0; i < featureDataset.GetAllFeatures().Length; i++)
                            {
                                GSOFeature featureInDs       = featureDataset.GetFeatureAt(i);
                                GSOFeature featureInTargetDs = featureInDs.Clone();
                                featureInDs.Dispose();
                                newFeatureDataset.AddFeature(featureInTargetDs);
                            }
                            newFeatureDataset.Save();
                            featureDataset.Close();
                            MessageBox.Show("复制成功!", "提示");
                        }
                    }
                }
            }
            else if (checkBoxCopyMult.Checked == true)
            {
                GSODataSource dsTarget = Utility.getDataSourceByFullName(globeControl1, comboBoxTargetDataSource.SelectedItem.ToString().Trim());
                if (dsTarget != null)
                {
                    string datasetNames = "";
                    for (int i = 0; i < listBoxCopyLayerList.SelectedItems.Count; i++)
                    {
                        GSODataset datasetInTargetDs = dsTarget.GetDatasetByName(listBoxCopyLayerList.SelectedItems[i].ToString().Trim());
                        if (datasetInTargetDs != null)
                        {
                            datasetNames += "\"" + listBoxCopyLayerList.SelectedItems[i].ToString().Trim() + "\" ";
                        }
                    }
                    if (datasetNames != "")
                    {
                        MessageBox.Show("数据集名称" + datasetNames + "在目标数据源中已存在", "提示");
                        return;
                    }
                    GSODataSource ds = Utility.getDataSourceByFullName(globeControl1, comboBoxDataSourceList.SelectedItem.ToString().Trim());
                    if (ds != null)
                    {
                        progressBar1.Visible = true;
                        progressBar1.Maximum = listBoxCopyLayerList.SelectedItems.Count - 1;
                        progressBar1.Minimum = 0;
                        for (int j = 0; j < listBoxCopyLayerList.SelectedItems.Count; j++)
                        {
                            //获取要复制的要素集
                            GSODataset        datasetInDs        = ds.GetDatasetByName(listBoxCopyLayerList.SelectedItems[j].ToString().Trim());
                            GSOFeatureDataset featureDatasetInDs = datasetInDs as GSOFeatureDataset;
                            if (featureDatasetInDs == null)
                            {
                                continue;
                            }
                            featureDatasetInDs.Open();

                            //创建新的数据库要素集
                            GSOFeatureDataset featureDatasetInTargetDs = dsTarget.CreateFeatureDataset(listBoxCopyLayerList.SelectedItems[j].ToString().Trim());

                            if (featureDatasetInTargetDs == null)
                            {
                                continue;
                            }
                            featureDatasetInTargetDs.Open();
                            for (int i = 0; i < featureDatasetInDs.FieldCount; i++)
                            {
                                GSOFieldAttr fieldInDs = featureDatasetInDs.GetField(i);
                                featureDatasetInTargetDs.AddField(fieldInDs);
                            }

                            //(2)向新的要素集写入数据
                            for (int i = 0; i < featureDatasetInDs.GetAllFeatures().Length; i++)
                            {
                                GSOFeature featureInDs       = featureDatasetInDs.GetFeatureAt(i);
                                GSOFeature featureInTargetDs = featureInDs.Clone();
                                featureInDs.Dispose();
                                featureDatasetInTargetDs.AddFeature(featureInTargetDs);
                            }
                            featureDatasetInTargetDs.Save();
                            featureDatasetInTargetDs.Close();
                            featureDatasetInDs.Close();

                            progressBar1.Value = j;
                        }
                        progressBar1.Visible = false;
                        MessageBox.Show("数据复制成功!", "提示");
                    }
                }
            }
        }
        private void btn_Union_Click(object sender, EventArgs e)
        {
            if (comboBoxTargetDataSource.SelectedItem == null)
            {
                MessageBox.Show("请选择目标数据源!", "提示");
                return;
            }
            string newLayerName = textBoxUnionLayerName.Text.Trim();

            if (newLayerName == "")
            {
                MessageBox.Show("请输入目标数据集名称!", "提示");
                return;
            }
            if (comboBoxDataSourceList1.SelectedItem == null)
            {
                MessageBox.Show("请选择要合并的数据源1!", "提示");
                return;
            }
            if (comboBoxUnionLayerList1.SelectedItem == null)
            {
                MessageBox.Show("请选择要合并的要素集1!", "提示");
                return;
            }
            if (comboBoxDataSourceList2.SelectedItem == null)
            {
                MessageBox.Show("请选择要合并的数据源2!", "提示");
                return;
            }
            if (comboBoxUnionLayerList2.SelectedItem == null)
            {
                MessageBox.Show("请选择要合并的要素集2!", "提示");
                return;
            }
            GSODataSource dsTarget = Utility.getDataSourceByFullName(globeControl1, comboBoxTargetDataSource.SelectedItem.ToString().Trim());

            if (dsTarget != null)
            {
                GSODataset dataset = dsTarget.GetDatasetByName(newLayerName);
                if (dataset != null)
                {
                    MessageBox.Show("目标数据集名称已存在目标数据源中!", "提示");
                    return;
                }
                GSOFeatureDataset featureDatasetInTargetDs = dsTarget.CreateFeatureDataset(newLayerName);
                if (featureDatasetInTargetDs == null)
                {
                    MessageBox.Show("目标数据集名称不符合要求!", "提示");
                    return;
                }
                GSODataSource dsUnion1 = Utility.getDataSourceByFullName(globeControl1, comboBoxDataSourceList1.SelectedItem.ToString().Trim());
                GSODataSource dsUnion2 = Utility.getDataSourceByFullName(globeControl1, comboBoxDataSourceList2.SelectedItem.ToString().Trim());
                if (dsUnion1 != null && dsUnion2 != null)
                {
                    GSOFeatureDataset datasetInUnionDs1 = dsUnion1.GetDatasetByName(comboBoxUnionLayerList1.SelectedItem.ToString().Trim()) as GSOFeatureDataset;
                    GSOFeatureDataset datasetInUnionDs2 = dsUnion1.GetDatasetByName(comboBoxUnionLayerList2.SelectedItem.ToString().Trim()) as GSOFeatureDataset;
                    if (datasetInUnionDs1 != null && datasetInUnionDs2 != null)
                    {
                        //判断要合并的数据集结构是否相同
                        datasetInUnionDs1.Open();
                        datasetInUnionDs2.Open();
                        if (datasetInUnionDs1.FieldCount != datasetInUnionDs2.FieldCount)
                        {
                            MessageBox.Show("要合并的数据集结构不相同,无法合并!", "错误");
                            return;
                        }
                        for (int i = 0; i < datasetInUnionDs1.FieldCount; i++)
                        {
                            if (datasetInUnionDs1.GetField(i).Equals(datasetInUnionDs2.GetField(i)) == false)
                            {
                                MessageBox.Show("要合并的数据集结构不相同,无法合并!", "错误");
                                return;
                            }
                        }
                        featureDatasetInTargetDs.Open();
                        for (int i = 0; i < datasetInUnionDs1.FieldCount; i++)
                        {
                            GSOFieldAttr fieldInUnionDs = datasetInUnionDs1.GetField(i);
                            featureDatasetInTargetDs.AddField(fieldInUnionDs);
                        }
                        //向新的数据集写入数据
                        for (int i = 0; i < datasetInUnionDs1.GetAllFeatures().Length; i++) //循环添加第一个要素集的所有feature到新数据集中
                        {
                            GSOFeature featureInUnionDs1 = datasetInUnionDs1.GetFeatureAt(i);
                            GSOFeature featureInTargetDs = featureInUnionDs1.Clone();
                            featureDatasetInTargetDs.AddFeature(featureInTargetDs);
                        }
                        for (int i = 0; i < datasetInUnionDs2.GetAllFeatures().Length; i++) //循环添加第一个要素集的所有feature到新数据集中
                        {
                            GSOFeature featureInUnionDs2 = datasetInUnionDs2.GetFeatureAt(i);
                            GSOFeature featureInTargetDs = featureInUnionDs2.Clone();
                            featureDatasetInTargetDs.AddFeature(featureInTargetDs);
                        }
                        featureDatasetInTargetDs.Save();
                        featureDatasetInTargetDs.Close();
                        datasetInUnionDs1.Close();
                        datasetInUnionDs2.Close();
                        MessageBox.Show("数据集合并成功!", "提示");
                        this.Close();
                    }
                }
            }
        }
예제 #6
0
        private bool apply()
        {
            double waveSpeedX = 0;

            if (!double.TryParse(textBoxWaveSpeedX.Text.Trim(), out waveSpeedX))
            {
                MessageBox.Show("水波横向速度不符合要求");
                return(false);
            }
            double waveSpeedY = 0;

            if (!double.TryParse(textBoxWaveSpeedY.Text.Trim(), out waveSpeedY))
            {
                MessageBox.Show("水波纵向速度不符合要求");
                return(false);
            }
            double waveWidth = 0;

            if (!double.TryParse(textBoxWaveWidth.Text.Trim(), out waveWidth))
            {
                MessageBox.Show("水波宽度不符合要求");
                return(false);
            }
            Color       waterColor          = pictureBoxWaterColor.BackColor;
            Color       reflectorColor      = Color.FromArgb(Convert.ToByte(upDownReflectOpaque.Value), pictureBoxReflectColor.BackColor);
            int         intLightType        = comboBoxLightType.SelectedIndex;
            string      waveNormalImagePath = textBoxNormalImage.Text;
            string      waveDuDvImagePath   = textBoxDuDvImage.Text;
            GSOFeatures featuresAdded       = new GSOFeatures();
            GSOFeatures featuresNomal       = new GSOFeatures();

            for (int i = mFeatures.Length - 1; i >= 0; i--)
            {
                GSOFeature feature = mFeatures[i];
                if (feature != null && feature.Geometry != null)
                {
                    if (feature.Geometry.Type == EnumGeometryType.GeoPolygon3D)
                    {
                        GSOGeoPolygon3D geoPolygon3d = (GSOGeoPolygon3D)feature.Geometry;
                        GSOGeoWater     geoWater     = geoPolygon3d.ConvertToGeoWater();
                        // 水一般都是绝对高度模式
                        //geoWater.Altitude = EnumAltitudeMode.Absolute;

                        geoWater.WaveSpeedX      = waveSpeedX;
                        geoWater.WaveSpeedY      = waveSpeedY;
                        geoWater.WaveWidth       = waveWidth;
                        geoWater.WaterColor      = waterColor;
                        geoWater.ReflectColor    = reflectorColor;
                        geoWater.WaveNormalImage = waveNormalImagePath;
                        geoWater.WaveDuDvImage   = waveDuDvImagePath;
                        geoWater.ReflectSky      = checkboxReflectSky.Checked;
                        geoWater.UseWaveLOD      = checkBoxWaveLOD.Checked;


                        GSOFeature newFeature = feature.Clone();
                        geoWater.Play();
                        newFeature.Geometry = geoWater;

                        featuresAdded.Add(newFeature);
                    }
                    else if (feature.Geometry.Type == EnumGeometryType.GeoWater)
                    {
                        GSOGeoWater geoWater = (GSOGeoWater)feature.Geometry;
                        // 水一般都是绝对高度模式
                        //geoWater.Altitude = EnumAltitudeMode.Absolute;

                        geoWater.WaveSpeedX      = waveSpeedX;
                        geoWater.WaveSpeedY      = waveSpeedY;
                        geoWater.WaveWidth       = waveWidth;
                        geoWater.WaterColor      = waterColor;
                        geoWater.ReflectColor    = reflectorColor;
                        geoWater.WaveNormalImage = waveNormalImagePath;
                        geoWater.WaveDuDvImage   = waveDuDvImagePath;
                        geoWater.ReflectSky      = checkboxReflectSky.Checked;
                        geoWater.UseWaveLOD      = checkBoxWaveLOD.Checked;

                        GSOFeature newFeature = feature.Clone();
                        geoWater.Play();
                        newFeature.Geometry = geoWater;

                        featuresAdded.Add(newFeature);
                    }
                    else
                    {
                        featuresNomal.Add(feature);
                    }
                }
            }
            mLayer.RemoveAllFeature();
            mLayer.AddFeatures(featuresAdded);
            mLayer.AddFeatures(featuresNomal);
            mGlobeControl.Refresh();
            return(true);
        }
        //应用
        private void buttonApply_Click(object sender, EventArgs e)
        {
            if (comboBoxLayerCaption.SelectedItem == null)
            {
                MessageBox.Show("请选择一个管线图层!", "提示");
                return;
            }
            if (comboBoxLayerValveCaption.SelectedItem == null)
            {
                MessageBox.Show("请选择一个工井图层!", "提示");
                return;
            }
            if (textBoxValueIndented.Text.Trim() == "")
            {
                MessageBox.Show("请输入缩进距离!", "提示");
                return;
            }
            if (textBoxAllowance.Text.Trim() == "")
            {
                MessageBox.Show("请输入容限值!", "提示");
                return;
            }

            double valueAllowance = 0.0;

            if (double.TryParse(textBoxAllowance.Text.Trim(), out valueAllowance) == false)
            {
                MessageBox.Show("请输入一个正确的容限值!", "提示");
                return;
            }

            float valueIndented = 0.0f;

            if (float.TryParse(textBoxValueIndented.Text.Trim(), out valueIndented) == false)
            {
                MessageBox.Show("请输入一个正确的缩进值!", "提示");
                return;
            }

            string   layerCaption      = comboBoxLayerCaption.SelectedItem.ToString().Trim();
            string   valveLayerCaption = comboBoxLayerValveCaption.SelectedItem.ToString().Trim();
            GSOLayer layer             = globeControl1.Globe.Layers.GetLayerByCaption(layerCaption);
            GSOLayer valveLayer        = globeControl1.Globe.Layers.GetLayerByCaption(valveLayerCaption);

            if (layer != null && valveLayerCaption != null)
            {
                featuresIndented.RemoveAll();
                cancelHighLight(layer.GetAllFeatures());


                for (int i = 0; i < layer.GetAllFeatures().Length; i++)
                {
                    GSOFeature feature = layer.GetAt(i);
                    if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D)
                    {
                        GSOGeoPolyline3D line       = feature.Geometry as GSOGeoPolyline3D;
                        double           lineLenght = line.GetSpaceLength(false, 6378137.0);
                        if (lineLenght <= valueIndented * 2)
                        {
                            continue;
                        }

                        featuresIndented.Add(feature);//缩进的管线集合
                        featuresInit.Add(feature.Clone());

                        //头缩进
                        GSOPoint3d       headPoint = line[0][0];
                        GSOGeoPolyline3D newline   = new GSOGeoPolyline3D();
                        GSOPoint3ds      part      = new GSOPoint3ds();
                        part.Add(headPoint);
                        headPoint.X = headPoint.X - 0.0000000005;
                        part.Add(headPoint);
                        newline.AddPart(part);
                        GSOGeoPolygon3D buffer   = newline.CreateBuffer(valueAllowance, true, 5, true, false);
                        GSOFeatures     features = valveLayer.FindFeaturesInPolygon(buffer, false);
                        if (features.Length > 0)
                        {
                            feature.HighLight = true;
                            if (line.Style != null && line.Style is GSOPipeLineStyle3D)
                            {
                                GSOPipeLineStyle3D style = line.Style as GSOPipeLineStyle3D;
                                style.HeadJointParam        = new GSOPipeJointParam();
                                style.HeadJointParam.Extent = -valueIndented;
                            }
                        }

                        //尾缩进
                        GSOPoint3d tailPoint = line[line.PartCount - 1][line[line.PartCount - 1].Count - 1];
                        newline = new GSOGeoPolyline3D();
                        part    = new GSOPoint3ds();
                        part.Add(tailPoint);
                        tailPoint.X = tailPoint.X - 0.0000000005;
                        part.Add(tailPoint);
                        newline.AddPart(part);
                        buffer   = newline.CreateBuffer(valueAllowance, true, 5, true, false);
                        features = valveLayer.FindFeaturesInPolygon(buffer, false);
                        if (features.Length > 0)
                        {
                            feature.HighLight = true;
                            if (line.Style != null && line.Style is GSOPipeLineStyle3D)
                            {
                                GSOPipeLineStyle3D style = line.Style as GSOPipeLineStyle3D;
                                style.TailJointParam        = new GSOPipeJointParam();
                                style.TailJointParam.Extent = -valueIndented;
                            }
                        }
                    }
                }
            }
            globeControl1.Globe.Refresh();
        }
예제 #8
0
파일: MainFrm.cs 프로젝트: StarU/qkKL6Dgf12
        private GSOAniObjTimeLine createKeyFrame(GSOAniObjTimeLine timeLine, GSOFeature featureAboutAnimation)
        {
            if (timeLine == null || featureAboutAnimation == null || featureAboutAnimation.Geometry == null)
            {
                return null;
            }
            GSOFeature feature = featureAboutAnimation.Clone();
            if (feature.Geometry.Style == null || feature.Geometry.Style is GSOSimpleLineStyle3D)
            {
                feature.Geometry.Style = new GSOPipeLineStyle3D();
            }
            feature.Geometry.AltitudeMode = EnumAltitudeMode.RelativeToGround;
            ((GSOGeoPolyline3D)feature.Geometry).SmoothToSpline();
            ((GSOStyle3D)feature.Geometry.Style).UsingBlur = true;
            globeControl1.Globe.MemoryLayer.AddFeature(feature);

            GSOAniFeature featureAnimation = new GSOAniFeature();//动画的类型--要素动画
            featureAnimation.Feature = feature;                  //动画的关联对象

            GSOAniEffectLineGrow effect = new GSOAniEffectLineGrow();//动画效果-线增长动画
            effect.StartValue = 0;
            effect.EndValue = 1;
            effect.FrameCount = 1200;
            effect.RepeatCount = 1;
            //effect.IsSmooth = false;

            GSOAniKeyFrame keyFream = new GSOAniKeyFrame(); //关键帧
            keyFream.Frame = 0;
            keyFream.AddEffect(effect);                     //给关键帧添加动画效果

            timeLine.AddKeyFrame(keyFream);
            return timeLine;
        }