ArVizInteractExample.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 RobotAPI::ArmarXObjects::ArVizInteractExample
17  * @author Fabian Paus ( fabian dot paus at kit dot edu )
18  * @date 2019
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
28 
30 
31 namespace armarx
32 {
33 
34  struct SingleSlider
35  {
36  SingleSlider(std::string const& name, viz::Color color) : box(name), color(color)
37  {
38  }
39 
42 
43  Eigen::Vector3f initial = Eigen::Vector3f::Zero();
44  Eigen::Vector3f translation = Eigen::Vector3f::Zero();
45  };
46 
47  struct SlidersState
48  {
49  SlidersState(Eigen::Vector3f origin) :
50  origin(origin),
51  x("BoxX", viz::Color::red()),
52  y("BoxY", viz::Color::green()),
53  z("BoxZ", viz::Color::blue()),
54  sphere("Sphere")
55  {
56  float boxSize = 50.0f;
57 
58  x.initial = origin + Eigen::Vector3f(0.5f * ARROW_LENGTH, 0.0f, 0.0f);
59  x.box.position(x.initial).color(x.color).size(boxSize).enable(
60  viz::interaction().translation(viz::AXES_X).hideDuringTransform());
61 
62  y.initial = origin + Eigen::Vector3f(0.0f, 0.5f * ARROW_LENGTH, 0.0f);
64  viz::interaction().translation(viz::AXES_Y).hideDuringTransform());
65 
66  z.initial = origin + Eigen::Vector3f(0.0f, 0.0f, 0.5f * ARROW_LENGTH);
68  viz::interaction().translation(viz::AXES_Z).hideDuringTransform());
69 
70  sphere.position(origin + 0.5f * ARROW_LENGTH * Eigen::Vector3f(1.0f, 1.0f, 1.0f))
72  .radius(30.0f);
73  }
74 
75  static constexpr const float ARROW_LENGTH = 1000.0f;
76 
77  void
79  {
80  layerInteract = arviz.layer("Sliders");
81 
82  float arrowWidth = 10.0f;
83 
84  viz::Arrow arrowX =
85  viz::Arrow("ArrowX")
87  .fromTo(origin, origin + Eigen::Vector3f(ARROW_LENGTH, 0.0f, 0.0f))
88  .width(arrowWidth);
89  layerInteract.add(arrowX);
90 
91  viz::Arrow arrowY =
92  viz::Arrow("ArrowY")
94  .fromTo(origin, origin + Eigen::Vector3f(0.0f, ARROW_LENGTH, 0.0f))
95  .width(arrowWidth);
96  layerInteract.add(arrowY);
97 
98  viz::Arrow arrowZ =
99  viz::Arrow("ArrowZ")
101  .fromTo(origin, origin + Eigen::Vector3f(0.0f, 0.0f, ARROW_LENGTH))
102  .width(arrowWidth);
103  layerInteract.add(arrowZ);
104 
105 
106  layerInteract.add(x.box);
109 
110  layerResult = arviz.layer("SlidersResult");
112  }
113 
114  void
116  {
117  std::string const& element = interaction.element();
118  Eigen::Matrix4f transform = interaction.transformation();
119  Eigen::Vector3f translation = transform.block<3, 1>(0, 3);
120 
121  SingleSlider* slider = nullptr;
122  if (element == "BoxX")
123  {
124  slider = &x;
125  }
126  else if (element == "BoxY")
127  {
128  slider = &y;
129  }
130  else if (element == "BoxZ")
131  {
132  slider = &z;
133  }
134  else
135  {
136  ARMARX_WARNING << "Unknown interaction: " << element;
137  return;
138  }
139 
140  switch (interaction.type())
141  {
143  {
144  slider->translation = translation;
145 
146  Eigen::Vector3f spherePosition(x.initial.x() + x.translation.x(),
147  y.initial.y() + y.translation.y(),
148  z.initial.z() + z.translation.z());
149  sphere.position(spherePosition);
150 
151  stage->add(layerResult);
152  }
153  break;
154 
156  {
157  // Do nothing
158  }
159  break;
160 
162  {
163  // If an object is deselected, we apply the transformation
164  slider->initial = slider->initial + slider->translation;
165  slider->translation = Eigen::Vector3f::Zero();
166  ARMARX_IMPORTANT << "Setting position to " << slider->initial.transpose();
167  slider->box.position(slider->initial);
168 
169  stage->add(layerInteract);
170  }
171  break;
172 
173  default:
174  {
175  // Do nothing for the other interaction types
176  }
177  break;
178  }
179  }
180 
181  Eigen::Vector3f origin;
185 
187 
190  };
191 
192  // ---------------
193 
194  // What abstractions are needed?
195  // MovableElement
196  // SpawnerElement
197 
198 
200  {
201  SlidersState2(Eigen::Vector3f origin) :
202  origin(origin), x("BoxX"), y("BoxY"), z("BoxZ"), sphere("Sphere")
203  {
204  float boxSize = 50.0f;
205 
206  // We use the Transformable<T>::position to set the position
207  // This keeps track of the internal state
208  x.position(origin + Eigen::Vector3f(0.5f * ARROW_LENGTH, 0.0f, 0.0f));
209  // A movable object is always hidden during the transformation
210  // The hideDuringTransform() flag is automatically set here
211  x.enable(viz::interaction().translation(viz::AXES_X));
212 
213  // Other attributes of the element can be set directly on the member
214  x.element.color(viz::Color::red()).size(boxSize);
215 
216  y.position(origin + Eigen::Vector3f(0.0f, 0.5f * ARROW_LENGTH, 0.0f));
217  y.enable(viz::interaction().translation(viz::AXES_Y));
218 
219  y.element.color(viz::Color::green()).size(boxSize);
220 
221  z.position(origin + Eigen::Vector3f(0.0f, 0.0f, 0.5f * ARROW_LENGTH));
222  z.enable(viz::interaction().translation(viz::AXES_Z));
223  z.element.color(viz::Color::blue()).size(boxSize);
224 
225  sphere.position(origin + 0.5f * ARROW_LENGTH * Eigen::Vector3f(1.0f, 1.0f, 1.0f))
227  .radius(30.0f);
228  }
229 
230  static constexpr const float ARROW_LENGTH = 1000.0f;
231 
232  void
234  {
235  layerInteract = arviz.layer("Sliders2");
236 
237  float arrowWidth = 10.0f;
238 
239  viz::Arrow arrowX =
240  viz::Arrow("ArrowX")
242  .fromTo(origin, origin + Eigen::Vector3f(ARROW_LENGTH, 0.0f, 0.0f))
243  .width(arrowWidth);
244  layerInteract.add(arrowX);
245 
246  viz::Arrow arrowY =
247  viz::Arrow("ArrowY")
249  .fromTo(origin, origin + Eigen::Vector3f(0.0f, ARROW_LENGTH, 0.0f))
250  .width(arrowWidth);
251  layerInteract.add(arrowY);
252 
253  viz::Arrow arrowZ =
254  viz::Arrow("ArrowZ")
256  .fromTo(origin, origin + Eigen::Vector3f(0.0f, 0.0f, ARROW_LENGTH))
257  .width(arrowWidth);
258  layerInteract.add(arrowZ);
259 
260 
261  layerInteract.add(x.element);
262  layerInteract.add(y.element);
263  layerInteract.add(z.element);
264 
265  layerResult = arviz.layer("SlidersResult2");
267  }
268 
269  void
271  {
272  // Let the Transformable<T> handle all events internally
273  bool needsLayerUpdate = false;
274  viz::TransformationResult xResult = x.handle(interaction);
275  needsLayerUpdate |= xResult.needsLayerUpdate;
276  needsLayerUpdate |= y.handle(interaction).needsLayerUpdate;
277  needsLayerUpdate |= z.handle(interaction).needsLayerUpdate;
278  if (needsLayerUpdate)
279  {
280  // At least one Transformable<T> indicated that the layer needs to be updated
281  stage->add(layerInteract);
282  }
283 
284  // We could react to specific events
285  if (xResult.wasTransformed)
286  {
287  ARMARX_INFO << "The x slider was transformed: " << x.getCurrentPose().col(3).x();
288  }
289 
290  // We handle the transform event ourselves to add custom behavior
291  // Here, we move the sphere based on the position of the sliders
293  {
294  // We can query getCurrentPose() to determine the poses of the sliders
295  // with the transformation applied to them
296  Eigen::Vector3f spherePosition(x.getCurrentPose().col(3).x(),
297  y.getCurrentPose().col(3).y(),
298  z.getCurrentPose().col(3).z());
299  sphere.position(spherePosition);
300 
301  stage->add(layerResult);
302  }
303  }
304 
305  Eigen::Vector3f origin;
309 
311 
314  };
315  // ---------------
316 
317 
318  enum class SpawnerType
319  {
320  Box,
321  Cylinder,
322  Sphere,
323  };
324 
325  enum class SpawnerOption
326  {
327  DeleteAll = 0,
328  DeleteType = 1,
329  };
330 
331  struct Spawner
332  {
334 
335  Eigen::Vector3f position = Eigen::Vector3f::Zero();
336  float size = 100.0f;
338 
339  void
340  visualize(int i, viz::Layer& layer)
341  {
344  {"Delete All", "Delete All of Type"});
345  std::string name = "Spawner_" + std::to_string(i);
346  switch (type)
347  {
348  case SpawnerType::Box:
349  {
351  interaction);
352  layer.add(box);
353  }
354  break;
356  {
357  viz::Cylinder cylinder = viz::Cylinder(name)
359  .radius(size * 0.5f)
360  .height(size)
361  .color(color)
363  layer.add(cylinder);
364  }
365  break;
366  case SpawnerType::Sphere:
367  {
368  viz::Sphere sphere = viz::Sphere(name)
370  .radius(size * 0.5f)
371  .color(color)
373  layer.add(sphere);
374  }
375  break;
376  }
377  }
378  };
379 
381  {
382  int index = 0;
383  Spawner* source = nullptr;
385  Eigen::Vector3f scale = Eigen::Vector3f::Ones();
386 
387  void
389  {
390  if (source == nullptr)
391  {
392  ARMARX_WARNING << "Tried to visualize a spawned object that does not have a source";
393  return;
394  }
395 
397  viz::interaction().selection().contextMenu({"Delete"});
398  std::string name = "Object_" + std::to_string(index);
399 
401  initial.block<3, 1>(0, 3) = source->position;
402  Eigen::Matrix4f pose = transform * initial;
403 
404  switch (source->type)
405  {
406  case SpawnerType::Box:
407  {
408  viz::Box box = viz::Box(name)
409  .pose(pose)
410  .scale(scale)
411  .size(source->size)
412  .color(source->color)
414  layer.add(box);
415  }
416  break;
418  {
419  viz::Cylinder cylinder = viz::Cylinder(name)
420  .pose(pose)
421  .scale(scale)
422  .radius(source->size * 0.5f)
423  .height(source->size)
424  .color(source->color)
426  layer.add(cylinder);
427  }
428  break;
429  case SpawnerType::Sphere:
430  {
431  viz::Sphere sphere = viz::Sphere(name)
432  .pose(pose)
433  .scale(scale)
434  .radius(source->size * 0.5f)
435  .color(source->color)
437  layer.add(sphere);
438  }
439  break;
440  }
441  }
442  };
443 
445  {
446  SpawnersState(Eigen::Vector3f origin) : origin(origin)
447  {
448  float size = 100.0f;
449  {
450  Spawner& spawner = spawners.emplace_back();
451  spawner.type = SpawnerType::Box;
452  spawner.position = origin + Eigen::Vector3f(750.0f, 500.0f, 0.5f * size);
453  spawner.color = viz::Color::cyan();
454  }
455  {
456  Spawner& spawner = spawners.emplace_back();
457  spawner.type = SpawnerType::Cylinder;
458  spawner.position = origin + Eigen::Vector3f(1250.0f, 500.0f, 0.5f * size);
459  spawner.color = viz::Color::magenta();
460  }
461  {
462  Spawner& spawner = spawners.emplace_back();
463  spawner.type = SpawnerType::Sphere;
464  spawner.position = origin + Eigen::Vector3f(1000.0f, 750.0f, 0.5f * size);
465  spawner.color = viz::Color::yellow();
466  }
467  }
468 
469  void
471  {
472  layerSpawners = arviz.layer("Spawners");
473 
474  int index = 0;
475  for (Spawner& spawner : spawners)
476  {
477  spawner.visualize(index, layerSpawners);
478  index += 1;
479  }
480 
481  layerObjects = arviz.layer("SpawnedObjects");
482  }
483 
484  void
486  {
488  for (auto& object : objects)
489  {
490  object.visualize(layerObjects);
491  }
492  stage->add(layerObjects);
493  }
494 
495  void
497  {
498  Spawner* spawner = nullptr;
499  for (int i = 0; i < (int)spawners.size(); ++i)
500  {
501  std::string name = "Spawner_" + std::to_string(i);
502  if (interaction.element() == name)
503  {
504  spawner = &spawners[i];
505  break;
506  }
507  }
508  if (spawner == nullptr)
509  {
510  ARMARX_INFO << "No spawner" << interaction.element();
511  // A spawned object was selected instead of a spawner
513  interaction.chosenContextMenuEntry() == 0)
514  {
515  // The delete context menu option was chosen
516  // So we remove the object from the internal list and redraw
517  auto newEnd = std::remove_if(objects.begin(),
518  objects.end(),
519  [&interaction](SpawnedObject const& object)
520  {
521  std::string name =
522  "Object_" + std::to_string(object.index);
523  return interaction.element() == name;
524  });
525  objects.erase(newEnd, objects.end());
526 
528  }
529  return;
530  }
531 
532  switch (interaction.type())
533  {
535  {
536  // Create a spawned object
538  spawnedObject.source = spawner;
540  spawnedObject.scale.setOnes();
541  }
542  break;
543 
545  {
546  // Update state of spawned object
547  spawnedObject.transform = interaction.transformation();
548  spawnedObject.scale = interaction.scale();
549  if (interaction.isTransformBegin())
550  {
551  // Visualize all other objects except the currently spawned one
553  }
554  if (interaction.isTransformEnd())
555  {
557  stage->add(layerObjects);
558  }
559  }
560  break;
561 
563  {
564  // Save state of spawned object
565  objects.push_back(spawnedObject);
566  }
567  break;
568 
570  {
571  SpawnerOption option = (SpawnerOption)(interaction.chosenContextMenuEntry());
572  switch (option)
573  {
575  {
576  objects.clear();
578 
579  stage->add(layerObjects);
580  }
581  break;
583  {
584  auto newEnd = std::remove_if(objects.begin(),
585  objects.end(),
586  [spawner](SpawnedObject const& obj)
587  { return obj.source == spawner; });
588  objects.erase(newEnd, objects.end());
589 
591  }
592  break;
593  }
594  }
595 
596  default:
597  {
598  // Ignore other interaction types
599  }
600  break;
601  }
602  }
603 
604  Eigen::Vector3f origin;
605 
606  std::vector<Spawner> spawners;
609  std::vector<SpawnedObject> objects;
610 
613  };
614 
615  /**
616  * @defgroup Component-ArVizInteractExample ArVizInteractExample
617  * @ingroup RobotAPI-Components
618  *
619  * An example for how to visualize 3D elements via the 3D visualization
620  * framework ArViz.
621  *
622  * The example creates several layers, fills them with visualization
623  * elements, and commits them to ArViz.
624  *
625  * To see the result:
626  * \li Start the component `ArVizStorage`
627  * \li Open the gui plugin `ArViz`
628  * \li Start the component `ArVizInteractExample`
629  *
630  * The scenario `ArVizInteractExample` starts the necessary components,
631  * including the example component.
632  *
633  *
634  * A component which wants to visualize data via ArViz should:
635  * \li `#include <RobotAPI/libraries/RobotAPIComponentPlugins/ArVizComponentPlugin.h>`
636  * \li Inherit from the `armarx::ArVizComponentPluginUser`. This adds the
637  * necessary properties (e.g. the topic name) and provides a
638  * ready-to-use ArViz client called `arviz`.
639  * \li Use the inherited ArViz client variable `arviz` of type `viz::Client`
640  * to create layers, add visualization elements to the layers,
641  * and commit the layers to the ArViz topic.
642  *
643  * \see ArVizInteractExample
644  *
645  *
646  * @class ArVizInteractExample
647  * @ingroup Component-ArVizInteractExample
648  *
649  * @brief An example for how to use ArViz.
650  *
651  * @see @ref Component-ArVizInteractExample
652  */
654  virtual armarx::Component,
655  // Deriving from armarx::ArVizComponentPluginUser adds necessary properties
656  // and provides a ready-to-use ArViz client called `arviz`.
658  {
659  std::string
660  getDefaultName() const override
661  {
662  return "ArVizInteractExample";
663  }
664 
667  {
670  return defs;
671  }
672 
673  void
674  onInitComponent() override
675  {
676  }
677 
678  void
680  {
682  task->start();
683  }
684 
685  void
687  {
688  const bool join = true;
689  task->stop(join);
690  task = nullptr;
691  }
692 
693  void
694  onExitComponent() override
695  {
696  }
697 
698  void
699  run()
700  {
701  viz::StagedCommit stage;
702 
703  viz::Layer regions = arviz.layer("Regions");
704  Eigen::Vector3f origin1(-2000.0f, 0.0f, 0.0f);
705  Eigen::Vector3f origin2(0.0f, 0.0f, 0.0f);
706  Eigen::Vector3f origin3(-2000.0f, -2000.0f, 0.0f);
707  Eigen::Vector3f origin4(0.0f, -2000.0f, 0.0f);
708  {
709  viz::Cylinder separatorX =
710  viz::Cylinder("SeparatorX")
711  .fromTo(origin1, origin1 + 4000.0f * Eigen::Vector3f::UnitX())
712  .radius(5.0f);
713  regions.add(separatorX);
714 
715  viz::Cylinder separatorY =
716  viz::Cylinder("SeparatorY")
717  .fromTo(origin4, origin4 + 4000.0f * Eigen::Vector3f::UnitY())
718  .radius(5.0f);
719  regions.add(separatorY);
720 
721  stage.add(regions);
722  }
723 
724 
725  SlidersState sliders(origin1 + Eigen::Vector3f(500.0f, 500.0f, 0.0f));
726  SlidersState2 sliders2(origin3 + Eigen::Vector3f(500.0f, 500.0f, 0.0f));
727  SpawnersState spawners(origin2);
728 
729  sliders.visualize(arviz);
730  stage.add(sliders.layerInteract);
731  stage.add(sliders.layerResult);
732 
733  sliders2.visualize(arviz);
734  stage.add(sliders2.layerInteract);
735  stage.add(sliders2.layerResult);
736 
737  spawners.visualize(arviz);
738  stage.add(spawners.layerSpawners);
739  stage.add(spawners.layerObjects);
740 
741  viz::CommitResult result = arviz.commit(stage);
742  ARMARX_INFO << "Initial commit at revision: " << result.revision();
743 
744  CycleUtil c(10.0f);
745  while (!task->isStopped())
746  {
747  result = arviz.commit(stage);
748 
749  // Reset the stage, so that it can be rebuild during the interaction handling
750  stage.reset();
751 
752  stage.requestInteraction(sliders.layerInteract);
753  stage.requestInteraction(sliders2.layerInteract);
754  stage.requestInteraction(spawners.layerSpawners);
755  stage.requestInteraction(spawners.layerObjects);
756 
757  viz::InteractionFeedbackRange interactions = result.interactions();
758  for (viz::InteractionFeedback const& interaction : interactions)
759  {
760  if (interaction.layer() == "Sliders")
761  {
762  sliders.handle(interaction, &stage);
763  }
764  if (interaction.layer() == "Sliders2")
765  {
766  sliders2.handle(interaction, &stage);
767  }
768  if (interaction.layer() == "Spawners" ||
769  interaction.layer() == "SpawnedObjects")
770  {
771  spawners.handle(interaction, &stage);
772  }
773  }
774 
775  c.waitForCycleDuration();
776  }
777  }
778 
780  };
781 
783 } // namespace armarx
784 
785 int
786 main(int argc, char* argv[])
787 {
788  return armarx::DecoupledMain(argc, argv);
789 }
armarx::viz::Color::black
static Color black(int a=255)
Definition: Color.h:68
ArVizComponentPlugin.h
armarx::SpawnedObject::scale
Eigen::Vector3f scale
Definition: ArVizInteractExample.cpp:385
armarx::viz::Client::commit
CommitResult commit(StagedCommit const &commit)
Definition: Client.cpp:89
armarx::viz::StagedCommit::add
void add(Layer const &layer)
Stage a layer to be committed later via client.apply(*this)
Definition: Client.h:37
armarx::Spawner
Definition: ArVizInteractExample.cpp:331
armarx::ArVizInteractExample::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: ArVizInteractExample.cpp:679
armarx::SpawnerType::Box
@ Box
armarx::SpawnedObject::source
Spawner * source
Definition: ArVizInteractExample.cpp:383
armarx::viz::InteractionFeedbackType::ContextMenuChosen
@ ContextMenuChosen
A context menu entry was chosen.
armarx::SingleSlider::box
viz::Box box
Definition: ArVizInteractExample.cpp:40
armarx::SpawnedObject::index
int index
Definition: ArVizInteractExample.cpp:382
armarx::viz::Cylinder::radius
Cylinder & radius(float r)
Definition: Elements.h:76
armarx::viz::TransformationResult::wasTransformed
bool wasTransformed
Definition: Interaction.h:180
armarx::viz::TransformationResult::needsLayerUpdate
bool needsLayerUpdate
Definition: Interaction.h:184
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:190
armarx::SpawnerType::Cylinder
@ Cylinder
armarx::SlidersState2::origin
Eigen::Vector3f origin
Definition: ArVizInteractExample.cpp:305
armarx::SpawnerType
SpawnerType
Definition: ArVizInteractExample.cpp:318
armarx::viz::CommitResult::revision
long revision() const
Definition: Client.h:80
armarx::viz::interaction
InteractionDescription interaction()
Definition: ElementOps.h:109
armarx::viz::Cylinder::fromTo
Cylinder & fromTo(Eigen::Vector3f from, Eigen::Vector3f to)
Definition: Elements.cpp:93
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::viz::Layer::clear
void clear()
Definition: Layer.h:24
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:650
armarx::SpawnerOption::DeleteType
@ DeleteType
armarx::Spawner::type
SpawnerType type
Definition: ArVizInteractExample.cpp:333
armarx::SlidersState2::ARROW_LENGTH
static constexpr const float ARROW_LENGTH
Definition: ArVizInteractExample.cpp:230
armarx::viz::Color::blue
static Color blue(int b=255, int a=255)
Definition: Color.h:100
armarx::CycleUtil
This util class helps with keeping a cycle time during a control cycle.
Definition: CycleUtil.h:40
armarx::Spawner::visualize
void visualize(int i, viz::Layer &layer)
Definition: ArVizInteractExample.cpp:340
armarx::SpawnerType::Sphere
@ Sphere
armarx::viz::Arrow
Definition: Elements.h:196
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
armarx::SpawnersState::objects
std::vector< SpawnedObject > objects
Definition: ArVizInteractExample.cpp:609
armarx::SlidersState::layerInteract
viz::Layer layerInteract
Definition: ArVizInteractExample.cpp:188
armarx::SpawnedObject::transform
Eigen::Matrix4f transform
Definition: ArVizInteractExample.cpp:384
RunningTask.h
armarx::viz::Cylinder::height
Cylinder & height(float h)
Definition: Elements.h:84
armarx::viz::InteractionDescription::scaling
Self & scaling(AxesFlags const &axes=AXES_XYZ)
Definition: ElementOps.h:83
armarx::viz::Layer::add
void add(ElementT const &element)
Definition: Layer.h:31
armarx::viz::StagedCommit
A staged commit prepares multiple layers to be committed.
Definition: Client.h:30
armarx::SingleSlider
Definition: ArVizInteractExample.cpp:34
armarx::SpawnersState::spawnedObject
SpawnedObject spawnedObject
Definition: ArVizInteractExample.cpp:607
armarx::RunningTask
Definition: ArmarXMultipleObjectsScheduler.h:36
armarx::Spawner::color
viz::Color color
Definition: ArVizInteractExample.cpp:337
armarx::SingleSlider::color
viz::Color color
Definition: ArVizInteractExample.cpp:41
armarx::viz::Sphere
Definition: Elements.h:133
armarx::SlidersState::z
SingleSlider z
Definition: ArVizInteractExample.cpp:184
switch
switch(yytype)
Definition: Grammar.cpp:657
armarx::SlidersState2::handle
void handle(viz::InteractionFeedback const &interaction, viz::StagedCommit *stage)
Definition: ArVizInteractExample.cpp:270
armarx::SlidersState::ARROW_LENGTH
static constexpr const float ARROW_LENGTH
Definition: ArVizInteractExample.cpp:75
armarx::viz::ElementOps::position
DerivedT & position(float x, float y, float z)
Definition: ElementOps.h:136
armarx::SpawnersState::layerObjects
viz::Layer layerObjects
Definition: ArVizInteractExample.cpp:612
armarx::viz::StagedCommit::reset
void reset()
Reset all staged layers and interaction requests.
Definition: Client.h:67
armarx::SlidersState::visualize
void visualize(viz::Client &arviz)
Definition: ArVizInteractExample.cpp:78
armarx::SlidersState2::visualize
void visualize(viz::Client &arviz)
Definition: ArVizInteractExample.cpp:233
armarx::SingleSlider::translation
Eigen::Vector3f translation
Definition: ArVizInteractExample.cpp:44
armarx::viz::Transformable
Definition: Interaction.h:188
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:570
armarx::ARMARX_DECOUPLED_REGISTER_COMPONENT
ARMARX_DECOUPLED_REGISTER_COMPONENT(JsonStorage)
armarx::ArVizComponentPluginUser
Provides a ready-to-use ArViz client arviz as member variable.
Definition: ArVizComponentPlugin.h:35
Color
uint32_t Color
RGBA color.
Definition: color.h:8
armarx::SlidersState2::z
viz::Transformable< viz::Box > z
Definition: ArVizInteractExample.cpp:308
armarx::ArVizInteractExample::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: ArVizInteractExample.cpp:674
armarx::viz::InteractionFeedbackType::Select
@ Select
An element was selected.
armarx::SpawnersState::spawners
std::vector< Spawner > spawners
Definition: ArVizInteractExample.cpp:606
armarx::SpawnerOption::DeleteAll
@ DeleteAll
armarx::SingleSlider::initial
Eigen::Vector3f initial
Definition: ArVizInteractExample.cpp:43
armarx::SlidersState::y
SingleSlider y
Definition: ArVizInteractExample.cpp:183
armarx::viz::CommitResult::interactions
InteractionFeedbackRange interactions() const
Definition: Client.h:86
armarx::viz::Arrow::width
Arrow & width(float w)
Definition: Elements.h:211
armarx::ArVizInteractExample::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: ArVizInteractExample.cpp:666
armarx::viz::InteractionDescription
Definition: ElementOps.h:35
armarx::viz::Color::yellow
static Color yellow(int y=255, int a=255)
Red + Green.
Definition: Color.h:116
armarx::SlidersState::x
SingleSlider x
Definition: ArVizInteractExample.cpp:182
armarx::viz::InteractionDescription::contextMenu
Self & contextMenu(std::vector< std::string > const &options)
Definition: ElementOps.h:54
armarx::viz::InteractionFeedbackType::Transform
@ Transform
The element was transformed (translated or rotated).
armarx::viz::Cylinder
Definition: Elements.h:71
armarx::viz::Sphere::radius
Sphere & radius(float r)
Definition: Elements.h:138
armarx::SpawnersState::SpawnersState
SpawnersState(Eigen::Vector3f origin)
Definition: ArVizInteractExample.cpp:446
armarx::viz::StagedCommit::requestInteraction
void requestInteraction(Layer const &layer)
Request interaction feedback for a particular layer.
Definition: Client.h:57
armarx::ArVizInteractExample::task
RunningTask< ArVizInteractExample >::pointer_type task
Definition: ArVizInteractExample.cpp:779
armarx::SlidersState::handle
void handle(viz::InteractionFeedback const &interaction, viz::StagedCommit *stage)
Definition: ArVizInteractExample.cpp:115
armarx::viz::Color
Definition: Color.h:12
armarx::SpawnedObject
Definition: ArVizInteractExample.cpp:380
armarx::viz::Box
Definition: Elements.h:47
armarx::Spawner::position
Eigen::Vector3f position
Definition: ArVizInteractExample.cpp:335
armarx::viz::InteractionFeedbackRange
Definition: Interaction.h:147
armarx::SlidersState2::y
viz::Transformable< viz::Box > y
Definition: ArVizInteractExample.cpp:307
armarx::viz::CommitResult
Definition: Client.h:77
armarx::viz::InteractionFeedback
Definition: Interaction.h:59
armarx::SlidersState2::sphere
viz::Sphere sphere
Definition: ArVizInteractExample.cpp:310
armarx::viz::Color::red
static Color red(int r=255, int a=255)
Definition: Color.h:88
armarx::viz::Color::cyan
static Color cyan(int c=255, int a=255)
Green + Blue.
Definition: Color.h:109
armarx::SpawnersState::handle
void handle(viz::InteractionFeedback const &interaction, viz::StagedCommit *stage)
Definition: ArVizInteractExample.cpp:496
armarx::SlidersState2::layerResult
viz::Layer layerResult
Definition: ArVizInteractExample.cpp:313
armarx::SlidersState2::x
viz::Transformable< viz::Box > x
Definition: ArVizInteractExample.cpp:306
armarx::to_string
const std::string & to_string(const std::string &s)
Definition: StringHelpers.h:41
armarx::SingleSlider::SingleSlider
SingleSlider(std::string const &name, viz::Color color)
Definition: ArVizInteractExample.cpp:36
armarx::ArVizInteractExample::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: ArVizInteractExample.cpp:686
armarx::red
QColor red()
Definition: StyleSheets.h:78
Component.h
armarx::SlidersState::origin
Eigen::Vector3f origin
Definition: ArVizInteractExample.cpp:181
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:91
armarx::transform
auto transform(const Container< InputT, Alloc > &in, OutputT(*func)(InputT const &)) -> Container< OutputT, typename std::allocator_traits< Alloc >::template rebind_alloc< OutputT >>
Convenience function (with less typing) to transform a container of type InputT into the same contain...
Definition: algorithm.h:351
armarx::SlidersState::layerResult
viz::Layer layerResult
Definition: ArVizInteractExample.cpp:189
CycleUtil.h
armarx::ArVizInteractExample
An example for how to use ArViz.
Definition: ArVizInteractExample.cpp:653
armarx::SpawnersState::visualize
void visualize(viz::Client &arviz)
Definition: ArVizInteractExample.cpp:470
armarx::viz::InteractionDescription::transform
Self & transform()
Definition: ElementOps.h:93
armarx::SpawnerOption
SpawnerOption
Definition: ArVizInteractExample.cpp:325
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:79
armarx::viz::Arrow::fromTo
Arrow & fromTo(const Eigen::Vector3f &from, const Eigen::Vector3f &to)
Definition: Elements.h:219
armarx::SlidersState::sphere
viz::Sphere sphere
Definition: ArVizInteractExample.cpp:186
option
#define option(type, fn)
Decoupled.h
armarx::SpawnersState::visualizeSpawnedObjects
void visualizeSpawnedObjects(viz::StagedCommit *stage)
Definition: ArVizInteractExample.cpp:485
armarx::viz::InteractionFeedbackType::Deselect
@ Deselect
An element was deselected.
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:69
armarx::viz::Color::magenta
static Color magenta(int m=255, int a=255)
Red + Blue.
Definition: Color.h:123
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
armarx::viz::ElementOps::pose
DerivedT & pose(Eigen::Matrix4f const &pose)
Definition: ElementOps.h:176
armarx::ArVizComponentPluginUser::arviz
armarx::viz::Client arviz
Definition: ArVizComponentPlugin.h:42
armarx::viz::ElementOps::scale
DerivedT & scale(Eigen::Vector3f scale)
Definition: ElementOps.h:254
armarx::SpawnedObject::visualize
void visualize(viz::Layer &layer)
Definition: ArVizInteractExample.cpp:388
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::viz::Box::size
Box & size(Eigen::Vector3f const &s)
Definition: Elements.h:52
armarx::viz::ElementOps::color
DerivedT & color(Color color)
Definition: ElementOps.h:218
armarx::SlidersState2::SlidersState2
SlidersState2(Eigen::Vector3f origin)
Definition: ArVizInteractExample.cpp:201
armarx::SlidersState
Definition: ArVizInteractExample.cpp:47
armarx::viz::Color::orange
static Color orange(int o=255, int a=255)
2 Red + 1 Green
Definition: Color.h:132
armarx::DecoupledMain
int DecoupledMain(int argc, char *argv[])
Definition: Decoupled.cpp:48
main
int main(int argc, char *argv[])
Definition: ArVizInteractExample.cpp:786
armarx::ArVizInteractExample::run
void run()
Definition: ArVizInteractExample.cpp:699
armarx::ArVizInteractExample::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: ArVizInteractExample.cpp:694
armarx::ArVizInteractExample::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: ArVizInteractExample.cpp:660
armarx::viz::Color::green
static Color green(int g=255, int a=255)
Definition: Color.h:94
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:193
armarx::viz::Client::layer
Layer layer(std::string const &name) const
Definition: Client.cpp:80
armarx::viz::InteractionDescription::selection
Self & selection()
Definition: ElementOps.h:47
armarx::viz::Client
Definition: Client.h:117
armarx::viz::Layer
Definition: Layer.h:12
armarx::SpawnersState::layerSpawners
viz::Layer layerSpawners
Definition: ArVizInteractExample.cpp:611
armarx::SlidersState2::layerInteract
viz::Layer layerInteract
Definition: ArVizInteractExample.cpp:312
armarx::SpawnersState::spawnedObjectCounter
int spawnedObjectCounter
Definition: ArVizInteractExample.cpp:608
armarx::Spawner::size
float size
Definition: ArVizInteractExample.cpp:336
armarx::SlidersState::SlidersState
SlidersState(Eigen::Vector3f origin)
Definition: ArVizInteractExample.cpp:49
armarx::SlidersState2
Definition: ArVizInteractExample.cpp:199
armarx::viz
This file is part of ArmarX.
Definition: ArVizStorage.cpp:418
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::SpawnersState::origin
Eigen::Vector3f origin
Definition: ArVizInteractExample.cpp:604
armarx::green
QColor green()
Definition: StyleSheets.h:72
armarx::SpawnersState
Definition: ArVizInteractExample.cpp:444
armarx::viz::TransformationResult
Definition: Interaction.h:177
DecoupledMain.h
armarx::viz::ElementOps::enable
DerivedT & enable(InteractionDescription const &interactionDescription)
Definition: ElementOps.h:309