本文整理汇总了C++中CBCGPRect::CenterPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ CBCGPRect::CenterPoint方法的具体用法?C++ CBCGPRect::CenterPoint怎么用?C++ CBCGPRect::CenterPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBCGPRect
的用法示例。
在下文中一共展示了CBCGPRect::CenterPoint方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnDrawShape
//*******************************************************************************
void CBCGPChartTextObject::OnDrawShape(CBCGPGraphicsManager* pGM, const CBCGPRect& rectDiagram)
{
if (m_bDrawConnector && !m_format.m_outlineFormat.m_brLineColor.IsEmpty())
{
CBCGPRect rectShape = m_rectScreen;
rectShape.Normalize();
if (!rectShape.PtInRect(m_ptAnchor))
{
CBCGPPoint pt;
if (bcg_CS_intersect(rectShape, m_ptAnchor, rectShape.CenterPoint(), pt))
{
pGM->DrawLine(m_ptAnchor, pt, m_format.m_outlineFormat.m_brLineColor,
m_format.m_outlineFormat.GetLineWidth(TRUE), &m_format.m_outlineFormat.m_strokeStyle);
}
CBCGPEllipse ellipse(m_ptAnchor, 2 * m_format.GetScaleRatio().cx, 2 * m_format.GetScaleRatio().cy);
pGM->FillEllipse(ellipse, m_format.m_brFillColor);
pGM->DrawEllipse(ellipse, m_format.m_outlineFormat.m_brLineColor);
}
}
CBCGPChartObject::OnDrawShape(pGM, rectDiagram);
}
示例2: bcg_pointInPie
bool bcg_pointInPie (const CBCGPRect& rect, double dblAngleStart, double dblAngleFinish, const CBCGPPoint& ptTestIn, double dblDoughnutPercent)
{
if (!rect.PtInRect(ptTestIn))
{
return false;
}
CBCGPPoint ptTest = ptTestIn;
CBCGPPoint ptCenter = rect.CenterPoint();
double dblRadiusX = 0.5 * rect.Width();
double dblRadiusY = 0.5 * rect.Height();
if (dblRadiusX > dblRadiusY && dblRadiusX != 0.)
{
ptTest.Scale(CBCGPPoint(dblRadiusY / dblRadiusX, 1.0), ptCenter);
}
else if (dblRadiusY > dblRadiusX && dblRadiusY != 0.)
{
ptTest.Scale(CBCGPPoint(1.0, dblRadiusX / dblRadiusY, 1.0), ptCenter);
}
double dblAngle = bcg_normalize_rad(bcg_angle(ptCenter, ptTest));
dblAngleStart = bcg_normalize_rad(dblAngleStart);
dblAngleFinish = bcg_normalize_rad(dblAngleFinish);
BOOL bIn = FALSE;
const BOOL bIsFullEllipse = bcg_IsFullEllipse(bcg_rad2deg(dblAngleStart), bcg_rad2deg(dblAngleFinish), TRUE, 0.1f);
if (bIsFullEllipse)
{
bIn = TRUE;
}
else
{
if (dblAngleStart > dblAngleFinish)
{
bIn = (dblAngle <= dblAngleFinish) || (dblAngleStart <= dblAngle);
}
else
{
bIn = (dblAngle >= dblAngleStart) && (dblAngle <= dblAngleFinish);
}
}
if (bIn)
{
double angleCos = cos(dblAngle);
double angleSin = sin(dblAngle);
CBCGPPoint ptEdge(ptCenter.x + angleCos * .5 * rect.Width(), ptCenter.y + angleSin * .5 * rect.Height());
double r = bcg_distance(ptEdge, ptCenter);
double distToCenter = bcg_distance(ptTestIn, ptCenter);
return (distToCenter <= r && distToCenter > r * dblDoughnutPercent);
}
return false;
}
示例3: HitTestShape
//***************************************************************************************
int CBCGPRadialMenuObject::HitTestShape(const CBCGPPoint& pt)
{
CBCGPRect rect = m_rect;
if (rect.Width() < rect.Height())
{
rect.top += (rect.Height() - rect.Width()) / 2;
rect.bottom = rect.top + rect.Width();
}
else if (rect.Height() < rect.Width())
{
rect.left += (rect.Width() - rect.Height()) / 2;
rect.right = rect.left + rect.Height();
}
rect.DeflateRect(2., 2.);
rect.right -= m_nShadowDepth;
rect.bottom -= m_nShadowDepth;
const double radius = rect.Width() / 2;
const double radiusSmall = INTERNAL_PART * rect.Width() + 1.0;
const CBCGPPoint center = rect.CenterPoint();
double dblDistanceToCenter = bcg_distance(pt, center);
if (dblDistanceToCenter > radius)
{
return -1;
}
const int nItems = (int)m_arItems.GetSize();
if (dblDistanceToCenter <= radiusSmall)
{
return m_bHasCenterButton ? nItems - 1 : -1;
}
const int nCircleItems = m_bHasCenterButton ? nItems - 1 : nItems;
if (nCircleItems == 0)
{
return -1;
}
double dblDeltaAngle = 360. / nCircleItems;
double dblStartAngle = 90. - dblDeltaAngle / 2;
double dblAngle = bcg_normalize_deg(bcg_rad2deg(acos((pt.x - center.x) / dblDistanceToCenter)));
if (pt.y > center.y)
{
dblAngle = 360 - dblAngle;
}
int nHit = (int)((dblAngle - dblStartAngle) / dblDeltaAngle);
if (dblAngle < dblStartAngle)
{
nHit = nCircleItems - 1 - (int)((dblStartAngle - dblAngle) / dblDeltaAngle);
}
return nHit;
}
示例4: OnDraw
//***************************************************************************************
void CBCGPRadialMenuObject::OnDraw(CBCGPGraphicsManager* pGM, const CBCGPRect& /*rectClip*/, DWORD dwFlags)
{
if (dwFlags == BCGP_DRAW_STATIC)
{
return;
}
m_nShadowDepth = pGM->IsSupported(BCGP_GRAPHICS_MANAGER_COLOR_OPACITY) ? GetShadowDepth() : 0;
CBCGPRect rect = m_rect;
if (rect.Width() < rect.Height())
{
rect.top += (rect.Height() - rect.Width()) / 2;
rect.bottom = rect.top + rect.Width();
}
else if (rect.Height() < rect.Width())
{
rect.left += (rect.Width() - rect.Height()) / 2;
rect.right = rect.left + rect.Height();
}
rect.DeflateRect(2., 2.);
rect.right -= m_nShadowDepth;
rect.bottom -= m_nShadowDepth;
const double radius = rect.Width() / 2;
const double radiusSmall = INTERNAL_PART * rect.Width() + 1.0;
const CBCGPPoint center = rect.CenterPoint();
CBCGPSize sizeIcon((double)m_cxIcon, 16);
if (!m_Icons.IsNull())
{
sizeIcon.cy = pGM->GetImageSize(m_Icons).cy;
}
const int nItems = (int)m_arItems.GetSize();
if (IsDirty())
{
int nCircleItems = m_bHasCenterButton ? nItems - 1 : nItems;
double dblDeltaAngle = nCircleItems == 0 ? 0. : 360. / nCircleItems;
double dblStartAngle = 90. - dblDeltaAngle / 2;
for (int i = 0; i < nItems; i++)
{
CBCGPRadialMenuItem* pItem = m_arItems[i];
ASSERT_VALID(pItem);
pItem->m_bIsCenter = i == nItems -1 && m_bHasCenterButton;
pItem->m_Shape.Destroy();
pItem->m_Shape.Clear();
if (!pItem->m_bIsCenter)
{
double dblFinishAngle = dblStartAngle + dblDeltaAngle;
const double dblStartAngleRad = bcg_deg2rad(dblStartAngle);
const double dblFinishAngleRad = bcg_deg2rad(dblFinishAngle);
const double dblMiddleAngleRad = bcg_deg2rad(dblStartAngle + dblDeltaAngle / 2);
double angleStartCos = cos(dblStartAngleRad);
double angleStartSin = sin(dblStartAngleRad);
double angleFinishCos = cos(dblFinishAngleRad);
double angleFinishSin = sin(dblFinishAngleRad);
pItem->m_Shape.SetStart(
CBCGPPoint(center.x + angleStartCos * radius, center.y - angleStartSin * radius));
pItem->m_Shape.AddArc(
CBCGPPoint(center.x + angleFinishCos * radius, center.y - angleFinishSin * radius),
CBCGPSize(radius, radius), dblStartAngle > dblFinishAngle, FALSE);
pItem->m_Shape.AddLine(
CBCGPPoint(center.x + angleFinishCos * radiusSmall, center.y - angleFinishSin * radiusSmall));
pItem->m_Shape.AddArc(
CBCGPPoint(center.x + angleStartCos * radiusSmall, center.y - angleStartSin * radiusSmall),
CBCGPSize(radiusSmall, radiusSmall), dblStartAngle < dblFinishAngle, FALSE);
pItem->m_ptCenter = CBCGPPoint(
center.x + cos(dblMiddleAngleRad) * 2 * radius / 3,
center.y - sin(dblMiddleAngleRad) * 2 * radius / 3);
dblStartAngle = dblFinishAngle;
}
else
{
pItem->m_Shape.SetStart(center);
pItem->m_Shape.AddLine(center);
pGM->CombineGeometry(pItem->m_Shape, pItem->m_Shape, CBCGPEllipseGeometry(CBCGPEllipse(center, radiusSmall, radiusSmall)), RGN_OR);
pItem->m_ptCenter = center;
}
}
}
CBCGPEllipse ellipseInt(center, radiusSmall, radiusSmall);
//.........这里部分代码省略.........