------------------------------------------------------------------------------
| 89 | |
| 90 | //------------------------------------------------------------------------------ |
| 91 | void vtkColorTransferFunctionItem::ComputeTexture() |
| 92 | { |
| 93 | double screenBounds[4]; |
| 94 | this->GetBounds(screenBounds); |
| 95 | if (screenBounds[0] == screenBounds[1] || !this->ColorTransferFunction) |
| 96 | { |
| 97 | return; |
| 98 | } |
| 99 | if (this->Texture == nullptr) |
| 100 | { |
| 101 | this->Texture = vtkImageData::New(); |
| 102 | } |
| 103 | |
| 104 | double dataBounds[4]; |
| 105 | this->TransformScreenToData(screenBounds[0], screenBounds[2], dataBounds[0], dataBounds[2]); |
| 106 | this->TransformScreenToData(screenBounds[1], screenBounds[3], dataBounds[1], dataBounds[3]); |
| 107 | |
| 108 | // Could depend of the screen resolution |
| 109 | const int dimension = this->GetTextureWidth(); |
| 110 | double* values = new double[dimension]; |
| 111 | // Texture 1D |
| 112 | this->Texture->SetExtent(0, dimension - 1, 0, 0, 0, 0); |
| 113 | this->Texture->AllocateScalars(VTK_UNSIGNED_CHAR, 4); |
| 114 | for (int i = 0; i < dimension; ++i) |
| 115 | { |
| 116 | values[i] = dataBounds[0] + i * (dataBounds[1] - dataBounds[0]) / (dimension - 1); |
| 117 | } |
| 118 | unsigned char* ptr = reinterpret_cast<unsigned char*>(this->Texture->GetScalarPointer(0, 0, 0)); |
| 119 | this->ColorTransferFunction->MapScalarsThroughTable2( |
| 120 | values, ptr, VTK_DOUBLE, dimension, VTK_LUMINANCE, VTK_RGBA); |
| 121 | if (this->Opacity != 1.0) |
| 122 | { |
| 123 | for (int i = 0; i < dimension; ++i) |
| 124 | { |
| 125 | ptr[3] = static_cast<unsigned char>(this->Opacity * ptr[3]); |
| 126 | ptr += 4; |
| 127 | } |
| 128 | } |
| 129 | delete[] values; |
| 130 | } |
| 131 | |
| 132 | //------------------------------------------------------------------------------ |
| 133 | bool vtkColorTransferFunctionItem::ConfigurePlotBar() |
nothing calls this directly
no test coverage detected