Commit e8dabd05 authored by David Thompson's avatar David Thompson
Browse files

Accept an optional model name.

parent a1cf4a09
......@@ -46,6 +46,7 @@ namespace smtk {
/// Default constructor.
Session::Session()
: m_nextModelNumber(0)
{
this->initializeOperatorSystem(Session::s_operators);
}
......
......@@ -92,6 +92,7 @@ protected:
}
internal::EntityIdToPtr m_storage;
int m_nextModelNumber;
private:
Session(const Session&); // Not implemented.
......
......@@ -84,8 +84,22 @@ smtk::model::OperatorResult CreateModel::operateInternal()
smtk::model::Manager::Ptr mgr;
if (sess)
{
// If a name was specified, use it. Or make one up.
smtk::attribute::StringItem::Ptr nameItem = this->findString("name");
std::string modelName;
if (nameItem && nameItem->isEnabled())
{
modelName = nameItem->value(0);
}
else
{
std::ostringstream ss;
ss << "model " << sess->m_nextModelNumber++;
modelName = ss.str();
}
mgr = sess->manager();
smtk::model::Model model = mgr->addModel(/* par. dim. */ 2, /* emb. dim. */ 3, "model");
smtk::model::Model model = mgr->addModel(/* par. dim. */ 2, /* emb. dim. */ 3, modelName);
storage->setId(model.entity());
storage->setSession(sess);
sess->addStorage(model.entity(), storage);
......
......@@ -9,7 +9,15 @@
Create a model given a set of coordinate axes in 3D and a minimum feature size.
</DetailedDescription>
<ItemDefinitions>
<Int Name="construction method">
<String Name="name" NumberOfValuesRequired="1" Optional="true">
<BriefDescription>A user-assigned name for the model.</BriefDescription>
<DetailedDescription>
A user-assigned name for the model.
The name need not be unique, but unique names are best.
If not assigned, a machine-generated name will be assigned.
</DetailedDescription>
</String>
<Int Name="construction method" AdvanceLevel="1">
<ChildrenDefinitions>
<Double Name="origin" NumberOfRequiredValues="3" Optional="true">
<DefaultValue>0., 0., 0.</DefaultValue>
......
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