------------------------------------------------------------------------------
| 165 | |
| 166 | //------------------------------------------------------------------------------ |
| 167 | void vtkTanglegramItem::PositionTree2() |
| 168 | { |
| 169 | // values used to calculate the amount of space we should leave between |
| 170 | // the two trees. |
| 171 | double averageX = ((fabs(this->Tree1Bounds[1] - this->Tree1Bounds[0]) + |
| 172 | fabs(this->Tree2Bounds[1] - this->Tree2Bounds[0])) / |
| 173 | 2.0); |
| 174 | double averageY = ((fabs(this->Tree1Bounds[3] - this->Tree1Bounds[2]) + |
| 175 | fabs(this->Tree2Bounds[3] - this->Tree2Bounds[2])) / |
| 176 | 2.0); |
| 177 | |
| 178 | // the starting X position for tree #2 |
| 179 | double x, x1, x2; |
| 180 | |
| 181 | // the starting Y position for tree #2 |
| 182 | double y, y1, y2; |
| 183 | |
| 184 | switch (this->Orientation) |
| 185 | { |
| 186 | case vtkDendrogramItem::DOWN_TO_UP: |
| 187 | x1 = (this->Tree1Bounds[1] + this->Tree1Bounds[0]) / 2.0; |
| 188 | x2 = (this->Tree2Bounds[1] + this->Tree2Bounds[0]) / 2.0; |
| 189 | x = x1 - x2; |
| 190 | |
| 191 | y = this->Tree1Bounds[3] + fabs(this->Tree2Bounds[3] - this->Tree2Bounds[2]) + averageY; |
| 192 | break; |
| 193 | |
| 194 | case vtkDendrogramItem::UP_TO_DOWN: |
| 195 | x1 = (this->Tree1Bounds[1] + this->Tree1Bounds[0]) / 2.0; |
| 196 | x2 = (this->Tree2Bounds[1] + this->Tree2Bounds[0]) / 2.0; |
| 197 | x = x1 - x2; |
| 198 | |
| 199 | y = this->Tree1Bounds[2] - fabs(this->Tree2Bounds[3] - this->Tree2Bounds[2]) - averageY; |
| 200 | break; |
| 201 | |
| 202 | case vtkDendrogramItem::RIGHT_TO_LEFT: |
| 203 | |
| 204 | x = this->Tree1Bounds[0] - fabs(this->Tree2Bounds[1] - this->Tree2Bounds[0]) - averageX; |
| 205 | |
| 206 | y1 = (this->Tree1Bounds[3] + this->Tree1Bounds[2]) / 2.0; |
| 207 | y2 = (this->Tree2Bounds[3] + this->Tree2Bounds[2]) / 2.0; |
| 208 | y = y1 - y2; |
| 209 | break; |
| 210 | |
| 211 | case vtkDendrogramItem::LEFT_TO_RIGHT: |
| 212 | default: |
| 213 | |
| 214 | x = this->Tree1Bounds[1] + fabs(this->Tree2Bounds[1] - this->Tree2Bounds[0]) + averageX; |
| 215 | |
| 216 | y1 = (this->Tree1Bounds[3] + this->Tree1Bounds[2]) / 2.0; |
| 217 | y2 = (this->Tree2Bounds[3] + this->Tree2Bounds[2]) / 2.0; |
| 218 | y = y1 - y2; |
| 219 | break; |
| 220 | } |
| 221 | |
| 222 | this->Dendrogram2->SetPosition(x, y); |
| 223 | this->PositionSet = true; |
| 224 | } |