YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025-2025 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6#include "mainwindow.h"
7#include <QApplication>
8
9#include <yarp/os/Property.h>
10#include <yarp/os/Network.h>
11
12int main(int argc, char *argv[])
13{
15
16 QApplication a(argc, argv);
17 MainWindow *window = nullptr;
18
19 yarp::os::Property options;
20 options.fromCommand(argc,argv);
21
22 if (options.check("help"))
23 {
24 yInfo("usage:");
25 yInfo("yarpframegrabbergui --local <localportname> --remote <grabberport> [--width <gui width>] [--height <gui height>] [--x <gui x pos>] [--y <gui y pos>]");
26 return 0;
27 }
28
29 yDebug("%s\n",options.toString().c_str());
30
31 // switch to subsections if available
32 yarp::os::Searchable *Network = &options.findGroup("NETWORK");
33 yarp::os::Searchable *Window = &options.findGroup("WINDOW");
34
35 if (Network->isNull()) { Network = &options; }
36 if (Window->isNull()) { Window = &options; }
37
38 yarp::os::Value *val =nullptr;
39
40 std::string localPortName = "/yarpframegrabbergui/rpc";
41 std::string remotePortName;
42 if (Network->check("local",val)){
43 localPortName = val->asString();
44 }
45 if (Network->check("remote",val)){
46 remotePortName = val->asString();
47 }
48
49 //yDebug("using local=%s remote=%s x=%d y=%d\n",portName,outPortName,posX,posY);
50
51 window = new MainWindow(localPortName, remotePortName);
52 int posX=0,posY=0;
53 int width,height;
54 width = window->width();
55 height = window->height();
56
57 if (Window->check("PosX",val)||Window->check("x",val)){
58 posX = val->asInt32();
59 }
60 if (Window->check("PosY",val)||Window->check("y",val)){
61 posY = val->asInt32();
62 }
63 if (Window->check("width",val)){
64 width = val->asInt32();
65 }
66 if (Window->check("height",val)){
67 height = val->asInt32();
68 }
69
70 window->resize(width,height);
71 window->move(posX,posY);
72 window->show();
73
74 int ret = a.exec();
75 delete window;
76
77 return (ret!=0?1:0);
78}
bool ret
#define yInfo(...)
Definition Log.h:319
#define yDebug(...)
Definition Log.h:275
MainWindow class.
Definition display.h:22
Utilities for manipulating the YARP network, including initialization and shutdown.
Definition Network.h:706
A class for storing options and configuration information.
Definition Property.h:33
std::string toString() const override
Return a standard text representation of the content of the object.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
void fromCommand(int argc, char *argv[], bool skipFirst=true, bool wipe=true)
Interprets a list of command arguments as a list of properties.
A base class for nested structures that can be searched.
Definition Searchable.h:31
virtual bool isNull() const
Checks if the object is invalid.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
A single value (typically within a Bottle).
Definition Value.h:44
virtual std::int32_t asInt32() const
Get 32-bit integer value.
Definition Value.cpp:210
virtual std::string asString() const
Get string value.
Definition Value.cpp:246
int main(int argc, char *argv[])
Definition main.cpp:393
The main, catch-all namespace for YARP.
Definition dirs.h:16