Exemplo n.º 1
0
void LightboxWidget::scrolled(int v)
{
  TRACKER("LightboxWidget::scrolled");
  
  std::for_each(m_slices->begin(), m_slices->end(), SliceHider(m_sv->viewport()->geometry()));
  if(!m_sv->verticalScrollBar()->draggingSlider())repaintSlices();
}
Exemplo n.º 2
0
void LightboxWidget::layoutSlices() const
{
  TRACKER("LightboxWidget::layoutSlices");
  SlicePlacer sp = std::for_each(m_slices->begin(), m_slices->end(), SlicePlacer(m_sv, 6, m_zoom));
  m_sv->resizeContents(sp.width(), sp.height());
  std::for_each(m_slices->begin(), m_slices->end(), SliceHider(m_sv->viewport()->geometry()));
}
Exemplo n.º 3
0
LightboxWidget::LightboxWidget(QWidget *parent,ImageGroup::Handle i,OverlayList::Handle ol, Cursor::Handle& c ) :  
  ImageWidget(parent,i,ol,c), m_image(i), m_zoom(1.0)
{
  TRACKER("LightboxWidget::LightboxWidget");
  m_sv = new QScrollView(this);
  
  setIcon( QPixmap(lightbox_xpm) );

  setCentralWidget(m_sv);
  
  m_sv->viewport()->setBackgroundColor(QColor(128, 128, 128));

  connect(m_sv->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(scrolled(int)));
  connect(m_sv->verticalScrollBar(), SIGNAL(sliderReleased()),  this, SLOT(repaintSlices()));

  connect(m_mainToolbarWidget, SIGNAL(zoomValueChanged(int)), this, SLOT(setZoom(int)));

  m_slices = SliceListHandle(new SliceList);

  for(int n = 0; n < m_image->inqZ(); ++n)
  {
    SliceWidget::Handle axial =
      SliceWidget::Handle(new AxialWidget(m_sv->viewport(), "axial", 
					  m_cursor, m_overlayList, m_drawSettings, m_undoList,
					  m_opts));
    
    m_sv->addChild(axial.get());
    m_slices->push_back(axial);

    connect(this, SIGNAL(crossHairModeChanged(bool)),     axial.get(), SLOT(crossHairMode(bool)));
    connect(this, SIGNAL(modeChanged(SliceWidget::Mode)), axial.get(), SLOT(setMode(SliceWidget::Mode)));
    connect(this, SIGNAL(crossHairModeChanged(bool)),     axial.get(), SLOT(crossHairMode(bool)));
    connect(this, SIGNAL(resetZoom()),                    axial.get(), SLOT(resetZoom()));
    connect(axial.get(), SIGNAL(message(const QString&, int )), SIGNAL(message(const QString&, int )));

//    m_mainToolbarWidget->setCursorMode();

    axial->setSlice(n,m_cursor->inqV());
    axial->setSliceIsFixed(true);
  }
  
  m_mainToolbarWidget->setCrossHairsMode(true);
}
Exemplo n.º 4
0
/* find the most plausible velocity. That is, the most distant
 * (in time) tracker which isn't too old, the movement vector was
 * in the same octant, and where the velocity is within an
 * acceptable range to the inital velocity.
 *
 * @return The tracker's velocity or 0 if the above conditions are unmet
 */
static double
QueryTrackers(DeviceVelocityPtr vel, int cur_t)
{
    int offset, dir = UNDEFINED, used_offset = -1, age_ms;

    /* initial velocity: a low-offset, valid velocity */
    double initial_velocity = 0, result = 0, velocity_diff;
    double velocity_factor = vel->corr_mul * vel->const_acceleration;   /* premultiply */

    /* loop from current to older data */
    for (offset = 1; offset < vel->num_tracker; offset++) {
        MotionTracker *tracker = TRACKER(vel, offset);
        double tracker_velocity;

        age_ms = cur_t - tracker->time;

        /* bail out if data is too old and protect from overrun */
        if (age_ms >= vel->reset_time || age_ms < 0) {
            DebugAccelF("query: tracker too old (reset after %d, age is %d)\n",
                        vel->reset_time, age_ms);
            break;
        }

        /*
         * this heuristic avoids using the linear-motion velocity formula
         * in CalcTracker() on motion that isn't exactly linear. So to get
         * even more precision we could subdivide as a final step, so possible
         * non-linearities are accounted for.
         */
        dir &= tracker->dir;
        if (dir == 0) {         /* we've changed octant of movement (e.g. NE → NW) */
            DebugAccelF("query: no longer linear\n");
            /* instead of breaking it we might also inspect the partition after,
             * but actual improvement with this is probably rare. */
            break;
        }

        tracker_velocity = CalcTracker(tracker, cur_t) * velocity_factor;

        if ((initial_velocity == 0 || offset <= vel->initial_range) &&
            tracker_velocity != 0) {
            /* set initial velocity and result */
            result = initial_velocity = tracker_velocity;
            used_offset = offset;
        }
        else if (initial_velocity != 0 && tracker_velocity != 0) {
            velocity_diff = fabs(initial_velocity - tracker_velocity);

            if (velocity_diff > vel->max_diff &&
                velocity_diff / (initial_velocity + tracker_velocity) >=
                vel->max_rel_diff) {
                /* we're not in range, quit - it won't get better. */
                DebugAccelF("query: tracker too different:"
                            " old %2.2f initial %2.2f diff: %2.2f\n",
                            tracker_velocity, initial_velocity, velocity_diff);
                break;
            }
            /* we're in range with the initial velocity,
             * so this result is likely better
             * (it contains more information). */
            result = tracker_velocity;
            used_offset = offset;
        }
    }
    if (offset == vel->num_tracker) {
        DebugAccelF("query: last tracker in effect\n");
        used_offset = vel->num_tracker - 1;
    }
    if (used_offset >= 0) {
#ifdef PTRACCEL_DEBUGGING
        MotionTracker *tracker = TRACKER(vel, used_offset);

        DebugAccelF("result: offset %i [dx: %f dy: %f diff: %i]\n",
                    used_offset, tracker->dx, tracker->dy,
                    cur_t - tracker->time);
#endif
    }
    return result;
}
Exemplo n.º 5
0
LightboxWidget::~LightboxWidget()
{
  TRACKER("LightboxWidget::~LightboxWidget");
}
Exemplo n.º 6
0
void LightboxWidget::resizeEvent(QResizeEvent *e)
{
  TRACKER("LightboxWidget::resizeEvent");
  layoutSlices();
}