Commit c0c7a5b8 authored by T.J. Corona's avatar T.J. Corona Committed by Kitware Robot

Merge topic 'merge-entity-name'

fdf96d21 Use a sane naming convention for merged entities
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !1749
parents c07bb29f fdf96d21
......@@ -32,6 +32,16 @@
using namespace smtk::model;
using namespace smtk::common;
namespace
{
// When entities are merged, a name for the resulting merged entity is created
// by concatenating the merging entities with " & ". This quickly becomes
// unwieldy when merging large numbers of entities. This value defines the
// maximum number of entities to merge before switching to the naming convention
// of "# entities".
static constexpr const std::size_t DescriptionAppendLimit = 5;
}
namespace smtk
{
namespace session
......@@ -172,11 +182,22 @@ Merge::Result Merge::operateInternal()
modified->appendValue(childEntityRef.component());
}
if (!name.empty())
// Construct a name for the resulting entity.
if (associations->numberOfValues() <= DescriptionAppendLimit)
{
if (!name.empty())
{
name += " & ";
}
name += eRef.name();
}
else
{
name += " & ";
if (name.empty())
{
name = std::to_string(associations->numberOfValues()) + " entities";
}
}
name += eRef.name();
// Add the model entity to the list of expunged components.
expunged->appendValue(std::static_pointer_cast<smtk::resource::Component>(*it));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment