Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef STROKEDEFORMATION_IMPL_H
Toshihiro Shimizu 890ddd
#define STROKEDEFORMATION_IMPL_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/**
Toshihiro Shimizu 890ddd
 * @author  Fabrizio Morciano <fabrizio.morciano@gmail.com></fabrizio.morciano@gmail.com>
Toshihiro Shimizu 890ddd
 */
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "ext/StrokeDeformation.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TNZEXT_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
#include "ExtUtil.h"
Toshihiro Shimizu 890ddd
e280ae
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
Toshihiro Shimizu 890ddd
// to avoid annoying warning
Toshihiro Shimizu 890ddd
#pragma warning(push)
Toshihiro Shimizu 890ddd
#pragma warning(disable : 4251)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace ToonzExt {
Shinya Kitaoka 120a6e
class DVAPI StrokeDeformationImpl {
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  bool init(const ContextStatus *);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool computeStroke2Transform(const ContextStatus *s,
Shinya Kitaoka 120a6e
                               TStroke *&stroke2transform, double &w,
Shinya Kitaoka 120a6e
                               ToonzExt::Interval &extremes);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ToonzExt::Potential *potential_;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  static TStroke
Shinya Kitaoka 120a6e
      *copyOfLastSelectedStroke_;  // deep copy stroke selected previously
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int cursorId_;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  TStroke *stroke2manipulate_;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  static TStroke *&getLastSelectedStroke();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  static void setLastSelectedStroke(TStroke *);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  static int &getLastSelectedDegree();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  static void setLastSelectedDegree(int degree);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  static ToonzExt::Intervals &getSpiresList();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  static ToonzExt::Intervals &getStraightsList();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ToonzExt::StrokeParametricDeformer *deformer_;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int shortcutKey_;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  double old_w0_;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TPointD old_w0_pos_;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // ref to simplify access
Shinya Kitaoka 120a6e
  std::vector<tstroke *=""> strokes_;</tstroke>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  StrokeDeformationImpl();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
* Is this the correct deformation?
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  virtual bool check_(const ContextStatus *) = 0;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
* Retrieve the nearest extremes to point selected.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  virtual bool findExtremes_(const ContextStatus *, Interval &) = 0;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual double findActionLength() = 0;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  virtual ~StrokeDeformationImpl();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  ToonzExt::Interval getExtremes();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  static const ContextStatus *&getImplStatus();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  const TStroke *getStrokeSelected() const {
Shinya Kitaoka 120a6e
    if (getImplStatus()) return this->getImplStatus()->stroke2change_;
Shinya Kitaoka 120a6e
    return 0;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  const TStroke *getCopiedStroke() const { return this->getStrokeSelected(); }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*Wrapper for activate.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  virtual bool activate_impl(const ContextStatus *);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
* Modify stroke.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  virtual void update_impl(const TPointD &delta);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
* Reduce control points and change stroke.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  virtual TStroke *deactivate_impl();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool check(const ContextStatus *);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
* Restore last good status.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  virtual void reset();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setPotential(Potential *);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /**
Shinya Kitaoka 120a6e
*Apply a designer on current deformation.
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  virtual void draw(Designer *);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TStroke *getTransformedStroke();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  ToonzExt::Potential *getPotential();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TPointD &oldW0();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int getShortcutKey() const { return shortcutKey_; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int getCursorId() const { return cursorId_; }
Shinya Kitaoka 120a6e
  void setCursorId(int id) { cursorId_ = id; }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
e280ae
#if defined(_MSC_VER) && (_MSC_VER <= 1200)
Toshihiro Shimizu 890ddd
#pragma warning(pop)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif /* STROKEDEFORMATION_IMPL_H */
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
//  End Of File
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------