//////////////////////////////////////////////////////////////////////////////
//
//  Copyright 2025 Autodesk, Inc.  All rights reserved.
//
//  Use of this software is subject to the terms of the Autodesk license 
//  agreement provided at the time of installation or download, or which 
//  otherwise accompanies this software in either electronic or hard copy form.   
//
//////////////////////////////////////////////////////////////////////////////
#ifndef __ANNOTATIONVIEW_H
#define __ANNOTATIONVIEW_H

#ifndef __ACMDEF_H
	#error include 'acmdef.h' before including this file
#endif
#ifndef __SYMSTD_H
	#error include 'symStd.h' before including this file
#endif
class AcmSymbol;
class AcmSymbolStd;
class AmdtAnViewStdImp;
///<summary>This class is for annotation view standard in AutoCAD/M.</summary>
class ACMSYMBB_CRX_DLLSHARE AmdtAnViewStd : public AcmSymbolStd
{
  friend class AcmSymbbInternals;

public:
  ACRX_DECLARE_MEMBERS(AmdtAnViewStd);
  virtual ~AmdtAnViewStd();
  const ACHAR* getBaseSymStdClassName() const override;

  ///<summary>Function returns default position of annotation view label entity. FIX_THIS_Table Item FIX_THIS_Table</summary>
  virtual Acm::AnnotLabelPositionType defaultLabelPosition() const;
  ///<summary>Returns default label pattern of annotation view label entity.</summary>
  virtual CString defaultLabelPattern()const;
  ///<summary>Function returns array of supported label pattern variables.</summary>
  ///<param name="patternVars">CStringArray, output only. Array of supported label pattern variables.
  ///Here is the default list of supported variables: FIX_THIS_Table Item CStringArray, output only. Array of supported label pattern variables.
  ///Here is the default list of supported variables: FIX_THIS_Table </param>
  virtual void labelPatternVariables (CStringArray &patternVars) const;
  ///<summary>Sets the factory default values.</summary>
  virtual Adesk::Boolean setFactoryDefaults();
  ///<summary>Returns default margin of annotation view.</summary>
  virtual double defaultMargin()const;
  ///<summary>Set default values for text height, text color, arrow size, arrow type and leader color to the same as that in master standard.</summary>
  virtual void setDefaultTextLeader();


  ///<summary>Function returns current position of annotation view label entity.</summary>
  Acm::AnnotLabelPositionType getLabelPosition()const;
  ///<summary>Function modifies current position of annotation view label entity.</summary>
  ///<param name="value">Input only. Position of annotation view label entity.</param>
  Adesk::Boolean setLabelPosition(Acm::AnnotLabelPositionType value);

  ///<summary>Returns default margin of annotation view.</summary>
  double getMargin() const;

  ///<summary>Returns label pattern used by annotation view label entities.</summary>
  const ACHAR* getLabelPattern() const;
  ///<summary>Modifies label pattern used by annotation view label entities.</summary>
  ///<param name="value">String, input only. Label pattern for label entity.</param>
  Adesk::Boolean setLabelPattern(const ACHAR* value);

  AcDbObjectId textStyleId() const;
  void setTextStyleId(const AcDbObjectId& id);
  ///<summary>Retrieves the by standard state for the corresponding property.</summary>
  bool textStyleByStandard() const;
  ///<summary>Set the by standard state for the corresponding property.</summary>
  ///<param name="byStandard">New state to set to.</param>
  void setTextStyleByStandard(bool byStandard);
  ///<summary>Set the by standard state for the corresponding property.</summary>
  ///<param name="byStandard">New state to set to.</param>
  virtual void setTextHeightByStandard(bool byStandard);
  ///<summary>Set the by standard state for the corresponding property.</summary>
  ///<param name="byStandard ">New state to set to.  </param>
  virtual void setTextColorByStandard(bool byStandard);
  ///<summary>Returns the value of the text height associated to the by standard state for this symbol std.</summary>
  virtual double byStdTextHeight() const;
  ///<summary>Returns the text color associated to the by standard state for this symbol std.</summary>
  virtual const AcCmColor & byStdTextTrueColor() const;

  virtual Acm::ErrorStatus getDescription(CString& desc,
                                          CBitmap*& pBmpLoaded,
                                          CBitmap*& pBmpReg,
                                          Adesk::Boolean& enablePref) const;

  virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler* filer);
  virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler* filer) const;
  ///<summary>Set height, color and text style of the specified text to that in the symbol standard.</summary>
  virtual void getMTextProperties(AcDbMText& text) const;
  ///<summary>Returns true if the text height associated to the by standard state for this symbol std 
  ///is a size up from the text height of the owning AcmStandard. Otherwise, returns false.</summary>
  virtual bool isHeightSizedUp() const;

protected:
  ///<summary>The constructor is protected.</summary>
  AmdtAnViewStd();
  ///<summary>This is a protected member function that is used to properly synchronize the AnnotationView
  ///standard if the standard changes units.</summary>
  virtual Acm::ErrorStatus onChangeUnits(Adesk::Boolean isMetric);

  virtual Acad::ErrorStatus subGetClassID(CLSID* pClsid) const;

private:
  AmdtAnViewStdImp* mpImp;
};
DBREF_DECLARE(AmdtAnViewStd)

class AmdtCAnnotationLabelImp;
class AmdtAnnotationLabel;

///<summary>This class is for subsymbol of annotation view label entity in AutoCAD/M.</summary>
class AmdtCAnnotationLabel : public AcmCSubSymbol {
public:

  AmdtCAnnotationLabel(AmdtAnnotationLabel* pSym);
  virtual ~AmdtCAnnotationLabel();

  // Copy constructor
  AmdtCAnnotationLabel(const AmdtCAnnotationLabel& other);

  Adesk::Boolean operator==(const AmdtCAnnotationLabel&) const;
  virtual AmdtCAnnotationLabel& operator=(const AmdtCAnnotationLabel&);
  virtual AmdtCAnnotationLabel* clone()const;
  virtual void clear();

  AmdtCAnnotationLabelImp* getImp() const { return mpImp; }

  virtual void getSubEntsText(AcmCAuxEntArray& subents) const;  
  ///<summary>Function used to modify offset of text in annotation view label entity, offset is vector from entity origin to position of label text.</summary>
  ///<param name="offset">Vector, input only. Vector specifying new offset of label text.</param>
  virtual void setLabelOffset(const AcGeVector3d& offset);
  virtual AcGeVector3d getLabelOffest() const;

  virtual AcGePoint3d origin() const override;
  ///<summary>Sets the origin of the symbol in WCS.</summary>
  virtual void setOrigin(const AcGePoint3d& origin) override;
  ///<summary>Gets the value of any symbol variable.</summary>
  virtual LPCTSTR value(Acm::Variable var) const override;
  ///<summary>Gets the value of any symbol variable.</summary>
  virtual Acm::ErrorStatus getValue(Acm::Variable var, CString& value) const override;
  ///<summary>Sets the value of any symbol variable.</summary>
  virtual Acm::ErrorStatus setValue(Acm::Variable var, LPCTSTR value) override;
  ///<summary>Gets the visibility status of the editing controls.</summary>
  virtual Acm::Visibility  variableStatus(Acm::Variable var) const override;
  ///<summary>Sets the visibility status of the editing controls.</summary>
  virtual Acm::ErrorStatus setVariableStatus(Acm::Variable var, Acm::Visibility status) override;
  ///<summary>Gets the variable support data, such as the help index, dialog index, tooltip string, and label string.</summary>
  virtual Acm::ErrorStatus getVarDlgInfo(Acm::Variable var, CVarDlgInfo& v) const override;
  ///<summary>Sets the variable support data, such as the help index, dialog index, tooltip string, and label string.</summary>
  virtual Acm::ErrorStatus setVarDlgInfo(Acm::Variable var, const CVarDlgInfo& v) override;


  virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler* filer, Adesk::UInt16 ver) override;
  virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler* filer) const override;

  Acad::ErrorStatus varInFields(const AcmVariant* pVar, AcRxObject* pFiler = nullptr) override;
  Acad::ErrorStatus varOutFields(AcmVariant* pVar, AcRxObject* pFiler = nullptr) const override;


  virtual Acad::ErrorStatus dxfInFields(AcDbDxfFiler* filer) override;
  virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler* filer) const override;

private:
    AmdtCAnnotationLabelImp* mpImp{ nullptr };
};




///<summary>This class is for annotation view label entity in AutoCAD/M.</summary>
class ACMSYMBB_CRX_DLLSHARE AmdtAnnotationLabel : public AcmSymbol {
  friend class AcmNoteTranslate;     
public:
  ACRX_DECLARE_MEMBERS(AmdtAnnotationLabel);
  ///<summary>Constructs the class.</summary>
  AmdtAnnotationLabel();
  ///<summary>Destroys the class.</summary>
  virtual ~AmdtAnnotationLabel();
  ///<summary>Function returns pointer to sub symbol entity.</summary>
  AmdtCAnnotationLabel* subSymbol() const;
  ///<param name="value">Pointer to string, input only. String specifying new pattern of annotation view label entity.</param>
  bool setLabelPattern(const ACHAR* value);
  ///<summary>Returns label pattern of annotation view label entity.</summary>
  const ACHAR* getLabelPattern() const;
  ///<summary>Function returns evaluated text defined by label pattern.</summary>
  const ACHAR* getLabelText() const;
  void setOrigin(const AcGePoint3d &origin);
  ///<summary>Associates structure view with annotation view label.</summary>
  ///<param name="viewId ">Object id, output only. Object id of structure view to be associated with annotation view label.</param>
  bool set2dStructureView(const AcDbObjectId& viewId);

  void get2dStructureView(AcDbObjectId& viewId) const;

  virtual Acm::ErrorStatus setSymbolDefaults(AcDbDatabase *pDb = NULL);
  virtual Acm::ErrorStatus resetServer(const AcDbObjectId& symbolStdId);

  using AcmSymbol::transformBy;
  ///<summary>Transforms all leaders. Default implementation doesn't cover any smart behavior.</summary>
  virtual Acad::ErrorStatus transformBy(const AcGeMatrix3d& xform, double symbolScale);
  ///<summary>This function is called during the updating of symbols that takes place when the standard is changed.</summary>
  virtual void              regen();

  virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler*);
  virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler*) const;
  virtual Acad::ErrorStatus subErase(Adesk::Boolean erasing);

protected:
  virtual Adesk::Boolean    subWorldDraw(AcGiWorldDraw* wsg);
  ///<summary>Sums geometry extents for a leader.</summary>
  virtual Acad::ErrorStatus subGetGeomExtents(AcDbExtents&) const;
  ///<summary>Queries the standard for sub-entities for all leaders and then the server for all sub-entities for all sub-symbols. All sub-entities are then exploded.</summary>
  virtual Acad::ErrorStatus subExplode(AcDbVoidPtrArray& entitySet) const;
  ///<summary>Lists all leaders including their vertices, standard name and original name, server name and version.</summary>
  virtual void              subList() const;
  ///<summary>Determines which sub-symbols or leaders belong to the GS marker. Then, it asks for sub-entities and applies getOsnapPoints to them.</summary>
  virtual Acad::ErrorStatus subGetOsnapPoints(AcDb::OsnapMode     osnapMode,
                                           INT_PTR             gsSelectionMark,
                                           const AcGePoint3d&  pickPoint,
                                           const AcGePoint3d&  lastPoint,
                                           const AcGeMatrix3d& viewXform,
                                           AcGePoint3dArray&   snapPoints,
                                           AcDbIntArray&       geomIds) const;
  ///<summary>Queries all leaders for their grip points.</summary>
  virtual Acad::ErrorStatus subGetGripPoints(AcGePoint3dArray&,
                                          AcDbIntArray&,
                                          AcDbIntArray&) const;
  ///<summary>Queries all leaders for their grip points.</summary>
  virtual Acad::ErrorStatus subGetGripPoints(AcDbGripDataPtrArray& grips,
                                          const double curViewUnitSize, 
                                          const int gripSize, 
                                          const AcGeVector3d& curViewDir,
                                          const int bitflags) const;
  ///<summary>Determines the leaders to which indices belong and apply moveGripPointsAt to them. 
  ///If the tip point is being edited, then the leaderTipPointChanged() member function of the symbol will be called. 
  ///If the leader contains a landing and it is changed, then the leaderLanding() member function of the symbol is called.</summary>
  virtual Acad::ErrorStatus subMoveGripPointsAt(const AcDbIntArray&, const AcGeVector3d&);
  virtual Acad::ErrorStatus subGetClassID(CLSID* pClsid) const;

private:
    AmdtCAnnotationLabel* mpSubSymbol;
};
DBREF_DECLARE(AmdtAnnotationLabel)

#endif // __ANNOTATIONVIEW_H

