Skip to content

Commit

Permalink
Qt5 upgrade WIP
Browse files Browse the repository at this point in the history
First pass at Qt5ing. Mostly changing the windows specific Qt5 defines into a all platform generic version. Add a few missing headers
  • Loading branch information
Mark Bolstad committed Jan 23, 2019
1 parent 8a7236f commit ccfa74e
Show file tree
Hide file tree
Showing 42 changed files with 141 additions and 105 deletions.
6 changes: 5 additions & 1 deletion build.cmake
Expand Up @@ -26,6 +26,7 @@ CMAKE_BUILD="Release"
CMAKE_EXE=""
BUILD_DIR=`pwd`
ROOT_DIR=`pwd`
DESIRED_QT_VERSION=4
NO_STOP_ON_ERROR="-i"

set -eu
Expand Down Expand Up @@ -76,7 +77,8 @@ while [[ $# > 0 ]]; do
CMAKE_ARGS+=" -DCMAKE_VERBOSE_MAKEFILE:BOOL=TRUE "
;;
-qt5)
CMAKE_ARGS+=" -DFORCE_QT4:BOOL=OFF "
DESIRED_QT_VERSION=5
CMAKE_ARGS+=" -DCMAKE_CXX_FLAGS=\"-std=c++11\" "
;;
-dev)
NO_STOP_ON_ERROR=""
Expand All @@ -103,6 +105,8 @@ while [[ $# > 0 ]]; do
shift
done

CMAKE_ARGS+=" -DDESIRED_QT_VERSION=$DESIRED_QT_VERSION "

PLATFORM=$PLATFORM_ARCH
PLATFORM+="_"
PLATFORM+=$CMAKE_BUILD
Expand Down
2 changes: 1 addition & 1 deletion v3d_main/3drenderer/GLee_r.h
Expand Up @@ -100,7 +100,7 @@ Peng, H, Ruan, Z., Atasoy, D., and Sternson, S. (2010) “Automatic reconstructi
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX //added by PHC, 2010-05-20 to overcome VC min max macro
#include <windows.h>
#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
#include <GL\glew.h>
#else
#include <GL/gl.h>
Expand Down
2 changes: 1 addition & 1 deletion v3d_main/3drenderer/ItemEditor.h
Expand Up @@ -39,7 +39,7 @@ Peng, H, Ruan, Z., Atasoy, D., and Sternson, S. (2010) “Automatic reconstructi
#define ITEM_EDITOR_H_

#include "../v3d/version_control.h"
#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
#include <QtWidgets>
#include "qwidget.h"
#else
Expand Down
2 changes: 1 addition & 1 deletion v3d_main/3drenderer/barFigureDialog.h
Expand Up @@ -40,7 +40,7 @@ Peng, H, Ruan, Z., Atasoy, D., and Sternson, S. (2010) “Automatic reconstructi


#include "version_control.h"
#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
#include <QtWidgets>
#else
#include <QtGui>
Expand Down
6 changes: 3 additions & 3 deletions v3d_main/3drenderer/gradients.h
Expand Up @@ -75,13 +75,13 @@ Peng, H, Ruan, Z., Atasoy, D., and Sternson, S. (2010) “Automatic reconstructi
#define GRADIENTS_H

#include <version_control.h>
#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
#include <QtWidgets>
#include "..\..\..\..\Qt\Qt5.6.2\Examples\Qt-5.6\widgets\painting\shared\hoverpoints.h"
#else
#include <QtGui>
#include <hoverpoints.h>
#endif
#include <hoverpoints.h>
#include "v3d_hoverpoints.h"

class ShadeWidget : public QWidget
{
Expand Down
2 changes: 1 addition & 1 deletion v3d_main/3drenderer/nstroke_tracing.cpp
Expand Up @@ -5844,7 +5844,7 @@ void Renderer_gl1::retypeMultiNeuronsByStroke()
// "\n else -- custom \n"),
// node_type, 0, 100, 1, &ok);
////=======
#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
node_type = QInputDialog::getInt(0, QObject::tr("Change node type in segment"),
QObject::tr("SWC type: "
"\n 0 -- undefined (white)"
Expand Down
2 changes: 1 addition & 1 deletion v3d_main/3drenderer/renderer_hit.cpp
Expand Up @@ -1316,7 +1316,7 @@ int Renderer_gl1::processHit(int namelen, int names[], int cx, int cy, bool b_me
bool ok1=true;
V3DLONG chno=1;
if (curImg->getCDim()>1)
#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
chno = QInputDialog::getInt(0, QString("select a channel"), QString("select a channel of image you'd apply AutoMarker to:"), 1, 1, int(curImg->getCDim()), 1, &ok1);
#else
chno = QInputDialog::getInteger(0, QString("select a channel"), QString("select a channel of image you'd apply AutoMarker to:"), 1, 1, int(curImg->getCDim()), 1, &ok1);
Expand Down
8 changes: 4 additions & 4 deletions v3d_main/3drenderer/renderer_labelfield.cpp
Expand Up @@ -154,7 +154,7 @@ void Renderer_gl1::loadLabelfieldSurf(const QString& filename, int ch)
{
qtitle = QObject::tr("Creating Range Surface");

#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
mesh_iso0 = QInputDialog::getInt(0, qtitle,
qchannel+ QObject::tr("Range from: "),
0, 0, 0xffff, 1, &ok); // 0--2^16
Expand All @@ -165,7 +165,7 @@ void Renderer_gl1::loadLabelfieldSurf(const QString& filename, int ch)
#endif
if (! ok) return;

#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
mesh_iso1 = QInputDialog::getInt(0, qtitle,
qchannel+ QObject::tr("Range from %1 to: ").arg(mesh_iso0),
mesh_iso0, mesh_iso0, 0xffff, 1, &ok); // 0--2^16
Expand All @@ -186,7 +186,7 @@ void Renderer_gl1::loadLabelfieldSurf(const QString& filename, int ch)
if (! ok) return;
mesh_method = items.indexOf(item);

#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
mesh_density = QInputDialog::getInt(0, qtitle,
qchannel+ QObject::tr("Creating Mesh density:"), 100, 0, 1000, 1, &ok);
#else
Expand Down Expand Up @@ -993,7 +993,7 @@ void Renderer_gl1::loadV3DSurface(const QString& filename)
int myoffset;
bool ok1;

#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
myoffset = QInputDialog::getInt((QWidget*)widget, "z offset", "z offset:", 0, -1000, 1000, 1, &ok1);
#else
myoffset = QInputDialog::getInteger((QWidget*)widget, "z offset", "z offset:", 0, -1000, 1000, 1, &ok1);
Expand Down
4 changes: 2 additions & 2 deletions v3d_main/3drenderer/v3dr_common.h
Expand Up @@ -44,7 +44,7 @@ Peng, H, Ruan, Z., Atasoy, D., and Sternson, S. (2010) ?�Automatic reconstruct
// Added by MK, 11/21/2016, for migrating from VS2010/Qt4 to VS2015/Qt5
#include "../v3d/version_control.h"

#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
#include <QtWidgets>
#else
#include <QtGui>
Expand Down Expand Up @@ -268,7 +268,7 @@ inline RGBA8 RGBA8FromQColor(QColor qc)
#define QCOLOR(rgba8) QColorFromRGBA8( rgba8 )
#define VCOLOR(rgba8) qVariantFromValue(QColorFromRGBA8( rgba8 ))

#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
#define QCOLORV(var) (var.value<QColor>( ))
#define RGBA8V(var) RGBA8FromQColor(var.value<QColor>( ))
#else
Expand Down
6 changes: 3 additions & 3 deletions v3d_main/3drenderer/v3dr_mainwindow.cpp
Expand Up @@ -382,7 +382,7 @@ int V3dR_MainWindow::getAnimateRotTimePoints(QString qtitle, bool* ok, int v)
{
timepoints = v;

#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
timepoints = QInputDialog::getInt(0, qtitle, QObject::tr("Time-points per rotation:"), timepoints, 0, 1000, 1, ok);
#else
timepoints = QInputDialog::getInteger(0, qtitle, QObject::tr("Time-points per rotation:"), timepoints, 0, 1000, 1, ok);
Expand Down Expand Up @@ -416,7 +416,7 @@ void V3dR_MainWindow::setAnimateRotSpeedSec()

bool ok;

#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
int time_sec = QInputDialog::getInt(0, QObject::tr("Animation"),
QObject::tr("Seconds per rotation of speed:"), rotationSpeedSec, 0, 1000, 1, &ok);
#else
Expand Down Expand Up @@ -551,7 +551,7 @@ void V3dR_MainWindow::saveMovie()
// frames of rotation
{

#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
rotation_frames = QInputDialog::getInt(0, qtitle, QObject::tr("Frames per rotation:"), rotation_frames, 0, 1000, 1, &ok);
#else
rotation_frames = QInputDialog::getInteger(0, qtitle, QObject::tr("Frames per rotation:"), rotation_frames, 0, 1000, 1, &ok);
Expand Down
74 changes: 43 additions & 31 deletions v3d_main/CMakeLists.txt
Expand Up @@ -30,6 +30,13 @@ set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMake)

include(CTest)

if(APPLE)
if(DARWIN_MAJOR_VERSION GREATER_EQUAL 18)
#message("Mac OS Version = Mojave")
add_definitions(-DGL_SILENCE_DEPRECATION)
endif()
endif()

find_package(OpenGL REQUIRED)

option( V3D_USE_OWN_TIFF "Use the TIFF library source code distributed with v3d" ON )
Expand Down Expand Up @@ -255,38 +262,33 @@ if(USE_HDF5)
include_directories(${HDF5_INCLUDE_DIR})
endif()

# search for Qt4
if (NOT FORCE_QT4)
find_package(Qt5Core CONFIG QUIET)
if (Qt5Core_FOUND)
message(STATUS "Using qt5")
# go on with other packages
find_package(Qt5 CONFIG REQUIRED Widgets Xml Network OpenGL Concurrent)

macro(qt_use_modules)
qt5_use_modules(${ARGN})
endmacro()

macro(qt_wrap_ui)
qt5_wrap_ui(${ARGN})
endmacro()

macro(qt_add_resources)
qt5_add_resources(${ARGN})
endmacro()

macro(qt_add_translation)
qt5_add_translation(${ARGN})
endmacro()

add_definitions(-DUSE_Qt5)
include_directories( ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}
${Qt5Xml_INCLUDE_DIRS} ${Qt5OpenGL_INCLUDE_DIRS}
${Qt5Concurrent_INCLUDE_DIRS})
endif()
# search for Qt
IF (DESIRED_QT_VERSION MATCHES 5)
find_package(Qt5 COMPONENTS Core Widgets Xml Network OpenGL Concurrent REQUIRED)

macro(qt_use_modules)
qt5_use_modules(${ARGN})
endmacro()

macro(qt_wrap_ui)
qt5_wrap_ui(${ARGN})
endmacro()

macro(qt_add_resources)
qt5_add_resources(${ARGN})
endmacro()

macro(qt_add_translation)
qt5_add_translation(${ARGN})
endmacro()

add_definitions(-DUSE_Qt5)
include_directories( ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}
${Qt5Xml_INCLUDE_DIRS} ${Qt5OpenGL_INCLUDE_DIRS}
${Qt5Concurrent_INCLUDE_DIRS})
endif()

if(FORCE_QT4 OR NOT Qt5Core_FOUND)
if(DESIRED_QT_VERSION MATCHES 4 OR NOT Qt5Core_FOUND)
find_package(Qt4 REQUIRED)
set(QT_USE_NETWORK TRUE) # Oct-07-2010 CMB
set(QT_USE_XML TRUE) # Oct-22-2010 CMB
Expand Down Expand Up @@ -315,9 +317,17 @@ set(BUILD_QT_DEMO_LIBRARY ON CACHE BOOL "Build rather than search for the qt sha

if (BUILD_QT_DEMO_LIBRARY)
set(arthurwidgets_path "${CMAKE_CURRENT_BINARY_DIR}/qt_shared/install")

if (Qt5Core_FOUND)
set( QT_DEMO_LIBRARY_SOURCE "qt5_shared_demos.tar.gz")
else()
set( QT_DEMO_LIBRARY_SOURCE "qt_shared_demos.tar.gz")
endif()

find_program(QT_QMAKE_EXECUTABLE qmake)
ExternalProject_Add(
ARTHURWIDGETS
URL ${CMAKE_CURRENT_SOURCE_DIR}/common_lib/src_packages/qt_shared_demos.tar.gz
URL ${CMAKE_CURRENT_SOURCE_DIR}/common_lib/src_packages/${QT_DEMO_LIBRARY_SOURCE}
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/qt_shared/src
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/qt_shared/install
UPDATE_COMMAND ""
Expand Down Expand Up @@ -383,6 +393,8 @@ else()
set(arthurwidgets_path "${QT_DEMOS_INCLUDE_DIR}/")
endif()

add_custom_target( qt_demos DEPENDS ${QT4_DEMOS_LIBRARY} )

message("QT_DEMOS_INCLUDE_DIR = ${QT_DEMOS_INCLUDE_DIR}")

if(NOT QT_DEMOS_INCLUDE_DIR)
Expand Down
4 changes: 2 additions & 2 deletions v3d_main/custom_toolbar/v3d_custom_toolbar.h
Expand Up @@ -7,7 +7,7 @@

#define __hierarchical_file_menu__
#include "version_control.h"
#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
#include <QtWidgets>
#else
#include <QtGui>
Expand All @@ -27,7 +27,7 @@ class EmptyClass{};
typedef void (EmptyClass::*VoidFunc)();
#ifndef __v3d_custom_toolbar_plugin__
typedef void (MainWindow::*MainWindowFunc)();
#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
typedef void (QMdiArea::*WorkspaceFunc)();
#else
typedef void (QWorkspace::*WorkspaceFunc)();
Expand Down
2 changes: 1 addition & 1 deletion v3d_main/io/io_bioformats.cpp
Expand Up @@ -2,7 +2,7 @@
#include "../basic_c_fun/v3d_message.h"

#include "version_control.h"
#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
#include <QtWidgets>
#else
#include <QtGui>
Expand Down
4 changes: 4 additions & 0 deletions v3d_main/neuron_annotator/analysis/DilationErosion.cpp
@@ -1,3 +1,7 @@
#if defined(USE_Qt5)
#include <QtConcurrent>
#endif

#include "DilationErosion.h"
#include "SleepThread.h"

Expand Down
5 changes: 5 additions & 0 deletions v3d_main/neuron_annotator/analysis/NeuronFragmentEditor.cpp
@@ -1,3 +1,8 @@
#if defined(USE_Qt5)
#include <QtConcurrent>
#endif


#include "NeuronFragmentEditor.h"
#include "../utility/ImageLoader.h"
#include "AnalysisTools.h"
Expand Down
5 changes: 5 additions & 0 deletions v3d_main/neuron_annotator/analysis/ScreenPatternAnnotator.cpp
@@ -1,3 +1,8 @@
#if defined(USE_Qt5)
#include <QtConcurrent>
#endif


#include "ScreenPatternAnnotator.h"
#include "../utility/ImageLoader.h"
#include "../../v3d/histogramsimple.h"
Expand Down
3 changes: 3 additions & 0 deletions v3d_main/neuron_annotator/analysis/VolumeIndex.cpp
Expand Up @@ -117,6 +117,9 @@ Implementation
6) the results reported
*********************/
#if defined(USE_Qt5)
#include <QtConcurrent>
#endif

#include "MaskChan.h"
#include "SleepThread.h"
Expand Down
5 changes: 5 additions & 0 deletions v3d_main/neuron_annotator/data_model/NaVolumeData.cpp
Expand Up @@ -3,6 +3,11 @@
#include "../utility/url_tools.h"
#include "../utility/FooDebug.h"
#include <iostream>

#if defined(USE_Qt5)
#include <QtConcurrent>
#endif

#include <QFuture>
#include <QUrl>

Expand Down
2 changes: 1 addition & 1 deletion v3d_main/neuron_annotator/gui/GalleryButton.cpp
Expand Up @@ -2,7 +2,7 @@
#include <cmath>
#include "GalleryButton.h"

#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
#include <QtWidgets>
#else
#include <QtGui>
Expand Down
2 changes: 1 addition & 1 deletion v3d_main/neuron_annotator/gui/GalleryButton.h
Expand Up @@ -4,7 +4,7 @@
#include "Na3DWidget.h"
#include "NeuronContextMenu.h"

#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
#include <QtWidgets>
#else
#include <QtGui>
Expand Down
6 changes: 3 additions & 3 deletions v3d_main/neuron_editing/neuron_sim_scores.cpp
Expand Up @@ -58,11 +58,11 @@ NeuronDistSimple neuron_score_rounding_nearest_neighbor(const NeuronTree *p1, co
{
bool ok1;

#if not defined(USE_Qt5_VS2015_Win7_81) && not defined(USE_Qt5_VS2015_Win10_10_14393)
V3DLONG d_thres_new = QInputDialog::getInteger(0, "change the default distance threshold",
#if defined(USE_Qt5)
V3DLONG d_thres_new = QInputDialog::getInt(0, "change the default distance threshold",
"The visible-spatial-distance threshold of two neurons: ", d_thres, 2, 20, 1, &ok1);
#else
V3DLONG d_thres_new = QInputDialog::getInt(0, "change the default distance threshold",
V3DLONG d_thres_new = QInputDialog::getInteger(0, "change the default distance threshold",
"The visible-spatial-distance threshold of two neurons: ", d_thres, 2, 20, 1, &ok1);
#endif
if (ok1)
Expand Down
2 changes: 1 addition & 1 deletion v3d_main/plugin_loader/pluginDialog.h
Expand Up @@ -35,7 +35,7 @@ Peng, H, Ruan, Z., Atasoy, D., and Sternson, S. (2010) “Automatic reconstructi
#ifndef PLUGINDIALOG_H
#define PLUGINDIALOG_H

#if defined(USE_Qt5_VS2015_Win7_81) || defined(USE_Qt5_VS2015_Win10_10_14393)
#if defined(USE_Qt5)
#include <QtWidgets>
#else
#include <QtGui>
Expand Down

0 comments on commit ccfa74e

Please sign in to comment.