File indexing completed on 2025-03-09 03:52:05

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2007-02-11
0007  * Description : a tool to show image using an OpenGL interface.
0008  *
0009  * SPDX-FileCopyrightText: 2007-2008 by Markus Leuthold <kusi at forum dot titlis dot org>
0010  * SPDX-FileCopyrightText: 2008-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #ifndef DIGIKAM_GLVIEWER_PLUGIN_GLVIEWER_TEXTURE_H
0017 #define DIGIKAM_GLVIEWER_PLUGIN_GLVIEWER_TEXTURE_H
0018 
0019 // Qt includes
0020 
0021 #include <QOpenGLTexture>
0022 #include <QOpenGLWidget>
0023 #include <QImage>
0024 #include <QString>
0025 
0026 // Local includes
0027 
0028 #include "dinfointerface.h"
0029 
0030 using namespace Digikam;
0031 
0032 namespace DigikamGenericGLViewerPlugin
0033 {
0034 
0035 class GLViewerTexture : public QOpenGLTexture
0036 {
0037 
0038 public:
0039 
0040     explicit GLViewerTexture(DInfoInterface* const iface, QWidget* const display);
0041     ~GLViewerTexture();
0042 
0043     bool load(const QString& fn, const QSize& size);
0044     bool load(const QImage& im);
0045     bool loadFullSize();
0046 
0047     GLfloat vertex_bottom() const;
0048     GLfloat vertex_top()    const;
0049     GLfloat vertex_left()   const;
0050     GLfloat vertex_right()  const;
0051 
0052     void setViewport(int w, int h);
0053     void zoom(float delta, const QPoint& mousepos);
0054     void reset(bool resetFullImage = false);
0055     void move(const QPoint& diff);
0056     bool setNewSize(QSize size);
0057     void rotate();
0058     void zoomToOriginal();
0059 
0060 private:
0061 
0062     bool loadInternal();
0063     void calcVertex();
0064 
0065 private:
0066 
0067     // Disable
0068     GLViewerTexture(const GLViewerTexture&) = delete;
0069 
0070 private:
0071 
0072     class Private;
0073     Private* const d;
0074 };
0075 
0076 } // namespace DigikamGenericGLViewerPlugin
0077 
0078 #endif // DIGIKAM_GLVIEWER_PLUGIN_GLVIEWER_TEXTURE_H