summaryrefslogtreecommitdiff
path: root/CIAO/examples/Display/NavDisplayGUI_exec/RootPanel.cpp
blob: c6737ee96c03dab4c83b8c95fe8c71858c0f3f49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// $Id$

#include "RootPanel.h"
#include <qmenubar.h>
#include <qapplication.h>
#include <qprogressdialog.h>
#include <stdlib.h>
#include <qsplitter.h>
#include "NodeItem.h"
#include "Command.h"


RootPanel::RootPanel(QCanvas &c, QWidget *parent, const char *name)
: QMainWindow(parent, name), canvas(c)
{
  QSplitter *s1 = new QSplitter( QSplitter::Vertical, this , "main" );


  navview = new MapView(canvas, s1);
  s1->moveToFirst(navview);

  details = new DetailView(s1);

  QMenuBar* menu = menuBar();

  QPopupMenu* file = new QPopupMenu;
    //file->insertItem("&Fill canvas", this, SLOT(init()), CTRL+Key_F);
    //file->insertItem("&Erase canvas", this, SLOT(clear()), CTRL+Key_E);
    //file->insertItem("&New view", this, SLOT(newView()), CTRL+Key_N);
    file->insertSeparator();
    file->insertItem("E&xit", qApp, SLOT(quit()), CTRL+Key_Q);
  menu->insertItem("&File", file);

  setCentralWidget(s1);
}


RootPanel::~RootPanel()
{
  clear();
}


void
RootPanel::addUnit(NavUnit *unit)
{
  NodeItem *el = new NodeItem(&canvas, *unit);
  nodeMap.bind(unit->getID(), el);
  UnitLocation loc = unit->getLocation();
  el->move(loc.x_, loc.y_);
  el->show();
  this->details->currentNode(unit);
}

void
RootPanel::updateUnit(NavUnit *unit)
{
  NodeItem *el = NULL;
  nodeMap.find(unit->getID(), el);
  UnitLocation loc = unit->getLocation();
  el->move(loc.x_, loc.y_);
  //canvas.update();

  this->details->updateLocation(loc);
}


void
RootPanel::clear()
{
  navview->clear();
}

void
RootPanel::customEvent(QCustomEvent *e)
{
  CommandBase *cmd = (CommandBase*)(e->data());
  cmd->execute();
  delete cmd;
/*
  int elapsed = time.restart();
  int fps = (elapsed == 0 ? 1000 : 1000 / elapsed);

  if(prev_fps != fps)
  {
    prev_fps = fps;
    ups->setNum(prev_fps);
  }
*/
}