Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TOOLEHANDLE_H
Toshihiro Shimizu 890ddd
#define TOOLEHANDLE_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
#include "timage.h"
Toshihiro Shimizu 890ddd
#include <qobject></qobject>
Toshihiro Shimizu 890ddd
#include <qmap></qmap>
shun-iwasawa 443318
#include <qelapsedtimer></qelapsedtimer>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// forward declaration
Toshihiro Shimizu 890ddd
class TTool;
Toshihiro Shimizu 890ddd
class QAction;
Toshihiro Shimizu 890ddd
class QString;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TNZTOOLS_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
//=============================================================================
Toshihiro Shimizu 890ddd
// ToolHandle
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DVAPI ToolHandle final : public QObject {
Shinya Kitaoka 120a6e
  Q_OBJECT
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TTool *m_tool;
Shinya Kitaoka 120a6e
  QString m_toolName;
Shinya Kitaoka 120a6e
  int m_toolTargetType;
Shinya Kitaoka 120a6e
  QString m_storedToolName;
shun-iwasawa 443318
  QElapsedTimer m_storedToolTime;
Shinya Kitaoka 120a6e
  QString m_oldToolName;
Shinya Kitaoka 120a6e
  bool m_toolIsBusy;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ToolHandle();
Shinya Kitaoka 120a6e
  ~ToolHandle();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TTool *getTool() const;
Shinya Kitaoka 120a6e
  void setTool(QString name);
Shinya Kitaoka 120a6e
  void setTargetType(int targetType);
Toshihiro Shimizu 890ddd
534c7c
  const QString& getRequestedToolName() const
534c7c
    { return m_toolName; }
534c7c
  
Shinya Kitaoka 120a6e
  // used to change tool for a short while (e.g. while keeping pressed a
Shinya Kitaoka 120a6e
  // short-key)
Shinya Kitaoka 120a6e
  void storeTool();
Shinya Kitaoka 120a6e
  void restoreTool();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // used to set a tool that is not listed in the toolbar (e.g. the
Shinya Kitaoka 120a6e
  // ShiftTraceTool).
Shinya Kitaoka 120a6e
  void setPseudoTool(QString name);
Shinya Kitaoka 120a6e
  void unsetPseudoTool();
Shinya Kitaoka 120a6e
  void setToolBusy(bool value);
Shinya Kitaoka 120a6e
  bool isToolBusy() { return m_toolIsBusy; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*! Notify tool parameters change (out of toolOption bar).*/
Shinya Kitaoka 120a6e
  void notifyToolChanged() { emit toolChanged(); }
cbbe07
  void notifyToolOptionsBoxChanged() { emit toolOptionsBoxChanged(); }
Shinya Kitaoka 120a6e
  void notifyToolCursorTypeChanged() { emit toolCursorTypeChanged(); }
manongjohn b66bc4
manongjohn b66bc4
  void notifyToolComboBoxListChanged(std::string id) {
manongjohn b66bc4
    emit toolComboBoxListChanged(id);
manongjohn b66bc4
  }
manongjohn b66bc4
Toshihiro Shimizu 890ddd
signals:
manongjohn b66bc4
  void toolComboBoxListChanged(std::string);
Shinya Kitaoka 120a6e
  void toolSwitched();
Shinya Kitaoka 120a6e
  void toolChanged();
cbbe07
  void toolOptionsBoxChanged();
Shinya Kitaoka 120a6e
  void toolEditingFinished();
Shinya Kitaoka 120a6e
  // used for changing the tool cursor when the options changed with short cut
Shinya Kitaoka 120a6e
  // keys assigned for tool options.
Shinya Kitaoka 120a6e
  void toolCursorTypeChanged();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public slots:
Shinya Kitaoka 120a6e
  // void changeTool(QAction* action);
Shinya Kitaoka 120a6e
  void onImageChanged(TImage::Type type);
Shinya Kitaoka 120a6e
  void updateMatrix();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // TOOLEHANDLE_H