diff --git a/src/plugins/io_pdb/CMakeLists.txt b/src/plugins/io_pdb/CMakeLists.txt
index d80919d56..ed282586f 100644
--- a/src/plugins/io_pdb/CMakeLists.txt
+++ b/src/plugins/io_pdb/CMakeLists.txt
@@ -1,17 +1,20 @@
# Meta-Objects
set(pdb_MOC_HDRS
pdb.hui
+ pdbexportoptions.h
pdbimportoptions.h
)
QT5_WRAP_CPP(pdb_MOC_SRCS ${pdb_MOC_HDRS} OPTIONS -I${PROJECT_SOURCE_DIR}/src)
SET(pdb_UIS
+ pdbexportoptions.ui
pdbimportoptions.ui
)
QT5_WRAP_UI(pdb_UIS_H ${pdb_UIS})
add_library(pdb MODULE
pdb_funcs.cpp
+ pdbexportoptions_funcs.cpp
pdbimportoptions_funcs.cpp
${pdb_MOC_SRCS}
${pdb_UIS_H}
diff --git a/src/plugins/io_pdb/Makefile.am b/src/plugins/io_pdb/Makefile.am
index cc2a1f8a4..8b7cd8ce0 100644
--- a/src/plugins/io_pdb/Makefile.am
+++ b/src/plugins/io_pdb/Makefile.am
@@ -19,9 +19,9 @@ clean-local:
-rm -f pdb.cpp
# AKF Model plugin
-pdb_la_SOURCES = pdbimportoptions.ui pdbimportoptions_funcs.cpp pdb_funcs.cpp pdb.hui
+pdb_la_SOURCES = pdbexportoptions.ui pdbexportoptions_funcs.cpp pdbimportoptions.ui pdbimportoptions_funcs.cpp pdb_funcs.cpp pdb.hui
pdb_la_LDFLAGS = -module -shared -avoid-version
-noinst_HEADERS = pdbimportoptions.h
+noinst_HEADERS = pdbexportoptions.h pdbimportoptions.h
AM_CPPFLAGS = -I${top_srcdir}/src @ATEN_INCLUDES@ @ATEN_CFLAGS@
diff --git a/src/plugins/io_pdb/pdb_funcs.cpp b/src/plugins/io_pdb/pdb_funcs.cpp
index 552d46a12..5d2b0b909 100644
--- a/src/plugins/io_pdb/pdb_funcs.cpp
+++ b/src/plugins/io_pdb/pdb_funcs.cpp
@@ -20,6 +20,7 @@
*/
#include "plugins/io_pdb/pdb.hui"
+#include "plugins/io_pdb/pdbexportoptions.h"
#include "plugins/io_pdb/pdbimportoptions.h"
#include "model/model.h"
#include "base/pattern.h"
@@ -33,6 +34,7 @@ PDBModelPlugin::PDBModelPlugin()
// Setup plugin options
pluginOptions_.add("strictFormat", "true");
+ pluginOptions_.add("useTypeNames", "false");
}
// Destructor
@@ -118,8 +120,10 @@ bool PDBModelPlugin::importData()
// Create default model
createModel("PDB Model");
- // Get strict flag, and define strict formats
+ // Get options
bool strict = pluginOptions_.value("strictFormat") == "true";
+
+ // Define formats
ParseFormat generalFormat("%-6s%r");
ParseFormat crystFormat("%9f%9f%9f%7f%7f%7f");
ParseFormat atomFormat("%5i %4s %8f%8f%8f%22*%2s");
@@ -257,6 +261,9 @@ bool PDBModelPlugin::exportData()
int molId, n, m, bondCount;
QString s;
+ // Get plugin options
+ bool useTypeNames = pluginOptions_.value("useTypeNames") == "true";
+
if (!fileParser_.writeLine("REMARK Aten-created PDB")) return false;
if (!fileParser_.writeLine("TITLE " + targetModel()->name())) return false;
@@ -280,7 +287,9 @@ bool PDBModelPlugin::exportData()
{
for (n = 0; n < p->nAtoms(); ++n)
{
- s = QString("%1%2").arg(ElementMap::symbol(i)).arg(n);
+ if (useTypeNames && i->type()) s = QString("%1%2").arg(i->type()->name()).arg(n);
+ else s = QString("%1%2").arg(ElementMap::symbol(i)).arg(n);
+
if (!fileParser_.writeLineF("ATOM %-5i %-4s MOL %-4i %8.3f%8.3f%8.3f%6.2f%6.2f %2s", i->id()+1, qPrintable(s), molId, i->r().x, i->r().y, i->r().z, 1.0, 1.0, ElementMap::symbol(i))) return false;
i = i->next;
}
@@ -289,7 +298,14 @@ bool PDBModelPlugin::exportData()
}
else for (i = targetModel()->atoms(); i != NULL; i = i->next)
{
- if (!fileParser_.writeLineF("ATOM %-5i %-4s MOL %-4i %8.3f%8.3f%8.3f%6.2f%6.2f %2s", i->id()+1, ElementMap::symbol(i), molId, i->r().x, i->r().y, i->r().z, 1.0, 1.0, ElementMap::symbol(i))) return false;
+ if (useTypeNames && i->type())
+ {
+ if (!fileParser_.writeLineF("ATOM %-5i %-4s MOL %-4i %8.3f%8.3f%8.3f%6.2f%6.2f %2s", i->id()+1, qPrintable(i->type()->name()), molId, i->r().x, i->r().y, i->r().z, 1.0, 1.0, ElementMap::symbol(i))) return false;
+ }
+ else
+ {
+ if (!fileParser_.writeLineF("ATOM %-5i %-4s MOL %-4i %8.3f%8.3f%8.3f%6.2f%6.2f %2s", i->id()+1, ElementMap::symbol(i), molId, i->r().x, i->r().y, i->r().z, 1.0, 1.0, ElementMap::symbol(i))) return false;
+ }
}
// Loop over atoms and write bond information
@@ -365,12 +381,14 @@ bool PDBModelPlugin::showImportOptionsDialog(KVMap& targetOptions) const
// Return whether the plugin has export options
bool PDBModelPlugin::hasExportOptions() const
{
- return false;
+ return true;
}
// Show export options dialog
bool PDBModelPlugin::showExportOptionsDialog(KVMap& targetOptions) const
{
- return false;
+ PDBExportOptionsDialog optionsDialog(targetOptions);
+
+ return (optionsDialog.updateAndExecute() == QDialog::Accepted);
}
diff --git a/src/plugins/io_pdb/pdbexportoptions.h b/src/plugins/io_pdb/pdbexportoptions.h
new file mode 100644
index 000000000..50025a37c
--- /dev/null
+++ b/src/plugins/io_pdb/pdbexportoptions.h
@@ -0,0 +1,67 @@
+/*
+ *** PDB Export Options Dialog
+ *** src/plugins/io_pdb/pdbexportoptions.h
+ Copyright T. Youngs 2007-2017
+
+ This file is part of Aten.
+
+ Aten is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Aten is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Aten. If not, see .
+*/
+
+#ifndef ATEN_PDBEXPORTOPTIONS_H
+#define ATEN_PDBEXPORTOPTIONS_H
+
+#include "base/kvmap.h"
+#include "plugins/io_pdb/ui_pdbexportoptions.h"
+
+ATEN_USING_NAMESPACE
+
+// Forward Declarations (Aten)
+/* none */
+
+// PDB Export Options Dialog
+class PDBExportOptionsDialog : public QDialog
+{
+ // All Qt declarations derived from QObject must include this macro
+ Q_OBJECT
+
+ public:
+ // Constructor
+ PDBExportOptionsDialog(KVMap& pluginOptions);
+
+ private:
+ // Main form declaration
+ Ui::PDBExportOptionsDialog ui;
+ // Reference to KVMap of plugin options stored in plugin
+ KVMap& pluginOptions_;
+
+
+ /*
+ * Widget Functions
+ */
+ private slots:
+ // Cancel / OK buttons
+ void on_CancelButton_clicked(bool checked);
+ void on_OKButton_clicked(bool checked);
+
+
+ /*
+ * Show Function
+ */
+ public:
+ // Update and show dialog (setting controls from pluginOptions_ if necessary)
+ int updateAndExecute();
+};
+
+#endif
diff --git a/src/plugins/io_pdb/pdbexportoptions.ui b/src/plugins/io_pdb/pdbexportoptions.ui
new file mode 100644
index 000000000..e48ce129b
--- /dev/null
+++ b/src/plugins/io_pdb/pdbexportoptions.ui
@@ -0,0 +1,123 @@
+
+
+ PDBExportOptionsDialog
+
+
+
+ 0
+ 0
+ 370
+ 123
+
+
+
+
+ 8
+
+
+
+ PDB Export Options
+
+
+
+ 4
+
+
+ 4
+
+
+ 4
+
+
+ 4
+
+
+ 4
+
+ -
+
+
+ Write atom type names instead of element names in the atom records
+
+
+ Use type names if available
+
+
+ true
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 362
+ 48
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ &Cancel
+
+
+ false
+
+
+ true
+
+
+
+ -
+
+
+
+ 75
+ true
+
+
+
+ &OK
+
+
+ false
+
+
+ true
+
+
+
+
+
+
+
+
+
+
diff --git a/src/plugins/io_pdb/pdbexportoptions_funcs.cpp b/src/plugins/io_pdb/pdbexportoptions_funcs.cpp
new file mode 100644
index 000000000..0d8fca182
--- /dev/null
+++ b/src/plugins/io_pdb/pdbexportoptions_funcs.cpp
@@ -0,0 +1,60 @@
+/*
+ *** PDB Export Options Functions
+ *** src/gui/io_pdb/pdbexportoptions_funcs.cpp
+ Copyright T. Youngs 2007-2017
+
+ This file is part of Aten.
+
+ Aten is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Aten is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Aten. If not, see .
+*/
+
+#include "plugins/io_pdb/pdbexportoptions.h"
+
+// Constructor
+PDBExportOptionsDialog::PDBExportOptionsDialog(KVMap& pluginOptions) : QDialog(NULL), pluginOptions_(pluginOptions)
+{
+ ui.setupUi(this);
+}
+
+/*
+ * Widget Functions
+ */
+
+void PDBExportOptionsDialog::on_CancelButton_clicked(bool checked)
+{
+ // Don't modify the stored pluginOptions_, just reject() the dialog
+ reject();
+}
+
+void PDBExportOptionsDialog::on_OKButton_clicked(bool checked)
+{
+ // Set options before we accept() the dialog.
+ pluginOptions_.add("useTypeNames", ui.UseTypeNamesCheck->isChecked() ? "true" : "false");
+
+ accept();
+}
+
+/*
+ * Show Function
+ */
+
+// Update and show dialog, setting controls from pluginOptions
+int PDBExportOptionsDialog::updateAndExecute()
+{
+ // Set controls to reflect current pluginOptions_
+ ui.UseTypeNamesCheck->setChecked(pluginOptions_.value("useTypeNames") == "true");
+
+ // Execute the dialog - option setting will be handled in the OK button slot
+ return exec();
+}
diff --git a/src/plugins/io_xyz/common.cpp b/src/plugins/io_xyz/common.cpp
index adc0d9dd5..35504c426 100644
--- a/src/plugins/io_xyz/common.cpp
+++ b/src/plugins/io_xyz/common.cpp
@@ -100,4 +100,4 @@ bool XYZFilePluginCommon::writeXYZModel(FilePluginInterface* plugin, FileParser&
}
return true;
-}
\ No newline at end of file
+}