Skip to content

Commit

Permalink
Extended FilePluginInterface to permit application of properly conver…
Browse files Browse the repository at this point in the history
…ted element names to atoms after their creation. Updated cif filter.
  • Loading branch information
trisyoungs committed Feb 1, 2018
1 parent 59836dc commit 4235fa9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/plugins/interfaces/fileplugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,27 @@ class FilePluginInterface : public BasePluginInterface

return i;
}
// Set element of specified Atom from supplied string, obeying current zmapping / conversion rules
int setAtomElement(Model* model, Atom* i, QString name)
{
// Find element in elements map
int el = ElementMap::find(name, standardOptions_.zMappingType() != ElementMap::nZMapTypes ? standardOptions_.zMappingType() : ElementMap::AutoZMap);

// Set data in atom
i->setData(qPrintable(name));

// KeepNames and KeepTypes standard options
ForcefieldAtom* ffa = NULL;
if (standardOptions_.isSetAndOn(FilePluginStandardImportOptions::KeepNamesSwitch)) ffa = model->addAtomName(el, name);
else if (standardOptions_.isSetAndOn(FilePluginStandardImportOptions::KeepTypesSwitch)) ffa = ElementMap::forcefieldAtom(name);
if (ffa != NULL)
{
i->setType(ffa);
i->setTypeFixed(true);
}

return el;
}
// Clear any created data
void clearCreatedData()
{
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/io_cif/cif_funcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ bool CIFModelPlugin::importData()
case (CIFModelPlugin::AtomSiteTypeSymbol):
case (CIFModelPlugin::AtomSiteLabel):
case (CIFModelPlugin::ChemCompAtomTypeSymbol):
if (i->element() == 0) i->setElement(ElementMap::find(fileParser_.argc(n)));
if (i->element() == 0) setAtomElement(targetModel(), i, fileParser_.argc(n));
break;
case (CIFModelPlugin::AtomSiteFractX):
case (CIFModelPlugin::AtomSiteFractY):
Expand Down

0 comments on commit 4235fa9

Please sign in to comment.