Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions avogadro/io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ set(HEADERS
fileformat.h
fileformatmanager.h
gromacsformat.h
mdcrdformat.h
mdlformat.h
pdbformat.h
poscarformat.h
Expand All @@ -46,6 +47,7 @@ set(SOURCES
fileformat.cpp
fileformatmanager.cpp
gromacsformat.cpp
mdcrdformat.cpp
mdlformat.cpp
pdbformat.cpp
poscarformat.cpp
Expand Down
10 changes: 6 additions & 4 deletions avogadro/io/fileformatmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "dcdformat.h"
#include "gromacsformat.h"
#include "lammpsformat.h"
#include "mdcrdformat.h"
#include "mdlformat.h"
#include "pdbformat.h"
#include "poscarformat.h"
Expand Down Expand Up @@ -162,7 +163,7 @@ bool FileFormatManager::addFormat(FileFormat* format)
namespace {
// Lookup each key from "keys" in "map", and remove "val" from the Map's
// data value (which is a vector of ValueType)
template<typename Map, typename VectorOfKeys, typename ValueType>
template <typename Map, typename VectorOfKeys, typename ValueType>
void removeFromMap(Map& map, const VectorOfKeys& keys, const ValueType& val)
{
typedef typename VectorOfKeys::const_iterator KeysIter;
Expand All @@ -180,7 +181,7 @@ void removeFromMap(Map& map, const VectorOfKeys& keys, const ValueType& val)
}
}
}
}
} // namespace

bool FileFormatManager::removeFormat(const std::string& identifier)
{
Expand Down Expand Up @@ -291,6 +292,7 @@ FileFormatManager::FileFormatManager()
addFormat(new CmlFormat);
addFormat(new CjsonFormat);
addFormat(new GromacsFormat);
addFormat(new MdcrdFormat);
addFormat(new MdlFormat);
addFormat(new PdbFormat);
addFormat(new PoscarFormat);
Expand Down Expand Up @@ -385,5 +387,5 @@ void FileFormatManager::appendError(const std::string& errorMessage)
m_error += errorMessage + "\n";
}

} // end Io namespace
} // end Avogadro namespace
} // namespace Io
} // namespace Avogadro
103 changes: 103 additions & 0 deletions avogadro/io/mdcrdformat.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/******************************************************************************

This source file is part of the Avogadro project.

Copyright 2013 Kitware, Inc.

This source code is released under the New BSD License, (the "License").

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

******************************************************************************/

#include "mdcrdformat.h"

#include <avogadro/core/elements.h>
#include <avogadro/core/molecule.h>
#include <avogadro/core/unitcell.h>
#include <avogadro/core/utilities.h>
#include <avogadro/core/vector.h>

#include <iomanip>
#include <iostream>
#include <istream>
#include <ostream>
#include <sstream>
#include <string>

using std::endl;
using std::getline;
using std::map;
using std::string;
using std::to_string;
using std::vector;

namespace Avogadro {
namespace Io {

using Core::Array;
using Core::Atom;
using Core::Elements;
using Core::lexicalCast;
using Core::Molecule;
using Core::split;
using Core::trimmed;
using Core::UnitCell;

#ifndef _WIN32
using std::isalpha;
#endif

#define MDCRD_EOF -1

MdcrdFormat::MdcrdFormat() {}

MdcrdFormat::~MdcrdFormat() {}

bool MdcrdFormat::read(std::istream& inStream, Core::Molecule& mol)
{
string title;
float x, y, z;

typedef map<string, unsigned char> AtomTypeMap;
AtomTypeMap atomTypes;

Array<Vector3> positions;

getline(inStream, title);
mol.setData("name", title);

while (inStream >> x >> y >> z) {
Vector3 pos(x, y, z);
positions.push_back(pos);
}

mol.setCoordinate3d(positions, 0);
return true;
}

bool MdcrdFormat::write(std::ostream& outStream, const Core::Molecule& mol)
{
return false;
}

std::vector<std::string> MdcrdFormat::fileExtensions() const
{
std::vector<std::string> ext;
ext.push_back("mdcrd");
return ext;
}

std::vector<std::string> MdcrdFormat::mimeTypes() const
{
std::vector<std::string> mime;
mime.push_back("N/A");
return mime;
}

} // namespace Io
} // namespace Avogadro
62 changes: 62 additions & 0 deletions avogadro/io/mdcrdformat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/******************************************************************************

This source file is part of the Avogadro project.

Copyright 2013 Kitware, Inc.

This source code is released under the New BSD License, (the "License").

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

******************************************************************************/

#ifndef AVOGADRO_IO_MDCRDFORMAT_H
#define AVOGADRO_IO_MDCRDFORMAT_H

#include "fileformat.h"

namespace Avogadro {
namespace Io {

/**
* @class MdcrdFormat mdcrdformat.h <avogadro/io/mdcrdformat.h>
* @brief Implementation of the generic mdcrd format.
* @author David C. Lonie
*/

class AVOGADROIO_EXPORT MdcrdFormat : public FileFormat
{
public:
MdcrdFormat();
~MdcrdFormat() override;

Operations supportedOperations() const override
{
return ReadWrite | MultiMolecule | File | Stream | String;
}

FileFormat* newInstance() const override { return new MdcrdFormat; }
std::string identifier() const override { return "Avogadro: AMBER MDCRD"; }
std::string name() const override { return "MDCRD"; }
std::string description() const override
{
return "Generic format that tabulates atomic symbols and 3D positions.";
}

std::string specificationUrl() const override { return ""; }

std::vector<std::string> fileExtensions() const override;
std::vector<std::string> mimeTypes() const override;

bool read(std::istream& inStream, Core::Molecule& molecule) override;
bool write(std::ostream& outStream, const Core::Molecule& molecule) override;
};

} // namespace Io
} // namespace Avogadro

#endif // AVOGADRO_IO_MDCRDFORMAT_H
3 changes: 3 additions & 0 deletions avogadro/qtgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ set(HEADERS
interfacewidget.h
meshgenerator.h
molecule.h
moleculeinfodialog.h
moleculemodel.h
multiviewwidget.h
periodictableview.h
Expand Down Expand Up @@ -74,6 +75,7 @@ set(SOURCES
interfacewidget.cpp
meshgenerator.cpp
molecule.cpp
moleculeinfodialog.cpp
moleculemodel.cpp
multiviewwidget.cpp
periodictablescene_p.cpp
Expand All @@ -90,6 +92,7 @@ set(SOURCES

set(UIS
customelementdialog.ui
moleculeinfodialog.ui
)
qt5_wrap_ui(UI_SOURCES ${UIS})
list(APPEND SOURCES ${UI_SOURCES})
Expand Down
Loading