summarylogtreecommitdiffstats
path: root/obabel3.patch
blob: 49887f9d1dd5a1a7f7c8afd978d4680187b1facf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
From 2fb8dea9d1ace5b1fc1ddcf0f7034cf119763b53 Mon Sep 17 00:00:00 2001
From: Andrius Merkys <andrius.merkys@gmail.com>
Date: Wed, 8 Jan 2020 11:47:58 +0200
Subject: [PATCH] Migrating xdrawchem to Open Babel 3.

---
 xdrawchem-qt5/xdrawchem.pro                 |  4 ++--
 xdrawchem-qt5/xdrawchem/ioiface.cpp         |  8 ++++----
 xdrawchem-qt5/xdrawchem/ioiface.h           |  3 +++
 xdrawchem-qt5/xdrawchem/molecule.h          |  4 ++++
 xdrawchem-qt5/xdrawchem/molecule_obmol.cpp  | 10 +++++-----
 xdrawchem-qt5/xdrawchem/molecule_smiles.cpp |  8 +++-----
 6 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/xdrawchem-qt5/xdrawchem.pro b/xdrawchem-qt5/xdrawchem.pro
index e8e1886..2b4e2a2 100644
--- a/xdrawchem-qt5/xdrawchem.pro
+++ b/xdrawchem-qt5/xdrawchem.pro
@@ -2,8 +2,8 @@ TEMPLATE = app
 TARGET = xdrawchem
 
 # edit to match your OB install
-exists(/usr/include/openbabel-2.0/openbabel/mol.h) {
-INCLUDEPATH += /usr/include/openbabel-2.0
+exists(/usr/include/openbabel3/openbabel/mol.h) {
+INCLUDEPATH += /usr/include/openbabel3
 LIBS += -lopenbabel
 }
 exists(/usr/local/include/openbabel-2.0/openbabel/mol.h) {
diff --git a/xdrawchem-qt5/xdrawchem/ioiface.cpp b/xdrawchem-qt5/xdrawchem/ioiface.cpp
index acba119..5123970 100644
--- a/xdrawchem-qt5/xdrawchem/ioiface.cpp
+++ b/xdrawchem-qt5/xdrawchem/ioiface.cpp
@@ -193,7 +193,7 @@ void IOIface::convertToChemData()
         int bondorder = bond->GetBondOrder();
 
         //set elements
-        if ( !atom1->IsCarbon() ) {
+        if ( atom1->GetAtomicNum() != 6 ) {
             QString str( "<element>" );
             str += IOIface::symbol[atom1->GetAtomicNum() - 1];
             str += "</element>";
@@ -201,7 +201,7 @@ void IOIface::convertToChemData()
 
         }
 
-        if ( !atom2->IsCarbon() ) {
+        if ( atom2->GetAtomicNum() != 6 ) {
             QString str( "<element>" );
 
             str += IOIface::symbol[atom2->GetAtomicNum() - 1];
@@ -216,7 +216,7 @@ void IOIface::convertToChemData()
 
         //label atoms if not Carbon
 
-        if ( !atom1->IsCarbon() ) {
+        if ( atom1->GetAtomicNum() != 6 ) {
 
             text = new Text( chemdata->getRender2D() );
             QString str = IOIface::symbol[atom1->GetAtomicNum() - 1];
@@ -229,7 +229,7 @@ void IOIface::convertToChemData()
             //qDebug() << "ioiface(1) text:" << str;
         }
 
-        if ( !atom2->IsCarbon() ) {
+        if ( atom2->GetAtomicNum() != 6 ) {
 
             text = new Text( chemdata->getRender2D() );
             QString str = IOIface::symbol[atom2->GetAtomicNum() - 1];
diff --git a/xdrawchem-qt5/xdrawchem/ioiface.h b/xdrawchem-qt5/xdrawchem/ioiface.h
index 9db30f8..dd671da 100644
--- a/xdrawchem-qt5/xdrawchem/ioiface.h
+++ b/xdrawchem-qt5/xdrawchem/ioiface.h
@@ -20,6 +20,9 @@
 
 #include "chemdata.h"
 
+#include <openbabel/atom.h>
+#include <openbabel/bond.h>
+#include <openbabel/math/vector3.h>
 #include <openbabel/mol.h>
 
 using namespace OpenBabel;
diff --git a/xdrawchem-qt5/xdrawchem/molecule.h b/xdrawchem-qt5/xdrawchem/molecule.h
index f11cb73..cf57096 100644
--- a/xdrawchem-qt5/xdrawchem/molecule.h
+++ b/xdrawchem-qt5/xdrawchem/molecule.h
@@ -3,6 +3,10 @@
 #ifndef MOLECULE_H
 #define MOLECULE_H
 
+#include <openbabel/atom.h>
+#include <openbabel/bond.h>
+#include <openbabel/elements.h>
+#include <openbabel/math/vector3.h>
 #include <openbabel/mol.h>
 #include <openbabel/obconversion.h>
 
diff --git a/xdrawchem-qt5/xdrawchem/molecule_obmol.cpp b/xdrawchem-qt5/xdrawchem/molecule_obmol.cpp
index b48d860..50dd949 100644
--- a/xdrawchem-qt5/xdrawchem/molecule_obmol.cpp
+++ b/xdrawchem-qt5/xdrawchem/molecule_obmol.cpp
@@ -58,7 +58,7 @@ bool Molecule::convertFromOBMol( OBMol * obmol )
     Point point;
     Text *text;
 
-    std::vector < OBEdgeBase * >::iterator bonditr;
+    std::vector < OBBond * >::iterator bonditr;
     std::map < Point, DPoint *, pt_cmp > points;
     std::map < Point, DPoint *, pt_cmp >::iterator itr;
 
@@ -133,7 +133,7 @@ bool Molecule::convertFromOBMol( OBMol * obmol )
         int bondorder = bond->GetBondOrder();
 
         //set elements
-        if ( !atom1->IsCarbon() ) {
+        if ( atom1->GetAtomicNum() != 6 ) {
             QString str( "<element>" );
 
             str += symbol[atom1->GetAtomicNum() - 1];
@@ -142,7 +142,7 @@ bool Molecule::convertFromOBMol( OBMol * obmol )
 
         }
 
-        if ( !atom2->IsCarbon() ) {
+        if ( atom2->GetAtomicNum() != 6 ) {
             QString str( "<element>" );
 
             str += symbol[atom2->GetAtomicNum() - 1];
@@ -155,7 +155,7 @@ bool Molecule::convertFromOBMol( OBMol * obmol )
 
         //label atoms if not Carbon
 
-        if ( !atom1->IsCarbon() ) {
+        if ( atom1->GetAtomicNum() != 6 ) {
 
             text = new Text( r );
             QString str = symbol[atom1->GetAtomicNum() - 1];
@@ -167,7 +167,7 @@ bool Molecule::convertFromOBMol( OBMol * obmol )
             addText( text );
         }
 
-        if ( !atom2->IsCarbon() ) {
+        if ( atom2->GetAtomicNum() != 6 ) {
 
             text = new Text( r );
             QString str = symbol[atom2->GetAtomicNum() - 1];
diff --git a/xdrawchem-qt5/xdrawchem/molecule_smiles.cpp b/xdrawchem-qt5/xdrawchem/molecule_smiles.cpp
index 5d7c8b3..4bf9fbb 100644
--- a/xdrawchem-qt5/xdrawchem/molecule_smiles.cpp
+++ b/xdrawchem-qt5/xdrawchem/molecule_smiles.cpp
@@ -254,8 +254,6 @@ void Molecule::FromSMILES( QString sm )
 
     DPoint *thisDPoint;
 
-    OpenBabel::OBElementTable etable;
-
     std::vector < OpenBabel::OBNodeBase * >::iterator ait;
 
     std::map < OpenBabel::OBAtom *, DPoint * >hashit;
@@ -265,9 +263,9 @@ void Molecule::FromSMILES( QString sm )
 
         qInfo() << "Adding OBAtom: " << i++ << " of element#: " <<
           thisAtom->GetAtomicNum() << " type: " <<
-          etable.GetSymbol(thisAtom->GetAtomicNum()) ;
+          OBElements::GetSymbol(thisAtom->GetAtomicNum()) ;
         thisDPoint = new DPoint;
-        tmp_element = etable.GetSymbol( thisAtom->GetAtomicNum() );
+        tmp_element = OBElements::GetSymbol( thisAtom->GetAtomicNum() );
 
         tmp_element_mask = tmp_element;
         tmp_element_mask.fill( ' ' );   // fix the mask characters
@@ -292,7 +290,7 @@ void Molecule::FromSMILES( QString sm )
 
     OpenBabel::OBBond * thisBond;
 
-    std::vector < OpenBabel::OBEdgeBase * >::iterator bit;
+    std::vector < OpenBabel::OBBond * >::iterator bit;
     for ( thisBond = myMol.BeginBond( bit ); thisBond; thisBond = myMol.NextBond( bit ) ) {
         addBond( hashit[thisBond->GetBeginAtom()], hashit[thisBond->GetEndAtom()], 1, thisBond->GetBondOrder(), QColor( 0, 0, 0 ), true );
     }