mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge remote-tracking branch 'origin/dev' into pre-proto
This commit is contained in:
@@ -32,6 +32,7 @@ ${CEE_CURRENT_LIST_DIR}RicImportGeoMechCaseFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicImportSummaryCaseFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicExportFeatureImpl.h
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RicSelectOrCreateViewFeatureImpl.h
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureAtPosFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicNewEllipseFractureTemplateFeature.h
|
||||
@@ -57,6 +58,8 @@ ${CEE_CURRENT_LIST_DIR}RicDeleteItemExecData.h
|
||||
${CEE_CURRENT_LIST_DIR}RicDeleteItemFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicDeleteSubItemsFeature.h
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RicCloseSourSimDataFeature.h
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RicCommandFeature.h
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RicReloadCaseFeature.h
|
||||
@@ -88,6 +91,7 @@ ${CEE_CURRENT_LIST_DIR}RicImportGeoMechCaseFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicImportSummaryCaseFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExportFeatureImpl.cpp
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RicSelectOrCreateViewFeatureImpl.cpp
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureAtPosFeature.cpp
|
||||
@@ -116,6 +120,8 @@ ${CEE_CURRENT_LIST_DIR}RicDeleteItemFeature.cpp
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RicDeleteSubItemsFeature.cpp
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RicCloseSourSimDataFeature.cpp
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RicReloadCaseFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicFlyToObjectFeature.cpp
|
||||
)
|
||||
|
||||
@@ -5,6 +5,7 @@ if (${CMAKE_VERSION} VERSION_GREATER "2.8.2")
|
||||
endif()
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicAddStoredFlowCharacteristicsPlotFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicShowWellAllocationPlotFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicShowFlowCharacteristicsPlotFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicAddStoredWellAllocationPlotFeature.h
|
||||
@@ -17,6 +18,7 @@ ${CEE_CURRENT_LIST_DIR}RicShowTotalAllocationDataFeature.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicAddStoredFlowCharacteristicsPlotFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicShowWellAllocationPlotFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicShowFlowCharacteristicsPlotFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicAddStoredWellAllocationPlotFeature.cpp
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil 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 "RicAddStoredFlowCharacteristicsPlotFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RimFlowPlotCollection.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimFlowCharacteristicsPlot.h"
|
||||
|
||||
#include "RiuMainPlotWindow.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicAddStoredFlowCharacteristicsPlotFeature, "RicAddStoredFlowCharacteristicsPlotFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicAddStoredFlowCharacteristicsPlotFeature::isCommandEnabled()
|
||||
{
|
||||
if (RiaApplication::instance()->project())
|
||||
{
|
||||
RimFlowPlotCollection* flowPlotColl = RiaApplication::instance()->project()->mainPlotCollection->flowPlotCollection();
|
||||
if (flowPlotColl)
|
||||
{
|
||||
RimFlowCharacteristicsPlot* flowCharacteristicsPlot = dynamic_cast<RimFlowCharacteristicsPlot*>(caf::SelectionManager::instance()->selectedItem());
|
||||
|
||||
if (flowPlotColl->defaultFlowCharacteristicsPlot() == flowCharacteristicsPlot)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAddStoredFlowCharacteristicsPlotFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
if (RiaApplication::instance()->project())
|
||||
{
|
||||
RimFlowPlotCollection* flowPlotColl = RiaApplication::instance()->project()->mainPlotCollection->flowPlotCollection();
|
||||
if (flowPlotColl)
|
||||
{
|
||||
RimFlowCharacteristicsPlot* sourceObject = dynamic_cast<RimFlowCharacteristicsPlot*>(caf::SelectionManager::instance()->selectedItem());
|
||||
|
||||
RimFlowCharacteristicsPlot* flowCharacteristicsPlot = dynamic_cast<RimFlowCharacteristicsPlot*>(sourceObject->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance()));
|
||||
CVF_ASSERT(flowCharacteristicsPlot);
|
||||
|
||||
flowPlotColl->addFlowCharacteristicsPlotToStoredPlots(flowCharacteristicsPlot);
|
||||
flowCharacteristicsPlot->resolveReferencesRecursively();
|
||||
|
||||
flowCharacteristicsPlot->loadDataAndUpdate();
|
||||
|
||||
flowPlotColl->updateConnectedEditors();
|
||||
|
||||
RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow();
|
||||
if (mainPlotWindow)
|
||||
{
|
||||
mainPlotWindow->selectAsCurrentItem(flowCharacteristicsPlot);
|
||||
mainPlotWindow->setExpanded(flowCharacteristicsPlot, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAddStoredFlowCharacteristicsPlotFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
//actionToSetup->setIcon(QIcon(":/new_icon16x16.png"));
|
||||
actionToSetup->setText("Add Stored Well Allocation Plot");
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil 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 RicAddStoredFlowCharacteristicsPlotFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled() override;
|
||||
virtual void onActionTriggered( bool isChecked ) override;
|
||||
virtual void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RicSelectViewUI.h"
|
||||
#include "RicSelectOrCreateViewFeatureImpl.h"
|
||||
|
||||
#include "RigFlowDiagResultAddress.h"
|
||||
#include "RigSingleWellResultsData.h"
|
||||
@@ -41,84 +41,13 @@
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
#include "cafCmdFeatureManager.h"
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseView* RicShowContributingWellsFeatureImpl::maniuplateSelectedView(RimEclipseResultCase* eclipseResultCase, QString wellName, int timeStep)
|
||||
{
|
||||
const QString lastUsedViewKey("lastUsedViewKey");
|
||||
|
||||
RimEclipseView* defaultSelectedView = nullptr;
|
||||
{
|
||||
QString lastUsedViewRef = RiaApplication::instance()->cacheDataObject(lastUsedViewKey).toString();
|
||||
RimEclipseView* lastUsedView = dynamic_cast<RimEclipseView*>(caf::PdmReferenceHelper::objectFromReference(RiaApplication::instance()->project(), lastUsedViewRef));
|
||||
if (lastUsedView)
|
||||
{
|
||||
RimEclipseResultCase* lastUsedViewResultCase = nullptr;
|
||||
lastUsedView->firstAncestorOrThisOfTypeAsserted(lastUsedViewResultCase);
|
||||
|
||||
if (lastUsedViewResultCase == eclipseResultCase)
|
||||
{
|
||||
defaultSelectedView = lastUsedView;
|
||||
}
|
||||
}
|
||||
|
||||
if (!defaultSelectedView)
|
||||
{
|
||||
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
|
||||
if (activeView)
|
||||
{
|
||||
RimEclipseResultCase* activeViewResultCase = nullptr;
|
||||
activeView->firstAncestorOrThisOfTypeAsserted(activeViewResultCase);
|
||||
|
||||
if (activeViewResultCase == eclipseResultCase)
|
||||
{
|
||||
defaultSelectedView = activeView;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (eclipseResultCase->views().size() > 0)
|
||||
{
|
||||
defaultSelectedView = dynamic_cast<RimEclipseView*>(eclipseResultCase->views()[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RicSelectViewUI featureUi;
|
||||
if (defaultSelectedView)
|
||||
{
|
||||
featureUi.setView(defaultSelectedView);
|
||||
}
|
||||
else
|
||||
{
|
||||
featureUi.setCase(eclipseResultCase);
|
||||
}
|
||||
|
||||
caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, "Show Contributing Wells in View", "");
|
||||
propertyDialog.resize(QSize(400, 200));
|
||||
|
||||
if (propertyDialog.exec() != QDialog::Accepted) return nullptr;
|
||||
|
||||
RimEclipseView* viewToManipulate = nullptr;
|
||||
if (featureUi.createNewView())
|
||||
{
|
||||
RimEclipseView* createdView = eclipseResultCase->createAndAddReservoirView();
|
||||
createdView->name = featureUi.newViewName();
|
||||
|
||||
// Must be run before buildViewItems, as wells are created in this function
|
||||
createdView->loadDataAndUpdate();
|
||||
eclipseResultCase->updateConnectedEditors();
|
||||
|
||||
viewToManipulate = createdView;
|
||||
}
|
||||
else
|
||||
{
|
||||
viewToManipulate = featureUi.selectedView();
|
||||
}
|
||||
RimEclipseView* viewToManipulate = RicSelectOrCreateViewFeatureImpl::showViewSelection(eclipseResultCase, "lastUsedWellAllocationView", "Show Contributing Wells in View");
|
||||
|
||||
CVF_ASSERT(viewToManipulate);
|
||||
|
||||
@@ -128,11 +57,7 @@ RimEclipseView* RicShowContributingWellsFeatureImpl::maniuplateSelectedView(RimE
|
||||
auto* feature = caf::CmdFeatureManager::instance()->getCommandFeature("RicShowMainWindowFeature");
|
||||
feature->actionTriggered(false);
|
||||
|
||||
RiuMainWindow::instance()->setExpanded(viewToManipulate, true);
|
||||
RiuMainWindow::instance()->selectAsCurrentItem(viewToManipulate);
|
||||
|
||||
QString refFromProjectToView = caf::PdmReferenceHelper::referenceFromRootToObject(RiaApplication::instance()->project(), viewToManipulate);
|
||||
RiaApplication::instance()->setCacheDataObject(lastUsedViewKey, refFromProjectToView);
|
||||
RicSelectOrCreateViewFeatureImpl::focusView(viewToManipulate);
|
||||
|
||||
return viewToManipulate;
|
||||
}
|
||||
|
||||
68
ApplicationCode/Commands/RicCloseSourSimDataFeature.cpp
Normal file
68
ApplicationCode/Commands/RicCloseSourSimDataFeature.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil 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 "RicCloseSourSimDataFeature.h"
|
||||
|
||||
#include "RimEclipseResultCase.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicCloseSourSimDataFeature, "RicCloseSourSimDataFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCloseSourSimDataFeature::isCommandEnabled()
|
||||
{
|
||||
return getSelectedEclipseCase() != nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCloseSourSimDataFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RimEclipseResultCase* eclipseCase = getSelectedEclipseCase();
|
||||
|
||||
if (eclipseCase == nullptr) return;
|
||||
|
||||
eclipseCase->setSourSimFileName(QString());
|
||||
eclipseCase->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCloseSourSimDataFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Close SourSim Data");
|
||||
actionToSetup->setIcon(QIcon(":/Erase.png"));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseResultCase* RicCloseSourSimDataFeature::getSelectedEclipseCase()
|
||||
{
|
||||
caf::PdmUiItem* selectedItem = caf::SelectionManager::instance()->selectedItem();
|
||||
RimEclipseResultCase* eclipseCase = dynamic_cast<RimEclipseResultCase*>(selectedItem);
|
||||
return eclipseCase;
|
||||
}
|
||||
40
ApplicationCode/Commands/RicCloseSourSimDataFeature.h
Normal file
40
ApplicationCode/Commands/RicCloseSourSimDataFeature.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil 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 RimEclipseResultCase;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicCloseSourSimDataFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
protected:
|
||||
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered( bool isChecked );
|
||||
virtual void setupActionLook( QAction* actionToSetup );
|
||||
|
||||
private:
|
||||
static RimEclipseResultCase* getSelectedEclipseCase();
|
||||
};
|
||||
@@ -49,6 +49,8 @@
|
||||
#include "RimWellLogTrack.h"
|
||||
#include "RimFishboneWellPath.h"
|
||||
#include "RimPerforationInterval.h"
|
||||
#include "RimFlowCharacteristicsPlot.h"
|
||||
#include "RimAsciiDataCurve.h"
|
||||
#include "RimWellPathFracture.h"
|
||||
#include "RimWellPathFractureCollection.h"
|
||||
|
||||
@@ -67,6 +69,7 @@ bool isDeletable(caf::PdmUiItem* uiItem)
|
||||
{
|
||||
// Enable delete of well allocation plots
|
||||
if (dynamic_cast<RimWellAllocationPlot*>(uiItem)) return true;
|
||||
if (dynamic_cast<RimFlowCharacteristicsPlot*>(uiItem)) return true;
|
||||
|
||||
// Disable delete of all sub objects of a well allocation plot
|
||||
caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(uiItem);
|
||||
@@ -99,9 +102,10 @@ bool isDeletable(caf::PdmUiItem* uiItem)
|
||||
if (dynamic_cast<RimIntersectionBox*>(uiItem)) return true;
|
||||
if (dynamic_cast<RimFormationNames*>(uiItem)) return true;
|
||||
if (dynamic_cast<RimFormationNamesCollection*>(uiItem)) return true;
|
||||
if (dynamic_cast<RimFishboneWellPath*>(uiItem)) return true;
|
||||
if (dynamic_cast<RimFishboneWellPath*>(uiItem)) return true;
|
||||
if (dynamic_cast<RimFishbonesMultipleSubs*>(uiItem)) return true;
|
||||
if (dynamic_cast<RimPerforationInterval*>(uiItem)) return true;
|
||||
if (dynamic_cast<RimAsciiDataCurve*>(uiItem)) return true;
|
||||
if (dynamic_cast<RimWellPathFractureCollection*>(uiItem)) return true;
|
||||
if (dynamic_cast<RimWellPathFracture*>(uiItem)) return true;
|
||||
if (dynamic_cast<RimEllipseFractureTemplate*>(uiItem)) return true;
|
||||
|
||||
131
ApplicationCode/Commands/RicSelectOrCreateViewFeatureImpl.cpp
Normal file
131
ApplicationCode/Commands/RicSelectOrCreateViewFeatureImpl.cpp
Normal file
@@ -0,0 +1,131 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil 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 "RicSelectOrCreateViewFeatureImpl.h"
|
||||
|
||||
#include "FlowCommands/RicSelectViewUI.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RimProject.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimEclipseResultCase.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
RimEclipseView* RicSelectOrCreateViewFeatureImpl::showViewSelection(RimEclipseResultCase* resultCase, const QString& lastUsedViewKey, const QString& dialogTitle)
|
||||
{
|
||||
RimEclipseView* defaultSelectedView = getDefaultSelectedView(resultCase, lastUsedViewKey);
|
||||
|
||||
RicSelectViewUI featureUi;
|
||||
if (defaultSelectedView)
|
||||
{
|
||||
featureUi.setView(defaultSelectedView);
|
||||
}
|
||||
else
|
||||
{
|
||||
featureUi.setCase(resultCase);
|
||||
}
|
||||
|
||||
caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, dialogTitle, "");
|
||||
propertyDialog.resize(QSize(400, 200));
|
||||
|
||||
if (propertyDialog.exec() != QDialog::Accepted) return nullptr;
|
||||
|
||||
RimEclipseView* viewToManipulate = nullptr;
|
||||
if (featureUi.createNewView())
|
||||
{
|
||||
RimEclipseView* createdView = resultCase->createAndAddReservoirView();
|
||||
createdView->name = featureUi.newViewName();
|
||||
|
||||
// Must be run before buildViewItems, as wells are created in this function
|
||||
createdView->loadDataAndUpdate();
|
||||
resultCase->updateConnectedEditors();
|
||||
|
||||
viewToManipulate = createdView;
|
||||
}
|
||||
else
|
||||
{
|
||||
viewToManipulate = featureUi.selectedView();
|
||||
}
|
||||
|
||||
QString refFromProjectToView = caf::PdmReferenceHelper::referenceFromRootToObject(RiaApplication::instance()->project(), viewToManipulate);
|
||||
RiaApplication::instance()->setCacheDataObject(lastUsedViewKey, refFromProjectToView);
|
||||
|
||||
return viewToManipulate;
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
void RicSelectOrCreateViewFeatureImpl::focusView(RimEclipseView* view)
|
||||
{
|
||||
RiuMainWindow::instance()->setExpanded(view, true);
|
||||
RiuMainWindow::instance()->selectAsCurrentItem(view);
|
||||
RiuMainWindow::instance()->raise();
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
RimEclipseView* RicSelectOrCreateViewFeatureImpl::getDefaultSelectedView(RimEclipseResultCase* resultCase, const QString& lastUsedViewKey)
|
||||
{
|
||||
RimEclipseView* defaultSelectedView = nullptr;
|
||||
|
||||
QString lastUsedViewRef = RiaApplication::instance()->cacheDataObject(lastUsedViewKey).toString();
|
||||
RimEclipseView* lastUsedView = dynamic_cast<RimEclipseView*>(caf::PdmReferenceHelper::objectFromReference(RiaApplication::instance()->project(), lastUsedViewRef));
|
||||
if (lastUsedView)
|
||||
{
|
||||
RimEclipseResultCase* lastUsedViewResultCase = nullptr;
|
||||
lastUsedView->firstAncestorOrThisOfTypeAsserted(lastUsedViewResultCase);
|
||||
|
||||
if (lastUsedViewResultCase == resultCase)
|
||||
{
|
||||
defaultSelectedView = lastUsedView;
|
||||
}
|
||||
}
|
||||
|
||||
if (!defaultSelectedView)
|
||||
{
|
||||
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
|
||||
if (activeView)
|
||||
{
|
||||
RimEclipseResultCase* activeViewResultCase = nullptr;
|
||||
activeView->firstAncestorOrThisOfTypeAsserted(activeViewResultCase);
|
||||
|
||||
if (activeViewResultCase == resultCase)
|
||||
{
|
||||
defaultSelectedView = activeView;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (resultCase->views().size() > 0)
|
||||
{
|
||||
defaultSelectedView = dynamic_cast<RimEclipseView*>(resultCase->views()[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return defaultSelectedView;
|
||||
}
|
||||
39
ApplicationCode/Commands/RicSelectOrCreateViewFeatureImpl.h
Normal file
39
ApplicationCode/Commands/RicSelectOrCreateViewFeatureImpl.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil 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 <QString>
|
||||
|
||||
class RimEclipseView;
|
||||
class RimEclipseResultCase;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicSelectOrCreateViewFeatureImpl
|
||||
{
|
||||
public:
|
||||
static RimEclipseView* showViewSelection(RimEclipseResultCase* resultCase, const QString& lastUsedViewKey, const QString& dialogTitle);
|
||||
static void focusView(RimEclipseView* view);
|
||||
|
||||
private:
|
||||
static RimEclipseView* getDefaultSelectedView(RimEclipseResultCase* resultCase, const QString& lastUsedViewKey);
|
||||
};
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ set (SOURCE_GROUP_HEADER_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryPlotFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFilterFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeatureUi.h
|
||||
${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicPasteSummaryPlotFeature.h
|
||||
@@ -23,6 +25,8 @@ set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryPlotFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFilterFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeatureUi.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicPasteSummaryPlotFeature.cpp
|
||||
|
||||
@@ -93,7 +93,7 @@ void RicNewSummaryPlotFeature::setupActionLook(QAction* actionToSetup)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewSummaryPlotFeature::createNewSummaryPlot(RimSummaryPlotCollection* summaryPlotColl, RimSummaryCase* summaryCase)
|
||||
RimSummaryPlot* RicNewSummaryPlotFeature::createNewSummaryPlot(RimSummaryPlotCollection* summaryPlotColl, RimSummaryCase* summaryCase)
|
||||
{
|
||||
RimSummaryPlot* plot = new RimSummaryPlot();
|
||||
summaryPlotColl->summaryPlots().push_back(plot);
|
||||
@@ -118,4 +118,6 @@ void RicNewSummaryPlotFeature::createNewSummaryPlot(RimSummaryPlotCollection* su
|
||||
mainPlotWindow->selectAsCurrentItem(newCurveFilter);
|
||||
mainPlotWindow->setExpanded(newCurveFilter, true);
|
||||
}
|
||||
|
||||
return plot;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
class RimSummaryCase;
|
||||
class RimSummaryPlotCollection;
|
||||
class RimSummaryPlot;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -31,7 +32,7 @@ class RicNewSummaryPlotFeature : public caf::CmdFeature
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
static void createNewSummaryPlot(RimSummaryPlotCollection* summaryPlotColl, RimSummaryCase* summaryCase);
|
||||
static RimSummaryPlot* createNewSummaryPlot(RimSummaryPlotCollection* summaryPlotColl, RimSummaryCase* summaryCase);
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
|
||||
@@ -0,0 +1,291 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil 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 "RicPasteAsciiDataToSummaryPlotFeature.h"
|
||||
|
||||
#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h"
|
||||
#include "RicNewSummaryPlotFeature.h"
|
||||
#include "RicPasteAsciiDataToSummaryPlotFeatureUi.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
#include "RimAsciiDataCurve.h"
|
||||
#include "RimSummaryCurveAppearanceCalculator.h"
|
||||
|
||||
#include "cafPdmDefaultObjectFactory.h"
|
||||
#include "cafPdmDocument.h"
|
||||
#include "cafPdmObjectGroup.h"
|
||||
#include "cafSelectionManager.h"
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
#include "cafPdmSettings.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
#include "cvfColor3.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QAction>
|
||||
#include <QClipboard>
|
||||
#include <QMimeData>
|
||||
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicPasteAsciiDataToSummaryPlotFeature, "RicPasteExcelToSummaryPlotFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicPasteAsciiDataToSummaryPlotFeature::isCommandEnabled()
|
||||
{
|
||||
caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());
|
||||
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
destinationObject->firstAncestorOrThisOfType(summaryPlot);
|
||||
if (!summaryPlot)
|
||||
{
|
||||
RimSummaryPlotCollection* summaryPlotCollection = nullptr;
|
||||
destinationObject->firstAncestorOrThisOfType(summaryPlotCollection);
|
||||
if (!summaryPlotCollection)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return hasPastedText();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPasteAsciiDataToSummaryPlotFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
|
||||
caf::PdmObjectHandle* destinationObject = dynamic_cast<caf::PdmObjectHandle*>(caf::SelectionManager::instance()->selectedItem());
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
destinationObject->firstAncestorOrThisOfType(summaryPlot);
|
||||
|
||||
RicPasteAsciiDataToSummaryPlotFeatureUi pasteOptions;
|
||||
if (!summaryPlot) pasteOptions.createNewPlot();
|
||||
caf::PdmSettings::readFieldsFromApplicationStore(&pasteOptions);
|
||||
|
||||
caf::PdmUiPropertyViewDialog propertyDialog(NULL, &pasteOptions, "Set Paste Options", "");
|
||||
if (propertyDialog.exec() != QDialog::Accepted) return;
|
||||
|
||||
if (!summaryPlot)
|
||||
{
|
||||
RimSummaryPlotCollection* summaryPlotCollection = nullptr;
|
||||
destinationObject->firstAncestorOrThisOfType(summaryPlotCollection);
|
||||
if (!summaryPlotCollection)
|
||||
{
|
||||
return;
|
||||
}
|
||||
summaryPlot = RicNewSummaryPlotFeature::createNewSummaryPlot(summaryPlotCollection, nullptr);
|
||||
if (!summaryPlot)
|
||||
{
|
||||
return;
|
||||
}
|
||||
summaryPlot->setDescription(pasteOptions.plotTitle());
|
||||
}
|
||||
|
||||
caf::PdmSettings::writeFieldsToApplicationStore(&pasteOptions);
|
||||
|
||||
QString text = getPastedData();
|
||||
|
||||
std::vector<RimAsciiDataCurve*> curves = parseCurves(text, pasteOptions);
|
||||
|
||||
for (RimAsciiDataCurve* curve : curves)
|
||||
{
|
||||
summaryPlot->addAsciiDataCruve(curve);
|
||||
}
|
||||
|
||||
summaryPlot->updateConnectedEditors();
|
||||
summaryPlot->loadDataAndUpdate();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPasteAsciiDataToSummaryPlotFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Paste Excel Data to Summary Curve");
|
||||
|
||||
RicPasteFeatureImpl::setIconAndShortcuts(actionToSetup);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicPasteAsciiDataToSummaryPlotFeature::getPastedData()
|
||||
{
|
||||
if (hasPastedText())
|
||||
{
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
return clipboard->text();
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicPasteAsciiDataToSummaryPlotFeature::hasPastedText()
|
||||
{
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
const QMimeData* mimeData = clipboard->mimeData();
|
||||
return mimeData->hasText();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimAsciiDataCurve*> RicPasteAsciiDataToSummaryPlotFeature::parseCurves(QString& data, const RicPasteAsciiDataToSummaryPlotFeatureUi& settings)
|
||||
{
|
||||
std::vector<RimAsciiDataCurve*> curves;
|
||||
std::vector<QString> headers;
|
||||
|
||||
QTextStream tableData(&data);
|
||||
|
||||
{
|
||||
QString header;
|
||||
|
||||
do {
|
||||
header = tableData.readLine();
|
||||
} while (header.isEmpty() && !tableData.atEnd());
|
||||
|
||||
// No header row found
|
||||
if (header.isEmpty()) return curves;
|
||||
|
||||
QStringList columnHeaders = header.split('\t');
|
||||
|
||||
for (size_t i = 1; i < columnHeaders.size(); ++i)
|
||||
{
|
||||
headers.push_back(columnHeaders[static_cast<int>(i)]);
|
||||
}
|
||||
|
||||
// No columns found
|
||||
if (headers.empty()) return curves;
|
||||
}
|
||||
|
||||
size_t numColumns = headers.size();
|
||||
std::vector<QDateTime> timeSteps;
|
||||
std::vector< std::vector<double> > values;
|
||||
values.resize(numColumns);
|
||||
|
||||
size_t row = 0;
|
||||
while (!tableData.atEnd())
|
||||
{
|
||||
++row;
|
||||
QString line = tableData.readLine();
|
||||
|
||||
// Skip empty lines
|
||||
if (line.isEmpty()) continue;
|
||||
|
||||
QStringList columns = line.split(settings.cellSeparator());
|
||||
|
||||
if (columns.size() != numColumns + 1)
|
||||
{
|
||||
RiaLogging::warning(QString("Invalid number of columns in row %1").arg(row));
|
||||
continue;
|
||||
}
|
||||
|
||||
QDateTime date = QDateTime::fromString(columns[0], settings.dateFormat());
|
||||
if (!date.isValid())
|
||||
{
|
||||
RiaLogging::warning(QString("First column of row %1 could not be parsed as a date: %2").arg(row).arg(columns[0]));
|
||||
continue;
|
||||
}
|
||||
timeSteps.push_back(date);
|
||||
|
||||
for (size_t col = 1; col < columns.size(); ++col)
|
||||
{
|
||||
bool ok;
|
||||
values[col - 1].push_back(settings.decimalLocale().toDouble(columns[static_cast<int>(col)], &ok));
|
||||
if (!ok)
|
||||
{
|
||||
RiaLogging::warning(QString("Could not parse value at row %1 column %2 as double: %3. Defaulting to 0.0").arg(row).arg(col).arg(columns[static_cast<int>(col)]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::map< CurveType, std::vector<RimAsciiDataCurve*> > curveToTypeMap;
|
||||
|
||||
QString curvePrefix = settings.curvePrefix();
|
||||
|
||||
for (size_t i = 0; i < values.size(); ++i)
|
||||
{
|
||||
RimAsciiDataCurve* curve = new RimAsciiDataCurve();
|
||||
curve->setTimeSteps(timeSteps);
|
||||
curve->setValues(values[i]);
|
||||
if (curvePrefix.isEmpty())
|
||||
{
|
||||
curve->setTitle(headers[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
curve->setTitle(QString("%1: %2").arg(curvePrefix).arg(headers[i]));
|
||||
}
|
||||
curveToTypeMap[guessCurveType(headers[i])].push_back(curve);
|
||||
curves.push_back(curve);
|
||||
}
|
||||
|
||||
for (auto& it : curveToTypeMap)
|
||||
{
|
||||
for (int i = 0; i < it.second.size(); ++i)
|
||||
{
|
||||
cvf::Color3f color;
|
||||
switch (it.first)
|
||||
{
|
||||
case CURVE_GAS:
|
||||
color = RimSummaryCurveAppearanceCalculator::cycledGreenColor(i);
|
||||
break;
|
||||
case CURVE_OIL:
|
||||
color = RimSummaryCurveAppearanceCalculator::cycledRedColor(i);
|
||||
break;
|
||||
case CURVE_WAT:
|
||||
color = RimSummaryCurveAppearanceCalculator::cycledBlueColor(i);
|
||||
break;
|
||||
default:
|
||||
color = RimSummaryCurveAppearanceCalculator::cycledNoneRGBBrColor(i);
|
||||
break;
|
||||
}
|
||||
it.second[i]->setColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
return curves;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPasteAsciiDataToSummaryPlotFeature::CurveType RicPasteAsciiDataToSummaryPlotFeature::guessCurveType(const QString& curveName)
|
||||
{
|
||||
if (curveName.contains("SW") || curveName.contains("water", Qt::CaseInsensitive))
|
||||
{
|
||||
return CURVE_WAT;
|
||||
}
|
||||
else if (curveName.contains("oil", Qt::CaseInsensitive))
|
||||
{
|
||||
return CURVE_OIL;
|
||||
}
|
||||
else if (curveName.contains("gas", Qt::CaseInsensitive))
|
||||
{
|
||||
return CURVE_GAS;
|
||||
}
|
||||
return CURVE_UNKNOWN;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil 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"
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
class RimSummaryCurve;
|
||||
class RimSummaryCurveFilter;
|
||||
class RimAsciiDataCurve;
|
||||
class RicPasteAsciiDataToSummaryPlotFeatureUi;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicPasteAsciiDataToSummaryPlotFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
public:
|
||||
enum CurveType
|
||||
{
|
||||
CURVE_GAS,
|
||||
CURVE_OIL,
|
||||
CURVE_WAT,
|
||||
CURVE_UNKNOWN,
|
||||
};
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled() override;
|
||||
virtual void onActionTriggered( bool isChecked ) override;
|
||||
virtual void setupActionLook(QAction* actionToSetup) override;
|
||||
|
||||
private:
|
||||
static QString getPastedData();
|
||||
static bool hasPastedText();
|
||||
|
||||
static std::vector<RimAsciiDataCurve*> parseCurves(QString& data, const RicPasteAsciiDataToSummaryPlotFeatureUi& settings);
|
||||
|
||||
static CurveType guessCurveType(const QString& curveName);
|
||||
};
|
||||
@@ -0,0 +1,194 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil 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 "RicPasteAsciiDataToSummaryPlotFeatureUi.h"
|
||||
|
||||
namespace caf {
|
||||
|
||||
template<>
|
||||
void RicPasteAsciiDataToSummaryPlotFeatureUi::DecimalSeparatorEnum::setUp()
|
||||
{
|
||||
addItem(RicPasteAsciiDataToSummaryPlotFeatureUi::DECIMAL_DOT, "DOT", "Dot: .");
|
||||
addItem(RicPasteAsciiDataToSummaryPlotFeatureUi::DECIMAL_COMMA, "COMMA", "Comma: ,");
|
||||
setDefault(RicPasteAsciiDataToSummaryPlotFeatureUi::DECIMAL_DOT);
|
||||
}
|
||||
|
||||
template<>
|
||||
void RicPasteAsciiDataToSummaryPlotFeatureUi::DateFormatEnum::setUp()
|
||||
{
|
||||
addItem(RicPasteAsciiDataToSummaryPlotFeatureUi::DATE_DDMMYYYY_DOT_SEPARATED, "dd.MM.yyyy", "Day.Month.Year (dd.MM.yyyy)");
|
||||
setDefault(RicPasteAsciiDataToSummaryPlotFeatureUi::DATE_DDMMYYYY_DOT_SEPARATED);
|
||||
}
|
||||
|
||||
template<>
|
||||
void RicPasteAsciiDataToSummaryPlotFeatureUi::TimeFormatEnum::setUp()
|
||||
{
|
||||
addItem(RicPasteAsciiDataToSummaryPlotFeatureUi::TIME_NONE, "NONE", "None");
|
||||
addItem(RicPasteAsciiDataToSummaryPlotFeatureUi::TIME_HHMM, "hh:mm", "Hour:Minute (hh:mm)");
|
||||
addItem(RicPasteAsciiDataToSummaryPlotFeatureUi::TIME_HHMMSS, "hh:mm:ss", "Hour:Minute:Second (hh:mm:ss)");
|
||||
addItem(RicPasteAsciiDataToSummaryPlotFeatureUi::TIME_HHMMSSZZZ, "hh:mm:ss.zzz", "Hour:Minute:Second.Millisecond (hh:mm:ss.zzz)");
|
||||
setDefault(RicPasteAsciiDataToSummaryPlotFeatureUi::TIME_NONE);
|
||||
}
|
||||
|
||||
template<>
|
||||
void RicPasteAsciiDataToSummaryPlotFeatureUi::CellSeparatorEnum::setUp()
|
||||
{
|
||||
addItem(RicPasteAsciiDataToSummaryPlotFeatureUi::CELL_TAB, "TAB", "Tab");
|
||||
addItem(RicPasteAsciiDataToSummaryPlotFeatureUi::CELL_COMMA, "COMMA", "Comma");
|
||||
setDefault(RicPasteAsciiDataToSummaryPlotFeatureUi::CELL_TAB);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RicPasteAsciiDataToSummaryPlotFeatureUi, "RicPasteExcelToSummaryPlotFeatureUi");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RicPasteAsciiDataToSummaryPlotFeatureUi::RicPasteAsciiDataToSummaryPlotFeatureUi() : m_createNewPlot(false)
|
||||
{
|
||||
CAF_PDM_InitObject("RicPasteAsciiDataToSummaryPlotFeatureUi", "", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_plotTitle, "PlotTitle", QString(), "Plot Title", "", "", "");
|
||||
CAF_PDM_InitField(&m_curvePrefix, "CurvePrefix", QString(), "Curve Prefix", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_decimalSeparator, "DecimalSeparator", "Decimal Separator", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_dateFormat, "DateFormat", "Date Format", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_timeFormat, "TimeFormat", "Time Format", "", "", "");
|
||||
CAF_PDM_InitField(&m_useCustomDateFormat, "UseCustomDateFormat", false, "Use Custom Date Format", "", "", "");
|
||||
CAF_PDM_InitField(&m_customDateFormat, "CustomDateFormat", QString(), "Custom Date Format", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_cellSeparator, "CellSeparator", "Cell Separator", "", "", "");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicPasteAsciiDataToSummaryPlotFeatureUi::dateFormat() const
|
||||
{
|
||||
if (m_useCustomDateFormat())
|
||||
{
|
||||
return m_customDateFormat();
|
||||
}
|
||||
else
|
||||
{
|
||||
QString format = m_dateFormat().text();
|
||||
if (m_timeFormat() != TIME_NONE)
|
||||
{
|
||||
format += " " + m_timeFormat().text();
|
||||
}
|
||||
return format;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QLocale RicPasteAsciiDataToSummaryPlotFeatureUi::decimalLocale() const
|
||||
{
|
||||
switch (m_decimalSeparator())
|
||||
{
|
||||
case DECIMAL_COMMA:
|
||||
return QLocale::Norwegian;
|
||||
case DECIMAL_DOT:
|
||||
default:
|
||||
return QLocale::c();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicPasteAsciiDataToSummaryPlotFeatureUi::cellSeparator() const
|
||||
{
|
||||
switch (m_cellSeparator())
|
||||
{
|
||||
case CELL_COMMA:
|
||||
return ",";
|
||||
case CELL_TAB:
|
||||
default:
|
||||
return "\t";
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicPasteAsciiDataToSummaryPlotFeatureUi::plotTitle() const
|
||||
{
|
||||
return m_plotTitle();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicPasteAsciiDataToSummaryPlotFeatureUi::curvePrefix() const
|
||||
{
|
||||
return m_curvePrefix();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPasteAsciiDataToSummaryPlotFeatureUi::createNewPlot()
|
||||
{
|
||||
m_createNewPlot = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPasteAsciiDataToSummaryPlotFeatureUi::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
{
|
||||
caf::PdmUiGroup* namingGroup = uiOrdering.addNewGroup("Naming");
|
||||
if (m_createNewPlot)
|
||||
{
|
||||
namingGroup->add(&m_plotTitle);
|
||||
}
|
||||
namingGroup->add(&m_curvePrefix);
|
||||
}
|
||||
|
||||
{
|
||||
caf::PdmUiGroup* valuesGroup = uiOrdering.addNewGroup("Values");
|
||||
valuesGroup->add(&m_decimalSeparator);
|
||||
}
|
||||
|
||||
{
|
||||
caf::PdmUiGroup* dateGroup = uiOrdering.addNewGroup("Dates");
|
||||
dateGroup->add(&m_useCustomDateFormat);
|
||||
if (m_useCustomDateFormat())
|
||||
{
|
||||
dateGroup->add(&m_customDateFormat);
|
||||
}
|
||||
else
|
||||
{
|
||||
dateGroup->add(&m_dateFormat);
|
||||
dateGroup->add(&m_timeFormat);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
caf::PdmUiGroup* cellGroup = uiOrdering.addNewGroup("Cells");
|
||||
|
||||
cellGroup->add(&m_cellSeparator);
|
||||
}
|
||||
|
||||
uiOrdering.skipRemainingFields();
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil 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 "cafPdmObject.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafAppEnum.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QLocale>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicPasteAsciiDataToSummaryPlotFeatureUi : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
enum DecimalSeparator
|
||||
{
|
||||
DECIMAL_COMMA,
|
||||
DECIMAL_DOT,
|
||||
};
|
||||
|
||||
typedef caf::AppEnum<DecimalSeparator> DecimalSeparatorEnum;
|
||||
|
||||
enum DateFormat
|
||||
{
|
||||
DATE_DDMMYYYY_DOT_SEPARATED,
|
||||
};
|
||||
|
||||
typedef caf::AppEnum<DateFormat> DateFormatEnum;
|
||||
|
||||
enum TimeFormat
|
||||
{
|
||||
TIME_NONE,
|
||||
TIME_HHMM,
|
||||
TIME_HHMMSS,
|
||||
TIME_HHMMSSZZZ,
|
||||
};
|
||||
|
||||
typedef caf::AppEnum<TimeFormat> TimeFormatEnum;
|
||||
|
||||
enum CellSeparator
|
||||
{
|
||||
CELL_COMMA,
|
||||
CELL_TAB,
|
||||
};
|
||||
|
||||
typedef caf::AppEnum<CellSeparator> CellSeparatorEnum;
|
||||
|
||||
public:
|
||||
RicPasteAsciiDataToSummaryPlotFeatureUi();
|
||||
|
||||
QString dateFormat() const;
|
||||
QLocale decimalLocale() const;
|
||||
QString cellSeparator() const;
|
||||
QString plotTitle() const;
|
||||
QString curvePrefix() const;
|
||||
|
||||
void createNewPlot();
|
||||
|
||||
protected:
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_plotTitle;
|
||||
caf::PdmField<QString> m_curvePrefix;
|
||||
caf::PdmField<DecimalSeparatorEnum> m_decimalSeparator;
|
||||
caf::PdmField<DateFormatEnum> m_dateFormat;
|
||||
caf::PdmField<TimeFormatEnum> m_timeFormat;
|
||||
caf::PdmField<bool> m_useCustomDateFormat;
|
||||
caf::PdmField<QString> m_customDateFormat;
|
||||
caf::PdmField<CellSeparatorEnum> m_cellSeparator;
|
||||
|
||||
bool m_createNewPlot;
|
||||
};
|
||||
Reference in New Issue
Block a user