mainwindow.cpp 2.27 KB
Newer Older
1
2
3
4
#include "mainwindow.h"

#include "tgt/assert.h"
#include "application/tumvisapplication.h"
5
6
#include "core/pipeline/abstractpipeline.h"
#include "core/pipeline/abstractprocessor.h"
7
8
9
10
11
12
13
14
15
16
17
18
19

namespace TUMVis {

    MainWindow::MainWindow(TumVisApplication* application)
        : QMainWindow()
        , _application(application)
        , _pipelineWidget(0)
    {
        tgtAssert(_application != 0, "Application must not be 0.");
        setup();
    }

    MainWindow::~MainWindow() {
schultezub's avatar
schultezub committed
20
        _application->s_PipelinesChanged.disconnect(this);
21
22
23
    }

    void MainWindow::setup() {
24
25
        _centralWidget = new QWidget(this);
        QHBoxLayout* boxLayout = new QHBoxLayout();
26
        boxLayout->setSpacing(4);
27

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
        _pipelineWidget = new PipelineTreeWidget(_centralWidget);
        boxLayout->addWidget(_pipelineWidget);

        _propCollectionWidget = new PropertyCollectionWidget(_centralWidget);
        boxLayout->addWidget(_propCollectionWidget);

        _centralWidget->setLayout(boxLayout);
        setCentralWidget(_centralWidget);

        connect(
            this, SIGNAL(updatePipelineWidget(const std::vector<AbstractPipeline*>&)), 
            _pipelineWidget, SLOT(update(const std::vector<AbstractPipeline*>&)));
        connect(
            _pipelineWidget, SIGNAL(clicked(const QModelIndex&)), 
            this, SLOT(onPipelineWidgetItemClicked(const QModelIndex&)));
        connect(
schultezub's avatar
schultezub committed
44
45
            this, SIGNAL(updatePropCollectionWidget(HasPropertyCollection*)),
            _propCollectionWidget, SLOT(updatePropCollection(HasPropertyCollection*)));
46
47
48
49
50
51
52
        _application->s_PipelinesChanged.connect(this, &MainWindow::onPipelinesChanged);
    }

    void MainWindow::onPipelinesChanged() {
        emit updatePipelineWidget(_application->_pipelines);
    }

53
54
55
56
57
    void MainWindow::onPipelineWidgetItemClicked(const QModelIndex& index) {
        if (index.isValid()) {
            // Yak, this is so ugly - another reason why GUI programming sucks...
            QVariant item = index.data(Qt::UserRole);
            HasPropertyCollection* ptr = static_cast<HasPropertyCollection*>(item.value<void*>());
58
            emit updatePropCollectionWidget(ptr);
59
60
61
62
63
64
        }
        else {
            emit updatePropCollectionWidget(0);
        }
    }

65
}