ArmarXPlotterDialog.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarX::Gui
17 * @author Mirko Waechter ( mirko.waechter at kit dot edu)
18 * @date 2012
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #include "ArmarXPlotterDialog.h"
24 #include "ArmarXPlotter.h"
25 
26 #include <IceUtil/UUID.h>
27 
28 #include <QFileDialog>
29 #include <sstream>
30 
32 
33 
34 namespace armarx
35 {
37  QDialog(parent),
38  uuid(IceUtil::generateUUID()),
39  iceManager(iceManager)
40  {
41  ui.setupUi(this);
42  model = NULL;
43 
44 
45  connect(ui.BTNAddSelectedChannels, SIGNAL(clicked()), this, SLOT(ButtonAddSelectedChannelClicked()));
46  connect(ui.BTNRemoveSelected, SIGNAL(clicked()), this, SLOT(ButtonRemoveChannelClicked()));
47  connect(ui.treeViewObservers, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(treeView_doubleClick(QModelIndex)));
48  connect(ui.listWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(ButtonRemoveChannelClicked(QModelIndex)));
49  connect(ui.btnRefresh, SIGNAL(clicked()), this, SLOT(updateObservers()));
50 
51 
52  }
53 
55  {
56  // ARMARX_INFO << "~ArmarXPlotterDialog" ;
57  }
58 
60  {
61  this->iceManager = iceManager;
62  }
63 
64 
65 
66  //string ArmarXPlotterDialog::getDefaultName() const
67  //{
68  // stringstream str;
69  // str << "ArmarXPlotterDialog" << uuid;
70  // return str.str();
71  //}
72 
73 
74  //void ArmarXPlotterDialog::onInitComponent()
75  //{
76  // usingProxy("ConditionHandler");
77  //}
78 
79  //void ArmarXPlotterDialog::onConnectComponent()
80  //{
81  // // get proxy of conditionhandler
82  // handler = getProxy<ConditionHandlerInterfacePrx>("ConditionHandler");
83 
84  // updateObservers();
85  //}
86 
87  //void ArmarXPlotterDialog::onExitComponent()
88  //{
89 
90  //}
91 
92  void ArmarXPlotterDialog::onCloseWidget(QCloseEvent* event)
93  {
94 
95  }
96 
98  {
99  if (!model)
100  {
101  model = new ObserverItemModel(iceManager, NULL);
102  // proxyModel = new InfixFilterModel(this);
103  // proxyModel->setSourceModel(model);
104  // ui.treeViewObservers->setModel(proxyModel);
105  ui.treeViewObservers->setModel(model);
106 
107  }
108 
109  model->updateObservers();
110 
111  // if(!iceManager)
112  // return;
113  // ObserverList observerList = iceManager->getIceGridSession()->getRegisteredObjectNames<ObserverInterfacePrx>("*Observer");
114  // ObserverList::iterator iter = observerList.begin();
115 
116  // while(iter != observerList.end())
117  // {
118  // model->updateModel(*iter, iceManager->getProxy<ObserverInterfacePrx>(*iter)->getAvailableChannels(), StringConditionCheckMap());
119  // iter++;
120  // }
121  }
122 
123 
124 
125 
126 
127 
129  {
130  QItemSelectionModel* selectionModel = ui.treeViewObservers->selectionModel();
131 
132  // auto selection = ui.treeViewObservers->getProxyModel()->mapSelectionToSource(selectionModel->selection());
133 
134  for (auto index : selectionModel->selection().indexes())
135  {
137  }
138 
139  ui.treeViewObservers->clearSelection();
140 
141  }
142 
144  {
145  QList<QListWidgetItem*> selectedItems = ui.listWidget->selectedItems();
146 
147  for (int i = 0; i < selectedItems.size(); ++i)
148  {
149  delete selectedItems.at(i);
150  }
151  }
152 
154  {
155  delete ui.listWidget->item(index.row());
156  }
157 
159  {
160  QStringList result;
161  QList <QListWidgetItem*> items = ui.listWidget->findItems(QString("*"), Qt::MatchWrap | Qt::MatchWildcard);
162  foreach (QListWidgetItem* item, items)
163  {
164  result.append(item->text());
165  }
166 
167  return result;
168  }
169 
170  void ArmarXPlotterDialog::treeView_selected(const QItemSelection& selected, const QItemSelection& deselected)
171  {
172  }
173 
174  void ArmarXPlotterDialog::treeView_doubleClick(const QModelIndex& proxyIndex)
175  {
176 
177  auto modelIndex = ui.treeViewObservers->getProxyModel()->mapToSource(proxyIndex);
178  QStandardItem* item = model->itemFromIndex(modelIndex);
179  QVariant id = item->data(OBSERVER_ITEM_ID);
180 
181  switch (item->data(OBSERVER_ITEM_TYPE).toInt())
182  {
183  case eDataFieldItem:
184  if (ui.listWidget->findItems(id.toString(), Qt::MatchExactly).size() == 0)
185  {
186  ui.listWidget->addItem(id.toString());
187  }
188 
189  break;
190 
191  }
192  }
193 
195  {
196  setParent(0);
197  }
198 
200  {
201  updateObservers();
202  }
203 
204 
205  void armarx::ArmarXPlotterDialog::on_btnSelectLoggingDir_clicked()
206  {
207  QString newLoggingDir = QFileDialog::getExistingDirectory(this, "Select a directory to which data should be logged",
208  ui.editLoggingDirectory->text());
209 
210  if (!newLoggingDir.isEmpty())
211  {
212  ui.editLoggingDirectory->setText(newLoggingDir);
213  }
214  }
215 }
armarx::ArmarXPlotterDialog::getSelectedDatafields
QStringList getSelectedDatafields()
Definition: ArmarXPlotterDialog.cpp:158
armarx::ArmarXPlotterDialog::updateObservers
void updateObservers()
Definition: ArmarXPlotterDialog.cpp:97
armarx::ArmarXPlotterDialog::onCloseWidget
void onCloseWidget(QCloseEvent *event)
emits the closeRequest signal
Definition: ArmarXPlotterDialog.cpp:92
ArmarXPlotter.h
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::ArmarXPlotterDialog::ArmarXPlotterDialog
ArmarXPlotterDialog(QWidget *parent, IceManagerPtr iceManager)
Definition: ArmarXPlotterDialog.cpp:36
OBSERVER_ITEM_TYPE
#define OBSERVER_ITEM_TYPE
Definition: ObserverItemModel.h:39
InfixFilterModel.h
armarx::ArmarXPlotterDialog::treeView_selected
void treeView_selected(const QItemSelection &selected, const QItemSelection &deselected)
Definition: ArmarXPlotterDialog.cpp:170
IceUtil
Definition: Instance.h:21
OBSERVER_ITEM_ID
#define OBSERVER_ITEM_ID
Definition: ObserverItemModel.h:40
armarx::ArmarXPlotterDialog::destroyed
void destroyed(QObject *)
Definition: ArmarXPlotterDialog.cpp:194
armarx::ArmarXPlotterDialog::ButtonAddSelectedChannelClicked
void ButtonAddSelectedChannelClicked()
Definition: ArmarXPlotterDialog.cpp:128
armarx::ObserverItemModel::updateObservers
void updateObservers()
Definition: ObserverItemModel.cpp:228
armarx::ArmarXPlotterDialog::ButtonRemoveChannelClicked
void ButtonRemoveChannelClicked()
Definition: ArmarXPlotterDialog.cpp:143
armarx::ArmarXPlotterDialog::setIceManager
void setIceManager(IceManagerPtr iceManager)
Definition: ArmarXPlotterDialog.cpp:59
ArmarXPlotterDialog.h
armarx::ArmarXPlotterDialog::~ArmarXPlotterDialog
~ArmarXPlotterDialog() override
Definition: ArmarXPlotterDialog.cpp:54
armarx::ArmarXPlotterDialog::treeView_doubleClick
void treeView_doubleClick(const QModelIndex &proxyIndex)
Definition: ArmarXPlotterDialog.cpp:174
armarx::ArmarXPlotterDialog::ui
Ui::ArmarXPlotterDialog ui
Definition: ArmarXPlotterDialog.h:74
IceUtil::Handle< IceManager >
armarx::eDataFieldItem
@ eDataFieldItem
Definition: ObserverItemModel.h:55
armarx::viz::toString
const char * toString(InteractionFeedbackType type)
Definition: Interaction.h:27
armarx::ObserverItemModel
Definition: ObserverItemModel.h:64
armarx::ArmarXPlotterDialog::showEvent
void showEvent(QShowEvent *) override
Definition: ArmarXPlotterDialog.cpp:199
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28