diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index f85b5bed76..b5bb252498 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -103,6 +103,7 @@ list( APPEND REFERENCED_CMAKE_FILES ModelVisualization/CMakeLists_files.cmake GeoMech/GeoMechVisualization/CMakeLists_files.cmake Commands/CMakeLists_files.cmake + Commands/OperationsUsingObjReferences/CMakeLists_files.cmake ) # Include source file lists from *.cmake files diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/CMakeLists_files.cmake b/ApplicationCode/Commands/OperationsUsingObjReferences/CMakeLists_files.cmake new file mode 100644 index 0000000000..50a8b67993 --- /dev/null +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/CMakeLists_files.cmake @@ -0,0 +1,23 @@ + +# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly +if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") + set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) +endif() + +set (SOURCE_GROUP_HEADER_FILES +${CEE_CURRENT_LIST_DIR}RicCopyReferencesToClipboardFeature.h +) + +set (SOURCE_GROUP_SOURCE_FILES +${CEE_CURRENT_LIST_DIR}RicCopyReferencesToClipboardFeature.cpp +) + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +source_group( "CommandFeature_ObjReferences" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp b/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp new file mode 100644 index 0000000000..e14d7749d6 --- /dev/null +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp @@ -0,0 +1,88 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library 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. +// +// This library 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 <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library 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 Lesser General Public License at <> +// for more details. +// +//################################################################################################## + +#include "RicCopyReferencesToClipboardFeature.h" + +#include "RimMimeData.h" +#include "cafPdmUiItem.h" +#include "cafSelectionManager.h" + +#include +#include +#include + + +namespace caf +{ + +CAF_CMD_SOURCE_INIT(RicCopyReferencesToClipboardFeature, "RicCopyReferencesToClipboardFeature"); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicCopyReferencesToClipboardFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCopyReferencesToClipboardFeature::onActionTriggered(bool isChecked) +{ + std::vector referenceList; + SelectionManager::instance()->selectionAsReferences(referenceList); + + MimeDataWithReferences* myObject = new MimeDataWithReferences; + myObject->setReferences(referenceList); + + QClipboard* clipboard = QApplication::clipboard(); + if (clipboard) + { + clipboard->setMimeData(myObject); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCopyReferencesToClipboardFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("RicCopyReferencesToClipboardFeature"); +} + +} // end namespace caf diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.h b/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.h new file mode 100644 index 0000000000..6a340736f2 --- /dev/null +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.h @@ -0,0 +1,61 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library 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. +// +// This library 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 <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library 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 Lesser General Public License at <> +// for more details. +// +//################################################################################################## + + +#pragma once + +#include "cafCmdFeature.h" + +namespace caf +{ + +//================================================================================================== +/// +//================================================================================================== +class RicCopyReferencesToClipboardFeature : public CmdFeature +{ + CAF_CMD_HEADER_INIT; +protected: + + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); +}; + + + +} // end namespace caf diff --git a/ApplicationCode/ProjectDataModel/RimMimeData.cpp b/ApplicationCode/ProjectDataModel/RimMimeData.cpp index e16db847d6..1f3143a04d 100644 --- a/ApplicationCode/ProjectDataModel/RimMimeData.cpp +++ b/ApplicationCode/ProjectDataModel/RimMimeData.cpp @@ -79,3 +79,67 @@ QString MimeDataWithIndexes::formatName() return "MimeDataWithIndexes"; } + + + + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +MimeDataWithReferences::MimeDataWithReferences() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +MimeDataWithReferences::MimeDataWithReferences(const MimeDataWithReferences& other) +{ + setReferences(other.references()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void MimeDataWithReferences::setReferences(const std::vector& references) +{ + m_references = references; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& MimeDataWithReferences::references() const +{ + return m_references; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool MimeDataWithReferences::hasFormat(const QString& mimetype) const +{ + return (mimetype == formatName()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList MimeDataWithReferences::formats() const +{ + QStringList supportedFormats = QMimeData::formats(); + supportedFormats << formatName(); + + return supportedFormats; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString MimeDataWithReferences::formatName() +{ + return "MimeDataWithReferences"; +} diff --git a/ApplicationCode/ProjectDataModel/RimMimeData.h b/ApplicationCode/ProjectDataModel/RimMimeData.h index 0ff9fa9714..28ad20fa7c 100644 --- a/ApplicationCode/ProjectDataModel/RimMimeData.h +++ b/ApplicationCode/ProjectDataModel/RimMimeData.h @@ -20,6 +20,9 @@ #include #include +#include + +#include //-------------------------------------------------------------------------------------------------- @@ -44,3 +47,27 @@ private: }; Q_DECLARE_METATYPE(MimeDataWithIndexes) + + +//-------------------------------------------------------------------------------------------------- +/// MimeData class used to carry string references to pdm objects +//-------------------------------------------------------------------------------------------------- +class MimeDataWithReferences : public QMimeData +{ + Q_OBJECT + +public: + MimeDataWithReferences(); + MimeDataWithReferences(const MimeDataWithReferences& other); + + void setReferences(const std::vector& references); + const std::vector& references() const; + virtual bool hasFormat(const QString& mimetype) const; + virtual QStringList formats() const; + static QString formatName(); + +private: + std::vector m_references; +}; + +Q_DECLARE_METATYPE(MimeDataWithReferences) diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index bf68018c9e..d58a54e18e 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -525,10 +525,12 @@ void RimProject::computeUtmAreaOfInterest() #include "RimEclipsePropertyFilter.h" #include "RimGeoMechPropertyFilterCollection.h" #include "RimGeoMechPropertyFilter.h" +#include "RimGeoMechView.h" #include "RimEclipseCellColors.h" #include "RimEclipseFaultColors.h" + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -544,9 +546,14 @@ void RimProject::actionsBasedOnSelection(std::vector& actions) caf::PdmUiItem* uiItem = uiItems[0]; CVF_ASSERT(uiItem); - if (dynamic_cast(uiItem)) + if (dynamic_cast(uiItem)) { - commandIds << "RicEclipseCaseCopy"; + commandIds << "RicCopyReferencesToClipboardFeature"; + } + else if (dynamic_cast(uiItem)) + { + commandIds << "RicCopyReferencesToClipboardFeature"; + commandIds << "RicEclipseCasePaste"; commandIds << "RicEclipseCaseClose"; commandIds << "RicEclipseCaseNewView"; diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index f0ea839723..bbb6117b65 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -1287,6 +1287,8 @@ void RiuMainWindow::setPdmRoot(caf::PdmObject* pdmRoot) m_projectTreeView->setPdmItem(pdmRoot); m_projectTreeView->treeView()->expandAll(); + + caf::SelectionManager::instance()->setPdmRootObject(pdmRoot); } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h index d5c4684977..09adab873b 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h @@ -84,8 +84,8 @@ public: void selectedItems(std::vector& items, int role = SelectionManager::APPLICATION_GLOBAL); void setSelectedItems(const std::vector& items, int role = SelectionManager::APPLICATION_GLOBAL); - void selectionAsReferences(std::vector& referenceList, int role) const; - void setSelectionFromReferences(const std::vector& referenceList, int role); + void selectionAsReferences(std::vector& referenceList, int role = SelectionManager::APPLICATION_GLOBAL) const; + void setSelectionFromReferences(const std::vector& referenceList, int role = SelectionManager::APPLICATION_GLOBAL); void clearAll(); void clear(int role);