Originally Posted by
jacek
How do you convert those coordinates?
I have a scale factor based on the width and height of the viewport in pixels, and the min and max of my ortho.
xScaleFactor = (mXMax - mXMin) / (mViewportRight - mViewportLeft);
yScaleFactor = (mYMax - mYMin) / (mViewportTop - mViewportBottom);
xScaleFactor = (mXMax - mXMin) / (mViewportRight - mViewportLeft);
yScaleFactor = (mYMax - mYMin) / (mViewportTop - mViewportBottom);
To copy to clipboard, switch view to plain text mode
I then convert the x and y coordinates like this
double x = ( event->x( ) - getLeftMarginWidth( ) ) *
xScaleFactor + mXMin;
double y = ( height( ) - event->y( ) -
getBottomMarginHeight( ) ) * yScaleFactor + mYMin;
double x = ( event->x( ) - getLeftMarginWidth( ) ) *
xScaleFactor + mXMin;
double y = ( height( ) - event->y( ) -
getBottomMarginHeight( ) ) * yScaleFactor + mYMin;
To copy to clipboard, switch view to plain text mode
This is how I convert the coordinates, and when I print out the conversion, it's value is the ortho value I expect.
Originally Posted by
jacek
And where is that "top QGLWidget" placed exactly?
I have a QVerticalSplitter with 2 QGLWidgets in the splitter. I also have 2 toolbars left of the 2 QGLWidgets, and they are also placed in the splitter so I have something looking like
---------------------------- <-- Top Of Window
| Toolbar | QGLWidget |
---------------------------- <-- Splitter
| Toolbar | QGLWidget |
---------------------------- <-- Bottom Of Window
The top QGLWidget is the one at the top of the window. That picture above is a simple layout of what the main portion on the window looks like.
My problem is when I move over the top QGLWidget it seems like it is asking for the scale factors from the bottom QGLWidget and not the top QGLWidget. But once I click on the top QGLWidget, then everything works how I expect it to. Thanks for your continued help!
Edit:
Fixed the diagram above
Bookmarks