Changeset 65 in tspsg-svn for trunk/src


Ignore:
Timestamp:
Oct 20, 2009, 9:38:01 PM (15 years ago)
Author:
laleppa
Message:

More code documentation.

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mainwindow.cpp

    r63 r65  
    2424#include "mainwindow.h"
    2525
     26/*!
     27 * \brief Class constructor.
     28 * \param parent Main Window parent widget.
     29 *
     30 *  Initializes Main Window and creates its layout based on target OS.
     31 *  Loads TSPSG settings and opens a task file if it was specified as a commandline parameter.
     32 */
    2633MainWindow::MainWindow(QWidget *parent)
    2734        : QMainWindow(parent)
     
    484491                output.append("<p>" + trUtf8("<b>WARNING!!!</b><br>This result is a record, but it may not be optimal.<br>Iterations need to be continued to check whether this result is optimal or get an optimal one.") + "</p>");
    485492        }
     493        output.append("<p></p>");
    486494        solutionText->setHtml(output.join(""));
    487495        solutionText->setDocumentTitle(trUtf8("Solution of Variant #%1 task").arg(spinVariant->value()));
     496
     497        // Scrolling to the end of text.
     498QTextCursor cursor(solutionText->textCursor());
     499        cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
     500        solutionText->setTextCursor(cursor);
     501
    488502        enableSolutionActions();
    489503        tabWidget->setCurrentIndex(1);
     
    493507void MainWindow::actionHelpAboutTriggered()
    494508{
    495         // TODO: Normal about window :-)
     509//! \todo TODO: Normal about window :-)
    496510QString about = QString::fromUtf8("TSPSG: TSP Solver and Generator\n");
    497511        about += QString::fromUtf8("    Version: "BUILD_VERSION"\n");
     
    569583}
    570584
     585/*!
     586 * \brief Handles Main Window close event.
     587 * \param event Close event.
     588 *
     589 *  Checks whether or not a current task was saved and asks for saving if not.
     590 *  Saves TSPSG settings.
     591 */
    571592void MainWindow::closeEvent(QCloseEvent *event)
    572593{
  • trunk/src/mainwindow.h

    r64 r65  
    1 /*
    2  *  TSPSG: TSP Solver and Generator
    3  *  Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     1/*!
     2 * \class MainWindow
     3 * \brief Class for handling Main Window UI and logic.
     4 * \author Copyright &copy; 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
    45 *
    56 *  $Id$
    67 *  $URL$
     8 *
     9 *  <b>TSPSG: TSP Solver and Generator</b>
    710 *
    811 *  This file is part of TSPSG.
     
    5457        void dataChanged(const QModelIndex &, const QModelIndex &);
    5558#ifndef QT_NO_PRINTER
    56         void printPreview(QPrinter *);
     59        void printPreview(QPrinter *printer);
    5760        void actionFilePrintPreviewTriggered();
    5861        void actionFilePrintTriggered();
  • trunk/src/settingsdialog.cpp

    r58 r65  
    2424#include "settingsdialog.h"
    2525
     26/*!
     27 * \brief Class constructor.
     28 * \param parent Settings Dialog parent widget.
     29 *
     30 * Initializes Settings Dialog and creates its layout based on target OS.
     31 */
    2632SettingsDialog::SettingsDialog(QWidget *parent)
    2733        : QDialog(parent), newFont(false), newColor(false)
     
    218224}
    219225
     226/*!
     227 * \brief Indicates whether or not the font color has been changed.
     228 */
    220229bool SettingsDialog::colorChanged() const
    221230{
     
    223232}
    224233
     234/*!
     235 * \brief Indicates whether or not the font properties have been changed.
     236 */
    225237bool SettingsDialog::fontChanged() const
    226238{
    227239        return newFont;
     240}
     241
     242void SettingsDialog::spinRandMinValueChanged(int val) {
     243        spinRandMax->setMinimum(val);
    228244}
    229245
  • trunk/src/settingsdialog.h

    r64 r65  
    1 /*
    2  *  TSPSG: TSP Solver and Generator
    3  *  Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     1/*!
     2 * \class SettingsDialog
     3 * \brief Class for handling Settings Dialog UI and logic.
     4 * \author Copyright &copy; 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
    45 *
    56 *  $Id$
    67 *  $URL$
     8 *
     9 *  <b>TSPSG: TSP Solver and Generator</b>
    710 *
    811 *  This file is part of TSPSG.
     
    2932#include "ui_settingsdialog.h"
    3033
    31 class SettingsDialog: public QDialog, public Ui::SettingsDialog
     34class SettingsDialog: public QDialog, Ui::SettingsDialog
    3235{
    3336        Q_OBJECT
     
    3639        bool colorChanged() const;
    3740        bool fontChanged() const;
    38 
    39 #ifndef Q_OS_WINCE
    40         QCheckBox *cbSaveState;
    41         QLabel *imgIcon;
    42         QLabel *labelHint;
    43         QFrame *lineVertical;
    44 #endif // Q_OS_WINCE
    4541
    4642private:
     
    5248#ifndef Q_OS_WINCE
    5349        bool event(QEvent *);
    54 #endif
     50
     51        QCheckBox *cbSaveState;
     52        QLabel *imgIcon;
     53        QLabel *labelHint;
     54        QFrame *lineVertical;
     55#endif // Q_OS_WINCE
    5556
    5657private slots:
     
    5859        void buttonColorClicked();
    5960        void buttonFontClicked();
    60         void spinRandMinValueChanged(int val) { spinRandMax->setMinimum(val); }
     61        void spinRandMinValueChanged(int);
    6162};
    6263
  • trunk/src/tspmodel.h

    r50 r65  
    1 /*
    2  *  TSPSG: TSP Solver and Generator
    3  *  Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     1/*!
     2 * \class CTSPModel
     3 * \author Copyright &copy; 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     4 * \brief This class implements table model for manipulating a task.
    45 *
    56 *  $Id$
    67 *  $URL$
     8 *
     9 *  <b>TSPSG: TSP Solver and Generator</b>
    710 *
    811 *  This file is part of TSPSG.
  • trunk/src/tspsolver.cpp

    r64 r65  
    2424#include "tspsolver.h"
    2525
     26//! Class constructor
    2627CTSPSolver::CTSPSolver()
    2728        : nCities(0)
     
    125126}
    126127
    127 // TODO: Comment the algorithm
     128/*!
     129 * \brief Solves the given task.
     130 * \param numCities Number of cities in the task.
     131 * \param task The matrix of city-to-city travel costs.
     132 * \param parent The parent widget for displaying messages and dialogs.
     133 *
     134 * \todo TODO: Comment the algorithm.
     135 */
    128136sStep *CTSPSolver::solve(int numCities, tMatrix task, QWidget *parent)
    129137{
     
    226234}
    227235
     236/*!
     237 * \brief Returns the sorted optimal path, starting from City 1.
     238 */
    228239QString CTSPSolver::getSortedPath() const
    229240{
     
    242253}
    243254
     255/*!
     256 * \brief Returns CTSPSolver's version ID.
     257 *
     258 *  Current version ID is <b>\$Id$</b>.
     259 */
    244260QString CTSPSolver::getVersionId()
    245261{
     
    247263}
    248264
     265/*!
     266 * \brief Returns whether or not the solution is definitely optimal.
     267 *
     268 *  The solution may need some further interations to determine whether it is optimal.
     269 *  In such cases this function returns \p false.
     270 */
    249271bool CTSPSolver::isOptimal() const
    250272{
  • trunk/src/tspsolver.h

    r64 r65  
    1 /*
    2  *  TSPSG: TSP Solver and Generator
    3  *  Copyright (C) 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     1/*!
     2 * \class CTSPSolver
     3 * \author Copyright &copy; 2007-2009 Lёppa <contacts[at]oleksii[dot]name>
     4 * \brief This class solves Travelling Salesman Problem task.
    45 *
    56 *  $Id$
    67 *  $URL$
     8 *
     9 *  <b>TSPSG: TSP Solver and Generator</b>
    710 *
    811 *  This file is part of TSPSG.
     
    2023 *  You should have received a copy of the GNU General Public License
    2124 *  along with TSPSG.  If not, see <http://www.gnu.org/licenses/>.
     25 *
     26 * \todo TODO: Deletion of solution tree on destroy and cleanup.
    2227 */
    2328
     
    2934#include "tspmodel.h"
    3035
     36//! A matrix of city-to-city travel costs.
    3137typedef QList<QList<double> > tMatrix;
    3238
    33 // This structure represents one step of solving
    34 // The tree of such elements will represent the solving process
     39/*!
     40 * \brief This structure represents one step of solving.
     41 *
     42 *  A tree of such elements will represent the solving process.
     43 */
     44//! \todo TODO: List alternative candidates.
    3545struct sStep {
    36         tMatrix matrix; // Steps's matrix
    37         double price; // Price of travel to this step
    38         struct {int nRow; int nCol;} candidate; // Candiadate for branching in current matrix
    39         bool alts; // This matrix has alternative candidates
    40         sStep *plNode, *prNode; // Pointers to left and right branch steps
    41         sStep() { price = candidate.nRow = candidate.nCol = -1; alts = false; plNode = prNode = NULL; } // Default values
     46        tMatrix matrix; //!< This step's matrix
     47        double price; //!< The price of travel to this step
     48        struct {
     49                int nRow; //!< A zero-based row number of the candidate
     50                int nCol; //!< A zero-based column number of the candidate
     51        } candidate; //!< A candiadate for branching in the current matrix
     52        bool alts; //!< Indicates whether or not matrix has alternative candidates
     53        sStep *plNode; //!< Pointer to the left branch step
     54        sStep *prNode; //!< Pointer to the right branch step
     55
     56        //! Assigns default values
     57        sStep() {
     58                price = candidate.nRow = candidate.nCol = -1;
     59                alts = false;
     60                plNode = prNode = NULL;
     61        }
    4262};
    4363
    44 // TSP Solver class
    4564class CTSPSolver
    4665{
Note: See TracChangeset for help on using the changeset viewer.