35#include <SimoxUtility/algorithm/string.h>
36#include <SimoxUtility/algorithm/string/string_tools.h>
50 "LoadPlugins",
"",
"List of paths to GuiPlugin-Libs (semi-colon seperated)");
52 "GuiConfigFile",
"",
"Path to config file, that should be loaded on startup");
55 "Disables the preloading of widgets. Can be helpful if some "
56 "preloaded widget crashes the gui.");
60 qApplication(nullptr), argc(argc), argv(argv)
65 QTextCodec::setCodecForLocale(QTextCodec::codecForName(
"UTF-8"));
77 this->registry = registry;
85 if (QMessageBox::question(
nullptr,
86 "ArmarX is not running",
87 "ArmarX is not running - do you want me to start it now?",
89 QMessageBox::Yes) == QMessageBox::Yes)
91 int result = startArmarX();
111 SoQt::init(argc, argv,
"ArmarXGuiApp*1123");
114 (void)coin_setenv(
"COIN_SEPARATE_DIFFUSE_TRANSPARENCY_OVERRIDE",
"1", TRUE);
118 QString configToLoad;
130 connect(mainWindow, SIGNAL(closeRequest()),
this, SLOT(closeRequest_sent()));
135 std::vector<std::string> pluginList =
Split(
plugins,
",");
136 for (
auto iter = pluginList.begin(); iter != pluginList.end(); ++iter)
140 ARMARX_VERBOSE <<
"Loading plugin: " << iter->c_str() << std::endl;
141 mainWindow->loadPlugin(iter->c_str());
145 std::cout <<
"Started ArmarXGui App" << std::endl;
148 this, &ArmarXGuiApp::runArmarXManager,
"ArmarXManagerWaitThread");
149 armarxManagerTask->start();
152 mainWindow->appendFileToWindowTitle();
155 int result = qApplication->exec();
160 armarXManager->waitForShutdown();
163 qApplication->quit();
174 ArmarXGuiApp::closeRequest_sent()
179 ArmarXGuiApp::runArmarXManager()
185 qApplication->quit();
190 ArmarXGuiApp::startArmarX()
192 CMakePackageFinder armarx_core(
"ArmarXCore");
193 CMakePackageFinder armarx_memoryx(
"MemoryX");
196 if (armarx_core.packageFound())
199 std::string(armarx_core.getBinaryDir() + std::string(
"/armarx start")).c_str());
203 res = system(
"armarx start");
205 res = WEXITSTATUS(res);
206 if (res == EXIT_SUCCESS)
209 if (armarx_memoryx.packageFound())
211 if (armarx_core.packageFound())
213 res = system(std::string(armarx_core.getBinaryDir() +
214 std::string(
"/armarx memory start"))
219 res = system(
"armarx memory assureRunning");
221 res = WEXITSTATUS(res);
222 if (res == EXIT_FAILURE)
224 QMessageBox::warning(
nullptr,
226 "Could not start MongoDB! See terminal output for more "
227 "information. The GUI will now started anyway.");
234 QMessageBox::critical(
237 "Could not start ArmarX! See terminal output for more information.");
246 QString username = qgetenv(
"USER");
247 if (username.isEmpty())
249 username = qgetenv(
"USERNAME");
255 getUserNameAtHostName(
const QString& delimiter,
const QString& at)
257 const QString hostname = QHostInfo::localHostName();
258 QString user = getUserName();
265 return user + delimiter + at + delimiter + hostname;
270 ArmarXGuiApp::makeName()
272 std::vector<std::string> items{
"ArmarXGui"};
273 items.push_back(getUserNameAtHostName(
"-",
"at").toStdString());
276 std::string name = simox::alg::join(items,
"_");
286 return QApplication::notify(obj, ev);
288 catch (std::exception& e)
301 QStringList infos = exceptionReason.split(
"Backtrace:");
303 auto item =
new QListWidgetItem(
"[" + QTime::currentTime().toString() +
"] " +
304 infos.first().trimmed());
305 item->setToolTip(exceptionReason);
307 list->scrollToBottom();
327 const auto guiWindowBaseName = QString{
"ArmarX"} +
" @ " + QHostInfo::localHostName();
328 setApplicationName(guiWindowBaseName);
331 const char* envArmarxWorkspace = std::getenv(
"ARMARX_WORKSPACE_NAME");
332 if (envArmarxWorkspace ==
nullptr)
334 envArmarxWorkspace = std::getenv(
"ARMARX_WORKSPACE");
337 QString applicationDisplayName;
338 if (envArmarxWorkspace !=
nullptr)
340 applicationDisplayName +=
"[▽" + QString(envArmarxWorkspace) +
"] ";
342 applicationDisplayName += getUserNameAtHostName(
" ",
"@");
343 setApplicationDisplayName(applicationDisplayName);
350 Qt::QueuedConnection);
357 Qt::QueuedConnection);
ApplicationPropertyDefinitions(std::string prefix)
int run(int argc, char *argv[]) override
Ice::Application replacement for the main function.
std::vector< std::string > getArmarXPackageNames()
getDefaultPackageNames returns the value of the ArmarX.DefaultPackages property It splits the string ...
ArmarXManagerPtr getArmarXManager()
void setName(const std::string &name)
Set name of the application.
void interruptCallback(int signal) override
Cleans up connections with IceStorm before terminating the app.
ArmarXGuiAppPropertyDefinitions(std::string prefix)
void setup(const ManagedIceObjectRegistryInterfacePtr ®istry, Ice::PropertiesPtr properties) override
Configures the app, sets Qt up.
int run(int argc, char *argv[]) override
ArmarXGuiApp(int &argc=ArmarXGuiApp::globalargc, char **argv=NULL)
Constructs and initialized an ArmarXGuiApp.
int exec(const ArmarXManagerPtr &armarXManager) override
Runs the Qt Event Loop.
The ArmarXMainWindow class.
static bool CheckIceConnection(const Ice::CommunicatorPtr &communicator, bool printHint)
Ui_ExceptionDialog exceptionDialogHandler
ArmarXQApplication(int &argc, char **argv)
bool notify(QObject *obj, QEvent *ev) override
void exceptionCaught(QString exceptionReason)
void showException(QString exceptionReason)
~ArmarXQApplication() override
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
Property< PropertyType > getProperty(const std::string &name)
Property creation and retrieval.
#define ARMARX_INFO
The normal logging level.
#define ARMARX_ERROR_S
The logging level for unexpected behaviour, that must be fixed.
#define ARMARX_VERBOSE
The logging level for verbose information.
::IceInternal::Handle<::Ice::Properties > PropertiesPtr
This file is part of ArmarX.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< ArmarXManager > ArmarXManagerPtr
IceUtil::Handle< ManagedIceObjectRegistryInterface > ManagedIceObjectRegistryInterfacePtr
std::string GetHandledExceptionString()
std::vector< std::string > Split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
static void ClearExceptionBacktrace()