There are some bugs in my program.
Polyline Editor:
Using a mouse and keyboard to do polyline editing.
(a) A house in the process of being drawn. The user has just clicked at the position drawn, and a line has been drawn from the previous point to the one designated by the mouse.
(b) Moving a point. The user positions the cursor near the vertex of some polyline, presses down the mouse button, and “drags” the chosen point to some other location before releasing the button. Upon release of the button, the previous lines connected to this point are erased, and new lines are drawn to it.
© A point is deleted from a polyline. The user clicks near the vertex of some polyline, and the two line segments connected to that vertex are erased. Then the two other endpoints of the segments just erased are connected with a line segment.
The functionality of the program should include the following “actions”:
Begin (‘b’) (create a new polyline)
Delete (‘d’) (delete the next point pointed to)
Move (‘m’) (drag the point pointed to to a new location)
Refresh (‘r’) (erase the screen and redraw all the polylines)
Quit (‘q’) (exit from the program)
#include<Windows.h>
#include<gl/glut.h>
#include<math.h>
#include<iostream>
#include<vector>
using namespace std;
int signal;
const int screenWidth = 1200;
const int screenHeight = 800;
const int windowPositionX = 100;
const int windowPositionY = 100;
class Point{
public:
double x;
double y;
Point(double x, double y){
this->x = x;
this->y = y;
}
Point(){
}
};
class Node{
public:
Point p;
Node *next;
Node *last;
Node(Point t):p(t.x, t.y){
next = this;
last = this;
}
};
Node* operateNode;
class List{
public:
Node *head;
int length;
List(){
length = 0;
head = NULL;
}
void push(Point newp){
Node *cur = new Node(newp);
cur->p = newp;
if (this->length == 0){
cur->next = cur;
cur->last = cur;
this->head = cur;
} else{
if (head == NULL)cout << "Impossible !!!!***********" << endl;
cur->last = this->head;
cur->next = this->head->next;
this->head->next->last = cur;
this->head->next = cur;
this->head = cur;
}
this->length++;
}
Node *search(Point p){
Node *cur = this->head;
while (1){
if (cur->p.x == p.x && cur->p.y == p.y){
break;
}
else{
cur = cur->next;
}
}
return cur;
}
void show(){
cout << "this list shows:" << endl;
cout << "head:" << this->head << endl;
Node *curr = this->head;
do{
if (curr == this->head)cout << "H";
cout << "(" << curr->p.x << "," << curr