PartGroup* Sheet::addPartGroup(int firstPart, int lastPart) { Q_ASSERT( firstPart >= 0 && firstPart < partCount() ); Q_ASSERT( lastPart >= 0 && lastPart < partCount() ); PartGroup *group = new PartGroup(this, firstPart, lastPart); d->partGroups.append(group); return group; }
//-------------------------------------------------------------------------------------------------- /// Get the part at the given index //-------------------------------------------------------------------------------------------------- Part* ModelBasicTreeNode::part(uint index) { CVF_ASSERT(m_partList.notNull()); CVF_ASSERT(index < partCount()); return m_partList->part(index); }
//-------------------------------------------------------------------------------------------------- /// Returns the first part found with the given name. NULL if not found. //-------------------------------------------------------------------------------------------------- Part* ModelBasicTreeNode::findPartByName(String name) { if (m_partList.notNull()) { uint numParts = partCount(); uint i; for (i = 0; i < numParts; i++) { Part* p = m_partList->part(i); CVF_ASSERT(p); if (p->name() == name) { return p; } } } uint numChildren = childCount(); uint i; for (i = 0; i < numChildren; i++) { ModelBasicTreeNode* c = child(i); CVF_ASSERT(c); Part* p = c->findPartByName(name); if (p) { return p; } } return NULL; }
void Sheet::insertPart(int before, Part* part) { Q_ASSERT( before >= 0 && before <= partCount() ); Q_ASSERT( part ); part->setParent(this); d->parts.insert(before, part); emit partAdded(before, part); }
Part* Sheet::insertPart(int before, const QString& name) { Q_ASSERT( before >= 0 && before <= partCount() ); Part* part = new Part(this, name); d->parts.insert(before, part); emit partAdded(before, part); return part; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- cvf::BoundingBox RigFemPartCollection::boundingBox() const { cvf::BoundingBox bBox; for (int i = 0; i < partCount(); i++) { bBox.add(part(i)->boundingBox()); } return bBox; }
void Sheet::removePart(int index, bool deletePart) { Q_ASSERT( index >= 0 && index < partCount() ); Part* part = d->parts.takeAt(index); emit partRemoved(index, part); if (deletePart) { delete part; } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- float RigFemPartCollection::characteristicElementSize() { if (partCount()) { return part(0)->characteristicElementSize(); } else { return 0; } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- size_t RigFemPartCollection::totalElementCount() const { size_t elementCount = 0; for (int i = 0; i < partCount(); i++) { elementCount += part(i)->elementCount(); } return elementCount; }
StaffSystem* Sheet::staffSystem(int index) { Q_ASSERT( index >= 0 ); int idx = d->staffSystems.size(); qreal ssHeight = 0; if (partCount() > 0) { Part* prt = part(partCount() - 1); ssHeight = prt->staff(prt->staffCount() - 1)->bottom() + 30; } while (index >= d->staffSystems.size()) { StaffSystem *ss = new StaffSystem(this); ss->setHeight(ssHeight); if (idx > 0 && partCount() > 0) { Part* prt = part(partCount() - 1); ss->setTop(d->staffSystems[idx-1]->top() + prt->staff(prt->staffCount() - 1)->bottom() + 30); } d->staffSystems.append(ss); idx++; } return d->staffSystems[index]; }
/* Make the version a full three version numbers by adding ".0" */ static char *completeVersion(cchar *version, cchar *fill) { char *pre, *result; int count; if (!version || smatch(version, "*")) { version = fill; } count = partCount(version); result = sclone(version); if ((pre = schr(result, '-')) != 0) { *pre++ = '\0'; } while (count++ < 3) { result = sjoin(result, ".", fill, NULL); } if (pre) { result = sjoin(result, "-", pre, NULL); } return result; }
static bool inRange(MprVersion *vp, cchar *expr) { char *cp, *ver, *op, *base, *pre, *all; cchar *high, *low; uint64 factor, min, max, num; while (isspace((uchar) *expr)) expr++; if (srmatch(expr, semExpr, &all, &op, &ver, NULL) <= 0) { mprLog("error", 5, "Bad version expression: %s", expr); return 0; } if (smatch(op, "~")) { /* ~VER Compatible with VER at the level of specificity given. ~1.2.3 == (>=1.2.3 <1.3.0) Compatible at the patch level ~1.2 == 1.2.x Compatible at the minor level ~1 == 1.x Compatible at the major level */ if (partCount(ver) == 3 && (cp = srchr(ver, '.')) != 0) { high = sjoin(snclone(ver, cp - ver), ".", MAX_VER_STR, NULL); if ((cp = schr(ver, '-')) != 0) { high = sjoin(high, cp, NULL); } return inRange(vp, sjoin(">=", ver, NULL)) && inRange(vp, sjoin("<", high, NULL)); } return inRange(vp, completeVersion(ver, "x")); } if (smatch(op, "^")) { /* ^VER Compatible with VER at the most significant level. ^0.2.3 == 0.2.3 <= VER < 0.3.0 ^1.2.3 == 1.2.3 <= VER < 2.0.0 So convert to a range */ high = ver; for (cp = ver, factor = VER_FACTOR * VER_FACTOR; *cp; cp++) { if (*cp == '.') { factor /= VER_FACTOR; } else if (isdigit((uchar) *cp) && *cp != '0') { num = (stoi(cp) + 1) * factor; high = numberToVersion(num); if ((cp = schr(ver, '-')) != 0) { high = sjoin(high, cp, NULL); } break; } } return inRange(vp, sjoin(">=", ver, NULL)) && inRange(vp, sjoin("<", high, NULL)); } ver = completeVersion(ver, "x"); if (srmatch(ver, semCriteria, &all, &base, &pre, NULL) <= 0) { mprLog("error", 5, "Cannot match version %s", ver); return 0; } if (vp->preVersion) { if (!pre) { return 0; } if (snumber(vp->preVersion)) { if (stoi(pre) < stoi(vp->preVersion)) { return 0; } } else { if (scmp(pre, vp->preVersion) < 0 && !smatch(pre, "-")) { return 0; } } } min = 0; max = MAX_VER * VER_FACTOR * VER_FACTOR; if (schr(ver, 'x')) { if (smatch(op, ">=")) { // 1.2.3 >= 2.x.x ... 1.2.3 >= 2.0.0 low = sreplace(ver, "x", "0"); min = versionToNumber(low); } else if (smatch(op, "<=")) { // 1.2.3 < 2.x.x ... 1.2.3 <2.MAX.MAX high = sreplace(ver, "x", MAX_VER_STR); max = versionToNumber(high); } else if (*op == '>') { // 1.2.3 > 2.x.x ... 1.2.3 > 2.0.0 low = sreplace(ver, "x", "0"); min = versionToNumber(low) + 1; } else if (*op == '<') { // 1.2.3 < 2.x.x ... 1.2.3 <2.MAX.MAX high = sreplace(ver, "x", MAX_VER_STR); max = versionToNumber(high) - 1; } else { low = sreplace(ver, "x", "0"); high = sreplace(ver, "x", MAX_VER_STR); return inRange(vp, sjoin(">=", low, NULL)) && inRange(vp, sjoin("<", high, NULL)); } } else if (smatch(op, ">=")) { min = versionToNumber(base); } else if (smatch(op, "<=")) { max = versionToNumber(base); } else if (*op == '>') { min = versionToNumber(base) + 1; } else if (*op == '<') { max = versionToNumber(base) - 1; } else { min = max = versionToNumber(base); } if (min <= vp->numberVersion && vp->numberVersion <= max) { return 1; } return 0; }