shun-iwasawa 86dc52
#pragma once
shun-iwasawa 86dc52
shun-iwasawa 86dc52
#ifndef VIEWTOOLS_H
shun-iwasawa 86dc52
#define VIEWTOOLS_H
shun-iwasawa 86dc52
shun-iwasawa 86dc52
#include "tools/tool.h"
shun-iwasawa 86dc52
#include "tstopwatch.h"
shun-iwasawa 86dc52
#include "tproperty.h"
shun-iwasawa 86dc52
shun-iwasawa 86dc52
//=============================================================================
shun-iwasawa 86dc52
// Rotate Tool
shun-iwasawa 86dc52
//-----------------------------------------------------------------------------
shun-iwasawa 86dc52
shun-iwasawa 86dc52
class RotateTool final : public QObject, public TTool {
shun-iwasawa 86dc52
  Q_OBJECT
shun-iwasawa 86dc52
shun-iwasawa 86dc52
  TStopWatch m_sw;
shun-iwasawa 86dc52
  TPointD m_oldPos;
shun-iwasawa 86dc52
  TPointD m_center;
shun-iwasawa 86dc52
  bool m_dragging;
shun-iwasawa 86dc52
  double m_angle;
shun-iwasawa 86dc52
  TPointD m_oldMousePos;
shun-iwasawa 86dc52
  TBoolProperty m_cameraCentered;
shun-iwasawa 86dc52
  TPropertyGroup m_prop;
shun-iwasawa 86dc52
shun-iwasawa 86dc52
public:
shun-iwasawa 86dc52
  RotateTool();
shun-iwasawa 86dc52
shun-iwasawa 86dc52
  ToolType getToolType() const override { return TTool::GenericTool; }
shun-iwasawa 86dc52
  void updateMatrix() override { return setMatrix(TAffine()); }
shun-iwasawa 86dc52
  TPropertyGroup *getProperties(int targetType) override { return &m_prop; }
shun-iwasawa 86dc52
shun-iwasawa 86dc52
  void leftButtonDown(const TPointD &pos, const TMouseEvent &e) override;
shun-iwasawa 86dc52
  void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override;
shun-iwasawa 86dc52
  void leftButtonUp(const TPointD &pos, const TMouseEvent &e) override;
shun-iwasawa 86dc52
  void draw() override;
shun-iwasawa 86dc52
shun-iwasawa 86dc52
  int getCursorId() const override;
shun-iwasawa 86dc52
artisteacher fd1c1e
  void updateTranslation() override {
shun-iwasawa 86dc52
    m_cameraCentered.setQStringName(tr("Rotate On Camera Center"));
shun-iwasawa 86dc52
  }
shun-iwasawa 86dc52
};
shun-iwasawa 86dc52
otakuto 42feb5
#endif  // VIEWTOOLS_H