iCub-main
main.cpp
Go to the documentation of this file.
1 #include "mainwindow.h"
2 #include <QApplication>
3 
4 #include <yarp/os/Property.h>
5 #include <yarp/os/Network.h>
6 
7 int main(int argc, char *argv[])
8 {
9  yarp::os::Network yarp;
10 
11  QApplication a(argc, argv);
12 
13  MainWindow *window = NULL;
14  if(argc == 3){
15  window = new MainWindow(argv[1],argv[2]);
16  window->show();
17  }else if (argc<3) {
18  printf("usage:\n");
19  printf("%s --local <localportname> --remote <grabberport> [--width <gui width>] [--height <gui height>] [--x <gui x pos>] [--y <gui y pos>]\n",argv[0]);
20  return 1;
21  }else if (argc>3){
22 
23  yarp::os::Property options;
24  options.fromCommand(argc,argv);
25 
26  printf("%s\n",options.toString().c_str());
27 
28  // switch to subsections if available
29  yarp::os::Searchable *Network = &options.findGroup("NETWORK");
30  yarp::os::Searchable *Window = &options.findGroup("WINDOW");
31  //yarp::os::Searchable *Program = &options.findGroup("PROGRAM");
32 
33  if (Network->isNull()) { Network = &options; }
34  if (Window->isNull()) { Window = &options; }
35  //if (Program->isNull()) { Program = &options; }
36 
37  yarp::os::Value *val;
38 
39  char portName[256]="",outPortName[256]="";
40 
41  if (Network->check("PortName",val)||Network->check("local",val)){
42  strcpy(portName, val->asString().c_str());
43  }
44 
45  if (Network->check("OutPortName",val)||Network->check("remote",val)){
46  strcpy(outPortName, val->asString().c_str());
47  }
48 
49  //printf("using local=%s remote=%s x=%d y=%d\n",portName,outPortName,posX,posY);
50  //fflush(stdout);
51 
52  window = new MainWindow(portName,outPortName);
53  int posX=0,posY=0;
54  int width,height;
55  width = window->width();
56  height = window->height();
57 
58  if (Window->check("PosX",val)||Window->check("x",val)){
59  posX = val->asInt32();
60  }
61  if (Window->check("PosY",val)||Window->check("y",val)){
62  posY = val->asInt32();
63  }
64  if (Window->check("width",val)){
65  width = val->asInt32();
66  }
67  if (Window->check("height",val)){
68  height = val->asInt32();
69  }
70 
71  window->resize(width,height);
72  window->move(posX,posY);
73  window->show();
74  }
75 
76  int ret = a.exec();
77  delete window;
78 
79  return (ret!=0?1:0);
80 }
int main(int argc, char *argv[])
Definition: main.cpp:31
Copyright (C) 2008 RobotCub Consortium.