本文整理汇总了C++中qreal函数的典型用法代码示例。如果您正苦于以下问题:C++ qreal函数的具体用法?C++ qreal怎么用?C++ qreal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qreal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: QByteArrayLiteral
void QQmlAccessible::doAction(const QString &actionName)
{
// Look for and call the accessible[actionName]Action() function on the item.
// This allows for overriding the default action handling.
const QByteArray functionName = QByteArrayLiteral("accessible") + actionName.toLatin1() + QByteArrayLiteral("Action");
if (object()->metaObject()->indexOfMethod(QByteArray(functionName + QByteArrayLiteral("()"))) != -1) {
QMetaObject::invokeMethod(object(), functionName);
return;
}
// Role-specific default action handling follows. Items are expected to provide
// properties according to role conventions. These will then be read and/or updated
// by the accessibility system.
// Checkable roles : checked
// Value-based roles : (via the value interface: value, minimumValue, maximumValue), stepSize
switch (role()) {
case QAccessible::RadioButton:
case QAccessible::CheckBox: {
QVariant checked = object()->property("checked");
if (checked.isValid()) {
if (actionName == QAccessibleActionInterface::toggleAction() ||
actionName == QAccessibleActionInterface::pressAction()) {
object()->setProperty("checked", QVariant(!checked.toBool()));
}
}
break;
}
case QAccessible::Slider:
case QAccessible::SpinBox:
case QAccessible::Dial:
case QAccessible::ScrollBar: {
if (actionName != QAccessibleActionInterface::increaseAction() &&
actionName != QAccessibleActionInterface::decreaseAction())
break;
// Update the value using QAccessibleValueInterface, respecting
// the minimum and maximum value (if set). Also check for and
// use the "stepSize" property on the item
if (QAccessibleValueInterface *valueIface = valueInterface()) {
QVariant valueV = valueIface->currentValue();
qreal newValue = valueV.toReal();
QVariant stepSizeV = object()->property("stepSize");
qreal stepSize = stepSizeV.isValid() ? stepSizeV.toReal() : qreal(1.0);
if (actionName == QAccessibleActionInterface::increaseAction()) {
newValue += stepSize;
} else {
newValue -= stepSize;
}
QVariant minimumValueV = valueIface->minimumValue();
if (minimumValueV.isValid()) {
newValue = qMax(newValue, minimumValueV.toReal());
}
QVariant maximumValueV = valueIface->maximumValue();
if (maximumValueV.isValid()) {
newValue = qMin(newValue, maximumValueV.toReal());
}
valueIface->setCurrentValue(QVariant(newValue));
}
break;
}
default:
break;
}
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:68,代码来源:qqmlaccessible.cpp
示例2: qreal
void QGraphicsWebViewPrivate::scroll(int dx, int dy, const QRect& rectToScroll)
{
q->scroll(qreal(dx), qreal(dy), QRectF(rectToScroll));
}
开发者ID:dzip,项目名称:webkit,代码行数:4,代码来源:qgraphicswebview.cpp
示例3: scaleVal
/**
* Compute scale parameter from user-controlled zoom factor
*/
inline qreal scaleVal( qreal zoom_scale)
{
return qPow( qreal(2), zoom_scale / qreal(5));
}
开发者ID:ezhangle,项目名称:codequery,代码行数:7,代码来源:graph_view.cpp
示例4: qreal
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtCore/qmath.h>
QT_BEGIN_NAMESPACE
const qreal qt_sine_table[QT_SINE_TABLE_SIZE] = {
qreal(0.0),
qreal(0.024541228522912288),
qreal(0.049067674327418015),
qreal(0.073564563599667426),
qreal(0.098017140329560604),
qreal(0.1224106751992162),
qreal(0.14673047445536175),
qreal(0.17096188876030122),
qreal(0.19509032201612825),
qreal(0.2191012401568698),
qreal(0.24298017990326387),
qreal(0.26671275747489837),
qreal(0.29028467725446233),
qreal(0.31368174039889152),
qreal(0.33688985339222005),
qreal(0.35989503653498811),
开发者ID:BGmot,项目名称:Qt,代码行数:31,代码来源:qmath.cpp
示例5: right
void KoTextLayoutTableArea::layoutColumns()
{
QTextTableFormat tableFormat = d->table->format();
d->columnPositions.resize(d->table->columns() + 1);
d->columnWidths.resize(d->table->columns() + 1);
// Table width.
d->tableWidth = 0;
qreal parentWidth = right() - left();
if (tableFormat.width().rawValue() == 0 || tableFormat.alignment() == Qt::AlignJustify) {
// We got a zero width value or alignment is justify, so use 100% of parent.
d->tableWidth = parentWidth - tableFormat.leftMargin() - tableFormat.rightMargin();
} else {
if (tableFormat.width().type() == QTextLength::FixedLength) {
// Fixed length value, so use the raw value directly.
d->tableWidth = tableFormat.width().rawValue();
} else if (tableFormat.width().type() == QTextLength::PercentageLength) {
// Percentage length value, so use a percentage of parent width.
d->tableWidth = tableFormat.width().rawValue() * (parentWidth / 100)
- tableFormat.leftMargin() - tableFormat.rightMargin();
} else {
// Unknown length type, so use 100% of parent.
d->tableWidth = parentWidth - tableFormat.leftMargin() - tableFormat.rightMargin();
}
}
// Column widths.
qreal availableWidth = d->tableWidth; // Width available for columns.
QList<int> fixedWidthColumns; // List of fixed width columns.
QList<int> relativeWidthColumns; // List of relative width columns.
qreal relativeWidthSum = 0; // Sum of relative column width values.
int numNonStyleColumns = 0;
for (int col = 0; col < d->table->columns(); ++col) {
KoTableColumnStyle columnStyle = d->carsManager.columnStyle(col);
if (columnStyle.hasProperty(KoTableColumnStyle::RelativeColumnWidth)) {
// Relative width specified. Will be handled in the next loop.
d->columnWidths[col] = 0.0;
relativeWidthColumns.append(col);
relativeWidthSum += columnStyle.relativeColumnWidth();
} else if (columnStyle.hasProperty(KoTableColumnStyle::ColumnWidth)) {
// Only width specified, so use it.
d->columnWidths[col] = columnStyle.columnWidth();
fixedWidthColumns.append(col);
availableWidth -= columnStyle.columnWidth();
} else {
// Neither width nor relative width specified.
d->columnWidths[col] = 0.0;
relativeWidthColumns.append(col); // handle it as a relative width column without asking for anything
++numNonStyleColumns;
}
}
// Handle the case that the fixed size columns are larger then the defined table width
if (availableWidth < 0.0) {
if (tableFormat.width().rawValue() == 0 && fixedWidthColumns.count() > 0) {
// If not table width was defined then we need to scale down the fixed size columns so they match
// into the width of the table.
qreal diff = (-availableWidth) / qreal(fixedWidthColumns.count());
foreach(int col, fixedWidthColumns) {
d->columnWidths[col] = qMax(qreal(0.0), d->columnWidths[col] - diff);
}
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:64,代码来源:KoTextLayoutTableArea.cpp
示例6: KisSpacingInformation
KisSpacingInformation KisColorSmudgeOp::paintAt(const KisPaintInformation& info)
{
KisBrushSP brush = m_brush;
// Simple error catching
if (!painter()->device() || !brush || !brush->canPaintFor(info)) {
return KisSpacingInformation(1.0);
}
if (m_smudgeRateOption.getMode() == KisSmudgeOption::SMEARING_MODE) {
/**
* Disable handling of the subpixel precision. In the smudge op we
* should read from the aligned areas of the image, so having
* additional internal offsets, created by the subpixel precision,
* will worsen the quality (at least because
* QRectF(m_dstDabRect).center() will not point to the real center
* of the brush anymore).
* Of course, this only really matters with smearing_mode (bug:327235),
* and you only notice the lack of subpixel precision in the dulling methods.
*/
m_dabCache->disableSubpixelPrecision();
}
//if precision
KoColor colorSpaceChanger = painter()->paintColor();
const KoColorSpace* preciseColorSpace = colorSpaceChanger.colorSpace();
/*if (colorSpaceChanger.colorSpace()->colorDepthId().id() == "U8") {
preciseColorSpace = KoColorSpaceRegistry::instance()->colorSpace(colorSpaceChanger.colorSpace()->colorModelId().id(), "U16", colorSpaceChanger.profile() );
colorSpaceChanger.convertTo(preciseColorSpace);
}
painter()->setPaintColor(colorSpaceChanger);*/
// get the scaling factor calculated by the size option
qreal scale = m_sizeOption.apply(info);
scale *= KisLodTransform::lodToScale(painter()->device());
qreal rotation = m_rotationOption.apply(info);
if (checkSizeTooSmall(scale)) return KisSpacingInformation();
setCurrentScale(scale);
setCurrentRotation(rotation);
QPointF scatteredPos =
m_scatterOption.apply(info,
brush->maskWidth(scale, rotation, 0, 0, info),
brush->maskHeight(scale, rotation, 0, 0, info));
QPointF hotSpot = brush->hotSpot(scale, scale, rotation, info);
/**
* Update the brush mask.
*
* Upon leaving the function:
* o m_maskDab stores the new mask
* o m_maskBounds stores the extents of the mask paint device
* o m_dstDabRect stores the destination rect where the mask is going
* to be written to
*/
updateMask(info, scale, rotation, scatteredPos);
QPointF newCenterPos = QRectF(m_dstDabRect).center();
/**
* Save the center of the current dab to know where to read the
* data during the next pass. We do not save scatteredPos here,
* because it may differ slightly from the real center of the
* brush (due to rounding effects), which will result in a
* really weird quality.
*/
QRect srcDabRect = m_dstDabRect.translated((m_lastPaintPos - newCenterPos).toPoint());
m_lastPaintPos = newCenterPos;
KisSpacingInformation spacingInfo =
effectiveSpacing(scale, rotation,
m_spacingOption, info);
if (m_firstRun) {
m_firstRun = false;
return spacingInfo;
}
// save the old opacity value and composite mode
quint8 oldOpacity = painter()->opacity();
QString oldCompositeOpId = painter()->compositeOp()->id();
qreal fpOpacity = (qreal(oldOpacity) / 255.0) * m_opacityOption.getOpacityf(info);
if (m_image && m_overlayModeOption.isChecked()) {
m_image->blockUpdates();
m_backgroundPainter->bitBlt(QPoint(), m_image->projection(), srcDabRect);
m_image->unblockUpdates();
}
else {
// IMPORTANT: clear the temporary painting device to color black with zero opacity:
// it will only clear the extents of the brush.
m_tempDev->clear(QRect(QPoint(), m_dstDabRect.size()));
}
if (m_smudgeRateOption.getMode() == KisSmudgeOption::SMEARING_MODE) {
m_smudgePainter->bitBlt(QPoint(), painter()->device(), srcDabRect);
} else {
//.........这里部分代码省略.........
开发者ID:hshrimali,项目名称:krita,代码行数:101,代码来源:kis_colorsmudgeop.cpp
示例7: switch
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
switch(event->type()) {
case QEvent::ToolTip:
{
if (obj != viewer) break;
QHelpEvent* e = static_cast<QHelpEvent*>(event);
if (attributeRect.contains(e->pos())){
QString attribute = viewer->attribute();
if(!attribute.isEmpty())
ToolTip::showText(e->globalPos(),
attribute.prepend("<b>").append("</b>"),
false, 0.8);
}
return true;
}
case QEvent::MouseButtonDblClick:
{
if (obj != viewer && obj != bottomFrame) break;
QMouseEvent *e = static_cast<QMouseEvent*>(event);
if(e->button() & Qt::LeftButton)
changeFullScreen();
return true;
}
case QEvent::ContextMenu:
{
QContextMenuEvent *e = static_cast<QContextMenuEvent*>(event);
showContextMenu(e->globalPos());
return true;
}
case QEvent::Wheel:
{
QWheelEvent *e = static_cast<QWheelEvent *>(event);
// if (e->delta() < 0)
// viewer->nextPic();
// else
// viewer->prePic();
qreal factor = 0.1;
switch(e->modifiers()){
case Qt::ShiftModifier:
factor = e->delta() / qreal(2400); // e->delta() is +120 or -120
break;
case Qt::ControlModifier:
factor = e->delta() / qreal(600);
break;
default:
factor = e->delta() / qreal(1200);
break;
}
viewer->zoomIn(factor, viewer->mapFromGlobal(e->globalPos()));
break;
}
default:
break;
}
return false;
}
开发者ID:404neko,项目名称:ezviewer-1,代码行数:62,代码来源:mainwindow.cpp
示例8: QCOMPARE
void tst_QColor::setCmyk()
{
QColor color;
for (int A = 0; A <= USHRT_MAX; ++A) {
{
// 0-255
int a = A >> 8;
color.setCmyk(0, 0, 0, 0, a);
QCOMPARE(color.alpha(), a);
int c, m, y, k, a2;
color.getCmyk(&c, &m, &y, &k, &a2);
QCOMPARE(a2, a);
}
{
// 0.0-1.0
qreal a = A / qreal(USHRT_MAX);
color.setCmykF(0.0, 0.0, 0.0, 0.0, a);
QCOMPARE(color.alphaF(), a);
qreal c, m, y, k, a2;
color.getCmykF(&c, &m, &y, &k, &a2);
QCOMPARE(a2, a);
}
}
for (int C = 0; C <= USHRT_MAX; ++C) {
{
// 0-255
int c = C >> 8;
color.setCmyk(c, 0, 0, 0, 0);
QCOMPARE(color.cyan(), c);
int c2, m, y, k, a;
color.getCmyk(&c2, &m, &y, &k, &a);
QCOMPARE(c2, c);
}
{
// 0.0-1.0
qreal c = C / qreal(USHRT_MAX);
color.setCmykF(c, 0.0, 0.0, 0.0, 0.0);
QCOMPARE(color.cyanF(), c);
qreal c2, m, y, k, a;
color.getCmykF(&c2, &m, &y, &k, &a);
QCOMPARE(c2, c);
}
}
for (int M = 0; M <= USHRT_MAX; ++M) {
{
// 0-255
int m = M >> 8;
color.setCmyk(0, m, 0, 0, 0);
QCOMPARE(color.magenta(), m);
int c, m2, y, k, a;
color.getCmyk(&c, &m2, &y, &k, &a);
QCOMPARE(m2, m);
}
{
// 0.0-1.0
qreal m = M / qreal(USHRT_MAX);
color.setCmykF(0.0, m, 0.0, 0.0, 0.0);
QCOMPARE(color.magentaF(), m);
qreal c, m2, y, k, a;
color.getCmykF(&c, &m2, &y, &k, &a);
QCOMPARE(m2, m);
}
}
for (int Y = 0; Y <= USHRT_MAX; ++Y) {
{
// 0-255
int y = Y >> 8;
color.setCmyk(0, 0, y, 0, 0);
QCOMPARE(color.yellow(), y);
int c, m, y2, k, a;
color.getCmyk(&c, &m, &y2, &k, &a);
QCOMPARE(y2, y);
}
{
// 0.0-1.0
qreal y = Y / qreal(USHRT_MAX);
color.setCmykF(0.0, 0.0, y, 0.0, 0.0);
QCOMPARE(color.yellowF(), y);
qreal c, m, y2, k, a;
color.getCmykF(&c, &m, &y2, &k, &a);
QCOMPARE(y2, y);
}
}
//.........这里部分代码省略.........
开发者ID:SfietKonstantin,项目名称:radeon-qt5-qtbase-kms,代码行数:101,代码来源:tst_qcolor.cpp
示例9: qRgba
void tst_QColor::setRgb()
{
QColor color;
for (int A = 0; A <= USHRT_MAX; ++A) {
{
// 0-255
int a = A >> 8;
QRgb rgb = qRgba(0, 0, 0, a);
color.setRgb(0, 0, 0, a);
QCOMPARE(color.alpha(), a);
QCOMPARE(color.rgb(), qRgb(0, 0, 0));
color.setRgb(rgb);
QCOMPARE(color.alpha(), 255);
QCOMPARE(color.rgb(), qRgb(0, 0, 0));
int r, g, b, a2;
color.setRgb(0, 0, 0, a);
color.getRgb(&r, &g, &b, &a2);
QCOMPARE(a2, a);
QColor c(0, 0, 0);
c.setAlpha(a);
QCOMPARE(c.alpha(), a);
}
{
// 0.0-1.0
qreal a = A / qreal(USHRT_MAX);
color.setRgbF(0.0, 0.0, 0.0, a);
QCOMPARE(color.alphaF(), a);
qreal r, g, b, a2;
color.getRgbF(&r, &g, &b, &a2);
QCOMPARE(a2, a);
QColor c(0, 0, 0);
c.setAlphaF(a);
QCOMPARE(c.alphaF(), a);
}
}
for (int R = 0; R <= USHRT_MAX; ++R) {
{
// 0-255
int r = R >> 8;
QRgb rgb = qRgb(r, 0, 0);
color.setRgb(r, 0, 0);
QCOMPARE(color.red(), r);
QCOMPARE(color.rgb(), rgb);
color.setRgb(rgb);
QCOMPARE(color.red(), r);
QCOMPARE(color.rgb(), rgb);
int r2, g, b, a;
color.getRgb(&r2, &g, &b, &a);
QCOMPARE(r2, r);
}
{
// 0.0-1.0
qreal r = R / qreal(USHRT_MAX);
color.setRgbF(r, 0.0, 0.0);
QCOMPARE(color.redF(), r);
qreal r2, g, b, a;
color.getRgbF(&r2, &g, &b, &a);
QCOMPARE(r2, r);
}
}
for (int G = 0; G <= USHRT_MAX; ++G) {
{
// 0-255
int g = G >> 8;
QRgb rgb = qRgb(0, g, 0);
color.setRgb(0, g, 0);
QCOMPARE(color.green(), g);
QCOMPARE(color.rgb(), rgb);
color.setRgb(rgb);
QCOMPARE(color.green(), g);
QCOMPARE(color.rgb(), rgb);
int r, g2, b, a;
color.getRgb(&r, &g2, &b, &a);
QCOMPARE(g2, g);
}
{
// 0.0-1.0
qreal g = G / qreal(USHRT_MAX);
color.setRgbF(0.0, g, 0.0);
QCOMPARE(color.greenF(), g);
//.........这里部分代码省略.........
开发者ID:SfietKonstantin,项目名称:radeon-qt5-qtbase-kms,代码行数:101,代码来源:tst_qcolor.cpp
示例10: shift
static ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold)
{
int map[4];
bool p1_p2_equal = (orig->x1 == orig->x2 && orig->y1 == orig->y2);
bool p2_p3_equal = (orig->x2 == orig->x3 && orig->y2 == orig->y3);
bool p3_p4_equal = (orig->x3 == orig->x4 && orig->y3 == orig->y4);
QPointF points[4];
int np = 0;
points[np] = QPointF(orig->x1, orig->y1);
map[0] = 0;
++np;
if (!p1_p2_equal) {
points[np] = QPointF(orig->x2, orig->y2);
++np;
}
map[1] = np - 1;
if (!p2_p3_equal) {
points[np] = QPointF(orig->x3, orig->y3);
++np;
}
map[2] = np - 1;
if (!p3_p4_equal) {
points[np] = QPointF(orig->x4, orig->y4);
++np;
}
map[3] = np - 1;
if (np == 1)
return Discard;
QRectF b = orig->bounds();
if (np == 4 && b.width() < .1*offset && b.height() < .1*offset) {
qreal l = (orig->x1 - orig->x2)*(orig->x1 - orig->x2) +
(orig->y1 - orig->y2)*(orig->y1 - orig->y2) *
(orig->x3 - orig->x4)*(orig->x3 - orig->x4) +
(orig->y3 - orig->y4)*(orig->y3 - orig->y4);
qreal dot = (orig->x1 - orig->x2)*(orig->x3 - orig->x4) +
(orig->y1 - orig->y2)*(orig->y3 - orig->y4);
if (dot < 0 && dot*dot < 0.8*l)
// the points are close and reverse dirction. Approximate the whole
// thing by a semi circle
return Circle;
}
QPointF points_shifted[4];
QLineF prev = QLineF(QPointF(), points[1] - points[0]);
QPointF prev_normal = prev.normalVector().unitVector().p2();
points_shifted[0] = points[0] + offset * prev_normal;
for (int i = 1; i < np - 1; ++i) {
QLineF next = QLineF(QPointF(), points[i + 1] - points[i]);
QPointF next_normal = next.normalVector().unitVector().p2();
QPointF normal_sum = prev_normal + next_normal;
qreal r = qreal(1.0) + prev_normal.x() * next_normal.x()
+ prev_normal.y() * next_normal.y();
if (qFuzzyIsNull(r)) {
points_shifted[i] = points[i] + offset * prev_normal;
} else {
qreal k = offset / r;
points_shifted[i] = points[i] + k * normal_sum;
}
prev_normal = next_normal;
}
points_shifted[np - 1] = points[np - 1] + offset * prev_normal;
*shifted = QBezier::fromPoints(points_shifted[map[0]], points_shifted[map[1]],
points_shifted[map[2]], points_shifted[map[3]]);
return good_offset(orig, shifted, offset, threshold);
}
开发者ID:wpbest,项目名称:copperspice,代码行数:77,代码来源:qbezier.cpp
示例11: qFastSin
//------------------------------------------------------------------------------
QGLBuilder& operator << ( QGLBuilder& builder, const QGLEllipsoid& ellipsoid )
{
// Determine the number of slices and stacks to generate.
static int const numberOfSlicesForSubdivisionDepth[] = { 8, 8, 16, 16, 32, 32, 64, 64, 128, 128 };
static int const numberOfStacksForSubdivisionDepth[] = { 4, 8, 8, 16, 16, 32, 32, 64, 64, 128 };
const unsigned int numberOfSlices = numberOfSlicesForSubdivisionDepth[ ellipsoid.GetSubdivisionDepth() - 1 ];
const unsigned int numberOfStacks = numberOfStacksForSubdivisionDepth[ ellipsoid.GetSubdivisionDepth() - 1 ];
// Precompute sin/cos values for the slices.
const unsigned int maxSlices = 128 + 1;
const unsigned int maxStacks = 128 + 1;
qreal sliceSin[ maxSlices ];
qreal sliceCos[ maxSlices ];
for( unsigned int slice = 0; slice < numberOfSlices; ++slice )
{
const qreal angle = 2 * M_PI * (numberOfSlices - 1 - slice) / numberOfSlices;
sliceSin[slice] = qFastSin(angle);
sliceCos[slice] = qFastCos(angle);
}
// Join first and last slice.
sliceSin[numberOfSlices] = sliceSin[0];
sliceCos[numberOfSlices] = sliceCos[0];
// Precompute sin/cos values for the stacks.
qreal stackSin[ maxStacks ];
qreal stackCos[ maxStacks ];
for( unsigned int stack = 0; stack <= numberOfStacks; ++stack )
{
// Efficiently handle end-points which also ensure geometry comes to a point at the poles (no round-off).
if( stack == 0 ) { stackSin[stack] = 0.0f; stackCos[stack] = 1.0f; }
else if( stack == numberOfStacks ) { stackSin[stack] = 0.0f; stackCos[stack] = -1.0f; }
else
{
const qreal angle = M_PI * stack / numberOfStacks;
stackSin[stack] = qFastSin(angle);
stackCos[stack] = qFastCos(angle);
}
}
// Half the dimensions of the ellipsoid for calculations below (centroid of ellipsoid is 0, 0, 0.)
const qreal xRadius = 0.5 * ellipsoid.GetXDiameter();
const qreal yRadius = 0.5 * ellipsoid.GetYDiameter();
const qreal zRadius = 0.5 * ellipsoid.GetZDiameter();
const qreal oneOverXRadiusSquared = 1.0 / (xRadius * xRadius);
const qreal oneOverYRadiusSquared = 1.0 / (yRadius * yRadius);
const qreal oneOverZRadiusSquared = 1.0 / (zRadius * zRadius);
// Create the stacks.
for( unsigned int stack = 0; stack < numberOfStacks; ++stack )
{
QGeometryData quadStrip;
for( unsigned int slice = 0; slice <= numberOfSlices; ++slice )
{
// Equation for ellipsoid surface is x^2/xRadius^2 + y^2/yRadius^2 + z^2/zRadius^2 = 1
// Location of vertices can be specified in terms of "polar coordinates".
const qreal nextx = xRadius * stackSin[stack+1] * sliceSin[slice];
const qreal nexty = yRadius * stackSin[stack+1] * sliceCos[slice];
const qreal nextz = zRadius * stackCos[stack+1];
quadStrip.appendVertex( QVector3D( nextx, nexty, nextz) );
// Equation for ellipsoid surface is Surface = x^2/xRadius^2 + y^2/yRadius^2 + z^2/zRadius^2 - 1
// Gradient for ellipsoid is x/xRadius^2*Nx> + y/yRadius^2*Ny> + z/zRadius^2*Nz>
// Gradient for sphere simplifies to x*Nx> + y*Ny> + z*Nz>
// const qreal nextGradientx = stackSin[stack+1] * sliceSin[slice];
// const qreal nextGradienty = stackSin[stack+1] * sliceCos[slice];
// const qreal nextGradientz = stackCos[stack+1];
const qreal nextGradientx = nextx * oneOverXRadiusSquared;
const qreal nextGradienty = nexty * oneOverYRadiusSquared;
const qreal nextGradientz = nextz * oneOverZRadiusSquared;
const qreal nextGradientMagSquared = nextGradientx * nextGradientx + nextGradienty * nextGradienty + nextGradientz * nextGradientz;
const qreal oneOverNextGradientMagnitude = 1.0 / sqrt( nextGradientMagSquared );
quadStrip.appendNormal( oneOverNextGradientMagnitude * QVector3D( nextGradientx, nextGradienty, nextGradientz ) );
quadStrip.appendTexCoord( QVector2D(1.0f - qreal(slice) / numberOfSlices, 1.0f - qreal(stack + 1) / numberOfStacks) );
const qreal x = xRadius * stackSin[stack] * sliceSin[slice];
const qreal y = yRadius * stackSin[stack] * sliceCos[slice];
const qreal z = zRadius * stackCos[stack];
quadStrip.appendVertex( QVector3D( x, y, z) );
// const qreal gradientx = stackSin[stack] * sliceSin[slice];
// const qreal gradienty = stackSin[stack] * sliceCos[slice];
// const qreal gradientz = stackCos[stack];
const qreal gradientx = x * oneOverXRadiusSquared;
const qreal gradienty = y * oneOverYRadiusSquared;
const qreal gradientz = z * oneOverZRadiusSquared;
const qreal gradientMagSquared = gradientx * gradientx + gradienty * gradienty + gradientz * gradientz;
const qreal oneOverGradientMagnitude = 1.0 / sqrt( gradientMagSquared );
quadStrip.appendNormal( oneOverGradientMagnitude * QVector3D( gradientx, gradienty, gradientz) );
quadStrip.appendTexCoord( QVector2D(1.0f - qreal(slice) / numberOfSlices, 1.0f - qreal(stack) / numberOfStacks) );
}
// The quad strip stretches from pole to pole.
builder.addQuadStrip( quadStrip );
}
return builder;
//.........这里部分代码省略.........
开发者ID:ruisebastiao,项目名称:qsim,代码行数:101,代码来源:QGLEllipsoid.cpp
示例12: addCentroid
void QGL2PEXVertexArray::addPath(const QVectorPath &path, GLfloat curveInverseScale, bool outline)
{
const QPointF* const points = reinterpret_cast<const QPointF*>(path.points());
const QPainterPath::ElementType* const elements = path.elements();
if (boundingRectDirty) {
minX = maxX = points[0].x();
minY = maxY = points[0].y();
boundingRectDirty = false;
}
if (!outline && !path.isConvex())
addCentroid(path, 0);
int lastMoveTo = vertexArray.size();
vertexArray.add(points[0]); // The first element is always a moveTo
do {
if (!elements) {
// qDebug("QVectorPath has no elements");
// If the path has a null elements pointer, the elements implicitly
// start with a moveTo (already added) and continue with lineTos:
for (int i=1; i<path.elementCount(); ++i)
lineToArray(points[i].x(), points[i].y());
break;
}
// qDebug("QVectorPath has element types");
for (int i=1; i<path.elementCount(); ++i) {
switch (elements[i]) {
case QPainterPath::MoveToElement:
if (!outline)
addClosingLine(lastMoveTo);
// qDebug("element[%d] is a MoveToElement", i);
vertexArrayStops.add(vertexArray.size());
if (!outline) {
if (!path.isConvex()) addCentroid(path, i);
lastMoveTo = vertexArray.size();
}
lineToArray(points[i].x(), points[i].y()); // Add the moveTo as a new vertex
break;
case QPainterPath::LineToElement:
// qDebug("element[%d] is a LineToElement", i);
lineToArray(points[i].x(), points[i].y());
break;
case QPainterPath::CurveToElement: {
QBezier b = QBezier::fromPoints(*(((const QPointF *) points) + i - 1),
points[i],
points[i+1],
points[i+2]);
QRectF bounds = b.bounds();
// threshold based on same algorithm as in qtriangulatingstroker.cpp
int threshold = qMin<float>(64, qMax(bounds.width(), bounds.height()) * 3.14f / (curveInverseScale * 6));
if (threshold < 3) threshold = 3;
qreal one_over_threshold_minus_1 = qreal(1) / (threshold - 1);
for (int t=0; t<threshold; ++t) {
QPointF pt = b.pointAt(t * one_over_threshold_minus_1);
lineToArray(pt.x(), pt.y());
}
i += 2;
break; }
default:
break;
}
}
} while (0);
if (!outline)
addClosingLine(lastMoveTo);
vertexArrayStops.add(vertexArray.size());
}
开发者ID:James-intern,项目名称:Qt,代码行数:72,代码来源:qgl2pexvertexarray.cpp
示例13: setZoomFactor
void WebView::applyZoom()
{
setZoomFactor(qreal(m_zoomLevels.at(m_currentZoomLevel)) / 100.0);
emit zoomLevelChanged(m_currentZoomLevel);
}
开发者ID:peelonet,项目名称:qupzilla,代码行数:6,代码来源:webview.cpp
示例14: switch
const QColor& KisColorSelectorSimple::colorAt(int x, int y)
{
if (x < 0) x = 0;
if (x > width()) x = width();
if (y < 0) y = 0;
if (y > width()) y = height();
qreal xRel = x/qreal(width());
qreal yRel = 1.-y/qreal(height());
qreal relPos;
if(height()>width())
relPos = 1.-y/qreal(height());
else
relPos = x/qreal(width());
QColor color;
color.setHsvF(m_hue, 1.0, 1.0);
switch(m_parameter) {
case KisColorSelector::SL:
m_qcolor.setHslF(m_hue, xRel, yRel);
break;
case KisColorSelector::SV:
m_qcolor.setHsvF(m_hue, xRel, yRel);
break;
case KisColorSelector::SV2:
m_qcolor.setHsvF(m_hue, xRel, xRel + (1.0-xRel)*yRel);
break;
case KisColorSelector::hsvSH:
m_qcolor.setHsvF(xRel, yRel, m_value);
break;
case KisColorSelector::hslSH:
m_qcolor.setHslF(xRel, yRel, m_lightness);
break;
case KisColorSelector::VH:
m_qcolor.setHsvF(xRel, m_hsvSaturation, yRel);
break;
case KisColorSelector::LH:
m_qcolor.setHslF(xRel, m_hslSaturation, yRel);
break;
case KisColorSelector::H:
m_qcolor.setHsvF(relPos, 1, 1);
break;
case KisColorSelector::hsvS:
m_qcolor.setHsvF(m_hue, relPos, m_value);
break;
case KisColorSelector::hslS:
m_qcolor.setHslF(m_hue, relPos, m_lightness);
break;
case KisColorSelector::V:
m_qcolor.setHsvF(m_hue, m_hsvSaturation, relPos);
break;
case KisColorSelector::L:
m_qcolor.setHslF(m_hue, m_hslSaturation, relPos);
break;
default:
Q_ASSERT(false);
m_qcolor = QColor();
return m_qcolor;
}
return m_qcolor;
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:63,代码来源:kis_color_selector_simple.cpp
示例15: locker
/*!
\internal
*/
QFontEngine *
QFontDatabase::findFont(int script, const QFontPrivate *fp,
const QFontDef &request)
{
QMutexLocker locker(fontDatabaseMutex());
const int force_encoding_id = -1;
if (!privateDb()->count)
initializeDb();
QFontEngine *engine;
QFontCache::Key key(request, script);
engine = QFontCache::instance()->findEngine(key);
if (engine) {
qDebug() << "Cache hit level 1";
return engine;
}
QString family_name, foundry_name;
parseFontName(request.family, foundry_name, family_name);
if (qt_enable_test_font && request.family == QLatin1String("__Qt__Box__Engine__")) {
engine =new QTestFontEngine(request.pixelSize);
engine->fontDef = request;
}
QtFontDesc desc;
match(script, request, family_name, foundry_name, force_encoding_id, &desc);
if (desc.family != 0 && desc.foundry != 0 && desc.style != 0) {
engine = loadEngine(script, request, desc.family, desc.foundry, desc.style, desc.size);
} else {
FM_DEBUG(" NO MATCH FOUND\n");
}
if (engine) {
initFontDef(desc, request, &engine->fontDef);
if (fp) {
QFontDef def = request;
if (def.family.isEmpty()) {
def.family = fp->request.family;
def.family = def.family.left(def.family.indexOf(QLatin1Char(',')));
}
}
}
if (!engine) {
if (!request.family.isEmpty()) {
QStringList fallbacks = fallbackFamilies(request.family,QFont::Style(request.style),QFont::StyleHint(request.styleHint),QUnicodeTables::Script(script));
for (int i = 0; i < fallbacks.size(); i++) {
QFontDef def = request;
def.family = fallbacks.at(i);
QFontCache::Key key(def,script);
engine = QFontCache::instance()->findEngine(key);
if (!engine) {
QtFontDesc desc;
match(script, def, def.family, QLatin1String(""), 0, &desc);
if (desc.family == 0 && desc.foundry == 0 && desc.style == 0) {
continue;
}
engine = loadEngine(script, def, desc.family, desc.foundry, desc.style, desc.size);
if (engine) {
initFontDef(desc, def, &engine->fontDef);
break;
}
}
}
}
if (!engine)
engine = new QFontEngineBox(request.pixelSize);
FM_DEBUG("returning box engine");
}
if (fp && fp->dpi > 0) {
engine->fontDef.pointSize = qreal(double((engine->fontDef.pixelSize * 72) / fp->dpi));
} else {
engine->fontDef.pointSize = request.pointSize;
}
return engine;
}
开发者ID:maxxant,项目名称:qt,代码行数:88,代码来源:qfontdatabase_qpa.cpp
示例16: qBound
QColor CallgrindHelper::colorForCostRatio(qreal ratio)
{
ratio = qBound(qreal(0.0), ratio, qreal(1.0));
return QColor::fromHsv(120 - ratio * 120, 255, 255, (-((ratio-1) * (ratio-1))) * 120 + 120);
}
开发者ID:kai66673,项目名称:qt-creator,代码行数:5,代码来源:callgrindhelper.cpp
示例17: Q_D
/*!
\reimp
*/
void QAbstractSlider::keyPressEvent(QKeyEvent *ev)
{
Q_D(QAbstractSlider);
SliderAction action = SliderNoAction;
#ifdef QT_KEYPAD_NAVIGATION
if (ev->isAutoRepeat()) {
if (!d->firstRepeat.isValid())
d->firstRepeat.start();
else if (1 == d->repeatMultiplier) {
// This is the interval in milli seconds which one key repetition
// takes.
const int repeatMSecs = d->firstRepeat.elapsed();
/**
* The time it takes to currently navigate the whole slider.
*/
const qreal currentTimeElapse = (qreal(maximum()) / singleStep()) * repeatMSecs;
/**
* This is an arbitrarily determined constant in msecs that
* specifies how long time it should take to navigate from the
* start to the end(excluding starting key auto repeat).
*/
const int SliderRepeatElapse = 2500;
d->repeatMultiplier = currentTimeElapse / SliderRepeatElapse;
}
}
else if (d->firstRepeat.isValid()) {
d->firstRepeat.invalidate();
d->repeatMultiplier = 1;
}
#endif
switch (ev->key()) {
#ifdef QT_KEYPAD_NAVIGATION
case Qt::Key_Select:
if (QApplication::keypadNavigationEnabled())
setEditFocus(!hasEditFocus());
else
ev->ignore();
break;
case Qt::Key_Back:
if (QApplication::keypadNavigationEnabled() && hasEditFocus()) {
setValue(d->origValue);
setEditFocus(false);
} else
ev->ignore();
break;
#endif
// It seems we need to use invertedAppearance for Left and right, otherwise, things look weird.
case Qt::Key_Left:
#ifdef QT_KEYPAD_NAVIGATION
// In QApplication::KeypadNavigationDirectional, we want to change the slider
// value if there is no left/right navigation possible and if this slider is not
// inside a tab widget.
if (QApplication::keypadNavigationEnabled()
&& (!hasEditFocus() && QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder
|| d->orientation == Qt::Vertical
|| !hasEditFocus()
&& (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) || QWidgetPrivate::inTabWidget(this)))) {
ev->ignore();
return;
}
if (QApplication::keypadNavigationEnabled() && d->orientation == Qt::Vertical)
action = d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd;
else
#endif
if (isRightToLeft())
action = d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd;
else
action = !d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd;
break;
case Qt::Key_Right:
#ifdef QT_KEYPAD_NAVIGATION
// Same logic as in Qt::Key_Left
if (QApplication::keypadNavigationEnabled()
&& (!hasEditFocus() && QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder
|| d->orientation == Qt::Vertical
|| !hasEditFocus()
&& (QWidgetPrivate::canKeypadNavigate(Qt::Horizontal) || QWidgetPrivate::inTabWidget(this)))) {
ev->ignore();
return;
}
if (QApplication::keypadNavigationEnabled() && d->orientation == Qt::Vertical)
action = d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub;
else
#endif
if (isRightToLeft())
action = d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub;
else
action = !d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub;
break;
case Qt::Key_Up:
//.........这里部分代码省略.........
开发者ID:ghjinlei,项目名称:qt5,代码行数:101,代码来源:qabstractslider.cpp
示例18: setZoomFactor
void WebView::applyZoom()
{
setZoomFactor(qreal(m_currentZoo
|
请发表评论