示例#1
0
        protected void DoTree(TreeNode parent, RCOperator right, ref double a, ref double g)
        {
            // This is not quite correct. Operators should have more space allocated like
            // blocks.
            // And not always assigned an area of one. TestTree16 and others will have to
            // change.
            TreeNode opNode = new TreeNode(parent, null, 0);

            opNode.n = 1;
            opNode.m = 1;
            opNode.g = 1;
            opNode.v = right.ToString();
            a       += opNode.n;
            g       += Math.Abs(opNode.n);
        }
示例#2
0
        protected void DoChart(RCCube result,
                               RCSymbolScalar parent,
                               ref long row,
                               long col,
                               RCBlock
                               right)
        {
            for (int i = 0; i < right.Count; ++i)
            {
                RCBlock current   = right.GetName(i);
                object  shortName = current.Name;
                if (shortName.Equals(""))
                {
                    shortName = (long)i;
                }
                RCSymbolScalar name = new RCSymbolScalar(parent, shortName);
                RCSymbolScalar cell = RCSymbolScalar.From(row, col, 0L);
                result.WriteCell("r", cell, row);
                result.WriteCell("c", cell, col);
                result.WriteCell("l", cell, 0L);
                result.WriteCell("k", cell, name);
                result.WriteCell("v", cell, shortName is long?shortName.ToString() : shortName);
                result.Axis.Write(cell);
                RCVectorBase vector = current.Value as RCVectorBase;
                if (vector != null)
                {
                    ++col;
                    switch (vector.TypeCode)
                    {
                    case 'l': DoChart <long> (result, name, row, col, (RCVector <long>)vector); break;

                    case 'd': DoChart <double> (result, name, row, col, (RCVector <double>)vector); break;

                    case 'm': DoChart <decimal> (result, name, row, col, (RCVector <decimal>)vector); break;

                    case 's': DoChart <string> (result, name, row, col, (RCVector <string>)vector); break;

                    case 'x': DoChart <byte> (result, name, row, col, (RCVector <byte>)vector); break;

                    case 'y': DoChart <RCSymbolScalar> (result,
                                                        name,
                                                        row,
                                                        col,
                                                        (RCVector <RCSymbolScalar>)vector); break;

                    case 'b': DoChart <bool> (result, name, row, col, (RCVector <bool>)vector); break;

                    default: throw new Exception("Unknown typecode: " + vector.TypeCode);
                    }
                    --col;
                    ++row;
                    continue;
                }
                RCBlock block = current.Value as RCBlock;
                if (block != null)
                {
                    ++col;
                    ++row;
                    DoChart(result, name, ref row, col, block);
                    --col;
                    continue;
                }
                RCOperator oper = current.Value as RCOperator;
                if (oper != null)
                {
                    ++col;
                    string val = oper.ToString();
                    cell = RCSymbolScalar.From(row, col, 0L);
                    result.WriteCell("r", cell, (long)row);
                    result.WriteCell("c", cell, (long)col);
                    result.WriteCell("l", cell, 0L);
                    result.WriteCell("k", cell, new RCSymbolScalar(name, 0L));
                    result.WriteCell("v", cell, val);
                    result.Write(cell);
                    ++row;
                    --col;
                    continue;
                }
                RCReference reference = current.Value as RCReference;
                if (reference != null)
                {
                    ++col;
                    string val = reference.ToString();
                    cell = RCSymbolScalar.From(row, col, 0L);
                    result.WriteCell("r", cell, (long)row);
                    result.WriteCell("c", cell, (long)col);
                    result.WriteCell("l", cell, 0L);
                    result.WriteCell("k", cell, new RCSymbolScalar(name, 0L));
                    result.WriteCell("v", cell, val);
                    result.Write(cell);
                    ++row;
                    --col;
                    continue;
                }
                RCCube cube = current.Value as RCCube;
                if (cube != null)
                {
                    ++col;
                    ++row;
                    DoChart(result, name, ref row, col, cube);
                    ++row;
                    --col;
                    continue;
                }
            }
        }