本文整理汇总了C++中Rect::Intersects方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::Intersects方法的具体用法?C++ Rect::Intersects怎么用?C++ Rect::Intersects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rect
的用法示例。
在下文中一共展示了Rect::Intersects方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ScrollCtrl
void Ctrl::ScrollCtrl(Top *top, Ctrl *q, const Rect& r, Rect cr, int dx, int dy)
{
if(top && r.Intersects(cr)) { // Uno: Contains -> Intersetcs
Rect to = cr;
GetTopRect(to, false);
if(r.Intersects(cr.Offseted(-dx, -dy))) { // Uno's suggestion 06/11/26 Contains -> Intersetcs
Rect from = cr.Offseted(-dx, -dy);
GetTopRect(from, false);
MoveCtrl *m = FindMoveCtrlPtr(top->move, q);
if(m && m->from == from && m->to == to) {
LLOG("ScrollView Matched " << from << " -> " << to);
m->ctrl = NULL;
return;
}
}
if(r.Intersects(cr.Offseted(dx, dy))) { // Uno's suggestion 06/11/26 Contains -> Intersetcs
Rect from = to;
to = cr.Offseted(dx, dy);
GetTopRect(to, false);
MoveCtrl& m = top->scroll_move.Add(q);
m.from = from;
m.to = to;
m.ctrl = q;
LLOG("ScrollView Add " << UPP::Name(q) << from << " -> " << to);
return;
}
cr &= r;
if(!cr.IsEmpty()) {
Refresh(cr);
Refresh(cr + Point(dx, dy));
}
}
}
示例2: GatherTransparentAreas
void Ctrl::GatherTransparentAreas(Vector<Rect>& area, SystemDraw& w, Rect r, const Rect& clip)
{
GuiLock __;
LTIMING("GatherTransparentAreas");
Point off = r.TopLeft();
Point viewpos = off + GetView().TopLeft();
r.Inflate(overpaint);
Rect notr = GetVoidRect();
if(notr.IsEmpty())
notr = GetOpaqueRect();
notr += viewpos;
if(!IsShown() || r.IsEmpty() || !clip.Intersects(r) || !w.IsPainting(r))
return;
if(notr.IsEmpty())
CombineArea(area, r & clip);
else {
if(notr != r) {
CombineArea(area, clip & Rect(r.left, r.top, notr.left, r.bottom));
CombineArea(area, clip & Rect(notr.right, r.top, r.right, r.bottom));
CombineArea(area, clip & Rect(notr.left, r.top, notr.right, notr.top));
CombineArea(area, clip & Rect(notr.left, notr.bottom, notr.right, r.bottom));
}
for(Ctrl *q = firstchild; q; q = q->next) {
Point qoff = q->InView() ? viewpos : off;
Rect qr = q->GetRect() + qoff;
if(clip.Intersects(qr))
q->GatherTransparentAreas(area, w, qr, clip);
}
}
}
示例3: mouseClick
void mouseClick(int button, int state, int x, int y)
{
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
{
Vec2 mousePos((float)x, (float)y);
for (int i = 0; i < rectangles.size(); ++i)
{
if (rectangles[i]->Intersects(mousePos))
{
nnet->ApplyChanges(changes[i]);
GenerateMutations();
return;
}
}
float* thingToChange = 0;
if (colourRect.Intersects(mousePos))
thingToChange = &colourWeight;
else if (sizeRect.Intersects(mousePos))
thingToChange = &sizeWeight;
else if (distanceRect.Intersects(mousePos))
thingToChange = &distanceWeight;
else if (areaRect.Intersects(mousePos))
thingToChange = &areaWeight;
if (thingToChange)
{
if (y > 700)
*thingToChange -= 0.1f;
else
*thingToChange += 0.1f;
}
}
}
示例4: Render
void MapBG::Render(Draw* w)
{
if (_currLevel < 0 || _currLevel >= _levels.GetCount() || !GetTopRender())
return;
MipMapLevel& level = _levels[_currLevel];
Point offset = GetTopRender()->GetPageOffset();
Rect page = GetTopRender()->GetPageRect();
Point lt = GetTopRender()->GetPagePos();
for (int i = 0; i < level.GetMipMaps().GetCount(); ++i)
{
Rect itemRect(level.GetMipMaps().GetKey(i), level.GetBlockSize());
if (page.Intersects(itemRect))
if (level.GetMipMaps()[i])
{
level.GetMipMaps()[i]
->Render(w,
itemRect
.Offseted(-lt)
.Offseted(offset));
}
}
IMapRender::Render(w);
}
示例5: tileRect
void
DrawTargetTiled::StrokeRect(const Rect& aRect, const Pattern& aPattern, const StrokeOptions &aStrokeOptions, const DrawOptions& aDrawOptions)
{
Rect deviceRect = mTransform.TransformBounds(aRect);
Margin strokeMargin = MaxStrokeExtents(aStrokeOptions, mTransform);
Rect outerRect = deviceRect;
outerRect.Inflate(strokeMargin);
Rect innerRect;
if (mTransform.IsRectilinear()) {
// If rects are mapped to rects, we can compute the inner rect
// of the stroked rect.
innerRect = deviceRect;
innerRect.Deflate(strokeMargin);
}
for (size_t i = 0; i < mTiles.size(); i++) {
if (mTiles[i].mClippedOut) {
continue;
}
Rect tileRect(mTiles[i].mTileOrigin.x,
mTiles[i].mTileOrigin.y,
mTiles[i].mDrawTarget->GetSize().width,
mTiles[i].mDrawTarget->GetSize().height);
if (outerRect.Intersects(tileRect) && !innerRect.Contains(tileRect)) {
mTiles[i].mDrawTarget->StrokeRect(aRect, aPattern, aStrokeOptions, aDrawOptions);
}
}
}
示例6: PaintOpaqueAreas
bool Ctrl::PaintOpaqueAreas(SystemDraw& w, const Rect& r, const Rect& clip, bool nochild)
{
GuiLock __;
LTIMING("PaintOpaqueAreas");
if(!IsShown() || r.IsEmpty() || !r.Intersects(clip) || !w.IsPainting(r))
return true;
Point off = r.TopLeft();
Point viewpos = off + GetView().TopLeft();
if(backpaint == EXCLUDEPAINT)
return w.ExcludeClip(r);
Rect cview = clip & (GetView() + off);
for(Ctrl *q = lastchild; q; q = q->prev)
if(!q->PaintOpaqueAreas(w, q->GetRect() + (q->InView() ? viewpos : off),
q->InView() ? cview : clip))
return false;
if(nochild && (lastchild || GetNext()))
return true;
Rect opaque = (GetOpaqueRect() + viewpos) & clip;
if(opaque.IsEmpty())
return true;
#ifdef SYSTEMDRAW
if(backpaint == FULLBACKPAINT && !dynamic_cast<BackDraw *>(&w))
#else
if(backpaint == FULLBACKPAINT && !w.IsBack())
#endif
{
ShowRepaintRect(w, opaque, LtRed());
BackDraw bw;
bw.Create(w, opaque.GetSize());
bw.Offset(viewpos - opaque.TopLeft());
bw.SetPaintingDraw(w, opaque.TopLeft());
{
LEVELCHECK(bw, this);
Paint(bw);
PaintCaret(bw);
}
bw.Put(w, opaque.TopLeft());
}
else {
w.Clip(opaque);
ShowRepaintRect(w, opaque, Green());
w.Offset(viewpos);
{
LEVELCHECK(w, this);
Paint(w);
PaintCaret(w);
}
w.End();
w.End();
}
LLOG("Exclude " << opaque);
return w.ExcludeClip(opaque);
}
示例7:
void
CliWindow::Invalidate (const Rect& region)
{
Rect bounds = _canvas.GetDrawBounds();
if (bounds.Intersects(region)) {
bounds = bounds.Intersect(region);
Redraw(bounds);
if (_parent) {
bounds.Move(Bounds().TopLeft()+_parent->ClientOffset());
_parent->Invalidate(bounds);
}
}
}
示例8:
void
DrawTargetTiled::Fill(const Path* aPath, const Pattern& aPattern, const DrawOptions& aDrawOptions)
{
Rect deviceRect = aPath->GetBounds(mTransform);
for (size_t i = 0; i < mTiles.size(); i++) {
if (!mTiles[i].mClippedOut &&
deviceRect.Intersects(Rect(mTiles[i].mTileOrigin.x,
mTiles[i].mTileOrigin.y,
mTiles[i].mDrawTarget->GetSize().width,
mTiles[i].mDrawTarget->GetSize().height))) {
mTiles[i].mDrawTarget->Fill(aPath, aPattern, aDrawOptions);
}
}
}
示例9: Rect
void
DrawTargetTiled::StrokeLine(const Point& aStart, const Point& aEnd, const Pattern& aPattern, const StrokeOptions &aStrokeOptions, const DrawOptions& aDrawOptions)
{
Rect lineBounds = Rect(aStart, Size()).UnionEdges(Rect(aEnd, Size()));
Rect deviceRect = mTransform.TransformBounds(lineBounds);
deviceRect.Inflate(MaxStrokeExtents(aStrokeOptions, mTransform));
for (size_t i = 0; i < mTiles.size(); i++) {
if (!mTiles[i].mClippedOut &&
deviceRect.Intersects(Rect(mTiles[i].mTileOrigin.x,
mTiles[i].mTileOrigin.y,
mTiles[i].mDrawTarget->GetSize().width,
mTiles[i].mDrawTarget->GetSize().height))) {
mTiles[i].mDrawTarget->StrokeLine(aStart, aEnd, aPattern, aStrokeOptions, aDrawOptions);
}
}
}
示例10: StatePerformed
void MapBG::StatePerformed(dword state, const String& param)
{
if (_currLevel < 0 || _currLevel >= _levels.GetCount())
return;
MipMapLevel& level = _levels[_currLevel];
Rect pageRect = GetPageRect();
if (_recalc || !_virtPage.Contains(GetPageRect()))
{
_virtPage = pageRect.Inflated(level.GetBlockSize() * _cachePageInitSize);
_recalc = true;
}
Rect currVirtualPage = _virtPage.Inflated(level.GetBlockSize() * _cachePageSize);
if (!_recalc)
return;
for (int i = 0; i < level.GetMipMaps().GetCount(); ++i)
{
Point pi = level.GetMipMaps().GetKey(i);
Rect itemRect(pi, level.GetBlockSize());
if (!level.GetMipMaps()[i])
continue;
if (currVirtualPage.Intersects(itemRect))
{
level.GetMipMaps()[i]->Prepare(
AppendFileName(_mapDir, NFormat("%d-%d-%d.png", _currLevel, pi.x, pi.y)),
level.GetBlockSize()
);
}
else
level.GetMipMaps()[i]->Release();
}
_recalc = false;
}
示例11: CtrlPaint
void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip) {
GuiLock __;
LEVELCHECK(w, this);
LTIMING("CtrlPaint");
Rect rect = GetRect().GetSize();
Rect orect = rect.Inflated(overpaint);
if(!IsShown() || orect.IsEmpty() || clip.IsEmpty() || !clip.Intersects(orect))
return;
Ctrl *q;
Rect view = rect;
for(int i = 0; i < frame.GetCount(); i++) {
LEVELCHECK(w, NULL);
frame[i].frame->FramePaint(w, view);
view = frame[i].view;
}
Rect oview = view.Inflated(overpaint);
bool hasviewctrls = false;
bool viewexcluded = false;
for(q = firstchild; q; q = q->next)
if(q->IsShown())
if(q->InFrame()) {
if(!viewexcluded && IsTransparent() && q->GetRect().Intersects(view)) {
w.Begin();
w.ExcludeClip(view);
viewexcluded = true;
}
LEVELCHECK(w, q);
Point off = q->GetRect().TopLeft();
w.Offset(off);
q->CtrlPaint(w, clip - off);
w.End();
}
else
hasviewctrls = true;
if(viewexcluded)
w.End();
DOLEVELCHECK;
if(!oview.IsEmpty()) {
if(oview.Intersects(clip) && w.IsPainting(oview)) {
LEVELCHECK(w, this);
if(overpaint) {
w.Clip(oview);
w.Offset(view.left, view.top);
Paint(w);
PaintCaret(w);
w.End();
w.End();
}
else {
w.Clipoff(view);
Paint(w);
PaintCaret(w);
w.End();
}
}
}
if(hasviewctrls && !view.IsEmpty()) {
Rect cl = clip & view;
w.Clip(cl);
for(q = firstchild; q; q = q->next)
if(q->IsShown() && q->InView()) {
LEVELCHECK(w, q);
Rect qr = q->GetRect();
Point off = qr.TopLeft() + view.TopLeft();
Rect ocl = cl - off;
if(ocl.Intersects(Rect(qr.GetSize()).Inflated(overpaint))) {
w.Offset(off);
q->CtrlPaint(w, cl - off);
w.End();
}
}
w.End();
}
}
示例12: ScrollView
void Ctrl::ScrollView(const Rect& _r, int dx, int dy)
{
GuiLock __;
if(IsFullRefresh() || !IsVisible())
return;
Size vsz = GetSize();
dx = sgn(dx) * min(abs(dx), vsz.cx);
dy = sgn(dy) * min(abs(dy), vsz.cy);
Rect r = _r & vsz;
Ctrl *w;
for(w = this; w->parent; w = w->parent)
if(w->InFrame()) {
Refresh();
return;
}
if(!w || !w->top) return;
Rect view = InFrame() ? GetView() : GetClippedView();
Rect sr = (r + view.TopLeft()) & view;
sr += GetScreenRect().TopLeft() - w->GetScreenRect().TopLeft();
if(w->AddScroll(sr, dx, dy))
Refresh();
else {
LTIMING("ScrollCtrls1");
Top *top = GetTopCtrl()->top;
for(Ctrl *q = GetFirstChild(); q; q = q->GetNext())
if(q->InView()) {
Rect cr = q->GetRect();
if(top && r.Intersects(cr)) { // Uno: Contains -> Intersetcs
Rect to = cr;
GetTopRect(to, false);
if(r.Intersects(cr.Offseted(-dx, -dy))) { // Uno's suggestion 06/11/26 Contains -> Intersetcs
Rect from = cr.Offseted(-dx, -dy);
GetTopRect(from, false);
MoveCtrl *m = FindMoveCtrlPtr(top->move, q);
if(m && m->from == from && m->to == to) {
LLOG("ScrollView Matched " << from << " -> " << to);
m->ctrl = NULL;
goto done;
}
}
if(r.Intersects(cr.Offseted(dx, dy))) { // Uno's suggestion 06/11/26 Contains -> Intersetcs
Rect from = to;
to = cr.Offseted(dx, dy);
GetTopRect(to, false);
MoveCtrl& m = top->scroll_move.Add(q);
m.from = from;
m.to = to;
m.ctrl = q;
LLOG("ScrollView Add " << UPP::Name(q) << from << " -> " << to);
goto done;
}
cr &= r;
if(!cr.IsEmpty()) {
Refresh(cr);
Refresh(cr + Point(dx, dy));
}
done:;
}
}
}
}
示例13: CtrlPaint
void Ctrl::CtrlPaint(SystemDraw& w, const Rect& clip) {
GuiLock __;
LEVELCHECK(w, this);
LTIMING("CtrlPaint");
Rect rect = GetRect().GetSize();
Rect orect = rect.Inflated(overpaint);
if(!IsShown() || orect.IsEmpty() || clip.IsEmpty() || !clip.Intersects(orect))
return;
w.PushContext();
//glPushMatrix();
ApplyTransform(TS_BEFORE_CTRL_PAINT);
Ctrl *q;
Rect view = rect;
for(int i = 0; i < frame.GetCount(); i++) {
LEVELCHECK(w, NULL);
frame[i].frame->FramePaint(w, view);
view = frame[i].view;
}
Rect oview = view.Inflated(overpaint);
bool hasviewctrls = false;
bool viewexcluded = false;
for(q = firstchild; q; q = q->next)
if(q->IsShown())
if(q->InFrame()) {
if(!viewexcluded && IsTransparent() && q->GetRect().Intersects(view)) {
w.Begin();
w.ExcludeClip(view);
viewexcluded = true;
}
LEVELCHECK(w, q);
Point off = q->GetRect().TopLeft();
w.Offset(off);
q->CtrlPaint(w, clip - off);
w.End();
}
else
hasviewctrls = true;
if(viewexcluded)
w.End();
//DOLEVELCHECK;
if(!oview.IsEmpty() && oview.Intersects(clip)) {
LEVELCHECK(w, this);
if(cliptobounds)
w.Clip(overpaint ? oview : view);
w.Offset(view.left, view.top);
Paint(w);
PaintCaret(w);
w.End();
if(hasviewctrls && !view.IsEmpty()) {
Rect cl = clip & view;
for(q = firstchild; q; q = q->next)
if(q->IsShown() && q->InView()) {
Rect rr(q->popup ? clip : cl);
LEVELCHECK(w, q);
Rect qr = q->GetRect();
Point off = qr.TopLeft() + view.TopLeft();
Rect ocl = cl - off;
if(ocl.Intersects(Rect(qr.GetSize()).Inflated(overpaint))) {
w.Offset(off);
q->CtrlPaint(w, rr - off);
w.End();
}
}
}
if(cliptobounds)
w.End();
}
ApplyTransform(TS_AFTER_CTRL_PAINT);
//glPopMatrix();
w.PopContext();
}