Skip to content

Commit

Permalink
updates for 1.9.11
Browse files Browse the repository at this point in the history
added SPEC file to qt5 branch and checking in fixes for 1.9.11
  • Loading branch information
bryanherger committed Dec 24, 2016
1 parent e8bab78 commit d4c27d9
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 54 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ Welcome to XDrawChem!

Please visit the project page at http://www.woodsidelabs.com/chemistry/xdrawchem.php

Current release (1.9.10-1) source tarball and RPM are at SourceForge: https://sourceforge.net/projects/xdrawchem/files/xdrawchem/1.9.10/
Current release (1.9.11-1) source tarball and RPM are at SourceForge: https://sourceforge.net/projects/xdrawchem/files/xdrawchem/1.9.10/

This package conatins two versions of XDrawChem:
This repository conatins three (!) versions of XDrawChem:

xdrawchem - this is the main development version. It is based on Qt 3.x.
xdrawchem-qt5 - this is the main development and release version (1.9.11 onwards). It is based on Qt 5.x.
(Starting with 1.10.x, this will be "xdrawchem" and the legacy version will be "xdrawchem-qt3")

xdrawchem - this is the legacy Qt3 version (1.9.10 and prior). It is based on Qt 3.x.

xdrawchem-qt4 - this is a contributed version. It is based on Qt 4.
Eventually, this will become the main version, but most distributions
Expand Down
47 changes: 47 additions & 0 deletions xdrawchem-qt5/SPECS/xdrawchem.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Summary: XDrawChem is an application for drawing and analyzing chemical structures and reactions.
Name: xdrawchem
Version: 1.9.11
Release: 1
License: GPL
Group: Applications/Productivity
URL: http://www.woodsidelabs.com/chemistry/xdrawchem.php
Source0: https://sourceforge.net/projects/%{name}/files/%{name}/%{version}/%{name}-%{version}-%{release}.rpmsrc.tar.gz
Requires: openbabel qt5-qtbase
BuildRequires: openbabel openbabel-devel qt5-qtbase-devel
BuildRoot: /var/tmp/%{name}-buildroot

%description
XDrawChem is an application for drawing and analyzing chemical structures and reactions.

%prep
%setup -q

%build
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT
qmake-qt5 PREFIX="/usr/local"
make

%install
install -D -m 0755 bin/xdrawchem $RPM_BUILD_ROOT/usr/local/bin/xdrawchem
mkdir -p $RPM_BUILD_ROOT/usr/local/share/xdrawchem
chmod 0755 $RPM_BUILD_ROOT/usr/local/share/xdrawchem
cp ring/* $RPM_BUILD_ROOT/usr/local/share/xdrawchem
mkdir -p $RPM_BUILD_ROOT/usr/local/share/xdrawchem/doc
chmod 0755 $RPM_BUILD_ROOT/usr/local/share/xdrawchem/doc
cp doc/* $RPM_BUILD_ROOT/usr/local/share/xdrawchem/doc

%clean
make clean
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%doc README.txt INSTALL.txt TODO.txt COPYRIGHT.txt
/usr/local/bin/xdrawchem
/usr/local/share/xdrawchem/*

%changelog
* Sun Dec 11 2016 Bryan Herger <bherger@users.sf.net>
- initial version of spec file

4 changes: 3 additions & 1 deletion xdrawchem-qt5/xdrawchem.pro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TEMPLATE = app
TARGET = xdrawchem-qt5
TARGET = xdrawchem

# edit to match your OB install
INCLUDEPATH += /usr/include/openbabel-2.0
Expand Down Expand Up @@ -29,6 +29,8 @@ doc.path = $${PREFIX}/share/xdrawchem/doc
doc.files = doc/*
INSTALLS += ringdir doc
QMAKE_CXXFLAGS_DEBUG += -O0 -g3
QMAKE_CXXFLAGS_GNUCXX11 =
QMAKE_CXXFLAGS_CXX11 =

//DEFINES += QT_NO_CAST_TO_ASCII
CONFIG += debug
Expand Down
2 changes: 1 addition & 1 deletion xdrawchem-qt5/xdrawchem/atom.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class Atom
n->bondOrderSum = bondOrderSum;
//System->arraycopy(nodeTable, 0, n->nodeTable, 0, 10);
for (int f = 0; f < 10; f++)
n->nodeTable.insert(f, nodeTable[f]); // shallow copy!
n->nodeTable.replace(f, nodeTable[f]); // shallow copy!
// the rest are deep copies.
n->intnodeTable = intnodeTable;
n->bondTable = bondTable;
Expand Down
8 changes: 4 additions & 4 deletions xdrawchem-qt5/xdrawchem/molecule_smiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void Molecule::SDG( bool coord )
a1 = atoms.at( c1 );
for ( c2 = 0; c2 < tmp_pt->neighbors.count(); c2++ ) {
refnum = tmp_pt->neighbors.at( c2 )->serial;
a1->nodeTable.insert( c2, atoms.at( refnum ) );
a1->nodeTable.replace( c2, atoms.at( refnum ) );
a1->bondTable[c2] = tmp_pt->bondorder[c2];
a1->intnodeTable[c2] = refnum;
}
Expand All @@ -106,12 +106,12 @@ void Molecule::SDG( bool coord )
c2 = 0;
for (tmp_pt = tmp_ring->first(); tmp_pt != 0; tmp_pt = tmp_ring->next()) {
a1 = atoms.at(tmp_pt->serial);
ring1->insert(c2, a1);
ring1->replace(c2, a1);
qInfo() << "RA" << c2 << ":" << tmp_pt->serial ;
c2++;
}
ring1->sort2();
s1.insert(c1, ring1);
s1.replace(c1, ring1);
c1++;
}
*/
Expand Down Expand Up @@ -463,7 +463,7 @@ void Molecule::FromSMILES(QString sm) {
int ringnum = tmp_token.right(1).toInt();
flag = true;
if (ring_array_status[ringnum] == false) { // save this atom
ring_closure_array.insert(ringnum, new_pt);
ring_closure_array.replace(ringnum, new_pt);
ring_array_status[ringnum] = true;
} else { // do ring closure
tmp_pt = ring_closure_array.at(ringnum);
Expand Down
56 changes: 40 additions & 16 deletions xdrawchem-qt5/xdrawchem/sdg.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,16 @@ class SPoint {
y = (double)y1;
}

/** Constructs a point as a dublicate of another point */
/** Constructs a point as a duplicate of another point */
SPoint(const SPoint &p){
x = p.x;
y = p.y;
}

/** return this SPoint as a QString */
QString toString() {
return QString("(%1,%2)").arg(x).arg(y);
}
};

/** Construct that stores the parameters needed for the placement of
Expand Down Expand Up @@ -135,6 +140,7 @@ class SDG {
ringTracker = 0;
ddebug = 0;
draw();
drawStatus("at end");
}

/** Performs the actual calculation of the coordinated based on a
Expand All @@ -154,7 +160,7 @@ class SDG {
atomSet[i]->status = 0;
atomSet[i]->ringCounter = 0;
}

drawStatus("start");
sortBondList();
for (int f = 0; f < atomSet.count(); f++)
{
Expand All @@ -170,6 +176,7 @@ class SDG {
sssr = sorf.findSSSR(atomSet); //should be passed from Molecule()
sssr.sort();
sssr.makeNodeRingLists(atomSet);
drawStatus("after sssr");

if (sssr.size() > 0){
/* We have rings
Expand Down Expand Up @@ -203,6 +210,7 @@ class SDG {
}
}
positionRingAtoms(complRing, SPoint(0,0), (double)0, 0, complRingSize - 1);
drawStatus("208");
ring = sssr.at(complRing);
ring->status = 1;

Expand All @@ -215,6 +223,7 @@ class SDG {
for (int f = 0; f < sssr.size(); f++){
if ((sssr.at(f))->status == 1) {
positionRingSubstituents(f);
drawStatus("222");
//if (true) return;
stillThere = true;
}
Expand Down Expand Up @@ -278,14 +287,21 @@ class SDG {
int whatToDraw(){
for (int f = 0; f < atomSet.count(); f++){
if (atomSet[f]->status == 1){
qDebug() << "whatToDraw(): " << f ;
qInfo() << "whatToDraw(): " << f ;
return f;
}
}
qDebug() << "whatToDraw(): -1" ;
qInfo() << "whatToDraw(): -1" ;
return -1;
}

/** Scans the array of nodes for those that have not been finally drawn */

void drawStatus(QString note){
// debug: what actually happened here?
for (int ii = 0; ii < atomSet.count(); ii++) { qInfo() << note << ":SDG pos:" << ii << ":status:" << atomSet[ii]->status << ":(" << atomSet[ii]->x << "," << atomSet[ii]->y << ")"; }
}

/** Takes care of drawing an ring-less graph once one start
atom has been placed. */

Expand Down Expand Up @@ -399,7 +415,7 @@ class SDG {
// ringType = 1 : spiro annulation requested;
// ringType = 2 : regular 1-bond annulation requested;
// ringType = 3 : annulation with more than two shared atoms
//System.out.println("Ring to substitute: " + ringIndex);
qInfo() << "Ring to substitute: " << ringIndex;
double ph = 0.0174532925;
Ring *ring = sssr.at(ringIndex);
int k = ring->size();
Expand Down Expand Up @@ -435,6 +451,7 @@ class SDG {
which already has been positioned by the calling
method */
handleRestOfRingSubstituents(ringIndex);
drawStatus("451");
return;

}
Expand All @@ -458,7 +475,7 @@ class SDG {
/* we found another ring to which atom belongs
which is not yet positioned. Let's remember it. */
secondRing = sssr.at(tempRing);
qDebug() << "secondRing:" << secondRing->getSortedString() ;
qInfo() << "secondRing:" << secondRing->getSortedString() ;
secondRingNumber = tempRing;
size = (getIntersection(ring->getNodeNumberList(), secondRing->getNodeNumberList())).count();
if (secondRing->notAllPositioned(atomSet)){
Expand Down Expand Up @@ -530,7 +547,7 @@ class SDG {
SPoint(atomSet[tempAtom]->x, atomSet[tempAtom]->y), rad);

if (alph != (double) 0.0)
//qDebug() << "Invoking rot-Atom() from line 538" ;
//qInfo() << "Invoking rot-Atom() from line 538" ;
tempPoint = rotAtom(SPoint(atomSet[tempAtom]->x, atomSet[tempAtom]->y), tempPoint, alph);

secondRing->x = tempPoint.x;
Expand Down Expand Up @@ -713,7 +730,7 @@ class SDG {
//System.out.println("Bicyclo");
for (il = 0; il < km; il++) {
if (atomSet[secondRing->getNodeNumber(il)]->status <= 0) {
//qDebug() << "Invoking rot-Atom() from line 719" ;
//qInfo() << "Invoking rot-Atom() from line 719" ;
temp2Point = rotAtom(SPoint(secondRing->x,secondRing->y), tempPoint, alph);
atomSet[secondRing->getNodeNumber(il)]->status = 1;
atomSet[secondRing->getNodeNumber(il)]->x = temp2Point.x;
Expand Down Expand Up @@ -777,7 +794,7 @@ class SDG {
x2 = round(center2.x * roundFactor) / roundFactor;
y2 = round(center2.y * roundFactor) / roundFactor;
angle = 360 / (sssr.at(numberOfSecondRing))->size();
qDebug() << "FRP:" << x1 << "," << y1 << ";" << x2 << "," << y2 ;
qInfo() << "FRP:" << x1 << "," << y1 << ";" << x2 << "," << y2 ;
FusedRingParams fRP;
// First block
if (x2 > x1 && y2 >= y1){
Expand Down Expand Up @@ -963,6 +980,7 @@ class SDG {
'vector' in distance 'distance' from origin. Originally called
'neuat()' */
SPoint placeAtom(SPoint origin, SPoint vector, double distance){
qInfo() << "placeAtom " << origin.toString() << " " << vector.toString() << " d=" << distance;
double a, b, cc;
a = vector.x - origin.x;
b = vector.y - origin.y;
Expand All @@ -974,11 +992,12 @@ class SDG {

/** Rotates the atom at Point 'point' around the Point 'center' with the angle 'angle' */
SPoint rotAtom(SPoint center, SPoint point, double angle){
qInfo() << "rotAtom " << center.toString() << " " << point.toString() << " a=" << angle;
double ph = 0.0174532925;
double p, co, si, x1, y1, x, y;

// make aliphatics look good
//qDebug() << "ANGLE:" << angle;
//qInfo() << "ANGLE:" << angle;

if (arerings == true) {
if (ncalls == 0) {
Expand Down Expand Up @@ -1010,7 +1029,7 @@ class SDG {
}
}

//qDebug() << " " << angle ;
//qInfo() << " " << angle ;
// end aliphatics garbling

p = ph * angle;
Expand All @@ -1029,6 +1048,7 @@ class SDG {
Returns "-1" if no ring was drawn or the ring number of the ring draw */
int positionAtomSubstituents(int atomIndex, SPoint point, SPoint helpPoint,
QVector<int> ilist, int modus, int ir, int igr){
qInfo() << "positionAtomSubstituents:atomIndex=" << atomIndex;
double ph = 0.0174532925;
int i, ib, /*ibb, iii, iph,*/ k;
double alph, /*b, phi,*/ rad/*, xx, yy*/;
Expand Down Expand Up @@ -1073,9 +1093,12 @@ class SDG {
for (i = 0; i < k; i++) {
tempAtom = atomSet[atomIndex]->intnodeTable[i];
if (atomSet[tempAtom]->status <= 0) {
double thisRot = rot[i];
if (thisRot > (double)359.9) thisRot = (double)0.0;
qInfo() << "placeAtom " << tempAtom << " status=" << atomSet[tempAtom]->status << " rot["<<i<<"]=" << thisRot;
tempPoint = placeAtom(helpPoint, point, bondLength);
//qDebug() << "Invoking rot-Atom() from line 1079" ;
test = rotAtom(point, tempPoint, rot[i]);
//qInfo() << "Invoking rot-Atom() from line 1079" ;
test = rotAtom(point, tempPoint, thisRot);
atomSet[tempAtom]->x = test.x;
atomSet[tempAtom]->y = test.y;
atomSet[tempAtom]->status = 1;
Expand All @@ -1102,7 +1125,7 @@ class SDG {
/* -------------------------------------------------------------*/
rad = bondLength/ 2 / sin(ph * (180.0 / igr));
tempPoint = placeAtom(SPoint(xh, yh), SPoint(x, y), rad);
//qDebug() << "Invoking rot-Atom() from line 1106" ;
//qInfo() << "Invoking rot-Atom() from line 1106" ;
tempPoint = rotAtom(SPoint(x, y), tempPoint, alph);
ring->x = tempPoint.x;
ring->y = tempPoint.y;
Expand Down Expand Up @@ -1312,7 +1335,7 @@ class SDG {
/* rotate substituents by angle pp */
/* if more than one neighbor has to be drawn */
/*----------------------------------------------*/
//qDebug() << "Invoking rot-Atom() from line 1317" ;
//qInfo() << "Invoking rot-Atom() from line 1317" ;
tempPoint = rotAtom(SPoint(x, y), SPoint(xx, yy), pp);
atomSet[atomSet[bridgeAtomNumber]->intnodeTable[i]]->x = tempPoint.x;
atomSet[atomSet[bridgeAtomNumber]->intnodeTable[i]]->y = tempPoint.y;
Expand All @@ -1330,7 +1353,7 @@ class SDG {
/* rotate substituents by angle pp */
/* if more than one neighbor has to be drawn */
/*----------------------------------------------*/
//qDebug() << "Invoking rot-Atom() from line 1335" ;
//qInfo() << "Invoking rot-Atom() from line 1335" ;
tempPoint = rotAtom(SPoint(x, y), SPoint(xx, yy), pp);
atomSet[atomSet[bridgeAtomNumber]->intnodeTable[i]]->x = tempPoint.x;
atomSet[atomSet[bridgeAtomNumber]->intnodeTable[i]]->y = tempPoint.y;
Expand Down Expand Up @@ -1389,6 +1412,7 @@ class SDG {
}
result = positionAtomSubstituents(ring->getNodeNumber(i), SPoint(atomSet[ring->getNodeNumber(i)]->x, atomSet[ring->getNodeNumber(i)]->y),
SPoint(ring->x, ring->y), ilist, ring->size(), ir, igr);
drawStatus("1406");
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions xdrawchem-qt5/xdrawchem/setofrings.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@ class setOfRings : public QVector<Ring *>
s2 = ring->getSortedString();
qInfo() << s1 << "-vs-" << s2 ;
if (s1 == s2){
qInfo("true!");
return true;
}
}
qInfo("false!");
return false;
}

Expand Down Expand Up @@ -131,8 +129,8 @@ class setOfRings : public QVector<Ring *>
void swap(int i, int j){
Ring *r;
r = at(i);
insert(i, at(j));
insert(j, r);
replace(i, at(j));
replace(j, r);
}

/** Lists the rings in this set to the console */
Expand All @@ -146,6 +144,7 @@ class setOfRings : public QVector<Ring *>
that it is part of. */

void makeNodeRingLists(QVector<Atom *> thisAtomSet){
qInfo() << "makeNodeRingLists: size = " << thisAtomSet.size();
Ring *ring = 0;
int nodeNo = -1;
for (int f = 0; f < size(); f++){
Expand Down
Loading

0 comments on commit d4c27d9

Please sign in to comment.