Пример #1
0
	bool GetInvalidateRect(RectD & retVal) const
	{
		if (!m_invalidateRect.IsEmptyArea())
			retVal = m_invalidateRect;

		if (m_hotItem)
		{
			if (hpcc::ElementG * hotElementG = GetElementG(m_hotItem))
			{
				retVal = hotElementG->GetBoundingBox();
				if (m_hotEdge)
				{
					if (hpcc::ElementG * hotElementG = GetElementG(m_hotEdge->GetFromVertex()))
						retVal.Union(hotElementG->GetBoundingBox());
					if (hpcc::ElementG * hotElementG = GetElementG(m_hotEdge->GetToVertex()))
						retVal.Union(hotElementG->GetBoundingBox());
				}
				else if(m_hotVertex)
				{
					for(IEdgeSet::const_iterator itr = m_hotVertex->GetInEdges().begin(); itr != m_hotVertex->GetInEdges().end(); ++itr)
					{
						if (hpcc::ElementG * hotElementG = GetElementG(itr->get()))
							retVal.Union(hotElementG->GetBoundingBox());
					}
					for(IEdgeSet::const_iterator itr = m_hotVertex->GetOutEdges().begin(); itr != m_hotVertex->GetOutEdges().end(); ++itr)
					{
						if (hpcc::ElementG * hotElementG = GetElementG(itr->get()))
							retVal.Union(hotElementG->GetBoundingBox());
					}
				}
			}
		}
		m_invalidateRect = retVal;
		return !m_invalidateRect.IsEmptyArea();
	}
Пример #2
0
void FixSubgraphSizes(ICluster * cluster, RectD  & parentRect)
{
	RectD childRect;
	for(IClusterSet::const_iterator itr = cluster->GetClusters().begin(); itr != cluster->GetClusters().end(); ++itr)
	{
		std::string cluster;
		FixSubgraphSizes(itr->get(), childRect);
	}

	for(IVertexSet::const_iterator itr = cluster->GetVertices().begin(); itr != cluster->GetVertices().end(); ++itr)
	{
		if (childRect.IsEmptyArea())
			childRect = GetBoundingRect(itr->get());
		else
			childRect.Union(GetBoundingRect(itr->get()));
	}

	//if (!GetBoundingRect(cluster).Contains(childRect))
	{
		if (childRect.IsEmptyArea())
			childRect = GetBoundingRect(cluster);
		else
			childRect.Union(GetBoundingRect(cluster));


		if (ElementG * eg = GetElementG(cluster))
		{
			assert(eg->m_polygons.size() == 1);
			if (eg->m_polygons.size() == 1)
			{
				eg->m_polygons[0]->m_points.clear();
				eg->m_polygons[0]->SetBoundingBox(RectD());
				eg->m_polygons[0]->m_points.push_back(PointD(childRect.GetLeft(), childRect.GetBottom()));
				eg->m_polygons[0]->m_points.push_back(PointD(childRect.GetLeft(), childRect.GetTop()));
				eg->m_polygons[0]->m_points.push_back(PointD(childRect.GetRight(), childRect.GetTop()));
				eg->m_polygons[0]->m_points.push_back(PointD(childRect.GetRight(), childRect.GetBottom()));
				eg->m_polygons[0]->m_points.push_back(PointD(childRect.GetLeft(), childRect.GetBottom()));
			}
			//eg->SetBoundingBox(childRect);
			eg->CalcBoundingBox();
		}

		//childRect.Union(GetBoundingRect(cluster));
		//ElementGPtr elementG = new ElementG(childRect);
		//cluster->SetProperty(SVG_PROP_ELEMENTG, elementG);
	}
	if (parentRect.IsEmptyArea())
		parentRect = childRect;
	else
		parentRect.Union(childRect);
}
Пример #3
0
static RectD BoundSelectionOnPage(const Vec<SelectionOnPage> &sel, int pageNo) {
    RectD bounds;
    for (size_t i = 0; i < sel.Count(); i++) {
        if (sel.At(i).pageNo == pageNo)
            bounds = bounds.Union(sel.At(i).rect);
    }
    return bounds;
}
Пример #4
0
GRAPHDB_API ElementG * GetElementG(IGraphItem * item)
{
	CUnknown * tmpProp = item->GetPropertyCUnknown(hpcc::SVG_PROP_ELEMENTG);
	if (tmpProp)
		return reinterpret_cast<hpcc::ElementG * >(tmpProp);
	
	RectD boundingBox;
	if (const ICluster * cluster = dynamic_cast<const ICluster *>(item))	//  Not all layouts support clusters!
	{
		bool first = true;
		for(IClusterSet::const_iterator itr = cluster->GetClusters().begin(); itr != cluster->GetClusters().end(); ++itr)
		{
			ElementGPtr elementG = GetElementG(*itr);
			if (first)
			{
				first = false;
				boundingBox = elementG->GetBoundingBox();
			}
			else
				boundingBox.Union(elementG->GetBoundingBox());
		}

		for(IVertexSet::const_iterator itr = cluster->GetVertices().begin(); itr != cluster->GetVertices().end(); ++itr)
		{
			ElementGPtr elementG = GetElementG(*itr);
			if (first)
			{
				first = false;
				boundingBox = elementG->GetBoundingBox();
			}
			else
				boundingBox.Union(elementG->GetBoundingBox());
		}
	}
	ElementGPtr elementG = new ElementG(boundingBox);
	item->SetProperty(SVG_PROP_ELEMENTG, elementG);
	return elementG;
}
Пример #5
0
	bool GetPrevInvalidateRect(RectD & retVal) const
	{
		bool first = true;
		for (CGraphHotItemMap::const_iterator itr = m_prevSelected.begin(); itr != m_prevSelected.end(); ++itr)
		{
			if (first)
			{
				first = false;
				itr->second.GetInvalidateRect(retVal);
			}
			else
			{
				RectD rect;
				itr->second.GetInvalidateRect(rect);
				retVal.Union(rect);
			}
		}
		return true;
	}