|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef IMAGEVIEWER_INCLUDE
|
|
Toshihiro Shimizu |
890ddd |
#define IMAGEVIEWER_INCLUDE
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/imagepainter.h"
|
|
shun_iwasawa |
7c988d |
#include "toonzqt/glwidget_for_highdpi.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
manongjohn |
2c447c |
#include <qtouchdevice></qtouchdevice>
|
|
manongjohn |
2c447c |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Forward declarations
|
|
Toshihiro Shimizu |
890ddd |
class FlipBook;
|
|
Toshihiro Shimizu |
890ddd |
class HistogramPopup;
|
|
shun-iwasawa |
ad7711 |
class QOpenGLFramebufferObject;
|
|
shun-iwasawa |
388550 |
class LutCalibrator;
|
|
manongjohn |
2c447c |
class QTouchEvent;
|
|
manongjohn |
2c447c |
class QGestureEvent;
|
|
shun-iwasawa |
fe0983 |
class QElapsedTimer;
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//====================
|
|
Toshihiro Shimizu |
890ddd |
// ImageViewer
|
|
Toshihiro Shimizu |
890ddd |
//--------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun_iwasawa |
7c988d |
class ImageViewer final : public GLWidgetForHighDpi {
|
|
Shinya Kitaoka |
120a6e |
Q_OBJECT
|
|
Shinya Kitaoka |
120a6e |
enum DragType {
|
|
Shinya Kitaoka |
120a6e |
eNone,
|
|
Shinya Kitaoka |
120a6e |
eDrawRect = 0x1,
|
|
Shinya Kitaoka |
120a6e |
eMoveRect = 0x2,
|
|
Shinya Kitaoka |
120a6e |
eMoveLeft = 0x4,
|
|
Shinya Kitaoka |
120a6e |
eMoveRight = 0x8,
|
|
Shinya Kitaoka |
120a6e |
eMoveUp = 0x10,
|
|
Shinya Kitaoka |
120a6e |
eMoveDown = 0x20
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
int m_dragType;
|
|
Shinya Kitaoka |
120a6e |
FlipBook *m_flipbook;
|
|
Shinya Kitaoka |
120a6e |
TPoint m_pressedMousePos;
|
|
Shinya Kitaoka |
120a6e |
|
|
luz paz |
67b4e9 |
// Modifying rect-picking position offset for vector image.
|
|
shun-iwasawa |
d5045c |
// For unknown reasons, glReadPixels is covering the entire window not the
|
|
shun-iwasawa |
d5045c |
// OpenGL widget.
|
|
shun-iwasawa |
d5045c |
TPointD m_winPosMousePosOffset;
|
|
shun-iwasawa |
d5045c |
|
|
Shinya Kitaoka |
120a6e |
Qt::MouseButton m_mouseButton;
|
|
Shinya Kitaoka |
120a6e |
bool m_draggingZoomSelection;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool m_rectRGBPick;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int m_FPS;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ImagePainter::VisualSettings m_visualSettings;
|
|
Shinya Kitaoka |
120a6e |
ImagePainter::CompareSettings m_compareSettings;
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
481b59 |
TImageP m_image; // displayed image
|
|
shun-iwasawa |
481b59 |
TImageP m_orgImage; // image without gain adjustment
|
|
Shinya Kitaoka |
120a6e |
TAffine m_viewAff;
|
|
Shinya Kitaoka |
120a6e |
QPoint m_pos;
|
|
Shinya Kitaoka |
120a6e |
bool m_isHistogramEnable;
|
|
Shinya Kitaoka |
120a6e |
HistogramPopup *m_histogramPopup;
|
|
manongjohn |
2c447c |
bool m_firstImage;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool m_isColorModel;
|
|
Shinya Kitaoka |
120a6e |
// when fx parameter is modified with showing the fx preview,
|
|
Shinya Kitaoka |
120a6e |
// a flipbook shows a red border line before the rendered result is shown.
|
|
Shinya Kitaoka |
120a6e |
bool m_isRemakingPreviewFx;
|
|
Shinya Kitaoka |
120a6e |
|
|
shun-iwasawa |
ad7711 |
// used for color calibration with 3DLUT
|
|
shun-iwasawa |
ad7711 |
QOpenGLFramebufferObject *m_fbo = NULL;
|
|
shun-iwasawa |
388550 |
LutCalibrator *m_lutCalibrator = NULL;
|
|
Shinya Kitaoka |
120a6e |
|
|
manongjohn |
2c447c |
bool m_touchActive = false;
|
|
manongjohn |
2c447c |
bool m_gestureActive = false;
|
|
manongjohn |
2c447c |
QTouchDevice::DeviceType m_touchDevice = QTouchDevice::TouchScreen;
|
|
manongjohn |
2c447c |
bool m_zooming = false;
|
|
manongjohn |
2c447c |
bool m_panning = false;
|
|
manongjohn |
2c447c |
double m_scaleFactor; // used for zoom gesture
|
|
manongjohn |
2c447c |
|
|
shun-iwasawa |
e40777 |
bool m_stylusUsed = false;
|
|
shun-iwasawa |
e40777 |
bool m_firstInitialized = true;
|
|
manongjohn |
2c447c |
|
|
shun-iwasawa |
fe0983 |
// passed from PlaybackExecutor
|
|
shun-iwasawa |
fe0983 |
QElapsedTimer *m_timer;
|
|
shun-iwasawa |
fe0983 |
qint64 m_targetInstant;
|
|
shun-iwasawa |
fe0983 |
|
|
Shinya Kitaoka |
120a6e |
int getDragType(const TPoint &pos, const TRect &loadBox);
|
|
Shinya Kitaoka |
120a6e |
void updateLoadbox(const TPoint &curPos);
|
|
Shinya Kitaoka |
120a6e |
void updateCursor(const TPoint &curPos);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// for RGB color picker
|
|
Shinya Kitaoka |
120a6e |
void pickColor(QMouseEvent *event, bool putValueToStyleEditor = false);
|
|
Shinya Kitaoka |
120a6e |
void rectPickColor(bool putValueToStyleEditor = false);
|
|
Shinya Kitaoka |
120a6e |
void setPickedColorToStyleEditor(const TPixel32 &color);
|
|
shun-iwasawa |
099c01 |
// get the image (m_image or the snapshot) to be picked.
|
|
shun-iwasawa |
099c01 |
TImageP getPickedImage(QPointF mousePos);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
ImageViewer(QWidget *parent, FlipBook *flipbook, bool showHistogram);
|
|
Shinya Kitaoka |
120a6e |
~ImageViewer();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setIsColorModel(bool isColorModel) { m_isColorModel = isColorModel; }
|
|
Shinya Kitaoka |
120a6e |
bool isColorModel() { return m_isColorModel; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setVisual(const ImagePainter::VisualSettings &settings);
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
481b59 |
void setImage(TImageP image, TImageP orgImage = TImageP());
|
|
Shinya Kitaoka |
120a6e |
TImageP getImage() { return m_image; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TAffine getViewAff() { return m_viewAff; }
|
|
Shinya Kitaoka |
120a6e |
void setViewAff(TAffine viewAff);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TAffine getImgToWidgetAffine(const TRectD &imgBounds) const;
|
|
Shinya Kitaoka |
120a6e |
TAffine getImgToWidgetAffine() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/*! If histogram popup exist and is open set its title to "Histogram: level
|
|
Shinya Kitaoka |
120a6e |
name"
|
|
Shinya Kitaoka |
120a6e |
if level Name is not empty. */
|
|
Shinya Kitaoka |
120a6e |
void setHistogramTitle(QString levelName);
|
|
Shinya Kitaoka |
120a6e |
void setHistogramEnable(bool enable);
|
|
Shinya Kitaoka |
120a6e |
/*! If histogram popup exist and is open, it is set to default and is hidden.
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
void hideHistogram();
|
|
Shinya Kitaoka |
120a6e |
void zoomQt(bool forward, bool reset);
|
|
shun-iwasawa |
92d40c |
void resetZoom();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setIsRemakingPreviewFx(bool on) {
|
|
Shinya Kitaoka |
120a6e |
m_isRemakingPreviewFx = on;
|
|
Shinya Kitaoka |
120a6e |
update();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
bool isRemakingPreviewFx() { return m_isRemakingPreviewFx; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void adaptView(const TRect &imgRect, const TRect &viewRect);
|
|
Shinya Kitaoka |
120a6e |
void adaptView(const QRect &viewerRect);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void doSwapBuffers();
|
|
Shinya Kitaoka |
120a6e |
void changeSwapBehavior(bool enable);
|
|
shun-iwasawa |
d5045c |
void invalidateCompHisto();
|
|
Keisuke Ogaki |
0c8292 |
|
|
shun-iwasawa |
fe0983 |
void setTimerAndTargetInstant(QElapsedTimer *timer, qint64 target) {
|
|
shun-iwasawa |
fe0983 |
m_timer = timer;
|
|
shun-iwasawa |
fe0983 |
m_targetInstant = target;
|
|
shun-iwasawa |
fe0983 |
}
|
|
shun-iwasawa |
fe0983 |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
473e70 |
void contextMenuEvent(QContextMenuEvent *event) override;
|
|
Shinya Kitaoka |
473e70 |
void initializeGL() override;
|
|
Shinya Kitaoka |
473e70 |
void resizeGL(int width, int height) override;
|
|
Shinya Kitaoka |
473e70 |
void paintGL() override;
|
|
Shinya Kitaoka |
473e70 |
|
|
shun-iwasawa |
a8f111 |
void showEvent(QShowEvent *) override;
|
|
shun-iwasawa |
a8f111 |
void hideEvent(QHideEvent *) override;
|
|
Shinya Kitaoka |
473e70 |
void mouseMoveEvent(QMouseEvent *event) override;
|
|
Shinya Kitaoka |
473e70 |
void mousePressEvent(QMouseEvent *event) override;
|
|
Shinya Kitaoka |
473e70 |
void mouseReleaseEvent(QMouseEvent *event) override;
|
|
Shinya Kitaoka |
473e70 |
void keyPressEvent(QKeyEvent *event) override;
|
|
Shinya Kitaoka |
473e70 |
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
|
Shinya Kitaoka |
473e70 |
void wheelEvent(QWheelEvent *) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void panQt(const QPoint &delta);
|
|
Shinya Kitaoka |
120a6e |
void zoomQt(const QPoint ¢er, double factor);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void dragCompare(const QPoint &dp);
|
|
Toshihiro Shimizu |
890ddd |
|
|
artisteacher |
fd1c1e |
void tabletEvent(QTabletEvent *e) override;
|
|
manongjohn |
2c447c |
void touchEvent(QTouchEvent *e, int type);
|
|
manongjohn |
2c447c |
void gestureEvent(QGestureEvent *e);
|
|
artisteacher |
fd1c1e |
bool event(QEvent *e) override;
|
|
manongjohn |
2c447c |
|
|
Toshihiro Shimizu |
890ddd |
public slots:
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void updateImageViewer();
|
|
Shinya Kitaoka |
120a6e |
void resetView();
|
|
Shinya Kitaoka |
120a6e |
void fitView();
|
|
Shinya Kitaoka |
120a6e |
void showHistogram();
|
|
Shinya Kitaoka |
120a6e |
void swapCompared();
|
|
shun-iwasawa |
388550 |
void onContextAboutToBeDestroyed();
|
|
shun-iwasawa |
a8f111 |
void onPreferenceChanged(const QString &prefName);
|
|
manongjohn |
2c447c |
|
|
manongjohn |
2c447c |
private:
|
|
manongjohn |
2c447c |
QPointF m_firstPanPoint;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif // IMAGEVIEWER_INCLUDE
|