/****************************************************************************** * Modifies the particle object. ******************************************************************************/ PipelineStatus SliceModifier::modifyParticles(TimePoint time, TimeInterval& validityInterval) { QString statusMessage = tr("%n input particles", 0, inputParticleCount()); // Compute filter mask. boost::dynamic_bitset<> mask(inputParticleCount()); size_t numRejected = filterParticles(mask, time, validityInterval); size_t numKept = inputParticleCount() - numRejected; if(createSelection() == false) { statusMessage += tr("\n%n particles deleted", 0, numRejected); statusMessage += tr("\n%n particles remaining", 0, numKept); if(numRejected == 0) return PipelineStatus(PipelineStatus::Success, statusMessage); // Delete the rejected particles. deleteParticles(mask, numRejected); } else { statusMessage += tr("\n%n particles selected", 0, numRejected); statusMessage += tr("\n%n particles unselected", 0, numKept); ParticlePropertyObject* selProperty = outputStandardProperty(ParticleProperty::SelectionProperty); OVITO_ASSERT(mask.size() == selProperty->size()); boost::dynamic_bitset<>::size_type i = 0; for(int& s : selProperty->intRange()) s = mask.test(i++); selProperty->changed(); } return PipelineStatus(PipelineStatus::Success, statusMessage); }
Selection* Document::createSelection(const QRect ®ion) { Selection *s = createSelection(); s->set(region); emit madeSelection(region); return s; }
//---------------------------------------------------------------------------------------------------- void UIViewCreatorDataSource::addViewToCurrentEditView () { UIViewCreatorController* controller = dynamic_cast<UIViewCreatorController*> (getViewController (dataBrowser, true)); if (controller) { if (UIEditController* editController = dynamic_cast<UIEditController*>(controller->getBaseController ())) { SharedPointer<UISelection> selection = createSelection (); editController->addSelectionToCurrentView (selection); } } }
void SelectionController::createSelection(const sf::IntRect& rect, const sf::Image& image, const std::vector<nSet::o_line>& conf_l) { createSelection(rect, &image); setInverted(false); pos_lines = new nSet::positionned_olines(); pos_lines->lines = std::vector<nSet::o_line>(conf_l); pos_lines->pos = getPosition(); updateCadre(); UNDO->push(*new SelecUpdated(this, *image_selec, pos_lines->pos, *pos_lines, inverted)); emit selectionCreated(); }
void SelectionController::addSelection(const sf::IntRect& rect, const sf::Image& image, const std::vector<nSet::o_line>& conf_l) { if (isSelected()) { sumSelection(rect, &image, true); pos_lines = new nSet::positionned_olines(*pos_lines); pos_lines->lines.insert(pos_lines->lines.end(), conf_l.begin(), conf_l.end()); pos_lines->pos = getPosition(); if (!reline()) { UNDO->push(*new SelecUpdated(this, *image_selec, pos_lines->pos, *pos_lines, inverted)); emit selectionUpdated(1); } } else createSelection(rect, image, conf_l); }
//---------------------------------------------------------------------------------------------------- CMouseEventResult UIViewCreatorDataSource::dbOnMouseMoved (const CPoint& where, const CButtonState& buttons, int32_t row, int32_t column, CDataBrowser* browser) { if (mouseDownRow >= 0 && buttons.isLeftButton ()) { SharedPointer<UISelection> selection = createSelection (); CMemoryStream stream (1024, 1024, false); if (selection->store (stream, description)) { stream.end (); CDropSource* dropSource = new CDropSource (stream.getBuffer (), static_cast<uint32_t> (stream.tell ()), CDropSource::kText); browser->doDrag (dropSource); dropSource->forget (); } mouseDownRow = -1; } return kMouseEventNotHandled; }