tahoma2d/toonz/sources/include/ext/StrokeParametricDeformer.h

141 lines
3.6 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef STROKE_PARAMETRIC_DEFORMER_H
#define STROKE_PARAMETRIC_DEFORMER_H
/**
* @author Fabrizio Morciano <fabrizio.morciano@gmail.com>
*/
#include "tcommon.h"
#include "tstrokedeformations.h"
#undef DVAPI
#undef DVVAR
#ifdef TNZEXT_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
2016-04-15 17:11:23 +12:00
#if defined(_WIN32) && (_MSC_VER <= 1200)
2016-03-19 06:57:51 +13:00
// to avoid annoying warning
#pragma warning(push)
#pragma warning(disable : 4290)
#endif
class TStroke;
2016-06-15 18:43:10 +12:00
namespace ToonzExt {
2016-03-19 06:57:51 +13:00
class Potential;
/**
* @brief This class implements new deformer.
2016-06-15 18:43:10 +12:00
*
2016-03-19 06:57:51 +13:00
* New stroke deformer doesn't change last point of stroke.
*/
class DVAPI StrokeParametricDeformer final : public TStrokeDeformation {
2016-03-19 06:57:51 +13:00
public:
2016-09-06 01:20:21 +12:00
StrokeParametricDeformer(double actionLength, double startParameter,
2016-06-15 18:43:10 +12:00
TStroke *s, Potential *);
~StrokeParametricDeformer();
/**
*@brief Set mouse movement from last valid position.
*@param vx horyzontal
*@param vy vertical
*/
void setMouseMove(double vx, double vy);
/**
*@brief Return displacement to use with function increaseControlPoints
*@param stroke to test
*@param w stroke parameter
*@return displacement to apply to obtain deformation
*@sa increaseControlPoints
*/
2016-06-19 20:06:29 +12:00
TThickPoint getDisplacement(const TStroke &stroke, double w) const override;
2016-06-15 18:43:10 +12:00
/**
*@brief Return displacement to use with function modifyControlPoints
*@param stroke to test
*@param n control point to get
*@return displacement to apply to obtain deformation
*@sa modifyControlPoints
*/
TThickPoint getDisplacementForControlPoint(const TStroke &stroke,
2016-06-19 20:06:29 +12:00
UINT n) const override;
2016-06-15 18:43:10 +12:00
TThickPoint getDisplacementForControlPointLen(const TStroke &stroke,
2016-06-19 20:06:29 +12:00
double cpLen) const override;
2016-06-15 18:43:10 +12:00
/**
*@brief This method compute the delta (gradient) referred to stroke in
* at parameter w.
*
* This value is the result of \f$ \frac{getDisplacement(stroke,w)}{dw} \f$.
*@note Sometimes this value can be approximated.
*@param stroke Stroke to test
*@param w Stroke parameter
*@return the @b gradient in w
*/
2016-06-19 20:06:29 +12:00
double getDelta(const TStroke &stroke, double w) const override;
2016-06-15 18:43:10 +12:00
/**
*@brief Max diff of delta (This value indicates when it's necessary
* to insert control point)
*@return max displacement permitted
*/
2016-06-19 20:06:29 +12:00
double getMaxDiff() const override;
2016-06-15 18:43:10 +12:00
// just for debug
const Potential *getPotential() const { return pot_; }
/**
2016-06-29 22:49:17 +12:00
*@brief Change sensitivity of deformer (just for debug).
2016-06-15 18:43:10 +12:00
*/
void setDiff(double diff) { diff_ = diff; }
/**
*@brief Retrieve the parameters range where is applied deformation.
*/
void getRange(double &from, double &to);
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
StrokeParametricDeformer(const StrokeParametricDeformer &);
StrokeParametricDeformer &operator=(const StrokeParametricDeformer &);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// mouse incremental movement
double vx_, vy_;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// parameter where is applicated action
double startParameter_;
2016-03-19 06:57:51 +13:00
2016-09-06 01:20:21 +12:00
// like startParameter_ but recover length
double startLength_;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// how many traits move
2016-09-06 01:20:21 +12:00
double actionLength_;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// deformation shape
Potential *pot_;
2016-03-19 06:57:51 +13:00
2016-06-29 22:49:17 +12:00
// sensitivity of deformer
2016-06-15 18:43:10 +12:00
// Indica il valore minimo a partire dal quale
// l'inseritore comincia a mettere punti di controllo
double diff_;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TStroke *ref_copy_;
2016-03-19 06:57:51 +13:00
};
}
2016-04-15 17:11:23 +12:00
#if defined(_WIN32) && (_MSC_VER <= 1200)
2016-03-19 06:57:51 +13:00
#pragma warning(pop)
#endif
#endif /* STROKE_PARAMETRIC_DEFORMER_H */
//-----------------------------------------------------------------------------
// End Of File
//-----------------------------------------------------------------------------