2018-11-27 03:31:54 -06:00
|
|
|
//##################################################################################################
|
|
|
|
//
|
|
|
|
// Custom Visualization Core library
|
|
|
|
// Copyright (C) Ceetron Solutions 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 "cafPdmUiSelection3dEditorVisualizer.h"
|
|
|
|
|
|
|
|
//==================================================================================================
|
2020-06-19 00:53:59 -05:00
|
|
|
///
|
2018-11-27 03:31:54 -06:00
|
|
|
///
|
|
|
|
///
|
|
|
|
//==================================================================================================
|
|
|
|
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
2020-06-19 00:53:59 -05:00
|
|
|
namespace caf
|
2018-11-27 03:31:54 -06:00
|
|
|
{
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-06-19 00:53:59 -05:00
|
|
|
/// The ownerViewer will take over ownership of this class. The ownerViewer is also the viewer distributed to
|
2018-11-27 03:31:54 -06:00
|
|
|
/// the 3dEditors created by this class to make them know where to exist.
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-06-19 00:53:59 -05:00
|
|
|
PdmUiSelection3dEditorVisualizer::PdmUiSelection3dEditorVisualizer( QWidget* ownerViewer )
|
|
|
|
: m_ownerViewer( ownerViewer )
|
2018-11-27 03:31:54 -06:00
|
|
|
{
|
2020-06-19 00:53:59 -05:00
|
|
|
this->setParent( ownerViewer ); // Makes this owned by the viewer.
|
2018-11-27 03:31:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-06-19 00:53:59 -05:00
|
|
|
///
|
2018-11-27 03:31:54 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
PdmUiSelection3dEditorVisualizer::~PdmUiSelection3dEditorVisualizer()
|
|
|
|
{
|
2020-06-19 00:53:59 -05:00
|
|
|
for ( const auto& editor : m_active3DEditors )
|
2018-11-27 03:31:54 -06:00
|
|
|
{
|
|
|
|
delete editor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-06-19 00:53:59 -05:00
|
|
|
///
|
2018-11-27 03:31:54 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void PdmUiSelection3dEditorVisualizer::updateVisibleEditors()
|
|
|
|
{
|
2020-06-19 00:53:59 -05:00
|
|
|
for ( const auto& editor : m_active3DEditors )
|
2018-11-27 03:31:54 -06:00
|
|
|
{
|
2020-06-19 00:53:59 -05:00
|
|
|
if ( editor ) editor->updateUi();
|
2018-11-27 03:31:54 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-06-19 00:53:59 -05:00
|
|
|
///
|
2018-11-27 03:31:54 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void PdmUiSelection3dEditorVisualizer::onSelectionManagerSelectionChanged( const std::set<int>& changedSelectionLevels )
|
|
|
|
{
|
2020-06-19 00:53:59 -05:00
|
|
|
if ( !changedSelectionLevels.count( 0 ) ) return;
|
2018-11-27 03:31:54 -06:00
|
|
|
|
2020-06-19 00:53:59 -05:00
|
|
|
for ( const auto& editor : m_active3DEditors )
|
2018-11-27 03:31:54 -06:00
|
|
|
{
|
|
|
|
delete editor;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_active3DEditors.clear();
|
|
|
|
|
2020-06-19 00:53:59 -05:00
|
|
|
if ( !m_ownerViewer ) return;
|
2018-11-27 03:31:54 -06:00
|
|
|
|
|
|
|
std::set<PdmUiItem*> totalSelection;
|
2020-06-19 00:53:59 -05:00
|
|
|
for ( int selLevel : changedSelectionLevels )
|
2018-11-27 03:31:54 -06:00
|
|
|
{
|
|
|
|
std::vector<PdmUiItem*> items;
|
2020-06-19 00:53:59 -05:00
|
|
|
caf::SelectionManager::instance()->selectedItems( items, selLevel );
|
|
|
|
totalSelection.insert( items.begin(), items.end() );
|
2018-11-27 03:31:54 -06:00
|
|
|
}
|
|
|
|
|
2020-06-19 00:53:59 -05:00
|
|
|
for ( PdmUiItem* item : totalSelection )
|
2018-11-27 03:31:54 -06:00
|
|
|
{
|
2020-06-19 00:53:59 -05:00
|
|
|
QString editor3dTypeName = item->ui3dEditorTypeName( m_configName );
|
|
|
|
if ( !editor3dTypeName.isEmpty() )
|
2018-11-27 03:31:54 -06:00
|
|
|
{
|
2020-06-19 00:53:59 -05:00
|
|
|
PdmObjectHandle* itemObject = dynamic_cast<PdmObjectHandle*>( item );
|
2019-11-06 07:04:42 -06:00
|
|
|
if ( itemObject )
|
2018-11-27 03:31:54 -06:00
|
|
|
{
|
2019-11-06 07:04:42 -06:00
|
|
|
// Editor in main view
|
|
|
|
{
|
2020-06-19 00:53:59 -05:00
|
|
|
PdmUi3dObjectEditorHandle* editor3d =
|
|
|
|
caf::Factory<PdmUi3dObjectEditorHandle, QString>::instance()->create( editor3dTypeName );
|
|
|
|
editor3d->setViewer( m_ownerViewer, false );
|
|
|
|
editor3d->setPdmObject( itemObject );
|
|
|
|
m_active3DEditors.emplace_back( editor3d );
|
2019-11-06 07:04:42 -06:00
|
|
|
editor3d->updateUi();
|
|
|
|
}
|
2020-06-19 00:53:59 -05:00
|
|
|
|
|
|
|
QVariant isComparisonActive = m_ownerViewer->property( "cafViewer_IsComparisonViewActive" );
|
2019-11-06 07:04:42 -06:00
|
|
|
|
|
|
|
// Editor in comparison view
|
2020-06-19 00:53:59 -05:00
|
|
|
if ( !isComparisonActive.isNull() && isComparisonActive.isValid() && isComparisonActive.toBool() )
|
2019-11-06 07:04:42 -06:00
|
|
|
{
|
2020-06-19 00:53:59 -05:00
|
|
|
PdmUi3dObjectEditorHandle* editor3d =
|
|
|
|
caf::Factory<PdmUi3dObjectEditorHandle, QString>::instance()->create( editor3dTypeName );
|
|
|
|
editor3d->setViewer( m_ownerViewer, true );
|
|
|
|
editor3d->setPdmObject( itemObject );
|
|
|
|
m_active3DEditors.emplace_back( editor3d );
|
2019-11-06 07:04:42 -06:00
|
|
|
editor3d->updateUi();
|
|
|
|
}
|
2018-11-27 03:31:54 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_ownerViewer->update();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end namespace caf
|