RemoteGui.cpp
Go to the documentation of this file.
1#include "RemoteGui.h"
2
3#include <utility>
4
7
11#include <ArmarXGui/interface/RemoteGuiInterface.h>
13
15{
16
17 namespace gui = RemoteGui;
19
20 RemoteGui::RemoteGui(const RemoteGuiInterfacePrx& remoteGui, RemoteGuiCallee& callee) :
21 RemoteGui::RemoteGuiBase(remoteGui), callee(callee)
22 {
23 createRemoteGuiTab();
24 }
25
26 void
27 xc::RemoteGui::createRemoteGuiTab()
28 {
29 auto boxLayout = gui::makeVBoxLayout();
30
31 const auto createButtonWithDescription =
32 [&boxLayout](const std::string& buttonNameAndText, const std::string& description = "")
33 {
34 const gui::WidgetPtr label = gui::makeTextLabel(buttonNameAndText);
35 const gui::WidgetPtr button = gui::makeButton(buttonNameAndText).toolTip(description);
36 const gui::WidgetPtr line = gui::makeHBoxLayout().children({label, button});
37 boxLayout.addChild(line);
38 };
39
40 createButtonWithDescription(
41 loadGraphButtonName,
42 "Use this button to create a map after you collected enough data.");
43 createButtonWithDescription(loadDataFromMemoryButtonName);
44 createButtonWithDescription(selectBoundingBoxCornerButtonName);
45 createButtonWithDescription(alignBoundingBoxButtonName);
46 createButtonWithDescription(findAssociationsButtonName);
47 createButtonWithDescription(computeCoarseCorrectionButtonName);
48 createButtonWithDescription(computeFineCorrectionButtonName);
49 createButtonWithDescription(storeRegistrationResultButtonName);
50
51 createTab(boxLayout);
52 }
53
54 const std::string&
55 xc::RemoteGui::tabName() const
56 {
57 return remoteGuiTabMame;
58 }
59
60 void
61 xc::RemoteGui::handleEvents(armarx::RemoteGui::TabProxy& tab)
62 {
63 auto callIfClicked = [&](const std::string& buttonName, auto&& cbFn, auto... args)
64 {
65 const ::armarx::RemoteGui::ButtonProxy button = getTab().getButton(buttonName);
66 if (button.clicked())
67 {
68 auto fn = std::bind(cbFn, &callee, std::forward<decltype(args)>(args)...);
69 fn();
70 }
71 };
72
73 auto callCallIfClicked = [&](const std::string& buttonName, auto&& cbFn, auto&& callArgs)
74 {
75 const ::armarx::RemoteGui::ButtonProxy button = getTab().getButton(buttonName);
76 if (button.clicked())
77 {
78 auto fn = std::bind(cbFn, &callee, callArgs());
79 fn();
80 }
81 };
82
83 static int selectedCorner = 0;
84
85
86 callIfClicked(loadGraphButtonName, &RemoteGuiCallee::loadGraph);
87 callIfClicked(loadDataFromMemoryButtonName, &RemoteGuiCallee::loadDataFromMemory);
88 callIfClicked(alignBoundingBoxButtonName, &RemoteGuiCallee::alignBoundingBox);
89 callIfClicked(findAssociationsButtonName, &RemoteGuiCallee::findAssociations);
90
91 callIfClicked(computeCoarseCorrectionButtonName, &RemoteGuiCallee::computeCoarseCorrection);
92 callIfClicked(computeFineCorrectionButtonName, &RemoteGuiCallee::computeFineCorrection);
93 callIfClicked(storeRegistrationResultButtonName, &RemoteGuiCallee::storeRegistrationResult);
94
95 callCallIfClicked(selectBoundingBoxCornerButtonName,
97 [&]() -> int { return selectedCorner++; });
98 }
99
100 void
101 xc::RemoteGui::enable()
102 {
103 getTab().internalSetDisabled(loadGraphButtonName, false);
104 }
105
106 void
107 xc::RemoteGui::disable()
108 {
109 getTab().internalSetDisabled(loadGraphButtonName, true);
110 }
111
112
113} // namespace armarx::cartographer_map_registration
armarx::RemoteGui::TabProxy & getTab()
RemoteGuiBase(const RemoteGuiInterfacePrx &remoteGui)
void createTab(const WidgetPtr &widget)
void internalSetDisabled(std::string const &name, bool disabled)
ButtonProxy getButton(std::string const &name)
RemoteGui(const RemoteGuiInterfacePrx &remoteGui, RemoteGuiCallee &callee)
Definition RemoteGui.cpp:20