Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/GeertLitjens/ASAP
Browse files Browse the repository at this point in the history
  • Loading branch information
GeertLitjens committed Jan 12, 2016
2 parents 8a43cf5 + 3f1c562 commit d418691
Show file tree
Hide file tree
Showing 36 changed files with 413 additions and 348 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ PROJECT(DIAGPathology)
SET(CMAKE_MODULE_PATH ${DIAGPathology_SOURCE_DIR}/cmakemodules)
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)

IF(NOT WIN32)
SET(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib:$ORIGIN/")
ENDIF(NOT WIN32)

# Use boost for cross-platform use of threading, file system and date_time handling
FIND_PACKAGE(Boost REQUIRED COMPONENTS date_time filesystem program_options regex system thread)
SET(Boost_DEFINITIONS "-DBOOST_ALL_DYN_LINK")
Expand Down
2 changes: 1 addition & 1 deletion annotation/AnnotationToMask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void AnnotationToMask::convert(const std::shared_ptr<AnnotationList>& annotation
if (nameOrder.empty()) {
buffer[y * 512 + x] = in_poly * label > buffer[y * 512 + x] ? in_poly * label : buffer[y * 512 + x];
}
else {
else if (in_poly) {
buffer[y * 512 + x] = in_poly * label;
}
}
Expand Down
6 changes: 6 additions & 0 deletions imgproc/generic/ColorDeconvolutionFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ class ColorDeconvolutionFilter : public ImageFilter<inType, double> {
cosy[2] = cosy[2] / leng;
cosz[2] = cosz[2] / leng;

for (int i=0; i<3; i++){
if (cosx[i] == 0.0) cosx[i] = 0.001;
if (cosy[i] == 0.0) cosy[i] = 0.001;
if (cosz[i] == 0.0) cosz[i] = 0.001;
}

/* matrix inversion */
double A = cosy[1] - cosx[1] * cosy[0] / cosx[0];
double V = cosz[1] - cosx[1] * cosz[0] / cosx[0];
Expand Down
15 changes: 6 additions & 9 deletions imgproc/generic/FilterBase.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include <memory>
#include "FilterBase.h"
#include "core/ProgressMonitor.h"

FilterBase::FilterBase() : _monitor(NULL), _cancel(false), _running(false) {
FilterBase::FilterBase() : _cancel(false), _running(false) {

}

Expand Down Expand Up @@ -41,22 +42,18 @@ void FilterBase::finish() {
}


const ProgressMonitor* const FilterBase::progressMonitor() const {
std::weak_ptr<ProgressMonitor> FilterBase::progressMonitor() const {
return _monitor;
}

void FilterBase::setProgressMonitor(ProgressMonitor* monitor) {
_monitorMutex.lock();
void FilterBase::setProgressMonitor(std::shared_ptr<ProgressMonitor> monitor) {
_monitor = monitor;
_monitorMutex.unlock();
}

void FilterBase::updateProgress(float progress) {
_monitorMutex.lock();
if (_monitor) {
_monitor->setProgress(progress);
if (std::shared_ptr<ProgressMonitor> shared_monitor = _monitor.lock()) {
shared_monitor->setProgress(progress);
}
_monitorMutex.unlock();
}

void FilterBase::cancel() {
Expand Down
8 changes: 4 additions & 4 deletions imgproc/generic/FilterBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#include "config/pathology_config.h"
#include <mutex>
#include <string>
#include <memory>

class ProgressMonitor;

class EXPORT_BASICFILTERS FilterBase {

std::mutex _monitorMutex;
std::mutex _cancelMutex;
ProgressMonitor* _monitor;
std::weak_ptr<ProgressMonitor> _monitor;
bool _cancel;
bool _running;

Expand All @@ -24,8 +24,8 @@ class EXPORT_BASICFILTERS FilterBase {

virtual std::string name() const;

const ProgressMonitor* const progressMonitor() const;
void setProgressMonitor(ProgressMonitor* monitor);
std::weak_ptr<ProgressMonitor> progressMonitor() const;
void setProgressMonitor(std::shared_ptr<ProgressMonitor> monitor);
void updateProgress(float progress);

void cancel();
Expand Down
6 changes: 3 additions & 3 deletions io/multiresolutionimageinterface/MultiResolutionImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public :
//! Obtains data as a patch, which is a basic image class containing all relevant information for further processing,
//! like data and colortype
template <typename T>
Patch<T>* getPatch(const long long& startX, const long long& startY, const unsigned long long& width,
Patch<T> getPatch(const long long& startX, const long long& startY, const unsigned long long& width,
const unsigned long long& height, const unsigned int& level)
{
std::vector<unsigned long long> dims(3,0);
Expand All @@ -60,8 +60,8 @@ public :
for (unsigned int i = 0; i < _spacing.size(); ++i) {
patchSpacing[i] = _spacing[i] * levelDownsample;
}
Patch<T>* patch = new Patch<T>(dims, this->getColorType(), data, true);
patch->setSpacing(patchSpacing);
Patch<T> patch = Patch<T>(dims, this->getColorType(), data, true);
patch.setSpacing(patchSpacing);
return patch;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
%include "std_map.i"
%include "std_shared_ptr.i"

%shared_ptr(ImageSource)
%shared_ptr(MultiResolutionImage)
%shared_ptr(OpenSlideImage)
%shared_ptr(VSIImage)
Expand All @@ -63,8 +64,8 @@ namespace std {
%template(vector_uint) vector<unsigned int>;
%template(vector_float) vector<float>;
%template(vector_double) vector<double>;
%template(vector_annotation) vector<Annotation*>;
%template(vector_annotation_group) vector<AnnotationGroup*>;
%template(vector_annotation) vector<shared_ptr<Annotation> >;
%template(vector_annotation_group) vector<shared_ptr<AnnotationGroup> >;
%template(vector_unsigned_long_long) vector<unsigned long long>;
%template(vector_long_long) vector<long long>;
%template(vector_string) vector<string>;
Expand Down
4 changes: 2 additions & 2 deletions workstation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ IF(BUILD_USING_QT4)
resources/icons.qrc
)
qt4_add_resources(RESOURCE_ADDED ${RESOURCE})
ADD_EXECUTABLE(ASAP ${SOURCE} ${HEADERS} ${PATHOLOHWORKSTATION_MOC})
ADD_EXECUTABLE(ASAP WIN32 ${SOURCE} ${HEADERS} ${PATHOLOHWORKSTATION_MOC})
TARGET_LINK_LIBRARIES(ASAP ${QT_LIBRARIES})
ELSE()
find_package(Qt5 COMPONENTS Core Widgets Gui OpenGL)
set(RESOURCE
resources/ASAP_resources.qrc
)
qt5_add_resources(RESOURCE_ADDED ${RESOURCE})
ADD_EXECUTABLE(ASAP ${SOURCE} ${HEADERS} ${RESOURCE_ADDED})
ADD_EXECUTABLE(ASAP WIN32 ${SOURCE} ${HEADERS} ${RESOURCE_ADDED})
QT5_USE_MODULES(ASAP Core Widgets OpenGL UiTools)
ENDIF()

Expand Down
32 changes: 13 additions & 19 deletions workstation/MiniMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

const char* const MiniMap::coverageColors[] = { "red", "green", "yellow", "black", "purple", "orange" };

MiniMap::MiniMap(QPixmap* overview, QWidget *parent)
MiniMap::MiniMap(const QPixmap& overview, QWidget *parent)
: QWidget(parent),
_overview(overview),
_fieldOfView(QRectF()),
Expand All @@ -21,14 +21,8 @@ MiniMap::MiniMap(QPixmap* overview, QWidget *parent)
policy.setHorizontalPolicy(QSizePolicy::Fixed);
policy.setVerticalPolicy(QSizePolicy::Fixed);
setSizePolicy(policy);
if (_overview) {
_aspectRatio = static_cast<float>(_overview->width()) / _overview->height();
}
}

MiniMap::~MiniMap() {
if (_overview) {
delete _overview;
if (!overview.isNull()) {
_aspectRatio = static_cast<float>(_overview.width()) / _overview.height();
}
}

Expand Down Expand Up @@ -59,7 +53,7 @@ void MiniMap::onCoverageUpdated() {
void MiniMap::mousePressEvent(QMouseEvent *event) {
float posX = event->pos().x();
float posY = event->pos().y();
QPointF pos((_overview->width() * posX) / width() + 1, (_overview->height() * posY) / height() + 1);
QPointF pos((_overview.width() * posX) / width() + 1, (_overview.height() * posY) / height() + 1);
emit positionClicked(pos);
}

Expand All @@ -69,8 +63,8 @@ void MiniMap::mouseMoveEvent(QMouseEvent *event) {

void MiniMap::paintEvent(QPaintEvent *event) {
QPainter painter(this);
if (_overview) {
painter.drawPixmap(1, 1, width(), height(), *_overview);
if (!_overview.isNull()) {
painter.drawPixmap(1, 1, width(), height(), _overview);
painter.setPen(QPen(Qt::white, 2));
painter.drawRect(1, 1, width() - 2, height() - 2);
painter.setPen(QPen(Qt::black, 1));
Expand All @@ -86,7 +80,7 @@ void MiniMap::paintEvent(QPaintEvent *event) {
for (std::vector<QPainterPath>::const_iterator it = pths.begin(); it != pths.end(); ++it) {
if (!it->isEmpty()) {
QTransform trans;
trans = trans.scale(width() / static_cast<float>(_overview->width()), height() / static_cast<float>(_overview->height()));
trans = trans.scale(width() / static_cast<float>(_overview.width()), height() / static_cast<float>(_overview.height()));
QPainterPath qpf2 = trans.map(*it);
unsigned int colorIndex = (it - pths.begin()) % 6;
painter.setPen(QPen(QColor(coverageColors[colorIndex])));
Expand All @@ -100,10 +94,10 @@ void MiniMap::paintEvent(QPaintEvent *event) {
QPen blue = QPen(QColor("blue"));
blue.setWidth(3);
painter.setPen(blue);
float rectX = width() * (_fieldOfView.left() / _overview->width()) + 1;
float rectY = height() * (_fieldOfView.top() / _overview->height()) + 1;
float rectW = width() * (_fieldOfView.width() / _overview->width()) - 2;
float rectH = height() * (_fieldOfView.height() / _overview->height()) - 2;
float rectX = width() * (_fieldOfView.left() / _overview.width()) + 1;
float rectY = height() * (_fieldOfView.top() / _overview.height()) + 1;
float rectW = width() * (_fieldOfView.width() / _overview.width()) - 2;
float rectH = height() * (_fieldOfView.height() / _overview.height()) - 2;
if (rectW > 3 && rectH > 3) {
painter.drawRect(rectX, rectY, rectW, rectH);
}
Expand All @@ -118,8 +112,8 @@ void MiniMap::paintEvent(QPaintEvent *event) {
QSize MiniMap::sizeHint() const {
QSize size(0, 0);
unsigned int baseSize = 250;
if (_overview) {
if (_overview->width() > _overview->height()) {
if (!_overview.isNull()) {
if (_overview.width() > _overview.height()) {
size = QSize(baseSize, baseSize / _aspectRatio);
}
else {
Expand Down
8 changes: 4 additions & 4 deletions workstation/MiniMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define MINIMAP_H

#include <QWidget>
#include <QPointer>

class QPixmap;
class TileManager;
Expand All @@ -10,8 +11,7 @@ class MiniMap : public QWidget {
Q_OBJECT

public:
MiniMap(QPixmap* overview, QWidget *parent = 0);
~MiniMap();
MiniMap(const QPixmap& overview, QWidget *parent);

QSize sizeHint() const;
int heightForWidth(int w) const;
Expand All @@ -28,9 +28,9 @@ public slots:
void paintEvent(QPaintEvent *event);

private:
QPixmap* _overview;
QPixmap _overview;
QRectF _fieldOfView;
TileManager* _manager;
QPointer<TileManager> _manager;
float _aspectRatio; //Width / height
static const char* const coverageColors[];
bool _drawCoverageMap;
Expand Down
Loading

0 comments on commit d418691

Please sign in to comment.