3a19fe
#pragma once
3a19fe
3a19fe
#ifndef ASSISTANTVANISHINGPOINT_INCLUDED
3a19fe
#define ASSISTANTVANISHINGPOINT_INCLUDED
3a19fe
3a19fe
3a19fe
// TnzTools includes
3a19fe
#include <tools assistant.h=""></tools>
3a19fe
#include <tools assistants="" guidelineline.h=""></tools>
3a19fe
3a19fe
// TnzCore includes
3a19fe
#include <tgl.h></tgl.h>
3a19fe
3a19fe
3a19fe
//*****************************************************************************************
3a19fe
//    TAssistantVanishingPoint definition
3a19fe
//*****************************************************************************************
3a19fe
3a19fe
class TAssistantVanishingPoint final : public TAssistant {
3a19fe
  Q_DECLARE_TR_FUNCTIONS(TAssistantVanishingPoint)
3a19fe
public:
3a19fe
  const TStringId m_idPassThrough;
3a19fe
  const TStringId m_idGrid;
3a19fe
  const TStringId m_idPerspective;
3a19fe
3a19fe
protected:
3a19fe
  TAssistantPoint &m_center;
3a19fe
  TAssistantPoint &m_a0;
3a19fe
  TAssistantPoint &m_a1;
3a19fe
  TAssistantPoint &m_b0;
3a19fe
  TAssistantPoint &m_b1;
3a19fe
  TAssistantPoint &m_grid0;
3a19fe
  TAssistantPoint &m_grid1;
3a19fe
3a19fe
public:
3a19fe
  TAssistantVanishingPoint(TMetaObject &object);
3a19fe
3a19fe
  static QString getLocalName();
3a19fe
3a19fe
  void updateTranslation() const override;
3a19fe
3a19fe
  inline bool getPassThrough() const
3a19fe
    { return data()[m_idPassThrough].getBool(); }
3a19fe
  inline bool getGrid() const
3a19fe
    { return data()[m_idGrid].getBool(); }
3a19fe
  inline bool getPerspective() const
3a19fe
    { return data()[m_idPerspective].getBool(); }
3a19fe
3a19fe
  void onDataChanged(const TVariant &value) override;
3a19fe
3a19fe
private:
3a19fe
  void fixCenter();
3a19fe
  void fixSidePoint(TAssistantPoint &p0, TAssistantPoint &p1, TPointD previousP0);
3a19fe
  void fixSidePoint(TAssistantPoint &p0, TAssistantPoint &p1);
3a19fe
  void fixGrid1(const TPointD &previousCenter, const TPointD &previousGrid0);
3a19fe
3a19fe
public:
3a19fe
  void onFixPoints() override;
3a19fe
  void onMovePoint(TAssistantPoint &point, const TPointD &position) override;
3a19fe
3a19fe
  void getGuidelines(
3a19fe
    const TPointD &position,
3a19fe
    const TAffine &toTool,
3a19fe
    TGuidelineList &outGuidelines ) const override;
3a19fe
3a19fe
  static void drawSimpleGrid(
3a19fe
    const TPointD ¢er,
3a19fe
    const TPointD &grid0,
3a19fe
    const TPointD &grid1,
3a19fe
    double alpha );
3a19fe
  
3a19fe
  static void drawPerspectiveGrid(
3a19fe
    const TPointD ¢er,
3a19fe
    const TPointD &grid0,
3a19fe
    const TPointD &grid1,
3a19fe
    double alpha );
3a19fe
  
3a19fe
  void draw(TToolViewer *viewer, bool enabled) const override;
3a19fe
  void drawEdit(TToolViewer *viewer) const override;
3a19fe
};
3a19fe
3a19fe
3a19fe
#endif