Commit 02ca9b2b authored by David Thompson's avatar David Thompson
Browse files

Use model manager to assign polygon names...

... and change the default prefix used to determine which names
should be rewritten when saving.
parent 3237de10
......@@ -94,12 +94,6 @@ smtk::model::OperatorResult CreateModel::operateInternal()
{
modelName = nameItem->value(0);
}
else
{
std::ostringstream ss;
ss << "model " << this->nextModelNumber();
modelName = ss.str();
}
mgr = sess->manager();
smtk::model::Model model = mgr->addModel(/* par. dim. */ 2, /* emb. dim. */ 3, modelName);
......@@ -107,6 +101,10 @@ smtk::model::OperatorResult CreateModel::operateInternal()
storage->setSession(sess);
this->addStorage(model.entity(), storage);
model.setSession(smtk::model::SessionRef(mgr, sess->sessionId()));
if (modelName.empty())
{
model.assignDefaultName();
}
result = this->createResult(smtk::model::OPERATION_SUCCEEDED);
this->addEntityToResult(result, model, CREATED);
......
......@@ -100,10 +100,10 @@ OperatorResult SaveSMTKModel::operateInternal()
std::string oldmodelname = modit->name();
bool matchDefault = false;
bool matchPrevious = false;
const std::string defaultprefix("model ");
const std::string defaultPrefix("Model ");
if (
renamePolicy == "all" ||
(matchDefault = std::equal(defaultprefix.begin(), defaultprefix.end(), oldmodelname.begin())) ||
(matchDefault = std::equal(defaultPrefix.begin(), defaultPrefix.end(), oldmodelname.begin())) ||
(matchPrevious = std::equal(oldfilename.begin(), oldfilename.end(), oldmodelname.begin())))
{
std::ostringstream newname;
......@@ -111,7 +111,7 @@ OperatorResult SaveSMTKModel::operateInternal()
std::string suffix;
if (matchDefault)
{
suffix = oldmodelname.substr(defaultprefix.size() - 1); // include space after prefix
suffix = oldmodelname.substr(defaultPrefix.size() - 1); // include space after prefix
}
else if (matchPrevious)
{
......
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