コード例 #1
0
ファイル: qgsmapcanvas.cpp プロジェクト: stevenmizuno/QGIS
void QgsMapCanvas::rendererJobFinished()
{
  QgsDebugMsg( QString( "CANVAS finish! %1" ).arg( !mJobCancelled ) );

  mMapUpdateTimer.stop();

  // TODO: would be better to show the errors in message bar
  Q_FOREACH ( const QgsMapRendererJob::Error& error, mJob->errors() )
  {
    QgsMessageLog::logMessage( error.layerID + " :: " + error.message, tr( "Rendering" ) );
  }

  if ( !mJobCancelled )
  {
    // take labeling results before emitting renderComplete, so labeling map tools
    // connected to signal work with correct results
    delete mLabelingResults;
    mLabelingResults = mJob->takeLabelingResults();

    QImage img = mJob->renderedImage();

    // emit renderComplete to get our decorations drawn
    QPainter p( &img );
    emit renderComplete( &p );

    QSettings settings;
    if ( settings.value( "/Map/logCanvasRefreshEvent", false ).toBool() )
    {
      QString logMsg = tr( "Canvas refresh: %1 ms" ).arg( mJob->renderingTime() );
      QgsMessageLog::logMessage( logMsg, tr( "Rendering" ) );
    }

    if ( mDrawRenderingStats )
    {
      int w = img.width(), h = img.height();
      QFont fnt = p.font();
      fnt.setBold( true );
      p.setFont( fnt );
      int lh = p.fontMetrics().height() * 2;
      QRect r( 0, h - lh, w, lh );
      p.setPen( Qt::NoPen );
      p.setBrush( QColor( 0, 0, 0, 110 ) );
      p.drawRect( r );
      p.setPen( Qt::white );
      QString msg = QString( "%1 :: %2 ms" ).arg( mUseParallelRendering ? "PARALLEL" : "SEQUENTIAL" ).arg( mJob->renderingTime() );
      p.drawText( r, msg, QTextOption( Qt::AlignCenter ) );
    }

    p.end();

    mMap->setContent( img, imageRect( img, mJob->mapSettings() ) );
  }

  // now we are in a slot called from mJob - do not delete it immediately
  // so the class is still valid when the execution returns to the class
  mJob->deleteLater();
  mJob = 0;

  emit mapCanvasRefreshed();
}
コード例 #2
0
void RenderThread::renderFinished()
{
    // If we're finished, delete the process and emit a completion signal
    if(renderprocess) {
        renderprocess->deleteLater();
        renderprocess = NULL;
    }
    emit renderComplete(project);
}
コード例 #3
0
ファイル: qgsmapcanvas.cpp プロジェクト: stevenmizuno/QGIS
//the format defaults to "PNG" if not specified
void QgsMapCanvas::saveAsImage( const QString& theFileName, QPixmap * theQPixmap, const QString& theFormat )
{
  //
  //check if the optional QPaintDevice was supplied
  //
  if ( theQPixmap != NULL )
  {
    // render
    QPainter painter;
    painter.begin( theQPixmap );
    QgsMapRendererCustomPainterJob job( mSettings, &painter );
    job.start();
    job.waitForFinished();
    emit renderComplete( &painter );
    painter.end();

    theQPixmap->save( theFileName, theFormat.toLocal8Bit().data() );
  }
  else //use the map view
  {
    mMap->contentImage().save( theFileName, theFormat.toLocal8Bit().data() );
  }
  //create a world file to go with the image...
  QgsRectangle myRect = mapSettings().visibleExtent();
  QString myHeader;
  // note: use 17 places of precision for all numbers output
  //Pixel XDim
  myHeader += qgsDoubleToString( mapUnitsPerPixel() ) + "\r\n";
  //Rotation on y axis - hard coded
  myHeader += "0 \r\n";
  //Rotation on x axis - hard coded
  myHeader += "0 \r\n";
  //Pixel YDim - almost always negative - see
  //http://en.wikipedia.org/wiki/World_file#cite_note-2
  myHeader += '-' + qgsDoubleToString( mapUnitsPerPixel() ) + "\r\n";
  //Origin X (center of top left cell)
  myHeader += qgsDoubleToString( myRect.xMinimum() + ( mapUnitsPerPixel() / 2 ) ) + "\r\n";
  //Origin Y (center of top left cell)
  myHeader += qgsDoubleToString( myRect.yMaximum() - ( mapUnitsPerPixel() / 2 ) ) + "\r\n";
  QFileInfo myInfo  = QFileInfo( theFileName );
  // allow dotted names
  QString myWorldFileName = myInfo.absolutePath() + '/' + myInfo.completeBaseName() + '.' + theFormat + 'w';
  QFile myWorldFile( myWorldFileName );
  if ( !myWorldFile.open( QIODevice::WriteOnly ) ) //don't use QIODevice::Text
  {
    return;
  }
  QTextStream myStream( &myWorldFile );
  myStream << myHeader;
} // saveAsImage
コード例 #4
0
gboolean
QDeclarativeVideoEditor::handleBusMessage (GstBus *, GstMessage *msg)
{
    switch (GST_MESSAGE_TYPE (msg)) {

    case GST_MESSAGE_EOS:
        qDebug() << "End of stream";
        setProgress(1.0);
        emit progressChanged();
        gst_element_set_state ((GstElement *) m_pipeline, GST_STATE_PAUSED);
        if(isRendering()) {
            m_rendering = false;
            ges_timeline_pipeline_set_mode (m_pipeline, TIMELINE_MODE_PREVIEW);
            emit renderComplete();
        }
        setProgress(-1.0);
        break;

    case GST_MESSAGE_ERROR: {
        gchar  *debug;
        GError *gerror;

        gst_message_parse_error (msg, &gerror, &debug);
        g_free (debug);

        qDebug() << "Error: " << gerror->message;
        if(isRendering()) {
            m_rendering = false;
            emit error(RENDERING_FAILED, gerror->message);
        } else {
            emit error(PLAYBACK_FAILED, gerror->message);
        }
        g_error_free (gerror);
        gst_element_set_state ((GstElement *) m_pipeline, GST_STATE_NULL);
        setProgress(-1.0);
        break;
    }
    default:
        break;
    }

    return TRUE;
}
コード例 #5
0
ファイル: runner.cpp プロジェクト: tritenour01/raytracer
void Runner::runRenderer(string sceneData, UIprogressEvent* e)
{
    QString cd = QDir::currentPath();
    string path = cd.toLocal8Bit().constData();
    path += "/.temp.scene";
    ofstream file(path.c_str());
    file<<sceneData;

    handler = e;

    currentWorker = new Worker(path, threads, blocks, handler);
    QThread* thread = new QThread();
    currentWorker->moveToThread(thread);

    connect(thread, SIGNAL(started()), currentWorker, SLOT(Render()));
    connect(currentWorker, SIGNAL(imageReady(UIimage*)), this, SLOT(setImage(UIimage*)));
    connect(currentWorker, SIGNAL(renderComplete()), this, SLOT(done()));
    connect(currentWorker, SIGNAL(renderInvalid()), this, SLOT(invalid()));
    connect(currentWorker, SIGNAL(renderInterrupted()), this, SLOT(interrupted()));

    thread->start();
}
コード例 #6
0
ファイル: runner.cpp プロジェクト: tritenour01/raytracer
void Worker::Render(void)
{
    QTime timer;
    timer.start();

    Raytracer R;
    if(!R.loadScene(filePath)){
        emit renderInvalid();
        return;
    }

    float setupTime = (float)timer.elapsed() / 1000.0f;
    Log::writeLine("Setup Time: " + Log::floatToString(setupTime));
    timer.restart();

    image = new QImage(R.getWidth(), R.getHeight(), QImage::Format_ARGB32);

    img = new UIimage("image", R.getWidth(), R.getHeight(), image->bits());
    emit imageReady(img);

    manager = new Manager(threads, blocks, img, &R);
    manager->setEventHandler(handler);

    if(!interrupted)
        manager->Render();

    float renderTime = (float)timer.elapsed() / 1000.0f;
    Log::writeLine("Render Time: " + Log::floatToString(renderTime));

    image->save("image.png", "PNG");

    if(interrupted)
        emit renderInterrupted();
    else
        emit renderComplete();
}
コード例 #7
0
ファイル: runner.cpp プロジェクト: tritenour01/raytracer
void Runner::done(void)
{
    emit renderComplete();
}
コード例 #8
0
ファイル: uchroma_funcs.cpp プロジェクト: trisyoungs/uchroma
// Constructor
UChromaWindow::UChromaWindow(QMainWindow *parent) : QMainWindow(parent),
	axesWindow_(*this), dataWindow_(*this), logWindow_(*this), styleWindow_(*this), transformWindow_(*this), viewWindow_(*this),
	createCollectionDialog_(*this), importDialog_(*this), editFitSetupDialog_(*this), saveImageDialog_(*this),
	viewTypeActionGroup_(this)
{
	// Initialise the icon resource
	Q_INIT_RESOURCE(icons);

	// Call the main creation function
	ui.setupUi(this);

	// Set pointer in UChromaSession and UChromaSignal
	UChromaSession::setMainWindow(this);
	UChromaSignal::setMainWindow(this);

	// Set variable defaults
	interactionMode_ = InteractionMode::ViewInteraction;
	interactionAxis_ = -1;
	interactionStarted_ = false;
	clickedInteractionValue_ = 0.0;
	clickedObject_ = Viewer::NoObject;
	currentInteractionValue_ = 0.0;
	refreshing_ = false;

	// Load settings...
	loadSettings();

	// Set UChroma pointers in widgets/dialogs where necessary
	ui.MainView->setUChromaWindow(this);

	// Connect signals / slots between the Viewer and uChroma
	connect(ui.MainView, SIGNAL(renderComplete(QString)), this, SLOT(updateRenderTimeLabel(QString)));

	// Hide LeftWidgets (Collection list etc.) initially
	ui.LeftWidgetsWidget->setVisible(false);

	// Connect CollectionTree context menu signal
	connect(ui.CollectionTree, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(collectionTreeContextMenuRequested(QPoint)));

	// Connect sub-window closed signal to toggle buttons / menu items in uChroma's main window
	connect(&axesWindow_, SIGNAL(windowClosed(bool)), ui.actionWindowAxes, SLOT(setChecked(bool)));
	connect(&dataWindow_, SIGNAL(windowClosed(bool)), ui.actionWindowData, SLOT(setChecked(bool)));
	connect(&logWindow_, SIGNAL(windowClosed(bool)), ui.actionWindowLog, SLOT(setChecked(bool)));
	connect(&styleWindow_, SIGNAL(windowClosed(bool)), ui.actionWindowStyle, SLOT(setChecked(bool)));
	connect(&transformWindow_, SIGNAL(windowClosed(bool)), ui.actionWindowTransform, SLOT(setChecked(bool)));
	connect(&viewWindow_, SIGNAL(windowClosed(bool)), ui.actionWindowView, SLOT(setChecked(bool)));

	// Create necessary action groups
	// -- ViewType actions
	viewTypeActionGroup_.addAction(ui.actionViewNormal);
	viewTypeActionGroup_.addAction(ui.actionViewAutoStretched3D);
	viewTypeActionGroup_.addAction(ui.actionViewFlatXY);
	viewTypeActionGroup_.addAction(ui.actionViewFlatXZ);
	viewTypeActionGroup_.addAction(ui.actionViewFlatZY);
	viewTypeActionGroup_.addAction(ui.actionViewLinked);
	// -- Interaction mode actions
	QActionGroup* actionGroup = new QActionGroup(this);
	actionGroup->addAction(ui.actionInteractNone);
	actionGroup->addAction(ui.actionInteractX);
	actionGroup->addAction(ui.actionInteractY);
	actionGroup->addAction(ui.actionInteractZ);

	// Add QLabel as a normal widget to the status bar
	statusBarInfoLabel_ = new QLabel(this);
	statusBarInfoLabel_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
	ui.StatusBar->addWidget(statusBarInfoLabel_);
	statusBarRenderingTimeLabel_ = new QLabel(this);
	ui.StatusBar->addPermanentWidget(statusBarRenderingTimeLabel_);	

	// Set initial interaction mode
	setInteractionMode(InteractionMode::ViewInteraction, -1);
}