I am currently creating a program the reads a text file of co-ordinates, puts each x and y co-ords into an array. From this I perform some calculations with them and finally the co-ordinates need plotting on a graph. I have created the GUI with axis and got all working apart from the plotting. Basically, I dont really know the best way to go ahead with it.
I have a button which is going to be used to plot the points. So I was thinking of creating the point or square then attaching and moving it when the plot button is pressed.
Is this a good way about it? I know how to attach but dont know how to move an object.
Does anyone have any better suggestions?
Here is my array:
void bestFit()
{
filename = input.getString();
text.clear();
if (file.is_open()) {
file.close();
}
file.open(filename.c_str());
if (!file.is_open()) {
popUpMessage("Can't open " + filename);
}
else {
float x;
float y;
std::string line;
/**Array to read the x and y co-ordinates from the data*/
float xValue[26];
float yValue[26];
std::getline(file, line);
for (int i=0; i<26; i++) {
file >> x >> y; //Read x and y coordinates
xValue[i] = x;
yValue[i] = y;
}