Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TOOLSUTILS_H
Toshihiro Shimizu 890ddd
#define TOOLSUTILS_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzCore includes
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
#include "tundo.h"
Toshihiro Shimizu 890ddd
#include "tvectorimage.h"
Toshihiro Shimizu 890ddd
#include "ttoonzimage.h"
Toshihiro Shimizu 890ddd
#include "trasterimage.h"
Toshihiro Shimizu 890ddd
#include "tregion.h"
Toshihiro Shimizu 890ddd
#include "tcurves.h"
Toshihiro Shimizu 890ddd
#include "tpixel.h"
Toshihiro Shimizu 890ddd
#include "tfilepath.h"
Toshihiro Shimizu 890ddd
#include "tpalette.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzLib includes
Toshihiro Shimizu 890ddd
#include "toonz/txshsimplelevel.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzTools includes
Toshihiro Shimizu 890ddd
#include "tools/tool.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "historytypes.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Qt includes
Toshihiro Shimizu 890ddd
#include <qstring></qstring>
Toshihiro Shimizu 890ddd
#include <qmenu></qmenu>
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 TVectorImageP;
Toshihiro Shimizu 890ddd
class TTileSetCM32;
Toshihiro Shimizu 890ddd
class TTileSetFullColor;
Toshihiro Shimizu 890ddd
class TStageObjectSpline;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//===================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//*****************************************************************************
Toshihiro Shimizu 890ddd
//    Mixed Tool utilities
Toshihiro Shimizu 890ddd
//*****************************************************************************
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace ToolUtils {
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
typedef std::vector<tstroke *=""> ArrayOfStroke;</tstroke>
Toshihiro Shimizu 890ddd
typedef ArrayOfStroke::const_iterator citAS;
Toshihiro Shimizu 890ddd
typedef ArrayOfStroke::iterator itAS;
Toshihiro Shimizu 890ddd
typedef std::vector<tthickquadratic *=""> ArrayOfTQ;</tthickquadratic>
Toshihiro Shimizu 890ddd
typedef std::vector<double> ArrayOfDouble;</double>
Toshihiro Shimizu 890ddd
typedef ArrayOfTQ::iterator itATQ;
Toshihiro Shimizu 890ddd
typedef ArrayOfTQ::const_iterator citATQ;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
// inserito per rendere piu' piccolo il numero di punti delle stroke
Shinya Kitaoka 120a6e
// ricampionate
Toshihiro Shimizu 890ddd
const double ReduceControlPointCorrection = 2.0;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// controlla la dimensione del raggio di pick sotto la quale click and up
Toshihiro Shimizu 890ddd
//  risulta insesibile
Toshihiro Shimizu 890ddd
const double PickRadius = 1.5;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void DVAPI drawRect(const TRectD &rect, const TPixel32 &color,
Shinya Kitaoka 120a6e
                    unsigned short stipple, bool doContrast = false);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DVAPI fillRect(const TRectD &rect, const TPixel32 &color);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void drawPoint(const TPointD &q, double pixelSize);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void drawCross(const TPointD &q, double pixelSize);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void drawArrow(const TSegment &s, double pixelSize);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DVAPI drawSquare(const TPointD &pos, double r, const TPixel32 &color);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void drawRectWhitArrow(const TPointD &pos, double r);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
QRadialGradient getBrushPad(int size, double hardness);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
//! Divide il primo rettangolo in piu' sottorettsngoli, in base all'intersezione
Shinya Kitaoka 120a6e
//! con il secondo
Toshihiro Shimizu 890ddd
QList<trect> splitRect(const TRect &first, const TRect &second);</trect>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
//! Return a transparent TRaster32P conteaining the self looped stroke fileed
Shinya Kitaoka 120a6e
//! with white!
Shinya Kitaoka 120a6e
//! If the stroke isn't self looped, the first point of the stroke is addee at
Shinya Kitaoka 120a6e
//! the end.
Shinya Kitaoka 120a6e
//! The returned image has the size of the stroke bounding box intrsected with
Shinya Kitaoka 120a6e
//! the \b imageBounds.
Toshihiro Shimizu 890ddd
//! If this intersection is empty a TRaster32P() is returned.
Shinya Kitaoka 120a6e
TRaster32P convertStrokeToImage(TStroke *stroke, const TRect &imageBounds,
Shinya Kitaoka 120a6e
                                TPoint &pos);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void drawBalloon(
Shinya Kitaoka 120a6e
    const TPointD &pos,     // position "pointed" by the balloon (world units)
Shinya Kitaoka 120a6e
    std::string text,       // balloon text
Shinya Kitaoka 120a6e
    const TPixel32 &color,  // ballon background color (text is black)
Shinya Kitaoka 120a6e
    TPoint delta,  // text position (pixels; pos is the origin; y grows upward)
shun_iwasawa 1fbdc9
    double pixelSize, bool isPicking = false,
Shinya Kitaoka 120a6e
    std::vector<trectd> *otherBalloons =</trectd>
Shinya Kitaoka 120a6e
        0);  // avoid other balloons positions; add the new ballons positions
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
enum HookType { NormalHook, PassHookA, PassHookB, OtherLevelHook };
Shinya Kitaoka 120a6e
void drawHook(const TPointD &p, HookType type, bool highlighted = false,
Shinya Kitaoka 120a6e
              bool onionSkin = false);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TStroke *merge(const ArrayOfStroke &a);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//================================================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI TToolUndo : public TUndo {
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  TXshSimpleLevelP m_level;
Shinya Kitaoka 120a6e
  TFrameId m_frameId;
Shinya Kitaoka 120a6e
  int m_row, m_col;
Shinya Kitaoka 120a6e
  bool m_isEditingLevel;
Shinya Kitaoka 120a6e
  bool m_createdFrame;
Shinya Kitaoka 120a6e
  bool m_createdLevel;
Shinya Kitaoka 120a6e
  bool m_animationSheetEnabled;
Shinya Kitaoka 120a6e
  std::vector<int> m_cellsData;  // represent original frame range when</int>
Shinya Kitaoka 120a6e
                                 // m_animationSheetEnabled, m_createdFrame and
Shinya Kitaoka 120a6e
                                 // !m_isEditingLevel; see tool.cpp
Shinya Kitaoka 120a6e
  TPaletteP m_oldPalette;
Shinya Kitaoka 120a6e
  std::string m_imageId;
Shinya Kitaoka 120a6e
  static int m_idCount;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void insertLevelAndFrameIfNeeded() const;
Shinya Kitaoka 120a6e
  void removeLevelAndFrameIfNeeded() const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void notifyImageChanged() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TToolUndo(TXshSimpleLevel *level, const TFrameId &frameId,
Shinya Kitaoka 120a6e
            bool createdFrame = false, bool createdLevel = false,
Shinya Kitaoka 120a6e
            const TPaletteP &oldPalette = 0);
Shinya Kitaoka 120a6e
  ~TToolUndo();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  virtual QString getToolName() { return QString("Tool"); }
Shinya Kitaoka 473e70
Shinya Kitaoka 473e70
  QString getHistoryString() override {
Shinya Kitaoka 120a6e
    return QObject::tr("%1   Level : %2  Frame : %3")
Shinya Kitaoka 120a6e
        .arg(getToolName())
Shinya Kitaoka 120a6e
        .arg(QString::fromStdWString(m_level->getName()))
Shinya Kitaoka 120a6e
        .arg(QString::number(m_frameId.getNumber()));
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//================================================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI TRasterUndo : public TToolUndo {
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  TTileSetCM32 *m_tiles;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TToonzImageP getImage() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TRasterUndo(TTileSetCM32 *tiles, TXshSimpleLevel *level,
Shinya Kitaoka 120a6e
              const TFrameId &frameId, bool createdFrame, bool createdLevel,
Shinya Kitaoka 120a6e
              const TPaletteP &oldPalette);  // get tiles ownership
Shinya Kitaoka 120a6e
  ~TRasterUndo();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  int getSize() const override;
Shinya Kitaoka 473e70
  void undo() const override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  QString getToolName() override { return QString("Raster Tool"); }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//================================================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI TFullColorRasterUndo : public TToolUndo {
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  TTileSetFullColor *m_tiles;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TRasterImageP getImage() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TFullColorRasterUndo(TTileSetFullColor *tiles, TXshSimpleLevel *level,
Shinya Kitaoka 120a6e
                       const TFrameId &frameId, bool createdFrame,
Shinya Kitaoka 120a6e
                       bool createdLevel,
Shinya Kitaoka 120a6e
                       const TPaletteP &oldPalette);  // get tiles ownership
Shinya Kitaoka 120a6e
  ~TFullColorRasterUndo();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  int getSize() const override;
Shinya Kitaoka 473e70
  void undo() const override;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  std::vector<trect> paste(const TRasterImageP &ti,</trect>
Shinya Kitaoka 120a6e
                           const TTileSetFullColor *tileSet) const;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class UndoModifyStroke : public TToolUndo {
Shinya Kitaoka 120a6e
  std::vector<tthickpoint> m_before, m_after;</tthickpoint>
Shinya Kitaoka 120a6e
  bool m_selfLoopBefore, m_selfLoopAfter;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int m_row;
Shinya Kitaoka 120a6e
  int m_column;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  int m_strokeIndex;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  UndoModifyStroke(TXshSimpleLevel *level, const TFrameId &frameId,
Shinya Kitaoka 120a6e
                   int strokeIndex);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ~UndoModifyStroke();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void onAdd() override;
Shinya Kitaoka 473e70
  void undo() const override;
Shinya Kitaoka 473e70
  void redo() const override;
Shinya Kitaoka 473e70
  int getSize() const override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class UndoModifyStrokeAndPaint final : public UndoModifyStroke {
Shinya Kitaoka 120a6e
  std::vector<tfilledregioninf> *m_fillInformation;</tfilledregioninf>
Shinya Kitaoka 120a6e
  TRectD m_oldBBox;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  UndoModifyStrokeAndPaint(TXshSimpleLevel *level, const TFrameId &frameId,
Shinya Kitaoka 120a6e
                           int strokeIndex);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ~UndoModifyStrokeAndPaint();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void onAdd() override;
Shinya Kitaoka 473e70
  void undo() const override;
Shinya Kitaoka 473e70
  int getSize() const override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  QString getToolName() override { return QObject::tr("Modify Stroke Tool"); }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class UndoModifyListStroke final : public TToolUndo {
Shinya Kitaoka 120a6e
  std::list<undomodifystroke *=""> m_strokeList;</undomodifystroke>
Shinya Kitaoka 120a6e
  std::list<undomodifystroke *="">::iterator m_beginIt, m_endIt;</undomodifystroke>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  std::vector<tfilledregioninf> *m_fillInformation;</tfilledregioninf>
Shinya Kitaoka 120a6e
  TRectD m_oldBBox;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  UndoModifyListStroke(TXshSimpleLevel *level, const TFrameId &frameId,
Shinya Kitaoka 120a6e
                       const std::vector<tstroke *=""> &strokeList);</tstroke>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ~UndoModifyListStroke();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void onAdd() override;
Shinya Kitaoka 473e70
  void undo() const override;
Shinya Kitaoka 473e70
  void redo() const override;
Shinya Kitaoka 473e70
  int getSize() const override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  QString getToolName() override { return QObject::tr("Modify Stroke Tool"); }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class UndoPencil final : public TToolUndo {
Shinya Kitaoka 120a6e
  int m_strokeId;
Shinya Kitaoka 120a6e
  TStroke *m_stroke;
Shinya Kitaoka 120a6e
  std::vector<tfilledregioninf> *m_fillInformation;</tfilledregioninf>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool m_autogroup;
Shinya Kitaoka 120a6e
  bool m_autofill;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  UndoPencil(TStroke *stroke, std::vector<tfilledregioninf> *fillInformation,</tfilledregioninf>
Shinya Kitaoka 120a6e
             TXshSimpleLevel *level, const TFrameId &frameId,
Shinya Kitaoka 120a6e
             bool m_createdFrame, bool m_createdLevel, bool autogroup = false,
Shinya Kitaoka 120a6e
             bool autofill = false);
Shinya Kitaoka 120a6e
  ~UndoPencil();
Shinya Kitaoka 473e70
  void undo() const override;
Shinya Kitaoka 473e70
  void redo() const override;
Shinya Kitaoka 473e70
  int getSize() const override;
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  QString getToolName() override { return QString("Vector Brush Tool"); }
Shinya Kitaoka 473e70
  int getHistoryType() override { return HistoryType::BrushTool; }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
/*--  Hardness=100 又は Pencilモード のときのGeometricToolのUndo --*/
Shinya Kitaoka 120a6e
class UndoRasterPencil : public TRasterUndo {
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  TStroke *m_stroke;
Shinya Kitaoka 120a6e
  bool m_selective, m_filled, m_doAntialias;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*-- HistoryにPrimitive名を表示するため --*/
Shinya Kitaoka 120a6e
  std::string m_primitiveName;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  UndoRasterPencil(TXshSimpleLevel *level, const TFrameId &frameId,
Shinya Kitaoka 120a6e
                   TStroke *stroke, bool selective, bool filled,
Shinya Kitaoka 120a6e
                   bool doAntialias, bool createdFrame, bool createdLevel,
Shinya Kitaoka 120a6e
                   std::string primitiveName);
Shinya Kitaoka 120a6e
  ~UndoRasterPencil();
Shinya Kitaoka 473e70
  void redo() const override;
Shinya Kitaoka 473e70
  int getSize() const override;
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  QString getToolName() override {
Shinya Kitaoka 120a6e
    return QString("Geometric Tool : %1")
Shinya Kitaoka 120a6e
        .arg(QString::fromStdString(m_primitiveName));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 473e70
  int getHistoryType() override { return HistoryType::GeometricTool; }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class UndoFullColorPencil : public TFullColorRasterUndo {
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  TStroke *m_stroke;
Shinya Kitaoka 120a6e
  double m_opacity;
Shinya Kitaoka 120a6e
  bool m_doAntialias;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  UndoFullColorPencil(TXshSimpleLevel *level, const TFrameId &frameId,
Shinya Kitaoka 120a6e
                      TStroke *stroke, double opacity, bool doAntialias,
Shinya Kitaoka 120a6e
                      bool createdFrame, bool createdLevel);
Shinya Kitaoka 120a6e
  ~UndoFullColorPencil();
Shinya Kitaoka 473e70
  void redo() const override;
Shinya Kitaoka 473e70
  int getSize() const override;
Shinya Kitaoka 473e70
  QString getToolName() override { return QString("Geometric Tool"); }
Shinya Kitaoka 473e70
  int getHistoryType() override { return HistoryType::GeometricTool; }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// undo class (path strokes). call it BEFORE and register it AFTER path change
Toshihiro Shimizu 890ddd
//
Shinya Kitaoka d1f6c4
class UndoPath final : public TUndo {
Shinya Kitaoka 120a6e
  TStageObjectSpline *m_spline;
Shinya Kitaoka 120a6e
  std::vector<tthickpoint> m_before, m_after;</tthickpoint>
Shinya Kitaoka 120a6e
  bool m_selfLoopBefore;
Shinya Kitaoka 120a6e
  // TStroke *m_before;
Shinya Kitaoka 120a6e
  // TStroke *m_after;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  UndoPath(TStageObjectSpline *spline);
Shinya Kitaoka 120a6e
  ~UndoPath();
Shinya Kitaoka 473e70
  void onAdd() override;
Shinya Kitaoka 473e70
  void undo() const override;
Shinya Kitaoka 473e70
  void redo() const override;
Shinya Kitaoka 473e70
  int getSize() const override;
Shinya Kitaoka 473e70
  QString getHistoryString() override { return QObject::tr("Modify Spline"); }
Shinya Kitaoka 473e70
  int getHistoryType() override { return HistoryType::ControlPointEditorTool; }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// UndoControlPointEditor
Toshihiro Shimizu 890ddd
//
Shinya Kitaoka d1f6c4
class UndoControlPointEditor final : public TToolUndo {
Shinya Kitaoka 120a6e
  std::pair<int, *="" vistroke=""> m_oldStroke;</int,>
Shinya Kitaoka 120a6e
  std::pair<int, *="" vistroke=""> m_newStroke;</int,>
Shinya Kitaoka 120a6e
  bool m_isStrokeDelete;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int m_row;
Shinya Kitaoka 120a6e
  int m_column;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  UndoControlPointEditor(TXshSimpleLevel *level, const TFrameId &frameId);
Shinya Kitaoka 120a6e
  ~UndoControlPointEditor();
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void onAdd() override;
Shinya Kitaoka 120a6e
  void addOldStroke(int index, VIStroke *vs);
Shinya Kitaoka 120a6e
  void addNewStroke(int index, VIStroke *vs);
Shinya Kitaoka 120a6e
  void isStrokeDelete(bool isStrokeDelete) {
Shinya Kitaoka 120a6e
    m_isStrokeDelete = isStrokeDelete;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void undo() const override;
Shinya Kitaoka 473e70
  void redo() const override;
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  int getSize() const override {
Shinya Kitaoka 120a6e
    return sizeof(*this) +
Shinya Kitaoka 38fd86
           /*(m_oldFillInformation.capacity()+m_newFillInformation.capacity())*sizeof(TFilledRegionInf)
Shinya Kitaoka 38fd86
              +*/
Shinya Kitaoka 120a6e
           500;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 473e70
Shinya Kitaoka 473e70
  QString getToolName() override { return QString("Control Point Editor"); }
Shinya Kitaoka 473e70
  int getHistoryType() override { return HistoryType::ControlPointEditorTool; }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// DragMenu
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DragMenu : public QMenu {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  DragMenu();
Shinya Kitaoka 120a6e
  QAction *exec(const QPoint &p, QAction *action = 0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 473e70
  void mouseReleaseEvent(QMouseEvent *e) override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// ChooseColumnMenu
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class ColumChooserMenu final : public DragMenu {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ColumChooserMenu(TXsheet *xsh, const std::vector<int> &columnIndexes);</int>
Shinya Kitaoka 120a6e
  int execute();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class ConeSubVolume {
Shinya Kitaoka 120a6e
  const static double m_values[21];
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ConeSubVolume() {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // calcola il sottovolume di un cono di raggio e volume unitario in base
Shinya Kitaoka 120a6e
  static double compute(double cover);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//! Return the right value in both case: LevelFrame and SceneFrame.
Toshihiro Shimizu 890ddd
TFrameId DVAPI getFrameId();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*
Shinya Kitaoka 120a6e
    The following functions set the specified (or current) level frame as edited
Shinya Kitaoka 120a6e
   (ie to be saved),
Toshihiro Shimizu 890ddd
    and, in the colormap case, update the associated savebox.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    The 'Minimize Savebox after Editing' preference is used to determine if the
Shinya Kitaoka 120a6e
   savebox has to be
Toshihiro Shimizu 890ddd
    shrunk to the image's bounding box or include the previous savebox.
Toshihiro Shimizu 890ddd
  */
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DVAPI updateSaveBox(const TXshSimpleLevelP &sl, const TFrameId &fid);
Shinya Kitaoka 120a6e
void DVAPI updateSaveBox(const TXshSimpleLevelP &sl, const TFrameId &fid,
Shinya Kitaoka 120a6e
                         TImageP img);
Toshihiro Shimizu 890ddd
void DVAPI updateSaveBox();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
bool DVAPI isJustCreatedSpline(TImage *image);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TRectD DVAPI interpolateRect(const TRectD &rect1, const TRectD &rect2,
Shinya Kitaoka 120a6e
                             double t);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
// bool DVAPI isASubRegion(int reg, const vector<tregion*> ®ions);</tregion*>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
//! Returns a TRectD that contains all points in \b points
Shinya Kitaoka 120a6e
//! If \b maxThickness is not zero, the TRectD is computed using this value.
Shinya Kitaoka 120a6e
TRectD DVAPI getBounds(const std::vector<tthickpoint> &points,</tthickpoint>
Shinya Kitaoka 120a6e
                       double maxThickness = 0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
//! Ritorna un raster uguale a quello dato ma ruotato di 90 gradi
Shinya Kitaoka 120a6e
//! Il parametro toRight indica se si sta ruotando a destra o a sinistra!
Toshihiro Shimizu 890ddd
template <typename pixel=""></typename>
Shinya Kitaoka 120a6e
TRasterPT<pixel> rotate90(const TRasterPT<pixel> &ras, bool toRight) {</pixel></pixel>
Shinya Kitaoka 120a6e
  if (!ras) return TRasterPT<pixel>(0);</pixel>
Shinya Kitaoka 120a6e
  int lx = ras->getLy();
Shinya Kitaoka 120a6e
  int ly = ras->getLx();
Shinya Kitaoka 120a6e
  TRasterPT<pixel> workRas(lx, ly);</pixel>
Shinya Kitaoka 120a6e
  for (int i = 0; i < ras->getLx(); i++) {
Shinya Kitaoka 120a6e
    for (int j = 0; j < ras->getLy(); j++) {
Shinya Kitaoka 120a6e
      if (toRight)
Shinya Kitaoka 120a6e
        workRas->pixels(ly - 1 - i)[j] = ras->pixels(j)[i];
Shinya Kitaoka 120a6e
      else
Shinya Kitaoka 120a6e
        workRas->pixels(i)[lx - 1 - j] = ras->pixels(j)[i];
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  return workRas;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
}  // namespace ToolUtils
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // TOOLSUTILS_H