Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "stdr_gui/stdr_map_metainformation/stdr_gui_thermal_source.h"
00023
00024 namespace stdr_gui{
00025
00032 CGuiThermalSource::CGuiThermalSource(
00033 QPoint p,std::string name, float resolution):
00034 position_(p),
00035 name_(name),
00036 resolution_(resolution),
00037 degrees_(0.0)
00038 {
00039
00040 }
00041
00046 CGuiThermalSource::~CGuiThermalSource(void)
00047 {
00048
00049 }
00050
00055 std::string CGuiThermalSource::getName(void)
00056 {
00057 return name_;
00058 }
00059
00065 bool CGuiThermalSource::checkProximity(QPoint p)
00066 {
00067 float dx = p.x() * resolution_ - position_.x() * resolution_;
00068 float dy = p.y() * resolution_ - position_.y() * resolution_;
00069 float dist = sqrt( pow(dx,2) + pow(dy,2) );
00070 return dist <= 0.3;
00071 }
00072
00078 void CGuiThermalSource::draw(QImage *img)
00079 {
00080 QPainter painter(img);
00081 int step = 3;
00082 painter.setPen(QColor(200, 0, 0, 200));
00083 for(unsigned int i = 0 ; i < 4 ; i++)
00084 {
00085 painter.drawEllipse(
00086 position_.x() - i * step,
00087 img->height() - position_.y() - i * step,
00088 2 * i * step,
00089 2 * i * step);
00090 }
00091
00093
00094 int text_size = name_.size();
00095
00096 painter.setPen(QColor(0,0,0,100 * (2)));
00097
00098 painter.drawRect(
00099 position_.x() + 10,
00100 img->height() - position_.y() - 30,
00101 3 + text_size * 9,
00102 20);
00103
00104 painter.setPen(QColor(255,255,255,100 * (2)));
00105
00106 painter.fillRect(
00107 position_.x() + 10,
00108 img->height() - position_.y() - 30,
00109 3 + text_size * 9,
00110 20,
00111 QBrush(QColor(0,0,0,100 * (2))));
00112
00113 painter.setFont(QFont("Courier New"));
00114 painter.drawText(
00115 position_.x() + 12,
00116 img->height() - position_.y() - 15,
00117 QString(name_.c_str()));
00118 }
00119
00125 void CGuiThermalSource::setDegrees(float degrees)
00126 {
00127 degrees_ = degrees;
00128 }
00129
00134 float CGuiThermalSource::getDegrees(void)
00135 {
00136 return degrees_;
00137 }
00138 }
00139