diff --git a/src/plugins/interfaces/fileplugin.h b/src/plugins/interfaces/fileplugin.h index b1365a60d..cbb7fe90b 100644 --- a/src/plugins/interfaces/fileplugin.h +++ b/src/plugins/interfaces/fileplugin.h @@ -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() { diff --git a/src/plugins/io_cif/cif_funcs.cpp b/src/plugins/io_cif/cif_funcs.cpp index e3511f53b..2a73be119 100644 --- a/src/plugins/io_cif/cif_funcs.cpp +++ b/src/plugins/io_cif/cif_funcs.cpp @@ -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):