//
#ifndef __SYMSTD_H
#define __SYMSTD_H

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

/////////////////////////////////////////////////////////////////////
// (C) Copyright 1993-2008 by Autodesk, Inc. 
//
// 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.
//
// stdmain.h: Definition of AcmStandard class. Base class for
//            mechanical standard
//
/////////////////////////////////////////////////////////////////////

class AcmStandardImp;
class AcmSymbolStd;
class AcmCArrowService;
class AcmCLeaderNodeIterator;
class AcmSymbolStd;
class AcmCLeader;
class AcmSymbolStdImp;

class DllImpExp AcmStandard : public AcDbObject
{
  friend class AcmSymbbInternals;
public:
  ACRX_DECLARE_MEMBERS(AcmStandard);

  virtual ~AcmStandard();

  LPCTSTR name() const;
  Acm::ErrorStatus setName(LPCTSTR newName);
  virtual LPCTSTR originalName() const;

  LPCTSTR separator() const;
  void setSeparator(LPCTSTR separator);

  double scale() const;
  void setScale(double scale);

  double arwScale() const;
  void setArwScale(double scale);
  virtual void getArrowSizeList(AcGeDoubleArray& lst) const;

  const AcCmColor & symbolTrueColor() const;
  void setSymbolTrueColor(const AcCmColor & color);  
  
  Adesk::UInt16 symbolColor() const;
  void setSymbolColor(Adesk::UInt16 color);

  // Update symbols according to LEAD/MSYM line properties
  const AcDbObjectId & symbolLT() const;
  void setSymbolLT(const AcDbObjectId& lineType);  

  const AcDb::LineWeight & symbolLW() const;
  void setSymbolLW(const AcDb::LineWeight& lineWgt);  

  const AcDbObjectId & leaderLT() const;
  void setLeaderLT(const AcDbObjectId& lineType);  

  const AcDb::LineWeight & leaderLW() const;
  void setLeaderLW(const AcDb::LineWeight& lineWgt);  

  bool isLgOff() const;

  const AcCmColor & leaderTrueColor() const;
  void setLeaderTrueColor(const AcCmColor & color);
    
  Adesk::UInt16 leaderColor() const;
  void setLeaderColor(Adesk::UInt16 color);

  const AcCmColor & textTrueColor() const;
  void setTextTrueColor(const AcCmColor & color);
    
  Adesk::UInt16 textColor() const;
  void setTextColor(Adesk::UInt16 color);

  Acm::ArrowType arrowType() const;
  Adesk::Boolean setArrowType(Acm::ArrowType type);

  double textHeight() const;
  void setTextHeight(double);
  virtual void getTextHeightList(AcGeDoubleArray& lst) const;

  double nextTextHeight() const;

  Adesk::Boolean isMetric() const;
  Acm::ErrorStatus setIsMetric(Adesk::Boolean m);


  enum StringCase {
    kNoChange = 0,  // for most standards
    kAllUpperCase,  // for ANSI
    kFirstLetterUpperCase 
  };     // used for translating strings in various standards

  virtual StringCase supportedStringCase() const;

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

  int getAcadArrowDescs(AcmCObjArray<AcmCArrowDesc>& list) const;

  AcmCArrowService* getArrowService(Acm::ArrowType type) const;

  LPCTSTR textStyleName() const;
  Acad::ErrorStatus setTextStyleName(LPCTSTR pName);

  AcDbObjectId textStyleId() const;
  void setTextStyleId(const AcDbObjectId& id);

  void getMTextProperties(AcDbMText& text) const;

  Acad::ErrorStatus newSymbolSupport(LPCTSTR baseClassName);

  Acad::ErrorStatus addSymbolStd(AcmSymbolStd* pStd,
                                 AcDbObjectId& symbolStdId,
                                 Adesk::Boolean setCurrent = Adesk::kTrue);

  Acm::ErrorStatus getCurrentSymbolStd(LPCTSTR className,
                                       AcDbObjectId& symbolStdId) const;

  Acm::ErrorStatus setCurrentSymbolStd(const AcDbObjectId& symbolStdId);

  Acm::ErrorStatus getCurrentStandards(AcDbObjectIdArray& idArray) const;

  Acm::ErrorStatus getAllSymbolSupport(CStringArray& names) const;
  Acm::ErrorStatus getAllSymbolStd(AcDbObjectIdArray& idArray) const;

  Acm::ErrorStatus removeSymbolStd(const AcDbObjectId& stdId);

  Acm::ErrorStatus getSymbolStd(LPCTSTR className,
                                AcDbObjectIdArray& idArray) const;
  virtual void getSubEnts(const AcmCLeader* pLeader, 
    AcmCAuxEntArray& entArray, Adesk::Boolean cutLastLines =Adesk::kTrue) const;

  virtual Adesk::Boolean acmInit();

  virtual void initToEditOriginal();
  virtual void initToEdit();
  virtual Adesk::Boolean setFactoryDefaults();
  virtual Adesk::Boolean setDimDefaults();

  virtual Acm::Visibility statusIsMetric() const;
  virtual Acm::Visibility statusTextStyle() const;
  virtual Acm::Visibility statusTextHeight() const;

  virtual Adesk::Boolean  isOriginal() const;

  Acm::ProjectionType projectionType() const;
  void setProjectionType(Acm::ProjectionType);

  Acm::ListInsertionPoint listInsertPoint() const;
  void setListInsertPoint(Acm::ListInsertionPoint);

  virtual Acad::ErrorStatus decomposeForSave(AcDb::AcDbDwgVersion ver,
                                              AcDbObject*& replaceObj,
                                              AcDbObjectId& replaceId,
                                              Adesk::Boolean& exchangeXData);
  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 Acad::ErrorStatus subErase(Adesk::Boolean erasing);
  virtual Acad::ErrorStatus subSwapIdWith(AcDbObjectId otherId,
                                          Adesk::Boolean swapXdata = false,
                                          Adesk::Boolean swapExtDict = false);

  Acad::ErrorStatus replaceWith(AcDbObjectId otherStdId);

  bool              useDimStyle() const;       // Just returns a bool if the dimstyle link is active
  AcDbObjectId      dimStyleId() const;
  //void              setDimStyleId(const AcDbObjectId& id);
  CString           dimStyleName() const;
  Acad::ErrorStatus setDimStyleName(CString pName);
  AcDbObjectId      arrowBlock() const; 
  void              setArrowBlock(const AcDbObjectId& id);
  void              setDimStyleMode(Acm::DimStyleMode mode);
  Acm::DimStyleMode dimStyleMode() const;
  bool              arrowTypeVaries() const;
  bool              dimColorVaries() const;
  void              updateFromDimStyle();
  void              updateSubStandardsFromDimStyle();
  void              synchronizeDimstyles();
  AcDbObjectIdArray getAssociatedDimstyles() const;

  // Reactor callback from Dimstyle changes
  virtual void modified(const AcDbObject* pObj);
  virtual void objectClosed(const AcDbObjectId objId);
  
protected:
  AcmStandardImp*  mpImp;
  
  AcmStandard();
  Adesk::UInt16  classVersion() const;
  Adesk::Boolean registerArrowService(AcmCArrowService* pNewSrv);
  Adesk::Boolean registerUserArrowService(AcmCArrowService* pNewSrv);
  Adesk::Boolean registerAutocadArrowService(AcmCArrowService* pNewSrv);
  virtual Acm::ErrorStatus onChangeUnits(Adesk::Boolean isMetric);
  virtual void   initArrowServices();
  void walkThroughLeaderSeg(const AcmCLeaderNodeIterator* pIter,
                            AcmCAuxEntArray& entArray,
                            const AcmCLeader* pLeader,
                            Adesk::Boolean cutLastLines =Adesk::kTrue, bool makeNdd = false) const;
  void makeArrowHeadAndCutLines(const AcmCLeader* pLeader, Adesk::Boolean cutLastLines, AcmCAuxEntArray&) const;
  void makeNDD(const AcmCLeader* pLeader, AcmCAuxEntArray&) const;
  
  virtual Acad::ErrorStatus   subGetClassID(CLSID* pClsid) const;

  virtual Acad::ErrorStatus subDeepClone(AcDbObject*    pOwnerObject,
                                      AcDbObject*&   pClonedObject,
                                      AcDbIdMapping& idMap,
                                      Adesk::Boolean isPrimary = Adesk::kTrue) const;

  virtual Acad::ErrorStatus subWblockClone(AcRxObject* pOwnerObject,
                                        AcDbObject*& pClonedObject,
                                        AcDbIdMapping& idMap,
                                        Adesk::Boolean isPrimary = Adesk::kTrue) const;

protected:
  // We are making this constructor and destructor protected to try and
  // ensure that they are not used.  The Tahoe team has discovered a 
  // bug with the destructor so has made it private in AcDbObject.
  // This doesn't allow us to compile unless we declare it on our classes
  // that are exported.  No implementation is supplied so that link
  // errors are encountered if either of these are used.
  // See Tahoe subdoc t39dca1.txt for more details.
  //
  void *operator new[](size_t nSize) { UNREFERENCED_PARAMETER(nSize);assert(0); return NULL; }
  void operator delete[](void *p) { UNREFERENCED_PARAMETER(p);assert(0); }
};

MAKE_ACDBOPENOBJECT_FUNCTION(AcmStandard);
DBREF_DECLARE(AcmStandard);


class DllImpExp AcmSymbolStd : public AcDbObject
{
  friend class AcmSymbbInternals;
public:
  ACRX_DECLARE_MEMBERS(AcmSymbolStd);
  
  virtual ~AcmSymbolStd();

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

  virtual Acm::ErrorStatus getRevision(CString& rev, Adesk::UInt16& year) const;
  virtual Adesk::Boolean   setFactoryDefaults();
  virtual Adesk::Boolean   isCompatibleTo(const AcmStandard* pStd) const;
  // Determines whether the symbol standard is created for a particular draft standard
  virtual Adesk::Boolean   isCreatedFor(const AcmStandard* pStd) const;

  virtual void initToEdit();
  virtual void initToEditOriginal();
  virtual Adesk::Boolean getTreeItems(AcmCObjPtrArray<CSymStdTreeItemDesc>& descArray) const;

  AcmStandard* owner(AcDb::OpenMode mode = AcDb::kForRead) 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 setDefaultTextLeader();

  virtual double textHeight() const;
  virtual void setTextHeight(double txtHeight);

  virtual bool textHeightByStandard() const;
  virtual void setTextHeightByStandard(bool byStandard);

  virtual double byStdTextHeight() const;

  virtual const AcCmColor & textTrueColor() const;
  virtual void setTextTrueColor(const AcCmColor & color);    

  virtual bool textColorByStandard() const;
  virtual void setTextColorByStandard(bool byStandard);

  virtual const AcCmColor & byStdTextTrueColor() const;

  virtual double arwScale() const;
  virtual void setArwScale(double scale);

  virtual bool arwScaleByStandard() const;
  virtual void setArwScaleByStandard(bool byStandard);

  virtual Acm::ArrowType arrowType() const;
  virtual Adesk::Boolean setArrowType(Acm::ArrowType type);

  virtual bool arrowTypeByStandard() const;
  virtual void setArrowTypeByStandard(bool byStandard);

  virtual const AcCmColor & leaderTrueColor() const;
  virtual void setLeaderTrueColor(const AcCmColor & color);  

  virtual bool leaderColorByStandard() const;
  virtual void setLeaderColorByStandard(bool byStandard);

  virtual void getMTextProperties(AcDbMText& text) const;
  virtual bool isExpandable() const;

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

  virtual bool isHeightSizedUp() const;

protected:
  AcmSymbolStd();
  Adesk::UInt16 classVersion() const;
  virtual Acm::ErrorStatus onChangeUnits(Adesk::Boolean isMetric);
  
  double getTextHeightValue() const;
  const AcCmColor& getTextTrueColorValue() const;
  Acm::ArrowType getArrowTypeValue() const;
  double getArwScaleValue() const;
  const AcCmColor& getLeaderTrueColorValue() const; 
  
  virtual Acad::ErrorStatus subDeepClone(AcDbObject*    pOwnerObject,
                                      AcDbObject*&   pClonedObject,
                                      AcDbIdMapping& idMap,
                                      Adesk::Boolean isPrimary = Adesk::kTrue) const;

  virtual Acad::ErrorStatus subWblockClone(AcRxObject* pOwnerObject,
                                        AcDbObject*& pClonedObject,
                                        AcDbIdMapping& idMap,
                                        Adesk::Boolean isPrimary = Adesk::kTrue) const;

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

protected:
  AcmSymbolStdImp *mpSymStdImp;
protected:
  // We are making this constructor and destructor protected to try and
  // ensure that they are not used.  The Tahoe team has discovered a 
  // bug with the destructor so has made it private in AcDbObject.
  // This doesn't allow us to compile unless we declare it on our classes
  // that are exported.  No implementation is supplied so that link
  // errors are encountered if either of these are used.
  // See Tahoe subdoc t39dca1.txt for more details.
  //
  void *operator new[](size_t nSize) { UNREFERENCED_PARAMETER(nSize);assert(0); return NULL; }
  void operator delete[](void *p) { UNREFERENCED_PARAMETER(p);assert(0); }
};

MAKE_ACDBOPENOBJECT_FUNCTION(AcmSymbolStd);
DBREF_DECLARE(AcmSymbolStd);


class AcmCSubSymbol
{
public:
  virtual ~AcmCSubSymbol();

  virtual AcGePoint3d origin() const = 0;
  virtual void setOrigin(const AcGePoint3d& origin) = 0;

  virtual LPCTSTR value(Acm::Variable var) const = 0;
  virtual Acm::ErrorStatus getValue(Acm::Variable var, CString& value) const = 0;
  virtual Acm::ErrorStatus setValue(Acm::Variable var, LPCTSTR value) = 0;

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

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

  virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler* filer, Adesk::UInt16 ver) = 0;
  virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler* filer) const = 0;
  virtual Acad::ErrorStatus dxfInFields(AcDbDxfFiler* filer) = 0;
  virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler* filer) const = 0;
};

inline
AcmCSubSymbol::~AcmCSubSymbol()
{}


class DllImpExp AcmCArrowService
{
public:
  virtual ~AcmCArrowService();

  virtual Acm::ArrowType  serviceType() const = 0;
  
  virtual Acm::ArrowGroup group() const = 0;
  virtual void setGroup(Acm::ArrowGroup group) = 0;
  
  virtual Adesk::Boolean hidden() const = 0;
  virtual void setHidden(Adesk::Boolean newVal) = 0;
  
  virtual AcmCArrowDesc* getDesc() const = 0;
  virtual void getSubEnts(AcmCAuxEntArray& entArray) const = 0;

  // Create a block from the arrow service
  virtual AcDbObjectId makeBlock() const = 0;
  // Find out the blockname this arrow service represents, and if it is predefined by ACAD
  // Returns "true" if the blockname is built into ACAD (and hence needs not be created)
  // and returns "false" if it is not built into ACAD. If the item doesnt support blocks
  // it returns false and the empty string, which is in reality only returned by the "abstract"
  // arrowhead types of "by standard" and "by block" themselves
  virtual Adesk::Boolean getBlockName(CString& name) const = 0;
  
  virtual void getSubEnts(AcmCAuxEntArray& entArray, const AcGeMatrix3d& xform) const = 0;  
  
  virtual void setArrowheadDir(const AcGeVector3d& dir) = 0;

  // PRID 400154: Arrow head color  default isNone
  virtual void setArrowheadColor(const AcCmColor & color) = 0;
};

inline 
AcmCArrowService::~AcmCArrowService()
{}


#endif // __SYMSTD_H
