|
Toshihiro Shimizu |
890ddd |
|
|
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 |
using namespace std;
|
|
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 |
|
|
Toshihiro Shimizu |
890ddd |
namespace ToolUtils
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
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 |
|
|
Toshihiro Shimizu |
890ddd |
// inserito per rendere piu' piccolo il numero di punti delle stroke 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 |
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI drawRect(const TRectD &rect, const TPixel32 &color, 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 |
|
|
Toshihiro Shimizu |
890ddd |
//! Divide il primo rettangolo in piu' sottorettsngoli, in base all'intersezione 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 |
|
|
Toshihiro Shimizu |
890ddd |
//! Return a transparent TRaster32P conteaining the self looped stroke fileed with white!
|
|
Toshihiro Shimizu |
890ddd |
//! If the stroke isn't self looped, the first point of the stroke is addee at the end.
|
|
Toshihiro Shimizu |
890ddd |
//! The returned image has the size of the stroke bounding box intrsected with the \b imageBounds.
|
|
Toshihiro Shimizu |
890ddd |
//! If this intersection is empty a TRaster32P() is returned.
|
|
Toshihiro Shimizu |
890ddd |
TRaster32P convertStrokeToImage(TStroke *stroke, const TRect &imageBounds, TPoint &pos);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void drawBalloon(
|
|
Toshihiro Shimizu |
890ddd |
const TPointD &pos, // position "pointed" by the balloon (world units)
|
|
Toshihiro Shimizu |
890ddd |
std::string text, // balloon text
|
|
Toshihiro Shimizu |
890ddd |
const TPixel32 &color, // ballon background color (text is black)
|
|
Toshihiro Shimizu |
890ddd |
TPoint delta, // text position (pixels; pos is the origin; y grows upward)
|
|
Toshihiro Shimizu |
890ddd |
bool isPicking = false,
|
|
Toshihiro Shimizu |
890ddd |
std::vector<trectd> *otherBalloons = 0); // avoid other balloons positions; add the new ballons positions</trectd>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
enum HookType { NormalHook,
|
|
Toshihiro Shimizu |
890ddd |
PassHookA,
|
|
Toshihiro Shimizu |
890ddd |
PassHookB,
|
|
Toshihiro Shimizu |
890ddd |
OtherLevelHook };
|
|
Toshihiro Shimizu |
890ddd |
void drawHook(
|
|
Toshihiro Shimizu |
890ddd |
const TPointD &p,
|
|
Toshihiro Shimizu |
890ddd |
HookType type,
|
|
Toshihiro Shimizu |
890ddd |
bool highlighted = false,
|
|
Toshihiro Shimizu |
890ddd |
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 |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TToolUndo : public TUndo
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
TXshSimpleLevelP m_level;
|
|
Toshihiro Shimizu |
890ddd |
TFrameId m_frameId;
|
|
Toshihiro Shimizu |
890ddd |
int m_row, m_col;
|
|
Toshihiro Shimizu |
890ddd |
bool m_isEditingLevel;
|
|
Toshihiro Shimizu |
890ddd |
bool m_createdFrame;
|
|
Toshihiro Shimizu |
890ddd |
bool m_createdLevel;
|
|
Toshihiro Shimizu |
890ddd |
bool m_animationSheetEnabled;
|
|
Toshihiro Shimizu |
890ddd |
std::vector<int> m_cellsData; // represent original frame range when m_animationSheetEnabled, m_createdFrame and !m_isEditingLevel; see tool.cpp</int>
|
|
Toshihiro Shimizu |
890ddd |
TPaletteP m_oldPalette;
|
|
Toshihiro Shimizu |
890ddd |
string m_imageId;
|
|
Toshihiro Shimizu |
890ddd |
static int m_idCount;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void insertLevelAndFrameIfNeeded() const;
|
|
Toshihiro Shimizu |
890ddd |
void removeLevelAndFrameIfNeeded() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void notifyImageChanged() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TToolUndo(TXshSimpleLevel *level, const TFrameId &frameId,
|
|
Toshihiro Shimizu |
890ddd |
bool createdFrame = false, bool createdLevel = false, const TPaletteP &oldPalette = 0);
|
|
Toshihiro Shimizu |
890ddd |
~TToolUndo();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
virtual QString getToolName()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return QString("Tool");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
virtual QString getHistoryString()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return QObject::tr("%1 Level : %2 Frame : %3")
|
|
Toshihiro Shimizu |
890ddd |
.arg(getToolName())
|
|
Toshihiro Shimizu |
890ddd |
.arg(QString::fromStdWString(m_level->getName()))
|
|
Toshihiro Shimizu |
890ddd |
.arg(QString::number(m_frameId.getNumber()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//================================================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TRasterUndo : public TToolUndo
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
TTileSetCM32 *m_tiles;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TToonzImageP getImage() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TRasterUndo(TTileSetCM32 *tiles, TXshSimpleLevel *level, const TFrameId &frameId,
|
|
Toshihiro Shimizu |
890ddd |
bool createdFrame, bool createdLevel, const TPaletteP &oldPalette); //get tiles ownership
|
|
Toshihiro Shimizu |
890ddd |
~TRasterUndo();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int getSize() const;
|
|
Toshihiro Shimizu |
890ddd |
void undo() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
virtual QString getToolName()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return QString("Raster Tool");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//================================================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI TFullColorRasterUndo : public TToolUndo
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
TTileSetFullColor *m_tiles;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRasterImageP getImage() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
TFullColorRasterUndo(TTileSetFullColor *tiles, TXshSimpleLevel *level, const TFrameId &frameId,
|
|
Toshihiro Shimizu |
890ddd |
bool createdFrame, bool createdLevel, const TPaletteP &oldPalette); //get tiles ownership
|
|
Toshihiro Shimizu |
890ddd |
~TFullColorRasterUndo();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int getSize() const;
|
|
Toshihiro Shimizu |
890ddd |
void undo() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Toshihiro Shimizu |
890ddd |
vector<trect> paste(const TRasterImageP &ti, const TTileSetFullColor *tileSet) const;</trect>
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class UndoModifyStroke : public TToolUndo
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
vector<tthickpoint> m_before, m_after;</tthickpoint>
|
|
Toshihiro Shimizu |
890ddd |
bool m_selfLoopBefore, m_selfLoopAfter;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int m_row;
|
|
Toshihiro Shimizu |
890ddd |
int m_column;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
int m_strokeIndex;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
UndoModifyStroke(TXshSimpleLevel *level, const TFrameId &frameId, int strokeIndex);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
~UndoModifyStroke();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void onAdd();
|
|
Toshihiro Shimizu |
890ddd |
void undo() const;
|
|
Toshihiro Shimizu |
890ddd |
void redo() const;
|
|
Toshihiro Shimizu |
890ddd |
int getSize() const;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class UndoModifyStrokeAndPaint : public UndoModifyStroke
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
vector<tfilledregioninf> *m_fillInformation;</tfilledregioninf>
|
|
Toshihiro Shimizu |
890ddd |
TRectD m_oldBBox;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
UndoModifyStrokeAndPaint(TXshSimpleLevel *level, const TFrameId &frameId, int strokeIndex);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
~UndoModifyStrokeAndPaint();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void onAdd();
|
|
Toshihiro Shimizu |
890ddd |
void undo() const;
|
|
Toshihiro Shimizu |
890ddd |
int getSize() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString getToolName()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return QObject::tr("Modify Stroke Tool");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class UndoModifyListStroke : public TToolUndo
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
list<undomodifystroke *=""> m_strokeList;</undomodifystroke>
|
|
Toshihiro Shimizu |
890ddd |
list<undomodifystroke *="">::iterator m_beginIt, m_endIt;</undomodifystroke>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
vector<tfilledregioninf> *m_fillInformation;</tfilledregioninf>
|
|
Toshihiro Shimizu |
890ddd |
TRectD m_oldBBox;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
UndoModifyListStroke(TXshSimpleLevel *level, const TFrameId &frameId, const std::vector<tstroke *=""> &strokeList);</tstroke>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
~UndoModifyListStroke();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void onAdd();
|
|
Toshihiro Shimizu |
890ddd |
void undo() const;
|
|
Toshihiro Shimizu |
890ddd |
void redo() const;
|
|
Toshihiro Shimizu |
890ddd |
int getSize() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString getToolName()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return QObject::tr("Modify Stroke Tool");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class UndoPencil : public TToolUndo
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int m_strokeId;
|
|
Toshihiro Shimizu |
890ddd |
TStroke *m_stroke;
|
|
Toshihiro Shimizu |
890ddd |
vector<tfilledregioninf> *m_fillInformation;</tfilledregioninf>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool m_autogroup;
|
|
Toshihiro Shimizu |
890ddd |
bool m_autofill;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
UndoPencil(TStroke *stroke, vector<tfilledregioninf> *fillInformation, TXshSimpleLevel *level,</tfilledregioninf>
|
|
Toshihiro Shimizu |
890ddd |
const TFrameId &frameId, bool m_createdFrame, bool m_createdLevel,
|
|
Toshihiro Shimizu |
890ddd |
bool autogroup = false, bool autofill = false);
|
|
Toshihiro Shimizu |
890ddd |
~UndoPencil();
|
|
Toshihiro Shimizu |
890ddd |
void undo() const;
|
|
Toshihiro Shimizu |
890ddd |
void redo() const;
|
|
Toshihiro Shimizu |
890ddd |
int getSize() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString getToolName()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return QString("Vector Brush Tool");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
int getHistoryType()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return HistoryType::BrushTool;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*-- Hardness=100 又は Pencilモード のときのGeometricToolのUndo --*/
|
|
Toshihiro Shimizu |
890ddd |
class UndoRasterPencil : public TRasterUndo
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
TStroke *m_stroke;
|
|
Toshihiro Shimizu |
890ddd |
bool m_selective, m_filled, m_doAntialias;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*-- HistoryにPrimitive名を表示するため --*/
|
|
Toshihiro Shimizu |
890ddd |
string m_primitiveName;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
UndoRasterPencil(TXshSimpleLevel *level, const TFrameId &frameId, TStroke *stroke,
|
|
Toshihiro Shimizu |
890ddd |
bool selective, bool filled, bool doAntialias, bool createdFrame, bool createdLevel,
|
|
Toshihiro Shimizu |
890ddd |
string primitiveName);
|
|
Toshihiro Shimizu |
890ddd |
~UndoRasterPencil();
|
|
Toshihiro Shimizu |
890ddd |
virtual void redo() const;
|
|
Toshihiro Shimizu |
890ddd |
int getSize() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString getToolName()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return QString("Geometric Tool : %1").arg(QString::fromStdString(m_primitiveName));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
int getHistoryType()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return HistoryType::GeometricTool;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class UndoFullColorPencil : public TFullColorRasterUndo
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
TStroke *m_stroke;
|
|
Toshihiro Shimizu |
890ddd |
double m_opacity;
|
|
Toshihiro Shimizu |
890ddd |
bool m_doAntialias;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
UndoFullColorPencil(TXshSimpleLevel *level, const TFrameId &frameId, TStroke *stroke, double opacity,
|
|
Toshihiro Shimizu |
890ddd |
bool doAntialias, bool createdFrame, bool createdLevel);
|
|
Toshihiro Shimizu |
890ddd |
~UndoFullColorPencil();
|
|
Toshihiro Shimizu |
890ddd |
virtual void redo() const;
|
|
Toshihiro Shimizu |
890ddd |
int getSize() const;
|
|
Toshihiro Shimizu |
890ddd |
QString getToolName()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return QString("Geometric Tool");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
int getHistoryType()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return HistoryType::GeometricTool;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
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 |
//
|
|
Toshihiro Shimizu |
890ddd |
class UndoPath : public TUndo
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TStageObjectSpline *m_spline;
|
|
Toshihiro Shimizu |
890ddd |
vector<tthickpoint> m_before, m_after;</tthickpoint>
|
|
Toshihiro Shimizu |
890ddd |
bool m_selfLoopBefore;
|
|
Toshihiro Shimizu |
890ddd |
//TStroke *m_before;
|
|
Toshihiro Shimizu |
890ddd |
//TStroke *m_after;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
UndoPath(TStageObjectSpline *spline);
|
|
Toshihiro Shimizu |
890ddd |
~UndoPath();
|
|
Toshihiro Shimizu |
890ddd |
void onAdd();
|
|
Toshihiro Shimizu |
890ddd |
void undo() const;
|
|
Toshihiro Shimizu |
890ddd |
void redo() const;
|
|
Toshihiro Shimizu |
890ddd |
int getSize() const;
|
|
Toshihiro Shimizu |
890ddd |
QString getHistoryString()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return QObject::tr("Modify Spline");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
int getHistoryType()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return HistoryType::ControlPointEditorTool;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// UndoControlPointEditor
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
class UndoControlPointEditor : public TToolUndo
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::pair<int, *="" vistroke=""> m_oldStroke;</int,>
|
|
Toshihiro Shimizu |
890ddd |
std::pair<int, *="" vistroke=""> m_newStroke;</int,>
|
|
Toshihiro Shimizu |
890ddd |
bool m_isStrokeDelete;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int m_row;
|
|
Toshihiro Shimizu |
890ddd |
int m_column;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
UndoControlPointEditor(TXshSimpleLevel *level, const TFrameId &frameId);
|
|
Toshihiro Shimizu |
890ddd |
~UndoControlPointEditor();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void onAdd();
|
|
Toshihiro Shimizu |
890ddd |
void addOldStroke(int index, VIStroke *vs);
|
|
Toshihiro Shimizu |
890ddd |
void addNewStroke(int index, VIStroke *vs);
|
|
Toshihiro Shimizu |
890ddd |
void isStrokeDelete(bool isStrokeDelete) { m_isStrokeDelete = isStrokeDelete; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void undo() const;
|
|
Toshihiro Shimizu |
890ddd |
void redo() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int getSize() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return sizeof(*this) + /*(m_oldFillInformation.capacity()+m_newFillInformation.capacity())*sizeof(TFilledRegionInf) +*/ 500;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
virtual QString getToolName()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return QString("Control Point Editor");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
int getHistoryType()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return HistoryType::ControlPointEditorTool;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// DragMenu
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DragMenu : public QMenu
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
DragMenu();
|
|
Toshihiro Shimizu |
890ddd |
QAction *exec(const QPoint &p, QAction *action = 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
void mouseReleaseEvent(QMouseEvent *e);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// ChooseColumnMenu
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class ColumChooserMenu : public DragMenu
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
ColumChooserMenu(TXsheet *xsh, const std::vector<int> &columnIndexes);</int>
|
|
Toshihiro Shimizu |
890ddd |
int execute();
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class ConeSubVolume
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
const static double m_values[21];
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
ConeSubVolume()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//calcola il sottovolume di un cono di raggio e volume unitario in base
|
|
Toshihiro Shimizu |
890ddd |
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 |
/*
|
|
Toshihiro Shimizu |
890ddd |
The following functions set the specified (or current) level frame as edited (ie to be saved),
|
|
Toshihiro Shimizu |
890ddd |
and, in the colormap case, update the associated savebox.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
The 'Minimize Savebox after Editing' preference is used to determine if the 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);
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI updateSaveBox(const TXshSimpleLevelP &sl, const TFrameId &fid, TImageP img);
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI updateSaveBox();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool DVAPI isJustCreatedSpline(TImage *image);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRectD DVAPI interpolateRect(const TRectD &rect1, const TRectD &rect2, double t);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//bool DVAPI isASubRegion(int reg, const vector<tregion*> ®ions);</tregion*>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!Returns a TRectD that contains all points in \b points
|
|
Toshihiro Shimizu |
890ddd |
//!If \b maxThickness is not zero, the TRectD is computed using this value.
|
|
Toshihiro Shimizu |
890ddd |
TRectD DVAPI getBounds(const vector<tthickpoint> &points, double maxThickness = 0);</tthickpoint>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!Ritorna un raster uguale a quello dato ma ruotato di 90 gradi
|
|
Toshihiro Shimizu |
890ddd |
//!Il parametro toRight indica se si sta ruotando a destra o a sinistra!
|
|
Toshihiro Shimizu |
890ddd |
template <typename pixel=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
TRasterPT<pixel> rotate90(const TRasterPT<pixel> &ras, bool toRight)</pixel></pixel>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!ras)
|
|
Toshihiro Shimizu |
890ddd |
return TRasterPT<pixel>(0);</pixel>
|
|
Toshihiro Shimizu |
890ddd |
int lx = ras->getLy();
|
|
Toshihiro Shimizu |
890ddd |
int ly = ras->getLx();
|
|
Toshihiro Shimizu |
890ddd |
TRasterPT<pixel> workRas(lx, ly);</pixel>
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < ras->getLx(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
for (int j = 0; j < ras->getLy(); j++) {
|
|
Toshihiro Shimizu |
890ddd |
if (toRight)
|
|
Toshihiro Shimizu |
890ddd |
workRas->pixels(ly - 1 - i)[j] = ras->pixels(j)[i];
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
workRas->pixels(i)[lx - 1 - j] = ras->pixels(j)[i];
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return workRas;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} // namespace ToolUtils
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif // TOOLSUTILS_H
|