Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tools/tool.h"
Toshihiro Shimizu 890ddd
#include "tools/cursors.h"
Toshihiro Shimizu 890ddd
#include "tproperty.h"
Toshihiro Shimizu 890ddd
#include "toonz/stageobjectutil.h"
Toshihiro Shimizu 890ddd
#include "tstroke.h"
Toshihiro Shimizu 890ddd
#include "tgl.h"
Toshihiro Shimizu 890ddd
#include "tenv.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonz/tstageobjecttree.h"
Toshihiro Shimizu 890ddd
#include "toonz/tstageobjectspline.h"
Toshihiro Shimizu 890ddd
#include "toonz/toonzscene.h"
Toshihiro Shimizu 890ddd
#include "toonz/txshcolumn.h"
Toshihiro Shimizu 890ddd
#include "toonz/stage.h"
Toshihiro Shimizu 890ddd
#include "toonz/tcamera.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tools/toolhandle.h"
Toshihiro Shimizu 890ddd
#include "toonz/tcolumnhandle.h"
Toshihiro Shimizu 890ddd
#include "toonz/tframehandle.h"
Toshihiro Shimizu 890ddd
#include "toonz/tobjecthandle.h"
Toshihiro Shimizu 890ddd
#include "toonz/txsheethandle.h"
Toshihiro Shimizu 890ddd
#include "toonz/tscenehandle.h"
Toshihiro Shimizu 890ddd
#include "toonz/tfxhandle.h"
Toshihiro Shimizu 890ddd
#include "toonz/tstageobjectcmd.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "edittoolgadgets.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// For Qt translation support
Toshihiro Shimizu 890ddd
#include <qcoreapplication></qcoreapplication>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <qdebug></qdebug>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// Scale Constraints
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace ScaleConstraints {
Shinya Kitaoka 120a6e
enum { None = 0, AspectRatio, Mass };
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TEnv::IntVar LockCenterX("EditToolLockCenterX", 0);
Toshihiro Shimizu 890ddd
TEnv::IntVar LockCenterY("EditToolLockCenterY", 0);
Toshihiro Shimizu 890ddd
TEnv::IntVar LockPositionX("EditToolLockPositionX", 0);
Toshihiro Shimizu 890ddd
TEnv::IntVar LockPositionY("EditToolLockPositionY", 0);
Toshihiro Shimizu 890ddd
TEnv::IntVar LockRotation("EditToolLockRotation", 0);
Toshihiro Shimizu 890ddd
TEnv::IntVar LockShearH("EditToolLockShearH", 0);
Toshihiro Shimizu 890ddd
TEnv::IntVar LockShearV("EditToolLockShearV", 0);
Toshihiro Shimizu 890ddd
TEnv::IntVar LockScaleH("EditToolLockScaleH", 0);
Toshihiro Shimizu 890ddd
TEnv::IntVar LockScaleV("EditToolLockScaleV", 0);
Toshihiro Shimizu 890ddd
TEnv::IntVar LockGlobalScale("EditToolLockGlobalScale", 0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TEnv::IntVar ShowEWNSposition("EditToolShowEWNSposition", 1);
Toshihiro Shimizu 890ddd
TEnv::IntVar ShowZposition("EditToolShowZposition", 1);
Toshihiro Shimizu 890ddd
TEnv::IntVar ShowSOposition("EditToolShowSOposition", 1);
Toshihiro Shimizu 890ddd
TEnv::IntVar ShowRotation("EditToolShowRotation", 1);
Toshihiro Shimizu 890ddd
TEnv::IntVar ShowGlobalScale("EditToolShowGlobalScale", 1);
Toshihiro Shimizu 890ddd
TEnv::IntVar ShowHVscale("EditToolShowHVscale", 1);
Toshihiro Shimizu 890ddd
TEnv::IntVar ShowShear("EditToolShowShear", 0);
Toshihiro Shimizu 890ddd
TEnv::IntVar ShowCenterPosition("EditToolShowCenterPosition", 0);
Toshihiro Shimizu 890ddd
TEnv::StringVar Active("EditToolActiveAxis", "Position");
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Shinya Kitaoka 120a6e
namespace {
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
using EditToolGadgets::DragTool;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// DragCenterTool
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DragCenterTool final : public DragTool {
Shinya Kitaoka 120a6e
  TStageObjectId m_objId;
Shinya Kitaoka 120a6e
  int m_frame;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool m_lockCenterX;
Shinya Kitaoka 120a6e
  bool m_lockCenterY;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TPointD m_firstPos;
Shinya Kitaoka 120a6e
  TPointD m_oldCenter;
Shinya Kitaoka 120a6e
  TPointD m_center;
Shinya Kitaoka 120a6e
  TAffine m_affine;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  DragCenterTool(bool lockCenterX, bool lockCenterY)
Shinya Kitaoka 120a6e
      : m_objId(
Shinya Kitaoka 120a6e
            TTool::getApplication()->getCurrentTool()->getTool()->getObjectId())
Shinya Kitaoka 120a6e
      , m_frame(
Shinya Kitaoka 120a6e
            TTool::getApplication()->getCurrentTool()->getTool()->getFrame())
Shinya Kitaoka 120a6e
      , m_lockCenterX(lockCenterX)
Shinya Kitaoka 120a6e
      , m_lockCenterY(lockCenterY) {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void leftButtonDown(const TPointD &pos, const TMouseEvent &) override {
Shinya Kitaoka 120a6e
    if (m_lockCenterX && m_lockCenterY) return;
Shinya Kitaoka 120a6e
    TXsheet *xsh =
Shinya Kitaoka 120a6e
        TTool::getApplication()->getCurrentTool()->getTool()->getXsheet();
Shinya Kitaoka 120a6e
    m_center = m_oldCenter = xsh->getCenter(m_objId, m_frame);
Shinya Kitaoka 120a6e
    m_firstPos             = pos;
Shinya Kitaoka 120a6e
    m_affine               = xsh->getPlacement(m_objId, m_frame).inv() *
Shinya Kitaoka 120a6e
               xsh->getParentPlacement(m_objId, m_frame);
Shinya Kitaoka 120a6e
    m_affine.a13 = m_affine.a23 = 0;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void leftButtonDrag(const TPointD &pos, const TMouseEvent &) override {
Shinya Kitaoka 120a6e
    if (m_lockCenterX && m_lockCenterY) return;
Shinya Kitaoka 120a6e
    double factor = 1.0 / Stage::inch;
Shinya Kitaoka 120a6e
    TPointD delta = pos - m_firstPos;
Shinya Kitaoka 120a6e
    if (m_lockCenterX)
Shinya Kitaoka 120a6e
      delta = TPointD(0.0, delta.y);
Shinya Kitaoka 120a6e
    else if (m_lockCenterY)
Shinya Kitaoka 120a6e
      delta  = TPointD(delta.x, 0.0);
Shinya Kitaoka 120a6e
    m_center = m_oldCenter + (m_affine * delta) * factor;
Shinya Kitaoka 120a6e
    TTool::getApplication()
Shinya Kitaoka 120a6e
        ->getCurrentTool()
Shinya Kitaoka 120a6e
        ->getTool()
Shinya Kitaoka 120a6e
        ->getXsheet()
Shinya Kitaoka 120a6e
        ->setCenter(m_objId, m_frame, m_center);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 473e70
  void leftButtonUp(const TPointD &pos, const TMouseEvent &) override {
Shinya Kitaoka 120a6e
    if ((m_lockCenterX && m_lockCenterY) || m_firstPos == pos) return;
Shinya Kitaoka 120a6e
    UndoStageObjectCenterMove *undo =
Shinya Kitaoka 120a6e
        new UndoStageObjectCenterMove(m_objId, m_frame, m_oldCenter, m_center);
Shinya Kitaoka 120a6e
    TTool::Application *app = TTool::getApplication();
Shinya Kitaoka 120a6e
    undo->setObjectHandle(app->getCurrentObject());
Shinya Kitaoka 120a6e
    undo->setXsheetHandle(app->getCurrentXsheet());
Shinya Kitaoka 120a6e
    TUndoManager::manager()->add(undo);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// DragChannelTool
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DragChannelTool : public DragTool {
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  TStageObjectValues m_before, m_after;
Shinya Kitaoka 120a6e
  bool m_globalKeyframesEnabled;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool m_isStarted;
Shinya Kitaoka 120a6e
  TPointD m_firstPos;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  DragChannelTool(TStageObject::Channel a0, bool globalKeyframesEnabled)
Shinya Kitaoka 120a6e
      : m_globalKeyframesEnabled(globalKeyframesEnabled)
Shinya Kitaoka 120a6e
      , m_isStarted(false)
Shinya Kitaoka 120a6e
      , m_firstPos() {
Shinya Kitaoka 120a6e
    TTool::Application *app = TTool::getApplication();
Shinya Kitaoka 120a6e
    m_before.setFrameHandle(app->getCurrentFrame());
Shinya Kitaoka 120a6e
    m_before.setObjectHandle(app->getCurrentObject());
Shinya Kitaoka 120a6e
    m_before.setXsheetHandle(app->getCurrentXsheet());
Shinya Kitaoka 120a6e
    m_before.add(a0);
Shinya Kitaoka 120a6e
    if (m_globalKeyframesEnabled) {
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_Angle);
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_X);
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_Y);
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_Z);
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_SO);
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_ScaleX);
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_ScaleY);
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_Scale);
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_Path);
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_ShearX);
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_ShearY);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    m_after = m_before;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  DragChannelTool(TStageObject::Channel a0, TStageObject::Channel a1,
Shinya Kitaoka 120a6e
                  bool globalKeyframesEnabled)
Shinya Kitaoka 120a6e
      : m_globalKeyframesEnabled(globalKeyframesEnabled)
Shinya Kitaoka 120a6e
      , m_isStarted(false)
Shinya Kitaoka 120a6e
      , m_firstPos() {
Shinya Kitaoka 120a6e
    TTool::Application *app = TTool::getApplication();
Shinya Kitaoka 120a6e
    m_before.setFrameHandle(app->getCurrentFrame());
Shinya Kitaoka 120a6e
    m_before.setObjectHandle(app->getCurrentObject());
Shinya Kitaoka 120a6e
    m_before.setXsheetHandle(app->getCurrentXsheet());
Shinya Kitaoka 120a6e
    m_before.add(a0);
Shinya Kitaoka 120a6e
    m_before.add(a1);
Shinya Kitaoka 120a6e
    if (m_globalKeyframesEnabled) {
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_Angle);
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_X);
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_Y);
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_Z);
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_SO);
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_ScaleX);
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_ScaleY);
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_Scale);
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_Path);
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_ShearX);
Shinya Kitaoka 120a6e
      m_before.add(TStageObject::T_ShearY);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    m_after = m_before;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void enableGlobalKeyframes(bool enabled) override {
Shinya Kitaoka 120a6e
    m_globalKeyframesEnabled = enabled;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void start() {
Shinya Kitaoka 120a6e
    m_isStarted = true;
Shinya Kitaoka 120a6e
    m_before.updateValues();
Shinya Kitaoka 120a6e
    m_after = m_before;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TPointD getCenter() {
Shinya Kitaoka 120a6e
    TTool *tool          = TTool::getApplication()->getCurrentTool()->getTool();
Shinya Kitaoka 120a6e
    TStageObjectId objId = tool->getObjectId();
Shinya Kitaoka 120a6e
    int frame            = tool->getFrame();
Shinya Kitaoka 120a6e
    TXsheet *xsh         = tool->getXsheet();
Shinya Kitaoka 120a6e
    return xsh->getParentPlacement(objId, frame).inv() *
Shinya Kitaoka 120a6e
           xsh->getPlacement(objId, frame) *
Shinya Kitaoka 120a6e
           (Stage::inch * xsh->getCenter(objId, frame));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  double getOldValue(int index) const { return m_before.getValue(index); }
Shinya Kitaoka 120a6e
  double getValue(int index) const { return m_after.getValue(index); }
Shinya Kitaoka 120a6e
  void setValue(double v) {
Shinya Kitaoka 120a6e
    m_after.setValue(v);
Shinya Kitaoka 120a6e
    m_after.applyValues();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  void setValues(double v0, double v1) {
Shinya Kitaoka 120a6e
    m_after.setValues(v0, v1);
Shinya Kitaoka 120a6e
    m_after.applyValues();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void leftButtonUp(const TPointD &pos, const TMouseEvent &) override {
Shinya Kitaoka 120a6e
    if (!m_isStarted || m_firstPos == pos)
Shinya Kitaoka 120a6e
      return;
Shinya Kitaoka 120a6e
    else
Shinya Kitaoka 120a6e
      m_isStarted = false;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    TTool::Application *app   = TTool::getApplication();
Shinya Kitaoka 120a6e
    UndoStageObjectMove *undo = new UndoStageObjectMove(m_before, m_after);
Shinya Kitaoka 120a6e
    undo->setObjectHandle(app->getCurrentObject());
Shinya Kitaoka 120a6e
    TUndoManager::manager()->add(undo);
Shinya Kitaoka 120a6e
    app->getCurrentScene()->setDirtyFlag(true);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// DragPositionTool
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DragPositionTool final : public DragChannelTool {
Shinya Kitaoka 120a6e
  bool m_lockPositionX;
Shinya Kitaoka 120a6e
  bool m_lockPositionY;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  DragPositionTool(bool lockPositionX, bool lockPositionY,
Shinya Kitaoka 120a6e
                   bool globalKeyframesEnabled)
Shinya Kitaoka 120a6e
      : DragChannelTool(TStageObject::T_X, TStageObject::T_Y,
Shinya Kitaoka 120a6e
                        globalKeyframesEnabled)
Shinya Kitaoka 120a6e
      , m_lockPositionX(lockPositionX)
Shinya Kitaoka 120a6e
      , m_lockPositionY(lockPositionY) {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void leftButtonDown(const TPointD &pos, const TMouseEvent &) override {
Shinya Kitaoka 120a6e
    if (m_lockPositionX && m_lockPositionY) return;
Shinya Kitaoka 120a6e
    start();
Shinya Kitaoka 120a6e
    m_firstPos = pos;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 473e70
  void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override {
Shinya Kitaoka 120a6e
    if (m_lockPositionX && m_lockPositionY) return;
Shinya Kitaoka 120a6e
    TPointD delta = pos - m_firstPos;
Shinya Kitaoka 120a6e
    if (m_lockPositionX)
Shinya Kitaoka 120a6e
      delta = TPointD(0, delta.y);
Shinya Kitaoka 120a6e
    else if (m_lockPositionY)
Shinya Kitaoka 120a6e
      delta = TPointD(delta.x, 0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (e.isShiftPressed()) {
Shinya Kitaoka 120a6e
      if (fabs(delta.x) > fabs(delta.y))
Shinya Kitaoka 120a6e
        delta.y = 0;
Shinya Kitaoka 120a6e
      else
Shinya Kitaoka 120a6e
        delta.x = 0;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    double factor = 1.0 / Stage::inch;
Shinya Kitaoka 120a6e
    setValues(getOldValue(0) + delta.x * factor,
Shinya Kitaoka 120a6e
              getOldValue(1) + delta.y * factor);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// DragSplinePositionTool
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DragSplinePositionTool final : public DragChannelTool {
Shinya Kitaoka 120a6e
  const TStroke *m_spline;
Shinya Kitaoka 120a6e
  std::vector<double> m_lengthAtCPs;</double>
Shinya Kitaoka 120a6e
  double m_offset;
Shinya Kitaoka 120a6e
  double m_splineLength;
Shinya Kitaoka 120a6e
  double m_tolerance;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  DragSplinePositionTool(const TStroke *spline, bool globalKeyframesEnabled)
Shinya Kitaoka 120a6e
      : DragChannelTool(TStageObject::T_Path, globalKeyframesEnabled)
Shinya Kitaoka 120a6e
      , m_spline(spline)
Shinya Kitaoka 120a6e
      , m_offset(0.0)
Shinya Kitaoka 120a6e
      , m_splineLength(0)
Shinya Kitaoka 120a6e
      , m_tolerance(0) {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  double getLengthAtPos(const TPointD &pos) const {
Shinya Kitaoka 120a6e
    assert(m_spline);
Shinya Kitaoka 120a6e
    double t = m_spline->getW(pos);
Shinya Kitaoka 120a6e
    return m_spline->getLength(t);
Shinya Kitaoka 120a6e
    /*
Shinya Kitaoka 120a6e
double length = m_spline->getLength();
Shinya Kitaoka 120a6e
if(length>0) return 100 * m_spline->getLength(t) / length;
Shinya Kitaoka 120a6e
else return 0.0;
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  double paramValueToLength(double s) const {
Shinya Kitaoka 120a6e
    return s * m_splineLength * 0.01;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  double lengthToParamValue(double len) const {
Shinya Kitaoka 120a6e
    if (m_splineLength > 0)
Shinya Kitaoka 120a6e
      return 100 * len / m_splineLength;
Shinya Kitaoka 120a6e
    else
Shinya Kitaoka 120a6e
      return 0.0;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void leftButtonDown(const TPointD &pos, const TMouseEvent &) override {
Shinya Kitaoka 120a6e
    m_firstPos = pos;
Shinya Kitaoka 120a6e
    start();
Shinya Kitaoka 120a6e
    assert(m_spline);
Shinya Kitaoka 120a6e
    m_tolerance    = sqrt(tglGetPixelSize2()) * 10;
Shinya Kitaoka 120a6e
    m_splineLength = m_spline->getLength();
Shinya Kitaoka 120a6e
    m_lengthAtCPs.clear();
Shinya Kitaoka 120a6e
    int n = m_spline->getControlPointCount();
Shinya Kitaoka 120a6e
    for (int i = 0; i < n; i += 4)
Shinya Kitaoka 120a6e
      m_lengthAtCPs.push_back(m_spline->getLengthAtControlPoint(i));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    m_offset = paramValueToLength(getOldValue(0)) - getLengthAtPos(pos);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool snapLengthToControlPoint(double &len) const {
Shinya Kitaoka 120a6e
    int n = (int)m_lengthAtCPs.size();
Shinya Kitaoka 120a6e
    if (n <= 0) return false;
Shinya Kitaoka 120a6e
    double cpLen = len;
Shinya Kitaoka 120a6e
    int k        = 0;
Shinya Kitaoka 120a6e
    while (k < n && m_lengthAtCPs[k] <= len) k++;
Shinya Kitaoka 120a6e
    if (k >= n) {
Shinya Kitaoka 120a6e
      // len is >= all CP lengths. The closest is the last
Shinya Kitaoka 120a6e
      cpLen = m_lengthAtCPs.back();
Shinya Kitaoka 120a6e
    } else if (k == 0) {
Shinya Kitaoka 120a6e
      // len is < all CP lengths. the closest is the first
Shinya Kitaoka 120a6e
      cpLen = m_lengthAtCPs.front();
Shinya Kitaoka 120a6e
    } else {
Shinya Kitaoka 120a6e
      // m_lengthAtCPs[k-1]<=len && len < m_lengthAtCPs[k]
Shinya Kitaoka 120a6e
      double cpLen0 = m_lengthAtCPs[k - 1];
Shinya Kitaoka 120a6e
      double cpLen1 = m_lengthAtCPs[k];
Shinya Kitaoka 120a6e
      assert(cpLen0 <= len && len < cpLen1);
Shinya Kitaoka 120a6e
      cpLen = (len - cpLen0 < cpLen1 - len) ? cpLen0 : cpLen1;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    if (fabs(cpLen - len) < m_tolerance) {
Shinya Kitaoka 120a6e
      len = cpLen;
Shinya Kitaoka 120a6e
      return true;
Shinya Kitaoka 120a6e
    } else
Shinya Kitaoka 120a6e
      return false;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void leftButtonDrag(const TPointD &pos, const TMouseEvent &) override {
Shinya Kitaoka 120a6e
    double len = tcrop(getLengthAtPos(pos) + m_offset, 0.0, m_splineLength);
Shinya Kitaoka 120a6e
    snapLengthToControlPoint(len);
Shinya Kitaoka 120a6e
    setValue(lengthToParamValue(len));
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// DragRotationTool
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DragRotationTool final : public DragChannelTool {
Shinya Kitaoka 120a6e
  TPointD m_lastPos;
Shinya Kitaoka 120a6e
  TPointD m_center;
Shinya Kitaoka 120a6e
  bool m_lockRotation;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  DragRotationTool(bool lockRotation, bool globalKeyframesEnabled)
Shinya Kitaoka 120a6e
      : DragChannelTool(TStageObject::T_Angle, globalKeyframesEnabled)
Shinya Kitaoka 120a6e
      , m_lockRotation(lockRotation) {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void leftButtonDown(const TPointD &pos, const TMouseEvent &) override {
Shinya Kitaoka 120a6e
    if (m_lockRotation) return;
Shinya Kitaoka 120a6e
    m_firstPos = pos;
Shinya Kitaoka 120a6e
    m_lastPos  = pos;
Shinya Kitaoka 120a6e
    m_center   = getCenter();
Shinya Kitaoka 120a6e
    start();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 473e70
  void leftButtonDrag(const TPointD &pos, const TMouseEvent &) override {
Shinya Kitaoka 120a6e
    if (m_lockRotation) return;
Shinya Kitaoka 120a6e
    TPointD a = m_lastPos - m_center;
Shinya Kitaoka 120a6e
    TPointD b = pos - m_center;
Shinya Kitaoka 120a6e
    m_lastPos = pos;
Shinya Kitaoka 120a6e
    /*
Shinya Kitaoka 120a6e
if(cameraFlag)
Shinya Kitaoka 120a6e
{
Shinya Kitaoka 120a6e
// m_viewer->updateViewMatrix();
Shinya Kitaoka 120a6e
b = m_viewer->mouseToTool(gb) - m_curCenter;
Shinya Kitaoka 120a6e
a = m_viewer->mouseToTool(gc) - m_curCenter;
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    double a2 = norm2(a), b2 = norm2(b);
Shinya Kitaoka 120a6e
    const double eps = 1e-8;
Shinya Kitaoka 120a6e
    if (a2 < eps || b2 < eps) return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    double dang = asin(cross(a, b) / sqrt(a2 * b2)) * M_180_PI;
Shinya Kitaoka 120a6e
    setValue(getValue(0) + dang);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// DragIsotropicScaleTool
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DragIsotropicScaleTool final : public DragChannelTool {
Shinya Kitaoka 120a6e
  TPointD m_center;
Shinya Kitaoka 120a6e
  double m_r0;
Shinya Kitaoka 120a6e
  bool m_lockGlobalScale;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  DragIsotropicScaleTool(bool lockGlobalScale, bool globalKeyframesEnabled)
Shinya Kitaoka 120a6e
      : DragChannelTool(TStageObject::T_Scale, globalKeyframesEnabled)
Shinya Kitaoka 120a6e
      , m_lockGlobalScale(lockGlobalScale)
Shinya Kitaoka 120a6e
      , m_r0(0) {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void leftButtonDown(const TPointD &pos, const TMouseEvent &) override {
Shinya Kitaoka 120a6e
    if (m_lockGlobalScale) return;
Shinya Kitaoka 120a6e
    m_firstPos = pos;
Shinya Kitaoka 120a6e
    m_center   = getCenter();
Shinya Kitaoka 120a6e
    start();
Shinya Kitaoka 120a6e
    m_r0 = norm(m_firstPos - m_center);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 473e70
  void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override {
Shinya Kitaoka 120a6e
    if (m_lockGlobalScale) return;
Shinya Kitaoka 120a6e
    if (m_r0 < 0.001) return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    // TPointD a = m_firstPos - m_center;
Shinya Kitaoka 120a6e
    double r1 = norm(pos - m_center);
Shinya Kitaoka 120a6e
    if (r1 < 0.0001) return;
Shinya Kitaoka 120a6e
    setValue(getOldValue(0) * r1 / m_r0);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// DragScaleTool
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DragScaleTool final : public DragChannelTool {
Shinya Kitaoka 120a6e
  TPointD m_center;
Shinya Kitaoka 120a6e
  int m_constraint;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool m_lockScaleH;
Shinya Kitaoka 120a6e
  bool m_lockScaleV;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  DragScaleTool(int constraint, bool lockScaleH, bool lockScaleV,
Shinya Kitaoka 120a6e
                bool globalKeyframesEnabled)
Shinya Kitaoka 120a6e
      : DragChannelTool(TStageObject::T_ScaleX, TStageObject::T_ScaleY,
Shinya Kitaoka 120a6e
                        globalKeyframesEnabled)
Shinya Kitaoka 120a6e
      , m_constraint(constraint)
Shinya Kitaoka 120a6e
      , m_lockScaleH(lockScaleH)
Shinya Kitaoka 120a6e
      , m_lockScaleV(lockScaleV) {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void leftButtonDown(const TPointD &pos, const TMouseEvent &) override {
Shinya Kitaoka 120a6e
    if (m_lockScaleH && m_lockScaleV) return;
Shinya Kitaoka 120a6e
    m_firstPos = pos;
Shinya Kitaoka 120a6e
    m_center   = getCenter();
Shinya Kitaoka 120a6e
    start();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 473e70
  void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override {
Shinya Kitaoka 120a6e
    if (m_lockScaleH && m_lockScaleV) return;
Shinya Kitaoka 120a6e
    TPointD center = m_center + TPointD(40, 40);
Shinya Kitaoka 120a6e
    TPointD a      = m_firstPos - center;
Shinya Kitaoka 120a6e
    TPointD b      = pos - center;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    const double eps = 1e-8;
Shinya Kitaoka 120a6e
    if (norm2(a) < eps || norm2(b) < eps) return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    double fx            = b.x / a.x;
Shinya Kitaoka 120a6e
    if (fabs(fx) > 1) fx = tsign(fx) * sqrt(abs(fx));
Shinya Kitaoka 120a6e
    double fy            = b.y / a.y;
Shinya Kitaoka 120a6e
    if (fabs(fy) > 1) fy = tsign(fy) * sqrt(abs(fy));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    int constraint = m_constraint;
Shinya Kitaoka 120a6e
    if (constraint == ScaleConstraints::None && e.isShiftPressed())
Shinya Kitaoka 120a6e
      constraint = ScaleConstraints::AspectRatio;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (constraint == ScaleConstraints::AspectRatio) {
Shinya Kitaoka 120a6e
      TPointD c = pos - m_firstPos;
Shinya Kitaoka 120a6e
      if (fabs(c.x) > fabs(c.y))
Shinya Kitaoka 120a6e
        fy = fx;
Shinya Kitaoka 120a6e
      else
Shinya Kitaoka 120a6e
        fx = fy;
Shinya Kitaoka 120a6e
    } else if (constraint == ScaleConstraints::Mass) {
Shinya Kitaoka 120a6e
      double bxay = b.x * a.y;
Shinya Kitaoka 120a6e
      double byax = b.y * a.x;
Shinya Kitaoka 120a6e
      if (fabs(bxay) < eps || fabs(byax) < eps) return;
Shinya Kitaoka 120a6e
      fx = bxay / byax;
Shinya Kitaoka 120a6e
      fy = byax / bxay;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    if (fabs(fx) > eps && fabs(fy) > eps) {
Shinya Kitaoka 120a6e
      double oldv0                   = getOldValue(0);
Shinya Kitaoka 120a6e
      double oldv1                   = getOldValue(1);
Shinya Kitaoka 120a6e
      if (fabs(oldv0) < 0.001) oldv0 = 0.001;
Shinya Kitaoka 120a6e
      if (fabs(oldv1) < 0.001) oldv1 = 0.001;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      double valueX = oldv0 * fx;
Shinya Kitaoka 120a6e
      double valueY = oldv1 * fy;
Shinya Kitaoka 120a6e
      if (m_lockScaleH)
Shinya Kitaoka 120a6e
        valueX = oldv0;
Shinya Kitaoka 120a6e
      else if (m_lockScaleV)
Shinya Kitaoka 120a6e
        valueY = oldv1;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      setValues(valueX, valueY);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// DragShearTool
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DragShearTool final : public DragChannelTool {
Shinya Kitaoka 120a6e
  TPointD m_center;
Shinya Kitaoka 120a6e
  bool m_lockShearH;
Shinya Kitaoka 120a6e
  bool m_lockShearV;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  DragShearTool(bool lockShearH, bool lockShearV, bool globalKeyframesEnabled)
Shinya Kitaoka 120a6e
      : DragChannelTool(TStageObject::T_ShearX, TStageObject::T_ShearY,
Shinya Kitaoka 120a6e
                        globalKeyframesEnabled)
Shinya Kitaoka 120a6e
      , m_lockShearH(lockShearH)
Shinya Kitaoka 120a6e
      , m_lockShearV(lockShearV) {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void leftButtonDown(const TPointD &pos, const TMouseEvent &) override {
Shinya Kitaoka 120a6e
    if (m_lockShearH && m_lockShearV) return;
Shinya Kitaoka 120a6e
    m_firstPos = pos;
Shinya Kitaoka 120a6e
    m_center   = getCenter();
Shinya Kitaoka 120a6e
    start();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 473e70
  void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override {
Shinya Kitaoka 120a6e
    if (m_lockShearH && m_lockShearV) return;
Shinya Kitaoka 120a6e
    TPointD a = m_firstPos - m_center;
Shinya Kitaoka 120a6e
    TPointD b = pos - m_center;
Shinya Kitaoka 120a6e
    double fx = a.x - b.x;
Shinya Kitaoka 120a6e
    double fy = b.y - a.y;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (m_lockShearH)
Shinya Kitaoka 120a6e
      fx = 0;
Shinya Kitaoka 120a6e
    else if (m_lockShearV)
Shinya Kitaoka 120a6e
      fy = 0;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (e.isShiftPressed()) {
Shinya Kitaoka 120a6e
      if (fabs(fx) > fabs(fy))
Shinya Kitaoka 120a6e
        fy = 0;
Shinya Kitaoka 120a6e
      else
Shinya Kitaoka 120a6e
        fx = 0;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    setValues(getOldValue(0) + 0.01 * fx, getOldValue(1) + 0.01 * fy);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// DragZTool
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DragZTool final : public DragChannelTool {
Shinya Kitaoka 120a6e
  TPoint m_lastPos;
Shinya Kitaoka 120a6e
  TTool::Viewer *m_viewer;
Shinya Kitaoka 120a6e
  double m_dz;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  DragZTool(TTool::Viewer *viewer, bool globalKeyframesEnabled)
Shinya Kitaoka 120a6e
      : DragChannelTool(TStageObject::T_Z, globalKeyframesEnabled)
Shinya Kitaoka 120a6e
      , m_viewer(viewer) {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void leftButtonDown(const TPointD &pos, const TMouseEvent &e) override {
Shinya Kitaoka 120a6e
    m_lastPos  = e.m_pos;
Shinya Kitaoka 120a6e
    m_firstPos = pos;
Shinya Kitaoka 120a6e
    m_dz       = 0;
Shinya Kitaoka 120a6e
    start();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 473e70
  void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override {
Shinya Kitaoka 120a6e
    double dz = m_viewer->projectToZ(e.m_pos - m_lastPos);
Shinya Kitaoka 120a6e
    m_lastPos = e.m_pos;
Shinya Kitaoka 120a6e
    if (dz != 0.0) {
Shinya Kitaoka 120a6e
      m_dz += dz;
Shinya Kitaoka 120a6e
      setValue(getOldValue(0) + m_dz);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Shinya Kitaoka 120a6e
}  // namespace
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// EditTool
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class EditTool final : public TTool {
Shinya Kitaoka 120a6e
  Q_DECLARE_TR_FUNCTIONS(EditTool)
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  DragTool *m_dragTool;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool m_firstTime;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  enum {
Shinya Kitaoka 120a6e
    None        = -1,
Shinya Kitaoka 120a6e
    Translation = 1,
Shinya Kitaoka 120a6e
    Rotation,
Shinya Kitaoka 120a6e
    Scale,
Shinya Kitaoka 120a6e
    ScaleX,
Shinya Kitaoka 120a6e
    ScaleY,
Shinya Kitaoka 120a6e
    ScaleXY,
Shinya Kitaoka 120a6e
    Center,
Shinya Kitaoka 120a6e
    ZTranslation,
Shinya Kitaoka 120a6e
    Shear,
Shinya Kitaoka 120a6e
  };
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // DragInfo m_dragInfo;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TPointD m_lastPos;
Shinya Kitaoka 120a6e
  TPointD m_curPos;
Shinya Kitaoka 120a6e
  TPointD m_firstPos;
Shinya Kitaoka 120a6e
  TPointD m_curCenter;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool m_active;
Shinya Kitaoka 120a6e
  bool m_keyFrameAdded;
Shinya Kitaoka 120a6e
  int m_what;
Shinya Kitaoka 120a6e
  int m_highlightedDevice;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  double m_oldValues[2];
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  double m_currentScaleFactor;
Shinya Kitaoka 120a6e
  FxGadgetController *m_fxGadgetController;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TEnumProperty m_scaleConstraint;
Shinya Kitaoka 120a6e
  TEnumProperty m_autoSelect;
Shinya Kitaoka 120a6e
  TBoolProperty m_globalKeyframes;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TBoolProperty m_lockCenterX;
Shinya Kitaoka 120a6e
  TBoolProperty m_lockCenterY;
Shinya Kitaoka 120a6e
  TBoolProperty m_lockPositionX;
Shinya Kitaoka 120a6e
  TBoolProperty m_lockPositionY;
Shinya Kitaoka 120a6e
  TBoolProperty m_lockRotation;
Shinya Kitaoka 120a6e
  TBoolProperty m_lockShearH;
Shinya Kitaoka 120a6e
  TBoolProperty m_lockShearV;
Shinya Kitaoka 120a6e
  TBoolProperty m_lockScaleH;
Shinya Kitaoka 120a6e
  TBoolProperty m_lockScaleV;
Shinya Kitaoka 120a6e
  TBoolProperty m_lockGlobalScale;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TBoolProperty m_showEWNSposition;
Shinya Kitaoka 120a6e
  TBoolProperty m_showZposition;
Shinya Kitaoka 120a6e
  TBoolProperty m_showSOposition;
Shinya Kitaoka 120a6e
  TBoolProperty m_showRotation;
Shinya Kitaoka 120a6e
  TBoolProperty m_showGlobalScale;
Shinya Kitaoka 120a6e
  TBoolProperty m_showHVscale;
Shinya Kitaoka 120a6e
  TBoolProperty m_showShear;
Shinya Kitaoka 120a6e
  TBoolProperty m_showCenterPosition;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TEnumProperty m_activeAxis;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TPropertyGroup m_prop;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  EditTool();
Shinya Kitaoka 120a6e
  ~EditTool();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  ToolType getToolType() const override { return TTool::ColumnTool; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool doesApply() const;  // ritorna vero se posso deformare l'oggetto corrente
Shinya Kitaoka 120a6e
  void saveOldValues();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  const TStroke *getSpline() const;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void rotate();
Shinya Kitaoka 120a6e
  void move();
Shinya Kitaoka 120a6e
  void moveCenter();
Shinya Kitaoka 120a6e
  void scale();
Shinya Kitaoka 120a6e
  void isoScale();
Shinya Kitaoka 120a6e
  void squeeze();
Shinya Kitaoka 120a6e
  void shear(const TPointD &pos, bool single);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void updateTranslation() override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void leftButtonDown(const TPointD &pos, const TMouseEvent &) override;
Shinya Kitaoka 473e70
  void leftButtonDrag(const TPointD &pos, const TMouseEvent &) override;
Shinya Kitaoka 473e70
  void leftButtonUp(const TPointD &pos, const TMouseEvent &) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void mouseMove(const TPointD &, const TMouseEvent &e) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void draw() override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void transform(const TAffine &aff);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void onActivate() override;
Shinya Kitaoka 473e70
  void onDeactivate() override;
Shinya Kitaoka 473e70
  bool onPropertyChanged(std::string propertyName) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void computeBBox();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  int getCursorId() const override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  TPropertyGroup *getProperties(int targetType) override { return &m_prop; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void updateMatrix() override {
Shinya Kitaoka 120a6e
    setMatrix(
Shinya Kitaoka 120a6e
        getCurrentObjectParentMatrix2());  // getCurrentObjectParentMatrix());
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void drawText(const TPointD &p, double unit, std::string text);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
EditTool::EditTool()
Shinya Kitaoka 120a6e
    : TTool("T_Edit")
Shinya Kitaoka 120a6e
    , m_active(false)
Shinya Kitaoka 120a6e
    , m_what(Translation)
Shinya Kitaoka 120a6e
    , m_highlightedDevice(None)
Shinya Kitaoka 120a6e
    , m_currentScaleFactor(1)
Shinya Kitaoka 120a6e
    , m_fxGadgetController(0)
Shinya Kitaoka 120a6e
    , m_keyFrameAdded(false)
Shinya Kitaoka 120a6e
    , m_scaleConstraint("Scale Constraint:")  // W_ToolOptions_ScaleConstraint
Shinya Kitaoka 120a6e
    , m_autoSelect("Auto Select Column")      // W_ToolOptions_AutoSelect
Shinya Kitaoka 120a6e
    , m_globalKeyframes("Global Key", false)  // W_ToolsOptions_GlobalKeyframes
Shinya Kitaoka 120a6e
    , m_lockCenterX("Lock Center E/W", false)
Shinya Kitaoka 120a6e
    , m_lockCenterY("Lock Center N/S", false)
Shinya Kitaoka 120a6e
    , m_lockPositionX("Lock Position E/W", false)
Shinya Kitaoka 120a6e
    , m_lockPositionY("Lock Position N/S", false)
Shinya Kitaoka 120a6e
    , m_lockRotation("Lock Rotation", false)
Shinya Kitaoka 120a6e
    , m_lockShearH("Lock Shear H", false)
Shinya Kitaoka 120a6e
    , m_lockShearV("Lock Shear V", false)
Shinya Kitaoka 120a6e
    , m_lockScaleH("Lock Scale H", false)
Shinya Kitaoka 120a6e
    , m_lockScaleV("Lock Scale V", false)
Shinya Kitaoka 120a6e
    , m_lockGlobalScale("Lock Global Scale", false)
Shinya Kitaoka 120a6e
    , m_showEWNSposition("E/W and N/S Positions", true)
Shinya Kitaoka 120a6e
    , m_showZposition("Z Position", true)
Shinya Kitaoka 120a6e
    , m_showSOposition("SO", true)
Shinya Kitaoka 120a6e
    , m_showRotation("Rotation", true)
Shinya Kitaoka 120a6e
    , m_showGlobalScale("Global Scale", true)
Shinya Kitaoka 120a6e
    , m_showHVscale("Horizontal and Vertical Scale", true)
Shinya Kitaoka 120a6e
    , m_showShear("Shear", true)
Shinya Kitaoka 120a6e
    , m_showCenterPosition("Center Position", true)
Shinya Kitaoka 120a6e
    , m_dragTool(0)
Shinya Kitaoka 120a6e
    , m_firstTime(true)
Shinya Kitaoka 120a6e
    , m_activeAxis("Active Axis") {
Shinya Kitaoka 120a6e
  bind(TTool::AllTargets);
Shinya Kitaoka 120a6e
  m_prop.bind(m_scaleConstraint);
Shinya Kitaoka 120a6e
  m_prop.bind(m_autoSelect);
Shinya Kitaoka 120a6e
  m_prop.bind(m_globalKeyframes);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_prop.bind(m_lockCenterX);
Shinya Kitaoka 120a6e
  m_prop.bind(m_lockCenterY);
Shinya Kitaoka 120a6e
  m_prop.bind(m_lockPositionX);
Shinya Kitaoka 120a6e
  m_prop.bind(m_lockPositionY);
Shinya Kitaoka 120a6e
  m_prop.bind(m_lockRotation);
Shinya Kitaoka 120a6e
  m_prop.bind(m_lockShearH);
Shinya Kitaoka 120a6e
  m_prop.bind(m_lockShearV);
Shinya Kitaoka 120a6e
  m_prop.bind(m_lockScaleH);
Shinya Kitaoka 120a6e
  m_prop.bind(m_lockScaleV);
Shinya Kitaoka 120a6e
  m_prop.bind(m_lockGlobalScale);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_prop.bind(m_showEWNSposition);
Shinya Kitaoka 120a6e
  m_prop.bind(m_showZposition);
Shinya Kitaoka 120a6e
  m_prop.bind(m_showSOposition);
Shinya Kitaoka 120a6e
  m_prop.bind(m_showRotation);
Shinya Kitaoka 120a6e
  m_prop.bind(m_showGlobalScale);
Shinya Kitaoka 120a6e
  m_prop.bind(m_showHVscale);
Shinya Kitaoka 120a6e
  m_prop.bind(m_showShear);
Shinya Kitaoka 120a6e
  m_prop.bind(m_showCenterPosition);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_scaleConstraint.addValue(L"None");
Shinya Kitaoka 120a6e
  m_scaleConstraint.addValue(L"A/R");
Shinya Kitaoka 120a6e
  m_scaleConstraint.addValue(L"Mass");
Shinya Kitaoka 120a6e
  m_scaleConstraint.setValue(L"None");
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_autoSelect.addValue(L"None");
Shinya Kitaoka 120a6e
  m_autoSelect.addValue(L"Column");
Shinya Kitaoka 120a6e
  m_autoSelect.addValue(L"Pegbar");
Shinya Kitaoka 120a6e
  m_autoSelect.setValue(L"None");
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_globalKeyframes.setId("GlobalKey");
Shinya Kitaoka 120a6e
  m_autoSelect.setId("AutoSelect");
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_prop.bind(m_activeAxis);
Shinya Kitaoka 120a6e
  m_activeAxis.addValue(L"Position");
Shinya Kitaoka 120a6e
  m_activeAxis.addValue(L"Rotation");
Shinya Kitaoka 120a6e
  m_activeAxis.addValue(L"Scale");
Shinya Kitaoka 120a6e
  m_activeAxis.addValue(L"Shear");
Shinya Kitaoka 120a6e
  m_activeAxis.addValue(L"Center");
Shinya Kitaoka 120a6e
  m_activeAxis.setValue(L"Position");
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_activeAxis.setId("EditToolActiveAxis");
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
EditTool::~EditTool() {
Shinya Kitaoka 120a6e
  delete m_dragTool;
Shinya Kitaoka 120a6e
  delete m_fxGadgetController;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void EditTool::updateTranslation() {
Shinya Kitaoka 120a6e
  m_scaleConstraint.setQStringName(tr("Scale Constraint:"));
Shinya Kitaoka 120a6e
  m_autoSelect.setQStringName(tr("Auto Select Column"));
Shinya Kitaoka 120a6e
  m_globalKeyframes.setQStringName(tr("Global Key"));
Shinya Kitaoka 120a6e
  m_lockCenterX.setQStringName(tr("Lock Center E/W"));
Shinya Kitaoka 120a6e
  m_lockCenterY.setQStringName(tr("Lock Center N/S"));
Shinya Kitaoka 120a6e
  m_lockPositionX.setQStringName(tr("Lock Position E/W"));
Shinya Kitaoka 120a6e
  m_lockPositionY.setQStringName(tr("Lock Position N/S"));
Shinya Kitaoka 120a6e
  m_lockRotation.setQStringName(tr("Lock Rotation"));
Shinya Kitaoka 120a6e
  m_lockShearH.setQStringName(tr("Lock Shear H"));
Shinya Kitaoka 120a6e
  m_lockShearV.setQStringName(tr("Lock Shear V"));
Shinya Kitaoka 120a6e
  m_lockScaleH.setQStringName(tr("Lock Scale H"));
Shinya Kitaoka 120a6e
  m_lockScaleV.setQStringName(tr("Lock Scale V"));
Shinya Kitaoka 120a6e
  m_lockGlobalScale.setQStringName(tr("Lock Global Scale"));
Shinya Kitaoka 120a6e
  m_showEWNSposition.setQStringName(tr("E/W and N/S Positions"));
Shinya Kitaoka 120a6e
  m_showZposition.setQStringName(tr("Z Position"));
Shinya Kitaoka 120a6e
  m_showSOposition.setQStringName(tr("SO"));
Shinya Kitaoka 120a6e
  m_showRotation.setQStringName(tr("Rotation"));
Shinya Kitaoka 120a6e
  m_showGlobalScale.setQStringName(tr("Global Scale"));
Shinya Kitaoka 120a6e
  m_showHVscale.setQStringName(tr("Horizontal and Vertical Scale"));
Shinya Kitaoka 120a6e
  m_showShear.setQStringName(tr("Shear"));
Shinya Kitaoka 120a6e
  m_showCenterPosition.setQStringName(tr("Center Position"));
Shinya Kitaoka 120a6e
  m_activeAxis.setQStringName(tr("Active Axis"));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool EditTool::doesApply() const {
Shinya Kitaoka 120a6e
  TXsheet *xsh = TTool::getApplication()->getCurrentXsheet()->getXsheet();
Shinya Kitaoka 120a6e
  assert(xsh);
Shinya Kitaoka 120a6e
  TStageObjectId objId =
Shinya Kitaoka 120a6e
      TTool::getApplication()->getCurrentObject()->getObjectId();
Shinya Kitaoka 120a6e
  if (objId.isColumn()) {
Shinya Kitaoka 120a6e
    TXshColumn *column = xsh->getColumn(objId.getIndex());
Shinya Kitaoka 120a6e
    if (column && column->getSoundColumn()) return false;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  return true;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
const TStroke *EditTool::getSpline() const {
Shinya Kitaoka 120a6e
  TTool::Application *app    = TTool::getApplication();
Shinya Kitaoka 120a6e
  TXsheet *xsh               = app->getCurrentXsheet()->getXsheet();
Shinya Kitaoka 120a6e
  TStageObjectId objId       = app->getCurrentObject()->getObjectId();
Shinya Kitaoka 120a6e
  TStageObject *pegbar       = xsh->getStageObject(objId);
Shinya Kitaoka 120a6e
  TStageObjectSpline *spline = pegbar ? pegbar->getSpline() : 0;
Shinya Kitaoka 120a6e
  return spline ? spline->getStroke() : 0;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void EditTool::mouseMove(const TPointD &, const TMouseEvent &e) {
Shinya Kitaoka 120a6e
  /*--左ドラッグ中なら無視--*/
Shinya Kitaoka 120a6e
  if (e.isLeftButtonPressed()) return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*-- FxGadgetを表示していなかったらPICKをしないで済ませる --*/
Shinya Kitaoka 120a6e
  int selectedDevice                                    = -1;
Shinya Kitaoka 120a6e
  if (m_fxGadgetController->hasGadget()) selectedDevice = pick(e.m_pos);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (selectedDevice < 1000) {
Shinya Kitaoka 120a6e
    selectedDevice = m_what;
Shinya Kitaoka 120a6e
    if (m_what == Translation && e.isCtrlPressed())
Shinya Kitaoka 120a6e
      selectedDevice = ZTranslation;
Shinya Kitaoka 120a6e
    else if (
Shinya Kitaoka 120a6e
        m_what == ZTranslation &&
Shinya Kitaoka 120a6e
        !e.isCtrlPressed()) /*--ここには、一度Z移動をした後に入る可能性がある--*/
Shinya Kitaoka 120a6e
      selectedDevice = Translation;
Shinya Kitaoka 120a6e
    else if (m_what == Scale && e.isCtrlPressed())
Shinya Kitaoka 120a6e
      selectedDevice = ScaleXY;
Shinya Kitaoka 120a6e
    else if (m_what == ScaleXY && !e.isCtrlPressed())
Shinya Kitaoka 120a6e
      selectedDevice = Scale;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (selectedDevice != m_highlightedDevice) {
Shinya Kitaoka 120a6e
    m_highlightedDevice = selectedDevice;
Shinya Kitaoka 120a6e
    m_fxGadgetController->selectById(selectedDevice);
Shinya Kitaoka 120a6e
    invalidate();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TPoint ga, gb, gc;
Toshihiro Shimizu 890ddd
TPoint lastScreenPos;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void EditTool::leftButtonDown(const TPointD &ppos, const TMouseEvent &e) {
Shinya Kitaoka 120a6e
  TPointD pos = ppos;
Shinya Kitaoka 120a6e
  /*-- Soundカラムの場合は何もしない --*/
Shinya Kitaoka 120a6e
  if (!doesApply()) return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_activeAxis.getValue() == L"Position")
Shinya Kitaoka 120a6e
    if (e.isCtrlPressed())
Shinya Kitaoka 120a6e
      m_what = ZTranslation;
Shinya Kitaoka 120a6e
    else
Shinya Kitaoka 120a6e
      m_what = Translation;
Shinya Kitaoka 120a6e
  else if (m_activeAxis.getValue() == L"Scale")
Shinya Kitaoka 120a6e
    if (e.isCtrlPressed())
Shinya Kitaoka 120a6e
      m_what = ScaleXY;
Shinya Kitaoka 120a6e
    else
Shinya Kitaoka 120a6e
      m_what = Scale;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int scaleConstraint = 0;
Shinya Kitaoka 120a6e
  if (m_scaleConstraint.getValue() == L"A/R")
Shinya Kitaoka 120a6e
    scaleConstraint = ScaleConstraints::AspectRatio;
Shinya Kitaoka 120a6e
  else if (m_scaleConstraint.getValue() == L"Mass")
Shinya Kitaoka 120a6e
    scaleConstraint = ScaleConstraints::Mass;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  assert(m_dragTool == 0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_highlightedDevice >= 1000) {
Shinya Kitaoka 120a6e
    m_dragTool = m_fxGadgetController->createDragTool(m_highlightedDevice);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (!m_dragTool) {
Shinya Kitaoka 120a6e
    switch (m_what) {
Shinya Kitaoka 120a6e
    case Center:
Shinya Kitaoka 120a6e
      m_dragTool = new DragCenterTool(m_lockCenterX.getValue(),
Shinya Kitaoka 120a6e
                                      m_lockCenterY.getValue());
Shinya Kitaoka 120a6e
      break;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    case Translation:
Shinya Kitaoka 120a6e
      if (const TStroke *spline = getSpline())
Shinya Kitaoka 120a6e
        m_dragTool =
Shinya Kitaoka 120a6e
            new DragSplinePositionTool(spline, m_globalKeyframes.getValue());
Shinya Kitaoka 120a6e
      else
Shinya Kitaoka 120a6e
        m_dragTool = new DragPositionTool(m_lockPositionX.getValue(),
Shinya Kitaoka 120a6e
                                          m_lockPositionY.getValue(),
Shinya Kitaoka 120a6e
                                          m_globalKeyframes.getValue());
Shinya Kitaoka 120a6e
      break;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    case Rotation:
Shinya Kitaoka 120a6e
      m_dragTool = new DragRotationTool(m_lockRotation.getValue(),
Shinya Kitaoka 120a6e
                                        m_globalKeyframes.getValue());
Shinya Kitaoka 120a6e
      break;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    case Scale:
Shinya Kitaoka 120a6e
      m_dragTool = new DragIsotropicScaleTool(m_lockGlobalScale.getValue(),
Shinya Kitaoka 120a6e
                                              m_globalKeyframes.getValue());
Shinya Kitaoka 120a6e
      break;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    case ScaleXY:
Shinya Kitaoka 120a6e
      m_dragTool = new DragScaleTool(scaleConstraint, m_lockScaleH.getValue(),
Shinya Kitaoka 120a6e
                                     m_lockScaleV.getValue(),
Shinya Kitaoka 120a6e
                                     m_globalKeyframes.getValue());
Shinya Kitaoka 120a6e
      break;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    case Shear:
Shinya Kitaoka 120a6e
      m_dragTool =
Shinya Kitaoka 120a6e
          new DragShearTool(m_lockShearH.getValue(), m_lockShearV.getValue(),
Shinya Kitaoka 120a6e
                            m_globalKeyframes.getValue());
Shinya Kitaoka 120a6e
      break;
Shinya Kitaoka 120a6e
    case ZTranslation:
Shinya Kitaoka 120a6e
      m_dragTool = new DragZTool(m_viewer, m_globalKeyframes.getValue());
Shinya Kitaoka 120a6e
      break;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (m_dragTool) {
Shinya Kitaoka 120a6e
    m_dragTool->enableGlobalKeyframes(m_globalKeyframes.getValue());
Shinya Kitaoka 120a6e
    TUndoManager::manager()->beginBlock();
Shinya Kitaoka 120a6e
    m_dragTool->leftButtonDown(pos, e);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  invalidate();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void EditTool::leftButtonDrag(const TPointD &pos, const TMouseEvent &e) {
Shinya Kitaoka 120a6e
  if (!m_dragTool) return;
Shinya Kitaoka 120a6e
  m_dragTool->leftButtonDrag(pos, e);
Shinya Kitaoka 120a6e
  TTool::getApplication()->getCurrentObject()->notifyObjectIdChanged(true);
Shinya Kitaoka 120a6e
  invalidate();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void EditTool::leftButtonUp(const TPointD &pos, const TMouseEvent &e) {
Shinya Kitaoka 120a6e
  if (m_dragTool) {
Shinya Kitaoka 120a6e
    m_dragTool->leftButtonUp(pos, e);
Shinya Kitaoka 120a6e
    TUndoManager::manager()->endBlock();
Shinya Kitaoka 120a6e
    delete m_dragTool;
Shinya Kitaoka 120a6e
    m_dragTool = 0;
Shinya Kitaoka 120a6e
    TTool::getApplication()->getCurrentObject()->notifyObjectIdChanged(false);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  m_keyFrameAdded = false;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
namespace {
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void drawArrow(double r, bool filled) {
Shinya Kitaoka 120a6e
  double z0 = 0.25 * r;
Shinya Kitaoka 120a6e
  double z1 = 2 * r;
Shinya Kitaoka 120a6e
  double z2 = 4 * r;
Shinya Kitaoka 120a6e
  double x0 = r;
Shinya Kitaoka 120a6e
  double x1 = 2 * r;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (filled) {
Shinya Kitaoka 120a6e
    glBegin(GL_POLYGON);
Shinya Kitaoka 120a6e
    glVertex3d(x1, 0, z2);
Shinya Kitaoka 120a6e
    glVertex3d(-x1, 0, z2);
Shinya Kitaoka 120a6e
    glVertex3d(-x1, 0, -z2);
Shinya Kitaoka 120a6e
    glVertex3d(x1, 0, -z2);
Shinya Kitaoka 120a6e
    glVertex3d(x1, 0, z2);
Shinya Kitaoka 120a6e
    glEnd();
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    glBegin(GL_LINE_STRIP);
Shinya Kitaoka 120a6e
    glVertex3d(x0, 0, z0);
Shinya Kitaoka 120a6e
    glVertex3d(x0, 0, z1);
Shinya Kitaoka 120a6e
    glVertex3d(x1, 0, z1);
Shinya Kitaoka 120a6e
    glVertex3d(0, 0, z2);
Shinya Kitaoka 120a6e
    glVertex3d(-x1, 0, z1);
Shinya Kitaoka 120a6e
    glVertex3d(-x0, 0, z1);
Shinya Kitaoka 120a6e
    glVertex3d(-x0, 0, z0);
Shinya Kitaoka 120a6e
    glVertex3d(-x0, 0, z0);
Shinya Kitaoka 120a6e
    glEnd();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    glBegin(GL_LINE_STRIP);
Shinya Kitaoka 120a6e
    glVertex3d(x0, 0, -z0);
Shinya Kitaoka 120a6e
    glVertex3d(x0, 0, -z1);
Shinya Kitaoka 120a6e
    glVertex3d(x1, 0, -z1);
Shinya Kitaoka 120a6e
    glVertex3d(0, 0, -z2);
Shinya Kitaoka 120a6e
    glVertex3d(-x1, 0, -z1);
Shinya Kitaoka 120a6e
    glVertex3d(-x0, 0, -z1);
Shinya Kitaoka 120a6e
    glVertex3d(-x0, 0, -z0);
Shinya Kitaoka 120a6e
    glVertex3d(-x0, 0, -z0);
Shinya Kitaoka 120a6e
    glEnd();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void drawCameraIcon() {
Shinya Kitaoka 120a6e
  glBegin(GL_LINE_STRIP);
Shinya Kitaoka 120a6e
  glVertex2i(5, 0);
Shinya Kitaoka 120a6e
  glVertex2i(16, 0);
Shinya Kitaoka 120a6e
  glVertex2i(16, 3);
Shinya Kitaoka 120a6e
  glVertex2i(16, 3);
Shinya Kitaoka 120a6e
  glVertex2i(22, 0);
Shinya Kitaoka 120a6e
  glVertex2i(22, 9);
Shinya Kitaoka 120a6e
  glVertex2i(16, 6);
Shinya Kitaoka 120a6e
  glVertex2i(16, 9);
Shinya Kitaoka 120a6e
  glVertex2i(14, 9);
Shinya Kitaoka 120a6e
  glVertex2i(16, 11);
Shinya Kitaoka 120a6e
  glVertex2i(16, 14);
Shinya Kitaoka 120a6e
  glVertex2i(14, 16);
Shinya Kitaoka 120a6e
  glVertex2i(11, 16);
Shinya Kitaoka 120a6e
  glVertex2i(9, 14);
Shinya Kitaoka 120a6e
  glVertex2i(9, 11);
Shinya Kitaoka 120a6e
  glVertex2i(11, 9);
Shinya Kitaoka 120a6e
  glVertex2i(7, 9);
Shinya Kitaoka 120a6e
  glVertex2i(7, 11);
Shinya Kitaoka 120a6e
  glVertex2i(5, 13);
Shinya Kitaoka 120a6e
  glVertex2i(2, 13);
Shinya Kitaoka 120a6e
  glVertex2i(0, 11);
Shinya Kitaoka 120a6e
  glVertex2i(0, 8);
Shinya Kitaoka 120a6e
  glVertex2i(2, 6);
Shinya Kitaoka 120a6e
  glVertex2i(5, 6);
Shinya Kitaoka 120a6e
  glVertex2i(5, 0);
Shinya Kitaoka 120a6e
  glEnd();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void drawZArrow() {
Shinya Kitaoka 120a6e
  /*--矢印--*/
Shinya Kitaoka 120a6e
  glBegin(GL_LINE_LOOP);
Shinya Kitaoka 120a6e
  glVertex2i(0, 3);
Shinya Kitaoka 120a6e
  glVertex2i(2, 2);
Shinya Kitaoka 120a6e
  glVertex2i(1, 2);
Shinya Kitaoka 120a6e
  glVertex2i(2, -3);
Shinya Kitaoka 120a6e
  glVertex2i(4, -3);
Shinya Kitaoka 120a6e
  glVertex2i(0, -6);
Shinya Kitaoka 120a6e
  glVertex2i(-4, -3);
Shinya Kitaoka 120a6e
  glVertex2i(-2, -3);
Shinya Kitaoka 120a6e
  glVertex2i(-1, 2);
Shinya Kitaoka 120a6e
  glVertex2i(-2, 2);
Shinya Kitaoka 120a6e
  glEnd();
Shinya Kitaoka 120a6e
  /*--Zの文字--*/
Shinya Kitaoka 120a6e
  glBegin(GL_LINE_STRIP);
Shinya Kitaoka 120a6e
  glVertex2i(3, 4);
Shinya Kitaoka 120a6e
  glVertex2i(5, 4);
Shinya Kitaoka 120a6e
  glVertex2i(3, 1);
Shinya Kitaoka 120a6e
  glVertex2i(5, 1);
Shinya Kitaoka 120a6e
  glEnd();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
}  // namespace
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void EditTool::drawText(const TPointD &p, double unit, std::string text) {
Shinya Kitaoka 120a6e
  glPushMatrix();
Shinya Kitaoka 120a6e
  glTranslated(p.x, p.y, 0.0);
Shinya Kitaoka 120a6e
  double sc = unit * 1.6;
Shinya Kitaoka 120a6e
  /*
Shinya Kitaoka 120a6e
double w = sc * tglGetTextWidth(text, GLUT_STROKE_ROMAN);
Shinya Kitaoka 120a6e
double h = sc;
Shinya Kitaoka 120a6e
glEnable(GL_BLEND);
Shinya Kitaoka 120a6e
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Shinya Kitaoka 120a6e
glColor4d(0.9,0.9,0.1,0.5);
Shinya Kitaoka 120a6e
glRectd(0,0,w,h);
Shinya Kitaoka 120a6e
glDisable(GL_BLEND);
Shinya Kitaoka 120a6e
glColor3d(0,0,0);
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  glScaled(sc, sc, 1);
Shinya Kitaoka 120a6e
  tglDrawText(TPointD(8, -3), text);
Shinya Kitaoka 120a6e
  glPopMatrix();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void EditTool::draw() {
Shinya Kitaoka 120a6e
  // the tool is using the coordinate system of the parent object
Shinya Kitaoka 120a6e
  // glColor3d(1,0,1);
Shinya Kitaoka 120a6e
  // tglDrawCircle(crossHair,50);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*--Level編集モードのときは表示しない--*/
Shinya Kitaoka 120a6e
  if (TTool::getApplication()->getCurrentFrame()->isEditingLevel()) return;
Shinya Kitaoka 120a6e
  const TPixel32 normalColor(250, 127, 240);
Shinya Kitaoka 120a6e
  const TPixel32 highlightedColor(150, 255, 140);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // collect information
Shinya Kitaoka 120a6e
  TXsheet *xsh = getXsheet();
Shinya Kitaoka 120a6e
  /*--編集中のStageObjectIDを取得--*/
Shinya Kitaoka 120a6e
  TStageObjectId objId = getObjectId();
Shinya Kitaoka 120a6e
  int frame            = getFrame();
Shinya Kitaoka 120a6e
  TAffine parentAff    = xsh->getParentPlacement(objId, frame);
Shinya Kitaoka 120a6e
  TAffine aff          = xsh->getPlacement(objId, frame);
Shinya Kitaoka 120a6e
  TPointD center       = Stage::inch * xsh->getCenter(objId, frame);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*--3D表示のとき、Zを動かせるようにする--*/
Shinya Kitaoka 120a6e
  if (getViewer()->is3DView()) {
Shinya Kitaoka 120a6e
    glPushMatrix();
Shinya Kitaoka 120a6e
    glPushName(ZTranslation);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    tglColor(m_highlightedDevice == ZTranslation ? highlightedColor
Shinya Kitaoka 120a6e
                                                 : normalColor);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    glPushMatrix();
Shinya Kitaoka 120a6e
    double z = xsh->getZ(objId, frame);
Shinya Kitaoka 120a6e
    glTranslated(0, -1, z);
Shinya Kitaoka 120a6e
    drawArrow(50, isPicking());
Shinya Kitaoka 120a6e
    glPopName();
Shinya Kitaoka 120a6e
    glPopMatrix();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    glPopMatrix();
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  double unit = sqrt(tglGetPixelSize2());
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*-- ObjectのCenter位置を取得 --*/
Shinya Kitaoka 120a6e
  glPushMatrix();
Shinya Kitaoka 120a6e
  tglMultMatrix(parentAff.inv() * TTranslation(aff * TPointD(0.0, 0.0)));
Shinya Kitaoka 120a6e
  tglColor(normalColor);
Shinya Kitaoka 120a6e
  tglDrawDisk(TPointD(0.0, 0.0), unit * 4);
Shinya Kitaoka 120a6e
  glPopMatrix();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*-- Z移動 : 矢印(中心はCameraのCenter) --*/
Shinya Kitaoka 120a6e
  if (m_activeAxis.getValue() == L"Position" &&
Shinya Kitaoka 120a6e
      m_highlightedDevice == ZTranslation) {
Shinya Kitaoka 120a6e
    tglColor(normalColor);
Shinya Kitaoka 120a6e
    glPushMatrix();
Shinya Kitaoka 120a6e
    TStageObjectId currentCamId =
Shinya Kitaoka 120a6e
        xsh->getStageObjectTree()->getCurrentCameraId();
Shinya Kitaoka 120a6e
    TAffine camParentAff = xsh->getParentPlacement(currentCamId, frame);
Shinya Kitaoka 120a6e
    TAffine camAff       = xsh->getPlacement(currentCamId, frame);
Shinya Kitaoka 120a6e
    tglMultMatrix(camParentAff.inv() *
Shinya Kitaoka 120a6e
                  TTranslation(camAff * TPointD(0.0, 0.0)));
Shinya Kitaoka 120a6e
    glScaled(unit * 8, unit * 8, 1);
Shinya Kitaoka 120a6e
    drawZArrow();
Shinya Kitaoka 120a6e
    glPopMatrix();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*-- Rotation, Position : 垂直/水平線 --*/
Shinya Kitaoka 120a6e
  if (m_activeAxis.getValue() == L"Rotation" ||
Shinya Kitaoka 120a6e
      m_activeAxis.getValue() == L"Position") {
Shinya Kitaoka 120a6e
    glPushMatrix();
Shinya Kitaoka 120a6e
    tglMultMatrix(parentAff.inv() * aff * TTranslation(center));
Shinya Kitaoka 120a6e
    glScaled(unit, unit, 1);
Shinya Kitaoka 120a6e
    tglColor(normalColor);
Shinya Kitaoka 120a6e
    glBegin(GL_LINE_STRIP);
Shinya Kitaoka 120a6e
    glVertex2i(-800, 0);
Shinya Kitaoka 120a6e
    glVertex2i(800, 0);
Shinya Kitaoka 120a6e
    glEnd();
Shinya Kitaoka 120a6e
    glBegin(GL_LINE_STRIP);
Shinya Kitaoka 120a6e
    glVertex2i(0, -100);
Shinya Kitaoka 120a6e
    glVertex2i(0, 100);
Shinya Kitaoka 120a6e
    glEnd();
Shinya Kitaoka 120a6e
    glPopMatrix();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  glPushMatrix();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  tglMultMatrix(parentAff.inv() * TTranslation(aff * center));
Shinya Kitaoka 120a6e
  center = TPointD();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool dragging = m_dragTool != 0;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // draw center
Shinya Kitaoka 120a6e
  tglColor(normalColor);
Shinya Kitaoka 120a6e
  glPushName(Center);
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
    tglDrawCircle(center, unit * 10);
Shinya Kitaoka 120a6e
    tglDrawCircle(center, unit * 8);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    /*-- 円の中に十字を描く Center位置にTranslate済み --*/
Shinya Kitaoka 120a6e
    glBegin(GL_LINE_STRIP);
Shinya Kitaoka 120a6e
    glVertex2d(-unit * 8, 0.0);
Shinya Kitaoka 120a6e
    glVertex2d(unit * 8, 0.0);
Shinya Kitaoka 120a6e
    glEnd();
Shinya Kitaoka 120a6e
    glBegin(GL_LINE_STRIP);
Shinya Kitaoka 120a6e
    glVertex2d(0.0, -unit * 8);
Shinya Kitaoka 120a6e
    glVertex2d(0.0, unit * 8);
Shinya Kitaoka 120a6e
    glEnd();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  glPopName();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // draw label (column/pegbar name; possibly camera icon)
Shinya Kitaoka 120a6e
  tglColor(normalColor);
Shinya Kitaoka 120a6e
  glPushMatrix();
Shinya Kitaoka 120a6e
  glTranslated(center.x + unit * 10, center.y - unit * 20, 0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*-- Object名を表示 --*/
Shinya Kitaoka 120a6e
  TStageObject *pegbar = xsh->getStageObject(objId);
Shinya Kitaoka 120a6e
  std::string name     = pegbar->getFullName();
Shinya Kitaoka 120a6e
  if (objId.isColumn() || objId.isPegbar() || objId.isTable()) {
Shinya Kitaoka 120a6e
    glScaled(unit * 2, unit * 1.5, 1);
Shinya Kitaoka 120a6e
    tglDrawText(TPointD(0, 0), name);
Shinya Kitaoka 120a6e
  } else if (objId.isCamera()) {
Shinya Kitaoka 120a6e
    glPushMatrix();
Shinya Kitaoka 120a6e
    glScaled(unit * 2, unit * 1.5, 1);
Shinya Kitaoka 120a6e
    tglDrawText(TPointD(12, 0), name);
Shinya Kitaoka 120a6e
    glPopMatrix();
Shinya Kitaoka 120a6e
    glScaled(unit, unit, 1);
Shinya Kitaoka 120a6e
    drawCameraIcon();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  glPopMatrix();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*--- アクティブでないカメラのPegbarを編集するときは、カメラ枠を表示する ---*/
Shinya Kitaoka 120a6e
  if (objId.isCamera()) {
Shinya Kitaoka 120a6e
    if (xsh->getStageObjectTree()->getCurrentCameraId() != objId) {
Shinya Kitaoka 120a6e
      // TODO : glLineStipple has been deprecated in the OpenGL APIs. Need to be
Shinya Kitaoka 120a6e
      // replaced. 2016/1/20 shun_iwasawa
Shinya Kitaoka 120a6e
      glEnable(GL_LINE_STIPPLE);
Shinya Kitaoka 120a6e
      glColor3d(1.0, 0.0, 1.0);
Shinya Kitaoka 120a6e
      glLineStipple(1, 0x1111);
Shinya Kitaoka 120a6e
      TRectD cameraRect = TTool::getApplication()
Shinya Kitaoka 120a6e
                              ->getCurrentScene()
Shinya Kitaoka 120a6e
                              ->getScene()
Shinya Kitaoka 120a6e
                              ->getCurrentCamera()
Shinya Kitaoka 120a6e
                              ->getStageRect();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      glPushMatrix();
Shinya Kitaoka 120a6e
      tglDrawRect(cameraRect);
Shinya Kitaoka 120a6e
      glPopMatrix();
Shinya Kitaoka 120a6e
      glDisable(GL_LINE_STIPPLE);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  glPopMatrix();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_fxGadgetController->draw(isPicking());
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void EditTool::onActivate() {
Shinya Kitaoka 120a6e
  if (m_firstTime) {
Shinya Kitaoka 120a6e
    m_lockCenterX.setValue(LockCenterX ? 1 : 0);
Shinya Kitaoka 120a6e
    m_lockCenterY.setValue(LockCenterY ? 1 : 0);
Shinya Kitaoka 120a6e
    m_lockPositionX.setValue(LockPositionX ? 1 : 0);
Shinya Kitaoka 120a6e
    m_lockPositionY.setValue(LockPositionY ? 1 : 0);
Shinya Kitaoka 120a6e
    m_lockRotation.setValue(LockRotation ? 1 : 0);
Shinya Kitaoka 120a6e
    m_lockShearH.setValue(LockShearH ? 1 : 0);
Shinya Kitaoka 120a6e
    m_lockShearV.setValue(LockShearV ? 1 : 0);
Shinya Kitaoka 120a6e
    m_lockScaleH.setValue(LockScaleH ? 1 : 0);
Shinya Kitaoka 120a6e
    m_lockScaleV.setValue(LockScaleV ? 1 : 0);
Shinya Kitaoka 120a6e
    m_lockGlobalScale.setValue(LockGlobalScale ? 1 : 0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    m_showEWNSposition.setValue(ShowEWNSposition ? 1 : 0);
Shinya Kitaoka 120a6e
    m_showZposition.setValue(ShowZposition ? 1 : 0);
Shinya Kitaoka 120a6e
    m_showSOposition.setValue(ShowSOposition ? 1 : 0);
Shinya Kitaoka 120a6e
    m_showRotation.setValue(ShowRotation ? 1 : 0);
Shinya Kitaoka 120a6e
    m_showGlobalScale.setValue(ShowGlobalScale ? 1 : 0);
Shinya Kitaoka 120a6e
    m_showHVscale.setValue(ShowHVscale ? 1 : 0);
Shinya Kitaoka 120a6e
    m_showShear.setValue(ShowShear ? 1 : 0);
Shinya Kitaoka 120a6e
    m_showCenterPosition.setValue(ShowCenterPosition ? 1 : 0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    m_fxGadgetController = new FxGadgetController(this);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    /*
Shinya Kitaoka 120a6e
m_foo.setTool(this);
Shinya Kitaoka 120a6e
m_foo.setFxHandle(getApplication()->getCurrentFx());
Shinya Kitaoka 120a6e
*/
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    m_firstTime = false;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TStageObjectId objId = getObjectId();
Shinya Kitaoka 120a6e
  if (objId == TStageObjectId::NoneId) {
Shinya Kitaoka 120a6e
    int index              = getColumnIndex();
Shinya Kitaoka 120a6e
    if (index == -1) objId = TStageObjectId::CameraId(0);
Shinya Kitaoka 120a6e
    objId                  = TStageObjectId::ColumnId(index);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  TTool::getApplication()->getCurrentObject()->setObjectId(objId);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void EditTool::onDeactivate() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool EditTool::onPropertyChanged(std::string propertyName) {
Shinya Kitaoka 120a6e
  if (propertyName == m_lockCenterX.getName())
Shinya Kitaoka 120a6e
    LockCenterX = (int)m_lockCenterX.getValue();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  else if (propertyName == m_lockCenterY.getName())
Shinya Kitaoka 120a6e
    LockCenterY = (int)m_lockCenterY.getValue();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  else if (propertyName == m_lockPositionX.getName())
Shinya Kitaoka 120a6e
    LockPositionX = (int)m_lockPositionX.getValue();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  else if (propertyName == m_lockPositionY.getName())
Shinya Kitaoka 120a6e
    LockPositionY = (int)m_lockPositionY.getValue();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  else if (propertyName == m_lockRotation.getName())
Shinya Kitaoka 120a6e
    LockRotation = (int)m_lockRotation.getValue();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  else if (propertyName == m_lockShearH.getName())
Shinya Kitaoka 120a6e
    LockShearH = (int)m_lockShearH.getValue();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  else if (propertyName == m_lockShearV.getName())
Shinya Kitaoka 120a6e
    LockShearV = (int)m_lockShearV.getValue();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  else if (propertyName == m_lockScaleH.getName())
Shinya Kitaoka 120a6e
    LockScaleH = (int)m_lockScaleH.getValue();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  else if (propertyName == m_lockScaleV.getName())
Shinya Kitaoka 120a6e
    LockScaleV = (int)m_lockScaleV.getValue();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  else if (propertyName == m_lockGlobalScale.getName())
Shinya Kitaoka 120a6e
    LockGlobalScale = (int)m_lockGlobalScale.getValue();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  else if (propertyName == m_showEWNSposition.getName())
Shinya Kitaoka 120a6e
    ShowEWNSposition = (int)m_showEWNSposition.getValue();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  else if (propertyName == m_showZposition.getName())
Shinya Kitaoka 120a6e
    ShowZposition = (int)m_showZposition.getValue();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  else if (propertyName == m_showSOposition.getName())
Shinya Kitaoka 120a6e
    ShowSOposition = (int)m_showSOposition.getValue();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  else if (propertyName == m_showRotation.getName())
Shinya Kitaoka 120a6e
    ShowRotation = (int)m_showRotation.getValue();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  else if (propertyName == m_showGlobalScale.getName())
Shinya Kitaoka 120a6e
    ShowGlobalScale = (int)m_showGlobalScale.getValue();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  else if (propertyName == m_showHVscale.getName())
Shinya Kitaoka 120a6e
    ShowHVscale = (int)m_showHVscale.getValue();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  else if (propertyName == m_showShear.getName())
Shinya Kitaoka 120a6e
    ShowShear = (int)m_showShear.getValue();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  else if (propertyName == m_showCenterPosition.getName())
Shinya Kitaoka 120a6e
    ShowCenterPosition = (int)m_showCenterPosition.getValue();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*-- Active Axis の変更 --*/
Shinya Kitaoka 120a6e
  else if (propertyName == m_activeAxis.getName()) {
Shinya Kitaoka 120a6e
    std::wstring activeAxis = m_activeAxis.getValue();
Shinya Kitaoka 120a6e
    if (activeAxis == L"Position")
Shinya Kitaoka 120a6e
      m_what = Translation;
Shinya Kitaoka 120a6e
    else if (activeAxis == L"Rotation")
Shinya Kitaoka 120a6e
      m_what = Rotation;
Shinya Kitaoka 120a6e
    else if (activeAxis == L"Scale")
Shinya Kitaoka 120a6e
      m_what = Scale;
Shinya Kitaoka 120a6e
    else if (activeAxis == L"Shear")
Shinya Kitaoka 120a6e
      m_what = Shear;
Shinya Kitaoka 120a6e
    else if (activeAxis == L"Center")
Shinya Kitaoka 120a6e
      m_what = Center;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  return true;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
int EditTool::getCursorId() const {
Shinya Kitaoka 120a6e
  /*--- FxParameter操作中のカーソル ---*/
Shinya Kitaoka 120a6e
  if (m_highlightedDevice >= 1000) return ToolCursor::FxGadgetCursor;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*--- カーソルをアクティブな軸に応じて選ぶ --*/
Shinya Kitaoka 120a6e
  std::wstring activeAxis = m_activeAxis.getValue();
Shinya Kitaoka 120a6e
  if (activeAxis == L"Position") {
Shinya Kitaoka 120a6e
    if (m_highlightedDevice == ZTranslation)
Shinya Kitaoka 120a6e
      return ToolCursor::MoveZCursor;
Shinya Kitaoka 120a6e
    else if (LockPositionX && LockPositionY)
Shinya Kitaoka 120a6e
      return ToolCursor::DisableCursor;
Shinya Kitaoka 120a6e
    else if (LockPositionX)
Shinya Kitaoka 120a6e
      return ToolCursor::MoveNSCursor;
Shinya Kitaoka 120a6e
    else if (LockPositionY)
Shinya Kitaoka 120a6e
      return ToolCursor::MoveEWCursor;
Shinya Kitaoka 120a6e
    else
Shinya Kitaoka 120a6e
      return ToolCursor::MoveCursor;
Shinya Kitaoka 120a6e
  } else if (activeAxis == L"Rotation") {
Shinya Kitaoka 120a6e
    return ToolCursor::RotCursor;
Shinya Kitaoka 120a6e
  } else if (activeAxis == L"Scale") {
Shinya Kitaoka 120a6e
    if (m_highlightedDevice == ScaleXY) {
Shinya Kitaoka 120a6e
      if (LockScaleH && LockScaleV)
Shinya Kitaoka 120a6e
        return ToolCursor::DisableCursor;
Shinya Kitaoka 120a6e
      else if (LockScaleH)
Shinya Kitaoka 120a6e
        return ToolCursor::ScaleVCursor;
Shinya Kitaoka 120a6e
      else if (LockScaleV)
Shinya Kitaoka 120a6e
        return ToolCursor::ScaleHCursor;
Shinya Kitaoka 120a6e
      else
Shinya Kitaoka 120a6e
        return ToolCursor::ScaleHVCursor;
Shinya Kitaoka 120a6e
    } else
Shinya Kitaoka 120a6e
      return ToolCursor::ScaleGlobalCursor;
Shinya Kitaoka 120a6e
  } else if (activeAxis == L"Shear") {
Shinya Kitaoka 120a6e
    if (LockShearH && LockShearV)
Shinya Kitaoka 120a6e
      return ToolCursor::DisableCursor;
Shinya Kitaoka 120a6e
    else if (LockShearH)
Shinya Kitaoka 120a6e
      return ToolCursor::ScaleVCursor;
Shinya Kitaoka 120a6e
    else if (LockShearV)
Shinya Kitaoka 120a6e
      return ToolCursor::ScaleHCursor;
Shinya Kitaoka 120a6e
    else
Shinya Kitaoka 120a6e
      return ToolCursor::ScaleCursor;
Shinya Kitaoka 120a6e
  } else if (activeAxis == L"Center") {
Shinya Kitaoka 120a6e
    if (LockCenterX && LockCenterY)
Shinya Kitaoka 120a6e
      return ToolCursor::DisableCursor;
Shinya Kitaoka 120a6e
    else if (LockCenterX)
Shinya Kitaoka 120a6e
      return ToolCursor::MoveNSCursor;
Shinya Kitaoka 120a6e
    else if (LockCenterY)
Shinya Kitaoka 120a6e
      return ToolCursor::MoveEWCursor;
Shinya Kitaoka 120a6e
    else
Shinya Kitaoka 120a6e
      return ToolCursor::MoveCursor;
Shinya Kitaoka 120a6e
  } else
Shinya Kitaoka 120a6e
    return ToolCursor::StrokeSelectCursor;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
EditTool arrowTool;