MCPcopy Create free account
hub / github.com/Kitware/VTK / GetClickedCollapsedSubTree

Method GetClickedCollapsedSubTree

Views/Infovis/vtkDendrogramItem.cxx:816–911  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

814
815//------------------------------------------------------------------------------
816vtkIdType vtkDendrogramItem::GetClickedCollapsedSubTree(double x, double y)
817{
818 // iterate over all the collapsed subtrees to see if this click refers
819 // to one of them.
820 vtkUnsignedIntArray* vertexIsPruned =
821 vtkArrayDownCast<vtkUnsignedIntArray>(this->Tree->GetVertexData()->GetArray("VertexIsPruned"));
822 vtkIdTypeArray* originalIdArray =
823 vtkArrayDownCast<vtkIdTypeArray>(this->PrunedTree->GetVertexData()->GetArray("OriginalId"));
824 int orientation = this->GetOrientation();
825
826 for (vtkIdType originalId = 0; originalId < vertexIsPruned->GetNumberOfTuples(); ++originalId)
827 {
828 if (vertexIsPruned->GetValue(originalId) > 0)
829 {
830 // Find PrunedTree's vertex that corresponds to this originalId.
831 for (vtkIdType prunedId = 0; prunedId < originalIdArray->GetNumberOfTuples(); ++prunedId)
832 {
833 if (originalIdArray->GetValue(prunedId) == originalId)
834 {
835 // determined where this collapsed subtree is rooted.
836 double point[3];
837 this->LayoutTree->GetPoint(prunedId, point);
838 point[0] = point[0] * this->MultiplierX + this->Position[0];
839 point[1] = point[1] * this->MultiplierY + this->Position[1];
840
841 // we also need the location of this node's parent
842 double parentPoint[3];
843 this->LayoutTree->GetPoint(this->LayoutTree->GetParent(prunedId), parentPoint);
844 parentPoint[0] = parentPoint[0] * this->MultiplierX + this->Position[0];
845 parentPoint[1] = parentPoint[1] * this->MultiplierY + this->Position[1];
846
847 float xMin = 0.0;
848 float xMax = 0.0;
849 float yMin = 0.0;
850 float yMax = 0.0;
851
852 switch (orientation)
853 {
854 case vtkDendrogramItem::DOWN_TO_UP:
855 // proper width (X) range: within +/- LeafSpacing of the vertex's
856 // X value.
857 xMin = point[0] - this->LeafSpacing / 2;
858 xMax = point[0] + this->LeafSpacing / 2;
859
860 // proper height (Y) range: >= parent's Y value
861 yMin = parentPoint[1];
862 yMax = this->MaxY;
863 break;
864
865 case vtkDendrogramItem::RIGHT_TO_LEFT:
866 // proper width (X) range: <= parent's X value.
867 xMin = this->MinX;
868 xMax = parentPoint[0];
869
870 // proper height (Y) range: within +/- LeafSpacing of the vertex's
871 // Y value.
872 yMin = point[1] - this->LeafSpacing / 2;
873 yMax = point[1] + this->LeafSpacing / 2;

Callers 1

MouseDoubleClickEventMethod · 0.95

Calls 7

GetOrientationMethod · 0.95
GetVertexDataMethod · 0.80
GetArrayMethod · 0.45
GetNumberOfTuplesMethod · 0.45
GetValueMethod · 0.45
GetPointMethod · 0.45
GetParentMethod · 0.45

Tested by

no test coverage detected