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