tools/drawMapTest/mainwindow.cpp
author unC0Rr
Wed, 01 Dec 2010 20:45:05 +0300
changeset 4439 27a896207aae
parent 4434 34c305fbc63c
child 4442 f8424e1bc936
permissions -rw-r--r--
Some more improvements
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4425
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
     1
#include "mainwindow.h"
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
     2
#include "ui_mainwindow.h"
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
     3
#include "drawmapscene.h"
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
     4
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
     5
MainWindow::MainWindow(QWidget *parent) :
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
     6
    QMainWindow(parent),
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
     7
    ui(new Ui::MainWindow)
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
     8
{
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
     9
    ui->setupUi(this);
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    10
4427
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    11
    scene = new DrawMapScene(this);
4425
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    12
    ui->graphicsView->setScene(scene);
4426
969e411c72aa Improve map editor a bit
unc0rr
parents: 4425
diff changeset
    13
969e411c72aa Improve map editor a bit
unc0rr
parents: 4425
diff changeset
    14
    connect(ui->pbUndo, SIGNAL(clicked()), scene, SLOT(undo()));
4427
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    15
    connect(scene, SIGNAL(pathChanged()), this, SLOT(scene_pathChanged()));
4425
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    16
}
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    17
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    18
MainWindow::~MainWindow()
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    19
{
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    20
    delete ui;
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    21
}
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    22
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    23
void MainWindow::changeEvent(QEvent *e)
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    24
{
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    25
    QMainWindow::changeEvent(e);
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    26
    switch (e->type()) {
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    27
    case QEvent::LanguageChange:
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    28
        ui->retranslateUi(this);
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    29
        break;
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    30
    default:
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    31
        break;
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    32
    }
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    33
}
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    34
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    35
void MainWindow::resizeEvent(QResizeEvent * event)
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    36
{
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    37
    Q_UNUSED(event);
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    38
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    39
    if(ui->graphicsView)
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    40
        ui->graphicsView->fitInView(ui->graphicsView->scene()->sceneRect(), Qt::KeepAspectRatio);
2314bb0c433d Small testing app for DrawMap scene
unc0rr
parents:
diff changeset
    41
}
4427
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    42
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    43
void MainWindow::scene_pathChanged()
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    44
{
4439
27a896207aae Some more improvements
unC0Rr
parents: 4434
diff changeset
    45
    QString str = scene->encode().toBase64();
27a896207aae Some more improvements
unC0Rr
parents: 4434
diff changeset
    46
    ui->plainTextEdit->setPlainText(str);
27a896207aae Some more improvements
unC0Rr
parents: 4434
diff changeset
    47
    ui->sbBytes->setValue(str.size());
4427
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    48
}
4434
34c305fbc63c Simple simplify() function
unc0rr
parents: 4427
diff changeset
    49
34c305fbc63c Simple simplify() function
unc0rr
parents: 4427
diff changeset
    50
void MainWindow::on_pbSimplify_clicked()
34c305fbc63c Simple simplify() function
unc0rr
parents: 4427
diff changeset
    51
{
4439
27a896207aae Some more improvements
unC0Rr
parents: 4434
diff changeset
    52
    scene->simplifyLast();
4434
34c305fbc63c Simple simplify() function
unc0rr
parents: 4427
diff changeset
    53
}