#ifndef __DATUMTGT_H
#define __DATUMTGT_H
//
//  (C) Copyright 1993-2009 by Autodesk, Inc.  All rights reserved.
//
// Permission to use, copy, modify, and distribute this software in
// object code form for any purpose and without fee is hereby granted, 
// provided that the above copyright notice appears in all copies and 
// that both that copyright notice and the limited warranty and
// restricted rights notice below appear in all supporting 
// documentation.
//
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. 
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK, INC. 
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
// UNINTERRUPTED OR ERROR FREE.
//
// Use, duplication, or disclosure by the U.S. Government is subject to 
// restrictions set forth in FAR 52.227-19 (Commercial Computer
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
// (Rights in Technical Data and Computer Software), as applicable.
//

#ifndef __ACMDEF_H
  #error include 'acmdef.h' before including this file
#endif
#ifndef __CAUXENT_H
  #error include 'cauxent.h' before including this file
#endif

#include "AdAChar.h"

class AcmCTarget;
class AcmCTargetBalloon;
class AcmCTargetService;
class AcmCDatumTargetImp;
class AcmDatumStdImp;

class DllImpExp AcmDatumStd : public AcmSymbolStd
{
  friend class AcmSymbbInternals;
public:
  ACRX_DECLARE_MEMBERS(AcmDatumStd);

  virtual ~AcmDatumStd();

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

  virtual void initToEditOriginal();
  virtual void initToEdit();

  AcDbObjectId hiddenLeaderLineId() const;
  Acm::ErrorStatus setHiddenLeaderLineId(const AcDbObjectId& idType);

  Acm::ErrorStatus getHiddenLeaderLtypeName(ACHAR*& pName) const;
  Acm::ErrorStatus setHiddenLeaderLtypeName(const ACHAR* pName);

  AcDbObjectId borderLineId() const;
  Acm::ErrorStatus setBorderLineId(const AcDbObjectId& idType);

  Acm::ErrorStatus getBorderLtypeName(ACHAR*& pName) const;
  Acm::ErrorStatus setBorderLtypeName(const ACHAR* pName);

  Adesk::Boolean drawLeaderArrow() const;
  void setDrawLeaderArrow(Adesk::Boolean status);

  double hatchAngle() const;
  void setHatchAngle(double value);

  double hatchDist() const;
  void setHatchDist(double value);

  Adesk::UInt16 pointColor() const;
  void setPointColor(Adesk::UInt16 color);
  
  const AcCmColor & pointTrueColor() const;
  void setPointTrueColor(const AcCmColor & color);

  double pointSize() const;
  void setPointSize(double value);

  virtual Adesk::Boolean setFactoryDefaults();

  virtual Acm::ErrorStatus checkVisibility(AcmCTargetBalloon* pData) const;
  virtual Acm::ErrorStatus initFields(AcmCTargetBalloon* pData) const;
  virtual Acm::ErrorStatus setSuggested(AcmCTargetBalloon* pData) const;

  virtual void getSubEnts(const AcmCSubSymbol* pSymb,
                          AcmCAuxEntArray& subents,
                          const AcGeMatrix3d& trans) const;

  virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler* filer);
  virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler* filer) const;
  virtual Acad::ErrorStatus dxfInFields(AcDbDxfFiler* filer);
  virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler* filer) const;

  AcmCTargetService* getService(Acm::TargetType type) const;

protected:
  AcmDatumStd();
  Adesk::Boolean registerService(AcmCTargetService* pNewServ);
  virtual Acm::ErrorStatus createDefaultLTypeBorderLine(const ACHAR* name);
  virtual Acm::ErrorStatus createDefaultLTypeHiddenLeaderLine(const ACHAR* name);

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

private:
  AcmDatumStdImp* mpImp;
};
MAKE_ACDBOPENOBJECT_FUNCTION(AcmDatumStd);
DBREF_DECLARE(AcmDatumStd)

class DllImpExp AcmDatumTarget : public AcmSymbol
{
public:
  ACRX_DECLARE_MEMBERS(AcmDatumTarget);

  AcmDatumTarget();
  AcmDatumTarget(Acm::TargetType type);
  virtual ~AcmDatumTarget();

  LPCTSTR value(Acm::Variable var) const;
  Acm::ErrorStatus setValue(Acm::Variable var, LPCTSTR value);

  Acm::Visibility  variableStatus(Acm::Variable var) const;
  Acm::ErrorStatus setVariableStatus(Acm::Variable var, Acm::Visibility status);

  Acm::ErrorStatus getVarDlgInfo(Acm::Variable var,CVarDlgInfo& v) const;
  Acm::ErrorStatus setVarDlgInfo(Acm::Variable var,const CVarDlgInfo& v);

  Acm::Orientation orientation() const;
  void setOrientation(Acm::Orientation o);

  virtual AcmCTarget *getNewTarget(Acm::TargetType type);
  virtual Acm::ErrorStatus setSymbolDefaults(AcDbDatabase* pDb = NULL);

  AcmCTargetBalloon* balloon() const;
  AcmCTarget* target() const;
  virtual void regen();

  double balloonRadius() const;
  AcDbObjectId lTypeId() const;

  void setLTypeIdToHidden();
  void setLTypeIdToSolid();

  Adesk::Boolean isHidden() const;
  void setHidden(Adesk::Boolean val);

  virtual void leaderTipPointChanged(const AcGeVector3d& offset,
                                     const AcmCLeader* leader);

  using AcmSymbol::transformBy;
  virtual Acad::ErrorStatus transformBy(const AcGeMatrix3d& xform,
                                        double symbolScale);

  virtual void mirrorCoordSys(const AcGeMatrix3d& xMirrorForm,
                              AcGeVector3d& XAxis,
                              AcGeVector3d& YAxis,
                              AcGeVector3d& normal) const;

  virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler* filer);
  virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler* filer) const;
  virtual Acad::ErrorStatus dxfInFields(AcDbDxfFiler* filer);
  virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler* filer) const;

  virtual void updateLeader();

  virtual Acm::ErrorStatus attachGeomRef(const void* pGeomRef,
                                         const AcDbObjectId &viewId,
                                         const AcGePoint3d &arrowheadLocation);

  virtual Acm::ErrorStatus attachGeomRef(const void* pGeomRef,
                                         const AcGePoint3d &arrowheadLocation);

protected:
  virtual Adesk::Boolean    subWorldDraw(AcGiWorldDraw* pMode);

  virtual Acad::ErrorStatus   subGetClassID(CLSID* pClsid) const;
  
  virtual Acad::ErrorStatus subGetOsnapPoints (AcDb::OsnapMode, INT_PTR,
                                               const AcGePoint3d&,
                                               const AcGePoint3d&,
                                               const AcGeMatrix3d&,
                                               AcGePoint3dArray&,
                                               AcDbIntArray&) const;

  virtual Acad::ErrorStatus subGetGripPoints(AcGePoint3dArray&,
                                             AcDbIntArray&,
                                             AcDbIntArray&) const;

  virtual Acad::ErrorStatus   subGetGripPoints(AcDbGripDataPtrArray& grips,
                                               const double curViewUnitSize, 
                                               const int gripSize, 
                                               const AcGeVector3d& curViewDir,
                                               const int bitflags) const;

  virtual Acad::ErrorStatus subMoveGripPointsAt(const AcDbIntArray& indices,
                                                const AcGeVector3d& offset);

  virtual Acad::ErrorStatus subGetStretchPoints(AcGePoint3dArray&) const;
  virtual Acad::ErrorStatus subMoveStretchPointsAt(const AcDbIntArray& indices,
                                                   const AcGeVector3d& offset);
  virtual Acad::ErrorStatus subTransformBy(const AcGeMatrix3d& xform);

  virtual Acad::ErrorStatus subGetGeomExtents(AcDbExtents&) const;
  virtual Acad::ErrorStatus subExplode(AcDbVoidPtrArray& entitySet) const;
  virtual void              subList() const;

private:
  void updateOrigin();
  AcmCDatumTargetImp* mpImp;
};                      
MAKE_ACDBOPENOBJECT_FUNCTION(AcmDatumTarget);
DBREF_DECLARE(AcmDatumTarget)

class AcmCTarget : public AcmCSubSymbol
{
public:
  virtual Acm::TargetType type() const = 0;

  virtual double scale() const = 0;
  virtual void getDefaultText(CString& text) const = 0;

  virtual AcGePoint3d recalcLeaderStart(const AcGePoint3d& pnt) const = 0;

  virtual Acad::ErrorStatus getGripPoints(AcGePoint3dArray&  gripPoints,
                                          AcDbIntArray&  osnapModes,
                                          AcDbIntArray&  geomIds) const = 0;
  
  virtual Acad::ErrorStatus moveGripPointsAt(const AcDbIntArray& indices,
                                             const AcGeVector3d& offset) = 0;
  
  virtual Acad::ErrorStatus moveStretchPointsAt(const AcDbIntArray& indices,
                                                const AcGeVector3d& offset) = 0;
  
  virtual int numGripPoints() const = 0;
  virtual Adesk::Boolean isKnownGrip(int indice) const = 0;
  virtual Acad::ErrorStatus transformBy(const AcGeMatrix3d& xform) = 0;
};   

class AcmCTargetBalloon : public AcmCTarget
{
public:
  virtual Acm::Orientation orientation() const = 0;
  virtual void setOrientation(Acm::Orientation o) = 0;
};


class AcmCTargetPoint : public AcmCTarget
{
public:
  virtual Adesk::Boolean drawPoint() const = 0;
  virtual void setDrawPoint(Adesk::Boolean flag) = 0;
};

class AcmCTargetLine : public AcmCTarget
{
public:
  virtual Adesk::Boolean drawLine() const = 0;
  virtual void setDrawLine(Adesk::Boolean flag) = 0;

  virtual AcGePoint3d endPoint() const = 0;
  virtual void setEndPoint(const AcGePoint3d& point) = 0;

  virtual double factor() const = 0;
  virtual void setFactor(double f) = 0;
  virtual AcGePoint3d midPoint() const = 0;
};


class AcmCTargetCircularArea : public AcmCTarget
{
public:
  virtual double radius() const = 0;
  virtual void setRadius(double r) = 0;
};

class AcmCTargetRectangularArea : public AcmCTarget
{
public:
  virtual double angle() const = 0;
  virtual void setAngle(double aplha) = 0;

  virtual double xSize() const = 0;
  virtual void setXSize(double x) = 0;

  virtual double ySize() const = 0;
  virtual void setYSize(double y) = 0;

  virtual AcGePoint3d cornerPoint() const = 0;
  virtual void setCornerPoint(const AcGePoint3d& pt) = 0;

  virtual AcGePoint3d anglePoint() const = 0;
  virtual void setAnglePoint(const AcGePoint3d& pt) = 0;
};                      

class AcmCTargetService 
{
public:
  virtual ~AcmCTargetService();

  virtual Acm::TargetType serviceType() const = 0;             
  virtual void getSubEnts(const AcmCSubSymbol* pData,
                          AcmCAuxEntArray& subEnts,
                          const AcGeMatrix3d& mTransform) const = 0;  

};                      

class AcmCTargetBalloonService : public AcmCTargetService 
{
public:
  
  virtual double radius() const = 0;
  virtual AcGePoint3d defaultSizePosition() const = 0;

protected:
  virtual double gapMultiple() const = 0;
  virtual void   drawOutside(const AcGePoint3d& p1,
                             const AcGePoint3d& p2,
                             AcDbMText& pText,
                             AcmCAuxEntArray& subEnts) const = 0;
};                      

inline 
AcmCTargetService::~AcmCTargetService()
{
}

#endif
