本文整理汇总了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());
}
示例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);
}
}