本文整理汇总了C++中Formula::right方法的典型用法代码示例。如果您正苦于以下问题:C++ Formula::right方法的具体用法?C++ Formula::right怎么用?C++ Formula::right使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Formula
的用法示例。
在下文中一共展示了Formula::right方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeLimits
void IteratorOpParser::computeLimits(vector<Formula*>& mainSymbols, vector<unsigned int>& iteratorOpSymbolIndexes, unsigned int currentMainIndex,
unsigned int currentItOpIndex, long* rightLimit, long* leftLimit) {
unsigned int& k = currentMainIndex;
unsigned int& i = currentItOpIndex;
Formula* currentMainSymbol = mainSymbols.at(k);
if (0 == k) {
*leftLimit = maxLeftLimit;
} else {
Formula* previousMainSymbol = mainSymbols.at(k - 1);
long prevRight = previousMainSymbol->right();
long distance = currentMainSymbol->left() - prevRight;
if (i > 0 && iteratorOpSymbolIndexes.at(i - 1) == k - 1) { //il simbolo precedente è un IteratorOp
*leftLimit = prevRight + distance / 2 + distance % 2; //la divisione è fra interi e quindi ci può essere arrotondamento
} else {
*leftLimit = prevRight + 1;
}
}
if (mainSymbols.size() - 1 == k) {
*rightLimit = maxRightLimit;
} else {
Formula* nextMainSymbol = mainSymbols.at(k + 1);
long currentRight = currentMainSymbol->right();
long nextLeft = nextMainSymbol->left();
long distance = nextLeft - currentRight;
if (i < iteratorOpSymbolIndexes.size() - 1 && iteratorOpSymbolIndexes.at(i + 1) == k + 1) { //il simbolo sucessivo è un IteratorOp
*rightLimit = currentRight + distance / 2; //la divisione è fra interi e quindi ci può essere arrotondamento
} else {
*rightLimit = nextLeft - 1;
}
}
}
示例2: if
vector<Formula*>& SubSupParser::rec_findSubSup(vector<Formula*>& allSymbols, vector<Formula*>& mainSymbols, vector<Formula*>& otherSymbols,
unsigned int currentMainIndex, double formulaMidline) {
unsigned int& i = currentMainIndex;
if (i >= mainSymbols.size()) {
return *(new vector<Formula*>());
}
Formula* currentMain = mainSymbols.at(i);
Formula* subscript = NULL;
Formula* superscript = NULL;
bool subformulaFound = true;
while (subformulaFound && !otherSymbols.empty()) {
Formula* currentOther = otherSymbols.at(0);
//se alcuni simboli vengono classificati come apice/pedice, vengono rimossi dal vettore. Per questo motivo il simbolo "corrente" è sempre il primo
int currentLeftLimit = currentMain->left();
int currentRightLimit = (i == mainSymbols.size() - 1) ? maxRightLimit : mainSymbols.at(i + 1)->left() - 1;
bool currentOtherBetweenLimits = (currentLeftLimit <= currentOther->left() && currentOther->right() <= currentRightLimit);
/* è possibile che il simbolo corrente sia un apice/pedice SE è completamente contenuto nell'intervallo (orizzontale) definito
* dall'estremo sinistro del simbolo corrente fino all'estremo sinistro (escluso) del prossimo simbolo. Si prende l'estremo sinistro
* e non il destro perché in questo modo si è sicuri che non ci sono "buchi" in cui
* si può trovare un simbolo non principale: in alcuni casi, e.g. il simbolo di integrale, è necessario che il limite sia quello sinistro.
*/
double currentMainMidline = currentMain->center().getY();
bool aboveMidline = currentOther->center().getY() <= currentMainMidline;
bool belowMidline = currentOther->center().getY() >= currentMainMidline;
bool crossedByMidline = !aboveMidline && !belowMidline;
if (currentOtherBetweenLimits) {
if (!crossedByMidline && !Blacklist::inSubSupBlacklist(currentMain)) {
if (belowMidline) { //pedice
findSubSup(&subscript, currentOther, allSymbols, mainSymbols, otherSymbols, i, false);
} else if (aboveMidline) { //apice
findSubSup(&superscript, currentOther, allSymbols, mainSymbols, otherSymbols, i, true);
}
subformulaFound = true;
} else {
mainSymbols.insert(mainSymbols.begin() + i + 1, currentOther);
otherSymbols.erase(otherSymbols.begin());
subformulaFound = false;
}
} else {
subformulaFound = false;
}
}
SubSup* newSubformula = new SubSup(currentMain, subscript, superscript);
vector<Formula*>& tmpFormula = rec_findSubSup(allSymbols, mainSymbols, otherSymbols, i + 1, formulaMidline);
tmpFormula.insert(tmpFormula.begin(), newSubformula);
return tmpFormula;
}
示例3: findSubformulaeSymbols
void IteratorOpParser::findSubformulaeSymbols(vector<Formula*>& mainSymbols, vector<Formula*>& otherSymbols, unsigned int currentMainIndex,
vector<Formula*>& underscriptSymbols, vector<Formula*>& overscriptSymbols, long currentRightLimit, long currentLeftLimit) {
unsigned int& k = currentMainIndex;
Formula* currentMainSymbol = mainSymbols.at(k);
if (underscriptSymbols.empty() && overscriptSymbols.empty()) {
// caso in cui non ci sono underscript e overscript ma (forse) apici e pedici
long currentMainMidline = currentMainSymbol->center().getY();
unsigned int j = 0;
bool beforeCurrentRightLimit = true;
while (j < otherSymbols.size() && beforeCurrentRightLimit) {
if (otherSymbols.at(j)->left() >= currentRightLimit) {
beforeCurrentRightLimit = false;
} else {
Formula* oth = otherSymbols.at(j);
bool crossedByMidline = oth->top() < currentMainMidline && currentMainMidline < oth->bottom();
if (crossedByMidline) {
mainSymbols.insert(mainSymbols.begin() + k + 1, oth);
otherSymbols.erase(otherSymbols.begin() + j);
currentRightLimit = oth->left();
}
j++;
}
}
currentLeftLimit = currentMainSymbol->right();
underscriptSymbols = FormulaParserUtils::extractSymbolsWithinRange(otherSymbols, currentRightLimit, currentLeftLimit, maxBottomLimit,
currentMainMidline, true);
overscriptSymbols = FormulaParserUtils::extractSymbolsWithinRange(otherSymbols, currentRightLimit, currentLeftLimit, currentMainMidline, maxTopLimit,
true);
} else {
// l'underscript e l'overscript, che al momento contengono solo simboli allineati verticalmente col main, vengono estesi
underscriptSymbols = FormulaParserUtils::extractSymbolsWithinRange(otherSymbols, currentRightLimit, currentLeftLimit, maxBottomLimit,
currentMainSymbol->bottom() + 1, true);
overscriptSymbols = FormulaParserUtils::extractSymbolsWithinRange(otherSymbols, currentRightLimit, currentLeftLimit, currentMainSymbol->top() - 1,
maxTopLimit, true);
}
}
示例4:
Formula * FractionParser::_buildNumDen(Formula * fraction, vector<Formula*> &remainingSymbols,
bool (FractionParser::*check)(Formula * fraction, Formula * f)) {
vector<Formula *> numDem;
vector<Formula *> other;
vector<Formula *>::iterator it = remainingSymbols.begin();
while (it != remainingSymbols.end()) {
Formula * f = *it;
SvgPoint fracBar = fraction->getBarycenter();
if (!(*f == *fraction)) {
if (f->right() < fraction->right() + pixelFracMargin
&& f->left() > fraction->left() - pixelFracMargin && (this->*check)(fraction, f)) {
numDem.push_back(f);
} else {
other.push_back(f);
}
}
it++;
}
if (numDem.size() != 0) {
other.insert(other.end(), it, remainingSymbols.end());
remainingSymbols = other;
Parser p;
Formula * numFormula = p.parse(numDem);
return numFormula;
} else {
return NULL;
}
}
示例5: findIteratorOpSymbolIndexes
vector<Formula*>& IteratorOpParser::_parse(vector<Formula*>& formulaToParse) {
vector<Formula*> mainSymbols, otherSymbols;
vector<Formula*>& result = *(new vector<Formula*>());
findMainSymbols(formulaToParse, mainSymbols, otherSymbols, false);
vector<unsigned int> iteratorOpSymbolIndexes = findIteratorOpSymbolIndexes(mainSymbols);
unsigned int i = 0;
for (unsigned int k = 0; k < mainSymbols.size(); k++) {
Formula* currentMainSymbol = mainSymbols.at(k);
if (i < iteratorOpSymbolIndexes.size() && iteratorOpSymbolIndexes.at(i) == k) {
long currentLeftLimit, currentRightLimit;
computeLimits(mainSymbols, iteratorOpSymbolIndexes, k, i, ¤tRightLimit, ¤tLeftLimit);
vector<Formula*>& underscriptSymbols = FormulaParserUtils::extractSymbolsWithinRange(otherSymbols, currentMainSymbol->right(),
currentMainSymbol->left(), maxBottomLimit, currentMainSymbol->bottom() + 1, false);
vector<Formula*>& overscriptSymbols = FormulaParserUtils::extractSymbolsWithinRange(otherSymbols, currentMainSymbol->right(),
currentMainSymbol->left(), currentMainSymbol->top(), maxTopLimit, false);
findSubformulaeSymbols(mainSymbols, otherSymbols, k, underscriptSymbols, overscriptSymbols, currentRightLimit, currentLeftLimit);
Parser parser;
Formula* underscript = parser.parse(underscriptSymbols);
Formula* overscript = parser.parse(overscriptSymbols);
Formula* newIteratorOp = new IteratorOp(currentMainSymbol, underscript, overscript);
result.push_back(newIteratorOp);
i++;
} else {
result.push_back(mainSymbols.at(k));
}
}
result.insert(result.end(), otherSymbols.begin(), otherSymbols.end());
sort(result.begin(), result.end(), Formula::BarHorizontalComparator());
return result;
}