rock_widget_collection  0.1
Public Slots | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SonarView Class Reference

#include <SonarView.h>

Inherits ImageViewOld.

Public Slots

void setOpenGL (bool flag)
 
void setSonarScan (const char *data, int size, double angle, double timeBetweenBins, bool fromBearing=false)
 
void setPosition (double posX, double posY, double sigmaX, double sigmaY)
 
void setOrientation (const double orientation)
 
void setDistance (double distance, double angle)
 
void paintLine (double bearing, const uint8_t *data, size_t len)
 
void paintReference (double bearing, int distance)
 
void paintPos (int posX, int posY, int sizeX=10, int sizeY=10)
 
- Public Slots inherited from ImageViewOld
void emitUserExport ()
 
void update ()
 
void update2 ()
 
void setDefaultImage ()
 
void setZoomEnabled (bool enabled)
 
virtual void openGL (bool flag)
 
bool onOpenGL ()
 
void setAspectRatio (bool value)
 
bool getAspectRatio ()
 
void saveImage (bool overlay=true)
 
bool saveImage2 (QString path, bool overlay=true)
 
bool saveImage3 (const QString &mode, int pixel_size, int width, int height, const char *pbuffer, QString path, QString format)
 
void resetCrop ()
 
void crop (int x, int y, int w, int h)
 
void addRawImage (const QString &mode, int pixel_size, int width, int height, const char *pbuffer, const int size)
 
void addFrame (const base::samples::frame::Frame &frame)
 
void addImage (const QImage &image)
 
void setGroupStatus (int groupNr, bool enable)
 
void clearGroups ()
 
int getHeight () const
 
int getWidth () const
 
int getFormat () const
 
- Public Slots inherited from MultiWidget
void setActive (bool b)
 
QString getMinimizedLabel ()
 
void setMinimizedLabel (QString label)
 
void childEvent (QChildEvent *event)
 
bool event (QEvent *event)
 
bool isHiddenWhenMinimized () const
 
void hideWhenMin (bool b)
 
- Public Slots inherited from PaintWidget
QObject * addItem (QObject *object)
 
QObject * addPoints (const QList< int > &points_x, const QList< int > &points_y, int groupNr, const QColor &color)
 
QObject * addText (int xPos, int yPos, int groupNr, const QString &text)
 
QObject * addLine (int xPos, int yPos, int groupNr, const QColor &color, int endX, int endY)
 
QObject * addEllipse (int xPos, int yPos, int groupNr, const QColor &color, int width, int height)
 
QObject * addRectangle (int xPos, int yPos, int groupNr, const QColor &color, int width, int height)
 
QObject * addPolyline (int groupNr, const QColor &color, const QList< QPoint > &points)
 
QObject * addPolygon (int groupNr, const QColor &color, const QList< QPoint > &points)
 
QObject * removeItem (QObject *drawItem, bool delete_object)
 
void removeAllItems (bool delete_objects)
 

Public Member Functions

 SonarView (QWidget *parent=NULL, bool use_openGL=true)
 
virtual ~SonarView ()
 
- Public Member Functions inherited from ImageViewOld
 ImageViewOld (QWidget *parent=NULL, bool use_openGL=false)
 
virtual ~ImageViewOld ()
 
void contextMenuEvent (QContextMenuEvent *event)
 
int heightForWidth (int w)
 
void mouseDoubleClickEvent (QMouseEvent *event)
 
- Public Member Functions inherited from MultiWidget
 MultiWidget (QWidget *parent=0)
 
- Public Member Functions inherited from PaintWidget
 PaintWidget (QWidget *parent)
 
 ~PaintWidget ()
 

Protected Member Functions

void paintEvent (QPaintEvent *event)
 
void keyPressEvent (QKeyEvent *)
 
- Protected Member Functions inherited from ImageViewOld
void drawDrawItemsToImage (QImage &image, bool all=false)
 
void drawDrawItemsToPainter (QPainter &painter, bool all=false)
 
virtual void resizeEvent (QResizeEvent *event)
 
void mousePressEvent (QMouseEvent *event)
 
void mouseReleaseEvent (QMouseEvent *event)
 
void calculateRects ()
 
std::pair< QPoint, bool > toImage (QPoint const &p)
 
- Protected Member Functions inherited from PaintWidget
void drawDrawItemsToImage (QImage &image, bool all=false)
 
void drawDrawItemsToPainter (QPainter &painter, bool all=false)
 
void paintEvent (QPaintEvent *event)
 

Protected Attributes

double lastScale
 
int lastBearing
 
QImage img
 
- Protected Attributes inherited from ImageViewOld
QMenu contextMenu
 
QAction * save_image_act
 
QAction * user_export_act
 
QString save_path
 
QImage originalImage
 
QImage image
 
QRect currentCrop
 
bool no_input
 
bool aspect_ratio
 
frame_helper::FrameQImageConverter frame_converter
 
ImageViewOldGLimage_view_gl
 
QRectF target
 
QRectF source
 
bool zoomEnabled
 
QPoint pressPoint
 
bool pressValid
 
- Protected Attributes inherited from MultiWidget
bool isActive
 
bool wasHidden
 
- Protected Attributes inherited from PaintWidget
QList< DrawItem * > items
 
QList< int > disabledGroups
 
bool isOpenGL
 

Additional Inherited Members

- Signals inherited from ImageViewOld
void clickImage (int x, int y)
 
void userExport ()
 
- Signals inherited from MultiWidget
void activityChanged (bool)
 
- Properties inherited from ImageViewOld
bool Use_OpenGL
 
bool Aspect_Ratio
 
- Properties inherited from MultiWidget
bool hideWhenMinimized
 
QString minimizedLabel
 

Detailed Description

Definition at line 12 of file SonarView.h.

Constructor & Destructor Documentation

SonarView::SonarView ( QWidget *  parent = NULL,
bool  use_openGL = true 
)

Definition at line 13 of file SonarView.cc.

13  :
14 ImageViewOld(parent,false),
15 img(10, 10, QImage::Format_RGB888)
16 {
17  resize(width(),height());
18  image_view_gl = 0;
19  use_openGL=false;
20  setOpenGL(use_openGL);
21  lastScale=0;
22 
23 }
void setOpenGL(bool flag)
Definition: SonarView.cc:30
ImageViewOld(QWidget *parent=NULL, bool use_openGL=false)
Definition: ImageViewOld.cc:15
double lastScale
Definition: SonarView.h:33
ImageViewOldGL * image_view_gl
Definition: ImageViewOld.h:195
QImage img
Definition: SonarView.h:36
SonarView::~SonarView ( )
virtual

Definition at line 26 of file SonarView.cc.

27 {
28 }

Member Function Documentation

void SonarView::keyPressEvent ( QKeyEvent *  event)
protected

Definition at line 150 of file SonarView.cc.

150  {
151  SonarViewGL *window = dynamic_cast<SonarViewGL*>(image_view_gl);
152  if(window) window->keyPressEvent(event);
153 }
ImageViewOldGL * image_view_gl
Definition: ImageViewOld.h:195
bool event(QEvent *event)
Definition: MultiWidget.h:63
void keyPressEvent(QKeyEvent *event)
Definition: SonarViewGL.cc:606
void SonarView::paintEvent ( QPaintEvent *  event)
protectedvirtual

Reimplemented from ImageViewOld.

Definition at line 167 of file SonarView.cc.

168 {
169  QPainter painter(this);
170  painter.drawImage(0, 0, img);
171 }
QImage img
Definition: SonarView.h:36
void SonarView::paintLine ( double  bearing,
const uint8_t *  data,
size_t  len 
)
slot

Definition at line 142 of file SonarView.cc.

142  {
143  double s = sin(bearing);
144  double c = cos(bearing);
145  for (size_t i = 0; i < len; i++)
146  img.setPixel((len) + (c * i), (len) + (s * i), qRgb(data[i], data[i], data[i]));
147 }
QImage img
Definition: SonarView.h:36
void SonarView::paintPos ( int  posX,
int  posY,
int  sizeX = 10,
int  sizeY = 10 
)
slot

Definition at line 135 of file SonarView.cc.

135  {
136  QPainter painter(&img);
137  painter.setPen(QColor(255,0,0));
138  painter.drawEllipse(QPoint(posX,posY),sizeX,sizeY);
139  addImage(img);
140 }
void addImage(const QImage &image)
QImage img
Definition: SonarView.h:36
void SonarView::paintReference ( double  bearing,
int  distance 
)
slot

Definition at line 119 of file SonarView.cc.

119  {
120  if(distance > img.size().width()){
121  return;
122  }
123  QPainter painter(&img);
124  double s = sin(bearing);
125  double c = cos(bearing);
126  int x = (img.size().width()/2.0)+(c*distance);
127  int y = (img.size().width()/2.0)+(s*distance);
128 
129  painter.setPen(QColor(255,255,0));
130  painter.drawEllipse(QPoint(x,y),5,5);
131  addImage(img);
132  //painter.drawPoint(x,y);
133 }
void addImage(const QImage &image)
QImage img
Definition: SonarView.h:36
void SonarView::setDistance ( double  distance,
double  angle 
)
slot

Definition at line 55 of file SonarView.cc.

55  {
56  SonarViewGL *window = dynamic_cast<SonarViewGL*>(image_view_gl);
57  double bearing = angle/(M_PI*2.0)*6399.0;
58  if(window){
59  window->setWallDist(bearing,distance,0);
60  }else{
61  //printf("scale: %f, distance: %f\n",lastScale,distance);
62  paintReference(angle,distance/lastScale);
63  }
64 }
void setWallDist(int bearing, int dist, int dist2)
Definition: SonarViewGL.cc:501
double lastScale
Definition: SonarView.h:33
ImageViewOldGL * image_view_gl
Definition: ImageViewOld.h:195
void paintReference(double bearing, int distance)
Definition: SonarView.cc:119
void SonarView::setOpenGL ( bool  flag)
slot

Definition at line 30 of file SonarView.cc.

31 {
32  if(flag)
33  {
34  //prevent activating if it is already activated
35  if(image_view_gl)
36  return;
37 
38  image_view_gl = new SonarViewGL(*this);
39  if (!image_view_gl)
40  return;
41  image_view_gl->resize(width(),height());
42  //image_view_gl->setAspectRatio(aspect_ratio);
43  image_view_gl->show();
44  //SonarViewGL *window = dynamic_cast<SonarViewGL*>(image_view_gl);
45  //window->reset(0.024); //TODO hardcoded value
46  }
47  else
48  {
49  delete image_view_gl;
50  image_view_gl = NULL;
51  }
52 
53 }
ImageViewOldGL * image_view_gl
Definition: ImageViewOld.h:195
void SonarView::setOrientation ( const double  orientation)
slot

Definition at line 161 of file SonarView.cc.

161  {
162  SonarViewGL *window = dynamic_cast<SonarViewGL*>(image_view_gl);
163  if(window)window->setOrientation(orientation);
164 }
void setOrientation(const double orientation)
Definition: SonarViewGL.cc:738
ImageViewOldGL * image_view_gl
Definition: ImageViewOld.h:195
void SonarView::setPosition ( double  posX,
double  posY,
double  sigmaX,
double  sigmaY 
)
slot

Definition at line 156 of file SonarView.cc.

156  {
157  SonarViewGL *window = dynamic_cast<SonarViewGL*>(image_view_gl);
158  if(window)window->setPosition(posX,posY,sigmaX,sigmaY);
159 }
ImageViewOldGL * image_view_gl
Definition: ImageViewOld.h:195
void setPosition(int xRot, int yRot, int zRot, int xMove, int yMove, int zMove, float zoom, int width, int height)
Definition: SonarViewGL.cc:592
void SonarView::setSonarScan ( const char *  data,
int  size,
double  angle,
double  timeBetweenBins,
bool  fromBearing = false 
)
slot

Definition at line 66 of file SonarView.cc.

66  {
67  SonarViewGL *window = dynamic_cast<SonarViewGL*>(image_view_gl);
68  double bearing = angle;
69  double newScale = ((timeBetweenBins*640.0)*1e-9);
70  if(!fromBearing){
71  bearing = angle/(M_PI*2.0)*6399.0;
72  newScale = timeBetweenBins*size/2.0;
73  }
74  newScale = (newScale*1500.0)/size;
75 
76  if(window){
77  if(newScale != lastScale){
78  lastScale = newScale;
79  printf("new Scale: %f\n",newScale);
80  window->reset(newScale);
81  }
82 
83  std::vector<uint8_t> data;
84  for(int i=0;i<size;i++){
85  data.push_back(data_[i]);
86  }
87  window->setData(data,bearing);
88  }else{
89  lastScale = newScale;
90  if(img.size().width() != size*2.0){
91  //img = QImage(size*2.0,size*2.0,QImage::Format_Mono);
92  img = QImage(size*2.0,size*2.0,QImage::Format_RGB888);
93  img.fill(0);
94  printf("Creating new Image with: %i,%i\n",img.size().width(),img.size().height());
95  }
96  int begin,end;
97  if(lastBearing-bearing>0 || lastBearing-bearing < -3000){
98  begin = lastBearing;
99  end = lastBearing-bearing;
100  }else{
101  begin = bearing;
102  end = bearing-lastBearing;
103  }
104 
105  for(int j=0;j<end;j++){
106  int i = ((begin+j));
107  if(i < 0 || i > 6399){
108  break;
109  }
110  paintLine(((double)i)/6399*2.0*M_PI,(const uint8_t*)data_,(size_t)size);
111  }
112  }
113  lastBearing = bearing;
114  addImage(img);
115  resize(width(),height());
116  //ImageView::update();
117 }
void paintLine(double bearing, const uint8_t *data, size_t len)
Definition: SonarView.cc:142
void reset(double currentScale)
Definition: SonarViewGL.cc:74
int lastBearing
Definition: SonarView.h:34
double lastScale
Definition: SonarView.h:33
ImageViewOldGL * image_view_gl
Definition: ImageViewOld.h:195
void addImage(const QImage &image)
void setData(const std::vector< uint8_t > data, int bearing)
Definition: SonarViewGL.cc:102
QImage img
Definition: SonarView.h:36

Member Data Documentation

QImage SonarView::img
protected

Definition at line 36 of file SonarView.h.

int SonarView::lastBearing
protected

Definition at line 34 of file SonarView.h.

double SonarView::lastScale
protected

Definition at line 33 of file SonarView.h.


The documentation for this class was generated from the following files: