1 #pragma once 2 3 #ifndef STROKE_PARAMETRIC_DEFORMER_H 4 #define STROKE_PARAMETRIC_DEFORMER_H 5 6 /** 7 * @author Fabrizio Morciano <fabrizio.morciano@gmail.com> 8 */ 9 10 #include "tcommon.h" 11 #include "tstrokedeformations.h" 12 13 #undef DVAPI 14 #undef DVVAR 15 #ifdef TNZEXT_EXPORTS 16 #define DVAPI DV_EXPORT_API 17 #define DVVAR DV_EXPORT_VAR 18 #else 19 #define DVAPI DV_IMPORT_API 20 #define DVVAR DV_IMPORT_VAR 21 #endif 22 23 #if defined(_MSC_VER) && (_MSC_VER <= 1200) 24 // to avoid annoying warning 25 #pragma warning(push) 26 #pragma warning(disable : 4290) 27 #endif 28 29 class TStroke; 30 31 namespace ToonzExt { 32 class Potential; 33 /** 34 * @brief This class implements new deformer. 35 * 36 * New stroke deformer doesn't change last point of stroke. 37 */ 38 class DVAPI StrokeParametricDeformer final : public TStrokeDeformation { 39 public: 40 StrokeParametricDeformer(double actionLength, double startParameter, 41 TStroke *s, Potential *); 42 43 ~StrokeParametricDeformer(); 44 45 /** 46 *@brief Set mouse movement from last valid position. 47 *@param vx horyzontal 48 *@param vy vertical 49 */ 50 void setMouseMove(double vx, double vy); 51 52 /** 53 *@brief Return displacement to use with function increaseControlPoints 54 *@param stroke to test 55 *@param w stroke parameter 56 *@return displacement to apply to obtain deformation 57 *@sa increaseControlPoints 58 */ 59 TThickPoint getDisplacement(const TStroke &stroke, double w) const override; 60 61 /** 62 *@brief Return displacement to use with function modifyControlPoints 63 *@param stroke to test 64 *@param n control point to get 65 *@return displacement to apply to obtain deformation 66 *@sa modifyControlPoints 67 */ 68 TThickPoint getDisplacementForControlPoint(const TStroke &stroke, 69 UINT n) const override; 70 TThickPoint getDisplacementForControlPointLen(const TStroke &stroke, 71 double cpLen) const override; 72 73 /** 74 *@brief This method compute the delta (gradient) referred to stroke in 75 * at parameter w. 76 * 77 * This value is the result of \f$ \frac{getDisplacement(stroke,w)}{dw} \f$. 78 *@note Sometimes this value can be approximated. 79 *@param stroke Stroke to test 80 *@param w Stroke parameter 81 *@return the @b gradient in w 82 */ 83 double getDelta(const TStroke &stroke, double w) const override; 84 85 /** 86 *@brief Max diff of delta (This value indicates when it's necessary 87 * to insert control point) 88 *@return max displacement permitted 89 */ 90 double getMaxDiff() const override; 91 92 // just for debug getPotential()93 const Potential *getPotential() const { return pot_; } 94 95 /** 96 *@brief Change sensitivity of deformer (just for debug). 97 */ setDiff(double diff)98 void setDiff(double diff) { diff_ = diff; } 99 100 /** 101 *@brief Retrieve the parameters range where is applied deformation. 102 */ 103 void getRange(double &from, double &to); 104 105 private: 106 StrokeParametricDeformer(const StrokeParametricDeformer &); 107 StrokeParametricDeformer &operator=(const StrokeParametricDeformer &); 108 109 // mouse incremental movement 110 double vx_, vy_; 111 112 // parameter where is applicated action 113 double startParameter_; 114 115 // like startParameter_ but recover length 116 double startLength_; 117 118 // how many traits move 119 double actionLength_; 120 121 // deformation shape 122 Potential *pot_; 123 124 // sensitivity of deformer 125 // Indica il valore minimo a partire dal quale 126 // l'inseritore comincia a mettere punti di controllo 127 double diff_; 128 129 TStroke *ref_copy_; 130 }; 131 } 132 133 #if defined(_MSC_VER) && (_MSC_VER <= 1200) 134 #pragma warning(pop) 135 #endif 136 137 #endif /* STROKE_PARAMETRIC_DEFORMER_H */ 138 //----------------------------------------------------------------------------- 139 // End Of File 140 //----------------------------------------------------------------------------- 141