void WhiteBoardColorChooser::drawSwapPixmap() { const int arrowHeight = m_swapPixmap.height() / 4.0f; const int arrowWidth = m_swapPixmap.width() / 2.0f; const int imageHeight = m_swapPixmap.height(); const int imageWidth = m_swapPixmap.width(); const QPointF arrowLeftPolyGon[3] = { QPointF(0, arrowHeight), QPointF(arrowHeight, 0), QPointF(arrowHeight, arrowHeight*2) }; const QPointF arrowDownPolyGon[3] = { QPointF(imageWidth-arrowWidth, imageHeight-arrowHeight-1), QPointF(imageWidth, imageHeight-arrowHeight-1), QPointF(imageWidth-arrowHeight, imageHeight-1) }; m_swapPixmap.fill(Qt::transparent); QPainter tPainter(&m_swapPixmap); tPainter.setBrush(Qt::black); tPainter.drawPolygon(arrowLeftPolyGon, 3); tPainter.drawPolygon(arrowDownPolyGon, 3); QPoint tCenterLine(imageWidth-arrowHeight, arrowHeight); tPainter.drawLine(tCenterLine,QPoint(arrowHeight, arrowHeight)); tPainter.drawLine(tCenterLine,QPoint(imageWidth-arrowHeight, imageWidth-arrowHeight)); tPainter.end(); }
//////////////////////////////////////////////////////// //渲染支撑到图像上 void SimpleSupport::draw(QImage* pImage) { int ihalfSize = mSize/2; float ihalfbase = mSize/1.73205081; QPointF points[4]; QPainter tPainter(pImage); tPainter.setPen(QColor(255,255,255)); tPainter.setBrush(QBrush(QColor(255,255,255))); tPainter.setBackgroundMode(Qt::OpaqueMode); switch(mType) { case st_CIRCLE: tPainter.drawEllipse(mPoint.x()-ihalfSize,mPoint.y()-ihalfSize,mSize,mSize); break; case st_SQUARE: tPainter.fillRect(mPoint.x()-ihalfSize,mPoint.y()-ihalfSize,mSize,mSize,Qt::white); break; case st_TRIANGLE: points[0].setX( mPoint.x()); points[0].setY(-ihalfSize + mPoint.y()); points[1].setX( ihalfbase + mPoint.x()); points[1].setY( ihalfSize + mPoint.y()); points[2].setX(-ihalfbase + mPoint.x()); points[2].setY( ihalfSize + mPoint.y()); tPainter.drawPolygon(points, 3); break; case st_DIAMOND: points[0].setX( mPoint.x()); points[0].setY(-ihalfSize + mPoint.y()); points[1].setX( ihalfbase + mPoint.x()); points[1].setY( mPoint.y()); points[2].setX( mPoint.x()); points[2].setY( ihalfSize + mPoint.y()); points[3].setX(-ihalfbase + mPoint.x()); points[3].setY( mPoint.y()); tPainter.drawPolygon(points, 4); break; default: break; } }