{
pixmap2.fill(Qt::white);
Q_UNUSED(option);
nodeAlertTemp = settings.value("NodeAlertTemp", 10).toDouble();
if (nodeData.addr!=0){
if(nodeData.fadeNumber>5&&nodeData.deletedNode!=0)
{
nodeData.fadeNumber-=fade_speed;
if (nodeData.fadeNumber<=5){
nodeData.fadeNumber=0;
nodeData.deletedNode=1;
index_number=0;
}
}
if(nodeData.fadeNumber<255&&nodeData.newNode!=0)
{
nodeData.fadeNumber+=fade_speed;
if (nodeData.fadeNumber>=255)
{
nodeData.fadeNumber=255;
nodeData.newNode=0;
//current_updateData(index_number);
index_number=0;
}
}
}
// Draw the grey shadow for a 3d effect.
painter->setPen(Qt::NoPen);
painter
->setBrush
(QColor(0x80, 0x80, 0x80,
(nodeData.
fadeNumber)));
painter->drawEllipse(-45, -45, 100, 100);
// Set gradient and color of the node
if (nodeData.addr==0&&updated == true)
{
// Mouse click on node or an update of node data~
gradient.setCenter(3, 3);
gradient.setFocalPoint(3, 3);
gradient.setColorAt(1, nodeColor.light(120));
gradient.setColorAt(.5, nodeColorDark.light(120));
gradient.setColorAt(0, nodeColorDark.light(120));
updated = false;
painter->setBrush(gradient);
}
else if (nodeData.addr==0&&updated == false)
{
gradient.setColorAt(0, nodeColor.light(150));
gradient.setColorAt(1, nodeColorDark);
painter->setBrush(gradient);
}
// end devices
if (nodeData.addr!=0&&updated == true)
{
// Mouse click on node or an update of node data~
gradient.setCenter(3, 3);
gradient.setFocalPoint(3, 3);
gradient.setColorAt(1, nodeColor);
gradient.setColorAt(.5, nodeColor);
gradient.setColorAt(0, nodeColor);
updated = false;
painter->setBrush(gradient);
}
else if (nodeData.addr!=0&&updated == false)
{
gradient.setColorAt(0, nodeColor);
gradient.setColorAt(.95, nodeColorDark);
gradient.setColorAt(1, nodeColor);
painter->setBrush(gradient);
}
// painter->setBrush(gradient);
// Draw black circle around the node
painter
->setPen
(QColor(0,
0,
0,
(nodeData.
fadeNumber)));
// Draw the node
painter->drawEllipse(-50, -50, 100, 100);
//x new text
// White pen for text
if (nodeData.addr==0)
{
painter
->setPen
(QPen(Qt
::white,
1));
}
else
{
if(nodeData.re<100)
{
painter
->setPen
(QColor(0,
0,
0,
(nodeData.
fadeNumber)));
}
else
{
painter
->setPen
(QColor(0xff, 0xff, 0xff,
(nodeData.
fadeNumber)));
}
}
// Write RE
if (nodeData.re>100)
{
rebyte=nodeData.re-100;
}
else
{
rebyte=nodeData.re;
}
if (rebyte>4&&nodeData.addr>0)
{
qsTemp.sprintf("%d Sec", rebyte);//rebyte
painter->setFont(timeFont);
painter->drawText(-50,+8,100,20,Qt::AlignCenter , qsTemp,0);
}
else if (nodeData.addr>0)
{
qsTemp.sprintf("%d Min", rebyte);
painter->setFont(timeFont);
painter->drawText(-50,+8,100,20,Qt::AlignCenter , qsTemp,0);
}
else if (nodeData.addr==0)
{
//qsTemp = timeStamp.toString("hh:mm:ss");
qsTemp = timeStamp.toString(Qt::LocalDate);
//qsTemp.sprintf("TxCt: %d", cnt_rf);// for Jeff battery test only
painter->setFont(timeFont);
painter->drawText(-50,+5,100,20,Qt::AlignCenter , qsTemp,0);
}
// Write the battery voltage
qsTemp.sprintf("%.1fV", nodeData.voltage);
painter->setFont(battFont);
painter->drawText(-50,+25,100,20,Qt::AlignCenter , qsTemp,0);
// Set text in the node
// Write the temperature
if(celsius)
{
qsTemp.sprintf("%.1f°C", ((nodeData.temp-32.0)/1.8));
}
else
{
qsTemp.sprintf("%.1f°F", nodeData.temp);
}
if (nodeData.addr==0) //node 0
{
//xpainter->setFont(tempFont);
painter->setFont(addrFont);
painter->drawText(-50,-45,100,40,Qt::AlignCenter , qsTemp,0);
}
else
{
painter->setFont(timeFont);
painter->drawText(-50,-48,100,40,Qt::AlignCenter , qsTemp,0);
}
if (nodeData.addr==0) //node 0
{
// Write node number
//qsTemp.sprintf("Node: %d", nodeData.addr);
qsTemp.sprintf("Access Point");
//xpainter->setFont(addrFont);
painter->setFont(timeFont);
painter->drawText(-50,-15,100,20,Qt::AlignCenter , qsTemp,0);
}
else
{
// Write node number
// end device details
qsTemp.sprintf("End Device %d", nodeData.addr);
//xpainter->setFont(addrFont);
painter->setFont(timeFont);
painter->drawText(-50,-22,100,20,Qt::AlignCenter , qsTemp,0);
//Write signal strength in ED node
if (nodeData.strength > 21)
{
qsTemp.sprintf("Strong", nodeData.strength);
painter->setFont(strengthFont);
painter->drawText(-50,-8,100,20,Qt::AlignCenter , qsTemp,0);
}
else if (nodeData.strength > 15)
{
qsTemp.sprintf("Medium", nodeData.strength);
painter->setFont(strengthFont);
painter->drawText(-50,-8,100,20,Qt::AlignCenter , qsTemp,0);
}
else
{
qsTemp.sprintf("Weak", nodeData.strength);
painter->setFont(strengthFont);
painter->drawText(-50,-8,100,20,Qt::AlignCenter , qsTemp,0);
}
//temperture alert,
if(nodeData.temp > (nodeAlertTemp*9)/5+32.0)
{
painter->setPen(Qt::NoPen);
painter
->setBrush
(QColor(0x80, 0x80, 0x80,
(nodeData.
fadeNumber)));
painter->drawEllipse(-45, -45, 100, 100);
gradient.setCenter(3, 3);
gradient.setFocalPoint(3, 3);
gradient.setColorAt(1, nodeAlertColor);
gradient.setColorAt(.5, nodeAlertColorDark);
gradient.setColorAt(0, nodeAlertColorDark);
painter->setBrush(gradient);
painter
->setPen
(QColor(0,
0,
0,
(nodeData.
fadeNumber)));
painter->drawEllipse(-50, -50, 100, 100);
if(celsius)
{
qsTemp.sprintf("ALERT!\n\ End Device %d\n\ %.1f°C\n\ ", nodeData.addr, ((nodeData.temp-32.0)/1.8));
painter
->setPen
(QPen(Qt
::black,
0));
painter->setFont(timeFont);
painter->drawText(-50,-50,100,100,Qt::AlignCenter , qsTemp,0);
}
else
{
qsTemp.sprintf("ALERT!\n\ End Device %d\n\ %.1f°F\n\ ", nodeData.addr, nodeData.temp);
painter
->setPen
(QPen(Qt
::black,
0));
painter->setFont(timeFont);
painter->drawText(-50,-50,100,100,Qt::AlignCenter , qsTemp,0);
}
}
painter->drawRect(-43,-20,85,15);
nameLine
->setGeometry
(QRect(-43,
-20,
85,
15));
[/COLOR
] }
void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
{
QPixmap pixmap2(200,100);
pixmap2.fill(Qt::white);
QPixmap pix;
QPainter painter1(&pixmap);
QPainter painter2(&pixmap2);
QString id;
Q_UNUSED(option);
QSettings settings;
nodeAlertTemp = settings.value("NodeAlertTemp", 10).toDouble();
if (nodeData.addr!=0){
if(nodeData.fadeNumber>5&&nodeData.deletedNode!=0)
{
nodeData.fadeNumber-=fade_speed;
if (nodeData.fadeNumber<=5){
nodeData.fadeNumber=0;
nodeData.deletedNode=1;
index_number=0;
}
}
if(nodeData.fadeNumber<255&&nodeData.newNode!=0)
{
nodeData.fadeNumber+=fade_speed;
if (nodeData.fadeNumber>=255)
{
nodeData.fadeNumber=255;
nodeData.newNode=0;
//current_updateData(index_number);
index_number=0;
}
}
}
// Draw the grey shadow for a 3d effect.
painter->setPen(Qt::NoPen);
painter->setBrush (QColor(0x80, 0x80, 0x80,(nodeData.fadeNumber)));
painter->drawEllipse(-45, -45, 100, 100);
// Set gradient and color of the node
QRadialGradient gradient(0, 0, 50, -20, -20);// access points
if (nodeData.addr==0&&updated == true)
{
// Mouse click on node or an update of node data~
gradient.setCenter(3, 3);
gradient.setFocalPoint(3, 3);
gradient.setColorAt(1, nodeColor.light(120));
gradient.setColorAt(.5, nodeColorDark.light(120));
gradient.setColorAt(0, nodeColorDark.light(120));
updated = false;
painter->setBrush(gradient);
}
else if (nodeData.addr==0&&updated == false)
{
gradient.setColorAt(0, nodeColor.light(150));
gradient.setColorAt(1, nodeColorDark);
painter->setBrush(gradient);
}
// end devices
if (nodeData.addr!=0&&updated == true)
{
// Mouse click on node or an update of node data~
gradient.setCenter(3, 3);
gradient.setFocalPoint(3, 3);
gradient.setColorAt(1, nodeColor);
gradient.setColorAt(.5, nodeColor);
gradient.setColorAt(0, nodeColor);
updated = false;
painter->setBrush(gradient);
}
else if (nodeData.addr!=0&&updated == false)
{
gradient.setColorAt(0, nodeColor);
gradient.setColorAt(.95, nodeColorDark);
gradient.setColorAt(1, nodeColor);
painter->setBrush(gradient);
}
// painter->setBrush(gradient);
// Draw black circle around the node
painter->setPen(QColor(0, 0, 0,(nodeData.fadeNumber)));
// Draw the node
painter->drawEllipse(-50, -50, 100, 100);
//x new text
// White pen for text
if (nodeData.addr==0)
{
painter->setPen(QPen(Qt::white, 1));
}
else
{
if(nodeData.re<100)
{
painter->setPen(QColor(0, 0, 0,(nodeData.fadeNumber)));
}
else
{
painter->setPen(QColor(0xff, 0xff, 0xff,(nodeData.fadeNumber)));
}
}
QString qsTemp;
QString qsTemp2;
// Write RE
if (nodeData.re>100)
{
rebyte=nodeData.re-100;
}
else
{
rebyte=nodeData.re;
}
if (rebyte>4&&nodeData.addr>0)
{
qsTemp.sprintf("%d Sec", rebyte);//rebyte
painter->setFont(timeFont);
painter->drawText(-50,+8,100,20,Qt::AlignCenter , qsTemp,0);
}
else if (nodeData.addr>0)
{
qsTemp.sprintf("%d Min", rebyte);
painter->setFont(timeFont);
painter->drawText(-50,+8,100,20,Qt::AlignCenter , qsTemp,0);
}
else if (nodeData.addr==0)
{
//qsTemp = timeStamp.toString("hh:mm:ss");
qsTemp = timeStamp.toString(Qt::LocalDate);
//qsTemp.sprintf("TxCt: %d", cnt_rf);// for Jeff battery test only
painter->setFont(timeFont);
painter->drawText(-50,+5,100,20,Qt::AlignCenter , qsTemp,0);
}
// Write the battery voltage
qsTemp.sprintf("%.1fV", nodeData.voltage);
painter->setFont(battFont);
painter->drawText(-50,+25,100,20,Qt::AlignCenter , qsTemp,0);
// Set text in the node
// Write the temperature
if(celsius)
{
qsTemp.sprintf("%.1f°C", ((nodeData.temp-32.0)/1.8));
}
else
{
qsTemp.sprintf("%.1f°F", nodeData.temp);
}
if (nodeData.addr==0) //node 0
{
//xpainter->setFont(tempFont);
painter->setFont(addrFont);
painter->drawText(-50,-45,100,40,Qt::AlignCenter , qsTemp,0);
}
else
{
painter->setFont(timeFont);
painter->drawText(-50,-48,100,40,Qt::AlignCenter , qsTemp,0);
}
if (nodeData.addr==0) //node 0
{
// Write node number
//qsTemp.sprintf("Node: %d", nodeData.addr);
qsTemp.sprintf("Access Point");
//xpainter->setFont(addrFont);
painter->setFont(timeFont);
painter->drawText(-50,-15,100,20,Qt::AlignCenter , qsTemp,0);
}
else
{
// Write node number
// end device details
qsTemp.sprintf("End Device %d", nodeData.addr);
//xpainter->setFont(addrFont);
painter->setFont(timeFont);
painter->drawText(-50,-22,100,20,Qt::AlignCenter , qsTemp,0);
//Write signal strength in ED node
if (nodeData.strength > 21)
{
qsTemp.sprintf("Strong", nodeData.strength);
painter->setFont(strengthFont);
painter->drawText(-50,-8,100,20,Qt::AlignCenter , qsTemp,0);
}
else if (nodeData.strength > 15)
{
qsTemp.sprintf("Medium", nodeData.strength);
painter->setFont(strengthFont);
painter->drawText(-50,-8,100,20,Qt::AlignCenter , qsTemp,0);
}
else
{
qsTemp.sprintf("Weak", nodeData.strength);
painter->setFont(strengthFont);
painter->drawText(-50,-8,100,20,Qt::AlignCenter , qsTemp,0);
}
//temperture alert,
if(nodeData.temp > (nodeAlertTemp*9)/5+32.0)
{
painter->setPen(Qt::NoPen);
painter->setBrush (QColor(0x80, 0x80, 0x80,(nodeData.fadeNumber)));
painter->drawEllipse(-45, -45, 100, 100);
gradient.setCenter(3, 3);
gradient.setFocalPoint(3, 3);
QRadialGradient gradient(0, 0, 50, -20, -20);
gradient.setColorAt(1, nodeAlertColor);
gradient.setColorAt(.5, nodeAlertColorDark);
gradient.setColorAt(0, nodeAlertColorDark);
painter->setBrush(gradient);
painter->setPen(QColor(0, 0, 0,(nodeData.fadeNumber)));
painter->drawEllipse(-50, -50, 100, 100);
if(celsius)
{
qsTemp.sprintf("ALERT!\n\ End Device %d\n\ %.1f°C\n\ ", nodeData.addr, ((nodeData.temp-32.0)/1.8));
painter->setPen(QPen(Qt::black, 0));
painter->setFont(timeFont);
painter->drawText(-50,-50,100,100,Qt::AlignCenter , qsTemp,0);
}
else
{
qsTemp.sprintf("ALERT!\n\ End Device %d\n\ %.1f°F\n\ ", nodeData.addr, nodeData.temp);
painter->setPen(QPen(Qt::black, 0));
painter->setFont(timeFont);
painter->drawText(-50,-50,100,100,Qt::AlignCenter , qsTemp,0);
}
}
painter->drawRect(-43,-20,85,15);
[COLOR="blue"]nameLine = new QLineEdit();
nameLine->setGeometry(QRect(-43,-20,85,15));[/COLOR] }
To copy to clipboard, switch view to plain text mode
Bookmarks