mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge pull request #4916 from OPM/export-contour-map-context-menu
#4822 Countour Map Export: Add export to context menu in 3D view
This commit is contained in:
commit
d39e31b982
@ -32,6 +32,9 @@
|
||||
#include "RimProject.h"
|
||||
#include "RimViewWindow.h"
|
||||
|
||||
#include "RiuViewer.h"
|
||||
|
||||
#include "cafCmdFeatureManager.h"
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
#include "cafSelectionManager.h"
|
||||
#include "cafUtils.h"
|
||||
@ -57,10 +60,13 @@ RicExportContourMapToTextFeature::RicExportContourMapToTextFeature()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicExportContourMapToTextFeature::isCommandEnabled()
|
||||
{
|
||||
RimEclipseContourMapView* existingEclipseContourMap = caf::SelectionManager::instance()
|
||||
->selectedItemOfType<RimEclipseContourMapView>();
|
||||
RimGeoMechContourMapView* existingGeoMechContourMap = caf::SelectionManager::instance()
|
||||
->selectedItemOfType<RimGeoMechContourMapView>();
|
||||
RimEclipseContourMapView* existingEclipseContourMap = nullptr;
|
||||
RimGeoMechContourMapView* existingGeoMechContourMap = nullptr;
|
||||
|
||||
auto sourceViews = findContourMapView();
|
||||
existingEclipseContourMap = sourceViews.first;
|
||||
existingGeoMechContourMap = sourceViews.second;
|
||||
|
||||
return existingEclipseContourMap || existingGeoMechContourMap;
|
||||
}
|
||||
|
||||
@ -69,14 +75,17 @@ bool RicExportContourMapToTextFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportContourMapToTextFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RimContourMapProjection* contourMapProjection = nullptr;
|
||||
RimEclipseContourMapView* existingEclipseContourMap = caf::SelectionManager::instance()
|
||||
->selectedItemOfType<RimEclipseContourMapView>();
|
||||
RimGeoMechContourMapView* existingGeoMechContourMap = caf::SelectionManager::instance()
|
||||
->selectedItemOfType<RimGeoMechContourMapView>();
|
||||
RimEclipseContourMapView* existingEclipseContourMap = nullptr;
|
||||
RimGeoMechContourMapView* existingGeoMechContourMap = nullptr;
|
||||
|
||||
auto sourceViews = findContourMapView();
|
||||
existingEclipseContourMap = sourceViews.first;
|
||||
existingGeoMechContourMap = sourceViews.second;
|
||||
|
||||
CAF_ASSERT( existingEclipseContourMap || existingGeoMechContourMap );
|
||||
|
||||
QString contourMapName;
|
||||
RimContourMapProjection* contourMapProjection = nullptr;
|
||||
QString contourMapName;
|
||||
if ( existingEclipseContourMap )
|
||||
{
|
||||
m_viewId = existingEclipseContourMap->id();
|
||||
@ -212,6 +221,46 @@ void RicExportContourMapToTextFeature::writeContourMapToStream( QTextStream&
|
||||
formatter.tableCompleted();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<RimEclipseContourMapView*, RimGeoMechContourMapView*> RicExportContourMapToTextFeature::findContourMapView()
|
||||
{
|
||||
RimEclipseContourMapView* existingEclipseContourMap = nullptr;
|
||||
RimGeoMechContourMapView* existingGeoMechContourMap = nullptr;
|
||||
|
||||
auto contextMenuWidget = dynamic_cast<RiuViewer*>(
|
||||
caf::CmdFeatureManager::instance()->currentContextMenuTargetWidget() );
|
||||
|
||||
if ( contextMenuWidget )
|
||||
{
|
||||
{
|
||||
auto candidate = dynamic_cast<RimEclipseContourMapView*>( contextMenuWidget->ownerReservoirView() );
|
||||
if ( candidate )
|
||||
{
|
||||
existingEclipseContourMap = candidate;
|
||||
}
|
||||
}
|
||||
{
|
||||
auto candidate = dynamic_cast<RimGeoMechContourMapView*>( contextMenuWidget->ownerReservoirView() );
|
||||
if ( candidate )
|
||||
{
|
||||
existingGeoMechContourMap = candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !existingEclipseContourMap && !existingGeoMechContourMap )
|
||||
{
|
||||
existingEclipseContourMap = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseContourMapView>();
|
||||
existingGeoMechContourMap = caf::SelectionManager::instance()->selectedItemOfType<RimGeoMechContourMapView>();
|
||||
}
|
||||
|
||||
auto pair = std::make_pair( existingEclipseContourMap, existingGeoMechContourMap );
|
||||
|
||||
return pair;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -22,7 +22,12 @@
|
||||
#include "cafCmdFeature.h"
|
||||
#include "cafPdmField.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
class RimContourMapProjection;
|
||||
class RimEclipseContourMapView;
|
||||
class RimGeoMechContourMapView;
|
||||
|
||||
class QTextStream;
|
||||
|
||||
//==================================================================================================
|
||||
@ -52,6 +57,9 @@ protected:
|
||||
const QString& undefinedValueLabel,
|
||||
bool excludeUndefinedValues );
|
||||
|
||||
private:
|
||||
static std::pair<RimEclipseContourMapView*, RimGeoMechContourMapView*> findContourMapView();
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_exportFileName;
|
||||
caf::PdmField<bool> m_exportLocalCoordinates;
|
||||
|
@ -213,7 +213,9 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event )
|
||||
}
|
||||
}
|
||||
|
||||
// Build menue
|
||||
// Build menus
|
||||
|
||||
caf::CmdFeatureManager::instance()->setCurrentContextMenuTargetWidget( m_viewer );
|
||||
|
||||
QMenu menu;
|
||||
caf::CmdFeatureMenuBuilder menuBuilder;
|
||||
@ -548,6 +550,8 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event )
|
||||
{
|
||||
}
|
||||
|
||||
menuBuilder << "RicExportContourMapToTextFeature";
|
||||
|
||||
menuBuilder.appendToMenu( &menu );
|
||||
|
||||
if ( !menu.isEmpty() )
|
||||
@ -555,6 +559,8 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event )
|
||||
menu.exec( event->globalPos() );
|
||||
}
|
||||
|
||||
caf::CmdFeatureManager::instance()->setCurrentContextMenuTargetWidget( nullptr );
|
||||
|
||||
// Delete items in temporary selection
|
||||
Riu3dSelectionManager::instance()->deleteAllItems( Riu3dSelectionManager::RUI_TEMPORARY );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user