void TextBase::endEdit(EditData& ed) { TextEditData* ted = static_cast<TextEditData*>(ed.getData(this)); score()->undoStack()->remove(ted->startUndoIdx); // remove all undo/redo records // replace all undo/redo records collected during text editing with // one property change QString actualText = xmlText(); if (ted->oldXmlText.isEmpty()) { UndoStack* us = score()->undoStack(); UndoCommand* ucmd = us->last(); if (ucmd) { const QList<UndoCommand*>& cl = ucmd->commands(); const UndoCommand* cmd = cl.back(); if (strncmp(cmd->name(), "Add:", 4) == 0) { const AddElement* ae = static_cast<const AddElement*>(cmd); if (ae->getElement() == this) { if (actualText.isEmpty()) { // we just created this empty text, rollback that operation us->rollback(); score()->update(); ed.element = 0; } else { setXmlText(ted->oldXmlText); // reset text to value before editing us->reopen(); // combine undo records of text creation with text editing undoChangeProperty(Pid::TEXT, actualText); layout1(); score()->endCmd(); } return; } } } } if (actualText.isEmpty()) { qDebug("actual text is empty"); score()->startCmd(); score()->undoRemoveElement(this); ed.element = 0; score()->endCmd(); return; } setXmlText(ted->oldXmlText); // reset text to value before editing score()->startCmd(); undoChangeProperty(Pid::TEXT, actualText); // change property to set text to actual value again // this also changes text of linked elements layout1(); triggerLayout(); // force relayout even if text did not change score()->endCmd(); static const qreal w = 2.0; score()->addRefresh(canvasBoundingRect().adjusted(-w, -w, w, w)); }
void Clef::layout() { // determine current number of lines and line distance int lines = 5; // assume a resonable default qreal lineDist = 1.0; StaffType* staffType; if (staff() && staff()->staffType()) { staffType = staff()->staffType(); if (!staffType->genClef()) { // if no clef, set empty bbox and do nothing setbbox(QRectF()); return; } // tablatures: if (staffType->group() == TAB_STAFF) { // if current clef type not compatible with tablature, // set tab clef according to score style if (clefTable[clefType()].staffGroup != TAB_STAFF) setClefType( ClefType(score()->styleI(ST_tabClef)) ); } // all staff types: init values from staff type lines = staffType->lines(); lineDist = staffType->lineDistance().val(); } // if nothing changed since last layout, do nothing if (curClefType == clefType() && curLines == lines && curLineDist == lineDist) return; // if something has changed, cache new values and re-layout curClefType = clefType(); curLines = lines; curLineDist = lineDist; layout1(); }
void tryLayout(Rectangle rectangles[4]){ layout1(rectangles); layout2(rectangles); layout3(rectangles); layout4(rectangles); layout5(rectangles); }
void TextBase::inputTransition(EditData& ed, QInputMethodEvent* ie) { TextEditData* ted = static_cast<TextEditData*>(ed.getData(this)); TextCursor* _cursor = &ted->cursor; // remove preedit string int n = preEdit.size(); while (n--) { if (_cursor->movePosition(QTextCursor::Left)) { TextBlock& l = _cursor->curLine(); l.remove(_cursor->column()); _cursor->text()->triggerLayout(); _cursor->text()->setTextInvalid(); } } qDebug("<%s><%s> len %d start %d, preEdit size %d", qPrintable(ie->commitString()), qPrintable(ie->preeditString()), ie->replacementLength(), ie->replacementStart(), preEdit.size()); if (!ie->commitString().isEmpty()) { _cursor->format()->setPreedit(false); score()->startCmd(); insertText(ed, ie->commitString()); score()->endCmd(); preEdit.clear(); } else { preEdit = ie->preeditString(); if (!preEdit.isEmpty()) { #if 0 for (auto a : ie->attributes()) { switch(a.type) { case QInputMethodEvent::TextFormat: { qDebug(" attribute TextFormat: %d-%d", a.start, a.length); QTextFormat tf = a.value.value<QTextFormat>(); } break; case QInputMethodEvent::Cursor: qDebug(" attribute Cursor at %d", a.start); break; default: qDebug(" attribute %d", a.type); } } #endif _cursor->format()->setPreedit(true); _cursor->updateCursorFormat(); editInsertText(_cursor, preEdit); setTextInvalid(); layout1(); score()->update(); } } ie->accept(); }
bool validarValor(float valor){ if(valor == 0){ printf("\nPor favor digite um numero ou maior que 0. \n"); system("pause"); system("cls"); layout1(); return false; } return true; }
Clef::Clef(const Clef& c) : Element(c) { _showCourtesy = c._showCourtesy; _showPreviousClef = c._showPreviousClef; _small = c._small; _clefTypes = c._clefTypes; curClefType = c.curClefType; curLines = c.curLines; curLineDist = c.curLineDist; layout1(); }
void Lyrics::layout() { // setPos(_textStyle.offset(spatium())); layout1(); QPointF rp(readPos()); if (!rp.isNull()) { if (score()->mscVersion() <= 114) { rp.ry() += lineSpacing() + 2; rp.rx() += bbox().width() * .5; } setUserOff(rp - ipos()); setReadPos(QPointF()); } }
void test(Pooma::Tester &tester) { // Create a mesh using a DomainLayout. DomainLayout<2> layout1(physicalVertexDomain, gl); tester.out() << layout1 << std::endl; Mesh mesh1(layout1, origin, spacings); // Set up some centerings. Centering<2> cell = canonicalCentering<2>(CellType, Continuous); // Initialize a field. Field<Mesh> f1(cell, layout1, mesh1); // Do the tests. testPositions(tester, f1); testNormals(tester, f1); testCellVolumes(tester, f1); testFaceAreas(tester, f1); testEdgeLengths(tester, f1); }
void TextLineSegment::layout() { layout1(); adjustReadPos(); }
int main(int argc, char *argv[]) { // Initialize POOMA and output stream, using Tester class Pooma::initialize(argc, argv); Pooma::Tester tester(argc, argv); tester.out() << argv[0] << ": Tests of global ID database." << std::endl; tester.out() << "------------------------------------------------" << std::endl; int size = 120; Interval<1> domain(size); UniformGridPartition<1> partition1(Loc<1>(10)); UniformGridLayout<1> layout1(domain,partition1, ReplicatedTag()); UniformGridPartition<1> partition2(Loc<1>(6)); UniformGridLayout<1> layout2(domain,partition2, ReplicatedTag()); std::vector<INode<1> > inodes; GlobalIDDataBase gidStore; UniformGridLayout<1>::const_iterator p = layout1.beginGlobal(); while (p != layout1.endGlobal()) { inodes.push_back(INode<1>(*p, layout1.ID(), &gidStore)); ++p; } int i; int ni = inodes.size(); for (i = 0; i < ni; ++i) { layout2.touches(inodes[i].domain(), std::back_inserter(inodes), TouchesConstructINode<1>(layout2.ID(),inodes[i].key(), &gidStore) ); } inodes.erase(inodes.begin(), inodes.begin() + ni); int gid1,gid2; int gidStore1,gidStore2; for (i = 0; i < inodes.size(); ++i) { gid1 = layout1.globalID(inodes[i].domain().firsts()); gid2 = layout2.globalID(inodes[i].domain().firsts()); gidStore1 = inodes[i].globalID(layout1.ID()); gidStore2 = inodes[i].globalID(layout2.ID()); tester.check(gid1 == gidStore1); tester.check(gid2 == gidStore2); tester.out() << "domain " << inodes[i].domain() << ", key " << inodes[i].key() << ", gid #1 - (" << gid1 << " == " << gidStore1 << ")" << ", gid #2 - (" << gid2 << " == " << gidStore2 << ")" << std::endl; } gidStore.print(tester.out()); tester.out() << "------------------------------------------------" << std::endl; int retval = tester.results("giddatabaseTest"); Pooma::finalize(); return retval; }
int main(int argc, char *argv[]) { Pooma::initialize(argc, argv); Pooma::Tester tester(argc, argv); // To declare a field, you first need to set up a layout. This requires // knowing the physical vertex-domain and the number of external guard // cell layers. Vertex domains contain enough points to hold all of the // rectilinear centerings that POOMA is likely to support for quite // awhile. Also, it means that the same layout can be used for all // fields, regardless of centering. Interval<2> physicalVertexDomain(14, 14); Loc<2> blocks(3, 3); GridLayout<2> layout1(physicalVertexDomain, blocks, GuardLayers<2>(1), LayoutTag_t()); GridLayout<2> layout0(physicalVertexDomain, blocks, GuardLayers<2>(0), LayoutTag_t()); Centering<2> cell = canonicalCentering<2>(CellType, Continuous, AllDim); Centering<2> vert = canonicalCentering<2>(VertexType, Continuous, AllDim); Centering<2> yedge = canonicalCentering<2>(EdgeType, Continuous, YDim); Vector<2> origin(0.0); Vector<2> spacings(1.0, 2.0); // First basic test verifies that we're assigning to the correct areas // on a brick. typedef Field<UniformRectilinearMesh<2>, double, MultiPatch<GridTag, BrickTag_t> > Field_t; Field_t b0(cell, layout1, origin, spacings); Field_t b1(vert, layout1, origin, spacings); Field_t b2(yedge, layout1, origin, spacings); Field_t b3(yedge, layout1, origin, spacings); Field_t bb0(cell, layout0, origin, spacings); Field_t bb1(vert, layout0, origin, spacings); Field_t bb2(yedge, layout0, origin, spacings); b0.all() = 0.0; b1.all() = 0.0; b2.all() = 0.0; b0 = 1.0; b1 = 1.0; b2 = 1.0; bb0.all() = 0.0; bb1.all() = 0.0; bb2.all() = 0.0; bb0 = 1.0; bb1 = 1.0; bb2 = 1.0; // SPMD code follows. // Note, SPMD code will work with the evaluator if you are careful // to perform assignment on all the relevant contexts. The patchLocal // function creates a brick on the local context, so you can just perform // the assignment on that context. int i; for (i = 0; i < b0.numPatchesLocal(); ++i) { Patch<Field_t>::Type_t patch = b0.patchLocal(i); // tester.out() << "context " << Pooma::context() << ": assigning to patch " << i // << " with domain " << patch.domain() << std::endl; patch += 1.5; } // This is safe to do since b1 and b2 are built with the same layout. for (i = 0; i < b1.numPatchesLocal(); ++i) { b1.patchLocal(i) += 1.5; b2.patchLocal(i) += 1.5; } for (i = 0; i < bb0.numPatchesLocal(); ++i) { Patch<Field_t>::Type_t patch = bb0.patchLocal(i); // tester.out() << "context " << Pooma::context() << ": assigning to patch on bb0 " << i // << " with domain " << patch.domain() << std::endl; patch += 1.5; } // This is safe to do since bb1 and bb2 are built with the same layout. for (i = 0; i < bb1.numPatchesLocal(); ++i) { bb1.patchLocal(i) += 1.5; bb2.patchLocal(i) += 1.5; } tester.check("cell centered field is 2.5", all(b0 == 2.5)); tester.check("vert centered field is 2.5", all(b1 == 2.5)); tester.check("edge centered field is 2.5", all(b2 == 2.5)); tester.out() << "b0.all():" << std::endl << b0.all() << std::endl; tester.out() << "b1.all():" << std::endl << b1.all() << std::endl; tester.out() << "b2.all():" << std::endl << b2.all() << std::endl; tester.check("didn't write into b0 boundary", sum(b0.all()) == 2.5 * b0.physicalDomain().size()); tester.check("didn't write into b1 boundary", sum(b1.all()) == 2.5 * b1.physicalDomain().size()); tester.check("didn't write into b2 boundary", sum(b2.all()) == 2.5 * b2.physicalDomain().size()); tester.check("cell centered field is 2.5", all(bb0 == 2.5)); tester.check("vert centered field is 2.5", all(bb1 == 2.5)); tester.check("edge centered field is 2.5", all(bb2 == 2.5)); tester.out() << "bb0:" << std::endl << bb0 << std::endl; tester.out() << "bb1:" << std::endl << bb1 << std::endl; tester.out() << "bb2:" << std::endl << bb2 << std::endl; typedef Field<UniformRectilinearMesh<2>, double, MultiPatch<GridTag, CompressibleBrickTag_t> > CField_t; CField_t c0(cell, layout1, origin, spacings); CField_t c1(vert, layout1, origin, spacings); CField_t c2(yedge, layout1, origin, spacings); CField_t cb0(cell, layout0, origin, spacings); CField_t cb1(vert, layout0, origin, spacings); CField_t cb2(yedge, layout0, origin, spacings); c0.all() = 0.0; c1.all() = 0.0; c2.all() = 0.0; c0 = 1.0; c1 = 1.0; c2 = 1.0; cb0.all() = 0.0; cb1.all() = 0.0; cb2.all() = 0.0; cb0 = 1.0; cb1 = 1.0; cb2 = 1.0; // SPMD code follows. // Note, SPMD code will work with the evaluator if you are careful // to perform assignment on all the relevant contexts. The patchLocal // function creates a brick on the local context, so you can just perform // the assignment on that context. for (i = 0; i < c0.numPatchesLocal(); ++i) { Patch<CField_t>::Type_t patch = c0.patchLocal(i); tester.out() << "context " << Pooma::context() << ": assigning to patch " << i << " with domain " << patch.domain() << std::endl; patch += 1.5; } // This is safe to do since c1 and c2 are built with the same layout. for (i = 0; i < c1.numPatchesLocal(); ++i) { c1.patchLocal(i) += 1.5; c2.patchLocal(i) += 1.5; } for (i = 0; i < cb0.numPatchesLocal(); ++i) { Patch<CField_t>::Type_t patch = cb0.patchLocal(i); tester.out() << "context " << Pooma::context() << ": assigning to patch on cb0 " << i << " with domain " << patch.domain() << std::endl; patch += 1.5; } // This is safe to do since cb1 and cb2 are cuilt with the same layout. for (i = 0; i < cb1.numPatchesLocal(); ++i) { cb1.patchLocal(i) += 1.5; cb2.patchLocal(i) += 1.5; } tester.check("cell centered field is 2.5", all(c0 == 2.5)); tester.check("vert centered field is 2.5", all(c1 == 2.5)); tester.check("edge centered field is 2.5", all(c2 == 2.5)); tester.out() << "c0.all():" << std::endl << c0.all() << std::endl; tester.out() << "c1.all():" << std::endl << c1.all() << std::endl; tester.out() << "c2.all():" << std::endl << c2.all() << std::endl; tester.check("didn't write into c0 boundary", sum(c0.all()) == 2.5 * c0.physicalDomain().size()); tester.check("didn't write into c1 boundary", sum(c1.all()) == 2.5 * c1.physicalDomain().size()); tester.check("didn't write into c2 boundary", sum(c2.all()) == 2.5 * c2.physicalDomain().size()); tester.check("cell centered field is 2.5", all(cb0 == 2.5)); tester.check("vert centered field is 2.5", all(cb1 == 2.5)); tester.check("edge centered field is 2.5", all(cb2 == 2.5)); tester.out() << "cb0:" << std::endl << cb0 << std::endl; tester.out() << "cb1:" << std::endl << cb1 << std::endl; tester.out() << "cb2:" << std::endl << cb2 << std::endl; //------------------------------------------------------------------ // Scalar code example: // c0 = iota(c0.domain()).comp(0); c1 = iota(c1.domain()).comp(1); // Make sure all the data-parallel are done: Pooma::blockAndEvaluate(); for (i = 0; i < c0.numPatchesLocal(); ++i) { Patch<CField_t>::Type_t local0 = c0.patchLocal(i); Patch<CField_t>::Type_t local1 = c1.patchLocal(i); Patch<CField_t>::Type_t local2 = c2.patchLocal(i); Interval<2> domain = local2.domain(); // physical domain of local y-edges // -------------------------------------------------------------- // I believe the following is probably the most efficient approach // for sparse computations. For data-parallel computations, the // evaluator will uncompress the patches and take brick views, which // provide the most efficient access. If you are only performing // the computation on a small portion of cells, then the gains would // be outweighed by the act of copying the compressed value to all the // cells. // // The read function is used on the right hand side, because // operator() is forced to uncompress the patch just in case you want // to write to it. for(Interval<2>::iterator pos = domain.begin(); pos != domain.end(); ++pos) { Loc<2> edge = *pos; Loc<2> rightCell = edge; // cell to right is same cell Loc<2> leftCell = edge - Loc<2>(1,0); Loc<2> topVert = edge + Loc<2>(0, 1); Loc<2> bottomVert = edge; local2(edge) = local0.read(rightCell) + local0.read(leftCell) + local1.read(topVert) + local1.read(bottomVert); } // This statement is optional, it tries to compress the patch after // we're done computing on it. Since I used .read() for the local0 and 1 // they remained in their original state. compress() can be expensive, so // it may not be worth trying unless space is really important. compress(local2); } tester.out() << "c0" << std::endl << c0 << std::endl; tester.out() << "c1" << std::endl << c1 << std::endl; tester.out() << "c2" << std::endl << c2 << std::endl; //------------------------------------------------------------------ // Interfacing with a c-function: // // This example handles the corner cases, where the patches from a // cell centered field with no guard layers actually contain some // extra data. Pooma::blockAndEvaluate(); for (i = 0; i < cb0.numPatchesLocal(); ++i) { Patch<CField_t>::Type_t local0 = cb0.patchLocal(i); Interval<2> physicalDomain = local0.physicalDomain(); double *data; int size = physicalDomain.size(); if (physicalDomain == local0.totalDomain()) { uncompress(local0); data = &local0(physicalDomain.firsts()); nonsense(data, size); } else { // In this case, the engine has extra storage even though the // field has the right domain. We copy it to a brick engine, // call the function and copy it back. No uncompress is required, // since the assignment will copy the compressed value into the // brick. // arrayView is a work-around. Array = Field doesn't work at // the moment. Array<2, double, Brick> brick(physicalDomain); Array<2, double, CompressibleBrick> arrayView(local0.engine()); brick = arrayView(physicalDomain); Pooma::blockAndEvaluate(); data = &brick(Loc<2>(0)); nonsense(data, size); arrayView(physicalDomain) = brick; // Note that we don't need a blockAndEvaluate here, since an iterate has // been spawned to perform the copy. } // If you want to try compress(local0) here, you should do blockAndEvaluate // first in case the local0 = brick hasn't been executed yet. } tester.out() << "cb0.all()" << std::endl << cb0 << std::endl; b2 = positions(b2).comp(0); RefCountedBlockPtr<double> block = pack(b2); // The following functions give you access to the raw data from pack. // Note that the lifetime of the data is managed by the RefCountedBlockPtr, // so when "block" goes out of scope, the data goes away. (i.e. Don't write // a function where you return block.beginPointer().) double *start = block.beginPointer(); // start of the data double *end = block.endPointer(); // one past the end int size = block.size(); // size of the data tester.out() << Pooma::context() << ":" << block.size() << std::endl; unpack(b3, block); tester.out() << "b2" << std::endl << b2 << std::endl; tester.out() << "b3" << std::endl << b3 << std::endl; tester.check("pack, unpack", all(b2 == b3)); int ret = tester.results("LocalPatch"); Pooma::finalize(); return ret; }
int main (){ setlocale(LC_ALL, "Portuguese"); //variaveis int tipoRefri, flag; float mlRefri, mlRun, mlGelo; float resulRefri, resulRun, resulGelo; int c,r,p,g; int resp=0, soma=0, valor=0; char entradarefri [10]; char entradarun [10]; char entradagelo [10]; do{ //layout layout(); system("pause"); system("cls"); layout1(); //Entrada de dados do{ printf("Digite o tipo do seu refrigerante:\n"); printf("1- Coca-cola\n"); printf("2- Pepsi\n"); printf("\n"); printf("Opção: "); if (scanf("%d", &tipoRefri) != 1) { printf("\nPor favor digite apenas numeros \n"); tipoRefri = 10; fflush(stdin); } }while(tipoRefri<1 || tipoRefri>2); system("cls"); layout1(); do{ printf("Digite a quantidade de ml de Refrigerante:\n"); printf("Coca-Cola (50ml a 60ml) ou Pepsi-Cola (60ml a 70ml)\n"); printf("Quantidade: "); scanf("%s", &entradarefri); mlRefri = atof (entradarefri); fflush(stdin); }while(!validarValor(mlRefri)); do{ printf("\nDigite a quantidade de ml de Run\n"); printf("Run (10ml a 30ml)\n"); printf("Quantidade: "); scanf("%s", &entradarun); mlRun = atof (entradarun); fflush(stdin); }while(!validarValor(mlRun)); do{ printf("\nDigite a quantidade de ml de Gelo\n"); printf("Gelo (20ml)\n"); printf("Quantidade: "); scanf("%s", &entradagelo); mlGelo = atof (entradagelo); fflush(stdin); }while(!validarValor(mlGelo)); printf ("\n"); //começa a verificar Coca if(tipoRefri == 1) //começa coca forte if(mlRefri >= 50 && mlRefri < 52 ){ c=1; printf("Coca-Forte\n"); }else if(mlRefri >= 52 && mlRefri < 54){ resulRefri = ((54-mlRefri)/(54-52)); c=1; printf("Coca-forte com o grau de: %.0f\n", resulRefri); //começa coca suave }else if(mlRefri >= 54 && mlRefri <56 ){ c=2; printf("Coca-Suave\n"); }else if(mlRefri >= 56 && mlRefri < 58){ c=2; resulRefri = ((58-mlRefri)/(58-56)); printf("Coca-suave com o grau de: %.0f\n", resulRefri); //começa coca fraca }else if(mlRefri >= 58 && mlRefri <= 60 ){ c=3; printf("Coca-Fraco\n"); } //começa verificar Pepsi if(tipoRefri == 2) //comecaPepsi forte if(mlRefri >= 60 && mlRefri < 62 ){ p=1; printf("Pepsi-Forte\n"); }else if(mlRefri >= 62 && mlRefri < 64){ p=1; resulRefri = ((64-mlRefri)/(64-62)); printf("Pepsi-forte com o grau de: %.0f\n", resulRefri); //comeca Pepsi suave }else if(mlRefri >= 64 && mlRefri <66 ){ p=2; printf("Pepsi-Suave\n"); }else if(mlRefri >= 66 && mlRefri < 68){ p=2; resulRefri = ((68-mlRefri)/(68-66)); printf("Pepsi-suave com o grau de: %.0f\n", resulRefri); //comeca pepsi fraca }else if(mlRefri >= 68 && mlRefri < 71 ){ p=3; printf("Pepsi-Fraco\n"); } //começa a verficar Run //começa Run fraco if(mlRun >= 10 && mlRun < 15 ){ r=3; printf("Run-Fraco\n"); //começa run suave }else if(mlRun >= 20 && mlRun <23 ){ r=2; printf("Run-Suave\n"); }else if(mlRun >= 15 && mlRun < 20){ r=2; resulRun = ((20-mlRun)/(20-15)); printf("Run-suave com o grau de: %.0f\n", resulRun); //começa run forte }else if(mlRun >= 27 && mlRun <= 30 ){ r=1; printf("Run-Forte\n"); } else if(mlRun >= 23 && mlRun < 27){ r=1; resulRun = ((27-mlRun)/(27-23)); printf("Run-forte com o grau de: %.0f\n", mlRun); } //começa a verificar o gelo if(mlGelo == 20){ g=1; printf("Gelado\n"); }else printf("Sem gelo\n"); printf("\n\n"); system("pause"); system("cls"); layout_Final(); //Defuzzificação //começa a verificar com coca-cola //começa paladar suave com coca if(tipoRefri == 1) { if(c==1 && r==3 && g==1){ valor=20; printf("\nBebida Com Coca-cola\n"); printf("Paladar: Suave\n"); printf("Seu preço é: R$ 20,00\n"); }else if(c==2 && r==2 && g==1){ valor=20; printf("\nBebida Com Coca-cola\n"); printf("Paladar: Suave\n"); printf("Seu preço é: R$ 20,00\n"); }else if(c==3 && r==1 && g==1) { valor=20; printf("\nBebida Com Coca-cola\n"); printf("Paladar: Suave\n"); printf("Seu preço é: R$ 20,00\n"); //começa paladar forte }else if(c==1 && r==2 && g==1){ valor=25; printf("\nBebida Com Coca-cola\n"); printf("Paladar: Forte\n"); printf("Seu preço é: R$ 25,00\n"); }else if(c==1 && r==1 && g==1){ valor=25; printf("\nBebida Com Coca-cola\n"); printf("Paladar: Forte\n"); printf("Seu preço é: R$ 25,00\n"); } else if(c==2 && r==1 && g==1){ valor=25; printf("\nBebida Com Coca-cola\n"); printf("Paladar: Forte\n"); printf("Seu preço é: R$ 25,00\n"); //comeca paladar fraco }else if(c==3 && r==3 && g==1){ valor=15; printf("\nBebida Com Coca-cola\n"); printf("Paladar: Fraco\n"); printf("Seu preço é: R$ 15,00\n"); }else if(c==3 && r==2 && g==1){ valor=15; printf("\nBebida Com Coca-cola\n"); printf("Paladar: Fraco\n"); printf("Seu preço é: R$ 15,00\n"); }else if(c==2 && r==3 && g==1){ valor=15; printf("\nBebida Com Coca-cola\n"); printf("Paladar: Fraco\n"); printf("Seu preço é: R$ 15,00\n"); } }else if(tipoRefri == 2) { //Começa a verificar com pepsi //começa paladar suave if(p==1 && r==3 && g==1){ valor=20; printf("\nBebida Com Pepsi\n"); printf("Paladar: Suave\n"); printf("Seu preço é: R$ 20,00\n"); }else if(p==2 && r==2 && g==1){ valor=20; printf("\nBebida Com Pepsi\n"); printf("Paladar: Suave\n"); printf("Seu preço é: R$ 20,00\n"); }else if(p==3 && r==1 && g==1) { valor=20; printf("\nBebida Com Pepsi\n"); printf("Paladar: Suave\n"); printf("Seu preço é: R$ 20,00\n"); //começa paladar forte }else if(p==1 && r==2 && g==1){ valor=25; printf("\nBebida Com Pepsi\n"); printf("Paladar: Forte\n"); printf("Seu preço é: R$ 25,00\n"); }else if(p==1 && r==1 && g==1){ valor=25; printf("\nBebida Com Pepsi\n"); printf("Paladar: Forte\n"); printf("Seu preço é: R$ 25,00\n"); } else if(p==2 && r==1 && g==1){ valor=25; printf("\nBebida Com Pepsi\n"); printf("Paladar: Forte\n"); printf("Seu preço é: R$ 25,00\n"); //começa paladar fraco }else if(p==3 && r==3 && g==1){ valor=15; printf("\nBebida Com Pepsi\n"); printf("Paladar: Fraco\n"); printf("Seu preço é: R$ 15,00\n"); }else if(p==3 && r==2 && g==1){ valor=15; printf("\nBebida Com Pepsi\n"); printf("Paladar: Fraco\n"); printf("Seu preço é: R$ 15,00\n"); }else if(p==2 && r==3 && g==1){ valor=15; printf("\nBebida Com Pepsi\n"); printf("Paladar: Fraco\n"); printf("Seu preço é: R$ 15,00\n"); } }else{ printf("\nSua bebida não é Cuba Livre\n"); } soma=soma+valor; system("pause"); system("cls"); layout1(); do { flag = 0; printf("Deseja continuar?\n"); printf("1-Sim\n"); printf("2-Nao\n"); if (scanf("%d", &resp) != 1) { printf("\nPor favor digite apenas numeros \n"); flag = 1; fflush(stdin); } }while(flag==1); }while(resp==1); layout_Final(); if(soma != 0) { printf("O valor total da conta é: %i\n\n", soma); } system("pause"); }
void TimeSig::layout() { if (_needLayout) layout1(); }
void Clef::spatiumChanged(qreal oldValue, qreal newValue) { layout1(); Element::spatiumChanged(oldValue, newValue); }
void Clef::layout() { // determine current number of lines and line distance int lines = 5; // assume resonable defaults qreal lineDist = 1.0; Staff* stf = staff(); StaffType* staffType = nullptr; Segment* clefSeg = static_cast<Segment*>(parent()); // check clef visibility and type compatibility if (clefSeg && stf && stf->staffType()) { bool bHide; // check staff type allows clef display staffType = staff()->staffType(); #if 0 // <<<<<<< HEAD if (!staffType->genClef()) { // if no clef, set empty bbox and do nothing qDeleteAll(elements); elements.clear(); setbbox(QRectF()); return; } // tablatures: if (staffType->group() == StaffGroup::TAB) { // if current clef type not compatible with tablature, // set tab clef according to score style if (ClefInfo::staffGroup(clefType()) != StaffGroup::TAB) setClefType( ClefType(score()->styleI(StyleIdx::tabClef)) ); #else bHide = !staffType->genClef(); // check clef is compatible with staff type group int tick = clefSeg->tick(); if (ClefInfo::staffGroup(clefType()) != staffType->group()) { if (tick > 0 && !generated()) // if clef is not generated, hide it bHide = true; else // if generated, replace with initial clef type // TODO : instead of initial staff clef (which is assumed to be compatible) // use the last compatible clef previously found in staff _clefTypes = stf->clefTypeList(0); #endif // >>>>>>> 38c666fa91f5bdaaa6d9ca0645c437c799be8c79 } // // courtesy clef // bool showClef = true; #if 0 // <<<<<<< HEAD Segment* clefSeg = static_cast<Segment*>(parent()); if (clefSeg) { int tick = clefSeg->tick(); // only if there is a clef change if (stf->clef(tick) != stf->clef(tick-1)) { // locate clef at the begining of next measure, if any Clef* clefNext = nullptr; Segment* clefSegNext = nullptr; Measure* meas = static_cast<Measure*>(clefSeg->parent()); Measure* measNext = meas->nextMeasure(); if (measNext) { clefSegNext = measNext->findSegment(SegmentType::Clef, tick); if (clefSegNext) clefNext = static_cast<Clef*>(clefSegNext->element(track())); } // show this clef if: it is not a courtesy clef (no next clef or not at the end of the measure) showClef = !clefNext || (clefSeg->tick() != meas->tick() + meas->ticks()) // if courtesy clef: show if score has courtesy clefs on || ( score()->styleB(StyleIdx::genCourtesyClef) // AND measure is not at the end of a repeat or of a section && !( (meas->repeatFlags() & Repeat::END) || meas->sectionBreak() ) // AND this clef has courtesy clef turned on && showCourtesy() ); if (!showClef) { // if no clef, set empty bbox and do nothing qDeleteAll(elements); elements.clear(); setbbox(QRectF()); return; } #else // only if there is a clef change if (!bHide && tick > 0 && stf->clef(tick) != stf->clef(tick-1)) { // locate clef at the begining of next measure, if any Clef* clefNext = nullptr; Segment* clefSegNext = nullptr; Measure* meas = static_cast<Measure*>(clefSeg->parent()); Measure* measNext = meas->nextMeasure(); if (measNext) { clefSegNext = measNext->findSegment(SegmentType::Clef, tick); if (clefSegNext) clefNext = static_cast<Clef*>(clefSegNext->element(track())); #endif // >>>>>>> 38c666fa91f5bdaaa6d9ca0645c437c799be8c79 } // show this clef if: it is not a courtesy clef (no next clef or not at the end of the measure) showClef = !clefNext || (clefSeg->tick() != meas->tick() + meas->ticks()) // if courtesy clef: show if score has courtesy clefs on || ( score()->styleB(StyleIdx::genCourtesyClef) // AND measure is not at the end of a repeat or of a section && !( (meas->repeatFlags() & Repeat::END) || meas->sectionBreak() ) // AND this clef has courtesy clef turned on && showCourtesy() ); bHide |= !showClef; } // if clef not to show or not compatible with staff group if (bHide) { qDeleteAll(elements); // set empty bbox and do nothing elements.clear(); setbbox(QRectF()); return; } lines = staffType->lines(); // init values from staff type lineDist = staffType->lineDistance().val(); } // if nothing changed since last layout, do nothing //DEBUG if (curClefType == clefType() && curLines == lines && curLineDist == lineDist) // return; // if something has changed, cache new values and re-layout curClefType = clefType(); curLines = lines; curLineDist = lineDist; layout1(); } //--------------------------------------------------------- // layout1 //--------------------------------------------------------- void Clef::layout1() { qreal smag = mag(); qreal _spatium = spatium(); // qreal msp = score()->spatium() * smag; qreal yoff = 0.0; qDeleteAll(elements); elements.clear(); Symbol* symbol = new Symbol(score()); switch (curClefType) { case ClefType::G: // G clef on 2nd line symbol->setSym(SymId::gClef); yoff = 3.0 * curLineDist; break; case ClefType::G1: // G clef 8va on 2nd line symbol->setSym(SymId::gClef8va); yoff = 3.0 * curLineDist; break; case ClefType::G2: // G clef 15ma on 2nd line symbol->setSym(SymId::gClef15ma); yoff = 3.0 * curLineDist; break; case ClefType::G3: // G clef 8vb on 2nd line symbol->setSym(SymId::gClef8vb); yoff = 3.0 * curLineDist; break; case ClefType::F: // F clef on penultimate line symbol->setSym(SymId::fClef); yoff = 1.0 * curLineDist; break; case ClefType::F8: // F clef 8va bassa on penultimate line symbol->setSym(SymId::fClef8vb); yoff = 1.0 * curLineDist; break; case ClefType::F15: // F clef 15ma bassa on penultimate line symbol->setSym(SymId::fClef15mb); yoff = 1.0 * curLineDist; break; case ClefType::F_B: // baritone clef symbol->setSym(SymId::fClef); yoff = 2.0 * curLineDist; break; case ClefType::F_C: // subbass clef symbol->setSym(SymId::fClef); yoff = 0.0; break; case ClefType::C1: // C clef in 1st line symbol->setSym(SymId::cClef); yoff = 4.0 * curLineDist; break; case ClefType::C2: // C clef on 2nd line symbol->setSym(SymId::cClef); yoff = 3.0 * curLineDist; break; case ClefType::C3: // C clef in 3rd line symbol->setSym(SymId::cClef); yoff = 2.0 * curLineDist; break; case ClefType::C4: // C clef on 4th line symbol->setSym(SymId::cClef); yoff = 1.0 * curLineDist; break; case ClefType::C5: // C clef on 5th line symbol->setSym(SymId::cClef); yoff = 0.0; break; case ClefType::TAB: // TAB clef symbol->setSym(SymId::sixStringTabClef); // on tablature, position clef at half the number of spaces * line distance yoff = curLineDist * (curLines - 1) * .5; break; case ClefType::TAB2: // TAB clef alternate style symbol->setSym(SymId::sixStringTabClefSerif); // on tablature, position clef at half the number of spaces * line distance yoff = curLineDist * (curLines - 1) * .5; break; case ClefType::PERC: // percussion clefs case ClefType::PERC2: // no longer supported: fall back to same glyph as PERC symbol->setSym(SymId::unpitchedPercussionClef1); yoff = curLineDist * (curLines - 1) * 0.5; break; case ClefType::G4: // G clef in 1st line symbol->setSym(SymId::gClef); yoff = 4.0 * curLineDist; break; case ClefType::F_8VA: // F clef 8va on penultimate line symbol->setSym(SymId::fClef8va); yoff = 1.0 * curLineDist; break; case ClefType::F_15MA: // F clef 15ma on penultimate line symbol->setSym(SymId::fClef15ma); yoff = 1.0 * curLineDist; break; case ClefType::INVALID: case ClefType::MAX: return; } symbol->setMag(smag); symbol->layout(); addElement(symbol, .0, yoff * _spatium); setbbox(QRectF()); for (auto i = elements.begin(); i != elements.end(); ++i) { Element* e = *i; e->setColor(curColor()); addbbox(e->bbox().translated(e->pos())); e->setSelected(selected()); } } //--------------------------------------------------------- // draw //--------------------------------------------------------- void Clef::draw(QPainter* painter) const { if (staff() && !staff()->staffType()->genClef()) return; QColor color(curColor()); foreach(Element* e, elements) { e->setColor(color); QPointF pt(e->pos()); painter->translate(pt); e->draw(painter); painter->translate(-pt); } }
void Text::layout() { layout1(); adjustReadPos(); }
void Clef::layout() { setPos(QPoint()); // determine current number of lines and line distance int lines = 5; // assume resonable defaults qreal lineDist = 1.0; Staff* stf = staff(); StaffType* staffType = nullptr; Segment* clefSeg = static_cast<Segment*>(parent()); // check clef visibility and type compatibility if (clefSeg && stf && stf->staffType()) { bool bHide; // check staff type allows clef display staffType = stf->staffType(); bHide = !staffType->genClef(); // check clef is compatible with staff type group int tick = clefSeg->tick(); if (ClefInfo::staffGroup(clefType()) != staffType->group()) { if (tick > 0 && !generated()) // if clef is not generated, hide it bHide = true; else // if generated, replace with initial clef type // TODO : instead of initial staff clef (which is assumed to be compatible) // use the last compatible clef previously found in staff _clefTypes = stf->clefType(0); } // // courtesy clef // bool showClef = true; // only if there is a clef change if (!bHide && tick > 0 ) { Measure* meas = clefSeg->measure(); // courtesy clef: end of last measure measure of system bool courtesy = clefSeg->tick() == meas->endTick() && meas->system() && (meas == meas->system()->lastMeasure() || meas->system()->measures().indexOf(meas) == -1); showClef = // show this clef if: // it is not a courtesy clef !courtesy // or, if courtesy clef: show if score has courtesy clefs on || ( score()->styleB(StyleIdx::genCourtesyClef) // AND measure is not at the end of a repeat or of a section && !( (meas->repeatFlags() & Repeat::END) || meas->isFinalMeasureOfSection() ) // AND this clef has courtesy clef turned on && showCourtesy() ); bHide |= !showClef; } // if clef not to show or not compatible with staff group if (bHide) { qDeleteAll(elements); // set empty bbox and do nothing elements.clear(); setbbox(QRectF()); return; } lines = staffType->lines(); // init values from staff type #if 0 // with fewer than 5 lines, keep clef toward top of staff (ignore line spacing) if (!stf->isPitchedStaff() || lines >= 5) #endif lineDist = staffType->lineDistance().val(); } // if nothing changed since last layout, do nothing //DEBUG if (curClefType == clefType() && curLines == lines && curLineDist == lineDist) // return; // if something has changed, cache new values and re-layout curClefType = clefType(); curLines = lines; curLineDist = lineDist; layout1(); }