------------------------------------------------------------------------------
| 68 | |
| 69 | //------------------------------------------------------------------------------ |
| 70 | void vtkTreeHeatmapItem::SetTable(vtkTable* table) |
| 71 | { |
| 72 | this->Heatmap->SetTable(table); |
| 73 | if (table == nullptr) |
| 74 | { |
| 75 | return; |
| 76 | } |
| 77 | |
| 78 | if (this->Dendrogram->GetTree() != nullptr && |
| 79 | this->Dendrogram->GetTree()->GetNumberOfVertices() != 0) |
| 80 | { |
| 81 | this->Dendrogram->SetDrawLabels(false); |
| 82 | } |
| 83 | this->Heatmap->SetVisible(true); |
| 84 | |
| 85 | // rearrange our table to match the order of the leaf nodes in this tree. |
| 86 | if (this->GetTree() != nullptr && this->GetTree()->GetNumberOfVertices() != 0) |
| 87 | { |
| 88 | this->ReorderTable(); |
| 89 | } |
| 90 | |
| 91 | // add an array to this table's field data to keep track of collapsed rows |
| 92 | // (unless it already has the array) |
| 93 | vtkBitArray* existingRowsArray = |
| 94 | vtkArrayDownCast<vtkBitArray>(this->GetTable()->GetFieldData()->GetArray("collapsed rows")); |
| 95 | if (existingRowsArray) |
| 96 | { |
| 97 | for (vtkIdType row = 0; row < this->GetTable()->GetNumberOfRows(); ++row) |
| 98 | { |
| 99 | existingRowsArray->SetValue(row, 0); |
| 100 | } |
| 101 | } |
| 102 | else |
| 103 | { |
| 104 | vtkSmartPointer<vtkBitArray> collapsedRowsArray = vtkSmartPointer<vtkBitArray>::New(); |
| 105 | collapsedRowsArray->SetNumberOfComponents(1); |
| 106 | collapsedRowsArray->SetName("collapsed rows"); |
| 107 | for (vtkIdType row = 0; row < this->GetTable()->GetNumberOfRows(); ++row) |
| 108 | { |
| 109 | collapsedRowsArray->InsertNextValue(0); |
| 110 | } |
| 111 | this->GetTable()->GetFieldData()->AddArray(collapsedRowsArray); |
| 112 | } |
| 113 | |
| 114 | // add an array to this table's field data to keep track of collapsed columns |
| 115 | // (unless it already has the array) |
| 116 | vtkBitArray* existingColumnsArray = |
| 117 | vtkArrayDownCast<vtkBitArray>(this->GetTable()->GetFieldData()->GetArray("collapsed columns")); |
| 118 | if (existingColumnsArray) |
| 119 | { |
| 120 | for (vtkIdType col = 0; col < this->GetTable()->GetNumberOfColumns(); ++col) |
| 121 | { |
| 122 | existingColumnsArray->SetValue(col, 0); |
| 123 | } |
| 124 | } |
| 125 | else |
| 126 | { |
| 127 | vtkSmartPointer<vtkBitArray> collapsedColumnsArray = vtkSmartPointer<vtkBitArray>::New(); |
nothing calls this directly
no test coverage detected