示例#1
0
static RectF RectFUnion(RectF& r1, RectF& r2) {
    if (r2.IsEmptyArea())
        return r1;
    if (r1.IsEmptyArea())
        return r2;
    RectF ru;
    ru.Union(ru, r1, r2);
    return ru;
}
示例#2
0
RectF CRender::getGraphExtent(bool selectedOnly) const
{
	RectF retVal;
	bool first = true;
	CComPtr<boost::scoped_lock_ref_counted> lock;

	CComPtr<IGraphItem> item;
	CComPtr<IUnknown> unk;
	CComQIPtr<IListWindowRenderer> lw;
	CComQIPtr<ILegacyRenderer> lv;

	RectF rc;
	IGraphItemVector results;
	m_graph->GetChildren(results);

	for(IGraphItemVector::iterator itr=results.begin(); itr!=results.end(); ++itr)
	{
		item=*itr;	

		CUniqueID id = item->GetID();
		unk=item->GetPropertyUnknown(0);

		if(unk!=0)
		{
			lv=unk.p;
			if(lv!=0)
			{
				if (selectedOnly && !lv->IsSelected())
				{
					continue;
				}
			
				if (first)
				{
					lv->GetTitlePos(retVal);
					first = false;
				}
				else
				{
					lv->GetTitlePos(rc);
					retVal.Union(retVal, retVal, rc);
				}

				lv->GetIconPos(rc);
				retVal.Union(retVal, retVal, rc);
				lv->GetImagePos(rc);
				retVal.Union(retVal, retVal, rc);
			}
			else
			{
				lw=unk.p;
				if(lw!=0)
				{
					if (selectedOnly && !lw->IsSelected())
					{
						continue;
					}

					if (first)
					{
						lw->GetBoundsBox(retVal);
						first = false;
					}
					else
					{
						lw->GetBoundsBox(rc);
						retVal.Union(retVal, retVal, rc);
					}
				}
			}
		}
	}

	return retVal;
}