mirror of
				https://github.com/OPM/ResInsight.git
				synced 2025-02-25 18:55:39 -06:00 
			
		
		
		
	Added general delete feature and use from cell range filter
This commit is contained in:
		@@ -42,6 +42,11 @@ ${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJ.h
 | 
				
			|||||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceK.h
 | 
					${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceK.h
 | 
				
			||||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputProperty.h
 | 
					${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputProperty.h
 | 
				
			||||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h
 | 
					${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# General delete of any object in a child array field
 | 
				
			||||||
 | 
					${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.h
 | 
				
			||||||
 | 
					${CEE_CURRENT_LIST_DIR}RicDeleteItemExecData.h
 | 
				
			||||||
 | 
					${CEE_CURRENT_LIST_DIR}RicDeleteItemFeature.h
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set (SOURCE_GROUP_SOURCE_FILES
 | 
					set (SOURCE_GROUP_SOURCE_FILES
 | 
				
			||||||
@@ -81,6 +86,11 @@ ${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJ.cpp
 | 
				
			|||||||
${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceK.cpp
 | 
					${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceK.cpp
 | 
				
			||||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputProperty.cpp
 | 
					${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputProperty.cpp
 | 
				
			||||||
${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp
 | 
					${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# General delete of any object in a child array field
 | 
				
			||||||
 | 
					${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.cpp
 | 
				
			||||||
 | 
					${CEE_CURRENT_LIST_DIR}RicDeleteItemExecData.cpp
 | 
				
			||||||
 | 
					${CEE_CURRENT_LIST_DIR}RicDeleteItemFeature.cpp
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
list(APPEND CODE_HEADER_FILES
 | 
					list(APPEND CODE_HEADER_FILES
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										133
									
								
								ApplicationCode/Commands/RicDeleteItemExec.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										133
									
								
								ApplicationCode/Commands/RicDeleteItemExec.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,133 @@
 | 
				
			|||||||
 | 
					//##################################################################################################
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//   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 <<http://www.gnu.org/licenses/gpl.html>>
 | 
				
			||||||
 | 
					//   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 <<http://www.gnu.org/licenses/lgpl-2.1.html>>
 | 
				
			||||||
 | 
					//   for more details.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//##################################################################################################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "RicDeleteItemExec.h"
 | 
				
			||||||
 | 
					#include "RicDeleteItemExecData.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "cafPdmChildArrayField.h"
 | 
				
			||||||
 | 
					#include "cafPdmReferenceHelper.h"
 | 
				
			||||||
 | 
					#include "cafPdmUiFieldHandle.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "cafNotificationCenter.h"
 | 
				
			||||||
 | 
					#include "cafSelectionManager.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace caf
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//--------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					/// 
 | 
				
			||||||
 | 
					//--------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					QString RicDeleteItemExec::name()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return m_commandData->classKeyword();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//--------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					/// 
 | 
				
			||||||
 | 
					//--------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void RicDeleteItemExec::redo()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    PdmFieldHandle* field = PdmReferenceHelper::fieldFromReference(m_commandData->m_rootObject, m_commandData->m_pathToField);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    PdmChildArrayFieldHandle* listField = dynamic_cast<PdmChildArrayFieldHandle*>(field);
 | 
				
			||||||
 | 
					    if (listField)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        std::vector<PdmObjectHandle*> children;
 | 
				
			||||||
 | 
					        listField->childObjects(&children);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        PdmObjectHandle* obj = children[m_commandData->m_indexToObject];
 | 
				
			||||||
 | 
					        caf::SelectionManager::instance()->removeObjectFromAllSelections(obj);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (m_commandData->m_deletedObjectAsXml().isEmpty())
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            QString encodedXml;
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                m_commandData->m_deletedObjectAsXml = xmlObj(obj)->writeObjectToXmlString();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        listField->erase(m_commandData->m_indexToObject);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        listField->uiCapability()->updateConnectedEditors();
 | 
				
			||||||
 | 
					        uiObj(listField->ownerObject())->updateConnectedEditors();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (m_notificationCenter) m_notificationCenter->notifyObservers();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        delete obj;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//--------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					/// 
 | 
				
			||||||
 | 
					//--------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void RicDeleteItemExec::undo()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    PdmFieldHandle* field = PdmReferenceHelper::fieldFromReference(m_commandData->m_rootObject, m_commandData->m_pathToField);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    PdmChildArrayFieldHandle* listField = dynamic_cast<PdmChildArrayFieldHandle*>(field);
 | 
				
			||||||
 | 
					    if (listField)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        PdmObjectHandle* obj = PdmXmlObjectHandle::readUnknownObjectFromXmlString(m_commandData->m_deletedObjectAsXml(), PdmDefaultObjectFactory::instance());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        listField->insertAt(m_commandData->m_indexToObject, obj);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        listField->uiCapability()->updateConnectedEditors();
 | 
				
			||||||
 | 
					        uiObj(listField->ownerObject())->updateConnectedEditors();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (m_notificationCenter) m_notificationCenter->notifyObservers();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//--------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					/// 
 | 
				
			||||||
 | 
					//--------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					RicDeleteItemExec::RicDeleteItemExec(NotificationCenter* notificationCenter)
 | 
				
			||||||
 | 
					    : CmdExecuteCommand(notificationCenter)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    m_commandData = new RicDeleteItemExecData;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//--------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					/// 
 | 
				
			||||||
 | 
					//--------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					RicDeleteItemExecData* RicDeleteItemExec::commandData()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    return m_commandData;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // end namespace caf
 | 
				
			||||||
							
								
								
									
										68
									
								
								ApplicationCode/Commands/RicDeleteItemExec.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								ApplicationCode/Commands/RicDeleteItemExec.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,68 @@
 | 
				
			|||||||
 | 
					//##################################################################################################
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//   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 <<http://www.gnu.org/licenses/gpl.html>>
 | 
				
			||||||
 | 
					//   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 <<http://www.gnu.org/licenses/lgpl-2.1.html>>
 | 
				
			||||||
 | 
					//   for more details.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//##################################################################################################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "cafCmdExecuteCommand.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace caf 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class PdmChildArrayFieldHandle;
 | 
				
			||||||
 | 
					class RicDeleteItemExecData;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//==================================================================================================
 | 
				
			||||||
 | 
					/// 
 | 
				
			||||||
 | 
					//==================================================================================================
 | 
				
			||||||
 | 
					class RicDeleteItemExec : public CmdExecuteCommand
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    RicDeleteItemExec(NotificationCenter* notificationCenter);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    RicDeleteItemExecData* commandData();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    virtual QString name();
 | 
				
			||||||
 | 
					    virtual void redo();
 | 
				
			||||||
 | 
					    virtual void undo();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					    RicDeleteItemExecData* m_commandData;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // end namespace caf
 | 
				
			||||||
							
								
								
									
										46
									
								
								ApplicationCode/Commands/RicDeleteItemExecData.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								ApplicationCode/Commands/RicDeleteItemExecData.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,46 @@
 | 
				
			|||||||
 | 
					//##################################################################################################
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//   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 <<http://www.gnu.org/licenses/gpl.html>>
 | 
				
			||||||
 | 
					//   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 <<http://www.gnu.org/licenses/lgpl-2.1.html>>
 | 
				
			||||||
 | 
					//   for more details.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//##################################################################################################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "RicDeleteItemExecData.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace caf
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CAF_PDM_SOURCE_INIT(RicDeleteItemExecData, "RicDeleteItemExecData");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // end namespace caf
 | 
				
			||||||
							
								
								
									
										73
									
								
								ApplicationCode/Commands/RicDeleteItemExecData.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								ApplicationCode/Commands/RicDeleteItemExecData.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,73 @@
 | 
				
			|||||||
 | 
					//##################################################################################################
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//   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 <<http://www.gnu.org/licenses/gpl.html>>
 | 
				
			||||||
 | 
					//   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 <<http://www.gnu.org/licenses/lgpl-2.1.html>>
 | 
				
			||||||
 | 
					//   for more details.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//##################################################################################################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "cafPdmObject.h"
 | 
				
			||||||
 | 
					#include "cafPdmField.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace caf 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//==================================================================================================
 | 
				
			||||||
 | 
					/// 
 | 
				
			||||||
 | 
					//==================================================================================================
 | 
				
			||||||
 | 
					class RicDeleteItemExecData : public PdmObject
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    CAF_PDM_HEADER_INIT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    RicDeleteItemExecData()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        CAF_PDM_InitObject("CmdDeleteItemExecData uiName", "", "CmdDeleteItemExecData tooltip", "CmdDeleteItemExecData whatsthis");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        CAF_PDM_InitField(&m_pathToField, "PathToField", QString(), "PathToField", "", "PathToField tooltip", "PathToField whatsthis");
 | 
				
			||||||
 | 
					        CAF_PDM_InitField(&m_indexToObject, "indexToObject", -1, "indexToObject", "", "indexToObject tooltip", "indexToObject whatsthis");
 | 
				
			||||||
 | 
					        CAF_PDM_InitField(&m_deletedObjectAsXml, "deletedObjectAsXml", QString(), "deletedObjectAsXml", "", "deletedObjectAsXml tooltip", "deletedObjectAsXml whatsthis");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    caf::PdmPointer<PdmObjectHandle> m_rootObject;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    caf::PdmField<QString>  m_pathToField;
 | 
				
			||||||
 | 
					    caf::PdmField<int>      m_indexToObject;
 | 
				
			||||||
 | 
					    caf::PdmField<QString>  m_deletedObjectAsXml;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // end namespace caf
 | 
				
			||||||
							
								
								
									
										118
									
								
								ApplicationCode/Commands/RicDeleteItemFeature.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										118
									
								
								ApplicationCode/Commands/RicDeleteItemFeature.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,118 @@
 | 
				
			|||||||
 | 
					//##################################################################################################
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//   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 <<http://www.gnu.org/licenses/gpl.html>>
 | 
				
			||||||
 | 
					//   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 <<http://www.gnu.org/licenses/lgpl-2.1.html>>
 | 
				
			||||||
 | 
					//   for more details.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//##################################################################################################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "RicDeleteItemFeature.h"
 | 
				
			||||||
 | 
					#include "RicDeleteItemExec.h"
 | 
				
			||||||
 | 
					#include "RicDeleteItemExecData.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "cafCmdExecCommandManager.h"
 | 
				
			||||||
 | 
					#include "cafCmdSelectionHelper.h"
 | 
				
			||||||
 | 
					#include "cafPdmChildArrayField.h"
 | 
				
			||||||
 | 
					#include "cafPdmField.h"
 | 
				
			||||||
 | 
					#include "cafPdmReferenceHelper.h"
 | 
				
			||||||
 | 
					#include "cafSelectionManager.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QAction>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace caf
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    CAF_CMD_SOURCE_INIT(RicDeleteItemFeature, "RicDeleteItemFeature");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//--------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					/// 
 | 
				
			||||||
 | 
					//--------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					bool RicDeleteItemFeature::isCommandEnabled() 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    caf::PdmObject* currentPdmObject = dynamic_cast<caf::PdmObject*>(caf::SelectionManager::instance()->selectedItem());
 | 
				
			||||||
 | 
					    if (!currentPdmObject) return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    caf::PdmChildArrayFieldHandle* childArrayFieldHandle = dynamic_cast<caf::PdmChildArrayFieldHandle*>(currentPdmObject->parentField());
 | 
				
			||||||
 | 
					    if (!childArrayFieldHandle) return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//--------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					/// 
 | 
				
			||||||
 | 
					//--------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void RicDeleteItemFeature::onActionTriggered(bool isChecked)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    std::vector<PdmUiItem*> items;
 | 
				
			||||||
 | 
					    SelectionManager::instance()->selectedItems(items);
 | 
				
			||||||
 | 
					    assert(items.size() > 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    caf::PdmObject* currentPdmObject = dynamic_cast<caf::PdmObject*>(items[0]);
 | 
				
			||||||
 | 
					    assert(currentPdmObject);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    caf::PdmChildArrayFieldHandle* childArrayFieldHandle = dynamic_cast<caf::PdmChildArrayFieldHandle*>(currentPdmObject->parentField());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    int indexAfter = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    std::vector<PdmObjectHandle*> childObjects;
 | 
				
			||||||
 | 
					    childArrayFieldHandle->childObjects(&childObjects);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (size_t i = 0; i < childObjects.size(); i++)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (childObjects[i] == currentPdmObject)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            indexAfter = static_cast<int>(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Did not find currently selected pdm object in the current list field
 | 
				
			||||||
 | 
					    assert(indexAfter != -1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    RicDeleteItemExec* executeCmd = new RicDeleteItemExec(SelectionManager::instance()->notificationCenter());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    RicDeleteItemExecData* data = executeCmd->commandData();
 | 
				
			||||||
 | 
					    data->m_rootObject = PdmReferenceHelper::findRoot(childArrayFieldHandle);
 | 
				
			||||||
 | 
					    data->m_pathToField = PdmReferenceHelper::referenceFromRootToField(data->m_rootObject, childArrayFieldHandle);
 | 
				
			||||||
 | 
					    data->m_indexToObject = indexAfter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    CmdExecCommandManager::instance()->processExecuteCommand(executeCmd);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//--------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					/// 
 | 
				
			||||||
 | 
					//--------------------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					void RicDeleteItemFeature::setupActionLook(QAction* actionToSetup)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    actionToSetup->setText("Delete object");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // end namespace caf
 | 
				
			||||||
							
								
								
									
										61
									
								
								ApplicationCode/Commands/RicDeleteItemFeature.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								ApplicationCode/Commands/RicDeleteItemFeature.h
									
									
									
									
									
										Normal file
									
								
							@@ -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 <<http://www.gnu.org/licenses/gpl.html>>
 | 
				
			||||||
 | 
					//   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 <<http://www.gnu.org/licenses/lgpl-2.1.html>>
 | 
				
			||||||
 | 
					//   for more details.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//##################################################################################################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "cafCmdFeature.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace caf 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//==================================================================================================
 | 
				
			||||||
 | 
					/// 
 | 
				
			||||||
 | 
					//==================================================================================================
 | 
				
			||||||
 | 
					class RicDeleteItemFeature : public CmdFeature 
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    CAF_CMD_HEADER_INIT;
 | 
				
			||||||
 | 
					protected:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Overrides
 | 
				
			||||||
 | 
					    virtual bool isCommandEnabled();
 | 
				
			||||||
 | 
					    virtual void onActionTriggered( bool isChecked );
 | 
				
			||||||
 | 
					    virtual void setupActionLook( QAction* actionToSetup );
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					} // end namespace caf
 | 
				
			||||||
@@ -71,7 +71,7 @@ void RicRangeFilterNewExec::redo()
 | 
				
			|||||||
    assert(cellRangeFilterCollection);
 | 
					    assert(cellRangeFilterCollection);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    RimCellRangeFilter* rangeFilter = new RimCellRangeFilter();
 | 
					    RimCellRangeFilter* rangeFilter = new RimCellRangeFilter();
 | 
				
			||||||
    rangeFilter->setParentContainer(cellRangeFilterCollection);
 | 
					    cellRangeFilterCollection->rangeFilters.push_back(rangeFilter);
 | 
				
			||||||
    rangeFilter->setDefaultValues();
 | 
					    rangeFilter->setDefaultValues();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    rangeFilter->name = QString("Range Filter (%1)").arg(cellRangeFilterCollection->rangeFilters().size());
 | 
					    rangeFilter->name = QString("Range Filter (%1)").arg(cellRangeFilterCollection->rangeFilters().size());
 | 
				
			||||||
@@ -98,8 +98,6 @@ void RicRangeFilterNewExec::redo()
 | 
				
			|||||||
    if (m_jSliceStart > -1) rangeFilter->startIndexJ = m_jSliceStart;
 | 
					    if (m_jSliceStart > -1) rangeFilter->startIndexJ = m_jSliceStart;
 | 
				
			||||||
    if (m_kSliceStart > -1) rangeFilter->startIndexK = m_kSliceStart;
 | 
					    if (m_kSliceStart > -1) rangeFilter->startIndexK = m_kSliceStart;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    cellRangeFilterCollection->rangeFilters.push_back(rangeFilter);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    cellRangeFilterCollection->reservoirView()->scheduleGeometryRegen(RANGE_FILTERED);
 | 
					    cellRangeFilterCollection->reservoirView()->scheduleGeometryRegen(RANGE_FILTERED);
 | 
				
			||||||
    cellRangeFilterCollection->reservoirView()->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE);
 | 
					    cellRangeFilterCollection->reservoirView()->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -575,6 +575,8 @@ void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
 | 
				
			|||||||
            actions.push_back(commandManager->action("RicRangeFilterNewSliceJ"));
 | 
					            actions.push_back(commandManager->action("RicRangeFilterNewSliceJ"));
 | 
				
			||||||
            actions.push_back(commandManager->action("RicRangeFilterNewSliceK"));
 | 
					            actions.push_back(commandManager->action("RicRangeFilterNewSliceK"));
 | 
				
			||||||
            actions.push_back(commandManager->action("RicRangeFilterDelete"));
 | 
					            actions.push_back(commandManager->action("RicRangeFilterDelete"));
 | 
				
			||||||
 | 
					            actions.push_back(commandManager->action("RicDeleteItemFeature"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else if (dynamic_cast<RimEclipsePropertyFilterCollection*>(uiItem))
 | 
					        else if (dynamic_cast<RimEclipsePropertyFilterCollection*>(uiItem))
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user