/** @cond doxygenLibsbmlInternal */ IdList* SBMLLevelVersionConverter::collectSpeciesReferenceIds() { IdList* srids = new IdList(); for (unsigned int i = 0; i < mDocument->getModel()->getNumReactions(); i++) { Reaction *r = mDocument->getModel()->getReaction(i); for (unsigned int j = 0; j < r->getNumReactants(); j++) { if (r->getReactant(j)->isSetId()) { srids->append(r->getReactant(j)->getId()); } } for (unsigned int j = 0; j < r->getNumProducts(); j++) { if (r->getProduct(j)->isSetId()) { srids->append(r->getProduct(j)->getId()); } } } return srids; }
void CreateRemoveCommandImplementation::removeOne(ElementInfo &element) { if (element.id() == element.logicalId()) { mLogicalApi.removeReferencesTo(element.id()); mLogicalApi.removeReferencesFrom(element.id()); mLogicalApi.removeElement(element.id()); mGraphicalApi.removeElement(element.id()); } else { element.setAllGraphicalProperties(mGraphicalApi.properties(element.id())); if (!mLogicalApi.logicalRepoApi().exist(element.logicalId())) { mGraphicalApi.removeElement(element.id()); return; } element.setAllLogicalProperties(mGraphicalApi.properties(element.logicalId())); const IdList graphicalIds = mGraphicalApi.graphicalIdsByLogicalId(element.logicalId()); mGraphicalApi.removeElement(element.id()); // Checking that the only graphical part is our element itself // (bijection between graphical and logical parts) if (graphicalIds.count() == 1 && graphicalIds[0] == element.id()) { mLogicalApi.removeReferencesTo(element.logicalId()); mLogicalApi.removeReferencesFrom(element.logicalId()); mLogicalApi.removeElement(element.logicalId()); } } }
int QWizardContainer::currentIndex() const { const IdList idList = m_wizard->pageIds(); const int currentId = m_wizard->currentId(); const int rc = idList.empty() ? -1 : idList.indexOf(currentId); return rc; }
void CreateRemoveCommandImplementation::remove() { if (mIsFromLogicalModel) { mLogicalApi.removeReferencesTo(mId); mLogicalApi.removeReferencesFrom(mId); mLogicalApi.removeElement(mId); mGraphicalApi.removeElement(mId); } else { mGraphicalPropertiesSnapshot = mGraphicalApi.properties(mId); const Id logicalId = mGraphicalApi.logicalId(mId); if (!mLogicalApi.logicalRepoApi().exist(logicalId)) { mGraphicalApi.removeElement(mId); refreshAllPalettes(); return; } mOldLogicalId = logicalId; mLogicalPropertiesSnapshot = mGraphicalApi.properties(logicalId); const IdList graphicalIds = mGraphicalApi.graphicalIdsByLogicalId(logicalId); mGraphicalApi.removeElement(mId); // Checking that the only graphical part is our element itself // (bijection between graphical and logical parts) if (graphicalIds.count() == 1 && graphicalIds[0] == mId) { mLogicalApi.removeReferencesTo(logicalId); mLogicalApi.removeReferencesFrom(logicalId); mLogicalApi.removeElement(logicalId); } } refreshAllPalettes(); }
void SubprogramBlock::run() { const Id logicalId = mGraphicalModelApi->logicalId(id()); const QString name = mLogicalModelApi->name(logicalId); const QString validName = utils::NameNormalizer::normalizeStrongly(name, false); if (validName.isEmpty()) { error(tr("Please enter valid c-style name for subprogram \"") + name + "\""); return; } const QList<DynamicParameter> parameters = dynamicParameters(); for (const DynamicParameter ¶m : parameters) { if (param.type == "bool") { setVariableValue<bool>(param.name, evalCode<bool>(param.code)); } else if (param.type == "int") { setVariableValue<int>(param.name, evalCode<int>(param.code)); } else if (param.type == "float") { setVariableValue<qreal>(param.name, evalCode<qreal>(param.code)); } else { setVariableValue<QString>(param.name, evalCode<QString>(param.code)); } } const Id logicalDiagram = mLogicalModelApi->logicalRepoApi().outgoingExplosion(logicalId); const IdList diagrams = mGraphicalModelApi->graphicalIdsByLogicalId(logicalDiagram); if (!diagrams.isEmpty()) { emit stepInto(diagrams[0]); } }
IdList Repository::findElementsByName(const QString &name, bool sensitivity, bool regExpression) const { const Qt::CaseSensitivity caseSensitivity = sensitivity ? Qt::CaseSensitive : Qt::CaseInsensitive; const QRegExp regExp(name, caseSensitivity); IdList result; if (regExpression){ for (Object * const element : mObjects.values()) { if (element->property("name").toString().contains(regExp) && !isLogicalId(mObjects.key(element))) { result.append(mObjects.key(element)); } } } else { for (Object * const element : mObjects.values()) { if (element->property("name").toString().contains(name, caseSensitivity) && !isLogicalId(mObjects.key(element))) { result.append(mObjects.key(element)); } } } return result; }
qReal::IdList Repository::elementsByPropertyContent(const QString &propertyValue, bool sensitivity , bool regExpression) const { const Qt::CaseSensitivity caseSensitivity = sensitivity ? Qt::CaseSensitive : Qt::CaseInsensitive; const QRegExp regExp(propertyValue, caseSensitivity); IdList result; for (Object * const element : mObjects.values()) { QMapIterator<QString, QVariant> iterator = element->propertiesIterator(); if (regExpression) { while (iterator.hasNext()) { if (iterator.next().value().toString().contains(regExp)) { result.append(mObjects.key(element)); break; } } } else { while (iterator.hasNext()) { if (iterator.next().value().toString().contains(propertyValue, caseSensitivity)) { result.append(mObjects.key(element)); break; } } } } return result; }
void ConstraintBase::ModifyToSatisfy() { if(type == Type::ANGLE) { Vector a = SK.GetEntity(entityA)->VectorGetNum(); Vector b = SK.GetEntity(entityB)->VectorGetNum(); if(other) a = a.ScaledBy(-1); if(workplane.v != EntityBase::FREE_IN_3D.v) { a = a.ProjectVectorInto(workplane); b = b.ProjectVectorInto(workplane); } double c = (a.Dot(b))/(a.Magnitude() * b.Magnitude()); valA = acos(c)*180/PI; } else { // We'll fix these ones up by looking at their symbolic equation; // that means no extra work. IdList<Equation,hEquation> l = {}; // Generate the equations even if this is a reference dimension GenerateReal(&l); ssassert(l.n == 1, "Expected constraint to generate a single equation"); // These equations are written in the form f(...) - d = 0, where // d is the value of the valA. valA += (l.elem[0].e)->Eval(); l.Clear(); } }
IdList GraphicalModelAssistApi::graphicalIdsByLogicalId(Id const &logicalId) const { IdList result; QList<QPersistentModelIndex> indexes = mGraphicalModel.indexesWithLogicalId(logicalId); foreach (QPersistentModelIndex index, indexes) { result.append(idByIndex(index)); }
bool Block::initNextBlocks() { if (id().isNull() || id() == Id::rootId()) { error(tr("Control flow break detected, stopping")); return false; } const IdList links = mGraphicalModelApi->graphicalRepoApi().outgoingLinks(id()); if (links.count() > 1) { error(tr("Too many outgoing links")); return false; } if (links.count() == 0) { error(tr("No outgoing links, please connect this block to something or use Final Node to end program")); return false; } if (links.count() == 1) { const Id nextBlockId = mGraphicalModelApi->graphicalRepoApi().otherEntityFromLink(links[0], id()); if (nextBlockId.isNull() || nextBlockId == Id::rootId()) { error(tr("Outgoing link is not connected")); return false; } mNextBlockId = nextBlockId; } return true; }
QString JavaHandler::generateToJava(QString const &pathToDir) { mErrorText = ""; this->pathToDir = pathToDir; Id repoId = ROOT_ID; if (checkTheModel()) { IdList allDiagrams = mApi.children(repoId); IdList classDiagrams; //separate just class diagrams, because they are the main diagrams, others are connected foreach (Id const aDiagram, allDiagrams) { if (objectType(aDiagram) == "ClassDiagram_ClassDiagramNode") { classDiagrams.append(aDiagram); } if (objectType(aDiagram) == "ActivityDiagram_ActivityDiagramNode") { //If there is no connected Class Methods it won't be serialized IdList incomingConnections = mApi.incomingConnections(aDiagram); if (incomingConnections.isEmpty()) { addError("Unable to serialize object " + objectType(aDiagram) + " with type: " + aDiagram.toString() + ". It is not connected to some class method."); } } } foreach (Id const classDiagram, classDiagrams) { serializeChildren(classDiagram); } }
bool QueueEditor::EditEntry(DownloadQueue* downloadQueue, int ID, DownloadQueue::EEditAction action, int offset, const char* text) { m_downloadQueue = downloadQueue; IdList cIdList; cIdList.push_back(ID); return InternEditList(nullptr, &cIdList, action, offset, text); }
void ConstraintBase::ModifyToSatisfy(void) { if(type == ANGLE) { Vector a = SK.GetEntity(entityA)->VectorGetNum(); Vector b = SK.GetEntity(entityB)->VectorGetNum(); if(other) a = a.ScaledBy(-1); if(workplane.v != EntityBase::FREE_IN_3D.v) { a = a.ProjectVectorInto(workplane); b = b.ProjectVectorInto(workplane); } double c = (a.Dot(b))/(a.Magnitude() * b.Magnitude()); valA = acos(c)*180/PI; } else { // We'll fix these ones up by looking at their symbolic equation; // that means no extra work. IdList<Equation,hEquation> l; // An uninit IdList could lead us to free some random address, bad. ZERO(&l); // Generate the equations even if this is a reference dimension GenerateReal(&l); if(l.n != 1) oops(); // These equations are written in the form f(...) - d = 0, where // d is the value of the valA. valA += (l.elem[0].e)->Eval(); l.Clear(); } }
IdList RefactoringApplier::elementsFromBlock(QString const &blockType) const { IdList list; IdList resultList; IdList const refactoringElements = mRefactoringRepoApi->children(Id::rootId()); foreach (Id const &refactoringElement, refactoringElements) { if (mRefactoringRepoApi->isGraphicalElement(refactoringElement)) { if (refactoringElement.element() == "RefactoringDiagramNode") { list = mRefactoringRepoApi->children(refactoringElement); foreach (Id const &id, list) { if (id.element() == blockType) { resultList.append(mRefactoringRepoApi->children(id)); break; } } foreach (Id const &id, list) { if (id.element() == "Link" && resultList.contains(toInRule(id)) && resultList.contains(fromInRule(id))) { resultList.append(id); } } } } }
IdList RefactoringApplier::applyElementsTo() { IdList result; for (int i = 0; i < mApply->size(); ++i) { result.append(mApply->at(i).second); } return result; }
/******************************************************************* * Function Name: join ********************************************************************/ string Ini::join( IdList &id ) { string s(""); for (Ini::IdList::const_iterator cursor = id.begin(); cursor != id.end(); cursor++) s += *cursor; return s; }
void DraggableElement::checkElementForChildren() { mIsRootDiagramNode = false; const IdList children = mEditorManagerProxy.children(mDeletedElementId); if (!children.isEmpty()) { QString childrenNames; foreach (const Id child, children) { childrenNames += " " + mEditorManagerProxy.friendlyName(child) + ","; }
QWidget *QWizardContainer::widget(int index) const { QWidget *rc = 0; if (index >= 0) { const IdList idList = m_wizard->pageIds(); if (index < idList.size()) rc = m_wizard->page(idList.at(index)); } return rc; }
IdList GraphicalModelAssistApi::graphicalIdsByLogicalId(const Id &logicalId) const { IdList result; QList<QPersistentModelIndex> indexes = mGraphicalModel.indexesWithLogicalId(logicalId); for (const QPersistentModelIndex &index : indexes) { result.append(idByIndex(index)); } return result; }
void MultipleRemoveCommand::setItemsToDelete(IdList &itemsToDelete) { IdList itemsToUpdate; addEdgesToBeDeleted(itemsToDelete); // QGraphicsScene::selectedItems() returns items in no particular order, // so we should handle parent-child relationships manually while (!itemsToDelete.isEmpty()) { const Id currentItem = itemsToDelete.at(0); const IdList children = mGraphicalApi.children(currentItem); foreach (const Id &child, children) { itemsToDelete.removeAll(child); // Child remove commands will be added in currentItem delete command } const bool isEdge = !mLogicalApi.editorManagerInterface().isGraphicalElementNode(currentItem); if (isEdge) { const Id src = mGraphicalApi.from(currentItem); if (src != Id() && !itemsToUpdate.contains(src)) { itemsToUpdate.append(src); } const Id dst = mGraphicalApi.to(currentItem); if (dst != Id() && !itemsToUpdate.contains(dst)) { itemsToUpdate.append(dst); } insertPreAction(graphicalDeleteCommand(currentItem), 0); } else { addPreAction(graphicalDeleteCommand(currentItem)); } itemsToDelete.removeAll(currentItem); }
IdList VisualInterpreterUnit::allRules() const { IdList const elements = elementsFromActiveDiagram(); IdList result; foreach (Id const &element, elements) { if (element.element() == "SemanticsRule") { result.append(element); } } return result; }
bool LoopElementGenerator::nextElementsGeneration() { IdList const outgoingLinks = mNxtGen->api()->outgoingLinks(mElementId); Q_ASSERT(outgoingLinks.size() == 2); int elementConnectedByIterationEdgeNumber = -1; int afterLoopElementNumber = -1; if (mNxtGen->api()->stringProperty(mNxtGen->api()->logicalId(outgoingLinks.at(0)), "Guard").toUtf8() == "итерация") { elementConnectedByIterationEdgeNumber = 0; afterLoopElementNumber = 1; } else { elementConnectedByIterationEdgeNumber = 1; afterLoopElementNumber = 0; } //generate loop Id const loopNextElement = mNxtGen->api()->to(outgoingLinks.at(elementConnectedByIterationEdgeNumber)); if (loopNextElement == Id::rootId()) { mNxtGen->errorReporter().addError("Loop block " + mElementId.toString() + " has no correct loop branch!"\ " May be you need to connect it to some diagram element.", mElementId); return false; } AbstractElementGenerator* const loopGen = ElementGeneratorFactory::generator(mNxtGen , loopNextElement, *mNxtGen->api()); mNxtGen->previousElement() = mElementId; mNxtGen->previousLoopElements().push(mElementId); if (!loopGen->generate()) { return false; } delete loopGen; //generate next blocks Id const nextBlockElement = mNxtGen->api()->to(outgoingLinks.at(afterLoopElementNumber)); if (nextBlockElement == Id::rootId()) { mNxtGen->errorReporter().addError("Loop block " + mElementId.toString() + " has no correct next block branch!"\ " May be you need to connect it to some diagram element.", mElementId); return false; } AbstractElementGenerator* nextBlocksGen = ElementGeneratorFactory::generator(mNxtGen , nextBlockElement, *mNxtGen->api()); mNxtGen->previousElement() = mElementId; mNxtGen->previousLoopElements().push(mElementId); if (!nextBlocksGen->generate()) { return false; } delete nextBlocksGen; return true; }
QString join(IdList ids) { QString result; if (ids.isEmpty()) return result; result = QString::number(ids.takeFirst()); foreach (auto id, ids) result += QLatin1Literal(",") % QString::number(id); return result; }
void PaletteToolbox::addSortedItemTypes(EditorManager &editman, const Id &diagram) { mEditorManager = &editman; IdList list = editman.elements(diagram); qSort(list.begin(), list.end(), idLessThan); foreach (const Id element, list) addItemType(element, editman.friendlyName(element) , editman.description(element), editman.icon(element)); }
bool DummyBlock::initNextBlocks() { IdList const links = mGraphicalModelApi->graphicalRepoApi().outgoingLinks(id()); if (links.count() == 0) { mNextBlockId = Id(); } else { mNextBlockId = mGraphicalModelApi->graphicalRepoApi().otherEntityFromLink(links[0], id()); } return true; }
IdList Repository::idsOfAllChildrenOf(Id id) const { IdList result; result.clear(); result.append(id); IdList list = mObjects[id]->children(); for (const Id &childId : list) { result.append(idsOfAllChildrenOf(childId)); } return result; }
IdList TestReparentingStrategy::getParents(const QModelIndex &sourceChildIndex, const IdList &ignore) { if (!sourceChildIndex.isValid()) { kWarning() << "invalid index"; return IdList(); } if (sourceChildIndex.data(ParentListRole).canConvert<IdList>()) { IdList list = sourceChildIndex.data(ParentListRole).value<IdList>(); foreach (Id toRemove, ignore) { list.removeAll(toRemove); }
void BadUserDialog::GetIds(IdList &theList) { ListArea *aList = mIsSimple?mSimpleUserList.get():mUserList.get(); theList.clear(); aList->RewindSelections(); while(aList->HasMoreSelections()) { BadUserItem *anItem = (BadUserItem *)aList->GetNextSelection(); theList.push_back(anItem->mColInt[1]); } }
bool LoopElementGenerator::preGenerationCheck() { IdList const outgoingLinks = mNxtGen->api()->outgoingLinks(mElementId); if ((outgoingLinks.size() != 2) || ((mNxtGen->api()->property(mNxtGen->api()->logicalId(outgoingLinks.at(0)), "Guard").toString() == "итерация") && (mNxtGen->api()->property(mNxtGen->api()->logicalId(outgoingLinks.at(1)), "Guard").toString() == "итерация") ) ) { return false; } return true; }
void RulesChecker::checkFinalNodeRule(qReal::Id const &node) { bool isLastNode = isEndNode(node); if (!isLastNode && !isStartNode(node)) { return; } IdList incorrectLinks = (isLastNode) ? outgoingSequenceFlow(node) : incomingSequenceFlow(node); if (!incorrectLinks.isEmpty()) { postError((isLastNode) ? linkFromFinalNode : linkToStartNode, node); foreach (Id const &key, incorrectLinks) { mDiagramElements.removeOne(key); }