本文整理汇总了C++中QPointF函数的典型用法代码示例。如果您正苦于以下问题:C++ QPointF函数的具体用法?C++ QPointF怎么用?C++ QPointF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QPointF函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paint
void AudioNoiseWidget::paintEvent(QPaintEvent *) {
QPainter paint(this);
QPalette pal;
paint.fillRect(rect(), pal.color(QPalette::Background));
AudioInputPtr ai = g.ai;
if (ai.get() == NULL || ! ai->sppPreprocess)
return;
QPolygonF poly;
ai->qmSpeex.lock();
spx_int32_t ps_size = 0;
speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_PSD_SIZE, &ps_size);
STACKVAR(spx_int32_t, noise, ps_size);
STACKVAR(spx_int32_t, ps, ps_size);
speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_PSD, ps);
speex_preprocess_ctl(ai->sppPreprocess, SPEEX_PREPROCESS_GET_NOISE_PSD, noise);
ai->qmSpeex.unlock();
qreal sx, sy;
sx = (static_cast<float>(width()) - 1.0f) / static_cast<float>(ps_size);
sy = static_cast<float>(height()) - 1.0f;
poly << QPointF(0.0f, height() - 1);
float fftmul = 1.0 / (32768.0);
for (int i=0; i < ps_size; i++) {
qreal xp, yp;
xp = i * sx;
yp = sqrtf(sqrtf(static_cast<float>(noise[i]))) - 1.0f;
yp = yp * fftmul;
yp = qMin<qreal>(yp * 3000.0f, 1.0f);
yp = (1 - yp) * sy;
poly << QPointF(xp, yp);
}
poly << QPointF(width() - 1, height() - 1);
poly << QPointF(0.0f, height() - 1);
paint.setPen(Qt::blue);
paint.setBrush(Qt::blue);
paint.drawPolygon(poly);
poly.clear();
for (int i=0;i < ps_size; i++) {
qreal xp, yp;
xp = i * sx;
yp = sqrtf(sqrtf(static_cast<float>(ps[i]))) - 1.0f;
yp = yp * fftmul;
yp = qMin(yp * 3000.0, 1.0);
yp = (1 - yp) * sy;
poly << QPointF(xp, yp);
}
paint.setPen(Qt::red);
paint.drawPolyline(poly);
}
示例2: borderForLineCoord
void QgsDecorationGrid::drawCoordinateAnnotation( QPainter* p, QPointF pos, const QString& annotationString )
{
Border frameBorder = borderForLineCoord( pos, p );
double textWidth = textWidthMillimeters( mGridAnnotationFont, annotationString );
//relevant for annotations is the height of digits
double textHeight = fontHeightCharacterMM( mGridAnnotationFont, QChar( '0' ) );
double xpos = pos.x();
double ypos = pos.y();
int rotation = 0;
if ( frameBorder == Left )
{
if ( mGridAnnotationPosition == InsideMapFrame )
{
if ( mGridAnnotationDirection == Vertical || mGridAnnotationDirection == BoundaryDirection )
{
xpos += textHeight + mAnnotationFrameDistance;
ypos += textWidth / 2.0;
rotation = 270;
}
else
{
xpos += mAnnotationFrameDistance;
ypos += textHeight / 2.0;
}
}
else //Outside map frame
{
if ( mGridAnnotationDirection == Vertical || mGridAnnotationDirection == BoundaryDirection )
{
xpos -= mAnnotationFrameDistance;
ypos += textWidth / 2.0;
rotation = 270;
}
else
{
xpos -= textWidth + mAnnotationFrameDistance;
ypos += textHeight / 2.0;
}
}
}
else if ( frameBorder == Right )
{
if ( mGridAnnotationPosition == InsideMapFrame )
{
if ( mGridAnnotationDirection == Vertical || mGridAnnotationDirection == BoundaryDirection )
{
xpos -= mAnnotationFrameDistance;
ypos += textWidth / 2.0;
rotation = 270;
}
else //Horizontal
{
xpos -= textWidth + mAnnotationFrameDistance;
ypos += textHeight / 2.0;
}
}
else //OutsideMapFrame
{
if ( mGridAnnotationDirection == Vertical || mGridAnnotationDirection == BoundaryDirection )
{
xpos += textHeight + mAnnotationFrameDistance;
ypos += textWidth / 2.0;
rotation = 270;
}
else //Horizontal
{
xpos += mAnnotationFrameDistance;
ypos += textHeight / 2.0;
}
}
}
else if ( frameBorder == Bottom )
{
if ( mGridAnnotationPosition == InsideMapFrame )
{
if ( mGridAnnotationDirection == Horizontal || mGridAnnotationDirection == BoundaryDirection )
{
ypos -= mAnnotationFrameDistance;
xpos -= textWidth / 2.0;
}
else //Vertical
{
xpos += textHeight / 2.0;
ypos -= mAnnotationFrameDistance;
rotation = 270;
}
}
else //OutsideMapFrame
{
if ( mGridAnnotationDirection == Horizontal || mGridAnnotationDirection == BoundaryDirection )
{
ypos += mAnnotationFrameDistance + textHeight;
xpos -= textWidth / 2.0;
}
else //Vertical
{
xpos += textHeight / 2.0;
//.........这里部分代码省略.........
示例3: main
int main()
{
{
// STREAM
//! [0]
QPolygon polygon;
polygon << QPoint(10, 20) << QPoint(20, 30);
//! [0]
}
{
// STREAMF
//! [1]
QPolygonF polygon;
polygon << QPointF(10.4, 20.5) << QPointF(20.2, 30.2);
//! [1]
}
{
// SETPOINTS
//! [2]
static const int points[] = { 10, 20, 30, 40 };
QPolygon polygon;
polygon.setPoints(2, points);
//! [2]
}
{
// SETPOINTS2
//! [3]
QPolygon polygon;
polygon.setPoints(2, 10, 20, 30, 40);
//! [3]
}
{
// PUTPOINTS
//! [4]
QPolygon polygon(1);
polygon[0] = QPoint(4, 5);
polygon.putPoints(1, 2, 6,7, 8,9);
//! [4]
}
{
// PUTPOINTS2
//! [5]
QPolygon polygon(3);
polygon.putPoints(0, 3, 4,5, 0,0, 8,9);
polygon.putPoints(1, 1, 6,7);
//! [5]
}
{
// PUTPOINTS3
//! [6]
QPolygon polygon1;
polygon1.putPoints(0, 3, 1,2, 0,0, 5,6);
// polygon1 is now the three-point polygon(1,2, 0,0, 5,6);
QPolygon polygon2;
polygon2.putPoints(0, 3, 4,4, 5,5, 6,6);
// polygon2 is now (4,4, 5,5, 6,6);
polygon1.putPoints(2, 3, polygon2);
// polygon1 is now the five-point polygon(1,2, 0,0, 4,4, 5,5, 6,6);
//! [6]
}
return 0;
}
示例4: fillRectVec
static void fillRectVec(QVector<QPointF> &v)
{
int numRects = v.size() / 5;
int first = 0;
v[first++] = QPointF(0, 0);
v[first++] = QPointF(10, 0);
v[first++] = QPointF(10, 10);
v[first++] = QPointF(0, 10);
v[first++] = QPointF(0, 0);
v[first++] = QPointF(0, 0);
v[first++] = QPointF(2, 2);
v[first++] = QPointF(4, 0);
v[first++] = QPointF(2, -2);
v[first++] = QPointF(0, 0);
v[first++] = QPointF(0, 0);
v[first++] = QPointF(4, 4);
v[first++] = QPointF(6, 2);
v[first++] = QPointF(2, -2);
v[first++] = QPointF(0, 0);
for (int i = first / 5; i < numRects; ++i) {
QPointF a = creatPoint();
QPointF b = creatPoint();
QPointF delta = a - b;
QPointF perp(delta.y(), -delta.x());
perp *= ((int)(20.0 * rand() / (RAND_MAX + 1.0))) / 20.0;
int j = 5 * i;
v[j++] = a + perp;
v[j++] = a - perp;
v[j++] = b - perp;
v[j++] = b + perp;
v[j++] = a + perp;
}
}
示例5: fullRect
QRectF QPageLayoutPrivate::fullRect(QPageLayout::Unit units) const
{
return units == m_units ? fullRect() : QRectF(QPointF(0, 0), fullSizeUnits(units));
}
示例6: QColor
//.........这里部分代码省略.........
!= excludeSquares->end() )
continue;
cheng4::Piece pc = board.piece(sq);
cheng4::Piece pt = cheng4::PiecePack::type(pc);
if ( pt == cheng4::ptNone )
continue;
cheng4::Color c = cheng4::PiecePack::color(pc);
if ( !pieceSet || !pieceSet->pieces[c][pt-1] )
continue;
pieceSet->pieces[c][pt-1]->renderer()->render(&p, sub);
}
// FIXME: better!!!
for (cheng4::Square s = 0; s < 64; s++)
{
cheng4::File f = cheng4::SquarePack::file(s);
cheng4::Rank r = cheng4::SquarePack::rank(s);
QRectF sub(rc.left() + sw*f + bordersz, rc.top() + sh*r + bordersz, sw, sh);
cheng4::Square sq = flip ? cheng4::SquarePack::flipH(cheng4::SquarePack::flipV(s)) : s;
// now highlight!!!
if ( highlight == cheng4::mcNone || highlight == cheng4::mcNull )
continue;
cheng4::Square from, to;
from = cheng4::MovePack::from(highlight);
to = cheng4::MovePack::to(highlight);
if ( sq != from && sq != to )
continue;
QPen hpen( highlightColor );
hpen.setWidth(2);
p.setPen( hpen );
p.setBrush( Qt::transparent );
p.drawRect( sub );
p.setPen( Qt::transparent );
}
if ( !border )
return;
// draw board letters
p.setPen( letterColor );
QTextOption opt;
opt.setAlignment(Qt::AlignCenter);
QFont font;
font.setBold(0);
font.setPixelSize(12);
p.setFont(font);
for (uint i=0; i<8; i++)
{
// rows:
QPointF pt( 0, bordersz + sh*i );
QRectF rct;
rct.setTopLeft( pt );
rct.setSize( QSizeF( bordersz, sh ) );
QString text;
int irow = 7-(int)i;
if ( flip )
irow = 8-1-irow;
text.sprintf("%d", irow+1);
p.drawText(rct, text, opt);
pt.setX( bordersz+sw*8 );
rct.setTopLeft( pt );
rct.setSize( QSizeF( bordersz, sh ) );
p.drawText(rct, text, opt);
// cols:
int icol = (int)i;
if ( flip )
icol = 8-1-i;
text.sprintf("%c", 'a' + icol);
pt.setX( bordersz + sw*i );
pt.setY( 0 );
rct.setTopLeft(pt);
rct.setSize( QSizeF( sw, bordersz ) );
p.drawText(rct, text, opt);
pt.setY( bordersz+sh*8 );
rct.setTopLeft( pt );
rct.setSize( QSizeF( sw, bordersz ) );
p.drawText(rct, text, opt);
}
// draw stm
QRectF upr;
upr.setTopLeft( QPointF( bordersz + sw*8 + bordersz/8, bordersz/8 ) );
upr.setSize( QSizeF( bordersz - 2*bordersz/8, bordersz - 2*bordersz/8 ) );
bool upper = board.turn() == (flip ? cheng4::ctWhite : cheng4::ctBlack);
p.setPen( wb[ cheng4::flip(board.turn()) ] );
p.setBrush( wb[ board.turn() ] );
if ( upper )
p.drawRect( upr );
QRectF lwr;
lwr.setTopLeft( QPointF( bordersz + sw*8 + bordersz/8, bordersz + sh*8 + bordersz/8 ) );
lwr.setSize( QSizeF( bordersz - 2*bordersz/8, bordersz - 2*bordersz/8 ) );
if ( !upper )
p.drawRect( lwr );
}
示例7: bboxCidade
/**
* Evento chamado quando o mouse é clicado
*/
void GraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
if(!running)
{
QPointF pos = mouseEvent->scenePos(); //posição do mouse na hora do clique
//qDebug() << "x: " << pos.x() << " y: " << pos.y();
bool colidiu = false;
QList<QGraphicsItem *> cidades = this->items(); //lista de cidades na tela
if(mouseEvent->button() == Qt::LeftButton) //adicionar uma cidade
{
QRectF bboxCidade(pos.x(),pos.y(), cidadeWidth, cidadeHeigth); //bouding box da elipse da cidade
//gradiente de cores de cada cidade
QRadialGradient gradient(10, 10, 10, 10, 10);
gradient.setColorAt(0, QColor::fromRgbF(0.5, 0.8, 0.7, 1));
gradient.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0));
gradient.setSpread(QGradient::ReflectSpread);
QBrush brush(gradient);
QGraphicsEllipseItem *cidade = new QGraphicsEllipseItem(bboxCidade);
cidade->setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
cidade->setBrush(brush);
cidade->setZValue(1.0);
for(int i = 0; i < cidades.size(); i++) //percorrendo a lista de cidades
{
if(cidades.at(i)->collidesWithItem(cidade) && cidades.at(i)->data(1).toBool())
{
colidiu = true;
break;
}
}
if(!colidiu) //se não houve colisão
{
cidade->setData(0, Cidade::getLastId() + 1);
cidade->setData(1, 1);
cidade->setData(4, pos);
this->addItem(cidade);
if(lastPos.x() != -10.0 && lastPos.y() != -10.0)
{
QPoint cids(Cidade::getLastId(),Cidade::getLastId() + 1);
//this->drawEdge(lastPos, pos, cids);
}
lastPos = pos;
emit cidadeCriada(pos); //sinal emitido quando uma cidade é criada
}
}
else if(mouseEvent->button() == Qt::RightButton) //remover uma cidade
{
for(int i = 0; i < cidades.size(); i++) //percorrendo a lista de cidades
{
if(cidades.at(i)->contains(pos) && cidades.at(i)->data(1).toInt() == 1) //o mouse foi clicado em cima de uma cidade
{
int chave = cidades.at(i)->data(0).toInt();
this->removeItem(cidades.at(i));
//this->removeEdge(chave);
if(items().size() == 0) lastPos = QPointF(-10,-10);
emit cidadeRemovida(chave); //sinal emitido quando uma cidade removida
}
}
}
}
}
示例8: startRender
void QgsMarkerSymbolLayerV2::drawPreviewIcon( QgsSymbolV2RenderContext& context, QSize size )
{
startRender( context );
renderPoint( QPointF( size.width() / 2, size.height() / 2 ), context );
stopRender( context );
}
示例9: DEG2RAD
QPointF QgsMarkerSymbolLayerV2::_rotatedOffset( const QPointF& offset, double angle )
{
angle = DEG2RAD( angle );
double c = cos( angle ), s = sin( angle );
return QPointF( offset.x() * c - offset.y() * s, offset.x() * s + offset.y() * c );
}
示例10: painter
void FGWCondition::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
QFontMetrics fm = painter.fontMetrics();
if (fm.ascent() + fm.descent() != m_fontHeight)
{
m_fontHeight = fm.ascent() + fm.descent();
updateTransforms();
}
// Y-Axis label
QTransform transform;
transform.rotate(270);
transform.translate(-(height() + fm.width(m_yAxisLabel)) / 2, fm.ascent());
painter.setTransform(transform);
painter.drawText(QPointF(0, 0), m_yAxisLabel);
// X-Axis label
transform.reset();
painter.setTransform(transform);
painter.drawText(QPointF((width() - fm.width(m_xAxisLabel)) / 2, height() - fm.descent()), m_xAxisLabel);
// The actual graph
if (m_forceCondition)
{
QPointF startPos(-1.0, 0.0);
QPointF startViewPos = m_model2View.map(startPos);
QPointF endPos(1.0, 0.0);
QPointF endViewPos = m_model2View.map(endPos);
double negativeSaturation = m_forceCondition->negativeSaturation();
if (m_forceCondition->negativeCoefficient() < 0.0)
{
negativeSaturation = -negativeSaturation;
}
double positiveSaturation = m_forceCondition->positiveSaturation();
if (m_forceCondition->positiveCoefficient() < 0.0)
{
positiveSaturation = -positiveSaturation;
}
double negativeDeadBandValue = CLIP11(m_forceCondition->offset() - m_forceCondition->deadBand());
double positiveDeadBandValue = CLIP11(m_forceCondition->offset() + m_forceCondition->deadBand());
double negCoeff = m_forceCondition->negativeCoefficient();
double negCoeffValue = 1000.0;
if (0.001 < fabs(negCoeff))
{
negCoeffValue = (1.0 / fabs(negCoeff)) - 1.0;
}
negCoeffValue *= m_forceCondition->negativeSaturation();
double negativeSaturationValue = negativeDeadBandValue - negCoeffValue;
if (negativeSaturationValue < -1.0)
{
double negCoeffVisible = negativeDeadBandValue + 1.0;
double ratio = negCoeffVisible / negCoeffValue;
negativeSaturation *= ratio;
negativeSaturationValue = -1.0;
}
double posCoeff = m_forceCondition->positiveCoefficient();
double posCoeffValue = 1000.0;
if (0.001 < fabs(posCoeff))
{
posCoeffValue = (1.0 / fabs(posCoeff)) - 1.0;
}
posCoeffValue *= m_forceCondition->positiveSaturation();
double positiveSaturationValue = positiveDeadBandValue + posCoeffValue;
if (1.0 < positiveSaturationValue)
{
double posCoeffVisible = 1.0 - positiveDeadBandValue;
double ratio = posCoeffVisible / posCoeffValue;
positiveSaturation *= ratio;
positiveSaturationValue = 1.0;
}
QPointF offsetPos(m_forceCondition->offset(), 0.0);
QPointF offsetViewPos = m_model2View.map(offsetPos);
QPointF negativeSaturationPos(-1.0, negativeSaturation);
QPointF negativeSaturationViewPos = m_model2View.map(negativeSaturationPos);
QPointF negativeCoefficientPos(negativeSaturationValue, negativeSaturation);
QPointF negativeCoefficientViewPos = m_model2View.map(negativeCoefficientPos);
QPointF negativeDeadBandPos(negativeDeadBandValue, 0.0);
QPointF negativeDeadBandViewPos = m_model2View.map(negativeDeadBandPos);
QPointF positiveDeadBandPos(positiveDeadBandValue, 0.0);
QPointF positiveDeadBandViewPos = m_model2View.map(positiveDeadBandPos);
QPointF positiveCoefficientPos(positiveSaturationValue, positiveSaturation);
QPointF positiveCoefficientViewPos = m_model2View.map(positiveCoefficientPos);
QPointF positiveSaturationPos(1.0, positiveSaturation);
QPointF positiveSaturationViewPos = m_model2View.map(positiveSaturationPos);
//.........这里部分代码省略.........
示例11: ClearEnvironment
void Playground::SetEnvironment()
{
ClearEnvironment();
countingTimeText = scene.addSimpleText(QString("0"));
countingTimeText->setPos(-100, 100);
srand(numberAgents * numberObstacles);
Obstacle * tempObstacle;
QPolygonF polygon;
int centerX, centerY;
qreal koef = 0.5;
for(int loop1 = 0; loop1 < numberObstacles; loop1++)
{
tempObstacle = new Obstacle();
polygon.clear();
centerX = rand() % 10 * 100 - 25 + rand() % 50;
centerY = rand() % 10 * 100 - 25 + rand() % 50;
int size = 30;
switch(rand() % 3)
{
case 0:
polygon.push_back(QPointF(koef * (centerX - size), koef * (centerY - size)));
polygon.push_back(QPointF(koef * (centerX + size), koef * (centerY - size)));
polygon.push_back(QPointF(koef * (centerX), koef * (centerY + size)));
break;
case 1:
polygon.push_back(QPointF(koef * (centerX - size), koef * (centerY - size)));
polygon.push_back(QPointF(koef * (centerX + size), koef * (centerY)));
polygon.push_back(QPointF(koef * (centerX - size), koef * (centerY + size)));
break;
case 2:
polygon.push_back(QPointF(koef * (centerX - size), koef * (centerY - size)));
polygon.push_back(QPointF(koef * (centerX + size), koef * (centerY - size)));
polygon.push_back(QPointF(koef * (centerX - size), koef * (centerY + size)));
break;
}
tempObstacle->setPolygon(polygon);
obstacle.push_back(tempObstacle);
scene.addItem(tempObstacle);
}
Agent * tempAgent;
PotentialField * tempField;
GoalPoint * tempGoal;
int agentX, agentY;
int agentWidth = 5;
for(int loop1 = 0; loop1 < numberAgents; loop1++)
{
switch(loop1 % 4)
{
case 0 :
agentX = -40;
agentY = rand() % 100 * 5;
break;
case 1 :
agentX = 510;
agentY = rand() % 100 * 5;
break;
case 2 :
agentY = -40;
agentX = rand() % 100 * 5;
break;
case 3 :
agentY = 510;
agentX = rand() % 100 * 5;
break;
}
tempAgent = new Agent(agentX, agentY, agentWidth, agentWidth, 0);
tempAgent->SetGoal(470 - agentX, 470 - agentY);
tempGoal = new GoalPoint(470 - agentX - 5, 470 - agentY - 5, 10, 10, 0);
tempField = new PotentialField(tempAgent, agentX, agentY, 0);
tempAgent->SetField(tempField);
agent.push_back(tempAgent);
scene.addItem(tempAgent);
field.push_back(tempField);
scene.addItem(tempField);
goalPoint.push_back(tempGoal);
scene.addItem(tempGoal);
}
}
示例12: int
void SkyQPainter::drawDeepSkySymbol(const QPointF &pos, int type, float size, float e, float positionAngle)
{
float x = pos.x();
float y = pos.y();
float zoom = Options::zoomFactor();
int isize = int(size);
float dx1 = -0.5*size;
float dx2 = 0.5*size;
float dy1 = -1.0*e*size/2.;
float dy2 = e*size/2.;
float x1 = x + dx1;
float x2 = x + dx2;
float y1 = y + dy1;
float y2 = y + dy2;
float dxa = -size/4.;
float dxb = size/4.;
float dya = -1.0*e*size/4.;
float dyb = e*size/4.;
float xa = x + dxa;
float xb = x + dxb;
float ya = y + dya;
float yb = y + dyb;
QString color;
float psize;
QBrush tempBrush;
std::function<void( float, float, float, float )> lambdaDrawEllipse;
std::function<void( float, float, float, float )> lambdaDrawLine;
std::function<void( float, float, float, float )> lambdaDrawCross;
if ( Options::useAntialias() ) {
lambdaDrawEllipse = [this]( float x, float y, float width, float height ) {
drawEllipse( QRectF( x, y, width, height ) );
};
lambdaDrawLine = [this]( float x1, float y1, float x2, float y2 ) {
drawLine( QLineF( x1, y1, x2, y2 ) );
};
lambdaDrawCross = [this]( float centerX, float centerY, float sizeX, float sizeY ) {
drawLine( QLineF( centerX - sizeX/2., centerY, centerX + sizeX/2., centerY ) );
drawLine( QLineF( centerX, centerY - sizeY/2., centerX, centerY + sizeY/2. ) );
};
}
else {
lambdaDrawEllipse = [this]( float x, float y, float width, float height ) {
drawEllipse( QRect( x, y, width, height ) );
};
lambdaDrawLine = [this]( float x1, float y1, float x2, float y2 ) {
drawLine( QLine( x1, y1, x2, y2 ) );
};
lambdaDrawCross = [this]( float centerX, float centerY, float sizeX, float sizeY ) {
drawLine( QLine( centerX - sizeX/2., centerY, centerX + sizeX/2., centerY ) );
drawLine( QLine( centerX, centerY - sizeY/2., centerX, centerY + sizeY/2. ) );
};
}
switch ( type ) {
case 0:
case 1: //catalog star
//Some NGC/IC objects are stars...changed their type to 1 (was double star)
if (size<2.) size = 2.;
lambdaDrawEllipse( x1, y1, size/2., size/2. );
break;
case 2: //Planet
break;
case 3: //Open cluster; draw circle of points
case 13: { // Asterism
tempBrush = brush();
color = pen().color().name();
setBrush( pen().color() );
psize = 2.;
if ( size > 50. ) psize *= 2.;
if ( size > 100. ) psize *= 2.;
auto putDot = [this, psize, &lambdaDrawEllipse]( float x, float y ) {
lambdaDrawEllipse( x, y, psize, psize );
};
putDot( xa, y1 );
putDot( xb, y1 );
putDot( xa, y2 );
putDot( xb, y2 );
putDot( x1, ya );
putDot( x1, yb );
putDot( x2, ya );
putDot( x2, yb );
setBrush( tempBrush );
break;
}
case 4: //Globular Cluster
if (size<2.) size = 2.;
save();
translate( x, y );
color = pen().color().name();
rotate( positionAngle ); //rotate the coordinate system
lambdaDrawEllipse( dx1, dy1, size, e*size );
lambdaDrawCross( 0, 0, size, e*size );
//.........这里部分代码省略.........
示例13: updateEdgeRects
void Draw_Triangle::updateEdgeRects()
{
handles[0]->setRect(QRectF(QPointF(item->boundingRect().topLeft().x()-5.0,item->boundingRect().topLeft().y()-5.0),QPointF(item->boundingRect().topLeft().x()+5.0,item->boundingRect().topLeft().y()+5.0)));
handles[1]->setRect(QRectF(QPointF(item->boundingRect().topLeft().x()-5.0,((item->boundingRect().topLeft().y()+StrtPnt.y())/2)-5.0),QPointF(item->boundingRect().topLeft().x()+5.0,((item->boundingRect().topLeft().y()+StrtPnt.y())/2)+5.0)));
handles[2]->setRect(QRectF(QPointF(item->boundingRect().topRight().x()-5.0,item->boundingRect().topRight().y()-5.0),QPointF(item->boundingRect().topRight().x()+5.0,item->boundingRect().topRight().y()+5.0)));
handles[3]->setRect(QRectF(QPointF(item->boundingRect().topRight().x()-5.0,((item->boundingRect().topRight().y()+EndPnt.y())/2)-5.0),QPointF(item->boundingRect().topRight().x()+5.0,((item->boundingRect().topRight().y()+EndPnt.y())/2)+5.0)));
handles[4]->setRect(QRectF(QPointF(StrtPnt.x()-5.0,StrtPnt.y()-5.0),QPointF(StrtPnt.x()+5.0,StrtPnt.y()+5.0)));
handles[6]->setRect(QRectF(QPointF(EndPnt.x()-5.0,EndPnt.y()-5.0),QPointF(EndPnt.x()+5.0,EndPnt.y()+5.0)));
handles[5]->setRect(QRectF(QPointF(((StrtPnt.x()+EndPnt.x())/2)-5.0,StrtPnt.y()-5.0),QPointF((StrtPnt.x()+EndPnt.x())/2+5.0,StrtPnt.y()+5.0)));
handles[7]->setRect(QRectF(QPointF(HeightPnt.x()-5.0,HeightPnt.y()-5.0),QPointF(HeightPnt.x()+5.0,HeightPnt.y()+5.0)));
Bounding_Rect->setRect(QRectF(item->boundingRect().topLeft(),item->boundingRect().bottomRight()));
QPointF pnt1,pnt2;
pnt1.setX(((item->boundingRect().topLeft().x()+item->boundingRect().bottomRight().x())/2)-5);
pnt1.setY(item->boundingRect().topLeft().y()-20);
pnt2.setX(((item->boundingRect().topLeft().x()+item->boundingRect().bottomRight().x())/2)+5);
pnt2.setY(item->boundingRect().topLeft().y()-10);
Rot_Rect->setRect(QRectF(pnt1,pnt2));
}
示例14: QString
void ezTimeWidget::UpdateStats()
{
if (!isVisible())
return;
if (!ezTelemetry::IsConnectedToServer())
{
ListClocks->setEnabled(false);
return;
}
ListClocks->setEnabled(true);
if (m_bClocksChanged)
{
m_bClocksChanged = false;
ListClocks->blockSignals(true);
ListClocks->clear();
for (ezMap<ezString, ezTimeWidget::ClockData>::Iterator it = m_ClockData.GetIterator(); it.IsValid(); ++it)
{
ListClocks->addItem(it.Key().GetData());
QListWidgetItem* pItem = ListClocks->item(ListClocks->count() - 1);
pItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
pItem->setCheckState (it.Value().m_bDisplay ? Qt::Checked : Qt::Unchecked);
pItem->setData(Qt::UserRole, QString(it.Key().GetData()));
pItem->setTextColor(s_Colors[it.Value().m_iColor % s_uiMaxColors]);
it.Value().m_pListItem = pItem;
}
ListClocks->blockSignals(false);
}
QPainterPath pp[s_uiMaxColors];
ezTime tMin = ezTime::Seconds(100.0);
ezTime tMax = ezTime::Seconds(0.0);
for (ezMap<ezString, ClockData>::Iterator it = s_pWidget->m_ClockData.GetIterator(); it.IsValid(); ++it)
{
if (it.Value().m_TimeSamples.IsEmpty() || !it.Value().m_bDisplay)
continue;
const ezUInt32 uiColorPath = it.Value().m_iColor % s_uiMaxColors;
ClockData& Clock = it.Value();
const ezDeque<TimeSample>& Samples = Clock.m_TimeSamples;
ezUInt32 uiFirstSample = 0;
while ((uiFirstSample < Samples.GetCount()) && (m_MaxGlobalTime - Samples[uiFirstSample].m_AtGlobalTime > m_DisplayInterval))
++uiFirstSample;
if (uiFirstSample < Samples.GetCount())
{
pp[uiColorPath].moveTo (QPointF((Samples[uiFirstSample].m_AtGlobalTime - m_MaxGlobalTime).GetSeconds(), Samples[uiFirstSample].m_Timestep.GetSeconds()));
for (ezUInt32 i = uiFirstSample + 1; i < Samples.GetCount(); ++i)
{
pp[uiColorPath].lineTo (QPointF ((Samples[i].m_AtGlobalTime - m_MaxGlobalTime).GetSeconds(), Samples[i].m_Timestep.GetSeconds()));
tMin = ezMath::Min(tMin, Samples[i].m_Timestep);
tMax = ezMath::Max(tMax, Samples[i].m_Timestep);
}
}
}
for (ezUInt32 i = 0; i < s_uiMaxColors; ++i)
m_pPath[i]->setPath(pp[i]);
// render the helper lines for time values
{
QPainterPath pMax;
for (ezUInt32 i = 1; i < 10; ++i)
{
pMax.moveTo(QPointF (-m_DisplayInterval.GetSeconds(), ezTime::Milliseconds(10.0 * i).GetSeconds()));
pMax.lineTo(QPointF (0, ezTime::Milliseconds(10.0 * i).GetSeconds()));
}
m_pPathMax->setPath(pMax);
}
ezTime tShowMax = ezTime::Seconds(1.0 / 10.0);
for (ezUInt32 t = 25; t < 100; t += 25)
{
tShowMax = ezTime::Milliseconds(1) * t;
if (tMax < tShowMax)
break;
}
{
TimeView->setSceneRect (QRectF (-m_DisplayInterval.GetSeconds(), 0, m_DisplayInterval.GetSeconds(), tShowMax.GetSeconds()));
TimeView->fitInView (QRectF (-m_DisplayInterval.GetSeconds(), 0, m_DisplayInterval.GetSeconds(), tShowMax.GetSeconds()));
}
//.........这里部分代码省略.........
示例15: qDebug
void Draw_Triangle::setEdgeRects()
{
QBrush rectbrush;
rectbrush.setColor(QColor(0,175,225));
rectbrush.setStyle(Qt::SolidPattern);
qDebug()<<"strt pnt "<<StrtPnt<<" "<<"end pnt "<<EndPnt<<"\n";
QGraphicsRectItem *rect = new QGraphicsRectItem(QRectF(QPointF(item->boundingRect().topLeft().x()-5.0,item->boundingRect().topLeft().y()-5.0),QPointF(item->boundingRect().topLeft().x()+5.0,item->boundingRect().topLeft().y()+5.0)));
rect->setBrush(rectbrush);
handles.push_back(rect);
rect = new QGraphicsRectItem(QRectF(QPointF(item->boundingRect().topLeft().x()-5.0,(item->boundingRect().topLeft().y()+25)-5.0),QPointF(item->boundingRect().topLeft().x()+5.0,(item->boundingRect().topLeft().y()+25)+5.0)));
rect->setBrush(rectbrush);
handles.push_back(rect);
rect = new QGraphicsRectItem(QRectF(QPointF(item->boundingRect().topRight().x()-5.0,item->boundingRect().topRight().y()-5.0),QPointF(item->boundingRect().topRight().x()+5.0,item->boundingRect().topRight().y()+5.0)));
rect->setBrush(rectbrush);
handles.push_back(rect);
rect = new QGraphicsRectItem(QRectF(QPointF(item->boundingRect().topRight().x()-5.0,(item->boundingRect().topRight().y()+25)-5.0),QPointF(item->boundingRect().topRight().x()+5.0,(item->boundingRect().topRight().y()+25)+5.0)));
rect->setBrush(rectbrush);
handles.push_back(rect);
rect = new QGraphicsRectItem(QRectF(QPointF(StrtPnt.x()-5.0,StrtPnt.y()-5.0),QPointF(StrtPnt.x()+5.0,StrtPnt.y()+5.0)));
rect->setBrush(rectbrush);
handles.push_back(rect);
rect = new QGraphicsRectItem(QRectF(QPointF((StrtPnt.x()+50)-5.0,StrtPnt.y()-5.0),QPointF((StrtPnt.x()+50)+5.0,StrtPnt.y()+5.0)));
rect->setBrush(rectbrush);
handles.push_back(rect);
rect = new QGraphicsRectItem(QRectF(QPointF(EndPnt.x()-5.0,EndPnt.y()-5.0),QPointF(EndPnt.x()+5.0,EndPnt.y()+5.0)));
rect->setBrush(rectbrush);
handles.push_back(rect);
rect = new QGraphicsRectItem(QRectF(QPointF(HeightPnt.x()-5.0,HeightPnt.y()-5.0),QPointF(HeightPnt.x()+5.0,HeightPnt.y()+5.0)));
rect->setBrush(rectbrush);
handles.push_back(rect);
QPen bound_rect;
bound_rect.setStyle(Qt::DashLine);
Bounding_Rect = new QGraphicsRectItem(QRectF(item->boundingRect().topLeft(),item->boundingRect().bottomRight()));
Bounding_Rect->setPen(bound_rect);
QPointF pnt1,pnt2;
pnt1.setX(((item->boundingRect().topLeft().x()+item->boundingRect().bottomRight().x())/2)-5);
pnt1.setY(item->boundingRect().topLeft().y()-20);
pnt2.setX(((item->boundingRect().topLeft().x()+item->boundingRect().bottomRight().x())/2)+5);
pnt2.setY(item->boundingRect().topLeft().y()-10);
Rot_Rect = new QGraphicsEllipseItem(QRectF(pnt1,pnt2));
Rot_Rect->setBrush(rectbrush);
}