stdr_gui_thermal_source.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002    STDR Simulator - Simple Two DImensional Robot Simulator
00003    Copyright (C) 2013 STDR Simulator
00004    This program is free software; you can redistribute it and/or modify
00005    it under the terms of the GNU General Public License as published by
00006    the Free Software Foundation; either version 3 of the License, or
00007    (at your option) any later version.
00008    This program is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011    GNU General Public License for more details.
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software Foundation,
00014    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
00015    
00016    Authors : 
00017    * Manos Tsardoulias, etsardou@gmail.com
00018    * Aris Thallas, aris.thallas@gmail.com
00019    * Chris Zalidis, zalidis@gmail.com 
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 


stdr_gui
Author(s): Manos Tsardoulias
autogenerated on Wed Sep 2 2015 03:36:44