Merge remote-tracking branch 'refs/remotes/origin/dev'

Conflicts:
	ApplicationCode/Commands/RicDeleteItemFeature.cpp
This commit is contained in:
Magne Sjaastad
2017-02-08 07:35:20 +01:00
505 changed files with 13421 additions and 5935 deletions

View File

@@ -19,8 +19,19 @@
#include "RicCopyReferencesToClipboardFeature.h"
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimGeoMechView.h"
#include "RimMimeData.h"
#include "RimSummaryCurve.h"
#include "RimSummaryCurveFilter.h"
#include "RimSummaryPlot.h"
#include "RimWellAllocationPlot.h"
#include "RimWellLogCurve.h"
#include "RimWellLogPlot.h"
#include "RimWellLogTrack.h"
#include "cafPdmObject.h"
#include "cafPdmUiItem.h"
#include "cafSelectionManager.h"
@@ -40,7 +51,7 @@ CAF_CMD_SOURCE_INIT(RicCopyReferencesToClipboardFeature, "RicCopyReferencesToCli
//--------------------------------------------------------------------------------------------------
bool RicCopyReferencesToClipboardFeature::isCommandEnabled()
{
return true;
return isAnyCopyableObjectSelected();
}
//--------------------------------------------------------------------------------------------------
@@ -48,8 +59,22 @@ bool RicCopyReferencesToClipboardFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicCopyReferencesToClipboardFeature::onActionTriggered(bool isChecked)
{
if (!isAnyCopyableObjectSelected()) return;
std::vector<QString> referenceList;
SelectionManager::instance()->selectionAsReferences(referenceList);
std::vector<PdmObject*> selectedFormationNamesCollObjs;
caf::SelectionManager::instance()->objectsByType(&selectedFormationNamesCollObjs);
for (PdmObject* pdmObject : selectedFormationNamesCollObjs)
{
if (RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported(pdmObject))
{
QString itemRef = PdmReferenceHelper::referenceFromRootToObject(SelectionManager::instance()->pdmRootObject(), pdmObject);
referenceList.push_back(itemRef);
}
}
MimeDataWithReferences* myObject = new MimeDataWithReferences;
myObject->setReferences(referenceList);
@@ -71,4 +96,74 @@ void RicCopyReferencesToClipboardFeature::setupActionLook(QAction* actionToSetup
actionToSetup->setShortcuts(QKeySequence::Copy);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicCopyReferencesToClipboardFeature::isAnyCopyableObjectSelected()
{
std::vector<PdmObject*> selectedFormationNamesCollObjs;
caf::SelectionManager::instance()->objectsByType(&selectedFormationNamesCollObjs);
for (PdmObject* pdmObject : selectedFormationNamesCollObjs)
{
if (RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported(pdmObject))
{
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported(PdmObject* pdmObject)
{
RimWellAllocationPlot* wellAllocPlot = nullptr;
pdmObject->firstAncestorOrThisOfType(wellAllocPlot);
if (dynamic_cast<RimGeoMechView*>(pdmObject))
{
return true;
}
else if (dynamic_cast<RimEclipseView*>(pdmObject))
{
return true;
}
else if (dynamic_cast<RimEclipseCase*>(pdmObject))
{
return true;
}
else if (dynamic_cast<RimSummaryPlot*>(pdmObject))
{
return true;
}
else if (dynamic_cast<RimSummaryCurve*>(pdmObject))
{
return true;
}
else if (dynamic_cast<RimSummaryCurveFilter*>(pdmObject))
{
return true;
}
else if (dynamic_cast<RimWellLogCurve*>(pdmObject))
{
if (!wellAllocPlot) return true;
}
else if (dynamic_cast<RimWellLogTrack*>(pdmObject))
{
if (!wellAllocPlot) return true;
}
else if (dynamic_cast<RimWellLogPlot*>(pdmObject))
{
if (!wellAllocPlot) return true;
}
return false;
}
} // end namespace caf

View File

@@ -25,6 +25,8 @@
namespace caf
{
class PdmObject;
//==================================================================================================
///
//==================================================================================================
@@ -37,6 +39,10 @@ protected:
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
private:
static bool isAnyCopyableObjectSelected();
static bool isCopyOfObjectSupported(PdmObject* pdmObject);
};