1 Star 0 Fork 1

TSherry / CarbonChem

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
baseclass.h 9.72 KB
一键复制 编辑 原始数据 按行查看 历史
#pragma once
#include<iostream>
#include<cstdio>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<set>
#include<graphics.h>
#include<conio.h>
#include<cwchar>
#include <tchar.h>
using namespace std;
//下面是对不同的结构的单独添加的数目的统计
extern short carbonnumber;//已经单独添加的碳原子数目
extern short groupswithoxygens;//已经单独添加的含氧基团数目
extern short groupsunoxygens;//已经单独添加的不含氧基团数目
extern short alkylnumbers;//已经单独添加的烃基数目
extern short ringnumbers;//已经单独添加的多元环状结构数目
extern int all;
//下面是输入时,用来选择不同种类结构的列表
extern const char groupswithoxygenname[20][10];
extern const char groupunoxygenname[20][10];
extern const char alkylname[20][13];
extern double themass;//相对分子质量
//下面是不同的类
class alkyl {
public:
short x, y;//位置
int unified;//用来区分不同基团的唯一的编号
int kind;//在输入的选择列表里的号码
int rank;//表示这是第几个单独添加的结构
double mass;//相对质量
void put(void)
{
switch (kind)
{
case 1:outtextxy(x, y, L"-CH"); settextstyle(25, 0, _T("Consolas"));
outtextxy(x + 60, y + 15, L"3"); unified = 2; break;
case 2:outtextxy(x, y, L"-C H"); settextstyle(25, 0, _T("Consolas")); unified = 3;
outtextxy(x + 40, y + 15, L"2"); outtextxy(x + 80, y + 15, L"5"); break;
case 3:outtextxy(x, y, L"-CH CH CH"); settextstyle(25, 0, _T("Consolas"));
outtextxy(x + 60, y + 15, L"2"); outtextxy(x + 120, y + 15, L"2");
outtextxy(x + 170, y + 15, L"3"); unified = 5; break;
case 4:outtextxy(x, y, L"-CH CH"); outtextxy(x + 20, y - 60, L"CH"); unified = 6;
settextstyle(25, 0, _T("Consolas")); outtextxy(x + 60, y - 40, L"3");
outtextxy(x + 60, y + 15, L"2"); outtextxy(x + 120, y + 15, L"3");
line(x + 27, y - 2, x + 27, y - 22); break;
case 5:outtextxy(x, y, L"-CH=CH"); settextstyle(25, 0, _T("Consolas"));
outtextxy(x + 114, y + 15, L"2"); unified = 4; break;
case 6:outtextxy(x, y, L"-C CH"); line(x + 40, y + 15, x + 80, y + 15);
line(x + 40, y + 20, x + 80, y + 20); line(x + 40, y + 25, x + 80, y + 25); break;
case 7:outtextxy(x, y, L"-C CCH"); line(x + 40, y + 15, x + 80, y + 15);
line(x + 40, y + 20, x + 80, y + 20); line(x + 40, y + 25, x + 80, y + 25);
settextstyle(25, 0, _T("Consolas"));outtextxy(x + 133, y + 15, L"3"); break;
case 8:outtextxy(x, y, L"-CH C CH"); line(x + 90, y + 15, x + 130, y + 15);
line(x + 90, y + 20, x + 130, y + 20); line(x + 90, y + 25, x + 130, y + 25);
settextstyle(25, 0, _T("Consolas")); outtextxy(x + 57, y + 15, L"2"); break;
case 9:outtextxy(x, y, L"-CH CH CH CH"); settextstyle(25, 0, _T("Consolas"));
outtextxy(x + 57, y + 15, L"2"); outtextxy(x + 114, y + 15, L"2");
outtextxy(x + 170, y + 15, L"2"); outtextxy(x + 227, y + 15, L"2"); break;
case 10:outtextxy(x, y, L"-CHCH CH"); outtextxy(x + 20, y + 60, L"CH");
settextstyle(25, 0, _T("Consolas")); outtextxy(100 + x, y + 15, L"2");
outtextxy(x + 155, y + 15, L"3"); outtextxy(x + 60, y + 75, L"3");
line(x + 27, y + 42, x + 27, y + 62); break;
case 11:line(x + 27, y - 2, x + 27, y - 22); line(x + 27, y + 42, x + 27, y + 62);
outtextxy(x, y, L"-CCH"); outtextxy(x+20, y - 64, L"CH"); outtextxy(x+20, y + 64, L"CH");
settextstyle(25, 0, _T("Consolas")); outtextxy(x + 80, y + 15, L"3");
outtextxy(x + 60, y - 49, L"3"); outtextxy(x + 60, y - 49, L"3"); break;
case 12:outtextxy(x, y, L"-CH CHCH"); outtextxy(x + 80, y + 64, L"CH");
settextstyle(25, 0, _T("Consolas")); outtextxy(x + 60, y + 15, L"2");
outtextxy(x + 120, y - 49, L"3"); outtextxy(x + 155, y - 49, L"3"); break;
default:
printf_s("输入的烃基编号出错,未找到对应的基团!\n");
}
switch (kind)
{
case 1:mass = 15.035; break;
case 2:mass = 29.062; break;
case 3:case 4:mass = 43.089; break;
case 5:mass = 26.033; break;
case 6:mass = 25.03; break;
case 7:case 8:mass = 37.041; break;
case 9:case 10:case 11:case 12:mass = 64.087; break;
default:mass = 0;
}
}
};
struct group {
short x, y;
int number;
int unified;
short left;
short right;
bool w_connect;//是否对外相连过
double mass;
};
class carbon {//碳12原子
public:
short number;//编号
short x, y;
int kind;/*种类,1表示饱和,2表示有碳碳双键,
3表示有碳碳三键,4表示不饱和且和其它种类原子相连
0表示已经因为一些原因而不存在*/
short remain;//剩下的可以连接的键的数目
int rank = 0;//表示这是第几个单独添加的结构
};
class groupwithoxygen {//含氧基团
public:
int kind;
short number;
short x, y;
int unified;
int rank = 0;//表示这是第几个单独添加的结构
double mass;
void put(void)
{
switch (kind)
{
case 1:outtextxy(x, y, L"-OH"); unified = 7; break;
case 2:outtextxy(x, y, L"O"); outtextxy(x, y+40, L"C");
line(x + 7, y + 30, x + 7, y + 47);
line(x + 12, y + 30, x + 12, y + 47);
line(x-2, y + 58, x - 17, y + 73); unified = 15;
line(x+22, y + 58, x + 37, y + 73); break;
case 3:outtextxy(x, y, L"-CHO"); unified = 8; break;
case 4:outtextxy(x, y, L"-COOH"); unified = 19; break;
case 5:outtextxy(x, y, L"-NO"); unified = 13;
settextstyle(25, 0, _T("Consolas"));
outtextxy(x+60, y+15, L"2"); break;
case 6:outtextxy(x, y, L"-NO"); unified = 23;break;
case 7:outtextxy(x, y, L"-SO H"); unified = 14;
settextstyle(25, 0, _T("Consolas"));
outtextxy(x + 60, y + 15, L"3"); break;
case 8:outtextxy(x, y, L"-O-"); unified = 17; break;
case 9:outtextxy(x, y, L"O"); outtextxy(x, y + 40, L"C O");
line(x + 7, y + 30, x + 7, y + 47);
line(x + 12, y + 30, x + 12, y + 47);
line(x, y + 60, x - 20, y + 60); unified = 16;
line(x + 20, y + 60, x + 40, y + 60);
line(x + 60, y + 60, x + 80, y + 60); break;
case 10:outtextxy(x, y, L"-CONH-"); unified = 18; break;
default:printf_s("这基团找不着啊\n"); _getch();
groupswithoxygens--; break;
}
switch (kind)
{
case 1:mass = 17.008; break;
case 2:mass = 28.011; break;
case 3:mass = 19.019; break;
case 4:mass = 35.019; break;
case 6:mass = 30.0067; break;
case 5:mass = 46.0067; break;
case 7:mass = 81.073; break;
case 8:mass = 16; break;
case 9:mass = 44.011; break;
case 10:mass = 43.0257; break;
default:mass = 0;
}
}
};
class groupwithoutoxygen {
public://不含氧的基团(不是烃基)
int kind;
int unified;
short number;
short x, y;
int rank = 0;//表示这是第几个单独添加的结构
double mass;
void put(void)
{
switch (kind)
{
case 1:cout << "何种卤素原子?1.F 2.Cl 3.Br 4.I\n";
int a; cin >> a; switch (a)
{
case 1:outtextxy(x, y, L"-F"); mass = 19; break;
case 2:outtextxy(x, y, L"-Cl"); mass = 35.453; break;
case 3:outtextxy(x, y, L"-Br"); mass = 79.904; break;
case 4:outtextxy(x, y, L"-I"); mass = 126.905; break;
default:cout << "这卤素原子对不上号啊!\n";
groupsunoxygens--; break; return;
}unified = 1; break;
case 2:outtextxy(x, y, L"-CN"); unified = 24; mass = 26.0177; break;
case 3:outtextxy(x, y, L"-S-S-"); unified = 38; mass = 64.12; break;
case 4:case 5:case 6:case 7:makebenrings(); break;
default:cout << "指令错误!" << endl; _getch(); break;
}
}
private:
void makebenrings(void)
{
line(x, y + 16, x + 26, y); line(x + 52, y + 16, x + 52, y + 46);
line(x, y + 16, x, y + 46); line(x + 26, y, x + 52, y + 16);
line(x, y + 46, x + 26, y + 60); line(x + 26, y + 60, x + 52, y + 46);
line(x + 6, y + 17, x + 27, y + 5); line(x + 6, y + 45, x + 25, y + 55);
line(x + 48, y + 16, x + 48, y + 46);//首先画出第一个苯环
switch (kind)
{
case 6://蒽有第三个苯环
line(x + 104, y + 16, x + 130, y); line(x + 156, y + 16, x + 156, y + 46);
line(x + 130, y, x + 156, y + 16); line(x + 104, y + 46, x + 130, y + 60);
line(x + 130, y + 60, x + 156, y + 46); unified = 27;
line(x + 129, y + 5, x + 150, y + 17); line(x + 129, y + 54, x + 150, y + 45);
mass = 178.23;
case 5://萘有第二个苯环
line(x + 52, y + 16, x + 78, y); line(x + 78, y, x + 104, y + 16);
line(x + 52, y + 46, x + 78, y + 60); line(x + 78, y + 60, x + 104, y + 46);
line(x + 104, y + 16, x + 104, y + 46); unified = 26;
line(x + 77, y + 5, x + 98, y + 17); line(x + 77, y + 54, x + 98, y + 45);
mass = 128.17; break;
case 7:
line(x + 52, y + 16, x + 78, y); line(x + 78, y, x + 104, y + 16);//ys
line(x + 52, y + 46, x + 78, y + 60); line(x + 78, y + 60, x + 104, y + 46);
line(x + 104, y + 16, x + 104, y + 46); unified = 28;
line(x + 77, y + 5, x + 98, y + 17); line(x + 77, y + 54, x + 98, y + 45);
/*如果我们去对比蒽和菲的结构式,我们可以发现菲的前两个苯环和蒽是完全
相同的,只是第三个苯环整体向上移动了约46像素,向左移动了约16像素*/
//line(x+104,y-30,x+94,y);
line(x + 130, y - 30, x + 130, y); line(x + 78, y, x + 78, y - 30);
line(x + 104, y - 46, x + 130, y - 30);
line(x + 104, y + 14, x + 130, y);
line(x + 104, y - 46, x + 78, y - 30);
line(x + 126, y - 30, x + 126, y); line(x + 103, y - 42, x + 80, y - 27);
mass = 178.23; break;
case 4:unified = 25; mass = 78.11; break;
default:printf_s("发生了鬼畜般地错误."); break;
}
}
};
class ring;
enum reaction {
substitute, add, elimination, hydrolysis, esterification, neutraliation,
oxidize, restore, peptide
};
/*分别是:取代反应,加成反应,消去反应,水解反应,酯化反应,酸碱中和反应
氧化反应,还原反应,成肽反应*/
extern int dertax[7][9];
extern int dertay[7][9];
extern int dertaxbezene[5][15];
extern int dertaybezene[5][15];
//实际上单独添加的不同结构,在此登记
extern carbon cs[257];//碳原子
extern groupwithoxygen gs[257];//含氧基团
extern groupwithoutoxygen ungs[257];//不含氧基团
extern alkyl alkyls[257];//烃基
extern ring rings[257];//多元环状结构,可能是碳环也可能是杂环
extern vector<group>groups;//所有的添加的结构从头到尾记录下来
C++
1
https://gitee.com/TSherry/carbon-chem.git
git@gitee.com:TSherry/carbon-chem.git
TSherry
carbon-chem
CarbonChem
master

搜索帮助