Exemple #1
0
 private void PointAway(out double xMax, out double yMax, out double xMin, out double yMin)
 {
     xMax = XRange.Max();
     yMax = YValues.Max();
     xMin = XRange.Min();
     yMin = YValues.Min();
 }
Exemple #2
0
        public void GblSettings_ForList2()
        {
            int[]        mfnList  = new XRange(100, 200).ToArray();
            const string database = "ISTU";

            GblStatement[] statements =
            {
                new GblStatement(),
                new GblStatement(),
                new GblStatement()
            };
            IrbisConnection connection = new IrbisConnection();
            GblSettings     settings   = GblSettings.ForList
                                         (
                connection,
                database,
                mfnList,
                statements
                                         );

            Assert.AreEqual(database, settings.Database);
            Assert.AreEqual(0, settings.MinMfn);
            Assert.AreEqual(0, settings.MaxMfn);
            Assert.IsNotNull(settings.MfnList);
            Assert.AreEqual(mfnList.Length, settings.MfnList.Length);
        }
Exemple #3
0
 //初始化RANGE
 private void initRange()
 {
     foreach (DataCfg cfg in cfgdata.datas)           //遍历RANGE配置
     {
         XRange range = XRangeFactory.getXRange(cfg); //工厂模式,根据配置生成实际FORM/RANGE/TABLE 对象
         try
         {
             range.init(cfg, book);         //range 初始化
             ranges.Add(range.Name, range); //将 range 放入集合,后续可根据range名获取range
             if (range.getRange() == null)  //如果对应的工作表中range区域 不存在,则报错,并将系统状态设置为Designer状态
             {
                 AlertUtil.Show("error", "Range对应命名区域不存在或配置异常,RangeId:" + cfg.RangeName + " 即将进入Designer模式");
                 statu = SysStatu.Designer;
             }
         }
         catch (Exception e)
         {
             Console.WriteLine(e.ToString());
             MessageBox.Show("Range对应命名区域不存在或配置异异常,RangeId:" + cfg.RangeName + "\n" + e.ToString());
             this.statu = SysStatu.RangeError;
             return;
         }
     }
     if (ranges.Count == 0)
     {
         this.statu = SysStatu.Designer;
         AlertUtil.Show("info", "未查询到有效DATA,进入设计模式!");
     }
 }
Exemple #4
0
 internal void AddFeature(uint id, Envelope geometry, Interval?zRange, Interval?mRange)
 {
     NumRecords++;
     XRange = XRange.ExpandedByInterval(Interval.Create(geometry.MinX, geometry.MaxX));
     YRange = YRange.ExpandedByInterval(Interval.Create(geometry.MinY, geometry.MaxY));
     ZRange = ZRange.ExpandedByInterval(zRange ?? Interval.Create());
     MRange = MRange.ExpandedByInterval(mRange ?? Interval.Create());
 }
Exemple #5
0
        public XRange StartRange(FrameRecord fr)
        {
            XRange activeRange = new XRange();

            activeRange.Start = fr;
            Ranges.Add(activeRange);
            return(activeRange);
        }
Exemple #6
0
 public void executeCmd(XRange range, SysEvent e, int id)
 {
     if (range != null)
     {
         XCommand cmd = range.getCommandByEvent(e, id);
         executeCmd(cmd);
     }
 }
Exemple #7
0
        //根据CfgCommand 初始化单个command
        private void initCommand(CommandCfg cmdcfg)
        {
            XCommand cmd = new XCommand(cmdcfg);

            commands.Add(cmd.CommandName, cmd);
            XRange range = getRangeByName(cmd.cfg.RangeName);

            range.setCommand(cmd);
        }
Exemple #8
0
        private void UpdateRanges()
        {
            XRange.Freeze();
            YRange.Freeze();

            XRange.Update(0, 0);
            YRange.Update(0, 0);

            d_sortedData = null;
            bool makesorted = false;

            for (int i = 0; i < d_data.Count; ++i)
            {
                Point p = d_data[i];

                if (i == 0 || p.X < XRange.Min)
                {
                    XRange.Min = p.X;
                }

                if (i == 0 || p.X > XRange.Max)
                {
                    XRange.Max = p.X;
                }

                if (i == 0 || p.Y < YRange.Min)
                {
                    YRange.Min = p.Y;
                }

                if (i == 0 || p.Y > YRange.Max)
                {
                    YRange.Max = p.Y;
                }

                if (makesorted)
                {
                    d_sortedData.Add(p);
                }

                if (i != 0 && !makesorted && d_data[i - 1].X > p.X)
                {
                    makesorted = true;

                    d_sortedData = new SortedList <Point>(new PointComparer());

                    for (int j = 0; j <= i; ++j)
                    {
                        d_sortedData.Add(d_data[i]);
                    }
                }
            }

            XRange.Thaw();
            YRange.Thaw();
        }
        public Range3Single Intersect(Range3Single other)
        {
            var xrange = XRange.Intersect(other.XRange);
            var yrange = YRange.Intersect(other.YRange);
            var zrange = ZRange.Intersect(other.ZRange);

            return(new Range3Single
                       (new Vector3(xrange.Min, yrange.Min, zrange.Min),
                       new Vector3(xrange.Max, yrange.Max, zrange.Max)));
        }
Exemple #10
0
        //根据当前选择点,判断选择区域
        public void setSelectedNamed()
        {
            if (app == null)
            {
                app       = new XApp(this.spreadsheetMain.Document, null);
                app.statu = SysStatu.SheetError;
            }
            AreasCollection areas = spreadsheetMain.Selection.Areas;

            /*if (currentXRange != null && RangeUtil.isInRange(areas, currentXRange.getRange()) < 0)
             * {
             *  this.currentXRange = null;
             * }*/
            this.currentXRange = null;
            rightClickBarManager.SetPopupContextMenu(spreadsheetMain, null);
            if (currentSheet != null && currentSheet.sheetName == "Config")
            {
                IList <Table> tables = spreadsheetMain.ActiveWorksheet.Tables.GetTables(spreadsheetMain.ActiveCell);
                if (tables.Count > 0 && tables[0].Name == "CFG_DATA")
                {
                    if (RangeUtil.isInRange(areas, tables[0].DataRange) >= 0)
                    {
                        rightClickBarManager.SetPopupContextMenu(spreadsheetMain, menus["CfgData"]);
                    }
                }
            }
            else if ((int)app.statu > 0)
            {
                XRSheet opSheet = app.getRSheetByName(spreadsheetMain.ActiveWorksheet.Name);
                //遍历当前Sheet全部命名区域,依次判断是否在区域范围内
                if (opSheet != null)
                {
                    foreach (var dicname in opSheet.ranges)
                    {
                        XRange xname = dicname.Value;
                        int    i     = xname.isInRange(areas);
                        if (i >= 0)
                        {
                            this.currentXRange = xname;
                            rightClickBarManager.SetPopupContextMenu(spreadsheetMain, menus["Normal"]);
                            //当选择点为命名区域时,将当前坐标写入单元格
                            //this.currentXRange.onMouseDown();
                            break;//如果判断到第一个区域,将该区域存储为currentXRange,退出循环判断
                        }
                    }
                }
                else
                {
                    currentXRange = null;
                }
            }
        }
Exemple #11
0
        //根据名称获取RANGE
        public XRange getRangeByName(String name)
        {
            XRange range = null;

            try
            {
                range = ranges[name];
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show("RANGE:" + name + "未注册!请检查配置!");
                MessageBox.Show(e.ToString());
            }
            return(range);
        }
Exemple #12
0
        public PRange()
        {
            m_nSelect = 0;
            m_dCalL   = 1.0;
            m_dCalH   = 1.0;

            m_dMinL = -100000.0;
            m_dMaxL = 100000.0;
            m_dMinH = -100000.0;
            m_dMaxH = 100000.0;

            m_sFormatL     = "{0:F1}";
            m_sFormatH     = "{0:F1}";
            m_cBolderColor = Color.DarkBlue;
            m_cValueColor  = Color.White;
            InitializeComponent();
            m_xRange = new XRange();
        }
Exemple #13
0
            public long TraverseMapAndCount(Vector2Int slope)
            {
                var treeCount = 0;
                var position  = new Vector2Int(XRange.Min, YRange.Max) + slope;

                while (map.ContainsKey(position))
                {
                    var value = map[position];
                    if (value == '#')
                    {
                        treeCount++;
                    }

                    position  += slope;
                    position.x = XRange.Wrap(position.x);
                }

                return(treeCount);
            }
Exemple #14
0
        public static XRange getXRange(DataCfg cfg)
        {
            XRange named    = null;
            String nametype = cfg.RangeName.Split('_')[0];

            //XNamedTable
            try
            {
                nametype = "XSheet.v2.Data.XSheetRange.XRange" + nametype.ToUpper();
                Console.WriteLine(nametype);
                Type type = Type.GetType(nametype, true);
                named = (XRange)Activator.CreateInstance(type);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                System.Windows.Forms.MessageBox.Show("DATA:" + cfg.TableTitle + "无法识别类型:" + nametype);
            }
            return(named);
        }
Exemple #15
0
        public String executeCmd(XRange range, SysEvent e)
        {
            String ans = "";
            Dictionary <int, XCommand> cmds = range.getCommandByEvent(e);

            if (cmds != null)
            {
                foreach (XCommand cmd in cmds.Values)
                {
                    if (CheckPrivilege(cmd))
                    {
                        ans = executeCmd(cmd);
                        if (ans.ToUpper() != "OK")
                        {
                            return("FAILED");
                        }
                    }
                }
            }
            return(ans);
        }
Exemple #16
0
        public override void Interpolate(Point3d position, Voxel voxel)
        {
            voxel.Position.X = position.X;
            voxel.Position.Y = position.Y;
            voxel.Position.Z = position.Z;

            if (!XRange.Contains(position.X) || !YRange.Contains(position.Y) || !ZRange.Contains(position.Z))
            {
                voxel.Value = 0;
            }
            else
            {
                float x0 = 0, x1 = 0, y0 = 0, y1 = 0, z0 = 0, z1 = 0;
                int   ix0 = 0, ix1 = 0, iy0 = 0, iy1 = 0, iz0 = 0, iz1 = 0;

                if (ConstantGridSpacing)
                {
                    ix0 = (int)((position.X - XCoords[0]) / GridSpacing.X);
                    ix1 = ix0 == XCoords.Length - 1 ? ix0 : ix0 + 1;
                    x0  = (float)XCoords[ix0];
                    x1  = (float)XCoords[ix1];
                    iy0 = (int)((position.Y - YCoords[0]) / GridSpacing.Y);
                    iy1 = iy0 == YCoords.Length - 1 ? iy0 : iy0 + 1;
                    y0  = (float)YCoords[iy0];
                    y1  = (float)YCoords[iy1];
                    if (GridSpacing.Z != 0)
                    {
                        iz0 = (int)((position.Z - ZCoords[0]) / GridSpacing.Z);
                        iz1 = iz0 == ZCoords.Length - 1 ? iz0 : iz0 + 1;
                        z0  = (float)ZCoords[iz0];
                        z1  = (float)ZCoords[iz1];
                    }
                    else
                    {
                        iz0 = 0; iz1 = 0;
                        z0  = (float)ZCoords[iz0];
                        z1  = (float)ZCoords[iz1];
                    }
                }
                else
                {
                    var xt = binarySearchForSurroundingCoords(position.X, XCoords);
                    x0  = (float)xt.Item1;
                    x1  = (float)xt.Item2;
                    ix0 = xt.Item3;
                    ix1 = xt.Item4;
                    var yt = binarySearchForSurroundingCoords(position.Y, YCoords);
                    y0  = (float)yt.Item1;
                    y1  = (float)yt.Item2;
                    iy0 = yt.Item3;
                    iy1 = yt.Item4;
                    var zt = binarySearchForSurroundingCoords(position.Z, ZCoords);
                    z0  = (float)zt.Item1;
                    z1  = (float)zt.Item2;
                    iz0 = zt.Item3;
                    iz1 = zt.Item4;
                }
                float xd;
                if (x1 == x0)
                {
                    xd = 0;
                }
                else
                {
                    xd = (float)(position.X - x0) / (x1 - x0);
                }
                double yd;
                if (y1 == y0)
                {
                    yd = 0;
                }
                else
                {
                    yd = (position.Y - y0) / (y1 - y0);
                }
                double zd;
                if (z1 == z0)
                {
                    zd = 0;
                }
                else
                {
                    zd = (position.Z - z0) / (z1 - z0);
                }
                float c00 = Data[ix0, iy0, iz0] * (1 - xd) + Data[ix1, iy0, iz0] * xd;
                float c01 = Data[ix0, iy0, iz1] * (1 - xd) + Data[ix1, iy0, iz1] * xd;
                float c10 = Data[ix0, iy1, iz0] * (1 - xd) + Data[ix1, iy1, iz0] * xd;
                float c11 = Data[ix0, iy1, iz1] * (1 - xd) + Data[ix1, iy1, iz1] * xd;
                float c0  = (float)(c00 * (1 - yd) + c10 * yd);
                float c1  = (float)(c01 * (1 - yd) + c11 * yd);
                float c   = (float)(c0 * (1 - zd) + c1 * zd);

                voxel.Value = c;
            }
        }
Exemple #17
0
 public override string ToString()
 {
     return($"(XRange = {XRange.ToString()}, YRange = {YRange.ToString()}, ZRange = {ZRange.ToString()})");
 }
Exemple #18
0
 public XRange EndRange(FrameRecord fr, XRange activeRange)
 {
     activeRange.End = fr;
     return(null);
 }
Exemple #19
0
        //通用事件响应,用于调用各类事件
        public void EventCall(SysEvent e, int i)
        {
            if (e == SysEvent.Btn_New)//NEW按钮
            {
                if (currentXRange.getDataTable() == null)
                {
                    executer.executeCmd(currentXRange, SysEvent.Btn_Search);
                }
                ChangeToStatu(SysStatu.Insert);

                currentXRange.newData(1);
            }
            else if (e == SysEvent.Btn_Edit)//EDIT按钮
            {
                ChangeToStatu(SysStatu.Update);
            }
            else if (e == SysEvent.Btn_Delete)//DELETE按钮
            {
                ChangeToStatu(SysStatu.Delete);
            }
            else if (e == SysEvent.Btn_Search)//SEARC按钮
            {
                executer.executeCmd(currentXRange, e, i);
            }
            else if (e == SysEvent.Btn_Save)//SAVE按钮
            {
                switch (app.statu)
                {
                case SysStatu.Designer:
                    break;

                case SysStatu.Single:
                    break;

                case SysStatu.Muilti:
                    break;

                case SysStatu.Update:
                    executer.executeCmd(currentXRange, SysEvent.Btn_Edit, i);
                    ChangeToStatu(muiltiFlag ? SysStatu.Muilti : SysStatu.Single);
                    break;

                case SysStatu.Delete:
                    executer.executeCmd(currentXRange, SysEvent.Btn_Delete, i);
                    ChangeToStatu(muiltiFlag ? SysStatu.Muilti : SysStatu.Single);
                    break;

                case SysStatu.Insert:
                    executer.executeCmd(currentXRange, SysEvent.Btn_New, i);
                    ChangeToStatu(muiltiFlag ? SysStatu.Muilti : SysStatu.Single);
                    break;

                case SysStatu.Error:
                    break;

                case SysStatu.AppError:
                    break;

                case SysStatu.RangeError:
                    break;

                case SysStatu.SheetError:
                    break;

                case SysStatu.CommandError:
                    break;

                case SysStatu.ActionError:
                    break;

                default:
                    break;
                }
            }
            else if (e == SysEvent.Event_Search)//右键->查看数据时间
            {
                Table table = null;
                for (int ti = 0; ti < spreadsheetMain.ActiveWorksheet.Tables.Count; ti++)
                {
                    if (spreadsheetMain.ActiveWorksheet.Tables[ti].Name == "CFG_DATA")
                    {
                        table = spreadsheetMain.ActiveWorksheet.Tables[ti];
                        break;
                    }
                }
                if (table == null)
                {
                    return;
                }
                int row = spreadsheetMain.SelectedCell[0].TopRowIndex - table.Range.TopRowIndex - 1;
                int col = spreadsheetMain.SelectedCell[0].LeftColumnIndex - table.Range.LeftColumnIndex;
                //取数据
                string        text   = table.DataRange[row, 6].DisplayText;
                string        name   = table.DataRange[row, 7].DisplayText;
                string        DBType = table.DataRange[row, 5].DisplayText;
                List <string> sql    = new List <string>();
                sql.Add(text);
                XRange targetRange = app.getRangeByName(name);
                if (targetRange != null)
                {
                    targetRange.doSearch(sql);
                    targetRange.DspShow();
                }
                else
                {
                    DateTime time = new DateTime();
                    time = DateTime.Now;
                    string sheetName = time.ToString("yyyyMMddHHmmss");
                    spreadsheetMain.Document.Worksheets.Add(sheetName);
                    Worksheet    sheet = spreadsheetMain.Document.Worksheets[sheetName];
                    DbConnection conn  = DBUtil.getConnection(DBType);
                    DataTable    dt    = DBUtil.getDataTable(DBType, sql[0], "", "", conn);
                    sheet.Import(dt, true, 0, 0);
                    Table ntable = sheet.Tables.Add(sheet.Range.FromLTRB(0, 0, dt.Columns.Count, dt.Rows.Count), true);
                    ntable.Name = table.DataRange[row, 0].DisplayText;
                    table.DataRange[row, 7].Value = table.DataRange[row, 0].DisplayText;
                    ChangeToStatu(SysStatu.Designer);
                }
            }
            else if (app.statu > 0)
            {
                if (e == SysEvent.Btn_Cancel)
                {
                    ChangeToStatu(muiltiFlag ? SysStatu.Muilti : SysStatu.Single);
                    executer.executeCmd(currentXRange, SysEvent.Btn_Search, 0);
                }
                else if (e == SysEvent.Btn_Save)
                {
                    String ans = executer.executeCmd(currentXRange, e);
                    if (ans == "OK")
                    {
                        ChangeToStatu(muiltiFlag ? SysStatu.Muilti : SysStatu.Single);
                    }
                    else
                    {
                    }
                }
            }

            return;
        }
Exemple #20
0
        // ----------------------------------------------------------------------------------------
        #region WireframeDimensions

        public void UpdateDimensions(Single3 origin)
        {
            XRange = XRange.Add(origin.X);
            YRange = YRange.Add(origin.Y);
            ZRange = ZRange.Add(origin.Z);
        }
Exemple #21
0
        public override void Interpolate(Point3d position, Voxel voxel)
        {
            voxel.Position.X = position.X;
            voxel.Position.Y = position.Y;
            voxel.Position.Z = position.Z;

            if (!XRange.Contains(position.X) || !YRange.Contains(position.Y) || !ZRange.Contains(position.Z))
            {
                voxel.Value = DefaultPhysicalValue;
            }
            else
            {
                try
                {
                    //float x0 = 0, x1 = 0, y0 = 0, y1 = 0, z0 = 0, z1 = 0;
                    //int ix0 = 0, ix1 = 0, iy0 = 0, iy1 = 0, iz0 = 0, iz1 = 0;

                    if (ConstantGridSpacing)
                    {
                        ix0 = (int)((position.X - XCoords[0]) / GridSpacing.X);
                        if (ix0 >= XCoords.Length - 1)
                        {
                            ix1 = ix0 = XCoords.Length - 1;
                        }
                        else
                        {
                            ix1 = ix0 + 1;
                        }
                        x0 = XCoords[ix0];
                        x1 = XCoords[ix1];

                        iy0 = (int)((position.Y - YCoords[0]) / GridSpacing.Y);
                        if (iy0 >= YCoords.Length - 1)
                        {
                            iy1 = iy0 = YCoords.Length - 1;
                        }
                        else
                        {
                            iy1 = iy0 + 1;
                        }

                        y0 = YCoords[iy0];
                        y1 = YCoords[iy1];
                        if (GridSpacing.Z != 0)
                        {
                            iz0 = (int)((position.Z - ZCoords[0]) / GridSpacing.Z);
                            iz1 = iz0 + 1;

                            if (iz0 >= ZCoords.Length - 1)
                            {
                                iz1 = iz0 = ZCoords.Length - 1;
                            }
                            else
                            {
                                iz1 = iz0 + 1;
                            }

                            z0 = ZCoords[iz0];
                            z1 = ZCoords[iz1];
                        }
                        else
                        {
                            iz0 = 0; iz1 = 0;
                            z0  = ZCoords[iz0];
                            z1  = ZCoords[iz1];
                        }
                    }
                    else
                    {
                        var xt = binarySearchForSurroundingCoords(position.X, XCoords);
                        x0  = (float)xt.Item1;
                        x1  = (float)xt.Item2;
                        ix0 = xt.Item3;
                        ix1 = xt.Item4;
                        var yt = binarySearchForSurroundingCoords(position.Y, YCoords);
                        y0  = (float)yt.Item1;
                        y1  = (float)yt.Item2;
                        iy0 = yt.Item3;
                        iy1 = yt.Item4;
                        var zt = binarySearchForSurroundingCoords(position.Z, ZCoords);
                        z0  = (float)zt.Item1;
                        z1  = (float)zt.Item2;
                        iz0 = zt.Item3;
                        iz1 = zt.Item4;
                    }

                    voxel.Value = Interpolation.TrilinearInterpolate(
                        (float)position.X, (float)position.Y, (float)position.Z,
                        x0, y0, z0,
                        x1, y1, z1,
                        Data[getIndex(ix0, iy0, iz0)],
                        Data[getIndex(ix1, iy0, iz0)],
                        Data[getIndex(ix0, iy0, iz1)],
                        Data[getIndex(ix1, iy0, iz1)],
                        Data[getIndex(ix0, iy1, iz0)],
                        Data[getIndex(ix1, iy1, iz0)],
                        Data[getIndex(ix0, iy1, iz1)],
                        Data[getIndex(ix1, iy1, iz1)]);
                }
#pragma warning disable CS0168 // The variable 'e' is declared but never used
                catch (Exception e)
#pragma warning restore CS0168 // The variable 'e' is declared but never used
                {
                    voxel.Value = DefaultPhysicalValue;
                }
            }
        }
 public bool ContainsPoint(double x, double y, double z)
 {
     return(XRange.Contains(x) && YRange.Contains(y) && ZRange.Contains(z));
 }
Exemple #23
0
 public double Distance2(Vector2 point)
 {
     return(XRange.Distance2(point.X) + YRange.Distance2(point.Y));
 }