当前位置: 首页>>代码示例>>C++>>正文


C++ QwtDoubleInterval::width方法代码示例

本文整理汇总了C++中QwtDoubleInterval::width方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtDoubleInterval::width方法的具体用法?C++ QwtDoubleInterval::width怎么用?C++ QwtDoubleInterval::width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QwtDoubleInterval的用法示例。


在下文中一共展示了QwtDoubleInterval::width方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: syncScale

/*!
   Synchronize an axis scale according to the scale of the reference axis

  \param axis Axis index ( see QwtPlot::AxisId )
  \param reference Interval of the reference axis
  \param size Size of the canvas
*/
QwtDoubleInterval QwtPlotRescaler::syncScale(int axis, 
    const QwtDoubleInterval& reference, const QSize &size) const 
{
    double dist;
    if ( orientation(referenceAxis()) == Qt::Horizontal )
        dist = reference.width() / size.width();
    else
        dist = reference.width() / size.height();

    if ( orientation(axis) == Qt::Horizontal )
        dist *= size.width();
    else
        dist *= size.height();

    dist /= aspectRatio(axis);

    QwtDoubleInterval intv;
    if ( rescalePolicy() == Fitting )
        intv = intervalHint(axis);
    else
        intv = interval(axis);

    intv = expandInterval(intv, dist, expandingDirection(axis));

    return intv;
}
开发者ID:AlexKraemer,项目名称:RFID_ME_HW_GUI,代码行数:33,代码来源:qwt_plot_rescaler.cpp

示例2: pixelDist

double QwtPlotRescaler::pixelDist(int axis, const QSize &size) const
{
    const QwtDoubleInterval intv = intervalHint(axis);

    double dist = 0.0;
    if ( !intv.isNull() )
    {
        if ( axis == referenceAxis() )
            dist = intv.width();
        else
        {
            const double r = aspectRatio(axis);
            if ( r > 0.0 )
                dist = intv.width() * r;
        }
    }

    if ( dist > 0.0 )
    {
        if ( orientation(axis) == Qt::Horizontal )
           dist /= size.width();
        else
           dist /= size.height();
    }

    return dist;
}
开发者ID:AlexKraemer,项目名称:RFID_ME_HW_GUI,代码行数:27,代码来源:qwt_plot_rescaler.cpp

示例3: divideScale

/*!
   \brief Calculate a scale division

   \param x1 First interval limit 
   \param x2 Second interval limit 
   \param maxMajSteps Maximum for the number of major steps
   \param maxMinSteps Maximum number of minor steps
   \param stepSize Step size. If stepSize == 0, the scaleEngine
                   calculates one.

   \sa QwtScaleEngine::stepSize(), QwtScaleEngine::subDivide()
*/
QwtScaleDiv QwtLinearScaleEngine::divideScale(double x1, double x2,
    int maxMajSteps, int maxMinSteps, double stepSize) const
{
    QwtDoubleInterval interval = QwtDoubleInterval(x1, x2).normalized();
    if (interval.width() <= 0 )
        return QwtScaleDiv();

    stepSize = qwtAbs(stepSize);
    if ( stepSize == 0.0 )
    {
        if ( maxMajSteps < 1 )
            maxMajSteps = 1;

        stepSize = divideInterval(interval.width(), maxMajSteps);
    }

    QwtScaleDiv scaleDiv;

    if ( stepSize != 0.0 )
    {
        QwtValueList ticks[QwtScaleDiv::NTickTypes];
        buildTicks(interval, stepSize, maxMinSteps, ticks);

        scaleDiv = QwtScaleDiv(interval, ticks);
    }

    if ( x1 > x2 )
        scaleDiv.invert();

    return scaleDiv;
}
开发者ID:376473984,项目名称:pvb,代码行数:43,代码来源:qwt_scale_engine.cpp

示例4: divideScale

/*!
   \brief Calculate a scale division

   \param x1 First interval limit
   \param x2 Second interval limit
   \param maxMajSteps Maximum for the number of major steps
   \param maxMinSteps Maximum number of minor steps
   \param stepSize Step size. If stepSize == 0, the scaleEngine
                   calculates one.
*/
QwtScaleDiv ProbabilityScaleEngine::divideScale(double x1, double x2,
    int, int, double stepSize) const
{
    QwtDoubleInterval interval = QwtDoubleInterval(x1, x2).normalized();
    interval = interval.limited(1e-4, 99.999);

    if (interval.width() <= 0 )
        return QwtScaleDiv();

    stepSize = fabs(qRound(stepSize));
    if ( stepSize == 0.0 )
        stepSize = 1.0;

    QwtScaleDiv scaleDiv;
    if ( stepSize != 0.0 ){
        QwtValueList ticks[QwtScaleDiv::NTickTypes];
		buildTicks(interval, stepSize, ticks);
        scaleDiv = QwtScaleDiv(interval, ticks);
    }

    if ( x1 > x2 )
        scaleDiv.invert();

    return scaleDiv;
}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:35,代码来源:ProbabilityScaleEngine.cpp

示例5: insertLevel

void ColorMapEditor::insertLevel()
{
int row = table->currentRow();
QwtDoubleInterval range = QwtDoubleInterval(min_val, max_val);

double val = 0.5*(table->item(row, 0)->text().toDouble() + table->item(row - 1, 0)->text().toDouble());
double mapped_val = (val - min_val)/range.width();
QColor c = QColor(color_map.rgb(QwtDoubleInterval(0, 1), mapped_val));

table->blockSignals(true);
table->insertRow(row);

QTableWidgetItem *it = new QTableWidgetItem(QString::number(val));
table->setItem(row, 0, it);
		
it = new QTableWidgetItem(c.name());
it->setFlags(Qt::ItemFlags(!Qt::ItemIsEditable));
it->setBackground(QBrush(c));
it->setForeground(QBrush(c));
table->setItem(row, 1, it);
table->blockSignals(false);
	
enableButtons(table->currentRow(), 0);
updateColorMap();
}
开发者ID:highperformancecoder,项目名称:scidavis,代码行数:25,代码来源:ColorMapEditor.cpp

示例6: setColorMap

void ColorMapEditor::setColorMap(const QwtLinearColorMap& map)
{
scaleColorsBox->setChecked(map.mode() == QwtLinearColorMap::ScaledColors);

QwtArray <double> colors = map.colorStops();
int rows = (int)colors.size();
table->setRowCount(rows);
table->blockSignals(true);
	
for (int i = 0; i < rows; i++)
	{
	QwtDoubleInterval range = QwtDoubleInterval(min_val, max_val);
	double val = min_val + colors[i] * range.width();
		
	QTableWidgetItem *it = new QTableWidgetItem(QString::number(val));
    table->setItem(i, 0, it);
		
	QColor c = QColor(map.rgb(QwtDoubleInterval(0, 1), colors[i]));
	it = new QTableWidgetItem(c.name());
	it->setFlags(Qt::ItemFlags(!Qt::ItemIsEditable));
	it->setBackground(QBrush(c));
	it->setForeground(QBrush(c));
    table->setItem(i, 1, it);
	}
table->blockSignals(false);
	
color_map = map;
}
开发者ID:highperformancecoder,项目名称:scidavis,代码行数:28,代码来源:ColorMapEditor.cpp

示例7: normalize

/**
 * Normalize the value to the range[0,1]
 * @param interval :: The data range
 * @param value :: The data value
 * @returns The fraction along the given interval using the current scale type
 */
double MantidColorMap::normalize(const QwtDoubleInterval &interval,
                                 double value) const {
  // nan numbers have the property that nan != nan, treat nan as being invalid
  if (interval.isNull() || m_num_colors == 0 || boost::math::isnan(value))
    return m_nan;

  const double width = interval.width();
  if (width <= 0.0 || value <= interval.minValue())
    return 0.0;

  if (value >= interval.maxValue())
    return 1.0;

  double ratio(0.0);
  if (m_scale_type == GraphOptions::Linear) {
    ratio = (value - interval.minValue()) / width;
  } else if (m_scale_type == GraphOptions::Power) {
    ratio = (pow(value, m_nth_power) - pow(interval.minValue(), m_nth_power)) /
            (pow(interval.maxValue(), m_nth_power) -
             pow(interval.minValue(), m_nth_power));
  } else {
    // Assume log10 type
    // Have to deal with the possibility that a user has entered 0 as a minimum
    double minValue = interval.minValue();
    if (minValue < LOG_ZERO_CUTOFF) {
      minValue = 1.0;
    }
    ratio = std::log10(value / minValue) /
            std::log10(interval.maxValue() / minValue);
  }
  return ratio;
}
开发者ID:liyulun,项目名称:mantid,代码行数:38,代码来源:MantidColorMap.cpp

示例8: rgb

/*!
  Map a value of a given interval into a rgb value

  \param interval Range for all values
  \param value Value to map into a rgb value
*/
QRgb QwtLinearColorMap::rgb(
    const QwtDoubleInterval &interval, double value) const
{
    const double width = interval.width();

    double ratio = 0.0;
    if ( width > 0.0 )
        ratio = (value - interval.minValue()) / width;

    return d_data->colorStops.rgb(d_data->mode, ratio);
}
开发者ID:9DSmart,项目名称:apm_planner,代码行数:17,代码来源:qwt_color_map.cpp

示例9: contains

/*!
  Check if an interval "contains" a value

  \param interval Interval
  \param value Value

  \sa QwtScaleArithmetic::compareEps()
*/
bool QwtScaleEngine::contains(
    const QwtDoubleInterval &interval, double value) const
{
    if (!interval.isValid() )
        return false;
    
    if ( QwtScaleArithmetic::compareEps(value, 
        interval.minValue(), interval.width()) < 0 )
    {
        return false;
    }

    if ( QwtScaleArithmetic::compareEps(value, 
        interval.maxValue(), interval.width()) > 0 )
    {
        return false;
    }

    return true;
}
开发者ID:376473984,项目名称:pvb,代码行数:28,代码来源:qwt_scale_engine.cpp

示例10: rgb

/*!
  Map a value of a given interval into a rgb value

  \param interval Range for all values
  \param value Value to map into a rgb value
*/
QRgb LinearTransparentColorMap::rgb(
    const QwtDoubleInterval& interval, double value) const
{
    const double width = interval.width();

    double ratio = 0.0;
    if (width > 0.0)
        ratio = (value - interval.minValue()) / width;
    if (ratio < 0)
        return qRgba(0, 0, 0, 0);
    return d_data->colorStops.rgb(d_data->mode, ratio);
}
开发者ID:Debilski,项目名称:Wellenprogramm,代码行数:18,代码来源:color_maps.cpp

示例11: divideScale

/*!
   \brief Calculate a scale division

   \param x1 First interval limit 
   \param x2 Second interval limit 
   \param maxMajSteps Maximum for the number of major steps
   \param maxMinSteps Maximum number of minor steps
   \param stepSize Step size. If stepSize == 0, the scaleEngine
                   calculates one.

   \sa QwtScaleEngine::stepSize, LogTimeScaleEngine::subDivide
*/
QwtScaleDiv LogTimeScaleEngine::divideScale(double x1, double x2,
    int maxMajSteps, int maxMinSteps, double stepSize) const
{
    QwtDoubleInterval interval = QwtDoubleInterval(x1, x2).normalized();
    interval = interval.limited(LOG_MIN, LOG_MAX);

    if (interval.width() <= 0 )
        return QwtScaleDiv();

    if (interval.maxValue() / interval.minValue() < 10.0)
    {
        // scale width is less than one decade -> build linear scale
    
        QwtLinearScaleEngine linearScaler;
        linearScaler.setAttributes(attributes());
        linearScaler.setReference(reference());
        linearScaler.setMargins(
                                #if (QWT_VERSION >= 0x050200)
				lowerMargin(), upperMargin()
				#else
				loMargin(), hiMargin()
				#endif
				);

        return linearScaler.divideScale(x1, x2, 
            maxMajSteps, maxMinSteps, stepSize);
    }

    stepSize = qwtAbs(stepSize);
    if ( stepSize == 0.0 )
    {
        if ( maxMajSteps < 1 )
            maxMajSteps = 1;

        stepSize = divideInterval(log10(interval).width(), maxMajSteps);
        if ( stepSize < 1.0 )
            stepSize = 1.0; // major step must be >= 1 decade
    }

    QwtScaleDiv scaleDiv;
    if ( stepSize != 0.0 )
    {
        QwtValueList ticks[QwtScaleDiv::NTickTypes];
        buildTicks(interval, stepSize, maxMinSteps, ticks);

        scaleDiv = QwtScaleDiv(interval, ticks);
    }

    if ( x1 > x2 )
        scaleDiv.invert();

    return scaleDiv;
}
开发者ID:bodylinksystems,项目名称:GoldenCheetah,代码行数:65,代码来源:LogTimeScaleEngine.cpp

示例12: expandScale

/*!
  Calculate the new scale interval of a plot axis

  \param axis Axis index ( see QwtPlot::AxisId )
  \param oldSize Previous size of the canvas
  \param newSize New size of the canvas

  \return Calculated new interval for the axis
*/
QwtDoubleInterval QwtPlotRescaler::expandScale( int axis,
    const QSize &oldSize, const QSize &newSize) const
{
    const QwtDoubleInterval oldInterval = interval(axis);

    QwtDoubleInterval expanded = oldInterval;
    switch(rescalePolicy())
    {
        case Fixed:
        {
            break; // do nothing
        }
        case Expanding:
        {
            if ( !oldSize.isEmpty() )
            {
                double width = oldInterval.width();
                if ( orientation(axis) == Qt::Horizontal )
                    width *= double(newSize.width()) / oldSize.width();
                else
                    width *= double(newSize.height()) / oldSize.height();

                expanded = expandInterval(oldInterval, 
                    width, expandingDirection(axis));
            }
            break;
        }
        case Fitting:
        {
            double dist = 0.0;
            for ( int ax = 0; ax < QwtPlot::axisCnt; ax++ )
            {
                const double d = pixelDist(ax, newSize);
                if ( d > dist )
                    dist = d;
            }
            if ( dist > 0.0 )
            {
                double width;
                if ( orientation(axis) == Qt::Horizontal )
                    width = newSize.width() * dist;
                else
                    width = newSize.height() * dist;

                expanded = expandInterval(intervalHint(axis), 
                    width, expandingDirection(axis));
            }
            break;
        }
    }

    return expanded;
}
开发者ID:AlexKraemer,项目名称:RFID_ME_HW_GUI,代码行数:62,代码来源:qwt_plot_rescaler.cpp

示例13: colorIndex

/*!
   Build and return a color map of 256 colors

   The color table is needed for rendering indexed images in combination
   with using colorIndex().

   \param interval Range for the values
   \return A color table, that can be used for a QImage
*/
QwtColorTable QwtColorMap::colorTable(
    const QwtDoubleInterval &interval) const
{
    QwtColorTable table(256);

    if ( interval.isValid() ) {
        const double step = interval.width() / (table.size() - 1);
        for ( int i = 0; i < (int) table.size(); i++ )
            table[i] = rgb(interval, interval.minValue() + step * i);
    }

    return table;
}
开发者ID:9DSmart,项目名称:apm_planner,代码行数:22,代码来源:qwt_color_map.cpp

示例14: updateColorMap

void ColorMapEditor::updateColorMap()
{
  int rows = table->rowCount();
  QColor c_min = QColor(table->item(0, 1)->text());
  QColor c_max = QColor(table->item(rows - 1, 1)->text());
  QwtLinearColorMap map(c_min, c_max);
  for (int i = 1; i < rows-1; i++){
    QwtDoubleInterval range = QwtDoubleInterval(min_val, max_val);
    double val = (((DoubleSpinBox*)table->cellWidget(i, 0))->value() - min_val)/range.width();
    map.addColorStop (val, QColor(table->item(i, 1)->text()));
  }

  color_map = map;
  setScaledColors(scaleColorsBox->isChecked());
}
开发者ID:Mantid-Test-Account,项目名称:mantid,代码行数:15,代码来源:ColorMapEditor.cpp

示例15: buildMajorTicks

QwtValueList QwtLinearScaleEngine::buildMajorTicks(
    const QwtDoubleInterval &interval, double stepSize) const
{
    int numTicks = qRound(interval.width() / stepSize) + 1;
    if ( numTicks > 10000 )
        numTicks = 10000;

    QwtValueList ticks;

    ticks += interval.minValue();
    for (int i = 1; i < numTicks - 1; i++)
        ticks += interval.minValue() + i * stepSize;
    ticks += interval.maxValue();

    return ticks;
}
开发者ID:376473984,项目名称:pvb,代码行数:16,代码来源:qwt_scale_engine.cpp


注:本文中的QwtDoubleInterval::width方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。