From a80dd157230ae6460bbb3d5a7adaf06e7c787c2c Mon Sep 17 00:00:00 2001
From: Tommy Persson <tommy.persson@liu.se>
Date: Sun, 23 Sep 2018 23:08:54 +0200
Subject: [PATCH] Initial files

---
 CMakeLists.txt         | 39 +++++++++++++++++++++++++++++++++++++--
 package.xml            |  4 +++-
 plugin_description.xml |  7 +++++++
 3 files changed, 47 insertions(+), 3 deletions(-)
 create mode 100644 plugin_description.xml

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d655733..47f5fe4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,7 +7,16 @@ project(lrs_rviz_melodic)
 ## Find catkin macros and libraries
 ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
 ## is used, also find other catkin packages
-find_package(catkin REQUIRED)
+find_package(catkin REQUIRED COMPONENTS
+  rviz
+  roscpp
+  )
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
+
+find_package(Qt5Core REQUIRED)
+find_package(Qt5Gui REQUIRED)
 
 ## System dependencies are found with CMake's conventions
 # find_package(Boost REQUIRED COMPONENTS system)
@@ -113,7 +122,9 @@ catkin_package(
 ## Your package locations should be listed before other locations
 include_directories(
 # include
-# ${catkin_INCLUDE_DIRS}
+  ${catkin_INCLUDE_DIRS}
+  /usr/include/OGRE
+  /opt/ros/melodic/include/rviz
 )
 
 ## Declare a C++ library
@@ -121,6 +132,12 @@ include_directories(
 #   src/${PROJECT_NAME}/lrs_rviz_melodic.cpp
 # )
 
+## Declare a C++ library
+add_library(lrs_rviz_plugin
+  src/image_visual.cc
+  src/image_display.cc
+)
+
 ## Add cmake target dependencies of the library
 ## as an example, code may need to be generated before libraries
 ## either from message generation or dynamic reconfigure
@@ -146,6 +163,13 @@ include_directories(
 #   ${catkin_LIBRARIES}
 # )
 
+target_link_libraries(lrs_rviz_plugin
+  ${catkin_LIBRARIES}
+  ${QT_LIBRARIES}
+  Qt5::Gui
+  Qt5::Core
+)
+
 #############
 ## Install ##
 #############
@@ -167,6 +191,12 @@ include_directories(
 #   RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
 # )
 
+install(TARGETS lrs_rviz_plugin
+   ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
+   LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
+   RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
+)
+
 ## Mark cpp header files for installation
 # install(DIRECTORY include/${PROJECT_NAME}/
 #   DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
@@ -181,6 +211,11 @@ include_directories(
 #   DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
 # )
 
+install(FILES
+  plugin_description.xml
+  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
+)
+
 #############
 ## Testing ##
 #############
diff --git a/package.xml b/package.xml
index c60e9e0..7326136 100644
--- a/package.xml
+++ b/package.xml
@@ -49,11 +49,13 @@
   <!-- Use doc_depend for packages you need only for building documentation: -->
   <!--   <doc_depend>doxygen</doc_depend> -->
   <buildtool_depend>catkin</buildtool_depend>
+  <depend>roscpp</depend>
+  <depend>rviz</depend>
 
 
   <!-- The export tag contains other, unspecified, tags -->
   <export>
     <!-- Other tools can request additional information be placed here -->
-
+    <rviz plugin="${prefix}/plugin_description.xml"/>
   </export>
 </package>
diff --git a/plugin_description.xml b/plugin_description.xml
new file mode 100644
index 0000000..85d6805
--- /dev/null
+++ b/plugin_description.xml
@@ -0,0 +1,7 @@
+<library path="lib/liblrs_rviz_plugin">
+  <class name="lrs_rviz/Image" type="lrs_rviz::ImageDisplay" base_class_type="rviz::Display">
+    <description>
+      Displays an image on the ground plane.
+    </description>
+  </class>
+</library>
-- 
GitLab