本文整理汇总了C++中brush函数的典型用法代码示例。如果您正苦于以下问题:C++ brush函数的具体用法?C++ brush怎么用?C++ brush使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了brush函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pen
QGraphicsScene* Ploter::drawParallelPlot(Machine **machines, int MachineCount, int JobCount)
{
int currentMashineJobWidth = 0;
int LabelsCount = JobCount;
plot.clear();
plot.setSceneRect(0,0,356,86);
QPen pen(colorTab[0]);
QBrush brush(colorTab[0]);
QString jobLabelContent;
QGraphicsSimpleTextItem **TimeLabels = new QGraphicsSimpleTextItem*[LabelsCount];
plot.clear();
for(int i=0; i < LabelsCount; ++i)
{
TimeLabels[i] = new QGraphicsSimpleTextItem();
}
int labelIdxj=0;
int offsetForJob;
int maxTime = 0;
for(int j=0; j < MachineCount; ++j)
{
offsetForJob = 0;
for(int i=1; i <= machines[j]->getNumberOfJobs(); ++i)
{
{
int jobId = machines[j]->getJobId(i);
pen.setColor(colorTab[jobId]);
brush.setColor(colorTab[jobId]);
jobLabelContent.setNum(jobId);
jobLabelContent.insert(0,"Z");
if(jobId != 0)
{
TimeLabels[labelIdxj]->setText(jobLabelContent);
TimeLabels[labelIdxj]->setPos(labelOffset.x() + offsetForJob * scale,
lineStartingY[j] + labelOffset.y());
}
currentMashineJobWidth = machines[j]->getJobDuration(i);
plot.addRect(lineStartingX + offsetForJob * scale,
lineStartingY[j],
currentMashineJobWidth * scale,
jobHeight ,
pen,
brush);
if(jobId != 0 && currentMashineJobWidth != 0)
plot.addItem(TimeLabels[labelIdxj++]);
offsetForJob += currentMashineJobWidth;
}
}
if(maxTime < machines[j]->getEndingTimeForLastJob()) maxTime = machines[j]->getEndingTimeForLastJob();
}
PrepareAxis(maxTime, MachineCount);
return &plot;
}
开发者ID:Zegis,项目名称:MPD-helper,代码行数:70,代码来源:ploter.cpp
示例2: sinf
void stitch::Vec3::equidistantVectors_FibonacciSpiralSphere(const size_t minimumNumVectors, std::vector<stitch::Vec3> &vectors, std::vector<size_t> &binIndices)
{
//std::cout << "stitch::Vec3::equidistantVectors_FibonacciSpiralSphere(...)...";
//std::cout.flush();
vectors.clear();
binIndices.clear();
//Generate the vectors based on the golden section spiral a.k.a. the Fibonacci Spiral sphere.
const float phi=(sqrtf(5.0f)+1.0f)/2.0f-1.0f;
const float ga=phi * ((float)M_PI);
for (size_t vectorNum=0; vectorNum<minimumNumVectors; ++vectorNum)
{
const float lon=ga * vectorNum;
const float lat=asinf(stitch::MathUtil::clamp(-1.0f + (2.0f * vectorNum)/minimumNumVectors, -1.0f, 1.0f));
#ifdef USE_CXX11
vectors.emplace_back(cosf(lon)*cosf(lat), sinf(lon)*cosf(lat), sinf(lat));
#else
vectors.push_back(Vec3(cosf(lon)*cosf(lat), sinf(lon)*cosf(lat), sinf(lat)));
#endif
}
//Build a brush that contains the sphere and use the updateVerticesAndLines method to create a new set of vertices and indices.
// It is assumed that a tesselation of the Fiboncci Spiral sphere would be strickly convex.
// Ducplicate brush vertices are not added.
{
stitch::Brush brush(new stitch::DiffuseMaterial(stitch::Colour_t(0.9f, 0.9f, 0.9f)));
const size_t numVertices=vectors.size();
//=== Create a permutation of vertices v0, v1, v2 ===
for (size_t vertexNum0=0; vertexNum0<numVertices; ++vertexNum0)
{
for (size_t vertexNum1=vertexNum0+1; vertexNum1<numVertices; ++vertexNum1)
{
for (size_t vertexNum2=vertexNum1+1; vertexNum2<numVertices; ++vertexNum2)
{
stitch::Vec3 v0=vectors[vertexNum0];
stitch::Vec3 v1=vectors[vertexNum1];
stitch::Vec3 v2=vectors[vertexNum2];
stitch::Plane plane(v0, v1, v2);
bool verticesOnPositiveSide=false;
bool verticesOnNegativeSide=false;
//Test if this permutation of vertices defines a brush face.
for (size_t vertexNum=0; vertexNum<numVertices; ++vertexNum)
{
if ((vertexNum!=vertexNum0) &&
(vertexNum!=vertexNum1) &&
(vertexNum!=vertexNum2))
{
stitch::Vec3 v=vectors[vertexNum];
if (v * plane.normal_<plane.d_)
{
verticesOnNegativeSide=true;
} else
{
verticesOnPositiveSide=true;
}
if (verticesOnPositiveSide && verticesOnNegativeSide)
{
break; //from for loop. Permutation of vertices v0, v1, v2 is not on a brush plane.
}
}
}
if (verticesOnPositiveSide && (!verticesOnNegativeSide))
{//All vertices on postive side i.e. this is a brush face.
//Flip brush face normal to have all other vertices on negative/in side of face.
plane.normal_=plane.normal_ * -1.0f;
plane.d_=plane.d_ * -1.0f;
brush.addFace(stitch::BrushFace(plane, false));
}
if ((!verticesOnPositiveSide) && verticesOnNegativeSide)
{//All vertices on negative side i.e. this is a brush face.
brush.addFace(stitch::BrushFace(plane, false));
}
}
}
//if ((vertexNum0%10)==0)
//{
//std::cout << 100.0f * (vertexNum0 / ((float)numVertices)) << "%...";
//std::cout.flush();
//}
}
//=== ===
//=== Calculate the face vertices from the brush face planes ===
brush.updateLinesVerticesAndBoundingVolume(true);
//=== ===
//.........这里部分代码省略.........
开发者ID:bduvenhage,项目名称:stitch-engine,代码行数:101,代码来源:Vec3.cpp
示例3: iter
void PSV_ChartItem::updateForDouble()
{
QMapIterator<QString,PSV_CurveInfo> iter(m_curveDataMap);
qreal posY = m_staStartPoint.y();
qreal posX = m_staStartPoint.x();
while(iter.hasNext())
{
iter.next();
PSV_CurveInfo curveInfo = iter.value();
updateAxisRange(curveInfo.m_axisType);
addCurveItem(curveInfo);
addEllipseItem(curveInfo);
if(!isStaHidden())
{
QGraphicsTextItem *textItem = new QGraphicsTextItem(this);
textItem->setData(E_ITEM_TYPE,PSV::staLabelItem);
textItem->setData(E_CURVE_NAME,curveInfo.m_curveName);
textItem->setFlags(QGraphicsItem::ItemIsSelectable);
textItem->installSceneEventFilter(this);
textItem->setDefaultTextColor(getDefaultColor());
textItem->setFont(staFont());
textItem->setHtml(curveInfo.m_staHtmText);
double textHeight = textItem->boundingRect().height();
int staMaxHeight = (int)textHeight* 6 / 10;
textItem->setPos(posX + textItem->boundingRect().height(),posY);
QPixmap pixmap(staMaxHeight,staMaxHeight);
pixmap.fill();
QPen pen(curveInfo.m_lineColor);
pen.setWidth(3);
QPainter painter(&pixmap);
painter.setPen(pen);
if(!curveInfo.m_isHidden)
{
QBrush brush(curveInfo.m_lineColor);
painter.setBrush(brush);
}
painter.drawRect(0, 0, pixmap.height(), pixmap.height());
QGraphicsPixmapItem* pixmapItem = new QGraphicsPixmapItem(pixmap,this);
pixmapItem->setPixmap(pixmap);
pixmapItem->setPos(posX,posY + textHeight * 2 / 10);
pixmapItem->setData(E_ITEM_TYPE,PSV::staLabelItem);
pixmapItem->setData(E_CURVE_NAME,curveInfo.m_curveName);
pixmapItem->setFlags(QGraphicsItem::ItemIsSelectable);
pixmapItem->installSceneEventFilter(this);
if(posX + 2 * m_staMaxWidth > m_chartRect.right())
{
posX = m_staStartPoint.x();
posY += textItem->boundingRect().height() + getData(PSV::margin,3).toInt();
}
else
{
posX += m_staMaxWidth;
}
}
}
//TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
// QGraphicsRectItem *item = new QGraphicsRectItem(m_rect,this);//TTTTTTTTTTTTTTT
// item->setPen(QPen(QColor(Qt::red)));//TTTTTTTTTTTTTTT
//TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
}
开发者ID:BIbiLion,项目名称:LSWuqiankun,代码行数:62,代码来源:psv_chartitem.cpp
示例4: GetGrid
// EFW - Various changes to make it draw cells better when using alternate
// color schemes. Also removed printing references as that's now done
// by PrintCell() and fixed the sort marker so that it doesn't draw out
// of bounds.
BOOL CGridCellBase::Draw(CDC* pDC, int nRow, int nCol, CRect rect, BOOL bEraseBkgnd /*=TRUE*/)
{
CGridCtrl* pGrid = GetGrid();
ASSERT(pGrid);
if (!pGrid || !pDC)
return FALSE;
if( rect.Width() <= 0 || rect.Height() <= 0) // prevents imagelist item from drawing even
return FALSE; // though cell is hidden
//TRACE3("Drawing %scell %d, %d\n", IsFixed()? _T("Fixed ") : _T(""), nRow, nCol);
int nSavedDC = pDC->SaveDC();
pDC->SetBkMode(TRANSPARENT);
// Get the default cell implementation for this kind of cell. We use it if this cell
// has anything marked as "default"
CGridDefaultCell *pDefaultCell = (CGridDefaultCell*) GetDefaultCell();
if (!pDefaultCell)
return FALSE;
// Set up text and background colours
COLORREF TextClr, TextBkClr;
TextClr = (GetTextClr() == CLR_DEFAULT)? pDefaultCell->GetTextClr() : GetTextClr();
if (GetBackClr() == CLR_DEFAULT)
TextBkClr = pDefaultCell->GetBackClr();
else
{
bEraseBkgnd = TRUE;
TextBkClr = GetBackClr();
}
// Draw cell background and highlighting (if necessary)
if ( IsFocused() || IsDropHighlighted() )
{
// Always draw even in list mode so that we can tell where the
// cursor is at. Use the highlight colors though.
if(GetState() & GVIS_SELECTED)
{
TextBkClr = ::GetSysColor(COLOR_HIGHLIGHT);
TextClr = ::GetSysColor(COLOR_HIGHLIGHTTEXT);
bEraseBkgnd = TRUE;
}
rect.right++; rect.bottom++; // FillRect doesn't draw RHS or bottom
if (bEraseBkgnd)
{
TRY
{
CBrush brush(TextBkClr);
pDC->FillRect(rect, &brush);
}
CATCH(CResourceException, e)
{
//e->ReportError();
}
END_CATCH
}
// Don't adjust frame rect if no grid lines so that the
// whole cell is enclosed.
if(pGrid->GetGridLines() != GVL_NONE)
{
rect.right--;
rect.bottom--;
}
if (pGrid->GetFrameFocusCell())
{
// Use same color as text to outline the cell so that it shows
// up if the background is black.
TRY
{
CBrush brush(TextClr);
pDC->FrameRect(rect, &brush);
}
CATCH(CResourceException, e)
{
//e->ReportError();
}
END_CATCH
}
pDC->SetTextColor(TextClr);
// Adjust rect after frame draw if no grid lines
if(pGrid->GetGridLines() == GVL_NONE)
{
rect.right--;
rect.bottom--;
}
rect.DeflateRect(1,1);
}
开发者ID:iqk168,项目名称:3111,代码行数:99,代码来源:GridCellBase.cpp
示例5: smileys
HRESULT CGifSmileyCtrl::OnDrawSmiley(ATL_DRAWINFO& di, bool bCustom=false)
{
USES_CONVERSION;
if (di.dwDrawAspect != DVASPECT_CONTENT)
{
return E_FAIL;
}
if ( bCustom && !IsVisible(di))
{
return S_OK;
}
if (!m_pGifImage)
{
return E_FAIL;
}
RECT& rc = *(RECT*)di.prcBounds;
HRGN hOldRgn, hNewRgn;
if (!IsRectEmpty(&m_rectPos))
{ //strange workaround for drawing zoom out smileys (look MS calculate it one pix larger than exactly)
if (rc.bottom-rc.top-1 == m_rectPos.bottom-m_rectPos.top
&& rc.right-rc.left== m_rectPos.right-m_rectPos.left)
rc.top+=1;
}
if ( bCustom )SelectSmileyClipRgn(di.hdcDraw, rc, hOldRgn, hNewRgn, TRUE);
InflateRect(&rc,-1,0); //border offset to fix blinked cursor painting
if ( (m_dwFlags&REO_INVERTEDSELECT) == 0 || !bCustom || m_bTransparent)
DoDrawSmiley(di.hdcDraw, rc, rc.right-rc.left,rc.bottom-rc.top, m_nFrameSize.Width, m_nFrameSize.Height);
else
{
Bitmap bmp(rc.right-rc.left,rc.bottom-rc.top, PixelFormat32bppARGB);
Graphics g(&bmp);
COLORREF col=(COLORREF)(m_clrBackColor);
SolidBrush brush(Color(GetRValue(col),GetGValue(col),GetBValue(col)));
g.FillRectangle( &brush, 0 ,0, rc.right-rc.left, rc.bottom-rc.top);
HDC hdc=g.GetHDC();
RECT mrc={0};
mrc.right=rc.right-rc.left;
mrc.bottom=rc.bottom-rc.top;
DoDrawSmiley(hdc, mrc, mrc.right-mrc.left,mrc.bottom-mrc.top, m_nFrameSize.Width, m_nFrameSize.Height);
InvertRect(hdc, &mrc);
BitBlt(di.hdcDraw, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, hdc, 0, 0, SRCCOPY );
g.ReleaseHDC(hdc);
}
if ((m_dwFlags&REO_SELECTED) == REO_SELECTED && bCustom)
{
//Draw frame around
HBRUSH oldBrush=(HBRUSH)SelectObject(di.hdcDraw, GetStockObject(NULL_BRUSH));
HPEN oldPen=(HPEN)SelectObject(di.hdcDraw, GetStockObject(BLACK_PEN));
::Rectangle(di.hdcDraw, rc.left, rc.top, rc.right, rc.bottom );
SelectObject(di.hdcDraw, oldBrush);
SelectObject(di.hdcDraw, oldPen);
}
AdvanceFrame();
if (!bCustom)
m_bPaintValid=false;
ResetClip(di.hdcDraw, hOldRgn, hNewRgn);
return S_OK;
}
开发者ID:0359xiaodong,项目名称:TeamTalk,代码行数:63,代码来源:GifSmileyCtrl.cpp
示例6: AbstractMode
VisibleAreaMode::VisibleAreaMode(QGraphicsScene& scene, Toolbar& toolbar)
: AbstractMode(scene),
toolbar_(toolbar),
initialized_(false),
rectTop(new QGraphicsRectItem),
rectBottom(new QGraphicsRectItem),
rectLeft(new QGraphicsRectItem),
rectRight(new QGraphicsRectItem),
lineTop(new QGraphicsLineItem),
lineBottom(new QGraphicsLineItem),
lineLeft(new QGraphicsLineItem),
lineRight(new QGraphicsLineItem) {
QPen pen(Qt::NoPen);
QBrush brush(Qt::black);
rectTop->setOpacity(.65);
rectBottom->setOpacity(.65);
rectLeft->setOpacity(.65);
rectRight->setOpacity(.65);
rectTop->setPen(pen);
rectBottom->setPen(pen);
rectLeft->setPen(pen);
rectRight->setPen(pen);
rectTop->setBrush(brush);
rectBottom->setBrush(brush);
rectLeft->setBrush(brush);
rectRight->setBrush(brush);
rectTop->setZValue(1);
rectBottom->setZValue(1);
rectLeft->setZValue(1);
rectRight->setZValue(1);
// First rectangle fullscreen
rectTop->setRect(0, 0, scene.width(), scene.height());
scene.addItem(rectTop);
scene.addItem(rectBottom);
scene.addItem(rectLeft);
scene.addItem(rectRight);
QPen linePen;
linePen.setWidthF(.2);
linePen.setColor(QColor(230, 230, 230));
lineTop->setPen(linePen);
lineBottom->setPen(linePen);
lineLeft->setPen(linePen);
lineRight->setPen(linePen);
lineTop->setZValue(1);
lineBottom->setZValue(1);
lineLeft->setZValue(1);
lineRight->setZValue(1);
scene.addItem(lineTop);
scene.addItem(lineBottom);
scene.addItem(lineLeft);
scene.addItem(lineRight);
}
开发者ID:dsimakov,项目名称:screenshotgun,代码行数:63,代码来源:VisibleAreaMode.cpp
示例7: pen1
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 );
//.........这里部分代码省略.........
开发者ID:2Dou,项目名称:PlayBox,代码行数:101,代码来源:SkinButton2.cpp
示例8: if
//.........这里部分代码省略.........
{
zMaxValue = round(zMaxValue, true);
MaxValue = zMaxValue;
}
}
paintTitle(p, rect);
paintLegend(p, rect);
paintAxis(p, rect);
std::list<QPolygon> Points;
int cp = 0;
int samples = countSamples();
int zeroy = int(rect.height() - 2 - ( -zMinValue / (zMaxValue - zMinValue) * (rect.height() - 4)));
if (samples > 1)
{
const QMatrix &mtx = p->worldMatrix();
p->setClipRect(int(mtx.dx() + 2), int(mtx.dy() + 2), rect.width() - 3, rect.height() - 3);
if (Zooming)
p->drawText(2, 2, rect.width() - 4, rect.height() - 4,
Qt::AlignLeft | Qt::AlignTop, tr("Zoom"));
std::list<bool>::reverse_iterator e = Enabled.rbegin();
for (std::list<std::list<double> >::reverse_iterator i = Values.rbegin();i != Values.rend();i++)
{
if (e == Enabled.rend() || *e)
{
std::list<double> &val = *i;
int count = 0;
int skip = SkipSamples;
QPolygon a(samples + 10);
int x = rect.width() - 2;
for (std::list<double>::reverse_iterator j = val.rbegin();j != val.rend() && x >=
2;
j++)
{
if (skip > 0)
skip--;
else
{
int val = int(rect.height() - 2 - ((*j - zMinValue) / (zMaxValue - zMinValue) * (rect.height() - 4)));
x = rect.width() - 2 - count * (rect.width() - 4) / (samples - 1);
a.setPoint(count, x, val);
count++;
if (count >= samples)
break;
}
}
a.resize(count*2);
Points.insert(Points.end(), a);
}
cp++;
if (e != Enabled.rend())
e++;
}
}
std::map<int, int> Bottom;
std::list<bool>::reverse_iterator e = Enabled.rbegin();
for (std::list<QPolygon>::iterator i = Points.begin();i != Points.end();)
{
while (e != Enabled.rend() && !*e)
{
cp--;
e++;
}
if (e != Enabled.rend())
e++;
cp--;
QPolygon a = *i;
int lx = 0;
int lb = 0;
for (int j = 0;j < a.size() / 2;j++)
{
int x, y;
a.point(j, &x, &y);
if (Bottom.find(x) == Bottom.end())
Bottom[x] = 0;
if (lx != x)
lb = Bottom[x];
a.setPoint(a.size() - 1 - j, x, zeroy - lb);
y -= lb;
a.setPoint(j, x, y);
Bottom[x] = zeroy - y;
lx = x;
}
p->save();
QBrush brush(toChartBrush(cp));
p->setBrush(brush.color());
p->drawPolygon(a);
if (brush.style() != Qt::SolidPattern)
{
p->setBrush(QBrush(Qt::white, brush.style()));
p->drawPolygon(a);
}
p->restore();
i++;
}
}
开发者ID:netrunner-debian-kde-extras,项目名称:tora,代码行数:101,代码来源:tobarchart.cpp
示例9: renderCode128
//.........这里部分代码省略.........
}
}
// calculate and append the checksum value to the list
int checksum = str.at(0);
for (i = 1; i < str.size(); ++i)
checksum += (str.at(i) * i);
checksum = checksum % 103;
str.push_back(checksum);
// lets determine some core attributes about this barcode
qreal bar_width = 1; // the width of the base unit bar 1/100 inch
// this is are mandatory minimum quiet zone
qreal quiet_zone = bar_width * 10;
if (quiet_zone < 0.1)
quiet_zone = 0.1;
// what kind of area do we have to work with
qreal draw_width = r.width();
qreal draw_height = r.height();
// how long is the value we need to encode?
int val_length = str.size() - 2; // we include start and checksum in are list so
// subtract them out for our calculations
// L = (11C + 35)X
// L length of barcode (excluding quite zone) in units same as X and I
// C the number of characters in the value excluding the start/stop and checksum characters
// X the width of a bar (pixels in our case)
qreal L;
qreal C = val_length;
qreal X = bar_width;
L = (((11.0 * C) + 35.0) * X);
// now we have the actual width the barcode will be so can determine the actual
// size of the quiet zone (we assume we center the barcode in the given area
// what should we do if the area is too small????
// At the moment the way the code is written is we will always start at the minimum
// required quiet zone if we don't have enough space.... I guess we'll just have over-run
// to the right
//
// calculate the starting position based on the alignment option
// for left align we don't need to do anything as the values are already setup for it
if (align == 1) { // center
qreal nqz = (draw_width - L) / 2.0;
if (nqz > quiet_zone)
quiet_zone = nqz;
} else if (align > 1) // right
quiet_zone = draw_width - (L + quiet_zone);
// else if(align < 1) {} // left : do nothing
qreal pos = r.left() + quiet_zone;
qreal top = r.top();
QPen pen(Qt::NoPen);
QBrush brush(QColor("black"));
bool space = false;
int idx = 0, b = 0;
qreal w = 0.0;
for (i = 0; i < str.size(); ++i) {
// loop through each value and render the barcode
idx = str.at(i);
if (idx < 0 || idx > 105) {
qDebug("Encountered a non-compliant element while rendering a 3of9 barcode -- skipping");
continue;
}
space = false;
for (b = 0; b < 6; ++b, space = !space) {
w = _128codes[idx].values[b] * bar_width;
if (!space) {
ORORect * rect = new ORORect();
rect->setPen(pen);
rect->setBrush(brush);
rect->setRect(QRectF(pos, top, w, draw_height));
page->addPrimitive(rect);
}
pos += w;
}
}
// we have to do the stop character separately like this because it has
// 7 elements in it's bar sequence rather than 6 like the others
int STOP_CHARACTER[] = { 2, 3, 3, 1, 1, 1, 2 };
space = false;
for (b = 0; b < 7; ++b, space = !space) {
w = STOP_CHARACTER[b] * bar_width;
if (!space) {
ORORect * rect = new ORORect();
rect->setPen(pen);
rect->setBrush(brush);
rect->setRect(QRectF(pos, top, w, draw_height));
page->addPrimitive(rect);
}
pos += w;
}
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:101,代码来源:code128.cpp
示例10: foreach
void frmListSubtitles::setSubtitlesList(const QList<QNapiSubtitleInfo> & list)
{
QNapi n;
n.addEngines(n.enumerateEngines());
ui.twSubtitles->clear();
ui.twSubtitles->setColumnCount(4);
ui.twSubtitles->setRowCount(list.size());
ui.twSubtitles->horizontalHeader()->hide();
ui.twSubtitles->verticalHeader()->hide();
ui.twSubtitles->verticalHeader()->setDefaultSectionSize(20);
ui.twSubtitles->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
int i = 0, good = 0, bad = 0;
foreach(QNapiSubtitleInfo s, list)
{
QTableWidgetItem *item;
bool highlight = (s.resolution != SUBTITLE_UNKNOWN);
QBrush brush((s.resolution == SUBTITLE_GOOD) ? QColor(qRgb(200, 255, 200)) : QColor(qRgb(255, 200, 200)));
if(highlight && (s.resolution == SUBTITLE_GOOD))
++good;
else if(highlight && (s.resolution == SUBTITLE_GOOD))
++bad;
QString lang_path = QString(":/languages/") + s.lang + ".gif";
if(QFile::exists(lang_path))
{
item = new QTableWidgetItem(QIcon(lang_path), "");
}
else
{
item = new QTableWidgetItem(s.lang);
}
if(highlight) item->setBackground(brush);
item->setToolTip(s.comment);
ui.twSubtitles->setItem(i, 1, item);
item = new QTableWidgetItem(s.name);
if(highlight) item->setBackground(brush);
item->setToolTip(s.comment);
ui.twSubtitles->setItem(i, 2, item);
item = new QTableWidgetItem(s.format);
if(highlight) item->setBackground(brush);
item->setToolTip(s.comment);
ui.twSubtitles->setItem(i, 3, item);
QNapiAbstractEngine *e = n.engineByName(s.engine);
if(e)
{
item = new QTableWidgetItem(e->engineIcon(), "");
if(highlight) item->setBackground(brush);
item->setToolTip(s.comment);
ui.twSubtitles->setItem(i, 0, item);
}
++i;
}
开发者ID:zadziora,项目名称:qnapi,代码行数:63,代码来源:frmlistsubtitles.cpp
示例11: paintEvent
void paintEvent(Wt::WPaintDevice *paintDevice) {
Wt::WPainter painter(paintDevice);
// Draw a grid of rectangles; each one in a different color.
for (int row = 0; row < 6; row++)
for (int col = 0; col < 6; col++) {
// Generate a unique RGB color for each square. Only the red and
// green values are modified; the blue channel has a fixed value.
Wt::WBrush brush(Wt::WColor(255 - 42*row, 255 - 42*col, 0));
painter.fillRect(row*25, col*25, 25, 25, brush);
}
painter.translate(0, 160);
// Draw a grid of circles similar to the above example but now using the
// strokePath method.
Wt::WPen pen;
pen.setWidth(3);
for (int row = 0; row < 6; row++) {
for (int col = 0; col < 6; col++) {
// Generate a unique RGB color for each circle. Only the green and
// blue values are modified; the red channel has a fixed value.
Wt::WPainterPath path;
path.addEllipse(3 + col*25, 3 + row*25, 20, 20);
pen.setColor(Wt::WColor(0, 255 - 42*row, 255 - 42*col));
painter.strokePath(path, pen);
}
}
painter.translate(0, 160);
// Transparency example with rectangles
// Create a background composed of 4 stacked rectangles.
painter.fillRect(0, 0, 150, 37.5, Wt::WBrush(Wt::yellow));
painter.fillRect(0, 37.5, 150, 37.5, Wt::WBrush(Wt::green));
painter.fillRect(0, 75, 150, 37.5, Wt::WBrush(Wt::blue));
painter.fillRect(0, 112.5, 150, 37.5, Wt::WBrush(Wt::red));
// On top of these draw semi transparent rectangles with increasing opacity
for (int i = 0; i < 10; i++) {
Wt::WBrush brush = Wt::WBrush(Wt::WColor(255, 255, 255, 255/10*i));
for (int j = 0; j < 4; j++) {
Wt::WPainterPath path;
path.addRect(5 + i*14, 5 + j*37.5, 14, 27.5);
painter.fillPath(path, brush);
}
}
painter.translate(0, 160);
// Transparency example with circles
// Create a square composed of four different colored squares.
painter.fillRect(0, 0, 75, 75, Wt::WBrush(Wt::yellow));
painter.fillRect(75, 0, 75, 75, Wt::WBrush(Wt::green));
painter.fillRect(0, 75, 75, 75, Wt::WBrush(Wt::blue));
painter.fillRect(75, 75, 75, 75, Wt::WBrush(Wt::red));
// On top of these draw a set of semi-transparant white circles with
// increasing diameter. The final result is a radial gradient.
for (int i = 1; i < 8; i++) {
Wt::WPainterPath path;
path.addEllipse(75 - i*10, 75 - i*10, i*20, i*20);
Wt::WBrush brush = Wt::WBrush(Wt::WColor(255, 255, 255, 50));
painter.fillPath(path, brush);
}
painter.translate(0, 170);
// Gradient Brush example
// Rectangle with a linear gradient from left top to right bottom
painter.setPen(Wt::WPen(Wt::NoPen));
Wt::WGradient linGrad;
linGrad.setLinearGradient(0, 0, 100, 150);
linGrad.addColorStop(0, Wt::WColor(255, 0, 0, 255));
linGrad.addColorStop(0.5, Wt::WColor(0, 0, 255, 255));
linGrad.addColorStop(1, Wt::WColor(0, 255, 0, 255));
Wt::WBrush linearGradientBrush(linGrad);
painter.setBrush(linearGradientBrush);
painter.drawRect(0, 0, 100, 150);
// Circle with a radial gradient
Wt::WGradient radGrad;
radGrad.setRadialGradient(170, 100, 50, 130, 130);
radGrad.addColorStop(0.2, Wt::WColor(255, 0, 0, 255));
radGrad.addColorStop(0.9, Wt::WColor(0, 0, 255, 255));
radGrad.addColorStop(1, Wt::WColor(0, 0, 255, 0));
Wt::WBrush radialGradientBrush(radGrad);
painter.setBrush(radialGradientBrush);
painter.drawEllipse(120, 50, 100, 100);
painter.translate(0, 170);
// LineWidth example
// You can use WPainter::drawLine() or WPainter::strokePath() to draw a
// line. Using strokePath() you can draw thicker lines.
// The line is centered on the path. In other words, the area that's drawn
// extends to half the line width on either side of the path. Because
// canvas coordinates do not directly reference pixels, you have to take
// special care to obtain crisp horizontal and vertical lines.
// All lines with an odd integer width thickness in the example below do
// not appear crisp, because of the path's positioning.
for (int i = 0; i < 11; i++) {
Wt::WPainterPath path;
//.........这里部分代码省略.........
开发者ID:DTidd,项目名称:wt,代码行数:101,代码来源:PaintingStyle.cpp
示例12: wcslen
void LayeredWindowBase::Render()
{
wchar_t pszbuf[] = L"1.Text Designer中文字也可顯示\n2.Text Designer中文字也可顯示\n3.Text Designer中文字也可顯示\n4.Text Designer中文字也可顯示\n5.Text Designer中文字也可顯示\n6.Text Designer中文字也可顯示 Text Designer中文字也可顯示\n7.Text Designer中文字也可顯示\n8.Text Designer中文字也可顯示\n9.Text Designer中文字也可顯示\n10.Text Designer中文字也可顯示";
int nStrLen = wcslen(pszbuf);
if (m_techType & LayeredWindow_TechType_D2D)
{
//m_pWin.pD2D->BeginDraw();
m_pWin.pD2D->m_pRenderTarget->Clear(D2D1::ColorF(D2D1::ColorF::White,0.5));
//m_pWin.pD2D->m_pRenderTarget->DrawText(pszbuf,nStrLen,
//
// IFR(m_spDWriteFactory->CreateTextFormat(
// msc_fontName,
// NULL,
// DWRITE_FONT_WEIGHT_NORMAL,
// DWRITE_FONT_STYLE_NORMAL,
// DWRITE_FONT_STRETCH_NORMAL,
// msc_fontSize,
// L"", //locale
// &m_spTextFormat
// ));
//// Center the text both horizontally and vertically.
//m_spTextFormat->SetTextAlignment(
// DWRITE_TEXT_ALIGNMENT_CENTER
// );
//m_spTextFormat->SetParagraphAlignment(
// DWRITE_PARAGRAPH_ALIGNMENT_CENTER
// );
//m_pWin.pD2D->m_pRenderTarget->DrawText(
// pszbuf,nStrLen,
// m_spTextFormat,
// D2D1::RectF(
// 0,0,rtSize.width, rtSize.height
// ),
// m_spBlackBrush
// );)
//m_pWin.pD2D->EndDraw();
}
else if (m_techType & LayeredWindow_TechType_GDI)
{
//m_pWin.pGDI->BeginDraw();
//Gdiplus::Graphics graphics( m_pBitmap->GetDC() ); //#MOD
m_pWin.pGDI->m_pGraphics->Clear( Gdiplus::Color( 128, 255, 255, 255 ) );
Gdiplus::FontFamily fontFamily(L"微軟正黑體");
Gdiplus::Font oMS( &fontFamily, 32, Gdiplus::FontStyle::FontStyleRegular, Gdiplus::Unit::UnitPixel );
Gdiplus::StringFormat strformat;
Gdiplus::GraphicsPath *Path;
Gdiplus::GraphicsPath path;
// Region *aRegion;
Gdiplus::RectF rectf;
rectf.X = 10;
rectf.Y = 10;
rectf.Width = 500;
rectf.Height = 500;
path.AddString(pszbuf, nStrLen, &fontFamily,
Gdiplus::FontStyleRegular, 32,rectf,&strformat );
Gdiplus::SolidBrush brush(Gdiplus::Color(255,100,255));
m_pWin.pGDI->m_pGraphics->FillPath(&brush, &path);
//SelectObject(m_bitmap.m_hdc, m_bitmap.m_bitmap);
//m_pWin.pGDI->EndDraw();
}
}
开发者ID:Harpseal,项目名称:sysAudioSpectrogram,代码行数:75,代码来源:LayeredWindowBase.cpp
示例13: renderCodeDatamatrix
void renderCodeDatamatrix(OROPage *page, const QRectF &qrect, const QString &qstr, ORBarcodeData * bc)
{
//5 pixel par carré
//qreal pix = 5;
//lecture du type de datamatrix
QRegExp regex("[a-zA-Z]{10}_([0-9]{1,2})_([LCR]{1})");
regex.indexIn(bc->format);
int type = regex.cap(1).toInt();
QString align = regex.cap(2);
size_t width, height, bytesPerPixel;
//pointer declaration
unsigned char *pxl = NULL;
DmtxEncode *enc = NULL;
DmtxImage *img = NULL;
ORORect *rect = NULL;
int valeur = 0;
/* 1) ENCODE a new Data Matrix barcode image (in memory only) */
enc = dmtxEncodeCreate();
//see DmtxSymbolSize in dmtx.h for more details
enc->sizeIdxRequest = type;
enc->marginSize = 0;
//number of pixel for one square
enc->moduleSize = 1;
try
{
//assert(enc != NULL);
dmtxEncodeDataMatrix(enc, qstr.size(), (unsigned char*)qstr.toStdString().c_str());
/* 2) COPY the new image data before releasing encoding memory */
width = dmtxImageGetProp(enc->image, DmtxPropWidth);
height = dmtxImageGetProp(enc->image, DmtxPropHeight);
bytesPerPixel = dmtxImageGetProp(enc->image, DmtxPropBytesPerPixel);
if(width > 1000000000)
{
throw std::runtime_error("Code is to big for the Datamatrix");
}
pxl = (unsigned char *)malloc(width * height * bytesPerPixel);
//assert(pxl != NULL);
memcpy(pxl, enc->image->pxl, width * height * bytesPerPixel);
dmtxEncodeDestroy(&enc);
/* 3) DECODE the Data Matrix barcode from the copied image */
img = dmtxImageCreate(pxl, width, height, DmtxPack24bppRGB);
QPen pen(Qt::NoPen);
QBrush brush(QColor("black"));
qreal Xo = 0;
qreal Yo = 0;
//length of square
qreal pas = 0;
datamatrixGeometry(align,qrect,img,&Xo,&Yo,&pas);
//draw the datamatrix
for(int y = 0; y < img->height; y++)
{
for(int x = 0; x < img->width; x++)
{
dmtxImageGetPixelValue(img,x,y,0,&valeur);
rect = new ORORect(bc);
rect->setPen(pen);
if(valeur == 0)
{
brush.setColor(Qt::black);
rect->setBrush(brush);
rect->setRect(QRectF( Xo + x*pas,
Yo - y*pas,
pas,
pas));
rect->setRotationAxis(qrect.topLeft());
page->addPrimitive(rect);
}
}
delete rect;
}
//memory cleanning
free(pxl);
dmtxEncodeDestroy(&enc);
dmtxImageDestroy(&img);
}
catch(...)
{
//there is a problem with the datamatrix
//RR is printed
printRR(page,bc,qrect);
//.........这里部分代码省略.........
开发者ID:gpazo,项目名称:xtuple-svn,代码行数:101,代码来源:datamatrix.cpp
示例14: ColorBlack
void acCustomGraphicsScene::drawBackground(QPainter *painter, const QRectF &rect)
{
// color Black
QColor ColorBlack(0, 0, 0);
// color White
QColor ColorWhite(255, 255, 255);
// Draw a line grid
if (m_gridenabled > 0)
{
painter->setPen(Qt::white);
// Start point for Horizonal steps
qreal startH = 0;
//Start point for Virtical steps
qreal startV = 0;
switch (m_gridenabled)
{
case eCustomGraphicsScene_Grids::Block:
{
QImage image(":/CompressonatorGUI/Images/GridSolid.png");
QBrush brush(image);
painter->fillRect(rect, brush);
break;
}
case eCustomGraphicsScene_Grids::Lines:
{
// First fill the BackGround as black
painter->fillRect(rect, ColorBlack);
// draw horizontal grid lines
painter->setPen(QPen(ColorWhite));
for (qreal y = startH; y < rect.bottom();)
{
y += m_gridStep;
painter->drawLine(rect.left(), y, rect.right(), y);
}
// draw virtical grid lines
for (qreal x = startV; x < rect.right();)
{
x += m_gridStep;
painter->drawLine(x, rect.top(), x, rect.bottom());
}
break;
}
case eCustomGraphicsScene_Grids::Dots:
{
// First fill the BackGround as black
painter->fillRect(rect, ColorBlack);
// draw points
painter->setPen(QPen(ColorWhite));
for (qreal y = startH; y < rect.bottom();)
{
y += m_gridStep;
// draw virtical grid lines
for (qreal x = startV; x < rect.right();)
{
x += m_gridStep;
painter->drawPoint(x, y);
}
}
break;
}
default:
{
painter->fillRect(rect, ColorBlack);
break;
}
}
}
else
painter->fillRect(rect, ColorBlack);
}
开发者ID:NoSuchProcess,项目名称:Compressonator,代码行数:85,代码来源:acCustomGraphics.cpp
示例15: PlotSymbol
void CSymbolTypeComboBox::DrawItem(LPDRAWITEMSTRUCT pDIStruct)
{
CRect rItemRect = pDIStruct->rcItem;
COLORREF clrNormal = ::GetSysColor(COLOR_WINDOW);
COLORREF clrSelected = ::GetSysColor(COLOR_HIGHLIGHT);
COLORREF drawColor = symColor;
CDC dcContext;
if (!dcContext.Attach(pDIStruct->hDC)) {
return;
}
int iState = pDIStruct->itemState;
if (iState & ODS_SELECTED)
{
drawColor = 0x00FFFFFF & ~(drawColor);
dcContext.SetBkColor(clrSelected);
dcContext.FillSolidRect(&rItemRect, clrSelected);
}
else
{
dcContext.SetBkColor(clrNormal);
dcContext.FillSolidRect(&rItemRect, clrNormal);
}
if (iState & ODS_FOCUS) {
dcContext.DrawFocusRect(&rItemRect);
}
int iItem = pDIStruct->itemID;
if (iItem != -1)
{
dcContext.SetBkMode(TRANSPARENT);
if (iState & ODS_DISABLED)
{
drawColor = ::GetSysColor(COLOR_INACTIVECAPTIONTEXT);
}
PlotSymbol currSym = PlotSymbol(iItem);
bool filledSym = PlotSymbolOps::SymbolIsFilled(currSym);
rItemRect.DeflateRect(4, 0);
int lThick = IMin(rItemRect.bottom - rItemRect.top - 2, symLThick);
if (filledSym)
lThick = 1;
CPen drawPen(PS_SOLID, lThick, drawColor);
CPen* pOldPen = dcContext.SelectObject(&drawPen);
CBrush brush(drawColor);
CBrush* pOldBrush = dcContext.SelectObject(&brush);
int drawSymSize = IMin((rItemRect.bottom - rItemRect.top), symSize);
int rectMidY = (rItemRect.top + rItemRect.bottom) / 2;
|
请发表评论