-
Notifications
You must be signed in to change notification settings - Fork 44
Feature/qt4 qt5 #177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Feature/qt4 qt5 #177
Changes from all commits
4c081ed
6160ccf
ee4a7c3
2d323d9
238f9fc
eef7f28
563ddb8
8ab436d
88cee60
a48e412
bf08f09
a600b09
5c8808e
124ee04
7befad1
b9b2095
2b54237
c71f7cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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) | ||
|
@@ -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 | ||
|
@@ -28,8 +35,10 @@ rock_vizkit_plugin(base-viz | |
SonarVisualization.cpp | ||
PointcloudVisualization.cpp | ||
DepthMapVisualization.cpp | ||
OrientedBoundingBoxVisualization.cpp | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should adding There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
@@ -41,6 +50,7 @@ rock_vizkit_plugin(base-viz | |
SonarVisualization.hpp | ||
PointcloudVisualization.hpp | ||
DepthMapVisualization.hpp | ||
OrientedBoundingBoxVisualization.hpp | ||
${OPTIONAL_MOC} | ||
HEADERS | ||
Uncertainty.hpp | ||
|
@@ -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) |
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); | ||
} | ||
} |
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 |
There was a problem hiding this comment.
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 deprecatedThere was a problem hiding this comment.
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.