Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef IMAGEUTILS_H
Toshihiro Shimizu 890ddd
#define IMAGEUTILS_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzBase includes
Toshihiro Shimizu 890ddd
#include "trasterfx.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzCore includes
Toshihiro Shimizu 890ddd
#include "tregion.h"
Toshihiro Shimizu 890ddd
#include "tvectorimage.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Qt includes
Toshihiro Shimizu 890ddd
#include <qwidget></qwidget>
Toshihiro Shimizu 890ddd
#include <qkeyevent></qkeyevent>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TOONZQT_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//    Forward declarations
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TFilePath;
Toshihiro Shimizu 890ddd
class TPropertyGroup;
Shinya Kitaoka 120a6e
// enum TRenderSettings::ResampleQuality;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class QHBoxLayout;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace ImageUtils {
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  \brief    Notify that a task on a single frame is completed.
Toshihiro Shimizu 890ddd
*/
Shinya Kitaoka d1f6c4
class DVAPI FrameTaskNotifier final : public QObject {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int m_errorCount, m_warningCount;
Shinya Kitaoka 120a6e
  bool m_abort;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  FrameTaskNotifier() : m_errorCount(0), m_warningCount(0), m_abort(false) {}
Shinya Kitaoka 120a6e
  ~FrameTaskNotifier() {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void notifyFrameCompleted(int frame) { emit frameCompleted(frame); }
Shinya Kitaoka 120a6e
  void notifyError() {
Shinya Kitaoka 120a6e
    m_errorCount++;
Shinya Kitaoka 120a6e
    emit error();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  void notifyLevelCompleted(const TFilePath &fullPath) {
Shinya Kitaoka 120a6e
    emit levelCompleted(fullPath);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool abortTask() { return m_abort; }
Shinya Kitaoka 120a6e
  void reset() { m_abort = false; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int getErrorCount() const { return m_errorCount; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
signals:
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void frameCompleted(int);
Shinya Kitaoka 120a6e
  void levelCompleted(const TFilePath &fullPath);
Shinya Kitaoka 120a6e
  void error();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected slots:
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void onCancelTask() { m_abort = true; }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TFilePath DVAPI duplicate(const TFilePath &levelPath);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DVAPI premultiply(const TFilePath &levelPath);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DVAPI convert(
Shinya Kitaoka 120a6e
    const TFilePath &source,  //!< Level path to convert from.
Shinya Kitaoka 120a6e
    const TFilePath &dest,    //!< Level path to convert to.
Shinya Kitaoka 120a6e
    const TFrameId &from,     //!< First source frame to convert. Supports
Shinya Kitaoka 38fd86
                              //! TFrameId::EMPTY_FRAME
Shinya Kitaoka 120a6e
    //!  to specify conversion from the beginning of level.
Shinya Kitaoka 120a6e
    const TFrameId
Shinya Kitaoka 120a6e
        &to,  //!< Last source frame to convert. Supports TFrameId::EMPTY_FRAME
Shinya Kitaoka 120a6e
              //!  to specify conversion to the end of level.
Shinya Kitaoka 120a6e
    double framerate,      //!< Frame rate for destination movie formats.
Shinya Kitaoka 120a6e
    TPropertyGroup *prop,  //!< Format properties for the destination level.
Shinya Kitaoka 120a6e
    FrameTaskNotifier
Shinya Kitaoka 120a6e
        *frameNotifier,  //!< Observer class for frame success notifications.
Shinya Kitaoka 120a6e
    const TPixel &bgColor =
Shinya Kitaoka 120a6e
        TPixel::Transparent,  //!< Destination Background color.
Shinya Kitaoka 120a6e
    bool removeDotBeforeFrameNumber =
Shinya Kitaoka 120a6e
        false /*-- ConvertPopup
Shinya Kitaoka 120a6e
                 での指定に合わせて、[レベル名].[フレーム番号].[拡張子]のうち、
Shinya Kitaoka 120a6e
                                                                                          [レベル名]と[フレーム番号]の間のドットを消す。 --*/
Shinya Kitaoka 120a6e
    );        //!< Converts a saved level to fullcolor, and saves the result.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DVAPI convertNaa2Tlv(
Shinya Kitaoka 120a6e
    const TFilePath &source,  //!< Level path to convert from.
Shinya Kitaoka 120a6e
    const TFilePath &dest,    //!< Level path to convert to.
Shinya Kitaoka 120a6e
    const TFrameId &from,     //!< First source frame to convert.
Shinya Kitaoka 120a6e
    const TFrameId &to,       //!< Last source frame to convert.
Shinya Kitaoka 120a6e
    FrameTaskNotifier
Shinya Kitaoka 120a6e
        *frameNotifier,  //!< Observer class for frame success notifications.
Shinya Kitaoka 120a6e
    TPalette *palette =
Shinya Kitaoka 120a6e
        0);  //!< Special conversion function from an antialiased level to tlv.
Shinya Kitaoka 120a6e
             //!  \sa  Function ImageUtils::convert().
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
double DVAPI getQuantizedZoomFactor(double zf, bool forward);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DVAPI getFillingInformationOverlappingArea(
Shinya Kitaoka 120a6e
    const TVectorImageP &vi, std::vector<tfilledregioninf> ®s,</tfilledregioninf>
Shinya Kitaoka 120a6e
    const TRectD &area1, const TRectD &area2 = TRectD());
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void DVAPI getFillingInformationInArea(const TVectorImageP &vi,
Shinya Kitaoka 120a6e
                                       std::vector<tfilledregioninf> ®s,</tfilledregioninf>
Shinya Kitaoka 120a6e
                                       const TRectD &area);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void DVAPI assignFillingInformation(TVectorImage &vi,
Shinya Kitaoka 120a6e
                                    const std::vector<tfilledregioninf> ®s);</tfilledregioninf>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DVAPI getStrokeStyleInformationInArea(
Shinya Kitaoka 120a6e
    const TVectorImageP &vi, std::vector<std::pair<int, int="">></std::pair<int,>
Shinya Kitaoka 120a6e
                                 &strokesInfo,  // pair:strokeIndex, styleIndex
Shinya Kitaoka 120a6e
    const TRectD &area);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//*********************************************************************************************
Toshihiro Shimizu 890ddd
//    FullScreenWidget  declaration
Toshihiro Shimizu 890ddd
//*********************************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Shinya Kitaoka 120a6e
  \brief    Temporary class used to deal with QTBUG #7556 - QGLWidgets going
Shinya Kitaoka 120a6e
  fullscreen \a need
Shinya Kitaoka 120a6e
            a containing widget that leaves a small margin to prevent the widget
Shinya Kitaoka 120a6e
  from covering other
Toshihiro Shimizu 890ddd
            widgets (specifically, context menus).
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DVAPI FullScreenWidget final : public QWidget {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QWidget *m_widget;  //!< (Owned) The content widget.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  FullScreenWidget(QWidget *parent = 0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setWidget(
Shinya Kitaoka 120a6e
      QWidget *widget);  //!< Sets the content, surrendering ownership.
Shinya Kitaoka 120a6e
  QWidget *widget() const { return m_widget; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public slots:
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool toggleFullScreen(bool quit = false);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//*********************************************************************************************
Toshihiro Shimizu 890ddd
//    ShortcutZoomer  declaration
Toshihiro Shimizu 890ddd
//*********************************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Shinya Kitaoka 120a6e
  \brief    The ShortcutZoomer abstract base class is used by viewer widget to
Shinya Kitaoka 120a6e
  access
Toshihiro Shimizu 890ddd
            shortcut-related commands.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  \details  This class is a wrapper for shortcuts established by the
Shinya Kitaoka 120a6e
  CommandManager
Toshihiro Shimizu 890ddd
            interface.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
            Subclass it defining the required view commands, then implement a
Toshihiro Shimizu 890ddd
            \p keyPressEvent() event handler in the viewer widget you want:
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
            \code
Toshihiro Shimizu 890ddd
            void MyViewer::keyPressEvent(QKeyEvent* ke)
Toshihiro Shimizu 890ddd
            {
Toshihiro Shimizu 890ddd
              if(ViewerZoomer(this).exec(event))
Toshihiro Shimizu 890ddd
                return;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
              return MyViewerBase::keyPressEvent(ke);
Toshihiro Shimizu 890ddd
            }
Toshihiro Shimizu 890ddd
            \endcode
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  \warning  Use the FullScreenWidget class to wrap a viewer class that
Toshihiro Shimizu 890ddd
            needs to go fullscreen.
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI ShortcutZoomer {
Shinya Kitaoka 120a6e
  QWidget *m_widget;  //!< Viewer widget being processed.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ShortcutZoomer(
Shinya Kitaoka 120a6e
      QWidget *viewerWidget);  //!< Constructs on the specified viewer widget.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QWidget *getWidget() {
Shinya Kitaoka 120a6e
    return m_widget;
Shinya Kitaoka 120a6e
  }  //!< Returns the processed viewer widget.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool exec(
Shinya Kitaoka 120a6e
      QKeyEvent *event);  //!< Processes a key event for shortcuts related to
Shinya Kitaoka 120a6e
                          //!  viewer commands.
Shinya Kitaoka 120a6e
                          //!  \return  Whether a shortcut was recognized.
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  virtual bool zoom(
Shinya Kitaoka 120a6e
      bool zoomin,
Shinya Kitaoka 120a6e
      bool resetZoom) = 0;  //!< Handler for zoom commands. Required.
Shinya Kitaoka 120a6e
  virtual bool fit() {
Shinya Kitaoka 120a6e
    return false;
Shinya Kitaoka 120a6e
  }  //!< Handler for 'fit to image' commands.
Shinya Kitaoka 120a6e
  virtual bool setActualPixelSize() {
Shinya Kitaoka 120a6e
    return false;
Shinya Kitaoka 120a6e
  }  //!< Handler for 'use actual pixel size' commands.
Shinya Kitaoka 120a6e
  virtual bool toggleFullScreen(
Shinya Kitaoka 120a6e
      bool quit = false)  //!  Handler for 'toggle fullscreen' commands.
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
    return false;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
}  // namespace ImageUtils
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif