本文整理汇总了C++中PixelBox::pointInside方法的典型用法代码示例。如果您正苦于以下问题:C++ PixelBox::pointInside方法的具体用法?C++ PixelBox::pointInside怎么用?C++ PixelBox::pointInside使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PixelBox
的用法示例。
在下文中一共展示了PixelBox::pointInside方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getClickedItem
OverlayItemInternal* OverlayView::getClickedItem(const WFAPI::ScreenPoint& p)
{
StackedSet::StackVec& stackedItems = m_stackSet.getStackedItems();
OverlayItemInternal* highlightedItem=NULL;
//first check if there is a highlighted item visible
for( StackedSet::StackVec::reverse_iterator itr = stackedItems.rbegin();
itr != stackedItems.rend(); itr++ )
{
OverlayItemInternal* curItem = *itr;
if(curItem->m_isHighlighted) {
highlightedItem=curItem;
break;
}
}
if(highlightedItem) {
MC2Point screenPoint;
m_projection.transform(screenPoint, highlightedItem->getPosition());
WFAPI::wf_uint32 pixScale =
static_cast<WFAPI::wf_uint32>(m_projection.getPixelScale());
const WFAPI::OverlayItemVisualSpec* visualSpec =
OverlayItemUtil::getCurrentVisualSpec(highlightedItem, pixScale);
const WFAPI::ImageSpec* background = visualSpec->getBackgroundImage();
WFAPI::ScreenPoint offsetPoint = visualSpec->getFocusPoint();
unsigned int width = background->getWidth();
unsigned int height = background->getHeight();
// Create our offset box
PixelBox box( MC2Point(-offsetPoint.getX(), -offsetPoint.getY()),
MC2Point(-offsetPoint.getX() + width,
-offsetPoint.getY() + height));
//Offset the box to the correct position on the screen
box.move(screenPoint);
//now check if we clicked the highlighted item
if(box.pointInside(p)) {
return highlightedItem;
}
}
//if we got this far we clicked a non-highlighted item
for( StackedSet::StackVec::reverse_iterator itr = stackedItems.rbegin();
itr != stackedItems.rend(); itr++ )
{
OverlayItemInternal* curItem = *itr;
//skip highlighted item
if(curItem == highlightedItem) {
continue;
}
PixelBox box = curItem->getPixelBox();
//check if we clicked an item that is not the currently highlighted item
if(box.pointInside(p)) {
return curItem;
}
}
return NULL;
}