Draw file name under thumbnail
This commit is contained in:
@@ -257,6 +257,14 @@ int ImageRingList::imageCount() const
|
|||||||
return m_images.size();
|
return m_images.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList ImageRingList::imageNames() const
|
||||||
|
{
|
||||||
|
QStringList ret;
|
||||||
|
for(auto &img : m_images)
|
||||||
|
ret.push_back(QFileInfo(img->name()).fileName());
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
QModelIndex ImageRingList::index(int row, int column, const QModelIndex &parent) const
|
QModelIndex ImageRingList::index(int row, int column, const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
return createIndex(row, column, m_images.at(row).get());
|
return createIndex(row, column, m_images.at(row).get());
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ public:
|
|||||||
void loadThumbnails();
|
void loadThumbnails();
|
||||||
void stopLoading();
|
void stopLoading();
|
||||||
int imageCount() const;
|
int imageCount() const;
|
||||||
|
QStringList imageNames() const;
|
||||||
|
|
||||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
||||||
QModelIndex parent(const QModelIndex &child) const override;
|
QModelIndex parent(const QModelIndex &child) const override;
|
||||||
|
|||||||
+33
-36
@@ -9,6 +9,7 @@
|
|||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
struct RawImageType
|
struct RawImageType
|
||||||
{
|
{
|
||||||
@@ -78,12 +79,13 @@ ImageWidget::~ImageWidget()
|
|||||||
makeCurrent();
|
makeCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageWidget::setImage(const RawImage *image)
|
void ImageWidget::setImage(const RawImage *image, int index)
|
||||||
{
|
{
|
||||||
if(image == nullptr)return;
|
if(image == nullptr)return;
|
||||||
|
|
||||||
m_imgWidth = image->width();
|
m_imgWidth = image->width();
|
||||||
m_imgHeight = image->height();
|
m_imgHeight = image->height();
|
||||||
|
m_currentImg = index;
|
||||||
|
|
||||||
const RawImageType &rawImageType = rawImageTypes[image->type()];
|
const RawImageType &rawImageType = rawImageTypes[image->type()];
|
||||||
|
|
||||||
@@ -102,22 +104,6 @@ void ImageWidget::setImage(const RawImage *image)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageWidget::setImage(const QPixmap &pixmap)
|
|
||||||
{
|
|
||||||
QImage img = pixmap.toImage();
|
|
||||||
|
|
||||||
m_imgWidth = pixmap.width();
|
|
||||||
m_imgHeight = pixmap.height();
|
|
||||||
|
|
||||||
m_image->destroy();
|
|
||||||
m_image->setData(img);
|
|
||||||
m_image->setMinMagFilters(QOpenGLTexture::LinearMipMapLinear, QOpenGLTexture::Linear);
|
|
||||||
m_image->setWrapMode(QOpenGLTexture::ClampToBorder);
|
|
||||||
m_image->setBorderColor(0, 0, 0, 0);
|
|
||||||
m_bwImg = false;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ImageWidget::setScale(float scale)
|
void ImageWidget::setScale(float scale)
|
||||||
{
|
{
|
||||||
m_scale = scale;
|
m_scale = scale;
|
||||||
@@ -130,13 +116,15 @@ void ImageWidget::blockRepaint(bool block)
|
|||||||
if(!block)update();
|
if(!block)update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageWidget::allocateThumbnails(int count)
|
void ImageWidget::allocateThumbnails(const QStringList &&names)
|
||||||
{
|
{
|
||||||
|
int count = names.size();
|
||||||
|
m_Names = std::move(names);
|
||||||
m_thumbnailTexture->destroy();
|
m_thumbnailTexture->destroy();
|
||||||
m_thumbnailTexture->create();
|
m_thumbnailTexture->create();
|
||||||
m_thumbnailTexture->setFormat(QOpenGLTexture::RGB16_UNorm);
|
m_thumbnailTexture->setFormat(QOpenGLTexture::RGB16_UNorm);
|
||||||
m_thumbnailTexture->setSize(THUMB_SIZE, THUMB_SIZE);
|
m_thumbnailTexture->setSize(THUMB_SIZE, THUMB_SIZE);
|
||||||
m_thumbnailTexture->setLayers(count);
|
m_thumbnailTexture->setLayers(names.size());
|
||||||
m_thumbnailTexture->allocateStorage();
|
m_thumbnailTexture->allocateStorage();
|
||||||
m_bufferSizes->bind();
|
m_bufferSizes->bind();
|
||||||
float *tmp = new float[count*3];
|
float *tmp = new float[count*3];
|
||||||
@@ -237,6 +225,24 @@ void ImageWidget::paintGL()
|
|||||||
mvp.ortho(rect());
|
mvp.ortho(rect());
|
||||||
m_thumbnailProgram->setUniformValue("mvp", mvp);
|
m_thumbnailProgram->setUniformValue("mvp", mvp);
|
||||||
if(f3)f3->glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, m_thumbnailCount);
|
if(f3)f3->glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, m_thumbnailCount);
|
||||||
|
|
||||||
|
QPainter painter(this);
|
||||||
|
int w = width()/THUMB_SIZE_BORDER;
|
||||||
|
for(int i=0; i < m_thumbnailCount; i++)
|
||||||
|
{
|
||||||
|
float x = (i % w) * THUMB_SIZE_BORDER;
|
||||||
|
float y = i / w * THUMB_SIZE_BORDER_Y + THUMB_SIZE - m_dy;
|
||||||
|
QRectF rect(x, y, THUMB_SIZE_BORDER, 32);
|
||||||
|
painter.drawText(rect, Qt::AlignCenter | Qt::TextWrapAnywhere, QString(m_Names.at(i)));
|
||||||
|
if(m_currentImg == i)
|
||||||
|
{
|
||||||
|
int off = (THUMB_SIZE_BORDER - THUMB_SIZE) / 2;
|
||||||
|
painter.save();
|
||||||
|
painter.setPen(QPen(Qt::red, 2.0));
|
||||||
|
painter.drawRect((i % w) * THUMB_SIZE_BORDER + off, i / w * THUMB_SIZE_BORDER_Y - m_dy + off, THUMB_SIZE, THUMB_SIZE);
|
||||||
|
painter.restore();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -416,24 +422,15 @@ ImageScrollAreaGL::~ImageScrollAreaGL()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageScrollAreaGL::setImage(RawImage *image)
|
void ImageScrollAreaGL::setImage(RawImage *image, int index)
|
||||||
{
|
{
|
||||||
m_imageWidget->setImage(image);
|
m_imageWidget->setImage(image, index);
|
||||||
m_imgWidth = image->width();
|
m_imgWidth = image->width();
|
||||||
m_imgHeight = image->height();
|
m_imgHeight = image->height();
|
||||||
if(m_bestFit)bestFit();
|
if(m_bestFit)bestFit();
|
||||||
updateScrollbars();
|
updateScrollbars();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageScrollAreaGL::setImage(const QPixmap &pixmap)
|
|
||||||
{
|
|
||||||
m_imageWidget->setImage(pixmap);
|
|
||||||
m_imgWidth = pixmap.width();
|
|
||||||
m_imgHeight = pixmap.height();
|
|
||||||
if(m_bestFit)bestFit();
|
|
||||||
updateScrollbars();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageWidget *ImageScrollAreaGL::imageWidget()
|
ImageWidget *ImageScrollAreaGL::imageWidget()
|
||||||
{
|
{
|
||||||
return m_imageWidget;
|
return m_imageWidget;
|
||||||
@@ -444,8 +441,8 @@ void ImageScrollAreaGL::setThumbnails(int count)
|
|||||||
m_thumbCount = count;
|
m_thumbCount = count;
|
||||||
if(m_thumbCount)
|
if(m_thumbCount)
|
||||||
{
|
{
|
||||||
m_verticalScrollBar->setRange(0, m_thumbCount / (m_imageWidget->width() / THUMB_SIZE_BORDER) * THUMB_SIZE_BORDER);
|
m_verticalScrollBar->setRange(0, m_thumbCount / (m_imageWidget->width() / THUMB_SIZE_BORDER) * THUMB_SIZE_BORDER_Y);
|
||||||
m_verticalScrollBar->setPageStep(THUMB_SIZE_BORDER);
|
m_verticalScrollBar->setPageStep(THUMB_SIZE_BORDER_Y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -461,8 +458,8 @@ void ImageScrollAreaGL::updateScrollbars(bool zoom)
|
|||||||
{
|
{
|
||||||
m_horizontalScrollBar->hide();
|
m_horizontalScrollBar->hide();
|
||||||
m_verticalScrollBar->show();
|
m_verticalScrollBar->show();
|
||||||
m_verticalScrollBar->setRange(0, m_thumbCount / (m_imageWidget->width() / THUMB_SIZE_BORDER) * THUMB_SIZE_BORDER);
|
m_verticalScrollBar->setRange(0, m_thumbCount / (m_imageWidget->width() / THUMB_SIZE_BORDER) * THUMB_SIZE_BORDER_Y);
|
||||||
m_verticalScrollBar->setPageStep(THUMB_SIZE_BORDER);
|
m_verticalScrollBar->setPageStep(THUMB_SIZE_BORDER_Y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -484,8 +481,8 @@ void ImageScrollAreaGL::resizeEvent(QResizeEvent *event)
|
|||||||
QWidget::resizeEvent(event);
|
QWidget::resizeEvent(event);
|
||||||
if(m_thumbCount)
|
if(m_thumbCount)
|
||||||
{
|
{
|
||||||
m_verticalScrollBar->setRange(0, m_thumbCount / (m_imageWidget->width() / THUMB_SIZE_BORDER) * THUMB_SIZE_BORDER);
|
m_verticalScrollBar->setRange(0, m_thumbCount / (m_imageWidget->width() / THUMB_SIZE_BORDER) * THUMB_SIZE_BORDER_Y);
|
||||||
m_verticalScrollBar->setPageStep(THUMB_SIZE_BORDER);
|
m_verticalScrollBar->setPageStep(THUMB_SIZE_BORDER_Y);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
+5
-4
@@ -40,6 +40,7 @@ class ImageWidget : public QOpenGLWidget
|
|||||||
std::unique_ptr<QOpenGLTexture> m_thumbnailTexture;
|
std::unique_ptr<QOpenGLTexture> m_thumbnailTexture;
|
||||||
int m_width, m_height;
|
int m_width, m_height;
|
||||||
int m_imgWidth, m_imgHeight;
|
int m_imgWidth, m_imgHeight;
|
||||||
|
int m_currentImg;
|
||||||
float m_low;
|
float m_low;
|
||||||
float m_mid;
|
float m_mid;
|
||||||
float m_high;
|
float m_high;
|
||||||
@@ -52,14 +53,15 @@ class ImageWidget : public QOpenGLWidget
|
|||||||
bool m_superpixel;
|
bool m_superpixel;
|
||||||
bool m_showThumbnails;
|
bool m_showThumbnails;
|
||||||
int m_thumbnailCount;
|
int m_thumbnailCount;
|
||||||
|
QStringList m_Names;
|
||||||
public:
|
public:
|
||||||
explicit ImageWidget(QWidget *parent = nullptr);
|
explicit ImageWidget(QWidget *parent = nullptr);
|
||||||
~ImageWidget();
|
~ImageWidget();
|
||||||
void setImage(const RawImage *image);
|
void setImage(const RawImage *image, int index);
|
||||||
void setImage(const QPixmap &pixmap);
|
void setImage(const QPixmap &pixmap);
|
||||||
void setScale(float scale);
|
void setScale(float scale);
|
||||||
void blockRepaint(bool block);
|
void blockRepaint(bool block);
|
||||||
void allocateThumbnails(int count);
|
void allocateThumbnails(const QStringList &&names);
|
||||||
public slots:
|
public slots:
|
||||||
void setMTFParams(float low, float mid, float high);
|
void setMTFParams(float low, float mid, float high);
|
||||||
void setOffset(int dx, int dy);
|
void setOffset(int dx, int dy);
|
||||||
@@ -92,8 +94,7 @@ class ImageScrollAreaGL : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit ImageScrollAreaGL(QWidget *parent = nullptr);
|
explicit ImageScrollAreaGL(QWidget *parent = nullptr);
|
||||||
~ImageScrollAreaGL();
|
~ImageScrollAreaGL();
|
||||||
void setImage(RawImage *image);
|
void setImage(RawImage *image, int index);
|
||||||
void setImage(const QPixmap &pixmap);
|
|
||||||
ImageWidget* imageWidget();
|
ImageWidget* imageWidget();
|
||||||
void setThumbnails(int count);
|
void setThumbnails(int count);
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
+3
-3
@@ -120,7 +120,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
|||||||
viewMenu->addAction(tr("100%"), m_imageGL, SLOT(oneToOne()));
|
viewMenu->addAction(tr("100%"), m_imageGL, SLOT(oneToOne()));
|
||||||
viewMenu->addAction(tr("Fullscreen"), this, SLOT(toggleFullScreen()), Qt::CTRL + Qt::Key_F11);
|
viewMenu->addAction(tr("Fullscreen"), this, SLOT(toggleFullScreen()), Qt::CTRL + Qt::Key_F11);
|
||||||
QAction *thumbnailsAction = viewMenu->addAction(tr("Thumbnails"), [this](bool checked){
|
QAction *thumbnailsAction = viewMenu->addAction(tr("Thumbnails"), [this](bool checked){
|
||||||
m_imageGL->imageWidget()->allocateThumbnails(m_ringList->imageCount());
|
m_imageGL->imageWidget()->allocateThumbnails(m_ringList->imageNames());
|
||||||
m_imageGL->imageWidget()->showThumbnail(checked);
|
m_imageGL->imageWidget()->showThumbnail(checked);
|
||||||
m_imageGL->setThumbnails(checked ? m_ringList->imageCount() : 0);
|
m_imageGL->setThumbnails(checked ? m_ringList->imageCount() : 0);
|
||||||
if(checked)m_ringList->loadThumbnails();
|
if(checked)m_ringList->loadThumbnails();
|
||||||
@@ -153,7 +153,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
|||||||
|
|
||||||
QAction *statsAction = analyzeGroup->addAction(tr("Image statistics"));
|
QAction *statsAction = analyzeGroup->addAction(tr("Image statistics"));
|
||||||
QAction *peakAction = analyzeGroup->addAction(tr("Peak finder"));
|
QAction *peakAction = analyzeGroup->addAction(tr("Peak finder"));
|
||||||
QAction *starAction = analyzeGroup->addAction("Star finder");
|
QAction *starAction = analyzeGroup->addAction(tr("Star finder"));
|
||||||
statsAction->setCheckable(true);
|
statsAction->setCheckable(true);
|
||||||
peakAction->setCheckable(true);
|
peakAction->setCheckable(true);
|
||||||
starAction->setCheckable(true);
|
starAction->setCheckable(true);
|
||||||
@@ -339,7 +339,7 @@ void MainWindow::pixmapLoaded(Image *image)
|
|||||||
//m_image->setImage(image->pixmap());
|
//m_image->setImage(image->pixmap());
|
||||||
if(image->rawImage())
|
if(image->rawImage())
|
||||||
{
|
{
|
||||||
m_imageGL->setImage(image->rawImage());
|
m_imageGL->setImage(image->rawImage(), image->number());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
const int THUMB_SIZE = 128;
|
const int THUMB_SIZE = 128;
|
||||||
const int THUMB_SIZE_BORDER = 138;
|
const int THUMB_SIZE_BORDER = 138;
|
||||||
|
const int THUMB_SIZE_BORDER_Y = 158;
|
||||||
|
|
||||||
class Peak
|
class Peak
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ void main(void)
|
|||||||
vec2 pos = qt_Vertex * 0.5;
|
vec2 pos = qt_Vertex * 0.5;
|
||||||
pos.y *= -1.0;
|
pos.y *= -1.0;
|
||||||
pos = pos * imageSize_num.xy + 69;
|
pos = pos * imageSize_num.xy + 69;
|
||||||
ivec2 off = ivec2(imageSize_num.z % viewport_row.z, imageSize_num.z / viewport_row.z) * 138;
|
ivec2 off = ivec2(imageSize_num.z % viewport_row.z, imageSize_num.z / viewport_row.z) * ivec2(138, 158);
|
||||||
|
|
||||||
gl_Position = mvp * vec4(pos - offset + off, 0.0, 1.0);
|
gl_Position = mvp * vec4(pos - offset + off, 0.0, 1.0);
|
||||||
qt_TexCoord0 = vec3(qt_MultiTexCoord0, imageSize_num.z + 0.1);
|
qt_TexCoord0 = vec3(qt_MultiTexCoord0, imageSize_num.z + 0.1);
|
||||||
|
|||||||
Reference in New Issue
Block a user