-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswftSimplePipelineViewer.cpp
246 lines (180 loc) · 8 KB
/
swftSimplePipelineViewer.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#include "swftSimplePipelineViewer.h"
#include "ui_swftSimplePipelineViewer.h"
#include "swftSimplePipelineElement.h"
#include "pqActiveObjects.h"
#include "pqApplicationCore.h"
#include "pqDisplayPolicy.h"
#include "pqLiveInsituVisualizationManager.h"
#include "pqOutputPort.h"
#include "pqPipelineAnnotationFilterModel.h"
#include "pqPipelineModel.h"
#include "pqPipelineModelSelectionAdaptor.h"
#include "pqPipelineSource.h"
#include "pqServer.h"
#include "pqServerManagerModel.h"
#include "pqUndoStack.h"
#include "pqView.h"
#include <QHeaderView>
#include <QKeyEvent>
#include <QSpacerItem>
#include <assert.h>
#define DEBUG 0
//=========================================================================
swftSimplePipelineViewer::swftSimplePipelineViewer(QWidget *parent) :
QWidget(parent),
ui(new Ui::swftSimplePipelineViewer)
{
// std::cout << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << std::endl;
ui->setupUi(this);
//get the pipeline model
this->PipelineModel = new pqPipelineModel(this);
this->FilteredPipelineModel = new pqPipelineAnnotationFilterModel(this);
this->FilteredPipelineModel->setSourceModel(this->PipelineModel);
//build the node list (will be empty at first)
this->leafList = new swftPipelineLeafListView(this->PipelineModel);
//Connect the model to the ServerManager model
pqServerManagerModel *smModel = pqApplicationCore::instance()->getServerManagerModel();
//connect the relevent signals/slots
QObject::connect(smModel, SIGNAL(preServerAdded(pqServer*)),
this->PipelineModel, SLOT(addServer(pqServer*)));
QObject::connect(smModel, SIGNAL(serverRemoved(pqServer*)),
this->PipelineModel, SLOT(removeServer(pqServer*)));
QObject::connect(smModel, SIGNAL(sourceAdded(pqPipelineSource*)),
this->PipelineModel, SLOT(addSource(pqPipelineSource*)));
QObject::connect(smModel, SIGNAL(sourceRemoved(pqPipelineSource*)),
this->PipelineModel, SLOT(removeSource(pqPipelineSource*)));
QObject::connect(smModel, SIGNAL(connectionAdded(pqPipelineSource*,pqPipelineSource*,int)),
this->PipelineModel, SLOT(addConnection(pqPipelineSource*,pqPipelineSource*,int)));
QObject::connect(smModel, SIGNAL(connectionRemoved(pqPipelineSource*,pqPipelineSource*,int)),
this->PipelineModel, SLOT(removeConnection(pqPipelineSource*,pqPipelineSource*,int)));
QObject::connect(&pqActiveObjects::instance(), SIGNAL(viewChanged(pqView*)),
this, SLOT(setActiveView(pqView*)));
}
QFrame* swftSimplePipelineViewer::lineWidget(const QString name)
{
QFrame *line;
line = new QFrame();
line->setObjectName(name);
line->setFrameShape(QFrame::HLine);
return line;
}
swftSimplePipelineViewer::~swftSimplePipelineViewer()
{
delete ui;
}
//-----------------------------------------------------------------------//
void swftSimplePipelineViewer::setActiveView(pqView *view)
{
//set the new view
this->PipelineModel->setView(view);
if(view && DEBUG)
{
std::cout << "Active View: " << this->PipelineModel->view()->getSMName().toAscii().data() << std::endl;
}
//repolulate the view based on new active view
this->populateControls(view);
}
//----------------------------------------------------------------------//
void swftSimplePipelineViewer::handleIndexClicked(const QModelIndex &index_)
{
// std::cout << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << std::endl;
}
//-------------------------------------------------------------------//
void swftSimplePipelineViewer::enableAnnotationFilter(const QString &annotationKey)
{
this->FilteredPipelineModel->enableAnnotationFilter(annotationKey);
}
//-------------------------------------------------------------------//
void swftSimplePipelineViewer::disableAnnotationFilter()
{
this->FilteredPipelineModel->disableAnnotationFilter();
}
//------------------------------------------------------------------//
void swftSimplePipelineViewer::enableSessionFilter(vtkSession *session)
{
this->FilteredPipelineModel->enableSessionFilter(session);
}
//------------------------------------------------------------------//
void swftSimplePipelineViewer::disableSessionFilter()
{
this->FilteredPipelineModel->disableSessionFilter();
}
//------------------------------------------------------------------//
void swftSimplePipelineViewer::updateData(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
// std::cout << __FILE__ << " " << __FUNCTION__ << " Line: " << __LINE__ << std::endl;
}
//------------------------------------------------------------------//
const QModelIndex swftSimplePipelineViewer::pipelineModelIndex(const QModelIndex &index) const
{
if(qobject_cast<const pqPipelineModel*>(index.model()))
{
return index;
}
const QSortFilterProxyModel *filterModel = qobject_cast<const QSortFilterProxyModel *>(index.model());
//make a recursive call to support unknown filter depth
return this->pipelineModelIndex(filterModel->mapToSource(index));
}
//-----------------------------------------------------------------//
const pqPipelineModel* swftSimplePipelineViewer::getPipelineModel(const QModelIndex &index) const
{
if(const pqPipelineModel* model = qobject_cast<const pqPipelineModel*>(index.model()))
{
return model;
}
const QSortFilterProxyModel *filterModel = qobject_cast<const QSortFilterProxyModel*>(index.model());
assert("Invalid model used inside index" && filterModel);
return this->getPipelineModel(filterModel->mapToSource(index));
}
//-----------------------------------------------------------------//
void swftSimplePipelineViewer::populateControls(pqView *view)
{
//1) Remove existing controlls
// std::cout << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << std::endl;
if(ui->scrollAreaWidgetContents->layout() != NULL)
{
QLayoutItem* item;
while ( ( item = ui->scrollAreaWidgetContents->layout()->takeAt( 0 ) ) != NULL )
{
if(item)
{
delete item->widget();
delete item;
}
}
}
//2) populate with new controlls
QSpacerItem *verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
if(view)
{
//parse view name
QString viewName = view->getSMName();
std::cout << "viewName: " << viewName.toAscii().data() << std::endl;
//find the active units for this view, and build the controller objects
for(int y = 0; y < this->leafList->nodeList.count(); y++)
{
if(this->leafList->nodeList[y]->tags.size() > 0 && viewName.contains(this->leafList->nodeList[y]->tags[0]))
{
std::cout << "Parsing Control Elemenets" << std::endl;
std::cout << "View Name: " << viewName.toAscii().data() << std::endl;
std::cout << "Tag: " << this->leafList->nodeList[y]->tags[0].toAscii().data() << std::endl;
swftSimplePipelineElement *newControl = new swftSimplePipelineElement();
const QString toolName = this->leafList->nodeList[y]->name;
//store reference in controller object (so we know what is being clicked!)
newControl->setPipelineLink(this->leafList);
newControl->setPipelineIndex(y);
//set the name in the tool to represent pipeline name
newControl->setToolName(toolName);
//set the tool status
newControl->setToolState(this->leafList->nodeList[y]->itemSelected);
ui->scrollAreaWidgetContents->layout()->addWidget(newControl);
}
}
}
ui->scrollAreaWidgetContents->layout()->addItem(verticalSpacer);
}
//-----------------------------------------------------------------//
void swftSimplePipelineViewer::expandWithModelIndexTranslation(const QModelIndex &index)
{
// remove if we dont need this function
}