From 9eab1cbdb269ec74cbe70671a46707c949d70cba Mon Sep 17 00:00:00 2001
From: roangel <roangel@student.ethz.ch>
Date: Thu, 20 Apr 2017 16:50:45 +0200
Subject: [PATCH] First compiling version of Qt stuff with catkin

---
 crazyflie_ws/sandbox/crazypkg/CMakeLists.txt  |  1 -
 pps_ws/src/d_fall_gui/CMakeLists.txt          | 50 ++++++++++++++++---
 .../GUI_Qt/CrazyFlyGUI/CrazyFlyGUI.pro        |  1 +
 .../CrazyFlyGUI/include/mainguiwindow.h       |  1 +
 .../GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp  | 12 +++--
 .../GUI_Qt/CrazyFlyGUI/src/mainguiwindow.ui   |  2 +-
 6 files changed, 53 insertions(+), 14 deletions(-)

diff --git a/crazyflie_ws/sandbox/crazypkg/CMakeLists.txt b/crazyflie_ws/sandbox/crazypkg/CMakeLists.txt
index be1120c2..3dd36d60 100755
--- a/crazyflie_ws/sandbox/crazypkg/CMakeLists.txt
+++ b/crazyflie_ws/sandbox/crazypkg/CMakeLists.txt
@@ -13,7 +13,6 @@ rosbuild_init()
 
 
 
-
 find_package(Qt5Widgets REQUIRED)
 find_package(Qt5Core REQUIRED)
 find_package(Qt5Gui REQUIRED)
diff --git a/pps_ws/src/d_fall_gui/CMakeLists.txt b/pps_ws/src/d_fall_gui/CMakeLists.txt
index 589cfd5f..b168af08 100644
--- a/pps_ws/src/d_fall_gui/CMakeLists.txt
+++ b/pps_ws/src/d_fall_gui/CMakeLists.txt
@@ -14,6 +14,10 @@ find_package(catkin REQUIRED COMPONENTS
   )
 
 
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(CMAKE_AUTOMOC ON)
+
 ## System dependencies are found with CMake's conventions
 # find_package(Boost REQUIRED COMPONENTS system)
 
@@ -22,16 +26,25 @@ find_package(Qt5Core REQUIRED)
 find_package(Qt5Gui REQUIRED)
 
 
+set(MY_LIB_PATH_SRC ${PROJECT_SOURCE_DIR}/GUI_Qt/CrazyFlyGUI/src)
+set(MY_LIB_PATH_INC ${PROJECT_SOURCE_DIR}/GUI_Qt/CrazyFlyGUI/include)
 
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+# #set the default path for built executables to the "bin" directory
+# set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
+# #set the default path for built libraries to the "lib" directory
+# set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
+
+add_definitions(-std=c++11)
 
-#set the default path for built executables to the "bin" directory
-set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
-#set the default path for built libraries to the "lib" directory
-set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
+set(SRC_HDRS
+  ${MY_LIB_PATH_INC}/crazyFlyZoneTab.h
+  ${MY_LIB_PATH_INC}/myGraphicsScene.h
+  ${MY_LIB_PATH_INC}/myGraphicsView.h
+  ${MY_LIB_PATH_INC}/mainguiwindow.h
+  )
 
-qt5_wrap_ui(UIS_HDRS gui/untitled/mainguiwindow.ui)
-qt5_wrap_cpp(SRC_HDRS gui/untitled/mainguiwindow.h)
+qt5_wrap_ui(UIS_HDRS GUI_Qt/CrazyFlyGUI/src/mainguiwindow.ui)
+qt5_wrap_cpp(SRC_MOC_HDRS ${SRC_HDRS})
 
 ## Uncomment this if the package has a setup.py. This macro ensures
 ## modules and global scripts declared therein get installed
@@ -133,6 +146,7 @@ catkin_package(
 ## Your package locations should be listed before other locations
 # include_directories(include)
 include_directories(
+  GUI_Qt/CrazyFlyGUI/include
   ${catkin_INCLUDE_DIRS}
 )
 
@@ -151,7 +165,27 @@ include_directories(
 ## The recommended prefix ensures that target names across packages don't collide
 # add_executable(${PROJECT_NAME}_node src/d_fall_gui_node.cpp)
 
-add_executable(GUI )
+add_executable(myGUI GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp GUI_Qt/CrazyFlyGUI/src/main.cpp ${UIS_HDRS} ${SRC_HDRS})
+qt5_use_modules(myGUI Widgets)
+
+
+
+set(MY_LIB_SOURCES
+    ${MY_LIB_PATH_SRC}/cornergrabber.cpp
+    ${MY_LIB_PATH_SRC}/crazyFlyZone.cpp
+    ${MY_LIB_PATH_SRC}/crazyFlyZoneTab.cpp
+    ${MY_LIB_PATH_SRC}/myGraphicsRectItem.cpp
+    ${MY_LIB_PATH_SRC}/myGraphicsScene.cpp
+    ${MY_LIB_PATH_SRC}/myGraphicsView.cpp
+    ${MY_LIB_PATH_SRC}/tablePiece.cpp
+    )
+
+
+add_library(my_library ${MY_LIB_SOURCES})
+
+target_link_libraries(myGUI Qt5::Widgets)
+target_link_libraries(my_library Qt5::Widgets)
+target_link_libraries(myGUI my_library)
 
 ## Rename C++ executable without prefix
 ## The above recommended prefix causes long target names, the following renames the
diff --git a/pps_ws/src/d_fall_gui/GUI_Qt/CrazyFlyGUI/CrazyFlyGUI.pro b/pps_ws/src/d_fall_gui/GUI_Qt/CrazyFlyGUI/CrazyFlyGUI.pro
index 8c0bc083..161c2ecb 100644
--- a/pps_ws/src/d_fall_gui/GUI_Qt/CrazyFlyGUI/CrazyFlyGUI.pro
+++ b/pps_ws/src/d_fall_gui/GUI_Qt/CrazyFlyGUI/CrazyFlyGUI.pro
@@ -12,6 +12,7 @@ TARGET = CrazyFlyGUI
 TEMPLATE = app
 
 INCLUDEPATH += $$PWD/include
+CONFIG += c++11
 
 
 SOURCES += \
diff --git a/pps_ws/src/d_fall_gui/GUI_Qt/CrazyFlyGUI/include/mainguiwindow.h b/pps_ws/src/d_fall_gui/GUI_Qt/CrazyFlyGUI/include/mainguiwindow.h
index f0fac1a6..73440b7b 100644
--- a/pps_ws/src/d_fall_gui/GUI_Qt/CrazyFlyGUI/include/mainguiwindow.h
+++ b/pps_ws/src/d_fall_gui/GUI_Qt/CrazyFlyGUI/include/mainguiwindow.h
@@ -8,6 +8,7 @@
 #include <QGridLayout>
 #include <QGraphicsRectItem>
 
+
 #ifndef DEBUG_GUI
 #include "ros/callback_queue.h"
 #include "ros/ros.h"
diff --git a/pps_ws/src/d_fall_gui/GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp b/pps_ws/src/d_fall_gui/GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp
index df0d0250..3a462c55 100644
--- a/pps_ws/src/d_fall_gui/GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp
+++ b/pps_ws/src/d_fall_gui/GUI_Qt/CrazyFlyGUI/src/mainguiwindow.cpp
@@ -1,12 +1,15 @@
 #include "mainguiwindow.h"
 #include "ui_mainguiwindow.h"
 #include "crazyFlyZoneTab.h"
+#include "myGraphicsScene.h"
+#include "myGraphicsView.h"
 
 #include <QObject>
 #include <QDoubleSpinBox>
 #include <QTextEdit>
 #include <QString>
 
+#include <string>
 
 #define N_MAX_CRAZYFLIES           20 // protection number
 
@@ -43,12 +46,13 @@ MainGUIWindow::~MainGUIWindow()
 void MainGUIWindow::set_tabs(int n)
 {
     ui->tabWidget->clear();
-    std::string str;
     for (int i = 0; i < n; i++)
     {
-        str = "CrazyFly ";
-        str += std::to_string(i+1);
-        QString qstr(str.c_str());
+        // str = "CrazyFly ";
+        // str += std::to_string(i+1);
+        QString qstr = "CrazyFly ";
+        qstr.append(QString::number(i+1));
+        // QString qstr(str.c_str());
         crazyFlyZoneTab* widget = new crazyFlyZoneTab(i);
         ui->tabWidget->addTab(widget, qstr);
         connect(widget, SIGNAL(centerButtonClickedSignal(int)), this, SLOT(centerViewIndex(int)));
diff --git a/pps_ws/src/d_fall_gui/GUI_Qt/CrazyFlyGUI/src/mainguiwindow.ui b/pps_ws/src/d_fall_gui/GUI_Qt/CrazyFlyGUI/src/mainguiwindow.ui
index a05c791a..1020c9ad 100644
--- a/pps_ws/src/d_fall_gui/GUI_Qt/CrazyFlyGUI/src/mainguiwindow.ui
+++ b/pps_ws/src/d_fall_gui/GUI_Qt/CrazyFlyGUI/src/mainguiwindow.ui
@@ -316,7 +316,7 @@
   <customwidget>
    <class>myGraphicsView</class>
    <extends>QGraphicsView</extends>
-   <header>./include/myGraphicsView.h</header>
+   <header>myGraphicsView.h</header>
   </customwidget>
  </customwidgets>
  <resources/>
-- 
GitLab