1 // XDrawChem
2 // Copyright (C) 2004-2005  Bryan Herger <bherger@users.sourceforge.net>
3 // Copyright (C) 2020  Yaman Qalieh <ybq987@gmail.com>
4 
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 
15 // You should have received a copy of the GNU General Public License
16 // along with this program.  If not, see <https://www.gnu.org/licenses/>.
17 
18 #include <QList>
19 
20 #include "arrow.h"
21 #include "bond.h"
22 #include "bracket.h"
23 #include "chemdata.h"
24 #include "curvearrow.h"
25 #include "defs.h"
26 #include "drawable.h"
27 #include "gobject.h"
28 #include "molecule.h"
29 #include "symbol.h"
30 #include "text.h"
31 
32 void ChemData::XDCEventHandler(XDC_Event *evt) {
33     GraphicObject *go;
34 
35     switch (evt->type()) {
36     case EVT_ADD_BOND:
37         if (evt->Param2() < 0)
38             addBond(evt->Start(), evt->End(), evt->Param1(), 1, evt->color(), evt->bool1());
39         else
40             addBond(evt->Start(), evt->End(), evt->Param1(), evt->Param2(), evt->color(),
41                     evt->bool1());
42         break;
43     case EVT_ADD_BOND_UP:
44         addBond(evt->Start(), evt->End(), 1, 5, evt->color());
45         break;
46     case EVT_ADD_BOND_DOWN:
47         addBond(evt->Start(), evt->End(), 1, 7, evt->color());
48         break;
49     case EVT_ADD_BOND_WAVY:
pkey_main(int argc,char ** argv)50         addBond(evt->Start(), evt->End(), 1, 6, evt->color());
51         break;
52     case EVT_ADD_BOND_DASH:
53         addBond(evt->Start(), evt->End(), evt->Param1(), 99, evt->color());
54         break;
55     case EVT_ADD_ARROW:
56         addArrow(evt->Start(), evt->End(), evt->color(), evt->Param1(), evt->Param2());
57         break;
58     case EVT_ADD_BRACKET:
59         addBracket(evt->Start(), evt->End(), evt->color(), evt->Param1());
60         break;
61     case EVT_ADD_CURVEARROW:
62         addCurveArrow(evt->Start(), evt->End(), evt->color(), evt->text());
63         break;
64     case EVT_ADD_GRAPHIC:
65         go = new GraphicObject(r);
66         go->setObjectType(TYPE_BEZIER); // for now!
67         go->SetStyle(evt->Param1());
68         go->SetColor(evt->color());
69         go->setPointArray(evt->points());
70         addGraphicObject(go);
71         break;
72     default:
73         qDebug() << "Unknown event type???";
74         break;
75     }
76 
77     // delete the event!
78     delete evt;
79 }
80