tools/drawMapTest/mainwindow.cpp
author unc0rr
Mon, 29 Nov 2010 22:23:56 +0300
changeset 4434 34c305fbc63c
parent 4427 c5193713055f
child 4439 27a896207aae
permissions -rw-r--r--
Simple simplify() function
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
{
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    45
    ui->plainTextEdit->setPlainText(scene->encode().toBase64());
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    46
}
4434
34c305fbc63c Simple simplify() function
unc0rr
parents: 4427
diff changeset
    47
34c305fbc63c Simple simplify() function
unc0rr
parents: 4427
diff changeset
    48
void MainWindow::on_pbSimplify_clicked()
34c305fbc63c Simple simplify() function
unc0rr
parents: 4427
diff changeset
    49
{
34c305fbc63c Simple simplify() function
unc0rr
parents: 4427
diff changeset
    50
    scene->simplify();
34c305fbc63c Simple simplify() function
unc0rr
parents: 4427
diff changeset
    51
}