Skip to content
Snippets Groups Projects
Commit 7561c54d authored by Fabian Paus's avatar Fabian Paus
Browse files

ArViz: Add client type for interaction feedback

parent 644a86bb
No related branches found
No related tags found
No related merge requests found
...@@ -61,9 +61,166 @@ namespace viz ...@@ -61,9 +61,166 @@ namespace viz
viz::data::CommitInput data_; viz::data::CommitInput data_;
}; };
enum class InteractionFeedbackType
{
None,
Select,
Deselect,
ContextMenuOpen,
ContextMenuChosen,
Transform,
};
inline Eigen::Matrix4f toEigen(data::GlobalPose const& pose)
{
Eigen::Quaternionf ori(pose.qw, pose.qx, pose.qy, pose.qz);
Eigen::Matrix4f result;
result.block<3, 3>(0, 0) = ori.toRotationMatrix();
result.block<3, 1>(0, 3) = Eigen::Vector3f(pose.x, pose.y, pose.z);
result.block<1, 4>(3, 0) = Eigen::Vector4f(0.0f, 0.0f, 0.0f, 1.0f);
return result;
}
struct InteractionFeedback struct InteractionFeedback
{ {
InteractionFeedbackType type() const
{
// Maks out all the flags in the higher bits
int type = data_.type & 0x7;
switch (type)
{
case data::InteractionFeedbackType::NONE:
return InteractionFeedbackType::None;
case data::InteractionFeedbackType::SELECT:
return InteractionFeedbackType::Select;
case data::InteractionFeedbackType::DESELECT:
return InteractionFeedbackType::Deselect;
case data::InteractionFeedbackType::CONTEXT_MENU_OPEN:
return InteractionFeedbackType::ContextMenuOpen;
case data::InteractionFeedbackType::CONTEXT_MENU_CHOSEN:
return InteractionFeedbackType::ContextMenuChosen;
case data::InteractionFeedbackType::TRANSFORM:
return InteractionFeedbackType::Transform;
default:
throw std::runtime_error("Unexpected InteractionFeedbackType");
}
}
bool isTranslation() const
{
return data_.type & data::InteractionFeedbackType::TRANSLATION_FLAG;
}
bool isRotation() const
{
return data_.type & data::InteractionFeedbackType::ROTATION_FLAG;
}
bool isAxisX() const
{
return data_.type & data::InteractionFeedbackType::AXIS_X_FLAG;
}
bool isAxisY() const
{
return data_.type & data::InteractionFeedbackType::AXIS_Y_FLAG;
}
bool isAxisZ() const
{
return data_.type & data::InteractionFeedbackType::AXIS_Z_FLAG;
}
bool isTransformBegin() const
{
return data_.type & data::InteractionFeedbackType::TRANSFORM_BEGIN_FLAG;
}
bool isTransformDuring() const
{
return data_.type & data::InteractionFeedbackType::TRANSFORM_DURING_FLAG;
}
bool isTransformEnd() const
{
return data_.type & data::InteractionFeedbackType::TRANSFORM_END_FLAG;
}
std::string const& layer() const
{
return data_.layer;
}
std::string const& element() const
{
return data_.element;
}
long revision() const
{
return data_.revision;
}
int chosenContextMenuEntry() const
{
return data_.chosenContextMenuEntry;
}
Eigen::Matrix4f originalPose() const
{
return toEigen(data_.originalPose);
}
Eigen::Matrix4f chosenPose() const
{
return toEigen(data_.chosenPose);
}
data::InteractionFeedback data_;
};
struct InteractionFeedbackRange
{
InteractionFeedback const* begin() const
{
return begin_;
}
InteractionFeedback const* end() const
{
return end_;
}
InteractionFeedback const* begin_;
InteractionFeedback const* end_;
};
struct CommitResult
{
long revision() const
{
return data_.revision;
}
InteractionFeedbackRange interactions() const
{
InteractionFeedback* begin = (InteractionFeedback*) data_.interactions.data();
InteractionFeedback* end = begin + data_.interactions.size();
return InteractionFeedbackRange{begin, end};
}
data::CommitResult data_;
}; };
struct Client struct Client
......
...@@ -270,6 +270,11 @@ namespace armarx::viz ...@@ -270,6 +270,11 @@ namespace armarx::viz
return *this; return *this;
} }
Polygon& lineColor(int r, int g, int b)
{
return lineColor(viz::Color(r, g, b));
}
Polygon& lineColorGlasbeyLUT(std::size_t id, int alpha = 255) Polygon& lineColorGlasbeyLUT(std::size_t id, int alpha = 255)
{ {
return lineColor(Color::fromRGBA(simox::color::GlasbeyLUT::at(id, alpha))); return lineColor(Color::fromRGBA(simox::color::GlasbeyLUT::at(id, alpha)));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment