示例#1
0
//重なっていたらtrueを返す
bool SRect::intersect(const SRect& rc) const
{
    if(rc.l()>m_r) return false;
    if(rc.r()<m_l) return false;
    if(rc.t()>m_b) return false;
    if(rc.b()<m_t) return false;
    return true;
}
示例#2
0
//範囲を指定して選択を行う
unsigned SXBSchLine::testSelection(const SRect& rc)
{
	unsigned nOutcode1 = SetOutCode(m_p1,rc);
	unsigned nOutcode2 = SetOutCode(m_p2,rc);
	if(nOutcode1 & nOutcode2) return 0;
	if((nOutcode1 == 0 )||(nOutcode2 == 0 )) return SELECT_ALL;
	unsigned nOutcode = nOutcode1 | nOutcode2;
	if(nOutcode == (OUTCODE_LEFT  | OUTCODE_RIGHT)) return SELECT_ALL;
	if(nOutcode == (OUTCODE_UPPER | OUTCODE_LOWER)) return SELECT_ALL;

	int x,y;
	int x1 = m_p1.x();
	int y1 = m_p1.y();
	int x2 = m_p2.x();
	int y2 = m_p2.y();

	if(nOutcode & OUTCODE_LEFT){	//片方が左に出ている
		x=rc.l();
		y=y1+((x-x1)*(y2-y1))/(x2-x1);
		if(y >= rc.t() && y <= rc.b()) return SELECT_ALL;
	}
	if(nOutcode & OUTCODE_RIGHT){	//片方が右に出ている
		x=rc.r();
		y=y1+((x-x1)*(y2-y1))/(x2-x1);
		if(y >= rc.t() && y <= rc.b()) return SELECT_ALL;
	}
	if(nOutcode & OUTCODE_UPPER){	//片方が上に出ている
		y=rc.t();
		x=x1+((y-y1)*(x2-x1))/(y2-y1);
		if(x >= rc.l() && x <= rc.r()) return SELECT_ALL;
	}
	if(nOutcode & OUTCODE_LOWER){	//片方が下に出ている
		y=rc.b();
		x=x1+((y-y1)*(x2-x1))/(y2-y1);
		if(x >= rc.l() && x <= rc.r()) return SELECT_ALL;
	}
	return 0;
}
示例#3
0
//描画が必要かどうかを返す
bool SXBSchLine::qRedraw(const SRect& rc)
{
	SRect rcDraw(rc.l()-1,rc.t()-1,rc.r()+1,rc.b()+1);
	if(testSelection(rcDraw)) 	return true;
	else 						return false;
}