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