#include "onf_stepselectclustersinlogs.h" #include "actions/onf_actionselectclustersinlogs.h" #include ONF_StepSelectClustersInLogs::ONF_StepSelectClustersInLogs() : SuperClass() { m_doc = nullptr; setManual(true); } QString ONF_StepSelectClustersInLogs::description() const { return tr("Sélection de clusters dans des billons"); } QString ONF_StepSelectClustersInLogs::detailledDescription() const { return tr(""); } QString ONF_StepSelectClustersInLogs::inputDescription() const { return SuperClass::inputDescription() + tr("

"); } QString ONF_StepSelectClustersInLogs::outputDescription() const { return SuperClass::outputDescription() + tr("

"); } QString ONF_StepSelectClustersInLogs::detailsDescription() const { return tr(""); } CT_VirtualAbstractStep* ONF_StepSelectClustersInLogs::createNewInstance() const { return new ONF_StepSelectClustersInLogs(); } //////////////////// PROTECTED METHODS ////////////////// void ONF_StepSelectClustersInLogs::declareInputModels(CT_StepInModelStructureManager& manager) { manager.addResult(_inResult, tr("Result")); manager.setZeroOrMoreRootGroup(_inResult, _inZeroOrMoreRootGroup); manager.addGroup(_inZeroOrMoreRootGroup, _inGroupLog); manager.addGroup(_inGroupLog, _inGroupCluster); manager.addItem(_inGroupCluster, _inItem, tr("Item")); } void ONF_StepSelectClustersInLogs::declareOutputModels(CT_StepOutModelStructureManager& manager) { manager.addResultCopy(_inResult); } void ONF_StepSelectClustersInLogs::fillPostInputConfigurationDialog(CT_StepConfigurableDialog* postInputConfigDialog) { Q_UNUSED(postInputConfigDialog) } void ONF_StepSelectClustersInLogs::compute() { m_doc = nullptr; m_status = 0; m_itemDrawableToAdd.clear(); QList groupsToRemove; // create a list of itemdrawable to add in the document for(CT_StandardItemGroup* groupLog : _inGroupLog.iterateOutputs(_inResult)) { if(isStopped()) break; quint64 logID = groupLog->id(); auto iterator = groupLog->groups(_inGroupCluster); for(const CT_StandardItemGroup* group_cluster : iterator) { const CT_AbstractSingularItemDrawable* item = group_cluster->singularItem(_inItem); if (item != nullptr) { m_itemDrawableToAdd.insert(item, group_cluster); m_clusterToLog.insert(item, logID); m_logToCluster.insert(logID, item); } } } // request the manual mode if(!isStopped()) requestManualMode(); // remove item selected from the list (to not remove them from the out result) QListIterator it(m_validatedItems); while(it.hasNext() && !isStopped()) { m_itemDrawableToAdd.remove(it.next()); } groupsToRemove.append(m_itemDrawableToAdd.values()); // we remove the parent group of all ItemDrawable that must be deleted from the out result // and all groups that don't contains a ItemDrawable researched QListIterator itE(groupsToRemove); while(itE.hasNext() && !isStopped()) { const CT_StandardItemGroup *group = itE.next(); const_cast(group)->setBeRemovedLater(true); } m_status = 1; if(!isStopped()) requestManualMode(); } void ONF_StepSelectClustersInLogs::initManualMode() { // create a new 3D document if(m_doc == nullptr) m_doc = guiContext()->documentManager()->new3DDocument(); m_validatedItems.clear(); m_doc->removeAllItemDrawable(); // TODO add async with GuiManagerInterface QHashIterator it(m_itemDrawableToAdd); while(it.hasNext()) { m_doc->addItemDrawable(*const_cast(it.next().key())); } // set the action (a copy of the action is added at all graphics view, and the action passed in parameter is deleted) m_doc->setCurrentAction(new ONF_ActionSelectClustersInLogs(&m_clusterToLog, &m_logToCluster, &m_validatedItems)); QMessageBox::information(nullptr, tr("Mode manuel"), tr("Bienvenue dans le mode manuel de cette " "étape de filtrage. Veuillez sélectionner les " "éléments dans la vue graphique puis valider en cliquant " "sur le pouce en haut de la fenêtre principale. Les éléments " "sélectionnés seront gardés dans le résultat de sortie."), QMessageBox::Ok); } void ONF_StepSelectClustersInLogs::useManualMode(bool quit) { if(m_status == 0) { if(quit) { } } else if(m_status == 1) { if(!quit) { m_doc = nullptr; quitManualMode(); } } }