manongjohn 19dec5
#pragma once
manongjohn 19dec5
manongjohn 19dec5
#ifndef EDITTOOL_INCLUDED
manongjohn 19dec5
#define EDITTOOL_INCLUDED
manongjohn 19dec5
manongjohn 19dec5
#include "tool.h"
manongjohn 19dec5
#include "tproperty.h"
manongjohn 19dec5
#include "edittoolgadgets.h"
manongjohn 19dec5
manongjohn 19dec5
// For Qt translation support
manongjohn 19dec5
#include <qcoreapplication></qcoreapplication>
manongjohn 19dec5
manongjohn 19dec5
using EditToolGadgets::DragTool;
manongjohn 19dec5
manongjohn 19dec5
//=============================================================================
manongjohn 19dec5
// EditTool
manongjohn 19dec5
//-----------------------------------------------------------------------------
manongjohn 19dec5
manongjohn 19dec5
class EditTool final : public QObject, public TTool {
manongjohn 19dec5
  Q_OBJECT
manongjohn 19dec5
manongjohn 19dec5
  DragTool* m_dragTool;
manongjohn 19dec5
manongjohn 19dec5
  bool m_firstTime;
manongjohn 19dec5
manongjohn 19dec5
  enum {
manongjohn 19dec5
    None        = -1,
manongjohn 19dec5
    Translation = 1,
manongjohn 19dec5
    Rotation,
manongjohn 19dec5
    Scale,
manongjohn 19dec5
    ScaleX,
manongjohn 19dec5
    ScaleY,
manongjohn 19dec5
    ScaleXY,
manongjohn 19dec5
    Center,
manongjohn 19dec5
    ZTranslation,
manongjohn 19dec5
    Shear,
manongjohn 19dec5
  };
manongjohn 19dec5
manongjohn 19dec5
  // DragInfo m_dragInfo;
manongjohn 19dec5
manongjohn 19dec5
  TPointD m_lastPos;
manongjohn 19dec5
  TPointD m_curPos;
manongjohn 19dec5
  TPointD m_firstPos;
manongjohn 19dec5
  TPointD m_curCenter;
manongjohn 19dec5
manongjohn 19dec5
  bool m_active;
manongjohn 19dec5
  bool m_keyFrameAdded;
manongjohn 19dec5
  int m_what;
manongjohn 19dec5
  int m_highlightedDevice;
manongjohn 19dec5
manongjohn 19dec5
  double m_oldValues[2];
manongjohn 19dec5
manongjohn 19dec5
  double m_currentScaleFactor;
manongjohn 19dec5
  FxGadgetController* m_fxGadgetController;
manongjohn 19dec5
manongjohn 19dec5
  bool m_isAltPressed;
manongjohn 19dec5
manongjohn 19dec5
  TEnumProperty m_scaleConstraint;
manongjohn 19dec5
  TEnumProperty m_autoSelect;
manongjohn 19dec5
  TBoolProperty m_globalKeyframes;
manongjohn 19dec5
manongjohn 19dec5
  TBoolProperty m_lockCenterX;
manongjohn 19dec5
  TBoolProperty m_lockCenterY;
manongjohn 19dec5
  TBoolProperty m_lockPositionX;
manongjohn 19dec5
  TBoolProperty m_lockPositionY;
manongjohn 19dec5
  TBoolProperty m_lockRotation;
manongjohn 19dec5
  TBoolProperty m_lockShearH;
manongjohn 19dec5
  TBoolProperty m_lockShearV;
manongjohn 19dec5
  TBoolProperty m_lockScaleH;
manongjohn 19dec5
  TBoolProperty m_lockScaleV;
manongjohn 19dec5
  TBoolProperty m_lockGlobalScale;
manongjohn 19dec5
manongjohn 19dec5
  TBoolProperty m_showEWNSposition;
manongjohn 19dec5
  TBoolProperty m_showZposition;
manongjohn 19dec5
  TBoolProperty m_showSOposition;
manongjohn 19dec5
  TBoolProperty m_showRotation;
manongjohn 19dec5
  TBoolProperty m_showGlobalScale;
manongjohn 19dec5
  TBoolProperty m_showHVscale;
manongjohn 19dec5
  TBoolProperty m_showShear;
manongjohn 19dec5
  TBoolProperty m_showCenterPosition;
manongjohn 19dec5
manongjohn 19dec5
  TEnumProperty m_activeAxis;
manongjohn 19dec5
manongjohn 19dec5
  TPropertyGroup m_prop;
manongjohn 19dec5
manongjohn 19dec5
  void drawMainHandle();
manongjohn 19dec5
  void onEditAllLeftButtonDown(TPointD& pos, const TMouseEvent& e);
manongjohn 19dec5
manongjohn 19dec5
public:
manongjohn 19dec5
  EditTool();
manongjohn 19dec5
  ~EditTool();
manongjohn 19dec5
manongjohn 19dec5
  ToolType getToolType() const override { return TTool::ColumnTool; }
manongjohn 19dec5
manongjohn 19dec5
  bool doesApply() const;  // ritorna vero se posso deformare l'oggetto corrente
manongjohn 19dec5
  void saveOldValues();
manongjohn 19dec5
  bool transformEnabled() const;
manongjohn 19dec5
manongjohn 19dec5
  const TStroke* getSpline() const;
manongjohn 19dec5
manongjohn 19dec5
  void rotate();
manongjohn 19dec5
  void move();
manongjohn 19dec5
  void moveCenter();
manongjohn 19dec5
  void scale();
manongjohn 19dec5
  void isoScale();
manongjohn 19dec5
  void squeeze();
manongjohn 19dec5
  void shear(const TPointD& pos, bool single);
manongjohn 19dec5
manongjohn 19dec5
  void updateTranslation() override;
manongjohn 19dec5
manongjohn 19dec5
  void leftButtonDown(const TPointD& pos, const TMouseEvent&) override;
manongjohn 19dec5
  void leftButtonDrag(const TPointD& pos, const TMouseEvent&) override;
manongjohn 19dec5
  void leftButtonUp(const TPointD& pos, const TMouseEvent&) override;
manongjohn 19dec5
manongjohn 19dec5
  void mouseMove(const TPointD&, const TMouseEvent& e) override;
manongjohn 19dec5
manongjohn 19dec5
  void draw() override;
manongjohn 19dec5
manongjohn 19dec5
  void transform(const TAffine& aff);
manongjohn 19dec5
manongjohn 19dec5
  void onActivate() override;
manongjohn 19dec5
  void onDeactivate() override;
manongjohn 19dec5
  bool onPropertyChanged(std::string propertyName) override;
manongjohn 19dec5
manongjohn 19dec5
  void computeBBox();
manongjohn 19dec5
manongjohn 19dec5
  int getCursorId() const override;
manongjohn 19dec5
manongjohn 19dec5
  TPropertyGroup* getProperties(int targetType) override { return &m_prop; }
manongjohn 19dec5
manongjohn 19dec5
  void updateMatrix() override {
manongjohn 19dec5
    setMatrix(
manongjohn 19dec5
        getCurrentObjectParentMatrix2());  // getCurrentObjectParentMatrix());
manongjohn 19dec5
  }
manongjohn 19dec5
manongjohn 19dec5
  void drawText(const TPointD& p, double unit, std::string text);
manongjohn 19dec5
manongjohn 19dec5
  QString updateEnabled(int rowIndex, int columnIndex) override;
manongjohn 19dec5
manongjohn 19dec5
signals:
manongjohn 19dec5
  void clickFlipHorizontal();
manongjohn 19dec5
  void clickFlipVertical();
manongjohn 19dec5
  void clickRotateLeft();
manongjohn 19dec5
  void clickRotateRight();
manongjohn 19dec5
};
manongjohn 19dec5
manongjohn 19dec5
#endif  // EDITTOOL_INCLUDED