Changeset 107 in tspsg-svn for trunk/src/mainwindow.cpp
- Timestamp:
- Apr 25, 2010, 4:36:27 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/mainwindow.cpp
r106 r107 510 510 pb->setFormat(tr("Generating header")); 511 511 pd.setLabelText(tr("Generating solution output...")); 512 pd.setMaximum( n);512 pd.setMaximum(solver.getTotalSteps() + 1); 513 513 pd.setValue(0); 514 514 … … 517 517 518 518 QPainter pic; 519 pic.begin(&graph); 520 pic.setRenderHint(QPainter::Antialiasing); 519 if (settings->value("Output/ShowGraph", DEF_SHOW_GRAPH).toBool()) { 520 pic.begin(&graph); 521 pic.setRenderHint(QPainter::Antialiasing); 522 } 521 523 522 524 QTextDocument *doc = solutionText->document(); … … 529 531 cur.insertText(tr("Task:")); 530 532 outputMatrix(cur, matrix); 531 drawNode(pic, 0); 533 if (settings->value("Output/ShowGraph", DEF_SHOW_GRAPH).toBool()) 534 drawNode(pic, 0); 532 535 cur.insertHtml("<hr>"); 533 536 cur.insertBlock(fmt_paragraph); … … 537 540 538 541 SStep *step = root; 539 542 int c = n = 1; 540 543 pb->setFormat(tr("Generating step %v")); 541 while ( n < spinCities->value()) {544 while ((step->next != SStep::NoNextStep) && (c < spinCities->value())) { 542 545 if (pd.wasCanceled()) { 543 546 pd.setLabelText(tr("Cleaning up...")); … … 553 556 pd.setValue(n); 554 557 555 if (step->prNode->prNode != NULL || ((step->prNode->prNode == NULL) && (step->plNode->prNode == NULL))) { 556 if (n != spinCities->value()) { 557 cur.beginEditBlock(); 558 cur.insertBlock(fmt_paragraph); 559 cur.insertText(tr("Step #%1").arg(n++)); 560 if (settings->value("Output/ShowMatrix", DEF_SHOW_MATRIX).toBool() && (!settings->value("Output/UseShowMatrixLimit", DEF_USE_SHOW_MATRIX_LIMIT).toBool() || (settings->value("Output/UseShowMatrixLimit", DEF_USE_SHOW_MATRIX_LIMIT).toBool() && (spinCities->value() <= settings->value("Output/ShowMatrixLimit", DEF_SHOW_MATRIX_LIMIT).toInt())))) { 561 outputMatrix(cur, *step); 562 } 563 cur.insertBlock(fmt_paragraph); 564 cur.insertText(tr("Selected candidate for branching: %1.").arg(tr("(%1;%2)").arg(step->candidate.nRow + 1).arg(step->candidate.nCol + 1)), fmt_default); 565 if (!step->alts.empty()) { 566 SCandidate cand; 567 QString alts; 568 foreach(cand, step->alts) { 569 if (!alts.isEmpty()) 570 alts += ", "; 571 alts += tr("(%1;%2)").arg(cand.nRow + 1).arg(cand.nCol + 1); 572 } 573 cur.insertBlock(fmt_paragraph); 574 cur.insertText(tr("%n alternate candidate(s) for branching: %1.", "", step->alts.count()).arg(alts), fmt_altlist); 575 } 576 cur.insertBlock(fmt_paragraph); 577 cur.insertText(" ", fmt_default); 578 cur.endEditBlock(); 558 cur.beginEditBlock(); 559 cur.insertBlock(fmt_paragraph); 560 cur.insertText(tr("Step #%1").arg(n)); 561 if (settings->value("Output/ShowMatrix", DEF_SHOW_MATRIX).toBool() && (!settings->value("Output/UseShowMatrixLimit", DEF_USE_SHOW_MATRIX_LIMIT).toBool() || (settings->value("Output/UseShowMatrixLimit", DEF_USE_SHOW_MATRIX_LIMIT).toBool() && (spinCities->value() <= settings->value("Output/ShowMatrixLimit", DEF_SHOW_MATRIX_LIMIT).toInt())))) { 562 outputMatrix(cur, *step); 563 } 564 cur.insertBlock(fmt_paragraph); 565 cur.insertText(tr("Selected route %1 %2 part.").arg((step->next == SStep::RightBranch) ? tr("with") : tr("without")).arg(tr("(%1;%2)").arg(step->candidate.nRow + 1).arg(step->candidate.nCol + 1)), fmt_default); 566 if (!step->alts.empty()) { 567 SStep::SCandidate cand; 568 QString alts; 569 foreach(cand, step->alts) { 570 if (!alts.isEmpty()) 571 alts += ", "; 572 alts += tr("(%1;%2)").arg(cand.nRow + 1).arg(cand.nCol + 1); 579 573 } 580 } 581 if (n < spinCities->value()) { 574 cur.insertBlock(fmt_paragraph); 575 cur.insertText(tr("%n alternate candidate(s) for branching: %1.", "", step->alts.count()).arg(alts), fmt_altlist); 576 } 577 cur.insertBlock(fmt_paragraph); 578 cur.insertText(" ", fmt_default); 579 cur.endEditBlock(); 580 581 if (settings->value("Output/ShowGraph", DEF_SHOW_GRAPH).toBool()) { 582 582 if (step->prNode != NULL) 583 drawNode(pic, n - 1, false, step->prNode);583 drawNode(pic, n, false, step->prNode); 584 584 if (step->plNode != NULL) 585 drawNode(pic, n - 1, true, step->plNode); 586 } 587 if (step->prNode->prNode != NULL) { 585 drawNode(pic, n, true, step->plNode); 586 } 587 n++; 588 589 if (step->next == SStep::RightBranch) { 590 c++; 588 591 step = step->prNode; 589 } else if (step-> plNode->prNode != NULL) {592 } else if (step->next == SStep::LeftBranch) { 590 593 step = step->plNode; 591 594 } else … … 617 620 } 618 621 cur.endEditBlock(); 619 pic.end(); 622 623 if (settings->value("Output/ShowGraph", DEF_SHOW_GRAPH).toBool()) { 624 pic.end(); 620 625 621 626 QImage i(graph.width() + 2, graph.height() + 2, QImage::Format_ARGB32); 622 i.fill(0);623 pic.begin(&i);624 pic.drawPicture(1, 1, graph);625 pic.end();626 doc->addResource(QTextDocument::ImageResource, QUrl("tspsg://graph.pic"), i);627 i.fill(0); 628 pic.begin(&i); 629 pic.drawPicture(1, 1, graph); 630 pic.end(); 631 doc->addResource(QTextDocument::ImageResource, QUrl("tspsg://graph.pic"), i); 627 632 628 633 QTextImageFormat img; 629 img.setName("tspsg://graph.pic"); 630 631 cur.setPosition(imgpos); 632 cur.insertImage(img, QTextFrameFormat::FloatRight); 634 img.setName("tspsg://graph.pic"); 635 636 cur.setPosition(imgpos); 637 cur.insertImage(img, QTextFrameFormat::FloatRight); 638 } 633 639 634 640 if (settings->value("Output/ScrollToEnd", DEF_SCROLL_TO_END).toBool()) { … … 784 790 } 785 791 pic.setBackgroundMode(Qt::OpaqueMode); 786 pic.drawText(QRectF(x - r, y - r, r * 2, r * 2), Qt::AlignCenter, isInteger(step->price) ? QString("\n%1").arg(step->price) : QString("\n%1").arg(step->price, 0, 'f', settings->value("Task/FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt())); 792 if (step->price != INFINITY) { 793 pic.drawText(QRectF(x - r, y - r, r * 2, r * 2), Qt::AlignCenter, isInteger(step->price) ? QString("\n%1").arg(step->price) : QString("\n%1").arg(step->price, 0, 'f', settings->value("Task/FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt())); 794 } else { 795 pic.drawText(QRectF(x - r, y - r, r * 2, r * 2), Qt::AlignCenter, "\n"INFSTR); 796 } 787 797 pic.setBackgroundMode(Qt::TransparentMode); 788 798 } else { … … 790 800 } 791 801 792 if (nstep == 1) 793 pic.drawLine(QPointF(r * 2.25, r * (3 * (nstep - 1) + 2)), QPointF(x, y - r)); 794 else 795 pic.drawLine(QPointF(r * 3.5, r * (3 * (nstep - 1) + 2)), QPointF(x, y - r)); 802 if (nstep == 1) { 803 pic.drawLine(QPointF(x, y - r), QPointF(r * 2.25, y - 2 * r)); 804 } else if (nstep > 1) { 805 pic.drawLine(QPointF(x, y - r), QPointF((step->pNode->next == SStep::RightBranch) ? r * 3.5 : r, y - 2 * r)); 806 } 796 807 797 808 } … … 806 817 toggleSolutionActions(false); 807 818 808 ev->acceptProposedAction(); 819 ev->setDropAction(Qt::CopyAction); 820 ev->accept(); 809 821 } 810 822 } … … 992 1004 cur.insertText(isInteger(step.matrix.at(r).at(c)) ? QString("%1").arg(step.matrix.at(r).at(c)) : QString("%1").arg(step.matrix.at(r).at(c), 0, 'f', settings->value("Task/FractionalAccuracy", DEF_FRACTIONAL_ACCURACY).toInt()), fmt_selected); 993 1005 else { 994 S Candidate cand;1006 SStep::SCandidate cand; 995 1007 cand.nRow = r; 996 1008 cand.nCol = c;
Note: See TracChangeset
for help on using the changeset viewer.