本文整理汇总了C++中qRound函数的典型用法代码示例。如果您正苦于以下问题:C++ qRound函数的具体用法?C++ qRound怎么用?C++ qRound使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qRound函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: maximum
void ProgressBar::paintEvent(QPaintEvent *)
{
// TODO move font into stylehelper
// TODO use stylehelper white
double range = maximum() - minimum();
double percent = 0.50;
if (range != 0)
percent = (value() - minimum()) / range;
if (percent > 1)
percent = 1;
else if (percent < 0)
percent = 0;
QPainter p(this);
QFont boldFont(p.font());
boldFont.setPointSizeF(StyleHelper::sidebarFontSize());
boldFont.setBold(true);
p.setFont(boldFont);
QFontMetrics fm(boldFont);
// Draw separator
int h = fm.height();
p.setPen(QColor(0, 0, 0, 70));
p.drawLine(0,0, size().width(), 0);
p.setPen(QColor(255, 255, 255, 70));
p.drawLine(0, 1, size().width(), 1);
p.setPen(StyleHelper::panelTextColor());
p.drawText(QPoint(7, h+1), m_title);
m_progressHeight = h-4;
m_progressHeight += ((m_progressHeight % 2) + 1) % 2; // make odd
// draw outer rect
QRect rect(INDENT, h+6, size().width()-2*INDENT-m_progressHeight+1, m_progressHeight-1);
p.setPen(StyleHelper::panelTextColor());
p.drawRect(rect);
// draw inner rect
QColor c = StyleHelper::panelTextColor();
c.setAlpha(180);
p.setPen(Qt::NoPen);
p.setBrush(c);
QRect inner = rect.adjusted(2, 2, -1, -1);
inner.adjust(0, 0, qRound((percent - 1) * inner.width()), 0);
if (m_error) {
// TODO this is not fancy enough
QColor red(255, 0, 0, 180);
p.setBrush(red);
// avoid too small red bar
if (inner.width() < 10)
inner.adjust(0, 0, 10 - inner.width(), 0);
} else if (value() == maximum()) {
QColor green(140, 255, 140, 180);
p.setBrush(green);
}
p.drawRect(inner);
if (value() < maximum() && !m_error) {
// draw cancel thingy
// TODO this is quite ugly at the moment
p.setPen(StyleHelper::panelTextColor());
p.setBrush(QBrush(Qt::NoBrush));
QRect cancelRect(size().width()-INDENT-m_progressHeight+3, h+6+1, m_progressHeight-3, m_progressHeight-3);
p.drawRect(cancelRect);
p.setPen(c);
p.drawLine(cancelRect.center()+QPoint(-1,-1), cancelRect.center()+QPoint(+3,+3));
p.drawLine(cancelRect.center()+QPoint(+3,-1), cancelRect.center()+QPoint(-1,+3));
}
}
开发者ID:halsten,项目名称:beaverdbg,代码行数:71,代码来源:progresspie.cpp
示例2: qAbs
void QgsDecorationScaleBar::render( QPainter * theQPainter )
{
QgsMapCanvas* canvas = QgisApp::instance()->mapCanvas();
int myBufferSize = 1; //softcode this later
//Get canvas dimensions
int myCanvasHeight = theQPainter->device()->height();
int myCanvasWidth = theQPainter->device()->width();
//Get map units per pixel. This can be negative at times (to do with
//projections) and that just confuses the rest of the code in this
//function, so force to a positive number.
double myMapUnitsPerPixelDouble = qAbs( canvas->mapUnitsPerPixel() );
double myActualSize = mPreferredSize;
// Exit if the canvas width is 0 or layercount is 0 or QGIS will freeze
int myLayerCount = canvas->layerCount();
if ( !myLayerCount || !myCanvasWidth || !myMapUnitsPerPixelDouble )
return;
//Large if statement which determines whether to render the scale bar
if ( enabled() )
{
// Hard coded sizes
int myMajorTickSize = 8;
int myTextOffsetX = 3;
int myMargin = 20;
QSettings settings;
QGis::UnitType myPreferredUnits = QGis::fromLiteral( settings.value( "/qgis/measure/displayunits", QGis::toLiteral( QGis::Meters ) ).toString() );
QGis::UnitType myMapUnits = canvas->mapUnits();
// Adjust units meter/feet/... or vice versa
myMapUnitsPerPixelDouble *= QGis::fromUnitToUnitFactor( myMapUnits, myPreferredUnits );
myMapUnits = myPreferredUnits;
//Calculate size of scale bar for preferred number of map units
double myScaleBarWidth = mPreferredSize / myMapUnitsPerPixelDouble;
//If scale bar is very small reset to 1/4 of the canvas wide
if ( myScaleBarWidth < 30 )
{
myScaleBarWidth = myCanvasWidth / 4; // pixels
myActualSize = myScaleBarWidth * myMapUnitsPerPixelDouble; // map units
};
//if scale bar is more than half the canvas wide keep halving until not
while ( myScaleBarWidth > myCanvasWidth / 3 )
{
myScaleBarWidth = myScaleBarWidth / 3;
};
myActualSize = myScaleBarWidth * myMapUnitsPerPixelDouble;
// Work out the exponent for the number - e.g, 1234 will give 3,
// and .001234 will give -3
double myPowerOf10 = floor( log10( myActualSize ) );
// snap to integer < 10 times power of 10
if ( mSnapping )
{
double scaler = pow( 10.0, myPowerOf10 );
myActualSize = qRound( myActualSize / scaler ) * scaler;
myScaleBarWidth = myActualSize / myMapUnitsPerPixelDouble;
}
//Get type of map units and set scale bar unit label text
QString myScaleBarUnitLabel;
switch ( myMapUnits )
{
case QGis::Meters:
if ( myActualSize > 1000.0 )
{
myScaleBarUnitLabel = tr( " km" );
myActualSize = myActualSize / 1000;
}
else if ( myActualSize < 0.01 )
{
myScaleBarUnitLabel = tr( " mm" );
myActualSize = myActualSize * 1000;
}
else if ( myActualSize < 0.1 )
{
myScaleBarUnitLabel = tr( " cm" );
myActualSize = myActualSize * 100;
}
else
myScaleBarUnitLabel = tr( " m" );
break;
case QGis::Feet:
if ( myActualSize > 5280.0 ) //5280 feet to the mile
{
myScaleBarUnitLabel = tr( " miles" );
// Adjust scale bar width to get even numbers
myActualSize = myActualSize / 5000;
myScaleBarWidth = ( myScaleBarWidth * 5280 ) / 5000;
}
else if ( myActualSize == 5280.0 ) //5280 feet to the mile
{
myScaleBarUnitLabel = tr( " mile" );
//.........这里部分代码省略.........
开发者ID:ACorradini,项目名称:QGIS,代码行数:101,代码来源:qgsdecorationscalebar.cpp
示例3: 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 )
{
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:shenglonglinapple,项目名称:slin_code,代码行数:98,代码来源:qwt_scale_engine.cpp
示例4: settings
void ColorInspector::onModeChanged()
{
// assume hsv if not checked
bool newValue = ui->rgbButton->isChecked();
QSettings settings(PENCIL2D, PENCIL2D);
settings.setValue("isRgb", newValue);
isRgbColors = newValue;
if (isRgbColors)
{
// Spinboxes may emit unwanted valueChanged signals when setting ranges
// so block them all first
QSignalBlocker b1(ui->RedspinBox);
QSignalBlocker b2(ui->GreenspinBox);
QSignalBlocker b3(ui->BluespinBox);
QSignalBlocker b4(ui->AlphaspinBox);
ui->red->setText("R");
ui->green->setText("G");
ui->blue->setText("B");
ui->alpha->setText("A");
ui->RedspinBox->setRange(0,255);
ui->RedspinBox->setSuffix("");
ui->GreenspinBox->setRange(0,255);
ui->GreenspinBox->setSuffix("");
ui->BluespinBox->setRange(0,255);
ui->BluespinBox->setSuffix("");
ui->AlphaspinBox->setRange(0,255);
ui->AlphaspinBox->setSuffix("");
mCurrentColor = mCurrentColor.toRgb();
ui->red_slider->setMax(255);
ui->red_slider->setColorType(ColorSlider::ColorType::RED);
ui->red_slider->setColorSpecType(ColorSlider::ColorSpecType::RGB);
ui->green_slider->setColorSpecType(ColorSlider::ColorSpecType::RGB);
ui->green_slider->setColorType(ColorSlider::ColorType::GREEN);
ui->blue_slider->setColorSpecType(ColorSlider::ColorSpecType::RGB);
ui->blue_slider->setColorType(ColorSlider::ColorType::BLUE);
ui->alpha_slider->setColorSpecType(ColorSlider::ColorSpecType::RGB);
ui->alpha_slider->setColorType(ColorSlider::ColorType::ALPHA);
ui->RedspinBox->setValue(mCurrentColor.red());
ui->GreenspinBox->setValue(mCurrentColor.green());
ui->BluespinBox->setValue(mCurrentColor.blue());
ui->AlphaspinBox->setValue(mCurrentColor.alpha());
}
else
{
QSignalBlocker b1(ui->RedspinBox);
QSignalBlocker b2(ui->GreenspinBox);
QSignalBlocker b3(ui->BluespinBox);
QSignalBlocker b4(ui->AlphaspinBox);
ui->red->setText("H");
ui->green->setText("S");
ui->blue->setText("V");
ui->alpha->setText("A");
ui->red_slider->setMax(359);
ui->red_slider->setColorType(ColorSlider::ColorType::HUE);
ui->red_slider->setColorSpecType(ColorSlider::ColorSpecType::HSV);
ui->green_slider->setColorType(ColorSlider::ColorType::SAT);
ui->green_slider->setColorSpecType(ColorSlider::ColorSpecType::HSV);
ui->blue_slider->setColorType(ColorSlider::ColorType::VAL);
ui->blue_slider->setColorSpecType(ColorSlider::ColorSpecType::HSV);
ui->alpha_slider->setColorType(ColorSlider::ColorType::ALPHA);
ui->alpha_slider->setColorSpecType(ColorSlider::ColorSpecType::HSV);
ui->RedspinBox->setRange(0,359);
ui->RedspinBox->setSuffix("°");
ui->GreenspinBox->setRange(0,100);
ui->GreenspinBox->setSuffix("%");
ui->BluespinBox->setRange(0,100);
ui->BluespinBox->setSuffix("%");
ui->AlphaspinBox->setRange(0,100);
ui->AlphaspinBox->setSuffix("%");
mCurrentColor = mCurrentColor.toHsv();
const qreal bound = 100.0 / 255.0; // from 255 to 100
ui->RedspinBox->setValue(mCurrentColor.hsvHue());
ui->GreenspinBox->setValue(qRound(mCurrentColor.hsvSaturation()*bound));
ui->BluespinBox->setValue(qRound(mCurrentColor.value()*bound));
ui->AlphaspinBox->setValue(qRound(mCurrentColor.alpha()*bound));
}
emit modeChange(isRgbColors);
}
开发者ID:chchwy,项目名称:pencil2d,代码行数:93,代码来源:colorinspector.cpp
示例5: SetStatusButtonText
void Dlg_Physics::UpdateUI(void)
{
CVX_Environment* ptEnv = pSim->pEnv; //pointer to current environment object
bool EqMode = pSim->IsEquilibriumEnabled();
// TimestepMag = pSim->dt/pSim->DtFrac;
//Sim
if (!pSim->Paused && pSim->Running) SetStatusButtonText(true);
else SetStatusButtonText(false);
ui.RecordButton->setChecked(pSim->Recording);
ui.UseEquilibriumCheck->setChecked(pSim->IsEquilibriumEnabled());
StopCondition CurStopCond = pSim->GetStopConditionType();
ui.StopSelectCombo->setCurrentIndex(CurStopCond);
ui.StopValueEdit->setEnabled(CurStopCond != SC_NONE);
ui.StopValueEdit->setText(QString::number(pSim->GetStopConditionValue()));
switch (CurStopCond){
case SC_NONE: ui.StopValueLabel->setText(""); break;
case SC_MAX_TIME_STEPS: ui.StopValueLabel->setText("#"); break;
case SC_MAX_SIM_TIME: ui.StopValueLabel->setText("Sec"); break;
case SC_TEMP_CYCLES: ui.StopValueLabel->setText("#"); break;
case SC_CONST_MAXENERGY: ui.StopValueLabel->setText("Avg mJ/Vox/500 ts"); break;
case SC_MIN_KE: ui.StopValueLabel->setText("Avg mJ/Vox/500 ts"); break;
case SC_MIN_MAXMOVE: ui.StopValueLabel->setText("Max mm/timestep"); break;
}
ui.dtSlider->setRange(0, 1000);
ui.dtSlider->setValue(qRound(pSim->DtFrac*500));
ui.dtEdit->setText(QString::number(pSim->DtFrac, 'g', 3));
ui.BondDampSlider->setEnabled(!EqMode);
ui.BondDampEdit->setEnabled(!EqMode);
ui.BondDampSlider->setRange(0, 100);
ui.BondDampSlider->setValue(qRound(pSim->GetBondDampZ()*50));
ui.BondDampEdit->setText(QString::number(pSim->GetBondDampZ(), 'g', 3));
//from .00001 to .1
ui.GNDDampSlider->setEnabled(!EqMode);
ui.GNDDampEdit->setEnabled(!EqMode);
ui.GNDDampSlider->setRange(0, 100);
if (pSim->GetSlowDampZ() == 0) ui.GNDDampSlider->setValue(0);
else ui.GNDDampSlider->setValue(qRound((log10(pSim->GetSlowDampZ())+5)*25.0));
ui.GNDDampEdit->setText(QString::number(pSim->GetSlowDampZ(), 'g', 3));
ui.UseSelfColCheck->setChecked(pSim->IsSelfColEnabled());
ui.ColDampSlider->setEnabled(pSim->IsSelfColEnabled());
ui.ColDampSlider->setRange(0, 100);
ui.ColDampSlider->setValue(qRound(pSim->GetCollisionDampZ()*50));
ui.ColDampEdit->setText(QString::number(pSim->GetCollisionDampZ(), 'g', 3));
ui.UseMaxVelLimitCheck->setEnabled(!EqMode);
ui.MaxVelLimitSlider->setEnabled(!EqMode);
ui.UseMaxVelLimitCheck->setChecked(pSim->IsMaxVelLimitEnabled());
ui.MaxVelLimitSlider->setEnabled(pSim->IsMaxVelLimitEnabled());
ui.MaxVelLimitSlider->setRange(0, 100);
ui.MaxVelLimitSlider->setValue(qRound(pSim->GetMaxVoxVelLimit()*400));
//Env
ui.UseTempCheck->setChecked(ptEnv->IsTempEnabled());
ui.TempSlider->setRange(0, 50); //+/- 25 degrees from TempBase
ui.TempSlider->setValue(qRound(25 + ptEnv->GetTempAmplitude()));
ui.TempEdit->setText(QString::number(ptEnv->GetTempBase() + ptEnv->GetTempAmplitude(), 'g', 3));
ui.Temp2Slider->setRange(0, 50); //+/- 25 degrees from TempBase
ui.Temp2Slider->setValue(qRound(25 + ptEnv->GetTemp2Amplitude()));
ui.Temp2Edit->setText(QString::number(ptEnv->GetTempBase() + ptEnv->GetTemp2Amplitude(), 'g', 3));
ui.VaryTempCheck->setChecked(ptEnv->IsTempVaryEnabled());
ui.TempPerSlider->setRange(0, 10000);
ui.TempPerSlider->setValue(qRound(ptEnv->GetTempPeriod()/pSim->OptimalDt)); //slider range of 0-10,000 timesteps
ui.TempPerEdit->setText(QString::number(ptEnv->GetTempPeriod(), 'g', 3));
ui.UseGravCheck->setChecked(ptEnv->IsGravityEnabled());
ui.GravSlider->setRange(0, 10000);
ui.GravSlider->setValue(qRound(-ptEnv->GetGravityAccel()/0.00981)); //1e-5 takes care for float -> int rounding...
ui.GravEdit->setText(QString::number(ptEnv->GetGravityAccel(), 'g', 3));
ui.UseFloorCheck->setChecked(ptEnv->IsFloorEnabled());
// ui.SurfMeshCheck->setEnabled(false);
// if (pSim->SurfMesh.DefMesh.Exists()) ui.SurfMeshCheck->setEnabled(true);
//View
bool ViewEnabled = true;
switch (pSim->GetCurViewMode()){
case RVM_NONE: ui.DispDisableRadio->setChecked(true); ViewEnabled = false; break;
case RVM_VOXELS: ui.DispVoxelsRadio->setChecked(true); break;
case RVM_BONDS: ui.DispConnRadio->setChecked(true); break;
}
ui.ViewOptionsGroup->setEnabled(ViewEnabled);
ui.ColorGroup->setEnabled(ViewEnabled);
ui.CoMCheck->setEnabled(ViewEnabled);
// ui.BbCheck->setEnabled(ViewEnabled);
switch (pSim->GetCurViewVox()){
case RVV_DISCRETE: ui.ViewDiscreteRadio->setChecked(true); break;
case RVV_DEFORMED: ui.ViewDeformedRadio->setChecked(true); break;
case RVV_SMOOTH: ui.ViewSmoothRadio->setChecked(true); break;
}
ui.ForcesCheck->setChecked(pSim->ViewForce);
//.........这里部分代码省略.........
开发者ID:WPI-ARC,项目名称:soft_hand,代码行数:101,代码来源:Dlg_Physics.cpp
示例6: new_dmga_gene
//.........这里部分代码省略.........
MPI_Recv( &msg, // from MPI #3
sizeof( msg ),
MPI_BYTE,
MPI_ANY_SOURCE,
MPI_ANY_TAG,
my_communicator,
&status );
DbTimMsg("Worker after receive instructions");
max_rss();
if ( status.MPI_TAG == FINISHED )
{
DbgLv(0) << "Deme" << grp_nbr << deme_nbr
<< ": Finish signalled at deme generation" << generation + 1;
break;
}
// See if we are really done
if ( generation == generations - 1 )
{
DbgLv(0) << "Deme" << grp_nbr << deme_nbr
<< ": At last generation";
continue;
}
// Mark duplicate genes
int f0 = 0; // An index into the fitness array
int f1 = 1; // A second index
// The value of 1.0e-8 for close fitness is arbitrary. Parameterize?
const double NEAR_MATCH = 1.0e-8;
const double EPSF_SCALE = 1.0e-3;
double fitpwr = (double)qRound( log10( fitness[ 0 ].fitness ) );
double epsilon_f = pow( 10.0, fitpwr ) * EPSF_SCALE;
DbgLv(1) << "gw:" << my_rank << ": Dup best-gene clean: fitness0 fitpwr epsilon_f"
<< fitness[0].fitness << fitpwr << epsilon_f;
while ( f1 < population )
{
double fitdiff = qAbs( fitness[ f0 ].fitness - fitness[ f1 ].fitness );
if ( fitdiff < epsilon_f )
{
bool match = true;
int g0 = fitness[ f0 ].index;
int g1 = fitness[ f1 ].index;
DGene gene0 = dgenes[ g0 ];
DGene gene1 = dgenes[ g1 ];
for ( int ii = 0; ii < nfloatc; ii++ )
{
double val0;
double val1;
US_dmGA_Constraints::AttribType
atype = cns_flt[ ii ].atype;
int mcompx = cns_flt[ ii ].mcompx;
fetch_attr_value( val0, gene0, atype, mcompx );
fetch_attr_value( val1, gene1, atype, mcompx );
double difv = qAbs( ( val0 - val1 ) / val0 );
if ( difv > NEAR_MATCH )
{
DbgLv(1) << "gw:" << my_rank << ": Dup NOT cleaned: f0 f1 fit0 fit1"
开发者ID:svn2github,项目名称:UltraScan3,代码行数:67,代码来源:dmga_worker.cpp
示例7: qRound
//-------------------------------------------------------------------
void SkewTWindow::saveFileSYLK (SylkFile &slk)
{
int lig, col;
lig = 1;
slk.addCell (lig++, 1, "XyGrib - SkewT data");
if (! skewt) {
slk.addCell (lig++, 1, "No data");
return;
}
Sounding * snd = skewt->getSounding ();
if (! snd) {
slk.addCell (lig++, 1, "No data");
return;
}
//-------------------------------
slk.addCell (lig, 1, "Location");
slk.addCell (lig, 2, skewt->location);
lig ++;
slk.addCell (lig, 1, "Data center");
slk.addCell (lig, 2, skewt->datacenter);
lig ++;
slk.addCell (lig, 1, "Reference date");
slk.addCell (lig, 2, Util::formatDateTimeShort(skewt->dateref));
lig ++;
slk.addCell (lig, 1, "Current date");
slk.addCell (lig, 2, Util::formatDateTimeShort(skewt->date));
lig ++;
//-------------------------------
// Indices LI, SI, KI, TT, SWEAT, CAPE, CIN
lig++;
slk.addCell (lig, 1, "LI");
if (GribDataIsDef(snd->LI))
slk.addCell (lig, 2, qRound(snd->LI));
lig++;
slk.addCell (lig, 1, "SI");
if (GribDataIsDef(snd->SI))
slk.addCell (lig, 2, qRound(snd->SI));
lig++;
slk.addCell (lig, 1, "KI");
if (GribDataIsDef(snd->KI))
slk.addCell (lig, 2, qRound(snd->KI));
lig++;
slk.addCell (lig, 1, "TT");
if (GribDataIsDef(snd->TT))
slk.addCell (lig, 2, qRound(snd->TT));
lig++;
slk.addCell (lig, 1, "SWEAT");
if (GribDataIsDef(snd->SWEAT))
slk.addCell (lig, 2, qRound(snd->SWEAT));
lig++;
slk.addCell (lig, 1, "CAPE");
if (GribDataIsDef(snd->CAPE))
slk.addCell (lig, 2, qRound(snd->CAPE));
lig++;
slk.addCell (lig, 1, "CIN");
if (GribDataIsDef(snd->CIN))
slk.addCell (lig, 2, qRound(snd->CIN));
lig++;
lig++;
//-------------------------------
// Altitude data
QList <SoundingPoint> *allpts = snd->getAllSounds();
QList <SoundingPointWind> *allwinds = snd->getAllSoundsWind();
QList <double> allAlts;
for (const auto & allpt : *allpts) {
if (allpt.ok() && !allAlts.contains(allpt.hpa))
allAlts << allpt.hpa;
}
for (const auto & allwind : *allwinds) {
if (allwind.ok() && !allAlts.contains(allwind.hpa))
allAlts << allwind.hpa;
}
qSort (allAlts);
col = 1;
slk.addCell (lig, col++, "Altitude (hPa)");
slk.addCell (lig, col++, tr("Temperature")+" ("+Util::getDataUnit(GRB_TEMP)+")");
slk.addCell (lig, col++, tr("Dew point")+" ("+Util::getDataUnit(GRB_TEMP)+")");
slk.addCell (lig, col++, tr("Wind speed")+" ("+Util::getDataUnit(GRB_WIND_SPEED)+")");
slk.addCell (lig, col++, tr("Wind direction")+" ("+Util::getDataUnit(GRB_WIND_DIR)+")");
for (double alt : allAlts) {
lig ++;
col = 1;
slk.addCell (lig, col++, alt);
double v;
SoundingPointWind w;
v = snd->getTempCByAlt (alt);
if (GribDataIsDef(v))
slk.addCell (lig, col, Util::formatTemperature(v+273.15,false).toDouble());
col ++;
v = snd->getDewpCByAlt (alt);
if (GribDataIsDef(v))
slk.addCell (lig, col, Util::formatTemperature(v+273.15,false).toDouble());
col ++;
w = snd->getWindByAlt (alt);
if (w.ok())
//.........这里部分代码省略.........
开发者ID:norulz,项目名称:zyGrib,代码行数:101,代码来源:SkewTWindow.cpp
示例8: drawBackbone
/*!
Draw a tick
\param painter Painter
\param value Value of the tick
\param len Length of the tick
\sa drawBackbone(), drawLabel()
*/
void QwtScaleDraw::drawTick( QPainter *painter, double value, double len ) const
{
if ( len <= 0 )
return;
const bool roundingAlignment = QwtPainter::roundingAlignment( painter );
QPointF pos = d_data->pos;
double tval = scaleMap().transform( value );
if ( roundingAlignment )
tval = qRound( tval );
const int pw = penWidth();
int a = 0;
if ( pw > 1 && roundingAlignment )
a = 1;
switch ( alignment() )
{
case LeftScale:
{
double x1 = pos.x() + a;
double x2 = pos.x() + a - pw - len;
if ( roundingAlignment )
{
x1 = qRound( x1 );
x2 = qRound( x2 );
}
QwtPainter::drawLine( painter, x1, tval, x2, tval );
break;
}
case RightScale:
{
double x1 = pos.x();
double x2 = pos.x() + pw + len;
if ( roundingAlignment )
{
x1 = qRound( x1 );
x2 = qRound( x2 );
}
QwtPainter::drawLine( painter, x1, tval, x2, tval );
break;
}
case BottomScale:
{
double y1 = pos.y();
double y2 = pos.y() + pw + len;
if ( roundingAlignment )
{
y1 = qRound( y1 );
y2 = qRound( y2 );
}
QwtPainter::drawLine( painter, tval, y1, tval, y2 );
break;
}
case TopScale:
{
double y1 = pos.y() + a;
double y2 = pos.y() - pw - len + a;
if ( roundingAlignment )
{
y1 = qRound( y1 );
y2 = qRound( y2 );
}
QwtPainter::drawLine( painter, tval, y1, tval, y2 );
break;
}
}
}
开发者ID:XelaRellum,项目名称:qwt,代码行数:86,代码来源:qwt_scale_draw.cpp
示例9: drawTick
/*!
Draws the baseline of the scale
\param painter Painter
\sa drawTick(), drawLabel()
*/
void QwtScaleDraw::drawBackbone( QPainter *painter ) const
{
const bool doAlign = QwtPainter::roundingAlignment( painter );
const QPointF &pos = d_data->pos;
const double len = d_data->len;
const int pw = qMax( penWidth(), 1 );
// pos indicates a border not the center of the backbone line
// so we need to shift its position depending on the pen width
// and the alignment of the scale
double off;
if ( doAlign )
{
if ( alignment() == LeftScale || alignment() == TopScale )
off = ( pw - 1 ) / 2;
else
off = pw / 2;
}
else
{
off = 0.5 * penWidth();
}
switch ( alignment() )
{
case LeftScale:
{
double x = pos.x() - off;
if ( doAlign )
x = qRound( x );
QwtPainter::drawLine( painter, x, pos.y(), x, pos.y() + len );
break;
}
case RightScale:
{
double x = pos.x() + off;
if ( doAlign )
x = qRound( x );
QwtPainter::drawLine( painter, x, pos.y(), x, pos.y() + len );
break;
}
case TopScale:
{
double y = pos.y() - off;
if ( doAlign )
y = qRound( y );
QwtPainter::drawLine( painter, pos.x(), y, pos.x() + len, y );
break;
}
case BottomScale:
{
double y = pos.y() + off;
if ( doAlign )
y = qRound( y );
QwtPainter::drawLine( painter, pos.x(), y, pos.x() + len, y );
break;
}
}
}
开发者ID:XelaRellum,项目名称:qwt,代码行数:71,代码来源:qwt_scale_draw.cpp
示例10: getOrientedTargetSize
bool SizeFitter::fitIt(QSize size, QSize &fittedSize, QRect *clippedRect) const
{
float scaleFactor;
bool result;
QSize orientedTargetSize = getOrientedTargetSize(size);
// enlarge?
if (!isFitOptionEnabled(Enlarge) &&
size.width() <= orientedTargetSize.width() &&
size.height() <= orientedTargetSize.height()) {
fittedSize = size;
if (clippedRect != 0) {
clippedRect->setTopLeft(QPoint(0, 0));
clippedRect->setSize(fittedSize);
}
return false;
}
result = false;
if (size.width() > size.height()) {
// landscape
scaleFactor = (float)orientedTargetSize.width() / (float)size.width();
fittedSize.setWidth(qRound(size.width() * scaleFactor));
fittedSize.setHeight(qRound(size.height() * scaleFactor));
if (scaleFactor != 1.0f) {
result = true;
}
// the new height might still be too large...
if (fittedSize.height() > orientedTargetSize.height()) {
// ...so scale again
scaleFactor = (float)orientedTargetSize.height() / (float)fittedSize.height();
fittedSize.setWidth (qRound(fittedSize.width() * scaleFactor));
fittedSize.setHeight(qRound(fittedSize.height() * scaleFactor));
if (scaleFactor != 1.0f) {
result = true ;
}
}
} else {
// portrait
scaleFactor = (float)orientedTargetSize.height() / (float)size.height();
fittedSize.setWidth (qRound(size.width() * scaleFactor));
fittedSize.setHeight (qRound(size.height() * scaleFactor));
if (scaleFactor != 1.0f) {
result = true;
}
// the new width might still be too large...
if (fittedSize.width() > orientedTargetSize.width()) {
// ...so scale again
scaleFactor = (float)orientedTargetSize.width() / (float)fittedSize.width();
fittedSize.setWidth (qRound(fittedSize.width() * scaleFactor));
fittedSize.setHeight (qRound(fittedSize.height() * scaleFactor));
if (scaleFactor != 1.0f) {
result = true ;
}
}
}
if (clippedRect != 0) {
// no clipping, select entire image
clippedRect->setTopLeft(QPoint(0, 0));
clippedRect->setSize(size);
}
return result;
}
开发者ID:CharuChopra84,项目名称:screenie,代码行数:73,代码来源:SizeFitter.cpp
示例11: scaleDiv
/*!
\brief Determine the minimum border distance
This member function returns the minimum space
needed to draw the mark labels at the scale's endpoints.
\param font Font
\param start Start border distance
\param end End border distance
*/
void QwtScaleDraw::getBorderDistHint(
const QFont &font, int &start, int &end ) const
{
start = 0;
end = 1.0;
if ( !hasComponent( QwtAbstractScaleDraw::Labels ) )
return;
const QList<double> &ticks = scaleDiv().ticks( QwtScaleDiv::MajorTick );
if ( ticks.count() == 0 )
return;
// Find the ticks, that are mapped to the borders.
// minTick is the tick, that is mapped to the top/left-most position
// in widget coordinates.
double minTick = ticks[0];
double minPos = scaleMap().transform( minTick );
double maxTick = minTick;
double maxPos = minPos;
for ( int i = 1; i < ticks.count(); i++ )
{
const double tickPos = scaleMap().transform( ticks[i] );
if ( tickPos < minPos )
{
minTick = ticks[i];
minPos = tickPos;
}
if ( tickPos > scaleMap().transform( maxTick ) )
{
maxTick = ticks[i];
maxPos = tickPos;
}
}
double e = 0.0;
double s = 0.0;
if ( orientation() == Qt::Vertical )
{
s = -labelRect( font, minTick ).top();
s -= qAbs( minPos - qRound( scaleMap().p2() ) );
e = labelRect( font, maxTick ).bottom();
e -= qAbs( maxPos - scaleMap().p1() );
}
else
{
s = -labelRect( font, minTick ).left();
s -= qAbs( minPos - scaleMap().p1() );
e = labelRect( font, maxTick ).right();
e -= qAbs( maxPos - scaleMap().p2() );
}
if ( s < 0.0 )
s = 0.0;
if ( e < 0.0 )
e = 0.0;
start = qCeil( s );
end = qCeil( e );
}
开发者ID:XelaRellum,项目名称:qwt,代码行数:74,代码来源:qwt_scale_draw.cpp
示例12: qDebug
void RenderStatistics::updateStats()
{
static QTime time;
static int frames;
static int lastTime;
if (frames == 0) {
time.start();
} else {
int elapsed = time.elapsed();
timesPerFrames.append(elapsed - lastTime);
lastTime = elapsed;
if (elapsed > 5000) {
qreal avgtime = elapsed / (qreal) frames;
qreal var = 0;
for (int i = 0; i < timesPerFrames.size(); ++i) {
qreal diff = timesPerFrames.at(i) - avgtime;
var += diff * diff;
}
var /= timesPerFrames.size();
qDebug("Average time per frame: %f ms (%i fps), std.dev: %f ms", avgtime, qRound(1000. / avgtime), qSqrt(var));
timePerFrame.append(avgtime);
timesPerFrames.clear();
time.start();
lastTime = 0;
frames = 0;
}
}
++frames;
}
开发者ID:ghjinlei,项目名称:qt5,代码行数:33,代码来源:main.cpp
示例13: qRound
int Controller::countDialogsWidthFromRatio(int bodyWidth) const {
auto result = qRound(bodyWidth * Auth().settings().dialogsWidthRatio());
accumulate_max(result, st::columnMinimalWidthLeft);
// accumulate_min(result, st::columnMaximalWidthLeft);
return result;
}
开发者ID:Federated-Blockchains-Initiative,项目名称:tdesktop,代码行数:6,代码来源:window_controller.cpp
示例14: Q_ASSERT
void QSGTextMaskMaterialData::updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect)
{
Q_ASSERT(oldEffect == 0 || newEffect->type() == oldEffect->type());
QSGTextMaskMaterial *material = static_cast<QSGTextMaskMaterial *>(newEffect);
QSGTextMaskMaterial *oldMaterial = static_cast<QSGTextMaskMaterial *>(oldEffect);
if (oldMaterial == 0 || material->color() != oldMaterial->color() || state.isOpacityDirty()) {
QColor c = material->color();
QVector4D color(c.redF(), c.greenF(), c.blueF(), c.alphaF());
color *= state.opacity();
program()->setUniformValue(m_color_id, color);
if (oldMaterial == 0 || material->color() != oldMaterial->color()) {
state.context()->functions()->glBlendColor(c.redF(),
c.greenF(),
c.blueF(),
c.alphaF());
}
}
bool updated = material->ensureUpToDate();
Q_ASSERT(material->texture());
Q_ASSERT(oldMaterial == 0 || oldMaterial->texture());
if (updated
|| oldMaterial == 0
|| oldMaterial->texture()->textureId() != material->texture()->textureId()) {
program()->setUniformValue(m_textureScale_id, QVector2D(1.0 / material->cacheTextureWidth(),
1.0 / material->cacheTextureHeight()));
glBindTexture(GL_TEXTURE_2D, material->texture()->textureId());
// Set the mag/min filters to be nearest. We only need to do this when the texture
// has been recreated.
if (updated) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
}
if (state.isMatrixDirty()) {
QMatrix4x4 transform = state.modelViewMatrix();
qreal xTranslation = transform(0, 3);
qreal yTranslation = transform(1, 3);
// Remove translation and check identity to see if matrix is only translating.
// If it is, we can round the translation to make sure the text is pixel aligned,
// which is the only thing that works with GL_NEAREST filtering. Adding rotations
// and scales to native rendered text is not a prioritized use case, since the
// default rendering type is designed for that.
transform(0, 3) = 0.0;
transform(1, 3) = 0.0;
if (transform.isIdentity()) {
transform(0, 3) = qRound(xTranslation);
transform(1, 3) = qRound(yTranslation);
transform = state.projectionMatrix() * transform;
program()->setUniformValue(m_matrix_id, transform);
} else {
program()->setUniformValue(m_matrix_id, state.combinedMatrix());
}
}
}
开发者ID:SamuelNevala,项目名称:qtdeclarative,代码行数:62,代码来源:qsgdefaultglyphnode_p.cpp
示例15: Q_ASSERT
void QSGTextMaskMaterial::populate(const QPointF &p,
const QVector<quint32> &glyphIndexes,
const QVector<QPointF> &glyphPositions,
QSGGeometry *geometry,
QRectF *boundingRect,
QPointF *baseLine,
const QMargins &margins)
{
Q_ASSERT(m_font.isValid());
QVector<QFixedPoint> fixedPointPositions;
for (int i=0; i<glyphPositions.size(); ++i)
fixedPointPositions.append(QFixedPoint::fromPointF(glyphPositions.at(i)));
QTextureGlyphCache *cache = glyphCache();
QRawFontPrivate *fontD = QRawFontPrivate::get(m_font);
cache->populate(fontD->fontEngine, glyphIndexes.size(), glyphIndexes.constData(),
fixedPointPositions.data());
cache->fillInPendingGlyphs();
int margin = fontD->fontEngine->glyphMargin(cache->glyphFormat());
qreal glyphCacheScaleX = cache->transform().m11();
qreal glyphCacheScaleY = cache->transform().m22();
qreal glyphCacheInverseScaleX = 1.0 / glyphCacheScaleX;
qreal glyphCacheInverseScaleY = 1.0 / glyphCacheScaleY;
Q_ASSERT(geometry->indexType() == GL_UNSIGNED_SHORT);
geometry->allocate(glyphIndexes.size() * 4, glyphIndexes.size() * 6);
QVector4D *vp = (QVector4D *)geometry->vertexDataAsTexturedPoint2D();
Q_ASSERT(geometry->sizeOfVertex() == sizeof(QVector4D));
ushort *ip = geometry->indexDataAsUShort();
QPointF position(p.x(), p.y() - m_font.ascent());
bool supportsSubPixelPositions = fontD->fontEngine->supportsSubPixelPositions();
for (int i=0; i<glyphIndexes.size(); ++i) {
QFixed subPixelPosition;
if (supportsSubPixelPositions)
subPixelPosition = fontD->fontEngine->subPixelPositionForX(QFixed::fromReal(glyphPositions.at(i).x()));
QTextureGlyphCache::GlyphAndSubPixelPosition glyph(glyphIndexes.at(i), subPixelPosition);
const QTextureGlyphCache::Coord &c = cache->coords.value(glyph);
QPointF glyphPosition = glyphPositions.at(i) + position;
// On a retina screen the glyph positions are not pre-scaled (as opposed to
// eg. the raster paint engine). To ensure that we get the same behavior as
// the raster engine (and CoreText itself) when it comes to rounding of the
// coordinates, we need to apply the scale factor before rounding, and then
// apply the inverse scale to get back to the coordinate system of the node.
qreal x = (qFloor(glyphPosition.x() * glyphCacheScaleX) * glyphCacheInverseScaleX) +
(c.baseLineX * glyphCacheInverseScaleX) - margin;
qreal y = (qRound(glyphPosition.y() * glyphCacheScaleY) * glyphCacheInverseScaleY) -
(c.baseLineY * glyphCacheInverseScaleY) - margin;
qreal w = c.w * glyphCacheInverseScaleX;
qreal h = c.h * glyphCacheInverseScaleY;
*boundingRect |= QRectF(x + margin, y + margin, w, h);
float cx1 = x - margins.left();
float cx2 = x + w + margins.right();
float cy1 = y - margins.top();
float cy2 = y + h + margins.bottom();
float tx1 = c.x - margins.left();
float tx2 = c.x + c.w + margins.right();
float ty1 = c.y - margins.top();
float ty2 = c.y + c.h + margins.bottom();
if (baseLine->isNull())
*baseLine = glyphPosition;
vp[4 * i + 0] = QVector4D(cx1, cy1, tx1, ty1);
vp[4 * i + 1] = QVector4D(cx2, cy1, tx2, ty1);
vp[4 * i + 2] = QVector4D(cx1, cy2, tx1, ty2);
vp[4 * i + 3] = QVector4D(cx2, cy2, tx2, ty2);
int o = i * 4;
ip[6 * i + 0] = o + 0;
ip[6 * i + 1] = o + 2;
ip[6 * i + 2] = o + 3;
ip[6 * i + 3] = o + 3;
ip[6 * i + 4] = o + 1;
ip[6 * i + 5] = o + 0;
}
}
开发者ID:tizenorg,项目名称:platform.upstream.qtdeclarative,代码行数:88,代码来源:qsgdefaultglyphnode_p.cpp
示例16: QStringList
// Return the memory profile: used, available, total
int US_Memory::memory_profile( int* pMemA, int* pMemT, int* pMemU )
{
int memavail;
int memtotal;
int memused;
int memavpc;
#ifdef Q_OS_LINUX // Unix: use free command
QProcess qproc;
qproc.start( "free", QStringList() << "-m" );
qproc.waitForFinished( -1 );
QString totmem = QString( qproc.readAllStandardOutput() ).trimmed();
totmem = totmem.section( "\n", 1, 1 );
totmem.replace( QRegExp( "\\s+" ), " " );
qDebug() << " UsMEM:LINUX: totmem" << totmem;
int fmtotal = totmem.section( " ", 1, 1 ).toInt();
int fmused = totmem.section( " ", 2, 2 ).toInt();
int fmfree = totmem.section( " ", 3, 3 ).toInt();
int fmbuffer = totmem.section( " ", 5, 5 ).toInt();
int fmcache = totmem.section( " ", 6, 6 ).toInt();
qDebug() << " UsMEM:LINUX: fmtotal,used,free,buffer,cache" << fmtotal << fmused
<< fmfree << fmbuffer << fmcache;
memtotal = fmtotal;
memused = qMax( fmused, ( fmtotal - fmfree - fmcache ) );
memavail = memtotal - memused;
#endif
#ifdef Q_OS_MAC // Mac: use sysctl and rss_now()
const double mb_bytes = ( 1024. * 1024. );
const double kb_bytes = 1024.;
QProcess qproc;
qproc.start( "sysctl", QStringList() << "-n" << "hw.memsize" );
qproc.waitForFinished( -1 );
QString totmem = QString( qproc.readAllStandardOutput() ).trimmed();
memtotal = qRound( totmem.toDouble() / mb_bytes );
memused = qRound( (double)rss_now() / kb_bytes );
memavail = memtotal - memused;
qDebug() << " UsMEM:Mac: totme
|
请发表评论