~vcs-imports/xdrawchem/1.9.9

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
#include <qwidget.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qdialog.h>
#include <qcolor.h>
#include <qfont.h>
#include <qnamespace.h>
#include <qlayout.h>
#include <iostream>

using std::cerr;
using std::endl;

#include "tool_1h_nmr.h"
#include "render2d.h"
#include "helpwindow.h"
#include "defs.h"

// defined in main.cpp
//extern QString RingDir;

Tool_1HNMR_Dialog::Tool_1HNMR_Dialog(QWidget *parent, QString name) : 
	ToolDialog(parent, name)
{
  setCaption( tr("1H NMR spectrum") );
  helpfile = "spectra.html";
  setBackgroundColor(lightGray);
  QGridLayout *mygrid;
  mygrid = new QGridLayout(this,3,2,5);
  ngw = new NewGraphWidget( this );
  ngw->setDataType(DATA_1HNMR);
  mygrid->addMultiCellWidget(ngw,0,0,0,1);
  peaktext = new QTextEdit( this, "peak list" );
  peaktext->setReadOnly(true);
  mygrid->addMultiCellWidget(peaktext,1,1,0,1);
  QPushButton *qhelp = new QPushButton( tr("Help"), this);
  qhelp->setPalette(QPalette(lightGray));
  mygrid->addWidget(qhelp,2,0);
  connect(qhelp, SIGNAL(clicked()), SLOT(SendHelp()));
  QPushButton *qclose = new QPushButton( tr("Close"), this);
  qclose->setPalette(QPalette(lightGray));
  mygrid->addWidget(qclose,2,1);
  connect(qclose, SIGNAL(clicked()), SLOT(accept()));
}

void Tool_1HNMR_Dialog::process() {
  this_mol->Calc1HNMR(false);
  peaklist = this_mol->peaklist;
  std::cerr << "got peak list" << endl;
  if (product_mol == 0) {
    for (tmp_peak = peaklist.first(); tmp_peak != 0; 
	 tmp_peak = peaklist.next() ) {
      ngw->AddPeak(tmp_peak, QColor(0,0,0) );
      peaktext->append(tmp_peak->comment);
      //peaktext->append("\n");
    }
    return;
  }
  peaktext->setColor( QColor(255,0,0) );
  peaktext->insert( tr("Peaks of reactant:\n") );
  for (tmp_peak = peaklist.first(); tmp_peak != 0; 
       tmp_peak = peaklist.next() ) {
    ngw->AddPeak(tmp_peak, QColor(255,0,0) );
    peaktext->insert(tmp_peak->comment);
    peaktext->insert("\n");
  }
  product_mol->Calc1HNMR(false);
  peaklist.clear();
  peaklist = product_mol->peaklist;
  peaktext->setColor( QColor(0,0,255) );
  peaktext->insert( tr("Peaks of product:\n") );
  for (tmp_peak = peaklist.first(); tmp_peak != 0; 
       tmp_peak = peaklist.next() ) {
    ngw->AddPeak(tmp_peak, QColor(0,0,255) );
    peaktext->insert(tmp_peak->comment);
    peaktext->insert("\n");
  }
}