mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2089 Cross Plot : Make sure context menu items works as expected
This commit is contained in:
@@ -24,10 +24,14 @@
|
||||
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryCrossPlot.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "RimSummaryCrossPlotCollection.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -61,3 +65,68 @@ void RiaSummaryTools::notifyCalculatedCurveNameHasChanged(const QString& previou
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryPlot* RiaSummaryTools::parentSummaryPlot(caf::PdmObject* object)
|
||||
{
|
||||
if (parentCrossPlot(object))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RimSummaryPlot* summaryPlot = nullptr;
|
||||
|
||||
if (object)
|
||||
{
|
||||
object->firstAncestorOrThisOfType(summaryPlot);
|
||||
}
|
||||
|
||||
return summaryPlot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryPlotCollection* RiaSummaryTools::parentSummaryPlotCollection(caf::PdmObject* object)
|
||||
{
|
||||
RimSummaryPlotCollection* summaryPlotColl = nullptr;
|
||||
|
||||
if (object)
|
||||
{
|
||||
object->firstAncestorOrThisOfType(summaryPlotColl);
|
||||
}
|
||||
|
||||
return summaryPlotColl;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCrossPlot* RiaSummaryTools::parentCrossPlot(caf::PdmObject* object)
|
||||
{
|
||||
RimSummaryCrossPlot* crossPlot = nullptr;
|
||||
|
||||
if (object)
|
||||
{
|
||||
object->firstAncestorOrThisOfType(crossPlot);
|
||||
}
|
||||
|
||||
return crossPlot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCrossPlotCollection* RiaSummaryTools::parentCrossPlotCollection(caf::PdmObject* object)
|
||||
{
|
||||
RimSummaryCrossPlotCollection* crossPlotColl = nullptr;
|
||||
|
||||
if (object)
|
||||
{
|
||||
object->firstAncestorOrThisOfType(crossPlotColl);
|
||||
}
|
||||
|
||||
return crossPlotColl;
|
||||
}
|
||||
|
||||
@@ -19,9 +19,16 @@
|
||||
#pragma once
|
||||
|
||||
class RimSummaryPlotCollection;
|
||||
class RimSummaryPlot;
|
||||
class RimSummaryCrossPlot;
|
||||
class RimSummaryCrossPlotCollection;
|
||||
|
||||
class QString;
|
||||
|
||||
namespace caf {
|
||||
class PdmObject;
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//==================================================================================================
|
||||
@@ -31,4 +38,10 @@ public:
|
||||
static RimSummaryPlotCollection* summaryPlotCollection();
|
||||
static void notifyCalculatedCurveNameHasChanged(const QString& previousCurveName,
|
||||
const QString& currentCurveName);
|
||||
|
||||
static RimSummaryPlot* parentSummaryPlot(caf::PdmObject* object);
|
||||
static RimSummaryPlotCollection* parentSummaryPlotCollection(caf::PdmObject* object);
|
||||
|
||||
static RimSummaryCrossPlot* parentCrossPlot(caf::PdmObject* object);
|
||||
static RimSummaryCrossPlotCollection* parentCrossPlotCollection(caf::PdmObject* object);
|
||||
};
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaSummaryTools.h"
|
||||
|
||||
#include "RicSummaryCurveCreator.h"
|
||||
#include "RicSummaryCurveCreatorDialog.h"
|
||||
@@ -122,7 +123,7 @@ RimSummaryPlot* RicEditSummaryPlotFeature::selectedSummaryPlot() const
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>(caf::SelectionManager::instance()->selectedItem());
|
||||
if (selObj)
|
||||
{
|
||||
selObj->firstAncestorOrThisOfType(sumPlot);
|
||||
sumPlot = RiaSummaryTools::parentSummaryPlot(selObj);
|
||||
}
|
||||
|
||||
return sumPlot;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "RicNewSummaryCrossPlotCurveFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaSummaryTools.h"
|
||||
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimOilField.h"
|
||||
@@ -26,7 +27,7 @@
|
||||
#include "RimSummaryCaseMainCollection.h"
|
||||
#include "RimSummaryCrossPlotCollection.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryCrossPlot.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
|
||||
#include "RiuMainPlotWindow.h"
|
||||
@@ -45,7 +46,7 @@ CAF_CMD_SOURCE_INIT(RicNewSummaryCrossPlotCurveFeature, "RicNewSummaryCrossPlotC
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewSummaryCrossPlotCurveFeature::isCommandEnabled()
|
||||
{
|
||||
return (selectedSummaryPlot());
|
||||
return (selectedCrossPlot());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -55,7 +56,7 @@ void RicNewSummaryCrossPlotCurveFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RimProject* project = RiaApplication::instance()->project();
|
||||
|
||||
RimSummaryPlot* plot = selectedSummaryPlot();
|
||||
RimSummaryCrossPlot* plot = selectedCrossPlot();
|
||||
if (plot)
|
||||
{
|
||||
RimSummaryCurve* newCurve = new RimSummaryCurve();
|
||||
@@ -91,19 +92,15 @@ void RicNewSummaryCrossPlotCurveFeature::setupActionLook(QAction* actionToSetup)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryPlot* RicNewSummaryCrossPlotCurveFeature::selectedSummaryPlot() const
|
||||
RimSummaryCrossPlot* RicNewSummaryCrossPlotCurveFeature::selectedCrossPlot() const
|
||||
{
|
||||
RimSummaryPlot* sumPlot = nullptr;
|
||||
RimSummaryCrossPlot* crossPlot = nullptr;
|
||||
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>(caf::SelectionManager::instance()->selectedItem());
|
||||
if (selObj)
|
||||
{
|
||||
selObj->firstAncestorOrThisOfType(sumPlot);
|
||||
crossPlot = RiaSummaryTools::parentCrossPlot(selObj);
|
||||
}
|
||||
|
||||
RimSummaryCrossPlotCollection* crossPlotColl = nullptr;
|
||||
sumPlot->firstAncestorOrThisOfType(crossPlotColl);
|
||||
if (!crossPlotColl) return nullptr;
|
||||
|
||||
return sumPlot;
|
||||
return crossPlot;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimSummaryPlot;
|
||||
class RimSummaryCrossPlot;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -36,5 +36,5 @@ protected:
|
||||
virtual void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
RimSummaryPlot* selectedSummaryPlot() const;
|
||||
RimSummaryCrossPlot* selectedCrossPlot() const;
|
||||
};
|
||||
|
||||
@@ -103,7 +103,7 @@ RimSummaryPlot* RicNewSummaryCurveFeature::selectedSummaryPlot() const
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>(caf::SelectionManager::instance()->selectedItem());
|
||||
if (selObj)
|
||||
{
|
||||
selObj->firstAncestorOrThisOfType(sumPlot);
|
||||
sumPlot = RiaSummaryTools::parentSummaryPlot(selObj);
|
||||
}
|
||||
|
||||
return sumPlot;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "RiaSummaryTools.h"
|
||||
|
||||
#include "RicEditSummaryPlotFeature.h"
|
||||
#include "RicSummaryCurveCreator.h"
|
||||
@@ -32,6 +33,7 @@
|
||||
#include "RiuMainPlotWindow.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
@@ -43,7 +45,17 @@ CAF_CMD_SOURCE_INIT(RicNewSummaryPlotFeature, "RicNewSummaryPlotFeature");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewSummaryPlotFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
RimSummaryPlotCollection* sumPlotColl = nullptr;
|
||||
|
||||
caf::PdmObject* selObj = dynamic_cast<caf::PdmObject*>(caf::SelectionManager::instance()->selectedItem());
|
||||
if (selObj)
|
||||
{
|
||||
sumPlotColl = RiaSummaryTools::parentSummaryPlotCollection(selObj);
|
||||
}
|
||||
|
||||
if (sumPlotColl) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -326,7 +326,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
|
||||
{
|
||||
commandIds << "RicPasteWellLogCurveFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimSummaryPlot*>(uiItem))
|
||||
else if (dynamic_cast<RimSummaryPlot*>(uiItem)) // This is also the definition for RimSummaryCrossPlot
|
||||
{
|
||||
commandIds << "RicPasteSummaryCurveFeature";
|
||||
commandIds << "RicPasteSummaryCurveFilterFeature";
|
||||
|
||||
Reference in New Issue
Block a user