L1 и L1 - значения для изменения цвета узла по отношению к истощению энергии. double l1 = 0,5; double l2 = 0.2;
if (srcnode) {
if (srcnode->energy_model()) {
energy = srcnode->energy_model()->energy();
initenergy = srcnode->energy_model()->initialenergy();
l1 = srcnode->energy_model()->level1();
l2 = srcnode->energy_model()->level2();
}
}
int energyLevel = 0 ;
double energyLeft = (double)(energy/initenergy) ;
if ((energyLeft <= 1) && (energyLeft >= l1)) energyLevel = 3;
if ((energyLeft >= l2) && (energyLeft < l1)) energyLevel = 2;
if ((energyLeft > 0) && (energyLeft < l2)) energyLevel = 1;
if (energyLevel == 0)
strcpy(colors,"-c black -o red");
else if (energyLevel == 1)
strcpy(colors,"-c red -o yellow");
else if (energyLevel == 2)
strcpy(colors,"-c yellow -o green");
else if (energyLevel == 3)
strcpy(colors,"-c green -o black");