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;
18  namespace xc = ::armarx::cartographer_map_registration;
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
102  {
103  getTab().internalSetDisabled(loadGraphButtonName, false);
104  }
105 
106  void
108  {
109  getTab().internalSetDisabled(loadGraphButtonName, true);
110  }
111 
112 
113 } // namespace armarx::cartographer_map_registration
StaticWidgets.h
armarx::cartographer_map_registration
Definition: RemoteGui.cpp:14
armarx::cartographer_map_registration::RemoteGuiCallee::storeRegistrationResult
virtual void storeRegistrationResult()=0
armarx::RemoteGui::makeButton
detail::ButtonBuilder makeButton(std::string const &name)
Definition: IntegerWidgets.h:52
armarx::cartographer_map_registration::RemoteGuiCallee::selectBoundingBoxCorner
virtual void selectBoundingBoxCorner(int i)=0
armarx::cartographer_map_registration::RemoteGuiCallee::loadGraph
virtual void loadGraph()=0
armarx::WidgetDescription::makeHBoxLayout
HBoxLayoutPtr makeHBoxLayout(std::vector< WidgetPtr > elements)
Definition: DefaultWidgetDescriptions.cpp:31
armarx::RemoteGui::makeTextLabel
detail::LabelBuilder makeTextLabel(std::string const &text)
Definition: StaticWidgets.h:24
ParameterMapping.h
IntegerWidgets.h
armarx::cartographer_map_registration::RemoteGui::enable
void enable()
armarx::cartographer_map_registration::RemoteGuiCallee::computeFineCorrection
virtual void computeFineCorrection()=0
armarx::RemoteGui::TabProxy
Definition: WidgetProxy.h:17
LayoutWidgets.h
armarx::cartographer_map_registration::RemoteGuiCallee
Definition: RemoteGui.h:33
RemoteGui.h
armarx::RemoteGui::detail::ToolTipMixin::toolTip
Derived & toolTip(std::string const &toolTip)
Definition: Basic.h:228
WidgetProxy.h
armarx::cartographer_map_registration::RemoteGui::disable
void disable()
armarx::cartographer_map_registration::RemoteGuiCallee::alignBoundingBox
virtual void alignBoundingBox()=0
armarx::cartographer_map_registration::RemoteGuiCallee::loadDataFromMemory
virtual void loadDataFromMemory()=0
armarx::WidgetDescription::WidgetPtr
::IceInternal::Handle<::armarx::WidgetDescription::Widget > WidgetPtr
Definition: NJointControllerBase.h:67
CycleUtil.h
armarx::cartographer_map_registration::RemoteGuiCallee::findAssociations
virtual void findAssociations()=0
armarx::WidgetDescription::makeVBoxLayout
VBoxLayoutPtr makeVBoxLayout(std::vector< WidgetPtr > elements)
Definition: DefaultWidgetDescriptions.cpp:39
armarx::cartographer_map_registration::RemoteGui::RemoteGui
RemoteGui(const RemoteGuiInterfacePrx &remoteGui, RemoteGuiCallee &callee)
Definition: RemoteGui.cpp:20
armarx::cartographer_map_registration::RemoteGuiCallee::computeCoarseCorrection
virtual void computeCoarseCorrection()=0
armarx::cartographer_map_registration::RemoteGui
Definition: RemoteGui.h:46
armarx::RemoteGui::Client::createTab
void createTab(Ice::ObjectPrx const &remoteGuiObject, std::string const &tabName, Widget const &rootWidget)
armarx::RemoteGui::RemoteGuiBase
Definition: RemoteGuiBase.h:32