3

Is there a way to manipulate the range of Z values for a Surface plot in a way that can preserve the original values so I can create a range slider with a min and max values from the GetLimits() method and then update the data array Z values so I can set new limits but move the slides back and forth to adjust the min/max Z value and see the plot adjust as I do it?

Given this code

            ILArray<float> tempArray = ILMath.tosingle(myDoubleArray);

            dataArray.a = tempArray;

            var plotCube = ilPanel1.Scene.First<ILPlotCube>();
            var surface =  plotCube.First<ILFastSurface>();

            surface.Update(Z: dataArray, colormap: new ILColormap(ILColormaps.ILNumerics));
            ilPanel1.Refresh();

The MinValue and MaxValue controls are initialized like this.

            float maxZ, minZ;
            dataArray.GetLimits(out minZ, out maxZ);
            var zRange = maxZ - minZ;

            MinValue.Maximum = (decimal)maxZ;
            MinValue.Minimum = (decimal)minZ;
            MinValue.Value = (decimal)minZ;

            MaxValue.Maximum = (decimal)maxZ;
            MaxValue.Minimum = (decimal)minZ;
            MaxValue.Value = (decimal)maxZ;

I want to be able to manipulate the Z values in the array like this

        dataArray[dataArray < (float)MinValue.Value] = (float)MinValue.Value;
        dataArray[dataArray > (float)MaxValue.Value] = (float)MaxValue.Value;

        var plotCube = ilPanel1.Scene.First<ILPlotCube>();
        var surface = plotCube.First<ILFastSurface>();

        surface.Update(Z: dataArray, colormap: new ILColormap(ILColormaps.ILNumerics));
        ilPanel1.Refresh();

The issue is that dataArray is being changed with new min/max values. How can I restore dataArray if you want to change back to a larger min/max? Do I just clone dataArray and use that to change the plot? Or is there a feature of ILArray that tracks changes and can restore the array?

Flexo
  • 87,323
  • 22
  • 191
  • 272
Jeff Davis
  • 1,755
  • 2
  • 11
  • 14
  • I am trying to figure out what you want to achieve for a while now. But no luck. Could you try to reformulate the question please? You might give an example of what you have and which result you expect. – Haymo Kutschbach Feb 17 '16 at 20:36
  • I have edited the question – Jeff Davis Feb 18 '16 at 17:27
  • I found a way to make this work. not sure if it is the best or correct way. I am able to clone the array to a temporary array ILArray tempArray = dataArray.C; and then make the min/max changes to the temp array and just pass the temp array to the update surface.Update(Z: tempArray); – Jeff Davis Feb 19 '16 at 19:41
  • It would be nicer if you could just edit the min/max values of the colorbar and it would update the surface without it updating the original data. – Jeff Davis Feb 19 '16 at 19:44
  • Do you want to change the vertices Z positions or the colors of the grid points or the colors data range? Right now you seem to change the z values. But how does this relate to the colorbar? – Haymo Kutschbach Feb 19 '16 at 23:21
  • It might help to say that I do not display Axis or Labels for my Plot Cube. I hide them. So the only source of data is the colobar values. They display the Z height range. I want the ability to "flatten" the Z heights to normalize the height and make the range be more realistic instead of the true values of the original data. For example I might want to display my surface in a range of -60 to 120nm but the acutal data in my data array is -800 to 600nm because of some stray values that cause the range to be more extream. – Jeff Davis Feb 22 '16 at 22:40

1 Answers1

1

The solution to this problem is to use a temporary array and clone the original array and then normalize the temporary array and update the surface with it.

        float min = surface.GetRangeMinValue(AxisNames.CAxis) + minOffs;
        float max = surface.GetRangeMaxValue(AxisNames.CAxis) + maxOffs;

         ILArray<float> tempArray = _dataArray.C;
        tempArray[tempArray < min] = min;
        tempArray[tempArray > max] = max;

        surface.Update(Z: tempArray);

_dataArray is a static property loaded once with the original data. Any updates are done with the code above

Jeff Davis
  • 1,755
  • 2
  • 11
  • 14