ImageMonitorPropertiesWidget.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::
17 * @author Kai Welke ( welke 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 
25 
26 
27 // STD/STL
28 #include <map>
29 #include <string>
30 
31 // Qt
32 #include <QApplication>
33 
34 // ArmarXGui
36 
37 
38 using namespace armarx;
39 
40 namespace visionx
41 {
42  ImageMonitorPropertiesWidget::ImageMonitorPropertiesWidget()
43  {
44  ui.setupUi(this);
46  proxyFinder->setSearchMask("*Provider|*Result");
47  ui.horizontalLayout->addWidget(proxyFinder);
48 
49  connect(proxyFinder,
50  SIGNAL(validProxySelected(QString)),
51  this,
52  SLOT(onValidProxySelected(QString)));
53  connect(ui.spinBoxDepthImageIndex,
54  SIGNAL(valueChanged(int)),
55  this,
56  SLOT(refreshRecordingWidgets()));
57  connect(ui.comboBoxCompressionType,
58  SIGNAL(currentIndexChanged(int)),
59  this,
60  SLOT(compressionTypeChanged(int)));
61 
62  // Initialise options for frame rate dropdown
63  this->ui.comboBoxFrameRate->addItem("Source framerate", -1);
64  for (unsigned int i = 30; i > 0; i -= 5)
65  {
66  this->ui.comboBoxFrameRate->addItem(QString::number(i) + " fps", static_cast<int>(i));
67  }
68  this->ui.comboBoxFrameRate->addItem("1 fps", 1);
69 
70  QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
71  this->setSizePolicy(sizePolicy);
72  }
73 
74  ImageMonitorPropertiesWidget::~ImageMonitorPropertiesWidget()
75  {
76  // pass
77  }
78 
79  void
81  IceManagerPtr iceManager)
82  {
83  this->iceManager = iceManager;
84  proxyFinder->setIceManager(iceManager, proxyFinder->getSelectedProxyName().isEmpty());
85  proxyFinder->setDefaultSelectedProxy(QString::fromStdString(properties.providerName));
86 
87  // select framerate
88  this->ui.comboBoxFrameRate->setCurrentIndex(
89  this->ui.comboBoxFrameRate->findData(properties.frameRate));
90 
91  ui.doubleSpinBoxBufferFps->setValue(static_cast<double>(properties.bufferFps));
92  ui.spinBoxImageBuffer->setValue(properties.imageBufferSize);
93 
94  QStringList l;
95  for (auto number : properties.imagesToShow)
96  {
97  l << QString::number(number);
98  }
99  ui.lineEditImagesToShow->setText(l.join(","));
100 
101  ui.spinBoxMaxDepth->setValue(properties.maxDepthmm);
102  ui.spinBoxDepthImageIndex->setValue(properties.depthImageIndex);
103 
104  ui.comboBoxCompressionType->setCurrentIndex((int)properties.compressionType);
105  // compressionTypeChanged((int)properties.compressionType);
106  ui.spinBoxCompressionQuality->setValue(properties.compressionQuality);
107  }
108 
110  ImageMonitorPropertiesWidget::getProperties()
111  {
112  ImageMonitorProperties properties;
113 
114  // retrieve provider name
115  QString text = proxyFinder->getSelectedProxyName();
116  std::string providerName = text.toStdString();
117  properties.providerName = providerName;
118 
119  // set framerate
120  properties.frameRate =
121  this->ui.comboBoxFrameRate->itemData(this->ui.comboBoxFrameRate->currentIndex())
122  .toInt();
123 
124  // buffer properties
125  properties.imageBufferSize = ui.spinBoxImageBuffer->value();
126  properties.bufferFps = static_cast<float>(ui.doubleSpinBoxBufferFps->value());
127  QStringList list = ui.lineEditImagesToShow->text().split(",");
128 
129  for (QString& s : list)
130  {
131  bool ok;
132  auto value = s.toULong(&ok);
133  if (ok)
134  {
135  properties.imagesToShow.insert(value);
136  }
137  }
138  for (auto i : properties.imagesToShow)
139  {
140  ARMARX_INFO_S << i;
141  }
142  properties.depthImageIndex = ui.spinBoxDepthImageIndex->value();
143  properties.maxDepthmm = ui.spinBoxMaxDepth->value();
144 
145  properties.compressionType =
146  static_cast<CompressionType>(ui.comboBoxCompressionType->currentIndex());
147  properties.compressionQuality = ui.spinBoxCompressionQuality->value();
148 
149  return properties;
150  }
151 
152  void
153  ImageMonitorPropertiesWidget::onValidProxySelected(const QString& proxyName)
154  {
155  try
156  {
157  // Try to get the object proxy "objPrx" represented by "proxyName"
158  IceGrid::AdminPrx admin = this->iceManager->getIceGridSession()->getAdmin();
159  Ice::Identity objectIceId = Ice::stringToIdentity(proxyName.toStdString());
160  visionx::ImageProviderInterfacePrx imageProviderPrx =
161  visionx::ImageProviderInterfacePrx::checkedCast(
162  admin->getObjectInfo(objectIceId).proxy);
163  unsigned int numImages = static_cast<unsigned int>(imageProviderPrx->getNumberImages());
164  this->numImageSources = numImages;
165  }
166  catch (...)
167  {
168  // pass
169  }
170  }
171 
172  void
173  ImageMonitorPropertiesWidget::compressionTypeChanged(int index)
174  {
175  ui.spinBoxCompressionQuality->setEnabled(index != 0);
176  if (index == 1)
177  {
178  ui.spinBoxCompressionQuality->setValue(9);
179  }
180  else if (index == 2)
181  {
182  ui.spinBoxCompressionQuality->setValue(95);
183  }
184  }
185 } // namespace visionx
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
index
uint8_t index
Definition: EtherCATFrame.h:59
list
list(APPEND SOURCES ${QT_RESOURCES}) set(COMPONENT_LIBS ArmarXGui ArmarXCoreObservers ArmarXCoreEigen3Variants PlotterController $
Definition: CMakeLists.txt:49
visionx::ImageMonitorProperties::maxDepthmm
int maxDepthmm
Definition: ImageMonitorWidgetController.h:105
visionx::ImageMonitorProperties::imageBufferSize
int imageBufferSize
Definition: ImageMonitorWidgetController.h:98
visionx::ImageMonitorProperties::depthImageIndex
int depthImageIndex
Definition: ImageMonitorWidgetController.h:104
visionx::imrecman::ok
@ ok
Definition: ImageRecordingManagerInterface.ice:45
visionx::ImageMonitorProperties::imagesToShow
std::set< size_t > imagesToShow
Definition: ImageMonitorWidgetController.h:100
visionx::ImageMonitorProperties::frameRate
int frameRate
Definition: ImageMonitorWidgetController.h:96
ImageMonitorPropertiesWidget.h
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:570
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
IceProxyFinder.h
visionx::ImageMonitorProperties::providerName
std::string providerName
Definition: ImageMonitorWidgetController.h:95
armarx::armem::server::ltm::util::mongodb::detail::update
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
Definition: mongodb.cpp:68
IceUtil::Handle< IceManager >
armarx::IceProxyFinder< ImageProviderInterfacePrx >
visionx::ImageMonitorProperties
ImageMonitorProperties brief one line description.
Definition: ImageMonitorWidgetController.h:90
ARMARX_INFO_S
#define ARMARX_INFO_S
Definition: Logging.h:202
visionx::ImageMonitorProperties::bufferFps
float bufferFps
Definition: ImageMonitorWidgetController.h:99
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
visionx::ImageMonitorProperties::compressionType
CompressionType compressionType
Definition: ImageMonitorWidgetController.h:106
visionx::ImageMonitorProperties::compressionQuality
int compressionQuality
Definition: ImageMonitorWidgetController.h:107