------------------------------------------------------------------------------
| 786 | |
| 787 | //------------------------------------------------------------------------------ |
| 788 | std::string vtkHeatmapItem::GetTooltipText(float x, float y) |
| 789 | { |
| 790 | int sceneRow = 0; |
| 791 | int sceneColumn = 0; |
| 792 | int orientation = this->GetOrientation(); |
| 793 | if (orientation == vtkHeatmapItem::UP_TO_DOWN || orientation == vtkHeatmapItem::DOWN_TO_UP) |
| 794 | { |
| 795 | sceneRow = static_cast<int>(floor(fabs(x - this->Position[0]) / this->CellHeight)); |
| 796 | sceneColumn = static_cast<int>(floor((y - this->MinY) / this->CellWidth)); |
| 797 | } |
| 798 | else |
| 799 | { |
| 800 | sceneRow = static_cast<int>(floor(fabs(y - this->Position[1]) / this->CellHeight)); |
| 801 | sceneColumn = static_cast<int>(floor((x - this->MinX) / this->CellWidth)); |
| 802 | } |
| 803 | |
| 804 | vtkIdType row = -1; |
| 805 | if (static_cast<unsigned int>(sceneRow) < this->SceneRowToTableRowMap.size()) |
| 806 | { |
| 807 | row = this->SceneRowToTableRowMap[sceneRow]; |
| 808 | } |
| 809 | vtkIdType column = -1; |
| 810 | if (static_cast<unsigned int>(sceneColumn) < this->SceneColumnToTableColumnMap.size()) |
| 811 | { |
| 812 | column = this->SceneColumnToTableColumnMap[sceneColumn]; |
| 813 | } |
| 814 | |
| 815 | if (row > -1 && column > -1) |
| 816 | { |
| 817 | std::string rowName; |
| 818 | if (this->RowNames) |
| 819 | { |
| 820 | rowName = this->RowNames->GetValue(row); |
| 821 | } |
| 822 | else |
| 823 | { |
| 824 | std::stringstream ss; |
| 825 | ss << row; |
| 826 | rowName = ss.str(); |
| 827 | } |
| 828 | if (this->BlankRows.find(rowName) != this->BlankRows.end()) |
| 829 | { |
| 830 | return ""; |
| 831 | } |
| 832 | |
| 833 | std::string columnName = this->Table->GetColumn(column)->GetName(); |
| 834 | |
| 835 | std::string tooltipText = "("; |
| 836 | tooltipText += rowName; |
| 837 | tooltipText += ", "; |
| 838 | tooltipText += columnName; |
| 839 | tooltipText += ")\n"; |
| 840 | tooltipText += this->Table->GetValue(row, column).ToString(); |
| 841 | |
| 842 | return tooltipText; |
| 843 | } |
| 844 | return ""; |
| 845 | } |