From: Carsten Niehaus Date: Mon, 12 Jun 2006 13:34:38 +0000 (+0000) Subject: * As we now support ObenBabel2 we don't need custom-made parsers X-Git-Tag: v3.80.2~71 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=1b0f6d6fe7e44c0855539769cc391050e01d5a37;p=libqmvoc.git * As we now support ObenBabel2 we don't need custom-made parsers svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=550632 --- diff --git a/libscience/CMakeLists.txt b/libscience/CMakeLists.txt index 8b7f211..6977d8d 100644 --- a/libscience/CMakeLists.txt +++ b/libscience/CMakeLists.txt @@ -15,8 +15,6 @@ set(science_LIB_SRCS chemicaldataobject.cpp moleculeparser.cpp parser.cpp - xml_cml.cpp - cmlclasses.cpp ) kde4_automoc(${science_LIB_SRCS}) diff --git a/libscience/cmlclasses.cpp b/libscience/cmlclasses.cpp deleted file mode 100644 index 9ca71b6..0000000 --- a/libscience/cmlclasses.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006 by Carsten Niehaus * - * cniehaus@kde.org * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ -#include "cmlclasses.h" - -using namespace CML; - -#include - -Molecule::Molecule(){} - -QString Molecule::debug() -{ - qDebug() << "Molecule " << m_id; - foreach( CML::Atom* a, m_atoms ) - qDebug() << a->debug(); - foreach( CML::Bond* b, m_bonds ) - qDebug() << b->debug(); -} - -Atom::Atom() -{ - m_elementType = QString( "" ); - m_id = QString( "" ); - coord_x2 = 0.0; - coord_x3 = 0.0; - coord_y2 = 0.0; - coord_y3 = 0.0; - coord_z3 = 0.0; -} - -Bond::Bond() -{ -} diff --git a/libscience/cmlclasses.h b/libscience/cmlclasses.h deleted file mode 100644 index ac76407..0000000 --- a/libscience/cmlclasses.h +++ /dev/null @@ -1,143 +0,0 @@ -#ifndef CMLCLASSES_H -#define CMLCLASSES_H -/*************************************************************************** - * Copyright (C) 2006 by Carsten Niehaus * - * cniehaus@kde.org * - * * - * This program 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 2 of the License, or * - * (at your option) any later version. * - * * - * This program 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 this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include - -#include -#include - -namespace CML -{ - -class Atom; -class Bond; - -class EDUSCIENCE_EXPORT Molecule -{ - public: - Molecule(); - - void setAtoms( QList list ){ - m_atoms = list; - } - - void setBonds( QList list ){ - m_bonds = list; - } - - void setID( const QString& id ){ - m_id = id; - } - - QString debug(); - - private: - QList m_atoms; - QList m_bonds; - - QString m_id; -}; - -class EDUSCIENCE_EXPORT Atom -{ - public: - Atom( ); - - QString debug(){ - QString db = "ID: " + m_id + " Type: " + m_elementType + " Coordinates: " + "x3: " + QString::number( coord_x3 ) + " y3: " + QString::number( coord_y3 )+ " z3:" + QString::number( coord_z3 ) + "\n"; - return db; - } - - void setID( const QString& id ){ - m_id = id; - } - - void setElementType( const QString& et ){ - m_elementType = et; - } - - void setX2( double i ){ - coord_x2 = i; - } - - void setX3( double i ){ - coord_x3 = i; - } - - void setY2( double i ){ - coord_y2 = i; - } - - void setY3( double i ){ - coord_y3 = i; - } - - void setZ3( double i ){ - coord_z3 = i; - } - - QString id() const{ - return m_id; - } - - private: - QString m_elementType; - QString m_id; - - //we need to store five possible coordinates, 2 for 2d, 3 for 3d - double coord_x2, coord_x3, - coord_y2, coord_y3, - coord_z3; -}; - -class EDUSCIENCE_EXPORT Bond -{ - public: - Bond(); - - QString debug(){ - QString db = "Atom 1: " + m_startatom_id + " ... Atom 2: " + m_endatom_id; - return db; - } - - - /** - * defines the two Atoms which start and stop the bond - */ - void setAtoms( const QString& id1, const QString& id2 ){ - m_startatom_id = id1; - m_endatom_id = id2; - } - - void setOrder( int o ){ - m_order = o; - } - - private: - QString m_startatom_id; - QString m_endatom_id; - - int m_order; -}; - -} -#endif // CMLCLASSES_H diff --git a/libscience/tests/2-propan-2-yloxypropane.cml b/libscience/tests/2-propan-2-yloxypropane.cml deleted file mode 100644 index 0358517..0000000 --- a/libscience/tests/2-propan-2-yloxypropane.cml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libscience/tests/CMakeLists.txt b/libscience/tests/CMakeLists.txt index 53c5282..7e8f484 100644 --- a/libscience/tests/CMakeLists.txt +++ b/libscience/tests/CMakeLists.txt @@ -25,17 +25,6 @@ target_link_libraries(xmlreadingtest ${KDE4_KDECORE_LIBS} science ) #target_link_libraries(isotopereadingtest ${KDE4_KDECORE_LIBS} science ) -########### next target ############### - -set(cml2test_SRCS cml2test.cpp ) - -kde4_automoc(${cml2test_SRCS}) - -kde4_add_executable(cml2test ${cml2test_SRCS}) - -target_link_libraries(cml2test ${KDE4_KDECORE_LIBS} science ) - - endif(KDE4_BUILD_TESTS) diff --git a/libscience/tests/cml2test.cpp b/libscience/tests/cml2test.cpp deleted file mode 100644 index 1358c7e..0000000 --- a/libscience/tests/cml2test.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include - -#include -#include -#include -#include - -#include "../xml_cml.h" -#include "../cmlclasses.h" - -int main(int argc, char *argv[]) -{ - if (argc < 2 || argc > 2) { - std::cout << "Usage: elements \n"; - return 1; - } - - CMLParser *handler = new CMLParser(); - - QFile xmlFile(argv[1]); - - if ( !xmlFile.open( IO_ReadOnly ) ) - return false; - - QXmlInputSource source( &xmlFile ); - QXmlSimpleReader xmlReader; - xmlReader.setContentHandler( handler ); - xmlReader.parse( source ); - - CML::Molecule * mol = handler->getMolecule(); - kDebug() << mol->debug() << endl; - - return 0; -} diff --git a/libscience/tests/tests_molecule.cml b/libscience/tests/tests_molecule.cml deleted file mode 100644 index de138bb..0000000 --- a/libscience/tests/tests_molecule.cml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/libscience/xml_cml.cpp b/libscience/xml_cml.cpp deleted file mode 100644 index ea6c3c3..0000000 --- a/libscience/xml_cml.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** - * ** Copyright ( C ) 1992-2000 Trolltech AS. All rights reserved. - * ** Copyright ( C ) 2006 Carsten Niehaus - * ** - * ** This file is part of an example program for Qt. This example - * ** program may be used, distributed and modified without limitation. - * ** - * *****************************************************************************/ - -#include "xml_cml.h" - -#include -#include - -#include - -CMLParser::CMLParser() - : QXmlDefaultHandler() -{ -} - -CMLParser::~CMLParser() -{ -} - -bool CMLParser::startDocument() -{ - return TRUE; -} - -bool CMLParser::startElement( const QString&, const QString&, - const QString& qName, - const QXmlAttributes& attr ) -{ - if ( qName.toUpper() == "MOLECULE" ) { - tmp_molecule = new CML::Molecule(); - - tmp_molecule->setID( attr.value( "id" ) ); - } - else if ( qName.toUpper() == "ATOM" ) { - tmp_atom = new CML::Atom(); - - QString x2 = attr.value( "x2"); - if ( x2 != QString( "" ) ) - tmp_atom->setX2( x2.toDouble() ); - - QString x3 = attr.value( "x3"); - if ( x3 != QString( "" ) ) - tmp_atom->setX3( x3.toDouble() ); - - QString y2 = attr.value( "y2"); - if ( y2 != QString( "" ) ) - tmp_atom->setY2( y2.toDouble() ); - - QString y3 = attr.value( "y3"); - if ( y3 != QString( "" ) ) - tmp_atom->setY3( y3.toDouble() ); - - QString z3 = attr.value( "z3"); - if ( z3 != QString( "" ) ) - tmp_atom->setZ3( z3.toDouble() ); - - tmp_atom->setID( attr.value( "id" ) ); - } - else if ( qName.toUpper() == "BOND" ) { - tmp_bond = new CML::Bond(); - - QString order = attr.value( "order"); - if ( order != QString( "" ) ) - tmp_bond->setOrder( order.toInt() ); - - QString atomRef = attr.value( "atomRefs2"); - if ( atomRef != QString( "" ) ) - { - QStringList Split = atomRef.split( " " ); - tmp_bond->setAtoms( Split.at( 0 ), Split.at( 1 ) ); - } - } - return TRUE; -} - -bool CMLParser::endElement( const QString&, const QString&, - const QString& qName ) -{ - if ( qName.toUpper() == "MOLECULE" ) { - tmp_molecule->setAtoms( getAtoms() ); - tmp_molecule->setBonds( getBonds() ); - } - else if ( qName.toUpper() == "ATOM" ) { - localAtoms.append( tmp_atom ); - tmp_atom = 0; - } - else if ( qName.toUpper() == "BOND" ) { - localBonds.append( tmp_bond ); - tmp_bond = 0; - } - return TRUE; -} - -bool CMLParser::characters( const QString &ch ) -{ - return TRUE; -} - -bool CMLParser::ignorableWhitespace( const QString &ch ) -{ - return TRUE; -} - -QList CMLParser::getAtoms() -{ - return localAtoms; -} - -QList CMLParser::getBonds() -{ - return localBonds; -} diff --git a/libscience/xml_cml.h b/libscience/xml_cml.h deleted file mode 100644 index 45e473f..0000000 --- a/libscience/xml_cml.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** - * ** $Id: xml_cml.h,v 1.2 2002/07/21 23:27:05 atenderholt Exp $ - * ** - * ** Copyright ( C ) 1992-2000 Trolltech AS. All rights reserved. - * ** - * ** This file is part of an example program for Qt. This example - * ** program may be used, distributed and modified without limitation. - * ** - * *****************************************************************************/ - -#ifndef XML_CML_H -#define XML_CML_H - -#include - -#include -#include - -#include "cmlclasses.h" - -class QString; - -// possible states (CMLParser::states) -// set in defs.h -//X #define CML_NONE 0 -//X #define CML_ATOM 1 -//X #define CML_BOND 2 -//X #define CML_MOLECULE 10 -//X #define CML_NONE 1 -//X #define CML_ATOM 2 -//X #define CML_BOND 3 -//X #define CML_ATOMARRAY 4 -//X #define CML_BONDARRAY 5 - - -class EDUSCIENCE_EXPORT CMLParser : public QXmlDefaultHandler -{ - public: - CMLParser(); - virtual ~CMLParser(); - - bool startDocument(); - - bool startElement( const QString&, - const QString&, - const QString& , - const QXmlAttributes& ); - - bool endElement( const QString&, const QString&, const QString& ); - - bool characters( const QString& ); - - bool ignorableWhitespace( const QString& ); - - QList getAtoms(); - QList getBonds(); - - CML::Molecule* getMolecule(){ - return tmp_molecule; - } - - private: - QList localAtoms; - QList localBonds; - - CML::Bond *tmp_bond; - - CML::Molecule *tmp_molecule; - - CML::Atom * tmp_atom; -}; - -#endif