Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
4c081ed
Initial qt5 port
Dec 2, 2021
6160ccf
Fix viz plugin loading for QT5
planthaber May 20, 2022
ee4a7c3
Correct PluginLoader metadata, do not install header
pierrewillenbrockdfki May 23, 2022
2d323d9
Merge remote-tracking branch 'autobuild/master' into feature/qt5
pierrewillenbrockdfki May 23, 2022
238f9fc
Merge pull request #158 from pierrewillenbrockdfki/feature/qt5
planthaber May 23, 2022
eef7f28
#ifdef style merge of branch 'feature/qt5' into feature/qt4-qt5
pierrewillenbrockdfki Apr 5, 2023
563ddb8
Cleanup merge result
pierrewillenbrockdfki Mar 22, 2023
8ab436d
Set NOCURDIR rock feature and fix SISL linking for that
pierrewillenbrockdfki Aug 9, 2023
88cee60
add std namespace to isnan to compile on 22.04
planthaber May 15, 2024
a48e412
add OrientedBoundingBoxVisualization
planthaber Jun 28, 2024
bf08f09
Merge remote-tracking branch 'autobuild/logmessage' into feature/qt4-qt5
planthaber Jul 30, 2024
a600b09
make sisl optional in viz plugin
planthaber Apr 10, 2025
5c8808e
fix target_compile_definitions
planthaber Apr 11, 2025
124ee04
Use RockQt macros to simplify the visualization CMakeLists.txt
pierrewillenbrockdfki Aug 26, 2025
7befad1
Add gui/osgviz as dependency
pierrewillenbrockdfki Aug 26, 2025
b9b2095
fix: Avoid building visualization when a qt dep(vizkit3d) is missing
pierrewillenbrockdfki Aug 27, 2025
2b54237
Merge remote-tracking branch 'rock.core/master' into feature/qt4-qt5
pierrewillenbrockdfki Sep 22, 2025
c71f7cb
fix: Build visualization test for qt4 and qt5
pierrewillenbrockdfki Sep 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ cmake_policy(SET CMP0057 NEW)

find_package(Rock)
rock_init(base 1.0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think passing arguments to rock_init() is deprecated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but lets not add that change on top as well.

rock_feature(NOCURDIR)

set(CMAKE_CXX_STANDARD 11)

Expand Down
2 changes: 2 additions & 0 deletions manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@
<depend package="rice" optional="1" />
<depend package="external/sisl" optional="1" />
<depend package="gui/vizkit3d" optional="1" />
<!-- gui/osgviz is directly used here, also pulled in by gui/vizkit3d -->
<depend package="gui/osgviz" optional="1" />
<tags>stable</tags>
</package>
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ if(SISL_FOUND)
Spline.cpp
Trajectory.cpp
)
set(BASE-TYPES_EXTRA_DEPS_CMAKE SISL)
endif()

rock_library(
Expand Down Expand Up @@ -118,10 +119,10 @@ rock_library(
DEPS_PKGCONFIG
base-logging
eigen3
DEPS_CMAKE ${BASE-TYPES_EXTRA_DEPS_CMAKE}
)

if(SISL_FOUND)
target_link_libraries(base-types ${SISL_LIBRARIES})
install(FILES ${CMAKE_SOURCE_DIR}/src/Spline.hpp
DESTINATION include/base/geometry)
configure_file(base-types-sisl.pc.in ${CMAKE_BINARY_DIR}/base-types-sisl.pc @ONLY)
Expand Down
16 changes: 13 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

rock_find_qt4(OPTIONAL)
rock_find_qt5(OPTIONAL)
include(RockQt)

if(SISL_FOUND)
list(APPEND OPTIONAL_TESTS
test_Spline.cpp)
Expand All @@ -21,9 +26,14 @@ rock_executable(benchmark benchmark.cpp bench_func.cpp
DEPS base-types
DEPS_PKGCONFIG base-logging
NOINSTALL)
rock_executable(test_DepthMapVisualization test_DepthMapVisualization.cpp
DEPS base-types base-viz
DEPS_PKGCONFIG vizkit3d

rock_qt_executable(
TARGETPREFIX test_DepthMapVisualization
QT4_SUFFIX ""
SOURCES test_DepthMapVisualization.cpp
DEPS base-types
DEPS_QT base-viz
DEPS_PKGCONFIG_QT vizkit3d
LIBS ${Boost_SYSTEM_LIBRARY}
NOINSTALL)

25 changes: 22 additions & 3 deletions viz/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
rock_find_qt4()
rock_find_qt4(OPTIONAL)
rock_find_qt5(OPTIONAL)

include(RockQt)

unset(OPTIONAL_HPP)
unset(OPTIONAL_MOC)
Expand All @@ -15,7 +18,11 @@ if(SISL_FOUND)
)
endif()

rock_vizkit_plugin(base-viz
rock_qt_vizkit_plugin(
TARGETPREFIX base-viz
QT4_SUFFIX ""
MISSINGQTDEPS_NOBUILD
SOURCES
PluginLoader.cpp Uncertainty.cpp Vizkit3DHelper.cpp
DistanceImageVisualization.cpp
LaserScanVisualization.cpp
Expand All @@ -28,8 +35,10 @@ rock_vizkit_plugin(base-viz
SonarVisualization.cpp
PointcloudVisualization.cpp
DepthMapVisualization.cpp
OrientedBoundingBoxVisualization.cpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should adding OrientedBoundingBoxVisualization be a separate PR? (I don't see anything wrong with that addition, i.e., I'd be fine with adding it here as well -- and this seems to have been in the qt4/qt5 branch for quite a while now ...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its hard to get it out of the history at this point; a revert would potentially remove it again depending on merge order.

${OPTIONAL_CPP}
MOC
PluginLoader.hpp
DistanceImageVisualization.hpp
LaserScanVisualization.hpp
MotionCommandVisualization.hpp
Expand All @@ -41,6 +50,7 @@ rock_vizkit_plugin(base-viz
SonarVisualization.hpp
PointcloudVisualization.hpp
DepthMapVisualization.hpp
OrientedBoundingBoxVisualization.hpp
${OPTIONAL_MOC}
HEADERS
Uncertainty.hpp
Expand All @@ -56,8 +66,17 @@ rock_vizkit_plugin(base-viz
SonarVisualization.hpp
PointcloudVisualization.hpp
DepthMapVisualization.hpp
OrientedBoundingBoxVisualization.hpp
${OPTIONAL_HPP}
DEPS base-types
LIBS ${Boost_SYSTEM_LIBRARY}
DEPS_PKGCONFIG base-logging
DEPS_PKGCONFIG base-logging PrimitivesFactory
)
if(SISL_FOUND)
if(TARGET base-viz)
target_compile_definitions(base-viz PRIVATE SISL_FOUND)
endif()
if(TARGET base-viz-qt5)
target_compile_definitions(base-viz-qt5 PRIVATE SISL_FOUND)
endif()
endif(SISL_FOUND)
69 changes: 69 additions & 0 deletions viz/OrientedBoundingBoxVisualization.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#include "OrientedBoundingBoxVisualization.hpp"

#include <osg/Geode>
#include <osg/Geometry>
#include <osg/Group>
#include <osg/ShapeDrawable>

#include <vizkit3d/Vizkit3DHelper.hpp>

using namespace vizkit3d;

struct OrientedBoundingBoxVisualization::Data {
// Copy of the value given to updateDataIntern.
// Making a copy is required because of how OSG works
std::vector<base::samples::OrientedBoundingBox> data;
};


OrientedBoundingBoxVisualization::OrientedBoundingBoxVisualization()
: p(new Data), color(1.0f, 1.0f, 1.0f, 1.0f) {
}

OrientedBoundingBoxVisualization::~OrientedBoundingBoxVisualization() {
delete p;
}

void OrientedBoundingBoxVisualization::setColor(QColor q_color) {
color = osg::Vec4(q_color.redF(), q_color.greenF(),
q_color.blueF(), q_color.alphaF());
setDirty();
emit propertyChanged("Color");
}

QColor OrientedBoundingBoxVisualization::getColor() const {
QColor q_color;
q_color.setRgbF(color[0], color[1], color[2], color[3]);
return q_color;
}

osg::ref_ptr<osg::Node> OrientedBoundingBoxVisualization::createMainNode() {
osg::ref_ptr<osg::Group> boxes = new osg::Group();

addBoxes(boxes);

return boxes;
}

void OrientedBoundingBoxVisualization::updateMainNode(osg::Node* node) {
node->asGroup()->removeChildren(0, node->asGroup()->getNumChildren());
addBoxes(node->asGroup());
}

void OrientedBoundingBoxVisualization::updateDataIntern(std::vector<base::samples::OrientedBoundingBox> const& data) {
p->data = data;
}

void OrientedBoundingBoxVisualization::updateDataIntern(base::samples::OrientedBoundingBox const& data) {
p->data.clear();
p->data.push_back(data);
}

void OrientedBoundingBoxVisualization::addBoxes(osg::Group* group) {
for (const auto & box : p->data) {
osg::ref_ptr<osgviz::Object> wireframe = primitives.createWireframeBox(box.dimension.x(), box.dimension.y(), box.dimension.z(), color);
wireframe->setPosition(box.position.x(), box.position.y(), box.position.z());
wireframe->setOrientation(box.orientation.x(), box.orientation.y(), box.orientation.z(), box.orientation.w());
group->addChild(wireframe);
}
}
88 changes: 88 additions & 0 deletions viz/OrientedBoundingBoxVisualization.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#pragma once

#include <vector>
#include <boost/noncopyable.hpp>
#include <vizkit3d/Vizkit3DPlugin.hpp>
#include <base/samples/OrientedBoundingBox.hpp>
#include <osgViz/modules/viz/Primitives/PrimitivesFactory.h>

namespace osg {
class Group;
}

namespace vizkit3d {


class OrientedBoundingBoxVisualization
: public vizkit3d::Vizkit3DPlugin< std::vector<base::samples::OrientedBoundingBox> >
, public vizkit3d::VizPluginAddType<base::samples::OrientedBoundingBox>
, boost::noncopyable
{
Q_OBJECT
Q_PROPERTY(QColor Color READ getColor WRITE setColor)

public:
OrientedBoundingBoxVisualization();
~OrientedBoundingBoxVisualization();

/**
* Thread-safe call of
* 'updateDataIntern ( std::vector<base::samples::OrientedBoundingBox> const& data )'.
*/
Q_INVOKABLE void updateData(std::vector<base::samples::OrientedBoundingBox> const &sample) {
vizkit3d::Vizkit3DPlugin< std::vector<base::samples::OrientedBoundingBox> >::updateData(sample);
}

/**
* Thread-safe call of 'updateDataIntern ( const base::samples::OrientedBoundingBox& data )'.
*/
Q_INVOKABLE void updateData(base::samples::OrientedBoundingBox const &sample) {
vizkit3d::Vizkit3DPlugin< std::vector<base::samples::OrientedBoundingBox> >::updateData(sample);
}

public slots:
/**
* Sets the color of all boxes.
*/
void setColor(QColor q_color);

/**
* Returns the current color of the boxes.
*/
QColor getColor() const;

protected:
/**
* OSG tree: Group <- Transformation <- Geode <- Sphere
* <- Triangle
*/
osg::ref_ptr<osg::Node> createMainNode();

/**
* Clears the group and redraws all boxes.
*/
void updateMainNode(osg::Node* node);

/**
* Replaces the current list of boxes with the passed one.
*/
void updateDataIntern(std::vector<base::samples::OrientedBoundingBox> const& data);

/**
* Clears the current list of boxes and adds the new waypoint.
*/
void updateDataIntern(base::samples::OrientedBoundingBox const& data);

private:
osg::ref_ptr<osg::Group> group;
struct Data;
Data* p;
osg::Vec4 color;
osgviz::PrimitivesFactory primitives;
/**
* Inserts all boxes into the tree using the tree structure shown
* in \a createMainNode() and the currently set color.
*/
void addBoxes(osg::Group* group);
};
} // namespace vizkit3d
Loading