35 #include <QApplication>
37 #include "ui_QGoLineageViewerWidget.h"
41 #include <QGridLayout>
44 #include <QInputDialog>
45 #include <QStringList>
48 #include <vtkQtTreeView.h>
51 #include "vtkGraphLayoutView.h"
52 #include "vtkRenderWindow.h"
53 #include "vtkTreeLayoutStrategy.h"
55 #include "vtkLookupTable.h"
56 #include "vtkViewTheme.h"
59 #include "vtkAdjacentVertexIterator.h"
60 #include "vtkMutableDirectedGraph.h"
61 #include "vtkStringArray.h"
62 #include "vtkDoubleArray.h"
63 #include "vtkPoints.h"
67 #include "vtkDataRepresentation.h"
69 #include "vtkDataSetAttributes.h"
72 #include "vtkAnnotationLink.h"
73 #include <vtkEventQtSlotConnect.h>
76 #include "vtkDelaunay2D.h"
77 #include "vtkGraphToPolyData.h"
78 #include "vtkPolyDataMapper.h"
80 #include "vtkRendererCollection.h"
83 #include <QFileDialog>
85 #include "vtkTreeReader.h"
93 this->
ui =
new Ui_QGoLineageViewerWidget;
94 this->
ui->setupUi(
this);
97 m_Graph = vtkSmartPointer<vtkMutableDirectedGraph>::New();
100 m_Tree = vtkSmartPointer<vtkTree>::New();
119 this->
m_connect = vtkSmartPointer<vtkEventQtSlotConnect>::New();
121 vtkCommand::SelectionChangedEvent,
124 vtkCommand::SelectionChangedEvent,
155 this->
ui->graphViewWidget->GetInteractor() );
156 this->
ui->graphViewWidget->SetRenderWindow(
160 this->
m_lut = vtkSmartPointer<vtkLookupTable>::New();
161 this->
m_lut->SetHueRange(0.667, 0.0);
162 this->
m_lut->Build();
165 vtkSmartPointer<vtkViewTheme> theme =
166 vtkSmartPointer<vtkViewTheme>::New();
167 theme->SetPointLookupTable(this->
m_lut);
168 theme->SetCellLookupTable(this->
m_lut);
197 connect(this->
ui->addLineagePushButton, SIGNAL(pressed()),
200 connect(this->
ui->deleteLineagePushButton, SIGNAL(pressed()),
204 connect(this->
ui->colorCheckBox, SIGNAL(stateChanged(
int)),
210 connect(this->
ui->scaleCheckBox, SIGNAL(stateChanged(
int)),
216 connect(this->
ui->labelCheckBox, SIGNAL(stateChanged(
int)),
222 connect(this->
ui->radialCheckBox, SIGNAL(stateChanged(
int)),
224 connect(this->
ui->radialSlider, SIGNAL(valueChanged(
int)),
228 connect(this->
ui->logCheckBox, SIGNAL(stateChanged(
int)),
230 connect(this->
ui->logSpinBox, SIGNAL(valueChanged(
double)),
234 connect(this->
ui->backCheckBox, SIGNAL(stateChanged(
int)),
244 int numberOfArrays =
m_Graph->GetVertexData()->GetNumberOfArrays();
245 this->
ui->colorComboBox->clear();
246 this->
ui->scaleComboBox->clear();
247 this->
ui->labelComboBox->clear();
250 for(
int i=0;i<numberOfArrays; i++)
253 m_Graph->GetVertexData()->GetArrayName(i);
254 this->
ui->labelComboBox->addItem(name);
256 if(
m_Graph->GetVertexData()->GetArray(name))
258 this->
ui->colorComboBox->addItem(name);
259 this->
ui->scaleComboBox->addItem(name);
272 void* vtkNotUsed(clientData),
285 for(
int i = 0; i < files.
size(); i++ )
287 vtkSmartPointer<vtkTreeReader> reader =
288 vtkSmartPointer<vtkTreeReader>::New();
289 reader->SetFileName(files[i].toLocal8Bit().data());
292 vtkSmartPointer<vtkTree> tree =
293 vtkSmartPointer<vtkTree>::New();
294 tree->CheckedDeepCopy(reader->GetOutput());
297 std::pair<QString, vtkSmartPointer<vtkTree> > treePair;
298 treePair.first = files[i];
299 treePair.second = tree;
311 vtkSmartPointer<vtkMutableDirectedGraph> newGraph =
312 vtkSmartPointer<vtkMutableDirectedGraph>::New();
313 vtkIdType rootID = newGraph->AddVertex();
316 vtkSmartPointer<vtkDoubleArray>
id =
317 vtkSmartPointer<vtkDoubleArray>::New();
318 id->SetName(
"Track ID");
319 id->InsertValue(rootID, 0);
321 vtkSmartPointer<vtkDoubleArray>
depth =
322 vtkSmartPointer<vtkDoubleArray>::New();
323 depth->SetName(
"Lineage Depth");
324 depth->InsertValue(rootID, 0);
327 std::list<std::pair<QString, vtkSmartPointer<vtkTree> > >::iterator
333 it->second->GetRoot(),
342 newGraph->GetVertexData()->AddArray(
id);
343 newGraph->GetVertexData()->AddArray(depth);
346 m_Graph->CheckedDeepCopy(newGraph);
347 m_Tree->CheckedDeepCopy(newGraph);
359 vtkSmartPointer<vtkTree> iOldTree,
360 vtkSmartPointer<vtkMutableDirectedGraph> iNewGraph,
361 vtkDoubleArray* iTrackIDArray,
362 unsigned int iDepth, vtkDoubleArray* iDepthArray)
365 vtkIdType newRoot = iNewGraph->AddChild(iParentID);
368 vtkDataArray*
id = iOldTree->GetVertexData()->GetArray(
"Track ID");
369 double value =
id->GetTuple1(iOldID);
370 iTrackIDArray->InsertValue( newRoot, value );
372 iDepthArray->InsertValue(newRoot, iDepth);
375 vtkSmartPointer<vtkAdjacentVertexIterator> it =
376 vtkSmartPointer<vtkAdjacentVertexIterator>::New();
377 iOldTree->GetChildren(iOldID, it);
381 UpdateTree(newRoot, it->Next() , iOldTree, iNewGraph,
383 iDepth+1, iDepthArray);
395 std::list<std::pair<QString, vtkSmartPointer<vtkTree> > >::iterator
400 lineages << it->
first;
406 tr(
"Lineage selection"),
407 tr(
"Please select the lineage you want to delete"),
408 lineages, 0,
false, &ok);
414 if( ! it->first.compare(item) )
453 (state ? this->
ui->scaleComboBox->currentText().toLocal8Bit().data() : NULL);
517 if(this->
ui->radialCheckBox->isChecked() )
550 if(this->
ui->logCheckBox->isChecked() )
572 this->
ui->graphViewWidget->GetRenderWindow()->GetRenderers()
577 this->
ui->graphViewWidget->GetRenderWindow()->GetRenderers()
QString tr(const char *sourceText, const char *disambiguation, int n)
const char * name() const
QByteArray toLocal8Bit() const
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QStringList getOpenFileNames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFlags< QFileDialog::Option > options)