Beispiel #1
0
 public Fac(FacClassReg facClassReg, FacStyleClass style, IRowBuffer rowInfo)
 {
     this._facClassReg = facClassReg;
     this._rowInfo     = rowInfo;
     this._style       = style;
     this._geoGroup    = new IGeometry[3];
 }
Beispiel #2
0
 public PipeLineFac(FacClassReg facClassReg, FacStyleClass style, IRowBuffer rowInfo, TopoClass tc, bool isSBackhind = true, bool isEBackhind = true)
     : base(facClassReg, style, rowInfo)
 {
     this._tc          = tc;
     this._isSBackhind = isSBackhind;
     this._isEBackhind = isEBackhind;
     this.Init();
 }
Beispiel #3
0
 public PipeNodeFac(FacClassReg facClassReg, FacStyleClass style, IRowBuffer rowInfo, TopoClass tc)
     : base(facClassReg, style, rowInfo)
 {
     this._angleZ = -1.0;
     this._yaw    = 0;
     this._pitch  = 0;
     this._tc     = tc;
     this.Init();
 }
Beispiel #4
0
 public PipeBuildFac(FacClassReg facClass, FacStyleClass style, IRowBuffer rowInfo)
     : base(facClass, style, rowInfo)
 {
     this.Init();
 }
Beispiel #5
0
        private void CmdEditFacilityStyle_FacStyleClassChangedEvent(DF3DPipeCreateTool.Class.FacStyleClass style)
        {
            try
            {
                this.beforeRowBufferMap.Clear();
                if (style == null)
                {
                    return;
                }

                DF3DFeatureClass dffc = CommonUtils.Instance().CurEditLayer;
                if (dffc == null)
                {
                    return;
                }
                IFeatureClass fc = dffc.GetFeatureClass();
                if (fc == null)
                {
                    return;
                }
                FacClassReg reg = FacilityInfoService.GetFacClassRegByFeatureClassID(fc.GuidString);
                if (reg == null)
                {
                    return;
                }
                TopoClass tc = FacilityInfoService.GetTopoClassByFacClassCode(reg.FacClassCode);
                if (tc == null)
                {
                    return;
                }
                FacilityClass facc = reg.FacilityType;
                if (facc == null)
                {
                    return;
                }
                IResourceManager manager = fc.FeatureDataSet as IResourceManager;
                if (manager == null)
                {
                    return;
                }

                IFieldInfoCollection fields = fc.GetFields();
                //int indexGroupid = -1;
                //int indexClassify = -1;
                //SubClass sc = null;
                //MajorClass mc = LogicDataStructureManage3D.Instance.GetMajorClassByDFFeatureClassID(fc.GuidString);
                //if (mc != null)
                //{
                //    indexClassify = fields.IndexOf(mc.ClassifyField);
                //    indexGroupid = fields.IndexOf("GroupId");

                //}

                int index = fields.IndexOf("StyleId");
                if (index == -1)
                {
                    return;
                }
                int mnindex = fields.IndexOf("ModelName");
                int mpindex = fields.IndexOf("Geometry");
                if (mpindex == -1)
                {
                    return;
                }
                HashMap hm = SelectCollection.Instance().GetSelectGeometrys();
                if (hm != null && hm.Count == 1)
                {
                    IRowBufferCollection res = new RowBufferCollection();
                    IRowBufferCollection rowBufferCollection = hm[dffc] as IRowBufferCollection;
                    if (rowBufferCollection != null)
                    {
                        for (int i = 0; i < rowBufferCollection.Count; i++)
                        {
                            IRowBuffer  rowBuffer   = rowBufferCollection.Get(i);
                            Fac         fac         = null;
                            IModelPoint mp          = null;
                            IModel      finemodel   = null;
                            IModel      simplemodel = null;
                            string      name        = "";
                            switch (facc.Name)
                            {
                            case "PipeNode":
                                fac = new PipeNodeFac(reg, style, rowBuffer, tc);
                                break;

                            case "PipeLine":
                                fac = new PipeLineFac(reg, style, rowBuffer, tc, false, false);
                                break;

                            case "PipeBuild":
                            case "PipeBuild1":
                                fac = new PipeBuildFac(reg, style, rowBuffer);
                                break;
                            }
                            if (UCAuto3DCreate.RebuildModel(fac, style, out mp, out finemodel, out simplemodel, out name))
                            {
                                if (finemodel == null || mp == null)
                                {
                                    continue;
                                }
                                mp.ModelEnvelope = finemodel.Envelope;
                                rowBuffer.SetValue(mpindex, mp);
                                rowBuffer.SetValue(index, style.ObjectId);
                                //if (mc != null)
                                //{
                                //    if (indexClassify != -1 && indexGroupid != -1)
                                //    {

                                //    }
                                //}
                                bool bRes = false;
                                if (!string.IsNullOrEmpty(mp.ModelName))
                                {
                                    if (!manager.ModelExist(mp.ModelName))
                                    {
                                        if (manager.AddModel(mp.ModelName, finemodel, simplemodel))
                                        {
                                            bRes = true;
                                        }
                                    }
                                    else
                                    {
                                        if (manager.UpdateModel(mp.ModelName, finemodel) && manager.UpdateSimplifiedModel(mp.ModelName, simplemodel))
                                        {
                                            bRes = true;
                                        }
                                    }
                                }
                                if (bRes)
                                {
                                    res.Add(rowBuffer);
                                }
                            }
                        }
                    }
                    beforeRowBufferMap[dffc] = res;
                    //SelectCollection.Instance().Clear();
                    UpdateDatabase();
                    DF3DApplication app = DF3DApplication.Application;
                    if (app == null || app.Current3DMapControl == null)
                    {
                        return;
                    }
                    app.Current3DMapControl.FeatureManager.RefreshFeatureClass(fc);
                }
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #6
0
        public List <PipeLineFac> GetTopoPipeLine()
        {
            if (this._tc == null)
            {
                return(null);
            }
            if (DF3DPipeCreateApp.App.PipeLib == null)
            {
                return(null);
            }
            IQueryFilter filter = null;
            IFdeCursor   o      = null;
            IRowBuffer   r      = null;
            Dictionary <string, List <int> > dictionary  = null;
            Dictionary <string, FacClassReg> dictReg     = null;
            Dictionary <int, int>            dictionary2 = null;
            List <PipeLineFac> list = null;

            try
            {
                IFeatureDataSet fds = DF3DPipeCreateApp.App.PipeLib.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return(null);
                }
                IFeatureClass class2 = fds.OpenFeatureClass(this._tc.TopoTable);
                if (class2 == null)
                {
                    return(null);
                }
                filter = new QueryFilterClass
                {
                    WhereClause = string.Format("(P_FacClass = '{0}' and PNode = {1}) or (E_FacClass = '{0}' and ENode = {1})", this._facClassReg.FeatureClassId, base._oid),
                    SubFields   = "oid,A_FacClass,Edge,PNode,ENode"
                };
                int count = class2.GetCount(filter);
                if (count == 0)
                {
                    return(null);
                }
                dictionary  = new Dictionary <string, List <int> >();
                dictionary2 = new Dictionary <int, int>();
                dictReg     = new Dictionary <string, FacClassReg>();
                o           = class2.Search(filter, true);
                while ((r = o.NextRow()) != null)
                {
                    if (!r.IsNull(1) && !r.IsNull(2))
                    {
                        FacClassReg reg = GetFacClassReg(r.GetValue(1).ToString());
                        if (!dictionary.ContainsKey(reg.FacClassCode))
                        {
                            dictionary.Add(reg.FacClassCode, new List <int>());
                            dictReg.Add(reg.FacClassCode, reg);
                        }
                        dictionary[reg.FacClassCode].Add(Fac.GetInt(r, 2));
                        if (Fac.GetInt(r, 3) == this._oid)
                        {
                            dictionary2.Add(Fac.GetInt(r, 2), 0);
                        }
                        else
                        {
                            dictionary2.Add(Fac.GetInt(r, 2), 1);
                        }
                    }
                }
                if (dictionary.Count == 0)
                {
                    return(null);
                }
                list = new List <PipeLineFac>();
                foreach (KeyValuePair <string, List <int> > pair in dictionary)
                {
                    FacClassReg reg = dictReg[pair.Key];
                    if (reg.FacilityType.Name == "PipeLine")
                    {
                        IFeatureClass class3 = reg.GetFeatureClass();
                        o = class3.GetRows(pair.Value.ToArray(), false);
                        while ((r = o.NextRow()) != null)
                        {
                            int index = r.FieldIndex("StyleId");
                            if (index == -1)
                            {
                                continue;
                            }
                            FacStyleClass style = GetFacStyleByID(r.GetValue(index).ToString());
                            if (style != null)
                            {
                                PipeLineFac line = new PipeLineFac(reg, style, r, this._tc);
                                line.Tag = dictionary2[line.FeatureId];
                                list.Add(line);
                            }
                        }
                    }
                }
                return(list);
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                if (o != null)
                {
                    Marshal.ReleaseComObject(o);
                    o = null;
                }
                if (r != null)
                {
                    Marshal.ReleaseComObject(r);
                    r = null;
                }
            }
        }
Beispiel #7
0
        private FacStyleClass GetFacStyleByID(string styleId)
        {
            if (DF3DPipeCreateApp.App.TemplateLib == null)
            {
                return(null);
            }
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

            try
            {
                IFeatureDataSet fds = DF3DPipeCreateApp.App.TemplateLib.OpenFeatureDataset("DataSet_BIZ");
                if (fds == null)
                {
                    return(null);
                }
                IObjectClass oc = fds.OpenObjectClass("OC_FacilityStyle");
                if (oc == null)
                {
                    return(null);
                }

                IQueryFilter filter = new QueryFilterClass
                {
                    WhereClause = string.Format("ObjectId = '{0}'", styleId)
                };
                cursor = oc.Search(filter, true);
                List <FacStyleClass> list = new List <FacStyleClass>();
                while ((row = cursor.NextRow()) != null)
                {
                    StyleType     type;
                    FacStyleClass fs = null;
                    if (row.FieldIndex("StyleType") >= 0 && Enum.TryParse <StyleType>(row.GetValue(row.FieldIndex("StyleType")).ToString(), out type))
                    {
                        Dictionary <string, string> dictionary = null;
                        if (row.FieldIndex("StyleInfo") >= 0)
                        {
                            object obj = row.GetValue(row.FieldIndex("StyleInfo"));
                            if (obj != null)
                            {
                                IBinaryBuffer buffer2 = row.GetValue(row.FieldIndex("StyleInfo")) as IBinaryBuffer;
                                if (buffer2 != null)
                                {
                                    dictionary = JsonTool.JsonToObject <Dictionary <string, string> >(Encoding.UTF8.GetString(buffer2.AsByteArray()));
                                }
                            }
                        }
                        switch (type)
                        {
                        case StyleType.PipeNodeStyle:
                            fs = new PipeNodeStyleClass(dictionary);
                            break;

                        case StyleType.PipeLineStyle:
                            fs = new PipeLineStyleClass(dictionary);
                            break;

                        case StyleType.PipeBuildStyle:
                            fs = new PipeBuildStyleClass(dictionary);
                            break;
                        }
                    }
                    if (fs == null)
                    {
                        continue;
                    }
                    if (row.FieldIndex("oid") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("oid"));
                        if (obj != null)
                        {
                            fs.Id = int.Parse(obj.ToString());
                        }
                    }
                    if (row.FieldIndex("ObjectId") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("ObjectId"));
                        if (obj != null)
                        {
                            fs.ObjectId = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("FacClassCode") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("FacClassCode"));
                        if (obj != null)
                        {
                            fs.FacClassCode = obj.ToString();
                        }
                    }
                    if (row.FieldIndex("Name") >= 0)
                    {
                        object obj = row.GetValue(row.FieldIndex("Name"));
                        if (obj != null)
                        {
                            fs.Name = obj.ToString();
                        }
                    }
                    int index = row.FieldIndex("Thumbnail");
                    if (index != -1 && !row.IsNull(index))
                    {
                        IBinaryBuffer b = row.GetValue(index) as IBinaryBuffer;
                        if (row != null)
                        {
                            MemoryStream stream = new MemoryStream(b.AsByteArray());
                            fs.Thumbnail = Image.FromStream(stream);
                        }
                    }
                    return(fs);
                }
                return(null);
            }
            catch (Exception exception)
            {
                return(null);
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
            }
        }