]> Git trees. - libqmvoc.git/commitdiff
* Adding a very first version of the CML-classes
authorCarsten Niehaus <cniehaus@gmx.de>
Wed, 7 Jun 2006 10:56:19 +0000 (10:56 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Wed, 7 Jun 2006 10:56:19 +0000 (10:56 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=549072

libscience/CMakeLists.txt
libscience/cml/CMakeLists.txt [new file with mode: 0644]
libscience/cml/cmlclasses.cpp [new file with mode: 0644]
libscience/cml/cmlclasses.h [new file with mode: 0644]
libscience/cml/test.cml [new file with mode: 0644]

index e22377a7d8f1a2202de1a1316949b19d639ce849..3aa77f98bc7c8acb524a425e81483b35192d4c35 100644 (file)
@@ -1,6 +1,7 @@
 
 add_subdirectory(data)
 add_subdirectory(tests)
+add_subdirectory(cml)
 
 
 ########### next target ###############
diff --git a/libscience/cml/CMakeLists.txt b/libscience/cml/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d9c4257
--- /dev/null
@@ -0,0 +1,15 @@
+include_directories( ${CMAKE_SOURCE_DIR}/libkdeedu/libscience  )
+
+set(cml_LIB_SRCS 
+       cmlclasses.cpp 
+#      xml_cml.cpp
+)
+
+kde4_automoc(${cml_LIB_SRCS})
+
+kde4_add_library(cml SHARED ${cml_LIB_SRCS})
+
+target_link_libraries(cml ${QT_QTXML_LIBRARY} ${QT_QTCORE_LIBRARY} )
+
+install_targets(${LIB_INSTALL_DIR} cml )
+
diff --git a/libscience/cml/cmlclasses.cpp b/libscience/cml/cmlclasses.cpp
new file mode 100644 (file)
index 0000000..1476713
--- /dev/null
@@ -0,0 +1,34 @@
+/***************************************************************************
+ *   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"
+#include <kdebug.h>
+using namespace CML;
+
+Molecule::Molecule()
+{
+}
+
+Atom::Atom()
+{
+}
+
+Bond::Bond()
+{
+}
diff --git a/libscience/cml/cmlclasses.h b/libscience/cml/cmlclasses.h
new file mode 100644 (file)
index 0000000..e1f0603
--- /dev/null
@@ -0,0 +1,104 @@
+#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 <QString>
+#include <QList>
+
+namespace CML
+{
+       
+class Molecule
+{
+       public:
+               Molecule();
+
+};
+
+class Atom
+{
+       public:
+               Atom( );
+
+               void setID( const QString& id ){
+                       m_id = id;
+               }
+               
+               void setElementType( const QString& et ){
+                       m_elementType = et;
+               }
+
+               void setiX2( int i ){
+                       coord_x2 = i;
+               }
+
+               void setiX3( int i ){
+                       coord_x3 = i;
+               }
+
+               void setiY2( int i ){
+                       coord_y2 = i;
+               }
+
+               void setiY3( int i ){
+                       coord_y3 = i;
+               }
+
+               void setiZ3( int i ){
+                       coord_z3 = i;
+               }
+
+       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 Bond
+{
+       public:
+               Bond();
+
+               /**
+                * defines the two Atoms which start and stop the bond
+                */
+               void setAtoms( CML::Atom* a1, CML::Atom* a2 ){
+                       m_start = a1;
+                       m_end = a2;
+               }
+
+               void setOrder( int o ){
+                       m_order = o;
+               }
+       
+       private:
+               Atom* m_start;
+               Atom* m_end;
+
+               int m_order;
+};
+
+}
+#endif // CMLCLASSES_H
diff --git a/libscience/cml/test.cml b/libscience/cml/test.cml
new file mode 100644 (file)
index 0000000..de138bb
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<molecule xmlns="http://www.xml-cml.org/schema/cml2/core" id="Ethanol">
+ <atomArray>
+  <atom id="a1" elementType="H" x3="-1.916300" y3="-0.043300" z3="-1.055200"/>
+  <atom id="a2" elementType="C" x3="-2.529600" y3="-0.050300" z3="-1.960600"/>
+  <atom id="a3" elementType="H" x3="-2.235900" y3="0.793700" z3="-2.591800"/>
+  <atom id="a4" elementType="H" x3="-2.311100" y3="-0.960600" z3="-2.527100"/>
+  <atom id="a5" elementType="C" x3="-4.003000" y3="0.025300" z3="-1.617800"/>
+  <atom id="a6" elementType="H" x3="-4.299600" y3="-0.832200" z3="-1.006300"/>
+  <atom id="a7" elementType="H" x3="-4.224400" y3="0.947100" z3="-1.071600"/>
+  <atom id="a8" elementType="O" x3="-4.760100" y3="0.012900" z3="-2.821500"/>
+  <atom id="a9" elementType="H" x3="-5.698200" y3="0.061600" z3="-2.569500"/>
+ </atomArray>
+ <bondArray>
+  <bond atomRefs2="a1 a2" order="1"/>
+  <bond atomRefs2="a2 a3" order="1"/>
+  <bond atomRefs2="a2 a4" order="1"/>
+  <bond atomRefs2="a2 a5" order="1"/>
+  <bond atomRefs2="a5 a6" order="1"/>
+  <bond atomRefs2="a5 a7" order="1"/>
+  <bond atomRefs2="a5 a8" order="1"/>
+  <bond atomRefs2="a8 a9" order="1"/>
+ </bondArray>
+</molecule>