IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> C++知识库 -> c++ easyx简单矢量管理系统大一下课程设计 -> 正文阅读

[C++知识库]c++ easyx简单矢量管理系统大一下课程设计

一级标题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:
	/*int m_x,m_y;
	int radius;*/
	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:
    /*int m_x1,m_x2;
    int m_y1,m_y2;*/
    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:
	/*int left;
	int top;
	int right;
	int bottom;*/
	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:
	/*int left;
	int top;
	int right;
	int bottom;*/
	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();//显示图形信息

	//void sort_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();//将文件中的数据保存在数组中
	
	//show_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 << "********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();
}

//按照编号排序
//void Graph::sort_graph()
//{
//	if (m_FileIsEmpty)
//	{
//		cout << "文件不存在或为空!" << endl;
//		system("pause");
//		system("cls");
//	}
//	else
//	{
//		for (int i = 0; i < m_graphNum; i++)
//		{
//			int max = i;
//			for (int j = i + 1; j < m_graphNum; j++)
//			{
//				if (m_graphArray[max]->m_Id> m_graphArray[j]->m_Id)
//				{
//					max = j;
//				}
//			}
//			if (i != max)
//			{
//				shape* temp = m_graphArray[i];
//				m_graphArray[i] = m_graphArray[max];
//				m_graphArray[max] = temp;
//			}
//		}
//	}
//	cout << "排序成功!排序后的结果为: " << endl;
//	save();   //排序后结果保存在文件中
//
//	show_graph();//展示所有的图形  
//}

//判断图形是否存在
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;//保存修改的种类  1.修改颜色线性和线宽信息  2.修改这个图形的全部信息
			cout << " 1.修改颜色线性和线宽信息  2.修改这个图形的全部信息\n";
			cin >> select;

            //  1.修改颜色线性和线宽信息
			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;
					}
				}
			}
			//  2.修改这个图形的全部信息
            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)//说明图形存在并且要删除index位置上的图形
		{
			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()
{
	/*
	 point* w =  new line(1, 2, 3, 4);  //测试代码
	 w->showinfo();
	 delete w;
	 */
	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;
		//case 4:  //按照图形编号把图形排序
		//	wm.sort_graph();
			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;
}

这是我存在系统中的图形数据,按2可以显示

可选择是否填充
不填充
填充

大一以来写代码最长的一次,将近两千行。

有很多缺点就是,画图形只能先输入图形数据,然后再画出图形,画图界面与输入数据界面不能同时存在。

其中如果输入错误数据也可能使程序崩掉,也有许多的错误。

慢慢完善!

  C++知识库 最新文章
【C++】友元、嵌套类、异常、RTTI、类型转换
通讯录的思路与实现(C语言)
C++PrimerPlus 第七章 函数-C++的编程模块(
Problem C: 算法9-9~9-12:平衡二叉树的基本
MSVC C++ UTF-8编程
C++进阶 多态原理
简单string类c++实现
我的年度总结
【C语言】以深厚地基筑伟岸高楼-基础篇(六
c语言常见错误合集
上一篇文章      下一篇文章      查看所有文章
加:2021-07-15 15:59:28  更:2021-07-15 16:01:51 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/5 11:57:43-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码