-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
61 lines (52 loc) · 1.57 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>
#include "galfile.h"
#include "chipplotter.h"
#include <QDebug>
#include "spotgraphicsitem.h"
#include "spot.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->actionFileOpen,SIGNAL(triggered()),SLOT(openGalFile()));
connect(ui->pushButtonZoomIn,SIGNAL(pressed()),ui->chipView,SLOT(zoomIn()));
connect(ui->pushButtonZoomOut,SIGNAL(pressed()),ui->chipView,SLOT(zoomOut()));
connect(ui->pushButtonSaveSeleceted,SIGNAL(pressed()),SLOT(saveSelectedItems()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::openGalFile()
{
QString fileName = QFileDialog::getOpenFileName();
_galFileList.append(new GalFile(fileName,this));
drawChip(_galFileList.last());
}
void MainWindow::drawChip(GalFile *file)
{
ChipPlotter * cp = new ChipPlotter(file,this);
QGraphicsScene * scene = cp->scene();
ui->chipView->setScene(scene);
ui->chipView->show();
ui->chipView->fitInView(scene->sceneRect(),Qt::KeepAspectRatio);
}
void MainWindow::saveSelectedItems()
{
QList<QGraphicsItem *> items = ui->chipView->scene()->selectedItems();
bool first = true;
foreach (QGraphicsItem * item, items) {
SpotGraphicsItem * spot =qgraphicsitem_cast<SpotGraphicsItem *> (item);
if (spot != 0)
{
if(first)
{
qDebug() << spot->spot()->dataNamesAsString();
}
qDebug() << spot->spot()->dataAsString();
}
}
}