Skip to content

Commit

Permalink
Add import feature to data source
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed May 13, 2024
1 parent 4c4f338 commit 256a1d4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 15 deletions.
9 changes: 0 additions & 9 deletions ApplicationLibCode/Commands/RicImportVfpDataFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@

CAF_CMD_SOURCE_INIT( RicImportVfpDataFeature, "RicImportVfpDataFeature" );

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicImportVfpDataFeature::isCommandEnabled() const
{
auto plotColl = caf::firstAncestorOfTypeFromSelectedObject<RimVfpPlotCollection>();
return ( plotColl != nullptr );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion ApplicationLibCode/Commands/RicImportVfpDataFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class RicImportVfpDataFeature : public caf::CmdFeature
CAF_CMD_HEADER_INIT;

private:
bool isCommandEnabled() const override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "RimOilField.h"
#include "RimProject.h"
#include "RimVfpPlotCollection.h"
#include "RimVfpTableData.h"

CAF_PDM_SOURCE_INIT( RimVfpDataCollection, "RimVfpDataCollection" );
Expand Down Expand Up @@ -63,3 +64,11 @@ std::vector<RimVfpTableData*> RimVfpDataCollection::vfpTableData() const
{
return m_vfpTableData.childrenByType();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpDataCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
{
RimVfpPlotCollection::addImportItems( menuBuilder );
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class RimVfpDataCollection : public caf::PdmObject
RimVfpTableData* importFromFile( const QString& fileName );
std::vector<RimVfpTableData*> vfpTableData() const;

private:
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;

private:
caf::PdmChildArrayField<RimVfpTableData*> m_vfpTableData;
};
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,18 @@ void RimVfpPlotCollection::deleteAllPlots()
m_vfpDecks.deleteChildren();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimVfpPlotCollection::addImportItems( caf::CmdFeatureMenuBuilder& menuBuilder )
{
// A variant with a true value is used to indicate that the VFP data is imported from a file
// This is used to distinguish between VFP data imported from a file and VFP data imported from a simulator
QVariant variant( QVariant::fromValue( true ) );
menuBuilder.addCmdFeatureWithUserData( "RicImportVfpDataFeature", "Import VFP Files", variant );
menuBuilder.addCmdFeature( "RicImportVfpDataFeature", "Import VFP from Simulator Files" );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -184,9 +196,5 @@ void RimVfpPlotCollection::loadDataAndUpdateAllPlots()
//--------------------------------------------------------------------------------------------------
void RimVfpPlotCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
{
// A variant with a true value is used to indicate that the VFP data is imported from a file
// This is used to distinguish between VFP data imported from a file and VFP data imported from a simulator
QVariant variant( QVariant::fromValue( true ) );
menuBuilder.addCmdFeatureWithUserData( "RicImportVfpDataFeature", "Import VFP Files", variant );
menuBuilder.addCmdFeature( "RicImportVfpDataFeature", "Import VFP from Simulator Files" );
addImportItems( menuBuilder );
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class RimVfpPlotCollection : public caf::PdmObject, public RimTypedPlotCollectio
void removePlot( RimVfpPlot* vfpPlot ) final;
void deleteAllPlots() override;

static void addImportItems( caf::CmdFeatureMenuBuilder& menuBuilder );

private:
void loadDataAndUpdateAllPlots() override;
void onChildrenUpdated( caf::PdmChildArrayFieldHandle* childArray, std::vector<caf::PdmObjectHandle*>& updatedObjects ) override;
Expand Down

0 comments on commit 256a1d4

Please sign in to comment.