本文整理汇总了C++中containsPoint函数的典型用法代码示例。如果您正苦于以下问题:C++ containsPoint函数的具体用法?C++ containsPoint怎么用?C++ containsPoint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了containsPoint函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pixel
unsigned int AutoPolygon::getSquareValue(const unsigned int& x, const unsigned int& y, const Rect& rect, const float& threshold)
{
/*
checking the 2x2 pixel grid, assigning these values to each pixel, if not transparent
+---+---+
| 1 | 2 |
+---+---+
| 4 | 8 | <- current pixel (curx,cury)
+---+---+
*/
unsigned int sv = 0;
//NOTE: due to the way we pick points from texture, rect needs to be smaller, otherwise it goes outside 1 pixel
auto fixedRect = Rect(rect.origin, rect.size-Size(2,2));
Vec2 tl = Vec2(x-1, y-1);
sv += (fixedRect.containsPoint(tl) && getAlphaByPos(tl) > threshold)? 1 : 0;
Vec2 tr = Vec2(x, y-1);
sv += (fixedRect.containsPoint(tr) && getAlphaByPos(tr) > threshold)? 2 : 0;
Vec2 bl = Vec2(x-1, y);
sv += (fixedRect.containsPoint(bl) && getAlphaByPos(bl) > threshold)? 4 : 0;
Vec2 br = Vec2(x, y);
sv += (fixedRect.containsPoint(br) && getAlphaByPos(br) > threshold)? 8 : 0;
CCASSERT(sv != 0 && sv != 15, "square value should not be 0, or 15");
return sv;
}
开发者ID:Fuzesunshine,项目名称:CocosTest,代码行数:25,代码来源:CCAutoPolygon.cpp
示例2: initTouchThings
void PropertyField::initTouchThings()
{
static bool touch_moved = false;
auto listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = [this](Touch* touch, Event* event){
auto point = touch->getLocation();
auto rect = DDConfig::propertyAreaRect();
touch_moved = false;
return !DDPropertyFieldProtocal::flagIsTappingExclusive && rect.containsPoint(point) && _tappingEnable && _showState==SS_AGENT;
};
listener->onTouchMoved = [this](Touch* touch, Event* event){
touch_moved = true;
};
listener->onTouchEnded = [this](Touch* touch, Event* event){
auto rect = DDConfig::propertyAreaRect();
if (rect.containsPoint(touch->getLocation()) && touch_moved == false) {
auto point = touch->getLocation();
// 遍历各个propNode
// 5个常规node
for (int i= 0; i < NUM_PROPERTY_MAX; i++) {
auto node = &_propertyNodes[i];
if (node->enable && node->clickable && help_checkIfPointInNode(node->image, point)) {
// 常规属性升级
if (node->cost <= DDMapData::s()->_cntGasLeft) {
ansClickAgentUpgrade(_battleAgentAid, node->propType);
} else {
ansClickGasRunOut();
}
return;
}
}
// 五行
if (_elementTypeNode.enable && _elementTypeNode.clickable && help_checkIfPointInNode(_elementTypeNode.image, point)) {
ansClickElementIcon(_battleAgentAid, _elementTypeNode.propType);
return;
}
// 移除按钮
if (_removeNode.enable && _removeNode.clickable && help_checkIfPointInNode(_removeNode.image, point)) {
ansClickRemoveIcon(_battleAgentAid, _removeNode.propType);
return;
}
}
};
listener->onTouchCancelled = [this](Touch* touch, Event* event){
};
_propertyLayer->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, _propertyLayer);
}
开发者ID:dgkae,项目名称:triplequest,代码行数:56,代码来源:PropertyField.cpp
示例3: init
void BuildingField::init(cocos2d::Layer *buildingLayer)
{
static bool touch_moved = false;
_buildingLayer = buildingLayer;
_buildingImage = Sprite::create("images/template_buildings.png");
_buildingImage->setPosition(DDConfig::buildingAreaCenter());
auto rect = DDConfig::buildingAreaRect();
_buildingImage->setScale(rect.size.width/_buildingImage->getContentSize().width);
_buildingImage->setZOrder(Z_BUILDING_IMAGE);
_buildingLayer->addChild(_buildingImage);
_selectionIcon = Sprite::create("images/template_buildings_select_icon.png");
_selectionIcon->setScale(rect.size.height/_selectionIcon->getContentSize().height);
_selectionIcon->setVisible(false);
_selectionIcon->setZOrder(Z_SELECT_ICON);
_buildingLayer->addChild(_selectionIcon);
auto listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = [this](Touch* touch, Event* event){
auto point = touch->getLocation();
auto rect = DDConfig::buildingAreaRect();
touch_moved = false;
return rect.containsPoint(point);
};
listener->onTouchMoved = [this](Touch* touch, Event* event){
touch_moved = true;
};
listener->onTouchEnded = [this](Touch* touch, Event* event){
auto rect = DDConfig::buildingAreaRect();
if (rect.containsPoint(touch->getLocation()) && touch_moved == false) {
//算出选中了哪一个
auto point = touch->getLocation();
float diffX = point.x - rect.origin.x;
float widthStep = DDConfig::buildingAreaSelectionWidth();
int which = diffX / widthStep;
CCLOG("buildingfiled select %d", which);
_selectionIcon->setVisible(true);
_selectionIcon->setPosition(rect.origin + Vec2{widthStep*which + widthStep*0.5f, rect.size.height*0.5f});
}
};
listener->onTouchCancelled = [this](Touch* touch, Event* event){
};
_buildingLayer->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, _buildingLayer);
}
开发者ID:dgkae,项目名称:NormalMapPreviewer,代码行数:52,代码来源:BuildingField.cpp
示例4: containsEntity
bool Brush::containsEntity(const Entity& entity) const {
BBoxf theirBounds = entity.bounds();
if (!bounds().contains(theirBounds))
return false;
Vec3f point = theirBounds.min;
if (!containsPoint(point))
return false;
point[0] = theirBounds.max[0];
if (!containsPoint(point))
return false;
point[1] = theirBounds.max[1];
if (!containsPoint(point))
return false;
point[0] = theirBounds.min[0];
if (!containsPoint(point))
return false;
point = theirBounds.max;
if (!containsPoint(point))
return false;
point[0] = theirBounds.min[0];
if (!containsPoint(point))
return false;
point[1] = theirBounds.min[1];
if (!containsPoint(point))
return false;
point[0] = theirBounds.max[0];
if (!containsPoint(point))
return false;
return true;
}
开发者ID:WakaLakaLake,项目名称:TrenchBroom,代码行数:31,代码来源:Brush.cpp
示例5: switch
bool CheckBox::handleMouse( UINT uMsg, POINT pt, WPARAM wParam, LPARAM lParam )
{
if( !_enabled || !visible() )
return false;
switch( uMsg )
{
case WM_LBUTTONDOWN:
case WM_LBUTTONDBLCLK:
{
if (containsPoint( pt ))
{
// Pressed while inside the control
_pressed = true;
// mdavidson come back to
SetCapture (_dialog->windowHandle());
if( !_hasFocus )
_dialog->RequestFocus (this);
return true;
}
break;
}
case WM_LBUTTONUP:
{
if( _pressed )
{
_pressed = false;
ReleaseCapture();
// Button click
if( containsPoint( pt ) )
{
SetCheckedInternal( !m_bChecked, true );
}
return true;
}
break;
}
};
return false;
}
开发者ID:SNce,项目名称:IBLBaker,代码行数:49,代码来源:IblCheckBox.cpp
示例6: getCorners
double RS_Image::getDistanceToPoint(const RS_Vector& coord,
RS_Entity** entity,
RS2::ResolveLevel /*level*/,
double /*solidDist*/) const{
if (entity) {
*entity = const_cast<RS_Image*>(this);
}
RS_VectorSolutions corners = getCorners();
//allow selecting image by clicking within images, bug#3464626
if(containsPoint(coord)){
//if coord is on image
RS_SETTINGS->beginGroup("/Appearance");
bool draftMode = (bool)RS_SETTINGS->readNumEntry("/DraftMode", 0);
RS_SETTINGS->endGroup();
if(!draftMode) return double(0.);
}
//continue to allow selecting by image edges
double minDist = RS_MAXDOUBLE;
for (size_t i = 0; i < corners.size(); ++i){
size_t const j = (i+1)%corners.size();
RS_Line const l{corners.get(i), corners.get(j)};
double const dist = l.getDistanceToPoint(coord, nullptr);
minDist = std::min(minDist, dist);
}
return minDist;
}
开发者ID:rmamba,项目名称:LibreCAD,代码行数:31,代码来源:rs_image.cpp
示例7: handleMouseMove
void ClickText::handleMouseMove(const Common::Point &point) {
if (containsPoint(point)) {
_curVisual = _visualActive;
} else {
_curVisual = _visualPassive;
}
}
开发者ID:Botje,项目名称:residualvm,代码行数:7,代码来源:clicktext.cpp
示例8: if
bool ScrollPane<T>::mouseDownSelf(float mx, float my, int button, int mod)
{
if(!containsPoint(mx,my))
return false;
// Click on scrollbar
if(haveScrollbar() && mx>x+width-scrollPaneScrollbarWidth && mx<x+width)
{
// Top scroll button?
if(my < y+scrollButtonHeight) {
if(scrollPos>0)
scrollPos--;
}
// Bottom scroll button?
else if(my > y+height-scrollButtonHeight) {
if(scrollPos<maxScroll)
scrollPos++;
}
// Elsewhere on scrollbar?
else {
// TODO
}
}
else
{
int index = (my-y)/lineHeight + scrollPos;
if(index == lastClickIndex && lastClickTime+doubleClickDelay>getTime())
activate();
lastClickTime = getTime();
lastClickIndex = index;
if(index>=0 && index<elements.size())
selection = index;
}
return true;
}
开发者ID:yixu34,项目名称:RefuseRobots,代码行数:35,代码来源:scrollpane.hpp
示例9: getNearestPointOnEntity
RS_Vector RS_Image::getNearestPointOnEntity(const RS_Vector& coord,
bool onEntity, double* dist, RS_Entity** entity) const{
if (entity!=NULL) {
*entity = const_cast<RS_Image*>(this);
}
RS_VectorSolutions corners =getCorners();
//allow selecting image by clicking within images, bug#3464626
if(containsPoint(coord)){
//if coord is within image
if(dist!=NULL) *dist=0.;
return coord;
}
RS_VectorSolutions points(4);
RS_Line l[] =
{
RS_Line(NULL, RS_LineData(corners.get(0), corners.get(1))),
RS_Line(NULL, RS_LineData(corners.get(1), corners.get(2))),
RS_Line(NULL, RS_LineData(corners.get(2), corners.get(3))),
RS_Line(NULL, RS_LineData(corners.get(3), corners.get(0)))
};
for (int i=0; i<4; ++i) {
points.set(i, l[i].getNearestPointOnEntity(coord, onEntity));
}
return points.getClosest(coord, dist);
}
开发者ID:PlastecProfiles,项目名称:LibreCAD,代码行数:30,代码来源:rs_image.cpp
示例10: size
bool UIWidget::setRect(const Rect& rect)
{
/*
if(rect.width() > 8192 || rect.height() > 8192) {
g_logger.error(stdext::format("attempt to set huge rect size (%s) for %s", stdext::to_string(rect), m_id));
return false;
}
*/
// only update if the rect really changed
Rect oldRect = m_rect;
if(rect == oldRect)
return false;
m_rect = rect;
// updates own layout
updateLayout();
// avoid massive update events
if(!m_updateEventScheduled) {
UIWidgetPtr self = static_self_cast<UIWidget>();
g_dispatcher.addEvent([self, oldRect]() {
self->m_updateEventScheduled = false;
if(oldRect != self->getRect())
self->onGeometryChange(oldRect, self->getRect());
});
m_updateEventScheduled = true;
}
// update hovered widget when moved behind mouse area
if(containsPoint(g_window.getMousePosition()))
g_ui.updateHoveredWidget();
return true;
}
开发者ID:Pucker,项目名称:otclient,代码行数:35,代码来源:uiwidget.cpp
示例11: onItemDragedAtPoint
void SudokuBox::onItemDragedAtPoint(const Vec2& point, int numberIndex) {
// log("SudokuBox::onItemDragedAtPoint with numberIndex is %d", numberIndex);
//check if this point in the box at first.
if (!containsPoint(point))
return;
//calculate the position in box for this point.
int pos = m_iCols * (m_iRows - ((int)point.y / CELL_SIZE) - 1) + ((int) point.x / CELL_SIZE);
// log("calculated the pos is %d", pos);
if (m_pOrgData[pos] <= 0) {
// if not changed, return
if (m_pData[pos] == numberIndex + 1)
return;
operation op;
op.pos = pos;
op.oldValue = m_pData[pos];
op.value = numberIndex + 1;
setNumber(pos, numberIndex + 1);
m_vctOps.push_back(op);
} else {
//its a original cell, ignore
// log("position %d is a original cell", pos);
}
}
开发者ID:gitter-badger,项目名称:kidsudoku,代码行数:26,代码来源:SudokuBox.cpp
示例12: computeTargetPosition
/*!
* The step of the control mode.
*/
ControlTargetPtr FollowGroup::step()
{
PositionMeters previousTargetPosition = m_targetPosition;
m_targetPosition = computeTargetPosition();
// check if the target position is inside the model area
if (!containsPoint(m_targetPosition)) {
// switch to the previous target
m_targetPosition = previousTargetPosition;
}
if (m_targetPosition.isValid()) {
PositionMeters robotPosition = m_robot->state().position();
QString status;
if (robotPosition.isValid()) {
status = QString("group distance %1 m")
.arg(robotPosition.distance2dTo(m_targetPosition), 0, 'f', 3);
} else {
status = QString("group distance unknown");
}
emit notifyControlModeStatus(status);
return ControlTargetPtr(new TargetPosition(m_targetPosition));
} else {
// otherwise the robot doesn't move
emit notifyControlModeStatus("target undefined");
return ControlTargetPtr(new TargetSpeed(0, 0));
}
}
开发者ID:gribovskiy,项目名称:CATS2,代码行数:30,代码来源:FollowGroup.cpp
示例13: containsPoint
bool FloatQuad::intersectsCircle(const FloatPoint& center, float radius) const
{
return containsPoint(center) // The circle may be totally contained by the quad.
|| lineIntersectsCircle(center, radius, m_p1, m_p2)
|| lineIntersectsCircle(center, radius, m_p2, m_p3)
|| lineIntersectsCircle(center, radius, m_p3, m_p4)
|| lineIntersectsCircle(center, radius, m_p4, m_p1);
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:8,代码来源:FloatQuad.cpp
示例14:
/**
* locate is the main location function. It handles both single-element
* and multi-element Geometries. The algorithm for multi-element Geometries
* is more complex, since it has to take into account the boundaryDetermination rule
*/
int
SimplePointInAreaLocator::locate(const Coordinate& p, const Geometry *geom)
{
if (geom->isEmpty()) return Location::EXTERIOR;
if (containsPoint(p,geom))
return Location::INTERIOR;
return Location::EXTERIOR;
}
开发者ID:aaronr,项目名称:geos,代码行数:13,代码来源:SimplePointInAreaLocator.cpp
示例15: getPolygon
NavPoly* NavMesh::getPolygon(point_t coord) {
//todo: use better datastructure for this.
for (auto it = polygon.begin(); it != polygon.end(); it++) {
if (it->containsPoint(coord))
return &*it;
}
return nullptr;
}
开发者ID:nstbayless,项目名称:sdlgame,代码行数:8,代码来源:NavMesh.cpp
示例16: nearSegment
bool Polygon::nearSegment(const Segment& seg, float threshold) const {
if (containsPoint(seg.pt[0]) || containsPoint(seg.pt[1])) {
return true;
}
unsigned int i = vertices.size() - 1;
for (unsigned int j = 0; j < vertices.size(); ++j) {
Segment edge(vertices[i], vertices[j]);
if (edge.nearSegment(seg, threshold)) {
return true;
}
i = j;
}
return false;
}
开发者ID:danbudanov,项目名称:robocup-software,代码行数:17,代码来源:Polygon.cpp
示例17: CCPoint
void HelloWorld::onMouseMove(Event* event) {
EventMouse* e = (EventMouse*)event;
CCPoint mousePosition = CCPoint(e->getCursorX(), e->getCursorY() + 640);
auto block1 = startMenuItem->getBoundingBox();
if (block1.containsPoint(mousePosition)) largerItem(startMenuItem, 1);
else largerItem(NULL, 0);
}
开发者ID:dengysh,项目名称:CatapultGame,代码行数:8,代码来源:HelloWorldScene.cpp
示例18: Rect
void HoleDemo::onTouchesBegan(const std::vector<Touch*>& touches, Event* event)
{
Touch *touch = (Touch *)touches[0];
Vec2 point = _outerClipper->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView()));
auto rect = Rect(0, 0, _outerClipper->getContentSize().width, _outerClipper->getContentSize().height);
if (!rect.containsPoint(point)) return;
this->pokeHoleAtPoint(point);
}
开发者ID:anilgulgor,项目名称:myGame,代码行数:8,代码来源:ClippingNodeTest.cpp
示例19: containsVertex
bool Polygon::containsVertex(const Polygon& other) const {
for (unsigned int i = 0; i < other.vertices.size(); ++i) {
if (containsPoint(other.vertices[i])) {
return true;
}
}
return false;
}
开发者ID:danbudanov,项目名称:robocup-software,代码行数:9,代码来源:Polygon.cpp
示例20: if
MessageType BattleScene::UIcontainsPoint(Vec2 position)
{//check if the UILayer contains the touchPoint
MessageType message;
auto rectKnight = uiLayer->KnightPngFrame->getBoundingBox();
auto rectArcher = uiLayer->ArcherPngFrame->getBoundingBox();
auto rectMage = uiLayer->MagePngFrame->getBoundingBox();
if (rectKnight.containsPoint(position) && uiLayer->KnightAngry->getPercentage() == 100)
message = MessageType::SPECIAL_KNIGHT;
else if (rectArcher.containsPoint(position) && uiLayer->ArcherAngry->getPercentage() == 100)
message = MessageType::SPECIAL_ARCHER;
else if (rectMage.containsPoint(position) && uiLayer->MageAngry->getPercentage() == 100)
message = MessageType::SPECIAL_MAGE;
else
return MessageType::NullMessageType;
return message;
}
开发者ID:WhatTeam,项目名称:FantasyLand,代码行数:18,代码来源:BattleScene.cpp
注:本文中的containsPoint函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论