Пример #1
0
void CttView::ADTFill(const COLORREF color){
	if (m_point.size() <= 2)return;
	CDC* pDC = GetWindowDC();
	CPen pen1(0, 0, color);
	pDC->SelectObject(&pen1);
	int start, end, msz=m_point.size();
	start = 10000;
	end = 0;
	for (int i = 0; i < msz; i++){
		start = min(start, m_point[i].y);
		end = max(end, m_point[i].y);
	}
	vector<EdgeTable> net(end+1);
	net.assign(end + 1, EdgeTable());
	Edge te;
	int miny;
	for (int i = 0; i < msz-1; i++){
		te = Edge(m_point[i], m_point[i + 1], miny);
		net[miny].Add(te);
	}
	te = Edge(m_point[msz-1], m_point[0], miny);
	net[miny].Add(te);
	
	EdgeTable adt = EdgeTable(start);
	for (int i = start; i <= end; i++){
		for (int j = 0; j < net[i].e.size(); j++)
			adt.Add(net[i].e[j]);
		for (int j = 1; j < adt.e.size(); j += 2){
			pDC->MoveTo((int)adt.e[j-1].x0, i);
			pDC->LineTo((int)adt.e[j].x0, i);
		}
		adt.Update();
	}
}
Пример #2
0
void Na2DViewer::paintCrosshair(QPainter& painter)
{
    float scale = defaultScale * cameraModel.scale();
    QBrush brush1(Qt::black);
    QBrush brush2(QColor(255, 255, 180));
    QPen pen1(brush1, 2.0/scale);
    QPen pen2(brush2, 1.0/scale);
    // qDebug() << "paint crosshair";
    // Q: Why all this complicated math instead of just [width()/2, height()/2]?
    // A: This helps debug/document placement of image focus
    qreal w2 = (pixmap.width() - 1.0) / 2.0; // origin at pixel center, not corner
    qreal h2 = (pixmap.height() - 1.0) / 2.0; // origin at pixel center, not corner
    qreal cx = w2 + flip_X * (cameraModel.focus().x() - w2) + 0.5;
    qreal cy = h2 + flip_Y * (cameraModel.focus().y() - h2) + 0.5;
    QPointF f(cx, cy);
    QPointF dx1(4.0 / scale, 0);
    QPointF dy1(0, 4.0 / scale);
    QPointF dx2(10.0 / scale, 0); // crosshair size is ten pixels
    QPointF dy2(0, 10.0 / scale);
    painter.setPen(pen1);
    painter.drawLine(f + dx1, f + dx2);
    painter.drawLine(f - dx1, f - dx2);
    painter.drawLine(f + dy1, f + dy2);
    painter.drawLine(f - dy1, f - dy2);
    painter.setPen(pen2);
    painter.drawLine(f + dx1, f + dx2);
    painter.drawLine(f - dx1, f - dx2);
    painter.drawLine(f + dy1, f + dy2);
    painter.drawLine(f - dy1, f - dy2);
}
Пример #3
0
void ChartWidget::paintEvent(QPaintEvent*)
{
    QPainter painter(this);
    painter.setWindow(0,0,width(),height());
    painter.eraseRect(0,0,width(),height());

    QPen pen0(Qt::SolidLine);
    pen0.setColor(palette().color(QPalette::Window));
    painter.setPen(pen0);
    painter.drawRect(0,0,width(),height());

    QPen pen1(Qt::DashDotLine);
    pen1.setColor(palette().color(QPalette::Mid));
    painter.setPen(pen1);
    painter.drawLine(0,height()/2,width(),height()/2);

    for (int i=10;i<m_polygon.count();i+=10)
    {
        painter.drawLine(m_polygon[i].x(),0,m_polygon[i].x(),height());
    }

    QPen pen2(Qt::SolidLine);
    pen2.setColor(palette().color(QPalette::Dark));
    painter.setPen(pen2);

    painter.drawEllipse(m_plyIndicator,height()/2-2,3,3);

    painter.setRenderHints(QPainter::Antialiasing);
    painter.drawPolyline(m_polygon);
}
void InlineColorPicker::paintEvent(QPaintEvent *e){
    QPainter p(this);
    p.setRenderHint(QPainter::Antialiasing, true);
    QPen pen1(QColor(0,0,0));
    p.setPen(pen1);
    p.drawRect(0,0,this->size().width(), this->size().height());

    QRect myRect(1,1, this->size().width()-2, this->size().height()-2);
    QLinearGradient gradient(myRect.topLeft(), myRect.topRight());

    gradient.setColorAt(0, QColor(255,0,0));
    gradient.setColorAt(0.17, QColor(255,255,0));
    gradient.setColorAt(0.34, QColor(0,255,0));
    gradient.setColorAt(0.50, QColor(0,255,255));
    gradient.setColorAt(0.66, QColor(0,0,255));
    gradient.setColorAt(0.82, QColor(255,0,255));
    gradient.setColorAt(1.0, QColor(255,0,0));

    p.fillRect(myRect,gradient);

    p.setRenderHint(QPainter::Antialiasing, true);

    p.setPen(QPen(QColor(0,0,0), 0.5));
    p.drawEllipse(x,y,14,14);

    p.setPen(QPen(QColor(255,255,255)));
    p.drawEllipse(x+1,y+1,12,12);

    p.setPen(QPen(QColor(100,100,100)));
    p.setBrush(QBrush(QColor(255,255,255,100)));
    p.drawEllipse(x+2,y+2,10,10);
}
Пример #5
0
void MainWindow::paintEvent(QPaintEvent * event)
{
	QPainter painter(this);
	QPen pen1(Qt::black);
	pen1.setWidth(1);
	painter.setPen(pen1);
	/*Shape s(Shape::T);
	s.rotate();
	s.rotate();
	Coords c= s.getCoords();
	int * sX = c.x();
	int * sY = c.y();
	for(int x =0; x<4; x++)
	{
		//std::cout << sX[x] << "  " << sY[x] << "\n";
		blocks.at(2+sX[x]).at(5+sY[x]).setFill(Qt::green);
	}
		//blocks.at(2).at(5).setFill(Qt::green);
   */
	for(int i = 0; i<blocks.size();i++)
	{
		for(int y = 0; y<blocks.at(i).size();y++)
		{
			painter.setBrush(blocks.at(i).at(y).getFill());
			painter.drawRect(blocks.at(i).at(y).getQRect());
		}
	}

	painter.end();
}
Пример #6
0
void MainWindow::paintEvent(QPaintEvent *) {
	int nelem = applist.count();
	int cols = nelem / ROWS + 1;

	QPainter painter(this);
	painter.setRenderHint(QPainter::Antialiasing);
	QSize sz = sizeHint();
	painter.fillRect(QRect(0, 0, sz.width(), sz.height()), QBrush(QColor(255, 20, 20)));

	int i = 0;
	int j = 0;
	for (; i < nelem; i++, j++) {
		if (j >= ROWS)
			j = 0;
			
		QIcon icon = applist[i].app_icon_;
		int sz = 64 ;
		if (active_index_ == i)
			sz -= animation_id_ * 3;
			
		QPixmap pixmap = icon.pixmap(QSize(sz, sz), QIcon::Normal, QIcon::On);
		painter.drawPixmap(QPoint(MARGIN * 2 + (64 - sz) / 2 + (i / ROWS) * 64, MARGIN *2 + j * 64 + TOP + (64 - sz) / 2), pixmap);
	}

	// vertical bars
	QPen pen1(Qt::black);
	painter.setPen(pen1);
	for (i = 0; i < cols; i++) {
		painter.drawLine(MARGIN * 2 + i * 64 + 21, MARGIN * 2 + TOP, MARGIN * 2 + i * 64 + 21, MARGIN * 2 + ROWS * 64 + TOP);
		painter.drawLine(MARGIN * 2 + i * 64 + 43, MARGIN * 2 + TOP, MARGIN * 2 + i * 64 + 43, MARGIN * 2 + ROWS * 64 + TOP);
		painter.drawLine(MARGIN * 2 + i * 64 + 64, MARGIN * 2 + TOP, MARGIN * 2 + i * 64 + 64, MARGIN * 2 + ROWS * 64 + TOP);
	}
	
	// horizontal bars
	for (i = 0; i < ROWS - 1; i++) {
		painter.drawLine(MARGIN * 2, MARGIN * 2 + 64 * (i + 1) - 1 + TOP,
			MARGIN * 2 + 64 * cols, MARGIN * 2 + 64 * (i + 1) - 1 + TOP);

	}

	// close button
	painter.fillRect(QRect(MARGIN * 2 + cols * 64 - 8, 8, 12, 3), QBrush(Qt::white));
	

	painter.setFont(QFont("Sans", TOP, QFont::Normal));
	QPen pen2(Qt::white);
	painter.setPen(pen2);
	painter.drawText(MARGIN * 2, TOP + MARGIN / 2, "Firetools");

	if (animation_id_ > 0) {
		animation_id_--;
		QTimer::singleShot(ADELAY, this, SLOT(update()));
	}
	
	
}
Пример #7
0
void DragDropRect::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){
    Q_UNUSED(option);
    Q_UNUSED(widget);

    QPen pen1(Qt::DashLine);
    painter->setPen(pen1);
    painter->setBrush(dragOver ? color.light(130) : color);
    painter->drawRoundedRect(boundingRect(),5,5);
    painter->drawText(4,50,"Foto hierhin");
}
Пример #8
0
void CttView::LineCai(const CPoint &x, const CPoint &y){
	int c[2][4];
	int cnum[2];
	CDC* pDC = GetWindowDC();
	CPen pen1(0, 0, RGB(255, 0, 0));
	CPen pen2(0, 3, RGB(0, 0, 0));
	CPen pen3(0, 2, RGB(0, 0, 0));
	GetC(c[0],cnum[0],x);
	GetC(c[1],cnum[1],y);
	if (cnum[0] & cnum[1]){
		pDC->SelectObject(&pen1);
		pDC->MoveTo(x);
		pDC->LineTo(y);
		return;
	}
	if ((cnum[0] | cnum[1])==0){
		pDC->SelectObject(&pen2);
		pDC->MoveTo(x);
		pDC->LineTo(y);
		return;
	}
	pDC->SelectObject(&pen1);
	pDC->MoveTo(x);
	pDC->LineTo(y);
	CPoint a[2];
	int an = 0;
	if (c[0][0] != c[1][0])//与下边有交
	{
		int jx = x.x + (1.0*m_d - x.y) / (y.y - x.y)  *(y.x - x.x);
		if (jx > m_l && jx < m_r) a[an++] = CPoint(jx, m_d);
	}
	if (c[0][1] != c[1][1])//与上边有交
	{
		int jx = x.x + (1.0*m_u - x.y) / (y.y - x.y)  *(y.x - x.x);
		if (jx > m_l && jx < m_r) a[an++] = CPoint(jx, m_u);
	}
	if (c[0][2] != c[1][2])//与右边有交
	{
		int jy = x.y + (1.0*m_r - x.x) / (y.x - x.x)  *(y.y - x.y);
		if (jy < m_d && jy > m_u) a[an++] = CPoint(m_r, jy);
	}
	if (c[0][3] != c[1][3])//与左边有交
	{
		int jy = x.y + (1.0*m_l - x.x) / (y.x - x.x)  *(y.y - x.y);
		if (jy < m_d && jy > m_u) a[an++] = CPoint(m_l, jy);
	}
	if (an == 1){
		if (cnum[0] == 0)a[an++] = x;
		else a[an++] = y;
	}
	pDC->SelectObject(&pen2);
	pDC->MoveTo(a[0]);
	pDC->LineTo(a[1]);
}
Пример #9
0
void CFreqDial::drawDial()
{
	wxMemoryDC dc;
	dc.SelectObject(*m_bitmap);

#if defined(__WXMSW__)
	int major, minor;
	::wxGetOsVersion(&major, &minor);

	wxColour bgColour;
	if (major >= 6)
		bgColour = wxColour(0xF0, 0xF0, 0xF0);		// Windows Vista and newer
	else if (major == 5 && minor >= 1)
		bgColour = wxColour(0xEC, 0xE9, 0xD8);		// Windows XP
	else
		bgColour = wxColour(0xD4, 0xD0, 0xC8);		// Windows 2000 and earlier
#elif defined(__WXGTK__)
	wxColour bgColour(0xF0, 0xF1, 0xF2);
	// wxColour bgColour(0xED, 0xE9, 0xE3);
#elif defined(__WXMAC__)
	wxColour bgColour(0xF0, 0xF0, 0xF0);
#else
#error "Unknown platform"
#endif

	wxBrush brush0(bgColour);
	wxPen pen0(bgColour);

	dc.SetPen(pen0);
	dc.SetBrush(brush0);
	dc.DrawRectangle(0, 0, m_width, m_height);

	int middleX = m_width / 2;
	int middleY = m_height / 2;

	dc.SetBrush(*wxLIGHT_GREY_BRUSH);
	wxPen pen1(*wxBLACK, 2, wxSOLID);
	dc.SetPen(pen1);
	dc.DrawCircle(middleX, middleY, (m_width - 2) / 2);

	int x = m_width / 2 - int(double(m_width / 2 - 25) * ::sin(m_angle * (M_PI / 180.0)) + 0.5);
	int y = m_height / 2 + int(double(m_height / 2 - 25) * ::cos(m_angle * (M_PI / 180.0)) + 0.5);

	dc.SetBrush(*wxBLACK_BRUSH);
	wxPen pen2(*wxWHITE, 2, wxSOLID);
	dc.SetPen(pen2);
	dc.DrawCircle(x, y, 20);

	dc.SelectObject(wxNullBitmap);

	wxClientDC clientDC(this);
	show(clientDC);
}
Пример #10
0
void GameWidget::paintEvent(QPaintEvent *e)
{
    QPainter p(this);

    if (m_bShowSoser)
    {
        p.drawPixmap(m_soserX, 0, m_soser);
    }

    for(TShips::const_iterator sit = m_ships.constBegin(); sit != m_ships.constEnd(); ++sit)
    {
        p.drawPixmap(sit->x, sit->y, *sit->pix);
    }

    QRadialGradient grad1(0, 0, 7);
    grad1.setColorAt(1, QColor(0,0,0));
    grad1.setColorAt(0, QColor(255,255,255));
    QPen pen1(QColor(0,0,0));
    QRadialGradient grad2(0, 0, 7);
    grad2.setColorAt(1, QColor(255,0,0));
    grad2.setColorAt(0, QColor(255,200,200));
    QPen pen2(QColor(255,0,0));
    
    p.setPen(pen1);
    p.setBrush(QBrush(grad1));
    int lastL = 1;

    for(TShots::const_iterator it = m_shots.constBegin(); it != m_shots.constEnd(); ++it)
    {
        int x = it->x, y = it->y, l = it->level;
        if (l != lastL)
        {
            p.setPen((l==1)?pen1:pen2);
            p.setBrush((l==1)?grad1:grad2);
            lastL = l;
        }
        p.setBrushOrigin(x, y);
        p.drawEllipse(x - 7, y - 7, 14, 14);
    }

    p.drawPixmap(m_gunX-32, m_gunY, PicBucket::instance().getPic(1, 2).pixmap);
    m_shotspreg = QRegion();

    if (m_lives == 0)
    {	
        p.setPen(QPen(Qt::NoPen));
        p.setBrush(QBrush(QColor(255,255,255,188)));
        p.drawRect(0, 0, sizeX, sizeY);
        QLabel::paintEvent(e);
        return;
    }
}
Пример #11
0
void CLrcMask::DrawBkMask()
{
	HDC hTempDc = GetDC(m_hWnd);
	HDC hMenDc = CreateCompatibleDC(hTempDc);

	DuiLib::CDuiRect rc;
	GetClientRect(&rc);

	HBITMAP hbmp;
	BITMAPINFO bitmapinfo;
	bitmapinfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
	bitmapinfo.bmiHeader.biBitCount = 32;
	bitmapinfo.bmiHeader.biHeight = rc.GetHeight();
	bitmapinfo.bmiHeader.biWidth = rc.GetWidth();
	bitmapinfo.bmiHeader.biPlanes = 1;
	bitmapinfo.bmiHeader.biCompression=BI_RGB;
	bitmapinfo.bmiHeader.biXPelsPerMeter=0;
	bitmapinfo.bmiHeader.biYPelsPerMeter=0;
	bitmapinfo.bmiHeader.biClrUsed=0;
	bitmapinfo.bmiHeader.biClrImportant=0;
	bitmapinfo.bmiHeader.biSizeImage = bitmapinfo.bmiHeader.biWidth * bitmapinfo.bmiHeader.biHeight * bitmapinfo.bmiHeader.biBitCount / 8;

	hbmp = CreateDIBSection(hMenDc,&bitmapinfo,0,NULL,0,0);
	SelectBitmap(hMenDc,hbmp);

	Graphics graphics(hMenDc);

	graphics.SetSmoothingMode(SmoothingModeAntiAlias);
	graphics.SetInterpolationMode(InterpolationModeHighQualityBicubic);
	SolidBrush brush(Color(50,200,200,200));
	Pen pen1(Color(155,223,223,223));
	Pen pen2(Color(55,223,223,223));
	LPRECT lpRect = &rc;
	RectF rect((Gdiplus::REAL)lpRect->left,(Gdiplus::REAL)lpRect->top,(Gdiplus::REAL)(lpRect->right-lpRect->left),(Gdiplus::REAL)(lpRect->bottom-lpRect->top));

	graphics.FillRectangle(&brush,rect);
	graphics.DrawRectangle(&pen1,rect.GetLeft()+2,rect.GetTop()+2,rect.Width - 4,rect.Height -4);
	graphics.DrawRectangle(&pen2,rect.GetLeft()+1,rect.GetTop()+1,rect.Width - 2,rect.Height -2);

	DuiLib::CDuiRect rtWnd;
	GetWindowRect(&rtWnd);

	DuiLib::CPoint dstPt(0,0);
	DuiLib::CPoint winPt(rtWnd.left,rtWnd.top);
	DuiLib::CSize size(rc.GetWidth(),rc.GetHeight());
	BLENDFUNCTION blend = {AC_SRC_OVER,0,255,AC_SRC_ALPHA};
	BOOL bret = ::UpdateLayeredWindow(m_hWnd,hTempDc,&winPt,&size,hMenDc,&dstPt,0,&blend,ULW_ALPHA);
	DeleteDC(hMenDc);
	ReleaseDC(m_hWnd,hTempDc);	

//	assert(bret);
}
Пример #12
0
//绘制K线图
void CHistoryView::DrawLineOfK(CDC *pDC)
{
	CHistoryDoc* pHistoryDoc = (CHistoryDoc*)GetDocument();
	int nSel = ( (CHistoryFrame*)GetParentFrame() )->GetSliderCtrlPos();

	int nCount = pHistoryDoc->m_arrayHistoryInfo.GetSize();
	double dbLeft = m_rectMid.left;//X起始位置
	double dbBottom = m_rectMid.bottom + m_nPenWidth;//Y起始位置
	CPen pen1( PS_SOLID,m_nPenWidth / 2,RGB(255,0,0) );
	CPen pen2( PS_SOLID,m_nPenWidth / 2,RGB(0,255,0) );
	CPen* pOldPen;
	for(int nI = 0;nI < m_nStockNumPerPage;nI++)
	{
		double dbHiPrice = pHistoryDoc->m_arrayHistoryInfo[nI + nSel]->m_dbHiPrice;//当日最高价
		double dbLowPrice = pHistoryDoc->m_arrayHistoryInfo[nI + nSel]->m_dbLowPrice;//当日最低价
		double dbOpenPrice = pHistoryDoc->m_arrayHistoryInfo[nI + nSel]->m_dbOpenPrice;//当日开盘价
		double dbClosePrice	= pHistoryDoc->m_arrayHistoryInfo[nI + nSel]->m_dbClosePrice;//当日收盘价
		double dbLowestPrice = pHistoryDoc->m_dbLowPrice;//历史最低价
		
		//绘制矩形
		dbLeft += m_dbXStep;
		CRect rect;
		rect.left = (int)dbLeft;
		rect.right = rect.left + int(m_dbXStep / 2);
		if(dbClosePrice >= dbOpenPrice)//收盘价高于开盘价
		{
			rect.top = int( (dbClosePrice - dbLowestPrice) * m_dbYPriceUnit + dbBottom );
			rect.bottom = int( (dbOpenPrice - dbLowestPrice) * m_dbYPriceUnit + dbBottom );
			CPen pen( PS_SOLID,m_nPenWidth / 2,RGB(255,0,0) );
			pOldPen = pDC->SelectObject(&pen1);
			pDC->Rectangle(&rect);
		}
		else//收盘价低于开盘价
		{
			rect.top = int( (dbOpenPrice - dbLowestPrice) * m_dbYPriceUnit + dbBottom );
			rect.bottom = int( (dbClosePrice - dbLowestPrice) * m_dbYPriceUnit + dbBottom );
			CBrush brush( RGB(0,255,0) );
			pDC->FillRect(&rect,&brush);
			pOldPen = pDC->SelectObject(&pen2);
		}	

		//绘制直线
		pDC->MoveTo( int(dbLeft + m_dbXStep / 4),rect.top);
		pDC->LineTo( int(dbLeft + m_dbXStep / 4),int( (dbHiPrice - dbLowestPrice) * m_dbYPriceUnit + dbBottom ) );
		pDC->MoveTo( int(dbLeft + m_dbXStep / 4),rect.bottom);
		pDC->LineTo( int(dbLeft + m_dbXStep / 4),int( (dbLowPrice - dbLowestPrice) * m_dbYPriceUnit + dbBottom ) );

		pDC->SelectObject(pOldPen);
	}

}
void CAnimateLineDrawView::OnTimer(UINT_PTR nIDEvent)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值

	CClientDC dc(this);
	static int x = 200;
	static int y = 200;
	CPen pen1(PS_SOLID,0,RGB(255,0,8));
	CPen *pOldPen = dc.SelectObject(&pen1);

	//以下代码实现动态曲线
	x = x+ m_offsetx;

	// 如果曲线没有超过屏幕图片框右边界线,直接在屏幕图片框内绘制曲线,不用平移
	if( x <= 400)
	{
		dc.MoveTo(x-m_offsetx,y);
		y = 200 - rand()%90; //模拟数据采样值
		dc.LineTo(x,y);
	}
	else // 如果超过屏幕图片框右边界线,直需要平移曲线图
	{
		CRect rect(200,100,400,200);
		CBrush bkBrush(HS_CROSS,RGB(0,128,0));

		// 保存需要移动的曲线图像
		m_dc.BitBlt(0,0,195,100,&dc,205,100,SRCCOPY);

		// 用背景图重绘屏幕图片框,消隐其中的所有曲线
		dc.SetBkColor(RGB(0,0,0));
		dc.FillRect(rect,&bkBrush);

		//将保存的曲线图向左平移5个单位
		dc.BitBlt(200,100,195,100,&m_dc,0,0,SRCCOPY);

		// 用新数据继续绘制曲线
		dc.MoveTo(395,y);
		y = 200 - rand()%90; //模拟数据采样值
		dc.LineTo(400,y);
	}

	dc.SelectObject(pOldPen);
	CView::OnTimer(nIDEvent);
}
Пример #14
0
//-------------------------------------------------------
void Terrain::createCrossCursor ()
{            
	//---------------------------------------------------
	// Define new cross cursor, more visible
	//---------------------------------------------------
/*		* B=1 and M=1 gives black.
		* B=0 and M=1 gives white.
		* B=0 and M=0 gives transparent.
		* B=1 and M=0 gives an XOR'd result.*/
	QBitmap *crossBits = new QBitmap(32,32);
	QBitmap *crossMask = new QBitmap(32,32);
	crossBits->clear();
 	crossMask->clear();
	QPainter pb (crossBits);
	QPainter pm (crossMask);
	QPen pen1(Qt::color1);
	pen1.setWidth(1);
	pb.setPen(pen1);
	pb.drawLine(6,16, 26,16);
	pb.drawLine(16,6, 16,26);
	pm.setPen(pen1);
	 // black
	pm.drawLine(6,16, 26,16);
	pm.drawLine(16,6, 16,26);
	// white
	pm.drawLine(6,15, 26,15);
	pm.drawLine(6,17, 26,17);
	
	pm.drawLine(15,6, 15,26);
	pm.drawLine(17,6, 17,26);
	
	pb.end();
	pm.end();
	myCrossCursor = QCursor(*crossBits, *crossMask);
    
    int v = 180;
    selectColor     = QColor(v,v,v);
    setCursor(myCrossCursor);
}
Пример #15
0
void CElcStatic::OnPaint()
{
	CPaintDC dc(this);

	DWORD dwStyle = GetStyle();
	DWORD dwStaticType = (dwStyle & SS_TYPEMASK);

	CRect rect;
	GetClientRect(rect);

	CElcMemDC dcMem(&dc, rect);

	if (m_bUseBackgndColor) {
		dcMem.FillSolidRect(rect, m_crBackgnd);
	}
	else if (GetParent()) {
		HBRUSH hBrush = (HBRUSH)GetParent()->SendMessage(WM_CTLCOLORSTATIC, (WPARAM)dcMem.GetSafeHdc(), (LPARAM)m_hWnd);
		if (hBrush)
			::FillRect(dcMem.GetSafeHdc(), rect, hBrush);
	}

	if (m_bUseTextColor) {
		dcMem.SetTextColor(m_crText);
	}

	if (m_pImage) {
		Graphics g(dcMem.GetSafeHdc());

		Rect rcImage(0, 0, m_pImage->GetWidth(), m_pImage->GetHeight());
		Rect rcDest;
		if (dwStyle & SS_CENTERIMAGE) {
			rcDest.X = rect.left + (rect.Width() - rcImage.Width) / 2;
			rcDest.Y = rect.top + (rect.Height() - rcImage.Height) / 2;
			rcDest.Width = rcImage.Width;
			rcDest.Height = rcImage.Height;
		}
		else {
			rcDest.X = rect.left;
			rcDest.Y = rect.top;
			rcDest.Width = rect.Width();
			rcDest.Height = rect.Height();
		}

		thePainter.DrawStretchImage(&g, m_pImage, &rcDest, &rcImage, 0);
	}
	else if (dwStaticType == SS_ICON
		|| dwStaticType == SS_BITMAP
		|| dwStaticType == SS_OWNERDRAW
		|| dwStaticType == SS_USERITEM
		|| dwStaticType == SS_ENHMETAFILE) 
	{
		// not support type
		// pls use SetImage() to replace
		ASSERT(0);
		return;
	}
	else if (dwStaticType == SS_BLACKRECT
		|| dwStaticType == SS_GRAYRECT
		|| dwStaticType == SS_WHITERECT
		|| dwStaticType == SS_BLACKFRAME
		|| dwStaticType == SS_GRAYFRAME
		|| dwStaticType == SS_WHITEFRAME)
	{
		// not support
		// pls use Standard MFC class : CStatic
		ASSERT(0);
		return;
	}
	else { 
		if (dwStaticType == SS_ETCHEDHORZ) {
			CPen pen1(PS_SOLID, 1, m_crEtched1);
			CPen * pOld = dcMem.SelectObject(&pen1);
			dcMem.MoveTo(rect.left, rect.top);
			dcMem.LineTo(rect.right - 2, rect.top);

			CPen pen2(PS_SOLID, 1, m_crEtched2);
			dcMem.SelectObject(&pen2);
			dcMem.MoveTo(rect.left + 2, rect.top+1);
			dcMem.LineTo(rect.right, rect.top+1);

			dcMem.SelectObject(&pOld);
		}
		else if (dwStaticType == SS_ETCHEDVERT) {
			CPen pen1(PS_SOLID, 1, m_crEtched1);
			CPen * pOld = dcMem.SelectObject(&pen1);
			dcMem.MoveTo(rect.left, rect.top);
			dcMem.LineTo(rect.left, rect.bottom - 2);

			CPen pen2(PS_SOLID, 1, m_crEtched2);
			dcMem.SelectObject(&pen2);
			dcMem.MoveTo(rect.left + 1, rect.top + 2);
			dcMem.LineTo(rect.left + 1, rect.bottom);

			dcMem.SelectObject(&pOld);
		}
		else if (dwStaticType == SS_ETCHEDFRAME) {
			// not implement
			// support later...
			ASSERT(0);
		}
		else {
			CFont* pOldFont = dcMem.SelectObject(GetFont());
			UINT nFormat = 0;
			
			if (dwStaticType == SS_LEFT) {
				nFormat = DT_LEFT | DT_NOFULLWIDTHCHARBREAK | DT_WORDBREAK;
			}
			else if (dwStaticType == SS_CENTER) {
				nFormat = DT_CENTER | DT_NOFULLWIDTHCHARBREAK | DT_WORDBREAK;
			}
			else if (dwStaticType == SS_RIGHT) {
				nFormat = DT_RIGHT | DT_NOFULLWIDTHCHARBREAK | DT_WORDBREAK;
			}
			else if (dwStaticType == SS_SIMPLE) {
				nFormat = DT_SINGLELINE | DT_VCENTER;
			}
			else if (dwStaticType == SS_LEFTNOWORDWRAP) {
				nFormat = DT_SINGLELINE;
			}

			/*
			// these codes are been commented because something errors are not been fiexd yet
			if (dwStyle & SS_ENDELLIPSIS) {
				nFormat |= DT_MODIFYSTRING | DT_END_ELLIPSIS | DT_WORD_ELLIPSIS;
			}
			if (dwStyle & SS_PATHELLIPSIS) {
				nFormat |= DT_MODIFYSTRING | DT_PATH_ELLIPSIS | DT_WORD_ELLIPSIS;
			}*/

			if (dwStyle & SS_NOPREFIX) {
				nFormat |= DT_NOPREFIX;
			}

			if (dwStyle & SS_EDITCONTROL) {
				nFormat |= DT_EDITCONTROL;
			}

			CString strText;
			GetWindowText(strText);
			dcMem.DrawText(strText, rect, nFormat);

			dcMem.SelectObject(pOldFont);
		}
	}

	dcMem.DrawMe();
}
Пример #16
0
void CTimeAxis::drawTimePoint(CDC* pDC, int idxYY, int idxLrc/*, COLORREF clr*/)
{
	if (pDC == NULL)
		return;

	if (m_pSyr == NULL)
		return;

	int num = m_pSyr->getYYerCount();
	if (num < 1)
		return;

	if (idxYY < 0 || idxYY >= num)
		return;

	int numLrc = m_pSyr->getYYerLrcsCount(idxYY);
	if (numLrc < 1)
		return;

	if (idxLrc < 0 || idxLrc >= numLrc)
		return;

	int time = m_pSyr->getYYerLrcTime(idxYY, idxLrc);
	if (time < m_minTime || time > m_maxTime)
		return;

	CRect rect;
	this->GetWindowRect(&rect);
	ScreenToClient(&rect);
	rect.top += TIME_BREV_H;

// 	int dy = rect.Height() / (num + 1);

	int x = rect.Width() * (time - m_minTime) / (m_maxTime - m_minTime) + rect.left;
	int y = rect.Height() * (idxYY + 1) / (num + 1) + rect.top;

	CPen *pOldPen = NULL;
	CPen pen1(PS_SOLID, 1, RGB(0, 255, 255));
	CPen pen2(PS_SOLID, 1, RGB(255, 0, 255));
	int state = m_pSyr->getYYerLrcState(idxYY, idxLrc);
	if (state == 0)
	{
		pOldPen = pDC->SelectObject(&pen1);
	}
	else if (state == 1)
	{
		pOldPen = pDC->SelectObject(&pen2);
	}

	int l = x - 2;
	int r = x + 2;
	int t = y - 5;
	int b = y + 5;
	if (l < rect.left)			l = rect.left;
	if (r > rect.right-1)		r = rect.right-1;
	if (t < rect.top+1)			t = rect.top+1;
	if (b > rect.bottom-1)		b = rect.bottom-1;
	pDC->MoveTo(l, t);
	pDC->LineTo(r, t);
	pDC->LineTo(r, b);
	pDC->LineTo(l, b);
	pDC->LineTo(l, t-1);

	t = rect.top - TIME_BREV_H + 3;
	b = t + 8;
	pDC->MoveTo(x, t);
	pDC->LineTo(x, b);

	pDC->SelectObject(pOldPen);
}
Пример #17
0
//绘制框架
void CHistoryView::DrawFrameText(CDC* pDC)
{
	CHistoryDoc* pHistoryDoc = (CHistoryDoc*)GetDocument();	
	//Draw矩形框
	CPen pen( PS_SOLID,m_nPenWidth,RGB(255,0,0) );
	CPen* pOldPen = pDC->SelectObject(&pen);
	pDC->SelectStockObject(NULL_BRUSH);
	pDC->Rectangle(&m_rectFrame);
	pDC->Rectangle(&m_rectTop);
	pDC->Rectangle(&m_rectMid);
	pDC->Rectangle(&m_rectBottom);
	pDC->SelectObject(&pOldPen);

	DrawTitle(pDC);

	//绘制数据
	COLORREF colorOldText = pDC->SetTextColor( RGB(255, 255, 0) );
	COLORREF colorOldBk = pDC->SetBkColor( RGB(0,0,0) );
	int nSel = (  (CHistoryFrame*)GetParentFrame() )->GetSliderCtrlPos();
	pHistoryDoc->GetPriceRange(nSel,m_nStockNumPerPage);
	CRect rect;
	CString str;
	rect.left	= m_rectMid.left - 100;
	rect.right	= m_rectMid.left - 5;
	rect.top	= m_rectMid.top;
	rect.bottom = rect.top - 100;
	str.Format("%.4lf",pHistoryDoc->m_dbHiPrice);
	pDC->DrawText(str,&rect,DT_SINGLELINE | DT_RIGHT);		//历史最高价

	rect.left	= m_rectMid.left - 100;
	rect.right	= m_rectMid.left - 5;
	rect.top	= m_rectMid.top;
	rect.bottom = m_rectMid.bottom;
	str.Format("%.4lf",pHistoryDoc->m_dbLowPrice);
	pDC->DrawText(str,&rect,DT_SINGLELINE | DT_BOTTOM | DT_RIGHT);		//历史最低价

	rect.left	= m_rectMid.left - 100;
	rect.right	= m_rectMid.left - 5;
	rect.top	= (m_rectMid.top + m_rectMid.bottom) / 2 + 10;
	rect.bottom = rect.top - 100;
	double dbAverPrice = ( pHistoryDoc->m_dbHiPrice 
						 + pHistoryDoc->m_dbLowPrice ) / 2;
	str.Format("%.4lf",dbAverPrice);
	pDC->DrawText(str,&rect,DT_SINGLELINE | DT_RIGHT);		//历史平均价
	CPen pen1(PS_SOLID,m_nPenWidth,RGB(255,255,0));
	CPen* pOldPen1 = pDC->SelectObject(&pen1);
	pDC->MoveTo(m_rectMid.left,rect.top);
	pDC->LineTo(m_rectMid.right,rect.top);
	pDC->SelectObject(pOldPen1);

	rect.left	= m_rectMid.left;
	rect.right	= m_rectMid.right;
	rect.top	= m_rectMid.bottom;
	rect.bottom = m_rectBottom.top;
	str.Format("%s",pHistoryDoc->m_arrayHistoryInfo[nSel]->m_cDealDate);
	pDC->DrawText(str,&rect,DT_SINGLELINE | DT_LEFT);		//交易日期
	str.Format("%s",pHistoryDoc->m_arrayHistoryInfo[nSel + m_nStockNumPerPage - 1]->m_cDealDate);
	pDC->DrawText(str,&rect,DT_SINGLELINE | DT_RIGHT);		//交易日期

	pDC->SetTextColor( RGB(0, 255, 0) );
	pDC->SetBkColor( RGB(0,0,0) );
	rect.left = m_rectBottom.left - 100;
	rect.right = m_rectBottom.left - 5;
	rect.top = m_rectBottom.top;
	rect.bottom = m_rectBottom.bottom;	
	str.Format("%d",pHistoryDoc->m_nHiQuantity);
	pDC->DrawText(str,&rect,DT_SINGLELINE | DT_RIGHT);		//最大成交量
	
	pDC->SetTextColor(colorOldText);
	pDC->SetBkColor(colorOldBk);


}
void CListCtrlEx::DrawItem(LPDRAWITEMSTRUCT lpDraw)
{try{
	int cCols = GetHeaderCtrl ()->GetItemCount ();
	CDC *dc = CDC::FromHandle (lpDraw->hDC);
	int xStart = lpDraw->rcItem.left;	
	CImageList *pImages = GetImageList (LVSIL_SMALL);
	BOOL bNeedBorder = FALSE;	

	

	CHeaderCtrl* pHdr = GetHeaderCtrl ();

	
	for (int i = 0; i < cCols; i++)
	{
		LVITEM item;
		TCHAR szItem [10000];
		int colWidth = GetColumnWidth (pHdr->OrderToIndex (i));

		xStart += 5;
		colWidth -= 5;

		item.iItem = lpDraw->itemID;
		item.iSubItem = i;
		item.pszText = szItem;
		item.cchTextMax = sizeof (szItem);
		item.mask = LVIF_IMAGE | LVIF_TEXT;

		GetItem (&item);

		
		if (i == 0)
		{
			item.state = GetItemState (lpDraw->itemID, LVIS_SELECTED|LVIS_FOCUSED);

			COLORREF clrBg = m_vInfo [lpDraw->itemID].clrBg;
			COLORREF clrText = m_vInfo [lpDraw->itemID].clrText;
	
			
			
			if (item.state & LVIS_FOCUSED)
				bNeedBorder = TRUE;

			if (item.state & LVIS_SELECTED)
			{
				clrBg = GetSysColor (COLOR_HIGHLIGHT);
				clrText = GetSysColor (COLOR_HIGHLIGHTTEXT);
				if (bNeedBorder == FALSE)
				{
					if (GetSelectionMark () == (int)lpDraw->itemID)
						bNeedBorder = TRUE;
				}
			}
		
			CBrush br;
			CPen pen;
			CBrush *oldBr;
			CPen *oldPen;

			if (RGBIsEqual (clrBg, clrText))
				clrText = (~clrText) & 0x00FFFFFF;

			dc->SetTextColor (clrText);

			br.CreateSolidBrush (clrBg);
			pen.CreatePen (PS_SOLID, 1, clrBg);

			oldBr = dc->SelectObject (&br);
			oldPen = dc->SelectObject (&pen);
			
			dc->Rectangle (&lpDraw->rcItem);

			
			if (m_bGrid)
			{
				CPen pen1 (PS_SOLID, 1, m_clrGrid);
				dc->SelectObject (&pen1);
				dc->MoveTo (lpDraw->rcItem.left, lpDraw->rcItem.bottom-1);
				dc->LineTo (lpDraw->rcItem.right, lpDraw->rcItem.bottom-1);
				dc->SelectObject (oldPen);
			}

			dc->SelectObject (oldBr);
			dc->SelectObject (oldPen);

			if (pImages)
			{
				

				CPoint pt;
				pt.x = xStart;
				pt.y = lpDraw->rcItem.top;
				if (m_pSelImages && (item.state & LVIS_SELECTED))
					m_pSelImages->Draw (dc, item.iImage, pt, ILD_TRANSPARENT);
				else
					pImages->Draw (dc, item.iImage, pt, ILD_TRANSPARENT);

				IMAGEINFO inf;
				pImages->GetImageInfo (item.iImage, &inf);

				xStart += inf.rcImage.right - inf.rcImage.left + 5;
				colWidth -= inf.rcImage.right - inf.rcImage.left + 5;
			}
		}

		if (*item.pszText)
		{
			

			int needX = GetStringWidth (item.pszText);
			BOOL bDrawText = TRUE;

			RECT rcText = lpDraw->rcItem;
			rcText.left = xStart;
			rcText.right = xStart + colWidth - 5;

			
			if (needX > colWidth-5)
			{
				RECT rc = rcText;
				int dx = GetStringWidth ("...");
				if (dx <= colWidth-5)
				{
					rc.left = rc.right - dx;
					dc->DrawText ("...", &rc, DT_SINGLELINE | DT_LEFT | DT_VCENTER);
					rcText.right = rc.left - 5;
				}
				else
					bDrawText = FALSE;
			}

			if (bDrawText)
				dc->DrawText (szItem, &rcText, DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_NOPREFIX);
		}

		xStart += colWidth;

		
		if (m_bGrid)
		{
			
			CPen pen (PS_SOLID, 1, m_clrGrid);
			CPen *oldPen = dc->SelectObject (&pen);
			dc->MoveTo (xStart-1, lpDraw->rcItem.top);
			dc->LineTo (xStart-1, lpDraw->rcItem.bottom);
			dc->SelectObject (oldPen);
		}
	}

	if (bNeedBorder)
	{
		

		dc->SetTextColor (m_vInfo [lpDraw->itemID].clrText);
		RECT rc = lpDraw->rcItem;
		rc.bottom--; rc.right--;
		dc->DrawFocusRect (&rc);
	}

}catch (...){}
}
Пример #19
0
void wxGenericComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) )
{
    // Determine wxDC to use based on need to double-buffer or
    // use system-generated transparent background portions
    wxDC* dcPtr;
    if ( HasTransparentBackground() )
        dcPtr = new wxPaintDC(this);
    else
        dcPtr = new wxAutoBufferedPaintDC(this);
    wxDC& dc = *dcPtr;

    wxSize sz = GetClientSize();
    const wxRect& butRect = m_btnArea;
    wxRect tcRect = m_tcArea;
    wxRect fullRect(0, 0, sz.x, sz.y);

    // artificial simple border
    if ( m_widthCustomBorder )
    {
        int customBorder = m_widthCustomBorder;

        // Set border colour
#ifdef __WXMAC__
        wxPen pen1( wxColour(133,133,133),
                    customBorder,
                    wxSOLID );
#else        
        wxPen pen1( wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT),
                    customBorder,
                    wxPENSTYLE_SOLID);
#endif
        dc.SetPen( pen1 );

        // area around both controls
        wxRect rect2(fullRect);
        if ( m_iFlags & wxCC_IFLAG_BUTTON_OUTSIDE )
        {
            rect2 = tcRect;
            if ( customBorder == 1 )
            {
                rect2.Inflate(1);
            }
            else
            {
            #ifdef __WXGTK__
                rect2.x -= 1;
                rect2.y -= 1;
            #else
                rect2.x -= customBorder;
                rect2.y -= customBorder;
            #endif
                rect2.width += 1 + customBorder;
                rect2.height += 1 + customBorder;
            }
        }

        dc.SetBrush( *wxTRANSPARENT_BRUSH );
        dc.DrawRectangle(rect2);
    }

    // Clear the main background if the system doesn't do it by itself
    if ( !HasTransparentBackground() &&
         (tcRect.x > 0 || tcRect.y > 0) )
    {
        wxColour winCol = GetParent()->GetBackgroundColour();
        dc.SetBrush(winCol);
        dc.SetPen(winCol);

        dc.DrawRectangle(fullRect);
    }

    if ( !m_btn )
    {
        // Standard button rendering
        DrawButton(dc, butRect);
    }

    // paint required portion on the control
    if ( !m_text || m_widthCustomPaint )
    {
        wxASSERT( m_widthCustomPaint >= 0 );

        // Clear the text-control area background
        wxColour tcCol = GetBackgroundColour();
        dc.SetBrush(tcCol);
        dc.SetPen(tcCol);
        dc.DrawRectangle(tcRect);

        // this is intentionally here to allow drawed rectangle's
        // right edge to be hidden
        if ( m_text )
            tcRect.width = m_widthCustomPaint;

        dc.SetFont( GetFont() );

        dc.SetClippingRegion(tcRect);
        if ( m_popupInterface )
            m_popupInterface->PaintComboControl(dc, tcRect);
        else
            wxComboPopup::DefaultPaintComboControl(this, dc, tcRect);
    }

    delete dcPtr;
}
/*----------------------------------------------------------------------------*/
void ChannelEdit :: paintEvent(QPaintEvent *event)
{
  QPainter painter(this);

  painter.fillRect(rect(), m_bgColor);
  painter.setPen(Qt::darkCyan);
  painter.drawText(QRectF(0,0,50, height()),
                   Qt::AlignCenter,
                   tr("Channel\n%1").arg(QString::number(m_channelId)));
  if(m_audioOpened)
  {
    qreal dX = (qreal)width() / (qreal) m_windowSize;

    QPen pen(m_markerColor);
    painter.setPen(pen);
    //Draw position line
    painter.drawLine(QPointF(dX * (m_position - m_startPosition), 0), QPointF(dX * (m_position - m_startPosition), height()));

    QPen pen1(m_fgColor);
    painter.setPen(pen1);


    int size = effects.size();
    for(int i = 0; i < size; i++)
    {
      EffectProperties *prop = effects[i];
      int pos = (int)(dX * (audioController->duration2quants(prop->timeStart()) - m_startPosition));
      painter.drawLine(QPoint(pos, 0), QPoint(pos, height()));
      if(prop->channel() < m_channelId)
      {
        //draw bottom arrow
        painter.drawLine(QPoint(pos - 2, height() - 8), QPoint(pos, height()));
        painter.drawLine(QPoint(pos + 2, height() - 8), QPoint(pos, height()));
      }
      else
      if(prop->channel() > m_channelId)
      {
        //draw top arrow
        painter.drawLine(QPoint(pos - 2, 8), QPoint(pos, 0));
        painter.drawLine(QPoint(pos + 2, 8), QPoint(pos, 0));
      }
      else
//      if(prop->channel() == m_channelId)
      {
        //draw effect
        if(effectController->effectSelected() == prop->id())
        {
          QBrush brush(Qt::darkBlue);
          painter.setBrush(brush);
        }
        else
        {
          QBrush brush(Qt::yellow);
          painter.setBrush(brush);
        }

        QPolygon pol = createPolygon(pos);
        painter.drawPolygon(pol);
        painter.drawPixmap(QRect(pos - 15, 1, 30, 30), effectController->effectIcon(prop->effectId()));
/*
        qreal radius = (height() - 10) / 2;
        qreal left = pos - radius;
        qreal top = 5;

        QRectF r(left, top, 2 * radius, 2 * radius);
        painter.drawEllipse(r);
*/
      }
    }
  }

  Inherited::paintEvent(event);
}
Пример #21
0
void CPlotter::DrawOverlay()                                 //DrawOverlay()
{
  if(m_OverlayPixmap.isNull() or m_WaterfallPixmap.isNull() or
     m_dialFreq==0) return;
//  int w = m_WaterfallPixmap.width();
  int x,y;

  QRect rect;
  QPainter painter(&m_OverlayPixmap);
  painter.initFrom(this);
  QLinearGradient gradient(0, 0, 0 ,m_h2);  //fill background with gradient
  gradient.setColorAt(1, Qt::black);
  gradient.setColorAt(0, Qt::darkBlue);
  painter.setBrush(gradient);
  painter.drawRect(0, 0, m_w, m_h2);
  painter.setBrush(Qt::SolidPattern);

  m_fSpan = m_w*m_fftBinWidth;
  int n=m_fSpan/10;
  m_freqPerDiv=10;
  if(n>25) m_freqPerDiv=50;
  if(n>70) m_freqPerDiv=100;
  if(n>140) m_freqPerDiv=200;
  if(n>310) m_freqPerDiv=500;
  float pixPerHdiv = m_freqPerDiv/m_fftBinWidth;
  float pixPerVdiv = float(m_h2)/float(VERT_DIVS);

  m_RFHz=int(1000000.0*m_dialFreq+m_StartFreq + 0.5) % 1000;
  m_hdivs = m_w*m_fftBinWidth/m_freqPerDiv + 0.9999;

  painter.setPen(QPen(Qt::white, 1,Qt::DotLine));
  for( int i=1; i<m_hdivs; i++)                   //draw vertical grids
  {
    x=int(i*pixPerHdiv);
    painter.drawLine(x,0,x,m_h2);
  }

  for( int i=1; i<VERT_DIVS; i++)                 //draw horizontal grids
  {
    y = (int)( (float)i*pixPerVdiv );
    painter.drawLine(0,y,m_w,y);
  }

  QRect rect0;
  QPainter painter0(&m_ScalePixmap);
  painter0.initFrom(this);

  //create Font to use for scales
  QFont Font("Arial");
  Font.setPointSize(12);
  QFontMetrics metrics(Font);
  Font.setWeight(QFont::Normal);
  painter0.setFont(Font);
  painter0.setPen(Qt::black);

  m_ScalePixmap.fill(Qt::white);
  painter0.drawRect(0, 0, m_w, 30);

//draw tick marks on upper scale
  for( int i=1; i<m_hdivs; i++) {         //major ticks
    x = (int)( (float)i*pixPerHdiv );
    painter0.drawLine(x,18,x,30);
  }
  int minor=5;
  if(m_freqPerDiv==200) minor=4;
  for( int i=1; i<minor*m_hdivs; i++) {   //minor ticks
    x = i*pixPerHdiv/minor;
    painter0.drawLine(x,24,x,30);
  }

//draw frequency values
  MakeFrequencyStrs();
  for( int i=0; i<=m_hdivs; i++) {
    if(0==i) {
      //left justify the leftmost text
      x = (int)( (float)i*pixPerHdiv);
      rect0.setRect(x,0, (int)pixPerHdiv, 20);
      painter0.drawText(rect0, Qt::AlignLeft|Qt::AlignVCenter,
                       m_HDivText[i]);
    }
    else if(m_hdivs == i) {
      //right justify the rightmost text
      x = (int)( (float)i*pixPerHdiv - pixPerHdiv);
      rect0.setRect(x,0, (int)pixPerHdiv, 20);
      painter0.drawText(rect0, Qt::AlignRight|Qt::AlignVCenter,
                       m_HDivText[i]);
    } else {
      //center justify the rest of the text
      x = (int)( (float)i*pixPerHdiv - pixPerHdiv/2);
      rect0.setRect(x,0, (int)pixPerHdiv, 20);
      painter0.drawText(rect0, Qt::AlignHCenter|Qt::AlignVCenter,
                       m_HDivText[i]);
    }
  }

  QPen pen0(Qt::green, 3);              //Mark decoding range with green line
  painter0.setPen(pen0);
  int x1,x2;
  if(m_nsps==8192) {
    x=XfromFreq(1500);
    x1=x - 100/m_fftBinWidth;
    x2=x + 100/m_fftBinWidth;
  } else {
    x=XfromFreq(1612.5);
    x1=x - 12.5/m_fftBinWidth;
    x2=x + 12.5/m_fftBinWidth;
  }
  pen0.setWidth(6);
  painter0.drawLine(x1,28,x2,28);

  QPen pen1(Qt::red, 3);                         //Mark Tx Freq with red tick
  painter0.setPen(pen1);
  x = XfromFreq(m_TxFreq);
  painter0.drawLine(x,17,x,30);

}
Пример #22
0
void CMapManagerView::OnLButtonDblClk(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	if(m_CurOper == ID_MEASUREDISTANCE)
	{
		m_bCountDis=0;
		CDC *pDC=GetDC();
		pDC->SetBkMode(TRANSPARENT);
		CPen pen(PS_SOLID,2,RGB(0,255,0));
        CPen *pOldPen=pDC->SelectObject(&pen);
		CBrush brush(RGB(200,255,200));
		CFont font;
		font.CreateFont(15,0,0,0,0,0,0,0,0,OUT_DEFAULT_PRECIS,CLIP_CHARACTER_PRECIS 
			,DEFAULT_QUALITY,DEFAULT_PITCH&FF_SWISS,"宋体");
		CFont *pOldFont=pDC->SelectObject(&font);
		CBrush *pOldBrush=pDC->SelectObject(&brush);
		pDC->Rectangle(point.x+5,point.y+5,point.x+208,point.y+60);
		
		float disX,disY,DisXY;
		float TempResult=0.0;
		for(int i=0;i<CountArray.GetSize()-1;i++)
		{
			disX=CountArray.GetAt(i+1).x-CountArray.GetAt(i).x;
			disY=CountArray.GetAt(i+1).y-CountArray.GetAt(i).y;
			DisXY=sqrt(disX*disX+disY*disY);
			TempResult+=DisXY;
		}
		
		CString ss;
		TempResult=labs(TempResult);
		ss.Format("%f",TempResult);
		ss="直线距离"+ss+"米";
		
		pDC->TextOut(point.x+15,point.y+15,ss);
		
		
		CountArray.RemoveAll();//清除当前记录点轨迹坐标串数组
	}
	if(m_CurOper == ID_MEASUREAREA)
	{
		m_bCountArea=0;
		CDC *pDC1=GetDC(); 			
		OnPrepareDC(pDC1);
		pDC1->SetBkMode(TRANSPARENT);//使当前字体无背景色
		CPen pen1(PS_DOT,1,RGB(0,0,255));
		CBrush brush1(HS_DIAGCROSS,RGB(3,200,200));
		CPen *pOldPen1=pDC1->SelectObject(&pen1);
		CBrush *pOldBrush1=pDC1->SelectObject(&brush1);
		int m_Number=CountArray.GetSize();
		CPoint *p_Point=new CPoint[m_Number];
		for(int i=0;i<m_Number;i++)
		{
			p_Point[i]=CountArray.GetAt(i);//画一个区域多变形
		}
		pDC1->Polygon(p_Point,m_Number);
		delete []p_Point;
		
	
		CDC *pDC=GetDC();
		pDC->SetBkMode(TRANSPARENT);
		CPen pen(PS_DOT,1,RGB(250,0,0));
        CPen *pOldPen=pDC->SelectObject(&pen);
		CBrush brush(RGB(200,255,200));
		CFont font;
		font.CreateFont(15,0,0,0,0,0,0,0,0,OUT_DEFAULT_PRECIS,CLIP_CHARACTER_PRECIS 
			,DEFAULT_QUALITY,DEFAULT_PITCH&FF_SWISS,"宋体");
		CFont *pOldFont=pDC->SelectObject(&font);
		CBrush *pOldBrush=pDC->SelectObject(&brush);
		pDC->Rectangle(point.x+5,point.y+5,point.x+200,point.y+50);
		
		float Result=0.0;
		float Area;
		if(CountArray.GetSize()>2)
		{
			CountArray.Add(CountArray.GetAt(0));
			for(int i=0;i<CountArray.GetSize()-1;i++)
			{
				CPoint Point1=CountArray.GetAt(i+1);
				CPoint Point0=CountArray.GetAt(i);
				

				Area=(-1)*(Point0.x*Point1.y-Point1.x*Point0.y)/2;
				Result+=Area;
			}
		}
		
		CString pp;
		Result=labs(Result);
		pp.Format("%f",Result);
		pp="面积"+pp+"平方米";
		pDC->TextOut(point.x+15,point.y+15,pp);
		
		CountArray.RemoveAll();//清除当前记录点轨迹坐标串数组
	}
	CView::OnLButtonDblClk(nFlags, point);
}
Пример #23
0
void CChartAreaWnd::DrawTaskBar( CDC* pDC, int x, int y, int w, int h, int fHeight, char* wbuff )
{
    int     x1,y1,x2,y2;
    CBrush* pOldBrush; 
    CPen*   pOldPen;
    CBrush  myBrush1;
    char    wbuff2[BUFF_SIZE];

    x1 = x;
    y1 = y;
    x2 = x + w;
    y2 = y + h;

    COLORREF col = RGB( 190, 190, 190 );
    
    CPen    pen1( PS_SOLID, 1, col );  
    myBrush1.CreateSolidBrush( col );
    pDC->SetBkColor( col );    
    pOldPen   = pDC->SelectObject( &pen1 );
    pOldBrush = pDC->SelectObject( &myBrush1 );

    pDC->Rectangle( x1, y1, x2, y2 );    

    pDC->MoveTo( x1, y1 );
    pDC->LineTo( x2, y1 );
    pDC->LineTo( x2, y2 );
    pDC->LineTo( x1, y2 );
    pDC->LineTo( x1, y1 );

    pDC->SelectObject( pOldPen );
    pDC->SelectObject( pOldBrush );

    x1 = x1+1;
    y1 = y1+1;    
    x2 = x2-1;
    y2 = y2-1;


    CPen    pen2( PS_SOLID, 1, RGB(255, 255, 255) );  
    pOldPen = pDC->SelectObject( &pen2 );
    pDC->MoveTo( x1, y1 );
    pDC->LineTo( x2, y1 );
    pDC->MoveTo( x1, y1 );
    pDC->LineTo( x1, y2 );
    pDC->SelectObject( pOldPen );


    CPen    pen3( PS_SOLID, 1, RGB(0, 0, 0) );  
    pOldPen = pDC->SelectObject( &pen3 );
    pDC->MoveTo( x2, y2 );
    pDC->LineTo( x2, y1 );
    pDC->MoveTo( x2, y2 );
    pDC->LineTo( x1, y2 );
    pDC->SelectObject( pOldPen );


    int slen = strlen(wbuff);

    for(;;) {
        if ( (fHeight/2)*slen > w ) 
            slen = slen - 2;
        else
            break;
    }

    if ( slen > 0 ){ 
        strncpy( wbuff2, wbuff, slen );
        wbuff2[slen] = '\0';
        pDC->TextOut( x1 + (w-(fHeight/2)*strlen(wbuff2))/2, 
                      y1 + (h-(fHeight))/2 ,
                      wbuff2, strlen(wbuff2) );
    }

}
Пример #24
0
void CSkinButton2::DrawFrame(Gdiplus::Graphics& gdi,CRect& rect)
{
	if( m_enmuDrawType == NO_FRAME )
	{
		Gdiplus::Pen pen1( m_colFrame1 );
		gdi.DrawLine( &pen1, rect.left+1, rect.top, rect.right-2, rect.top );
		gdi.DrawLine( &pen1, rect.left+1, rect.bottom-1, rect.right-2, rect.bottom-1 );
		gdi.DrawLine( &pen1, rect.left, rect.top+1, rect.left, rect.bottom-2 );
		gdi.DrawLine( &pen1, rect.right-1, rect.top+1, rect.right-1, rect.bottom-2 );

		Gdiplus::Color colpix;
		pen1.GetColor( &colpix );
		colpix.SetValue( Gdiplus::Color::MakeARGB(colpix.GetA()/2,colpix.GetR(),colpix.GetG(),colpix.GetB() ) );
		Gdiplus::Pen penPix1( colpix );
		gdi.DrawLine( &penPix1, rect.left, rect.top, rect.left+1, rect.top );
		gdi.DrawLine( &penPix1, rect.right-1, rect.top, rect.right-1, rect.top+1 );
		gdi.DrawLine( &penPix1, rect.right-1, rect.bottom-1, rect.right-2, rect.bottom-1 );
		gdi.DrawLine( &penPix1, rect.left,  rect.bottom-1, rect.left+1,  rect.bottom-1 );

		CRect rect2 = rect;
		::InflateRect( &rect2, -1,-1 );
		if( !m_bMouseDown )
		{
			Gdiplus::Pen pen2(m_colFrame2);
			if( m_bMouseDown )
				pen2.SetColor(m_colFrame1);
			else
				pen2.SetColor(m_colFrame2);

			gdi.DrawLine( &pen2, rect2.left+1, rect2.top, rect2.right-2, rect2.top );
			gdi.DrawLine( &pen2, rect2.left+1, rect2.bottom-1, rect2.right-2, rect2.bottom-1 );
			gdi.DrawLine( &pen2, rect2.left, rect2.top+1, rect2.left, rect2.bottom-2 );
			gdi.DrawLine( &pen2, rect2.right-1, rect2.top+1, rect2.right-1, rect2.bottom-2 );

			Gdiplus::Color colpix2;
			pen2.GetColor( &colpix2 );
			colpix2.SetValue( Gdiplus::Color::MakeARGB(colpix2.GetA()/2,colpix2.GetR(),colpix2.GetG(),colpix2.GetB() ) );
			Gdiplus::Pen penPix2( colpix2 );
			gdi.DrawLine( &penPix2, rect2.left, rect2.top, rect2.left+1, rect2.top );
			gdi.DrawLine( &penPix2, rect2.right-1, rect2.top, rect2.right-1, rect2.top+1 );
			gdi.DrawLine( &penPix2, rect2.right-1, rect2.bottom-1, rect2.right-2, rect2.bottom-1 );
			gdi.DrawLine( &penPix2, rect2.left,  rect2.bottom-1, rect2.left+1,  rect2.bottom-1 );
		}

		if( m_bMouseDown )
		{
			Gdiplus::RectF rc( rect2.left, rect2.top, rect2.Width(), rect2.Height()/3 );
			Gdiplus::Color colBrush1,colBrush2;
			colBrush1.SetValue( Gdiplus::Color::MakeARGB(15,1,1,1)  );
			colBrush2.SetValue( Gdiplus::Color::MakeARGB(0,1,1,1)  );

			LinearGradientBrush brush( rc, colBrush1, colBrush2,LinearGradientModeVertical );
			gdi.FillRectangle( &brush, rc );
		}
		else
		{
			Gdiplus::RectF rc( rect2.left, rect2.top, rect2.Width(), rect2.Height()/2 );
			rc.Inflate(-1,-1);
			LinearGradientBrush brush( rc, m_colBrush1, m_colBrush2,LinearGradientModeVertical );
			gdi.FillRectangle( &brush, rc );
		}

		return;
	}
	else if( m_enmuDrawType == NO_FRAME_SELECT )
	{
		Gdiplus::Pen pen1( m_colFrame1 );
		gdi.DrawLine( &pen1, rect.left+1, rect.top, rect.right-2, rect.top );
		gdi.DrawLine( &pen1, rect.left+1, rect.bottom-1, rect.right-2, rect.bottom-1 );
		gdi.DrawLine( &pen1, rect.left, rect.top+1, rect.left, rect.bottom-2 );
		gdi.DrawLine( &pen1, rect.right-1, rect.top+1, rect.right-1, rect.bottom-2 );

		Gdiplus::Color colpix;
		pen1.GetColor( &colpix );
		colpix.SetValue( Gdiplus::Color::MakeARGB(colpix.GetA()/2,colpix.GetR(),colpix.GetG(),colpix.GetB() ) );
		Gdiplus::Pen penPix1( colpix );
		gdi.DrawLine( &penPix1, rect.left, rect.top, rect.left+1, rect.top );
		gdi.DrawLine( &penPix1, rect.right-1, rect.top, rect.right-1, rect.top+1 );
		gdi.DrawLine( &penPix1, rect.right-1, rect.bottom-1, rect.right-2, rect.bottom-1 );
		gdi.DrawLine( &penPix1, rect.left,  rect.bottom-1, rect.left+1,  rect.bottom-1 );

		CRect rect2 = rect;
		::InflateRect( &rect2, -1,-1 );
		if( !m_bMouseDown )
		{
			Gdiplus::Pen pen2(m_colFrame2);
			if( m_bMouseDown )
				pen2.SetColor(m_colFrame1);
			else
				pen2.SetColor(m_colFrame2);

			gdi.DrawLine( &pen2, rect2.left+1, rect2.top, rect2.right-2, rect2.top );
			gdi.DrawLine( &pen2, rect2.left+1, rect2.bottom-1, rect2.right-2, rect2.bottom-1 );
			gdi.DrawLine( &pen2, rect2.left, rect2.top+1, rect2.left, rect2.bottom-2 );
			gdi.DrawLine( &pen2, rect2.right-1, rect2.top+1, rect2.right-1, rect2.bottom-2 );

			Gdiplus::Color colpix2;
			pen2.GetColor( &colpix2 );
			colpix2.SetValue( Gdiplus::Color::MakeARGB(colpix2.GetA()/2,colpix2.GetR(),colpix2.GetG(),colpix2.GetB() ) );
			Gdiplus::Pen penPix2( colpix2 );
			gdi.DrawLine( &penPix2, rect2.left, rect2.top, rect2.left+1, rect2.top );
			gdi.DrawLine( &penPix2, rect2.right-1, rect2.top, rect2.right-1, rect2.top+1 );
			gdi.DrawLine( &penPix2, rect2.right-1, rect2.bottom-1, rect2.right-2, rect2.bottom-1 );
			gdi.DrawLine( &penPix2, rect2.left,  rect2.bottom-1, rect2.left+1,  rect2.bottom-1 );
		}

	/*	if( m_bMouseDown )
		{
			Gdiplus::RectF rc( rect2.left, rect2.top, rect2.Width(), rect2.Height()/3 );
			Gdiplus::Color colBrush1,colBrush2;
			colBrush1.SetValue( Gdiplus::Color::MakeARGB(15,1,1,1)  );
			colBrush2.SetValue( Gdiplus::Color::MakeARGB(0,1,1,1)  );

			LinearGradientBrush brush( rc, colBrush1, colBrush2,LinearGradientModeVertical );
			gdi.FillRectangle( &brush, rc );
		}
		else
		{
			Gdiplus::RectF rc( rect2.left, rect2.top, rect2.Width(), rect2.Height()/2 );
			rc.Inflate(-1,-1);
			LinearGradientBrush brush( rc, m_colBrush1, m_colBrush2,LinearGradientModeVertical );
			gdi.FillRectangle( &brush, rc );
		}*/

		CRect rect3 = rect2;
		::InflateRect( &rect3, -1,-1 );
		Gdiplus::RectF rc( rect3.left, rect3.top, rect3.Width(), rect3.Height() );
		LinearGradientBrush brush( rc, m_colBK, m_colBK,LinearGradientModeVertical );
		gdi.FillRectangle( &brush, rc );

		Gdiplus::Color colBlack1 = Gdiplus::Color::MakeARGB(30,50,50,50);
		Gdiplus::Color colBlack2 = Gdiplus::Color::MakeARGB(15,50,50,50);
	    Gdiplus::RectF rc1( rect3.left, rect3.top+rect3.Height()/2, rect3.Width(), rect3.Height()/2 );
		LinearGradientBrush brush2( rc1, colBlack1, colBlack2,LinearGradientModeVertical );
		gdi.FillRectangle( &brush2, rc1 );
		return;
	}
	if( m_enmuDrawType == TOP_ARC )
	{
		Gdiplus::Pen pen1( m_colFrame1 );
		gdi.DrawLine( &pen1, rect.left+5, rect.top, rect.right-7, rect.top );
		gdi.DrawLine( &pen1, rect.left, rect.bottom-1, rect.right, rect.bottom-1 );
		gdi.DrawLine( &pen1, rect.left, rect.top+5, rect.left, rect.bottom-2 );
		gdi.DrawLine( &pen1, rect.right-1, rect.top+5, rect.right-1, rect.bottom-2 );

		CRect rect2 = rect;
		::InflateRect( &rect2, -1,-1 );
		if( !m_bMouseDown )
		{
			Gdiplus::Pen pen2(m_colFrame2);
			gdi.DrawLine( &pen2, rect2.left+4, rect2.top, rect2.right-5, rect2.top );
			gdi.DrawLine( &pen2, rect2.left, rect2.bottom-1, rect2.right-1, rect2.bottom-1 );
			gdi.DrawLine( &pen2, rect2.left, rect2.top+4, rect2.left, rect2.bottom-2 );
			gdi.DrawLine( &pen2, rect2.right-1, rect2.top+4, rect2.right-1, rect2.bottom-2 );

			Gdiplus::RectF rectLeftTop2;
			rectLeftTop2.X = rect2.left;
			rectLeftTop2.Y  = rect2.top;
			rectLeftTop2.Width = 6;
			rectLeftTop2.Height  = 6;
			gdi.DrawArc(  &pen2, rectLeftTop2,180,90 );

			Gdiplus::RectF rectRightTop2;
			rectRightTop2.X = rect2.right-7;
			rectRightTop2.Y  = rect2.top;
			rectRightTop2.Width = 6;
			rectRightTop2.Height  = 6;
			gdi.DrawArc(  &pen2, rectRightTop2,270,90 );
		}

		Gdiplus::RectF rectLeftTop;
		rectLeftTop.X = rect.left;
		rectLeftTop.Y  = rect.top;
		rectLeftTop.Width = 9;
		rectLeftTop.Height  = 9;
		gdi.DrawArc(  &pen1, rectLeftTop,180,90 );

		Gdiplus::RectF rectRightTop;
		rectRightTop.X = rect.right-10;
		rectRightTop.Y  = rect.top;
		rectRightTop.Width = 9;
		rectRightTop.Height  = 9;
		gdi.DrawArc(  &pen1, rectRightTop,270,90 );

		/*Gdiplus::SolidBrush sb( m_colBrush );
		Gdiplus::Brush *pbrush = sb.Clone();*/
		if( m_bMouseDown )
		{
			Gdiplus::RectF rc( rect2.left, rect2.top, rect2.Width(), rect2.Height()/3 );
			Gdiplus::Color colBrush1,colBrush2;
			colBrush1.SetValue( Gdiplus::Color::MakeARGB(15,1,1,1)  );
			colBrush2.SetValue( Gdiplus::Color::MakeARGB(0,1,1,1)  );

			LinearGradientBrush brush( rc, colBrush1, colBrush2,LinearGradientModeVertical );
			gdi.FillRectangle( &brush, rc );
		}
		else
		{
			Gdiplus::RectF rc( rect2.left, rect2.top, rect2.Width(), rect2.Height()/2 );
			rc.Inflate(-1,-1);
			LinearGradientBrush brush( rc, m_colBrush1, m_colBrush2,LinearGradientModeVertical );
			gdi.FillRectangle( &brush, rc );
		}
	}
	else if( m_enmuDrawType == BOTTON_ARC )
	{
	}
	else if( m_enmuDrawType == RIGHT_ARC )
	{
	}
	else if( m_enmuDrawType == LEFT_ARC )
	{
	}
	else if( m_enmuDrawType & (TOP_ARC|BOTTON_ARC) || m_enmuDrawType & (RIGHT_ARC|LEFT_ARC) )
	{
		// 四角都有弧线
	}

	//gdi.DrawString(
}
Пример #25
0
void CTimeAxis::drawTimeBrev(CDC* pDC)
{
	if (pDC == NULL)
		return;

	if (m_pSyr == NULL)
		return;

	int num = m_pSyr->getYYerCount();
	if (num < 1)
		return;

	CRect rect;
	this->GetWindowRect(&rect);
	ScreenToClient(&rect);
	rect.top += 4;
	rect.bottom = rect.top + 6;
	CPen pen(PS_SOLID, 3, RGB(0, 255, 255));
	CPen pen1(PS_SOLID, 1, RGB(255, 0, 0));
	CPen *pOldPen = NULL;
	int maxTime = 2*m_pSyr->getMaxTime();
	if (maxTime >= m_allTime)
	{
// 		pOldPen = pDC->SelectObject(&pen);
// 		pDC->MoveTo(rect.left, rect.top + 3);
// 		pDC->LineTo(rect.right-1, rect.top + 3);

		CRect rect1;
		rect1.left = rect.Width() * m_minTime / maxTime + rect.left;
		rect1.right = rect.Width() * m_maxTime / maxTime + rect.left;
		rect1.top = rect.top;
		rect1.bottom = rect.bottom;
		pDC->SelectObject(&pen1);
// 		pDC->Rectangle(&rect1);
		pDC->MoveTo(rect1.left, rect1.top);
		pDC->LineTo(rect1.left, rect1.bottom-1);
		pDC->LineTo(rect1.right-1, rect1.bottom-1);
		pDC->LineTo(rect1.right-1, rect1.top);
		pDC->LineTo(rect1.left, rect1.top);
		pDC->SelectObject(pOldPen);
	}
	else if (maxTime > m_minTime)
	{
		CRect rect1(rect);
		rect1.left = rect.Width() * m_minTime / m_maxTime + rect.left;
		rect1.right = rect.Width() * maxTime / m_maxTime + rect.left;

// 		pOldPen = pDC->SelectObject(&pen);
// 		pDC->MoveTo(rect1.left, rect1.top + 3);
// 		pDC->LineTo(rect1.right-1, rect1.top + 3);

		pDC->SelectObject(&pen1);
// 		pDC->Rectangle(&rect);
		pDC->MoveTo(rect.left, rect.top);
		pDC->LineTo(rect.left, rect.bottom-1);
		pDC->LineTo(rect.right-1, rect.bottom-1);
		pDC->LineTo(rect.right-1, rect.top);
		pDC->LineTo(rect.left, rect.top);
		pDC->SelectObject(pOldPen);
	}
// 	Invalidate();
}
Пример #26
0
void Hokuyo::paintEvent(QPaintEvent *event)
// display the data on the winder
{

    flag = 0;
	int center_h = (int) (this->parentWidget()->height() /2);
	int center_w = (int) (this->parentWidget()->width() /2);
    QPainter painter(this);

    //***************************************************************

        QPen pen2(Qt::black, 2, Qt::SolidLine);
        painter.setPen(pen2);
        painter.setBrush(Qt::red);
        QRectF rectangle(center_w - 2, center_h-2, 4, 4);
        painter.drawEllipse(rectangle);
    //*******************************************************

    if(showLRF) // if show laser range finder
    {
        QPen pen(Qt::black, 2, Qt::DashDotDotLine);

        painter.setPen(pen);

        painter.drawLine(20, 40, 120, 40);
    }

    else if(showIR) // if show small infrared sensor
    {
        QPen pen(Qt::black, 2, Qt::SolidLine);

        painter.setPen(pen);

        painter.drawLine(20, 40, 20 + center_h, 40);

    }
//**************************************************************
    if(showIR)
    {
        painter.setBrush(Qt::cyan);

        QPen pen1(Qt::black, 2, Qt::SolidLine);
	
	QPointF points_front[3];
	QPointF points_back[3];


	points_front[0] = QPointF(center_w,center_h);
	points_front[1] = QPointF(center_w - 50, center_h + (float)this->IR01_update * center_h);
	points_front[2] = QPointF(center_w + 50, center_h + (float)this->IR01_update * center_h);

    	painter.setPen(pen1);
    	painter.drawPolygon(points_front,3);

    	painter.setBrush(Qt::darkCyan);

	points_back[0] = QPointF(center_w, center_h);
	points_back[1] = QPointF(center_w - 50, center_h - (float)this->IR02_update * center_h);
	points_back[2] = QPointF(center_w + 50, center_h - (float)this->IR02_update * center_h);

    	painter.drawPolygon(points_back,3);
    }


    else if(showLRF)
    {
        QPen pen3(Qt::black, 2, Qt::DashDotDotLine);
        painter.setPen(pen3);

        int count = 0;

        if(hokuyo_points!=NULL)
        {
            for(int it=0;it<683;it++)
            {
                painter.drawPoint(hokuyo_points[it].x * 100 + 300, -(hokuyo_points[it].y * 100) + 300);
                if(showlines)
                painter.drawLine(300,300,hokuyo_points[it].x * 100 + 300, -(hokuyo_points[it].y * 100) + 300);
                count ++;
            }
        }

        flag = 1;
   }


}
int CXTPSyntaxEditDrawTextProcessor::PrintRowPart(CDC* pDC, int nRow, int nPosY, UINT nFlags,
												  LPCTSTR pcszText, int nchCount, int *pnPrintedTextLen)
{
	if (pnPrintedTextLen)
		*pnPrintedTextLen = 0;

	if (m_nPrintingRow != nRow)
	{
		m_nPrintingRow = nRow;
		m_ptNextPrintPos = CPoint(0, 0);
	}

	if (nRow == -1)
		return 0;

	//--------------------------------------------------------
	int nTextLen = 0;

	if (nchCount < 0)
	{
		nchCount = (int)_tcsclen(pcszText);
		nTextLen = (int)_tcslen(pcszText);
	}
	else
	{
		nTextLen = (int)_tcsnbcnt(pcszText, nchCount);
	}
	ASSERT(nchCount <= (int)_tcsclen(pcszText));

	//--------------------------------------------------------
	if (m_arBuf_aDx.GetSize() < nTextLen)
		m_arBuf_aDx.SetSize(nTextLen + 100);

	LPINT alpDx = (int*)m_arBuf_aDx.GetData();

	//--------------------------------------------------------
	CRect rcText = m_rcTextRect;
	int nTextLen_rest = nTextLen;
	LPCTSTR pTxt = NULL;

	for (pTxt = pcszText; nTextLen_rest;)
	{
		int nY = m_rcTextRect.top + nPosY + m_ptNextPrintPos.y;
		int nX = m_rcTextRect.left + m_ptNextPrintPos.x;

		if (nY + GetRowHeight() > m_rcTextRect.bottom)
			break;

		//--------------------------------------------------------
		int nMaxExtent = max(0, rcText.right - nX - 20);
		int nFit = 0;

		CSize szText(0, 0);

		BOOL bResExt = GetTextExtentExPoint(
						m_bUseOutputDC ? pDC->m_hDC : pDC->m_hAttribDC,  // HDC hdc, // handle to DC
						pTxt,               // LPCTSTR lpString,         // character string
						nTextLen_rest,      // int nCount,               // number of characters
						nMaxExtent,         // maximum extent for string
						&nFit,              // LPINT lpnFit,    // maximum number of characters
						alpDx,     // array of partial string widths
						&szText //LPSIZE lpSize    // string dimensions
					);
		VERIFY(bResExt);

		//nFit = min(nFit, nTextLen_rest);

		LPCTSTR pTextToDtaw = pTxt;
		BOOL bAllTextDrawn = (nFit == nTextLen_rest);

		if (nFit > 0 && nFit <= nTextLen_rest)
		{
			CString strSeps = _T(" .,!?)-+=;\\"); //_T(" .,!?)-+=*&^%$#@~`:;\\|/");
			int nFit_wb = 0;
			int nTextLen_wb = nTextLen_rest;
			LPCTSTR pTxt_wb = pTxt;

			LPCTSTR p_prev = NULL;
			int i = 0;
			for (i = 0; i < nFit; i++)
			{
				p_prev = pTxt;
				pTxt = _tcsinc(pTxt);
				int nCharLen = int(pTxt - p_prev);
				i += nCharLen - 1; // skip second byte for MBCS chars.

				nTextLen_rest--;

				if ((nFlags & DT_WORDBREAK) && strSeps.Find(*p_prev, 0) >= 0)
				{
					nFit_wb = i+1;
					nTextLen_wb = nTextLen_rest;
					pTxt_wb = pTxt;
				}
			}

			if (!bAllTextDrawn && (nFlags & DT_WORDBREAK))
			{
				if (nFit_wb >= 0)
				{
					nFit = nFit_wb;
					nTextLen_rest = nTextLen_wb;
					pTxt = pTxt_wb;
				}
			}

			if (nFit)
			{
				m_ptNextPrintPos.x += alpDx[nFit - 1] + 1;
			}
		}

		// Draw text (if need)
		if (nFit && (nFlags & DT_CALCRECT) == 0)
		{
			rcText.left = max(rcText.left, nX); // ENSURE THE TEXT IS CLIPPED APPROPRIATELY
			pDC->ExtTextOut(nX, nY, ETO_CLIPPED, &rcText, pTextToDtaw, nFit, NULL);
		}

		CXTPRowInfo* pRI = GetRowInfo(nRow);
		if (pRI)
			pRI->nMaxWidth = m_ptNextPrintPos.x;

		// Move point to the next line (if need)
		if (!bAllTextDrawn && (nFlags & DT_SINGLELINE) == 0)
		{
			int nIconX = m_rcTextRect.left + m_ptNextPrintPos.x + 3;
			int nIconY = m_rcTextRect.top + nPosY + m_ptNextPrintPos.y;

			int nDelta = GetRowHeight() - GetRowHeight()/4;

			CPen pen1(PS_SOLID, 1, RGB(0,0,0));
			CPen pen2(PS_SOLID, 2, RGB(0,0,0));

			CPen* pPen_old = pDC->SelectObject(&pen1);

			pDC->MoveTo(nIconX, nIconY + nDelta/2);
			pDC->LineTo(nIconX, nIconY + nDelta);
			pDC->LineTo(nIconX + nDelta/2 - 1, nIconY + nDelta);

			pDC->SelectObject(&pen2);
			pDC->MoveTo(nIconX + 1, nIconY + nDelta - 1);
			pDC->LineTo(nIconX + nDelta/2, nIconY + nDelta/2);

			pDC->SelectObject(pPen_old);

			int nSublineOffsetX = m_tmText.tmAveCharWidth * 3;
			m_ptNextPrintPos.y += GetRowHeight();
			m_ptNextPrintPos.x = nSublineOffsetX;

			if (pRI)
				pRI->nMaxWidth = m_ptNextPrintPos.x;
		}
		else
		{
			break;
		}
	}

	if (pnPrintedTextLen)
	{
		int nLen0 = int(pTxt - pcszText);
		*pnPrintedTextLen = (int)_tcsnccnt(pcszText, nLen0);
	}

	return m_ptNextPrintPos.y + GetRowHeight();
}
Пример #28
0
void Plot::paintEvent(QPaintEvent *event)
{
    QWidget::paintEvent(event);

    if (softMinimum == softMaximum)
        return;

    for (const auto l : legend)
        if (l->pen() != Qt::transparent)
            goto draw;

    return;

    draw:

    QPainter painter(this);

    // set coordinate system
    QSize s;
    s.setHeight(height() - padding_top - padding_bottom);

    // TODO bug - wykres nie działa, jeśli wartości brzegowe nie są całkowite - problem z setWindow
    double minval = 0;//double minval = qFloor(minimax.minimum(softMinimum, softMaximum));
    double maxval = 0;//qCeil(minimax.maximum(softMinimum, softMaximum));
    for (auto i : session->chart->series())
        if (legend[i]->pen() != Qt::transparent)
            for (int j = softMinimum; j <= softMaximum && j < reinterpret_cast<QtCharts::QLineSeries*>(i)->count(); j++)
                maxval = qMax(maxval, reinterpret_cast<QtCharts::QLineSeries*>(i)->at(j).y());

    if (minval == maxval)
        minval--;

    double delta = tickSpan(minval, maxval, s.height(), 24);
    /* TODO do pewnej wysokości nie powinno się rozrzedzać podziałki, tylko ją zwyczajnie skalować */

    double ut = maxval = qCeil(maxval / delta) * delta;//double ut = qFloor(maxval / delta) * delta;
    double lt = qCeil(minval / delta) * delta;

    int scale = 1;

    while (delta * scale < 1)
        scale *= 10;

    s.setWidth(width() - 50 - 20);

    painter.setViewport(50 + 10, height() - padding_bottom, s.width(), -s.height());
    painter.setWindow(softMinimum, minval, softMaximum - softMinimum, (maxval - minval) * scale);

    auto transform = painter.combinedTransform();

    // draw axis
    painter.setRenderHint(QPainter::Antialiasing);

    QPen pen1(QBrush("#808080"), 1.);
    pen1.setCosmetic(true);

    painter.setPen(pen1);

    painter.drawLine(softMinimum, minval * scale, softMaximum, minval * scale);

    int gap = tickSpan(painter.fontMetrics().width(QString::number(softMaximum)) + 20, width() - 50);

    painter.setViewTransformEnabled(false);

    for (int i = softMinimum + (gap - (softMinimum % gap)) % gap; i <= softMaximum; i += gap)
    {
        auto tick = transform.map(QPointF(i, minval)).toPoint();

        painter.drawLine(tick, tick + QPoint(0, 5));
        painter.drawText(QRect(tick + QPoint(0, 9), QSize()), Qt::AlignHCenter | Qt::AlignTop | Qt::TextDontClip, QString::number(i));
    }

    for (qreal i = lt; i <= ut; i += delta)
        painter.drawText(QRect(transform.map(QPointF(softMinimum, i * scale)).toPoint() - QPoint(9, 0), QSize()), Qt::AlignRight | Qt::AlignVCenter | Qt::TextDontClip, QString::number(i));

    painter.setViewTransformEnabled(true);

    pen1.setStyle(Qt::DashLine);
    pen1.setColor("#333333");

    painter.setPen(pen1);

    for (qreal i = (lt != minval ? lt : lt + delta); i <= ut; i += delta)
        painter.drawLine(softMinimum, i * scale, softMaximum, i * scale);

    painter.save();
    painter.scale(1, scale);

    // plot data
    for (auto i : session->chart->series())
    {
        auto interval = reinterpret_cast<QtCharts::QLineSeries*>(i)->pointsVector().mid(softMinimum, softMaximum - softMinimum + 1);
        if (interval.isEmpty()) continue;
        interval.prepend({interval.first().x(), 0});
        interval.append({interval.last().x(), 0});

        QLinearGradient gradient(0, minval, 0, maxval);
        gradient.setColorAt(0, Qt::transparent);
        gradient.setColorAt(1, legend[i]->brush());

        painter.setPen(Qt::NoPen);
        painter.setBrush(gradient);

        painter.drawPolygon(interval);

        QPen pen2(legend[i]->pen(), 2.);
        pen2.setCosmetic(true);

        painter.setPen(pen2);

        painter.drawPolyline(&interval[1], interval.size() - 2);
    }

    painter.restore();

    if (softMinimum <= value() && value() <= softMaximum)
    {
        painter.setViewTransformEnabled(false);

        int crs = transform.map(QPointF(value(), 0)).x();

        QPen pen3(Qt::white, 2.);
        pen3.setJoinStyle(Qt::MiterJoin);

        painter.setPen(pen3);
        painter.setBrush(QBrush(Qt::white));
        painter.drawLine(crs, padding_top - 5, crs, height() - padding_bottom);
        painter.drawConvexPolygon(QPolygon({{crs, padding_top - 2}, {crs - 3, padding_top - 5}, {crs + 3, padding_top - 5}}));
    }
}
Пример #29
0
void wxGenericComboCtrl::OnPaintEvent( wxPaintEvent& WXUNUSED(event) )
{
    wxSize sz = GetClientSize();
    wxAutoBufferedPaintDC dc(this);

    const wxRect& rectb = m_btnArea;
    wxRect rect = m_tcArea;

    // artificial simple border
    if ( m_widthCustomBorder )
    {
        int customBorder = m_widthCustomBorder;

        // Set border colour
        wxPen pen1( wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT),
                    customBorder,
                    wxSOLID );
        dc.SetPen( pen1 );

        // area around both controls
        wxRect rect2(0,0,sz.x,sz.y);
        if ( m_iFlags & wxCC_IFLAG_BUTTON_OUTSIDE )
        {
            rect2 = m_tcArea;
            if ( customBorder == 1 )
            {
                rect2.Inflate(1);
            }
            else
            {
            #ifdef __WXGTK__
                rect2.x -= 1;
                rect2.y -= 1;
            #else
                rect2.x -= customBorder;
                rect2.y -= customBorder;
            #endif
                rect2.width += 1 + customBorder;
                rect2.height += 1 + customBorder;
            }
        }

        dc.SetBrush( *wxTRANSPARENT_BRUSH );
        dc.DrawRectangle(rect2);
    }

#ifndef __WXMAC__  // see note in OnThemeChange
    wxColour winCol = GetBackgroundColour();
#else
    wxColour winCol = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
#endif
    dc.SetBrush(winCol);
    dc.SetPen(winCol);

    //wxLogDebug(wxT("hei: %i tcy: %i tchei: %i"),GetClientSize().y,m_tcArea.y,m_tcArea.height);
    //wxLogDebug(wxT("btnx: %i tcx: %i tcwid: %i"),m_btnArea.x,m_tcArea.x,m_tcArea.width);

    // clear main background
    dc.DrawRectangle(rect);
    
    if ( !m_btn )
    {
        // Standard button rendering
        DrawButton(dc,rectb);
    }

    // paint required portion on the control
    if ( (!m_text || m_widthCustomPaint) )
    {
        wxASSERT( m_widthCustomPaint >= 0 );

        // this is intentionally here to allow drawed rectangle's
        // right edge to be hidden
        if ( m_text )
            rect.width = m_widthCustomPaint;

        dc.SetFont( GetFont() );

        dc.SetClippingRegion(rect);
        if ( m_popupInterface )
            m_popupInterface->PaintComboControl(dc,rect);
        else
            wxComboPopup::DefaultPaintComboControl(this,dc,rect);
    }
}
Пример #30
0
void GraphView::DrawPoint(int index, wxRegion *region, bool maybe_repaint_cursor) {

	bool repaint_cursor = false;
	int current_index = 0;

	if (index < 0)
		return;

	if (!m_draw->GetValuesTable().at(index).IsData())
		return;

	wxDC* dc = m_dc;
	if (!dc->Ok())
		return;

	int x, y;

	GetPointPosition(dc, index, &x , &y);

	bool wide = m_draw->GetSelected() && m_draw->GetDoubleCursor();

	int line_width = wide ? 3 : 1;

	m_sdc.SetLineWidth(wide ? 3 : 1);
	m_sdc.SetWhiteForeground();	

	wxPen pen1(m_draw->GetDrawInfo()->GetDrawColor(), line_width, wxSOLID);
	wxPen pen2(alt_color, line_width, wxSOLID);
	dc->SetPen(pen1);

    	dc->SetBrush(wxBrush(wxColour(0,0,0), wxTRANSPARENT));

	int i = index;

	const Draw::VT& vt = m_draw->GetValuesTable();

	bool is_alternate = AlternateColor(index);

	if (i - 1 >= 0 && vt.at(i-1).IsData()) {
		int x1, y1;

		GetPointPosition(dc, i - 1, &x1, &y1);

		bool ac = AlternateColor(i - 1);

		if (ac && is_alternate)  {
			dc->SetPen(pen2);
		} else {
			dc->SetPen(pen1);
		}

		dc->DrawLine(x1, y1, x, y);
		m_sdc.DrawLine(x1, y1, x, y);

		if (ac)
			dc->SetPen(pen2);
		else
			dc->SetPen(pen1);

		DrawDot(x1, y1, dc, &m_sdc, region);

		if (region)
			region->Union(x1 , std::min(y, y1) - line_width, abs(x - x1) + 2 * line_width, abs(y - y1) + 2 * line_width);

		if (maybe_repaint_cursor && 
			m_draw->GetCurrentIndex() != -1  &&
			m_draw->GetCurrentIndex() == i) {

			repaint_cursor = true;
			current_index = i - 1;
		}

	}

	if ((i + 1) < (int)vt.size() && vt.at(i + 1).IsData()) {
		int x2, y2;

		bool ac = AlternateColor(i + 1);
		
		if (ac && is_alternate) {
			dc->SetPen(pen2);
		} else {
			dc->SetPen(pen1);
		}

		GetPointPosition(dc, i + 1, &x2 , &y2);

		dc->DrawLine(x, y, x2, y2);
		m_sdc.DrawLine(x, y, x2, y2);

		if (ac)
			dc->SetPen(pen2);
		else
			dc->SetPen(pen1);

		DrawDot(x2, y2, dc, &m_sdc, region);

		if (region)
			region->Union(x, std::min(y, y2) - line_width, abs(x - x2) + 2 * line_width, abs(y - y2) + 2 * line_width);

		if (maybe_repaint_cursor && 
			m_draw->GetCurrentIndex() != -1 &&
			m_draw->GetCurrentIndex() == i) {
			repaint_cursor = true;
			current_index = i + 1;
		}

	}
	

	if (is_alternate) 
		dc->SetPen(pen2);
	else
		dc->SetPen(pen1);

	DrawDot(x, y, dc, &m_sdc, region);

	m_sdc.SetLineWidth(1);
	pen1.SetWidth(1);
	pen2.SetWidth(1);


	if (repaint_cursor)
		DrawCursor(current_index, region);

	dc->SetPen(wxNullPen);
	dc->SetBrush(wxNullBrush);

}