Skip to content

Commit

Permalink
vwv: Add non linear traversal off settings
Browse files Browse the repository at this point in the history
The more you drag your mouse the more the action has an effect.
  • Loading branch information
Zack Moratto committed Apr 20, 2012
1 parent 6c98691 commit 38c2398
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 29 deletions.
55 changes: 31 additions & 24 deletions src/vw/gui/GlPreviewWidget.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -724,59 +724,66 @@ void GlPreviewWidget::paintEvent(QPaintEvent * /* event */) {
void GlPreviewWidget::mousePressEvent(QMouseEvent *event) { void GlPreviewWidget::mousePressEvent(QMouseEvent *event) {
m_show_legend = true; m_show_legend = true;
lastPos = event->pos(); lastPos = event->pos();
m_last_gain = m_gain; // Store this so the user can do linear
m_last_offset = m_offset; // and nonlinear steps.
m_last_gamma = m_gamma;
m_last_viewport_min = QPoint( m_current_viewport.min().x(),
m_current_viewport.min().y() );
updateCurrentMousePosition(); updateCurrentMousePosition();
} }


void GlPreviewWidget::mouseMoveEvent(QMouseEvent *event) { void GlPreviewWidget::mouseMoveEvent(QMouseEvent *event) {
// Left mouse button moves the image around // Diff variables are just the movement of the mouse normalized to
if (event->buttons() & Qt::LeftButton) { // 0.0-1.0;
float x_diff = float(event->x() - lastPos.x()) / m_viewport_width; float x_diff = float(event->x() - lastPos.x()) / m_viewport_width;
float y_diff = float(event->y() - lastPos.y()) / m_viewport_height; float y_diff = float(event->y() - lastPos.y()) / m_viewport_height;
float ticks; float width = m_current_viewport.width();
float width = m_current_viewport.width(); float height = m_current_viewport.height();
float height = m_current_viewport.height();
// Right mouse button just kicks up the gain of all mouse actions
if (event->buttons() & Qt::LeftButton || event->buttons() & Qt::RightButton) {

if ( event->buttons() & Qt::RightButton ) {
x_diff *= 2;
y_diff *= 2;
}


std::ostringstream s; std::ostringstream s;
switch (m_adjust_mode) { switch (m_adjust_mode) {


case TransformAdjustment: case TransformAdjustment:
m_current_viewport.min().x() -= x_diff * width; m_current_viewport.min().x() =
m_current_viewport.min().y() -= y_diff * height; m_last_viewport_min.x() - x_diff * width;
m_current_viewport.max().x() -= x_diff * width; m_current_viewport.min().y() =
m_current_viewport.max().y() -= y_diff * height; m_last_viewport_min.y() - y_diff * height;
m_current_viewport.max().x() =
m_last_viewport_min.x() - x_diff * width + width;
m_current_viewport.max().y() =
m_last_viewport_min.y() - y_diff * height + height;
break; break;


case GainAdjustment: case GainAdjustment:
// The number '5' below adjusts the sensitivity. m_gain = m_last_gain * pow(2.0,x_diff);
ticks = pow(2, 5 * x_diff);
if (m_gain * ticks > 1e-8 && m_gain * ticks < 1e8)
m_gain *= ticks;
s << "Gain: " << (log(m_gain)/log(2)) << " f-stops\n"; s << "Gain: " << (log(m_gain)/log(2)) << " f-stops\n";
m_legend_status = s.str(); m_legend_status = s.str();
break; break;


case OffsetAdjustment: case OffsetAdjustment:
m_offset += x_diff * (m_image_max - m_image_min); m_offset = m_last_offset +
(pow(100,fabs(x_diff))-1.0)*(x_diff > 0 ? 0.1 : -0.1);
s << "Offset: " << m_offset << "\n"; s << "Offset: " << m_offset << "\n";
m_legend_status = s.str(); m_legend_status = s.str();
break; break;


case GammaAdjustment: case GammaAdjustment:
// The number '5.0' below adjust the sensitivity. m_gamma = m_last_gamma * pow(2.0,x_diff);
ticks = pow(2, x_diff * 5.0);
if (m_gamma * ticks > 0.01 && m_gamma * ticks < 10.0)
m_gamma *= ticks;
s << "Gamma: " << m_gamma << "\n"; s << "Gamma: " << m_gamma << "\n";
m_legend_status = s.str(); m_legend_status = s.str();
break; break;
} }

} else if (event->buttons() & Qt::RightButton) {
m_gain += GLfloat(event->x() - lastPos.x()) / m_viewport_width *10;
} }


// Regardless, we store the current position for the text legend. // Regardless, we store the current position for the text legend.
lastPos = event->pos();
updateCurrentMousePosition(); updateCurrentMousePosition();
} }


Expand Down
9 changes: 4 additions & 5 deletions src/vw/gui/GlPreviewWidget.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ namespace gui {
AdjustmentMode m_adjust_mode; AdjustmentMode m_adjust_mode;


// Mouse positions and legend information // Mouse positions and legend information
QPoint lastPos; QPoint lastPos, currentImagePos, m_last_viewport_min;
QPoint currentImagePos;
std::string m_legend_status; std::string m_legend_status;


// Dimensions & stats // Dimensions & stats
Expand All @@ -173,9 +172,9 @@ namespace gui {


// Image Parameters // Image Parameters
vw::BBox2 m_current_viewport; vw::BBox2 m_current_viewport;
float m_gain; float m_gain, m_last_gain;
float m_offset; float m_offset, m_last_offset;
float m_gamma; float m_gamma, m_last_gamma;
int m_current_transaction_id; int m_current_transaction_id;
bool m_exact_transaction_id_match; bool m_exact_transaction_id_match;
int m_current_level; int m_current_level;
Expand Down

0 comments on commit 38c2398

Please sign in to comment.