YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
qtyarpview.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6
7#ifndef QTYARPVIEW_H
8#define QTYARPVIEW_H
9
10#include <QQuickItem>
11#include "videoproducer.h"
12
13//#include <cstdio>
14#include <yarp/os/Property.h>
15#include <yarp/os/Network.h>
17#include "ImagePort.h"
18#include "signalhandler.h"
19//using namespace yarp::os;
20
21//-------------------------------------------------
22// Program Options
23//-------------------------------------------------
28{
29 unsigned int m_refreshTime;
30 char m_portName[256];
31 char m_title[256];
32 char m_networkName[256];
35 int m_posX;
36 int m_posY;
37 char m_fileName[256];
39 char m_outPortName[256];
40 char m_outRightPortName[256]; //Name for the mouse right click related port
43 int m_rightEnabled; //If true the right click related output is enabled
46};
47typedef struct mOptions pgmOptions;
48
56class QtYARPView : public QQuickItem
57{
58 Q_OBJECT
59
60 Q_DISABLE_COPY(QtYARPView)
61 Q_PROPERTY(QObject *videoProducer READ getVideoProducer NOTIFY videoProducerChanged)
62 Q_PROPERTY(int posX READ posX NOTIFY posXChanged)
63 Q_PROPERTY(int posY READ posY NOTIFY posYChanged)
64 Q_PROPERTY(int windowWidth READ windowWidth NOTIFY widthChanged)
65 Q_PROPERTY(int windowHeight READ windowHeight NOTIFY heightChanged)
67
68public:
69 QtYARPView(QQuickItem *parent = 0);
70 ~QtYARPView();
71
72 Q_INVOKABLE void freeze(bool check);
73 Q_INVOKABLE void synchDisplayPeriod(bool check);
74 Q_INVOKABLE void synchDisplaySize(bool check);
75 Q_INVOKABLE void changeRefreshInterval(int);
76 Q_INVOKABLE void saveFrame();
77 Q_INVOKABLE void setFileName(QUrl url);
78 Q_INVOKABLE void setFilesName(QUrl url);
79 Q_INVOKABLE void startDumpFrames();
80 Q_INVOKABLE void stopDumpFrames();
81 Q_INVOKABLE bool parseParameters(QStringList);
82 Q_INVOKABLE bool rightClickEnabled();
83 Q_INVOKABLE void clickCoords_2(int x, int y);
84 Q_INVOKABLE void clickCoords_4(int start_x, int start_y, int end_x, int end_y);
85 Q_INVOKABLE void rightClickCoords_2(int x, int y);
86 Q_INVOKABLE void rightClickCoords_4(int start_x, int start_y, int end_x, int end_y);
87
88 Q_INVOKABLE QString getPixelAsStr(int x, int y);
89
90 QObject *getVideoProducer();
91 int posX();
92 int posY();
96
97private:
98 void createObjects();
99 void deleteObjects();
100 void printHelp();
101 void setOptionsToDefault();
102 void setOptions(yarp::os::Searchable& options);
103 bool openPorts();
104 void closePorts();
105 void saveOptFile(char *fileName);
106 void periodToFreq(double avT, double mT, double MT, double &avH, double &mH, double &MH);
107
108private:
110
111 // This Network yarp must be placed before any other yarp dependent member
112 yarp::os::Network yarp;
113 SignalHandler sigHandler;
114#ifdef YARP_LITTLE_ENDIAN
116#else
118#endif
121 InputCallback *ptr_portCallback;
122 pgmOptions _options;
123
124signals:
133 void sendPortFps(QString avg, QString min, QString max);
134 void sendDisplayFps(QString avg, QString min, QString max);
135 void synchRate(bool check);
136 void autosize(bool check);
137 void setName(QString name);
138 void setTitle(QString inputTitle);
139private slots:
140 void onSendFps(double portAvg, double portMin, double portMax, double dispAvg, double dispMin, double dispMax);
141 void onWindowSizeChangeRequested();
142};
143
144#endif // QTYARPVIEW_H
This class is a callback class that receives the video frame from the YARP backend.
Definition ImagePort.h:31
The plugin Core class.
Definition qtyarpview.h:57
int posX
Returns the x position from the options.
Definition qtyarpview.h:62
Q_INVOKABLE void setFilesName(QUrl url)
Sets the current filename of the frame set is going to be saved.
void setName(QString name)
Q_INVOKABLE void clickCoords_4(int start_x, int start_y, int end_x, int end_y)
Q_INVOKABLE QString getPixelAsStr(int x, int y)
Pics the rgb value of the pixel specified by x and y and return it as a string.
Q_INVOKABLE void saveFrame()
Saves the current frame.
void setTitle(QString inputTitle)
Q_INVOKABLE void clickCoords_2(int x, int y)
Q_INVOKABLE void rightClickCoords_2(int x, int y)
int posY
Returns the y position from the options.
Definition qtyarpview.h:63
void autosize(bool check)
Q_INVOKABLE void startDumpFrames()
Saves the current frame set.
int windowWidth
Returns the width from the options.
Definition qtyarpview.h:64
Q_INVOKABLE bool rightClickEnabled()
int windowHeight
Returns the height from the options.
Definition qtyarpview.h:65
void refreshIntervalChanged()
void synchRate(bool check)
void optionsSet()
Q_INVOKABLE void stopDumpFrames()
Stops the current frame set save mode.
void sendPortFps(QString avg, QString min, QString max)
Q_INVOKABLE void rightClickCoords_4(int start_x, int start_y, int end_x, int end_y)
void sizeChanged()
void posXChanged()
Q_INVOKABLE void synchDisplayPeriod(bool check)
Synchs the video stream to the display.
void widthChanged()
Q_INVOKABLE void setFileName(QUrl url)
Sets the current filename of the frame is going to be saved.
void heightChanged()
Q_INVOKABLE void changeRefreshInterval(int)
Changes the refresh interval.
void sendDisplayFps(QString avg, QString min, QString max)
QObject * videoProducer
Definition qtyarpview.h:61
void posYChanged()
Q_INVOKABLE void synchDisplaySize(bool check)
Synchs the size of the window with the size of the video stream.
Q_INVOKABLE bool parseParameters(QStringList)
parse the parameters received from the main container in QstringList form
QObject * getVideoProducer()
returns the videoproducer that acts as bridge between C++ code and QML VideoOutput.
int refreshInterval
Gets the refresh interval from options.
Definition qtyarpview.h:66
Q_INVOKABLE void freeze(bool check)
Freeze the video stream.
void videoProducerChanged()
The class that handles some signals.
The videoproducer class.
A mini-server for performing network communication in the background.
The main, catch-all namespace for YARP.
Definition dirs.h:16
The struct that stores the options.
Definition qtyarpview.h:28
int m_windHeight
Definition qtyarpview.h:34
bool m_synchRate
Definition qtyarpview.h:44
char m_outPortName[256]
Definition qtyarpview.h:39
bool m_autosize
Definition qtyarpview.h:45
unsigned int m_refreshTime
Definition qtyarpview.h:29
int m_saveOnExit
Definition qtyarpview.h:38
char m_outNetworkName[256]
Definition qtyarpview.h:41
char m_outRightPortName[256]
Definition qtyarpview.h:40
int m_rightEnabled
Definition qtyarpview.h:43
char m_fileName[256]
Definition qtyarpview.h:37
int m_posY
Definition qtyarpview.h:36
int m_posX
Definition qtyarpview.h:35
char m_title[256]
Definition qtyarpview.h:31
char m_portName[256]
Definition qtyarpview.h:30
char m_networkName[256]
Definition qtyarpview.h:32
int m_windWidth
Definition qtyarpview.h:33
int m_outputEnabled
Definition qtyarpview.h:42