Exemplo n.º 1
0
        // Summary:
        //     Build RowView index to object and vice versa.
        protected void buildRowViewIndex()
        {
            if (rawDataSet == null || rawDataSet.Tables.Count == 0)
            {
                return;
            }

            DataTable dt = rawDataSet.Tables[0];

            rowView2Obj = new Dictionary <DataRow, DGObject>();
            foreach (DGObject obj in _objs.Values)
            {
                rowView2Obj[obj.rawData] = obj;
            }

            obj2RowView = new Dictionary <DGObject, DataRow>();
            foreach (DataRow dr in dt.Rows)
            {
                if (rowView2Obj.ContainsKey(dr))
                {
                    // get the object using the DataRow as an index
                    //
                    DGObject obj = rowView2Obj[dr];
                    obj2RowView[obj] = dr;
                }
            }
        }
Exemplo n.º 2
0
        public bool load(DbContext dbContext)
        {
            rawDataSet = new DataSet(definition.Type);

            DGObject objHelper =
                ObjectHelper.CreateDGObjectFromSubclassName(definition.Type);
            bool success = objHelper.LoadObjs(this, dbContext);

            buildIDIndex();
            buildRowViewIndex();

            return(success);
        }
        // Read object (i.e., Name list) from the specified table.
        // REQUIREMENT:
        //      1. The specified table must have a 'Name' column.
        //
        public virtual bool ReadDGObjects(DGObjects objs, string tableNameSQL,
            string defNamesSQL, string orderSQL, string conditionSQL)
        {
            ReadRawData(objs, tableNameSQL, orderSQL, conditionSQL);

            DataTable table = objs.rawDataSet.Tables[0];
            foreach (DataRow row in table.Rows)
            {
                DGObject dgObj = new DGObject(row);

                try
                {
                    if (table.Columns.Contains("ID"))
                        dgObj.id = Convert.ToInt32(row["ID"]);

                    if (table.Columns.Contains("Name"))
                        dgObj.name = Convert.ToString(row["Name"]);

                    if (table.Columns.Contains("FullName"))
                        dgObj.fullName = ReadString(row, "FullName");

                    if (table.Columns.Contains("Description"))
                        dgObj.description = ReadString(row, "Description");

                    dgObj.shape = ReadShape(row);
                }
                catch (FormatException ex)
                {
                    string str = ex.ToString();
                    ErrorReport.Report(str);
                    continue;
                }
                objs[dgObj.id.ToString() + ":" + dgObj.name] = dgObj;
            }

            return true;
        }
Exemplo n.º 4
0
 public void highlightObject(DGObject obj, bool on = true)
 {
     if (obj == null || obj.parent == null)
         return;
     string layerID = obj.parent.definition.GISLayerName;
     IGraphicsLayer gLayer = _map.Layers[layerID] as IGraphicsLayer;
     if (gLayer == null)
         return;
     gLayer.highlightObject(obj, on);
 }
Exemplo n.º 5
0
        public static LPResult ProjectTunnel_LS(EngineeringMap targetEMap, DGObject obj, 
            ISpatialReference sp, DrawTunnelsSettings lsSettings)
        {
            IPolyline projLine = targetEMap.profileLine;
            if (projLine == null)
                return null;

            Tunnel tunnel = obj as Tunnel;
            if (tunnel.LineNo == null)
                return null;
            int lineNo = tunnel.LineNo.Value;
            double mapScale = targetEMap.Scale;

            Domain domain = Globals.project.getDomain(DomainType.Structure);
            DGObjectsCollection allAxes = domain.getObjects("TunnelAxis");
            TunnelAxis axis = allAxes[tunnel.id] as TunnelAxis;
            if (axis == null)
                return null;

            double distance = 0;
            IMapPoint pt = Runtime.geometryEngine.newMapPoint(0, 0, sp);
            IMapPoint prjPt = Runtime.geometryEngine.newMapPoint(0, 0,sp);
            List<IMapPoint> upperPnts = new List<IMapPoint>();
            List<IMapPoint> lowerPnts = new List<IMapPoint>();
            int num = axis.AxisPoints.Count;
            double height = 0.0;
            if (tunnel.Height != null)
                height = tunnel.Height.Value;

            TunnelAxis profileAxis = new TunnelAxis();
            List<TunnelAxisPoint> pts = new List<TunnelAxisPoint>();
            profileAxis.AxisPoints = pts;
            profileAxis.LineNo = lineNo;

            for (int i = 0; i < num; ++i)
            {
                TunnelAxisPoint axisPt = axis.AxisPoints[i];
                pt = Runtime.geometryEngine.newMapPoint(axisPt.X, axisPt.Y, sp);

                GeomUtil.ProjectPointToPolyline(pt,
                    projLine.GetPoints(), ref distance, ref prjPt);
                distance /= mapScale;
                distance += lsSettings.xOffset;

                double X = distance;
                double Y = (axisPt.Z + height / 2.0) * lsSettings.zScale;
                IMapPoint upperPnt = Runtime.geometryEngine.newMapPoint(X, Y, sp);
                upperPnts.Add(upperPnt);

                X = distance;
                Y = (axisPt.Z - height / 2.0) * lsSettings.zScale;
                IMapPoint lowerPnt = Runtime.geometryEngine.newMapPoint(X, Y, sp);
                lowerPnts.Add(lowerPnt);

                TunnelAxisPoint newPt = new TunnelAxisPoint();
                newPt.X = distance;
                newPt.Z = axisPt.Z * lsSettings.zScale;
                newPt.Mileage = axisPt.Mileage;
                profileAxis.AxisPoints.Add(newPt);
            }
            lowerPnts.Reverse();
            upperPnts.AddRange(lowerPnts);
            upperPnts.Add(upperPnts[0]);

            IPointCollection tunnelPnts = Runtime.geometryEngine.newPointCollection();
            foreach (IMapPoint mp in upperPnts)
                tunnelPnts.Add(mp);
            IGraphic g = Runtime.graphicEngine.newPolygon(tunnelPnts);

            ISimpleLineSymbol linesymbol = Runtime.graphicEngine.newSimpleLineSymbol(
                                Colors.Black, Core.Graphics.SimpleLineStyle.Solid, 0.5);
            ISymbol symbol = Runtime.graphicEngine.newSimpleFillSymbol(
                                Colors.Red, SimpleFillStyle.Solid, linesymbol);
            g.Symbol = symbol;

            LPResult result = new LPResult();
            result.id = obj.id;
            result.name = obj.id.ToString() + targetEMap.MapID;
            result.Obj = obj;
            result.Graphic = g;
            result.PlanAxis = axis;
            result.ProfileAxis = profileAxis;
            result.Setting = lsSettings;
            return result;
        }
Exemplo n.º 6
0
 public void highlightObject(DGObject obj, bool on = true){}
 /// <summary>
 /// get the value of a specific index at the specific date
 /// </summary>
 /// <param name="date"></param>
 /// <param name="index"></param>
 /// <returns></returns>
 //private double GetValueOfAIndex(DateTime date,int index)
 //{
 //}
 private List<IGrouping<string, DataRow>> GetDataRowsFromDgobject(DGObject dgobj)
 {
     try
     {
         DataTable _dt = dgobj.tableViews(new List<DGObject>() { dgobj })[1].Table;
         var _datarows = (from d in _dt.AsEnumerable()
                          group d by d.Field<DateTime>(_tiemFieldName).ToShortDateString() into _dateGroups
                          orderby _dateGroups.Key descending
                          select _dateGroups).ToList();
         return _datarows;
     }
     catch(Exception e)
     {
         return null;
     }
 }
        /// <summary>
        /// judge whether a dgobject  is index;
        /// </summary>
        /// <param name="_dgObj"></param>
        /// <returns></returns>
        private bool IsIndex(DGObject _dgObj)
        {
            bool result = false;

            return result;
        }
Exemplo n.º 9
0
 public int highlightObject(DGObject obj, bool on = true)
 {
     int count = 0;
     if (_obj2Graphics != null &&
         _obj2Graphics.ContainsKey(obj))
     {
         IGraphicCollection gc = _obj2Graphics[obj];
         foreach (IGraphic g in gc)
         {
             if (g.IsSelected != on)
                 g.IsSelected = on;
         }
     }
     return count;
 }
Exemplo n.º 10
0
 public IGraphicCollection getGraphics(DGObject obj)
 {
     if (_obj2Graphics == null)
         return null;
     if (_obj2Graphics.ContainsKey(obj))
         return _obj2Graphics[obj];
     else
         return null;
 }