stdr_gui_co2_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_co2_source.h"
00023 
00024 namespace stdr_gui{
00025    
00032   CGuiCo2Source::CGuiCo2Source(QPoint p,std::string name, float resolution):
00033     position_(p),
00034     name_(name),
00035     resolution_(resolution),
00036     ppm_(0.0)
00037   {
00038   
00039   }
00040   
00045   CGuiCo2Source::~CGuiCo2Source(void)
00046   {
00047 
00048   }
00049   
00054   std::string CGuiCo2Source::getName(void)
00055   {
00056     return name_;
00057   }
00058   
00064   bool CGuiCo2Source::checkProximity(QPoint p)
00065   {
00066     float dx = p.x() * resolution_ - position_.x() * resolution_;
00067     float dy = p.y() * resolution_ - position_.y() * resolution_;
00068     float dist = sqrt( pow(dx,2) + pow(dy,2) );
00069     return dist <= 0.3;
00070   }
00071   
00077   void CGuiCo2Source::draw(QImage *img)
00078   {
00079     QPainter painter(img);
00080     int step = 3;
00081     painter.setPen(QColor(0,200,0,200));
00082     for(unsigned int i = 0 ; i < 4 ; i++)
00083     {
00084       painter.drawEllipse(
00085         position_.x() - i * step, 
00086         img->height() - position_.y() - i * step, 
00087         2 * i * step, 
00088         2 * i * step);
00089     }
00090     
00092     
00093     int text_size = name_.size();
00094     
00095     //~ painter.setPen(QColor(0,0,0,100 * (2 - visualization_status_)));
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 - visualization_status_)));
00105     painter.setPen(QColor(255,255,255,100 * (2)));
00106     
00107     painter.fillRect(
00108       position_.x() + 10,
00109       img->height() - position_.y() - 30,
00110       3 + text_size * 9,
00111       20,
00112       QBrush(QColor(0,0,0,100 * (2))));
00113       //~ QBrush(QColor(0,0,0,100 * (2 - visualization_status_))));
00114     
00115     painter.setFont(QFont("Courier New"));
00116     painter.drawText(
00117       position_.x() + 12,
00118       img->height() - position_.y() - 15,
00119       QString(name_.c_str()));
00120   }
00121   
00127   void CGuiCo2Source::setPpm(float ppm)
00128   {
00129     ppm_ = ppm;
00130   }
00131   
00136   float CGuiCo2Source::getPpm(void)
00137   {
00138     return ppm_;
00139   }
00140 }
00141 


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