#include <TopologyVis.h>
Public Member Functions | |
TopologyVis () | |
Protected Member Functions | |
void | initVis (cModule *terminal) |
void | showOverlayNeighborArrow (const NodeHandle &neighbor, bool flush=true, char *displayString=NULL) |
Draws an arrow from this node to neighbor. | |
void | deleteOverlayNeighborArrow (const NodeHandle &neighbor) |
Removes an arrow from this node to neighbor. | |
Protected Attributes | |
cModule * | thisTerminal |
BootstrapOracle * | bootstrapOracle |
pointer to corresponding node | |
cGate * | thisOutGateArray |
cGate * | thisInGateArray |
Private Member Functions | |
void | compactGateArray (cModule *terminal, enum VisDrawDirection dir) |
compacts arrow gate-array |
TopologyVis::TopologyVis | ( | ) |
void TopologyVis::initVis | ( | cModule * | terminal | ) | [protected] |
00039 { 00040 thisTerminal = terminal; 00041 bootstrapOracle = BootstrapOracleAccess().get(); 00042 00043 // set up arrow-gates 00044 thisOutGateArray = thisTerminal->gate("overlayNeighborArrowOut"); 00045 thisInGateArray = thisTerminal->gate("overlayNeighborArrowIn"); 00046 thisTerminal->setGateSize("overlayNeighborArrowOut", 1); 00047 thisTerminal->setGateSize("overlayNeighborArrowIn", 1); 00048 00049 }
void TopologyVis::showOverlayNeighborArrow | ( | const NodeHandle & | neighbor, | |
bool | flush = true , |
|||
char * | displayString = NULL | |||
) | [protected] |
Draws an arrow from this node to neighbor.
neighbor | neighbor to point to | |
flush | delete all previous drawn arrows starting at this node? | |
displayString | display string to define the arrow drawing style |
00053 { 00054 if (!ev.isGUI() || !thisTerminal) 00055 return; 00056 00057 char red[] = "o=red,1"; 00058 if (displayString == NULL) 00059 displayString = red; 00060 00061 cModule* neighborTerminal; 00062 cGate* neighborInGateArray; 00063 00064 // flush 00065 if (flush) { 00066 for (int l = 0; l < thisOutGateArray->size(); l++) { 00067 cGate* tempGate = 00068 thisTerminal->gate("overlayNeighborArrowOut", l)->toGate(); 00069 00070 thisTerminal->gate("overlayNeighborArrowOut", l)->disconnect(); 00071 if (tempGate != NULL) 00072 compactGateArray(tempGate->ownerModule(), IN); 00073 } 00074 thisTerminal->setGateSize("overlayNeighborArrowOut" ,0); 00075 } 00076 00077 if (bootstrapOracle->getPeerInfo(neighbor) == NULL) 00078 return; 00079 00080 neighborTerminal 00081 = simulation.module(bootstrapOracle 00082 ->getPeerInfo(neighbor)->getModuleID()); 00083 if (neighborTerminal != NULL) { 00084 neighborInGateArray = neighborTerminal->gate("overlayNeighborArrowIn"); 00085 } else 00086 return; 00087 00088 if (thisTerminal == neighborTerminal) 00089 return; 00090 00091 //do not draw double 00092 for (int i = 0; i < thisOutGateArray->size(); i++) 00093 if (thisTerminal->gate("overlayNeighborArrowOut", i) 00094 ->toGate() != NULL && 00095 neighborTerminal == thisTerminal 00096 ->gate("overlayNeighborArrowOut", i) 00097 ->toGate()->ownerModule()) 00098 return; 00099 00100 // IN 00101 int i = 0; 00102 if (neighborInGateArray->size() == 0) { 00103 neighborTerminal->setGateSize("overlayNeighborArrowIn", 1); 00104 } else { 00105 for (i = 0; i < neighborInGateArray->size() - 1; i++) { 00106 if (!(neighborTerminal->gate("overlayNeighborArrowIn", i) 00107 ->isConnectedOutside())) 00108 break; 00109 } 00110 if (neighborTerminal->gate("overlayNeighborArrowIn", i) 00111 ->isConnectedOutside()) { 00112 neighborTerminal->setGateSize("overlayNeighborArrowIn", i + 2); 00113 i++; 00114 } 00115 } 00116 00117 // OUT 00118 int j = 0; 00119 if (thisOutGateArray->size() == 0) 00120 thisTerminal->setGateSize("overlayNeighborArrowOut", 1); 00121 else { 00122 for (j = 0; j < (thisOutGateArray->size() - 1); j++) { 00123 if (!(thisTerminal->gate("overlayNeighborArrowOut", j) 00124 ->isConnectedOutside())) 00125 break; 00126 } 00127 if (thisTerminal->gate("overlayNeighborArrowOut", j) 00128 ->isConnectedOutside()) { 00129 thisTerminal->setGateSize("overlayNeighborArrowOut", j + 2); 00130 j++; 00131 } 00132 } 00133 00134 thisTerminal->gate("overlayNeighborArrowOut", j)-> 00135 connectTo(neighborTerminal->gate("overlayNeighborArrowIn", i)); 00136 00137 thisTerminal->gate("overlayNeighborArrowOut", j)-> 00138 setDisplayString(displayString); 00139 }
void TopologyVis::deleteOverlayNeighborArrow | ( | const NodeHandle & | neighbor | ) | [protected] |
Removes an arrow from this node to neighbor.
neighbor | neighbor to remove arrow to |
00142 { 00143 if (!ev.isGUI() || !thisTerminal) 00144 return; 00145 00146 cModule* neighborTerminal 00147 = simulation.module(bootstrapOracle 00148 ->getPeerInfo(neighbor)->getModuleID()); 00149 00150 if (neighborTerminal == NULL) 00151 return; 00152 00153 //find gate 00154 bool compactOut = false; 00155 bool compactIn = false; 00156 for (int i = 0; i < thisOutGateArray->size(); i++) { 00157 // NULL-Gate? 00158 if (thisTerminal->gate("overlayNeighborArrowOut", i) 00159 ->toGate() == NULL) { 00160 compactOut = true; 00161 continue; 00162 } 00163 00164 if (thisTerminal->gate("overlayNeighborArrowOut", i) 00165 ->toGate()->ownerModule()->id() == neighborTerminal->id()) { 00166 thisTerminal->gate("overlayNeighborArrowOut", i)->disconnect(); 00167 compactOut = true; 00168 compactIn = true; 00169 } 00170 } 00171 00172 //compact OUT-array 00173 if (compactOut) 00174 compactGateArray(thisTerminal, OUT); 00175 //compact IN-array 00176 if (compactIn) 00177 compactGateArray(neighborTerminal, IN); 00178 }
void TopologyVis::compactGateArray | ( | cModule * | terminal, | |
enum VisDrawDirection | dir | |||
) | [private] |
compacts arrow gate-array
terminal | node | |
dir | in- or out-array? |
00182 { 00183 cGate* gateArray = (dir == OUT ? terminal->gate("overlayNeighborArrowOut") 00184 : terminal->gate("overlayNeighborArrowIn")); 00185 const char* gateName = (dir == OUT ? "overlayNeighborArrowOut" 00186 : "overlayNeighborArrowIn"); 00187 00188 for (int j = 0; j < gateArray->size() - 1; j++) { 00189 if (terminal->gate(gateName, j)->isConnectedOutside()) 00190 continue; 00191 00192 cGate* tempGate = NULL; 00193 int k = 1; 00194 while ((tempGate == NULL) && ((j + k) != gateArray->size())) { 00195 tempGate = (dir == OUT ? 00196 terminal->gate(gateName, j + k)->toGate() : 00197 terminal->gate(gateName, j + k)->fromGate()); 00198 k++; 00199 } 00200 00201 if (tempGate == NULL) 00202 break; 00203 00204 if (dir == OUT) { 00205 terminal->gate(gateName, j + k - 1)->disconnect(); 00206 terminal->gate(gateName, j)->connectTo(tempGate); 00207 } else { 00208 tempGate->disconnect(); 00209 tempGate->connectTo(terminal->gate(gateName, j)); 00210 } 00211 } 00212 00213 int nullGates = 0; 00214 for (int j = 0; j < gateArray->size(); j++) 00215 if (!terminal->gate(gateName, j)->isConnectedOutside()) 00216 nullGates++; 00217 00218 terminal->setGateSize(gateName, gateArray->size() - nullGates); 00219 }
cModule* TopologyVis::thisTerminal [protected] |
BootstrapOracle* TopologyVis::bootstrapOracle [protected] |
cGate* TopologyVis::thisOutGateArray [protected] |
cGate* TopologyVis::thisInGateArray [protected] |