Exemplo n.º 1
0
void MouseHandler::Build2DEllipse(string nameOfAlgo, IEllipsoidBuilder* builder, bool toDraw)
{
	Window* window = Window::Create();
	if (toDraw == true && (nameOfAlgo != Rublev && nameOfAlgo != Petunin)) toDraw = false;

	if (window->vertexes->size() < 3) return;
	Ellipsoid2D* el;

	vector<Point2D>* conv = NULL;
	if (nameOfAlgo == GeneticMatrix || nameOfAlgo == Khachiyan) conv = ConvHull(*window->vertexes);

	vector<Point2D> points;
	if (conv != NULL) points = (*conv);
	else points = *window->vertexes;

	if (toDraw) el = builder->Exec(points, window);
	else el = builder->Exec(points);

	DrawEvent* draw = new DrawEvent();
	draw->add(window->vertexes);
	if (el != NULL)
	{
		el->SetColor(Color(0.0f, 1.0f, 0.0f));
		draw->add(1, el);
	}
	window->AddNewDrawEvent(draw);
	delete draw; draw = NULL;

	WriteResultsToFile("Resources/Output Data.txt", nameOfAlgo, el);

	delete el; el = NULL;
}
Exemplo n.º 2
0
void MouseHandler::AddVertex(Point2D & p)
{
	Window* window = Window::Create();
	window->vertexes->push_back(p);
	DrawEvent* draw = new DrawEvent();
	draw->add(1, &p);
	window->AddNext(draw);
	delete draw;
	draw = NULL;
}
Exemplo n.º 3
0
void MouseHandler::ReadVertexesFromFile()
{
	Window* window = Window::Create();
	if (window->vertexes != NULL)
	{
		if (!window->vertexes->empty()) window->vertexes->clear();
		delete window->vertexes;
		window->vertexes = NULL;
	}
	window->clear();
	window->vertexes = Helper::ReadPoints("Resources/Input Data.txt");
	DrawEvent* draw = new DrawEvent();
	draw->add(window->vertexes);
	window->AddNext(draw);
	delete draw;
	draw = NULL;
}