NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hi Everyone, I have a 2-D scatter diagram with a CurveManipulationRenderer that works very nicely to select data points inside multiple curves. Now, I'm trying to extend it to 3D. What I would like is to be able to rotate and/or zoom the plot, with the Curves, and when a button is pressed, I would like to be able to select the data points that currently appear inside the Curves. So, I get ScreenCoords for the data points(3D) and for the curve samples(2D, so I put z=0). It seems to work when I don't change the plot, but once I zoom or rotate, it no longer works (I get unpredictable results - sometimes more points are selected, sometimes fewer are selected, etc). I've looked at the screen coordinates of both the data points and the curves, and they all look to be changing predictably as I zoom/rotate the plot, but I'm obviously missing something. Any suggestions very much appreciated! Adele Here is the bit of code I am using (inside the actionPerformed of my button): //nrows is the number of data points //I've checked that dataset[ixvar],dataset[iyvar] and dataset[izvar] are correct DisplayRenderer dr = display.getDisplayRenderer(); MouseBehavior mb = dr.getMouseBehavior(); // float[] x = new float[nrows]; float[] y = new float[nrows]; for(int i=0;i<nrows;i++){ //save the screen coordinates of the data point: double[] position = new double[] { (double)dataset[ixvar][i], (double)dataset[iyvar][i], (double)dataset[izvar][i]}; int[] screen = mb.getScreenCoords(position); x[i] = (float)screen[0]; y[i] = (float)screen[1]; } boolean[] selected = new boolean[nrows]; for(int i=0;i<nrows;i++) selected[i]=false; SampledSet[] sets = set.getSets(); // for(int j=1; j<sets.length; j++){//starts from 1 (invisible starter set) float[][] samples = sets[j].getSamples(true); //extract the samples boolean yes = DelaunayCustom.checkAndFixSelfIntersection(samples); //save the screen coordinates of the points on the curve: float[][]samp = new float[2][samples[0].length]; for(int jj<samples[0].length;jj++){ double[] position = new double[] { (double)samples[0][jj], (double)samples[1][jj], (double)0.0}; int[] screen = mb.getScreenCoords(position); samp[0][jj] = (float)screen[0]; samp[1][jj] = (float)screen[1]; } for (int i=0; i<nrows; i++) { // test to see if the screen coordinates for this data point are // inside the screen coordinates of the sampled curve: if(DelaunayCustom.inside(samp,x[i],y[i])) { selected[i] = true; } } }
visad
archives: