Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TOOL_INCLUDED
Toshihiro Shimizu 890ddd
#define TOOL_INCLUDED
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzLib includes
Toshihiro Shimizu 890ddd
#include "toonz/tstageobjectid.h"
Toshihiro Shimizu 890ddd
#include "toonz/txsheet.h"
Toshihiro Shimizu 890ddd
#include "toonz/imagepainter.h"
Toshihiro Shimizu 890ddd
#include "toonz/tapplication.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzCore includes
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
#include "tgeometry.h"
Toshihiro Shimizu 890ddd
#include "tfilepath.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Qt includes
Toshihiro Shimizu 890ddd
#include <qstring></qstring>
shun_iwasawa 491a52
#include <qpoint></qpoint>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TNZTOOLS_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 TToolParam;
Toshihiro Shimizu 890ddd
class TMouseEvent;
Toshihiro Shimizu 890ddd
class TStroke;
Toshihiro Shimizu 890ddd
class TImage;
Toshihiro Shimizu 890ddd
class TPropertyGroup;
Toshihiro Shimizu 890ddd
class TColorStyle;
Toshihiro Shimizu 890ddd
class TFrameId;
Toshihiro Shimizu 890ddd
class TPalette;
Toshihiro Shimizu 890ddd
class TSelection;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TFrameHandle;
Toshihiro Shimizu 890ddd
class TXshLevelHandle;
Toshihiro Shimizu 890ddd
class TXsheetHandle;
Toshihiro Shimizu 890ddd
class TObjectHandle;
Toshihiro Shimizu 890ddd
class TColumnHandle;
Toshihiro Shimizu 890ddd
class TSceneHandle;
Toshihiro Shimizu 890ddd
class TPaletteHandle;
Toshihiro Shimizu 890ddd
class ToolHandle;
Toshihiro Shimizu 890ddd
class TSelectionHandle;
Toshihiro Shimizu 890ddd
class TOnionSkinMaskHandle;
Toshihiro Shimizu 890ddd
class PaletteController;
Toshihiro Shimizu 890ddd
class TFxHandle;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class ToolOptionsBox;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class QMenu;
shun-iwasawa 7f1e30
class QKeyEvent;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//===================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//*****************************************************************************************
Toshihiro Shimizu 890ddd
//    TMouseEvent  definition
Toshihiro Shimizu 890ddd
//*****************************************************************************************
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI TMouseEvent {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  enum ModifierBitshift  //! \brief  Bit shifts from 1 associated with modifier
Shinya Kitaoka 120a6e
                         //! keys.
Shinya Kitaoka 120a6e
  { SHIFT_BITSHIFT,      //!< Bit shift for the Shift key modifier.
Shinya Kitaoka 120a6e
    ALT_BITSHIFT,        //!< Bit shift for the Alt key modifier.
Shinya Kitaoka 120a6e
    CTRL_BITSHIFT        //!< Bit shift for the Ctrl key modifier.
Shinya Kitaoka 120a6e
  };
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  enum ModifierMask  //! \brief  Bitmask specifying modifier keys applying on a
Shinya Kitaoka 120a6e
  {                  //!         mouse event.
Shinya Kitaoka 120a6e
    NO_KEY    = 0x0,
Shinya Kitaoka 120a6e
    SHIFT_KEY = (1 << SHIFT_BITSHIFT),  //!< Shift key is being pressed.
Shinya Kitaoka 120a6e
    ALT_KEY   = (1 << ALT_BITSHIFT),    //!< Alt key is begin pressed.
Shinya Kitaoka 120a6e
    CTRL_KEY  = (1 << CTRL_BITSHIFT)    //!< Ctrl key is being pressed.
Shinya Kitaoka 120a6e
  };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
shun_iwasawa bc352c
  TPointD m_pos;  //!< Mouse position in window coordinates, bottom-left origin.
shun-iwasawa 600da6
  double m_pressure;  //!< Pressure of the tablet pen (0.0 - 1.0) , or 1.0 for
shun-iwasawa 600da6
                      //! pure mouse events.
shun-iwasawa 600da6
Shinya Kitaoka 120a6e
  ModifierMask m_modifiersMask;  //!< Bitmask specifying key modifiers applying
Shinya Kitaoka 38fd86
                                 //! on the event.
Toshihiro Shimizu 890ddd
shun_iwasawa 491a52
  Qt::MouseButtons m_buttons;
shun_iwasawa 491a52
  Qt::MouseButton m_button;
shun_iwasawa bc352c
  QPointF m_mousePos;  // mouse position obtained with QMouseEvent::pos() or
shun_iwasawa bc352c
                       // QTabletEvent::pos()
bf1d82
  bool m_isTablet;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TMouseEvent()
shun-iwasawa 600da6
      : m_pressure(1.0)
shun_iwasawa 491a52
      , m_modifiersMask(NO_KEY)
shun_iwasawa 491a52
      , m_buttons(Qt::NoButton)
shun_iwasawa b0e644
      , m_button(Qt::NoButton)
shun_iwasawa b0e644
      , m_isTablet(false) {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool isShiftPressed() const { return (m_modifiersMask & SHIFT_KEY); }
Shinya Kitaoka 120a6e
  bool isAltPressed() const { return (m_modifiersMask & ALT_KEY); }
Shinya Kitaoka 120a6e
  bool isCtrlPressed() const { return (m_modifiersMask & CTRL_KEY); }
shun_iwasawa b0e644
shun_iwasawa 491a52
  bool isLeftButtonPressed() const { return (m_buttons & Qt::LeftButton) != 0; }
shun_iwasawa 491a52
  Qt::MouseButtons buttons() const { return m_buttons; }
shun_iwasawa 491a52
  Qt::MouseButton button() const { return m_button; }
shun_iwasawa bc352c
  QPointF mousePos() const { return m_mousePos; }
bf1d82
  bool isTablet() const { return m_isTablet; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setModifiers(bool shiftPressed, bool altPressed, bool ctrlPressed) {
Shinya Kitaoka 120a6e
    m_modifiersMask = ModifierMask((shiftPressed << SHIFT_BITSHIFT) |
Shinya Kitaoka 120a6e
                                   (altPressed << ALT_BITSHIFT) |
Shinya Kitaoka 120a6e
                                   (ctrlPressed << CTRL_BITSHIFT));
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ModifierMask getModifiersMask() const { return m_modifiersMask; }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//*****************************************************************************************
Toshihiro Shimizu 890ddd
//    TTool  declaration
Toshihiro Shimizu 890ddd
//*****************************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Shinya Kitaoka 120a6e
  \brief    TTool is the abstract base class defining the interface for Toonz
Shinya Kitaoka 120a6e
tools - the ones
Shinya Kitaoka 120a6e
            accessible from the Toolbar panel that users can activate to edit
Shinya Kitaoka 120a6e
the scene contents
Toshihiro Shimizu 890ddd
            interactively.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  \details  Toonz implements a number of interactive tools, like the Brush
Shinya Kitaoka 120a6e
Tool, Fill
Shinya Kitaoka 120a6e
            Tool, Zoom Tool and others. They all inherit from this
Shinya Kitaoka 120a6e
class, which provides
Shinya Kitaoka 120a6e
            the necessary interface and framework to implement a generic
Shinya Kitaoka 120a6e
interactive tool in Toonz.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
            A Toonz Tool should re-implement the following key functionalities:
Toshihiro Shimizu 890ddd
 
    Shinya Kitaoka 120a6e
                  
  • The abstract getToolType() method, which classifies the tool,
  • Shinya Kitaoka 120a6e
    and
    Toshihiro Shimizu 890ddd
                       eventually getTargetType()
    Toshihiro Shimizu 890ddd
                  
  • The draw() method, used to draw the tool on screen
  • Toshihiro Shimizu 890ddd
                  
  • The mouse-related methods, to grant user interaction
  • Shinya Kitaoka 120a6e
                  
  • The getProperties() and onPropertyChanged() methods, to
  • Shinya Kitaoka 120a6e
    define and track
    Toshihiro Shimizu 890ddd
                       a tool's TProperty members
    Shinya Kitaoka 120a6e
                  
  • The addContextMenuItems() method, to insert actions in
  • Shinya Kitaoka 120a6e
    right-click menus
    Toshihiro Shimizu 890ddd
     
    Toshihiro Shimizu 890ddd
                  \par Tool classification
    Shinya Kitaoka 120a6e
                Toonz enforces a strict classification of its tools that is used to
    Shinya Kitaoka 120a6e
    enable or disable them
    Toshihiro Shimizu 890ddd
                in the appropriate contexts:
    Toshihiro Shimizu 890ddd
      Shinya Kitaoka 120a6e
                    
    • Generic Tools: the tool is always enabled, since it
    • Shinya Kitaoka 120a6e
      does not need to access
      Shinya Kitaoka 120a6e
                          specific scene contents. Hidden tools typically prefer to
      Shinya Kitaoka 120a6e
      select this type since they
      Toshihiro Shimizu 890ddd
                          should handle disablements silently.
      Shinya Kitaoka 120a6e
                    
    • Column Tools: the tool is used to alter or define the
    • Shinya Kitaoka 120a6e
      placement of a column's
      Shinya Kitaoka 120a6e
                          content. It is disabled in Filmstrip view mode, since that's
      Shinya Kitaoka 120a6e
      a strictly level-related view.
      Shinya Kitaoka 120a6e
                    
    • LevelRead Tools: the tool is used to \a read a level's
    • Shinya Kitaoka 120a6e
      images data. It is therefore
      Shinya Kitaoka 120a6e
                          enabled on all view modes. The tool is disabled in camera
      Shinya Kitaoka 120a6e
      stand or 3D view modes if the
      Shinya Kitaoka 120a6e
                          level's host column has sustained a placement which makes it
      Shinya Kitaoka 120a6e
      impossible to access image
      Toshihiro Shimizu 890ddd
                          data (as is the case with Plastic-deformed columns).
      Shinya Kitaoka 120a6e
                    
    • LevelWrite Tools: the tool is used to \a write a
    • Shinya Kitaoka 120a6e
      level's images data. It is
      Shinya Kitaoka 120a6e
                          disabled in all contexts where a LevelRead Tool would be
      Shinya Kitaoka 120a6e
      disabled. It is also disabled in
      Shinya Kitaoka 120a6e
                          case the current level is of a type unsupported for write,
      Shinya Kitaoka 120a6e
      \a or the level is read-only
      Toshihiro Shimizu 890ddd
                          on disk.
      Toshihiro Shimizu 890ddd
      Shinya Kitaoka 120a6e
                  Furthermore, tools define a bitwise combination of Target
      Shinya Kitaoka 120a6e
      Types, which are the category
      Shinya Kitaoka 120a6e
                  of level types it can work on (including every image type and the
      Shinya Kitaoka 120a6e
      motion path type).
      Shinya Kitaoka 120a6e
                  The Target Type is used only associated with LevelRead and
      Shinya Kitaoka 120a6e
      LevelWrite tool types.
      Toshihiro Shimizu 890ddd
       \n\n
      Shinya Kitaoka 120a6e
                  There are a number of additional generic rules that define whenever
      Shinya Kitaoka 120a6e
      a tool is disabled:
      Toshihiro Shimizu 890ddd
       
        Toshihiro Shimizu 890ddd
                      
      • Every tool is disabled when a viewer is in playback.
      • Shinya Kitaoka 120a6e
                      
      • Every non-Generic tool is disabled on level/columns that do
      • Shinya Kitaoka 120a6e
        not host a
        Toshihiro Shimizu 890ddd
                           placeable image type (eg sound or magpie data).
        Shinya Kitaoka 120a6e
                      
      • Every non-Generic tool is disabled when working on
      • Shinya Kitaoka 120a6e
        columns/levels that have
        Toshihiro Shimizu 890ddd
                           been hidden.
        Shinya Kitaoka 120a6e
                      
      • Every non-Generic tool is disabled when working on columns
      • Shinya Kitaoka 120a6e
        that have been locked
        Toshihiro Shimizu 890ddd
                           (the lock icon on a column header).
        Toshihiro Shimizu 890ddd
         
        Toshihiro Shimizu 890ddd
                      \par Drawing
        Shinya Kitaoka 120a6e
                    Tools use OpenGL to draw in their currently associated Viewer
        Shinya Kitaoka 120a6e
        instance, which can be retrieved
        Shinya Kitaoka 120a6e
                    through the getViewer() accessor function. The viewer is assigned to
        Shinya Kitaoka 120a6e
        the tool just before it
        Shinya Kitaoka 120a6e
                    invokes the tool's draw() function - use the onSetViewer() virtual
        Shinya Kitaoka 120a6e
        method to access viewer data
        Shinya Kitaoka 120a6e
                    \a before the viewer starts drawing (observe the tool is typically
        Shinya Kitaoka 120a6e
        drawn as an overlay, on top
        Toshihiro Shimizu 890ddd
                    of other stuff).
        Toshihiro Shimizu 890ddd
         \n\n
        Shinya Kitaoka 120a6e
                    Just before draw() is invoked by the viewer, the \p GL_MODELVIEW
        Shinya Kitaoka 120a6e
        matrix is automatically pushed
        Shinya Kitaoka 120a6e
                    by the viewer with the tool-to-window affine returned by getMatrix()
        Shinya Kitaoka 120a6e
        (multiplied by the viewer's
        Shinya Kitaoka 120a6e
                    view affine). Use glGetDoublev() to retrieve the effective
        Shinya Kitaoka 120a6e
        tool-to-window reference change
        Shinya Kitaoka 120a6e
                    affine, and in case reimplement updateMatrix() to specify the affine
        Shinya Kitaoka 120a6e
        returned by getMatrix().
        Toshihiro Shimizu 890ddd
         \n\n
        Shinya Kitaoka 120a6e
                    The default implementation for updateMatrix() sets the tool
        Shinya Kitaoka 120a6e
        reference to current object's
        Toshihiro Shimizu 890ddd
                    world one.
        Toshihiro Shimizu 890ddd
        Toshihiro Shimizu 890ddd
                      \par Tool Properties
        Shinya Kitaoka 120a6e
                    A tool's properties must be implemented by defining one or more
        Shinya Kitaoka 120a6e
        TPropertyGroup containers,
        Shinya Kitaoka 120a6e
                    and adding them the TProperty specializations corresponding to the
        Shinya Kitaoka 120a6e
        required parameters.
        Toshihiro Shimizu 890ddd
         \n\n
        Shinya Kitaoka 120a6e
                    Every TProperty instance in group 0 is automatically added to the
        Shinya Kitaoka 120a6e
        Tool Options panel
        Shinya Kitaoka 120a6e
                    in Toonz's GUI. Further groups or special toolbar options must be
        Shinya Kitaoka 120a6e
        currently hard-coded
        Shinya Kitaoka 120a6e
                    elsewhere. Tool Options panel construction will probably be
        Shinya Kitaoka 120a6e
        redirected to the tool in
        Toshihiro Shimizu 890ddd
                    future Toonz versions.
        Toshihiro Shimizu 890ddd
        Toshihiro Shimizu 890ddd
                      \par Context Menu Items
        Shinya Kitaoka 120a6e
                    The addContextMenuItems() is used to insert context menu actions \a
        Shinya Kitaoka 120a6e
        before the standard
        Shinya Kitaoka 120a6e
                    actions provided by the tool viewer. Remember to insert separators
        Shinya Kitaoka 120a6e
        to isolate commands
        Toshihiro Shimizu 890ddd
                    of different type (such as view, editing, etc).
        Toshihiro Shimizu 890ddd
        */
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
        class DVAPI TTool {
        Toshihiro Shimizu 890ddd
        public:
        Shinya Kitaoka 120a6e
          class Viewer;
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          typedef TApplication Application;
        Toshihiro Shimizu 890ddd
        Toshihiro Shimizu 890ddd
        public:
        Shinya Kitaoka 120a6e
          enum ToolType         //!  Tool editing type.
        Shinya Kitaoka 120a6e
          { GenericTool   = 1,  //!< Tool will not deal with specific scene content.
        Shinya Kitaoka 120a6e
            ColumnTool    = 2,  //!< Tool deals with placement of column objects.
        Shinya Kitaoka 120a6e
            LevelReadTool = 4,  //!< Tool reads a level's image data.
        Shinya Kitaoka 120a6e
            LevelWriteTool =
        Shinya Kitaoka 120a6e
                8,  //!< Tool writes a level's image data (implies LevelReadTool).
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
            // Convenience testing flags - getToolType() should not return these
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
            LevelTool = LevelReadTool | LevelWriteTool };
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          enum ToolTargetType  //!  Object types the tool can operate on.
        Shinya Kitaoka 120a6e
          { NoTarget    = 0x0,
        Shinya Kitaoka 120a6e
            VectorImage = 0x1,   //!< Will work on vector images
        Shinya Kitaoka 120a6e
            ToonzImage  = 0x2,   //!< Will work on colormap (tlv) images
        Shinya Kitaoka 120a6e
            RasterImage = 0x4,   //!< Will work on fullcolor images
        Shinya Kitaoka 120a6e
            MeshImage   = 0x8,   //!< Will work on mesh images
        Shinya Kitaoka 120a6e
            Splines     = 0x10,  //!< Will work on motion paths
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
            LevelColumns = 0x20,  //!< Will work on level columns
        Shinya Kitaoka 120a6e
            MeshColumns  = 0x40,  //!< Will work on mesh columns
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
            EmptyTarget = 0x80,  //!< Will work on empty cells/columns
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
            CommonImages = VectorImage | ToonzImage | RasterImage,
        Shinya Kitaoka 120a6e
            AllImages    = CommonImages | MeshImage,
        Shinya Kitaoka 120a6e
            Vectors      = VectorImage | Splines,
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
            CommonLevels = CommonImages | LevelColumns,
        Shinya Kitaoka 120a6e
            MeshLevels   = MeshImage | MeshColumns,
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
            AllTargets = 0xffffffff,
        Shinya Kitaoka 120a6e
          };
        Toshihiro Shimizu 890ddd
        Toshihiro Shimizu 890ddd
        public:
        Shinya Kitaoka 120a6e
          static TTool *getTool(std::string toolName, ToolTargetType targetType);
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          static TApplication *getApplication();
        Shinya Kitaoka 120a6e
          static void setApplication(TApplication *application) {
        Shinya Kitaoka 120a6e
            m_application = application;
        Shinya Kitaoka 120a6e
          }
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          /*! \warning  In case there is no level currently selected, or the
        Shinya Kitaoka 120a6e
                  object to be edited is a spline path, the xsheet cell
        Shinya Kitaoka 120a6e
                  returned by getImageCell() is empty. */
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          static TXshCell
        Shinya Kitaoka 120a6e
          getImageCell();  //!< Returns the level-frame pair to be edited by the tool.
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          /*! \details  The image returned by getImage() is either the one
        Shinya Kitaoka 120a6e
                  associated to getImageCell(), or the vector image
        Shinya Kitaoka 120a6e
                  corresponding to currently edited spline path. */
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          static TImage *getImage(
        Shinya Kitaoka 120a6e
              bool toBeModified,
        Shinya Kitaoka 120a6e
              int subsampling = 0);  //!< Returns the image to be edited by the tool.
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          static TImage *touchImage();  //!< Returns a pointer to the actual image - the
        Shinya Kitaoka 120a6e
                                        //!  one of the frame that has been selected.
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          /*! \details      This function is necessary since tools are created before
        Shinya Kitaoka 120a6e
        the main
        Shinya Kitaoka 120a6e
                      application (TAB or Toonz) starts, and hence tr() calls have no
        Shinya Kitaoka 120a6e
        effect
        Shinya Kitaoka 120a6e
                      (the translation is not yet installed - to install one you need at
        Shinya Kitaoka 120a6e
        least
        Shinya Kitaoka 120a6e
                      an instance of QApplication / QCoreApplication).
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
        \deprecated   This so much stinks of a bug turned into design choice... */
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          static void updateToolsPropertiesTranslation();  //!< Updates translation of
        Shinya Kitaoka 38fd86
                                                           //! the bound properties of
        Shinya Kitaoka 120a6e
          //!  every tool (invoking updateTranslation() for each).
        Toshihiro Shimizu 890ddd
        Toshihiro Shimizu 890ddd
        public:
        Shinya Kitaoka 120a6e
          TTool(std::string toolName);
        Shinya Kitaoka 120a6e
          virtual ~TTool() {}
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          virtual ToolType getToolType() const = 0;
        Shinya Kitaoka 120a6e
          ToolTargetType getTargetType() const { return (ToolTargetType)m_targetType; }
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          std::string getName() const { return m_name; }
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          /*! \details  The default returns a generic box containing the options
        Shinya Kitaoka 120a6e
                  for property group 0).
        Shinya Kitaoka 120a6e
        \sa       See tooloptions.h for more details. */
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          virtual ToolOptionsBox *
        Shinya Kitaoka 120a6e
          createOptionsBox();  //!< Factory function returning a newly created
        Shinya Kitaoka 120a6e
                               //!  GUI options box to be displayed for the tool
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          void setViewer(Viewer *viewer) {
        Shinya Kitaoka 120a6e
            m_viewer = viewer;
        Shinya Kitaoka 120a6e
            onSetViewer();
        Shinya Kitaoka 120a6e
          }
        Shinya Kitaoka 120a6e
          Viewer *getViewer() const { return m_viewer; }
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          double getPixelSize() const;
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          //! Causes the refreshing of the \b rect portion of the viewer.
        Shinya Kitaoka 120a6e
          //! If rect is empty all viewer is refreshed. \b rect must be in image
        Shinya Kitaoka 120a6e
          //! coordinate.
        Shinya Kitaoka 120a6e
          void invalidate(const TRectD &rect = TRectD());
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          /*!
        Shinya Kitaoka 120a6e
                  Picks a region of the scene, using an OpenGL projection matrix to
        Shinya Kitaoka 120a6e
                  restrict drawing to a small regionaround \p p of the viewport.
        Shinya Kitaoka 120a6e
                  Retuns -1 if no object's view has been changed.
        Shinya Kitaoka 120a6e
          */
        shun_iwasawa bc352c
          int pick(const TPointD &p);
        Shinya Kitaoka 120a6e
          bool isPicking() const { return m_picking; }
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          virtual void updateTranslation(){};
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          /*!
        Shinya Kitaoka 120a6e
        This method is called before leftButtonDown() and can be used e.g. to create the
        Shinya Kitaoka 120a6e
        image if needed.
        Shinya Kitaoka 120a6e
        return true if the method execution can have changed the current tool
        Shinya Kitaoka 120a6e
        */
        Shinya Kitaoka 120a6e
          virtual bool preLeftButtonDown() { return false; }
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          virtual void mouseMove(const TPointD &, const TMouseEvent &) {}
        Shinya Kitaoka 120a6e
          virtual void leftButtonDown(const TPointD &, const TMouseEvent &) {}
        Shinya Kitaoka 120a6e
          virtual void leftButtonDrag(const TPointD &, const TMouseEvent &) {}
        Shinya Kitaoka 120a6e
          virtual void leftButtonUp(const TPointD &, const TMouseEvent &) {}
        Shinya Kitaoka 120a6e
          virtual void leftButtonDoubleClick(const TPointD &, const TMouseEvent &) {}
        Shinya Kitaoka 120a6e
          virtual void rightButtonDown(const TPointD &, const TMouseEvent &) {}
        shun-iwasawa 7f1e30
          virtual bool keyDown(QKeyEvent *) { return false; }
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          virtual void onInputText(std::wstring, std::wstring, int, int){};
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          virtual void onSetViewer() {}
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          virtual void onActivate() {
        Shinya Kitaoka 120a6e
          }  //!< Callback invoked whenever the tool activates.
        Shinya Kitaoka 120a6e
          virtual void onDeactivate() {
        Shinya Kitaoka 120a6e
          }  //!< Callback for tool deactivation, includes tool switch.
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          virtual void onImageChanged() {}  //!< Notifies changes in the image in use.
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          virtual void onEnter() {
        Shinya Kitaoka 120a6e
          }  //!< Callback for the mouse entering the viewer area.
        Shinya Kitaoka 120a6e
          virtual void onLeave() {
        Shinya Kitaoka 120a6e
          }  //!< Callback for the mouse leaving the viewer area.
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          /*-- rasterSelectionTool
        Shinya Kitaoka 120a6e
           * のフローティング選択が残った状態でフレームが移動したときの挙動を決める --*/
        Shinya Kitaoka 120a6e
          virtual void onFrameSwitched() {}
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          virtual void reset() {}
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          virtual void draw() {}  //!< Draws the tool on the viewer.
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          bool isActive() const {
        Shinya Kitaoka 120a6e
            return m_active;
        Shinya Kitaoka 120a6e
          }  //!< Used to know if a tool is active, (used in TextTool only).
        Shinya Kitaoka 120a6e
          void setActive(bool active) { m_active = active; }
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          virtual TPropertyGroup *getProperties(int) { return 0; }
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          /*!
        Shinya Kitaoka 120a6e
                  Does the tasks associated to changes in \p propertyName and returns \p
        Shinya Kitaoka 120a6e
             true;
        Toshihiro Shimizu 890ddd
          */
        Shinya Kitaoka 120a6e
          virtual bool onPropertyChanged(std::string propertyName) {
        Shinya Kitaoka 120a6e
            return false;
        Shinya Kitaoka 120a6e
          }  //!< Does the tasks associated to changes in \p propertyName and
        Shinya Kitaoka 120a6e
             //!  returns \p true.
        Shinya Kitaoka 120a6e
          virtual TSelection *getSelection() {
        Shinya Kitaoka 120a6e
            return 0;
        Shinya Kitaoka 120a6e
          }  //!< Returns a pointer to the tool selection.
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          //! \sa    For a list of cursor ids cursor.h
        Shinya Kitaoka 120a6e
          virtual int getCursorId() const {
        Shinya Kitaoka 120a6e
            return 0;
        Shinya Kitaoka 120a6e
          }  //!< Returns the type of cursor used by the tool.
        Shinya Kitaoka 120a6e
        shun_iwasawa d51821
          // returns true if the pressed key is recognized and processed.
        shun_iwasawa d51821
          // used in SceneViewer::event(), reimplemented in SelectionTool
        shun_iwasawa d51821
          // and ControlPointEditorTool
        shun_iwasawa d51821
          virtual bool isEventAcceptable(QEvent *e) { return false; }
        shun_iwasawa d51821
        Shinya Kitaoka 120a6e
          TXsheet *getXsheet() const;  //!< Returns a pointer to the actual Xsheet.
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          int getFrame();        //!< Returns the actual frame in use.
        Shinya Kitaoka 120a6e
          int getColumnIndex();  //!< Returns the actual column index.
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          TStageObjectId
        Shinya Kitaoka 120a6e
          getObjectId();  //!< Returns a pointer to the actual stage object.
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          void notifyImageChanged();  //!< Notifies changes on the actual image; used to
        Shinya Kitaoka 38fd86
                                      //! update
        Shinya Kitaoka 38fd86
          //!  images on the level view.
        Shinya Kitaoka 120a6e
          void notifyImageChanged(const TFrameId &fid);  //!< Notifies changes on the
        Shinya Kitaoka 38fd86
          //! frame \p fid; used to update
        Shinya Kitaoka 38fd86
          //!  images on the level view.
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          /*! \details   It can depend on the actual frame and the actual cell or
        Shinya Kitaoka 120a6e
                    on the current fid (editing level). In editing scene if
        Shinya Kitaoka 120a6e
                    the current cell is empty the method returns TFrameId::NO_FRAME. */
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          TFrameId getCurrentFid()
        Shinya Kitaoka 120a6e
              const;  //!< Returns the number of the actual editing frame.
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          const TAffine &getMatrix() const { return m_matrix; }
        Shinya Kitaoka 120a6e
          void setMatrix(const TAffine &matrix) { m_matrix = matrix; }
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          TAffine getCurrentColumnMatrix()
        Shinya Kitaoka 120a6e
              const;  //!< Returns the current column matrix transformation.
        Shinya Kitaoka 120a6e
                      //!  \sa  TXsheet::getPlacement.
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          TAffine getCurrentColumnParentMatrix()
        Shinya Kitaoka 120a6e
              const;  //!< Returns the current matrix transformation of the
        Shinya Kitaoka 120a6e
                      //!  current stage object parent.
        Shinya Kitaoka 120a6e
          TAffine getCurrentObjectParentMatrix() const;
        Shinya Kitaoka 120a6e
          TAffine getCurrentObjectParentMatrix2() const;
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          /*!
        Shinya Kitaoka 120a6e
                  Returns the matrix transformation of the stage object with column
        Shinya Kitaoka 120a6e
          index equal to \p index
        Shinya Kitaoka 120a6e
                  and frame as the current frame.
        Shinya Kitaoka 120a6e
          \sa TXsheet::getPlacement.
        Toshihiro Shimizu 890ddd
          */
        Shinya Kitaoka 120a6e
          TAffine getColumnMatrix(int index) const;
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          /*!
        Shinya Kitaoka 120a6e
           Updates the current matrix transformation with the actual column matrix
        Shinya Kitaoka 120a6e
        transformation.
        Shinya Kitaoka 120a6e
        \sa getCurrentColumnMatrix().
        Shinya Kitaoka 120a6e
        */
        Shinya Kitaoka 120a6e
          virtual void updateMatrix();
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          /*!
        Shinya Kitaoka 120a6e
           Add a context menu to the actual tool, as for example pressing right mouse
        Shinya Kitaoka 120a6e
           button
        Shinya Kitaoka 120a6e
           with the stroke selection tool.
        Shinya Kitaoka 120a6e
        */
        Shinya Kitaoka 120a6e
          virtual void addContextMenuItems(QMenu *menu) {}
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          void enable(bool on) { m_enabled = on; }
        Shinya Kitaoka 120a6e
          bool isEnabled() const { return m_enabled; }
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          QString updateEnabled();  //!< Sets the tool's \a enability and returns a
        Shinya Kitaoka 120a6e
                                    //!  reason in case the tool was disabled.
        Shinya Kitaoka 120a6e
          bool isColumnLocked(int columnIndex) const;
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          void resetInputMethod();  //!< Resets Input Context (IME)
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          // return true if the pencil mode is active in the Brush / PaintBrush / Eraser
        Shinya Kitaoka 120a6e
          // Tools.
        Shinya Kitaoka 120a6e
          virtual bool isPencilModeActive() { return false; }
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          void setSelectedFrames(const std::set<tframeid> &selectedFrames);</tframeid>
        Shinya Kitaoka 120a6e
          static const std::set<tframeid> &getSelectedFrames() {</tframeid>
        Shinya Kitaoka 120a6e
            return m_selectedFrames;
        Shinya Kitaoka 120a6e
          }
        Toshihiro Shimizu 890ddd
        Toshihiro Shimizu 890ddd
        public:
        Shinya Kitaoka 120a6e
          static std::vector<int> m_cellsData;  //!< \deprecated  brutto brutto. fix</int>
        Shinya Kitaoka 38fd86
                                                //! quick & dirty del baco #6213 (undo
        Shinya Kitaoka 38fd86
          //! con animation sheet) spiegazioni in
        Shinya Kitaoka 38fd86
          //! tool.cpp
        Shinya Kitaoka 120a6e
          static bool m_isLevelCreated;  //!< \deprecated  Shouldn't expose global
        Shinya Kitaoka 38fd86
                                         //! static variables.
        Shinya Kitaoka 120a6e
          static bool m_isFrameCreated;  //!< \deprecated  Shouldn't expose global
        Shinya Kitaoka 38fd86
                                         //! static variables.
        Toshihiro Shimizu 890ddd
        Toshihiro Shimizu 890ddd
        protected:
        Shinya Kitaoka 120a6e
          std::string m_name;  //!< The tool's name.
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          Viewer *m_viewer;  //!< Tool's current viewer.
        Shinya Kitaoka 120a6e
          TAffine m_matrix;  //!< World-to-window reference change affine.
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          int m_targetType;  //!< The tool's image type target.
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          bool m_enabled;  //!< Whether the tool allows user interaction.
        Shinya Kitaoka 120a6e
          bool m_active;
        Shinya Kitaoka 120a6e
          bool m_picking;
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          static TApplication *m_application;
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          static std::set<tframeid> m_selectedFrames;</tframeid>
        Toshihiro Shimizu 890ddd
        Toshihiro Shimizu 890ddd
        protected:
        Shinya Kitaoka 120a6e
          void bind(int targetType);
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          virtual void onSelectedFramesChanged() {}
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
          virtual QString disableString() {
        Shinya Kitaoka 120a6e
            return QString();
        Shinya Kitaoka 120a6e
          }  //!< Returns a custom reason to disable the tool
        Toshihiro Shimizu 890ddd
        };
        Toshihiro Shimizu 890ddd
        Toshihiro Shimizu 890ddd
        //*****************************************************************************************
        Toshihiro Shimizu 890ddd
        //    TTool::Viewer  declaration
        Toshihiro Shimizu 890ddd
        //*****************************************************************************************
        Toshihiro Shimizu 890ddd
        Toshihiro Shimizu 890ddd
        /*!
        Shinya Kitaoka 120a6e
          \brief    The TTool::Viewer class is the abstract base class that provides an
        Shinya Kitaoka 120a6e
          interface for
        Shinya Kitaoka 120a6e
                    TTool viewer widgets (it is required that such widgets support
        Shinya Kitaoka 120a6e
          OpenGL).
        Toshihiro Shimizu 890ddd
        */
        Toshihiro Shimizu 890ddd
        Shinya Kitaoka 120a6e
        class TTool::Viewer {
        Toshihiro Shimizu 890ddd
        protected:
        Shinya Kitaoka 120a6e
          ImagePainter::VisualSettings
        Shinya Kitaoka 120a6e
              m_visualSettings;  //!< Settings used by the Viewer to draw scene contents
        Toshihiro Shimizu 890ddd
        Toshihiro Shimizu 890ddd
        public:
        Shinya Kitaoka 120a6e
          Viewer() {}
        Shinya Kitaoka 120a6e
          virtual ~Viewer() {}
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          const ImagePainter::VisualSettings &visualSettings() const {
        Shinya Kitaoka 120a6e
            return m_visualSettings;
        Shinya Kitaoka 120a6e
          }
        Shinya Kitaoka 120a6e
          ImagePainter::VisualSettings &visualSettings() { return m_visualSettings; }
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          virtual double getPixelSize()
        Shinya Kitaoka 120a6e
              const = 0;  //!< Returns the length of a pixel in current OpenGL
        Shinya Kitaoka 120a6e
                          //!< coordinates
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          virtual void invalidateAll() = 0;    //!< Redraws the entire viewer, passing
        Shinya Kitaoka 38fd86
                                               //! through Qt's event system
        Shinya Kitaoka 120a6e
          virtual void GLInvalidateAll() = 0;  //!< Redraws the entire viewer, bypassing
        Shinya Kitaoka 38fd86
                                               //! Qt's event system
        Shinya Kitaoka 120a6e
          virtual void GLInvalidateRect(const TRectD &rect) = 0;  //!< Same as
        Shinya Kitaoka 38fd86
                                                                  //! GLInvalidateAll(),
        Shinya Kitaoka 38fd86
          //! for a specific
        Shinya Kitaoka 38fd86
          //! clipping rect
        Shinya Kitaoka 120a6e
          virtual void invalidateToolStatus() = 0;  //!< Forces the viewer to update the
        Shinya Kitaoka 38fd86
                                                    //! perceived status of tools
        Shinya Kitaoka 120a6e
          virtual TAffine getViewMatrix() const {
        Shinya Kitaoka 120a6e
            return TAffine();
        Shinya Kitaoka 120a6e
          }  //!< Gets the viewer's current view affine (ie the transform from
        Shinya Kitaoka 120a6e
             //!<  starting to current  world view <\I>)
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          //! return the column index of the drawing intersecting point \b p
        Shinya Kitaoka 120a6e
          //! (window coordinate, pixels, bottom-left origin)
        shun_iwasawa bc352c
          virtual int posToColumnIndex(const TPointD &p, double distance,
        Shinya Kitaoka 120a6e
                                       bool includeInvisible = true) const = 0;
        shun_iwasawa bc352c
          virtual void posToColumnIndexes(const TPointD &p, std::vector<int> &indexes,</int>
        Shinya Kitaoka 120a6e
                                          double distance,
        Shinya Kitaoka 120a6e
                                          bool includeInvisible = true) const = 0;
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          //! return the row of the drawing intersecting point \b p (used with
        Shinya Kitaoka 120a6e
          //! onionskins)
        Shinya Kitaoka 120a6e
          //! (window coordinate, pixels, bottom-left origin)
        shun_iwasawa bc352c
          virtual int posToRow(const TPointD &p, double distance,
        shun-iwasawa 1d5937
                               bool includeInvisible  = true,
        shun-iwasawa 1d5937
                               bool currentColumnOnly = false) const = 0;
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          //! return pos in pixel, bottom-left origin
        shun_iwasawa bc352c
          virtual TPointD worldToPos(const TPointD &worldPos) const = 0;
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          //! return the OpenGL nameId of the object intersecting point \b p
        Shinya Kitaoka 120a6e
          //! (window coordinate, pixels, bottom-left origin)
        shun_iwasawa bc352c
          virtual int pick(const TPointD &point) = 0;
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          // note: winPos in pixel, top-left origin;
        Shinya Kitaoka 120a6e
          // when no camera movements have been defined then worldPos = 0 at camera
        Shinya Kitaoka 120a6e
          // center
        shun_iwasawa bc352c
          virtual TPointD winToWorld(const TPointD &winPos) const = 0;
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          // delta.x: right panning, pixels; delta.y: down panning, pixels
        shun_iwasawa bc352c
          virtual void pan(const TPointD &delta) = 0;
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          // center: window coordinates, pixels, bottomleft origin
        Shinya Kitaoka 120a6e
          virtual void zoom(const TPointD ¢er, double scaleFactor) = 0;
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          virtual void rotate(const TPointD ¢er, double angle) = 0;
        Shinya Kitaoka 120a6e
          virtual void rotate3D(double dPhi, double dTheta)        = 0;
        Jeremy Bullock 628337
          virtual bool is3DView() const      = 0;
        Jeremy Bullock 628337
          virtual bool getIsFlippedX() const = 0;
        Jeremy Bullock 628337
          virtual bool getIsFlippedY() const = 0;
        Shinya Kitaoka 120a6e
        shun_iwasawa bc352c
          virtual double projectToZ(const TPointD &delta) = 0;
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          virtual TPointD getDpiScale() const = 0;
        Jeremy Bullock cd00fd
          virtual int getVGuideCount()        = 0;
        Jeremy Bullock cd00fd
          virtual int getHGuideCount()        = 0;
        Jeremy Bullock cd00fd
          virtual double getHGuide(int index) = 0;
        Jeremy Bullock cd00fd
          virtual double getVGuide(int index) = 0;
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          virtual void
        Shinya Kitaoka 120a6e
          resetInputMethod() = 0;  // Intended to call QWidget->resetInputContext()
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          virtual void setFocus() = 0;
        Shinya Kitaoka 120a6e
        Shinya Kitaoka 120a6e
          /*-- Toolで画面の内外を判断するため --*/
        Shinya Kitaoka 120a6e
          virtual TRectD getGeometry() const = 0;
        Shinya Kitaoka 120a6e
        shun-iwasawa ad7711
          virtual void bindFBO() {}
        shun-iwasawa ad7711
          virtual void releaseFBO() {}
        Toshihiro Shimizu 890ddd
        };
        Toshihiro Shimizu 890ddd
        Toshihiro Shimizu 890ddd
        #endif