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 
25 #include <sstream>
26 
27 #include <QFileDialog>
28 
29 #include <IceUtil/UUID.h>
30 
32 
33 #include "ArmarXPlotter.h"
34 
35 namespace armarx
36 {
38  QDialog(parent), uuid(IceUtil::generateUUID()), iceManager(iceManager)
39  {
40  ui.setupUi(this);
41  model = NULL;
42 
43 
44  connect(ui.BTNAddSelectedChannels,
45  SIGNAL(clicked()),
46  this,
48  connect(ui.BTNRemoveSelected, SIGNAL(clicked()), this, SLOT(ButtonRemoveChannelClicked()));
49  connect(ui.treeViewObservers,
50  SIGNAL(doubleClicked(QModelIndex)),
51  this,
52  SLOT(treeView_doubleClick(QModelIndex)));
53  connect(ui.listWidget,
54  SIGNAL(doubleClicked(QModelIndex)),
55  this,
56  SLOT(ButtonRemoveChannelClicked(QModelIndex)));
57  connect(ui.btnRefresh, SIGNAL(clicked()), this, SLOT(updateObservers()));
58  }
59 
61  {
62  // ARMARX_INFO << "~ArmarXPlotterDialog" ;
63  }
64 
65  void
67  {
68  this->iceManager = iceManager;
69  }
70 
71  //string ArmarXPlotterDialog::getDefaultName() const
72  //{
73  // stringstream str;
74  // str << "ArmarXPlotterDialog" << uuid;
75  // return str.str();
76  //}
77 
78 
79  //void ArmarXPlotterDialog::onInitComponent()
80  //{
81  // usingProxy("ConditionHandler");
82  //}
83 
84  //void ArmarXPlotterDialog::onConnectComponent()
85  //{
86  // // get proxy of conditionhandler
87  // handler = getProxy<ConditionHandlerInterfacePrx>("ConditionHandler");
88 
89  // updateObservers();
90  //}
91 
92  //void ArmarXPlotterDialog::onExitComponent()
93  //{
94 
95  //}
96 
97  void
99  {
100  }
101 
102  void
104  {
105  if (!model)
106  {
107  model = new ObserverItemModel(iceManager, NULL);
108  // proxyModel = new InfixFilterModel(this);
109  // proxyModel->setSourceModel(model);
110  // ui.treeViewObservers->setModel(proxyModel);
111  ui.treeViewObservers->setModel(model);
112  }
113 
114  model->updateObservers();
115 
116  // if(!iceManager)
117  // return;
118  // ObserverList observerList = iceManager->getIceGridSession()->getRegisteredObjectNames<ObserverInterfacePrx>("*Observer");
119  // ObserverList::iterator iter = observerList.begin();
120 
121  // while(iter != observerList.end())
122  // {
123  // model->updateModel(*iter, iceManager->getProxy<ObserverInterfacePrx>(*iter)->getAvailableChannels(), StringConditionCheckMap());
124  // iter++;
125  // }
126  }
127 
128  void
130  {
131  QItemSelectionModel* selectionModel = ui.treeViewObservers->selectionModel();
132 
133  // auto selection = ui.treeViewObservers->getProxyModel()->mapSelectionToSource(selectionModel->selection());
134 
135  for (auto index : selectionModel->selection().indexes())
136  {
138  }
139 
140  ui.treeViewObservers->clearSelection();
141  }
142 
143  void
145  {
146  QList<QListWidgetItem*> selectedItems = ui.listWidget->selectedItems();
147 
148  for (int i = 0; i < selectedItems.size(); ++i)
149  {
150  delete selectedItems.at(i);
151  }
152  }
153 
154  void
156  {
157  delete ui.listWidget->item(index.row());
158  }
159 
160  QStringList
162  {
163  QStringList result;
164  QList<QListWidgetItem*> items =
165  ui.listWidget->findItems(QString("*"), Qt::MatchWrap | Qt::MatchWildcard);
166  foreach (QListWidgetItem* item, items)
167  {
168  result.append(item->text());
169  }
170 
171  return result;
172  }
173 
174  void
175  ArmarXPlotterDialog::treeView_selected(const QItemSelection& selected,
176  const QItemSelection& deselected)
177  {
178  }
179 
180  void
181  ArmarXPlotterDialog::treeView_doubleClick(const QModelIndex& proxyIndex)
182  {
183 
184  auto modelIndex = ui.treeViewObservers->getProxyModel()->mapToSource(proxyIndex);
185  QStandardItem* item = model->itemFromIndex(modelIndex);
186  QVariant id = item->data(OBSERVER_ITEM_ID);
187 
188  switch (item->data(OBSERVER_ITEM_TYPE).toInt())
189  {
190  case eDataFieldItem:
191  if (ui.listWidget->findItems(id.toString(), Qt::MatchExactly).size() == 0)
192  {
193  ui.listWidget->addItem(id.toString());
194  }
195 
196  break;
197  }
198  }
199 
200  void
202  {
203  setParent(0);
204  }
205 
206  void
208  {
209  updateObservers();
210  }
211 
212  void
213  armarx::ArmarXPlotterDialog::on_btnSelectLoggingDir_clicked()
214  {
215  QString newLoggingDir =
216  QFileDialog::getExistingDirectory(this,
217  "Select a directory to which data should be logged",
218  ui.editLoggingDirectory->text());
219 
220  if (!newLoggingDir.isEmpty())
221  {
222  ui.editLoggingDirectory->setText(newLoggingDir);
223  }
224  }
225 } // namespace armarx
armarx::ArmarXPlotterDialog::getSelectedDatafields
QStringList getSelectedDatafields()
Definition: ArmarXPlotterDialog.cpp:161
armarx::ArmarXPlotterDialog::updateObservers
void updateObservers()
Definition: ArmarXPlotterDialog.cpp:103
armarx::ArmarXPlotterDialog::onCloseWidget
void onCloseWidget(QCloseEvent *event)
emits the closeRequest signal
Definition: ArmarXPlotterDialog.cpp:98
ArmarXPlotter.h
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::ArmarXPlotterDialog::ArmarXPlotterDialog
ArmarXPlotterDialog(QWidget *parent, IceManagerPtr iceManager)
Definition: ArmarXPlotterDialog.cpp:37
OBSERVER_ITEM_TYPE
#define OBSERVER_ITEM_TYPE
Definition: ObserverItemModel.h:37
InfixFilterModel.h
armarx::ArmarXPlotterDialog::treeView_selected
void treeView_selected(const QItemSelection &selected, const QItemSelection &deselected)
Definition: ArmarXPlotterDialog.cpp:175
IceUtil
Definition: Instance.h:21
OBSERVER_ITEM_ID
#define OBSERVER_ITEM_ID
Definition: ObserverItemModel.h:38
armarx::ArmarXPlotterDialog::destroyed
void destroyed(QObject *)
Definition: ArmarXPlotterDialog.cpp:201
armarx::ArmarXPlotterDialog::ButtonAddSelectedChannelClicked
void ButtonAddSelectedChannelClicked()
Definition: ArmarXPlotterDialog.cpp:129
armarx::ObserverItemModel::updateObservers
void updateObservers()
Definition: ObserverItemModel.cpp:254
armarx::ArmarXPlotterDialog::ButtonRemoveChannelClicked
void ButtonRemoveChannelClicked()
Definition: ArmarXPlotterDialog.cpp:144
armarx::ArmarXPlotterDialog::setIceManager
void setIceManager(IceManagerPtr iceManager)
Definition: ArmarXPlotterDialog.cpp:66
ArmarXPlotterDialog.h
armarx::ArmarXPlotterDialog::~ArmarXPlotterDialog
~ArmarXPlotterDialog() override
Definition: ArmarXPlotterDialog.cpp:60
armarx::ArmarXPlotterDialog::treeView_doubleClick
void treeView_doubleClick(const QModelIndex &proxyIndex)
Definition: ArmarXPlotterDialog.cpp:181
armarx::ArmarXPlotterDialog::ui
Ui::ArmarXPlotterDialog ui
Definition: ArmarXPlotterDialog.h:73
IceUtil::Handle< IceManager >
armarx::eDataFieldItem
@ eDataFieldItem
Definition: ObserverItemModel.h:53
armarx::viz::toString
const char * toString(InteractionFeedbackType type)
Definition: Interaction.h:28
armarx::ObserverItemModel
Definition: ObserverItemModel.h:61
armarx::ArmarXPlotterDialog::showEvent
void showEvent(QShowEvent *) override
Definition: ArmarXPlotterDialog.cpp:207
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27