Fix problem with black background in snapshot export

This commit is contained in:
Gaute Lindkvist 2020-01-08 14:52:28 +01:00
parent 3fc7378b8f
commit a58d854030
11 changed files with 44 additions and 27 deletions

View File

@ -81,11 +81,12 @@ RicfCommandResponse RicfExportWellLogPlotData::execute()
{ {
std::vector<RimWellLogPlot*> plots; std::vector<RimWellLogPlot*> plots;
RiaApplication::instance()->project()->descendantsIncludingThisOfType( plots ); RiaApplication::instance()->project()->descendantsIncludingThisOfType( plots );
RicfExportWellLogPlotDataResult* result = new RicfExportWellLogPlotDataResult;
for ( RimWellLogPlot* plot : plots ) for ( RimWellLogPlot* plot : plots )
{ {
if ( plot->id() == m_viewId() ) if ( plot->id() == m_viewId() )
{ {
RicfExportWellLogPlotDataResult* result = new RicfExportWellLogPlotDataResult;
if ( m_format() == ASCII ) if ( m_format() == ASCII )
{ {
QString validFileName = QString validFileName =
@ -106,16 +107,22 @@ RicfCommandResponse RicfExportWellLogPlotData::execute()
plot, plot,
m_exportTvdRkb(), m_exportTvdRkb(),
m_capitalizeFileNames(), m_capitalizeFileNames(),
true,
m_resampleInterval() ); m_resampleInterval() );
result->exportedFiles.v() = exportedFiles; if ( exportedFiles.empty() )
} {
response.setResult( result ); errorMessages << QString( "No files exported for '%1'" ).arg( plot->description() );
if ( result->exportedFiles().empty() ) }
{ else
errorMessages << "No files exported"; {
result->exportedFiles.v().insert( result->exportedFiles.v().end(),
exportedFiles.begin(),
exportedFiles.end() );
}
} }
} }
} }
response.setResult( result );
} }
else else
{ {

View File

@ -48,6 +48,7 @@ std::vector<QString> RicExportToLasFileFeature::exportToLasFiles( const QString&
const RimWellLogPlot* plotWindow, const RimWellLogPlot* plotWindow,
bool exportTvdRkb, bool exportTvdRkb,
bool capitalizeFileNames, bool capitalizeFileNames,
bool alwaysOverwrite,
double resampleInterval ) double resampleInterval )
{ {
std::vector<RimWellLogCurve*> allCurves; std::vector<RimWellLogCurve*> allCurves;
@ -75,6 +76,7 @@ std::vector<QString> RicExportToLasFileFeature::exportToLasFiles( const QString&
wellNames, wellNames,
rkbDiffs, rkbDiffs,
capitalizeFileNames, capitalizeFileNames,
alwaysOverwrite,
resampleInterval ); resampleInterval );
} }
} }
@ -88,6 +90,7 @@ std::vector<QString> RicExportToLasFileFeature::exportToLasFiles( const QString&
const std::vector<QString>& wellNames, const std::vector<QString>& wellNames,
const std::vector<double>& rkbDiffs, const std::vector<double>& rkbDiffs,
bool capitalizeFileNames, bool capitalizeFileNames,
bool alwaysOverwrite,
double resampleInterval ) double resampleInterval )
{ {
RigLasFileExporter lasExporter( curves ); RigLasFileExporter lasExporter( curves );
@ -104,7 +107,7 @@ std::vector<QString> RicExportToLasFileFeature::exportToLasFiles( const QString&
lasExporter.setRkbDiffs( wellNames, rkbDiffs ); lasExporter.setRkbDiffs( wellNames, rkbDiffs );
} }
writtenFiles = lasExporter.writeToFolder( exportFolder, filePrefix, capitalizeFileNames ); writtenFiles = lasExporter.writeToFolder( exportFolder, filePrefix, capitalizeFileNames, alwaysOverwrite );
// Remember the path to next time // Remember the path to next time
RiaApplication::instance()->setLastUsedDialogDirectory( "WELL_LOGS_DIR", exportFolder ); RiaApplication::instance()->setLastUsedDialogDirectory( "WELL_LOGS_DIR", exportFolder );
@ -186,6 +189,7 @@ void RicExportToLasFileFeature::onActionTriggered( bool isChecked )
wellNames, wellNames,
rkbDiffs, rkbDiffs,
featureUi.capitalizeFileName, featureUi.capitalizeFileName,
false,
resampleInterval ); resampleInterval );
} }
} }

View File

@ -39,17 +39,19 @@ public:
static std::vector<QString> exportToLasFiles( const QString& exportFolder, static std::vector<QString> exportToLasFiles( const QString& exportFolder,
const QString& filePrefix, const QString& filePrefix,
const RimWellLogPlot* plotWindow, const RimWellLogPlot* plotWindow,
bool exportTvdRkb = false, bool exportTvdRkb,
bool capitalizeFileNames = false, bool capitalizeFileNames,
double resampleInterval = 0.0 ); bool alwaysOverwrite,
double resampleInterval );
static std::vector<QString> exportToLasFiles( const QString& exportFolder, static std::vector<QString> exportToLasFiles( const QString& exportFolder,
const QString& filePrefix, const QString& filePrefix,
std::vector<RimWellLogCurve*> curves, std::vector<RimWellLogCurve*> curves,
const std::vector<QString>& wellNames = std::vector<QString>(), const std::vector<QString>& wellNames,
const std::vector<double>& rkbDiffs = std::vector<double>(), const std::vector<double>& rkbDiffs,
bool capitalizeFileNames = false, bool capitalizeFileNames,
double resampleInterval = 0.0 ); bool alwaysOverwrite,
double resampleInterval );
protected: protected:
// Overrides // Overrides

View File

@ -42,7 +42,7 @@ class Plot(PdmObject):
Returns: Returns:
A list of files exported A list of files exported
""" """
res = self._execute_command(exportWellLogPlotData=Cmd.ExportWellLogPlotDataRequest(exportFormat='LAS', res = self._execute_command(exportWellLogPlotData=Cmd.ExportWellLogPlotDataRequest(exportFormat='LAS',
viewId=self.view_id, viewId=self.view_id,
exportFolder=export_folder, exportFolder=export_folder,

View File

@ -157,7 +157,9 @@ class Project(PdmObject):
pdm_objects = self.descendants("RimPlotWindow") pdm_objects = self.descendants("RimPlotWindow")
plot_list = [] plot_list = []
for pdm_object in pdm_objects: for pdm_object in pdm_objects:
plot_list.append(Plot(pdm_object)) plot = Plot(pdm_object)
if plot.view_id != -1:
plot_list.append(plot)
return plot_list return plot_list
def plot(self, view_id): def plot(self, view_id):

View File

@ -1040,6 +1040,8 @@ void RimWellPltPlot::initAfterRead()
{ {
RimWellLogPlot& wellLogPlot = dynamic_cast<RimWellLogPlot&>( *this ); RimWellLogPlot& wellLogPlot = dynamic_cast<RimWellLogPlot&>( *this );
wellLogPlot = std::move( *m_wellLogPlot_OBSOLETE.value() ); wellLogPlot = std::move( *m_wellLogPlot_OBSOLETE.value() );
delete m_wellLogPlot_OBSOLETE;
m_wellLogPlot_OBSOLETE = nullptr;
} }
if ( m_showPlotTitle_OBSOLETE() && !m_showPlotWindowTitle() ) if ( m_showPlotTitle_OBSOLETE() && !m_showPlotWindowTitle() )

View File

@ -1107,6 +1107,8 @@ void RimWellRftPlot::initAfterRead()
{ {
RimWellLogPlot& wellLogPlot = dynamic_cast<RimWellLogPlot&>( *this ); RimWellLogPlot& wellLogPlot = dynamic_cast<RimWellLogPlot&>( *this );
wellLogPlot = std::move( *m_wellLogPlot_OBSOLETE.value() ); wellLogPlot = std::move( *m_wellLogPlot_OBSOLETE.value() );
delete m_wellLogPlot_OBSOLETE;
m_wellLogPlot_OBSOLETE = nullptr;
} }
if ( m_showPlotTitle_OBSOLETE() && !m_showPlotWindowTitle() ) if ( m_showPlotTitle_OBSOLETE() && !m_showPlotWindowTitle() )
{ {

View File

@ -215,7 +215,6 @@ public:
} }
else if ( firstCurveData->depthUnit() == RiaDefines::UNIT_NONE ) else if ( firstCurveData->depthUnit() == RiaDefines::UNIT_NONE )
{ {
CVF_ASSERT( false );
lasFile->AddLog( "DEPTH", lasFile->AddLog( "DEPTH",
"", "",
"Depth in Connection number", "Depth in Connection number",
@ -269,10 +268,6 @@ public:
{ {
lasFile->setDepthUnit( "FT" ); lasFile->setDepthUnit( "FT" );
} }
else if ( firstCurveData->depthUnit() == RiaDefines::UNIT_NONE )
{
CVF_ASSERT( false );
}
double absentValue = SingleLasFileMetaData::createAbsentValue( m_minimumCurveValue ); double absentValue = SingleLasFileMetaData::createAbsentValue( m_minimumCurveValue );
lasFile->SetMissing( absentValue ); lasFile->SetMissing( absentValue );
@ -387,7 +382,8 @@ void RigLasFileExporter::setRkbDiffs( const std::vector<QString>& wellNames, con
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
std::vector<QString> RigLasFileExporter::writeToFolder( const QString& exportFolder, std::vector<QString> RigLasFileExporter::writeToFolder( const QString& exportFolder,
const QString& filePrefix /*= ""*/, const QString& filePrefix /*= ""*/,
bool capitalizeFileName /*= false*/ ) bool capitalizeFileName /*= false*/,
bool alwaysOverwrite /*= false*/ )
{ {
std::vector<QString> writtenFiles; std::vector<QString> writtenFiles;
@ -413,7 +409,7 @@ std::vector<QString> RigLasFileExporter::writeToFolder( const QString& exportFol
fileName = fileName.toUpper(); fileName = fileName.toUpper();
} }
QString fullPathName = dir.absoluteFilePath( fileName ); QString fullPathName = dir.absoluteFilePath( fileName );
if ( caf::Utils::fileExists( fullPathName ) ) if ( caf::Utils::fileExists( fullPathName ) && !alwaysOverwrite )
{ {
QString txt = QString( "File %1 exists.\n\nDo you want to overwrite the file?" ).arg( fullPathName ); QString txt = QString( "File %1 exists.\n\nDo you want to overwrite the file?" ).arg( fullPathName );
int ret = QMessageBox::question( nullptr, int ret = QMessageBox::question( nullptr,

View File

@ -38,8 +38,10 @@ public:
void wellPathsAndRkbDiff( std::vector<QString>* wellNames, std::vector<double>* rkbDiffs ); void wellPathsAndRkbDiff( std::vector<QString>* wellNames, std::vector<double>* rkbDiffs );
void setRkbDiffs( const std::vector<QString>& wellNames, const std::vector<double>& rkbDiffs ); void setRkbDiffs( const std::vector<QString>& wellNames, const std::vector<double>& rkbDiffs );
std::vector<QString> std::vector<QString> writeToFolder( const QString& exportFolder,
writeToFolder( const QString& exportFolder, const QString& filePrefix = "", bool capitalizeFileName = false ); const QString& filePrefix = "",
bool capitalizeFileName = false,
bool alwaysOverwrite = false );
private: private:
std::vector<SingleLasFileMetaData> createLasFileDescriptions( const std::vector<RimWellLogCurve*>& curves ); std::vector<SingleLasFileMetaData> createLasFileDescriptions( const std::vector<RimWellLogCurve*>& curves );

View File

@ -350,6 +350,7 @@ void RiuMultiPlotPage::renderTo( QPaintDevice* paintDevice )
void RiuMultiPlotPage::renderTo( QPainter* painter, double scalingFactor ) void RiuMultiPlotPage::renderTo( QPainter* painter, double scalingFactor )
{ {
setSelectionsVisible( false ); setSelectionsVisible( false );
painter->fillRect( painter->viewport(), Qt::white );
m_plotTitle->render( painter ); m_plotTitle->render( painter );
// Subtract margins because we are rendering into part inside the margins // Subtract margins because we are rendering into part inside the margins

View File

@ -623,7 +623,6 @@ void RiuQwtPlotWidget::renderTo( QPainter* painter, const QRect& targetRect, dou
QPoint canvasBottomRightInWindowCoords = canvasBottomRightInPlotCoords + plotTopLeftInWindowCoords; QPoint canvasBottomRightInWindowCoords = canvasBottomRightInPlotCoords + plotTopLeftInWindowCoords;
QwtPlotRenderer renderer( this ); QwtPlotRenderer renderer( this );
renderer.setDiscardFlag( QwtPlotRenderer::DiscardBackground, true );
renderer.render( this, painter, targetRect ); renderer.render( this, painter, targetRect );
static_cast<QwtPlotCanvas*>( this->canvas() )->setPaintAttribute( QwtPlotCanvas::BackingStore, true ); static_cast<QwtPlotCanvas*>( this->canvas() )->setPaintAttribute( QwtPlotCanvas::BackingStore, true );