//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RicSnapshotAllPlotsToFileFeature::saveAllPlots()
{
    RiaApplication* app = RiaApplication::instance();

    RiuMainPlotWindow* mainPlotWindow = app->mainPlotWindow();
    if (!mainPlotWindow) return;

    RimProject* proj = app->project();
    if (!proj) return;

    // Save images in snapshot catalog relative to project directory
    QString snapshotFolderName = app->createAbsolutePathFromProjectRelativePath("snapshots");

    QDir snapshotPath(snapshotFolderName);
    if (!snapshotPath.exists())
    {
        if (!snapshotPath.mkpath(".")) return;
    }

    const QString absSnapshotPath = snapshotPath.absolutePath();

    // Well log plots
    {
        std::vector<RimWellLogPlot*> wellLogPlots;
        proj->descendantsIncludingThisOfType(wellLogPlots);
        for (RimWellLogPlot* wellLogPlot : wellLogPlots)
        {
            if (wellLogPlot && wellLogPlot->viewWidget())
            {
                QString fileName = wellLogPlot->description();
                fileName.replace(" ", "_");

                QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png");

                RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, wellLogPlot);
            }
        }
    }

    // Summary plots
    {
        std::vector<RimSummaryPlot*> summaryPlots;
        proj->descendantsIncludingThisOfType(summaryPlots);
        for (RimSummaryPlot* summaryPlot : summaryPlots)
        {
            if (summaryPlot && summaryPlot->viewWidget())
            {
                QString fileName = summaryPlot->description();
                fileName.replace(" ", "_");

                QString absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName, ".png");

                RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, summaryPlot);
            }
        }
    }
}
Пример #2
0
void CanvasProcessor::saveImageLayer() {
    std::string snapshotPath(saveLayerDirectory_.get() + "/" + toLower(getIdentifier()) + "-" +
                             currentDateTime() + ".png");
    saveImageLayer(snapshotPath);
}