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


C++ Scalar::labels方法代码示例

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


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

示例1: on_applyButton_clicked

void TimeAnalysisWidget::on_applyButton_clicked()
{
    bool low = _ui->lowRadioButton->isChecked();
    int numClusters = _ui->numClustersSpin->value();
    std::vector<Point*> &points = low?_lowPoints.data():_highPoints.data();

    std::vector<Point> centers;
    std::vector<int> assignment;
    PointClusterer::kmeans(PointClusterer::RANDOM,numClusters,
                           PointClusterer::EUCLIDEAN,
                           points, 10, centers, assignment);

    std::ostringstream ss;
    ss << "K-means " << numClusters << (low?" [low]":" [high]");
    Scalar *scalar = addScalar(ss.str());

    // create labels
    scalar->labels().clear();
    for (unsigned i=0; i<centers.size(); ++i) {
        ss.str("");
        ss << "Cluster [" << i << "]";
        scalar->labels().push_back(ss.str());
    }

    // assigne scalar values to points
    for (unsigned i=0; i<assignment.size(); ++i) {
        Point *p = _lowPoints.data()[i];
        p->setScalarValue(scalar, assignment[i]);
    }

    // refill combox
    fillScalarComboBox();
    _ui->colorByComboBox->setCurrentIndex(scalar->index());
}
开发者ID:Rambo2015,项目名称:TaxiVis,代码行数:34,代码来源:timeanalysiswidget.cpp

示例2: loadLowAndHighData

void TimeAnalysisWidget::loadLowAndHighData(std::string filename)
{
    std::string basename = filename.substr(0, filename.find_last_of('.'));    
    _highPoints.load(basename + ".high");

    //_lowPoints.load(basename + ".low");
    //_lowPoints.load(basename + ".low_normalized_cols");
//    _lowPoints.load(basename + ".low_normalized_rows");
    _lowPoints.load(basename + ".low_standarised");
    //_lowPoints.load(basename + ".low_unnormalized");

    // adding default scalars
    Scalar *noneScalar = addScalar("None");
    noneScalar->labels().push_back("None");

    Scalar *dayScalar = addScalar("Day");
    for (int i=0; i<7; ++i)
        dayScalar->labels().push_back(QDate::longDayName(i+1).toStdString());

    Scalar *wend_wdayScalar = addScalar("Weekend/Weekdays");
    wend_wdayScalar->labels().push_back("Weekdays");
    wend_wdayScalar->labels().push_back("Weekends");

    for (int i=0; i<_lowPoints.numPoints(); ++i) {
        Point *lp = _lowPoints.data()[i];
        Point *hp = _highPoints.data()[i];

        QDate d = lp->getDate();

        lp->setScalarValue(noneScalar, 0);
        lp->setScalarValue(dayScalar, d.dayOfWeek()-1);
        lp->setScalarValue(wend_wdayScalar, d.dayOfWeek()==6||d.dayOfWeek()==7);

        hp->setScalarValue(noneScalar, 0);
        hp->setScalarValue(dayScalar, d.dayOfWeek());
        hp->setScalarValue(wend_wdayScalar, d.dayOfWeek()==6||d.dayOfWeek()==7);
    }
}
开发者ID:Rambo2015,项目名称:TaxiVis,代码行数:38,代码来源:timeanalysiswidget.cpp


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