more useful wheel behaviour when in raster mode (opacity/pointsize/clip planes)

This commit is contained in:
Paolo Cignoni cignoni 2010-11-17 15:53:30 +00:00
parent 9511bf41d6
commit c5697b8a79
2 changed files with 15 additions and 16 deletions

View File

@ -282,9 +282,6 @@ void GLArea::paintEvent(QPaintEvent */*event*/)
drawLight();
//If it is a raster viewer draw the image as a texture
if(isRaster())
drawTarget();
glPushMatrix();
@ -353,6 +350,9 @@ void GLArea::paintEvent(QPaintEvent */*event*/)
}
glPopMatrix(); // We restore the state to immediately before the trackball
//If it is a raster viewer draw the image as a texture
if(isRaster()) drawTarget();
// Double click move picked point to center
// It has to be done in the before trackball space (we MOVE the trackball itself...)
if(hasToPick && !hasToGetPickPos)
@ -748,11 +748,9 @@ void GLArea::tabletEvent(QTabletEvent*e)
void GLArea::wheelEvent(QWheelEvent*e)
{
setFocus();
if(!isRaster())
{
const int WHEEL_STEP = 120;
float notch = e->delta()/ float(WHEEL_STEP);
switch(e->modifiers())
const int WHEEL_STEP = 120;
float notch = e->delta()/ float(WHEEL_STEP);
switch(e->modifiers())
{
case Qt::ShiftModifier + Qt::ControlModifier : clipRatioFar = math::Clamp( clipRatioFar*powf(1.2f, notch),0.01f,50.0f); break;
case Qt::ControlModifier : clipRatioNear = math::Clamp(clipRatioNear*powf(1.2f, notch),0.01f,50.0f); break;
@ -762,10 +760,12 @@ void GLArea::wheelEvent(QWheelEvent*e)
break;
case Qt::ShiftModifier : fov = math::Clamp(fov*powf(1.2f,notch),5.0f,90.0f); break;
default:
trackball.MouseWheel( e->delta()/ float(WHEEL_STEP));
if(isRaster())
this->opacity = math::Clamp( opacity*powf(1.2f, notch),0.1f,1.0f);
else
trackball.MouseWheel( e->delta()/ float(WHEEL_STEP));
break;
}
}
update();
}
@ -1192,8 +1192,6 @@ void GLArea::loadRaster(int id)
void GLArea::drawTarget() {
if(!targetTex) return;
double ratio = 1.0f;
//ratio = align.imageRatio; quale ratio?
if(meshDoc->rm()==0) return;
QImage &curImg = meshDoc->rm()->currentPlane->image;
float imageRatio = float(curImg.width())/float(curImg.height());
@ -1209,10 +1207,12 @@ void GLArea::drawTarget() {
glColor4f(1, 1, 1, opacity);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, targetTex);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glColor3f(1.0f, 1.0f, 1.0f);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); //first point
glVertex3f(-1.0f*imageRatio, -1.0f, 0.0f);

View File

@ -329,7 +329,7 @@ private:
int zoomx, zoomy;
bool zoom;
double opacity;
float opacity;
GLuint targetTex; // here we store the reference image. The raster image is rendered as a texture
public:
@ -337,8 +337,7 @@ public:
void setIsRaster(bool viewMode);
void loadRaster(int id);
void setOpacity(int o) { opacity = o/100.0; update(); } //between 0 and 100
void setTarget(QImage &image);
void setTarget(QImage &image);
private:
void drawTarget();