37 #include <QHBoxLayout>
39 #include <QToolButton>
41 #include <QMetaObject>
47 #include "boost/bind.hpp"
48 #include <QMetaMethod>
49 #include "libQtSignalAdapters/Qt2Func.h"
50 #include "libQtSignalAdapters/ConnectionFactories.h"
65 mRenderingFpsLabel(new QLabel(this)),
66 mGrabbingInfoLabel(new QLabel(this)),
67 mTpsLabel(new QLabel(this))
79 connect(
trackingService().
get(), SIGNAL(activeToolChanged(
const QString&)),
this, SLOT(updateToolButtons()));
81 connect(
viewService().
get(), SIGNAL(fps(
int)),
this, SLOT(renderingFpsSlot(
int)));
83 connect(
videoService().
get(), SIGNAL(fps(
int)),
this, SLOT(grabbingFpsSlot(
int)));
84 connect(
videoService().
get(), SIGNAL(connected(
bool)),
this, SLOT(grabberConnectedSlot(
bool)));
87 this->addPermanentWidget(mRenderingFpsLabel);
94 void StatusBar::resetToolManagerConnection()
96 this->disconnectFromToolSignals();
98 this->connectToToolSignals();
99 this->updateToolButtons();
102 void StatusBar::connectToToolSignals()
104 this->disconnectFromToolSignals();
106 this->addPermanentWidget(mTpsLabel);
109 for (TrackingService::ToolMap::iterator it = tools.begin(); it != tools.end(); ++it)
116 connect(tool.get(), SIGNAL(toolVisible(
bool)),
this, SLOT(updateToolButtons()));
119 current.mTool = tool;
120 current.mAction.reset(
new QAction(tool->getName(), NULL));
121 current.mAction->setToolTip(
"Press to set active");
123 QtSignalAdapters::connect0<void()>(
124 current.mAction.get(),
126 boost::bind(&StatusBar::activateTool,
this, tool->getUid()));
128 current.mButton.reset(
new QToolButton);
129 current.mButton->setDefaultAction(current.mAction.get());
130 this->addPermanentWidget(current.mButton.get());
131 mToolData.push_back(current);
134 this->updateToolButtons();
137 void StatusBar::disconnectFromToolSignals()
139 this->removeWidget(mTpsLabel);
141 for (
unsigned i = 0; i < mToolData.size(); ++i)
143 ToolData current = mToolData[i];
145 disconnect(current.mTool.get(), SIGNAL(toolVisible(
bool)),
this, SLOT(updateToolButtons()));
146 this->removeWidget(current.mButton.get());
152 void StatusBar::activateTool(QString uid)
157 void StatusBar::updateToolButtons()
161 for (
unsigned i = 0; i < mToolData.size(); ++i)
163 ToolData current = mToolData[i];
165 QString color = this->getToolStyle(tool->getVisible(), tool->isInitialized(), activeTool == tool);
166 current.mButton->setStyleSheet(QString(
"QToolButton { %1; }").arg(color));
168 if (!tool->isInitialized())
169 current.mAction->setToolTip(
"Tool is not Initialized");
170 else if (activeTool == tool)
171 current.mAction->setToolTip(
"Active Tool");
172 else if (tool->getVisible())
173 current.mAction->setToolTip(
"Tool not visible/not tracking");
175 current.mAction->setToolTip(
"Tool visible. Press to set as active");
179 QString StatusBar::getToolStyle(
bool visible,
bool initialized,
bool active)
182 return QString(
"background-color: silver");
187 return QString(
"background-color: lime");
189 return QString(
"background-color: green");
192 return QString(
"background-color: orangered");
195 void StatusBar::renderingFpsSlot(
int numFps)
197 QString fpsString =
"FPS: " + QString::number(numFps);
198 mRenderingFpsLabel->setText(fpsString);
201 void StatusBar::tpsSlot(
int numTps)
203 QString tpsString =
"TPS: " + QString::number(numTps);
204 mTpsLabel->setText(tpsString);
207 void StatusBar::grabbingFpsSlot(
int numFps)
209 QString infoString =
"VideoConnection-FPS: " + QString::number(numFps);
210 mGrabbingInfoLabel->setText(infoString);
213 void StatusBar::grabberConnectedSlot(
bool connected)
217 this->addPermanentWidget(mGrabbingInfoLabel);
218 mGrabbingInfoLabel->show();
221 this->removeWidget(mGrabbingInfoLabel);
224 void StatusBar::showMessageSlot(
Message message)
226 QString text = QString(
"[%1] %4")
235 this->showMessage(text, message.
getTimeout());
QString qstring_cast(const T &val)
static MessageListenerPtr create(LogPtr log=LogPtr())
boost::shared_ptr< class TrackingService > TrackingServicePtr
TrackingServicePtr getTrackingService()
QString getText() const
The raw message.
static MessageFilterStatusBarPtr create()
int getTimeout() const
Timout tells the statusbar how long it should be displayed, this depends on the message level...
LogicManager * logicManager()
std::map< QString, ToolPtr > ToolMap
cxLogicManager_EXPORT ViewServicePtr viewService()
cxLogicManager_EXPORT VideoServicePtr videoService()
cxLogicManager_EXPORT TrackingServicePtr trackingService()
void newMessage(Message message)
MESSAGE_LEVEL getMessageLevel() const
The category of the message.
virtual ~StatusBar()
empty
StatusBar()
connects signals and slots
boost::shared_ptr< class Tool > ToolPtr