2015-07-29 14:19:43 +02:00
|
|
|
//##################################################################################################
|
|
|
|
|
//
|
|
|
|
|
// 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 "cafSelectionManager.h"
|
|
|
|
|
|
|
|
|
|
#include "cafPdmReferenceHelper.h"
|
|
|
|
|
#include "cafPdmUiFieldHandle.h"
|
|
|
|
|
#include "cafPdmUiObjectHandle.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace caf
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
SelectionManager* SelectionManager::instance()
|
|
|
|
|
{
|
|
|
|
|
static SelectionManager* singleton = new SelectionManager;
|
|
|
|
|
return singleton;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-28 09:58:07 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
/// Obsolete. Do not use this method.
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
caf::NotificationCenter* SelectionManager::notificationCenter()
|
|
|
|
|
{
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-29 14:19:43 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-08-21 15:05:49 +02:00
|
|
|
void SelectionManager::selectedItems(std::vector<PdmUiItem*>& items, int selectionLevel /*= 0*/)
|
2015-07-29 14:19:43 +02:00
|
|
|
{
|
2018-08-21 15:05:49 +02:00
|
|
|
const auto& levelSelectionPairIt = m_selectionPrLevel.find(selectionLevel);
|
|
|
|
|
|
|
|
|
|
if (levelSelectionPairIt == m_selectionPrLevel.end()) return ;
|
|
|
|
|
|
|
|
|
|
std::vector< std::pair<PdmPointer<PdmObjectHandle>, PdmUiItem*> >& selection = levelSelectionPairIt->second;
|
2015-07-29 14:19:43 +02:00
|
|
|
|
|
|
|
|
for (size_t i = 0; i < selection.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
if (selection[i].first.notNull())
|
|
|
|
|
{
|
|
|
|
|
items.push_back(selection[i].second);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-08-31 15:13:58 +02:00
|
|
|
void SelectionManager::setSelectedItems(const std::vector<PdmUiItem*>& items)
|
2015-07-29 14:19:43 +02:00
|
|
|
{
|
2018-08-31 15:13:58 +02:00
|
|
|
std::map <int, std::vector< std::pair<PdmPointer<PdmObjectHandle>, PdmUiItem*> > > newCompleteSelectionMap;
|
|
|
|
|
|
|
|
|
|
std::vector< std::pair<PdmPointer<PdmObjectHandle>, PdmUiItem*> > & newSelection = newCompleteSelectionMap[0];
|
|
|
|
|
|
|
|
|
|
extractInternalSelectionItems(items, &newSelection);
|
|
|
|
|
|
|
|
|
|
std::set<int> changedLevels = findChangedLevels(newCompleteSelectionMap);
|
2015-07-29 14:19:43 +02:00
|
|
|
|
2018-08-31 15:13:58 +02:00
|
|
|
if ( !changedLevels.empty() )
|
|
|
|
|
{
|
|
|
|
|
m_selectionPrLevel = newCompleteSelectionMap;
|
|
|
|
|
notifySelectionChanged(changedLevels);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void SelectionManager::extractInternalSelectionItems(const std::vector<PdmUiItem *> &items,
|
|
|
|
|
std::vector<std::pair<PdmPointer<PdmObjectHandle>, PdmUiItem *>> *newSelection)
|
|
|
|
|
{
|
|
|
|
|
for ( size_t i = 0; i < items.size(); i++ )
|
2015-07-29 14:19:43 +02:00
|
|
|
{
|
|
|
|
|
PdmUiFieldHandle* fieldHandle = dynamic_cast<PdmUiFieldHandle*>(items[i]);
|
2018-08-31 15:13:58 +02:00
|
|
|
if ( fieldHandle )
|
2015-07-29 14:19:43 +02:00
|
|
|
{
|
|
|
|
|
PdmObjectHandle* obj = fieldHandle->fieldHandle()->ownerObject();
|
|
|
|
|
|
2018-08-31 15:13:58 +02:00
|
|
|
newSelection->push_back(std::make_pair(obj, fieldHandle));
|
2015-07-29 14:19:43 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PdmUiObjectHandle* obj = dynamic_cast<PdmUiObjectHandle*>(items[i]);
|
2018-08-31 15:13:58 +02:00
|
|
|
if ( obj )
|
2015-07-29 14:19:43 +02:00
|
|
|
{
|
2018-08-31 15:13:58 +02:00
|
|
|
newSelection->push_back(std::make_pair(obj->objectHandle(), obj));
|
2015-07-29 14:19:43 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-31 15:13:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void SelectionManager::setSelectedItemsAtLevel(const std::vector<PdmUiItem*>& items, int selectionLevel)
|
|
|
|
|
{
|
|
|
|
|
std::vector< std::pair<PdmPointer<PdmObjectHandle>, PdmUiItem*> >& selection = m_selectionPrLevel[selectionLevel];
|
|
|
|
|
std::vector< std::pair<PdmPointer<PdmObjectHandle>, PdmUiItem*> > newSelection;
|
|
|
|
|
|
|
|
|
|
extractInternalSelectionItems(items, &newSelection);
|
2015-07-29 14:19:43 +02:00
|
|
|
|
2018-06-27 13:15:20 +02:00
|
|
|
if (newSelection != selection)
|
|
|
|
|
{
|
|
|
|
|
selection = newSelection;
|
2018-08-31 15:13:58 +02:00
|
|
|
notifySelectionChanged({selectionLevel});
|
2018-06-27 13:15:20 +02:00
|
|
|
}
|
2015-07-29 14:19:43 +02:00
|
|
|
}
|
|
|
|
|
|
2018-08-31 15:13:58 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void SelectionManager::setSelection(const std::vector< SelectionItem > completeSelection)
|
|
|
|
|
{
|
|
|
|
|
std::map <int, std::vector< std::pair<PdmPointer<PdmObjectHandle>, PdmUiItem*> > > newCompleteSelectionMap;
|
|
|
|
|
std::map<int, std::vector<PdmUiItem*> > newSelectionPrLevel;
|
|
|
|
|
|
|
|
|
|
for (const SelectionItem& item: completeSelection)
|
|
|
|
|
{
|
|
|
|
|
newSelectionPrLevel[item.selectionLevel].push_back(item.item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (auto& levelItemsPair: newSelectionPrLevel)
|
|
|
|
|
{
|
|
|
|
|
std::vector< std::pair<PdmPointer<PdmObjectHandle>, PdmUiItem*> > & newSelectionLevel = newCompleteSelectionMap[levelItemsPair.first];
|
|
|
|
|
extractInternalSelectionItems(levelItemsPair.second, &newSelectionLevel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::set<int> changedLevels = findChangedLevels(newCompleteSelectionMap);
|
|
|
|
|
|
|
|
|
|
if ( !changedLevels.empty())
|
|
|
|
|
{
|
|
|
|
|
m_selectionPrLevel = newCompleteSelectionMap;
|
|
|
|
|
notifySelectionChanged(changedLevels);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::set<int> SelectionManager::findChangedLevels(const std::map<int, std::vector<std::pair<PdmPointer<PdmObjectHandle>, PdmUiItem *>>> & newCompleteSelectionMap ) const
|
|
|
|
|
{
|
|
|
|
|
std::set<int> changedLevels;
|
|
|
|
|
|
|
|
|
|
// Compare the existing levels with the corresponding levels in the new selection
|
|
|
|
|
|
|
|
|
|
for ( auto& levelSelectionPair : m_selectionPrLevel )
|
|
|
|
|
{
|
|
|
|
|
auto it = newCompleteSelectionMap.find(levelSelectionPair.first);
|
|
|
|
|
if ( it != newCompleteSelectionMap.end() )
|
|
|
|
|
{
|
|
|
|
|
if ( levelSelectionPair.second != it->second ) changedLevels.insert(levelSelectionPair.first);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ( !levelSelectionPair.second.empty() ) changedLevels.insert(levelSelectionPair.first);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add each of the levels in the new selection that are not present in the existing selection
|
|
|
|
|
for ( auto& levelSelectionPair : newCompleteSelectionMap )
|
|
|
|
|
{
|
|
|
|
|
auto it = m_selectionPrLevel.find(levelSelectionPair.first);
|
|
|
|
|
if ( it == m_selectionPrLevel.end() )
|
|
|
|
|
{
|
|
|
|
|
changedLevels.insert(levelSelectionPair.first);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return changedLevels;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-29 14:19:43 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-08-21 15:05:49 +02:00
|
|
|
PdmUiItem* SelectionManager::selectedItem(int selectionLevel /*= 0*/)
|
2015-07-29 14:19:43 +02:00
|
|
|
{
|
2018-08-21 15:05:49 +02:00
|
|
|
const auto& levelSelectionPairIt = m_selectionPrLevel.find(selectionLevel);
|
|
|
|
|
if (levelSelectionPairIt == m_selectionPrLevel.end()) return nullptr;
|
|
|
|
|
|
|
|
|
|
std::vector< std::pair<PdmPointer<PdmObjectHandle>, PdmUiItem*> >& selection = levelSelectionPairIt->second;
|
2015-07-29 14:19:43 +02:00
|
|
|
|
|
|
|
|
if (selection.size() == 1)
|
|
|
|
|
{
|
|
|
|
|
if (selection[0].first.notNull())
|
|
|
|
|
{
|
|
|
|
|
return selection[0].second;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-18 18:05:08 +01:00
|
|
|
return nullptr;
|
2015-07-29 14:19:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-08-31 15:13:58 +02:00
|
|
|
void SelectionManager::setSelectedItem(PdmUiItem* item)
|
|
|
|
|
{
|
|
|
|
|
std::vector<PdmUiItem*> singleSelection;
|
|
|
|
|
singleSelection.push_back(item);
|
|
|
|
|
|
|
|
|
|
setSelectedItems(singleSelection);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void SelectionManager::setSelectedItemAtLevel(PdmUiItem* item, int selectionLevel)
|
2015-07-29 14:19:43 +02:00
|
|
|
{
|
|
|
|
|
std::vector<PdmUiItem*> singleSelection;
|
|
|
|
|
singleSelection.push_back(item);
|
|
|
|
|
|
2018-08-31 15:13:58 +02:00
|
|
|
setSelectedItemsAtLevel(singleSelection, selectionLevel);
|
2015-07-29 14:19:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
SelectionManager::SelectionManager()
|
|
|
|
|
{
|
2018-02-18 18:05:08 +01:00
|
|
|
m_activeChildArrayFieldHandle = nullptr;
|
2015-07-29 14:19:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-08-21 15:05:49 +02:00
|
|
|
void SelectionManager::selectionAsReferences(std::vector<QString>& referenceList, int selectionLevel /*= 0*/) const
|
2015-07-29 14:19:43 +02:00
|
|
|
{
|
2018-08-21 15:05:49 +02:00
|
|
|
const auto& levelSelectionPairIt = m_selectionPrLevel.find(selectionLevel);
|
|
|
|
|
|
|
|
|
|
if (levelSelectionPairIt == m_selectionPrLevel.end()) return;
|
|
|
|
|
|
|
|
|
|
const std::vector< std::pair<PdmPointer<PdmObjectHandle>, PdmUiItem*> >& selection = levelSelectionPairIt->second;
|
2015-07-29 14:19:43 +02:00
|
|
|
|
|
|
|
|
for (size_t i = 0; i < selection.size(); i++)
|
|
|
|
|
{
|
2015-10-23 15:21:23 +02:00
|
|
|
if (!selection[i].first.isNull())
|
|
|
|
|
{
|
|
|
|
|
PdmUiObjectHandle* pdmObj = dynamic_cast<PdmUiObjectHandle*>(selection[i].second);
|
|
|
|
|
if (pdmObj)
|
|
|
|
|
{
|
|
|
|
|
QString itemRef = PdmReferenceHelper::referenceFromRootToObject(m_rootObject, pdmObj->objectHandle());
|
|
|
|
|
|
|
|
|
|
referenceList.push_back(itemRef);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-29 14:19:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-08-31 15:13:58 +02:00
|
|
|
void SelectionManager::setSelectionAtLevelFromReferences(const std::vector<QString>& referenceList, int selectionLevel /*= 0*/)
|
2015-07-29 14:19:43 +02:00
|
|
|
{
|
|
|
|
|
std::vector<PdmUiItem*> uiItems;
|
|
|
|
|
|
2015-08-13 06:23:33 -07:00
|
|
|
for (size_t i = 0; i < referenceList.size(); i++)
|
2015-07-29 14:19:43 +02:00
|
|
|
{
|
|
|
|
|
QString reference = referenceList[i];
|
|
|
|
|
|
|
|
|
|
PdmObjectHandle* pdmObj = PdmReferenceHelper::objectFromReference(m_rootObject, reference);
|
|
|
|
|
if (pdmObj)
|
|
|
|
|
{
|
|
|
|
|
caf::PdmUiObjectHandle* uiObject = uiObj(pdmObj);
|
|
|
|
|
if (uiObject)
|
|
|
|
|
{
|
|
|
|
|
uiItems.push_back(uiObject);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-31 15:13:58 +02:00
|
|
|
setSelectedItemsAtLevel(uiItems, selectionLevel);
|
2015-07-29 14:19:43 +02:00
|
|
|
}
|
|
|
|
|
|
2018-08-29 15:42:35 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
bool SelectionManager::isSelected(PdmUiItem* item, int selectionLevel) const
|
|
|
|
|
{
|
|
|
|
|
auto levelIter = m_selectionPrLevel.find(selectionLevel);
|
|
|
|
|
|
|
|
|
|
if (levelIter == m_selectionPrLevel.end()) return false;
|
|
|
|
|
|
|
|
|
|
const std::vector< std::pair<PdmPointer<PdmObjectHandle>, PdmUiItem*> >& selection = levelIter->second;
|
|
|
|
|
|
|
|
|
|
auto iter = selection.begin();
|
|
|
|
|
while ( iter != selection.end() )
|
|
|
|
|
{
|
|
|
|
|
if ( iter->second == item )
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
++iter;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-29 14:19:43 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void SelectionManager::clearAll()
|
|
|
|
|
{
|
2018-08-21 13:41:56 +02:00
|
|
|
std::set<int> changedSelectionLevels;
|
|
|
|
|
|
2018-08-21 15:05:49 +02:00
|
|
|
for ( auto & levelSelectionPair : m_selectionPrLevel)
|
2015-07-29 14:19:43 +02:00
|
|
|
{
|
2018-08-21 15:05:49 +02:00
|
|
|
if ( !levelSelectionPair.second.empty())
|
2018-06-27 13:15:20 +02:00
|
|
|
{
|
2018-08-21 15:05:49 +02:00
|
|
|
levelSelectionPair.second.clear();
|
|
|
|
|
changedSelectionLevels.insert(levelSelectionPair.first);
|
2018-06-27 13:15:20 +02:00
|
|
|
}
|
2015-07-29 14:19:43 +02:00
|
|
|
}
|
2018-08-21 15:05:49 +02:00
|
|
|
|
|
|
|
|
m_selectionPrLevel.clear();
|
2018-08-31 15:13:58 +02:00
|
|
|
|
|
|
|
|
if ( changedSelectionLevels.size() )
|
2018-08-21 13:41:56 +02:00
|
|
|
{
|
2018-08-31 15:13:58 +02:00
|
|
|
notifySelectionChanged(changedSelectionLevels);
|
2018-08-21 13:41:56 +02:00
|
|
|
}
|
2015-07-29 14:19:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-08-21 15:05:49 +02:00
|
|
|
void SelectionManager::clear(int selectionLevel)
|
2015-07-29 14:19:43 +02:00
|
|
|
{
|
2018-08-21 15:05:49 +02:00
|
|
|
const auto& levelSelectionPairIt = m_selectionPrLevel.find(selectionLevel);
|
|
|
|
|
|
|
|
|
|
if (levelSelectionPairIt == m_selectionPrLevel.end()) return;
|
|
|
|
|
|
|
|
|
|
if ( !levelSelectionPairIt->second.empty() )
|
2018-06-27 13:15:20 +02:00
|
|
|
{
|
2018-08-21 15:05:49 +02:00
|
|
|
m_selectionPrLevel[selectionLevel].clear();
|
2015-07-29 14:19:43 +02:00
|
|
|
|
2018-08-31 15:13:58 +02:00
|
|
|
notifySelectionChanged({selectionLevel});
|
2018-06-27 13:15:20 +02:00
|
|
|
}
|
2015-07-29 14:19:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-08-31 15:13:58 +02:00
|
|
|
void SelectionManager::notifySelectionChanged( const std::set<int>& changedSelectionLevels )
|
2015-07-29 14:19:43 +02:00
|
|
|
{
|
2018-06-27 13:15:20 +02:00
|
|
|
for (auto receiver: m_selectionReceivers)
|
|
|
|
|
{
|
2018-08-31 15:13:58 +02:00
|
|
|
receiver->onSelectionManagerSelectionChanged(changedSelectionLevels);
|
2018-06-27 13:15:20 +02:00
|
|
|
}
|
2015-07-29 14:19:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void SelectionManager::removeObjectFromAllSelections(PdmObjectHandle* pdmObject)
|
|
|
|
|
{
|
2018-08-21 13:41:56 +02:00
|
|
|
std::set<int> changedSelectionLevels;
|
2015-07-29 14:19:43 +02:00
|
|
|
|
2018-08-21 15:05:49 +02:00
|
|
|
for ( auto & levelSelectionPair : m_selectionPrLevel)
|
2015-07-29 14:19:43 +02:00
|
|
|
{
|
2018-08-21 15:05:49 +02:00
|
|
|
std::vector< std::pair<PdmPointer<PdmObjectHandle>, PdmUiItem*> >& selection = levelSelectionPair.second;
|
2015-07-29 14:19:43 +02:00
|
|
|
|
|
|
|
|
std::vector< std::pair<PdmPointer<PdmObjectHandle>, PdmUiItem*> >::iterator iter = selection.begin();
|
|
|
|
|
while (iter != selection.end())
|
|
|
|
|
{
|
|
|
|
|
if (iter->first.notNull())
|
|
|
|
|
{
|
|
|
|
|
PdmObjectHandle* selectionObj = dynamic_cast<PdmObjectHandle*>(iter->second);
|
|
|
|
|
if (selectionObj == pdmObject)
|
|
|
|
|
{
|
|
|
|
|
iter = selection.erase(iter);
|
|
|
|
|
|
2018-08-21 15:05:49 +02:00
|
|
|
changedSelectionLevels.insert(levelSelectionPair.first);
|
2015-07-29 14:19:43 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
++iter;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
++iter;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-31 15:13:58 +02:00
|
|
|
notifySelectionChanged(changedSelectionLevels);
|
2015-07-29 14:19:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SelectionManager::setPdmRootObject(PdmObjectHandle* root)
|
|
|
|
|
{
|
|
|
|
|
m_rootObject = root;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void SelectionManager::setActiveChildArrayFieldHandle(PdmChildArrayFieldHandle* childArray)
|
|
|
|
|
{
|
|
|
|
|
m_activeChildArrayFieldHandle = childArray;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
PdmChildArrayFieldHandle* SelectionManager::activeChildArrayFieldHandle()
|
|
|
|
|
{
|
|
|
|
|
return m_activeChildArrayFieldHandle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // end namespace caf
|