本文整理汇总了C++中qPow函数的典型用法代码示例。如果您正苦于以下问题:C++ qPow函数的具体用法?C++ qPow怎么用?C++ qPow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qPow函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: filterAvailableUSDAmountValue
void Exchange_Bitstamp::filterAvailableUSDAmountValue(double *amount)
{
double decValue=mainWindow.getValidDoubleForPercision((*amount)*mainWindow.floatFee,baseValues.currentPair.priceDecimals,false);
decValue+=qPow(0.1,qMax(baseValues.currentPair.priceDecimals,1));
*amount=mainWindow.getValidDoubleForPercision((*amount)-decValue,baseValues.currentPair.currBDecimals,false);
}
开发者ID:MaratAkhmatnurov,项目名称:QtBitcoinTrader,代码行数:6,代码来源:exchange_bitstamp.cpp
示例2: qPow
void ImageView::wheelEvent(QWheelEvent *event)
{
qreal factor = qPow(Constants::DEFAULT_SCALE_FACTOR, event->delta() / 240.0);
doScale(factor);
event->accept();
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:6,代码来源:imageview.cpp
示例3: return
qreal Curve::calcYDerivative(qreal t)
{
return (t * t + 2 * t - 1) / qPow(t + 1, 2.);
}
开发者ID:eugenechereshnev,项目名称:computer-graphics,代码行数:4,代码来源:curve.cpp
示例4: qDebug
void MainWindow::tick()
{
if((pig_count==0&&bird_count==6) || score==33000)
{
qDebug() << "pig_count : " << pig_count;
qDebug() << "bird_count : " << bird_count;
qDebug() << "score : " << score;
showResult();
}
ui->lcdNumber->display(score);
ui->lcdNumber_2->display(pig_count);
ui->lcdNumber_3->display(6-bird_count);
if(shot)
{
CD = (*Bit)->available;
b2Vec2 speed = (*Bit)->Body->GetLinearVelocity();
VB = qSqrt(qPow(speed.x,2)+qPow(speed.y,2));
b2Vec2 X = (*Bit)->Body->GetPosition();;
if((X.y>120 || X.x<-20) || X.x>100)
outer = true;
if((VB==0 || outer) && bird_count == 2)
{
bird2 = new Bird(2,6.8f, 10.7f,BIRD_DENSITY, BIRD_RADIUS, &timer, QPixmap(":/bird/img/Angry Birds Seasons/angry-bird-yellow-icon.png"), world, scene);
BIRD.push_back(bird2);
delete (*Bit);
BIRD.erase(Bit);
shot = false;
newed = true;
outer = false;
}
else if((VB==0 || outer) && bird_count == 3)
{
bird3 = new Bird(3,6.8f, 10.7f,BIRD_DENSITY*4, 1.5, &timer, QPixmap(":/bird/img/Angry Birds Seasons/BLOCK_STEEL_BALL.png"), world, scene);
BIRD.push_back(bird3);
delete (*Bit);
BIRD.erase(Bit);
shot = false;
newed = true;
outer = false;
}
else if((VB==0 || outer) && bird_count == 4)
{
bird4 = new Bird(4,6.8f, 10.7f,BIRD_DENSITY, BIRD_RADIUS*1.75, &timer, QPixmap(":/bird/img/Angry Birds Seasons/BIRD_GREY_YELL.png"), world, scene);
BIRD.push_back(bird4);
delete (*Bit);
BIRD.erase(Bit);
shot = false;
newed = true;
outer = false;
}
else if((VB==0 || outer) && bird_count == 5)
{
bird5 = new Bird(5,7.1f, 10.9f,BIRD_DENSITY, BIRD_RADIUS*2, &timer, QPixmap(":/bird/img/Angry Birds Seasons/TA.png"), world, scene);
BIRD.push_back(bird5);
delete (*Bit);
BIRD.erase(Bit);
shot = false;
newed = true;
outer = false;
}
else if((VB==0 || outer) && bird_count == 6)
{
bird6 = new Bird(6,6.8f, 10.7f,BIRD_DENSITY, BIRD_RADIUS, &timer, QPixmap(""), world, scene);
BIRD.push_back(bird6);
delete (*Bit);
BIRD.erase(Bit);
shot = false;
newed = true;
outer = false;
showResult();
}
}
for(it = WOOD.begin(); it!= WOOD.end(); ++it)
{
if((*it)->death)
{
delete (*it);
WOOD.erase(it);
score += 2000;
//qDebug() << score;
}
}
for(it = PIG.begin(); it!= PIG.end(); ++it)
{
if((*it)->death)
{
delete (*it);
PIG.erase(it);
score += 5000;
--pig_count;
//qDebug() << score;
}
}
world->Step(1.0/60.0, 6, 2);
scene->update();
}
开发者ID:bladeath860620,项目名称:pd2-Angrybird,代码行数:96,代码来源:mainwindow.cpp
示例5: QLineF
QLineF item_rectangles::snapLine(QLineF mouseLine, QSizeF Box)
{
qreal a = mouseLine.angle();
qreal relA = QLineF(0,0, Box.width(), -Box.height()).angle();
qreal tarA = 0;
bool isDiagonal=false;
bool isVertical=false;
if(a == 0)
{
tarA = a;
goto skipAngleCalculate;
}
else if(a == 90)
{
tarA = a;
isVertical=true;
goto skipAngleCalculate;
}
else if(a == 180)
{
tarA = a;
goto skipAngleCalculate;
}
else if(a == 270)
{
tarA = a;
isVertical=true;
goto skipAngleCalculate;
}
//Calculating target angle
if(a <= 90){
if(a < relA/2){
tarA = 0;
}else if(a <= 90-(90-relA)/2 ){
tarA = relA;
isDiagonal=true;
}else{
tarA = 90;
isVertical=true;
}
}else if(a <= 180){
if(a <= 90+(90-relA)/2 ){
tarA = 90;
isVertical=true;
}else if(a <= 180-relA/2 ){
tarA = 180-relA;
isDiagonal=true;
}else{
tarA = 180;
}
}else if(a <= 270){
if(a < 180+(relA/2)){
tarA = 180;
}else if(a <= 270-(90-relA)/2){
tarA = 180+relA;
isDiagonal=true;
}else{
tarA = 270;
isVertical=true;
}
}else{
if(a <= 270+(90-relA)/2 ){
tarA = 270;
isVertical=true;
}else if(a < 360-relA/2){
tarA = 360-relA;
isDiagonal=true;
}else{
tarA = 360;
}
}
skipAngleCalculate:
qreal diagonalSize = qSqrt( qPow(Box.height(),2) + qPow(Box.width(),2) ); //get box diagonal size
qreal Lenght = mouseLine.length() -
((isDiagonal)? qRound(mouseLine.length())%qRound(diagonalSize) //Diagonal
: (isVertical ? qRound(mouseLine.length())%qRound(Box.height()): //Vertical
qRound(mouseLine.length())%qRound(Box.width()) ) ); //Horizontal
return QLineF::fromPolar(Lenght,tarA).translated(mouseLine.p1());;
}
开发者ID:jpmac26,项目名称:PGE-Project,代码行数:86,代码来源:item_rectangles.cpp
示例6: qwtPowInterval
static inline QwtInterval qwtPowInterval( double base, const QwtInterval &interval )
{
return QwtInterval( qPow( base, interval.minValue() ),
qPow( base, interval.maxValue() ) );
}
开发者ID:mirams,项目名称:opencor,代码行数:5,代码来源:qwt_scale_engine.cpp
示例7: b2Vec2
bool MainWindow::eventFilter(QObject *, QEvent *event)
{
if(pressed && event->type() == QEvent::MouseButtonRelease)
{
arrow->setVisible(false);
Force_pos = static_cast<QMouseEvent*>(event)->pos();
if(pressed && bird_count!=3 && bird_count!=5)
shootbird->play();
pressed = false;
b2Vec2 linearV = b2Vec2((clicked_point.x()-Force_pos.x())/15,(Force_pos.y()-clicked_point.y())/15);
if(bird_count == 1)
{
bird1->setLinearVelocity(linearV);
bird1->Body->SetGravityScale(1);
++bird_count;
shot = true;
skill = true;
/*BIRD.push_back(bird1);
Bit = BIRD.begin();*/
newed = false;
}
else if(bird_count == 2 && newed)
{
bird2->setLinearVelocity(linearV);
bird2->Body->SetGravityScale(1);
++bird_count;
shot = true;
skill = true;
//BIRD.push_back(bird2);
//++Bit;
newed = false;
}
else if(bird_count == 3 && newed)
{
bird3->setLinearVelocity(linearV);
bird3->Body->SetGravityScale(1);
++bird_count;
shot = true;
skill = true;
//BIRD.push_back(bird3);
//++Bit;
newed = false;
}
else if(bird_count == 4 && newed)
{
bird4->setLinearVelocity(linearV);
bird4->Body->SetGravityScale(1);
++bird_count;
shot = true;
skill = true;
//BIRD.push_back(bird4);
//++Bit;
newed = false;
}
else if(bird_count == 5 && newed)
{
bird5->setLinearVelocity(linearV);
bird5->Body->SetGravityScale(1);
++bird_count;
shot = true;
skill = true;
//BIRD.push_back(bird5);
//++Bit;
newed = false;
}
}
else if(event->type() == QEvent::MouseMove)
{
//Force_pos = static_cast<QMouseEvent*>(event)->pos();
if(pressed && !BIRD.empty() && !shot && VB == 0)
{
//qDebug() << "ARROW!";
QPointF temp = static_cast<QMouseEvent*>(event)->pos();
arrow->resetTransform();
arrow->setPos(QPointF(50, 400));
arrow->setRotation(qAtan2(-temp.y()+clicked_point.y(), -temp.x()+clicked_point.x())*180/pi);
arrow->setScale(qSqrt(qPow(temp.y()-clicked_point.y(), 2) + qPow(temp.x()-clicked_point.x(), 2))/300);
arrow->setVisible(true);
}
}
return false;
}
开发者ID:bladeath860620,项目名称:pd2-Angrybird,代码行数:82,代码来源:mainwindow.cpp
示例8: qPow
void QAGC::setFixedGain(float gain) {
mutex.lock();
m_gainFix = qPow(10.0, gain/20.0);
mutex.unlock();
}
开发者ID:amontefusco,项目名称:cudaSDR,代码行数:6,代码来源:qtdsp_agc.cpp
示例9: qBound
void OpenAL::setInputGain(qreal dB)
{
gain = qBound(minInGain, dB, maxInGain);
gainFactor = qPow(10.0, (gain / 20.0));
}
开发者ID:initramfs,项目名称:qTox,代码行数:5,代码来源:openal.cpp
示例10: Q_UNUSED
QgsRasterBlock * QgsBrightnessContrastFilter::block( int bandNo, QgsRectangle const & extent, int width, int height )
{
Q_UNUSED( bandNo );
QgsDebugMsg( QString( "width = %1 height = %2 extent = %3" ).arg( width ).arg( height ).arg( extent.toString() ) );
QgsRasterBlock *outputBlock = new QgsRasterBlock();
if ( !mInput )
{
return outputBlock;
}
// At this moment we know that we read rendered image
int bandNumber = 1;
QgsRasterBlock *inputBlock = mInput->block( bandNumber, extent, width, height );
if ( !inputBlock || inputBlock->isEmpty() )
{
QgsDebugMsg( "No raster data!" );
delete inputBlock;
return outputBlock;
}
if ( mBrightness == 0 && mContrast == 0 )
{
QgsDebugMsg( "No brightness changes." );
delete outputBlock;
return inputBlock;
}
if ( !outputBlock->reset( QGis::ARGB32_Premultiplied, width, height ) )
{
delete inputBlock;
return outputBlock;
}
// adjust image
QRgb myNoDataColor = qRgba( 0, 0, 0, 0 );
QRgb myColor;
int r, g, b, alpha;
double f = qPow(( mContrast + 100 ) / 100.0, 2 );
for ( qgssize i = 0; i < ( qgssize )width*height; i++ )
{
if ( inputBlock->color( i ) == myNoDataColor )
{
outputBlock->setColor( i, myNoDataColor );
continue;
}
myColor = inputBlock->color( i );
alpha = qAlpha( myColor );
r = adjustColorComponent( qRed( myColor ), alpha, mBrightness, f );
g = adjustColorComponent( qGreen( myColor ), alpha, mBrightness, f );
b = adjustColorComponent( qBlue( myColor ), alpha, mBrightness, f );
outputBlock->setColor( i, qRgba( r, g, b, alpha ) );
}
delete inputBlock;
return outputBlock;
}
开发者ID:ColeCummins,项目名称:QGIS,代码行数:62,代码来源:qgsbrightnesscontrastfilter.cpp
示例11: qPow
qreal MyWidget::yt5(qreal x)
{
return qPow(qExp(1), 2 * x - 1) - 2 * qPow(qExp(1), x) + qExp(1) - 1;
}
开发者ID:gehirn,项目名称:lab3,代码行数:4,代码来源:mywidget.cpp
示例12: qPow
/*!
Draw the rose
\param painter Painter
\param palette Palette
\param center Center of the rose
\param radius Radius of the rose
\param north Position pointing to north
\param width Width of the rose
\param numThorns Number of thorns
\param numThornLevels Number of thorn levels
\param shrinkFactor Factor to shrink the thorns with each level
*/
void QwtSimpleCompassRose::drawRose(
QPainter *painter,
const QPalette &palette,
const QPointF ¢er, double radius, double north, double width,
int numThorns, int numThornLevels, double shrinkFactor )
{
if ( numThorns < 4 )
numThorns = 4;
if ( numThorns % 4 )
numThorns += 4 - numThorns % 4;
if ( numThornLevels <= 0 )
numThornLevels = numThorns / 4;
if ( shrinkFactor >= 1.0 )
shrinkFactor = 1.0;
if ( shrinkFactor <= 0.5 )
shrinkFactor = 0.5;
painter->save();
painter->setPen( Qt::NoPen );
for ( int j = 1; j <= numThornLevels; j++ )
{
double step = qPow( 2.0, j ) * M_PI / numThorns;
if ( step > M_PI_2 )
break;
double r = radius;
for ( int k = 0; k < 3; k++ )
{
if ( j + k < numThornLevels )
r *= shrinkFactor;
}
double leafWidth = r * width;
if ( 2.0 * M_PI / step > 32 )
leafWidth = 16;
const double origin = north / 180.0 * M_PI;
for ( double angle = origin;
angle < 2.0 * M_PI + origin; angle += step )
{
const QPointF p = qwtPolar2Pos( center, r, angle );
const QPointF p1 = qwtPolar2Pos( center, leafWidth, angle + M_PI_2 );
const QPointF p2 = qwtPolar2Pos( center, leafWidth, angle - M_PI_2 );
const QPointF p3 = qwtPolar2Pos( center, r, angle + step / 2.0 );
const QPointF p4 = qwtPolar2Pos( center, r, angle - step / 2.0 );
QPainterPath darkPath;
darkPath.moveTo( center );
darkPath.lineTo( p );
darkPath.lineTo( qwtIntersection( center, p3, p1, p ) );
painter->setBrush( palette.brush( QPalette::Dark ) );
painter->drawPath( darkPath );
QPainterPath lightPath;
lightPath.moveTo( center );
lightPath.lineTo( p );
lightPath.lineTo( qwtIntersection( center, p4, p2, p ) );
painter->setBrush( palette.brush( QPalette::Light ) );
painter->drawPath( lightPath );
}
}
painter->restore();
}
开发者ID:Aconex,项目名称:pcp,代码行数:84,代码来源:qwt_compass_rose.cpp
示例13: qPow
void FeaturesCalculation::calculateTextureParameter(PARAMETR param)
{
float qrt = 0, fabs = 0, thigmaSqr = 0, U = 0;
for(int k = 0; k < seedVect.length(); k++)
{
for(int i=0; i< seedVect[k].GLCM.rows; i++)
for(int j=0; j< seedVect[k].GLCM.cols; j++)
{
if(param == DISSIMILARITY)
{
qrt = qPow(i-j,2);
fabs = qSqrt(qrt);
seedVect[k].dissimilarity += fabs*seedVect[k].GLCM.at<uchar>(i,j);
}
if(param == ENERGY)
{
seedVect[k].energy += qPow(seedVect[k].GLCM.at<uchar>(i,j),2);
}
if(param == ENTROPY)
{
if (seedVect[k].GLCM.at<uchar>(i,j) != 0)
{
// float ln = -qLn(seedVect[k].GLCM.at<uchar>(i,j));
seedVect[k].entropy += -qLn(seedVect[k].GLCM.at<uchar>(i,j)) * seedVect[k].GLCM.at<uchar>(i,j);
}
// printf("ln = %f, char =%d entropy = %f\n", ln, seedVect[k].GLCM.at<uchar>(i,j), seedVect[k].entropy);
}
if(param == HOMOGENEITY)
{
qrt = qPow(i-j,2);
if(qrt != 1)
seedVect[k].homogeneity += (1/(1-qPow(i-j,2)))*seedVect[k].GLCM.at<uchar>(i,j);
}
if(param == CONTRAST)
{
int pixel = seedVect[k].GLCM.at<uchar>(i,j);
float dividing = pixel;
float qrt = qPow(i-j, 2);
float contr = qrt * dividing;
seedVect[k].contrast += contr;
}
if(param == CORRELATION)
{
calculateUandThigma(k, U, thigmaSqr);
seedVect[k].correlation += seedVect[k].GLCM.at<uchar>(i,j)*(i-U)*(j-U) / thigmaSqr;
}
}
if(param == DISSIMILARITY)
seedVect[k].dissimilarity = seedVect[k].dissimilarity / (seedVect[k].countOfPairs);
if(param == HOMOGENEITY)
seedVect[k].homogeneity = seedVect[k].homogeneity / (seedVect[k].countOfPairs);
if(param == CONTRAST)
seedVect[k].contrast = seedVect[k].contrast/(seedVect[k].countOfPairs);
if(param == ENERGY)
seedVect[k].energy = seedVect[k].energy / (seedVect[k].countOfPairs);
if(param == ENTROPY)
seedVect[k].entropy = seedVect[k].entropy / (seedVect[k].countOfPairs);
if(param == CORRELATION)
seedVect[k].correlation = seedVect[k].correlation / (seedVect[k].countOfPairs);
}
}
开发者ID:PavelKubitski,项目名称:testCV2,代码行数:84,代码来源:FeaturesCaculation.cpp
示例14: new_image
QImage EdgeDetection::gradientMagnitudeImage(QImage *image)
{
QImage new_image(image->size(), QImage::Format_ARGB32_Premultiplied);
// QImage orient_image(image->size(), QImage::Format_ARGB32_Premultiplied);
QList<QPair<QPoint, QPair<int, int> > > x_y_struct;
x_y_struct.append( qMakePair(QPoint(-1,-1), QPair<int,int>(-1, 1) ));
x_y_struct.append( qMakePair(QPoint(-1,0), QPair<int,int>(-2, 0) ));
x_y_struct.append( qMakePair(QPoint(-1,1), QPair<int,int>(-1,-1) ));
x_y_struct.append( qMakePair(QPoint(0,-1), QPair<int,int>(0,2) ));
x_y_struct.append( qMakePair(QPoint(0,0), QPair<int,int>(0,0) ));
x_y_struct.append( qMakePair(QPoint(0,1), QPair<int,int>(0,-2) ));
x_y_struct.append( qMakePair(QPoint(1,-1), QPair<int,int>(1,1) ));
x_y_struct.append( qMakePair(QPoint(1,0), QPair<int,int>(2,0) ));
x_y_struct.append( qMakePair(QPoint(1,1), QPair<int,int>(1, -1) ));
// QList<QPair<QPoint, qreal> > orientations;
// qreal orien_min = 1000;
// qreal orien_max = 0;
// int threshold = QInputDialog::getInteger(0, "Threshold", "Threshold value:", -1, -1, 255);
for( int y=0; y < image->height(); y++ ) {
for( int x=0; x < image->width(); x++ ) {
QPoint point(x,y);
int x_sum = 0;
int x_rsum = 0;
int x_gsum = 0;
int x_bsum = 0;
int y_sum = 0;
int y_rsum = 0;
int y_gsum = 0;
int y_bsum = 0;
//Perform Convolution on X
for (int i=0; i < x_y_struct.size(); i++) {
QPoint offset = x_y_struct.at(i).first;
QPair<int,int> multiplier = x_y_struct.at(i).second;
//Only convolve real pixels
int pixel_x = offset.x() + x;
int pixel_y = offset.y() + y;
QRgb color;
if ( pixel_x < 0 ||
pixel_x >= image->width() ||
pixel_y < 0 ||
pixel_y >= image->height() ) {
color = qRgb(128, 128, 128);
} else {
color = image->pixel(QPoint(pixel_x, pixel_y));
}
int gray_val = qGray(color);
x_sum += gray_val * multiplier.first;
x_rsum += qRed(color) * multiplier.first;
x_gsum += qGreen(color) * multiplier.first;
x_bsum += qBlue(color) * multiplier.first;
y_sum += gray_val * multiplier.second;
y_rsum += qRed(color) * multiplier.second;
y_gsum += qGreen(color) * multiplier.second;
y_bsum += qBlue(color) * multiplier.second;
}
//Gradient
qreal gradient = qSqrt(qPow(x_sum / 8, 2) + qPow(y_sum / 8, 2));
qreal r_gradient = qSqrt(qPow(x_rsum / 8, 2) + qPow(y_rsum / 8, 2));
qreal g_gradient = qSqrt(qPow(x_gsum / 8, 2) + qPow(y_gsum / 8, 2));
qreal b_gradient = qSqrt(qPow(x_bsum / 8, 2) + qPow(y_bsum / 8, 2));
//Orientation
// qreal orientation = qAtan2(y_sum, x_sum);
// if ( orientation < orien_min )
// orien_min = orientation;
// if ( orientation > orien_max )
// orien_max = orientation;
// orientations.append(qMakePair(point, orientation));
//Threshold
// QRgb val;
// if ( threshold < 0 ) {
// val = qRgb(gradient, gradient, gradient);
// } else if ( gradient > threshold ) {
// val = qRgb(255,255,255);
// } else
// val = qRgb(0,0,0);
// new_image.setPixel(point, val);
new_image.setPixel(point, qRgb(r_gradient, g_gradient, b_gradient));
}
}
// for( int i=0; i < orientations.size(); i++ ) {
// QPair<QPoint, qreal> o_pair = orientations.at(i);
// qreal normal = Utility::rangeConvert(orien_max, orien_min, 255, 0, o_pair.second);
// orient_image.setPixel(o_pair.first, qRgb(normal, normal, normal));
// }
return new_image;
}
开发者ID:tjflexmaster,项目名称:CS650,代码行数:100,代码来源:EdgeDetection.cpp
示例15: base
/*!
\brief Calculate minor/medium ticks for major ticks
\param majorTicks Major ticks
\param maxMinorSteps Maximum number of minor steps
\param stepSize Step size
\param minorTicks Array to be filled with the calculated minor ticks
\param mediumTicks Array to be filled with the calculated medium ticks
*/
void QwtLogScaleEngine::buildMinorTicks(
const QList<double> &majorTicks,
int maxMinorSteps, double stepSize,
QList<double> &minorTicks,
QList<double> &mediumTicks ) const
{
const double logBase = base();
if ( stepSize < 1.1 ) // major step width is one base
{
double minStep = divideInterval( stepSize, maxMinorSteps + 1 );
if ( minStep == 0.0 )
return;
const int numSteps = qRound( stepSize / minStep );
int mediumTickIndex = -1;
if ( ( numSteps > 2 ) && ( numSteps % 2 == 0 ) )
mediumTickIndex = numSteps / 2;
for ( int i = 0; i < majorTicks.count() - 1; i++ )
{
const double v = majorTicks[i];
const double s = logBase / numSteps;
if ( s >= 1.0 )
{
if ( !qFuzzyCompare( s, 1.0 ) )
minorTicks += v * s;
for ( int j = 2; j < numSteps; j++ )
{
minorTicks += v * j * s;
}
}
else
{
for ( int j = 1; j < numSteps; j++ )
{
const double tick = v + j * v * ( logBase - 1 ) / numSteps;
if ( j == mediumTickIndex )
mediumTicks += tick;
else
minorTicks += tick;
}
}
}
}
else
{
double minStep = divideInterval( stepSize, maxMinorSteps );
if ( minStep == 0.0 )
return;
if ( minStep < 1.0 )
minStep = 1.0;
// # subticks per interval
int numTicks = qRound( stepSize / minStep ) - 1;
// Do the minor steps fit into the interval?
if ( qwtFuzzyCompare( ( numTicks + 1 ) * minStep,
stepSize, stepSize ) > 0 )
{
numTicks = 0;
}
if ( numTicks < 1 )
return;
int mediumTickIndex = -1;
if ( ( numTicks > 2 ) && ( numTicks % 2 ) )
mediumTickIndex = numTicks / 2;
// substep factor = base^substeps
const qreal minFactor = qMax( qPow( logBase, minStep ), qreal( logBase ) );
for ( int i = 0; i < majorTicks.count(); i++ )
{
double tick = majorTicks[i];
for ( int j = 0; j < numTicks; j++ )
{
tick *= minFactor;
if ( j == mediumTickIndex )
mediumTicks += tick;
else
minorTicks += tick;
}
}
}
//.........这里部分代码省略.........
开发者ID:mirams,项目名称:opencor,代码行数:101,代码来源:qwt_scale_engine.cpp
示例16: QWidget
QWidget *WalkmeshManager::buildCameraPage()
{
QWidget *ret = new QWidget(this);
ListWidget *listWidget = new ListWidget(ret);
listWidget->addAction(ListWidget::Add, tr("Ajouter caméra"), this, SLOT(addCamera()));
listWidget->addAction(ListWidget::Rem, tr("Supprimer caméra"), this, SLOT(removeCamera()));
caToolbar = listWidget->toolBar();
camList = listWidget->listWidget();
caVectorXEdit = new VertexWidget(ret);
caVectorYEdit = new VertexWidget(ret);
caVectorZEdit = new VertexWidget(ret);
caSpaceXEdit = new QDoubleSpinBox(ret);
qreal maxInt = qPow(2,31);
caSpaceXEdit->setRange(-maxInt, maxInt);
caSpaceXEdit->setDecimals(0);
caSpaceYEdit = new QDoubleSpinBox(ret);
caSpaceYEdit->setRange(-maxInt, maxInt);
caSpaceYEdit->setDecimals(0);
caSpaceZEdit = new QDoubleSpinBox(ret);
caSpaceZEdit->setRange(-maxInt, maxInt);
caSpaceZEdit->setDecimals(0);
caZoomEdit = new QSpinBox(ret);
caZoomEdit->setRange(-32768, 32767);
QGridLayout *caLayout = new QGridLayout(ret);
caLayout->addWidget(listWidget, 0, 0, 8, 1);
caLayout->addWidget(new QLabel(tr("Distance (zoom) :")), 0, 1, 1, 3);
caLayout->addWidget(caZoomEdit, 0, 4, 1, 2);
caLayout->addWidget(new QLabel(tr("Axes de la caméra :")), 1, 1, 1, 6);
caLayout->addWidget(caVectorXEdit, 2, 1, 1, 6);
caLayout->addWidget(caVectorYEdit, 3, 1, 1, 6);
caLayout->addWidget(caVectorZEdit, 4, 1, 1, 6);
caLayout->addWidget(new QLabel(tr("Position de la caméra :")), 5, 1, 1, 6);
caLayout->addWidget(new QLabel(tr("X")), 6, 1);
caLayout->addWidget(caSpaceXEdit, 6, 2);
caLayout->addWidget(new QLabel(tr("Y")), 6, 3);
caLayout->addWidget(caSpaceYEdit, 6, 4);
caLayout->addWidget(new QLabel(tr("Z")), 6, 5);
caLayout->addWidget(caSpaceZEdit, 6, 6);
caLayout->setRowStretch(7, 1);
caLayout->setColumnStretch(2, 1);
caLayout->setColumnStretch(4, 1);
caLayout->setColumnStretch(6, 1);
connect(camList, SIGNAL(currentRowChanged(int)), SLOT(setCurrentCamera(int)));
connect(caVectorXEdit, SIGNAL(valuesChanged(Vertex_s)), SLOT(editCaVector(Vertex_s)));
connect(caVectorYEdit, SIGNAL(valuesChanged(Vertex_s)), SLOT(editCaVector(Vertex_s)));
connect(caVectorZEdit, SIGNAL(valuesChanged(Vertex_s)), SLOT(editCaVector(Vertex_s)));
connect(caSpaceXEdit, SIGNAL(valueChanged(double)), SLOT(editCaPos(double)));
connect(caSpaceYEdit, SIGNAL(valueChanged(double)), SLOT(editCaPos(double)));
connect(caSpaceZEdit, SIGNAL(valueChanged(double)), SLOT(editCaPos(double)));
connect(caZoomEdit, SIGNAL(valueChanged(int)), SLOT(editCaZoom(int)));
return ret;
}
开发者ID:TurBoss,项目名称:makoureactor,代码行数:63,代码来源:WalkmeshManager.cpp
示例17: interval
/*!
Align and divide an interval
\param maxNumSteps Max. number of steps
\param x1 First limit of the interval (In/Out)
\param x2 Second limit of the interval (In/Out)
\param stepSize Step size (Out)
\sa QwtScaleEngine::setAttribute()
*/
void QwtLogScaleEngine::autoScale( int maxNumSteps,
double &x1, double &x2, double &stepSize ) const
{
if ( x1 > x2 )
qSwap( x1, x2 );
const double logBase = base();
QwtInterval interval( x1 / qPow( logBase, lowerMargin() ),
x2 * qPow( logBase, upperMargin() ) );
if ( interval.maxValue() / interval.minValue() < logBase )
{
// scale width is less than one step -> try to build a linear scale
QwtLinearScaleEngine linearScaler;
linearScaler.setAttributes( attributes() );
linearScaler.setReference( reference() );
linearScaler.setMargins( lowerMargin(), upperMargin() );
linearScaler.autoScale( maxNumSteps, x1, x2, stepSize );
QwtInterval linearInterval = QwtInterval( x1, x2 ).normalized();
linearInterval = linearInterval.limited( LOG_MIN, LOG_MAX );
if ( linearInterval.maxValue() / linearInterval.minValue() < logBase )
{
// the aligned scale is still less than one step
#if 1
// this code doesn't make any sense, but for compatibility
// reasons we keep it until 6.2. But it will be ignored
// in divideScale
if ( stepSize < 0.0 )
stepSize = -qwtLog( logBase, qAbs( stepSize ) );
else
stepSize = qwtLog( logBase, stepSize );
#endif
return;
}
}
double logRef = 1.0;
if ( reference() > LOG_MIN / 2 )
logRef = qMin( reference(), LOG_MAX / 2 );
if ( testAttribute( QwtScaleEngine::Symmetric ) )
{
const double delta = qMax( interval.maxValue() / logRef,
logRef / interval.minValue() );
interval.setInterval( logRef / delta, logRef * delta );
}
if ( testAttribute( QwtScaleEngine::IncludeReference ) )
interval = interval.extend( logRef );
interval = interval.limited( LOG_MIN, LOG_MAX );
if ( interval.width() == 0.0 )
interval = buildInterval( interval.minValue() );
stepSize = divideInterval( qwtLogInterval( logBase, interval ).width(),
qMax( maxNumSteps, 1 ) );
if ( stepSize < 1.0 )
stepSize = 1.0;
if ( !testAttribute( QwtScaleEngine::Floating ) )
interval = align( interval, stepSize );
x1 = interval.minValue();
x2 = interval.maxValue();
if ( testAttribute( QwtScaleEngine::Inverted ) )
{
qSwap( x1, x2 );
stepSize = -stepSize;
}
}
开发者ID:mirams,项目名称:opencor,代码行数:90,代码来源:qwt_scale_engine.cpp
示例18: qPow
double QgsRasterChecker::tolerance( double val, int places )
{
// float precision is about 7 decimal digits, double about 16
// default places = 6
return 1. * qPow( 10, qRound( log10( qAbs( val ) ) - places ) );
}
开发者ID:spatialthoughts,项目名称:QGIS,代码行数:6,代码来源:qgsrasterchecker.cpp
示例19: switch
void MainWindow::mousePressEvent(QMouseEvent *event)
{
pressed = true;
clicked_point = static_cast<QMouseEvent*>(event)->pos();
if(skill && shot && pressed && CD)
{
b2Vec2 gravity;
b2Vec2 speed = (*Bit)->Body->GetLinearVelocity();
b2Vec2 gravity_center;
b2Vec2 bodypos;
float dist;
switch(bird_count-1)
{
case 1:
qDebug() << "red";
skill = false;
pressed = false;
break;
case 2:
qDebug() << "yellow";
(*Bit)->Body->SetLinearVelocity(b2Vec2(speed.x*10,speed.y*10));
skill = false;
pressed = false;
break;
case 3:
qDebug() << "iron";
(*Bit)->Body->SetLinearVelocity(b2Vec2(0,-300));
skill = false;
pressed = false;
break;
case 4:
qDebug() << "black";
gravity_center = (*Bit)->Body->GetPosition();
for(it=WOOD.begin(); it!=WOOD.end(); ++it)
{
bodypos = (*it)->Body->GetPosition();
dist = qSqrt(qPow(gravity_center.x-bodypos.x,2)+qPow(gravity_center.y-bodypos.y,2));
if(dist<=4)
{
gravity = b2Vec2(4000000/dist,4000000/dist);
(*it)->Body->ApplyForceToCenter(gravity, true);
}
}
for(it=PIG.begin(); it!=PIG.end(); ++it)
{
bodypos = (*it)->Body->GetPosition();
dist = qSqrt(qPow(gravity_center.x-bodypos.x,2)+qPow(gravity_center.y-bodypos.y,2));
gravity = b2Vec2(800000/dist,800000/dist);
(*it)->Body->ApplyForceToCenter(gravity, true);
}
skill = false;
pressed = false;
break;
case 5:
qDebug() << "TA NUCLEAR";
gravity_center = (*Bit)->Body->GetPosition();
for(it=WOOD.begin(); it!=WOOD.end(); ++it)
{
bodypos = (*it)->Body->GetPosition();
dist = qSqrt(qPow(gravity_center.x-bodypos.x,2)+qPow(gravity_center.y-bodypos.y,2));
gravity = b2Vec2(20000000000/dist,20000000000/dist);
(*it)->Body->ApplyForceToCenter(gravity, true);
}
for(it=PIG.begin(); it!=PIG.end(); ++it)
{
bodypos = (*it)->Body->GetPosition();
dist = qSqrt(qPow(gravity_center.x-bodypos.x,2)+qPow(gravity_center.y-bodypos.y,2));
gravity = b2Vec2(20000000000/dist,20000000000/dist);
(*it)->Body->ApplyForceToCenter(gravity, true);
}
(*Bit)->Body->ApplyLinearImpulse(b2Vec2(400000,400000),gravity_center,true);
skill = false;
pressed = false;
break;
default:
qDebug() << "nothing happens";
break;
}
}
}
开发者ID:bladeath860620,项目名称:pd2-Angrybird,代码行数:81,代码来源:mainwindow.cpp
示例20: switch
// Méthodes publiques
char * Page::getTextValue(char * T, WORD champ, genAmountType genVal)
{
switch (champ)
{
case champ_velRange:
if (genVal.ranges.byLo == genVal.ranges.byHi)
sprintf(T, "%d", genVal.ranges.byLo);
else
sprintf(T, "%d-%d", genVal.ranges.byLo, genVal.ranges.byHi);
break;
case champ_keyRange:
if (genVal.ranges.byLo == genVal.ranges.byHi)
sprintf(T, "%s", Config::getInstance()->getKeyName(genVal.ranges.byLo).toStdString().c_str());
else
sprintf(T, "%s-%s", Config::getInstance()->getKeyName(genVal.ranges.byLo).toStdString().c_str(),
Config::getInstance()->getKeyName(genVal.ranges.byHi).toStdString().c_str());
break;
case champ_initialAttenuation: case champ_pan: case champ_initialFilterQ:
case champ_modLfoToVolume:
case champ_sustainVolEnv: case champ_sustainModEnv:
case champ_chorusEffectsSend: case champ_reverbEffectsSend:
sprintf(T, "%.1f", (double)genVal.shAmount/10);
break;
case champ_keynum: case champ_overridingRootKey:
sprintf(T, "%s", Config::getInstance()->getKeyName(genVal.wAmount).toStdString().c_str());
break;
case champ_sampleModes: case champ_exclusiveClass: case champ_velocity:
sprintf(T,"%d", genVal.wAmount);
break;
case champ_scaleTuning: case champ_coarseTune: case champ_fineTune:
case champ_modLfoToFilterFc: case champ_modEnvToFilterFc:
case champ_modEnvToPitch: case champ_modLfoToPitch: case champ_vibLfoToPitch:
case champ_keynumToModEnvHold: case champ_keynumToVolEnvHold:
case champ_keynumToModEnvDecay: case champ_keynumToVolEnvDecay:
case champ_startAddrsOffset: case champ_startAddrsCoarseOffset:
case champ_startloopAddrsOffset: case champ_startloopAddrsCoarseOffset:
case champ_endAddrsOffset: case champ_endAddrsCoarseOffset:
case champ_endloopAddrsOffset: case champ_endloopAddrsCoarseOffset:
sprintf(T,"%d", genVal.shAmount);
break;
case champ_initialFilterFc:
if (m_typePage == PAGE_PRST)
sprintf(T,"%.3f", qPow(2., (double)genVal.shAmount/1200));
else
sprintf(T,"%.0f", qPow(2., (double)genVal.shAmount/1200)*8.176);
break;
case champ_freqModLFO: case champ_freqVibLFO:
if (m_typePage == PAGE_PRST)
sprintf(T,"%.3f", qPow(2., (double)genVal.shAmount/1200));
else
sprintf(T,"%.3f", qPow(2., (double)genVal.shAmount/1200)*8.176);
break;
case champ_delayModEnv: case champ_attackModEnv: case champ_holdModEnv: case champ_decayModEnv: case champ_releaseModEnv:
case champ_delayVolEnv: case champ_attackVolEnv: case champ_holdVolEnv: case champ_decayVolEnv: case champ_releaseVolEnv:
case champ_delayModLFO: case champ_delayVibLFO:
sprintf(T,"%.3f", qPow(2., (double)genVal.shAmount/1200)); break;
case champ_sfModDestOper:
sprintf(T,"%d", genVal.wAmount);
break;
case champ_sfModTransOper:
switch (genVal.wAmount)
{
case 2: strcpy(T, trUtf8(", valeur absolue").toStdString().c_str()); break;
default: T[0] = '\0';
}
break;
case champ_modAmount:
sprintf(T,"%d", genVal.shAmount);
break;
case champ_indexMod:
sprintf(T,"%d"
|
请发表评论