Changeset 55 in tspsg-svn for trunk/src


Ignore:
Timestamp:
Aug 11, 2009, 6:54:01 PM (15 years ago)
Author:
laleppa
Message:

+ PDF format option when saving solution if platform supports printing.

  • Check alternative candidates for subcycles.
Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/globals.h

    r54 r55  
    3939#define DEF_RAND_MAX 10
    4040#define DEF_NUM_CITIES 5
    41 #define DEF_OFFSET 100
    4241#define DEF_FONT_FAMILY "Courier New"
    4342#define DEF_FONT_SIZE 10
  • trunk/src/mainwindow.cpp

    r54 r55  
    280280static QString selectedFile;
    281281        if (selectedFile.isEmpty())
     282#ifndef QT_NO_PRINTER
     283                selectedFile = "solution.pdf";
     284#else
    282285                selectedFile = "solution.html";
     286#endif // QT_NO_PRINTER
    283287QFileDialog sd(this);
    284288        sd.setAcceptMode(QFileDialog::AcceptSave);
    285 QStringList filters(trUtf8("HTML Files") + " (*.html *.htm)");
     289QStringList filters;
     290#ifndef QT_NO_PRINTER
     291        filters.append(trUtf8("PDF Files") + "(*.pdf)");
     292#endif
     293        filters.append(trUtf8("HTML Files") + " (*.html *.htm)");
    286294#if QT_VERSION >= 0x040500
    287295        filters.append(trUtf8("OpenDocument Files") + " (*.odt)");
     
    297305        selectedFile = files.first();
    298306        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
     307#ifndef QT_NO_PRINTER
     308        if (selectedFile.endsWith(".pdf",Qt::CaseInsensitive)) {
     309QPrinter printer(QPrinter::HighResolution);
     310                printer.setOutputFormat(QPrinter::PdfFormat);
     311                printer.setOutputFileName(selectedFile);
     312                solutionText->document()->print(&printer);
     313                QApplication::restoreOverrideCursor();
     314                return;
     315        }
     316#endif
    299317#if QT_VERSION >= 0x040500
    300318QTextDocumentWriter dw(selectedFile);
     
    488506{
    489507        // TODO: Normal about window :-)
    490 QString about = QString::fromUtf8("TSPSG - TSP Solver and Generator\n");
     508QString about = QString::fromUtf8("TSPSG: TSP Solver and Generator\n");
    491509        about += QString::fromUtf8("    Version: "BUILD_VERSION"\n");
    492510        about += QString::fromUtf8("    Copyright (C) 2007-%1 Lёppa <contacts[at]oleksii[dot]name>\n").arg(QDate::currentDate().toString("yyyy"));
  • trunk/src/tspsolver.cpp

    r54 r55  
    9797        for (int r = 0; r < nCities; r++)
    9898                for (int c = 0; c < nCities; c++)
    99 //                      if ((matrix[r][c] == 0) && !forbidden.values(r).contains(c)) {
     99//                      if ((matrix.at(r).at(c) == 0) && !forbidden.values(r).contains(c)) {
    100100                        if (matrix.at(r).at(c) == 0) {
    101101                                sum = findMinInRow(r,matrix,c) + findMinInCol(c,matrix,r);
     
    105105                                        nCol = c;
    106106                                        alts = false;
    107                                 } else if (sum == h)
     107                                } else if ((sum == h) && !hasSubCycles(r,c))
    108108                                        alts = true;
    109109                        }
Note: See TracChangeset for help on using the changeset viewer.