mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1018 : Added PdmUiTableView used to define multiple snapshot definitions
This commit is contained in:
parent
58caac451c
commit
06d120bd29
@ -22,13 +22,14 @@
|
|||||||
#include "RimProject.h"
|
#include "RimProject.h"
|
||||||
#include "RiuExportMultipleSnapshotsWidget.h"
|
#include "RiuExportMultipleSnapshotsWidget.h"
|
||||||
|
|
||||||
|
#include "cafCmdExecCommandManager.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
|
||||||
|
|
||||||
CAF_CMD_SOURCE_INIT(RicExportMultipleSnapshotsFeature, "RicExportMultipleSnapshotsFeature");
|
CAF_CMD_SOURCE_INIT(RicExportMultipleSnapshotsFeature, "RicExportMultipleSnapshotsFeature");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -48,6 +49,9 @@ void RicExportMultipleSnapshotsFeature::onActionTriggered(bool isChecked)
|
|||||||
|
|
||||||
if (proj)
|
if (proj)
|
||||||
{
|
{
|
||||||
|
// Enable the command system to be able to assign a value to multiple fields at the same time
|
||||||
|
caf::CmdExecCommandSystemActivator activator;
|
||||||
|
|
||||||
RiuExportMultipleSnapshotsWidget dlg(nullptr, proj);
|
RiuExportMultipleSnapshotsWidget dlg(nullptr, proj);
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,13 @@
|
|||||||
|
|
||||||
#include "RimMultiSnapshotDefinition.h"
|
#include "RimMultiSnapshotDefinition.h"
|
||||||
|
|
||||||
|
#include "RiaApplication.h"
|
||||||
|
#include "RimCase.h"
|
||||||
|
#include "RimProject.h"
|
||||||
|
#include "RimView.h"
|
||||||
|
|
||||||
|
#include "cafPdmPointer.h"
|
||||||
|
|
||||||
|
|
||||||
CAF_PDM_SOURCE_INIT(RimMultiSnapshotDefinition, "MultiSnapshotDefinition");
|
CAF_PDM_SOURCE_INIT(RimMultiSnapshotDefinition, "MultiSnapshotDefinition");
|
||||||
|
|
||||||
@ -43,4 +50,41 @@ RimMultiSnapshotDefinition::~RimMultiSnapshotDefinition()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
QList<caf::PdmOptionItemInfo> RimMultiSnapshotDefinition::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
||||||
|
{
|
||||||
|
QList<caf::PdmOptionItemInfo> options;
|
||||||
|
|
||||||
|
RimProject* proj = RiaApplication::instance()->project();
|
||||||
|
|
||||||
|
if (fieldNeedingOptions == &caseObject && proj)
|
||||||
|
{
|
||||||
|
std::vector<RimCase*> cases;
|
||||||
|
proj->allCases(cases);
|
||||||
|
|
||||||
|
for (RimCase* c : cases)
|
||||||
|
{
|
||||||
|
options.push_back(caf::PdmOptionItemInfo(c->caseUserDescription(), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(c))));
|
||||||
|
}
|
||||||
|
|
||||||
|
options.push_back(caf::PdmOptionItemInfo("All", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(nullptr))));
|
||||||
|
}
|
||||||
|
else if (fieldNeedingOptions == &viewObject)
|
||||||
|
{
|
||||||
|
if (caseObject())
|
||||||
|
{
|
||||||
|
std::vector<RimView*> views = caseObject()->views();
|
||||||
|
for (RimView* view : views)
|
||||||
|
{
|
||||||
|
options.push_back(caf::PdmOptionItemInfo(view->name(), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(view))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
options.push_back(caf::PdmOptionItemInfo("All", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(nullptr))));
|
||||||
|
}
|
||||||
|
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -42,4 +42,6 @@ public:
|
|||||||
caf::PdmField<int> timeStepStart;
|
caf::PdmField<int> timeStepStart;
|
||||||
caf::PdmField<int> timeStepEnd;
|
caf::PdmField<int> timeStepEnd;
|
||||||
|
|
||||||
|
|
||||||
|
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
|
||||||
};
|
};
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "RiuExportMultipleSnapshotsWidget.h"
|
#include "RiuExportMultipleSnapshotsWidget.h"
|
||||||
|
|
||||||
|
#include "RimMultiSnapshotDefinition.h"
|
||||||
#include "RimProject.h"
|
#include "RimProject.h"
|
||||||
|
|
||||||
#include "cafCmdFeatureManager.h"
|
#include "cafCmdFeatureManager.h"
|
||||||
@ -36,8 +37,8 @@
|
|||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RiuExportMultipleSnapshotsWidget::RiuExportMultipleSnapshotsWidget(QWidget* parent, RimProject* project)
|
RiuExportMultipleSnapshotsWidget::RiuExportMultipleSnapshotsWidget(QWidget* parent, RimProject* project)
|
||||||
: m_rimProject(project),
|
: QDialog(parent),
|
||||||
QDialog(parent)
|
m_rimProject(project)
|
||||||
{
|
{
|
||||||
setWindowTitle("Export Multiple Snapshots");
|
setWindowTitle("Export Multiple Snapshots");
|
||||||
|
|
||||||
@ -52,14 +53,13 @@ RiuExportMultipleSnapshotsWidget::RiuExportMultipleSnapshotsWidget(QWidget* pare
|
|||||||
|
|
||||||
m_pdmTableView->setListField(&(project->multiSnapshotDefinitions()));
|
m_pdmTableView->setListField(&(project->multiSnapshotDefinitions()));
|
||||||
|
|
||||||
|
// Set active child array to be able to use generic delete
|
||||||
caf::SelectionManager::instance()->setActiveChildArrayFieldHandle(&(project->multiSnapshotDefinitions()));
|
caf::SelectionManager::instance()->setActiveChildArrayFieldHandle(&(project->multiSnapshotDefinitions()));
|
||||||
|
|
||||||
dialogLayout->addWidget(m_pdmTableView);
|
dialogLayout->addWidget(m_pdmTableView);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
|
||||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
|
|
||||||
@ -71,6 +71,8 @@ RiuExportMultipleSnapshotsWidget::RiuExportMultipleSnapshotsWidget(QWidget* pare
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RiuExportMultipleSnapshotsWidget::~RiuExportMultipleSnapshotsWidget()
|
RiuExportMultipleSnapshotsWidget::~RiuExportMultipleSnapshotsWidget()
|
||||||
{
|
{
|
||||||
|
m_pdmTableView->setListField(nullptr);
|
||||||
|
|
||||||
caf::SelectionManager::instance()->setActiveChildArrayFieldHandle(nullptr);
|
caf::SelectionManager::instance()->setActiveChildArrayFieldHandle(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,10 +84,28 @@ void RiuExportMultipleSnapshotsWidget::customMenuRequested(QPoint pos)
|
|||||||
caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
|
caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
|
||||||
|
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
menu.addAction(commandManager->action("PdmListField_AddItem", "Add new row"));
|
menu.addAction(commandManager->action("PdmListField_DeleteItem","Delete row"));
|
||||||
|
|
||||||
|
QAction* newRowAction = new QAction("Add new row", this);
|
||||||
|
connect(newRowAction, SIGNAL(triggered()), SLOT(addSnapshotItem()));
|
||||||
|
menu.addAction(newRowAction);
|
||||||
|
|
||||||
// Qt doc: QAbstractScrollArea and its subclasses that map the context menu event to coordinates of the viewport().
|
// Qt doc: QAbstractScrollArea and its subclasses that map the context menu event to coordinates of the viewport().
|
||||||
QPoint globalPos = m_pdmTableView->tableView()->viewport()->mapToGlobal(pos);
|
QPoint globalPos = m_pdmTableView->tableView()->viewport()->mapToGlobal(pos);
|
||||||
|
|
||||||
menu.exec(globalPos);
|
menu.exec(globalPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiuExportMultipleSnapshotsWidget::addSnapshotItem()
|
||||||
|
{
|
||||||
|
if (!m_rimProject) return;
|
||||||
|
|
||||||
|
RimMultiSnapshotDefinition* multiSnapshot = new RimMultiSnapshotDefinition();
|
||||||
|
// TODO: init with available time step from
|
||||||
|
|
||||||
|
m_rimProject->multiSnapshotDefinitions.push_back(multiSnapshot);
|
||||||
|
m_rimProject->multiSnapshotDefinitions.uiCapability()->updateConnectedEditors();
|
||||||
|
}
|
||||||
|
@ -37,6 +37,7 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void customMenuRequested(QPoint pos);
|
void customMenuRequested(QPoint pos);
|
||||||
|
void addSnapshotItem();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RimProject* m_rimProject;
|
RimProject* m_rimProject;
|
||||||
|
Loading…
Reference in New Issue
Block a user