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
38using namespace armarx;
39
40namespace visionx
41{
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
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
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
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
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
uint8_t index
Widget to conveniently retrieve a proxy instance name of a specific interface type (the template para...
void update(ImageMonitorProperties properties, armarx::IceManagerPtr iceManager)
ImageMonitorProperties brief one line description.
#define ARMARX_INFO_S
Definition Logging.h:202
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< IceManager > IceManagerPtr
IceManager smart pointer.
Definition ArmarXFwd.h:39
ArmarX headers.