Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kill qt3 #126

Merged
merged 12 commits into from
Feb 14, 2022
19 changes: 12 additions & 7 deletions CMake/CommonMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
# use OpenMP features
#
MACRO(USE_OPENMP)
IF(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
SET(OpenMP_C_FLAGS "-Xpreprocessor -fopenmp")
SET(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp")
ENDIF()
FIND_PACKAGE(OpenMP)
IF(OpenMP_FOUND)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
LIST( APPEND MY_EXTERNAL_LINK_LIBRARIES ${OpenMP_CXX_LIBRARIES} )
INCLUDE_DIRECTORIES(${OpenMP_CXX_INCLUDE_DIRS}) # todo: use imported target instead
ELSE()
MESSAGE("OpenMP not found. Disabling OpenMP parallelization.")
ADD_DEFINITIONS(-DNO_OPENMP_SUPPORT)
Expand Down Expand Up @@ -80,9 +85,9 @@ MACRO(SUBDIR_LIST result curdir)
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
SET(dirlist "")
FOREACH(child ${children})
IF(IS_DIRECTORY ${curdir}/${child})
LIST(APPEND dirlist ${child})
ENDIF()
IF(IS_DIRECTORY ${curdir}/${child})
LIST(APPEND dirlist ${child})
ENDIF()
ENDFOREACH()
SET(${result} ${dirlist})
ENDMACRO()
Expand All @@ -94,13 +99,13 @@ MACRO(INIT_BUNDLE app_name)

SET(BUNDLE_INSTALL_TARGET ${CMAKE_INSTALL_PREFIX})
IF(APPLE)
SET(APP_BUNDLE_NAME "${app_name}.app")
SET(APP_BUNDLE_NAME "${app_name}.app")
SET(BUNDLE_INSTALL_DIRECTORY ${BUNDLE_INSTALL_TARGET}/${APP_BUNDLE_NAME}/Contents/MacOS)
LIST(APPEND BUNDLE_APPS ${BUNDLE_INSTALL_TARGET}/${APP_BUNDLE_NAME})
LIST(APPEND BUNDLE_APPS ${BUNDLE_INSTALL_TARGET}/${APP_BUNDLE_NAME})
ELSE()
SET(APP_BUNDLE_NAME ${app_name})
SET(APP_BUNDLE_NAME ${app_name})
SET(BUNDLE_INSTALL_DIRECTORY ${CMAKE_INSTALL_PREFIX})
LIST(APPEND BUNDLE_APPS ${CMAKE_INSTALL_PREFIX}/${app_name})
LIST(APPEND BUNDLE_APPS ${CMAKE_INSTALL_PREFIX}/${app_name})
ENDIF(APPLE)
ENDMACRO()

Expand Down
2 changes: 1 addition & 1 deletion CMake/ThirdPartyQt4.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# - preprocessor definitions needed by package
#

FIND_PACKAGE(Qt4 4.8.5 COMPONENTS QtCore QtGui QtScript Qt3Support QtXml QtOpenGL REQUIRED)
FIND_PACKAGE(Qt4 4.8.5 COMPONENTS QtCore QtGui QtScript QtXml QtOpenGL Qt3Support REQUIRED)
dyollb marked this conversation as resolved.
Show resolved Hide resolved

MACRO(USE_QT4)
SET(QT_USE_QTOPENGL TRUE)
Expand Down
16 changes: 8 additions & 8 deletions Core/ImageReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ class RGBToValue
};
} // namespace

bool ImageReader::GetInfo2D(const char* filename, unsigned& width, unsigned& height)
bool ImageReader::GetInfo2D(const std::string& filename, unsigned& width, unsigned& height)
{
unsigned nrslices;
float spacing[3];
Transform tr;
return ImageReader::GetInfo(filename, width, height, nrslices, spacing, tr);
}

bool ImageReader::GetImageStack(const std::vector<const char*>& filenames, float** img_stack, unsigned width, unsigned height, const std::function<float(unsigned char, unsigned char, unsigned char)>& color2grey)
bool ImageReader::GetImageStack(const std::vector<std::string>& filenames, float** img_stack, unsigned width, unsigned height, const std::function<float(unsigned char, unsigned char, unsigned char)>& color2grey)
{
using rgbpixel_type = itk::RGBPixel<unsigned char>;
using input_image_type = itk::Image<rgbpixel_type, 3>;
Expand Down Expand Up @@ -104,12 +104,12 @@ bool ImageReader::GetImageStack(const std::vector<const char*>& filenames, float
return true;
}

bool ImageReader::GetSlice(const char* filename, float* slice, unsigned slicenr, unsigned width, unsigned height)
bool ImageReader::GetSlice(const std::string& filename, float* slice, unsigned slicenr, unsigned width, unsigned height)
{
return GetVolume(filename, &slice, slicenr, 1, width, height);
}

float* ImageReader::GetSliceInfo(const char* filename, unsigned slicenr, unsigned& width, unsigned& height)
float* ImageReader::GetSliceInfo(const std::string& filename, unsigned slicenr, unsigned& width, unsigned& height)
{
unsigned nrslices;
float spacing[3];
Expand All @@ -126,12 +126,12 @@ float* ImageReader::GetSliceInfo(const char* filename, unsigned slicenr, unsigne
return nullptr;
}

bool ImageReader::GetVolume(const char* filename, float** slices, unsigned nrslices, unsigned width, unsigned height)
bool ImageReader::GetVolume(const std::string& filename, float** slices, unsigned nrslices, unsigned width, unsigned height)
{
return GetVolume(filename, slices, 0, nrslices, width, height);
}

bool ImageReader::GetVolume(const char* filename, float** slices, unsigned startslice, unsigned nrslices, unsigned width, unsigned height)
bool ImageReader::GetVolume(const std::string& filename, float** slices, unsigned startslice, unsigned nrslices, unsigned width, unsigned height)
{
// ITK does not know how to load VTI
boost::filesystem::path path(filename);
Expand Down Expand Up @@ -180,9 +180,9 @@ bool ImageReader::GetVolume(const char* filename, float** slices, unsigned start
return true;
}

bool ImageReader::GetInfo(const char* filename, unsigned& width, unsigned& height, unsigned& nrslices, float spacing[3], Transform& transform)
bool ImageReader::GetInfo(const std::string& filename, unsigned& width, unsigned& height, unsigned& nrslices, float spacing[3], Transform& transform)
{
auto image_io = itk::ImageIOFactory::CreateImageIO(filename, itk::ImageIOFactory::ReadMode);
auto image_io = itk::ImageIOFactory::CreateImageIO(filename.c_str(), itk::ImageIOFactory::ReadMode);
if (image_io)
{
image_io->SetFileName(filename);
Expand Down
14 changes: 7 additions & 7 deletions Core/ImageReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ class Transform;
class ISEG_CORE_API ImageReader
{
public:
static bool GetInfo2D(const char* filename, unsigned& width, unsigned& height);
static bool GetInfo2D(const std::string& filename, unsigned& width, unsigned& height);

/// loads 2D image into pre-allocated memory
static bool GetImageStack(const std::vector<const char*>& filenames, float** img_stack, unsigned width, unsigned height, const std::function<float(unsigned char, unsigned char, unsigned char)>& color2grey);
static bool GetImageStack(const std::vector<std::string>& filenames, float** img_stack, unsigned width, unsigned height, const std::function<float(unsigned char, unsigned char, unsigned char)>& color2grey);

/// get image size, spacing and transform
static bool GetInfo(const char* filename, unsigned& width, unsigned& height, unsigned& nrslices, float spacing[3], Transform& transform);
static bool GetInfo(const std::string& filename, unsigned& width, unsigned& height, unsigned& nrslices, float spacing[3], Transform& transform);

/// loads image into pre-allocated memory
static bool GetSlice(const char* filename, float* slice, unsigned slicenr, unsigned width, unsigned height);
static bool GetSlice(const std::string& filename, float* slice, unsigned slicenr, unsigned width, unsigned height);

/// \note allocates memory for slice using new
static float* GetSliceInfo(const char* filename, unsigned slicenr, unsigned& width, unsigned& height);
static float* GetSliceInfo(const std::string& filename, unsigned slicenr, unsigned& width, unsigned& height);

/// loads image into pre-allocated memory
static bool GetVolume(const char* filename, float** slices, unsigned nrslices, unsigned width, unsigned height);
static bool GetVolume(const char* filename, float** slices, unsigned startslice, unsigned nrslices, unsigned width, unsigned height);
static bool GetVolume(const std::string& filename, float** slices, unsigned nrslices, unsigned width, unsigned height);
static bool GetVolume(const std::string& filename, float** slices, unsigned startslice, unsigned nrslices, unsigned width, unsigned height);
};

} // namespace iseg
40 changes: 20 additions & 20 deletions Core/VTIreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@

namespace iseg {

bool VTIreader::GetSlice(const char* filename, float* slice, unsigned slicenr, unsigned width, unsigned height)
bool VTIreader::GetSlice(const std::string& filename, float* slice, unsigned slicenr, unsigned width, unsigned height)
{
vtkXMLImageDataReader* reader = vtkXMLImageDataReader::New();
if (reader->CanReadFile(filename) == 0)
if (reader->CanReadFile(filename.c_str()) == 0)
{
return false;
}
reader->SetFileName(filename);
reader->SetFileName(filename.c_str());
reader->Update();

int ext[6] = {0, 0, 0, 0, 0, 0};
Expand Down Expand Up @@ -104,14 +104,14 @@ bool VTIreader::GetSlice(const char* filename, float* slice, unsigned slicenr, u
return true;
}

float* VTIreader::GetSliceInfo(const char* filename, unsigned slicenr, unsigned& width, unsigned& height)
float* VTIreader::GetSliceInfo(const std::string& filename, unsigned slicenr, unsigned& width, unsigned& height)
{
vtkXMLImageDataReader* reader = vtkXMLImageDataReader::New();
if (reader->CanReadFile(filename) == 0)
if (reader->CanReadFile(filename.c_str()) == 0)
{
return nullptr;
}
reader->SetFileName(filename);
reader->SetFileName(filename.c_str());
reader->Update();

int ext[6] = {0, 0, 0, 0, 0, 0};
Expand Down Expand Up @@ -179,16 +179,16 @@ float* VTIreader::GetSliceInfo(const char* filename, unsigned slicenr, unsigned&
return slice;
}

bool VTIreader::GetVolume(const char* filename, float** slices, unsigned nrslices, unsigned width, unsigned height, const std::string& arrayName)
bool VTIreader::GetVolume(const std::string& filename, float** slices, unsigned nrslices, unsigned width, unsigned height, const std::string& arrayName)
{
vtkXMLImageDataReader* reader = vtkXMLImageDataReader::New();
if (reader->CanReadFile(filename) == 0)
if (reader->CanReadFile(filename.c_str()) == 0)
{
std::cerr << "VTIreader::getVolume() : can not read file " << filename
<< endl;
return false;
}
reader->SetFileName(filename);
reader->SetFileName(filename.c_str());
reader->Update();

int ext[6] = {0, 0, 0, 0, 0, 0};
Expand Down Expand Up @@ -268,14 +268,14 @@ bool VTIreader::GetVolume(const char* filename, float** slices, unsigned nrslice
return true;
}

bool VTIreader::GetVolumeAll(const char* filename, float** slicesbmp, float** sliceswork, tissues_size_t** slicestissue, unsigned nrslices, unsigned width, unsigned height)
bool VTIreader::GetVolumeAll(const std::string& filename, float** slicesbmp, float** sliceswork, tissues_size_t** slicestissue, unsigned nrslices, unsigned width, unsigned height)
{
vtkXMLImageDataReader* reader = vtkXMLImageDataReader::New();
if (reader->CanReadFile(filename) == 0)
if (reader->CanReadFile(filename.c_str()) == 0)
{
return false;
}
reader->SetFileName(filename);
reader->SetFileName(filename.c_str());
reader->Update();

int ext[6] = {0, 0, 0, 0, 0, 0};
Expand Down Expand Up @@ -394,14 +394,14 @@ bool VTIreader::GetVolumeAll(const char* filename, float** slicesbmp, float** sl
return true;
}

bool VTIreader::GetVolume(const char* filename, float** slices, unsigned startslice, unsigned nrslices, unsigned width, unsigned height, const std::string& arrayName)
bool VTIreader::GetVolume(const std::string& filename, float** slices, unsigned startslice, unsigned nrslices, unsigned width, unsigned height, const std::string& arrayName)
{
vtkXMLImageDataReader* reader = vtkXMLImageDataReader::New();
if (reader->CanReadFile(filename) == 0)
if (reader->CanReadFile(filename.c_str()) == 0)
{
return false;
}
reader->SetFileName(filename);
reader->SetFileName(filename.c_str());
reader->Update();

int ext[6] = {0, 0, 0, 0, 0, 0};
Expand Down Expand Up @@ -480,14 +480,14 @@ bool VTIreader::GetVolume(const char* filename, float** slices, unsigned startsl
return true;
}

bool VTIreader::GetInfo(const char* filename, unsigned& width, unsigned& height, unsigned& nrslices, float* pixelsize, float* offset, std::vector<std::string>& arrayNames)
bool VTIreader::GetInfo(const std::string& filename, unsigned& width, unsigned& height, unsigned& nrslices, float* pixelsize, float* offset, std::vector<std::string>& arrayNames)
{
vtkXMLImageDataReader* reader = vtkXMLImageDataReader::New();
if (reader->CanReadFile(filename) == 0)
if (reader->CanReadFile(filename.c_str()) == 0)
{
return false;
}
reader->SetFileName(filename);
reader->SetFileName(filename.c_str());
reader->UpdateInformation();
int extent[6];
double spacing[3];
Expand Down Expand Up @@ -528,7 +528,7 @@ bool VTIreader::GetInfo(const char* filename, unsigned& width, unsigned& height,
return true;
}

bool VTIwriter::WriteVolumeAll(const char* filename, float** slicesbmp, float** sliceswork, tissues_size_t** slicestissue, tissues_size_t nrtissues, unsigned nrslices, unsigned width, unsigned height, float* pixelsize, float* offset, bool binary, bool compress)
bool VTIwriter::WriteVolumeAll(const std::string& filename, float** slicesbmp, float** sliceswork, tissues_size_t** slicestissue, tissues_size_t nrtissues, unsigned nrslices, unsigned width, unsigned height, float* pixelsize, float* offset, bool binary, bool compress)
{
vtkSmartPointer<vtkImageData> input = vtkSmartPointer<vtkImageData>::New();
input->SetExtent(0, (int)width - 1, 0, (int)height - 1, 0, (int)nrslices - 1);
Expand Down Expand Up @@ -650,7 +650,7 @@ bool VTIwriter::WriteVolumeAll(const char* filename, float** slicesbmp, float**
writer->SetDataModeToAppended();
if (binary)
writer->EncodeAppendedDataOff();
writer->SetFileName(filename);
writer->SetFileName(filename.c_str());
writer->Write();

return true;
Expand Down
14 changes: 7 additions & 7 deletions Core/VTIreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ namespace iseg {
class VTIreader
{
public:
static bool GetInfo(const char* filename, unsigned& width, unsigned& height, unsigned& nrslices, float* pixelsize, float* offset, std::vector<std::string>& arrayNames);
static bool GetSlice(const char* filename, float* slice, unsigned slicenr, unsigned width, unsigned height);
static float* GetSliceInfo(const char* filename, unsigned slicenr, unsigned& width, unsigned& height);
static bool GetVolume(const char* filename, float** slices, unsigned nrslices, unsigned width, unsigned height, const std::string& arrayName);
static bool GetVolume(const char* filename, float** slices, unsigned startslice, unsigned nrslices, unsigned width, unsigned height, const std::string& arrayName);
static bool GetVolumeAll(const char* filename, float** slicesbmp, float** sliceswork, tissues_size_t** slicestissue, unsigned nrslices, unsigned width, unsigned height);
static bool GetInfo(const std::string& filename, unsigned& width, unsigned& height, unsigned& nrslices, float* pixelsize, float* offset, std::vector<std::string>& arrayNames);
static bool GetSlice(const std::string& filename, float* slice, unsigned slicenr, unsigned width, unsigned height);
static float* GetSliceInfo(const std::string& filename, unsigned slicenr, unsigned& width, unsigned& height);
static bool GetVolume(const std::string& filename, float** slices, unsigned nrslices, unsigned width, unsigned height, const std::string& arrayName);
static bool GetVolume(const std::string& filename, float** slices, unsigned startslice, unsigned nrslices, unsigned width, unsigned height, const std::string& arrayName);
static bool GetVolumeAll(const std::string& filename, float** slicesbmp, float** sliceswork, tissues_size_t** slicestissue, unsigned nrslices, unsigned width, unsigned height);
};

class VTIwriter
{
public:
static bool WriteVolumeAll(const char* filename, float** slicesbmp, float** sliceswork, tissues_size_t** slicestissue, tissues_size_t nrtissues, unsigned nrslices, unsigned width, unsigned height, float* pixelsize, float* offset, bool binary, bool compress);
static bool WriteVolumeAll(const std::string& filename, float** slicesbmp, float** sliceswork, tissues_size_t** slicestissue, tissues_size_t nrtissues, unsigned nrslices, unsigned width, unsigned height, float* pixelsize, float* offset, bool binary, bool compress);
};

} // namespace iseg
2 changes: 1 addition & 1 deletion Core/testsuite/test_ImageIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class TestColorImageIO

std::vector<float> data(w * h, 0);
std::vector<float*> stack(1, data.data());
std::vector<const char*> files(1, file_path.c_str());
std::vector<std::string> files(1, file_path);
BOOST_REQUIRE(ImageReader::GetImageStack(files, stack.data(), w, h, [](unsigned char, unsigned char g, unsigned char) { return static_cast<float>(g); }));

itk::Index<2> idx = {0, 0};
Expand Down
41 changes: 32 additions & 9 deletions Data/Property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,7 @@ namespace iseg {

void Property::OnModified(eChangeType change)
{
Property_ptr me;
try
{
me = shared_from_this();
}
catch (const std::exception& e)
{
ISEG_WARNING_MSG(e.what());
}
auto me = Self();

// signal change
if (me && !m_BlockSignals)
Expand All @@ -31,6 +23,19 @@ void Property::OnModified(eChangeType change)
}
}

Property_ptr Property::Self()
{
try
{
return shared_from_this();
}
catch (const std::exception& e)
{
ISEG_WARNING_MSG(e.what());
}
return Property_ptr();
}

void Property::OnChildModified(Property_ptr child, eChangeType change) const
{
// signal change
Expand Down Expand Up @@ -140,6 +145,24 @@ std::shared_ptr<PropertyButton> PropertyButton::Create(value_type value, const s
return std::shared_ptr<PropertyButton>(new PropertyButton(value, txt));
}

void PropertyButton::SetCheckable(bool v)
{
if (v != m_Checkable)
{
m_Checkable = v;
OnModified(Property::kStateChanged);
}
}

void PropertyButton::SetChecked(bool v)
{
if (v != m_Checked)
{
m_Checked = v;
OnModified(Property::kStateChanged);
}
}

std::shared_ptr<PropertySlider> PropertySlider::Create(value_type value, value_type min_value, value_type max_value)
{
return std::shared_ptr<PropertySlider>(new PropertySlider(value, min_value, max_value));
Expand Down
Loading