tahoma2d/toonz/sources/include/toonzqt/imageutils.h

231 lines
7.1 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef IMAGEUTILS_H
#define IMAGEUTILS_H
// TnzBase includes
#include "trasterfx.h"
// TnzCore includes
#include "tregion.h"
#include "tvectorimage.h"
// Qt includes
#include <QWidget>
#include <QKeyEvent>
#undef DVAPI
#undef DVVAR
#ifdef TOONZQT_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
//=============================================================================
// Forward declarations
class TFilePath;
class TPropertyGroup;
2016-06-15 18:43:10 +12:00
// enum TRenderSettings::ResampleQuality;
2016-03-19 06:57:51 +13:00
class QHBoxLayout;
//=============================================================================
2016-06-15 18:43:10 +12:00
namespace ImageUtils {
2016-03-19 06:57:51 +13:00
/*!
\brief Notify that a task on a single frame is completed.
*/
class DVAPI FrameTaskNotifier final : public QObject {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int m_errorCount, m_warningCount;
bool m_abort;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FrameTaskNotifier() : m_errorCount(0), m_warningCount(0), m_abort(false) {}
~FrameTaskNotifier() {}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void notifyFrameCompleted(int frame) { emit frameCompleted(frame); }
void notifyError() {
m_errorCount++;
emit error();
}
void notifyLevelCompleted(const TFilePath &fullPath) {
emit levelCompleted(fullPath);
}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
bool abortTask() { return m_abort; }
void reset() { m_abort = false; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int getErrorCount() const { return m_errorCount; }
2016-03-19 06:57:51 +13:00
signals:
2016-06-15 18:43:10 +12:00
void frameCompleted(int);
void levelCompleted(const TFilePath &fullPath);
void error();
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void onCancelTask() { m_abort = true; }
2016-03-19 06:57:51 +13:00
};
//----------------------------------------------------
TFilePath DVAPI duplicate(const TFilePath &levelPath);
void DVAPI premultiply(const TFilePath &levelPath);
void DVAPI convert(
2016-06-15 18:43:10 +12:00
const TFilePath &source, //!< Level path to convert from.
const TFilePath &dest, //!< Level path to convert to.
const TFrameId &from, //!< First source frame to convert. Supports
2016-06-20 14:23:05 +12:00
//! TFrameId::EMPTY_FRAME
2016-06-15 18:43:10 +12:00
//! to specify conversion from the beginning of level.
const TFrameId
&to, //!< Last source frame to convert. Supports TFrameId::EMPTY_FRAME
//! to specify conversion to the end of level.
double framerate, //!< Frame rate for destination movie formats.
TPropertyGroup *prop, //!< Format properties for the destination level.
FrameTaskNotifier
*frameNotifier, //!< Observer class for frame success notifications.
const TPixel &bgColor =
TPixel::Transparent, //!< Destination Background color.
bool removeDotBeforeFrameNumber =
false /*-- ConvertPopup
[].[].[]
[][] --*/
); //!< Converts a saved level to fullcolor, and saves the result.
2016-03-19 06:57:51 +13:00
void DVAPI convertNaa2Tlv(
2016-06-15 18:43:10 +12:00
const TFilePath &source, //!< Level path to convert from.
const TFilePath &dest, //!< Level path to convert to.
const TFrameId &from, //!< First source frame to convert.
const TFrameId &to, //!< Last source frame to convert.
FrameTaskNotifier
*frameNotifier, //!< Observer class for frame success notifications.
TPalette *palette =
2016-10-04 01:04:35 +13:00
0, //!< Special conversion function from an antialiased level to tlv.
//! \sa Function ImageUtils::convert().
bool removeUnusedStyles = false,
double dpi = 0.0); //! Remove unused styles from input palette.
2016-03-19 06:57:51 +13:00
double DVAPI getQuantizedZoomFactor(double zf, bool forward);
void DVAPI getFillingInformationOverlappingArea(
2016-06-15 18:43:10 +12:00
const TVectorImageP &vi, std::vector<TFilledRegionInf> &regs,
const TRectD &area1, const TRectD &area2 = TRectD());
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void DVAPI getFillingInformationInArea(const TVectorImageP &vi,
std::vector<TFilledRegionInf> &regs,
const TRectD &area);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void DVAPI assignFillingInformation(TVectorImage &vi,
const std::vector<TFilledRegionInf> &regs);
2016-03-19 06:57:51 +13:00
void DVAPI getStrokeStyleInformationInArea(
2016-06-15 18:43:10 +12:00
const TVectorImageP &vi, std::vector<std::pair<int, int>>
&strokesInfo, // pair:strokeIndex, styleIndex
const TRectD &area);
2016-03-19 06:57:51 +13:00
//*********************************************************************************************
// FullScreenWidget declaration
//*********************************************************************************************
/*!
2016-06-15 18:43:10 +12:00
\brief Temporary class used to deal with QTBUG #7556 - QGLWidgets going
fullscreen \a need
a containing widget that leaves a small margin to prevent the widget
from covering other
2016-03-19 06:57:51 +13:00
widgets (specifically, context menus).
*/
class DVAPI FullScreenWidget final : public QWidget {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QWidget *m_widget; //!< (Owned) The content widget.
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FullScreenWidget(QWidget *parent = 0);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setWidget(
QWidget *widget); //!< Sets the content, surrendering ownership.
QWidget *widget() const { return m_widget; }
2016-03-19 06:57:51 +13:00
public slots:
2016-06-15 18:43:10 +12:00
bool toggleFullScreen(bool quit = false);
2016-03-19 06:57:51 +13:00
};
//*********************************************************************************************
// ShortcutZoomer declaration
//*********************************************************************************************
/*!
2016-06-15 18:43:10 +12:00
\brief The ShortcutZoomer abstract base class is used by viewer widget to
access
2016-03-19 06:57:51 +13:00
shortcut-related commands.
2016-06-15 18:43:10 +12:00
\details This class is a wrapper for shortcuts established by the
CommandManager
2016-03-19 06:57:51 +13:00
interface.
Subclass it defining the required view commands, then implement a
\p keyPressEvent() event handler in the viewer widget you want:
\code
void MyViewer::keyPressEvent(QKeyEvent* ke)
{
if(ViewerZoomer(this).exec(event))
return;
return MyViewerBase::keyPressEvent(ke);
}
\endcode
\warning Use the FullScreenWidget class to wrap a viewer class that
needs to go fullscreen.
*/
2016-06-15 18:43:10 +12:00
class DVAPI ShortcutZoomer {
QWidget *m_widget; //!< Viewer widget being processed.
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
ShortcutZoomer(
QWidget *viewerWidget); //!< Constructs on the specified viewer widget.
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QWidget *getWidget() {
return m_widget;
} //!< Returns the processed viewer widget.
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
bool exec(
QKeyEvent *event); //!< Processes a key event for shortcuts related to
//! viewer commands.
//! \return Whether a shortcut was recognized.
2016-03-19 06:57:51 +13:00
protected:
2016-06-15 18:43:10 +12:00
virtual bool zoom(
bool zoomin,
bool resetZoom) = 0; //!< Handler for zoom commands. Required.
virtual bool fit() {
return false;
} //!< Handler for 'fit to image' commands.
virtual bool setActualPixelSize() {
return false;
} //!< Handler for 'use actual pixel size' commands.
virtual bool toggleFullScreen(
bool quit = false) //! Handler for 'toggle fullscreen' commands.
{
return false;
}
2016-03-19 06:57:51 +13:00
};
2016-06-15 18:43:10 +12:00
} // namespace ImageUtils
2016-03-19 06:57:51 +13:00
#endif