Skip to content

Commit

Permalink
Updated to the release version
Browse files Browse the repository at this point in the history
  • Loading branch information
wol101 committed Nov 20, 2018
1 parent 286dec5 commit 22f34eb
Show file tree
Hide file tree
Showing 27 changed files with 1,849 additions and 1,328 deletions.
98 changes: 96 additions & 2 deletions GalenQt/CImg.h

Large diffs are not rendered by default.

28 changes: 17 additions & 11 deletions GalenQt/CustomScroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <cmath>
#include <cfloat>

#define DEBUG_SCROLLER 0

CustomScroller::CustomScroller(QWidget *parent) : QWidget(parent)
{
m_graphicsView = 0;
Expand Down Expand Up @@ -57,7 +59,9 @@ void CustomScroller::scrollContents(int value)
m_graphicsView->setCentreX(newX);
m_graphicsView->setCentreY(newY);
m_graphicsView->update();
// qDebug("scrollContents newX = %g newY = %g", newX, newY);
#if DEBUG_SCROLLER
qDebug("scrollContents horizontal=%g vertical=%g newX=%g newY=%g", horizontal, vertical, newX, newY);
#endif
}
}

Expand All @@ -80,7 +84,9 @@ void CustomScroller::resizeEvent(QResizeEvent *event)
{
Q_UNUSED(event);
// this where I have to adjust the various elements of the scroll bar
// qDebug("resizeEvent QResizeEvent oldSize() = %d,%d size() = %d,%d", event->oldSize().width(), event->oldSize().height(), event->size().width(), event->size().height());
#if DEBUG_SCROLLER
qDebug("resizeEvent QResizeEvent oldSize() = %d,%d size() = %d,%d", event->oldSize().width(), event->oldSize().height(), event->size().width(), event->size().height());
#endif
if (m_graphicsView)
{
// set the ranges to the biggest necessary value
Expand Down Expand Up @@ -114,7 +120,9 @@ void CustomScroller::resizeEvent(QResizeEvent *event)
m_verticalScrollBar->setRange(0, vRange);
m_verticalScrollBar->setPageStep(int(viewPortHeight));
m_verticalScrollBar->setValue(vScrollFraction * vRange);
// qDebug("resizeEvent hRange = %g vRange = %g viewPortWidth = %g viewPortHeight = %g", hRange, vRange, viewPortWidth, viewPortHeight);
#if DEBUG_SCROLLER
qDebug("resizeEvent hRange = %g vRange = %g viewPortWidth = %g viewPortHeight = %g", hRange, vRange, viewPortWidth, viewPortHeight);
#endif
scrollContents(0);
}
}
Expand Down Expand Up @@ -165,13 +173,9 @@ void CustomScroller::contentsResized()
m_verticalScrollBar->setRange(0, vRange);
m_verticalScrollBar->setPageStep(int(viewPortHeight));
m_verticalScrollBar->setValue(vScrollFraction * vRange);
// float hRange = m_topRightBound.x() - m_bottomLeftBound.x();
// float vRange = m_topRightBound.y() - m_bottomLeftBound.y();
// m_horizontalScrollBar->setRange(0, hRange);
// m_horizontalScrollBar->setPageStep(int(viewPortWidth));
// m_verticalScrollBar->setRange(0, vRange);
// m_verticalScrollBar->setPageStep(int(viewPortHeight));
// qDebug("resizeEvent hRange = %g vRange = %g viewPortWidth = %g viewPortHeight = %g", hRange, vRange, viewPortWidth, viewPortHeight);
#if DEBUG_SCROLLER
qDebug("contentsResized hRange = %g vRange = %g viewPortWidth = %g viewPortHeight = %g", hRange, vRange, viewPortWidth, viewPortHeight);
#endif
scrollContents(0);
}
}
Expand All @@ -180,7 +184,9 @@ void CustomScroller::setScrollFractions(float horizontal, float vertical)
{
int newX = m_horizontalScrollBar->maximum() * horizontal;
int newY = m_verticalScrollBar->maximum() * vertical;
// qDebug("setScrollFractions newX = %d newY = %d", newX, newY);
#if DEBUG_SCROLLER
qDebug("setScrollFractions newX = %d newY = %d", newX, newY);
#endif
m_horizontalScrollBar->setValue(newX);
m_verticalScrollBar->setValue(newY);
}
Expand Down
28 changes: 18 additions & 10 deletions GalenQt/GalenQt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
#-------------------------------------------------

QT += core gui xml printsupport svg
QT += core gui xml printsupport svg charts
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = GalenQt
Expand All @@ -31,18 +31,23 @@ else:win32 {
DEFINES += EXTRA_COLOUR_DIALOG_OPTIONS=0
DEFINES += TIF_PLATFORM_CONSOLE
DEFINES += cimg_display=0
DEFINES += cimg_verbosity=1
DEFINES += cimg_use_tiff
# DEFINES += cimg_use_openmp
DEFINES += _USE_MATH_DEFINES
SOURCES += libtiff/tif_win32.c
SOURCES += hdf5/src/H5lib_settings.c hdf5/src/H5Tinit.c
HEADERS += hdf5/src/H5pubconf.h hdf5/src/H5config.h
# QMAKE_CXXFLAGS += -bigobj -Wall
# QMAKE_CXXFLAGS += -openmp
QMAKE_CXXFLAGS_DEBUG += -Od -RTCsu
QMAKE_CXXFLAGS_RELEASE += -Ox -fp:fast -GL
QMAKE_CXXFLAGS_DEBUG += -W4 -Od -RTCsu
QMAKE_CXXFLAGS_RELEASE += -Ox -fp:fast -GL -openmp
QMAKE_LFLAGS_RELEASE += -LTCG
CONFIG(release, debug|release) {
#This is a release build
DEFINES += cimg_use_openmp
DEFINES += cimg_verbosity=0
DEFINES += QT_NO_DEBUG_OUTPUT
} else {
#This is a debug build
DEFINES += cimg_verbosity=2
}
}
else:unix {
DEFINES += EXTRA_FILE_DIALOG_OPTIONS=QFileDialog::DontUseNativeDialog
Expand Down Expand Up @@ -419,7 +424,8 @@ SOURCES += main.cpp\
hdf5/hl/src/H5PT.c \
hdf5/hl/src/H5TB.c \
HDF5ReaderDialog.cpp \
Utilities.cpp
Utilities.cpp \
ScatterPlotDialog.cpp

HEADERS += MainWindow.h \
GraphicsView.h \
Expand Down Expand Up @@ -620,14 +626,16 @@ HEADERS += MainWindow.h \
hdf5/hl/src/H5TBpublic.h \
hdf5/hl/src/hdf5_hl.h \
HDF5ReaderDialog.h \
Utilities.h
Utilities.h \
ScatterPlotDialog.h

FORMS += \
AboutDialog.ui \
MdiChild.ui \
PCADialog.ui \
LDADialog.ui \
HDF5ReaderDialog.ui
HDF5ReaderDialog.ui \
ScatterPlotDialog.ui

RESOURCES += \
mdi.qrc
Expand Down
127 changes: 70 additions & 57 deletions GalenQt/GraphicsView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ GraphicsView::GraphicsView(QWidget *parent) :
m_textureBlue = 0;
m_textureBlack = 0;
m_textureMarker = 0;
m_blackImage = 0;
m_markerImage = 0;;
m_updateRepeatCount = 0;
m_textureUpdateRepeats = 1;
m_drawRed = false;
Expand Down Expand Up @@ -67,6 +69,8 @@ GraphicsView::~GraphicsView()
if (m_textureBlue) delete m_textureBlue;
if (m_textureBlack) delete m_textureBlack;
if (m_textureMarker) delete m_textureMarker;
if (m_blackImage) delete m_blackImage;
if (m_markerImage) delete m_markerImage;
doneCurrent();
}

Expand Down Expand Up @@ -125,32 +129,32 @@ void GraphicsView::initShaders()

void GraphicsView::initTextures()
{
QImage blackImage(8, 8, QImage::Format_Grayscale8);
blackImage.fill(0);
m_blackImage = new QImage(8, 8, QImage::Format_Grayscale8);
m_blackImage->fill(0);
if (m_textureBlack) delete m_textureBlack;
m_textureBlack = new QOpenGLTexture(blackImage, QOpenGLTexture::DontGenerateMipMaps);
m_textureBlack = new QOpenGLTexture(*m_blackImage, QOpenGLTexture::DontGenerateMipMaps);
m_textureBlack->setMinificationFilter(QOpenGLTexture::Linear);
m_textureBlack->setMagnificationFilter(QOpenGLTexture::Nearest);
m_textureBlack->setWrapMode(QOpenGLTexture::ClampToEdge);
if (m_textureRed) delete m_textureRed;
m_textureRed = new QOpenGLTexture(blackImage, QOpenGLTexture::DontGenerateMipMaps);
m_textureRed = new QOpenGLTexture(*m_blackImage, QOpenGLTexture::DontGenerateMipMaps);
m_textureRed->setMinificationFilter(QOpenGLTexture::Linear);
m_textureRed->setMagnificationFilter(QOpenGLTexture::Nearest);
m_textureRed->setWrapMode(QOpenGLTexture::ClampToEdge);
if (m_textureGreen) delete m_textureGreen;
m_textureGreen = new QOpenGLTexture(blackImage, QOpenGLTexture::DontGenerateMipMaps);
m_textureGreen = new QOpenGLTexture(*m_blackImage, QOpenGLTexture::DontGenerateMipMaps);
m_textureGreen->setMinificationFilter(QOpenGLTexture::Linear);
m_textureGreen->setMagnificationFilter(QOpenGLTexture::Nearest);
m_textureGreen->setWrapMode(QOpenGLTexture::ClampToEdge);
if (m_textureBlue) delete m_textureBlue;
m_textureBlue = new QOpenGLTexture(blackImage, QOpenGLTexture::DontGenerateMipMaps);
m_textureBlue = new QOpenGLTexture(*m_blackImage, QOpenGLTexture::DontGenerateMipMaps);
m_textureBlue->setMinificationFilter(QOpenGLTexture::Linear);
m_textureBlue->setMagnificationFilter(QOpenGLTexture::Nearest);
m_textureBlue->setWrapMode(QOpenGLTexture::ClampToEdge);

QImage markerImage(":/images/cursor-cross.png");
m_markerImage = new QImage(":/images/cursor-cross.png");
if (m_textureMarker) delete m_textureMarker;
m_textureMarker = new QOpenGLTexture(markerImage, QOpenGLTexture::DontGenerateMipMaps);
m_textureMarker = new QOpenGLTexture(*m_markerImage, QOpenGLTexture::DontGenerateMipMaps);
m_textureMarker->setMinificationFilter(QOpenGLTexture::Linear);
m_textureMarker->setMagnificationFilter(QOpenGLTexture::Nearest);
m_textureMarker->setWrapMode(QOpenGLTexture::ClampToEdge);
Expand Down Expand Up @@ -314,31 +318,65 @@ void GraphicsView::paintGL()
// Clear color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

qDebug("m_textureDisplayRed.minimum=%g", m_textureDisplayRed.minimum);
qDebug("m_textureDisplayRed.maximum=%g", m_textureDisplayRed.maximum);
qDebug("m_textureDisplayGreen.minimum=%g", m_textureDisplayGreen.minimum);
qDebug("m_textureDisplayGreen.maximum=%g", m_textureDisplayGreen.maximum);
qDebug("m_textureDisplayBlue.minimum=%g", m_textureDisplayBlue.minimum);
qDebug("m_textureDisplayBlue.maximum=%g", m_textureDisplayBlue.maximum);
// qDebug("m_textureDisplayRed.minimum=%g", m_textureDisplayRed.minimum);
// qDebug("m_textureDisplayRed.maximum=%g", m_textureDisplayRed.maximum);
// qDebug("m_textureDisplayGreen.minimum=%g", m_textureDisplayGreen.minimum);
// qDebug("m_textureDisplayGreen.maximum=%g", m_textureDisplayGreen.maximum);
// qDebug("m_textureDisplayBlue.minimum=%g", m_textureDisplayBlue.minimum);
// qDebug("m_textureDisplayBlue.maximum=%g", m_textureDisplayBlue.maximum);

m_shaderProgram.bind();

m_shaderProgram.setUniformValue("hasTexture", true);
m_shaderProgram.setUniformValue("redMin", m_textureDisplayRed.minimum);
m_shaderProgram.setUniformValue("redMax", m_textureDisplayRed.maximum);
m_shaderProgram.setUniformValue("greenMin", m_textureDisplayGreen.minimum);
m_shaderProgram.setUniformValue("greenMax", m_textureDisplayGreen.maximum);
m_shaderProgram.setUniformValue("blueMin", m_textureDisplayBlue.minimum);
m_shaderProgram.setUniformValue("blueMax", m_textureDisplayBlue.maximum);
m_shaderProgram.setUniformValue("redGamma", m_textureDisplayRed.gamma);
m_shaderProgram.setUniformValue("redZebra", m_textureDisplayRed.zebra);
m_shaderProgram.setUniformValue("greenGamma", m_textureDisplayGreen.gamma);
m_shaderProgram.setUniformValue("greenZebra", m_textureDisplayGreen.zebra);
m_shaderProgram.setUniformValue("blueGamma", m_textureDisplayBlue.gamma);
m_shaderProgram.setUniformValue("blueZebra", m_textureDisplayBlue.zebra);
m_shaderProgram.setUniformValue("redLog", m_textureDisplayRed.log);
m_shaderProgram.setUniformValue("greenLog", m_textureDisplayGreen.log);
m_shaderProgram.setUniformValue("blueLog", m_textureDisplayBlue.log);

if (m_drawRed)
{
m_shaderProgram.setUniformValue("redGamma", m_textureDisplayRed.gamma);
m_shaderProgram.setUniformValue("redLog", m_textureDisplayRed.log);
m_shaderProgram.setUniformValue("redMax", m_textureDisplayRed.maximum);
m_shaderProgram.setUniformValue("redMin", m_textureDisplayRed.minimum);
m_shaderProgram.setUniformValue("redZebra", m_textureDisplayRed.zebra);
}
else
{
m_shaderProgram.setUniformValue("redGamma", 1.0f);
m_shaderProgram.setUniformValue("redLog", false);
m_shaderProgram.setUniformValue("redMax", 1.0f);
m_shaderProgram.setUniformValue("redMin", 0.0f);
m_shaderProgram.setUniformValue("redZebra", 1.0f);
}
if (m_drawGreen)
{
m_shaderProgram.setUniformValue("greenGamma", m_textureDisplayGreen.gamma);
m_shaderProgram.setUniformValue("greenLog", m_textureDisplayGreen.log);
m_shaderProgram.setUniformValue("greenMax", m_textureDisplayGreen.maximum);
m_shaderProgram.setUniformValue("greenMin", m_textureDisplayGreen.minimum);
m_shaderProgram.setUniformValue("greenZebra", m_textureDisplayGreen.zebra);
}
else
{
m_shaderProgram.setUniformValue("greenGamma", 1.0f);
m_shaderProgram.setUniformValue("greenLog", false);
m_shaderProgram.setUniformValue("greenMax", 1.0f);
m_shaderProgram.setUniformValue("greenMin", 0.0f);
m_shaderProgram.setUniformValue("greenZebra", 1.0f);
}
if (m_drawBlue)
{
m_shaderProgram.setUniformValue("blueGamma", m_textureDisplayBlue.gamma);
m_shaderProgram.setUniformValue("blueLog", m_textureDisplayBlue.log);
m_shaderProgram.setUniformValue("blueMax", m_textureDisplayBlue.maximum);
m_shaderProgram.setUniformValue("blueMin", m_textureDisplayBlue.minimum);
m_shaderProgram.setUniformValue("blueZebra", m_textureDisplayBlue.zebra);
}
else
{
m_shaderProgram.setUniformValue("blueGamma", 1.0f);
m_shaderProgram.setUniformValue("blueLog", false);
m_shaderProgram.setUniformValue("blueMax", 1.0f);
m_shaderProgram.setUniformValue("blueMin", 0.0f);
m_shaderProgram.setUniformValue("blueZebra", 1.0f);
}

// Set the 3 textures
glActiveTexture(GL_TEXTURE0);
Expand Down Expand Up @@ -627,7 +665,7 @@ void GraphicsView::setImageWidth()
int blueWidth = 1;
int blueHeight = 1;
if (m_textureRed) { redWidth = m_textureRed->width(); redHeight = m_textureRed->height(); }
if (m_textureGreen) {greenWidth = m_textureGreen->width(); greenHeight = m_textureGreen->height(); }
if (m_textureGreen) { greenWidth = m_textureGreen->width(); greenHeight = m_textureGreen->height(); }
if (m_textureBlue) { blueWidth = m_textureBlue->width(); blueHeight = m_textureBlue->height(); }
m_imageWidth = MAX(redWidth, MAX(greenWidth, blueWidth));
m_imageHeight = MAX(redHeight, MAX(greenHeight, blueHeight));
Expand Down Expand Up @@ -659,18 +697,9 @@ void GraphicsView::menuRequest(const QPoint &p)
QMenu menu(this);
QAction *deletePointAct = new QAction(QIcon(":/images/edit-delete-2.png"), tr("Delete Nearest Point"), this);
deletePointAct->setStatusTip(tr("Deletes the nearest point to the cursor in the active list"));
QAction *logDisplayAct = new QAction(QIcon(":/images/tree_s.png"), tr("Display Log"), this);
logDisplayAct->setStatusTip(tr("Displays the log transformed image"));
QAction *normalDisplayAct = new QAction(QIcon(":/images/no_tree_s.png"), tr("Display Normal"), this);
normalDisplayAct->setStatusTip(tr("Displays the untransformed image"));

menu.addAction(logDisplayAct);
menu.addAction(normalDisplayAct);
menu.addSeparator();
if (m_labelledPoints.size()) menu.addAction(deletePointAct);

if (m_textureDisplayRed.log && m_textureDisplayGreen.log && m_textureDisplayBlue.log) logDisplayAct->setEnabled(false);
if (!m_textureDisplayRed.log && !m_textureDisplayGreen.log && !m_textureDisplayBlue.log) normalDisplayAct->setEnabled(false);
menu.addAction(deletePointAct);
if (m_labelledPoints.size() == 0) deletePointAct->setEnabled(false);

QPoint gp = this->mapToGlobal(p);
QAction *action = menu.exec(gp);
Expand All @@ -682,22 +711,6 @@ void GraphicsView::menuRequest(const QPoint &p)
QVector3D newCoordinate = invertedVPMatrix * QVector3D(x, y, 0);
emit deleteLabelledPoint(newCoordinate.x(), newCoordinate.y());
}
if (action == logDisplayAct)
{
m_textureDisplayRed.log = true;
m_textureDisplayGreen.log = true;
m_textureDisplayBlue.log = true;
emit emitDrawLog(true);
update();
}
if (action == normalDisplayAct)
{
m_textureDisplayRed.log = false;
m_textureDisplayGreen.log = false;
m_textureDisplayBlue.log = false;
emit emitDrawLog(false);
update();
}
}

float GraphicsView::centreY() const
Expand Down
3 changes: 2 additions & 1 deletion GalenQt/GraphicsView.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ class GraphicsView : public QOpenGLWidget, protected QOpenGLFunctions
void deleteLabelledPoint(float x, float y);
void statusString(QString s);
void emitZoom(float zoom);
void emitDrawLog(bool drawLog);
void newCentre(float x, float y);
void imageDimensionsChanged();

Expand Down Expand Up @@ -139,6 +138,8 @@ private slots:
QOpenGLTexture *m_textureBlue;
QOpenGLTexture *m_textureBlack;
QOpenGLTexture *m_textureMarker;
QImage *m_blackImage;
QImage *m_markerImage;

unsigned char m_updateRepeatCount;
unsigned char m_textureUpdateRepeats;
Expand Down
2 changes: 0 additions & 2 deletions GalenQt/HDF5ReaderDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,8 @@ void HDF5ReaderDialog::writeTiffFiles()
SingleChannelImage *image = new SingleChannelImage();
image->AllocateMemory(m_nx, m_ny, false);
std::copy(m_data + i * size, m_data + (i + 1) * size, image->data());
image->UpdateMinMax();
image->setNumBins(Settings::value("Number of Histogram Bins", int(32)).toInt());
image->UpdateHistogram();
image->UpdateDisplay();
QString name = QString("HDF%1").arg(i, 4, 10, QChar('0'));
image->setName(name);
QString filename = QString("HDF_Output_Image_%1.tif").arg(i, 4, 10, QChar('0'));
Expand Down
3 changes: 2 additions & 1 deletion GalenQt/HistogramDisplayWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <QPalette>
#include <QMenu>
#include <QAction>
#include <QtDebug>

#include <cmath>
#include <cfloat>
Expand All @@ -41,7 +42,7 @@ HistogramDisplayWidget::~HistogramDisplayWidget()
void HistogramDisplayWidget::mousePressEvent(QMouseEvent *event)
{

//std::cerr << event->pos().x() << " " << event->pos().y() << "\n";
//qDebug() << event->pos().x() << " " << event->pos().y() << "\n";

if (event->buttons() & Qt::LeftButton)
{
Expand Down
Loading

0 comments on commit 22f34eb

Please sign in to comment.