//
#ifndef __FCFRAME_H
#define __FCFRAME_H
//
//  (C) Copyright 1993-2008 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.
//
#include "AdAChar.h"

class AcmCFCF;
class AcmCFCFImp;
class AcmFCFStdImp;
class AcmFCF;

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

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

  AcDbObjectId gdtStyleId() const;
  void setGdtStyleId(const AcDbObjectId& id);

  Acad::ErrorStatus setGdtStyleName(LPCTSTR value);
  Acad::ErrorStatus getGdtStyleName(CString& name,CString& font) const;
  Acad::ErrorStatus getGdtFontName(const ACHAR*& fontName) const;
  Acad::ErrorStatus setGdtFontName(LPCTSTR value);

	double frameGap() const;
  void setFrameGap(double value);

  Adesk::Boolean endPadding() const;
  void setEndPadding(Adesk::Boolean value);

  Adesk::Boolean mergeSymbol() const;
  void setMergeSymbol(Adesk::Boolean value);

  Adesk::Boolean mergeTolerance() const;
  void setMergeTolerance(Adesk::Boolean value);

  Adesk::Boolean mergeDatum() const;
  void setMergeDatum(Adesk::Boolean value);

  Adesk::Boolean separateProjected() const;
  void setSeparateProjected(Adesk::Boolean value);

  Adesk::Boolean separateDatumId() const;
  void setSeparateDatumId(Adesk::Boolean value);

  void getOfferedAuxSymbols(AcDbIntArray& array) const;
  void setOfferedAuxSymbols(const AcDbIntArray& array);

  void getOfferedGdtSymbols(AcDbIntArray& array) const;
  void setOfferedGdtSymbols(const AcDbIntArray& array);

  virtual Adesk::Boolean getGeom(AcmCObjArray<AcmCGDTSymbolDesc>& list,
                                 AcmCFCF* pSubSym = NULL) const;

  virtual Adesk::Boolean setGeom(const AcmCObjArray<AcmCGDTSymbolDesc>& list);

  virtual Adesk::Boolean getMat(AcmCObjArray<AcmCGDTSymbolDesc>& list) const;
  virtual Adesk::Boolean setMat(const AcmCObjArray<AcmCGDTSymbolDesc>& list);

  virtual Adesk::Boolean getSymbolImp(int subSym,
                                      CString& symtext) const;
  
  virtual Adesk::Boolean getSymbolImp(Acm::GdtSymbolType subSym,
                                      CString& symtext) const;

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

  virtual Adesk::Boolean getArrowDesc(AcmCObjArray<AcmCArrowDesc>& list,
                                      Adesk::Boolean allSrv = Adesk::kTrue) const;

  virtual Adesk::Boolean setFactoryDefaults();
  virtual void setDefaultSubSymbol(AcmCFCF* pData) const;

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

  virtual void getSubEnts(const AcmCFCF* pSymb,
                          AcmCAuxEntArray& subents, AcGePoint3d* = NULL) const;

  virtual void getSubEntsAllAround(AcmCAuxEntArray& subents,
                                   const AcGeMatrix3d& mat) 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;

  enum Variable {
    kMergeSymbol = 0,
    kMergeTolerance,
    kMergeDatums,
    kEndPadding,
    kGDTStyle,
    kSepProjected,
    kSepDatumId
  };

  virtual Acm::Visibility variableStatus(AcmFCFStd::Variable var) const;
  virtual void setVariableStatus(AcmFCFStd::Variable var, Acm::Visibility status);
  virtual Adesk::Boolean isLandingAllowed() const;
  virtual Acm::ArrowType defaultSecondaryArrowType() const;

protected:
  AcmFCFStd();
  Acad::ErrorStatus createDefaultStyle(LPCTSTR styleName, LPCTSTR fontName);
  
  virtual Acad::ErrorStatus   subGetClassID(CLSID* pClsid) const;

private:
  AcmFCFStdImp *mpImp;
};
MAKE_ACDBOPENOBJECT_FUNCTION(AcmFCFStd);
DBREF_DECLARE(AcmFCFStd)

class AcmCFCF : public AcmCSubSymbol
{
public:
  virtual Acm::GdtSymbolType symbol() const = 0;
  virtual void setSymbol(Acm::GdtSymbolType sym) = 0;
  virtual void getSymbolAllowedList(AcDbIntArray& arr) const = 0;
  virtual void setSymbolAllowedList(const AcDbIntArray& arr) = 0;

  virtual Acm::GdtSymbolType symbol2() const = 0;
  virtual void setSymbol2(Acm::GdtSymbolType sym) = 0;

  virtual Acm::GdtSymbolType symbol3() const = 0;
  virtual void setSymbol3(Acm::GdtSymbolType sym) = 0;

  virtual Adesk::Boolean isAllAround() const = 0;
  virtual void setAllAround(Adesk::Boolean status) = 0;

  virtual Adesk::UInt8 leaderStatus() const = 0;
};


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

  AcmFCF();
  virtual ~AcmFCF();

  Adesk::UInt8 leaderStatus() const;

  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::GdtSymbolType symbol() const;
  void setSymbol(Acm::GdtSymbolType sym);
  
  Acm::GdtSymbolType symbol2() const;
  void setSymbol2(Acm::GdtSymbolType sym);

  Acm::GdtSymbolType symbol3() const;
  bool setSymbol3(Acm::GdtSymbolType sym);

  Adesk::Boolean isAllAround() const;
  void setAllAround(Adesk::Boolean status);

  virtual void setOrigin (const AcGePoint3d &origin);
  virtual AcGePoint3d getOrigin() const;
  virtual Acm::ErrorStatus setSymbolDefaults(AcDbDatabase* pDb = NULL);

  virtual Acm::ErrorStatus addLeader(const AcGePoint3dArray &ptrArray);
  
  virtual void leaderTipPointChanged(const AcGeVector3d& offset,
                                     const AcmCLeader* leader);
  
  virtual void leaderLandingChanged(const AcGeVector3d& offset,
                                    const AcmCLeader* leader);

  virtual AcmCFCF* subSymbol() const;
  virtual AcmCFCF* newSubFCF() const;


  virtual void regen();
  virtual Acm::ErrorStatus removeLeader(Adesk::UInt16 index);

  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;

protected:
  virtual Adesk::Boolean    subWorldDraw(AcGiWorldDraw* mode);
  
  virtual void subList() const;
  
  virtual Acad::ErrorStatus subTransformBy(const AcGeMatrix3d& xform);

  virtual Acad::ErrorStatus subExplode(AcDbVoidPtrArray& entitySet) const;
  virtual Acad::ErrorStatus subGetGeomExtents(AcDbExtents& extents) const;
  
  virtual Acad::ErrorStatus subGetGripPoints(AcGePoint3dArray& gripPoints,
                                          AcDbIntArray& osnapModes,
                                          AcDbIntArray&  geomIds) const;

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

  virtual Acad::ErrorStatus subGetOsnapPoints(AcDb::OsnapMode  osnapMode,
                                           INT_PTR gsSelectionMark,
                                           const AcGePoint3d& pickPoint,
                                           const AcGePoint3d& lastPoint,
                                           const AcGeMatrix3d& viewXfrm,
                                           AcGePoint3dArray& snapPoints,
                                           AcDbIntArray& geomIds) const;

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

  virtual Acad::ErrorStatus subMoveStretchPointsAt(const AcDbIntArray& indices,
                                                const AcGeVector3d& offset);
  
  virtual Acad::ErrorStatus	subGetClassID(CLSID* pClsid) const;

  void setupSecondLeader(); 

private:
  AcmCFCFImp* mpSubSymbol; 
    
};                      
MAKE_ACDBOPENOBJECT_FUNCTION(AcmFCF);
DBREF_DECLARE(AcmFCF)

#endif // __FCFRAME_H