void CKLBUIScore::execute(u32 deltaT) { deltaT = deltaT; // Avoid Warning bool useFloat = CHANGE_B; s32 fDot = 0; int column; if (useFloat) { m_pScoreNode->setScoreFloat(m_fValue, m_fPrec, true); if (!m_bFillZero) { column = countColumn(m_pScoreNode->getScore()); fDot = 1; } } else { int value = m_value; if(m_bCountClip && value >= m_maxvalue) value = m_maxvalue - 1; m_pScoreNode->setScore(value, true); column = countColumn(value); // 桁数をカウント } m_pScoreNode->setPriority(m_order); m_pScoreNode->update(); if(!m_bFillZero) { int offX; int offY; int stepX = m_stepX; int stepY = m_stepY; int max_cols = m_column; int dotStepX = (m_dotStepX * fDot); int dotStepY = (m_dotStepY * fDot); if(column > max_cols) { column = max_cols; } switch(m_align) { default: case ALIGN_RIGHT: offX = 0; offY = 0; break; case ALIGN_CENTER: offX = ((m_width - stepX * column) + dotStepX) / 2; offY = ((m_height - stepY * column) + dotStepY) / 2; break; case ALIGN_LEFT: offX = (m_width - (stepX * column)) + dotStepX; offY = (m_height - (stepY * column)) + dotStepY; break; } m_pScoreNode->setTranslate(-offX, -offY); } RESET_A; RESET_B; }
bool verifyFileConsistency(const char *filename) { std::ifstream ifs(filename); if (!ifs) { return false; } std::string line; std::getline(ifs, line); size_t ncol = countColumn(line); while (std::getline(ifs, line)) { if (countColumn(line) != ncol + 1) return false; } return true; }
void HistogramTablesFormatter::QueryHistogram(unsigned typeIndex, std::vector<HistogramItem> &histogram) { casacore::Table &table(getTable(HistogramCountTable, false)); const unsigned nrRow = table.nrow(); casacore::ROScalarColumn<int> typeColumn(table, ColumnNameType); casacore::ROScalarColumn<double> binStartColumn(table, ColumnNameBinStart); casacore::ROScalarColumn<double> binEndColumn(table, ColumnNameBinEnd); casacore::ROScalarColumn<double> countColumn(table, ColumnNameCount); for(unsigned i=0;i<nrRow;++i) { if(typeColumn(i) == (int) typeIndex) { HistogramItem item; item.binStart = binStartColumn(i); item.binEnd = binEndColumn(i); item.count = countColumn(i); histogram.push_back(item); } } }
void HistogramTablesFormatter::StoreValue(unsigned typeIndex, double binStart, double binEnd, double count) { openCountTable(true); unsigned newRow = _countTable->nrow(); _countTable->addRow(); casacore::ScalarColumn<int> typeColumn(*_countTable, ColumnNameType); casacore::ScalarColumn<double> binStartColumn(*_countTable, ColumnNameBinStart); casacore::ScalarColumn<double> binEndColumn(*_countTable, ColumnNameBinEnd); casacore::ScalarColumn<double> countColumn(*_countTable, ColumnNameCount); typeColumn.put(newRow, typeIndex); binStartColumn.put(newRow, binStart); binEndColumn.put(newRow, binEnd); countColumn.put(newRow, count); }
static std::vector<WP> readWaypoint(const char *filename) { std::ifstream ifs(filename); std::string line; std::getline(ifs, line); // Remove first line size_t ncol = countColumn(line); std::vector<WP> waypoints; if (ncol == 3) { while (std::getline(ifs, line)) { waypoints.push_back(parseWaypoint(line, false)); } size_t last = waypoints.size() - 1; for (size_t i = 0; i < waypoints.size(); ++i) { double yaw; if (i == last) { yaw = atan2(waypoints[i-1].pose.position.y - waypoints[i].pose.position.y, waypoints[i-1].pose.position.x - waypoints[i].pose.position.x); yaw -= M_PI; } else { yaw = atan2(waypoints[i+1].pose.position.y - waypoints[i].pose.position.y, waypoints[i+1].pose.position.x - waypoints[i].pose.position.x); } waypoints[i].pose.orientation = tf::createQuaternionMsgFromYaw(yaw); } } else if (ncol == 4) { while (std::getline(ifs, line)) { waypoints.push_back(parseWaypoint(line, true)); } } return waypoints; }