Commit e0800f3e authored by David Thompson's avatar David Thompson

Make mesh names editable.

parent 4cd942d7
......@@ -19,6 +19,7 @@
#include "smtk/mesh/core/CellSet.h"
#include "smtk/mesh/core/Component.h"
#include "smtk/mesh/core/MeshSet.h"
#include "smtk/mesh/operators/SetMeshName.h"
#include "smtk/model/Entity.h"
#include "smtk/model/EntityRef.h"
......@@ -67,7 +68,9 @@ bool ComponentPhraseContent::editable(ContentType attr) const
if (attr == TITLE || attr == COLOR)
{
auto modelComp = dynamic_pointer_cast<smtk::model::Entity>(m_component);
return !!modelComp;
auto meshComp = dynamic_pointer_cast<smtk::mesh::Component>(m_component);
// Models may be assigned a color and a name; meshes may be assigned a name.
return !!modelComp || (attr == TITLE && !!meshComp);
}
}
return false;
......@@ -193,6 +196,21 @@ bool ComponentPhraseContent::editStringValue(ContentType attr, const std::string
}
}
}
auto meshComp = std::dynamic_pointer_cast<smtk::mesh::Component>(m_component);
if (meshComp)
{
auto op = smtk::mesh::SetMeshName::create();
if (op->parameters()->associate(meshComp))
{
op->parameters()->findString("name")->setValue(val);
auto res = op->operate();
if (res->findInt("outcome")->value() ==
static_cast<int>(smtk::operation::Operation::Outcome::SUCCEEDED))
{
return true;
}
}
}
}
return false;
}
......
......@@ -180,8 +180,9 @@ void SubphraseGenerator::componentsOfResource(
}
else if (meshRsrc)
{
constexpr int mutability = static_cast<int>(smtk::view::PhraseContent::ContentType::TITLE);
smtk::resource::Component::Visitor visitor = [&](const smtk::resource::Component::Ptr& entry) {
result.push_back(ComponentPhraseContent::createPhrase(entry, 0, src));
result.push_back(ComponentPhraseContent::createPhrase(entry, mutability, src));
};
meshRsrc->visit(visitor);
}
......
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