一级标题c++ easyx简单矢量管理系统大一下课程设计
 可以画点,线,圆,椭圆,矩形,多边形,折线。 画出图形的数据可保存在同文件夹下的txt文档中  填充功能要在同文件夹下放入名为image名称的jpg图片即可完成填充功能  代码如下 我是把设计的图形分为不同的类,用分文件编写 你也可放在同一个文件中。  图形类 (虚基类)无cpp部分 shape.h
#pragma once
#include<iostream>
#include<iomanip>
using namespace std;
class shape
{
public:
int m_Id;
int Id;
int x, y;
int m_x1, m_x2;
int m_y1, m_y2;
int m_x, m_y;
int radius;
int left;
int top;
int right;
int bottom;
int left1;
int top1;
int right1;
int bottom1;
int color1, color2;
int line_shape;
int line_width;
int num;
int m_point[100] = {};
virtual void showInfo() = 0;
};
圆类Circle.h
#include<iostream>
using namespace std;
#include"shape.h"
class circle1 :public shape
{
public:
circle1(int m_id, int id, int x, int y, int radius,int color3,int color4, int lineshape, int linewidth);
void showInfo();
};
圆类Circle.cpp
#include"Circle.h"
circle1::circle1(int m_id, int id, int x, int y, int radius1, int color3, int color4, int lineshape, int linewidth)
{
m_Id = m_id;
Id = id;
m_x = x;
m_y = y;
radius = radius1;
color1 = color3;
color2 = color4;
line_shape = lineshape;
line_width = linewidth;
}
void circle1::showInfo()
{
cout << "编号:" << m_Id << " ";
cout << "图形种类: " << "3.圆"
<< "\t圆心点坐标:"
<< "\t(" <<m_x << "," << m_y << ")"
<< "\t半径为:" << radius << "\t边框颜色:"
<<color1 << "\t填充颜色:"
<< color2 << " 线类型:"
<< line_shape << " 线宽:"
<< line_width;
cout << endl;
}
点类point.h
#pragma once
#include<iostream>
using namespace std;
#include"shape.h"
class point1 :public shape
{
public:
point1(int m_id, int id, int x1, int y1, int color3);
void showInfo();
};
点类point.cpp
#include"point.h"
point1::point1(int m_id, int id, int x1, int y1, int color3)
{
m_Id = m_id;
Id = id;
x = x1;
y = y1;
color1 = color3;
}
void point1::showInfo()
{
cout << "编号:" << m_Id << " ";
cout << "图形种类: " << "1.点"
<< "\t点坐标:"
<< "\t(" << x << "," << y << ")" << "\t 点颜色:"
<< color1 ;
cout << endl;
}
直线Line.h
#pragma once
#include<iostream>
using namespace std;
#include"shape.h"
class Line1 :public shape
{
public:
Line1(int m_id, int id, int x1, int y1, int x2, int y2, int color3, int lineshape, int linewidth);
void showInfo();
};
直线Line.cpp
#include"Line.h"
Line1::Line1(int m_id, int id, int x1, int y1, int x2, int y2, int color3, int lineshape, int linewidth)
{
m_Id = m_id;
Id = id;
m_x1 = x1;
m_x2 = x2;
m_y1 = y1;
m_y2 = y2;
color1 = color3;
line_shape = lineshape;
line_width = linewidth;
}
void Line1::showInfo()
{
cout << "编号:" << m_Id << " ";
cout << "图形种类: " << "2.直线 ";
cout<< "\t直线两点坐标:"
<< "\t(" << m_x1 << "," << m_y1 << ")"
<< " " << "(" << m_x2 << "," << m_y2 << ")" << "\t线颜色:"
<<color1 << " 线类型:"
<< line_shape << " 线宽:"
<< line_width;
cout << endl;
}
椭圆类ellipse.h
#pragma once
#include<iostream>
using namespace std;
#include"shape.h"
class ellipse1 :public shape
{
public:
ellipse1(int m_id, int id, int left1, int top1, int right1, int bottom1, int color3, int color4, int lineshape, int linewidth);
void showInfo();
};
椭圆类ellipse.cpp
#include"ellipse.h"
ellipse1::ellipse1(int m_id, int id, int left1, int top1, int right1, int bottom1, int color3, int color4, int lineshape, int linewidth)
{
m_Id = m_id;
Id = id;
left = left1;
top = top1;
right = right1;
bottom = bottom1;
color1 = color3;
color2 = color4;
line_shape = lineshape;
line_width = linewidth;
}
void ellipse1::showInfo()
{
cout << "编号:" << m_Id << " ";
cout << "图形种类: " << "4.椭圆"
<< "\t椭圆位置坐标:" << "\t(" << left << "," << top << ")"
<< " " << "(" << right << "," << bottom << ")" << "\t边框颜色:"
<<color1 << "\t填充颜色:"
<<color2 << " 线类型:"
<<line_shape << " 线宽:"
<<line_width;
cout << endl;
}
多边形solidpolygon1.h
#pragma once
#include<iostream>
using namespace std;
#include"shape.h"
class solidpolygon11:public shape
{
public:
solidpolygon11(int m_id,int id, int num1,int m_point1[], int color3, int color4, int lineshape, int linewidth);
void showInfo();
};
多边形solidpolygon1.cpp
#include"solidpolygon1.h"
solidpolygon11::solidpolygon11(int m_id, int id, int num1 , int m_point1[], int color3, int color4, int lineshape, int linewidth)
{
m_Id = m_id;
Id = id;
num = num1;
for (int i = 0; i < 2*num; i++)
{
m_point[i] = m_point1[i];
}
color1 = color3;
color2 = color4;
line_shape = lineshape;
line_width = linewidth;
}
void solidpolygon11::showInfo()
{
cout << "编号:" << m_Id << " ";
cout << "图形种类: " << "6.多边形: " << "边数:" << num << " ";
cout << "\t多边形坐标:";
for (int i = 0; i < 2*num; i += 2)
{
cout << "(" << m_point[i] << "," << m_point[i+ 1] << ")";
};
cout<< "\t线颜色:"
<< color1 << "\t填充颜色:"
<< color2 << " 线类型:"
<< line_shape << " 线宽:"
<< line_width;
cout << endl;
}
折线polyline1.h
#pragma once
#include"shape.h"
using namespace std;
class polyline1 :public shape
{
public:
polyline1(int m_id, int id, int num1, int m_point1[], int color3,int lineshape, int linewidth);
void showInfo();
};
折线polyline1.cpp
#include"polyline1.h"
polyline1::polyline1(int m_id, int id, int num1,int m_point1[], int color3,int lineshape, int linewidth)
{
m_Id = m_id;
Id = id;
num = num1;
for (int i = 0; i < 2 * num; i++)
{
m_point[i] = m_point1[i];
}
color1 = color3;
line_shape = lineshape;
line_width = linewidth;
}
void polyline1::showInfo()
{
cout << "编号:" << m_Id << " ";
cout << "图形种类: " << "7.折线: " << "点数:" << num << " ";
cout << "\t点坐标:";
for (int i = 0; i < 2*num; i+=2)
{
cout << "(" << m_point[i] << "," << m_point[i + 1] << ")";
};
cout << "\t线颜色:"
<< color1 << " 线类型:"
<< line_shape << "线宽:"
<< line_width;
cout << endl;
}
矩形rectangle.h
#pragma once
#include<iostream>
using namespace std;
#include"shape.h"
class rectangle1 :public shape
{
public:
rectangle1(int m_id, int id, int left1, int top1, int right1, int bottom1, int color3, int color4, int lineshape, int linewidth);
void showInfo();
};
矩形rectangle.cpp
#include"rectangle.h"
rectangle1::rectangle1(int m_id, int id, int left2, int top2, int right2, int bottom2, int color3, int color4,int lineshape, int linewidth)
{
m_Id = m_id;
Id = id;
left1 = left2;
top1 = top2;
right1 = right2;
bottom1 = bottom2;
color1 = color3;
color2 = color4;
line_shape = lineshape;
line_width = linewidth;
}
void rectangle1::showInfo()
{
cout << "编号:" << m_Id << " ";
cout << "图形种类: " << "5.矩形"
<< "\t矩形位置坐标:" << "\t(" << left1 << "," << top1 << ")" << " "
<< "(" << right1 << "," << bottom1 << ")" << "\t边框颜色:"
<< color1 << "\t填充颜色:"
<< color2 << " 线类型:"
<< line_shape << " 线宽:"
<< line_width;
cout << endl;
}
图形类graph.h完成功能的部分
#pragma once
#include<iostream>
using namespace std;
#include <graphics.h>
#include <conio.h>
#include"shape.h"
#include"Circle.h"
#include"ellipse.h"
#include"Line.h"
#include"rectangle.h"
#include"point.h"
#include"solidpolygon1.h"
#include"polyline1.h"
#include<fstream>
#define FILENAME "empFile.txt"
class Graph
{
public:
Graph();
static int count;
int m_graphNum;
bool m_FileIsEmpty;
int get_graphNum();
void init_graph();
void show_menu();
void show_graph();
int isExist(int id);
void Find_graph();
void Mod_graph();
void del_graph();
void draw_graph();
void drawline(int x, int y, int n);
void Setlinestyle(int linestyle1, int linewidth1);
void Setlinecolor(int n);
void Setfillcolor(int n);
void exitsystem();
void save();
shape** m_graphArray;
void add_graph();
void showcolor();
void lineshapewidth();
void clear_File();
~Graph();
};
图形类graph.cpp完成功能的部分 函数体实现部分
#include "graph.h"
int Graph::count = 1;
Graph::Graph()
{
ifstream ifs;
ifs.open(FILENAME, ios::in);
if (!ifs.is_open())
{
cout << "文件不存在!" << endl;
m_graphNum = 0;
m_FileIsEmpty = true;
m_graphArray = NULL;
ifs.close();
return;
}
char ch;
ifs >> ch;
if (ifs.eof())
{
cout << "您的图形系统为空!添加请按1!" << endl;
m_graphNum = 0;
m_graphArray = NULL;
m_FileIsEmpty = true;
ifs.close();
return;
}
int num = get_graphNum();
m_graphNum = num;
m_graphArray = new shape * [m_graphNum];
init_graph();
}
void Graph::show_menu()
{
cout << "********************************" << endl;
cout << "****欢迎使用矢量图处理系统******" << endl;
cout << "********0.退出管理系统**********" << endl;
cout << "********1.添加矢量图形**********" << endl;
cout << "********2.显示图形信息**********" << endl;
cout << "********3.画出矢量图形**********" << endl;
cout << "********4.按照编号查找图形******" << endl;
cout << "********5.修改图形信息**********" << endl;
cout << "********6.按编号删除图形********" << endl;
cout << "********7.清空图形文件**********" << endl;
cout << "********************************" << endl;
cout << endl;
}
void Graph::add_graph()
{
cout << "请输入添加图形的数量" << endl;
int addnum = 0;
cin >> addnum;
if (addnum > 0)
{
int newsize = m_graphNum + addnum;
shape** newspace = new shape * [newsize];
if (m_graphArray != NULL)
{
for (int i = 0; i < m_graphNum; i++)
{
newspace[i] = m_graphArray[i];
}
}
for (int i = 0; i < addnum; i++)
{
cout << "请输入添加的第" << i + 1 << "个图形" << endl;
cout << "1.点" << endl;
cout << "2.直线" << endl;
cout << "3.圆" << endl;
cout << "4.椭圆" << endl;
cout << "5.矩形" << endl;
cout << "6.多边形" << endl;
cout << "7.折线" << endl;
int id;
cin >> id;
shape* w = NULL;
if (id == 1)
{
int m_id;
m_id = count;
int x1, y1;
int color1, color2;
cout << "请输入点参数" << endl;
cout << "第一个点 ";
cin >> x1 >> y1;
showcolor();
cin >> color1;
w = new point1(m_id,id, x1, y1,color1);
count++;
}
else if (id == 2)
{
int m_id;
m_id = count;
int x1, x2;
int y1, y2;
int color1, color2;
int lineshape, linewidth;
cout << "请输入直线的两个点参数" << endl;
cout << "第一个点 ";
cin >> x1 >> y1;
cout << "第二个点 ";
cin >> x2 >> y2;
showcolor();
cin >> color1;
lineshapewidth();
cin >> lineshape >> linewidth;
w = new Line1(m_id,id, x1, y1, x2, y2,color1,lineshape, linewidth);
count++;
}
else if (id == 3)
{
int m_id;
m_id = count;
int x, y;
int radius;
int color1, color2;
int lineshape, linewidth;
cout << "请输入圆的圆心 " << endl;
cin >> x >> y;
cout << "半径 ";
cin >> radius;
showcolor();
cin >> color1 >> color2;
lineshapewidth();
cin >> lineshape >> linewidth;
w = new circle1(m_id,id, x, y, radius, color1, color2, lineshape, linewidth);
count++;
}
else if (id == 4)
{
int m_id;
m_id = count;
int x1, x2;
int y1, y2;
int color1, color2;
int lineshape, linewidth;
cout << "请输入椭圆的两个点参数" << endl;
cout << "第一个点 ";
cin >> x1 >> y1;
cout << "第二个点 ";
cin >> x2 >> y2;
showcolor();
cin >> color1 >> color2;
lineshapewidth();
cin >> lineshape >> linewidth;
w = new ellipse1(m_id,id, x1, y1, x2, y2, color1, color2, lineshape, linewidth);
count++;
}
else if (id == 5)
{
int m_id;
m_id = count;
int left, top, right, bottom;
int color1, color2;
int lineshape, linewidth;
cout << "请输入矩形的两点参数" << endl;
cout << "请输入第一个点 ";
cin >> left >> top;
cout << "第二个点 ";
cin >> right >> bottom;
showcolor();
cin >> color1 >> color2;
lineshapewidth();
cin >> lineshape >> linewidth;
w = new rectangle1(m_id,id, left, top, right, bottom, color1, color2, lineshape, linewidth);
count++;
}
else if (id == 6)
{
int m_id;
m_id = count;
int num1;
int m_point1[50]= { 0 };
int color1, color2;
int lineshape, linewidth;
cout << "请输入多边形的点数:" << endl;
cin >> num1;
int index1 = 1;
for (int j = 0; j < 2 * num1; j += 2)
{
cout << "第"<<index1<< "个点的x坐标: ";
cin >> m_point1[j];
cout << "第" <<index1<< "个点的y坐标: ";
cin >> m_point1[j+1];
index1++;
}
showcolor();
cin >> color1 >> color2;
lineshapewidth();
cin >> lineshape >> linewidth;
w = new solidpolygon11(m_id,id,num1,m_point1,color1,color2,lineshape,linewidth);
count++;
}
else if (id == 7)
{
int m_id;
m_id = count;
int num1;
int m_point1[100] = { 0 };
int color1;
int lineshape, linewidth;
cout << "请输入折线的点数:" << endl;
cin >> num1;
int index1 = 1;
for (int j = 0; j < 2 * num1; j += 2)
{
cout << "第" << index1 << "个点的x坐标: ";
cin >> m_point1[j];
cout << "第" << index1 << "个点的y坐标: ";
cin >> m_point1[j + 1];
index1++;
}
showcolor();
cin >> color1;
lineshapewidth();
cin >> lineshape >> linewidth;
w = new polyline1(m_id,id, num1, m_point1, color1, lineshape, linewidth);
count++;
}
newspace[m_graphNum + i] = w;
}
delete[]m_graphArray;
m_graphArray = newspace;
m_graphNum = newsize;
m_FileIsEmpty = false;
cout << "成功添加" << addnum << "个图形" << endl;
save();
}
else
{
cout << "输入有误!" << endl;
}
system("pause");
system("cls");
}
void Graph::save()
{
ofstream ofs;
ofs.open(FILENAME, ios::out);
for (int i = 0; i < m_graphNum; i++)
{
if (m_graphArray[i]->Id == 1)
{
ofs << m_graphArray[i]->Id << " "
<< m_graphArray[i]->x << " "
<< m_graphArray[i]->y <<" "
<<m_graphArray[i]->color1<<" "
<< m_graphArray[i]->m_Id << " "
<< endl;
}
if (m_graphArray[i]->Id == 2)
{
ofs << m_graphArray[i]->Id << " ";
ofs << m_graphArray[i]->m_x1 << " ";
ofs << m_graphArray[i]->m_y1 << " ";
ofs << m_graphArray[i]->m_x2 << " ";
ofs << m_graphArray[i]->m_y2 << " ";
ofs << m_graphArray[i]->color1 << " ";
ofs << m_graphArray[i]->line_shape << " ";
ofs << m_graphArray[i]->line_width << " ";
ofs << m_graphArray[i]->m_Id << " ";
ofs << endl;
}
if (m_graphArray[i]->Id == 3)
{
ofs << m_graphArray[i]->Id << " "
<< m_graphArray[i]->m_x << " "
<< m_graphArray[i]->m_y << " "
<< m_graphArray[i]->radius << " "
<< m_graphArray[i]->color1 << " "
<< m_graphArray[i]->color2 << " "
<< m_graphArray[i]->line_shape << " "
<< m_graphArray[i]->line_width << " "
<< m_graphArray[i]->m_Id << " "
<< endl;
}
if (m_graphArray[i]->Id == 4)
{
ofs << m_graphArray[i]->Id << " "
<< m_graphArray[i]->left << " "
<< m_graphArray[i]->top << " "
<< m_graphArray[i]->right << " "
<< m_graphArray[i]->bottom << " "
<< m_graphArray[i]->color1 << " "
<< m_graphArray[i]->color2<<" "
<< m_graphArray[i]->line_shape << " "
<< m_graphArray[i]->line_width << " "
<< m_graphArray[i]->m_Id << " "
<<endl;
}
if (m_graphArray[i]->Id == 5)
{
ofs << m_graphArray[i]->Id << " "
<< m_graphArray[i]->left1 << " "
<< m_graphArray[i]->top1 << " "
<< m_graphArray[i]->right1 << " "
<< m_graphArray[i]->bottom1 << " "
<< m_graphArray[i]->color1 << " "
<< m_graphArray[i]->color2 << " "
<< m_graphArray[i]->line_shape << " "
<< m_graphArray[i]->line_width << " "
<< m_graphArray[i]->m_Id << " "
<< endl;
}
if (m_graphArray[i]->Id == 6)
{
ofs << m_graphArray[i]->Id << " ";
ofs << m_graphArray[i]->num << " ";
for (int j = 0; j < 2 * m_graphArray[i]->num; j += 2)
{
ofs << m_graphArray[i]->m_point[j] << " "
<< m_graphArray[i]->m_point[j + 1] << " ";
};
ofs<< m_graphArray[i]->color1 << " "
<< m_graphArray[i]->color2 << " "
<< m_graphArray[i]->line_shape << " "
<< m_graphArray[i]->line_width << " "
<< m_graphArray[i]->m_Id << " "
<< endl;
}
if (m_graphArray[i]->Id ==7)
{
ofs << m_graphArray[i]->Id << " ";
ofs << m_graphArray[i]->num << " ";
for (int j = 0; j < 2 * m_graphArray[i]->num; j += 2)
{
ofs << m_graphArray[i]->m_point[j] << " "
<< m_graphArray[i]->m_point[j + 1] << " ";
};
ofs << m_graphArray[i]->color1 << " "
<< m_graphArray[i]->line_shape << " "
<< m_graphArray[i]->line_width << " "
<< m_graphArray[i]->m_Id << " "
<< endl;
}
}
ofs.close();
}
int Graph::isExist(int id)
{
int index = -1;
for (int i = 0; i < m_graphNum; i++)
{
if (m_graphArray[i]->m_Id == id)
{
index = i;
break;
}
}
return index;
}
void Graph::Find_graph()
{
if (m_FileIsEmpty)
{
cout << "文件不存在或者为空!" << endl;
}
else
{
int Fid;
cout << "请输入要查找图形的编号!" << endl;
cin >> Fid;
int ret = isExist(Fid);
if (ret != -1)
{
cout << "查找成功!该图形的信息如下: " << endl;
m_graphArray[ret]->showInfo();
}
else
{
cout << "查找失败!没有此图!" << endl;
}
}
system("pause");
system("cls");
}
void Graph::Mod_graph()
{
if (m_FileIsEmpty)
{
cout << "文件不存在或者为空!" << endl;
}
else
{
cout << "请输入修改图形的编号!" << endl;
show_graph();
int Mid;
cin >> Mid;
int ret = isExist(Mid);
if (ret != -1)
{
int select = 0;
cout << " 1.修改颜色线性和线宽信息 2.修改这个图形的全部信息\n";
cin >> select;
if (select == 1)
{
if (m_graphArray[ret]->Id == 1)
{
cout << "你要修改的是点,请输入要修改点的颜色:" << endl;
int color;
showcolor();
cin >> color;
m_graphArray[ret]->color1 = color;
}
if (m_graphArray[ret]->Id == 2)
{
cout << "你要修改的是线,请输入要修改点的属性:" << endl;
int n=1;
cout << "要修改线的颜色请输入0" << endl;
cin >> n;
if (n == 0)
{
showcolor();
int change_color = 0;
m_graphArray[ret]->color1 == change_color;
n = 1;
}
cout << "要更改线的类型请输入0\n";
cin >> n;
if (n == 0)
{
lineshapewidth();
int change_shape = 0;
cin >> change_shape;
m_graphArray[ret]->line_shape = change_shape;
n = 1;
}
cout << "要更改线的宽度请输入0\n";
cin >> n;
if (n == 0)
{
cout << "请输入线的宽度:" << endl;
int change_width = 0;
cin >> change_width;
m_graphArray[ret]->line_width = change_width;
n = 1;
}
}
if (m_graphArray[ret]->Id == 3)
{
cout << "你要修改的是圆,请输入要修改点的属性:" << endl;
int n = 1;
cout << "要修改圆线的颜色请输入0\n" << endl;
cin >> n;
if (n == 0)
{
showcolor();
int change_color = 0;
m_graphArray[ret]->color1 == change_color;
n = 1;
}
cout << "要修改圆的填充颜色请输入0\n" << endl;
cin >> n;
if (n == 0)
{
showcolor();
int change_fillcolor = 0;
m_graphArray[ret]->color2 == change_fillcolor;
n = 1;
}
cout << "要更改圆边的类型请输入0\n";
cin >> n;
if (n == 0)
{
lineshapewidth();
int change_shape = 0;
cin >> change_shape;
m_graphArray[ret]->line_shape = change_shape;
n = 1;
}
cout << "要更改圆边线的宽度请输入0\n";
cin >> n;
if (n == 0)
{
cout << "请输入圆边线的宽度:" << endl;
int change_width = 0;
cin >> change_width;
m_graphArray[ret]->line_width = change_width;
n = 1;
}
}
if (m_graphArray[ret]->Id == 4)
{
cout << "你要修改的是椭圆,请输入要修改点的属性:" << endl;
int n = 1;
cout << "要修改椭圆线的颜色请输入0\n" << endl;
cin >> n;
if (n == 0)
{
showcolor();
int change_color = 0;
m_graphArray[ret]->color1 == change_color;
n = 1;
}
cout << "要修改椭圆的填充颜色请输入0\n" << endl;
cin >> n;
if (n == 0)
{
showcolor();
int change_fillcolor = 0;
m_graphArray[ret]->color2 == change_fillcolor;
n = 1;
}
cout << "要更改椭圆边的类型请输入0\n";
cin >> n;
if (n == 0)
{
lineshapewidth();
int change_shape = 0;
cin >> change_shape;
m_graphArray[ret]->line_shape = change_shape;
n = 1;
}
cout << "要更改椭圆边线的宽度请输入0\n";
cin >> n;
if (n == 0)
{
cout << "请输入椭圆边线的宽度:" << endl;
int change_width = 0;
cin >> change_width;
m_graphArray[ret]->line_width = change_width;
n = 1;
}
}
if (m_graphArray[ret]->Id == 5)
{
cout << "你要修改的是矩形,请输入要修改点的属性:" << endl;
int n = 1;
cout << "要修改矩形线的颜色请输入0\n" << endl;
cin >> n;
if (n == 0)
{
showcolor();
int change_color = 0;
m_graphArray[ret]->color1 == change_color;
n = 1;
}
cout << "要修改矩形的填充颜色请输入0\n" << endl;
cin >> n;
if (n == 0)
{
showcolor();
int change_fillcolor = 0;
m_graphArray[ret]->color2 == change_fillcolor;
n = 1;
}
cout << "要更改矩形边的类型请输入0\n";
cin >> n;
if (n == 0)
{
lineshapewidth();
int change_shape = 0;
cin >> change_shape;
m_graphArray[ret]->line_shape = change_shape;
n = 1;
}
cout << "要更改矩形边线的宽度请输入0\n";
cin >> n;
if (n == 0)
{
cout << "请输入矩形线的宽度:" << endl;
int change_width = 0;
cin >> change_width;
m_graphArray[ret]->line_width = change_width;
n = 1;
}
}
if (m_graphArray[ret]->Id == 6)
{
cout << "你要修改的是多边形,请输入要修改点的属性:" << endl;
int n = 1;
cout << "要修改多边形线的颜色请输入0\n" << endl;
cin >> n;
if (n == 0)
{
showcolor();
int change_color = 0;
m_graphArray[ret]->color1 == change_color;
n = 1;
}
cout << "要修改多边形的填充颜色请输入0\n" << endl;
cin >> n;
if (n == 0)
{
showcolor();
int change_fillcolor = 0;
m_graphArray[ret]->color2 == change_fillcolor;
n = 1;
}
cout << "要更改多边形边的类型请输入0\n";
cin >> n;
if (n == 0)
{
lineshapewidth();
int change_shape = 0;
cin >> change_shape;
m_graphArray[ret]->line_shape = change_shape;
n = 1;
}
cout << "要更改多边形边线的宽度请输入0\n";
cin >> n;
if (n == 0)
{
cout << "请输入多边形线的宽度:" << endl;
int change_width = 0;
cin >> change_width;
m_graphArray[ret]->line_width = change_width;
n = 1;
}
}
if (m_graphArray[ret]->Id == 7)
{
cout << "你要修改的是折线,请输入要修改折线的属性:" << endl;
int n = 1;
cout << "要修改折线的颜色请输入0\n" << endl;
cin >> n;
if (n == 0)
{
showcolor();
int change_color = 0;
m_graphArray[ret]->color1 == change_color;
n = 1;
}
cout << "要更改折线的类型请输入0\n";
cin >> n;
if (n == 0)
{
lineshapewidth();
int change_shape = 0;
cin >> change_shape;
m_graphArray[ret]->line_shape = change_shape;
n = 1;
}
cout << "要更改多边形折线的宽度请输入0\n";
cin >> n;
if (n == 0)
{
cout << "请输入折线的宽度:" << endl;
int change_width = 0;
cin >> change_width;
m_graphArray[ret]->line_width = change_width;
n = 1;
}
}
}
else
{
delete m_graphArray[ret];
cout << "请输入修改后的图形种类" << endl;
cout << "1.点" << endl;
cout << "2.直线" << endl;
cout << "3.圆" << endl;
cout << "4.椭圆" << endl;
cout << "5.矩形" << endl;
cout << "6.多边形" << endl;
cout << "7.折线" << endl;
int id;
cin >> id;
shape* w = NULL;
if (id == 1)
{
int x1, y1;
int color1, color2;
cout << "请输入点参数" << endl;
cout << "第一个点 ";
cin >> x1 >> y1;
showcolor();
cin >> color1;
w = new point1(Mid, id, x1, y1, color1);
}
if (id == 2)
{
int x1, x2;
int y1, y2;
int color1, color2;
int lineshape, linewidth;
cout << "请输入直线的两个点参数" << endl;
cout << "第一个点 ";
cin >> x1 >> y1;
cout << "第二个点 ";
cin >> x2 >> y2;
showcolor();
cin >> color1;
lineshapewidth();
cin >> lineshape >> linewidth;
w = new Line1(Mid, id, x1, x2, y1, y2, color1, lineshape, linewidth);
}
if (id == 3)
{
int x, y;
int radius;
int color1, color2;
int lineshape, linewidth;
cout << "请输入圆的圆心 " << endl;
cin >> x >> y;
cout << "半径 ";
cin >> radius;
showcolor();
cin >> color1 >> color2;
lineshapewidth();
cin >> lineshape >> linewidth;
w = new circle1(Mid, id, x, y, radius, color1, color2, lineshape, linewidth);
}
if (id == 4)
{
int x1, x2;
int y1, y2;
int color1, color2;
int lineshape, linewidth;
cout << "请输入椭圆的两个点参数" << endl;
cout << "第一个点 ";
cin >> x1 >> y1;
cout << "第二个点 ";
cin >> x2 >> y2;
showcolor();
cin >> color1 >> color2;
lineshapewidth();
cin >> lineshape >> linewidth;
w = new ellipse1(Mid, id, x1, y1, x2, y2, color1, color2, lineshape, linewidth);
}
if (id == 5)
{
int left, top, right, bottom;
int color1, color2;
int lineshape, linewidth;
cout << "请输入矩形的两点参数" << endl;
cout << "请输入第一个点 ";
cin >> left >> top;
cout << "第二个点 ";
cin >> right >> bottom;
showcolor();
cin >> color1 >> color2;
lineshapewidth();
cin >> lineshape >> linewidth;
w = new rectangle1(Mid, id, left, top, right, bottom, color1, color2, lineshape, linewidth);
}
if (id == 6)
{
int num1;
int m_point1[50] = { 0 };
int color1, color2;
int lineshape, linewidth;
cout << "请输入多边形的边数:" << endl;
cin >> num1;
int index1 = 1;
for (int j = 0; j < 2 * num1; j += 2)
{
cout << "第" << index1 << "个点的x坐标: ";
cin >> m_point1[j];
cout << "第" << index1 << "个点的y坐标: ";
cin >> m_point1[j + 1];
index1++;
}
showcolor();
cin >> color1 >> color2;
lineshapewidth();
cin >> lineshape >> linewidth;
w = new solidpolygon11(Mid, id, num1, m_point1, color1, color2, lineshape, linewidth);
}
if (id == 7)
{
int num1;
int m_point1[100] = { 0 };
int color1;
int lineshape, linewidth;
cout << "请输入折线的点数:" << endl;
cin >> num1;
int index1 = 1;
for (int j = 0; j < 2 * num1; j += 2)
{
cout << "第" << index1 << "个点的x坐标: ";
cin >> m_point1[j];
cout << "第" << index1 << "个点的y坐标: ";
cin >> m_point1[j + 1];
index1++;
}
showcolor();
cin >> color1;
lineshapewidth();
cin >> lineshape >> linewidth;
w = new polyline1(Mid, id, num1, m_point1, color1, lineshape, linewidth);
}
m_graphArray[ret] = w;
cout << "修改成功!" << endl;
}
save();
}
else
{
cout << " 修改失败,查无此人!" << endl;
}
}
system("pause");
system("cls");
}
void Graph::del_graph()
{
if (m_FileIsEmpty)
{
cout << "文件不存在或记录为空" << endl;
}
else
{
cout << "请输入想要删除的图形编号" << endl;
cout << "你共有以下图形!" << endl;
show_graph();
int id = 0;
cin >> id;
int index = isExist(id);
if (index != -1)
{
for (int i = index; i < m_graphNum; i++)
{
m_graphArray[i] = m_graphArray[i + 1];
}
m_graphNum--;
save();
cout << "删除成功" << endl;
}
else
{
cout << "删除失败,未找到该职工!" << endl;
}
}
system("pause");
system("cls");
}
void Graph::init_graph()
{
ifstream ifs;
ifs.open(FILENAME, ios::in);
int m_id;
int id ;
int x = 0, y = 0;
int m_x1 = 0, m_x2 = 0;
int m_y1 = 0, m_y2 = 0;
int m_x = 0, m_y = 0;
int radius = 0;
int left = 0;
int top = 0;
int right = 0;
int bottom = 0;
int left1 = 0;
int top1 = 0;
int right1 = 0;
int bottom1 = 0;
int color1=0, color2=0;
int lineshape = 0, linewidth = 0;
int num1 = 0;
int m_point1[100] = { 0 };
int index = 0;
while (ifs >> id)
{
shape* w= NULL;
if (id == 1)
{
ifs >> x; ifs >> y;
ifs >> color1;
ifs >> m_id;
w = new point1(m_id,id, x, y,color1);
}
if (id == 2)
{
ifs >> m_x1;ifs >> m_y1;
ifs >> m_x2; ifs >> m_y2;
ifs >> color1;
ifs >> lineshape; ifs >> linewidth;
ifs >> m_id;
w = new Line1(m_id,id, m_x1, m_y1, m_x2, m_y2, color1, lineshape, linewidth);
}
if (id == 3)
{
ifs >> m_x; ifs >> m_y;
ifs >> radius;
ifs >> color1; ifs >> color2;
ifs >> lineshape; ifs >> linewidth;
ifs >> m_id;
w = new circle1(m_id,id, m_x, m_y,radius, color1, color2, lineshape, linewidth);
}
if (id == 4)
{
ifs >> left;
ifs >> top;
ifs >> right;
ifs >> bottom;
ifs >> color1; ifs >> color2;
ifs >> lineshape; ifs >> linewidth;
ifs >> m_id;
w = new ellipse1(m_id,id, left, top, right, bottom, color1, color2, lineshape, linewidth);
}
if (id == 5)
{
ifs >> left1;
ifs >> top1;
ifs >> right1;
ifs >> bottom1;
ifs >> color1;
ifs >> color2;
ifs >> lineshape;
ifs >> linewidth;
ifs >> m_id;
w = new rectangle1(m_id,id, left1, top1, right1, bottom1,color1, color2, lineshape, linewidth);
}
if (id == 6)
{
ifs >> num1;
for (int i = 0; i < 2 * num1; i += 2)
{
ifs >> m_point1[i];
ifs >> m_point1[i + 1];
}
ifs >> color1;
ifs >> color2;
ifs >> lineshape;
ifs >> linewidth;
ifs >> m_id;
w = new solidpolygon11(m_id,id, num1, m_point1,color1, color2, lineshape, linewidth);
}
if (id == 7)
{
ifs >> num1;
for (int i = 0; i < 2 * num1; i += 2)
{
ifs >> m_point1[i];
ifs >> m_point1[i + 1];
}
ifs >> color1;
ifs >> lineshape;
ifs >> linewidth;
ifs >> m_id;
w = new polyline1(m_id,id, num1, m_point1, color1, lineshape, linewidth);
}
m_graphArray[index] = w;
index++;
}
count = m_graphArray[m_graphNum - 1]->m_Id+1;
ifs.close();
}
int Graph::get_graphNum()
{
ifstream ifs;
ifs.open(FILENAME, ios::in);
int m_id;
int Id = 0;
int x = 0, y = 0;
int m_x1 = 0, m_x2 = 0;
int m_y1 = 0, m_y2 = 0;
int m_x = 0, m_y = 0;
int radius = 0;
int left = 0;
int top = 0;
int right = 0;
int bottom = 0;
int left1 = 0;
int top1 = 0;
int right1 = 0;
int bottom1 = 0;
int color1=0, color2=0;
int lineshape = 0, linewidth = 0;
int num1 = 0;
int m_point1[50] = { 0 };
int num = 0;
while (ifs >> Id)
{
if (Id == 1)
{
ifs >> x; ifs >> y;
ifs >> color1;
ifs >> m_id;
num++;
}
if (Id == 2)
{
ifs >> m_x1; ifs >> m_y1;
ifs >> m_x2; ifs >> m_y2;
ifs >> color1;
ifs >> lineshape;
ifs >> linewidth;
ifs >> m_id;
num++;
}
if (Id == 3)
{
ifs >> m_x; ifs >> m_y;
ifs >> radius;
ifs >> color1;
ifs >> color2;
ifs >> lineshape;
ifs >> linewidth;
ifs >> m_id;
num++;
}
if (Id == 4)
{
ifs >> left;
ifs >> top;
ifs >> right;
ifs >> bottom;
ifs >> color1;
ifs >> color2;
ifs >> lineshape;
ifs >> linewidth;
ifs >> m_id;
num++;
}
if (Id == 5)
{
ifs >> left1;
ifs >> top1;
ifs >> right1;
ifs >> bottom1;
ifs >> color1;
ifs >> color2;
ifs >> lineshape;
ifs >> linewidth;
ifs >> m_id;
num++;
}
if (Id == 6)
{
ifs >> num1;
for (int i = 0; i < 2 * num1; i += 2)
{
ifs >> m_point1[i];
ifs >> m_point1[i + 1];
}
ifs >> color1;
ifs >> color2;
ifs >> lineshape;
ifs >> linewidth;
ifs >> m_id;
num++;
}
if (Id == 7)
{
ifs >> num1;
for (int i = 0; i < 2 * num1; i += 2)
{
ifs >> m_point1[i];
ifs >> m_point1[i + 1];
}
ifs >> color1;
ifs >> lineshape;
ifs >> linewidth;
ifs >> m_id;
num++;
}
}
return num;
}
void Graph::show_graph()
{
if (m_FileIsEmpty)
{
cout << "文件存在或记录为空!" << endl;
}
else
{
int num = get_graphNum();
m_graphNum = num;
cout << "文件中的图形的数量为:" << num << endl;
m_graphArray = new shape * [m_graphNum];
init_graph();
for (int i = 0; i < m_graphNum; i++)
{
m_graphArray[i]->showInfo();
}
}
}
void Graph::draw_graph()
{
if (m_FileIsEmpty)
{
cout << "文件存在或记录为空!" << endl;
}
else
{
int num = get_graphNum();
m_graphNum = num;
cout << "文件中的图形的数量为:" << num << endl;
m_graphArray = new shape * [m_graphNum];
init_graph();
cout << "选择是否填充" << endl;
cout << "1.不填充" << endl;
cout << "2.填充" << endl;
int select = 0;
cin >> select;
initgraph(1200, 600);
setbkcolor(WHITE);
cleardevice();
if(select==1)
{
for (int i = 0; i < m_graphNum; i++)
{
if (m_graphArray[i]->Id == 1)
{
drawline(m_graphArray[i]->m_x, m_graphArray[i]->m_y, m_graphArray[i]->color1);
}
if (m_graphArray[i]->Id == 2)
{
Setlinestyle(m_graphArray[i]->line_shape, m_graphArray[i]->line_width);
Setlinecolor(m_graphArray[i]->color1);
line(m_graphArray[i]->m_x1, m_graphArray[i]->m_y1, m_graphArray[i]->m_x2, m_graphArray[i]->m_y2);
}
if (m_graphArray[i]->Id == 3)
{
Setlinestyle(m_graphArray[i]->line_shape, m_graphArray[i]->line_width);
Setfillcolor(m_graphArray[i]->color2);
Setlinecolor(m_graphArray[i]->color1);
fillcircle(m_graphArray[i]->m_x, m_graphArray[i]->m_y, m_graphArray[i]->radius);
}
if (m_graphArray[i]->Id == 4)
{
Setlinestyle(m_graphArray[i]->line_shape, m_graphArray[i]->line_width);
Setfillcolor(m_graphArray[i]->color2);
Setlinecolor(m_graphArray[i]->color1);
fillellipse(m_graphArray[i]->left, m_graphArray[i]->top, m_graphArray[i]->right, m_graphArray[i]->bottom);
}
if (m_graphArray[i]->Id == 5)
{
Setlinestyle(m_graphArray[i]->line_shape, m_graphArray[i]->line_width);
Setfillcolor(m_graphArray[i]->color2);
Setlinecolor(m_graphArray[i]->color1);
fillrectangle(m_graphArray[i]->left1, m_graphArray[i]->top1, m_graphArray[i]->right1, m_graphArray[i]->bottom1);
}
if (m_graphArray[i]->Id == 6)
{
Setlinestyle(m_graphArray[i]->line_shape, m_graphArray[i]->line_width);
Setfillcolor(m_graphArray[i]->color2);
Setlinecolor(m_graphArray[i]->color1);
fillpolygon((POINT*)(m_graphArray[i]->m_point), m_graphArray[i]->num);
}
if (m_graphArray[i]->Id == 7)
{
Setlinestyle(m_graphArray[i]->line_shape, m_graphArray[i]->line_width);
Setlinecolor(m_graphArray[i]->color1);
polyline((POINT*)(m_graphArray[i]->m_point),m_graphArray[i]->num);
}
}
}
else
{
for (int i = 0; i < m_graphNum; i++)
{
if (m_graphArray[i]->Id == 1)
{
drawline(m_graphArray[i]->m_x, m_graphArray[i]->m_y, m_graphArray[i]->color1);
}
if (m_graphArray[i]->Id == 2)
{
Setlinestyle(m_graphArray[i]->line_shape, m_graphArray[i]->line_width);
Setlinecolor(m_graphArray[i]->color1);
line(m_graphArray[i]->m_x1, m_graphArray[i]->m_y1, m_graphArray[i]->m_x2, m_graphArray[i]->m_y2);
}
if (m_graphArray[i]->Id == 3)
{
Setlinestyle(m_graphArray[i]->line_shape, m_graphArray[i]->line_width);
Setlinecolor(m_graphArray[i]->color1);
IMAGE image;
loadimage(&image, _T(".\\image.jpg"),2*(m_graphArray[i]->radius),2* (m_graphArray[i]->radius));
putimage((m_graphArray[i]->m_x) - (m_graphArray[i]->radius), (m_graphArray[i]->m_y) - (m_graphArray[i]->radius), &image);
circle(m_graphArray[i]->m_x, m_graphArray[i]->m_y, m_graphArray[i]->radius);
}
if (m_graphArray[i]->Id == 4)
{
Setlinestyle(m_graphArray[i]->line_shape, m_graphArray[i]->line_width);
Setlinecolor(m_graphArray[i]->color1);
IMAGE image;
loadimage(&image, _T(".\\image.jpg"), m_graphArray[i]->right-m_graphArray[i]->left, m_graphArray[i]->bottom-m_graphArray[i]->top);
putimage(m_graphArray[i]->left, m_graphArray[i]->top, &image);
ellipse(m_graphArray[i]->left, m_graphArray[i]->top, m_graphArray[i]->right, m_graphArray[i]->bottom);
}
if (m_graphArray[i]->Id == 5)
{
Setlinestyle(m_graphArray[i]->line_shape, m_graphArray[i]->line_width);
Setlinecolor(m_graphArray[i]->color1);
IMAGE image;
loadimage(&image, _T(".\\image.jpg"), m_graphArray[i]->right1 - m_graphArray[i]->left1, m_graphArray[i]->bottom1 - m_graphArray[i]->top1);
putimage(m_graphArray[i]->left1, m_graphArray[i]->top1, &image);
rectangle(m_graphArray[i]->left1, m_graphArray[i]->top1, m_graphArray[i]->right1,m_graphArray[i]->right1);
}
if (m_graphArray[i]->Id == 6)
{
Setlinestyle(m_graphArray[i]->line_shape, m_graphArray[i]->line_width);
Setfillcolor(m_graphArray[i]->color2);
Setlinecolor(m_graphArray[i]->color1);
IMAGE image;
loadimage(&image, _T(".\\image.jpg"));
polygon((POINT*)(m_graphArray[i]->m_point), m_graphArray[i]->num);
}
if (m_graphArray[i]->Id == 7)
{
Setlinestyle(m_graphArray[i]->line_shape, m_graphArray[i]->line_width);
Setlinecolor(m_graphArray[i]->color1);
polyline((POINT*)(m_graphArray[i]->m_point), m_graphArray[i]->num);
}
}
}
_getch();
}
}
void Graph::exitsystem()
{
cout << "欢迎下次使用!" << endl;
system("pause");
exit(0);
}
void Graph::showcolor()
{
cout << "请选择边框颜色和填充颜色,不封闭图形仅输入线条颜色\n";
cout << setw(15) << "黑色" << setw(10) << "0\n"
<< setw(15) << "蓝色" << setw(10) << "1\n"
<< setw(15) << "绿色" << setw(10) << "2\n"
<< setw(15) << "蓝绿色" << setw(10) << "3\n"
<< setw(15) << "红色" << setw(10) << "4\n"
<< setw(15) << "洋红" << setw(10) << "5\n"
<< setw(15) << "棕色" << setw(10) << "6\n"
<< setw(15) << "浅灰色" << setw(10) << "7\n"
<< setw(15) << "深灰" << setw(10) << "8\n"
<< setw(15) << "浅蓝" << setw(10) << "9\n"
<< setw(15) << "浅绿" << setw(10) << "10\n"
<< setw(15) << "浅青" << setw(10) << "11\n"
<< setw(15) << "浅红" << setw(10) << "12\n"
<< setw(15) << "浅品红色" << setw(10) << "13\n"
<< setw(15) << "黄" << setw(10) << "14\n"
<< setw(15) << "白" << setw(10) << "15\n";
}
void Graph::lineshapewidth()
{
cout << "请选择线型和输入线宽\n";
cout << setw(15) << "实线" << setw(10) << "0\n"
<< setw(15) << "--------" << setw(10) << "1\n"
<< setw(15) << "…………" << setw(10) << "2\n"
<< setw(15) << "_._._." << setw(10) << "3\n"
<< setw(15) << "_.._.._.." << setw(10) << "4\n"
<< setw(15) << "线线不可见" << setw(10) << "5\n";
}
void Graph::Setlinecolor(int n)
{
switch (n)
{
case 0:setlinecolor(BLACK); break;
case 1:setlinecolor(BLUE); break;
case 2:setlinecolor(GREEN); break;
case 3:setlinecolor(CYAN); break;
case 4:setlinecolor(RED); break;
case 5:setlinecolor(MAGENTA); break;
case 6:setlinecolor(BROWN); break;
case 7:setlinecolor(LIGHTGRAY); break;
case 8:setlinecolor(DARKGRAY); break;
case 9:setlinecolor(LIGHTBLUE); break;
case 10:setlinecolor(LIGHTGREEN); break;
case 11:setlinecolor(LIGHTCYAN); break;
case 12:setlinecolor(LIGHTRED); break;
case 13:setlinecolor(LIGHTMAGENTA);
case 14:setlinecolor(YELLOW);
case 15:setlinecolor(WHITE);
default:cout << "error";
break;
}
}
void Graph::Setfillcolor(int n)
{
switch (n)
{
case 0:setfillcolor(BLACK); break;
case 1:setfillcolor(BLUE); break;
case 2:setfillcolor(GREEN); break;
case 3:setfillcolor(CYAN); break;
case 4:setfillcolor(RED); break;
case 5:setfillcolor(MAGENTA); break;
case 6:setfillcolor(BROWN); break;
case 7:setfillcolor(LIGHTGRAY); break;
case 8:setfillcolor(DARKGRAY); break;
case 9:setfillcolor(LIGHTBLUE); break;
case 10:setfillcolor(LIGHTGREEN); break;
case 11:setfillcolor(LIGHTCYAN); break;
case 12:setfillcolor(LIGHTRED); break;
case 13:setfillcolor(LIGHTMAGENTA);
case 14:setfillcolor(YELLOW);
case 15:setfillcolor(WHITE);
default:cout << "error";
break;
}
}
void Graph::Setlinestyle(int linestyle1, int linewidth1)
{
switch (linestyle1)
{
case 0:setlinestyle(PS_SOLID,linewidth1); break;
case 1:setlinestyle(PS_DASH,linewidth1); break;
case 2:setlinestyle(PS_DOT,linewidth1); break;
case 3:setlinestyle(PS_DASHDOT,linewidth1); break;
case 4:setlinestyle(PS_DASHDOTDOT,linewidth1); break;
case 5:setlinestyle(PS_NULL,linewidth1); break;
default:cout << "error";
break;
}
}
void Graph::drawline(int x,int y,int n)
{
switch (n)
{
case 0:putpixel(x,y,BLACK); break;
case 1:putpixel(x, y, BLUE); break;
case 2:putpixel(x, y, GREEN); break;
case 3:putpixel(x, y, CYAN); break;
case 4:putpixel(x, y, RED); break;
case 5:putpixel(x, y, MAGENTA); break;
case 6:putpixel(x, y, BROWN); break;
case 7:putpixel(x, y, LIGHTGRAY); break;
case 8:putpixel(x, y, DARKGRAY); break;
case 9:putpixel(x, y, LIGHTBLUE); break;
case 10:putpixel(x, y, LIGHTGREEN); break;
case 11:putpixel(x, y, LIGHTCYAN); break;
case 12:putpixel(x, y, LIGHTRED); break;
case 13:putpixel(x, y, LIGHTMAGENTA);
case 14:putpixel(x, y, YELLOW);
case 15:putpixel(x, y, WHITE);
default:cout << "error";
break;
}
}
void Graph::clear_File()
{
cout << "确定清空吗?" << endl;
cout << "1、确定" << endl;
cout << "2、返回" << endl;
int select = 0;
cin >> select;
if (select == 1)
{
ofstream ofs(FILENAME, ios::trunc);
ofs.close();
if (m_graphArray!= NULL)
{
for (int i = 0; i < m_graphNum; i++)
{
delete m_graphArray[i];
m_graphArray[i] = NULL;
}
delete m_graphArray;
m_graphArray = NULL;
m_graphNum = 0;
m_FileIsEmpty = true;
}
cout << "清空成功!" << endl;
}
system("pause");
system("cls");
}
Graph::~Graph()
{
if (m_graphArray != NULL)
{
for (int i = 0; i < m_graphNum; i++)
{
if (m_graphArray[i]!= NULL)
{
delete m_graphArray[i];
}
}
delete[]m_graphArray;
m_graphArray = NULL;
}
}
矢量管理系统.cpp 用户输入选择部分
#include<iostream>
using namespace std;
#include <graphics.h>
#include <conio.h>
#include"graph.h"
#include"Line.h"
#include"shape.h"
#include"Circle.h"
#include"ellipse.h"
#include"rectangle.h"
#include"solidpolygon1.h"
#include"polyline1.h"
int main()
{
Graph wm;
int choice = 0;
while (true)
{
wm.show_menu();
cout << "请输入您的选择" << endl;
cin >> choice;
switch (choice)
{
case 0:
wm.exitsystem();
break;
case 1:
wm.add_graph();
break;
case 2:
wm.show_graph();
break;
case 3:
wm.draw_graph();
break;
break;
case 4:
wm.Find_graph();
break;
case 5:
wm.Mod_graph();
break;
case 6:
wm.del_graph();
break;
case 7:
wm.clear_File();
break;
default:
system("cls");
break;
}
}
return 0;
}

  
大一以来写代码最长的一次,将近两千行。
有很多缺点就是,画图形只能先输入图形数据,然后再画出图形,画图界面与输入数据界面不能同时存在。
其中如果输入错误数据也可能使程序崩掉,也有许多的错误。
慢慢完善!
|