예제 #1
0
        /// <summary>
        /// create new color enumeration based on a specific colormap
        /// </summary>
        /// <param name="basemap"></param>
        public ILColorEnumerator(Colormaps basemap)
        {
            ILColormap cm = new ILColormap(basemap);

            m_colors = new List <Color>();
            for (int i = 0; i < cm.Length; i++)
            {
                m_colors.Add(cm.Map(i));
            }
            m_curPos = 0;
        }
예제 #2
0
 private void create(ILBaseArray data, Colormaps colormap) {
     ILArray<float> dataF = ILNumerics.BuiltInFunctions.ILMath.tosingle(data); 
     m_boxes = new ILLitBox3D[data.Dimensions[0],data.Dimensions[1]];
     float maxY = data.Dimensions[0] * (m_barLengthY + m_paddingY);
     // prepare coloring for top quads 
     ILColormap cmap = new ILColormap(colormap); 
     float minV,maxV,mult;
     dataF.GetLimits(out minV, out maxV);
     if (maxV > minV) {
         mult = (cmap.Length - 1) / (maxV - minV);
     } else {
         minV = 0; 
         mult = 0;
     }
     for (int r = 0; r < data.Dimensions[0]; r++) {
         for (int c = 0; c < data.Dimensions[1]; c++) {
             float val = dataF.GetValue(r, c);  
             ILPoint3Df max = new ILPoint3Df(
                 (float)(c * (m_paddingX + m_barLengthX) + m_barLengthX)
                 , (float)(maxY - r * (m_paddingY + m_barLengthY))
                 , val);
             ILPoint3Df min = new ILPoint3Df(
                 max.X - m_barLengthX
                 , max.Y - m_barLengthY
                 , 0);
             Color topColor = cmap.Map((double)(val - minV) * mult); 
             ILLitBox3D box = new ILLitBox3D(m_panel,min,max,m_barColor,topColor);
             box.GradientColor = m_barColorGradient;
             box.TopLabel.Color = topColor;
             box.TopLabel.Text = ""; 
             m_boxes[r, c] = box; 
             Add(box); 
         }
     }
 }
예제 #3
0
            public static ILArray<int> configureVertices(
                    ILArray<float> xVals, ILArray<float> yVals,
                    ILArray<float> zVals, ILColormap cmap, C4fN3fV3f[] Vertices, byte opacity) {
                int i = 0, x, y, y0 = zVals.Dimensions[0] - 1;
                float minZ, maxZ;
                if (!zVals.GetLimits(out minZ, out maxZ,false))
                    minZ = maxZ = 1.0f;
                x = 0;
                y = 0;
                ILArray<float> colors = (tosingle((zVals - minZ) / (maxZ - minZ)))[":"] * (cmap.Length - 1);
                colors[isnan(colors)] = 0;
                bool useXvals = (xVals != null && !xVals.IsEmpty);
                bool useYvals = (yVals != null && !yVals.IsEmpty);
                foreach (float a in zVals.Values) {
                    C4fN3fV3f v = Vertices[i];
                    v.Position = new ILPoint3Df(
                         (useXvals)? xVals.GetValue(y,x): x 
                        ,(useYvals)? yVals.GetValue(y,x): y0 - y
                        , a);
                    byte r, g, b;
                    cmap.Map(colors.GetValue(i), out r, out g, out b);
                    v.Color = Color.FromArgb(255, r, g, b);
                    v.Alpha = opacity; 
                    Vertices[i++] = v;
                    // set next position
                    if (++y >= zVals.Dimensions[0]) {
                        x++;
                        y = 0;
                    }
                }

                // create quad indices
                int numQuad = (zVals.Dimensions[0] - 1) * (zVals.Dimensions[1] - 1);
                x = 0; y = 0;
                ILArray<double> ret = zeros(4, numQuad);
                ILArray<double> mult = counter(0.0, 1.0, zVals.Dimensions.ToIntArray());
                mult = mult["0:" + (zVals.Dimensions[0] - 2), "0:" + (zVals.Dimensions[1] - 2)];
                mult = mult[":"].T; 

                ret["0;:"] = mult;
                ret["3;:"] = mult + 1;
                mult = mult + zVals.Dimensions.SequentialIndexDistance(1); 
                ret["2;:"] = mult + 1;
                ret["1;:"] = mult; 
                return toint32(ret); 
            }
예제 #4
0
            internal static ILArray<double> CreateVertices(ILBaseArray dataInput 
                                            ,out ILArray<double> indices
                                            ,double beta, double scaling
                                            , ILColormap colormap) {
                // each arrow needs 4 vertices (indexed rendering)
                ILArray<double> data = todouble(dataInput);
                int numRows = data.Dimensions[0];
                int numCols = data.Dimensions[1];
                ILArray<double> ret = new ILArray<double>(4, numCols * numRows, 2);
                // prepare indices
                indices = repmat(new ILArray<double>(new double[] { 0, 2, 1, 2, 3, 2 }, 6, 1), 1, numCols * numRows);
                indices = indices + repmat(counter(0.0, 4.0, 1, numCols * numRows), 6, 1);
                indices = indices.Reshape(2, numRows * numCols * 3);
                // normalize incoming data to length 1.0 
                ILArray<double> l = sqrt(sum(data * data, 2));
                double maxL = (double)max(maxall(l),MachineParameterDouble.eps);
                l = (l / maxL)[":"].T * scaling;
                ILArray<double> alpha = atan2(data[":;:;1"], data[":;:;0"]);
                alpha = alpha[":"].T;
                ILArray<double> x = data[":;:;0"][":"].T * scaling;
                ILArray<double> y = data[":;:;1"][":"].T * scaling;
                ILArray<double> xO = repmat(linspace(1, numCols, numCols), numRows, 1)[":"].T;
                ILArray<double> yO = repmat(linspace(numRows, 1, numRows).T, 1, numCols)[":"].T;
                ret["0;:;0"] = xO - x;
                ret["1;:;0"] = xO + x - l / 2 * cos(alpha + beta);
                ret["2;:;0"] = xO + x;
                ret["3;:;0"] = xO + x - l / 2 * cos(alpha - beta);

                ret["0;:;1"] = yO - y;
                ret["1;:;1"] = yO + y - l / 2 * sin(alpha + beta);
                ret["2;:;1"] = yO + y;
                ret["3;:;1"] = yO + y - l / 2 * sin(alpha - beta);

                ret["0;0;2"] = 0.0;
                // prepare colors 
                ret[":;:;3:5"] = todouble(
                    repmat(colormap.Map
                            (tosingle(l) * colormap.Length).Reshape(1, l.Length, 3) * 255, 4, 1, 1));
                return ret.Reshape(4 * numRows * numCols, 6).T;
            }