Ejemplo n.º 1
0
void WCalendar::renderMonth()
{
  needRenderMonth_ = true;

  if (isRendered())
    scheduleRender();
}
Ejemplo n.º 2
0
void PdfView::setupPage(int newPage) {
  qDebug() << "setupPage" << newPage;
  if (_imagedPage == newPage && !_pageImage.isNull()) return;

  if (_imagedPage == (newPage - 1) && !_nextImage.isNull()) {
    qDebug() << "Flipping to _nextImage.";
    _pageImage = _nextImage;
    _nextImage = QPixmap();
  } else {
    qDebug() << "Re-rendering: _imagedPage =" << _imagedPage;
    _pageImage = QPixmap();
    _nextImage = QPixmap();
  }

  if (_pageImage.isNull()) {
    qDebug() << "Rendering current page image.";
    Poppler::Page *page = doc->page(newPage);
    QImage image = scaler()->scaleAndRender(page, this);

    _pageImage = QPixmap::fromImage(image);
    _imagedPage = newPage;
  }

  if (_nextImage.isNull() && (newPage + 1) < pageCount()) {
    if (!_renderScheduled) {
      _renderScheduled = true;
      QTimer::singleShot(0, this, SLOT(scheduleRender()));
    }
  }
}
Ejemplo n.º 3
0
void WMediaPlayer::clearSources()
{
  media_.clear();

  mediaUpdated_ = true;
  scheduleRender();
}
Ejemplo n.º 4
0
void WMediaPlayer::addSource(Encoding encoding, const WLink& link)
{
  media_.push_back(Source());
  media_.back().link = link;
  media_.back().encoding = encoding;

  mediaUpdated_ = true;
  scheduleRender();
}
Ejemplo n.º 5
0
void Window::mouseReleaseEvent(QMouseEvent *event)
{
    if (m_lastPos != QPoint(-1, -1)) {
        QPainter p(&m_image);
        p.setRenderHint(QPainter::Antialiasing);
        p.drawLine(m_lastPos, event->pos());
        m_lastPos = QPoint(-1, -1);
    }

    scheduleRender();
}
Ejemplo n.º 6
0
void Window::wheelEvent(QWheelEvent *event)
{
    qDebug() << "wheelEvent delta" << event->delta() << "orientation" << event->orientation();
    qDebug() << "wheelEvent pixelDelta" << event->pixelDelta();
    qDebug() << "wheelEvent angleDelta" << event->angleDelta();

    const bool useQt4API = false;

    if (useQt4API) {
        if (event->orientation() == Qt::Horizontal)
            scrollOffset.setX(scrollOffset.x() + event->delta());
        else
            scrollOffset.setY(scrollOffset.y() + event->delta());
        scheduleRender();
    } else {
        if (!event->pixelDelta().isNull()) {
            scrollOffset += event->pixelDelta();
            scheduleRender();
        }
    }
}
Ejemplo n.º 7
0
JSignal<>& WMediaPlayer::signal(const char *name)
{
  for (unsigned i = 0; i < signals_.size(); ++i) {
    if (signals_[i]->name() == name)
      return *signals_[i];
  }

  JSignal<> *result;
  signals_.push_back(result = new JSignal<>(this, name, true));

  scheduleRender();

  return *result;
}
Ejemplo n.º 8
0
void Window::keyPressEvent(QKeyEvent *event)
{
    switch (event->key()) {
    case Qt::Key_Backspace:
        m_text.chop(1);
        break;
    case Qt::Key_Enter:
    case Qt::Key_Return:
        m_text.append('\n');
        break;
    default:
        m_text.append(event->text());
        break;
    }
    scheduleRender();
}
Ejemplo n.º 9
0
Archivo: window.cpp Proyecto: RSATom/Qt
void Window::resizeEvent(QResizeEvent *)
{
    QImage old = m_image;

    int width = qMax(geometry().width(), old.width());
    int height = qMax(geometry().height(), old.height());

    if (width > old.width() || height > old.height()) {
        m_image = QImage(width, height, QImage::Format_RGB32);
        m_image.fill(colorTable[(m_backgroundColorIndex) % (sizeof(colorTable) / sizeof(colorTable[0]))].rgba());

        QPainter p(&m_image);
        p.drawImage(0, 0, old);
    }
    scheduleRender();
}
Ejemplo n.º 10
0
void Window::exposeEvent(QExposeEvent *)
{
    scheduleRender();
}
Ejemplo n.º 11
0
Archivo: WMenu.C Proyecto: LifeGo/wt
void WMenu::updateSelectionEvent()
{
  needSelectionEventUpdate_ = true;
  scheduleRender();
}
Ejemplo n.º 12
0
//-----------------------------------------------------------------------------
int ctkVTKSliceViewTest1(int argc, char * argv [] )
{
  QApplication app(argc, argv);

  // Test arguments
  QString filename = "HeadMRVolume.mhd";

  // Command line parser
  ctkCommandLineParser parser;
  parser.addArgument("", "-I", QVariant::Bool);
  parser.addArgument("", "-D", QVariant::String);
  bool ok = false;
  QHash<QString, QVariant> parsedArgs = parser.parseArguments(app.arguments(), &ok);
  if (!ok)
    {
    std::cerr << qPrintable(parser.errorString()) << std::endl;
    return EXIT_FAILURE;
    }

  bool interactive = parsedArgs["-I"].toBool();
  QString data_directory = parsedArgs["-D"].toString();

  QString imageFilename = data_directory + "/" + filename;

  // Instanciate the reader factory
  vtkSmartPointer<vtkImageReader2Factory> imageFactory =
      vtkSmartPointer<vtkImageReader2Factory>::New();

  // Instanciate an image reader
  vtkSmartPointer<vtkImageReader2> imageReader;
  imageReader.TakeReference(imageFactory->CreateImageReader2(imageFilename.toLatin1()));
  if (!imageReader)
    {
    std::cerr << "Failed to instanciate image reader using: " 
              << qPrintable(imageFilename) << std::endl;
    return EXIT_FAILURE;
    }

  // Read image
  imageReader->SetFileName(imageFilename.toLatin1());
  imageReader->Update();
  vtkSmartPointer<vtkImageData> image = imageReader->GetOutput();

  // Top level widget
  QWidget widget;

  // .. and its associated layout
  QVBoxLayout * topLevelLayout = new QVBoxLayout(&widget);
  topLevelLayout->setContentsMargins(0, 0, 0, 0);

  // Horizontal layout to contain the spinboxes
  QHBoxLayout * spinBoxLayout = new QHBoxLayout;
  topLevelLayout->addLayout(spinBoxLayout);

  int defaultRowCount = 4;
  int defaultColumnCount = 3;

  // SpinBox to change number of row in lightBox
  QSpinBox * rowSpinBox = new QSpinBox;
  rowSpinBox->setRange(1, 10);
  rowSpinBox->setSingleStep(1);
  rowSpinBox->setValue(defaultRowCount);
  spinBoxLayout->addWidget(rowSpinBox);

  // SpinBox to change number of column in lightBox
  QSpinBox * columnSpinBox = new QSpinBox;
  columnSpinBox->setRange(1, 10);
  columnSpinBox->setSingleStep(1);
  columnSpinBox->setValue(defaultColumnCount);
  spinBoxLayout->addWidget(columnSpinBox);

  ctkVTKSliceView * sliceView = new ctkVTKSliceView;
  sliceView->setRenderEnabled(true);
  sliceView->setMinimumSize(600, 600);
  sliceView->setImageData(image);
  sliceView->setHighlightedBoxColor(QColor(Qt::yellow));
  sliceView->lightBoxRendererManager()->SetRenderWindowLayout(defaultRowCount, defaultColumnCount);
  sliceView->lightBoxRendererManager()->SetHighlighted(0, 0, true);
  sliceView->setCornerAnnotationText("CTK");
  sliceView->scheduleRender();
  topLevelLayout->addWidget(sliceView);

  // Set connection
  QObject::connect(rowSpinBox, SIGNAL(valueChanged(int)),
                   sliceView, SLOT(setLightBoxRendererManagerRowCount(int)));
  QObject::connect(columnSpinBox, SIGNAL(valueChanged(int)),
                   sliceView, SLOT(setLightBoxRendererManagerColumnCount(int)));

  ctkVTKObjectEventsObserver vtkObserver;
  vtkObserver.addConnection(sliceView->lightBoxRendererManager(), vtkCommand::ModifiedEvent,
                            sliceView, SLOT(scheduleRender()));

  widget.show();

  // TODO Add image regression test

  if (!interactive)
    {
    QTimer::singleShot(1000, &app, SLOT(quit()));
    }
  return app.exec();
}