mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-12 00:16:10 -06:00
#5116 Implement delete of an imported file for well measurements.
This commit is contained in:
parent
16f3108e64
commit
22aece407e
@ -60,6 +60,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemExecData.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteSubItemsFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteSummaryCaseCollectionFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellMeasurementFilePathFeature.h
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCloseSourSimDataFeature.h
|
||||
|
||||
@ -147,6 +148,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemFeature.cpp
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteSubItemsFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteSummaryCaseCollectionFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellMeasurementFilePathFeature.cpp
|
||||
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCloseSourSimDataFeature.cpp
|
||||
|
||||
|
@ -0,0 +1,68 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicDeleteWellMeasurementFilePathFeature.h"
|
||||
|
||||
#include "RimWellMeasurement.h"
|
||||
#include "RimWellMeasurementCollection.h"
|
||||
#include "RimWellMeasurementFilePath.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicDeleteWellMeasurementFilePathFeature, "RicDeleteWellMeasurementFilePathFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicDeleteWellMeasurementFilePathFeature::isCommandEnabled()
|
||||
{
|
||||
std::vector<RimWellMeasurementFilePath*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
return !objects.empty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicDeleteWellMeasurementFilePathFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
std::vector<RimWellMeasurementFilePath*> selectedFilePaths;
|
||||
caf::SelectionManager::instance()->objectsByType( &selectedFilePaths );
|
||||
if ( selectedFilePaths.empty() ) return;
|
||||
|
||||
RimWellMeasurementFilePath* filePath = selectedFilePaths[0];
|
||||
|
||||
RimWellMeasurementCollection* wellMeasurementCollection = nullptr;
|
||||
filePath->firstAncestorOrThisOfType( wellMeasurementCollection );
|
||||
if ( !wellMeasurementCollection ) return;
|
||||
|
||||
wellMeasurementCollection->removeMeasurementsForFilePath( filePath );
|
||||
wellMeasurementCollection->removeFilePath( filePath );
|
||||
|
||||
wellMeasurementCollection->uiCapability()->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicDeleteWellMeasurementFilePathFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Delete Well Measurement File" );
|
||||
actionToSetup->setIcon( QIcon( ":/Erase.png" ) );
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicDeleteWellMeasurementFilePathFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
@ -94,6 +94,7 @@ void RicImportWellMeasurementsFeature::onActionTriggered( bool isChecked )
|
||||
wellMeasurement->setQuality( measurement.quality );
|
||||
wellMeasurement->setKind( measurement.kind );
|
||||
wellMeasurement->setRemark( measurement.remark );
|
||||
wellMeasurement->setFilePath( measurement.filePath );
|
||||
|
||||
// Ignore values for kinds which is known to not have values
|
||||
if ( !RimWellMeasurement::kindHasValue( measurement.kind ) )
|
||||
|
@ -28,6 +28,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimFileWellPath.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimModeledWellPath.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurement.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementCollection.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementFilePath.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellPathGeometryDef.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellPathAttribute.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellPathAttributeCollection.h
|
||||
@ -179,6 +180,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimFileWellPath.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimModeledWellPath.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurement.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementCollection.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellMeasurementFilePath.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellPathGeometryDef.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellPathAttribute.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellPathAttributeCollection.cpp
|
||||
|
@ -117,6 +117,7 @@
|
||||
#include "RimWellLogPlot.h"
|
||||
#include "RimWellLogPlotCollection.h"
|
||||
#include "RimWellLogTrack.h"
|
||||
#include "RimWellMeasurementFilePath.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathAttributeCollection.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
@ -326,6 +327,10 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder.subMenuEnd();
|
||||
appendExportCompletions( menuBuilder );
|
||||
}
|
||||
else if ( dynamic_cast<RimWellMeasurementFilePath*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicDeleteWellMeasurementFilePathFeature";
|
||||
}
|
||||
else if ( dynamic_cast<RimWellPath*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicNewEditableWellPathFeature";
|
||||
|
@ -38,6 +38,7 @@ RimWellMeasurement::RimWellMeasurement()
|
||||
CAF_PDM_InitFieldNoDefault( &m_kind, "Kind", "Kind", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_quality, "Quality", "Quality", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_remark, "Remark", "Remark", "", "", "" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_filePath, "FilePath", "File Path", "", "", "" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -157,6 +158,22 @@ void RimWellMeasurement::setRemark( const QString& remark )
|
||||
m_remark = remark;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellMeasurement::filePath() const
|
||||
{
|
||||
return m_filePath;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellMeasurement::setFilePath( const QString& filePath )
|
||||
{
|
||||
m_filePath = filePath;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -54,6 +54,8 @@ public:
|
||||
void setQuality( int quality );
|
||||
QString remark() const;
|
||||
void setRemark( const QString& remark );
|
||||
QString filePath() const;
|
||||
void setFilePath( const QString& filePath );
|
||||
|
||||
static bool kindHasValue( const QString& measurementKind );
|
||||
static cvf::Color3f mapToColor( const QString& measurementKind );
|
||||
@ -73,4 +75,5 @@ private:
|
||||
caf::PdmField<QString> m_kind;
|
||||
caf::PdmField<int> m_quality;
|
||||
caf::PdmField<QString> m_remark;
|
||||
caf::PdmField<QString> m_filePath;
|
||||
};
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "RimProject.h"
|
||||
#include "RimWellLogTrack.h"
|
||||
#include "RimWellMeasurement.h"
|
||||
#include "RimWellMeasurementFilePath.h"
|
||||
|
||||
#include "cafCmdFeatureMenuBuilder.h"
|
||||
#include "cafPdmUiTableViewEditor.h"
|
||||
@ -40,6 +41,9 @@ RimWellMeasurementCollection::RimWellMeasurementCollection()
|
||||
m_measurements.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
|
||||
m_measurements.uiCapability()->setUiTreeHidden( true );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_importedFiles, "ImportedFiles", "Imported Files", "", "", "" );
|
||||
m_importedFiles.uiCapability()->setUiTreeHidden( false );
|
||||
|
||||
this->setName( "Well Measurements" );
|
||||
}
|
||||
|
||||
@ -88,6 +92,7 @@ void RimWellMeasurementCollection::insertMeasurement( RimWellMeasurement* insert
|
||||
else
|
||||
m_measurements.push_back( measurement );
|
||||
|
||||
addFilePath( measurement->filePath() );
|
||||
this->updateAllReferringTracks();
|
||||
}
|
||||
|
||||
@ -97,6 +102,7 @@ void RimWellMeasurementCollection::insertMeasurement( RimWellMeasurement* insert
|
||||
void RimWellMeasurementCollection::appendMeasurement( RimWellMeasurement* measurement )
|
||||
{
|
||||
m_measurements.push_back( measurement );
|
||||
addFilePath( measurement->filePath() );
|
||||
this->updateAllReferringTracks();
|
||||
}
|
||||
|
||||
@ -145,6 +151,7 @@ void RimWellMeasurementCollection::defineEditorAttribute( const caf::PdmFieldHan
|
||||
void RimWellMeasurementCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
uiOrdering.add( &m_measurements );
|
||||
uiOrdering.skipRemainingFields( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -153,6 +160,7 @@ void RimWellMeasurementCollection::defineUiOrdering( QString uiConfigName, caf::
|
||||
void RimWellMeasurementCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering,
|
||||
QString uiConfigName /*= ""*/ )
|
||||
{
|
||||
uiTreeOrdering.add( &m_importedFiles );
|
||||
uiTreeOrdering.skipRemainingChildren( true );
|
||||
}
|
||||
|
||||
@ -171,3 +179,68 @@ void RimWellMeasurementCollection::fieldChangedByUi( const caf::PdmFieldHandle*
|
||||
this->updateAllReferringTracks();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<QString> RimWellMeasurementCollection::importedFiles() const
|
||||
{
|
||||
std::set<QString> importedFiles;
|
||||
for ( auto importedFile : m_importedFiles )
|
||||
{
|
||||
importedFiles.insert( importedFile->filePath() );
|
||||
}
|
||||
|
||||
return importedFiles;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellMeasurementCollection::addFilePath( const QString& filePath )
|
||||
{
|
||||
std::set<QString> existingFilePaths = importedFiles();
|
||||
if ( existingFilePaths.find( filePath ) == existingFilePaths.end() )
|
||||
{
|
||||
RimWellMeasurementFilePath* measurementFilePath = new RimWellMeasurementFilePath;
|
||||
measurementFilePath->setFilePath( filePath );
|
||||
m_importedFiles.push_back( measurementFilePath );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellMeasurementCollection::removeFilePath( RimWellMeasurementFilePath* measurementFilePath )
|
||||
{
|
||||
m_importedFiles.removeChildObject( measurementFilePath );
|
||||
delete measurementFilePath;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellMeasurementCollection::removeMeasurementsForFilePath( RimWellMeasurementFilePath* measurementFilePath )
|
||||
{
|
||||
// Find all measurements for this file path
|
||||
std::vector<RimWellMeasurement*> measurementsToRemove;
|
||||
for ( auto attr : m_measurements )
|
||||
{
|
||||
if ( attr->filePath() == measurementFilePath->filePath() )
|
||||
{
|
||||
measurementsToRemove.push_back( attr );
|
||||
}
|
||||
}
|
||||
|
||||
// Remove then remove them without invalidating the iterator
|
||||
for ( unsigned int i = 0; i < measurementsToRemove.size(); i++ )
|
||||
{
|
||||
m_measurements.removeChildObject( measurementsToRemove[i] );
|
||||
delete measurementsToRemove[i];
|
||||
}
|
||||
|
||||
RimProject* proj;
|
||||
this->firstAncestorOrThisOfTypeAsserted( proj );
|
||||
proj->scheduleCreateDisplayModelAndRedrawAllViews();
|
||||
this->updateAllReferringTracks();
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "cafPdmProxyValueField.h"
|
||||
|
||||
class RimWellMeasurement;
|
||||
class RimWellMeasurementFilePath;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -45,6 +46,12 @@ public:
|
||||
void deleteMeasurement( RimWellMeasurement* measurementToDelete );
|
||||
void deleteAllMeasurements();
|
||||
|
||||
std::set<QString> importedFiles() const;
|
||||
|
||||
void addFilePath( const QString& filePath );
|
||||
void removeFilePath( RimWellMeasurementFilePath* measurementFilePath );
|
||||
void removeMeasurementsForFilePath( RimWellMeasurementFilePath* measurementFilePath );
|
||||
|
||||
protected:
|
||||
void defineEditorAttribute( const caf::PdmFieldHandle* field,
|
||||
QString uiConfigName,
|
||||
@ -57,4 +64,5 @@ protected:
|
||||
|
||||
private:
|
||||
caf::PdmChildArrayField<RimWellMeasurement*> m_measurements;
|
||||
caf::PdmChildArrayField<RimWellMeasurementFilePath*> m_importedFiles;
|
||||
};
|
||||
|
@ -0,0 +1,63 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimWellMeasurementFilePath.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimWellMeasurementFilePath, "WellMeasurementFilePath" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellMeasurementFilePath::RimWellMeasurementFilePath()
|
||||
{
|
||||
CAF_PDM_InitObject( "RimWellMeasurementFilePath", "", "", "" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_filePath, "FilePath", "File Path", "", "", "" );
|
||||
m_filePath.uiCapability()->setUiReadOnly( true );
|
||||
setUiName( "File Path" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellMeasurementFilePath::~RimWellMeasurementFilePath() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellMeasurementFilePath::filePath() const
|
||||
{
|
||||
return m_filePath.v().path();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellMeasurementFilePath::setFilePath( const QString& filePath )
|
||||
{
|
||||
m_filePath = caf::FilePath( filePath );
|
||||
setUiName( filePath );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellMeasurementFilePath::initAfterRead()
|
||||
{
|
||||
setUiName( filePath() );
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2020- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafFilePath.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimWellMeasurementFilePath : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimWellMeasurementFilePath();
|
||||
~RimWellMeasurementFilePath() override;
|
||||
|
||||
QString filePath() const;
|
||||
void setFilePath( const QString& filePath );
|
||||
|
||||
protected:
|
||||
void initAfterRead() override;
|
||||
|
||||
private:
|
||||
caf::PdmField<caf::FilePath> m_filePath;
|
||||
};
|
Loading…
Reference in New Issue
Block a user