void QgsCompoundColorWidget::mouseReleaseEvent( QMouseEvent *e ) { if ( mPickingColor ) { //end color picking operation by sampling the color under cursor stopPicking( e->globalPos() ); e->accept(); return; } QWidget::mouseReleaseEvent( e ); }
void QgsCompoundColorWidget::keyPressEvent( QKeyEvent *e ) { if ( !mPickingColor ) { //if not picking a color, use default tool button behavior QWidget::keyPressEvent( e ); return; } //cancel picking, sampling the color if space was pressed stopPicking( QCursor::pos(), e->key() == Qt::Key_Space ); }
void mySelect(GLdouble x, GLdouble y, int width, int height) { // mouse curser in window x,y; window width,hight // http://www.lighthouse3d.com/opengl/picking/index.php?openglway3 GLint view[4]; glSelectBuffer(64, buff); glRenderMode(GL_SELECT); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glGetIntegerv(GL_VIEWPORT,view); gluPickMatrix(x,((GLdouble)height)-y,30.0f,30.0f,view); gluPerspective (45.0f, (GLfloat)(width)/(GLfloat)(height), // Calculate The Aspect Ratio Of The Window 1.0f, 100.0f); glMatrixMode (GL_MODELVIEW); // Select The Modelview Matrix DrawS(); stopPicking(); glLoadIdentity (); glRenderMode(GL_RENDER); // stopPicking(); }