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_sound_source.h"
00023
00024 namespace stdr_gui{
00025
00032 CGuiSoundSource::CGuiSoundSource(QPoint p,std::string name, float resolution):
00033 position_(p),
00034 name_(name),
00035 resolution_(resolution),
00036 db_(0.0)
00037 {
00038
00039 }
00040
00045 CGuiSoundSource::~CGuiSoundSource(void)
00046 {
00047
00048 }
00049
00054 std::string CGuiSoundSource::getName(void)
00055 {
00056 return name_;
00057 }
00058
00064 bool CGuiSoundSource::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 CGuiSoundSource::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
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
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
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 CGuiSoundSource::setDb(float db)
00128 {
00129 db_ = db;
00130 }
00131
00136 float CGuiSoundSource::getDb(void)
00137 {
00138 return db_;
00139 }
00140 }
00141