43 Eigen::Vector3f
initial = Eigen::Vector3f::Zero();
56 float boxSize = 50.0f;
59 x.box.position(
x.initial).color(
x.color).size(boxSize).enable(
63 y.box.position(
y.initial).color(
y.color).size(boxSize).enable(
67 z.box.position(
z.initial).color(
z.color).size(boxSize).enable(
71 .color(viz::Color::orange())
82 float arrowWidth = 10.0f;
86 .
color(viz::Color::red())
93 .
color(viz::Color::green())
100 .
color(viz::Color::blue())
117 std::string
const& element = interaction.element();
118 Eigen::Matrix4f
transform = interaction.transformation();
119 Eigen::Vector3f translation =
transform.block<3, 1>(0, 3);
122 if (element ==
"BoxX")
126 else if (element ==
"BoxY")
130 else if (element ==
"BoxZ")
140 switch (interaction.type())
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);
204 float boxSize = 50.0f;
214 x.element.color(viz::Color::red()).size(boxSize);
219 y.element.color(viz::Color::green()).size(boxSize);
223 z.element.color(viz::Color::blue()).size(boxSize);
226 .color(viz::Color::orange())
237 float arrowWidth = 10.0f;
241 .
color(viz::Color::red())
248 .
color(viz::Color::green())
255 .
color(viz::Color::blue())
273 bool needsLayerUpdate =
false;
276 needsLayerUpdate |=
y.handle(interaction).needsLayerUpdate;
277 needsLayerUpdate |=
z.handle(interaction).needsLayerUpdate;
278 if (needsLayerUpdate)
287 ARMARX_INFO <<
"The x slider was transformed: " <<
x.getCurrentPose().col(3).x();
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);
335 Eigen::Vector3f
position = Eigen::Vector3f::Zero();
344 {
"Delete All",
"Delete All of Type"});
345 std::string name =
"Spawner_" + std::to_string(i);
384 Eigen::Matrix4f
transform = Eigen::Matrix4f::Identity();
385 Eigen::Vector3f
scale = Eigen::Vector3f::Ones();
392 ARMARX_WARNING <<
"Tried to visualize a spawned object that does not have a source";
398 std::string name =
"Object_" + std::to_string(
index);
400 Eigen::Matrix4f initial = Eigen::Matrix4f::Identity();
401 initial.block<3, 1>(0, 3) =
source->position;
402 Eigen::Matrix4f pose =
transform * initial;
452 spawner.
position =
origin + Eigen::Vector3f(750.0f, 500.0f, 0.5f * size);
453 spawner.
color = viz::Color::cyan();
458 spawner.
position =
origin + Eigen::Vector3f(1250.0f, 500.0f, 0.5f * size);
459 spawner.
color = viz::Color::magenta();
464 spawner.
position =
origin + Eigen::Vector3f(1000.0f, 750.0f, 0.5f * size);
465 spawner.
color = viz::Color::yellow();
499 for (
int i = 0; i < (int)
spawners.size(); ++i)
501 std::string name =
"Spawner_" + std::to_string(i);
502 if (interaction.element() == name)
508 if (spawner ==
nullptr)
510 ARMARX_INFO <<
"No spawner" << interaction.element();
513 interaction.chosenContextMenuEntry() == 0)
517 auto newEnd = std::remove_if(
objects.begin(),
522 "Object_" + std::to_string(object.index);
523 return interaction.element() == name;
532 switch (interaction.type())
549 if (interaction.isTransformBegin())
554 if (interaction.isTransformEnd())
584 auto newEnd = std::remove_if(
objects.begin(),
587 { return obj.source == spawner; });
662 return "ArVizInteractExample";
688 const bool join =
true;
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);
711 .
fromTo(origin1, origin1 + 4000.0f * Eigen::Vector3f::UnitX())
713 regions.
add(separatorX);
717 .
fromTo(origin4, origin4 + 4000.0f * Eigen::Vector3f::UnitY())
719 regions.
add(separatorY);
725 SlidersState sliders(origin1 + Eigen::Vector3f(500.0f, 500.0f, 0.0f));
726 SlidersState2 sliders2(origin3 + Eigen::Vector3f(500.0f, 500.0f, 0.0f));
745 while (!
task->isStopped())
747 result =
arviz.commit(stage);
760 if (interaction.layer() ==
"Sliders")
762 sliders.
handle(interaction, &stage);
764 if (interaction.layer() ==
"Sliders2")
766 sliders2.
handle(interaction, &stage);
768 if (interaction.layer() ==
"Spawners" ||
769 interaction.layer() ==
"SpawnedObjects")
771 spawners.
handle(interaction, &stage);
775 c.waitForCycleDuration();
#define ARMARX_DECOUPLED_REGISTER_COMPONENT(ComponentT)
Provides a ready-to-use ArViz client arviz as member variable.
armarx::viz::Client arviz
Default component property definition container.
Baseclass for all ArmarX ManagedIceObjects requiring properties.
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
This util class helps with keeping a cycle time during a control cycle.
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
virtual Layer layer(std::string const &name) const
DerivedT & enable(InteractionDescription const &interactionDescription)
DerivedT & pose(Eigen::Matrix4f const &pose)
DerivedT & color(Color color)
DerivedT & position(float x, float y, float z)
DerivedT & scale(Eigen::Vector3f scale)
uint32_t Color
RGBA color.
#define ARMARX_INFO
The normal logging level.
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
This file is part of ArmarX.
InteractionDescription interaction()
@ Transform
The element was transformed (translated or rotated).
@ ContextMenuChosen
A context menu entry was chosen.
@ Deselect
An element was deselected.
@ Select
An element was selected.
This file offers overloads of toIce() and fromIce() functions for STL container types.
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...
int DecoupledMain(int argc, char *argv[])
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
An example for how to use ArViz.
void onInitComponent() override
Pure virtual hook for the subclass.
void onDisconnectComponent() override
Hook for subclass.
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Creates the property definition container.
void onConnectComponent() override
Pure virtual hook for the subclass.
RunningTask< ArVizInteractExample >::pointer_type task
void onExitComponent() override
Hook for subclass.
std::string getDefaultName() const override
Retrieve default name of component.
Eigen::Vector3f translation
SingleSlider(std::string const &name, viz::Color color)
void visualize(viz::Layer &layer)
Eigen::Matrix4f transform
void visualize(int i, viz::Layer &layer)
Arrow & fromTo(const Eigen::Vector3f &from, const Eigen::Vector3f &to)
Box & size(Eigen::Vector3f const &s)
InteractionFeedbackRange interactions() const
Cylinder & height(float h)
Cylinder & radius(float r)
Cylinder & fromTo(Eigen::Vector3f from, Eigen::Vector3f to)
Self & contextMenu(std::vector< std::string > const &options)
Self & scaling(AxesFlags const &axes=AXES_XYZ)
void add(ElementT const &element)
A staged commit prepares multiple layers to be committed.
void requestInteraction(Layer const &layer)
Request interaction feedback for a particular layer.
void add(Layer const &layer)
Stage a layer to be committed later via client.apply(*this)
void reset()
Reset all staged layers and interaction requests.