[4] | 1 | /****************************************************************************** |
---|
| 2 | * SAGE - Scalable Adaptive Graphics Environment |
---|
| 3 | * |
---|
| 4 | * Copyright (C) 2004 Electronic Visualization Laboratory, |
---|
| 5 | * University of Illinois at Chicago |
---|
| 6 | * |
---|
| 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright |
---|
| 13 | * notice, this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above |
---|
| 15 | * copyright notice, this list of conditions and the following disclaimer |
---|
| 16 | * in the documentation and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the University of Illinois at Chicago nor |
---|
| 18 | * the names of its contributors may be used to endorse or promote |
---|
| 19 | * products derived from this software without specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
| 22 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
| 23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
| 24 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
---|
| 25 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
---|
| 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
| 27 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
---|
| 28 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
---|
| 29 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
---|
| 30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
---|
| 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | * |
---|
| 33 | * Direct questions, comments etc about SAGE to http://www.evl.uic.edu/cavern/forum/ |
---|
| 34 | * |
---|
| 35 | *****************************************************************************/ |
---|
| 36 | |
---|
| 37 | /*------------------------------------------------------------------------ |
---|
| 38 | - Author: Arun Rao |
---|
| 39 | - Library: Tile Config |
---|
| 40 | - Revision Date: 4/22/2004 |
---|
| 41 | - Module: tile_config.cpp |
---|
| 42 | - Purpose: Contains all class details/implementation for building |
---|
| 43 | - a description of a tile display system, at run time |
---|
| 44 | ---------------------------------------------------------------------------*/ |
---|
| 45 | #include "tile_config.h" |
---|
| 46 | #include <string.h> |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | //---------------------------------------------------------- |
---|
| 50 | // |
---|
| 51 | // |
---|
| 52 | // |
---|
| 53 | // |
---|
| 54 | // |
---|
| 55 | //----------------------------------------------------------- |
---|
| 56 | |
---|
| 57 | Physical_Tile::Physical_Tile():screenWidth(0),screenHeight(0), |
---|
| 58 | leftMullion(0),rightMullion(0),topMullion(0),bottomMullion(0), |
---|
| 59 | id(-1),next(NULL),source(NULL) |
---|
| 60 | { |
---|
| 61 | //nothing else to do |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | Physical_Tile::~Physical_Tile() |
---|
| 65 | { |
---|
| 66 | |
---|
| 67 | source = NULL; |
---|
| 68 | next = NULL; |
---|
| 69 | |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | void Physical_Tile::Source(Display_Node* dn) |
---|
| 73 | { |
---|
| 74 | source = dn; |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | Display_Node* Physical_Tile::Source() |
---|
| 78 | { return source; } |
---|
| 79 | |
---|
| 80 | float Physical_Tile::LowerLeftX(){ return lowerleftX; } |
---|
| 81 | float Physical_Tile::LowerLeftY(){ return lowerleftY; } |
---|
| 82 | |
---|
| 83 | void Physical_Tile::LowerLeftX(float lx){ lowerleftX = lx; } |
---|
| 84 | void Physical_Tile::LowerLeftY(float ly){ lowerleftY = ly; } |
---|
| 85 | |
---|
| 86 | |
---|
| 87 | float Physical_Tile::ScreenWidthDimension() |
---|
| 88 | { return screenWidth; } |
---|
| 89 | |
---|
| 90 | void Physical_Tile::ScreenWidthDimension(float dim) |
---|
| 91 | { screenWidth = dim; } |
---|
| 92 | |
---|
| 93 | float Physical_Tile::ScreenHeightDimension(void) |
---|
| 94 | { return screenHeight; } |
---|
| 95 | |
---|
| 96 | void Physical_Tile::ScreenHeightDimension(float dim) |
---|
| 97 | { screenHeight = dim; } |
---|
| 98 | |
---|
| 99 | float Physical_Tile::TopMullionThickness() |
---|
| 100 | { return topMullion; } |
---|
| 101 | |
---|
| 102 | void Physical_Tile::TopMullionThickness(float t) |
---|
| 103 | { topMullion = t; } |
---|
| 104 | |
---|
| 105 | float Physical_Tile::BottomMullionThickness() |
---|
| 106 | { return bottomMullion; } |
---|
| 107 | |
---|
| 108 | void Physical_Tile::BottomMullionThickness(float t) |
---|
| 109 | { bottomMullion = t; } |
---|
| 110 | |
---|
| 111 | float Physical_Tile::LeftMullionThickness() |
---|
| 112 | { return leftMullion; } |
---|
| 113 | |
---|
| 114 | void Physical_Tile::LeftMullionThickness(float t) |
---|
| 115 | { leftMullion = t; } |
---|
| 116 | |
---|
| 117 | float Physical_Tile::RightMullionThickness() |
---|
| 118 | { return rightMullion; } |
---|
| 119 | |
---|
| 120 | void Physical_Tile::RightMullionThickness(float t) |
---|
| 121 | { rightMullion = t; } |
---|
| 122 | |
---|
| 123 | int Physical_Tile::ID() |
---|
| 124 | { return id; } |
---|
| 125 | |
---|
| 126 | void Physical_Tile::ID(int i) |
---|
| 127 | { id = i; } |
---|
| 128 | |
---|
| 129 | Physical_Tile* Physical_Tile::Next() |
---|
| 130 | { return next; } |
---|
| 131 | |
---|
| 132 | void Physical_Tile::Next(Physical_Tile* n) |
---|
| 133 | { next = n; } |
---|
| 134 | //---------------------------------------------------------- |
---|
| 135 | // |
---|
| 136 | // |
---|
| 137 | // |
---|
| 138 | // |
---|
| 139 | // |
---|
| 140 | //----------------------------------------------------------- |
---|
| 141 | |
---|
| 142 | Virtual_Desktop_Tile::Virtual_Desktop_Tile():lowerLeftX(0),lowerLeftY(0),widthRatio(0), |
---|
| 143 | heightRatio(0),id(-1),next(NULL),nonMullionLLX(0), |
---|
| 144 | nonMullionLLY(0) |
---|
| 145 | { |
---|
| 146 | //do nothing |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | Virtual_Desktop_Tile::~Virtual_Desktop_Tile() |
---|
| 150 | { |
---|
| 151 | |
---|
| 152 | next = NULL; |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | float Virtual_Desktop_Tile::LowerLeftX() |
---|
| 156 | { return lowerLeftX; } |
---|
| 157 | |
---|
| 158 | void Virtual_Desktop_Tile::LowerLeftX(float x) |
---|
| 159 | { lowerLeftX = x; } |
---|
| 160 | |
---|
| 161 | float Virtual_Desktop_Tile::LowerLeftY() |
---|
| 162 | { return lowerLeftY; } |
---|
| 163 | |
---|
| 164 | void Virtual_Desktop_Tile::LowerLeftY(float y) |
---|
| 165 | { lowerLeftY = y; } |
---|
| 166 | |
---|
| 167 | void Virtual_Desktop_Tile::LowerLeftPixelX(int p) |
---|
| 168 | { lowerLeftPixelX = p; } |
---|
| 169 | |
---|
| 170 | void Virtual_Desktop_Tile::LowerLeftPixelY(int p) |
---|
| 171 | { lowerLeftPixelY = p; } |
---|
| 172 | |
---|
| 173 | void Virtual_Desktop_Tile::WidthInPixels(int p) |
---|
| 174 | { widthInPixels = p; } |
---|
| 175 | |
---|
| 176 | void Virtual_Desktop_Tile::HeightInPixels(int p) |
---|
| 177 | { heightInPixels = p; } |
---|
| 178 | |
---|
| 179 | int Virtual_Desktop_Tile::LowerLeftPixelX() |
---|
| 180 | { return lowerLeftPixelX; } |
---|
| 181 | |
---|
| 182 | int Virtual_Desktop_Tile::LowerLeftPixelY() |
---|
| 183 | { return lowerLeftPixelY; } |
---|
| 184 | |
---|
| 185 | int Virtual_Desktop_Tile::WidthInPixels() |
---|
| 186 | { return widthInPixels; } |
---|
| 187 | |
---|
| 188 | int Virtual_Desktop_Tile::HeightInPixels() |
---|
| 189 | { return heightInPixels; } |
---|
| 190 | |
---|
| 191 | float Virtual_Desktop_Tile::WidthRatio() |
---|
| 192 | { return widthRatio; } |
---|
| 193 | |
---|
| 194 | void Virtual_Desktop_Tile::WidthRatio(float r) |
---|
| 195 | { widthRatio = r; } |
---|
| 196 | |
---|
| 197 | float Virtual_Desktop_Tile::HeightRatio() |
---|
| 198 | { return heightRatio; } |
---|
| 199 | |
---|
| 200 | void Virtual_Desktop_Tile::HeightRatio(float r) |
---|
| 201 | { heightRatio = r; } |
---|
| 202 | |
---|
| 203 | int Virtual_Desktop_Tile::ID() |
---|
| 204 | { return id; } |
---|
| 205 | |
---|
| 206 | void Virtual_Desktop_Tile::ID(int i) |
---|
| 207 | { id = i; } |
---|
| 208 | |
---|
| 209 | Virtual_Desktop_Tile* Virtual_Desktop_Tile::Next() |
---|
| 210 | { return next; } |
---|
| 211 | |
---|
| 212 | void Virtual_Desktop_Tile::Next(Virtual_Desktop_Tile* vdt) |
---|
| 213 | { next = vdt; } |
---|
| 214 | |
---|
| 215 | Display_Node* Virtual_Desktop_Tile::DisplayNode() |
---|
| 216 | { return dispNode; } |
---|
| 217 | |
---|
| 218 | void Virtual_Desktop_Tile::DisplayNode(Display_Node* dn) |
---|
| 219 | { dispNode = dn; } |
---|
| 220 | |
---|
| 221 | int Virtual_Desktop_Tile::NonMullionLLX() |
---|
| 222 | { return nonMullionLLX; } |
---|
| 223 | |
---|
| 224 | int Virtual_Desktop_Tile::NonMullionLLY() |
---|
| 225 | { return nonMullionLLY; } |
---|
| 226 | |
---|
| 227 | void Virtual_Desktop_Tile::NonMullionLLX(int x) |
---|
| 228 | { nonMullionLLX = x; } |
---|
| 229 | |
---|
| 230 | void Virtual_Desktop_Tile::NonMullionLLY(int y) |
---|
| 231 | { nonMullionLLY = y; } |
---|
| 232 | |
---|
| 233 | //---------------------------------------------------------- |
---|
| 234 | // |
---|
| 235 | // |
---|
| 236 | // |
---|
| 237 | // |
---|
| 238 | // |
---|
| 239 | //----------------------------------------------------------- |
---|
| 240 | VDTtoPTmapper::VDTtoPTmapper(Physical_Tile* tpt, Virtual_Desktop_Tile* tvdt):pt(tpt),vdt(tvdt) |
---|
| 241 | { } |
---|
| 242 | |
---|
| 243 | VDTtoPTmapper::~VDTtoPTmapper() |
---|
| 244 | { } |
---|
| 245 | |
---|
| 246 | Physical_Tile* VDTtoPTmapper::PhysicalTile(){ return pt; } |
---|
| 247 | |
---|
| 248 | Virtual_Desktop_Tile* VDTtoPTmapper::VirtualDesktopTile(){ return vdt; } |
---|
| 249 | |
---|
| 250 | //---------------------------------------------------------- |
---|
| 251 | // |
---|
| 252 | // |
---|
| 253 | // |
---|
| 254 | // |
---|
| 255 | // |
---|
| 256 | //----------------------------------------------------------- |
---|
| 257 | |
---|
| 258 | Display_Node::Display_Node():nodeName(NULL),ip(NULL),next(NULL),maps(NULL),numberOfMaps(0) |
---|
| 259 | { |
---|
| 260 | |
---|
| 261 | } |
---|
| 262 | |
---|
| 263 | Display_Node::~Display_Node() |
---|
| 264 | { |
---|
| 265 | |
---|
| 266 | if( maps && numberOfMaps) |
---|
| 267 | { |
---|
| 268 | |
---|
| 269 | |
---|
| 270 | } |
---|
| 271 | |
---|
| 272 | if( ip ) |
---|
| 273 | delete [] ip; |
---|
| 274 | |
---|
| 275 | if( nodeName ) |
---|
| 276 | delete [] nodeName; |
---|
| 277 | |
---|
| 278 | next = NULL; |
---|
| 279 | } |
---|
| 280 | |
---|
| 281 | void Display_Node::Name(char* newName) |
---|
| 282 | { |
---|
| 283 | if( nodeName ) |
---|
| 284 | delete [] nodeName; |
---|
| 285 | |
---|
| 286 | nodeName = new char[strlen(newName) + 1]; |
---|
| 287 | strcpy(nodeName,newName); |
---|
| 288 | } |
---|
| 289 | |
---|
| 290 | void Display_Node::IP(char* newIP) |
---|
| 291 | { |
---|
| 292 | if( ip ) |
---|
| 293 | delete [] ip; |
---|
| 294 | |
---|
| 295 | ip = new char[strlen(newIP) + 1]; |
---|
| 296 | strcpy(ip,newIP); |
---|
| 297 | } |
---|
| 298 | |
---|
| 299 | char* Display_Node::Name(){ return nodeName; } |
---|
| 300 | char* Display_Node::IP(){ return ip; } |
---|
| 301 | Display_Node* Display_Node::Next(){ return next; } |
---|
| 302 | void Display_Node::Next(Display_Node* dn){ next = dn; } |
---|
| 303 | |
---|
| 304 | int Display_Node::NumberOfMaps(){ return numberOfMaps; } |
---|
| 305 | void Display_Node::NumberOfMaps(int n) //need to adjust maps |
---|
| 306 | { |
---|
| 307 | VDTtoPTmapper** tempMap = maps; |
---|
| 308 | maps = NULL; |
---|
| 309 | maps = new VDTtoPTmapper*[n]; |
---|
| 310 | |
---|
| 311 | int i = 0; |
---|
| 312 | |
---|
| 313 | //copy over as many nodes as the new maps array can fit |
---|
| 314 | for( ; i < n; i++) |
---|
| 315 | { |
---|
| 316 | if( i < numberOfMaps && tempMap) |
---|
| 317 | { |
---|
| 318 | maps[i] = tempMap[i]; |
---|
| 319 | tempMap[i] = NULL; |
---|
| 320 | } |
---|
| 321 | else |
---|
| 322 | maps[i] = NULL; |
---|
| 323 | } |
---|
| 324 | |
---|
| 325 | //clean up any nodes left over in the old maps array |
---|
| 326 | for( ; i < numberOfMaps && tempMap; i++) |
---|
| 327 | { |
---|
| 328 | tempMap[i]->VirtualDesktopTile()->DisplayNode(NULL); |
---|
| 329 | tempMap[i]->PhysicalTile()->Source(NULL); |
---|
| 330 | |
---|
| 331 | } |
---|
| 332 | |
---|
| 333 | delete [] tempMap; |
---|
| 334 | numberOfMaps = n; |
---|
| 335 | |
---|
| 336 | } |
---|
| 337 | |
---|
| 338 | |
---|
| 339 | VDTtoPTmapper** Display_Node::Maps(){ return maps; } |
---|
| 340 | |
---|
| 341 | bool Display_Node::AddMap(VDTtoPTmapper* pMap) |
---|
| 342 | { |
---|
| 343 | |
---|
| 344 | for(int i = 0; i < numberOfMaps; i++) |
---|
| 345 | { |
---|
| 346 | if(maps[i] == NULL) |
---|
| 347 | { |
---|
| 348 | maps[i] = pMap; |
---|
| 349 | maps[i]->VirtualDesktopTile()->DisplayNode(this); |
---|
| 350 | maps[i]->PhysicalTile()->Source(this); |
---|
| 351 | return true; |
---|
| 352 | |
---|
| 353 | } |
---|
| 354 | |
---|
| 355 | } |
---|
| 356 | |
---|
| 357 | return false; |
---|
| 358 | } |
---|
| 359 | |
---|
| 360 | void Display_Node::RemoveMap(VDTtoPTmapper* vpMap) |
---|
| 361 | { |
---|
| 362 | for(int i = 0; i < numberOfMaps; i++) |
---|
| 363 | { |
---|
| 364 | if(maps[i] && maps[i] == vpMap) |
---|
| 365 | { |
---|
| 366 | delete maps[i]; |
---|
| 367 | maps[i] = NULL; |
---|
| 368 | } |
---|
| 369 | } |
---|
| 370 | } |
---|
| 371 | |
---|
| 372 | void Display_Node::RemoveMap(int index) |
---|
| 373 | { |
---|
| 374 | if(index < numberOfMaps && maps[index]) |
---|
| 375 | { |
---|
| 376 | delete maps[index]; |
---|
| 377 | maps[index] = NULL; |
---|
| 378 | } |
---|
| 379 | } |
---|
| 380 | |
---|
| 381 | //---------------------------------------------------------- |
---|
| 382 | // |
---|
| 383 | // |
---|
| 384 | // |
---|
| 385 | // |
---|
| 386 | // |
---|
| 387 | //----------------------------------------------------------- |
---|
| 388 | |
---|
| 389 | DisplayCluster::DisplayCluster():displayNodeListHead(NULL) |
---|
| 390 | { |
---|
| 391 | |
---|
| 392 | } |
---|
| 393 | |
---|
| 394 | DisplayCluster::~DisplayCluster() |
---|
| 395 | { |
---|
| 396 | |
---|
| 397 | } |
---|
| 398 | |
---|
| 399 | |
---|
| 400 | void DisplayCluster::AddDisplayNode(Display_Node* dn) |
---|
| 401 | { |
---|
| 402 | Display_Node* temp = displayNodeListHead; |
---|
| 403 | if(temp) |
---|
| 404 | { |
---|
| 405 | while(temp->Next()) |
---|
| 406 | { |
---|
| 407 | temp = temp->Next(); |
---|
| 408 | } |
---|
| 409 | |
---|
| 410 | temp->Next(dn); |
---|
| 411 | dn->Next(NULL); |
---|
| 412 | } |
---|
| 413 | else |
---|
| 414 | { |
---|
| 415 | displayNodeListHead = dn; |
---|
| 416 | dn->Next(NULL); |
---|
| 417 | |
---|
| 418 | } |
---|
| 419 | |
---|
| 420 | } |
---|
| 421 | |
---|
| 422 | |
---|
| 423 | void DisplayCluster::RemoveDisplayNode(char* name) |
---|
| 424 | { |
---|
| 425 | |
---|
| 426 | } |
---|
| 427 | |
---|
| 428 | void DisplayCluster::RemoveDisplayNodeByName(char* name) |
---|
| 429 | { |
---|
| 430 | RemoveDisplayNode(name); |
---|
| 431 | } |
---|
| 432 | |
---|
| 433 | |
---|
| 434 | void DisplayCluster::RemoveDisplayNodeByIP(char* ip) |
---|
| 435 | { |
---|
| 436 | |
---|
| 437 | } |
---|
| 438 | |
---|
| 439 | Display_Node* DisplayCluster::getFirstNode() |
---|
| 440 | { |
---|
| 441 | return this->displayNodeListHead; |
---|
| 442 | } |
---|
| 443 | |
---|
| 444 | |
---|
| 445 | //Generate and insert a mapping between virtual tile and physical tile to a display node |
---|
| 446 | //Assuming the physical tile already knows the display node source |
---|
| 447 | bool DisplayCluster::GenerateMapping(Virtual_Desktop_Tile* vdt, Physical_Tile* pt) |
---|
| 448 | { |
---|
| 449 | //make sure the physical tile is on the physical display associated with this display cluster |
---|
| 450 | if(!pd->TileOnPhysicalDisplay(pt)) |
---|
| 451 | return false; |
---|
| 452 | |
---|
| 453 | |
---|
| 454 | if(pt->Source() == NULL) |
---|
| 455 | return false; //the physical tile must already have a source |
---|
| 456 | |
---|
| 457 | //make sure that the source node is on this display cluster |
---|
| 458 | if(!NodeOnCluster(pt->Source())) |
---|
| 459 | return false; |
---|
| 460 | |
---|
| 461 | VDTtoPTmapper* map = new VDTtoPTmapper(pt,vdt); |
---|
| 462 | if(pt->Source()->AddMap(map)) |
---|
| 463 | return true; |
---|
| 464 | |
---|
| 465 | delete map; |
---|
| 466 | return false; |
---|
| 467 | |
---|
| 468 | } |
---|
| 469 | |
---|
| 470 | PhysicalDisplay* DisplayCluster::PhysicalDisplayAssoc(){ return pd; } |
---|
| 471 | void DisplayCluster::PhysicalDisplayAssoc(PhysicalDisplay* tpd) |
---|
| 472 | { |
---|
| 473 | pd = tpd; |
---|
| 474 | } |
---|
| 475 | |
---|
| 476 | //Generate and insert a mapping between virtual and physical tile using the given display node |
---|
| 477 | bool DisplayCluster::GenerateMapping(Virtual_Desktop_Tile* vdt, Physical_Tile *pt, Display_Node *dn) |
---|
| 478 | { |
---|
| 479 | //make sure the physical tile is on the physical display associated with this display cluster |
---|
| 480 | if(!pd->TileOnPhysicalDisplay(pt)) |
---|
| 481 | return false; |
---|
| 482 | |
---|
| 483 | Display_Node *itr = displayNodeListHead; |
---|
| 484 | //make sure the node is on this display cluster |
---|
| 485 | if(!NodeOnCluster(dn)) |
---|
| 486 | return false; |
---|
| 487 | |
---|
| 488 | VDTtoPTmapper* map = new VDTtoPTmapper(pt,vdt); |
---|
| 489 | if(dn->AddMap(map)) |
---|
| 490 | return true; |
---|
| 491 | |
---|
| 492 | delete map; |
---|
| 493 | return false; |
---|
| 494 | |
---|
| 495 | } |
---|
| 496 | |
---|
| 497 | void DisplayCluster::RemoveMapping(Virtual_Desktop_Tile* vdt, Physical_Tile *pt, Display_Node* dn) |
---|
| 498 | { |
---|
| 499 | if(!NodeOnCluster(dn)) |
---|
| 500 | return; |
---|
| 501 | |
---|
| 502 | VDTtoPTmapper** maps = dn->Maps(); |
---|
| 503 | int count = dn->NumberOfMaps(); |
---|
| 504 | |
---|
| 505 | for(int i = 0; i < count; i++) |
---|
| 506 | { |
---|
| 507 | if(maps[i] && maps[i]->PhysicalTile() == pt && maps[i]->VirtualDesktopTile() == vdt) |
---|
| 508 | dn->RemoveMap(i); |
---|
| 509 | } |
---|
| 510 | |
---|
| 511 | } |
---|
| 512 | |
---|
| 513 | bool DisplayCluster::NodeOnCluster(Display_Node* dn) |
---|
| 514 | { |
---|
| 515 | Display_Node* itr = displayNodeListHead; |
---|
| 516 | while(itr) |
---|
| 517 | { |
---|
| 518 | if(itr == dn) |
---|
| 519 | { |
---|
| 520 | return true; |
---|
| 521 | } |
---|
| 522 | itr = itr->Next(); |
---|
| 523 | } |
---|
| 524 | |
---|
| 525 | return false; |
---|
| 526 | } |
---|
| 527 | |
---|
| 528 | void DisplayCluster::RemoveMapsWith(Virtual_Desktop_Tile* tvdt) |
---|
| 529 | { |
---|
| 530 | Display_Node* itr = displayNodeListHead; |
---|
| 531 | while(itr) |
---|
| 532 | { |
---|
| 533 | VDTtoPTmapper** maps = itr->Maps(); |
---|
| 534 | int count = itr->NumberOfMaps(); |
---|
| 535 | for( ;count > 0; count--) |
---|
| 536 | { |
---|
| 537 | if(maps[count - 1] && maps[count - 1]->VirtualDesktopTile() == tvdt) |
---|
| 538 | itr->RemoveMap(count - 1); |
---|
| 539 | } |
---|
| 540 | |
---|
| 541 | itr = itr->Next(); |
---|
| 542 | } |
---|
| 543 | } |
---|
| 544 | |
---|
| 545 | void DisplayCluster::RemoveMapsWith(Physical_Tile* tpt) |
---|
| 546 | { |
---|
| 547 | Display_Node* itr = displayNodeListHead; |
---|
| 548 | while(itr) |
---|
| 549 | { |
---|
| 550 | VDTtoPTmapper** maps = itr->Maps(); |
---|
| 551 | int count = itr->NumberOfMaps(); |
---|
| 552 | for( ;count > 0; count--) |
---|
| 553 | { |
---|
| 554 | if(maps[count - 1] && maps[count - 1]->PhysicalTile() == tpt) |
---|
| 555 | itr->RemoveMap(count - 1); |
---|
| 556 | } |
---|
| 557 | |
---|
| 558 | itr = itr->Next(); |
---|
| 559 | } |
---|
| 560 | } |
---|
| 561 | |
---|
| 562 | VirtualDesktop* DisplayCluster::VirtualDesktopAssoc(){ return vd; } |
---|
| 563 | void DisplayCluster::VirtualDesktopAssoc(VirtualDesktop* tvd) |
---|
| 564 | { |
---|
| 565 | |
---|
| 566 | } |
---|
| 567 | |
---|
| 568 | //---------------------------------------------------------- |
---|
| 569 | // |
---|
| 570 | // |
---|
| 571 | // |
---|
| 572 | // |
---|
| 573 | // |
---|
| 574 | //----------------------------------------------------------- |
---|
| 575 | |
---|
| 576 | |
---|
| 577 | PhysicalDisplay::PhysicalDisplay():physicalTileListHead(NULL),vd(NULL),dc(NULL), |
---|
| 578 | pixelsPerInch(1.0) |
---|
| 579 | { |
---|
| 580 | |
---|
| 581 | |
---|
| 582 | } |
---|
| 583 | |
---|
| 584 | PhysicalDisplay::~PhysicalDisplay() |
---|
| 585 | { |
---|
| 586 | |
---|
| 587 | } |
---|
| 588 | |
---|
| 589 | void PhysicalDisplay::VirtualDesktopAssoc(VirtualDesktop *tvd) |
---|
| 590 | { |
---|
| 591 | vd = tvd; |
---|
| 592 | } |
---|
| 593 | VirtualDesktop* PhysicalDisplay::VirtualDesktopAssoc(){ return vd; } |
---|
| 594 | |
---|
| 595 | int PhysicalDisplay::AddPhysicalTile(Physical_Tile* pt) |
---|
| 596 | { |
---|
| 597 | int ID = 1; |
---|
| 598 | if(physicalTileListHead == NULL) |
---|
| 599 | { |
---|
| 600 | physicalTileListHead = pt; |
---|
| 601 | } |
---|
| 602 | else |
---|
| 603 | { |
---|
| 604 | Physical_Tile *itr = physicalTileListHead; |
---|
| 605 | while(itr->Next()) |
---|
| 606 | { |
---|
| 607 | itr = itr->Next(); |
---|
| 608 | ID++; |
---|
| 609 | } |
---|
| 610 | |
---|
| 611 | itr->Next(pt); |
---|
| 612 | pt->Next(NULL); |
---|
| 613 | } |
---|
| 614 | |
---|
| 615 | pt->ID(ID); |
---|
| 616 | return ID; |
---|
| 617 | } |
---|
| 618 | |
---|
| 619 | Physical_Tile* PhysicalDisplay::RemovePhysicalTileByID(int ID, bool delquery) |
---|
| 620 | { |
---|
| 621 | |
---|
| 622 | Physical_Tile *itr = physicalTileListHead; |
---|
| 623 | |
---|
| 624 | if(itr->ID() == ID) |
---|
| 625 | { |
---|
| 626 | physicalTileListHead = itr->Next(); |
---|
| 627 | |
---|
| 628 | } |
---|
| 629 | else |
---|
| 630 | { |
---|
| 631 | while(itr->Next()) |
---|
| 632 | { |
---|
| 633 | //in order to take care of accidental redundant data, loop for each entry |
---|
| 634 | if(itr->Next()->ID() == ID) |
---|
| 635 | { |
---|
| 636 | itr->Next(itr->Next()->Next()); |
---|
| 637 | if(dc) |
---|
| 638 | dc->RemoveMapsWith(itr); |
---|
| 639 | |
---|
| 640 | } |
---|
| 641 | } |
---|
| 642 | } |
---|
| 643 | |
---|
| 644 | if(delquery) |
---|
| 645 | { |
---|
| 646 | delete itr; |
---|
| 647 | return NULL; |
---|
| 648 | } |
---|
| 649 | else |
---|
| 650 | return itr; |
---|
| 651 | |
---|
| 652 | |
---|
| 653 | } |
---|
| 654 | |
---|
| 655 | |
---|
| 656 | DisplayCluster* PhysicalDisplay::DisplayClusterAssoc() |
---|
| 657 | { return dc; } |
---|
| 658 | |
---|
| 659 | void PhysicalDisplay::DisplayClusterAssoc(DisplayCluster* tdc) |
---|
| 660 | { |
---|
| 661 | //go through the current display cluster and remove all the mappings that were made to the |
---|
| 662 | //physical tiles associated with this display cluster |
---|
| 663 | Physical_Tile* itr = physicalTileListHead; |
---|
| 664 | while(itr) |
---|
| 665 | { |
---|
| 666 | if(dc) |
---|
| 667 | dc->RemoveMapsWith(itr); |
---|
| 668 | itr->Source(NULL); |
---|
| 669 | itr = itr->Next(); |
---|
| 670 | } |
---|
| 671 | |
---|
| 672 | dc = tdc; |
---|
| 673 | |
---|
| 674 | |
---|
| 675 | } |
---|
| 676 | |
---|
| 677 | bool PhysicalDisplay::TileOnPhysicalDisplay(Physical_Tile* pt) |
---|
| 678 | { |
---|
| 679 | Physical_Tile* itr = physicalTileListHead; |
---|
| 680 | while(itr) |
---|
| 681 | { |
---|
| 682 | if(itr == pt) |
---|
| 683 | return true; |
---|
| 684 | |
---|
| 685 | itr = itr->Next(); |
---|
| 686 | } |
---|
| 687 | |
---|
| 688 | return false; |
---|
| 689 | } |
---|
| 690 | Physical_Tile* PhysicalDisplay::getFirstNode() |
---|
| 691 | { return physicalTileListHead; } |
---|
| 692 | |
---|
| 693 | float PhysicalDisplay::PixelsPerInch(){ return pixelsPerInch; } |
---|
| 694 | void PhysicalDisplay::PixelsPerInch(float ratio) |
---|
| 695 | { pixelsPerInch = ratio; } |
---|
| 696 | |
---|
| 697 | //---------------------------------------------------------- |
---|
| 698 | // |
---|
| 699 | // |
---|
| 700 | // |
---|
| 701 | // |
---|
| 702 | // |
---|
| 703 | //----------------------------------------------------------- |
---|
| 704 | |
---|
| 705 | VirtualDesktop::VirtualDesktop():dc(NULL),pd(NULL),tileListHead(NULL),vertRes(1),horizRes(1) //just 1 pixel by 1 pixel |
---|
| 706 | { |
---|
| 707 | } |
---|
| 708 | |
---|
| 709 | VirtualDesktop::~VirtualDesktop() |
---|
| 710 | { |
---|
| 711 | Virtual_Desktop_Tile* itr = tileListHead; |
---|
| 712 | while(itr) |
---|
| 713 | { |
---|
| 714 | if(dc) |
---|
| 715 | dc->RemoveMapsWith(itr); |
---|
| 716 | tileListHead = itr->Next(); |
---|
| 717 | delete itr; |
---|
| 718 | itr = tileListHead; |
---|
| 719 | } |
---|
| 720 | } |
---|
| 721 | |
---|
| 722 | DisplayCluster* VirtualDesktop::DisplayClusterAssoc(){ return dc; } |
---|
| 723 | void VirtualDesktop::DisplayClusterAssoc(DisplayCluster *tdc) |
---|
| 724 | { |
---|
| 725 | dc = tdc; |
---|
| 726 | }
|
---|
| 727 |
|
---|
| 728 | PhysicalDisplay* VirtualDesktop::PhysicalDisplayAssoc(){ return pd; }
|
---|
| 729 | void VirtualDesktop::PhysicalDisplayAssoc(PhysicalDisplay* tpd)
|
---|
| 730 | {
|
---|
| 731 | pd = tpd;
|
---|
| 732 | }
|
---|
| 733 |
|
---|
| 734 | void VirtualDesktop::AddTile(Virtual_Desktop_Tile* tvdt)
|
---|
| 735 | {
|
---|
| 736 | //the tile has to be already mapped to a physical tile,
|
---|
| 737 | VDTtoPTmapper* mapping = NULL;
|
---|
| 738 | if(!dc)
|
---|
| 739 | return;
|
---|
| 740 |
|
---|
| 741 | Display_Node* itr = dc->getFirstNode();
|
---|
| 742 |
|
---|
| 743 | while(itr)
|
---|
| 744 | {
|
---|
| 745 | int count = itr->NumberOfMaps();
|
---|
| 746 | VDTtoPTmapper** maps = itr->Maps();
|
---|
| 747 | for( ;count > 0; count--)
|
---|
| 748 | {
|
---|
| 749 | if(maps[count - 1] && maps[count - 1]->VirtualDesktopTile() == tvdt)
|
---|
| 750 | {
|
---|
| 751 | mapping = maps[count - 1];
|
---|
| 752 | itr = NULL;
|
---|
| 753 | break;
|
---|
| 754 | }
|
---|
| 755 | }
|
---|
| 756 |
|
---|
| 757 | if(itr)
|
---|
| 758 | itr = itr->Next();
|
---|
| 759 | }
|
---|
| 760 |
|
---|
| 761 | if(!mapping)
|
---|
| 762 | return;
|
---|
| 763 |
|
---|
| 764 | //there is a mapping...continue
|
---|
| 765 |
|
---|
| 766 |
|
---|
| 767 | //put at end of list
|
---|
| 768 | Virtual_Desktop_Tile* vdtItr = tileListHead;
|
---|
| 769 | if(vdtItr == NULL)
|
---|
| 770 | {
|
---|
| 771 | tileListHead = tvdt;
|
---|
| 772 | tvdt->Next(NULL);
|
---|
| 773 | return;
|
---|
| 774 | }
|
---|
| 775 |
|
---|
| 776 | while(vdtItr->Next())
|
---|
| 777 | {
|
---|
| 778 | vdtItr = vdtItr->Next();
|
---|
| 779 | }
|
---|
| 780 |
|
---|
| 781 | vdtItr->Next(tvdt);
|
---|
| 782 | tvdt->Next(NULL);
|
---|
| 783 |
|
---|
| 784 | }
|
---|
| 785 |
|
---|
| 786 | void VirtualDesktop::RemoveTile(Virtual_Desktop_Tile* tvdt)
|
---|
| 787 | {
|
---|
| 788 | Virtual_Desktop_Tile* itr = tileListHead;
|
---|
| 789 | while(itr)
|
---|
| 790 | {
|
---|
| 791 | if(itr == tvdt)
|
---|
| 792 | {
|
---|
| 793 | if(dc)
|
---|
| 794 | {
|
---|
| 795 | return dc->RemoveMapsWith(tvdt);
|
---|
| 796 | }
|
---|
| 797 | }
|
---|
| 798 | itr = itr->Next();
|
---|
| 799 | }
|
---|
| 800 |
|
---|
| 801 | }
|
---|
| 802 |
|
---|
| 803 | Virtual_Desktop_Tile* VirtualDesktop::getFirstNode(void)
|
---|
| 804 | {
|
---|
| 805 | return tileListHead;
|
---|
| 806 | }
|
---|
| 807 |
|
---|
| 808 | bool VirtualDesktop::Update()
|
---|
| 809 | {
|
---|
| 810 | if(!pd)
|
---|
| 811 | return false;
|
---|
| 812 |
|
---|
| 813 |
|
---|
| 814 | float positiveHoriz, positiveVert, negativeHoriz, negativeVert;
|
---|
| 815 | positiveHoriz = positiveVert = negativeHoriz = negativeVert = 0.0;
|
---|
| 816 | float leftMullion, bottomMullion;
|
---|
| 817 | //need to determine the whole virtual desktop size
|
---|
| 818 | Physical_Tile* ptItr = pd->getFirstNode();
|
---|
| 819 | while(ptItr)
|
---|
| 820 | {
|
---|
| 821 | if(ptItr->LowerLeftX() < negativeHoriz)
|
---|
| 822 | {
|
---|
| 823 | negativeHoriz = ptItr->LowerLeftX();
|
---|
| 824 | leftMullion = ptItr->LeftMullionThickness();
|
---|
| 825 | }
|
---|
| 826 | else if(ptItr->LowerLeftX() + ptItr->ScreenWidthDimension() > positiveHoriz)
|
---|
| 827 | {
|
---|
| 828 | positiveHoriz = ptItr->LowerLeftX() + ptItr->ScreenWidthDimension();
|
---|
| 829 | }
|
---|
| 830 |
|
---|
| 831 | if(ptItr->LowerLeftY() < negativeVert)
|
---|
| 832 | {
|
---|
| 833 | negativeVert = ptItr->LowerLeftY();
|
---|
| 834 | bottomMullion = ptItr->BottomMullionThickness();
|
---|
| 835 |
|
---|
| 836 | }
|
---|
| 837 | else if(ptItr->LowerLeftY() + ptItr->ScreenHeightDimension() > positiveVert)
|
---|
| 838 | {
|
---|
| 839 | positiveVert = ptItr->LowerLeftY() + ptItr->ScreenHeightDimension();
|
---|
| 840 | }
|
---|
| 841 |
|
---|
| 842 | ptItr = ptItr->Next();
|
---|
| 843 | }
|
---|
| 844 |
|
---|
| 845 | //save off the resolutions.
|
---|
| 846 | horizRes = (int)((positiveHoriz - negativeHoriz) * (pd->PixelsPerInch()));
|
---|
| 847 | vertRes = (int)((positiveVert - negativeVert) * (pd->PixelsPerInch()));
|
---|
| 848 |
|
---|
| 849 |
|
---|
| 850 | //go through all the virtual tiles and adjust their properties based on their mapped physical tiles
|
---|
| 851 | Virtual_Desktop_Tile* vdtItr = tileListHead;
|
---|
| 852 | while(vdtItr)
|
---|
| 853 | {
|
---|
| 854 | VDTtoPTmapper* mapping;
|
---|
| 855 |
|
---|
| 856 | mapping = NULL;
|
---|
| 857 | if(!dc)
|
---|
| 858 | return false;
|
---|
| 859 |
|
---|
| 860 | Display_Node* itr = dc->getFirstNode();
|
---|
| 861 |
|
---|
| 862 | while(itr)
|
---|
| 863 | {
|
---|
| 864 | int count = itr->NumberOfMaps();
|
---|
| 865 | VDTtoPTmapper** maps = itr->Maps();
|
---|
| 866 | for( ;count > 0; count--)
|
---|
| 867 | {
|
---|
| 868 | if(maps[count - 1] && maps[count - 1]->VirtualDesktopTile() == vdtItr)
|
---|
| 869 | {
|
---|
| 870 | mapping = maps[count - 1];
|
---|
| 871 | itr = NULL;
|
---|
| 872 | break;
|
---|
| 873 | }
|
---|
| 874 | }
|
---|
| 875 |
|
---|
| 876 | if(itr)
|
---|
| 877 | itr = itr->Next();
|
---|
| 878 | }
|
---|
| 879 |
|
---|
| 880 | //we have an unmapped virtual tile....doesn't make sense, stop and return false
|
---|
| 881 | if(!mapping)
|
---|
| 882 | return false;
|
---|
| 883 |
|
---|
| 884 | //calculate the virtual tile properties
|
---|
| 885 | float posXRatio, posYRatio, widthRatio, heightRatio;
|
---|
| 886 | posXRatio = posYRatio = widthRatio = heightRatio = 0.0;
|
---|
| 887 | Physical_Tile* ptTemp = mapping->PhysicalTile();
|
---|
| 888 |
|
---|
| 889 | vdtItr->LowerLeftPixelX( (ptTemp->LowerLeftX() + ptTemp->LeftMullionThickness()) * pd->PixelsPerInch() );
|
---|
| 890 | vdtItr->LowerLeftPixelY( (ptTemp->LowerLeftY() + ptTemp->BottomMullionThickness()) * pd->PixelsPerInch() );
|
---|
| 891 | vdtItr->LowerLeftX( (float)vdtItr->LowerLeftPixelX() / horizRes);
|
---|
| 892 | vdtItr->LowerLeftY( (float)vdtItr->LowerLeftPixelY() / vertRes);
|
---|
| 893 |
|
---|
| 894 | vdtItr->WidthInPixels( ptTemp->ScreenWidthDimension() * pd->PixelsPerInch() );
|
---|
| 895 | vdtItr->HeightInPixels( ptTemp->ScreenHeightDimension() * pd->PixelsPerInch());
|
---|
| 896 | vdtItr->WidthRatio( (float)vdtItr->WidthInPixels() / horizRes);
|
---|
| 897 | vdtItr->HeightRatio( (float)vdtItr->HeightInPixels() / vertRes);
|
---|
| 898 |
|
---|
| 899 | vdtItr->ID( ptTemp->ID()); //map the id of the virtual tile to the same id of the physical tile
|
---|
| 900 |
|
---|
| 901 | //move on
|
---|
| 902 | vdtItr = vdtItr->Next();
|
---|
| 903 |
|
---|
| 904 | }
|
---|
| 905 |
|
---|
| 906 |
|
---|
| 907 | return true;
|
---|
| 908 |
|
---|
| 909 | }
|
---|