├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── applications ├── CMakeLists.txt ├── ExampleApplication │ ├── ApplicationGUI.cpp │ ├── ApplicationGUI.hpp │ ├── CMakeLists.txt │ └── main.cpp └── RecordApplication │ ├── CMakeLists.txt │ ├── RecordApplicationGUI.cpp │ ├── RecordApplicationGUI.hpp │ └── main.cpp ├── cmake ├── ExternalFAST.cmake ├── ExternalFMT.cmake ├── ExternalQt5.cmake ├── ExternalRomocc.cmake ├── Externals.cmake ├── InstallFiles │ └── qt.conf ├── Macros.cmake ├── Qt5Core │ ├── Qt5CTestMacros.cmake │ ├── Qt5CoreConfig.cmake │ ├── Qt5CoreConfigExtras.cmake │ ├── Qt5CoreConfigExtrasMkspecDir.cmake │ ├── Qt5CoreConfigVersion.cmake │ └── Qt5CoreMacros.cmake ├── Qt5Gui │ ├── Qt5GuiConfig.cmake │ ├── Qt5GuiConfigExtras.cmake │ └── Qt5GuiConfigVersion.cmake ├── Qt5Multimedia │ ├── Qt5MultimediaConfig.cmake │ ├── Qt5MultimediaConfigVersion.cmake │ ├── Qt5Multimedia_AudioCaptureServicePlugin.cmake │ └── Qt5Multimedia_QM3uPlaylistPlugin.cmake ├── Qt5MultimediaWidgets │ ├── Qt5MultimediaWidgetsConfig.cmake │ └── Qt5MultimediaWidgetsConfigVersion.cmake ├── Qt5Network │ ├── Qt5NetworkConfig.cmake │ ├── Qt5NetworkConfigVersion.cmake │ ├── Qt5Network_QConnmanEnginePlugin.cmake │ ├── Qt5Network_QGenericEnginePlugin.cmake │ └── Qt5Network_QNetworkManagerEnginePlugin.cmake ├── Qt5OpenGL │ ├── Qt5OpenGLConfig.cmake │ └── Qt5OpenGLConfigVersion.cmake ├── Qt5Widgets │ ├── Qt5WidgetsConfig.cmake │ ├── Qt5WidgetsConfigExtras.cmake │ ├── Qt5WidgetsConfigVersion.cmake │ └── Qt5WidgetsMacros.cmake └── Requirements.cmake └── source └── EchoBot ├── CMakeLists.txt ├── Core ├── CMakeLists.txt ├── Config.cpp ├── Config.h ├── DataTypes.cpp ├── DataTypes.h └── SmartPointers.h ├── Exporters ├── CMakeLists.txt ├── PointCloudExporter.cpp ├── PointCloudExporter.h └── Tests │ └── PointCloudExporterTests.cpp ├── GUI ├── CMakeLists.txt └── Widgets │ ├── CMakeLists.txt │ ├── CalibrationWidget.cpp │ ├── CalibrationWidget.h │ ├── ConnectionWidget.cpp │ ├── ConnectionWidget.h │ ├── Icons │ ├── application-exit-4.png │ ├── arrow-down-double.png │ ├── arrow-down.png │ ├── arrow-left.png │ ├── arrow-right.png │ ├── arrow-up-double.png │ ├── arrow-up.png │ ├── button-blue.ico │ ├── button-green.ico │ ├── button-red.ico │ ├── edit-redo-7.ico │ ├── edit-undo-7.ico │ ├── folder-2.ico │ ├── network-idle.ico │ ├── network-offline.ico │ ├── network-transmit-receive.ico │ ├── off.ico │ ├── on.ico │ ├── ryNeg.png │ ├── ryPos.png │ ├── rzNeg.png │ ├── rzPos.png │ ├── systemexit.ico │ ├── user-available.ico │ ├── user-busy.ico │ ├── xNeg.png │ ├── xPos.png │ ├── y.ico │ ├── yNeg.png │ └── yPos.png │ ├── RecordWidget.cpp │ ├── RecordWidget.h │ ├── RobotManualMoveWidget.cpp │ └── RobotManualMoveWidget.h ├── Interfaces ├── CMakeLists.txt ├── Camera │ ├── CMakeLists.txt │ ├── CameraDataProcessing.cpp │ ├── CameraDataProcessing.h │ ├── CameraInterface.cpp │ └── CameraInterface.hpp ├── Robot │ ├── CMakeLists.txt │ ├── RobotInterface.cpp │ └── RobotInterface.h ├── SensorInterface.h ├── Tests │ └── RobotInterfaceTests.cpp └── Ultrasound │ ├── CMakeLists.txt │ ├── UltrasoundImageProcessing.cpp │ ├── UltrasoundImageProcessing.h │ ├── UltrasoundInterface.cpp │ └── UltrasoundInterface.hpp ├── Tests ├── CMakeLists.txt ├── CatchMain.cpp ├── WorkflowTests.cpp └── catch.hpp ├── Utilities ├── CMakeLists.txt ├── CalibrationTool.cpp ├── CalibrationTool.h ├── PointCloudUtilities.cpp ├── PointCloudUtilities.h ├── RecordTool.cpp ├── RecordTool.h ├── Tests │ └── CalibrationToolTests.cpp ├── Utilities.cpp └── Utilities.h └── Visualization ├── CADModels ├── .gitignore ├── 5S-Probe.vtk ├── C5-2_60_Ultrasonix.vtk ├── clarius_probe_with_holder_ur5.vtk └── ur5 │ ├── base.vtk │ ├── forearm.vtk │ ├── shoulder.vtk │ ├── upperarm.vtk │ ├── wrist1.vtk │ ├── wrist2.vtk │ └── wrist3.vtk ├── CMakeLists.txt ├── RobotVisualization.cpp ├── RobotVisualization.h ├── RobotVisualizationTests.cpp ├── VisualizationHelper.cpp └── VisualizationHelper.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | .idea/ 35 | build*/ 36 | data/ -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(EchoBot) 3 | 4 | include(cmake/Macros.cmake) 5 | 6 | #### Options 7 | option(ECHOBOT_BUILD_TESTS "Build tests." ON) 8 | option(ECHOBOT_BUILD_QT5 "Download and build Qt. Turn OFF if you want to use pre-built binaries existing on your machine." ON) 9 | option(ECHOBOT_BUILD_FAST "Download and build FAST." OFF) 10 | option(ECHOBOT_BUILD_ROMOCC "Download and build libromocc." ON) 11 | option(ECHOBOT_BUILD_FMT "Download and build fmt." ON) 12 | option(ECHOBOT_ENABLE_CLARIUS_STREAMING "Enable streaming from Clarius probe." OFF) 13 | 14 | # Enable C++ 14 15 | set(CMAKE_CXX_STANDARD 14) 16 | 17 | # Get rid of Qt error with position independent code 18 | if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") 19 | add_definitions("-fPIC") 20 | endif() 21 | 22 | #### Paths 23 | set(ECHOBOT_TEST_DATA_DIR "" CACHE PATH "Directory of test data. Default is ROOT/data/.") 24 | set(ECHOBOT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/source/EchoBot") 25 | set(ECHOBOT_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/source/ ${CMAKE_CURRENT_BINARY_DIR}) 26 | 27 | ## Set build folders 28 | # First for the generic no-config case (e.g. with mingw) 29 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) 30 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib ) 31 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib ) 32 | 33 | #### Module path 34 | set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/ ${CMAKE_MODULE_PATH}) # For finding the custom Find modules 35 | 36 | # Headers for Qt objects 37 | # TODO make a macro for adding these 38 | set(QT_HEADERS 39 | source/EchoBot/Interfaces/Robot/RobotInterface.h 40 | source/EchoBot/GUI/Widgets/ConnectionWidget.h 41 | source/EchoBot/GUI/Widgets/RecordWidget.h 42 | source/EchoBot/GUI/Widgets/RobotManualMoveWidget.h 43 | source/EchoBot/GUI/Widgets/CalibrationWidget.h 44 | ) 45 | 46 | # Set debug define if debug mode is set 47 | if(CMAKE_BUILD_TYPE STREQUAL Debug) 48 | message("-- EchoBot Debug mode set") 49 | add_definitions("-DECHOBOT_DEBUG") 50 | endif() 51 | 52 | #### Setup all external depedencies 53 | include(cmake/Requirements.cmake) 54 | 55 | #### Set include dirs 56 | message("-- Includes: ${ECHOBOT_INCLUDE_DIRS}") 57 | include_directories(${ECHOBOT_INCLUDE_DIRS}) 58 | 59 | get_directory_property(hasParent PARENT_DIRECTORY) 60 | if(hasParent) 61 | set(ECHOBOT_INCLUDE_DIRS ${ECHOBOT_INCLUDE_DIRS} PARENT_SCOPE) 62 | endif() 63 | 64 | # Set up RPATH with relative path so that binaries will find libraries in the lib folder 65 | if(APPLE) 66 | set(CMAKE_MACOSX_RPATH ON) 67 | set(CMAKE_INSTALL_RPATH "@loader_path/../lib") 68 | else() 69 | set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib") 70 | endif() 71 | 72 | #### Add all subdirs 73 | project_add_subdirectories(source/EchoBot) 74 | 75 | SET(CMAKE_INCLUDE_CURRENT_DIR ON) 76 | 77 | message("-- Dependencies: ${ECHOBOT_EXTERNAL_DEPENDENCIES}") 78 | 79 | #### Create library and executables 80 | add_library(EchoBot SHARED ${ECHOBOT_SOURCE_FILES} ${HEADERS_MOC}) 81 | add_dependencies(EchoBot ${ECHOBOT_EXTERNAL_DEPENDENCIES}) 82 | 83 | include(GenerateExportHeader) 84 | generate_export_header(EchoBot EXPORT_FILE_NAME EchoBotExport.hpp) 85 | 86 | ## Link everything 87 | message("-- Libs: ${LIBRARIES}") 88 | target_link_libraries(EchoBot PUBLIC ${LIBRARIES}) 89 | target_include_directories(EchoBot PUBLIC ${ECHOBOT_INCLUDE_DIRS}) 90 | 91 | add_custom_command(TARGET EchoBot PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory 92 | ${CMAKE_SOURCE_DIR}/source/EchoBot/Visualization/CADModels 93 | $/source/EchoBot/Visualization/CADModels) 94 | 95 | add_custom_command(TARGET EchoBot PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory 96 | ${CMAKE_SOURCE_DIR}/source/EchoBot/GUI/Widgets/Icons 97 | $/source/EchoBot/GUI/Widgets/Icons) 98 | 99 | project_add_subdirectories(applications) 100 | 101 | ## Build test executable 102 | if(ECHOBOT_BUILD_TESTS) 103 | add_executable(testEchoBot ${ECHOBOT_TEST_SOURCE_FILES}) 104 | target_link_libraries(testEchoBot EchoBot) 105 | endif() -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2019, SINTEF Digital, Health Research 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 17 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # EchoBot 2 | 3 | EchoBot is an open-source robotic ultrasound system that integrates core libraries for building generic and autonomous robotic US applications. 4 | 5 | ### Features 6 | 7 | Several of the essential components are implemented in the frameworks FAST and libromocc. This include 8 | 9 | * **Sensor interface** - Ultrasound scanners, robots and depth cameras 10 | * **Machine Learning** - Real-time inference through several supported engines, such as TensorFlow. 11 | * **Visualization** - Supports 3D and 2D rendering 12 | * **GUI Widgets** - Premade widgets that can be used in multiple applications 13 | 14 | ### Structure 15 | 16 | EchoBot is written in C++ using CMake, Qt, Eigen, libromocc and FAST. 17 | 18 | 19 | ### Development instructions 20 | 21 | #### Option 1. Install with FAST preinstalled on your system 22 | 23 | Build and install the echobot branch of [FAST](https://github.com/androst/FAST/tree/echobot) on your system. Remember to enable building 24 | Tensorflow, Realsense and OpenIGTLink in the CMake. Optionally enable the Clarius module. After installation, you can build EchoBot on 25 | your system by pointing to the FAST install directory. 26 | 27 | Linux (Ubuntu 18.04): 28 | ```bash 29 | git clone https://github.com/androst/EchoBot.git 30 | cd EchoBot 31 | mkdir build 32 | cd build 33 | cmake .. -DFAST_DIR=/path/to/FAST/cmake/ 34 | make -j8 35 | ``` 36 | 37 | #### Option 2. Build FAST with EchoBot 38 | 39 | This is not working as intended at the moment. 40 | -------------------------------------------------------------------------------- /applications/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project_add_subdirectories(ExampleApplication) 2 | project_add_subdirectories(RecordApplication) -------------------------------------------------------------------------------- /applications/ExampleApplication/ApplicationGUI.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ECHOBOT_APPLICATIONGUI_H 2 | #define ECHOBOT_APPLICATIONGUI_H 3 | 4 | #include "EchoBot/Interfaces/Ultrasound/UltrasoundInterface.hpp" 5 | #include "EchoBot/Interfaces/Camera/CameraInterface.hpp" 6 | #include "EchoBot/Interfaces/Robot/RobotInterface.h" 7 | #include "EchoBot/Visualization/RobotVisualization.h" 8 | 9 | #include "EchoBot/GUI/Widgets/RobotManualMoveWidget.h" 10 | #include "EchoBot/GUI/Widgets/ConnectionWidget.h" 11 | #include "EchoBot/GUI/Widgets/RecordWidget.h" 12 | #include "EchoBot/GUI/Widgets/CalibrationWidget.h" 13 | 14 | #include "FAST/Visualization/Window.hpp" 15 | #include "FAST/Streamers/Streamer.hpp" 16 | #include "FAST/Streamers/FileStreamer.hpp" 17 | #include "FAST/Streamers/ImageFileStreamer.hpp" 18 | #include "FAST/Streamers/MeshFileStreamer.hpp" 19 | #include "FAST/Streamers/OpenIGTLinkStreamer.hpp" 20 | #include "FAST/Streamers/ClariusStreamer.hpp" 21 | #include "FAST/Tools/OpenIGTLinkClient/OpenIGTLinkClient.hpp" 22 | #include "FAST/Visualization/LineRenderer/LineRenderer.hpp" 23 | 24 | class QPushButton; 25 | class QTabWidget; 26 | 27 | namespace echobot { 28 | 29 | class MouseListener; 30 | 31 | class ApplicationGUI : public Window { 32 | ECHOBOT_OBJECT(ApplicationGUI) 33 | 34 | private slots: 35 | void robotConnectButtonSlot(); 36 | void robotDisconnectButtonSlot(); 37 | void robotShutdownButtonSlot(); 38 | void playbackButtonSlot(); 39 | void stopPlaybackButtonSlot(); 40 | 41 | private: 42 | ApplicationGUI(); 43 | 44 | SharedPointer mRobotInterface; 45 | SharedPointer mCameraInterface; 46 | SharedPointer mUltrasoundInterface; 47 | SharedPointer mRobotVisualizator; 48 | 49 | std::unordered_map mCameraPlaybackStreamers; 50 | 51 | RobotManualMoveWidget* mRobotMoveWidget; 52 | ConnectionWidget* mConnectionWidget; 53 | RecordWidget* mRecordWidget; 54 | CalibrationWidget* mCalibrationWidget; 55 | 56 | void connectToCamera(); 57 | void disconnectFromCamera(); 58 | void stopStreaming(); 59 | 60 | void connectToUltrasound(); 61 | void disconnectFromUltrasound(); 62 | 63 | void setupUI(); 64 | 65 | QString mGraphicsFolderName; 66 | QPushButton *calibrateButton, *registerDataButton, *registerTargetButton, *moveToolManualButton; 67 | QPushButton *moveToolRegisteredButton, *planMoveToolRegisteredButton, *enableSegmentationButton; 68 | QTabWidget *tabWidget; 69 | 70 | void extractPointCloud(); 71 | bool mCameraPlayback = false; 72 | bool mCameraStreaming = false; 73 | bool mUltrasoundStreaming = false; 74 | bool mTargetRegistered = false; 75 | bool mMovingToTarget = false; 76 | Vector6d mTargetJointConfig; 77 | Transform3d mTargetOpConfig; 78 | 79 | QWidget* getWorkflowWidget(); 80 | 81 | void restartCamera(); 82 | 83 | void setupRobotManipulatorVisualization(); 84 | void setupCameraVisualization(); 85 | void setupUltrasoundVisualization(); 86 | 87 | void setupConnections(); 88 | 89 | void calibrateSystem(); 90 | void registerTarget(); 91 | void moveToolToManualTarget(); 92 | void planMoveToRegisteredTarget(); 93 | void moveToolToRegisteredTarget(); 94 | void registerCloudToData(); 95 | void enableNeuralNetworkSegmentation(); 96 | 97 | void loadPreoperativeData(); 98 | Mesh::pointer mPreoperativeData; 99 | 100 | void addCoordinateAxis(Eigen::Affine3f transform); 101 | std::vector mCoordinateAxis; 102 | void renderCoordinateAxis(float axisLength = 500); 103 | 104 | void initializeRenderers(); 105 | }; 106 | 107 | } 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /applications/ExampleApplication/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project_add_application(ExampleApplication 2 | main.cpp 3 | ApplicationGUI.cpp 4 | ApplicationGUI.hpp 5 | ) -------------------------------------------------------------------------------- /applications/ExampleApplication/main.cpp: -------------------------------------------------------------------------------- 1 | #include "ApplicationGUI.hpp" 2 | 3 | using namespace echobot; 4 | 5 | int main() { 6 | ApplicationGUI::pointer window = ApplicationGUI::New(); 7 | window->start(); 8 | } -------------------------------------------------------------------------------- /applications/RecordApplication/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project_add_application(RecordApplication 2 | main.cpp 3 | RecordApplicationGUI.cpp 4 | RecordApplicationGUI.hpp 5 | ) -------------------------------------------------------------------------------- /applications/RecordApplication/RecordApplicationGUI.cpp: -------------------------------------------------------------------------------- 1 | #include "RecordApplicationGUI.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | #include 12 | #include "FAST/Visualization/ImageRenderer/ImageRenderer.hpp" 13 | #include "FAST/Streamers/RealSenseStreamer.hpp" 14 | 15 | namespace echobot { 16 | 17 | RecordApplicationGUI::RecordApplicationGUI() 18 | { 19 | mCameraInterface = CameraInterface::New(); 20 | mUltrasoundInterface = UltrasoundInterface::New(); 21 | 22 | setupUI(); 23 | setupConnections(); 24 | } 25 | 26 | void RecordApplicationGUI::setupConnections() 27 | { 28 | QObject::connect(mConnectionWidget, &ConnectionWidget::cameraConnected, std::bind(&RecordApplicationGUI::connectToCamera, this)); 29 | QObject::connect(mConnectionWidget, &ConnectionWidget::cameraDisconnected, std::bind(&RecordApplicationGUI::disconnectFromCamera, this)); 30 | 31 | QObject::connect(mConnectionWidget, &ConnectionWidget::usConnected, std::bind(&RecordApplicationGUI::connectToUltrasound, this)); 32 | QObject::connect(mConnectionWidget, &ConnectionWidget::usDisconnected, std::bind(&RecordApplicationGUI::disconnectFromUltrasound, this)); 33 | 34 | QObject::connect(mRecordWidget, &RecordWidget::playbackStarted, this, &RecordApplicationGUI::playbackButtonSlot); 35 | QObject::connect(mRecordWidget, &RecordWidget::playbackStopped, this, &RecordApplicationGUI::stopPlaybackButtonSlot); 36 | } 37 | 38 | // Camera 39 | 40 | void RecordApplicationGUI::connectToCamera() { 41 | stopComputationThread(); 42 | removeAllRenderers(); 43 | 44 | setupCameraVisualization(); 45 | if(mUltrasoundStreaming){ 46 | mUltrasoundInterface->connect(); 47 | setupUltrasoundVisualization(); 48 | } 49 | mCameraStreaming = true; 50 | 51 | reinitializeViews(); 52 | startComputationThread(); 53 | } 54 | 55 | void RecordApplicationGUI::disconnectFromCamera() { 56 | stopComputationThread(); 57 | removeAllRenderers(); 58 | 59 | if(mUltrasoundStreaming){ 60 | mUltrasoundInterface->connect(); 61 | setupUltrasoundVisualization(); 62 | } 63 | mCameraStreaming = false; 64 | 65 | startComputationThread(); 66 | } 67 | 68 | 69 | void RecordApplicationGUI::playbackButtonSlot() 70 | { 71 | stopComputationThread(); 72 | removeAllRenderers(); 73 | 74 | setupUltrasoundVisualization(); 75 | mUltrasoundStreaming = true; 76 | 77 | setupCameraVisualization(); 78 | mCameraStreaming = true; 79 | 80 | reinitializeViews(); 81 | startComputationThread(); 82 | } 83 | 84 | void RecordApplicationGUI::stopPlaybackButtonSlot() 85 | { 86 | mUltrasoundStreaming = false; 87 | this->stopStreaming(); 88 | } 89 | 90 | void RecordApplicationGUI::setupCameraVisualization() { 91 | getView(0)->addRenderer(mCameraInterface->getImageRenderer()); 92 | getView(1)->addRenderer(mCameraInterface->getDepthImageRenderer()); 93 | } 94 | 95 | void RecordApplicationGUI::stopStreaming() 96 | { 97 | stopComputationThread(); 98 | removeAllRenderers(); 99 | startComputationThread(); 100 | } 101 | 102 | // Ultrasound 103 | void RecordApplicationGUI::connectToUltrasound() { 104 | stopComputationThread(); 105 | removeAllRenderers(); 106 | setupUltrasoundVisualization(); 107 | 108 | if(mCameraStreaming || mCameraPlayback){ 109 | mCameraInterface->connect(); 110 | setupCameraVisualization(); 111 | } 112 | 113 | mUltrasoundStreaming = true; 114 | reinitializeViews(); 115 | startComputationThread(); 116 | } 117 | 118 | void RecordApplicationGUI::disconnectFromUltrasound() { 119 | stopComputationThread(); 120 | removeAllRenderers(); 121 | 122 | if(mCameraStreaming || mCameraPlayback){ 123 | mCameraInterface->connect(); 124 | setupCameraVisualization(); 125 | } 126 | mUltrasoundStreaming = false; 127 | startComputationThread(); 128 | } 129 | 130 | void RecordApplicationGUI::setupUltrasoundVisualization() 131 | { 132 | getView(2)->addRenderer(mUltrasoundInterface->getImageRenderer()); 133 | } 134 | 135 | // UI Setup 136 | 137 | void RecordApplicationGUI::setupUI() 138 | { 139 | View* view2D = createView(); 140 | View* view3D = createView(); 141 | View* viewUS = createView(); 142 | 143 | setTitle("Record application"); 144 | setWidth(1920); 145 | setHeight(1080); 146 | enableMaximized(); 147 | 148 | viewUS->set2DMode(); 149 | viewUS->setBackgroundColor(Color::White()); 150 | viewUS->setFixedWidth(860); 151 | 152 | view3D->set2DMode(); 153 | view3D->setBackgroundColor(Color::White()); 154 | view3D->setFixedWidth(540); 155 | //view3D->setLookAt(Vector3f(0, -500, -500), Vector3f(0, 0, 1000), Vector3f(0, -1, 0), 500, 5000); 156 | 157 | view2D->set2DMode(); 158 | view2D->setBackgroundColor(Color::White()); 159 | view2D->setFixedWidth(540); 160 | 161 | QVBoxLayout* menuLayout = new QVBoxLayout; 162 | menuLayout->setAlignment(Qt::AlignTop); 163 | int menuWidth = 480; 164 | 165 | // Title label 166 | QLabel* title = new QLabel; 167 | title->setText("
Record application
"); 168 | menuLayout->addWidget(title, 0, Qt::AlignTop); 169 | 170 | 171 | mConnectionWidget = new ConnectionWidget(menuWidth); 172 | mConnectionWidget->addInterface(mUltrasoundInterface); 173 | mConnectionWidget->addInterface(mCameraInterface); 174 | menuLayout->addWidget(mConnectionWidget, 0, Qt::AlignTop); 175 | 176 | mRecordWidget = new RecordWidget(mCameraInterface, mUltrasoundInterface, menuWidth, 400); 177 | menuLayout->addWidget(mRecordWidget, 0, Qt::AlignTop); 178 | menuLayout->addStretch(); 179 | 180 | // Quit button 181 | QPushButton* quitButton = new QPushButton; 182 | quitButton->setText("Quit (q)"); 183 | quitButton->setStyleSheet("QPushButton { background-color: red; color: white; }"); 184 | QObject::connect(quitButton, &QPushButton::clicked, std::bind(&Window::stop, this)); 185 | menuLayout->addWidget(quitButton,0,Qt::AlignBottom); 186 | 187 | QHBoxLayout* layout = new QHBoxLayout; 188 | layout->addLayout(menuLayout); 189 | layout->addWidget(viewUS); 190 | 191 | QWidget* imageWidget = new QWidget; 192 | QVBoxLayout* vLayout = new QVBoxLayout; 193 | imageWidget->setLayout(vLayout); 194 | vLayout->addWidget(view2D); 195 | vLayout->addWidget(view3D); 196 | 197 | layout->addWidget(imageWidget); 198 | mWidget->setLayout(layout); 199 | } 200 | 201 | } -------------------------------------------------------------------------------- /applications/RecordApplication/RecordApplicationGUI.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ECHOBOT_RECORDAPPLICATIONGUI_H 2 | #define ECHOBOT_RECORDAPPLICATIONGUI_H 3 | 4 | #include "EchoBot/Interfaces/Ultrasound/UltrasoundInterface.hpp" 5 | #include "EchoBot/Interfaces/Camera/CameraInterface.hpp" 6 | #include "EchoBot/GUI/Widgets/ConnectionWidget.h" 7 | #include "EchoBot/GUI/Widgets/RecordWidget.h" 8 | 9 | #include "FAST/Visualization/Window.hpp" 10 | #include "FAST/Streamers/Streamer.hpp" 11 | 12 | namespace echobot { 13 | 14 | class RecordApplicationGUI : public Window { 15 | FAST_OBJECT(RecordApplicationGUI) 16 | 17 | private: 18 | RecordApplicationGUI(); 19 | 20 | SharedPointer mCameraInterface; 21 | SharedPointer mUltrasoundInterface; 22 | 23 | ConnectionWidget* mConnectionWidget; 24 | RecordWidget* mRecordWidget; 25 | 26 | void connectToCamera(); 27 | void disconnectFromCamera(); 28 | void stopStreaming(); 29 | void connectToUltrasound(); 30 | void disconnectFromUltrasound(); 31 | void setupUI(); 32 | 33 | bool mCameraPlayback = false; 34 | bool mCameraStreaming = false; 35 | bool mUltrasoundStreaming = false; 36 | 37 | void setupCameraVisualization(); 38 | void setupUltrasoundVisualization(); 39 | void setupConnections(); 40 | 41 | private slots: 42 | void playbackButtonSlot(); 43 | void stopPlaybackButtonSlot(); 44 | }; 45 | 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /applications/RecordApplication/main.cpp: -------------------------------------------------------------------------------- 1 | #include "RecordApplicationGUI.hpp" 2 | 3 | using namespace echobot; 4 | 5 | int main() { 6 | RecordApplicationGUI::pointer window = RecordApplicationGUI::New(); 7 | window->start(); 8 | } -------------------------------------------------------------------------------- /cmake/ExternalFAST.cmake: -------------------------------------------------------------------------------- 1 | # Download and set up Eigen 2 | 3 | include(cmake/Externals.cmake) 4 | 5 | ExternalProject_Add(FAST 6 | PREFIX ${ECHOBOT_EXTERNAL_BUILD_DIR}/FAST 7 | BINARY_DIR ${ECHOBOT_EXTERNAL_BUILD_DIR}/FAST 8 | GIT_REPOSITORY "https://github.com/androst/FAST.git" 9 | GIT_TAG "echobot" 10 | CMAKE_ARGS 11 | -DFAST_MODULE_OpenIGTLink=ON 12 | -DFAST_MODULE_RealSense=ON 13 | -DFAST_MODULE_Visualization=ON 14 | -DFAST_MODULE_TensorFlow=ON 15 | -DFAST_BUILD_TensorFlow_CUDA=ON 16 | -DFAST_MODULE_WholeSlideImaging=ON 17 | -DFAST_MODULE_Clarius=ON 18 | -DFAST_BUILD_TOOLS=OFF 19 | -DCLARIUS_SDK_DIR=${CLARIUS_SDK_DIR} 20 | CMAKE_CACHE_ARGS 21 | -DOpenCL_INCLUDE_DIR:PATH=${OpenCL_INCLUDE_DIR} 22 | -DOpenCL_LIBRARY:PATH=${OpenCL_LIBRARY} 23 | -DCMAKE_INSTALL_PREFIX:PATH=${ECHOBOT_EXTERNAL_BUILD_DIR} 24 | -DCMAKE_BUILD_TYPE:STRING=Release 25 | -DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF 26 | -DCMAKE_INSTALL_MESSAGE:BOOL=LAZY 27 | ) 28 | 29 | if(WIN32) 30 | set(FAST_LIBRARY FAST.lib) 31 | else() 32 | set(FAST_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}FAST${CMAKE_SHARED_LIBRARY_SUFFIX}) 33 | set(FAST_INCLUDE_DIR ${ECHOBOT_EXTERNAL_BUILD_DIR}/FAST/fast/include) 34 | set(FAST_LIBRARY_DIR ${ECHOBOT_EXTERNAL_BUILD_DIR}/FAST/lib) 35 | link_directories(${FAST_LIBRARY_DIR}) 36 | endif() 37 | 38 | list(APPEND ECHOBOT_INCLUDE_DIRS ${FAST_INCLUDE_DIR}) 39 | list(APPEND ECHOBOT_INCLUDE_DIRS ${OpenCL_INCLUDE_DIR}) 40 | list(APPEND LIBRARIES ${FAST_LIBRARY} pthread) 41 | list(APPEND ECHOBOT_EXTERNAL_DEPENDENCIES FAST) -------------------------------------------------------------------------------- /cmake/ExternalFMT.cmake: -------------------------------------------------------------------------------- 1 | include(cmake/Externals.cmake) 2 | 3 | ExternalProject_Add(fmt 4 | PREFIX ${ECHOBOT_EXTERNAL_BUILD_DIR}/fmt 5 | BINARY_DIR ${ECHOBOT_EXTERNAL_BUILD_DIR}/fmt 6 | GIT_REPOSITORY "https://github.com/fmtlib/fmt.git" 7 | GIT_TAG "6.1.2" 8 | CMAKE_CACHE_ARGS 9 | -DBUILD_SHARED_LIBS:BOOL=TRUE 10 | -DCMAKE_BUILD_TYPE:STRING=Release 11 | -DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF 12 | -DCMAKE_INSTALL_MESSAGE:BOOL=LAZY 13 | -DCMAKE_INSTALL_PREFIX:PATH=${ECHOBOT_EXTERNAL_INSTALL_DIR} 14 | ) 15 | 16 | if(WIN32) 17 | set(FMT_LIBRARY fmt.lib) 18 | else() 19 | set(FMT_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}fmt${CMAKE_SHARED_LIBRARY_SUFFIX}) 20 | set(FMT_INCLUDE_DIRS ${ECHOBOT_EXTERNAL_BUILD_DIR}/fmt/include ${ECHOBOT_EXTERNAL_BUILD_DIR}/fmt ${ECHOBOT_EXTERNAL_BUILD_DIR}/fmt/src/fmt/source) 21 | set(FMT_LIBRARY_DIR ${ECHOBOT_EXTERNAL_BUILD_DIR}/fmt/lib) 22 | link_directories(${FMT_LIBRARY_DIR}) 23 | endif() 24 | 25 | list(APPEND ECHOBOT_INCLUDE_DIRS ${FMT_INCLUDE_DIRS}) 26 | list(APPEND LIBRARIES ${FMT_LIBRARY}) 27 | list(APPEND ECHOBOT_EXTERNAL_DEPENDENCIES fmt) -------------------------------------------------------------------------------- /cmake/ExternalQt5.cmake: -------------------------------------------------------------------------------- 1 | # Download and build Qt5 2 | 3 | include(cmake/Externals.cmake) 4 | 5 | # List of modules can be found in git repo here: github.com/qt/qt5 6 | set(MODULES_TO_EXCLUDE 7 | -skip qt3d 8 | -skip qtactiveqt 9 | -skip qtandroidextras 10 | -skip qtcanvas3d 11 | -skip qtcharts 12 | -skip qtconnectivity 13 | -skip qtdatavis3d 14 | -skip qtdeclarative 15 | -skip qtdoc 16 | -skip qtdocgallery 17 | -skip qtfeedback 18 | -skip qtgamepad 19 | -skip qtgraphicaleffects 20 | -skip qtimageformats 21 | -skip qtlocation 22 | -skip qtlottie 23 | -skip qtmacextras 24 | -skip qtnetworkauth 25 | -skip qtpim 26 | -skip qtpurchasing 27 | -skip qtqa 28 | -skip qtquick3d 29 | -skip qtquickcontrols 30 | -skip qtquickcontrols2 31 | -skip qtquicktimeline 32 | -skip qtremoteobjects 33 | -skip qtrepotools 34 | -skip qtscript 35 | -skip qtscxml 36 | -skip qtsensors 37 | -skip qtserialbus 38 | -skip qtserialport 39 | -skip qtspeech 40 | -skip qtsvg 41 | -skip qtsystems 42 | -skip qttools 43 | -skip qttranslations 44 | -skip qtvirtualkeyboard 45 | -skip qtwayland 46 | -skip qtwebchannel 47 | -skip qtwebengine 48 | -skip qtwebglplugin 49 | -skip qtwebsockets 50 | -skip qtwebview 51 | -skip qtwinextras 52 | -skip qtx11extras 53 | -skip qtxmlpatterns 54 | ) 55 | 56 | if(WIN32) 57 | #set(BUILD_COMMAND set CL=/MP; nmake) 58 | set(BUILD_COMMAND nmake) 59 | set(CONFIGURE_COMMAND ${ECHOBOT_EXTERNAL_BUILD_DIR}/qt5/src/qt5/configure.bat) 60 | set(URL "http://download.qt.io/archive/qt/5.9/5.9.4/single/qt-everywhere-opensource-src-5.9.4.zip") 61 | set(URL_HASH SHA256=37c5347e3c98a2ac02c2368cd5d9af0bb2c8f2f4632306188238db4f8c644f08) 62 | set(OPTIONS 63 | -opensource; 64 | -confirm-license; 65 | -release; 66 | -no-compile-examples; 67 | -no-openssl; 68 | -no-libproxy; 69 | -nomake tools; 70 | -nomake tests; 71 | -opengl desktop; 72 | -qt-zlib; 73 | -qt-libpng; 74 | -qt-libjpeg; 75 | -qt-freetype; 76 | ${MODULES_TO_EXCLUDE} 77 | ) 78 | else() 79 | set(BUILD_COMMAND make -j4) 80 | set(CONFIGURE_COMMAND ${ECHOBOT_EXTERNAL_BUILD_DIR}/qt5/src/qt5/configure) 81 | set(URL "http://download.qt.io/archive/qt/5.14/5.14.0/single/qt-everywhere-src-5.14.0.tar.xz") 82 | set(URL_HASH SHA256=be9a77cd4e1f9d70b58621d0753be19ea498e6b0da0398753e5038426f76a8ba) 83 | if(APPLE) 84 | set(OPTIONS 85 | -opensource; 86 | -confirm-license; 87 | -release; 88 | -no-compile-examples; 89 | -no-openssl; 90 | -no-libproxy; 91 | -nomake tools; 92 | -nomake tests; 93 | -opengl desktop; 94 | -qt-zlib; 95 | -qt-libpng; 96 | -qt-libjpeg; 97 | -no-directfb; 98 | -no-framework; 99 | ${MODULES_TO_EXCLUDE} 100 | ) 101 | else() 102 | set(OPTIONS 103 | -opensource; 104 | -confirm-license; 105 | -release; 106 | -no-compile-examples; 107 | -no-openssl; 108 | -no-libproxy; 109 | -nomake tools; 110 | -nomake tests; 111 | -opengl desktop; 112 | -qt-zlib; 113 | -qt-libpng; 114 | -qt-libjpeg; 115 | -qt-freetype; 116 | -qt-harfbuzz; 117 | -qt-pcre; 118 | -qt-xcb; 119 | -no-directfb; 120 | -no-linuxfb; 121 | ${MODULES_TO_EXCLUDE} 122 | ) 123 | endif() 124 | endif() 125 | 126 | ExternalProject_Add(qt5 127 | PREFIX ${ECHOBOT_EXTERNAL_BUILD_DIR}/qt5 128 | BINARY_DIR ${ECHOBOT_EXTERNAL_BUILD_DIR}/qt5 129 | URL ${URL} 130 | URL_HASH ${URL_HASH} 131 | CONFIGURE_COMMAND 132 | ${CONFIGURE_COMMAND} 133 | -prefix ${ECHOBOT_EXTERNAL_INSTALL_DIR}; 134 | ${OPTIONS} 135 | BUILD_COMMAND 136 | ${BUILD_COMMAND} 137 | INSTALL_COMMAND 138 | ${BUILD_COMMAND} install 139 | ) 140 | 141 | if(WIN32) 142 | set(Qt5Gui_LIBRARY Qt5Gui.lib) 143 | set(Qt5Core_LIBRARY Qt5Core.lib) 144 | set(Qt5Widgets_LIBRARY Qt5Widgets.lib) 145 | set(Qt5OpenGL_LIBRARY Qt5OpenGL.lib) 146 | set(Qt5Multimedia_LIBRARY Qt5Multimedia.lib) 147 | set(Qt5MultimediaWidgets_LIBRARY Qt5MultimediaWidgets.lib) 148 | set(Qt5Network_LIBRARY Qt5Network.lib) 149 | else() 150 | set(Qt5Gui_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}Qt5Gui${CMAKE_SHARED_LIBRARY_SUFFIX}) 151 | set(Qt5Core_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}Qt5Core${CMAKE_SHARED_LIBRARY_SUFFIX}) 152 | set(Qt5Widgets_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}Qt5Widgets${CMAKE_SHARED_LIBRARY_SUFFIX}) 153 | set(Qt5OpenGL_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}Qt5OpenGL${CMAKE_SHARED_LIBRARY_SUFFIX}) 154 | set(Qt5Multimedia_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}Qt5Multimedia${CMAKE_SHARED_LIBRARY_SUFFIX}) 155 | set(Qt5MultimediaWidgets_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}Qt5MultimediaWidgets${CMAKE_SHARED_LIBRARY_SUFFIX}) 156 | set(Qt5Core_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}Qt5Core${CMAKE_SHARED_LIBRARY_SUFFIX}) 157 | set(Qt5Network_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}Qt5Network${CMAKE_SHARED_LIBRARY_SUFFIX}) 158 | endif() 159 | 160 | list(APPEND ECHOBOT_EXTERNAL_DEPENDENCIES qt5) 161 | -------------------------------------------------------------------------------- /cmake/ExternalRomocc.cmake: -------------------------------------------------------------------------------- 1 | # Download and set up Eigen 2 | 3 | include(cmake/Externals.cmake) 4 | 5 | ExternalProject_Add(romocc 6 | PREFIX ${ECHOBOT_EXTERNAL_BUILD_DIR}/romocc 7 | BINARY_DIR ${ECHOBOT_EXTERNAL_BUILD_DIR}/romocc 8 | GIT_REPOSITORY "https://github.com/SINTEFMedtek/libromocc.git" 9 | GIT_TAG "0.0.4" 10 | CMAKE_ARGS 11 | -DROMOCC_BUILD_TESTS:BOOL=OFF 12 | -DROMOCC_BUILD_EXAMPLES:BOOL=OFF 13 | -DROMOCC_BUILD_URSIMULATOR:BOOL=OFF 14 | CMAKE_CACHE_ARGS 15 | -DCMAKE_BUILD_TYPE:STRING=Release 16 | -DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF 17 | -DCMAKE_INSTALL_MESSAGE:BOOL=LAZY 18 | -DCMAKE_INSTALL_PREFIX:PATH=${ECHOBOT_EXTERNAL_INSTALL_DIR} 19 | ) 20 | 21 | if(WIN32) 22 | set(ROMOCC_LIBRARY romocc.lib) 23 | else() 24 | set(ROMOCC_LIBRARY ${CMAKE_SHARED_LIBRARY_PREFIX}romocc${CMAKE_SHARED_LIBRARY_SUFFIX}) 25 | set(ROMOCC_INCLUDE_DIRS ${ECHOBOT_EXTERNAL_BUILD_DIR}/romocc/include ${ECHOBOT_EXTERNAL_BUILD_DIR}/romocc ${ECHOBOT_EXTERNAL_BUILD_DIR}/romocc/src/romocc/source) 26 | set(ROMOCC_LIBRARY_DIR ${ECHOBOT_EXTERNAL_BUILD_DIR}/romocc/lib) 27 | link_directories(${ROMOCC_LIBRARY_DIR}) 28 | endif() 29 | 30 | list(APPEND ECHOBOT_INCLUDE_DIRS ${ROMOCC_INCLUDE_DIRS}) 31 | list(APPEND LIBRARIES ${ROMOCC_LIBRARY}) 32 | list(APPEND ECHOBOT_EXTERNAL_DEPENDENCIES romocc) -------------------------------------------------------------------------------- /cmake/Externals.cmake: -------------------------------------------------------------------------------- 1 | include(ExternalProject) 2 | 3 | set(ECHOBOT_DOWNLOAD_DIR ${PROJECT_SOURCE_DIR}/external/) 4 | set(ECHOBOT_EXTERNAL_BUILD_DIR ${PROJECT_BINARY_DIR}/external) 5 | set(ECHOBOT_EXTERNAL_INSTALL_DIR ${PROJECT_BINARY_DIR}) 6 | -------------------------------------------------------------------------------- /cmake/InstallFiles/qt.conf: -------------------------------------------------------------------------------- 1 | [Paths] 2 | Prefix=../ 3 | Libraries=lib 4 | Plugins=QtPlugins 5 | -------------------------------------------------------------------------------- /cmake/Macros.cmake: -------------------------------------------------------------------------------- 1 | #### Macro for adding source files and directories 2 | macro (project_add_sources) 3 | file (RELATIVE_PATH _relPath "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}") 4 | foreach (_src ${ARGN}) 5 | if (_relPath) 6 | list (APPEND ECHOBOT_SOURCE_FILES "${_relPath}/${_src}") 7 | else() 8 | list (APPEND ECHOBOT_SOURCE_FILES "${_src}") 9 | endif() 10 | endforeach() 11 | if (_relPath) 12 | # propagate ECHOBOT_SOURCE_FILES to parent directory 13 | set (ECHOBOT_SOURCE_FILES ${ECHOBOT_SOURCE_FILES} PARENT_SCOPE) 14 | endif() 15 | endmacro() 16 | 17 | #### Macro for adding subdirectories 18 | macro (project_add_subdirectories) 19 | file (RELATIVE_PATH _relPath "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}") 20 | foreach (_src ${ARGN}) 21 | add_subdirectory(${_src}) 22 | endforeach() 23 | if (_relPath) 24 | # propagate to parent directory 25 | set (ECHOBOT_TEST_SOURCE_FILES ${ECHOBOT_TEST_SOURCE_FILES} PARENT_SCOPE) 26 | set (ECHOBOT_SOURCE_FILES ${ECHOBOT_SOURCE_FILES} PARENT_SCOPE) 27 | set (ECHOBOT_APPS ${ECHOBOT_APPS} PARENT_SCOPE) 28 | endif() 29 | endmacro() 30 | 31 | macro (project_add_test_sources) 32 | file (RELATIVE_PATH _relPath "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}") 33 | foreach (_src ${ARGN}) 34 | if (_relPath) 35 | list (APPEND ECHOBOT_TEST_SOURCE_FILES "${_relPath}/${_src}") 36 | else() 37 | list (APPEND ECHOBOT_TEST_SOURCE_FILES "${_src}") 38 | endif() 39 | endforeach() 40 | if (_relPath) 41 | # propagate ECHOBOT_TEST_SOURCE_FILES to parent directory 42 | set (ECHOBOT_TEST_SOURCE_FILES ${ECHOBOT_TEST_SOURCE_FILES} PARENT_SCOPE) 43 | endif() 44 | endmacro() 45 | 46 | ### Macro for add application 47 | macro (project_add_application NAME) 48 | list(APPEND ECHOBOT_APPS ${NAME}) 49 | add_executable(${NAME} ${ARGN}) 50 | target_link_libraries(${NAME} EchoBot) 51 | install(TARGETS ${NAME} 52 | DESTINATION echobot/bin 53 | ) 54 | file (RELATIVE_PATH _relPath "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}") 55 | if(_relPath) 56 | # propagate to parent directory 57 | set(ECHOBOT_APPS ${ECHOBOT_APPS} PARENT_SCOPE) 58 | endif() 59 | endmacro() 60 | -------------------------------------------------------------------------------- /cmake/Qt5Core/Qt5CTestMacros.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # W A R N I N G 3 | # ------------- 4 | # 5 | # This file is not part of the Qt API. It exists purely as an 6 | # implementation detail. This file, and its contents may change from version to 7 | # version without notice, or even be removed. 8 | # 9 | # We mean it. 10 | 11 | message("CMAKE_VERSION: ${CMAKE_VERSION}") 12 | message("CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}") 13 | message("CMAKE_MODULES_UNDER_TEST: ${CMAKE_MODULES_UNDER_TEST}") 14 | foreach(_mod ${CMAKE_MODULES_UNDER_TEST}) 15 | message("CMAKE_${_mod}_MODULE_MAJOR_VERSION: ${CMAKE_${_mod}_MODULE_MAJOR_VERSION}") 16 | message("CMAKE_${_mod}_MODULE_MINOR_VERSION: ${CMAKE_${_mod}_MODULE_MINOR_VERSION}") 17 | message("CMAKE_${_mod}_MODULE_PATCH_VERSION: ${CMAKE_${_mod}_MODULE_PATCH_VERSION}") 18 | endforeach() 19 | 20 | set(BUILD_OPTIONS_LIST) 21 | 22 | if (CMAKE_C_COMPILER) 23 | list(APPEND BUILD_OPTIONS_LIST "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}") 24 | endif() 25 | 26 | if (CMAKE_CXX_COMPILER) 27 | list(APPEND BUILD_OPTIONS_LIST "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}") 28 | endif() 29 | 30 | if (CMAKE_BUILD_TYPE) 31 | list(APPEND BUILD_OPTIONS_LIST "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") 32 | endif() 33 | 34 | if (CMAKE_TOOLCHAIN_FILE) 35 | list(APPEND BUILD_OPTIONS_LIST "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") 36 | endif() 37 | 38 | if (CMAKE_VERBOSE_MAKEFILE) 39 | list(APPEND BUILD_OPTIONS_LIST "-DCMAKE_VERBOSE_MAKEFILE=1") 40 | endif() 41 | 42 | if (NO_GUI) 43 | list(APPEND BUILD_OPTIONS_LIST "-DNO_GUI=True") 44 | endif() 45 | if (NO_WIDGETS) 46 | list(APPEND BUILD_OPTIONS_LIST "-DNO_WIDGETS=True") 47 | endif() 48 | if (NO_DBUS) 49 | list(APPEND BUILD_OPTIONS_LIST "-DNO_DBUS=True") 50 | endif() 51 | 52 | # Qt requires C++11 features in header files, which means 53 | # the buildsystem needs to add a -std flag for certain compilers 54 | # CMake adds the flag automatically in most cases, but notably not 55 | # on Windows prior to CMake 3.3 56 | if (CMAKE_VERSION VERSION_LESS 3.3) 57 | if (CMAKE_CXX_COMPILER_ID STREQUAL AppleClang 58 | OR (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)) 59 | list(APPEND BUILD_OPTIONS_LIST "-DCMAKE_CXX_FLAGS=-std=gnu++0x -stdlib=libc++") 60 | elseif (CMAKE_CXX_COMPILER_ID STREQUAL GNU 61 | OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) 62 | list(APPEND BUILD_OPTIONS_LIST "-DCMAKE_CXX_FLAGS=-std=gnu++0x") 63 | endif() 64 | endif() 65 | 66 | foreach(module ${CMAKE_MODULES_UNDER_TEST}) 67 | list(APPEND BUILD_OPTIONS_LIST 68 | "-DCMAKE_${module}_MODULE_MAJOR_VERSION=${CMAKE_${module}_MODULE_MAJOR_VERSION}" 69 | "-DCMAKE_${module}_MODULE_MINOR_VERSION=${CMAKE_${module}_MODULE_MINOR_VERSION}" 70 | "-DCMAKE_${module}_MODULE_PATCH_VERSION=${CMAKE_${module}_MODULE_PATCH_VERSION}" 71 | ) 72 | endforeach() 73 | 74 | macro(expect_pass _dir) 75 | cmake_parse_arguments(_ARGS "" "BINARY" "" ${ARGN}) 76 | string(REPLACE "(" "_" testname "${_dir}") 77 | string(REPLACE ")" "_" testname "${testname}") 78 | add_test(${testname} ${CMAKE_CTEST_COMMAND} 79 | --build-and-test 80 | "${CMAKE_CURRENT_SOURCE_DIR}/${_dir}" 81 | "${CMAKE_CURRENT_BINARY_DIR}/${_dir}" 82 | --build-config "${CMAKE_BUILD_TYPE}" 83 | --build-generator ${CMAKE_GENERATOR} 84 | --build-makeprogram ${CMAKE_MAKE_PROGRAM} 85 | --build-project ${_dir} 86 | --build-options "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ${BUILD_OPTIONS_LIST} 87 | --test-command ${_ARGS_BINARY} 88 | ) 89 | endmacro() 90 | 91 | macro(expect_fail _dir) 92 | string(REPLACE "(" "_" testname "${_dir}") 93 | string(REPLACE ")" "_" testname "${testname}") 94 | file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}") 95 | file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/${_dir}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}") 96 | 97 | file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}/${_dir}/FindPackageHints.cmake" "set(Qt5Tests_PREFIX_PATH \"${CMAKE_PREFIX_PATH}\")") 98 | 99 | file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}/CMakeLists.txt" 100 | " 101 | cmake_minimum_required(VERSION 2.8) 102 | project(${_dir}) 103 | 104 | try_compile(Result \${CMAKE_CURRENT_BINARY_DIR}/${_dir} 105 | \${CMAKE_CURRENT_SOURCE_DIR}/${_dir} 106 | ${_dir} 107 | OUTPUT_VARIABLE Out 108 | ) 109 | message(\"\${Out}\") 110 | if (Result) 111 | message(SEND_ERROR \"Succeeded build which should fail\") 112 | endif() 113 | " 114 | ) 115 | add_test(${testname} ${CMAKE_CTEST_COMMAND} 116 | --build-and-test 117 | "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}" 118 | "${CMAKE_CURRENT_BINARY_DIR}/failbuild/${_dir}/build" 119 | --build-config "${CMAKE_BUILD_TYPE}" 120 | --build-generator ${CMAKE_GENERATOR} 121 | --build-makeprogram ${CMAKE_MAKE_PROGRAM} 122 | --build-project ${_dir} 123 | --build-options "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ${BUILD_OPTIONS_LIST} 124 | ) 125 | endmacro() 126 | 127 | function(test_module_includes) 128 | 129 | set(all_args ${ARGN}) 130 | set(packages_string "") 131 | set(libraries_string "") 132 | 133 | foreach(_package ${Qt5_MODULE_TEST_DEPENDS}) 134 | set(packages_string 135 | " 136 | ${packages_string} 137 | find_package(Qt5${_package} 5.0.0 REQUIRED) 138 | " 139 | ) 140 | endforeach() 141 | 142 | while(all_args) 143 | list(GET all_args 0 qtmodule) 144 | list(REMOVE_AT all_args 0 1) 145 | 146 | set(CMAKE_MODULE_VERSION ${CMAKE_${qtmodule}_MODULE_MAJOR_VERSION}.${CMAKE_${qtmodule}_MODULE_MINOR_VERSION}.${CMAKE_${qtmodule}_MODULE_PATCH_VERSION} ) 147 | 148 | set(packages_string 149 | "${packages_string} 150 | find_package(Qt5${qtmodule} 5.0.0 REQUIRED) 151 | include_directories(\${Qt5${qtmodule}_INCLUDE_DIRS}) 152 | add_definitions(\${Qt5${qtmodule}_DEFINITIONS})\n") 153 | 154 | list(FIND CMAKE_MODULES_UNDER_TEST ${qtmodule} _findIndex) 155 | if (NOT _findIndex STREQUAL -1) 156 | set(packages_string 157 | "${packages_string} 158 | if(NOT \"\${Qt5${qtmodule}_VERSION}\" VERSION_EQUAL ${CMAKE_MODULE_VERSION}) 159 | message(SEND_ERROR \"Qt5${qtmodule}_VERSION variable was not ${CMAKE_MODULE_VERSION}. Got \${Qt5${qtmodule}_VERSION} instead.\") 160 | endif() 161 | if(NOT \"\${Qt5${qtmodule}_VERSION_MAJOR}\" VERSION_EQUAL ${CMAKE_${qtmodule}_MODULE_MAJOR_VERSION}) 162 | message(SEND_ERROR \"Qt5${qtmodule}_VERSION_MAJOR variable was not ${CMAKE_${qtmodule}_MODULE_MAJOR_VERSION}. Got \${Qt5${qtmodule}_VERSION_MAJOR} instead.\") 163 | endif() 164 | if(NOT \"\${Qt5${qtmodule}_VERSION_MINOR}\" VERSION_EQUAL ${CMAKE_${qtmodule}_MODULE_MINOR_VERSION}) 165 | message(SEND_ERROR \"Qt5${qtmodule}_VERSION_MINOR variable was not ${CMAKE_${qtmodule}_MODULE_MINOR_VERSION}. Got \${Qt5${qtmodule}_VERSION_MINOR} instead.\") 166 | endif() 167 | if(NOT \"\${Qt5${qtmodule}_VERSION_PATCH}\" VERSION_EQUAL ${CMAKE_${qtmodule}_MODULE_PATCH_VERSION}) 168 | message(SEND_ERROR \"Qt5${qtmodule}_VERSION_PATCH variable was not ${CMAKE_${qtmodule}_MODULE_PATCH_VERSION}. Got \${Qt5${qtmodule}_VERSION_PATCH} instead.\") 169 | endif() 170 | if(NOT \"\${Qt5${qtmodule}_VERSION_STRING}\" VERSION_EQUAL ${CMAKE_MODULE_VERSION}) 171 | message(SEND_ERROR \"Qt5${qtmodule}_VERSION_STRING variable was not ${CMAKE_MODULE_VERSION}. Got \${Qt5${qtmodule}_VERSION_STRING} instead.\") 172 | endif()\n" 173 | ) 174 | endif() 175 | set(libraries_string "${libraries_string} Qt5::${qtmodule}") 176 | endwhile() 177 | 178 | file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/module_includes/CMakeLists.txt" 179 | " 180 | cmake_minimum_required(VERSION 2.8) 181 | project(module_includes) 182 | 183 | ${packages_string} 184 | 185 | set(CMAKE_CXX_FLAGS \"\${CMAKE_CXX_FLAGS} \${Qt5Core_EXECUTABLE_COMPILE_FLAGS}\") 186 | if (CMAKE_VERSION VERSION_LESS 3.3) 187 | if (CMAKE_CXX_COMPILER_ID STREQUAL AppleClang 188 | OR (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)) 189 | set(CMAKE_CXX_FLAGS \"\${CMAKE_CXX_FLAGS} -std=gnu++0x -stdlib=libc++\") 190 | elseif (CMAKE_CXX_COMPILER_ID STREQUAL GNU 191 | OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) 192 | set(CMAKE_CXX_FLAGS \"\${CMAKE_CXX_FLAGS} -std=gnu++0x\") 193 | endif() 194 | endif() 195 | 196 | add_executable(module_includes_exe \"\${CMAKE_CURRENT_SOURCE_DIR}/main.cpp\") 197 | target_link_libraries(module_includes_exe ${libraries_string})\n" 198 | ) 199 | 200 | set(all_args ${ARGN}) 201 | set(includes_string "") 202 | set(instances_string "") 203 | while(all_args) 204 | list(GET all_args 0 qtmodule) 205 | list(GET all_args 1 qtclass) 206 | if (${qtclass}_NAMESPACE) 207 | set(qtinstancetype ${${qtclass}_NAMESPACE}::${qtclass}) 208 | else() 209 | set(qtinstancetype ${qtclass}) 210 | endif() 211 | list(REMOVE_AT all_args 0 1) 212 | set(includes_string 213 | "${includes_string} 214 | #include <${qtclass}> 215 | #include 216 | #include 217 | #include " 218 | ) 219 | set(instances_string 220 | "${instances_string} 221 | ${qtinstancetype} local${qtclass}; 222 | ") 223 | endwhile() 224 | 225 | file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/module_includes/main.cpp" 226 | " 227 | 228 | ${includes_string} 229 | 230 | int main(int, char **) { ${instances_string} return 0; }\n" 231 | ) 232 | 233 | add_test(module_includes ${CMAKE_CTEST_COMMAND} 234 | --build-and-test 235 | "${CMAKE_CURRENT_BINARY_DIR}/module_includes/" 236 | "${CMAKE_CURRENT_BINARY_DIR}/module_includes/build" 237 | --build-config "${CMAKE_BUILD_TYPE}" 238 | --build-generator ${CMAKE_GENERATOR} 239 | --build-makeprogram ${CMAKE_MAKE_PROGRAM} 240 | --build-project module_includes 241 | --build-options "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" ${BUILD_OPTIONS_LIST} 242 | ) 243 | endfunction() 244 | -------------------------------------------------------------------------------- /cmake/Qt5Core/Qt5CoreConfig.cmake: -------------------------------------------------------------------------------- 1 | 2 | if (CMAKE_VERSION VERSION_LESS 2.8.3) 3 | message(FATAL_ERROR "Qt 5 requires at least CMake version 2.8.3") 4 | endif() 5 | 6 | get_filename_component(_qt5Core_install_prefix "${ECHOBOT_EXTERNAL_INSTALL_DIR}" ABSOLUTE) 7 | 8 | # For backwards compatibility only. Use Qt5Core_VERSION instead. 9 | set(Qt5Core_VERSION_STRING 5.8.0) 10 | 11 | set(Qt5Core_LIBRARIES Qt5::Core) 12 | 13 | macro(_qt5_Core_check_file_exists file) 14 | #if(NOT EXISTS "${file}" ) 15 | # message(FATAL_ERROR "The imported target \"Qt5::Core\" references the file 16 | #\"${file}\" 17 | #but this file does not exist. Possible reasons include: 18 | #* The file was deleted, renamed, or moved to another location. 19 | #* An install or uninstall procedure did not complete successfully. 20 | #* The installation package was faulty and contained 21 | # \"${CMAKE_CURRENT_LIST_FILE}\" 22 | #but not all the files it references. 23 | #") 24 | # endif() 25 | endmacro() 26 | 27 | macro(_populate_Core_target_properties Configuration LIB_LOCATION IMPLIB_LOCATION) 28 | set_property(TARGET Qt5::Core APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration}) 29 | 30 | set(imported_location "${_qt5Core_install_prefix}/lib/${LIB_LOCATION}") 31 | _qt5_Core_check_file_exists(${imported_location}) 32 | set_target_properties(Qt5::Core PROPERTIES 33 | "INTERFACE_LINK_LIBRARIES" "${_Qt5Core_LIB_DEPENDENCIES}" 34 | "IMPORTED_LOCATION_${Configuration}" ${imported_location} 35 | "IMPORTED_SONAME_${Configuration}" "libQt5Core.so.5" 36 | # For backward compatibility with CMake < 2.8.12 37 | "IMPORTED_LINK_INTERFACE_LIBRARIES_${Configuration}" "${_Qt5Core_LIB_DEPENDENCIES}" 38 | ) 39 | 40 | endmacro() 41 | 42 | if (NOT TARGET Qt5::Core) 43 | 44 | set(_Qt5Core_OWN_INCLUDE_DIRS "${_qt5Core_install_prefix}/include/" "${_qt5Core_install_prefix}/include/QtCore") 45 | set(Qt5Core_PRIVATE_INCLUDE_DIRS "") 46 | include("${CMAKE_CURRENT_LIST_DIR}/ExtraSourceIncludes.cmake" OPTIONAL) 47 | 48 | foreach(_dir ${_Qt5Core_OWN_INCLUDE_DIRS}) 49 | _qt5_Core_check_file_exists(${_dir}) 50 | endforeach() 51 | 52 | # Only check existence of private includes if the Private component is 53 | # specified. 54 | list(FIND Qt5Core_FIND_COMPONENTS Private _check_private) 55 | if (NOT _check_private STREQUAL -1) 56 | foreach(_dir ${Qt5Core_PRIVATE_INCLUDE_DIRS}) 57 | _qt5_Core_check_file_exists(${_dir}) 58 | endforeach() 59 | endif() 60 | 61 | set(Qt5Core_INCLUDE_DIRS ${_Qt5Core_OWN_INCLUDE_DIRS}) 62 | 63 | set(Qt5Core_DEFINITIONS -DQT_CORE_LIB) 64 | set(Qt5Core_COMPILE_DEFINITIONS QT_CORE_LIB) 65 | set(_Qt5Core_MODULE_DEPENDENCIES "") 66 | 67 | 68 | set(_Qt5Core_FIND_DEPENDENCIES_REQUIRED) 69 | if (Qt5Core_FIND_REQUIRED) 70 | set(_Qt5Core_FIND_DEPENDENCIES_REQUIRED REQUIRED) 71 | endif() 72 | set(_Qt5Core_FIND_DEPENDENCIES_QUIET) 73 | if (Qt5Core_FIND_QUIETLY) 74 | set(_Qt5Core_DEPENDENCIES_FIND_QUIET QUIET) 75 | endif() 76 | set(_Qt5Core_FIND_VERSION_EXACT) 77 | if (Qt5Core_FIND_VERSION_EXACT) 78 | set(_Qt5Core_FIND_VERSION_EXACT EXACT) 79 | endif() 80 | 81 | set(Qt5Core_EXECUTABLE_COMPILE_FLAGS "") 82 | 83 | foreach(_module_dep ${_Qt5Core_MODULE_DEPENDENCIES}) 84 | if (NOT Qt5${_module_dep}_FOUND) 85 | find_package(Qt5${_module_dep} 86 | 5.8.0 ${_Qt5Core_FIND_VERSION_EXACT} 87 | ${_Qt5Core_DEPENDENCIES_FIND_QUIET} 88 | ${_Qt5Core_FIND_DEPENDENCIES_REQUIRED} 89 | PATHS "${CMAKE_CURRENT_LIST_DIR}/.." NO_DEFAULT_PATH 90 | ) 91 | endif() 92 | 93 | if (NOT Qt5${_module_dep}_FOUND) 94 | set(Qt5Core_FOUND False) 95 | return() 96 | endif() 97 | 98 | list(APPEND Qt5Core_INCLUDE_DIRS "${Qt5${_module_dep}_INCLUDE_DIRS}") 99 | list(APPEND Qt5Core_PRIVATE_INCLUDE_DIRS "${Qt5${_module_dep}_PRIVATE_INCLUDE_DIRS}") 100 | list(APPEND Qt5Core_DEFINITIONS ${Qt5${_module_dep}_DEFINITIONS}) 101 | list(APPEND Qt5Core_COMPILE_DEFINITIONS ${Qt5${_module_dep}_COMPILE_DEFINITIONS}) 102 | list(APPEND Qt5Core_EXECUTABLE_COMPILE_FLAGS ${Qt5${_module_dep}_EXECUTABLE_COMPILE_FLAGS}) 103 | endforeach() 104 | list(REMOVE_DUPLICATES Qt5Core_INCLUDE_DIRS) 105 | list(REMOVE_DUPLICATES Qt5Core_PRIVATE_INCLUDE_DIRS) 106 | list(REMOVE_DUPLICATES Qt5Core_DEFINITIONS) 107 | list(REMOVE_DUPLICATES Qt5Core_COMPILE_DEFINITIONS) 108 | list(REMOVE_DUPLICATES Qt5Core_EXECUTABLE_COMPILE_FLAGS) 109 | 110 | set(_Qt5Core_LIB_DEPENDENCIES "") 111 | 112 | 113 | add_library(Qt5::Core SHARED IMPORTED) 114 | 115 | #set_property(TARGET Qt5::Core PROPERTY 116 | # INTERFACE_INCLUDE_DIRECTORIES ${_Qt5Core_OWN_INCLUDE_DIRS}) 117 | set_property(TARGET Qt5::Core PROPERTY 118 | INTERFACE_COMPILE_DEFINITIONS QT_CORE_LIB) 119 | 120 | _populate_Core_target_properties(RELEASE "libQt5Core.so.5.8.0" "" ) 121 | 122 | 123 | 124 | 125 | file(GLOB pluginTargets "${CMAKE_CURRENT_LIST_DIR}/Qt5Core_*Plugin.cmake") 126 | 127 | macro(_populate_Core_plugin_properties Plugin Configuration PLUGIN_LOCATION) 128 | set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration}) 129 | 130 | set(imported_location "${_qt5Core_install_prefix}/plugins/${PLUGIN_LOCATION}") 131 | _qt5_Core_check_file_exists(${imported_location}) 132 | set_target_properties(Qt5::${Plugin} PROPERTIES 133 | "IMPORTED_LOCATION_${Configuration}" ${imported_location} 134 | ) 135 | endmacro() 136 | 137 | if (pluginTargets) 138 | foreach(pluginTarget ${pluginTargets}) 139 | include(${pluginTarget}) 140 | endforeach() 141 | endif() 142 | 143 | 144 | include("${CMAKE_CURRENT_LIST_DIR}/Qt5CoreConfigExtras.cmake") 145 | 146 | include("${CMAKE_CURRENT_LIST_DIR}/Qt5CoreMacros.cmake") 147 | 148 | _qt5_Core_check_file_exists("${CMAKE_CURRENT_LIST_DIR}/Qt5CoreConfigVersion.cmake") 149 | 150 | endif() 151 | -------------------------------------------------------------------------------- /cmake/Qt5Core/Qt5CoreConfigExtras.cmake: -------------------------------------------------------------------------------- 1 | 2 | if (NOT TARGET Qt5::qmake) 3 | add_executable(Qt5::qmake IMPORTED) 4 | 5 | set(imported_location "${_qt5Core_install_prefix}/bin/qmake") 6 | _qt5_Core_check_file_exists(${imported_location}) 7 | 8 | set_target_properties(Qt5::qmake PROPERTIES 9 | IMPORTED_LOCATION ${imported_location} 10 | ) 11 | endif() 12 | 13 | if (NOT TARGET Qt5::moc) 14 | add_executable(Qt5::moc IMPORTED) 15 | 16 | set(imported_location "${_qt5Core_install_prefix}/bin/moc") 17 | _qt5_Core_check_file_exists(${imported_location}) 18 | 19 | set_target_properties(Qt5::moc PROPERTIES 20 | IMPORTED_LOCATION ${imported_location} 21 | ) 22 | # For CMake automoc feature 23 | get_target_property(QT_MOC_EXECUTABLE Qt5::moc LOCATION) 24 | endif() 25 | 26 | if (NOT TARGET Qt5::rcc) 27 | add_executable(Qt5::rcc IMPORTED) 28 | 29 | set(imported_location "${_qt5Core_install_prefix}/bin/rcc") 30 | _qt5_Core_check_file_exists(${imported_location}) 31 | 32 | set_target_properties(Qt5::rcc PROPERTIES 33 | IMPORTED_LOCATION ${imported_location} 34 | ) 35 | endif() 36 | 37 | set(Qt5Core_QMAKE_EXECUTABLE Qt5::qmake) 38 | set(Qt5Core_MOC_EXECUTABLE Qt5::moc) 39 | set(Qt5Core_RCC_EXECUTABLE Qt5::rcc) 40 | 41 | set_property(TARGET Qt5::Core PROPERTY INTERFACE_QT_MAJOR_VERSION 5) 42 | set_property(TARGET Qt5::Core PROPERTY INTERFACE_QT_COORD_TYPE double) 43 | set_property(TARGET Qt5::Core APPEND PROPERTY 44 | COMPATIBLE_INTERFACE_STRING QT_MAJOR_VERSION QT_COORD_TYPE 45 | ) 46 | 47 | include("${CMAKE_CURRENT_LIST_DIR}/Qt5CoreConfigExtrasMkspecDir.cmake") 48 | 49 | foreach(_dir ${_qt5_corelib_extra_includes}) 50 | _qt5_Core_check_file_exists(${_dir}) 51 | endforeach() 52 | 53 | list(APPEND Qt5Core_INCLUDE_DIRS ${_qt5_corelib_extra_includes}) 54 | #set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${_qt5_corelib_extra_includes}) 55 | set(_qt5_corelib_extra_includes) 56 | 57 | # Targets using Qt need to use the POSITION_INDEPENDENT_CODE property. The 58 | # Qt5_POSITION_INDEPENDENT_CODE variable is used in the # qt5_use_module 59 | # macro to add it. 60 | set(Qt5_POSITION_INDEPENDENT_CODE True) 61 | 62 | # On x86 and x86-64 systems with ELF binaries (especially Linux), due to 63 | # a new optimization in GCC 5.x in combination with a recent version of 64 | # GNU binutils, compiling Qt applications with -fPIE is no longer 65 | # enough. 66 | # Applications now need to be compiled with the -fPIC option if the Qt option 67 | # "reduce relocations" is active. For backward compatibility only, Qt accepts 68 | # the use of -fPIE for GCC 4.x versions. 69 | if (CMAKE_VERSION VERSION_LESS 2.8.12 70 | AND (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU" 71 | OR CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)) 72 | set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE "ON") 73 | else() 74 | set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_OPTIONS -fPIC) 75 | endif() 76 | 77 | # Applications using qmake or cmake >= 2.8.12 as their build system will 78 | # adapt automatically. Applications using an older release of cmake in 79 | # combination with GCC 5.x need to change their CMakeLists.txt to add 80 | # Qt5Core_EXECUTABLE_COMPILE_FLAGS to CMAKE_CXX_FLAGS. In particular, 81 | # applications using cmake >= 2.8.9 and < 2.8.11 will continue to build 82 | # with the -fPIE option and invoke the special compatibility mode if using 83 | # GCC 4.x. 84 | set(Qt5Core_EXECUTABLE_COMPILE_FLAGS "") 85 | if (CMAKE_VERSION VERSION_LESS 2.8.12 86 | AND (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" 87 | AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)) 88 | set(Qt5Core_EXECUTABLE_COMPILE_FLAGS "-fPIC") 89 | endif() 90 | 91 | 92 | set(Qt5_DISABLED_FEATURES 93 | cups 94 | imageformat-jpeg 95 | ) 96 | 97 | set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS $<$>:QT_NO_DEBUG>) 98 | 99 | set_property(TARGET Qt5::Core PROPERTY INTERFACE_COMPILE_FEATURES cxx_decltype) 100 | 101 | set(QT_VISIBILITY_AVAILABLE "True") 102 | 103 | 104 | 105 | get_filename_component(_Qt5CoreConfigDir ${CMAKE_CURRENT_LIST_FILE} PATH) 106 | 107 | set(_Qt5CTestMacros "${_Qt5CoreConfigDir}/Qt5CTestMacros.cmake") 108 | 109 | _qt5_Core_check_file_exists(${_Qt5CTestMacros}) 110 | -------------------------------------------------------------------------------- /cmake/Qt5Core/Qt5CoreConfigExtrasMkspecDir.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(_qt5_corelib_extra_includes "${_qt5Core_install_prefix}/external/qt5/src/qt5/qtbase//mkspecs/linux-g++") 3 | -------------------------------------------------------------------------------- /cmake/Qt5Core/Qt5CoreConfigVersion.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(PACKAGE_VERSION 5.8.0) 3 | 4 | if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) 5 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 6 | else() 7 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 8 | if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) 9 | set(PACKAGE_VERSION_EXACT TRUE) 10 | endif() 11 | endif() 12 | -------------------------------------------------------------------------------- /cmake/Qt5Gui/Qt5GuiConfig.cmake: -------------------------------------------------------------------------------- 1 | 2 | if (CMAKE_VERSION VERSION_LESS 2.8.3) 3 | message(FATAL_ERROR "Qt 5 requires at least CMake version 2.8.3") 4 | endif() 5 | 6 | get_filename_component(_qt5Gui_install_prefix "${ECHOBOT_EXTERNAL_INSTALL_DIR}" ABSOLUTE) 7 | 8 | # For backwards compatibility only. Use Qt5Gui_VERSION instead. 9 | set(Qt5Gui_VERSION_STRING 5.8.0) 10 | 11 | set(Qt5Gui_LIBRARIES Qt5::Gui) 12 | 13 | macro(_qt5_Gui_check_file_exists file) 14 | #if(NOT EXISTS "${file}" ) 15 | # message(FATAL_ERROR "The imported target \"Qt5::Gui\" references the file 16 | #\"${file}\" 17 | #but this file does not exist. Possible reasons include: 18 | #* The file was deleted, renamed, or moved to another location. 19 | #* An install or uninstall procedure did not complete successfully. 20 | #* The installation package was faulty and contained 21 | # \"${CMAKE_CURRENT_LIST_FILE}\" 22 | #but not all the files it references. 23 | #") 24 | # endif() 25 | endmacro() 26 | 27 | macro(_populate_Gui_target_properties Configuration LIB_LOCATION IMPLIB_LOCATION) 28 | set_property(TARGET Qt5::Gui APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration}) 29 | 30 | set(imported_location "${_qt5Gui_install_prefix}/lib/${LIB_LOCATION}") 31 | _qt5_Gui_check_file_exists(${imported_location}) 32 | set_target_properties(Qt5::Gui PROPERTIES 33 | "INTERFACE_LINK_LIBRARIES" "${_Qt5Gui_LIB_DEPENDENCIES}" 34 | "IMPORTED_LOCATION_${Configuration}" ${imported_location} 35 | "IMPORTED_SONAME_${Configuration}" "libQt5Gui.so.5" 36 | # For backward compatibility with CMake < 2.8.12 37 | "IMPORTED_LINK_INTERFACE_LIBRARIES_${Configuration}" "${_Qt5Gui_LIB_DEPENDENCIES}" 38 | ) 39 | 40 | endmacro() 41 | 42 | if (NOT TARGET Qt5::Gui) 43 | 44 | set(_Qt5Gui_OWN_INCLUDE_DIRS "${_qt5Gui_install_prefix}/include/" "${_qt5Gui_install_prefix}/include/QtGui") 45 | set(Qt5Gui_PRIVATE_INCLUDE_DIRS "") 46 | include("${CMAKE_CURRENT_LIST_DIR}/ExtraSourceIncludes.cmake" OPTIONAL) 47 | 48 | #foreach(_dir ${_Qt5Gui_OWN_INCLUDE_DIRS}) 49 | # _qt5_Gui_check_file_exists(${_dir}) 50 | #endforeach() 51 | 52 | # Only check existence of private includes if the Private component is 53 | # specified. 54 | list(FIND Qt5Gui_FIND_COMPONENTS Private _check_private) 55 | if (NOT _check_private STREQUAL -1) 56 | foreach(_dir ${Qt5Gui_PRIVATE_INCLUDE_DIRS}) 57 | _qt5_Gui_check_file_exists(${_dir}) 58 | endforeach() 59 | endif() 60 | 61 | set(Qt5Gui_INCLUDE_DIRS ${_Qt5Gui_OWN_INCLUDE_DIRS}) 62 | 63 | set(Qt5Gui_DEFINITIONS -DQT_GUI_LIB) 64 | set(Qt5Gui_COMPILE_DEFINITIONS QT_GUI_LIB) 65 | set(_Qt5Gui_MODULE_DEPENDENCIES "Core") 66 | 67 | 68 | set(_Qt5Gui_FIND_DEPENDENCIES_REQUIRED) 69 | if (Qt5Gui_FIND_REQUIRED) 70 | set(_Qt5Gui_FIND_DEPENDENCIES_REQUIRED REQUIRED) 71 | endif() 72 | set(_Qt5Gui_FIND_DEPENDENCIES_QUIET) 73 | if (Qt5Gui_FIND_QUIETLY) 74 | set(_Qt5Gui_DEPENDENCIES_FIND_QUIET QUIET) 75 | endif() 76 | set(_Qt5Gui_FIND_VERSION_EXACT) 77 | if (Qt5Gui_FIND_VERSION_EXACT) 78 | set(_Qt5Gui_FIND_VERSION_EXACT EXACT) 79 | endif() 80 | 81 | set(Qt5Gui_EXECUTABLE_COMPILE_FLAGS "") 82 | 83 | foreach(_module_dep ${_Qt5Gui_MODULE_DEPENDENCIES}) 84 | if (NOT Qt5${_module_dep}_FOUND) 85 | find_package(Qt5${_module_dep} 86 | 5.8.0 ${_Qt5Gui_FIND_VERSION_EXACT} 87 | ${_Qt5Gui_DEPENDENCIES_FIND_QUIET} 88 | ${_Qt5Gui_FIND_DEPENDENCIES_REQUIRED} 89 | PATHS "${CMAKE_CURRENT_LIST_DIR}/.." NO_DEFAULT_PATH 90 | ) 91 | endif() 92 | 93 | if (NOT Qt5${_module_dep}_FOUND) 94 | set(Qt5Gui_FOUND False) 95 | return() 96 | endif() 97 | 98 | list(APPEND Qt5Gui_INCLUDE_DIRS "${Qt5${_module_dep}_INCLUDE_DIRS}") 99 | list(APPEND Qt5Gui_PRIVATE_INCLUDE_DIRS "${Qt5${_module_dep}_PRIVATE_INCLUDE_DIRS}") 100 | list(APPEND Qt5Gui_DEFINITIONS ${Qt5${_module_dep}_DEFINITIONS}) 101 | list(APPEND Qt5Gui_COMPILE_DEFINITIONS ${Qt5${_module_dep}_COMPILE_DEFINITIONS}) 102 | list(APPEND Qt5Gui_EXECUTABLE_COMPILE_FLAGS ${Qt5${_module_dep}_EXECUTABLE_COMPILE_FLAGS}) 103 | endforeach() 104 | list(REMOVE_DUPLICATES Qt5Gui_INCLUDE_DIRS) 105 | list(REMOVE_DUPLICATES Qt5Gui_PRIVATE_INCLUDE_DIRS) 106 | list(REMOVE_DUPLICATES Qt5Gui_DEFINITIONS) 107 | list(REMOVE_DUPLICATES Qt5Gui_COMPILE_DEFINITIONS) 108 | list(REMOVE_DUPLICATES Qt5Gui_EXECUTABLE_COMPILE_FLAGS) 109 | 110 | set(_Qt5Gui_LIB_DEPENDENCIES "Qt5::Core") 111 | 112 | 113 | add_library(Qt5::Gui SHARED IMPORTED) 114 | 115 | #set_property(TARGET Qt5::Gui PROPERTY 116 | # INTERFACE_INCLUDE_DIRECTORIES ${_Qt5Gui_OWN_INCLUDE_DIRS}) 117 | set_property(TARGET Qt5::Gui PROPERTY 118 | INTERFACE_COMPILE_DEFINITIONS QT_GUI_LIB) 119 | 120 | _populate_Gui_target_properties(RELEASE "libQt5Gui.so.5.8.0" "" ) 121 | 122 | 123 | 124 | 125 | file(GLOB pluginTargets "${CMAKE_CURRENT_LIST_DIR}/Qt5Gui_*Plugin.cmake") 126 | 127 | macro(_populate_Gui_plugin_properties Plugin Configuration PLUGIN_LOCATION) 128 | set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration}) 129 | 130 | set(imported_location "${_qt5Gui_install_prefix}/plugins/${PLUGIN_LOCATION}") 131 | _qt5_Gui_check_file_exists(${imported_location}) 132 | set_target_properties(Qt5::${Plugin} PROPERTIES 133 | "IMPORTED_LOCATION_${Configuration}" ${imported_location} 134 | ) 135 | endmacro() 136 | 137 | if (pluginTargets) 138 | foreach(pluginTarget ${pluginTargets}) 139 | include(${pluginTarget}) 140 | endforeach() 141 | endif() 142 | 143 | 144 | include("${CMAKE_CURRENT_LIST_DIR}/Qt5GuiConfigExtras.cmake") 145 | 146 | 147 | _qt5_Gui_check_file_exists("${CMAKE_CURRENT_LIST_DIR}/Qt5GuiConfigVersion.cmake") 148 | 149 | endif() 150 | -------------------------------------------------------------------------------- /cmake/Qt5Gui/Qt5GuiConfigExtras.cmake: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | set(_GL_INCDIRS "/usr/include/libdrm") 5 | find_path(_qt5gui_OPENGL_INCLUDE_DIR GL/gl.h 6 | PATHS ${_GL_INCDIRS} 7 | ) 8 | #if (NOT _qt5gui_OPENGL_INCLUDE_DIR) 9 | # message(FATAL_ERROR "Failed to find \"GL/gl.h\" in \"${_GL_INCDIRS}\".") 10 | #endif() 11 | unset(_GL_INCDIRS) 12 | 13 | # Don't check for existence of the _qt5gui_OPENGL_INCLUDE_DIR because it is 14 | # optional. 15 | 16 | #list(APPEND Qt5Gui_INCLUDE_DIRS ${_qt5gui_OPENGL_INCLUDE_DIR}) 17 | #set_property(TARGET Qt5::Gui APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${_qt5gui_OPENGL_INCLUDE_DIR}) 18 | 19 | unset(_qt5gui_OPENGL_INCLUDE_DIR CACHE) 20 | 21 | 22 | macro(_qt5gui_find_extra_libs Name Libs LibDir IncDirs) 23 | set(Qt5Gui_${Name}_LIBRARIES) 24 | set(Qt5Gui_${Name}_INCLUDE_DIRS ${IncDirs}) 25 | foreach(_lib ${Libs}) 26 | string(REGEX REPLACE [^_A-Za-z0-9] _ _cmake_lib_name ${_lib}) 27 | if (NOT TARGET Qt5::Gui_${_cmake_lib_name} AND NOT _Qt5Gui_${_cmake_lib_name}_LIBRARY_DONE) 28 | find_library(Qt5Gui_${_cmake_lib_name}_LIBRARY ${_lib} 29 | ) 30 | if (NOT Qt5Gui_${_cmake_lib_name}_LIBRARY) 31 | # The above find_library call doesn't work for finding 32 | # libraries in Windows SDK paths outside of the proper 33 | # environment, even if the libraries are present. In other 34 | # cases it is OK for the libraries to not be found 35 | # because they are optional dependencies of Qt5Gui, needed 36 | # only if the qopengl.h header is used. 37 | # We try to find the libraries in the first place because Qt may be 38 | # compiled with another set of GL libraries (such as coming 39 | # from ANGLE). The point of these find calls is to try to 40 | # find the same binaries as Qt is compiled with (as they are 41 | # in the interface of QtGui), so an effort is made to do so 42 | # above with paths known to qmake. 43 | set(_Qt5Gui_${_cmake_lib_name}_LIBRARY_DONE TRUE) 44 | unset(Qt5Gui_${_cmake_lib_name}_LIBRARY CACHE) 45 | else() 46 | add_library(Qt5::Gui_${_cmake_lib_name} SHARED IMPORTED) 47 | #set_property(TARGET Qt5::Gui_${_cmake_lib_name} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Qt5Gui_${Name}_INCLUDE_DIRS}) 48 | 49 | set_property(TARGET Qt5::Gui_${_cmake_lib_name} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 50 | _qt5_Gui_check_file_exists("${Qt5Gui_${_cmake_lib_name}_LIBRARY}") 51 | set_property(TARGET Qt5::Gui_${_cmake_lib_name} PROPERTY IMPORTED_LOCATION_RELEASE "${Qt5Gui_${_cmake_lib_name}_LIBRARY}") 52 | 53 | unset(Qt5Gui_${_cmake_lib_name}_LIBRARY CACHE) 54 | 55 | find_library(Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG ${_lib}d 56 | PATHS "${LibDir}" 57 | NO_DEFAULT_PATH 58 | ) 59 | if (Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG) 60 | set_property(TARGET Qt5::Gui_${_cmake_lib_name} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) 61 | _qt5_Gui_check_file_exists("${Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG}") 62 | set_property(TARGET Qt5::Gui_${_cmake_lib_name} PROPERTY IMPORTED_LOCATION_DEBUG "${Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG}") 63 | endif() 64 | unset(Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG CACHE) 65 | list(APPEND Qt5Gui_${Name}_LIBRARIES Qt5::Gui_${_cmake_lib_name}) 66 | endif() 67 | endif() 68 | endforeach() 69 | endmacro() 70 | 71 | 72 | _qt5gui_find_extra_libs(EGL "EGL" "" "/usr/include/libdrm") 73 | 74 | _qt5gui_find_extra_libs(OPENGL "GL" "" "/usr/include/libdrm") 75 | 76 | 77 | 78 | set(Qt5Gui_OPENGL_IMPLEMENTATION GL) 79 | 80 | get_target_property(_configs Qt5::Gui IMPORTED_CONFIGURATIONS) 81 | foreach(_config ${_configs}) 82 | set_property(TARGET Qt5::Gui APPEND PROPERTY 83 | IMPORTED_LINK_DEPENDENT_LIBRARIES_${_config} 84 | ${Qt5Gui_EGL_LIBRARIES} ${Qt5Gui_OPENGL_LIBRARIES} 85 | ) 86 | endforeach() 87 | unset(_configs) 88 | -------------------------------------------------------------------------------- /cmake/Qt5Gui/Qt5GuiConfigVersion.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(PACKAGE_VERSION 5.8.0) 3 | 4 | if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) 5 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 6 | else() 7 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 8 | if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) 9 | set(PACKAGE_VERSION_EXACT TRUE) 10 | endif() 11 | endif() 12 | -------------------------------------------------------------------------------- /cmake/Qt5Multimedia/Qt5MultimediaConfig.cmake: -------------------------------------------------------------------------------- 1 | 2 | if (CMAKE_VERSION VERSION_LESS 2.8.3) 3 | message(FATAL_ERROR "Qt 5 requires at least CMake version 2.8.3") 4 | endif() 5 | 6 | get_filename_component(_qt5Multimedia_install_prefix "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE) 7 | 8 | # For backwards compatibility only. Use Qt5Multimedia_VERSION instead. 9 | set(Qt5Multimedia_VERSION_STRING 5.8.0) 10 | 11 | set(Qt5Multimedia_LIBRARIES Qt5::Multimedia) 12 | 13 | macro(_qt5_Multimedia_check_file_exists file) 14 | if(NOT EXISTS "${file}" ) 15 | # message(FATAL_ERROR "The imported target \"Qt5::Multimedia\" references the file 16 | # \"${file}\" 17 | #but this file does not exist. Possible reasons include: 18 | #* The file was deleted, renamed, or moved to another location. 19 | #* An install or uninstall procedure did not complete successfully. 20 | #* The installation package was faulty and contained 21 | # \"${CMAKE_CURRENT_LIST_FILE}\" 22 | #but not all the files it references. 23 | #") 24 | endif() 25 | endmacro() 26 | 27 | macro(_populate_Multimedia_target_properties Configuration LIB_LOCATION IMPLIB_LOCATION) 28 | set_property(TARGET Qt5::Multimedia APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration}) 29 | 30 | set(imported_location "${_qt5Multimedia_install_prefix}/lib/${LIB_LOCATION}") 31 | _qt5_Multimedia_check_file_exists(${imported_location}) 32 | set_target_properties(Qt5::Multimedia PROPERTIES 33 | "INTERFACE_LINK_LIBRARIES" "${_Qt5Multimedia_LIB_DEPENDENCIES}" 34 | "IMPORTED_LOCATION_${Configuration}" ${imported_location} 35 | "IMPORTED_SONAME_${Configuration}" "libQt5Multimedia.so.5" 36 | # For backward compatibility with CMake < 2.8.12 37 | "IMPORTED_LINK_INTERFACE_LIBRARIES_${Configuration}" "${_Qt5Multimedia_LIB_DEPENDENCIES}" 38 | ) 39 | 40 | endmacro() 41 | 42 | if (NOT TARGET Qt5::Multimedia) 43 | 44 | set(_Qt5Multimedia_OWN_INCLUDE_DIRS "${_qt5Multimedia_install_prefix}/include/" "${_qt5Multimedia_install_prefix}/include/QtMultimedia") 45 | set(Qt5Multimedia_PRIVATE_INCLUDE_DIRS "") 46 | include("${CMAKE_CURRENT_LIST_DIR}/ExtraSourceIncludes.cmake" OPTIONAL) 47 | 48 | foreach(_dir ${_Qt5Multimedia_OWN_INCLUDE_DIRS}) 49 | _qt5_Multimedia_check_file_exists(${_dir}) 50 | endforeach() 51 | 52 | # Only check existence of private includes if the Private component is 53 | # specified. 54 | list(FIND Qt5Multimedia_FIND_COMPONENTS Private _check_private) 55 | if (NOT _check_private STREQUAL -1) 56 | foreach(_dir ${Qt5Multimedia_PRIVATE_INCLUDE_DIRS}) 57 | _qt5_Multimedia_check_file_exists(${_dir}) 58 | endforeach() 59 | endif() 60 | 61 | set(Qt5Multimedia_INCLUDE_DIRS ${_Qt5Multimedia_OWN_INCLUDE_DIRS}) 62 | 63 | set(Qt5Multimedia_DEFINITIONS -DQT_MULTIMEDIA_LIB) 64 | set(Qt5Multimedia_COMPILE_DEFINITIONS QT_MULTIMEDIA_LIB) 65 | set(_Qt5Multimedia_MODULE_DEPENDENCIES "Network;Gui;Core") 66 | 67 | 68 | set(_Qt5Multimedia_FIND_DEPENDENCIES_REQUIRED) 69 | if (Qt5Multimedia_FIND_REQUIRED) 70 | set(_Qt5Multimedia_FIND_DEPENDENCIES_REQUIRED REQUIRED) 71 | endif() 72 | set(_Qt5Multimedia_FIND_DEPENDENCIES_QUIET) 73 | if (Qt5Multimedia_FIND_QUIETLY) 74 | set(_Qt5Multimedia_DEPENDENCIES_FIND_QUIET QUIET) 75 | endif() 76 | set(_Qt5Multimedia_FIND_VERSION_EXACT) 77 | if (Qt5Multimedia_FIND_VERSION_EXACT) 78 | set(_Qt5Multimedia_FIND_VERSION_EXACT EXACT) 79 | endif() 80 | 81 | set(Qt5Multimedia_EXECUTABLE_COMPILE_FLAGS "") 82 | 83 | foreach(_module_dep ${_Qt5Multimedia_MODULE_DEPENDENCIES}) 84 | if (NOT Qt5${_module_dep}_FOUND) 85 | find_package(Qt5${_module_dep} 86 | 5.8.0 ${_Qt5Multimedia_FIND_VERSION_EXACT} 87 | ${_Qt5Multimedia_DEPENDENCIES_FIND_QUIET} 88 | ${_Qt5Multimedia_FIND_DEPENDENCIES_REQUIRED} 89 | PATHS "${CMAKE_CURRENT_LIST_DIR}/.." NO_DEFAULT_PATH 90 | ) 91 | endif() 92 | 93 | if (NOT Qt5${_module_dep}_FOUND) 94 | set(Qt5Multimedia_FOUND False) 95 | return() 96 | endif() 97 | 98 | list(APPEND Qt5Multimedia_INCLUDE_DIRS "${Qt5${_module_dep}_INCLUDE_DIRS}") 99 | list(APPEND Qt5Multimedia_PRIVATE_INCLUDE_DIRS "${Qt5${_module_dep}_PRIVATE_INCLUDE_DIRS}") 100 | list(APPEND Qt5Multimedia_DEFINITIONS ${Qt5${_module_dep}_DEFINITIONS}) 101 | list(APPEND Qt5Multimedia_COMPILE_DEFINITIONS ${Qt5${_module_dep}_COMPILE_DEFINITIONS}) 102 | list(APPEND Qt5Multimedia_EXECUTABLE_COMPILE_FLAGS ${Qt5${_module_dep}_EXECUTABLE_COMPILE_FLAGS}) 103 | endforeach() 104 | list(REMOVE_DUPLICATES Qt5Multimedia_INCLUDE_DIRS) 105 | list(REMOVE_DUPLICATES Qt5Multimedia_PRIVATE_INCLUDE_DIRS) 106 | list(REMOVE_DUPLICATES Qt5Multimedia_DEFINITIONS) 107 | list(REMOVE_DUPLICATES Qt5Multimedia_COMPILE_DEFINITIONS) 108 | list(REMOVE_DUPLICATES Qt5Multimedia_EXECUTABLE_COMPILE_FLAGS) 109 | 110 | set(_Qt5Multimedia_LIB_DEPENDENCIES "Qt5::Network;Qt5::Gui;Qt5::Core") 111 | 112 | 113 | add_library(Qt5::Multimedia SHARED IMPORTED) 114 | 115 | #set_property(TARGET Qt5::Multimedia PROPERTY 116 | # INTERFACE_INCLUDE_DIRECTORIES ${_Qt5Multimedia_OWN_INCLUDE_DIRS}) 117 | set_property(TARGET Qt5::Multimedia PROPERTY 118 | INTERFACE_COMPILE_DEFINITIONS QT_MULTIMEDIA_LIB) 119 | 120 | _populate_Multimedia_target_properties(RELEASE "libQt5Multimedia.so.5.8.0" "" ) 121 | 122 | 123 | 124 | 125 | file(GLOB pluginTargets "${CMAKE_CURRENT_LIST_DIR}/Qt5Multimedia_*Plugin.cmake") 126 | 127 | macro(_populate_Multimedia_plugin_properties Plugin Configuration PLUGIN_LOCATION) 128 | set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration}) 129 | 130 | set(imported_location "${_qt5Multimedia_install_prefix}/plugins/${PLUGIN_LOCATION}") 131 | _qt5_Multimedia_check_file_exists(${imported_location}) 132 | set_target_properties(Qt5::${Plugin} PROPERTIES 133 | "IMPORTED_LOCATION_${Configuration}" ${imported_location} 134 | ) 135 | endmacro() 136 | 137 | if (pluginTargets) 138 | foreach(pluginTarget ${pluginTargets}) 139 | include(${pluginTarget}) 140 | endforeach() 141 | endif() 142 | 143 | 144 | 145 | 146 | _qt5_Multimedia_check_file_exists("${CMAKE_CURRENT_LIST_DIR}/Qt5MultimediaConfigVersion.cmake") 147 | 148 | endif() 149 | -------------------------------------------------------------------------------- /cmake/Qt5Multimedia/Qt5MultimediaConfigVersion.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(PACKAGE_VERSION 5.8.0) 3 | 4 | if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) 5 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 6 | else() 7 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 8 | if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) 9 | set(PACKAGE_VERSION_EXACT TRUE) 10 | endif() 11 | endif() 12 | -------------------------------------------------------------------------------- /cmake/Qt5Multimedia/Qt5Multimedia_AudioCaptureServicePlugin.cmake: -------------------------------------------------------------------------------- 1 | 2 | add_library(Qt5::AudioCaptureServicePlugin MODULE IMPORTED) 3 | 4 | _populate_Multimedia_plugin_properties(AudioCaptureServicePlugin RELEASE "mediaservice/libqtmedia_audioengine.so") 5 | 6 | list(APPEND Qt5Multimedia_PLUGINS Qt5::AudioCaptureServicePlugin) 7 | -------------------------------------------------------------------------------- /cmake/Qt5Multimedia/Qt5Multimedia_QM3uPlaylistPlugin.cmake: -------------------------------------------------------------------------------- 1 | 2 | add_library(Qt5::QM3uPlaylistPlugin MODULE IMPORTED) 3 | 4 | _populate_Multimedia_plugin_properties(QM3uPlaylistPlugin RELEASE "playlistformats/libqtmultimedia_m3u.so") 5 | 6 | list(APPEND Qt5Multimedia_PLUGINS Qt5::QM3uPlaylistPlugin) 7 | -------------------------------------------------------------------------------- /cmake/Qt5MultimediaWidgets/Qt5MultimediaWidgetsConfig.cmake: -------------------------------------------------------------------------------- 1 | 2 | if (CMAKE_VERSION VERSION_LESS 2.8.3) 3 | message(FATAL_ERROR "Qt 5 requires at least CMake version 2.8.3") 4 | endif() 5 | 6 | get_filename_component(_qt5MultimediaWidgets_install_prefix "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE) 7 | 8 | # For backwards compatibility only. Use Qt5MultimediaWidgets_VERSION instead. 9 | set(Qt5MultimediaWidgets_VERSION_STRING 5.8.0) 10 | 11 | set(Qt5MultimediaWidgets_LIBRARIES Qt5::MultimediaWidgets) 12 | 13 | macro(_qt5_MultimediaWidgets_check_file_exists file) 14 | if(NOT EXISTS "${file}" ) 15 | # message(FATAL_ERROR "The imported target \"Qt5::MultimediaWidgets\" references the file 16 | # \"${file}\" 17 | #but this file does not exist. Possible reasons include: 18 | #* The file was deleted, renamed, or moved to another location. 19 | #* An install or uninstall procedure did not complete successfully. 20 | #* The installation package was faulty and contained 21 | # \"${CMAKE_CURRENT_LIST_FILE}\" 22 | #but not all the files it references. 23 | #") 24 | endif() 25 | endmacro() 26 | 27 | macro(_populate_MultimediaWidgets_target_properties Configuration LIB_LOCATION IMPLIB_LOCATION) 28 | set_property(TARGET Qt5::MultimediaWidgets APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration}) 29 | 30 | set(imported_location "${_qt5MultimediaWidgets_install_prefix}/lib/${LIB_LOCATION}") 31 | _qt5_MultimediaWidgets_check_file_exists(${imported_location}) 32 | set_target_properties(Qt5::MultimediaWidgets PROPERTIES 33 | "INTERFACE_LINK_LIBRARIES" "${_Qt5MultimediaWidgets_LIB_DEPENDENCIES}" 34 | "IMPORTED_LOCATION_${Configuration}" ${imported_location} 35 | "IMPORTED_SONAME_${Configuration}" "libQt5MultimediaWidgets.so.5" 36 | # For backward compatibility with CMake < 2.8.12 37 | "IMPORTED_LINK_INTERFACE_LIBRARIES_${Configuration}" "${_Qt5MultimediaWidgets_LIB_DEPENDENCIES}" 38 | ) 39 | 40 | endmacro() 41 | 42 | if (NOT TARGET Qt5::MultimediaWidgets) 43 | 44 | set(_Qt5MultimediaWidgets_OWN_INCLUDE_DIRS "${_qt5MultimediaWidgets_install_prefix}/include/" "${_qt5MultimediaWidgets_install_prefix}/include/QtMultimediaWidgets") 45 | set(Qt5MultimediaWidgets_PRIVATE_INCLUDE_DIRS "") 46 | include("${CMAKE_CURRENT_LIST_DIR}/ExtraSourceIncludes.cmake" OPTIONAL) 47 | 48 | foreach(_dir ${_Qt5MultimediaWidgets_OWN_INCLUDE_DIRS}) 49 | _qt5_MultimediaWidgets_check_file_exists(${_dir}) 50 | endforeach() 51 | 52 | # Only check existence of private includes if the Private component is 53 | # specified. 54 | list(FIND Qt5MultimediaWidgets_FIND_COMPONENTS Private _check_private) 55 | if (NOT _check_private STREQUAL -1) 56 | foreach(_dir ${Qt5MultimediaWidgets_PRIVATE_INCLUDE_DIRS}) 57 | _qt5_MultimediaWidgets_check_file_exists(${_dir}) 58 | endforeach() 59 | endif() 60 | 61 | set(Qt5MultimediaWidgets_INCLUDE_DIRS ${_Qt5MultimediaWidgets_OWN_INCLUDE_DIRS}) 62 | 63 | set(Qt5MultimediaWidgets_DEFINITIONS -DQT_MULTIMEDIAWIDGETS_LIB) 64 | set(Qt5MultimediaWidgets_COMPILE_DEFINITIONS QT_MULTIMEDIAWIDGETS_LIB) 65 | set(_Qt5MultimediaWidgets_MODULE_DEPENDENCIES "Multimedia;Widgets;Gui;Core") 66 | 67 | 68 | set(_Qt5MultimediaWidgets_FIND_DEPENDENCIES_REQUIRED) 69 | if (Qt5MultimediaWidgets_FIND_REQUIRED) 70 | set(_Qt5MultimediaWidgets_FIND_DEPENDENCIES_REQUIRED REQUIRED) 71 | endif() 72 | set(_Qt5MultimediaWidgets_FIND_DEPENDENCIES_QUIET) 73 | if (Qt5MultimediaWidgets_FIND_QUIETLY) 74 | set(_Qt5MultimediaWidgets_DEPENDENCIES_FIND_QUIET QUIET) 75 | endif() 76 | set(_Qt5MultimediaWidgets_FIND_VERSION_EXACT) 77 | if (Qt5MultimediaWidgets_FIND_VERSION_EXACT) 78 | set(_Qt5MultimediaWidgets_FIND_VERSION_EXACT EXACT) 79 | endif() 80 | 81 | set(Qt5MultimediaWidgets_EXECUTABLE_COMPILE_FLAGS "") 82 | 83 | foreach(_module_dep ${_Qt5MultimediaWidgets_MODULE_DEPENDENCIES}) 84 | if (NOT Qt5${_module_dep}_FOUND) 85 | find_package(Qt5${_module_dep} 86 | 5.8.0 ${_Qt5MultimediaWidgets_FIND_VERSION_EXACT} 87 | ${_Qt5MultimediaWidgets_DEPENDENCIES_FIND_QUIET} 88 | ${_Qt5MultimediaWidgets_FIND_DEPENDENCIES_REQUIRED} 89 | PATHS "${CMAKE_CURRENT_LIST_DIR}/.." NO_DEFAULT_PATH 90 | ) 91 | endif() 92 | 93 | if (NOT Qt5${_module_dep}_FOUND) 94 | set(Qt5MultimediaWidgets_FOUND False) 95 | return() 96 | endif() 97 | 98 | list(APPEND Qt5MultimediaWidgets_INCLUDE_DIRS "${Qt5${_module_dep}_INCLUDE_DIRS}") 99 | list(APPEND Qt5MultimediaWidgets_PRIVATE_INCLUDE_DIRS "${Qt5${_module_dep}_PRIVATE_INCLUDE_DIRS}") 100 | list(APPEND Qt5MultimediaWidgets_DEFINITIONS ${Qt5${_module_dep}_DEFINITIONS}) 101 | list(APPEND Qt5MultimediaWidgets_COMPILE_DEFINITIONS ${Qt5${_module_dep}_COMPILE_DEFINITIONS}) 102 | list(APPEND Qt5MultimediaWidgets_EXECUTABLE_COMPILE_FLAGS ${Qt5${_module_dep}_EXECUTABLE_COMPILE_FLAGS}) 103 | endforeach() 104 | list(REMOVE_DUPLICATES Qt5MultimediaWidgets_INCLUDE_DIRS) 105 | list(REMOVE_DUPLICATES Qt5MultimediaWidgets_PRIVATE_INCLUDE_DIRS) 106 | list(REMOVE_DUPLICATES Qt5MultimediaWidgets_DEFINITIONS) 107 | list(REMOVE_DUPLICATES Qt5MultimediaWidgets_COMPILE_DEFINITIONS) 108 | list(REMOVE_DUPLICATES Qt5MultimediaWidgets_EXECUTABLE_COMPILE_FLAGS) 109 | 110 | set(_Qt5MultimediaWidgets_LIB_DEPENDENCIES "Qt5::Multimedia;Qt5::Widgets;Qt5::Gui;Qt5::Core") 111 | 112 | 113 | add_library(Qt5::MultimediaWidgets SHARED IMPORTED) 114 | 115 | #set_property(TARGET Qt5::MultimediaWidgets PROPERTY 116 | # INTERFACE_INCLUDE_DIRECTORIES ${_Qt5MultimediaWidgets_OWN_INCLUDE_DIRS}) 117 | set_property(TARGET Qt5::MultimediaWidgets PROPERTY 118 | INTERFACE_COMPILE_DEFINITIONS QT_MULTIMEDIAWIDGETS_LIB) 119 | 120 | _populate_MultimediaWidgets_target_properties(RELEASE "libQt5MultimediaWidgets.so.5.8.0" "" ) 121 | 122 | 123 | 124 | 125 | file(GLOB pluginTargets "${CMAKE_CURRENT_LIST_DIR}/Qt5MultimediaWidgets_*Plugin.cmake") 126 | 127 | macro(_populate_MultimediaWidgets_plugin_properties Plugin Configuration PLUGIN_LOCATION) 128 | set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration}) 129 | 130 | set(imported_location "${_qt5MultimediaWidgets_install_prefix}/plugins/${PLUGIN_LOCATION}") 131 | _qt5_MultimediaWidgets_check_file_exists(${imported_location}) 132 | set_target_properties(Qt5::${Plugin} PROPERTIES 133 | "IMPORTED_LOCATION_${Configuration}" ${imported_location} 134 | ) 135 | endmacro() 136 | 137 | if (pluginTargets) 138 | foreach(pluginTarget ${pluginTargets}) 139 | include(${pluginTarget}) 140 | endforeach() 141 | endif() 142 | 143 | 144 | 145 | 146 | _qt5_MultimediaWidgets_check_file_exists("${CMAKE_CURRENT_LIST_DIR}/Qt5MultimediaWidgetsConfigVersion.cmake") 147 | 148 | endif() 149 | -------------------------------------------------------------------------------- /cmake/Qt5MultimediaWidgets/Qt5MultimediaWidgetsConfigVersion.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(PACKAGE_VERSION 5.8.0) 3 | 4 | if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) 5 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 6 | else() 7 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 8 | if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) 9 | set(PACKAGE_VERSION_EXACT TRUE) 10 | endif() 11 | endif() 12 | -------------------------------------------------------------------------------- /cmake/Qt5Network/Qt5NetworkConfig.cmake: -------------------------------------------------------------------------------- 1 | 2 | if (CMAKE_VERSION VERSION_LESS 2.8.3) 3 | message(FATAL_ERROR "Qt 5 requires at least CMake version 2.8.3") 4 | endif() 5 | 6 | get_filename_component(_qt5Network_install_prefix "${ECHOBOT_EXTERNAL_INSTALL_DIR}" ABSOLUTE) 7 | 8 | # For backwards compatibility only. Use Qt5Network_VERSION instead. 9 | set(Qt5Network_VERSION_STRING 5.8.0) 10 | 11 | set(Qt5Network_LIBRARIES Qt5::Network) 12 | 13 | macro(_qt5_Network_check_file_exists file) 14 | if(NOT EXISTS "${file}" ) 15 | # message(FATAL_ERROR "The imported target \"Qt5::Network\" references the file 16 | # \"${file}\" 17 | #but this file does not exist. Possible reasons include: 18 | #* The file was deleted, renamed, or moved to another location. 19 | #* An install or uninstall procedure did not complete successfully. 20 | #* The installation package was faulty and contained 21 | # \"${CMAKE_CURRENT_LIST_FILE}\" 22 | #but not all the files it references. 23 | #") 24 | endif() 25 | endmacro() 26 | 27 | macro(_populate_Network_target_properties Configuration LIB_LOCATION IMPLIB_LOCATION) 28 | set_property(TARGET Qt5::Network APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration}) 29 | 30 | set(imported_location "${_qt5Network_install_prefix}/lib/${LIB_LOCATION}") 31 | _qt5_Network_check_file_exists(${imported_location}) 32 | set_target_properties(Qt5::Network PROPERTIES 33 | "INTERFACE_LINK_LIBRARIES" "${_Qt5Network_LIB_DEPENDENCIES}" 34 | "IMPORTED_LOCATION_${Configuration}" ${imported_location} 35 | "IMPORTED_SONAME_${Configuration}" "libQt5Network.so.5" 36 | # For backward compatibility with CMake < 2.8.12 37 | "IMPORTED_LINK_INTERFACE_LIBRARIES_${Configuration}" "${_Qt5Network_LIB_DEPENDENCIES}" 38 | ) 39 | 40 | endmacro() 41 | 42 | if (NOT TARGET Qt5::Network) 43 | 44 | set(_Qt5Network_OWN_INCLUDE_DIRS "${_qt5Network_install_prefix}/include/" "${_qt5Network_install_prefix}/include/QtNetwork") 45 | set(Qt5Network_PRIVATE_INCLUDE_DIRS "") 46 | include("${CMAKE_CURRENT_LIST_DIR}/ExtraSourceIncludes.cmake" OPTIONAL) 47 | 48 | foreach(_dir ${_Qt5Network_OWN_INCLUDE_DIRS}) 49 | _qt5_Network_check_file_exists(${_dir}) 50 | endforeach() 51 | 52 | # Only check existence of private includes if the Private component is 53 | # specified. 54 | list(FIND Qt5Network_FIND_COMPONENTS Private _check_private) 55 | if (NOT _check_private STREQUAL -1) 56 | foreach(_dir ${Qt5Network_PRIVATE_INCLUDE_DIRS}) 57 | _qt5_Network_check_file_exists(${_dir}) 58 | endforeach() 59 | endif() 60 | 61 | set(Qt5Network_INCLUDE_DIRS ${_Qt5Network_OWN_INCLUDE_DIRS}) 62 | 63 | set(Qt5Network_DEFINITIONS -DQT_NETWORK_LIB) 64 | set(Qt5Network_COMPILE_DEFINITIONS QT_NETWORK_LIB) 65 | set(_Qt5Network_MODULE_DEPENDENCIES "Core") 66 | 67 | 68 | set(_Qt5Network_FIND_DEPENDENCIES_REQUIRED) 69 | if (Qt5Network_FIND_REQUIRED) 70 | set(_Qt5Network_FIND_DEPENDENCIES_REQUIRED REQUIRED) 71 | endif() 72 | set(_Qt5Network_FIND_DEPENDENCIES_QUIET) 73 | if (Qt5Network_FIND_QUIETLY) 74 | set(_Qt5Network_DEPENDENCIES_FIND_QUIET QUIET) 75 | endif() 76 | set(_Qt5Network_FIND_VERSION_EXACT) 77 | if (Qt5Network_FIND_VERSION_EXACT) 78 | set(_Qt5Network_FIND_VERSION_EXACT EXACT) 79 | endif() 80 | 81 | set(Qt5Network_EXECUTABLE_COMPILE_FLAGS "") 82 | 83 | foreach(_module_dep ${_Qt5Network_MODULE_DEPENDENCIES}) 84 | if (NOT Qt5${_module_dep}_FOUND) 85 | find_package(Qt5${_module_dep} 86 | 5.8.0 ${_Qt5Network_FIND_VERSION_EXACT} 87 | ${_Qt5Network_DEPENDENCIES_FIND_QUIET} 88 | ${_Qt5Network_FIND_DEPENDENCIES_REQUIRED} 89 | PATHS "${CMAKE_CURRENT_LIST_DIR}/.." NO_DEFAULT_PATH 90 | ) 91 | endif() 92 | 93 | if (NOT Qt5${_module_dep}_FOUND) 94 | set(Qt5Network_FOUND False) 95 | return() 96 | endif() 97 | 98 | list(APPEND Qt5Network_INCLUDE_DIRS "${Qt5${_module_dep}_INCLUDE_DIRS}") 99 | list(APPEND Qt5Network_PRIVATE_INCLUDE_DIRS "${Qt5${_module_dep}_PRIVATE_INCLUDE_DIRS}") 100 | list(APPEND Qt5Network_DEFINITIONS ${Qt5${_module_dep}_DEFINITIONS}) 101 | list(APPEND Qt5Network_COMPILE_DEFINITIONS ${Qt5${_module_dep}_COMPILE_DEFINITIONS}) 102 | list(APPEND Qt5Network_EXECUTABLE_COMPILE_FLAGS ${Qt5${_module_dep}_EXECUTABLE_COMPILE_FLAGS}) 103 | endforeach() 104 | list(REMOVE_DUPLICATES Qt5Network_INCLUDE_DIRS) 105 | list(REMOVE_DUPLICATES Qt5Network_PRIVATE_INCLUDE_DIRS) 106 | list(REMOVE_DUPLICATES Qt5Network_DEFINITIONS) 107 | list(REMOVE_DUPLICATES Qt5Network_COMPILE_DEFINITIONS) 108 | list(REMOVE_DUPLICATES Qt5Network_EXECUTABLE_COMPILE_FLAGS) 109 | 110 | set(_Qt5Network_LIB_DEPENDENCIES "Qt5::Core") 111 | 112 | 113 | add_library(Qt5::Network SHARED IMPORTED) 114 | 115 | #set_property(TARGET Qt5::Network PROPERTY 116 | # INTERFACE_INCLUDE_DIRECTORIES ${_Qt5Network_OWN_INCLUDE_DIRS}) 117 | set_property(TARGET Qt5::Network PROPERTY 118 | INTERFACE_COMPILE_DEFINITIONS QT_NETWORK_LIB) 119 | 120 | _populate_Network_target_properties(RELEASE "libQt5Network.so.5.8.0" "" ) 121 | 122 | 123 | 124 | 125 | file(GLOB pluginTargets "${CMAKE_CURRENT_LIST_DIR}/Qt5Network_*Plugin.cmake") 126 | 127 | macro(_populate_Network_plugin_properties Plugin Configuration PLUGIN_LOCATION) 128 | set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration}) 129 | 130 | set(imported_location "${_qt5Network_install_prefix}/plugins/${PLUGIN_LOCATION}") 131 | _qt5_Network_check_file_exists(${imported_location}) 132 | set_target_properties(Qt5::${Plugin} PROPERTIES 133 | "IMPORTED_LOCATION_${Configuration}" ${imported_location} 134 | ) 135 | endmacro() 136 | 137 | if (pluginTargets) 138 | foreach(pluginTarget ${pluginTargets}) 139 | include(${pluginTarget}) 140 | endforeach() 141 | endif() 142 | 143 | 144 | 145 | 146 | _qt5_Network_check_file_exists("${CMAKE_CURRENT_LIST_DIR}/Qt5NetworkConfigVersion.cmake") 147 | 148 | endif() 149 | -------------------------------------------------------------------------------- /cmake/Qt5Network/Qt5NetworkConfigVersion.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(PACKAGE_VERSION 5.8.0) 3 | 4 | if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) 5 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 6 | else() 7 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 8 | if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) 9 | set(PACKAGE_VERSION_EXACT TRUE) 10 | endif() 11 | endif() 12 | -------------------------------------------------------------------------------- /cmake/Qt5Network/Qt5Network_QConnmanEnginePlugin.cmake: -------------------------------------------------------------------------------- 1 | 2 | add_library(Qt5::QConnmanEnginePlugin MODULE IMPORTED) 3 | 4 | _populate_Network_plugin_properties(QConnmanEnginePlugin RELEASE "bearer/libqconnmanbearer.so") 5 | 6 | list(APPEND Qt5Network_PLUGINS Qt5::QConnmanEnginePlugin) 7 | -------------------------------------------------------------------------------- /cmake/Qt5Network/Qt5Network_QGenericEnginePlugin.cmake: -------------------------------------------------------------------------------- 1 | 2 | add_library(Qt5::QGenericEnginePlugin MODULE IMPORTED) 3 | 4 | _populate_Network_plugin_properties(QGenericEnginePlugin RELEASE "bearer/libqgenericbearer.so") 5 | 6 | list(APPEND Qt5Network_PLUGINS Qt5::QGenericEnginePlugin) 7 | -------------------------------------------------------------------------------- /cmake/Qt5Network/Qt5Network_QNetworkManagerEnginePlugin.cmake: -------------------------------------------------------------------------------- 1 | 2 | add_library(Qt5::QNetworkManagerEnginePlugin MODULE IMPORTED) 3 | 4 | _populate_Network_plugin_properties(QNetworkManagerEnginePlugin RELEASE "bearer/libqnmbearer.so") 5 | 6 | list(APPEND Qt5Network_PLUGINS Qt5::QNetworkManagerEnginePlugin) 7 | -------------------------------------------------------------------------------- /cmake/Qt5OpenGL/Qt5OpenGLConfig.cmake: -------------------------------------------------------------------------------- 1 | 2 | if (CMAKE_VERSION VERSION_LESS 2.8.3) 3 | message(FATAL_ERROR "Qt 5 requires at least CMake version 2.8.3") 4 | endif() 5 | 6 | get_filename_component(_qt5OpenGL_install_prefix "${ECHOBOT_EXTERNAL_INSTALL_DIR}" ABSOLUTE) 7 | 8 | # For backwards compatibility only. Use Qt5OpenGL_VERSION instead. 9 | set(Qt5OpenGL_VERSION_STRING 5.8.0) 10 | 11 | set(Qt5OpenGL_LIBRARIES Qt5::OpenGL) 12 | 13 | macro(_qt5_OpenGL_check_file_exists file) 14 | #if(NOT EXISTS "${file}" ) 15 | # message(FATAL_ERROR "The imported target \"Qt5::OpenGL\" references the file 16 | #\"${file}\" 17 | #but this file does not exist. Possible reasons include: 18 | #* The file was deleted, renamed, or moved to another location. 19 | #* An install or uninstall procedure did not complete successfully. 20 | #* The installation package was faulty and contained 21 | # \"${CMAKE_CURRENT_LIST_FILE}\" 22 | #but not all the files it references. 23 | #") 24 | # endif() 25 | endmacro() 26 | 27 | macro(_populate_OpenGL_target_properties Configuration LIB_LOCATION IMPLIB_LOCATION) 28 | set_property(TARGET Qt5::OpenGL APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration}) 29 | 30 | set(imported_location "${_qt5OpenGL_install_prefix}/lib/${LIB_LOCATION}") 31 | _qt5_OpenGL_check_file_exists(${imported_location}) 32 | set_target_properties(Qt5::OpenGL PROPERTIES 33 | "INTERFACE_LINK_LIBRARIES" "${_Qt5OpenGL_LIB_DEPENDENCIES}" 34 | "IMPORTED_LOCATION_${Configuration}" ${imported_location} 35 | "IMPORTED_SONAME_${Configuration}" "libQt5OpenGL.so.5" 36 | # For backward compatibility with CMake < 2.8.12 37 | "IMPORTED_LINK_INTERFACE_LIBRARIES_${Configuration}" "${_Qt5OpenGL_LIB_DEPENDENCIES}" 38 | ) 39 | 40 | endmacro() 41 | 42 | if (NOT TARGET Qt5::OpenGL) 43 | 44 | set(_Qt5OpenGL_OWN_INCLUDE_DIRS "${_qt5OpenGL_install_prefix}/include/" "${_qt5OpenGL_install_prefix}/include/QtOpenGL") 45 | set(Qt5OpenGL_PRIVATE_INCLUDE_DIRS "") 46 | include("${CMAKE_CURRENT_LIST_DIR}/ExtraSourceIncludes.cmake" OPTIONAL) 47 | 48 | #foreach(_dir ${_Qt5OpenGL_OWN_INCLUDE_DIRS}) 49 | # _qt5_OpenGL_check_file_exists(${_dir}) 50 | #endforeach() 51 | 52 | # Only check existence of private includes if the Private component is 53 | # specified. 54 | list(FIND Qt5OpenGL_FIND_COMPONENTS Private _check_private) 55 | if (NOT _check_private STREQUAL -1) 56 | foreach(_dir ${Qt5OpenGL_PRIVATE_INCLUDE_DIRS}) 57 | _qt5_OpenGL_check_file_exists(${_dir}) 58 | endforeach() 59 | endif() 60 | 61 | set(Qt5OpenGL_INCLUDE_DIRS ${_Qt5OpenGL_OWN_INCLUDE_DIRS}) 62 | 63 | set(Qt5OpenGL_DEFINITIONS -DQT_OPENGL_LIB) 64 | set(Qt5OpenGL_COMPILE_DEFINITIONS QT_OPENGL_LIB) 65 | set(_Qt5OpenGL_MODULE_DEPENDENCIES "Widgets;Gui;Core") 66 | 67 | 68 | set(_Qt5OpenGL_FIND_DEPENDENCIES_REQUIRED) 69 | if (Qt5OpenGL_FIND_REQUIRED) 70 | set(_Qt5OpenGL_FIND_DEPENDENCIES_REQUIRED REQUIRED) 71 | endif() 72 | set(_Qt5OpenGL_FIND_DEPENDENCIES_QUIET) 73 | if (Qt5OpenGL_FIND_QUIETLY) 74 | set(_Qt5OpenGL_DEPENDENCIES_FIND_QUIET QUIET) 75 | endif() 76 | set(_Qt5OpenGL_FIND_VERSION_EXACT) 77 | if (Qt5OpenGL_FIND_VERSION_EXACT) 78 | set(_Qt5OpenGL_FIND_VERSION_EXACT EXACT) 79 | endif() 80 | 81 | set(Qt5OpenGL_EXECUTABLE_COMPILE_FLAGS "") 82 | 83 | foreach(_module_dep ${_Qt5OpenGL_MODULE_DEPENDENCIES}) 84 | if (NOT Qt5${_module_dep}_FOUND) 85 | find_package(Qt5${_module_dep} 86 | 5.8.0 ${_Qt5OpenGL_FIND_VERSION_EXACT} 87 | ${_Qt5OpenGL_DEPENDENCIES_FIND_QUIET} 88 | ${_Qt5OpenGL_FIND_DEPENDENCIES_REQUIRED} 89 | PATHS "${CMAKE_CURRENT_LIST_DIR}/.." NO_DEFAULT_PATH 90 | ) 91 | endif() 92 | 93 | if (NOT Qt5${_module_dep}_FOUND) 94 | set(Qt5OpenGL_FOUND False) 95 | return() 96 | endif() 97 | 98 | list(APPEND Qt5OpenGL_INCLUDE_DIRS "${Qt5${_module_dep}_INCLUDE_DIRS}") 99 | list(APPEND Qt5OpenGL_PRIVATE_INCLUDE_DIRS "${Qt5${_module_dep}_PRIVATE_INCLUDE_DIRS}") 100 | list(APPEND Qt5OpenGL_DEFINITIONS ${Qt5${_module_dep}_DEFINITIONS}) 101 | list(APPEND Qt5OpenGL_COMPILE_DEFINITIONS ${Qt5${_module_dep}_COMPILE_DEFINITIONS}) 102 | list(APPEND Qt5OpenGL_EXECUTABLE_COMPILE_FLAGS ${Qt5${_module_dep}_EXECUTABLE_COMPILE_FLAGS}) 103 | endforeach() 104 | list(REMOVE_DUPLICATES Qt5OpenGL_INCLUDE_DIRS) 105 | list(REMOVE_DUPLICATES Qt5OpenGL_PRIVATE_INCLUDE_DIRS) 106 | list(REMOVE_DUPLICATES Qt5OpenGL_DEFINITIONS) 107 | list(REMOVE_DUPLICATES Qt5OpenGL_COMPILE_DEFINITIONS) 108 | list(REMOVE_DUPLICATES Qt5OpenGL_EXECUTABLE_COMPILE_FLAGS) 109 | 110 | set(_Qt5OpenGL_LIB_DEPENDENCIES "Qt5::Widgets;Qt5::Gui;Qt5::Core") 111 | 112 | 113 | add_library(Qt5::OpenGL SHARED IMPORTED) 114 | 115 | #set_property(TARGET Qt5::OpenGL PROPERTY 116 | # INTERFACE_INCLUDE_DIRECTORIES ${_Qt5OpenGL_OWN_INCLUDE_DIRS}) 117 | set_property(TARGET Qt5::OpenGL PROPERTY 118 | INTERFACE_COMPILE_DEFINITIONS QT_OPENGL_LIB) 119 | 120 | _populate_OpenGL_target_properties(RELEASE "libQt5OpenGL.so.5.8.0" "" ) 121 | 122 | 123 | 124 | 125 | file(GLOB pluginTargets "${CMAKE_CURRENT_LIST_DIR}/Qt5OpenGL_*Plugin.cmake") 126 | 127 | macro(_populate_OpenGL_plugin_properties Plugin Configuration PLUGIN_LOCATION) 128 | set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration}) 129 | 130 | set(imported_location "${_qt5OpenGL_install_prefix}/plugins/${PLUGIN_LOCATION}") 131 | _qt5_OpenGL_check_file_exists(${imported_location}) 132 | set_target_properties(Qt5::${Plugin} PROPERTIES 133 | "IMPORTED_LOCATION_${Configuration}" ${imported_location} 134 | ) 135 | endmacro() 136 | 137 | if (pluginTargets) 138 | foreach(pluginTarget ${pluginTargets}) 139 | include(${pluginTarget}) 140 | endforeach() 141 | endif() 142 | 143 | 144 | 145 | 146 | _qt5_OpenGL_check_file_exists("${CMAKE_CURRENT_LIST_DIR}/Qt5OpenGLConfigVersion.cmake") 147 | 148 | endif() 149 | -------------------------------------------------------------------------------- /cmake/Qt5OpenGL/Qt5OpenGLConfigVersion.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(PACKAGE_VERSION 5.8.0) 3 | 4 | if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) 5 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 6 | else() 7 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 8 | if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) 9 | set(PACKAGE_VERSION_EXACT TRUE) 10 | endif() 11 | endif() 12 | -------------------------------------------------------------------------------- /cmake/Qt5Widgets/Qt5WidgetsConfig.cmake: -------------------------------------------------------------------------------- 1 | 2 | if (CMAKE_VERSION VERSION_LESS 2.8.3) 3 | message(FATAL_ERROR "Qt 5 requires at least CMake version 2.8.3") 4 | endif() 5 | 6 | get_filename_component(_qt5Widgets_install_prefix "${ECHOBOT_EXTERNAL_INSTALL_DIR}/" ABSOLUTE) 7 | 8 | # For backwards compatibility only. Use Qt5Widgets_VERSION instead. 9 | set(Qt5Widgets_VERSION_STRING 5.8.0) 10 | 11 | set(Qt5Widgets_LIBRARIES Qt5::Widgets) 12 | 13 | macro(_qt5_Widgets_check_file_exists file) 14 | #if(NOT EXISTS "${file}" ) 15 | # message(FATAL_ERROR "The imported target \"Qt5::Widgets\" references the file 16 | #\"${file}\" 17 | #but this file does not exist. Possible reasons include: 18 | #* The file was deleted, renamed, or moved to another location. 19 | #* An install or uninstall procedure did not complete successfully. 20 | #* The installation package was faulty and contained 21 | # \"${CMAKE_CURRENT_LIST_FILE}\" 22 | #but not all the files it references. 23 | #") 24 | # endif() 25 | endmacro() 26 | 27 | macro(_populate_Widgets_target_properties Configuration LIB_LOCATION IMPLIB_LOCATION) 28 | set_property(TARGET Qt5::Widgets APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration}) 29 | 30 | set(imported_location "${_qt5Widgets_install_prefix}/lib/${LIB_LOCATION}") 31 | _qt5_Widgets_check_file_exists(${imported_location}) 32 | set_target_properties(Qt5::Widgets PROPERTIES 33 | "INTERFACE_LINK_LIBRARIES" "${_Qt5Widgets_LIB_DEPENDENCIES}" 34 | "IMPORTED_LOCATION_${Configuration}" ${imported_location} 35 | "IMPORTED_SONAME_${Configuration}" "libQt5Widgets.so.5" 36 | # For backward compatibility with CMake < 2.8.12 37 | "IMPORTED_LINK_INTERFACE_LIBRARIES_${Configuration}" "${_Qt5Widgets_LIB_DEPENDENCIES}" 38 | ) 39 | 40 | endmacro() 41 | 42 | if (NOT TARGET Qt5::Widgets) 43 | 44 | set(_Qt5Widgets_OWN_INCLUDE_DIRS "${_qt5Widgets_install_prefix}/include/" "${_qt5Widgets_install_prefix}/include/QtWidgets") 45 | set(Qt5Widgets_PRIVATE_INCLUDE_DIRS "") 46 | include("${CMAKE_CURRENT_LIST_DIR}/ExtraSourceIncludes.cmake" OPTIONAL) 47 | 48 | #foreach(_dir ${_Qt5Widgets_OWN_INCLUDE_DIRS}) 49 | # _qt5_Widgets_check_file_exists(${_dir}) 50 | #endforeach() 51 | 52 | # Only check existence of private includes if the Private component is 53 | # specified. 54 | list(FIND Qt5Widgets_FIND_COMPONENTS Private _check_private) 55 | if (NOT _check_private STREQUAL -1) 56 | foreach(_dir ${Qt5Widgets_PRIVATE_INCLUDE_DIRS}) 57 | _qt5_Widgets_check_file_exists(${_dir}) 58 | endforeach() 59 | endif() 60 | 61 | set(Qt5Widgets_INCLUDE_DIRS ${_Qt5Widgets_OWN_INCLUDE_DIRS}) 62 | 63 | set(Qt5Widgets_DEFINITIONS -DQT_WIDGETS_LIB) 64 | set(Qt5Widgets_COMPILE_DEFINITIONS QT_WIDGETS_LIB) 65 | set(_Qt5Widgets_MODULE_DEPENDENCIES "Gui;Core") 66 | 67 | 68 | set(_Qt5Widgets_FIND_DEPENDENCIES_REQUIRED) 69 | if (Qt5Widgets_FIND_REQUIRED) 70 | set(_Qt5Widgets_FIND_DEPENDENCIES_REQUIRED REQUIRED) 71 | endif() 72 | set(_Qt5Widgets_FIND_DEPENDENCIES_QUIET) 73 | if (Qt5Widgets_FIND_QUIETLY) 74 | set(_Qt5Widgets_DEPENDENCIES_FIND_QUIET QUIET) 75 | endif() 76 | set(_Qt5Widgets_FIND_VERSION_EXACT) 77 | if (Qt5Widgets_FIND_VERSION_EXACT) 78 | set(_Qt5Widgets_FIND_VERSION_EXACT EXACT) 79 | endif() 80 | 81 | set(Qt5Widgets_EXECUTABLE_COMPILE_FLAGS "") 82 | 83 | foreach(_module_dep ${_Qt5Widgets_MODULE_DEPENDENCIES}) 84 | if (NOT Qt5${_module_dep}_FOUND) 85 | find_package(Qt5${_module_dep} 86 | 5.8.0 ${_Qt5Widgets_FIND_VERSION_EXACT} 87 | ${_Qt5Widgets_DEPENDENCIES_FIND_QUIET} 88 | ${_Qt5Widgets_FIND_DEPENDENCIES_REQUIRED} 89 | PATHS "${CMAKE_CURRENT_LIST_DIR}/.." NO_DEFAULT_PATH 90 | ) 91 | endif() 92 | 93 | if (NOT Qt5${_module_dep}_FOUND) 94 | set(Qt5Widgets_FOUND False) 95 | return() 96 | endif() 97 | 98 | list(APPEND Qt5Widgets_INCLUDE_DIRS "${Qt5${_module_dep}_INCLUDE_DIRS}") 99 | list(APPEND Qt5Widgets_PRIVATE_INCLUDE_DIRS "${Qt5${_module_dep}_PRIVATE_INCLUDE_DIRS}") 100 | list(APPEND Qt5Widgets_DEFINITIONS ${Qt5${_module_dep}_DEFINITIONS}) 101 | list(APPEND Qt5Widgets_COMPILE_DEFINITIONS ${Qt5${_module_dep}_COMPILE_DEFINITIONS}) 102 | list(APPEND Qt5Widgets_EXECUTABLE_COMPILE_FLAGS ${Qt5${_module_dep}_EXECUTABLE_COMPILE_FLAGS}) 103 | endforeach() 104 | list(REMOVE_DUPLICATES Qt5Widgets_INCLUDE_DIRS) 105 | list(REMOVE_DUPLICATES Qt5Widgets_PRIVATE_INCLUDE_DIRS) 106 | list(REMOVE_DUPLICATES Qt5Widgets_DEFINITIONS) 107 | list(REMOVE_DUPLICATES Qt5Widgets_COMPILE_DEFINITIONS) 108 | list(REMOVE_DUPLICATES Qt5Widgets_EXECUTABLE_COMPILE_FLAGS) 109 | 110 | set(_Qt5Widgets_LIB_DEPENDENCIES "Qt5::Gui;Qt5::Core") 111 | 112 | 113 | add_library(Qt5::Widgets SHARED IMPORTED) 114 | 115 | #set_property(TARGET Qt5::Widgets PROPERTY 116 | # INTERFACE_INCLUDE_DIRECTORIES ${_Qt5Widgets_OWN_INCLUDE_DIRS}) 117 | set_property(TARGET Qt5::Widgets PROPERTY 118 | INTERFACE_COMPILE_DEFINITIONS QT_WIDGETS_LIB) 119 | 120 | _populate_Widgets_target_properties(RELEASE "libQt5Widgets.so.5.8.0" "" ) 121 | 122 | 123 | 124 | 125 | file(GLOB pluginTargets "${CMAKE_CURRENT_LIST_DIR}/Qt5Widgets_*Plugin.cmake") 126 | 127 | macro(_populate_Widgets_plugin_properties Plugin Configuration PLUGIN_LOCATION) 128 | set_property(TARGET Qt5::${Plugin} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${Configuration}) 129 | 130 | set(imported_location "${_qt5Widgets_install_prefix}/plugins/${PLUGIN_LOCATION}") 131 | _qt5_Widgets_check_file_exists(${imported_location}) 132 | set_target_properties(Qt5::${Plugin} PROPERTIES 133 | "IMPORTED_LOCATION_${Configuration}" ${imported_location} 134 | ) 135 | endmacro() 136 | 137 | if (pluginTargets) 138 | foreach(pluginTarget ${pluginTargets}) 139 | include(${pluginTarget}) 140 | endforeach() 141 | endif() 142 | 143 | 144 | include("${CMAKE_CURRENT_LIST_DIR}/Qt5WidgetsConfigExtras.cmake") 145 | 146 | include("${CMAKE_CURRENT_LIST_DIR}/Qt5WidgetsMacros.cmake") 147 | 148 | _qt5_Widgets_check_file_exists("${CMAKE_CURRENT_LIST_DIR}/Qt5WidgetsConfigVersion.cmake") 149 | 150 | endif() 151 | -------------------------------------------------------------------------------- /cmake/Qt5Widgets/Qt5WidgetsConfigExtras.cmake: -------------------------------------------------------------------------------- 1 | 2 | if (NOT TARGET Qt5::uic) 3 | add_executable(Qt5::uic IMPORTED) 4 | 5 | set(imported_location "${_qt5Widgets_install_prefix}/bin/uic") 6 | _qt5_Widgets_check_file_exists(${imported_location}) 7 | 8 | set_target_properties(Qt5::uic PROPERTIES 9 | IMPORTED_LOCATION ${imported_location} 10 | ) 11 | endif() 12 | 13 | include("${CMAKE_CURRENT_LIST_DIR}/Qt5Widgets_AccessibleFactory.cmake" OPTIONAL) 14 | 15 | set(Qt5Widgets_UIC_EXECUTABLE Qt5::uic) 16 | -------------------------------------------------------------------------------- /cmake/Qt5Widgets/Qt5WidgetsConfigVersion.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(PACKAGE_VERSION 5.8.0) 3 | 4 | if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) 5 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 6 | else() 7 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 8 | if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) 9 | set(PACKAGE_VERSION_EXACT TRUE) 10 | endif() 11 | endif() 12 | -------------------------------------------------------------------------------- /cmake/Qt5Widgets/Qt5WidgetsMacros.cmake: -------------------------------------------------------------------------------- 1 | #============================================================================= 2 | # Copyright 2005-2011 Kitware, Inc. 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 9 | # * Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of Kitware, Inc. nor the names of its 17 | # contributors may be used to endorse or promote products derived 18 | # from this software without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | #============================================================================= 32 | 33 | ###################################### 34 | # 35 | # Macros for building Qt files 36 | # 37 | ###################################### 38 | 39 | include(CMakeParseArguments) 40 | 41 | 42 | # qt5_wrap_ui(outfiles inputfile ... ) 43 | 44 | function(QT5_WRAP_UI outfiles ) 45 | set(options) 46 | set(oneValueArgs) 47 | set(multiValueArgs OPTIONS) 48 | 49 | cmake_parse_arguments(_WRAP_UI "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 50 | 51 | set(ui_files ${_WRAP_UI_UNPARSED_ARGUMENTS}) 52 | set(ui_options ${_WRAP_UI_OPTIONS}) 53 | 54 | foreach(it ${ui_files}) 55 | get_filename_component(outfile ${it} NAME_WE) 56 | get_filename_component(infile ${it} ABSOLUTE) 57 | set(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.h) 58 | add_custom_command(OUTPUT ${outfile} 59 | COMMAND ${Qt5Widgets_UIC_EXECUTABLE} 60 | ARGS ${ui_options} -o ${outfile} ${infile} 61 | MAIN_DEPENDENCY ${infile} VERBATIM) 62 | list(APPEND ${outfiles} ${outfile}) 63 | endforeach() 64 | set(${outfiles} ${${outfiles}} PARENT_SCOPE) 65 | endfunction() 66 | -------------------------------------------------------------------------------- /cmake/Requirements.cmake: -------------------------------------------------------------------------------- 1 | # Setup all dependencies, both internal (have to be installed on the system) 2 | # and external (downloaded and built automatically) 3 | 4 | ## Qt 5 | if(ECHOBOT_BUILD_QT5) 6 | include(cmake/ExternalQt5.cmake) 7 | # Use Project Qt CMake files 8 | set(Qt5Core_DIR ${PROJECT_SOURCE_DIR}/cmake/Qt5Core) 9 | set(Qt5Gui_DIR ${PROJECT_SOURCE_DIR}/cmake/Qt5Gui) 10 | set(Qt5Widgets_DIR ${PROJECT_SOURCE_DIR}/cmake/Qt5Widgets) 11 | set(Qt5OpenGL_DIR ${PROJECT_SOURCE_DIR}/cmake/Qt5OpenGL) 12 | set(Qt5Multimedia_DIR ${PROJECT_SOURCE_DIR}/cmake/Qt5Multimedia) 13 | set(Qt5MultimediaWidgets_DIR ${PROJECT_SOURCE_DIR}/cmake/Qt5MultimediaWidgets) 14 | set(Qt5Network_DIR ${PROJECT_SOURCE_DIR}/cmake/Qt5Network) 15 | find_package(Qt5Widgets REQUIRED PATHS ${PROJECT_SOURCE_DIR}/cmake/) 16 | find_package(Qt5OpenGL REQUIRED PATHS ${PROJECT_SOURCE_DIR}/cmake/) 17 | find_package(Qt5Multimedia REQUIRED PATHS ${PROJECT_SOURCE_DIR}/cmake/) 18 | find_package(Qt5MultimediaWidgets REQUIRED PATHS ${PROJECT_SOURCE_DIR}/cmake/) 19 | find_package(Qt5Network REQUIRED PATHS ${PROJECT_SOURCE_DIR}/cmake/) 20 | list(APPEND LIBRARIES ${Qt5Core_LIBRARY}) 21 | list(APPEND LIBRARIES ${Qt5Gui_LIBRARY}) 22 | list(APPEND LIBRARIES ${Qt5Widgets_LIBRARY}) 23 | list(APPEND LIBRARIES ${Qt5OpenGL_LIBRARY}) 24 | list(APPEND LIBRARIES ${Qt5Multimedia_LIBRARY}) 25 | list(APPEND LIBRARIES ${Qt5MultimediaWidgets_LIBRARY}) 26 | list(APPEND LIBRARIES ${Qt5Network_LIBRARY}) 27 | else(ECHOBOT_BUILD_QT5) 28 | find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets OpenGL Multimedia MultimediaWidgets Network) 29 | list(APPEND LIBRARIES Qt5::Core) 30 | list(APPEND LIBRARIES Qt5::Gui) 31 | list(APPEND LIBRARIES Qt5::Widgets) 32 | list(APPEND LIBRARIES Qt5::OpenGL) 33 | list(APPEND LIBRARIES Qt5::Multimedia) 34 | list(APPEND LIBRARIES Qt5::MultimediaWidgets) 35 | list(APPEND LIBRARIES Qt5::Network) 36 | endif(ECHOBOT_BUILD_QT5) 37 | 38 | list(APPEND ECHOBOT_INCLUDE_DIRS ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} 39 | ${Qt5OpenGL_INCLUDE_DIRS} ${Qt5Multimedia_INCLUDE_DIRS} ${Qt5MultimediaWidgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}) 40 | 41 | if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") 42 | add_definitions("-fPIC") # Get rid of Qt error with position independent code 43 | endif() 44 | 45 | qt5_wrap_cpp(HEADERS_MOC ${QT_HEADERS}) 46 | 47 | ## External depedencies 48 | 49 | # FAST 50 | if(ECHOBOT_BUILD_FAST) 51 | include(cmake/ExternalFAST.cmake) 52 | else(ECHOBOT_BUILD_FAST) 53 | find_package(FAST REQUIRED) 54 | list(APPEND LIBRARIES ${FAST_LIBRARIES}) 55 | list(APPEND ECHOBOT_INCLUDE_DIRS ${FAST_INCLUDE_DIRS}) 56 | list(APPEND ECHOBOT_EXTERNAL_LIBRARIES ${FAST_LIBRARY_DIRS}) 57 | endif(ECHOBOT_BUILD_FAST) 58 | 59 | # Clarius streaming 60 | if(ECHOBOT_ENABLE_CLARIUS_STREAMING) 61 | # User has to supply the path to the claris sdk 62 | set(CLARIUS_SDK_DIR "NOT_SET" CACHE PATH "Path to the clarius listen API.") 63 | if(${CLARIUS_SDK_DIR} STREQUAL "NOT_SET") 64 | message(FATAL_ERROR "Clarius ultrasound module was enabled, but Clarius SDK dir has not been set in CMake") 65 | else() 66 | message(STATUS "Clarius ultrasound module enabled. Clarius SDK dir set to: ${CLARIUS_SDK_DIR}") 67 | endif() 68 | 69 | list(APPEND ECHOBOT_INCLUDE_DIRS ${CLARIUS_SDK_DIR}/include) 70 | if(WIN32) 71 | list(APPEND LIBRARIES ${CLARIUS_SDK_DIR}/lib/listen.lib) 72 | else() 73 | list(APPEND LIBRARIES liblisten.so) 74 | link_directories(${CLARIUS_SDK_DIR}/lib/) 75 | endif() 76 | endif() 77 | 78 | # Romocc 79 | if(ECHOBOT_BUILD_ROMOCC) 80 | include(cmake/ExternalRomocc.cmake) 81 | else(ECHOBOT_BUILD_ROMOCC) 82 | find_package(Romocc REQUIRED) 83 | list(APPEND LIBRARIES ${ROMOCC_LIBRARIES}) 84 | list(APPEND ECHOBOT_INCLUDE_DIRS ${ROMOCC_INCLUDE_DIRS}) 85 | list(APPEND ECHOBOT_EXTERNAL_LIBRARIES ${ROMOCC_LIBRARY_DIRS}) 86 | endif(ECHOBOT_BUILD_ROMOCC) 87 | 88 | # Romocc 89 | if(ECHOBOT_BUILD_FMT) 90 | include(cmake/ExternalFMT.cmake) 91 | endif(ECHOBOT_BUILD_FMT) 92 | 93 | # Make sure project can find external includes and libaries 94 | link_directories(${ECHOBOT_EXTERNAL_INSTALL_DIR}/lib/ ${ECHOBOT_EXTERNAL_LIBRARIES}) 95 | list(APPEND ECHOBOT_INCLUDE_DIRS ${ECHOBOT_EXTERNAL_INSTALL_DIR}/include) -------------------------------------------------------------------------------- /source/EchoBot/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project_add_subdirectories(GUI Interfaces Tests Visualization Utilities Exporters Core) -------------------------------------------------------------------------------- /source/EchoBot/Core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project_add_sources( 2 | SmartPointers.h 3 | Config.cpp 4 | Config.h 5 | DataTypes.cpp 6 | DataTypes.h 7 | ) -------------------------------------------------------------------------------- /source/EchoBot/Core/Config.cpp: -------------------------------------------------------------------------------- 1 | #include "Config.h" 2 | #include "EchoBot/Utilities/Utilities.h" 3 | 4 | #include 5 | #include 6 | 7 | namespace echobot{ 8 | namespace Config{ 9 | namespace { 10 | // Initialize global variables, put in anonymous namespace to hide them 11 | bool mConfigurationLoaded = false; 12 | std::string mConfigFilename = ""; 13 | std::string mBasePath = ""; 14 | std::string mDataPath; 15 | std::string mConfigPath; 16 | std::string mTestDataPath; 17 | std::string mLibraryPath; 18 | } 19 | 20 | 21 | std::string getPath() { 22 | if (mBasePath != "") 23 | return mBasePath; 24 | std::string path = ""; 25 | std::string slash = "/"; 26 | 27 | Dl_info dl_info; 28 | int ret = dladdr((void *)&getPath, &dl_info); 29 | const char* dlpath = dl_info.dli_fname; 30 | path = std::string(dlpath); 31 | // Remove lib name and lib folder 32 | int libPos = path.rfind(slash + "lib" + slash); 33 | 34 | path = path.substr(0, libPos); 35 | path = path + slash; // Make sure there is a slash at the end 36 | 37 | return path; 38 | } 39 | 40 | void loadConfiguration() { 41 | if (mConfigurationLoaded) 42 | return; 43 | 44 | // Set default paths 45 | mDataPath = getPath() + "../data/"; 46 | mLibraryPath = getPath() + "/lib/"; 47 | mConfigPath = getPath() + "../config/"; 48 | 49 | // Read and parse configuration file 50 | // It should reside in the build folder when compiling, and in the root folder when using release 51 | std::string filename; 52 | if(mConfigFilename == "") { 53 | filename = getPath() + "echobot_configuration.txt"; 54 | } 55 | else { 56 | filename = mConfigFilename; 57 | } 58 | 59 | std::ifstream file(filename); 60 | if (!file.is_open()) { 61 | mConfigurationLoaded = true; 62 | return; 63 | } 64 | 65 | std::string line; 66 | std::getline(file, line); 67 | while (!file.eof()) { 68 | trim(line); 69 | if (line[0] == '#' || line.size() == 0) { 70 | // Comment or empty line, skip 71 | std::getline(file, line); 72 | continue; 73 | } 74 | std::vector list = split(line, "="); 75 | std::string key = list[0]; 76 | std::string value = list[1]; 77 | trim(key); 78 | trim(value); 79 | value = replace(value, "@ROOT@", getPath()); 80 | 81 | if (key == "DataPath") { 82 | mDataPath = value; 83 | } 84 | 85 | std::getline(file, line); 86 | } 87 | file.close(); 88 | mConfigurationLoaded = true; 89 | } 90 | 91 | std::string getRegistrationDataPath() { 92 | loadConfiguration(); 93 | return mDataPath + "registration/"; 94 | } 95 | 96 | std::string getDataPath() { 97 | loadConfiguration(); 98 | return mDataPath; 99 | } 100 | 101 | std::string getTestDataPath() { 102 | loadConfiguration(); 103 | return mDataPath + "testdata/"; 104 | } 105 | 106 | std::string getNeuralNetworkModelPath() { 107 | loadConfiguration(); 108 | return mDataPath + "nn_models/"; 109 | } 110 | 111 | std::string getConfigPath() { 112 | loadConfiguration(); 113 | return mConfigPath; 114 | } 115 | } 116 | } 117 | 118 | -------------------------------------------------------------------------------- /source/EchoBot/Core/Config.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by androst on 12.01.20. 3 | // 4 | 5 | #ifndef ECHOBOT_CONFIG_H 6 | #define ECHOBOT_CONFIG_H 7 | 8 | #include 9 | #include 10 | 11 | namespace echobot{ 12 | 13 | namespace Config{ 14 | ECHOBOT_EXPORT std::string getRegistrationDataPath(); 15 | ECHOBOT_EXPORT std::string getTestDataPath(); 16 | ECHOBOT_EXPORT std::string getConfigPath(); 17 | ECHOBOT_EXPORT std::string getNeuralNetworkModelPath(); 18 | } 19 | 20 | 21 | } 22 | 23 | #endif //ECHOBOT_CONFIG_H 24 | -------------------------------------------------------------------------------- /source/EchoBot/Core/DataTypes.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by androst on 12.01.20. 3 | // 4 | 5 | #include "DataTypes.h" 6 | -------------------------------------------------------------------------------- /source/EchoBot/Core/DataTypes.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by androst on 12.01.20. 3 | // 4 | 5 | #ifndef ECHOBOT_DATATYPES_H 6 | #define ECHOBOT_DATATYPES_H 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include "FAST/Importers/ImageFileImporter.hpp" 20 | #include "FAST/Importers/VTKMeshFileImporter.hpp" 21 | 22 | #include "FAST/Algorithms/SurfaceExtraction/SurfaceExtraction.hpp" 23 | #include "FAST/Algorithms/ImageResizer/ImageResizer.hpp" 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include 39 | 40 | namespace echobot{ 41 | using Eigen::Affine3f; 42 | using Eigen::Matrix3f; 43 | using Eigen::Vector3f; 44 | using Eigen::VectorXf; 45 | using Eigen::MatrixXf; 46 | 47 | using fast::ProcessObject; 48 | using fast::DataChannel; 49 | using fast::DataObject; 50 | using fast::Color; 51 | using fast::Image; 52 | using fast::AffineTransformation; 53 | using fast::Renderer; 54 | using fast::Streamer; 55 | using fast::Mesh; 56 | using fast::VertexRenderer; 57 | using fast::ImageRenderer; 58 | using fast::LineRenderer; 59 | using fast::RealSenseStreamer; 60 | using fast::ImageFileStreamer; 61 | using fast::MeshFileStreamer; 62 | using fast::MeshVertex; 63 | using fast::MeshTriangle; 64 | using fast::TriangleRenderer; 65 | using fast::Window; 66 | using fast::View; 67 | using fast::FileExporter; 68 | using fast::MetaImageExporter; 69 | using fast::ImageFileImporter; 70 | using fast::ImageResizer; 71 | using fast::SurfaceExtraction; 72 | using fast::VTKMeshFileImporter; 73 | using fast::SegmentationNetwork; 74 | using fast::SegmentationRenderer; 75 | 76 | using romocc::TransformUtils::Affine::toVector6D; 77 | using romocc::TransformUtils::Affine::toAffine3DFromVector6D; 78 | } 79 | 80 | #endif //ECHOBOT_DATATYPES_H 81 | -------------------------------------------------------------------------------- /source/EchoBot/Core/SmartPointers.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by androst on 30.05.19. 3 | // 4 | 5 | #ifndef ECHOBOT_SMARTPOINTERS_H 6 | #define ECHOBOT_SMARTPOINTERS_H 7 | 8 | #pragma once 9 | #include 10 | 11 | #define ECHOBOT_OBJECT(className) \ 12 | public: \ 13 | typedef SharedPointer pointer; \ 14 | static SharedPointer New() { \ 15 | SharedPointer smartPtr(new className()); \ 16 | smartPtr->setPtr(smartPtr); \ 17 | \ 18 | return smartPtr; \ 19 | } \ 20 | virtual std::string getNameOfClass() const { \ 21 | return std::string(#className); \ 22 | }; \ 23 | static std::string getStaticNameOfClass() { \ 24 | return std::string(#className); \ 25 | }; \ 26 | private: \ 27 | void setPtr(className::pointer ptr) { \ 28 | mPtr = ptr; \ 29 | } \ 30 | 31 | 32 | 33 | #ifdef WIN32 34 | 35 | namespace echobot { 36 | 37 | template 38 | class SharedPointer : public std::shared_ptr { 39 | using std::shared_ptr::shared_ptr; // inherit constructor 40 | 41 | }; 42 | 43 | }; // end namespace echobot 44 | 45 | // Custom hashing functions for the smart pointers so that they can be used in unordered_map etc. 46 | namespace std { 47 | template 48 | class hash >{ 49 | public: 50 | size_t operator()(const echobot::SharedPointer &object) const { 51 | return (std::size_t)object.get(); 52 | } 53 | }; 54 | 55 | } // end namespace std 56 | 57 | #else 58 | 59 | namespace echobot { 60 | 61 | template 62 | using SharedPointer = std::shared_ptr; 63 | 64 | } 65 | 66 | #endif 67 | 68 | 69 | #endif //ECHOBOT_SMARTPOINTERS_H 70 | -------------------------------------------------------------------------------- /source/EchoBot/Exporters/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project_add_sources( 2 | PointCloudExporter.cpp 3 | PointCloudExporter.h 4 | ) 5 | 6 | project_add_test_sources( 7 | Tests/PointCloudExporterTests.cpp 8 | ) -------------------------------------------------------------------------------- /source/EchoBot/Exporters/PointCloudExporter.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by androst on 20.12.19. 3 | // 4 | 5 | #include "PointCloudExporter.h" 6 | #include "FAST/Data/Mesh.hpp" 7 | #include "FAST/SceneGraph.hpp" 8 | #include 9 | 10 | 11 | namespace echobot { 12 | 13 | 14 | PointCloudExporter::PointCloudExporter() { 15 | createInputPort(0); 16 | mWriteNormals = false; 17 | mWriteColors = false; 18 | } 19 | 20 | void PointCloudExporter::setWriteNormals(bool writeNormals) { 21 | mWriteNormals = writeNormals; 22 | } 23 | 24 | void PointCloudExporter::setWriteColors(bool writeColors) { 25 | mWriteColors = writeColors; 26 | } 27 | 28 | void PointCloudExporter::execute() { 29 | if(mFilename == "") 30 | throw fast::Exception("No filename given to the PointCloudExporter"); 31 | 32 | auto mesh = getInputData(); 33 | 34 | // Get transformation 35 | auto transform = fast::SceneGraph::getAffineTransformationFromData(mesh)->getTransform(); 36 | 37 | FILE *file; 38 | file = fopen(mFilename.c_str(), "w"); 39 | 40 | if(!file) 41 | throw fast::Exception("Unable to open the file " + mFilename); 42 | 43 | fmt::memory_buffer buffer; 44 | 45 | // Write header 46 | fmt::format_to(buffer, "# vtk DataFile Version 3.0\n"); 47 | fmt::format_to(buffer, "vtk output\n"); 48 | fmt::format_to(buffer, "ASCII\n", ""); 49 | fmt::format_to(buffer, "DATASET POLYDATA\n"); 50 | 51 | // Write vertices 52 | auto access = mesh->getMeshAccess(ACCESS_READ); 53 | auto vertices = access->getVertices(); 54 | 55 | auto start = std::chrono::high_resolution_clock::now(); 56 | 57 | fmt::format_to(buffer, "POINTS {} float\n", vertices.size()); 58 | for(auto vertex : vertices) { 59 | auto point = (transform.matrix() * vertex.getPosition().homogeneous()).head(3); 60 | fmt::format_to(buffer, "{0} {1} {2}\n", point.x(), point.y(), point.z()); 61 | } 62 | 63 | if (mesh->getNrOfTriangles() > 0) { 64 | std::vector triangles = access->getTriangles(); 65 | // Write triangles 66 | 67 | fmt::format_to(buffer, "POLYGONS {0} {1}\n", mesh->getNrOfTriangles(), mesh->getNrOfTriangles() * 4); 68 | for (auto triangle : triangles) { 69 | fmt::format_to(buffer, "3 {0} {1} {2}\n", triangle.getEndpoint1(), triangle.getEndpoint2(), 70 | triangle.getEndpoint3()); 71 | } 72 | 73 | } 74 | 75 | if (mesh->getNrOfLines() > 0) { 76 | // Write lines 77 | auto lines = access->getLines(); 78 | fmt::format_to(buffer, "LINES {0} {1}\n", mesh->getNrOfLines(), mesh->getNrOfLines() * 3); 79 | 80 | for (auto line : lines) { 81 | fmt::format_to(buffer, "2 {0} {1}\n", line.getEndpoint1(), line.getEndpoint2()); 82 | } 83 | } 84 | 85 | if (mWriteNormals) { 86 | fmt::format_to(buffer, "POINTS_DATA {}\n", vertices.size()); 87 | fmt::format_to(buffer, "NORMALS Normals float\n"); 88 | 89 | for (auto vertex : vertices) { 90 | VectorXf normal = vertex.getNormal(); 91 | normal = transform.linear() * normal; // Transform the normal 92 | 93 | // Normalize it 94 | float length = normal.norm(); 95 | if (length == 0) { // prevent NaN situations 96 | fmt::format_to(buffer, "0 1 0\n"); 97 | } else { 98 | normal.normalize(); 99 | fmt::format_to(buffer, "{0} {1} {2}\n", normal.x(), normal.y(), normal.z()); 100 | } 101 | auto normals_part_stop = std::chrono::high_resolution_clock::now(); 102 | } 103 | } 104 | 105 | if (mWriteColors) { 106 | fmt::format_to(buffer, "POINTS_DATA {}\n", vertices.size()); 107 | fmt::format_to(buffer, "VECTORS vertex_colors float\n"); 108 | 109 | for (auto vertex : vertices) { 110 | Color color = vertex.getColor(); 111 | fmt::format_to(buffer, "{0} {1} {2}\n", color.getRedValue(), color.getGreenValue(), 112 | color.getBlueValue()); 113 | } 114 | } 115 | 116 | std::string out = fmt::to_string(buffer); 117 | fwrite(out.c_str(), 1, out.length(), file); 118 | fclose(file); 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /source/EchoBot/Exporters/PointCloudExporter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by androst on 20.12.19. 3 | // 4 | 5 | #ifndef ECHOBOT_POINTCLOUDEXPORTER_H 6 | #define ECHOBOT_POINTCLOUDEXPORTER_H 7 | 8 | #include "EchoBot/Core/SmartPointers.h" 9 | #include "EchoBot/Core/DataTypes.h" 10 | 11 | #include "FAST/Exporters/FileExporter.hpp" 12 | 13 | namespace echobot { 14 | 15 | class PointCloudExporter : public FileExporter { 16 | ECHOBOT_OBJECT(PointCloudExporter) 17 | 18 | public: 19 | void setWriteNormals(bool writeNormals); 20 | void setWriteColors(bool writeColors); 21 | 22 | private: 23 | PointCloudExporter(); 24 | void execute(); 25 | 26 | bool mWriteNormals; 27 | bool mWriteColors; 28 | 29 | std::stringstream ss; 30 | }; 31 | 32 | } 33 | 34 | 35 | 36 | #endif //ECHOBOT_POINTCLOUDEXPORTER_H 37 | -------------------------------------------------------------------------------- /source/EchoBot/Exporters/Tests/PointCloudExporterTests.cpp: -------------------------------------------------------------------------------- 1 | #include "EchoBot/Tests/catch.hpp" 2 | #include "EchoBot/Exporters/PointCloudExporter.h" 3 | #include "FAST/Data/Mesh.hpp" 4 | 5 | using namespace echobot; 6 | 7 | TEST_CASE("Export point cloud", "[EchoBot][Exporters]") { 8 | Mesh::pointer mesh = Mesh::New(); 9 | std::vector vertices = { 10 | MeshVertex(Vector3f(1, 1, 1)), 11 | MeshVertex(Vector3f(1, 1, 10)), 12 | MeshVertex(Vector3f(1, 10, 10)), 13 | 14 | MeshVertex(Vector3f(1, 1, 1)), 15 | MeshVertex(Vector3f(1, 1, 10)), 16 | MeshVertex(Vector3f(30, 15, 15)), 17 | 18 | MeshVertex(Vector3f(1, 1, 10)), 19 | MeshVertex(Vector3f(1, 10, 10)), 20 | MeshVertex(Vector3f(30, 15, 15)), 21 | 22 | MeshVertex(Vector3f(1, 1, 1)), 23 | MeshVertex(Vector3f(1, 10, 10)), 24 | MeshVertex(Vector3f(30, 15, 15)) 25 | }; 26 | std::vector triangles = { 27 | MeshTriangle(0, 1, 2), 28 | MeshTriangle(3, 4, 5), 29 | MeshTriangle(6, 7, 8), 30 | MeshTriangle(9, 10, 11) 31 | }; 32 | 33 | mesh->create(vertices, {}, triangles); 34 | 35 | auto exporter = PointCloudExporter::New(); 36 | exporter->setInputData(mesh); 37 | exporter->setFilename("VTKMeshFileExporter3DTest.vtk"); 38 | CHECK_NOTHROW(exporter->update()); 39 | } -------------------------------------------------------------------------------- /source/EchoBot/GUI/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project_add_subdirectories(Widgets) 2 | -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project_add_sources( 2 | RobotManualMoveWidget.cpp 3 | RobotManualMoveWidget.h 4 | ConnectionWidget.cpp 5 | ConnectionWidget.h 6 | RecordWidget.cpp 7 | RecordWidget.h 8 | CalibrationWidget.cpp 9 | CalibrationWidget.h 10 | ) -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/CalibrationWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef ECHOBOT_CALIBRATIONWIDGET_H 2 | #define ECHOBOT_CALIBRATIONWIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "EchoBot/Interfaces/Robot/RobotInterface.h" 10 | #include "EchoBot/Interfaces/Camera/CameraInterface.hpp" 11 | #include "EchoBot/Interfaces/Ultrasound/UltrasoundInterface.hpp" 12 | #include "EchoBot/Utilities/CalibrationTool.h" 13 | 14 | class QPushButton; 15 | class QDoubleSpinBox; 16 | class QComboBox; 17 | 18 | namespace echobot 19 | { 20 | 21 | class CalibrationWidget : public QTabWidget 22 | { 23 | Q_OBJECT 24 | 25 | public: 26 | CalibrationWidget(int widgetWidth=540, int widgetHeight=220); 27 | void addInterface(SensorInterface::pointer sensorInterface); 28 | void calibrateSystem(); 29 | CalibrationTool::pointer getCalibrationTool(){return mCalibrationTool;}; 30 | 31 | private: 32 | void setupWidget(); 33 | void setupConnections(); 34 | 35 | int mWidgetWidth; 36 | int mWidgetHeight; 37 | 38 | SharedPointer mRobotInterface; 39 | SharedPointer mCameraInterface; 40 | SharedPointer mUltrasoundInterface; 41 | SharedPointer mCalibrationTool; 42 | 43 | QPushButton *mCalibrateButton, *mSaveMatrixButton; 44 | QDoubleSpinBox *mRXSpinBox, *mRYSpinBox, *mRZSpinBox, *mXSpinBox, *mYSpinBox, *mZSpinBox; 45 | QComboBox *mMatrixComboBox; 46 | 47 | QWidget* getCalibrationWidget(); 48 | QWidget* getCalibrationModificationWidget(); 49 | 50 | void updateToolToUSTransform(); 51 | Vector6d getVectorFromSpinboxes(); 52 | 53 | private slots: 54 | void updateSpinBoxes(); 55 | void updateCalibration(); 56 | void saveMatrixToFile(); 57 | }; 58 | 59 | } // end namespace echobot 60 | 61 | #endif //ECHOBOT_CALIBRATIONWIDGET_H 62 | -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/ConnectionWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef ECHOBOT_CONNECTIONWIDGET_H 2 | #define ECHOBOT_CONNECTIONWIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "EchoBot/Interfaces/Robot/RobotInterface.h" 10 | #include "EchoBot/Interfaces/Ultrasound/UltrasoundInterface.hpp" 11 | #include "EchoBot/Interfaces/Camera/CameraInterface.hpp" 12 | 13 | namespace echobot 14 | { 15 | 16 | class ConnectionWidget : public QTabWidget 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | ConnectionWidget(int widgetWidth=540, int widgetHeight=160); 22 | void addInterface(SensorInterface::pointer sensorInterface); 23 | 24 | signals: 25 | void robotConnected(); 26 | void robotDisconnected(); 27 | void robotShutdown(); 28 | void cameraConnected(); 29 | void cameraDisconnected(); 30 | void usConnected(); 31 | void usDisconnected(); 32 | 33 | public slots: 34 | void updateCameraROI(); 35 | 36 | private slots: 37 | void robotShutdownSlot(); 38 | void usStreamerChangedSlot(const QString streamerOption); 39 | 40 | void robotToggleConnection(); 41 | void usToggleConnection(); 42 | void cameraToggleConnection(); 43 | 44 | private: 45 | int mWidgetWidth; 46 | int mWidgetHeight; 47 | 48 | SharedPointer mRobotInterface; 49 | SharedPointer mCameraInterface; 50 | SharedPointer mUltrasoundInterface; 51 | 52 | QLineEdit *mRobotIPLineEdit, *mUsIPLineEdit, *mCameraMinDepthLineEdit,*mCameraMaxDepthLineEdit; 53 | QPushButton *mCameraConnectionButton, *mUSConnectionButton, *mRobotConnectionButton, *mRobotShutdownButton;; 54 | QComboBox *mUSStreamerOptionCBox, *mRobotOptionCBox; 55 | QLineEdit *mCameraMinWidthLineEdit, *mCameraMaxWidthLineEdit, *mCameraMinHeightLineEdit, *mCameraMaxHeightLineEdit; 56 | 57 | QString mGraphicsFolderName; 58 | bool mRobotConnected = false; 59 | bool mUSConnected = false; 60 | bool mCameraConnected = false; 61 | 62 | QWidget* createRobotConnectionWidget(); 63 | QWidget* createCameraConnectionWidget(); 64 | QWidget* createUltrasoundConnectionWidget(); 65 | }; 66 | 67 | } 68 | 69 | #endif //ECHOBOT_CONNECTIONWIDGET_H 70 | -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/application-exit-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/application-exit-4.png -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/arrow-down-double.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/arrow-down-double.png -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/arrow-down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/arrow-down.png -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/arrow-left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/arrow-left.png -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/arrow-right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/arrow-right.png -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/arrow-up-double.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/arrow-up-double.png -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/arrow-up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/arrow-up.png -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/button-blue.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/button-blue.ico -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/button-green.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/button-green.ico -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/button-red.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/button-red.ico -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/edit-redo-7.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/edit-redo-7.ico -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/edit-undo-7.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/edit-undo-7.ico -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/folder-2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/folder-2.ico -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/network-idle.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/network-idle.ico -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/network-offline.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/network-offline.ico -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/network-transmit-receive.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/network-transmit-receive.ico -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/off.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/off.ico -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/on.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/on.ico -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/ryNeg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/ryNeg.png -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/ryPos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/ryPos.png -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/rzNeg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/rzNeg.png -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/rzPos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/rzPos.png -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/systemexit.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/systemexit.ico -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/user-available.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/user-available.ico -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/user-busy.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/user-busy.ico -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/xNeg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/xNeg.png -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/xPos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/xPos.png -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/y.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/y.ico -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/yNeg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/yNeg.png -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/Icons/yPos.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SINTEFMedtek/EchoBot/ce08f2d81cb7a2b4236068bff6eab6de56731632/source/EchoBot/GUI/Widgets/Icons/yPos.png -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/RecordWidget.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by androst on 14.02.19. 3 | // 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "RecordWidget.h" 27 | 28 | namespace echobot 29 | { 30 | 31 | RecordWidget::RecordWidget(SharedPointer cameraInterface, SharedPointer usInterface, 32 | int widgetWidth, int widgetHeight) : 33 | mCameraInterface(cameraInterface), 34 | mUltrasoundInterface(usInterface), 35 | mWidgetWidth(widgetWidth), 36 | mWidgetHeight(widgetHeight) 37 | { 38 | setupWidget(); 39 | setupConnections(); 40 | 41 | this->setFixedWidth(mWidgetWidth); 42 | this->setFixedHeight(mWidgetHeight); 43 | 44 | mRecordTool = RecordTool::New(); 45 | } 46 | 47 | void RecordWidget::setupWidget() 48 | { 49 | QWidget *recordWidget = getRecordWidget(); 50 | this->addTab(recordWidget, "Record exam"); 51 | 52 | QWidget *settingsRecordWidget = getSettingsRecordWidget(); 53 | this->addTab(settingsRecordWidget, "Settings"); 54 | } 55 | 56 | void RecordWidget::setupConnections() 57 | { 58 | QObject::connect(mPlayButton, &QPushButton::clicked, std::bind(&RecordWidget::playRecording, this)); 59 | QObject::connect(mRecordButton, &QPushButton::clicked, std::bind(&RecordWidget::toggleRecord, this)); 60 | } 61 | 62 | void RecordWidget::toggleRecord() { 63 | mRecording = !mRecording; 64 | if(mRecording) { 65 | mRecordButton->setText("Stop recording"); 66 | mRecordButton->setStyleSheet("QPushButton { background-color: red; color: white; }"); 67 | mStorageDir->setDisabled(true); 68 | mRecordTimer->start(); 69 | 70 | // Create recording pathkom 71 | std::string path = mStorageDir->text().toUtf8().constData(); 72 | if(mRecordingNameLineEdit->text() != "") { 73 | mRecordingName = fast::currentDateTime() + " " + mRecordingNameLineEdit->text().toUtf8().constData(); 74 | } else { 75 | mRecordingName = fast::currentDateTime(); 76 | } 77 | std::string recordingPath = (QString(path.c_str()) + QDir::separator() + QString(mRecordingName.c_str()) + QDir::separator()).toUtf8().constData(); 78 | 79 | std::cout << "Getting ready to start recording..." << std::endl; 80 | if(mPointCloudDumpCheckBox->isChecked() && mCameraInterface->isConnected()) 81 | mRecordTool->addRecordChannel("PointClouds", mCameraInterface->getOutputPort(3)); 82 | 83 | if(mImageDumpCheckBox->isChecked() && mCameraInterface->isConnected()) 84 | mRecordTool->addRecordChannel("CameraImages", mCameraInterface->getOutputPort(0)); 85 | 86 | if(mUltrasoundDumpCheckBox->isChecked() && mUltrasoundInterface->isConnected()) 87 | mRecordTool->addRecordChannel("Ultrasound", mUltrasoundInterface->getOutputPort(0)); 88 | 89 | mRecordTool->startRecording(recordingPath); 90 | 91 | QTimer *timer = new QTimer(this); 92 | QObject::connect(timer, &QTimer::timeout, std::bind(&RecordWidget::updateQueueSize, this)); 93 | timer->start(100); 94 | } else { 95 | mRecordButton->setText("Record"); 96 | mRecordButton->setStyleSheet("QPushButton { background-color: green; color: white; }"); 97 | mStorageDir->setDisabled(false); 98 | mRecordTool->stopRecording(); 99 | refreshRecordingsList(); 100 | } 101 | } 102 | 103 | void RecordWidget::refreshRecordingsList() { 104 | // Get all folders in the folder mStorageDir 105 | QDirIterator it(mStorageDir->text()); 106 | mRecordingsList->clear(); 107 | while(it.hasNext()) { 108 | it.next(); 109 | QString next = it.fileName(); 110 | if(next.size() > 4) 111 | mRecordingsList->addItem(next); 112 | } 113 | } 114 | 115 | void RecordWidget::updateQueueSize() { 116 | auto queueSize = mRecordTool->getQueueSize(); 117 | mRecordingInformation->setText("Data dumping: " + QString::number(queueSize) + " objects left. " 118 | "Don't close application."); 119 | 120 | if(queueSize == 0) 121 | mRecordingInformation->setHidden(true); 122 | } 123 | 124 | void RecordWidget::playRecording() { 125 | mCameraPlayback = !mCameraPlayback; 126 | if(!mCameraPlayback) { 127 | mPlayButton->setText("Play"); 128 | mPlayButton->setStyleSheet("QPushButton { background-color: green; color: white; }"); 129 | emit(playbackStopped()); 130 | } else { 131 | auto selectedItems = mRecordingsList->selectedItems(); 132 | if(selectedItems.size() == 0) { 133 | // Show error message 134 | QMessageBox *message = new QMessageBox; 135 | message->setWindowTitle("Error"); 136 | message->setText("You did not select a recording."); 137 | message->show(); 138 | return; 139 | } 140 | 141 | std::string selectedRecording = ( 142 | mStorageDir->text() + 143 | QDir::separator() + 144 | selectedItems[0]->text() + 145 | QDir::separator() 146 | ).toUtf8().constData(); 147 | 148 | std::string selectedRecordingPointClouds = selectedRecording + "/PointClouds/"; 149 | std::string selectedRecordingImages = selectedRecording + "/CameraImages/"; 150 | std::string selectedRecordingUS = selectedRecording + "/Ultrasound/"; 151 | 152 | // Set up streaming from disk 153 | if(QDir(QString::fromStdString(selectedRecordingImages)).exists() && 154 | QDir(QString::fromStdString(selectedRecordingPointClouds)).exists()) 155 | { 156 | mCameraInterface->setPlayback(selectedRecording); 157 | mCameraInterface->connect(); 158 | } 159 | 160 | if(QDir(QString::fromStdString(selectedRecordingUS)).exists()) 161 | { 162 | mUltrasoundInterface->setPlayback(selectedRecordingUS + "Image-2D_#.mhd"); 163 | mUltrasoundInterface->connect(); 164 | } 165 | 166 | emit(this->playbackStarted()); 167 | 168 | mPlayButton->setText("Stop"); 169 | mPlayButton->setStyleSheet("QPushButton { background-color: red; color: white; }"); 170 | } 171 | } 172 | 173 | QWidget* RecordWidget::getRecordWidget() 174 | { 175 | QGroupBox* group = new QGroupBox(); 176 | group->setFlat(true); 177 | 178 | QGridLayout *mainLayout = new QGridLayout(); 179 | group->setLayout(mainLayout); 180 | 181 | mRecordTimer = new QElapsedTimer; 182 | 183 | QLabel* storageDirLabel = new QLabel; 184 | storageDirLabel->setText("Storage directory:"); 185 | mainLayout->addWidget(storageDirLabel, 0, 0, 1, 1); 186 | 187 | mStorageDir = new QLineEdit; 188 | mStorageDir->setText(QDir::homePath() + QDir::separator() + QString("EchoBot_Recordings")); 189 | mainLayout->addWidget(mStorageDir, 0, 1, 1, 1); 190 | 191 | QLabel* recordingNameLabel = new QLabel; 192 | recordingNameLabel->setText("Subject name:"); 193 | mainLayout->addWidget(recordingNameLabel, 1, 0, 1, 1); 194 | 195 | mRecordingNameLineEdit = new QLineEdit; 196 | mainLayout->addWidget(mRecordingNameLineEdit, 1, 1, 1, 1); 197 | 198 | mRecordButton = new QPushButton; 199 | mRecordButton->setText("Record"); 200 | mRecordButton->setStyleSheet("QPushButton { background-color: green; color: white; }"); 201 | mainLayout->addWidget(mRecordButton, 2, 0, 1, 1); 202 | 203 | mPlayButton = new QPushButton; 204 | mPlayButton->setText("Play"); 205 | mPlayButton->setStyleSheet("QPushButton { background-color: green; color: white; }"); 206 | mainLayout->addWidget(mPlayButton, 2, 1, 1, 1); 207 | 208 | mRecordingsList = new QListWidget; 209 | mainLayout->addWidget(mRecordingsList, 3, 0, 1, 2); 210 | mRecordingsList->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); 211 | mRecordingsList->setSortingEnabled(true); 212 | refreshRecordingsList(); 213 | 214 | mRecordingInformation = new QLabel; 215 | mRecordingInformation->setStyleSheet("QLabel { font-size: 14px; }"); 216 | mainLayout->addWidget(mRecordingInformation, 4, 0, 1, 2); 217 | 218 | return group; 219 | } 220 | 221 | QWidget* RecordWidget::getSettingsRecordWidget() 222 | { 223 | QGroupBox* group = new QGroupBox(); 224 | group->setFlat(true); 225 | 226 | QGridLayout *mainLayout = new QGridLayout(); 227 | group->setLayout(mainLayout); 228 | 229 | mImageDumpCheckBox = new QCheckBox("Camera Images"); 230 | mImageDumpCheckBox->setLayoutDirection(Qt::RightToLeft); 231 | mImageDumpCheckBox->setChecked(true); 232 | 233 | mPointCloudDumpCheckBox = new QCheckBox("Camera point clouds"); 234 | mPointCloudDumpCheckBox->setLayoutDirection(Qt::RightToLeft); 235 | mPointCloudDumpCheckBox->setChecked(true); 236 | 237 | mUltrasoundDumpCheckBox = new QCheckBox("Ultrasound images"); 238 | mUltrasoundDumpCheckBox->setLayoutDirection(Qt::RightToLeft); 239 | mUltrasoundDumpCheckBox->setChecked(true); 240 | 241 | mainLayout->addWidget(mImageDumpCheckBox, 0, 0, 1, 1); 242 | mainLayout->addWidget(mPointCloudDumpCheckBox, 1, 0, 1, 1); 243 | mainLayout->addWidget(mUltrasoundDumpCheckBox, 2, 0, 1, 1); 244 | 245 | return group; 246 | } 247 | 248 | } -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/RecordWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef ECHOBOT_RECORDWIDGET_H 2 | #define ECHOBOT_RECORDWIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "FAST/Streamers/ImageFileStreamer.hpp" 11 | #include "FAST/Streamers/MeshFileStreamer.hpp" 12 | 13 | #include "EchoBot/Interfaces/Robot/RobotInterface.h" 14 | #include "EchoBot/Interfaces/Ultrasound/UltrasoundInterface.hpp" 15 | #include "EchoBot/Interfaces/Camera/CameraInterface.hpp" 16 | #include "EchoBot/Utilities/RecordTool.h" 17 | 18 | class QPushButton; 19 | class QLabel; 20 | class QTabWidget; 21 | class QElapsedTimer; 22 | class QListWidget; 23 | 24 | namespace echobot 25 | { 26 | 27 | class RecordWidget : public QTabWidget 28 | { 29 | Q_OBJECT 30 | 31 | public: 32 | RecordWidget(SharedPointer cameraInterface, SharedPointer usInterface, 33 | int widgetWidth=540, int widgetHeight=220); 34 | 35 | signals: 36 | void recordingStarted(); 37 | void playbackStarted(); 38 | void playbackStopped(); 39 | 40 | private: 41 | void setupWidget(); 42 | void setupConnections(); 43 | 44 | int mWidgetWidth; 45 | int mWidgetHeight; 46 | 47 | SharedPointer mRobotInterface; 48 | SharedPointer mCameraInterface; 49 | SharedPointer mUltrasoundInterface; 50 | SharedPointer mRecordTool; 51 | 52 | QPushButton *mRecordButton, *mPlayButton; 53 | QLineEdit* mStorageDir, *mRecordingNameLineEdit; 54 | QLabel* mRecordingInformation; 55 | QElapsedTimer* mRecordTimer; 56 | QListWidget* mRecordingsList; 57 | QCheckBox *mImageDumpCheckBox, *mPointCloudDumpCheckBox, *mUltrasoundDumpCheckBox; 58 | 59 | std::string mRecordingName; 60 | std::unordered_map mPlaybackStreamers; 61 | 62 | QWidget* getRecordWidget(); 63 | QWidget* getSettingsRecordWidget(); 64 | 65 | void refreshRecordingsList(); 66 | void toggleRecord(); 67 | void playRecording(); 68 | 69 | bool mRecording = false; 70 | bool mCameraPlayback = false; 71 | bool mCameraStreaming = false; 72 | 73 | void updateQueueSize(); 74 | }; 75 | 76 | } // end namespace echobot 77 | 78 | #endif //ECHOBOT_RECORDWIDGET_H 79 | -------------------------------------------------------------------------------- /source/EchoBot/GUI/Widgets/RobotManualMoveWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef ROBOTMANUALMOVEWIDGET_H 2 | #define ROBOTMANUALMOVEWIDGET_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "EchoBot/Interfaces/Robot/RobotInterface.h" 12 | 13 | /** 14 | * Implementation of Manual motion GUI tab. 15 | * 16 | * 17 | * \author Andreas Østvik 18 | */ 19 | 20 | 21 | namespace echobot 22 | { 23 | 24 | class RobotManualMoveWidget : public QWidget 25 | { 26 | Q_OBJECT 27 | 28 | public: 29 | RobotManualMoveWidget(RobotInterface::pointer robotInterface, int widgetWidth=540, int widgetHeight=380); 30 | virtual ~RobotManualMoveWidget(){}; 31 | 32 | private: 33 | void setupWidget(); 34 | void setupConnections(); 35 | 36 | int mWidgetWidth; 37 | int mWidgetHeight; 38 | 39 | QBoxLayout *mainLayout; 40 | 41 | RobotInterface::pointer mRobotInterface; 42 | 43 | void connectMovementButtons(); 44 | void connectJointButtons(); 45 | 46 | void setMoveToolLayout(QVBoxLayout *vLayout); 47 | void setMoveSettingsWidget(QVBoxLayout *vLayout); 48 | void setCoordInfoWidget(QVBoxLayout *vLayout); 49 | void setJointMoveWidget(QVBoxLayout *vLayout); 50 | 51 | QPushButton *negZButton, *posZButton, *posXButton, *negYButton, *posYButton, *negXButton; 52 | QPushButton *rotNegZButton, *rotPosZButton, *rotPosXButton, *rotNegYButton, *rotPosYButton, *rotNegXButton; 53 | 54 | QLineEdit *xPosLineEdit, *yPosLineEdit, *zPosLineEdit; 55 | QLineEdit *rxLineEdit, *ryLineEdit, *rzLineEdit; 56 | 57 | QLineEdit *q1LineEdit, *q2LineEdit, *q3LineEdit; 58 | QLineEdit *q4LineEdit, *q5LineEdit, *q6LineEdit; 59 | 60 | QPushButton *q1PosButton, *q1NegButton; 61 | QPushButton *q2PosButton, *q2NegButton; 62 | QPushButton *q3PosButton, *q3NegButton; 63 | QPushButton *q4PosButton, *q4NegButton; 64 | QPushButton *q5PosButton, *q5NegButton; 65 | QPushButton *q6PosButton, *q6NegButton; 66 | 67 | QButtonGroup *linearMotionButtons, *rotationMotionButtons, *jointConfigurationButtons; 68 | 69 | QLineEdit *accelerationLineEdit, *velocityLineEdit, *timeLineEdit; 70 | 71 | void coordButtonPressed(int axis,int sign); 72 | void rotButtonPressed(int axis,int sign); 73 | void jointButtonPressed(int joint,int sign); 74 | 75 | void setAutoRepeat(bool isRepeated, QButtonGroup *buttons); 76 | void setMaximumWidth(int width, QButtonGroup *buttons); 77 | 78 | 79 | public slots: 80 | void updatePositions(); 81 | 82 | void moveButtonReleased(); 83 | void jointButtonReleased(); 84 | 85 | void posZButtonPressed(); 86 | void negZButtonPressed(); 87 | void posYButtonPressed(); 88 | void negYButtonPressed(); 89 | void posXButtonPressed(); 90 | void negXButtonPressed(); 91 | void posRXButtonPressed(); 92 | void negRXButtonPressed(); 93 | void posRYButtonPressed(); 94 | void negRYButtonPressed(); 95 | void posRZButtonPressed(); 96 | void negRZButtonPressed(); 97 | 98 | void q1PosButtonPressed(); 99 | void q2PosButtonPressed(); 100 | void q3PosButtonPressed(); 101 | void q4PosButtonPressed(); 102 | void q5PosButtonPressed(); 103 | void q6PosButtonPressed(); 104 | void q1NegButtonPressed(); 105 | void q2NegButtonPressed(); 106 | void q3NegButtonPressed(); 107 | void q4NegButtonPressed(); 108 | void q5NegButtonPressed(); 109 | void q6NegButtonPressed(); 110 | 111 | }; 112 | 113 | } // end namespace echobot 114 | 115 | #endif // ROBOTMANUALMOVEWIDGET_H 116 | -------------------------------------------------------------------------------- /source/EchoBot/Interfaces/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project_add_subdirectories(Camera) 2 | project_add_subdirectories(Robot) 3 | project_add_subdirectories(Ultrasound) 4 | 5 | project_add_sources( 6 | SensorInterface.h 7 | ) 8 | 9 | project_add_test_sources( 10 | Tests/RobotInterfaceTests.cpp 11 | ) 12 | -------------------------------------------------------------------------------- /source/EchoBot/Interfaces/Camera/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project_add_sources( 2 | CameraInterface.cpp 3 | CameraInterface.hpp 4 | CameraDataProcessing.cpp 5 | CameraDataProcessing.h 6 | ) 7 | -------------------------------------------------------------------------------- /source/EchoBot/Interfaces/Camera/CameraDataProcessing.cpp: -------------------------------------------------------------------------------- 1 | #include "CameraDataProcessing.h" 2 | 3 | #include "FAST/Data/Image.hpp" 4 | #include "FAST/Data/Mesh.hpp" 5 | #include "FAST/Algorithms/IterativeClosestPoint/IterativeClosestPoint.hpp" 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace echobot { 12 | 13 | CameraDataProcessing::CameraDataProcessing() { 14 | createInputPort(0); 15 | createInputPort(1, false); 16 | createInputPort(2, false); 17 | 18 | createOutputPort(0); // RGB image clean 19 | createOutputPort(1); // RGB image annotated 20 | createOutputPort(2); // Depth image clean 21 | createOutputPort(3); // Point cloud clean 22 | createOutputPort(4); // Point cloud annotated 23 | 24 | // Create annotation image 25 | mAnnotationImage = Image::New(); 26 | mAnnotationImage->create(512, 424, fast::TYPE_UINT8, 1); 27 | mAnnotationImage->fill(0); 28 | 29 | mTargetCloud = Mesh::New(); 30 | mTargetCloud->create(0, 0, 0, false, false, false); 31 | mTargetCloudExtracted = false; 32 | } 33 | 34 | void CameraDataProcessing::execute() { 35 | Image::pointer rgbInput = getInputData(0); 36 | mCurrentImage = rgbInput; 37 | 38 | if(mInputConnections.count(1)) { 39 | Image::pointer depthInput = getInputData(1); 40 | mCurrentDepthImage = depthInput; 41 | } 42 | 43 | if(mInputConnections.count(2)){ 44 | Mesh::pointer meshInput = getInputData(2); 45 | mCurrentCloud = meshInput; 46 | 47 | auto cloudAccess = mCurrentCloud->getMeshAccess(ACCESS_READ); 48 | std::vector vertices = cloudAccess->getVertices(); 49 | std::vector filteredPoints; 50 | for(auto vertex: vertices) { 51 | auto position = vertex.getPosition(); 52 | if (!position.z() || position.z() > mMaxRange || position.z() < mMinRange) 53 | continue; 54 | 55 | if(position.x() > mMaxWidth || position.x() < mMinWidth) 56 | continue; 57 | 58 | if(position.y() > mMaxHeight || position.y() < mMinHeight) 59 | continue; 60 | 61 | filteredPoints.push_back(vertex); 62 | } 63 | 64 | Mesh::pointer filteredCloud = Mesh::New(); 65 | filteredCloud->create(filteredPoints); 66 | filteredCloud->setCreationTimestamp(mCurrentCloud->getCreationTimestamp()); 67 | mCurrentCloud = filteredCloud; 68 | } 69 | 70 | if (mTargetCloudExtracted) { 71 | //reportInfo() << "Running ICP" << reportEnd(); 72 | auto icp = fast::IterativeClosestPoint::New(); 73 | //icp->enableRuntimeMeasurements(); 74 | icp->setFixedMesh(mCurrentCloud); 75 | icp->setMovingMesh(mTargetCloud); 76 | icp->setDistanceThreshold(100); // All points further away than 10 cm from the centroid is removed 77 | //icp->setMinimumErrorChange(0.5); 78 | icp->setRandomPointSampling(300); 79 | //icp->getReporter().setReportMethod(Reporter::COUT); 80 | icp->setMaximumNrOfIterations(20); 81 | icp->update(); 82 | //reportInfo() << "Finished ICP in: " << reportEnd(); 83 | //icp->getAllRuntimes()->printAll(); 84 | if (!mTargetCloudPlaced) { 85 | AffineTransformation::pointer currentTransform = mTargetCloud->getSceneGraphNode()->getTransformation(); 86 | AffineTransformation::pointer newTransform = icp->getOutputTransformation(); 87 | mTargetCloud->getSceneGraphNode()->setTransformation(newTransform->multiply(currentTransform)); 88 | mTargetCloudPlaced = true; 89 | } 90 | } else { 91 | mTargetCloud = mCurrentCloud; 92 | } 93 | 94 | addOutputData(0, mCurrentImage); 95 | addOutputData(1, mAnnotationImage); 96 | addOutputData(2, mCurrentDepthImage); 97 | addOutputData(3, mCurrentCloud); 98 | addOutputData(4, mTargetCloud); 99 | } 100 | 101 | void CameraDataProcessing::addLine(Eigen::Vector2i start, Eigen::Vector2i end) { 102 | std::cout << "Drawing from: " << start.transpose() << " to " << end.transpose() << std::endl; 103 | // Draw line in some auxillary image 104 | mAnnotationImage = mAnnotationImage->copy(fast::Host::getInstance()); 105 | fast::ImageAccess::pointer access = mAnnotationImage->getImageAccess(ACCESS_READ_WRITE); 106 | Eigen::Vector2f direction = end.cast() - start.cast(); 107 | int length = (end - start).norm(); 108 | int brushSize = 6; 109 | for (int i = 0; i < length; ++i) { 110 | float distance = (float) i / length; 111 | for (int a = -brushSize; a <= brushSize; a++) { 112 | for (int b = -brushSize; b <= brushSize; b++) { 113 | Eigen::Vector2f offset(a, b); 114 | if (offset.norm() > brushSize) 115 | continue; 116 | Eigen::Vector2f position = start.cast() + direction * distance + offset; 117 | try { 118 | access->setScalar(position.cast(), 1); 119 | } catch (fast::Exception &e) { 120 | 121 | } 122 | } 123 | } 124 | } 125 | } 126 | 127 | void CameraDataProcessing::calculateTargetCloud(RealSenseStreamer::pointer streamer) { 128 | std::cout << "Creating target cloud..." << std::endl; 129 | auto access = mAnnotationImage->getImageAccess(ACCESS_READ); 130 | auto meshAccess = mCurrentCloud->getMeshAccess(ACCESS_READ); 131 | std::vector vertices = meshAccess->getVertices(); 132 | std::vector outputVertices; 133 | for (int y = 0; y < mAnnotationImage->getHeight(); ++y) { 134 | for (int x = 0; x < mAnnotationImage->getWidth(); ++x) { 135 | try { 136 | if (access->getScalar(Eigen::Vector2i(x, y)) == 1) { 137 | MeshVertex vertex = streamer->getPoint(x, y); 138 | if (!std::isnan(vertex.getPosition().x())) { 139 | outputVertices.push_back(vertex); 140 | } 141 | } 142 | } catch (fast::Exception &e) { 143 | 144 | } 145 | } 146 | } 147 | 148 | mTargetCloud = Mesh::New(); 149 | mTargetCloud->create(outputVertices); 150 | std::cout << "Created target cloud." << std::endl; 151 | mTargetCloudExtracted = true; 152 | } 153 | 154 | SharedPointer CameraDataProcessing::getTargetCloud() { 155 | return mTargetCloud; 156 | } 157 | 158 | void CameraDataProcessing::removeTargetCloud() { 159 | mTargetCloudExtracted = false; 160 | mAnnotationImage->fill(0); 161 | } 162 | 163 | void CameraDataProcessing::setMaxRange(float range) { 164 | if(range < 0) 165 | throw fast::Exception("Range has to be >= 0"); 166 | mMaxRange = range; 167 | } 168 | 169 | void CameraDataProcessing::setMinRange(float range) { 170 | if(range < 0) 171 | throw fast::Exception("Range has to be >= 0"); 172 | mMinRange = range; 173 | } 174 | 175 | void CameraDataProcessing::setMaxWidth(float range) { 176 | mMaxWidth = range; 177 | } 178 | 179 | void CameraDataProcessing::setMinWidth(float range) { 180 | mMinWidth = range; 181 | } 182 | 183 | void CameraDataProcessing::setMaxHeight(float range) { 184 | mMaxHeight = range; 185 | } 186 | 187 | void CameraDataProcessing::setMinHeight(float range) { 188 | mMinHeight = range; 189 | } 190 | 191 | } -------------------------------------------------------------------------------- /source/EchoBot/Interfaces/Camera/CameraDataProcessing.h: -------------------------------------------------------------------------------- 1 | #ifndef ECHOBOT_CAMERADATAPROCESSING_H 2 | #define ECHOBOT_CAMERADATAPROCESSING_H 3 | 4 | #include "EchoBot/Core/SmartPointers.h" 5 | #include "EchoBot/Core/DataTypes.h" 6 | 7 | #include "FAST/ProcessObject.hpp" 8 | #include "FAST/Data/Mesh.hpp" 9 | #include "FAST/Streamers/RealSenseStreamer.hpp" 10 | 11 | namespace echobot 12 | { 13 | 14 | class CameraDataProcessing : public ProcessObject { 15 | ECHOBOT_OBJECT(CameraDataProcessing) 16 | 17 | public: 18 | void calculateTargetCloud(SharedPointer streamer); 19 | 20 | void removeTargetCloud(); 21 | 22 | bool isTargetCloudExtracted() { return mTargetCloudExtracted; }; 23 | 24 | SharedPointer getTargetCloud(); 25 | 26 | void addLine(Eigen::Vector2i start, Eigen::Vector2i end); 27 | 28 | void setMaxRange(float range); 29 | void setMinRange(float range); 30 | void setMaxWidth(float range); 31 | void setMinWidth(float range); 32 | void setMaxHeight(float range); 33 | void setMinHeight(float range); 34 | 35 | private: 36 | CameraDataProcessing(); 37 | 38 | void execute(); 39 | 40 | SharedPointer mCurrentImage; 41 | SharedPointer mCurrentDepthImage; 42 | SharedPointer mCurrentCloud; 43 | 44 | SharedPointer mAnnotationImage; 45 | SharedPointer mTargetCloud; 46 | 47 | bool mTargetCloudExtracted = false; 48 | bool mTargetRegistered = false; 49 | bool mTargetCloudPlaced = false; 50 | 51 | float mMaxRange = std::numeric_limits::max(); 52 | float mMinRange = 0; 53 | float mMaxWidth = std::numeric_limits::max(); 54 | float mMinWidth = -std::numeric_limits::max(); 55 | float mMaxHeight = std::numeric_limits::max(); 56 | float mMinHeight = -std::numeric_limits::max(); 57 | }; 58 | 59 | } 60 | 61 | #endif //ECHOBOT_CAMERADATAPROCESSING_H 62 | -------------------------------------------------------------------------------- /source/EchoBot/Interfaces/Camera/CameraInterface.cpp: -------------------------------------------------------------------------------- 1 | #include "CameraInterface.hpp" 2 | #include "FAST/Data/Image.hpp" 3 | #include "FAST/Data/Mesh.hpp" 4 | #include "FAST/Algorithms/IterativeClosestPoint/IterativeClosestPoint.hpp" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | 15 | namespace echobot { 16 | 17 | DataChannel::pointer CameraInterface::getOutputPort(uint portID) 18 | { 19 | return mProcessObject->getOutputPort(portID); 20 | } 21 | 22 | void CameraInterface::setCameraROI(float minRange, float maxRange, float minWidth, float maxWidth, float minHeight, float maxHeight) 23 | { 24 | mProcessObject->setMinRange(minRange); 25 | mProcessObject->setMaxRange(maxRange); 26 | mProcessObject->setMinWidth(minWidth); 27 | mProcessObject->setMaxWidth(maxWidth); 28 | mProcessObject->setMinHeight(minHeight); 29 | mProcessObject->setMaxHeight(maxHeight); 30 | } 31 | 32 | void CameraInterface::connect() 33 | { 34 | mProcessObject = CameraDataProcessing::New(); 35 | 36 | if(mStreamOption == StreamOption::Stream){ 37 | mCameraStreamer = RealSenseStreamer::New(); 38 | mProcessObject->setInputConnection(0, mCameraStreamer->getOutputPort(0)); 39 | mProcessObject->setInputConnection(1, mCameraStreamer->getOutputPort(1)); 40 | mProcessObject->setInputConnection(2, mCameraStreamer->getOutputPort(2)); 41 | } else if (mStreamOption == StreamOption::Playback) { 42 | auto imageStreamer = ImageFileStreamer::New(); 43 | imageStreamer->setFilenameFormat(mPlaybackFilepath + "/CameraImages/Image-2D_#.mhd"); 44 | imageStreamer->enableLooping(); 45 | imageStreamer->setSleepTime(33.3); 46 | mCameraStreamer = imageStreamer; 47 | 48 | auto meshStreamer = MeshFileStreamer::New(); 49 | meshStreamer->setFilenameFormat(mPlaybackFilepath + "/PointClouds/#.vtk"); 50 | meshStreamer->enableLooping(); 51 | meshStreamer->setSleepTime(33.3); 52 | meshStreamer->update(); 53 | 54 | mProcessObject->setInputConnection(0, mCameraStreamer->getOutputPort(0)); 55 | mProcessObject->setInputConnection(2, meshStreamer->getOutputPort(0)); 56 | } 57 | mConnected = true; 58 | } 59 | 60 | void CameraInterface::disconnect() 61 | { 62 | mProcessObject->stopPipeline(); 63 | mCameraStreamer->stopPipeline(); 64 | mImageRenderer->stopPipeline(); 65 | mDepthImageRenderer->stopPipeline(); 66 | mPointCloudRenderer->stopPipeline(); 67 | mConnected = false; 68 | } 69 | 70 | Renderer::pointer CameraInterface::getImageRenderer() 71 | { 72 | // Renderer RGB image 73 | mImageRenderer = ImageRenderer::New(); 74 | mImageRenderer->addInputConnection(mProcessObject->getOutputPort(0)); 75 | return mImageRenderer; 76 | } 77 | 78 | Renderer::pointer CameraInterface::getDepthImageRenderer() 79 | { 80 | // Renderer depth image 81 | mDepthImageRenderer = ImageRenderer::New(); 82 | mDepthImageRenderer->addInputConnection(mProcessObject->getOutputPort(2)); 83 | mDepthImageRenderer->setIntensityLevel(1000); 84 | mDepthImageRenderer->setIntensityWindow(500); 85 | return mDepthImageRenderer; 86 | } 87 | 88 | Renderer::pointer CameraInterface::getPointCloudRenderer() 89 | { 90 | // Renderer point cloud 91 | mPointCloudRenderer = VertexRenderer::New(); 92 | mPointCloudRenderer->addInputConnection(mProcessObject->getOutputPort(4)); 93 | mPointCloudRenderer->setDefaultSize(1.5); 94 | return mPointCloudRenderer; 95 | } 96 | 97 | void CameraInterface::setPlayback(std::string filepath) 98 | { 99 | mPlaybackFilepath = filepath; 100 | mStreamOption = StreamOption::Playback; 101 | } 102 | 103 | 104 | CameraInterface::CameraInterface() { 105 | mPointCloudRenderer = VertexRenderer::New(); 106 | mDepthImageRenderer = ImageRenderer::New(); 107 | mImageRenderer = ImageRenderer::New(); 108 | } 109 | 110 | CameraInterface::~CameraInterface() { 111 | } 112 | 113 | } -------------------------------------------------------------------------------- /source/EchoBot/Interfaces/Camera/CameraInterface.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ECHOBOT_CAMERAINTERFACE_H 2 | #define ECHOBOT_CAMERAINTERFACE_H 3 | 4 | #include "EchoBot/Interfaces/SensorInterface.h" 5 | #include "CameraDataProcessing.h" 6 | 7 | #include "FAST/Visualization/Renderer.hpp" 8 | #include "FAST/Visualization/ImageRenderer/ImageRenderer.hpp" 9 | #include "FAST/Visualization/VertexRenderer/VertexRenderer.hpp" 10 | #include "FAST/Streamers/RealSenseStreamer.hpp" 11 | 12 | namespace echobot 13 | { 14 | 15 | class CameraInterface : public SensorInterface { 16 | ECHOBOT_OBJECT(CameraInterface) 17 | 18 | public: 19 | typedef enum {Stream, Playback} StreamOption; 20 | ~CameraInterface(); 21 | 22 | void connect(); 23 | void disconnect(); 24 | bool isConnected(){return mConnected;}; 25 | void setPlayback(std::string filepath); 26 | 27 | Renderer::pointer getPointCloudRenderer(); 28 | Renderer::pointer getDepthImageRenderer(); 29 | Renderer::pointer getImageRenderer(); 30 | 31 | CameraDataProcessing::pointer getProcessObject(){ return mProcessObject;}; 32 | DataChannel::pointer getOutputPort(uint portID = 0); 33 | Streamer::pointer getStreamObject(){ return mCameraStreamer;}; 34 | 35 | void setCameraROI( float minRange = 0, float maxRange = 2000, 36 | float minWidth = -1000, float maxWidth = 1000, 37 | float minHeight = -1000, float maxHeight = 1000); 38 | 39 | private: 40 | CameraInterface(); 41 | 42 | SharedPointer mProcessObject; 43 | SharedPointer mCameraStreamer; 44 | SharedPointer mPointCloudRenderer; 45 | SharedPointer mImageRenderer; 46 | SharedPointer mDepthImageRenderer; 47 | StreamOption mStreamOption = StreamOption::Stream; 48 | std::string mPlaybackFilepath = ""; 49 | bool mConnected = false; 50 | 51 | }; 52 | 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /source/EchoBot/Interfaces/Robot/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project_add_sources( 2 | RobotInterface.cpp 3 | RobotInterface.h 4 | ) 5 | -------------------------------------------------------------------------------- /source/EchoBot/Interfaces/Robot/RobotInterface.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by androst on 04.10.18. 3 | // 4 | 5 | #include "RobotInterface.h" 6 | 7 | namespace echobot 8 | { 9 | 10 | RobotInterface::RobotInterface() { 11 | mRobot = SharedPointer(new romocc::Robot); 12 | } 13 | 14 | RobotInterface::~RobotInterface() { 15 | mRobot->disconnect(); 16 | } 17 | 18 | void RobotInterface::setConfiguration(romocc::Manipulator manipulator, const std::string& ip_address, const int& port){ 19 | mManipulator = manipulator; 20 | mHost = ip_address; 21 | mPort = port; 22 | } 23 | 24 | void RobotInterface::connect(){ 25 | mRobot->addUpdateSubscription(std::bind(&RobotInterface::stateUpdated, this)); 26 | mRobot->configure(mManipulator, mHost, mPort); 27 | mRobot->connect(); 28 | } 29 | 30 | void RobotInterface::disconnect(){ 31 | mRobot->disconnect(); 32 | } 33 | 34 | bool RobotInterface::isConnected() 35 | { 36 | return mRobot->isConnected(); 37 | } 38 | 39 | RobotState::pointer RobotInterface::getCurrentState() 40 | { 41 | return mRobot->getCurrentState(); 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /source/EchoBot/Interfaces/Robot/RobotInterface.h: -------------------------------------------------------------------------------- 1 | #ifndef ECHOBOT_ROBOTINTERFACE_H 2 | #define ECHOBOT_ROBOTINTERFACE_H 3 | 4 | #include 5 | 6 | #include "EchoBot/Interfaces/SensorInterface.h" 7 | #include 8 | 9 | namespace echobot 10 | { 11 | 12 | using namespace romocc; 13 | 14 | class RobotInterface : public QObject, public SensorInterface 15 | { 16 | Q_OBJECT 17 | ECHOBOT_OBJECT(RobotInterface) 18 | 19 | public: 20 | RobotInterface(); 21 | ~RobotInterface(); 22 | 23 | Robot::pointer getRobot(){ return mRobot;}; 24 | 25 | void connect(); 26 | void disconnect(); 27 | bool isConnected(); 28 | 29 | void setConfiguration(romocc::Manipulator manipulator, const std::string& ip_address, const int& port); 30 | 31 | RobotState::pointer getCurrentState(); 32 | Manipulator getManipulatorInfo(){return mManipulator;}; 33 | 34 | private: 35 | SharedPointer mRobot; 36 | Manipulator mManipulator; 37 | std::string mHost; 38 | int mPort; 39 | 40 | 41 | signals: 42 | void stateUpdated(); 43 | }; 44 | 45 | } 46 | 47 | #endif //ECHOBOT_ROBOTINTERFACE_H 48 | -------------------------------------------------------------------------------- /source/EchoBot/Interfaces/SensorInterface.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by androst on 30.05.19. 3 | // 4 | 5 | #ifndef ECHOBOT_SENSORINTERFACE_H 6 | #define ECHOBOT_SENSORINTERFACE_H 7 | 8 | #include 9 | #include 10 | 11 | namespace echobot 12 | { 13 | 14 | class SensorInterface { 15 | ECHOBOT_OBJECT(SensorInterface) 16 | 17 | protected: 18 | std::weak_ptr mPtr; 19 | }; 20 | 21 | } 22 | 23 | 24 | #endif //ECHOBOT_SENSORINTERFACE_H 25 | -------------------------------------------------------------------------------- /source/EchoBot/Interfaces/Tests/RobotInterfaceTests.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by androst on 06.08.19. 3 | // 4 | 5 | #include "EchoBot/Tests/catch.hpp" 6 | #include "source/EchoBot/Interfaces/Robot/RobotInterface.h" 7 | 8 | namespace echobot 9 | { 10 | 11 | TEST_CASE("Create RobotInterface object", "[EchoBot][Interfaces]") { 12 | auto robotInterface = echobot::RobotInterface::New(); 13 | } 14 | 15 | TEST_CASE("Connect and listen to new states", "[EchoBot][Interfaces]"){ 16 | auto robotInterface = echobot::RobotInterface::New(); 17 | robotInterface->setConfiguration(ManipulatorType::UR10, "10.218.180.32", 30003); 18 | robotInterface->connect(); 19 | 20 | for(int i = 0; i<50; i++) 21 | { 22 | std::cout << robotInterface->getCurrentState()->getJointConfig().transpose() << std::endl; 23 | } 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /source/EchoBot/Interfaces/Ultrasound/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project_add_sources( 2 | UltrasoundInterface.cpp 3 | UltrasoundInterface.hpp 4 | UltrasoundImageProcessing.cpp 5 | UltrasoundImageProcessing.h 6 | ) 7 | -------------------------------------------------------------------------------- /source/EchoBot/Interfaces/Ultrasound/UltrasoundImageProcessing.cpp: -------------------------------------------------------------------------------- 1 | #include "UltrasoundImageProcessing.h" 2 | #include "EchoBot/Core/Config.h" 3 | 4 | #include "FAST/Algorithms/UltrasoundImageCropper/UltrasoundImageCropper.hpp" 5 | #include "FAST/Algorithms/ImageCropper/ImageCropper.hpp" 6 | #include "FAST/Algorithms/NeuralNetwork/SegmentationNetwork.hpp" 7 | #include "FAST/Exporters/MetaImageExporter.hpp" 8 | 9 | 10 | namespace echobot { 11 | 12 | UltrasoundImageProcessing::UltrasoundImageProcessing() { 13 | createInputPort(0); 14 | 15 | createOutputPort(0); // Raw image 16 | createOutputPort(1); // Processed image 17 | 18 | mSegmentationThread = new std::thread(std::bind(&UltrasoundImageProcessing::segmentationThread, this)); 19 | mImageTransform = Eigen::Affine3d::Identity(); 20 | } 21 | 22 | UltrasoundImageProcessing::~UltrasoundImageProcessing() { 23 | { 24 | std::lock_guard lock(mFrameBufferMutex); 25 | mStop = true; 26 | } 27 | mSegmentationThread->join(); 28 | } 29 | 30 | void UltrasoundImageProcessing::execute() { 31 | auto port = getInputPort(0); 32 | 33 | auto cropper = fast::UltrasoundImageCropper::New(); 34 | cropper->setInputConnection(port); 35 | port = cropper->getOutputPort(); 36 | cropper->update(); 37 | mRawImage = port->getNextFrame(); 38 | 39 | if (mSegmentationEnabled) { 40 | mSegmentationNetwork->setInputConnection(port); 41 | port = mSegmentationNetwork->getOutputPort(); 42 | mSegmentationNetwork->update(); 43 | } 44 | 45 | mProcessedImage = port->getNextFrame(); 46 | 47 | AffineTransformation::pointer T = AffineTransformation::New(); 48 | T->setTransform(mImageTransform.cast()); 49 | mProcessedImage->getSceneGraphNode()->setTransformation(T); 50 | 51 | try { 52 | addOutputData(0, mRawImage); 53 | addOutputData(1, mProcessedImage); 54 | } catch (fast::ThreadStopped &e) { 55 | std::cout << "Thread stopped in USImageProcessing" << std::endl; 56 | } 57 | 58 | } 59 | 60 | void UltrasoundImageProcessing::segmentationThread() { 61 | while (true) { 62 | { 63 | std::lock_guard lock(mFrameBufferMutex); 64 | if (mStop) 65 | break; 66 | } 67 | } 68 | } 69 | 70 | void UltrasoundImageProcessing::setImageTransform(Eigen::Affine3d transform){ 71 | mImageTransform = transform; 72 | } 73 | 74 | void UltrasoundImageProcessing::setupNeuralNetworks() { 75 | mSegmentationNetwork = SegmentationNetwork::New(); 76 | mSegmentationNetwork->setScaleFactor(1.0f / 255.0f); 77 | const auto engine = mSegmentationNetwork->getInferenceEngine()->getName(); 78 | if(engine.substr(0,10) == "TensorFlow") { 79 | // TensorFlow needs to know what the output node is called 80 | mSegmentationNetwork->setOutputNode(0, "conv2d_23/truediv"); 81 | } 82 | mSegmentationNetwork->load(fast::join(Config::getNeuralNetworkModelPath(), "aorta_segmentation_new.pb")); 83 | mSegmentationEnabled = true; 84 | } 85 | 86 | } -------------------------------------------------------------------------------- /source/EchoBot/Interfaces/Ultrasound/UltrasoundImageProcessing.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by androst on 19.08.19. 3 | // 4 | 5 | #ifndef ECHOBOT_ULTRASOUNDIMAGEPROCESSING_H 6 | #define ECHOBOT_ULTRASOUNDIMAGEPROCESSING_H 7 | 8 | #include 9 | #include "EchoBot/Core/SmartPointers.h" 10 | #include "EchoBot/Core/DataTypes.h" 11 | 12 | #include "FAST/ProcessObject.hpp" 13 | #include "FAST/Data/Image.hpp" 14 | 15 | namespace echobot { 16 | 17 | 18 | class UltrasoundImageProcessing : public ProcessObject { 19 | ECHOBOT_OBJECT(UltrasoundImageProcessing) 20 | 21 | public: 22 | ~UltrasoundImageProcessing(); 23 | 24 | SharedPointer getProcessedImage(){ return mProcessedImage;}; 25 | void setImageTransform(Eigen::Affine3d transform); 26 | bool isSegmentationEnabled(){ return mSegmentationEnabled;}; 27 | void setupNeuralNetworks(); 28 | 29 | private: 30 | UltrasoundImageProcessing(); 31 | 32 | void execute(); 33 | 34 | SharedPointer mRawImage, mProcessedImage; 35 | Eigen::Affine3d mImageTransform; 36 | 37 | void segmentationThread(); 38 | 39 | std::thread *mSegmentationThread; 40 | std::mutex mFrameBufferMutex; 41 | 42 | bool mSegmentationEnabled = false; 43 | SharedPointer mSegmentationNetwork; 44 | 45 | 46 | bool mStop = false; 47 | }; 48 | } 49 | 50 | 51 | #endif //ECHOBOT_ULTRASOUNDIMAGEPROCESSING_H 52 | -------------------------------------------------------------------------------- /source/EchoBot/Interfaces/Ultrasound/UltrasoundInterface.cpp: -------------------------------------------------------------------------------- 1 | #include "UltrasoundInterface.hpp" 2 | 3 | #include "FAST/Streamers/OpenIGTLinkStreamer.hpp" 4 | #include "FAST/Streamers/ClariusStreamer.hpp" 5 | #include "FAST/Streamers/ImageFileStreamer.hpp" 6 | #include "FAST/Visualization/ImageRenderer/ImageRenderer.hpp" 7 | 8 | namespace echobot 9 | { 10 | 11 | UltrasoundInterface::UltrasoundInterface() { 12 | fast::Config::setStreamingMode(fast::STREAMING_MODE_NEWEST_FRAME_ONLY); 13 | } 14 | 15 | UltrasoundInterface::~UltrasoundInterface() { 16 | } 17 | 18 | void UltrasoundInterface::connect() 19 | { 20 | if(mStreamerType == Clarius){ 21 | mUltrasoundStreamer = fast::ClariusStreamer::New(); 22 | } 23 | else if(mStreamerType == IGTLink){ 24 | auto usStreamer = fast::OpenIGTLinkStreamer::New(); 25 | usStreamer->setConnectionAddress(mIP); 26 | usStreamer->setConnectionPort(mPort); 27 | mUltrasoundStreamer = usStreamer; 28 | } 29 | else if(mStreamerType == Playback){ 30 | auto usStreamer = fast::ImageFileStreamer::New(); 31 | usStreamer->setFilenameFormat(mPlaybackFilepath); 32 | usStreamer->enableLooping(); 33 | usStreamer->setSleepTime(33.3); 34 | mUltrasoundStreamer = usStreamer; 35 | } 36 | 37 | mProcessObject = UltrasoundImageProcessing::New(); 38 | mProcessObject->setInputConnection(mUltrasoundStreamer->getOutputPort()); 39 | mConnected = true; 40 | } 41 | 42 | void UltrasoundInterface::disconnect() 43 | { 44 | mUltrasoundStreamer->stopPipeline(); 45 | mImageRenderer->stopPipeline(); 46 | mSegmentationRenderer->stopPipeline(); 47 | mProcessObject->stopPipeline(); 48 | mConnected = false; 49 | } 50 | 51 | void UltrasoundInterface::setStreamer(UltrasoundStreamerType streamer, std::string ip, uint32_t port) 52 | { 53 | mStreamerType = streamer; 54 | mIP = ip; 55 | mPort = port; 56 | } 57 | 58 | UltrasoundInterface::UltrasoundStreamerType UltrasoundInterface::getStreamerType() 59 | { 60 | return mStreamerType; 61 | } 62 | 63 | void UltrasoundInterface::setPlayback(std::string filepath) 64 | { 65 | mStreamerType = UltrasoundStreamerType::Playback; 66 | mPlaybackFilepath = filepath; 67 | } 68 | 69 | DataChannel::pointer UltrasoundInterface::getOutputPort(uint portID) 70 | { 71 | return mProcessObject->getOutputPort(portID); 72 | } 73 | 74 | Renderer::pointer UltrasoundInterface::getImageRenderer() 75 | { 76 | mImageRenderer = fast::ImageRenderer::New(); 77 | mImageRenderer->addInputConnection(mProcessObject->getOutputPort(0)); 78 | return mImageRenderer; 79 | } 80 | 81 | 82 | void UltrasoundInterface::setImageTransform(Eigen::Affine3d transform) { 83 | mProcessObject->setImageTransform(transform); 84 | } 85 | 86 | Renderer::pointer UltrasoundInterface::getSegmentationRenderer() { 87 | auto segmentationRenderer = fast::SegmentationRenderer::New(); 88 | segmentationRenderer->addInputConnection(mProcessObject->getOutputPort(1)); 89 | segmentationRenderer->setOpacity(0.25); 90 | segmentationRenderer->setColor(fast::Segmentation::LABEL_FOREGROUND, Color::Red()); 91 | segmentationRenderer->setColor(fast::Segmentation::LABEL_BLOOD, Color::Black()); 92 | mSegmentationRenderer = segmentationRenderer; 93 | return mSegmentationRenderer; 94 | } 95 | 96 | void UltrasoundInterface::enableSegmentation() { 97 | mProcessObject->setupNeuralNetworks(); 98 | } 99 | 100 | } -------------------------------------------------------------------------------- /source/EchoBot/Interfaces/Ultrasound/UltrasoundInterface.hpp: -------------------------------------------------------------------------------- 1 | #ifndef ECHOBOT_ULTRASOUNDINTERFACE_H 2 | #define ECHOBOT_ULTRASOUNDINTERFACE_H 3 | 4 | #include 5 | #include "EchoBot/Core/SmartPointers.h" 6 | #include "EchoBot/Interfaces/Robot/RobotInterface.h" 7 | #include "EchoBot/Interfaces/Ultrasound/UltrasoundImageProcessing.h" 8 | 9 | #include "FAST/ProcessObject.hpp" 10 | #include "FAST/Data/Image.hpp" 11 | #include "FAST/Streamers/ClariusStreamer.hpp" 12 | #include "FAST/Streamers/OpenIGTLinkStreamer.hpp" 13 | #include "FAST/Visualization/Renderer.hpp" 14 | 15 | namespace echobot 16 | { 17 | 18 | class UltrasoundInterface : public SensorInterface { 19 | ECHOBOT_OBJECT(UltrasoundInterface) 20 | 21 | public: 22 | typedef enum {Clarius, IGTLink, Playback} UltrasoundStreamerType; // Supported ultrasound streamers 23 | 24 | ~UltrasoundInterface(); 25 | void connect(); 26 | void disconnect(); 27 | bool isConnected(){return mConnected;}; 28 | 29 | void setStreamer(UltrasoundStreamerType streamer, std::string ip = "", uint32_t port = 18944); 30 | void setPlayback(std::string filepath); 31 | void setImageTransform(Eigen::Affine3d transform); 32 | void enableSegmentation(); 33 | 34 | DataChannel::pointer getOutputPort(uint portID = 0); 35 | 36 | Streamer::pointer getStreamObject(){ return mUltrasoundStreamer;}; 37 | UltrasoundImageProcessing::pointer getProcessObject(){ return mProcessObject;}; 38 | Renderer::pointer getImageRenderer(); 39 | Renderer::pointer getSegmentationRenderer(); 40 | UltrasoundStreamerType getStreamerType(); 41 | 42 | private: 43 | UltrasoundInterface(); 44 | UltrasoundStreamerType mStreamerType; 45 | std::string mIP = "localhost"; 46 | uint32_t mPort = 18944; 47 | std::string mPlaybackFilepath = ""; 48 | 49 | SharedPointer mUltrasoundStreamer; 50 | SharedPointer mProcessObject; 51 | SharedPointer mImageRenderer, mSegmentationRenderer; 52 | 53 | bool mConnected = false; 54 | }; 55 | 56 | } // end namespace echobot 57 | #endif 58 | -------------------------------------------------------------------------------- /source/EchoBot/Tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project_add_test_sources( 2 | catch.hpp 3 | CatchMain.cpp 4 | WorkflowTests.cpp 5 | ) -------------------------------------------------------------------------------- /source/EchoBot/Tests/CatchMain.cpp: -------------------------------------------------------------------------------- 1 | #define CATCH_CONFIG_RUNNER 2 | #include "catch.hpp" 3 | 4 | int main(int argc, char* argv[]) { 5 | int result = Catch::Session().run(argc, argv); 6 | return result; 7 | } -------------------------------------------------------------------------------- /source/EchoBot/Utilities/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project_add_sources( 2 | RecordTool.cpp 3 | RecordTool.h 4 | CalibrationTool.cpp 5 | CalibrationTool.h 6 | PointCloudUtilities.cpp 7 | PointCloudUtilities.h 8 | Utilities.cpp 9 | Utilities.h 10 | ) 11 | 12 | project_add_test_sources( 13 | Tests/CalibrationToolTests.cpp 14 | ) -------------------------------------------------------------------------------- /source/EchoBot/Utilities/CalibrationTool.cpp: -------------------------------------------------------------------------------- 1 | #include "CalibrationTool.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace echobot { 8 | 9 | 10 | void CalibrationTool::calibrate() { 11 | 12 | } 13 | 14 | Eigen::Affine3d CalibrationTool::loadCalFile(std::string path) { 15 | auto calMat = Eigen::Affine3d::Identity(); 16 | std::ifstream inFile; 17 | inFile.open(path); 18 | 19 | if(inFile.is_open()) 20 | { 21 | for(int row = 0; row < calMat.rows(); row++){ 22 | for(int col = 0; col < calMat.cols(); col++) 23 | { 24 | double item = 0; 25 | inFile >> item; 26 | calMat(row, col) = item; 27 | } 28 | } 29 | inFile.close(); 30 | } 31 | return calMat; 32 | } 33 | 34 | void CalibrationTool::saveCalFile(std::string path, Eigen::Affine3d calMat) { 35 | std::ofstream outFile; 36 | outFile.open(path); 37 | 38 | if(outFile.is_open()){ 39 | outFile << calMat.matrix(); 40 | outFile.close(); 41 | } 42 | } 43 | 44 | CalibrationTool::CalibrationTool() { 45 | mCalibrationFilePath = Config::getConfigPath() + "calibration/"; 46 | m_rMb = loadCalFile(mCalibrationFilePath + "camMbase.cal"); 47 | m_eeMt = loadCalFile(mCalibrationFilePath + "eeMtool.cal"); 48 | m_tMus = loadCalFile(mCalibrationFilePath + "toolMus.cal"); 49 | m_registration_pcMdata = loadCalFile(mCalibrationFilePath + "registration_pcMdata.cal"); 50 | m_registration_pcMt = loadCalFile(mCalibrationFilePath + "registration_pcMt.cal"); 51 | std::cout << m_registration_pcMdata.matrix() << std::endl; 52 | } 53 | 54 | void CalibrationTool::set_rMb(Eigen::Affine3d mat) { 55 | m_rMb = mat; 56 | } 57 | 58 | void CalibrationTool::set_eeMt(Eigen::Affine3d mat) { 59 | m_eeMt = mat; 60 | } 61 | 62 | void CalibrationTool::set_tMus(Eigen::Affine3d mat) { 63 | m_tMus = mat; 64 | } 65 | 66 | void CalibrationTool::set_registration_pcMdata(Eigen::Affine3d mat) { 67 | m_registration_pcMdata = mat; 68 | } 69 | 70 | void CalibrationTool::set_registration_pcMt(Eigen::Affine3d mat) { 71 | m_registration_pcMt = mat; 72 | } 73 | 74 | Eigen::Affine3d CalibrationTool::get_registration_pcMdata(){ 75 | std::cout << m_registration_pcMdata.matrix() << std::endl; 76 | return m_registration_pcMdata; 77 | } 78 | 79 | } 80 | 81 | -------------------------------------------------------------------------------- /source/EchoBot/Utilities/CalibrationTool.h: -------------------------------------------------------------------------------- 1 | #ifndef ECHOBOT_CALIBRATIONTOOL_H 2 | #define ECHOBOT_CALIBRATIONTOOL_H 3 | 4 | #include 5 | #include "EchoBot/Core/SmartPointers.h" 6 | #include "EchoBot/Core/Config.h" 7 | 8 | 9 | namespace echobot { 10 | 11 | class CalibrationTool { 12 | ECHOBOT_OBJECT(CalibrationTool) 13 | 14 | public: 15 | void calibrate(); 16 | Eigen::Affine3d get_rMb(){ return m_rMb;}; 17 | Eigen::Affine3d get_eeMt(){ return m_eeMt;}; 18 | Eigen::Affine3d get_tMus(){ return m_tMus;}; 19 | Eigen::Affine3d get_registration_pcMdata(); 20 | Eigen::Affine3d get_registration_pcMt(){ return m_registration_pcMt;}; 21 | 22 | void set_rMb(Eigen::Affine3d mat); 23 | void set_eeMt(Eigen::Affine3d mat); 24 | void set_tMus(Eigen::Affine3d mat); 25 | void set_registration_pcMdata(Eigen::Affine3d mat); 26 | void set_registration_pcMt(Eigen::Affine3d mat); 27 | 28 | std::string getCalibrationFilePath(){return mCalibrationFilePath;}; 29 | void setCalibrationFilePath(std::string path){mCalibrationFilePath = path;}; 30 | 31 | static Eigen::Affine3d loadCalFile(std::string path); 32 | static void saveCalFile(std::string path, Eigen::Affine3d calMat); 33 | 34 | private: 35 | Eigen::Affine3d m_rMb, m_eeMt, m_tMus, m_registration_pcMdata, m_registration_pcMt; 36 | std::string mCalibrationFilePath; 37 | 38 | CalibrationTool(); 39 | std::weak_ptr mPtr; 40 | }; 41 | 42 | } 43 | 44 | 45 | #endif //ECHOBOT_CALIBRATIONTOOL_H 46 | -------------------------------------------------------------------------------- /source/EchoBot/Utilities/PointCloudUtilities.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by androst on 06.01.20. 3 | // 4 | 5 | #include "PointCloudUtilities.h" 6 | #include 7 | #include 8 | 9 | namespace echobot{ 10 | 11 | Mesh::pointer decimateMesh(Mesh::pointer pointCloud, double fractionOfPointsToKeep) { 12 | auto accessFixedSet = pointCloud->getMeshAccess(ACCESS_READ); 13 | auto vertices = accessFixedSet->getVertices(); 14 | 15 | // Sample the preferred amount of points from the point cloud 16 | auto numVertices = (unsigned int) vertices.size(); 17 | auto numSamplePoints = (unsigned int) ceil(fractionOfPointsToKeep * numVertices); 18 | std::vector newVertices; 19 | 20 | std::unordered_set movingIndices; 21 | unsigned int sampledPoints = 0; 22 | std::default_random_engine distributionEngine; 23 | std::uniform_int_distribution distribution(0, numVertices - 1); 24 | while (sampledPoints < numSamplePoints) { 25 | unsigned int index = distribution(distributionEngine); 26 | if (movingIndices.count(index) < 1 && vertices.at(index).getPosition().array().isNaN().sum() == 0) { 27 | newVertices.push_back(vertices.at(index)); 28 | movingIndices.insert(index); 29 | ++sampledPoints; 30 | } 31 | } 32 | 33 | // Add noise to point cloud 34 | float minX, minY, minZ; 35 | Vector3f position0 = vertices[0].getPosition(); 36 | minX = position0[0]; 37 | minY = position0[1]; 38 | minZ = position0[2]; 39 | float maxX = minX, maxY = minY, maxZ = minZ; 40 | for (auto &vertex : vertices) { 41 | Vector3f position = vertex.getPosition(); 42 | if (position[0] < minX) { minX = position[0]; } 43 | if (position[0] > maxX) { maxX = position[0]; } 44 | if (position[1] < minY) { minY = position[1]; } 45 | if (position[1] > maxY) { maxY = position[1]; } 46 | if (position[2] < minZ) { minZ = position[2]; } 47 | if (position[2] > maxZ) { maxZ = position[2]; } 48 | } 49 | Mesh::pointer newCloud = Mesh::New(); 50 | newCloud->create(newVertices); 51 | // Update point cloud to include the removed points and added noise 52 | return newCloud; 53 | } 54 | 55 | Mesh::pointer reduceMeshExtent(Mesh::pointer mesh, float xMin, float xMax, float yMin, float yMax, float zMin, float zMax) { 56 | auto meshAccess = mesh->getMeshAccess(ACCESS_READ); 57 | std::vector vertices = meshAccess->getVertices(); 58 | std::vector filteredPoints; 59 | 60 | for (auto vertex: vertices) { 61 | auto position = vertex.getPosition(); 62 | if (!position.z() || position.z() > zMax || position.z() < zMin) 63 | continue; 64 | 65 | if (position.x() > xMax || position.x() < xMin) 66 | continue; 67 | 68 | if (position.y() > yMax || position.y() < yMin) 69 | continue; 70 | 71 | filteredPoints.push_back(vertex); 72 | } 73 | 74 | auto reducedMesh = Mesh::New(); 75 | reducedMesh->create(filteredPoints); 76 | reducedMesh->setCreationTimestamp(mesh->getCreationTimestamp()); 77 | return reducedMesh; 78 | } 79 | 80 | Vector3f calculateCentroid(std::vector vertices) { 81 | auto output = Eigen::Vector3f(); 82 | for(auto vertix: vertices) 83 | output += vertix.getPosition(); 84 | 85 | output = output/vertices.size(); 86 | return output; 87 | } 88 | 89 | MeshProcessing::MeshProcessing() { 90 | createInputPort(0); 91 | createOutputPort(0); 92 | } 93 | 94 | void MeshProcessing::execute() { 95 | auto input = getInputData(); 96 | auto output = input; 97 | 98 | if(mBoundsModified) 99 | output = reduceMeshExtent(input, m_xMin, m_xMax, m_yMin, m_yMax, m_zMin, m_zMax); 100 | 101 | if(mDecimationFraction < 1.0) 102 | output = decimateMesh(output, mDecimationFraction); 103 | 104 | addOutputData(0, output); 105 | } 106 | 107 | void MeshProcessing::setBounds(float xMin, float xMax, float yMin, float yMax, float zMin, float zMax) { 108 | m_xMin = xMin; 109 | m_xMax = xMax; 110 | m_yMin = yMin; 111 | m_yMax = yMax; 112 | m_zMin = zMin; 113 | m_zMax = zMax; 114 | mBoundsModified = true; 115 | } 116 | 117 | void MeshProcessing::setDecimationFraction(float fraction) { 118 | mDecimationFraction = fraction; 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /source/EchoBot/Utilities/PointCloudUtilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by androst on 06.01.20. 3 | // 4 | 5 | #ifndef ECHOBOT_POINTCLOUDUTILITIES_H 6 | #define ECHOBOT_POINTCLOUDUTILITIES_H 7 | 8 | #include "EchoBot/Core/SmartPointers.h" 9 | #include "EchoBot/Core/DataTypes.h" 10 | 11 | #include "FAST/ProcessObject.hpp" 12 | #include "FAST/Data/Mesh.hpp" 13 | 14 | namespace echobot { 15 | 16 | Mesh::pointer decimateMesh(Mesh::pointer mesh, double fractionOfPointsToKeep); 17 | Mesh::pointer reduceMeshExtent(Mesh::pointer mesh, float zMax, float zMin, float xMax, float xMin, float yMax, float yMin); 18 | Vector3f calculateCentroid(std::vector vertices); 19 | 20 | class MeshProcessing : public ProcessObject { 21 | ECHOBOT_OBJECT(MeshProcessing) 22 | 23 | public: 24 | void setBounds(float xMin, float xMax, float yMin, float yMax, float zMin, float zMax); 25 | void setDecimationFraction(float fraction); 26 | 27 | private: 28 | MeshProcessing(); 29 | void execute(); 30 | 31 | bool mBoundsModified = false; 32 | float m_zMax = std::numeric_limits::max(); 33 | float m_zMin = 0; 34 | float m_xMax = std::numeric_limits::max(); 35 | float m_xMin = -std::numeric_limits::max(); 36 | float m_yMax = std::numeric_limits::max(); 37 | float m_yMin = -std::numeric_limits::max(); 38 | float mDecimationFraction = 1.0; 39 | }; 40 | 41 | } 42 | 43 | #endif //ECHOBOT_POINTCLOUDUTILITIES_H 44 | -------------------------------------------------------------------------------- /source/EchoBot/Utilities/RecordTool.cpp: -------------------------------------------------------------------------------- 1 | #include "RecordTool.h" 2 | 3 | #include 4 | #include 5 | #include "FAST/Streamers/ImageFileStreamer.hpp" 6 | #include "FAST/Streamers/MeshFileStreamer.hpp" 7 | #include "EchoBot/Exporters/PointCloudExporter.h" 8 | 9 | #include 10 | #include 11 | 12 | namespace echobot { 13 | 14 | void RecordTool::addRecordChannel(std::string name, DataChannel::pointer channel) 15 | { 16 | mRecordChannels[name] = channel; 17 | mLastTimeStamps[name] = 0; 18 | 19 | uint port = getNrOfInputConnections(); 20 | createInputPort(port); 21 | createOutputPort(port); 22 | setInputConnection(port, channel); 23 | } 24 | 25 | 26 | void RecordTool::startRecording(std::string path) { 27 | mStoragePath = path; 28 | mFrameCounter = 0; 29 | 30 | fast::createDirectories(mStoragePath); 31 | for (auto ch: mRecordChannels) 32 | fast::createDirectories((mStoragePath + "/" + ch.first)); 33 | 34 | mRecording = true; 35 | mRecordThread = new std::thread(std::bind(&RecordTool::queueForDataDump, this)); 36 | 37 | if(mDumpThread == nullptr || mDataQueue.size() == 0) 38 | mDumpThread = new std::thread(std::bind(&RecordTool::dataDumpThread, this)); 39 | } 40 | 41 | void RecordTool::stopRecording() { 42 | mRecording = false; 43 | mRecordThread->join(); 44 | } 45 | 46 | void RecordTool::execute() 47 | { 48 | } 49 | 50 | RecordTool::RecordTool() 51 | { 52 | m_fillCount = std::make_unique(0); 53 | m_emptyCount = std::make_unique(4000); 54 | } 55 | 56 | void RecordTool::queueForDataDump() 57 | { 58 | while(mRecording) { 59 | if(mTimeStampUpdated) 60 | m_emptyCount->wait(); 61 | 62 | { 63 | std::unique_lock lock(mRecordBufferMutex); 64 | if (!mRecording) 65 | break; 66 | 67 | std::map latestData; 68 | std::map latestTimeStamps; 69 | 70 | for (auto ch: mRecordChannels) { 71 | auto dumpData = DumpData(mStoragePath, mFrameCounter, ch.second->getNextFrame()); 72 | latestData[ch.first] = dumpData; 73 | latestTimeStamps[ch.first] = latestData[ch.first].data->getCreationTimestamp(); 74 | } 75 | 76 | mTimeStampUpdated = false; 77 | int count = 0; 78 | for (auto stamp: latestTimeStamps){ 79 | if(stamp.second > mLastTimeStamps[stamp.first]) 80 | count = count+1; 81 | } 82 | 83 | if(count == latestTimeStamps.size()) 84 | { 85 | mTimeStampUpdated = true; 86 | mLastTimeStamps = latestTimeStamps; 87 | mDataQueue.push(latestData); 88 | ++mFrameCounter; 89 | } 90 | 91 | if(mTimeStampUpdated) 92 | m_fillCount->signal(); 93 | } 94 | } 95 | } 96 | 97 | 98 | void RecordTool::dataDumpThread() { 99 | while (true) { 100 | m_fillCount->wait(); 101 | 102 | if (mDataQueue.empty() && mRecording) 103 | continue; 104 | else if (mDataQueue.empty() && !mRecording) 105 | break; 106 | 107 | for (auto data: mDataQueue.front()) { 108 | auto className = data.second.data->getNameOfClass(); 109 | auto parentPath = data.second.storagePath + "/" + data.first + "/"; 110 | std::string frameNr = std::to_string(data.second.frameNr); 111 | 112 | if (className == "Mesh") { 113 | auto meshExporter = PointCloudExporter::New(); 114 | meshExporter->setInputData(data.second.data); 115 | meshExporter->setWriteNormals(false); 116 | meshExporter->setWriteColors(true); 117 | meshExporter->setFilename(parentPath + frameNr + ".vtk"); 118 | meshExporter->update(); 119 | } else if (className == "Image") { 120 | auto imageExporter = MetaImageExporter::New(); 121 | imageExporter->setInputData(data.second.data); 122 | imageExporter->setFilename(parentPath + "Image-2D_" + frameNr + ".mhd"); 123 | imageExporter->update(); 124 | } 125 | } 126 | mDataQueue.pop(); 127 | m_emptyCount->signal(); 128 | } 129 | } 130 | 131 | 132 | uint RecordTool::getQueueSize() const { 133 | return mDataQueue.size(); 134 | } 135 | 136 | bool RecordTool::isRecording() const { 137 | return mRecording; 138 | } 139 | 140 | 141 | } 142 | 143 | -------------------------------------------------------------------------------- /source/EchoBot/Utilities/RecordTool.h: -------------------------------------------------------------------------------- 1 | #ifndef ECHOBOT_RECORDTOOL_H 2 | #define ECHOBOT_RECORDTOOL_H 3 | 4 | #include "EchoBot/Core/SmartPointers.h" 5 | #include "EchoBot/Core/DataTypes.h" 6 | #include "EchoBot/Interfaces/SensorInterface.h" 7 | 8 | #include "FAST/ProcessObject.hpp" 9 | #include "FAST/Streamers/Streamer.hpp" 10 | #include "FAST/Semaphore.hpp" 11 | #include 12 | #include 13 | 14 | class QElapsedTimer; 15 | 16 | namespace echobot { 17 | 18 | class RecordTool : public ProcessObject { 19 | ECHOBOT_OBJECT(RecordTool) 20 | 21 | public: 22 | void addRecordChannel(std::string name, DataChannel::pointer channel); 23 | void startRecording(std::string path); 24 | void stopRecording(); 25 | 26 | uint getQueueSize() const; 27 | bool isRecording() const; 28 | 29 | private: 30 | RecordTool(); 31 | void execute(); 32 | 33 | 34 | void dataDumpThread(); 35 | void queueForDataDump(); 36 | 37 | std::map mRecordChannels; 38 | 39 | struct DumpData{ 40 | DumpData(std::string path = "", uint frameNr = 0, DataObject::pointer data = nullptr) 41 | : storagePath(path), frameNr(frameNr), data(data){} 42 | 43 | std::string storagePath; 44 | uint frameNr; 45 | DataObject::pointer data; 46 | }; 47 | 48 | typedef std::map DataContainer; 49 | 50 | std::queue mDataQueue; 51 | std::map mLastTimeStamps; 52 | bool mTimeStampUpdated = true; 53 | 54 | bool mRecording = false; 55 | std::string mStoragePath; 56 | uint mFrameCounter; 57 | 58 | std::thread* mRecordThread; 59 | std::thread* mDumpThread; 60 | std::mutex mRecordBufferMutex; 61 | 62 | std::unique_ptr m_fillCount; 63 | std::unique_ptr m_emptyCount; 64 | }; 65 | 66 | } 67 | 68 | 69 | #endif //ECHOBOT_RECORDTOOL_H 70 | -------------------------------------------------------------------------------- /source/EchoBot/Utilities/Tests/CalibrationToolTests.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "EchoBot/Tests/catch.hpp" 5 | #include "EchoBot/Core/DataTypes.h" 6 | #include "EchoBot/Utilities/CalibrationTool.h" 7 | 8 | namespace echobot 9 | { 10 | 11 | TEST_CASE("Initialize tool and calibrate", "[EchoBot][Utilities]"){ 12 | auto calibrationTool = CalibrationTool::New(); 13 | calibrationTool->calibrate(); 14 | 15 | std::cout << calibrationTool->get_rMb().matrix() << std::endl; 16 | std::cout << calibrationTool->get_eeMt().matrix() << std::endl; 17 | std::cout << calibrationTool->get_tMus().matrix() << std::endl; 18 | } 19 | 20 | TEST_CASE("Load calibration files.", "[EchoBot][Utilities]") { 21 | auto calibrationTool = CalibrationTool::New(); 22 | auto path = Config::getConfigPath() + "calibration/camMbase.cal"; 23 | 24 | auto calMat = CalibrationTool::loadCalFile(path); 25 | std::cout << path << std::endl; 26 | std::cout << calMat.matrix() << std::endl; 27 | 28 | auto vec = toVector6D(calMat); 29 | std::cout << vec << std::endl; 30 | } 31 | 32 | TEST_CASE("Save calibration files.", "[EchoBot][Utilities]") { 33 | auto calibrationTool = CalibrationTool::New(); 34 | auto path = Config::getConfigPath() + "calibration/test.cal"; 35 | 36 | auto calMat = Eigen::Affine3d::Identity(); 37 | calMat(0,3) = 30.3; 38 | 39 | CalibrationTool::saveCalFile(path, calMat); 40 | } 41 | 42 | TEST_CASE("Load ", "[EchoBot][Utilities]") { 43 | 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /source/EchoBot/Utilities/Utilities.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by androst on 12.01.20. 3 | // 4 | 5 | #include "Utilities.h" 6 | 7 | namespace echobot{ 8 | 9 | std::vector split(const std::string input, const std::string &delimiter) { 10 | std::vector parts; 11 | int startPos = 0; 12 | while(true) { 13 | int pos = input.find(delimiter, startPos); 14 | if(pos == std::string::npos) { 15 | parts.push_back(input.substr(startPos)); 16 | break; 17 | } 18 | 19 | if(pos - startPos > 0) 20 | parts.push_back(input.substr(startPos, pos - startPos)); 21 | startPos = pos + delimiter.length(); 22 | } 23 | 24 | return parts; 25 | } 26 | 27 | std::string replace(std::string str, std::string find, std::string replacement) { 28 | while(true) { 29 | int pos = str.find(find); 30 | if(pos == std::string::npos) 31 | break; 32 | str.replace(pos, find.size(), replacement); 33 | } 34 | 35 | return str; 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /source/EchoBot/Utilities/Utilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by androst on 12.01.20. 3 | // 4 | 5 | #ifndef ECHOBOT_UTILITIES_H 6 | #define ECHOBOT_UTILITIES_H 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace echobot{ 14 | 15 | ECHOBOT_EXPORT std::vector split(const std::string input, const std::string& delimiter = " "); 16 | ECHOBOT_EXPORT std::string replace(std::string str, std::string find, std::string replacement); 17 | 18 | // trim from start (in place) 19 | static inline void ltrim(std::string &s) { 20 | s.erase(s.begin(), std::find_if(s.begin(), s.end(), 21 | [](unsigned char c) {return !std::isspace(c); })); 22 | } 23 | 24 | // trim from end (in place) 25 | static inline void rtrim(std::string &s) { 26 | s.erase(std::find_if(s.rbegin(), s.rend(), 27 | [](unsigned char c) {return !std::isspace(c); }).base(), s.end()); 28 | } 29 | 30 | // trim from both ends (in place) 31 | static inline void trim(std::string &s) { 32 | ltrim(s); 33 | rtrim(s); 34 | } 35 | 36 | } // end namespace echobot 37 | 38 | #endif //ECHOBOT_UTILITIES_H 39 | -------------------------------------------------------------------------------- /source/EchoBot/Visualization/CADModels/.gitignore: -------------------------------------------------------------------------------- 1 | /original 2 | clarius_probe_with_holder.vtk -------------------------------------------------------------------------------- /source/EchoBot/Visualization/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project_add_sources( 2 | RobotVisualization.cpp 3 | RobotVisualization.h 4 | VisualizationHelper.cpp 5 | VisualizationHelper.h 6 | ) 7 | 8 | project_add_test_sources( 9 | RobotVisualizationTests.cpp 10 | ) 11 | -------------------------------------------------------------------------------- /source/EchoBot/Visualization/RobotVisualization.cpp: -------------------------------------------------------------------------------- 1 | #include "RobotVisualization.h" 2 | #include "EchoBot/Core/DataTypes.h" 3 | #include 4 | #include "FAST/SceneGraph.hpp" 5 | 6 | namespace echobot 7 | { 8 | 9 | RobotVisualizator::RobotVisualizator() 10 | { 11 | mCADModelPath = "../../source/EchoBot/Visualization/CADModels/"; 12 | mRenderer = TriangleRenderer::New(); 13 | } 14 | 15 | void RobotVisualizator::setInterface(RobotInterface::pointer robotInterface) 16 | { 17 | mRobotInterface = robotInterface; 18 | 19 | auto subpath = "ur5/"; 20 | auto probe_filename = "clarius_probe_with_holder_ur5.vtk"; 21 | 22 | if(mRobotInterface->getManipulatorInfo().manipulator == ManipulatorType::UR10) 23 | { 24 | subpath = "ur10e/"; 25 | probe_filename = "clarius_probe_with_holder_ur10.vtk"; 26 | } 27 | 28 | this->addPart("base", mCADModelPath + subpath + "base.vtk"); 29 | this->addPart("shoulder", mCADModelPath + subpath + "shoulder.vtk"); 30 | this->addPart("forearm", mCADModelPath + subpath + "forearm.vtk"); 31 | this->addPart("upperarm", mCADModelPath + subpath +"upperarm.vtk"); 32 | this->addPart("wrist1", mCADModelPath + subpath +"wrist1.vtk"); 33 | this->addPart("wrist2", mCADModelPath + subpath +"wrist2.vtk"); 34 | this->addPart("wrist3", mCADModelPath + subpath +"wrist3.vtk"); 35 | this->addTool("tool", mCADModelPath + probe_filename); 36 | 37 | QObject::connect(mRobotInterface.get(), &RobotInterface::stateUpdated, 38 | std::bind(&RobotVisualizator::updatePositions, this)); 39 | } 40 | 41 | void RobotVisualizator::updatePositions() 42 | { 43 | auto currentState = mRobotInterface->getRobot()->getCurrentState(); 44 | auto rMb = mRobotInterface->getRobot()->getCoordinateSystem()->get_rMb(); 45 | auto eeMt = mRobotInterface->getRobot()->getCoordinateSystem()->get_eeMt(); 46 | 47 | if(currentState->getJointConfig() != mPreviousJointConfig 48 | || rMb.matrix() != mPrevious_rMb.matrix() 49 | || eeMt.matrix() != mPrevious_eeMt.matrix()) 50 | { 51 | if(mRobotInterface->getManipulatorInfo().manipulator == ManipulatorType::UR5) 52 | { 53 | Eigen::Affine3d offset_link2 = Eigen::Affine3d::Identity(); 54 | offset_link2.translate(Eigen::Vector3d(0.0,0.0,121.0)); 55 | 56 | mParts["base"]->setTransformation(rMb); 57 | mParts["shoulder"]->setTransformation(rMb*currentState->getTransformToJoint(1)); 58 | mParts["forearm"]->setTransformation(rMb*currentState->getTransformToJoint(1)*offset_link2); 59 | mParts["forearm"]->rotate(0,0, currentState->getJointConfig()(1)*180/M_PI+90); 60 | mParts["upperarm"]->setTransformation(rMb*currentState->getTransformToJoint(2)); 61 | mParts["upperarm"]->rotate(0,0, currentState->getJointConfig()(2)*180/M_PI); 62 | mParts["wrist1"]->setTransformation(rMb*currentState->getTransformToJoint(4)); 63 | mParts["wrist2"]->setTransformation(rMb*currentState->getTransformToJoint(5)); 64 | mParts["wrist3"]->setTransformation(rMb*currentState->getTransformToJoint(6)); 65 | mTool->setTransformation(rMb*currentState->getTransformToJoint(6)*eeMt); 66 | } else if(mRobotInterface->getManipulatorInfo().manipulator == ManipulatorType::UR10) 67 | { 68 | mParts["base"]->setTransformation(rMb*currentState->getTransformToJoint(0)); 69 | mParts["base"]->rotate(90, 0, 0); 70 | 71 | mParts["shoulder"]->setTransformation(rMb*currentState->getTransformToJoint(1)); 72 | 73 | mParts["upperarm"]->setTransformation(rMb*currentState->getTransformToJoint(1)); 74 | mParts["upperarm"]->rotate(0, 0, currentState->getJointConfig()(1)*180/M_PI+90); 75 | 76 | mParts["forearm"]->setTransformation(rMb*currentState->getTransformToJoint(2)); 77 | mParts["forearm"]->rotate(0, 0, currentState->getJointConfig()(2)*180/M_PI+90); 78 | 79 | mParts["wrist1"]->setTransformation(rMb*currentState->getTransformToJoint(4)); 80 | mParts["wrist2"]->setTransformation(rMb*currentState->getTransformToJoint(5)); 81 | mParts["wrist3"]->setTransformation(rMb*currentState->getTransformToJoint(6)); 82 | 83 | mTool->setTransformation(rMb*currentState->getTransformToJoint(6)*eeMt); 84 | } 85 | 86 | mPreviousJointConfig = currentState->getJointConfig(); 87 | mPrevious_rMb = rMb; 88 | mPrevious_eeMt = eeMt; 89 | } 90 | 91 | } 92 | 93 | void RobotPart::setTransformation(Eigen::Affine3d transform) 94 | { 95 | AffineTransformation::pointer T = AffineTransformation::New(); 96 | T->setTransform(transform.cast()); 97 | mMesh->getSceneGraphNode()->setTransformation(T); 98 | } 99 | 100 | void RobotVisualizator::addPart(std::string partName, std::string cadFilepath) 101 | { 102 | auto part = RobotPart::New(); 103 | part->setPart(partName, cadFilepath); 104 | mParts[partName] = part; 105 | } 106 | 107 | void RobotVisualizator::addTool(std::string toolName, std::string cadFilepath) 108 | { 109 | auto tool = RobotTool::New(); 110 | tool->setPart(toolName, cadFilepath); 111 | mTool = tool; 112 | } 113 | 114 | 115 | TriangleRenderer::pointer RobotVisualizator::getRenderer() 116 | { 117 | mRenderer = TriangleRenderer::New(); 118 | mRenderer->addInputData(mParts["base"]->getMesh()); 119 | mRenderer->addInputData(mParts["shoulder"]->getMesh()); 120 | mRenderer->addInputData(mParts["upperarm"]->getMesh()); 121 | mRenderer->addInputData(mParts["forearm"]->getMesh()); 122 | mRenderer->addInputData(mParts["wrist1"]->getMesh()); 123 | mRenderer->addInputData(mParts["wrist2"]->getMesh()); 124 | mRenderer->addInputData(mParts["wrist3"]->getMesh()); 125 | return mRenderer; 126 | } 127 | 128 | RobotTool::RobotTool() 129 | { 130 | } 131 | 132 | TriangleRenderer::pointer RobotTool::getRenderer() 133 | { 134 | mRenderer = fast::TriangleRenderer::New(); 135 | mRenderer->addInputData(this->getMesh()); 136 | return mRenderer; 137 | } 138 | 139 | RobotPart::RobotPart() 140 | { 141 | } 142 | 143 | void RobotPart::setPart(std::string partName, std::string filename) 144 | { 145 | mPartName = partName; 146 | mMesh = getMeshFromFile(filename); 147 | } 148 | 149 | Mesh::pointer RobotPart::getMesh () 150 | { 151 | return mMesh; 152 | } 153 | 154 | std::string RobotPart::getName() const 155 | { 156 | return mPartName; 157 | } 158 | 159 | 160 | void RobotPart::rotate(double rx, double ry, double rz) 161 | { 162 | AffineTransformation::pointer T = mMesh->getSceneGraphNode()->getTransformation(); 163 | 164 | Matrix3f m; 165 | m = Eigen::AngleAxisf(rx*M_PI/180, Vector3f::UnitX())* 166 | Eigen::AngleAxisf(ry*M_PI/180, Vector3f::UnitY())* 167 | Eigen::AngleAxisf(rz*M_PI/180, Vector3f::UnitZ()); 168 | 169 | Affine3f transform = T->getTransform(); 170 | transform.linear() = transform.linear()*m; 171 | 172 | T->setTransform(transform); 173 | mMesh->getSceneGraphNode()->setTransformation(T); 174 | } 175 | 176 | void RobotPart::translate(double x, double y, double z) 177 | { 178 | auto currentTransform = mMesh->getSceneGraphNode()->getTransformation(); 179 | auto offset = Eigen::Affine3f::Identity(); 180 | offset.translate(Eigen::Vector3f(x, y, z)); 181 | Affine3f newTransform = currentTransform->getTransform()*offset; 182 | currentTransform->setTransform(newTransform); 183 | mMesh->getSceneGraphNode()->setTransformation(currentTransform); 184 | } 185 | 186 | void RobotPart::transform(Eigen::Affine3d transform) 187 | { 188 | AffineTransformation::pointer T = mMesh->getSceneGraphNode()->getTransformation(); 189 | 190 | Affine3f current = T->getTransform(); 191 | T->setTransform(current*transform.cast()); 192 | 193 | mMesh->getSceneGraphNode()->setTransformation(T); 194 | } 195 | 196 | Mesh::pointer RobotPart::getMeshFromFile(std::string filename) 197 | { 198 | fast::VTKMeshFileImporter::pointer importer = fast::VTKMeshFileImporter::New(); 199 | importer->setFilename(filename); 200 | 201 | DataChannel::pointer importPort = importer->getOutputPort(); 202 | importer->update(); 203 | 204 | return importPort->getNextFrame(); 205 | } 206 | 207 | 208 | 209 | } -------------------------------------------------------------------------------- /source/EchoBot/Visualization/RobotVisualization.h: -------------------------------------------------------------------------------- 1 | #ifndef ROBOTVISUALIZATION_H 2 | #define ROBOTVISUALIZATION_H 3 | 4 | #include "EchoBot/Interfaces/Robot/RobotInterface.h" 5 | 6 | #include "FAST/ProcessObject.hpp" 7 | #include "FAST/Visualization/TriangleRenderer/TriangleRenderer.hpp" 8 | 9 | /** 10 | * Implementation of visualization of Robot Visualizator and tool. 11 | * 12 | * \author Andreas Østvik 13 | */ 14 | 15 | namespace echobot 16 | { 17 | 18 | class RobotPart 19 | { 20 | ECHOBOT_OBJECT(RobotPart) 21 | 22 | public: 23 | RobotPart(); 24 | 25 | void transform(Eigen::Affine3d transform); 26 | void rotate(double rx, double ry, double rz); 27 | void translate(double x, double y, double z); 28 | 29 | void setPart(std::string partName, std::string cadFile); 30 | void setTransformation(Eigen::Affine3d transform); 31 | 32 | Mesh::pointer getMesh(); 33 | std::string getName() const; 34 | 35 | 36 | private: 37 | Mesh::pointer mMesh; 38 | std::string mPartName; 39 | Mesh::pointer getMeshFromFile(std::string filename); 40 | 41 | std::weak_ptr mPtr; 42 | }; 43 | 44 | class RobotTool : public RobotPart 45 | { 46 | ECHOBOT_OBJECT(RobotTool) 47 | 48 | public: 49 | RobotTool(); 50 | TriangleRenderer::pointer getRenderer(); 51 | 52 | private: 53 | TriangleRenderer::pointer mRenderer; 54 | std::weak_ptr mPtr; 55 | }; 56 | 57 | class RobotVisualizator 58 | { 59 | ECHOBOT_OBJECT(RobotVisualizator) 60 | 61 | public: 62 | RobotVisualizator(); 63 | void setInterface(RobotInterface::pointer robotInterface); 64 | 65 | TriangleRenderer::pointer getRenderer(); 66 | RobotTool::pointer getTool(){ return this->mTool;}; 67 | 68 | private: 69 | RobotInterface::pointer mRobotInterface; 70 | TriangleRenderer::pointer mRenderer; 71 | std::map mParts; 72 | RobotTool::pointer mTool; 73 | 74 | romocc::Transform3d mPrevious_rMb, mPrevious_eeMt; 75 | romocc::Vector6d mPreviousJointConfig; 76 | std::string mCADModelPath; 77 | 78 | void addPart(std::string partName, std::string cadFilepath); 79 | void addTool(std::string toolName, std::string cadFilepath); 80 | 81 | void updatePositions(); 82 | 83 | std::weak_ptr mPtr; 84 | }; 85 | 86 | } 87 | 88 | #endif // ROBOTVISUALIZATION_H 89 | -------------------------------------------------------------------------------- /source/EchoBot/Visualization/RobotVisualizationTests.cpp: -------------------------------------------------------------------------------- 1 | #include "EchoBot/Tests/catch.hpp" 2 | #include "EchoBot/Utilities/PointCloudUtilities.h" 3 | #include "EchoBot/Exporters/PointCloudExporter.h" 4 | #include "EchoBot/Core/Config.h" 5 | 6 | #include "EchoBot/Interfaces/Robot/RobotInterface.h" 7 | #include "RobotVisualization.h" 8 | #include "VisualizationHelper.h" 9 | 10 | #include "FAST/Visualization/SimpleWindow.hpp" 11 | 12 | 13 | 14 | namespace echobot { 15 | 16 | TEST_CASE("Visualize robot joints", "[EchoBot][Visualization]") { 17 | auto robotInterface = RobotInterface::New(); 18 | robotInterface->setConfiguration(ManipulatorType::UR10, "192.168.153.131", 30003); 19 | robotInterface->connect(); 20 | 21 | auto robotVisualizator = RobotVisualizator::New(); 22 | robotVisualizator->setInterface(robotInterface); 23 | 24 | auto refMbase = Eigen::Affine3f::Identity(); 25 | auto bMee = robotInterface->getCurrentState()->get_bMee().cast(); 26 | 27 | auto window = fast::SimpleWindow::New(); 28 | window->set3DMode(); 29 | window->addRenderer(robotVisualizator->getRenderer()); 30 | window->addRenderer(VisualizationHelper::createCoordinateFrameRenderer(refMbase, 300)); 31 | window->addRenderer(VisualizationHelper::createCoordinateFrameRenderer(bMee, 300)); 32 | window->start(); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /source/EchoBot/Visualization/VisualizationHelper.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by androst on 16.01.20. 3 | // 4 | 5 | #include "VisualizationHelper.h" 6 | 7 | #include "EchoBot/Core/DataTypes.h" 8 | #include 9 | 10 | namespace echobot { 11 | 12 | fast::LineRenderer::pointer VisualizationHelper::createCoordinateFrameRenderer(Eigen::Affine3f transform, 13 | float axisLength) 14 | { 15 | std::vector vertices = { 16 | MeshVertex(transform.linear()*Vector3f(0, 0, 0) + transform.translation()), 17 | MeshVertex(transform.linear()*Vector3f(axisLength, 0, 0) + transform.translation()), 18 | MeshVertex(transform.linear()*Vector3f(0, axisLength, 0) + transform.translation()), 19 | MeshVertex(transform.linear()*Vector3f(0, 0, axisLength) + transform.translation()), 20 | }; 21 | 22 | 23 | std::vector x_line = {fast::MeshLine(0, 1)}; 24 | std::vector y_line = {fast::MeshLine(0, 2)}; 25 | std::vector z_line = {fast::MeshLine(0, 3)}; 26 | 27 | auto x_mesh = Mesh::New(); 28 | x_mesh->create(vertices, x_line); 29 | 30 | auto y_mesh = Mesh::New(); 31 | y_mesh->create(vertices, y_line); 32 | 33 | auto z_mesh = Mesh::New(); 34 | z_mesh->create(vertices, z_line); 35 | 36 | auto lineRenderer = fast::LineRenderer::New(); 37 | lineRenderer->addInputData(x_mesh); 38 | lineRenderer->addInputData(y_mesh); 39 | lineRenderer->addInputData(z_mesh); 40 | lineRenderer->setColor(0, Color::Red()); 41 | lineRenderer->setColor(1, Color::Green()); 42 | lineRenderer->setColor(2, Color::Blue()); 43 | return lineRenderer; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /source/EchoBot/Visualization/VisualizationHelper.h: -------------------------------------------------------------------------------- 1 | #ifndef ECHOBOT_VISUALIZATIONHELPER_H 2 | #define ECHOBOT_VISUALIZATIONHELPER_H 3 | 4 | #include "EchoBot/Core/SmartPointers.h" 5 | #include "EchoBot/Core/DataTypes.h" 6 | 7 | #include "FAST/Visualization/LineRenderer/LineRenderer.hpp" 8 | 9 | namespace echobot { 10 | 11 | class VisualizationHelper { 12 | ECHOBOT_OBJECT(VisualizationHelper) 13 | 14 | public: 15 | static LineRenderer::pointer createCoordinateFrameRenderer(Eigen::Affine3f transform, float axisLength = 500); 16 | 17 | private: 18 | std::weak_ptr mPtr; 19 | 20 | }; 21 | 22 | } 23 | 24 | #endif //ECHOBOT_VISUALIZATIONHELPER_H 25 | --------------------------------------------------------------------------------