void GridMap::move(const Eigen::Vector2d& position) { Array2i indexShift; Vector2d positionShift = position - position_; getIndexShiftFromPositionShift(indexShift, positionShift, resolution_); Vector2d alignedPositionShift; getPositionShiftFromIndexShift(alignedPositionShift, indexShift, resolution_); // Delete fields that fall out of map (and become empty cells). for (int i = 0; i < indexShift.size(); i++) { if (indexShift(i) != 0) { if (abs(indexShift(i)) >= getBufferSize()(i)) { // Entire map is dropped. clear(); } else { // Drop cells out of map. int sign = (indexShift(i) > 0 ? 1 : -1); int startIndex = bufferStartIndex_(i) - (sign < 0 ? 1 : 0); int endIndex = startIndex - sign + indexShift(i); int nCells = abs(indexShift(i)); int index = (sign > 0 ? startIndex : endIndex); mapIndexWithinRange(index, getBufferSize()(i)); if (index + nCells <= getBufferSize()(i)) { // One region to drop. if (i == 0) clearCols(index, nCells); if (i == 1) clearRows(index, nCells); } else { // Two regions to drop. int firstIndex = index; int firstNCells = getBufferSize()(i) - firstIndex; if (i == 0) clearCols(firstIndex, firstNCells); if (i == 1) clearRows(firstIndex, firstNCells); int secondIndex = 0; int secondNCells = nCells - firstNCells; if (i == 0) clearCols(secondIndex, secondNCells); if (i == 1) clearRows(secondIndex, secondNCells); } } } } // Update information. bufferStartIndex_ += indexShift; mapIndexWithinRange(bufferStartIndex_, getBufferSize()); position_ += alignedPositionShift; // if (indexShift.all() != 0) // TODO Move notifier to implementation. // ROS_DEBUG("Grid map has been moved to position (%f, %f).", position_.x(), position_.y()); }
void Screen::displayColorChart( void ) { Screen::repeatCh( 0, separatorRow-6, scBorder, 205, screenCols ); clearRows( separatorRow-5, 4 ); if ( (Screen::colorMode == false) || (ColorScheme == 1) ) { // Monochrome users - give them lables Screen::printf( 0, separatorRow-4, scNormal, "0 Wht 1 Black 2 Navy Bl 3 Grn 4 Red 5 Brown 6 Magenta 7 Orange" ); Screen::printf( 0, separatorRow-3, scNormal, "8 Yel 9 L Grn 10 Teal 11 L Cyan 12 L Bl 13 Pink 14 Gray 15 L Gray" ); } else { // Color users - give them example colors with numbers for ( int i=0; i < 16; i++ ) { Screen::printf( i*4+8, separatorRow-4, scNormal, " %2d ", i ); } for ( int i=0; i < 16; i++ ) { Screen::printf( i*4+8, separatorRow-3, mIRCtoCGAMap[i], "\xdb\xdb\xdb\xdb" ); } } Screen::repeatCh( 0, separatorRow-1, scBorder, 205, screenCols ); colorPopup = true; gotoxy( cur_x, cur_y2 ); }
TranscriptionComponent::~TranscriptionComponent() { retrainButton = nullptr; clearButton = nullptr; clearRows(); }
void RoxieOutputRowArray::kill() { clearRows(); maxRows = 0; ReleaseRoxieRow(rows); rows = NULL; }
void AddressBookImpl::refresh() { LOG_PRINT_L2("Refreshing addressbook"); clearRows(); // Fetch from Wallet2 and create vector of AddressBookRow objects std::vector<tools::wallet2::address_book_row> rows = m_wallet->m_wallet->get_address_book(); for (size_t i = 0; i < rows.size(); ++i) { tools::wallet2::address_book_row * row = &rows.at(i); std::string payment_id = (row->m_payment_id == crypto::null_hash)? "" : epee::string_tools::pod_to_hex(row->m_payment_id); std::string address = cryptonote::get_account_address_as_str(m_wallet->m_wallet->testnet(), row->m_is_subaddress, row->m_address); // convert the zero padded short payment id to integrated address if (!row->m_is_subaddress && payment_id.length() > 16 && payment_id.substr(16).find_first_not_of('0') == std::string::npos) { payment_id = payment_id.substr(0,16); crypto::hash8 payment_id_short; if(tools::wallet2::parse_short_payment_id(payment_id, payment_id_short)) { address = cryptonote::get_account_integrated_address_as_str(m_wallet->m_wallet->testnet(), row->m_address, payment_id_short); // Don't show payment id when integrated address is used payment_id = ""; } } AddressBookRow * abr = new AddressBookRow(i, address, payment_id, row->m_description); m_rows.push_back(abr); } }
BOOL LLComboBox::operateOnAll(EOperation op) { if (op == OP_DELETE) { clearRows(); return TRUE; } return FALSE; }
void t_RenderClass::moveDown() { corey--; if (!checkValid()) { corey++; makeStatic(); clearRows(); } }
void AnGenericRowProvider::setRowData(const std::vector<AnListClass *> &rowData) { clearRows(); std::vector<AnListClass *>::const_iterator it; for (it = rowData.begin(); it != rowData.end(); ++it) { addSubject(*it); allrows_.push_back(*it); } updateVisible(); }
void SubaddressAccountImpl::refresh() { LOG_PRINT_L2("Refreshing subaddress account"); clearRows(); for (uint32_t i = 0; i < m_wallet->m_wallet->get_num_subaddress_accounts(); ++i) { m_rows.push_back(new SubaddressAccountRow( i, m_wallet->m_wallet->get_subaddress_as_str({i,0}), m_wallet->m_wallet->get_subaddress_label({i,0}), cryptonote::print_money(m_wallet->m_wallet->balance(i)), cryptonote::print_money(m_wallet->m_wallet->unlocked_balance(i)) )); } }
TranscriptionComponent::TranscriptionComponent() { trainingColour = Colour(0xDDFECBCB); playingColour = Colour(0xDD999999); addAndMakeVisible(table); table.setModel(this); table.setColour (ListBox::outlineColourId, Colours::grey); table.setOutlineThickness (1); table.setColour(ListBox::backgroundColourId, Colour()); // Add Columns To Table table.getHeader().addColumn("Index", 1, 50, 50, 50, TableHeaderComponent::notResizableOrSortable, -1); table.getHeader().addColumn("Include", 2, 50, 50, 50, TableHeaderComponent::notResizableOrSortable, -1); table.getHeader().addColumn("Time", 3, 250, 250, 250, TableHeaderComponent::notResizableOrSortable, -1); table.getHeader().addColumn("Predicted Class", 4, 100, 100, 100, TableHeaderComponent::notResizableOrSortable, -1); table.getHeader().addColumn("Features", 5, 300, 300, 300, TableHeaderComponent::notResizableOrSortable, -1); table.getHeader().addColumn("Actual Class", 6, 100, 100, 100, TableHeaderComponent::notResizableOrSortable, -1); table.setColour(ListBox::backgroundColourId, Colour(playingColour)); // table.getHeader().setStretchToFitActive (true); addAndMakeVisible (retrainButton = new TextButton ("retrainButton")); retrainButton->setButtonText (TRANS("Update Training")); retrainButton->setConnectedEdges (Button::ConnectedOnLeft | Button::ConnectedOnRight); retrainButton->setColour (TextButton::buttonColourId, Colour (0xFF5B5B5B)); retrainButton->setColour (TextButton::buttonOnColourId, Colour (0xFF9A9A9A)); addAndMakeVisible (clearButton = new TextButton ("clearButton")); clearButton->setButtonText (TRANS("Clear Training")); clearButton->setConnectedEdges (Button::ConnectedOnLeft | Button::ConnectedOnRight); clearButton->setColour (TextButton::buttonColourId, Colour (0xFF5B5B5B)); clearButton->setColour (TextButton::buttonOnColourId, Colour (0xFF9A9A9A)); clearRows(); m_iNumClasses = 0; }
void BaseSqlTableModel::replaceRows( QVector<RowInfo>&& rows, TrackId2Rows&& trackIdToRows) { // NOTE(uklotzde): Use r-value references for parameters here, because // conceptually those parameters should replace the corresponding internal // member variables. Currently Qt4/5 doesn't support move semantics and // instead prevents unnecessary deep copying by implicit sharing (COW) // behind the scenes. Moving would be more efficient, although implicit // sharing meets all requirements. If Qt will ever add move support for // its container types in the future this code becomes even more efficient. DEBUG_ASSERT(rows.empty() == trackIdToRows.empty()); DEBUG_ASSERT(rows.size() >= trackIdToRows.size()); if (rows.isEmpty()) { clearRows(); } else { beginInsertRows(QModelIndex(), 0, rows.size() - 1); m_rowInfo = rows; m_trackIdToRows = trackIdToRows; endInsertRows(); } }
/* Take a Block object and place it into the placedBlocks array then check if any rows need to be cleared Returns the number of rows cleared (returned by clearRows) */ int Stage::placeBlock( Block *block ) { // Iterate through the block's bounds and place all chunks // that are occupied by the block into placedBlocks_ for( int x = -2; x < 2; x++ ) { for( int y = -1; y < 3; y++ ) { // check if the block occupies this spot if( block->intersects( block->x() + x, block->y() + y ) ) { // the block occupies these coords, so set placedBlocks accordingly placedBlocks_[block->y() + y][block->x() + x] = block->color(); } } } // Clear any rows that the block could have completed return clearRows( block->y() ); }
AddressBookImpl::~AddressBookImpl() { clearRows(); }
SubaddressAccountImpl::~SubaddressAccountImpl() { clearRows(); }
void SparseRowCpuMatrix::zeroMem() { apply([](real* buf, size_t len) { memset(buf, 0, sizeof(real) * len); }); clearRows(); }
void BaseSqlTableModel::select() { if (!m_bInitialized) { return; } // We should be able to detect when a select() would be a no-op. The DAO's // do not currently broadcast signals for when common things happen. In the // future, we can turn this check on and avoid a lot of needless // select()'s. rryan 9/2011 // if (!m_bDirty) { // if (sDebug) { // qDebug() << this << "Skipping non-dirty select()"; // } // return; // } if (sDebug) { qDebug() << this << "select()"; } PerformanceTimer time; time.start(); // Prepare query for id and all columns not in m_trackSource QString queryString = QString("SELECT %1 FROM %2 %3") .arg(m_tableColumnsJoined, m_tableName, m_tableOrderBy); if (sDebug) { qDebug() << this << "select() executing:" << queryString; } QSqlQuery query(m_database); // This causes a memory savings since QSqlCachedResult (what QtSQLite uses) // won't allocate a giant in-memory table that we won't use at all. query.setForwardOnly(true); if (!query.prepare(queryString)) { LOG_FAILED_QUERY(query); return; } if (!query.exec()) { LOG_FAILED_QUERY(query); return; } // Remove all the rows from the table after(!) the query has been // executed successfully. See Bug #1090888. // TODO(rryan) we could edit the table in place instead of clearing it? clearRows(); // The size of the result set is not known in advance for a // forward-only query, so we cannot reserve memory for rows // in advance. QVector<RowInfo> rowInfo; QSet<TrackId> trackIds; while (query.next()) { TrackId trackId(query.value(kIdColumn)); trackIds.insert(trackId); RowInfo thisRowInfo; thisRowInfo.trackId = trackId; // save rows where this currently track id is located thisRowInfo.order = rowInfo.size(); // Get all the table columns and store them in the hash for this // row-info section. thisRowInfo.metadata.reserve(m_tableColumns.size()); for (int i = 0; i < m_tableColumns.size(); ++i) { thisRowInfo.metadata << query.value(i); } rowInfo.push_back(thisRowInfo); } if (sDebug) { qDebug() << "Rows actually received:" << rowInfo.size(); } if (m_trackSource) { m_trackSource->filterAndSort(trackIds, m_currentSearch, m_currentSearchFilter, m_trackSourceOrderBy, m_sortColumns, m_tableColumns.size() - 1, &m_trackSortOrder); // Re-sort the track IDs since filterAndSort can change their order or mark // them for removal (by setting their row to -1). for (QVector<RowInfo>::iterator it = rowInfo.begin(); it != rowInfo.end(); ++it) { // If the sort is not a track column then we will sort only to // separate removed tracks (order == -1) from present tracks (order == // 0). Otherwise we sort by the order that filterAndSort returned to us. if (m_trackSourceOrderBy.isEmpty()) { it->order = m_trackSortOrder.contains(it->trackId) ? 0 : -1; } else { it->order = m_trackSortOrder.value(it->trackId, -1); } } } // RowInfo::operator< sorts by the order field, except -1 is placed at the // end so we can easily slice off rows that are no longer present. Stable // sort is necessary because the tracks may be in pre-sorted order so we // should not disturb that if we are only removing tracks. qStableSort(rowInfo.begin(), rowInfo.end()); TrackId2Rows trackIdToRows; for (int i = 0; i < rowInfo.size(); ++i) { const RowInfo& row = rowInfo[i]; if (row.order == -1) { // We've reached the end of valid rows. Resize rowInfo to cut off // this and all further elements. rowInfo.resize(i); break; } trackIdToRows[row.trackId].push_back(i); } // We're done! Issue the update signals and replace the master maps. replaceRows( std::move(rowInfo), std::move(trackIdToRows)); // Both rowInfo and trackIdToRows (might) have been moved and // must not be used afterwards! qDebug() << this << "select() took" << time.elapsed().debugMillisWithUnit() << m_rowInfo.size(); }
void NpcDialog::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "ok") { if (mActionState == NPC_ACTION_NEXT) { if (!PacketLimiter::limitPackets(PacketType::PACKET_NPC_NEXT)) return; nextDialog(); addText(std::string(), false); } else if (mActionState == NPC_ACTION_CLOSE || mActionState == NPC_ACTION_WAIT) { closeDialog(); } else if (mActionState == NPC_ACTION_INPUT) { std::string printText; // Text that will get printed // in the textbox switch (mInputState) { case NPC_INPUT_LIST: { if (gui) gui->resetClickCount(); const int selectedIndex = mItemList->getSelected(); if (selectedIndex >= static_cast<int>(mItems.size()) || selectedIndex < 0 || !PacketLimiter::limitPackets( PacketType::PACKET_NPC_INPUT)) { return; } unsigned char choice = static_cast<unsigned char>( selectedIndex + 1); printText = mItems[selectedIndex]; npcHandler->listInput(mNpcId, choice); break; } case NPC_INPUT_STRING: { if (!PacketLimiter::limitPackets( PacketType::PACKET_NPC_INPUT)) { return; } printText = mTextField->getText(); npcHandler->stringInput(mNpcId, printText); break; } case NPC_INPUT_INTEGER: { if (!PacketLimiter::limitPackets( PacketType::PACKET_NPC_INPUT)) { return; } printText = strprintf("%d", mIntField->getValue()); npcHandler->integerInput( mNpcId, mIntField->getValue()); break; } case NPC_INPUT_ITEM: { if (!PacketLimiter::limitPackets( PacketType::PACKET_NPC_INPUT)) { return; } std::string str; const int sz = mInventory->getNumberOfSlotsUsed(); if (sz == 0) { str = "0,0"; } else { const Item *item = mInventory->getItem(0); if (item) { str = strprintf("%d,%d", item->getId(), item->getColor()); } else { str = "0,0"; } for (int f = 1; f < sz; f ++) { str.append(";"); item = mInventory->getItem(f); if (item) { str.append(strprintf("%d,%d", item->getId(), item->getColor())); } else { str.append("0,0"); } } } // need send selected item npcHandler->stringInput(mNpcId, str); mInventory->clear(); break; } case NPC_INPUT_NONE: default: break; } if (mInputState != NPC_INPUT_ITEM) { // addText will auto remove the input layout addText(strprintf("> \"%s\"", printText.c_str()), false); } mNewText.clear(); } if (!mLogInteraction) mTextBox->clearRows(); } else if (eventId == "reset") { switch (mInputState) { case NPC_INPUT_STRING: mTextField->setText(mDefaultString); break; case NPC_INPUT_INTEGER: mIntField->setValue(mDefaultInt); break; case NPC_INPUT_ITEM: mInventory->clear(); break; case NPC_INPUT_NONE: case NPC_INPUT_LIST: default: break; } } else if (eventId == "inc") { mIntField->setValue(mIntField->getValue() + 1); } else if (eventId == "dec") { mIntField->setValue(mIntField->getValue() - 1); } else if (eventId == "clear") { switch (mInputState) { case NPC_INPUT_ITEM: mInventory->clear(); break; case NPC_INPUT_STRING: case NPC_INPUT_INTEGER: case NPC_INPUT_LIST: case NPC_INPUT_NONE: default: clearRows(); break; } } else if (eventId == "close") { if (mActionState == NPC_ACTION_INPUT) { switch (mInputState) { case NPC_INPUT_ITEM: npcHandler->stringInput(mNpcId, "0,0"); break; case NPC_INPUT_STRING: case NPC_INPUT_INTEGER: case NPC_INPUT_NONE: case NPC_INPUT_LIST: default: npcHandler->listInput(mNpcId, 255); break; } closeDialog(); } } else if (eventId == "add") { if (inventoryWindow) { const Item *const item = inventoryWindow->getSelectedItem(); if (item) { mInventory->addItem(item->getId(), item->getType(), 1, 1, item->getColor(), item->getIdentified(), item->getDamaged(), item->getFavorite(), Equipm_false, Equipped_false); } } } }