Skip to content

Commit

Permalink
Cleanup (remove unused code and format style) (#492)
Browse files Browse the repository at this point in the history
* Remove unused classes

* Remove SingleViewWindow

* Remove DrawableTexture

* Remove vtkQtProgressDialog

* Remove vtkProgressTerminalOutput

* Remove use of deprecated AllDockWidgetFeatures

* Add linter workflow

* Using super-linter with clang-format

* Ran clang-format

* Remove code wrongfully triggering clang-format

* Is this a bug in clang-format?
* Will just remove it for now

* Fix compile issues introduced in cleanup

* Modernize and clean CMakeLists style

* Amend previous run of clang-format

* Add missing includes in guiutilities
  • Loading branch information
errollgarner authored Jun 27, 2023
1 parent 5653f2e commit 278c4c7
Show file tree
Hide file tree
Showing 323 changed files with 19,330 additions and 22,219 deletions.
23 changes: 23 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
BasedOnStyle: Google
IndentWidth: 4
---
Language: Cpp
ColumnLimit: 120
AccessModifierOffset: -4
SpaceBeforeParens: Never
SpacesInParentheses: true
SpaceInEmptyParentheses: false
SpaceInEmptyBlock: false
SpaceAroundPointerQualifiers: Both
SpaceAfterLogicalNot: false
SpaceBeforeAssignmentOperators: true
AlignConsecutiveAssignments: Consecutive
BreakBeforeBraces: Allman
AlignAfterOpenBracket: Align
DerivePointerAlignment: false
PointerAlignment: Middle
AllowShortLambdasOnASingleLine: Empty
UseTab: Never
SpacesInSquareBrackets: false
---
33 changes: 33 additions & 0 deletions .github/workflows/super-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This workflow executes several linters on changed files based on languages used in your code base whenever
# you push a code or open a pull request.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/github/super-linter
name: Lint Code Base

on:
push:
branches: "master"
pull_request:
branches: "master"
types: [opened, edited]
jobs:
run-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0

- name: Lint Code Base
uses: github/super-linter@v4
env:
FILTER_REGEX_EXCLUDE: .*/IbisPlugins.*|.*/svl/.*|.*moc_.*|.*/IbisLib/.*
# VALIDATE_CPP: true
VALIDATE_CLANG_FORMAT: true
DEFAULT_BRANCH: "master"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINTER_RULES_PATH: /
65 changes: 32 additions & 33 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
cmake_minimum_required( VERSION 3.5 )

SET(CMAKE_COMMON_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMakeCommon)
set( CMAKE_COMMON_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMakeCommon )

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeCommon ${CMAKE_MODULE_PATH})
set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeCommon ${CMAKE_MODULE_PATH} )

#=====================================================
# Find location to install the progs
#
# This MUST come before PROJECT or it does not work
#======================================================
INCLUDE(${CMAKE_COMMON_DIR}/InstallLocation.cmake)
include( ${CMAKE_COMMON_DIR}/InstallLocation.cmake )

PROJECT( ibis )
project( ibis )

INCLUDE(CMakeDependentOption)
include( CMakeDependentOption )

#----------------------------------------
# Tell the compiler to use c++11 which is required with Qt >= 5.7
Expand All @@ -24,7 +24,7 @@ set( CMAKE_CXX_STANDARD 11 )
# Define a variable to hold the path of automatically compiled
# dependencies.
#==================================================================
include(${CMAKE_COMMON_DIR}/DependencyVersions.cmake)
include( ${CMAKE_COMMON_DIR}/DependencyVersions.cmake )
set( IBIS_EXTERNAL_DEPENDENCIES_DIR ${CMAKE_CURRENT_BINARY_DIR}/../IbisDeps CACHE PATH "Path where the external dependencies (itk, vtk, openCV) have been built" )

#==================================================================
Expand All @@ -39,7 +39,7 @@ endif()
if( IBIS_USE_QT_NETWORK )
list( APPEND IbisQtModules Network )
endif()
if(UNIX AND NOT APPLE)
if( UNIX AND NOT APPLE )
list( APPEND IbisQtModules X11Extras )
endif()
find_package( Qt5 COMPONENTS ${IbisQtModules} REQUIRED )
Expand All @@ -48,15 +48,15 @@ find_package( Qt5 COMPONENTS ${IbisQtModules} REQUIRED )
# ibis was never tested with versions 5.6.0, 5.7.0 and 5.8.0. It might work with 5.8.0.
# it worked with 5.9.3

if (Qt5Widgets_FOUND)
if (Qt5Widgets_VERSION VERSION_LESS 5.6.0)
message(SEND_ERROR "Qt version 5.5.x or lower is no longer supported.\nCurrently supported Qt version is 5.9 and higher.\nYou are using " ${Qt5Widgets_VERSION} "." )
elseif (Qt5Widgets_VERSION VERSION_LESS 5.9.0)
message(SEND_ERROR "Currently supported Qt version is 5.9 and higher.\nYou are using " ${Qt5Widgets_VERSION} ". It may work." )
if( Qt5Widgets_FOUND )
if( Qt5Widgets_VERSION VERSION_LESS 5.6.0 )
message( SEND_ERROR "Qt version 5.5.x or lower is no longer supported.\nCurrently supported Qt version is 5.9 and higher.\nYou are using " ${Qt5Widgets_VERSION} "." )
elseif( Qt5Widgets_VERSION VERSION_LESS 5.9.0 )
message( SEND_ERROR "Currently supported Qt version is 5.9 and higher.\nYou are using " ${Qt5Widgets_VERSION} ". It may work." )
endif()
else()
message(SEND_ERROR "The Qt5Widgets library could not be found!")
endif(Qt5Widgets_FOUND)
message( SEND_ERROR "The Qt5Widgets library could not be found!" )
endif()

include_directories( ${Qt5Widgets_INCLUDE_DIRS} )
include_directories( ${Qt5Xml_INCLUDE_DIRS} )
Expand Down Expand Up @@ -84,7 +84,7 @@ include( ${ITK_USE_FILE} )
#==================================================================
# Look for OpenCV (required by some plugins, but not the main app)
#==================================================================
OPTION( IBIS_USE_OPENCV "Use OpenCV library" OFF )
option( IBIS_USE_OPENCV "Use OpenCV library" OFF )
if( IBIS_USE_OPENCV )
set( AutoOpenCVPath ${IBIS_EXTERNAL_DEPENDENCIES_DIR}/opencv-${IBIS_OPENCV_LONG_VERSION}/build )
find_package( OpenCV ${IBIS_OPENCV_LONG_VERSION} REQUIRED EXACT PATHS ${AutoOpenCVPath} )
Expand All @@ -105,7 +105,7 @@ endif()
#==================================================================
# Create options to build or not the different dependent projects.
#==================================================================
OPTION( IBIS_BUILD_DEFAULT_HARDWARE_MODULE "Build hardware module based on OpenIGTLink and dependencies (OpenIGTLink and OpenIGTLinkIO)" ON )
option( IBIS_BUILD_DEFAULT_HARDWARE_MODULE "Build hardware module based on OpenIGTLink and dependencies (OpenIGTLink and OpenIGTLinkIO)" ON )

find_package ( OpenCL QUIET )
include(${CMAKE_COMMON_DIR}/OpenCLMacros.cmake)
Expand Down Expand Up @@ -150,22 +150,22 @@ add_subdirectory( Ibis )
#
option( IBIS_BUILD_DOCUMENTATION "Build ibis documentation using Doxygen" OFF )
if( IBIS_BUILD_DOCUMENTATION )
option(DOXYGEN_SHORT_NAMES "Build Doxygen of VTK using short file names" OFF)
option(DOXYGEN_GENERATE_HTMLHELP "Generate HTML help (CHM) files" ON)
if(DOXYGEN_SHORT_NAMES)
set(DOXYGEN_SHORT_NAMES YES)
option( DOXYGEN_SHORT_NAMES "Build Doxygen of VTK using short file names" OFF )
option( DOXYGEN_GENERATE_HTMLHELP "Generate HTML help (CHM) files" ON )
if( DOXYGEN_SHORT_NAMES )
set( DOXYGEN_SHORT_NAMES YES )
else()
set(DOXYGEN_SHORT_NAMES NO)
set( DOXYGEN_SHORT_NAMES NO )
endif()
if(DOXYGEN_GENERATE_HTMLHELP)
set(DOXYGEN_GENERATE_HTMLHELP YES)
if( DOXYGEN_GENERATE_HTMLHELP )
set( DOXYGEN_GENERATE_HTMLHELP YES )
else()
set(DOXYGEN_GENERATE_HTMLHELP NO)
set( DOXYGEN_GENERATE_HTMLHELP NO )
endif()
find_package(Doxygen REQUIRED)
if (DOXYGEN_FOUND)
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxygen/Doxyfile)
if( DOXYGEN_FOUND )
set( DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/doxyfile.in )
set( DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxygen/Doxyfile )
# configure Doxygen file
configure_file( ${DOXYGEN_IN} ${DOXYGEN_OUT} )
# note the option ALL which allows to build the docs together with the application
Expand All @@ -174,8 +174,7 @@ if( IBIS_BUILD_DOCUMENTATION )
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
else (DOXYGEN_FOUND)
message("Doxygen needs to be installed to generate documentation")
endif (DOXYGEN_FOUND)
endif()

else( DOXYGEN_FOUND )
message( "Doxygen needs to be installed to generate documentation" )
endif()
endif()
16 changes: 7 additions & 9 deletions Ibis/commandlinearguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ See Copyright.txt or http://ibisneuronav.org/Copyright.html for details.
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "commandlinearguments.h"

#include <iostream>

CommandLineArguments::CommandLineArguments()
: m_viewerOnly( false )
, m_loadPrevConfig( false )
, m_loadDefaultConfig( false )
, m_loadConfigFile( false )
: m_viewerOnly( false ), m_loadPrevConfig( false ), m_loadDefaultConfig( false ), m_loadConfigFile( false )
{
}

Expand All @@ -24,17 +22,17 @@ bool CommandLineArguments::ParseArguments( QStringList & args )
for( int i = 1; i < args.size(); ++i )
{
QString arg = args[i];
if( arg == "-l")
if( arg == "-l" )
m_loadPrevConfig = true;
else if( arg == "-d")
else if( arg == "-d" )
m_loadDefaultConfig = true;
else if( arg == "-f" )
{
m_loadConfigFile = true;
if( args.size() > i + 1 )
{
QString nextArg = args[i+1];
if( nextArg.startsWith('-') )
QString nextArg = args[i + 1];
if( nextArg.startsWith( '-' ) )
{
std::cerr << "Error: expecting config filename after -f option" << std::endl;
return false;
Expand All @@ -48,7 +46,7 @@ bool CommandLineArguments::ParseArguments( QStringList & args )
return false;
}
}
else if( arg == "-v")
else if( arg == "-v" )
m_viewerOnly = true;
else
m_loadFileNames.push_back( arg );
Expand Down
4 changes: 0 additions & 4 deletions Ibis/commandlinearguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ See Copyright.txt or http://ibisneuronav.org/Copyright.html for details.

class CommandLineArguments
{

public:

CommandLineArguments();
bool ParseArguments( QStringList & args );

Expand All @@ -29,14 +27,12 @@ class CommandLineArguments
QStringList GetDataFilesToLoad() { return m_loadFileNames; }

protected:

bool m_viewerOnly;
bool m_loadPrevConfig;
bool m_loadDefaultConfig;
bool m_loadConfigFile;
QString m_configFile;
QStringList m_loadFileNames;

};

#endif
28 changes: 15 additions & 13 deletions Ibis/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,38 @@ See Copyright.txt or http://ibisneuronav.org/Copyright.html for details.
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include <QVTKRenderWidget.h>
#include <vtkObject.h>

#include <QApplication>
#include <QTimer>
#include <QFile>
#include <QDir>
#include <QFile>
#include <QMessageBox>
#include <QTimer>

#include "application.h"
#include "mainwindow.h"
#include "commandlinearguments.h"
#include <vtkObject.h>
#include <QVTKRenderWidget.h>
#include "mainwindow.h"

int main( int argc, char** argv )
int main( int argc, char ** argv )
{
// Disable VTK warnings unless not wanted
#ifdef VTK_NO_WARNINGS
vtkObject::SetGlobalWarningDisplay( 0 );
#endif

// Set default format for render windows - Warning: has to be done before QApplication instanciation
QSurfaceFormat::setDefaultFormat(QVTKRenderWidget::defaultFormat());
QSurfaceFormat::setDefaultFormat( QVTKRenderWidget::defaultFormat() );

// Create Qt app
QApplication a( argc, argv );
Q_INIT_RESOURCE(IbisLib);
Q_INIT_RESOURCE( IbisLib );

// Warning : IBIS IS NOT APPROVED FOR CLINICAL USE.
if( !QFile::exists( QDir::homePath() + QString("/.ibis/no-clinical-warning.txt") ) )
QMessageBox::warning( nullptr, "WARNING!", QString("The Ibis platform is not approved for clinical use.") );
// On Mac, we always do Viewer-mode only without command-line params for now
if( !QFile::exists( QDir::homePath() + QString( "/.ibis/no-clinical-warning.txt" ) ) )
QMessageBox::warning( nullptr, "WARNING!", QString( "The Ibis platform is not approved for clinical use." ) );

// On Mac, we always do Viewer-mode only without command-line params for now
// Parse command-line arguments
CommandLineArguments cmdArgs;
QStringList args = a.arguments();
Expand Down Expand Up @@ -70,7 +72,7 @@ int main( int argc, char** argv )
a.installEventFilter( mw );

// Will cause OnStartMainLoop slot to be called after main loop is started
QTimer::singleShot( 0, mw, SLOT(OnStartMainLoop()) );
QTimer::singleShot( 0, mw, SLOT( OnStartMainLoop() ) );

// Start main loop
int ret = a.exec();
Expand Down
Loading

0 comments on commit 278c4c7

Please sign in to comment.