Exemplo n.º 1
0
hdMultiPosRect &hdPolyLineFigure::getBasicDisplayBox()
{
	basicDisplayBox.height = 0;
	basicDisplayBox.width = 0;

	int posIdx;
	//optimize this if needed in a future, because right now calculate displaybox for all posIdx
	hdIteratorBase *iterator;
	for(posIdx = 0; posIdx < basicDisplayBox.CountPositions(); posIdx++)
	{
		if(points[posIdx]->count() >= 1)
		{
			basicDisplayBox.SetPosition(posIdx, pointAt(posIdx, 0));
		}
		else
		{
			basicDisplayBox.SetPosition(posIdx, wxPoint(0, 0));
		}

		iterator = points[posIdx]->createIterator();
		while(iterator->HasNext())
		{
			hdPoint *p = (hdPoint *) iterator->Next();
			hdRect r = hdRect(p->x, p->y, 0, 0);
			basicDisplayBox.add(posIdx, r);
		}

		delete iterator;
	}
	return basicDisplayBox;
}
Exemplo n.º 2
0
bool hdGeometry::lineContainsPoint(double x1, double y1, double x2, double y2, double px, double py)
{
	hdPoint p = hdPoint(x1, y1);
	hdRect r = hdRect(p);
	r.add(x2, y2);
	r.Inflate(2, 2);
	if(!r.Contains(px, py))
	{
		return false;
	}

	double a, b, x, y;
	double val1, val2;

	val1 = px - x1;
	if( x1 == x2 )
	{
		return (ddabs(val1) < 3);
	}

	val2 = py - y1;
	if( y1 == y2 )
	{
		return (ddabs(val2) < 3);
	}

	a = (y1 - y2) / (x1 - x2);
	b = y1 - a * x1;
	x = (py - b) / a;
	y = a * px + b;

	val1 = x - px;
	val2 = y - py;
	bool out = (min( ddabs(val1), ddabs(val2)) < 4);
	return out;
}
Exemplo n.º 3
0
hdRect &hdLocatorConnector::getDisplayBox(int posIdx)
{
	hdPoint p = figureLocator->locate(posIdx, getOwner());
	displayBox = hdRect(p.x - (size / 2), p.y - (size / 2), size, size);
	return displayBox;
}