Exemple #1
0
BOOL CGauge::OnDragStart(int nHitTest,CPointF point)
{
	REAL dx = m_pWnd->GetStartPos().x;
	REAL dy = m_pWnd->GetStartPos().y;

	CRectF rc;
	GetBoundsRect(rc);
	rc.OffsetRect(-dx,-dy);

	BOOL bRet = FALSE;

	CClientDC dc(m_pWnd);
	CElastic elastic(&dc,this);

	CPoints pts;

	switch (nHitTest)
	{
	case TopLeft:
		PointHelper::RecalcPoints(m_rcBounds,CRectF(point.x,point.y,rc.right,rc.bottom),m_pts,pts);
		break;
	case Top:
		PointHelper::RecalcPoints(m_rcBounds,CRectF(rc.left,point.y,rc.right,rc.bottom),m_pts,pts);
		break;
	case TopRight:
		PointHelper::RecalcPoints(m_rcBounds,CRectF(rc.left,point.y,point.x,rc.bottom),m_pts,pts);
		break; 
	case Right:
		PointHelper::RecalcPoints(m_rcBounds,CRectF(rc.left,rc.top,point.x,rc.bottom),m_pts,pts);
		break;
	case BottomRight:
		PointHelper::RecalcPoints(m_rcBounds,CRectF(rc.left,rc.top,point.x,point.y),m_pts,pts);
		break;
	case Bottom:
		PointHelper::RecalcPoints(m_rcBounds,CRectF(rc.left,rc.top,rc.right,point.y),m_pts,pts);
		break;
	case BottomLeft:
		PointHelper::RecalcPoints(m_rcBounds,CRectF(point.x,rc.top,rc.right,point.y),m_pts,pts);
		break;
	case Left:
		PointHelper::RecalcPoints(m_rcBounds,CRectF(point.x,rc.top,rc.right,rc.bottom),m_pts,pts);
		break;
	case Body: 
		PointHelper::RecalcPoints(m_rcBounds,CRectF(rc.left,rc.top,rc.right,rc.bottom),m_pts,pts);
		bRet = TRUE;
		break;
	default:
		GetPoints(pts);
		PointHelper::OffsetPoints(pts,-dx,-dy);
		pts[nHitTest-HtIndex] = CPoint((int)point.x,(int)point.y);
		break;
	} 

	dc.Polyline(pts.GetData(),(int)pts.GetCount());

	return bRet;
}
Exemple #2
0
void CRoundRect::DrawRoundRectXY(CDC *pDC,REAL left,REAL top,REAL right,REAL bottom,REAL fXEllipse,REAL fYEllipse)
{
	if (CRectF(left,top,right,bottom).IsRectEmpty())
		return;

	REAL w = right - left;
	REAL h = bottom - top;

	REAL fWidth = (REAL)(fXEllipse*w);
	REAL fHeight = (REAL)(fYEllipse*h);

	if ((fWidth<0 && w>0) ||(fWidth>0 && w<0))
		fWidth = 0;
	else if (abs(fWidth) > abs(w))
		fWidth = w;

	if ((fHeight<0 && h>0) ||(fHeight>0 && h<0))
		fHeight = 0;
	else if (abs(fHeight) > abs(h))
		fHeight = h;

	if (fWidth==0.0 || fHeight==0.0)
	{
		DrawRect(pDC,left,top,right,bottom);
	}
	else
	{
		exchange_if_less(REAL,right,left);
		exchange_if_less(REAL,bottom,top);
		absx(fWidth);absx(fHeight);

		pDC->RoundRect((int)left,(int)top,(int)right,(int)bottom,(int)fWidth,(int)fHeight);
	}
}
// 範囲選択開始
void CGridLabel::mousePressEvent(QMouseEvent *ev)
{
	if ( !m_pEditData || !m_bCatchable ) { return ; }
	if ( ev->button() != Qt::LeftButton ) { return ; }

	bCatching = true ;
	m_bRectMove = false ;

	if ( m_pEditData->getCatchRect().contains( ev->pos() / mScale ) ) {	// 範囲内選択した場合
		m_bRectMove = true ;

		if ( m_bPressCtrl ) {	// Ctrl押してたら
			m_MovePos = ev->pos() ;
			repaint() ;
		}
		else {
			startDragAndDrop(ev) ;
		}
	}
	else {
		int x = ev->pos().x() / mScale ;
		int y = ev->pos().y() / mScale ;
		CRectF r = CRectF(x, y, x+1, y+1) ;
		m_pEditData->setCatchRect(r);
		repaint() ;

		emit sig_changeCatchRect(r) ;
	}
}
Exemple #4
0
void CGauge::OnDrag(int nHitTest,CPointF point)
{
	CRectF rc;
	GetBoundsRect(rc);

	REAL dx = m_pWnd->GetStartPos().x;
	REAL dy = m_pWnd->GetStartPos().y;
	rc.OffsetRect(-dx,-dy);

	CClientDC dc(m_pWnd);
	CElastic elastic(&dc,this);

	CPoints pts1,pts2;

	switch (nHitTest)
	{
	case TopLeft:
		PointHelper::RecalcPoints(m_rcBounds,CRectF(m_pWnd->GetCapturePos().x,m_pWnd->GetCapturePos().y,rc.right,rc.bottom),m_pts,pts1);
		PointHelper::RecalcPoints(m_rcBounds,CRectF(point.x,point.y,rc.right,rc.bottom),m_pts,pts2);
		break;
	case Top:
		PointHelper::RecalcPoints(m_rcBounds,CRectF(rc.left,m_pWnd->GetCapturePos().y,rc.right,rc.bottom),m_pts,pts1);
		PointHelper::RecalcPoints(m_rcBounds,CRectF(rc.left,point.y,rc.right,rc.bottom),m_pts,pts2);
		break;
	case TopRight:
		PointHelper::RecalcPoints(m_rcBounds,CRectF(rc.left,m_pWnd->GetCapturePos().y,m_pWnd->GetCapturePos().x,rc.bottom),m_pts,pts1);
		PointHelper::RecalcPoints(m_rcBounds,CRectF(rc.left,point.y,point.x,rc.bottom),m_pts,pts2);
		break; 
	case Right:
		PointHelper::RecalcPoints(m_rcBounds,CRectF(rc.left,rc.top,m_pWnd->GetCapturePos().x,rc.bottom),m_pts,pts1);
		PointHelper::RecalcPoints(m_rcBounds,CRectF(rc.left,rc.top,point.x,rc.bottom),m_pts,pts2);
		break;
	case BottomRight:
		PointHelper::RecalcPoints(m_rcBounds,CRectF(rc.left,rc.top,m_pWnd->GetCapturePos().x,m_pWnd->GetCapturePos().y),m_pts,pts1); 
		PointHelper::RecalcPoints(m_rcBounds,CRectF(rc.left,rc.top,point.x,point.y),m_pts,pts2); 
		break;
	case Bottom:
		PointHelper::RecalcPoints(m_rcBounds,CRectF(rc.left,rc.top,rc.right,m_pWnd->GetCapturePos().y),m_pts,pts1);
		PointHelper::RecalcPoints(m_rcBounds,CRectF(rc.left,rc.top,rc.right,point.y),m_pts,pts2);
		break;
	case BottomLeft:
		PointHelper::RecalcPoints(m_rcBounds,CRectF(m_pWnd->GetCapturePos().x,rc.top,rc.right,m_pWnd->GetCapturePos().y),m_pts,pts1);
		PointHelper::RecalcPoints(m_rcBounds,CRectF(point.x,rc.top,rc.right,point.y),m_pts,pts2); 
		break;
	case Left:
		PointHelper::RecalcPoints(m_rcBounds,CRectF(m_pWnd->GetCapturePos().x,rc.top,rc.right,rc.bottom),m_pts,pts1); 
		PointHelper::RecalcPoints(m_rcBounds,CRectF(point.x,rc.top,rc.right,rc.bottom),m_pts,pts2); 
		break;
	case Body: 
		{
			REAL x = m_pWnd->GetCapturePos().x-m_pWnd->GetMarkPos().x;
			REAL y = m_pWnd->GetCapturePos().y-m_pWnd->GetMarkPos().y;

			PointHelper::RecalcPoints(m_rcBounds,CRectF(rc.left+x,rc.top+y,rc.right+x,rc.bottom+y),m_pts,pts1);

			x = point.x-m_pWnd->GetMarkPos().x;
			y = point.y-m_pWnd->GetMarkPos().y;
			PointHelper::RecalcPoints(m_rcBounds,CRectF(rc.left+x,rc.top+y,rc.right+x,rc.bottom+y),m_pts,pts2);
		}
		break;
	default:
		{
			GetPoints(pts1);
			PointHelper::OffsetPoints(pts1,-dx,-dy);
			pts1[nHitTest-HtIndex] = CPoint((int)m_pWnd->GetCapturePos().x,(int)m_pWnd->GetCapturePos().y);	
			pts2.Copy(pts1);
			pts2[nHitTest-HtIndex] = CPoint((int)point.x,(int)point.y);
		}
		break;
	}

	dc.Polyline(pts1.GetData(),(int)pts1.GetCount()); 
	dc.Polyline(pts2.GetData(),(int)pts2.GetCount()); 
}
CSpeedLine::CSpeedLine(const CDrawingObjectParams &params)
	: CPolyLine(CRectF(0.0f, 0.0f, 0.0f, 0.0f), params.GetValueFloatColor(DOP_COLOR), static_cast<DrawingObjectType>(params.GetValueInt(DOP_TYPE)))
{
	SetParams(params);
}
	CScalarField2D::CScalarField2D(void)
		: m_pField(nullptr),CDataField2D( CRectF(0,0,0,0), 0, 0 )
	{
		m_bHasMinMax = false;
	}