ToddAtWSU

08-20-2007, 01:47 PM

I have a plot that is 3-dimensional. I start the plot out by having it appear you are above the plot looking down on it so all the lines of data appear to be flat along the x and y axes. I then make it possible to rotate about the x-axis so it appears the user is now standing in front of the object and looking at it. An example of this is if I am in a helicopter over a mountain range, I do not see which is higher, just where the mountains lie. Then when I get to the ground I suddenly see all the peaks and valleys of the mountains. This is how my data appears on the screen when I rotate it about the x-axis.

The problem I am having is I allow the user to click on one of these lines with the mouse. I am capturing the mouse's coordinates and converting them to the ortho coordinates and then looping through my lines to see if the user clicked on a line and if so I am changing its color and doing other things with it. This code is working fine when I have no rotation about the x-axis. But once I add rotation into the picture, my line grabbing is off. My code snippet looks like this:

for( int point = 0 ; point < numPoints ; point++ )

{

// If this is true, we have found a selection

double xData;

double yData;

if( ps->getDataMode( ) == PointSet::VECTOR_DATA )

{

xData = ps->x->at( point );

yData = ps->y->at( point );

}

else if( ps->getDataMode( ) == PointSet::POINTER_DATA )

{

xData = ps->xData[point];

yData = ps->yData[point];

}

double xWaver = ( mCurrentXMax - mCurrentXMin ) * 0.02;

double yWaver = ( mCurrentYMax - mCurrentYMin ) * 0.02 - mDataLayer->getXRotation( );

if( ( xData > x - xWaver && xData < x + xWaver ) &&

( yData > y - yWaver && yData < y + yWaver ) )

{

foundSweep = true;

break;

} // end if( ps->x->at( point ) == x && ps->y->at( point ) == y )

} // end for( int point = 0 ; point < numPoints && foundSweep == false ; point++ )

if( foundSweep == true )

{

break;

}

} // end for( int sets = 0 ; sets < numPointSets && foundSweep == false ; sets++ ) I am creating a "waver" so I basically say if the data falls into the mouseclick +/- a waver amount, I must have clicked on it. But I don't know how to account for the rotation in the x-axis. This stretches things out on the y-axis to the viewer but messes up my grabbing. When a line appeared to run about y = 34, with the rotation, the line appears to be on some spots at y = 34 to y = 36 because of the peaks rising up and the low portions staying low.

Does anybody have an idea how I can account for the rotation to allow almost flawless clicking of the lines in my plot? Thanks for any help you have and please let me know if I can provide any more information that would assist you in helping me resolve this.

The problem I am having is I allow the user to click on one of these lines with the mouse. I am capturing the mouse's coordinates and converting them to the ortho coordinates and then looping through my lines to see if the user clicked on a line and if so I am changing its color and doing other things with it. This code is working fine when I have no rotation about the x-axis. But once I add rotation into the picture, my line grabbing is off. My code snippet looks like this:

for( int point = 0 ; point < numPoints ; point++ )

{

// If this is true, we have found a selection

double xData;

double yData;

if( ps->getDataMode( ) == PointSet::VECTOR_DATA )

{

xData = ps->x->at( point );

yData = ps->y->at( point );

}

else if( ps->getDataMode( ) == PointSet::POINTER_DATA )

{

xData = ps->xData[point];

yData = ps->yData[point];

}

double xWaver = ( mCurrentXMax - mCurrentXMin ) * 0.02;

double yWaver = ( mCurrentYMax - mCurrentYMin ) * 0.02 - mDataLayer->getXRotation( );

if( ( xData > x - xWaver && xData < x + xWaver ) &&

( yData > y - yWaver && yData < y + yWaver ) )

{

foundSweep = true;

break;

} // end if( ps->x->at( point ) == x && ps->y->at( point ) == y )

} // end for( int point = 0 ; point < numPoints && foundSweep == false ; point++ )

if( foundSweep == true )

{

break;

}

} // end for( int sets = 0 ; sets < numPointSets && foundSweep == false ; sets++ ) I am creating a "waver" so I basically say if the data falls into the mouseclick +/- a waver amount, I must have clicked on it. But I don't know how to account for the rotation in the x-axis. This stretches things out on the y-axis to the viewer but messes up my grabbing. When a line appeared to run about y = 34, with the rotation, the line appears to be on some spots at y = 34 to y = 36 because of the peaks rising up and the low portions staying low.

Does anybody have an idea how I can account for the rotation to allow almost flawless clicking of the lines in my plot? Thanks for any help you have and please let me know if I can provide any more information that would assist you in helping me resolve this.