本文整理汇总了C++中Selection::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Selection::begin方法的具体用法?C++ Selection::begin怎么用?C++ Selection::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Selection
的用法示例。
在下文中一共展示了Selection::begin方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: newItemsInspected
void InspectorPanel::newItemsInspected(const Selection& objects)
{
// Ignore items in both
// Create items in objects and not in current
// Delete items in current and not in objects
Selection toCreate, toDelete;
std::set_difference(objects.begin(), objects.end(),
m_currentSel.begin(), m_currentSel.end(),
std::inserter(toCreate, toCreate.begin()));
std::set_difference(m_currentSel.begin(), m_currentSel.end(),
objects.begin(), objects.end(),
std::inserter(toDelete, toDelete.begin()));
for(const auto& object : toDelete)
{
auto widget_it = m_map.get<0>().find(object);
if(widget_it != m_map.get<0>().end())
{
(*widget_it)->deleteLater();
*m_map.get<0>().erase(widget_it);
}
}
for(const auto& object : toCreate)
{
auto widget = InspectorWidgetList::makeInspectorWidget(object->objectName(),
object,
m_tabWidget);
m_tabWidget->addTab(widget, widget->tabName());
m_map.insert(widget);
}
m_currentSel = objects;
}
示例2: avgFlatten
void TerrainImpl::avgFlatten(const Selection& selection, float intensity)
{
// add by 王宏张 2007-7-25
// 计算平均高度
float avgHeiht = 0.0f;
for(Selection::const_iterator iter = selection.begin() ; iter != selection.end() ; ++iter)
{
if(size_t(iter->first.getX() + selection.getPosition().getX()) >= mInfo->getWidth()
|| size_t(iter->first.getY() + selection.getPosition().getY()) >= mInfo->getHeight())
continue;
float height = mInfo->at(size_t(iter->first.getX() + selection.getPosition().getX())
, size_t(iter->first.getY() + selection.getPosition().getY()));
avgHeiht += height;
}
avgHeiht /= selection.size();
for(Selection::const_iterator iter = selection.begin() ; iter != selection.end() ; ++iter)
{
if(size_t(iter->first.getX() + selection.getPosition().getX()) >= mInfo->getWidth()
|| size_t(iter->first.getY() + selection.getPosition().getY()) >= mInfo->getHeight())
continue;
float& height = mInfo->at(size_t(iter->first.getX() + selection.getPosition().getX())
, size_t(iter->first.getY() + selection.getPosition().getY()));
height = avgHeiht; // avgFlatten算法
}
updateTiles(selection.getMin().getX(), selection.getMin().getY(), selection.getMax().getX(), selection.getMax().getY());
}
示例3: setSelection
void PropertyTreeModel::setSelection(const Selection& selection)
{
deselectAll();
Selection::const_iterator it;
for(it = selection.begin(); it != selection.end(); ++it){
const TreePath& path = *it;
PropertyRow* row = rowFromPath(path);
if(row)
selectRow(row, true, false);
}
}
开发者ID:NightOwlsEntertainment,项目名称:PetBox_A_Journey_to_Conquer_Elementary_Algebra,代码行数:11,代码来源:PropertyTreeModel.cpp
示例4: AnnounceSelectedSetChanged
void BaseGrid::AnnounceSelectedSetChanged(const Selection &lines_added, const Selection &lines_removed) {
if (batch_level > 0) {
// Remove all previously added lines that are now removed
Selection temp;
set_difference(batch_selection_added, lines_removed, temp);
std::swap(temp, batch_selection_added);
temp.clear();
// Remove all previously removed lines that are now added
set_difference(batch_selection_removed, lines_added, temp);
std::swap(temp, batch_selection_removed);
// Add new stuff to batch sets
batch_selection_added.insert(lines_added.begin(), lines_added.end());
batch_selection_removed.insert(lines_removed.begin(), lines_removed.end());
}
else {
SubtitleSelectionController::AnnounceSelectedSetChanged(lines_added, lines_removed);
}
}
示例5: deform
void TerrainImpl::deform(const Selection& selection, float intensity)
{
for(Selection::const_iterator iter = selection.begin() ; iter != selection.end() ; iter ++)
{
if(size_t(iter->first.getX() + selection.getPosition().getX()) >= mInfo->getWidth()
|| size_t(iter->first.getY() + selection.getPosition().getY()) >= mInfo->getHeight())
continue;
float& height = mInfo->at(size_t(iter->first.getX() + selection.getPosition().getX())
, size_t(iter->first.getY() + selection.getPosition().getY()));
height += intensity * iter->second;
}
updateTiles(selection.getMin().getX(), selection.getMin().getY(), selection.getMax().getX(), selection.getMax().getY());
}
示例6: updateComposition_
void TFCompositeModifier::updateComposition_(){
Selection selection = manager_.getComposition();
clearLayout_();
bool recalculate = false;
M4D::Common::TimeStamp lastChange;
Editor* editor;
Composition newComposition;
Composition::iterator found;
for(Selection::iterator it = selection.begin(); it != selection.end(); ++it)
{
found = composition_.find(*it);
if(found == composition_.end())
{
editor = new Editor(editors_.find(*it)->second);
newComposition.insert(std::make_pair<TF::Size, Editor*>(
*it,
editor)
);
recalculate = true;
}
else
{
lastChange = found->second->editor->lastChange();
if(found->second->change != lastChange)
{
recalculate = true;
found->second->change = lastChange;
}
editor = found->second;
editor->updateName();
newComposition.insert(*found);
composition_.erase(found);
}
layout_->addWidget(editor->name);
}
layout_->addItem(pushUpSpacer_);
if(!composition_.empty()) recalculate = true;
for(Composition::iterator it = composition_.begin(); it != composition_.end(); ++it)
{
layout_->removeWidget(it->second->name);
delete it->second;
}
composition_.swap(newComposition);
if(recalculate) computeResultFunction_();
}
示例7: RecombineLines
/// @brief Recombine
void SubtitlesGrid::RecombineLines() {
using namespace std;
Selection selectedSet = GetSelectedSet();
if (selectedSet.size() < 2) return;
AssDialogue *activeLine = GetActiveLine();
vector<AssDialogue*> sel;
sel.reserve(selectedSet.size());
copy(selectedSet.begin(), selectedSet.end(), back_inserter(sel));
for_each(sel.begin(), sel.end(), trim_text);
sort(sel.begin(), sel.end(), &AssFile::CompStart);
typedef vector<AssDialogue*>::iterator diag_iter;
diag_iter end = sel.end() - 1;
for (diag_iter cur = sel.begin(); cur != end; ++cur) {
AssDialogue *d1 = *cur;
diag_iter d2 = cur + 1;
// 1, 1+2 (or 2+1), 2 gets turned into 1, 2, 2 so kill the duplicate
if (d1->Text == (*d2)->Text) {
expand_times(d1, *d2);
delete d1;
context->ass->Line.remove(d1);
continue;
}
// 1, 1+2, 1 turns into 1, 2, [empty]
if (d1->Text.empty()) {
delete d1;
context->ass->Line.remove(d1);
continue;
}
// If d2 is the last line in the selection it'll never hit the above test
if (d2 == end && (*d2)->Text.empty()) {
delete *d2;
context->ass->Line.remove(*d2);
continue;
}
// 1, 1+2
while (d2 <= end && (*d2)->Text.StartsWith(d1->Text, &(*d2)->Text)) {
expand_times(*d2, d1);
trim_text(*d2);
++d2;
}
// 1, 2+1
while (d2 <= end && (*d2)->Text.EndsWith(d1->Text, &(*d2)->Text)) {
expand_times(*d2, d1);
trim_text(*d2);
++d2;
}
// 1+2, 2
while (d2 <= end && d1->Text.EndsWith((*d2)->Text, &d1->Text)) {
expand_times(d1, *d2);
trim_text(d1);
++d2;
}
// 2+1, 2
while (d2 <= end && d1->Text.StartsWith((*d2)->Text, &d1->Text)) {
expand_times(d1, *d2);
trim_text(d1);
++d2;
}
}
// Remove now non-existent lines from the selection
Selection lines;
transform(context->ass->Line.begin(), context->ass->Line.end(), inserter(lines, lines.begin()), cast<AssDialogue*>());
Selection newSel;
set_intersection(lines.begin(), lines.end(), selectedSet.begin(), selectedSet.end(), inserter(newSel, newSel.begin()));
if (newSel.empty())
newSel.insert(*lines.begin());
// Restore selection
if (!newSel.count(activeLine))
activeLine = *newSel.begin();
SetSelectionAndActive(newSel, activeLine);
context->ass->Commit(_("combining"), AssFile::COMMIT_DIAG_ADDREM | AssFile::COMMIT_DIAG_FULL);
}
示例8: UpdateMaps
void BaseGrid::UpdateMaps(bool preserve_selected_rows) {
BeginBatch();
int active_row = line_index_map[active_line];
std::vector<int> sel_rows;
if (preserve_selected_rows) {
sel_rows.reserve(selection.size());
transform(selection.begin(), selection.end(), back_inserter(sel_rows),
[this](AssDialogue *diag) { return GetDialogueIndex(diag); });
}
index_line_map.clear();
line_index_map.clear();
for (auto curdiag : context->ass->Line | agi::of_type<AssDialogue>()) {
line_index_map[curdiag] = (int)index_line_map.size();
index_line_map.push_back(curdiag);
}
if (preserve_selected_rows) {
Selection sel;
// If the file shrank enough that no selected rows are left, select the
// last row
if (sel_rows.empty())
sel_rows.push_back(index_line_map.size() - 1);
else if (sel_rows[0] >= (int)index_line_map.size())
sel_rows[0] = index_line_map.size() - 1;
for (int row : sel_rows) {
if (row >= (int)index_line_map.size()) break;
sel.insert(index_line_map[row]);
}
SetSelectedSet(sel);
}
else {
Selection lines;
copy(index_line_map.begin(), index_line_map.end(), inserter(lines, lines.begin()));
Selection new_sel;
// Remove lines which no longer exist from the selection
set_intersection(selection.begin(), selection.end(),
lines.begin(), lines.end(),
inserter(new_sel, new_sel.begin()));
SetSelectedSet(new_sel);
}
// Force a reannounce of the active line if it hasn't changed, as it isn't
// safe to touch the active line while processing a commit event which would
// cause this function to be called
AssDialogue *line = active_line;
active_line = 0;
// The active line may have ceased to exist; pick a new one if so
if (line_index_map.size() && line_index_map.find(line) == line_index_map.end()) {
if (active_row < (int)index_line_map.size()) {
SetActiveLine(index_line_map[active_row]);
}
else if (preserve_selected_rows && !selection.empty()) {
SetActiveLine(index_line_map[sel_rows[0]]);
}
else {
SetActiveLine(index_line_map.back());
}
}
else {
SetActiveLine(line);
}
if (selection.empty() && active_line) {
Selection sel;
sel.insert(active_line);
SetSelectedSet(sel);
}
EndBatch();
SetColumnWidths();
Refresh(false);
}