#pragma once #include "AecDbEntityBaseEx.h" #include "EntitySet.h" #include "adsprintf.h" #include "GeCurveSegment.h" #include "singleton.h" #include "GeRectAngle.h" #include "AttachmentPrototype.h" #include "GePoly2D.h" #define RAPIDJSON_HAS_STDSTRING 1 #include "rapidjson/document.h" #include "rapidjson/encodings.h" #include "rapidjson/stringbuffer.h" #include "rapidjson/prettywriter.h" namespace DIMJson { using namespace rapidjson; typedef GenericDocument > WDocument; typedef GenericValue > WValue; typedef const GenericValue > WCValue; typedef GenericArray Arr; typedef GenericArray CArr; typedef WValue::ConstMemberIterator MCIt; typedef WValue::MemberIterator MIt; typedef WValue::ConstValueIterator VCIt; typedef WValue::ValueIterator VIt; typedef GenericStringBuffer > WStringBuffer; typedef PrettyWriter> WPrettyWriter; typedef Writer> WWriter; WDocument::AllocatorType& getJsonAllocator(); std::wstring write2JsonString(const WValue &v, bool pretty); bool json2File(LPCTSTR path, const WValue &v, bool pretty, bool bUTF8); bool file2Json(LPCTSTR pszJson, WDocument &doc); } class OptionData { public: static BOOL g_bBlk3D; static BOOL g_bMeterUnitHoleElevDim; static int g_iPrecForHoleElevDim; static double _DIST_SNAP; static ADSPrintf adsout; static BOOL g_bFastCalMode; static int g_bTextAdjust; static BOOL g_bLayoutRotate; //布图旋转 static BOOL g_bDClickInplaceEdit; static BOOL g_bTextStyleEx; static double g_nHighBold; static CString g_sLayerStd; //默认尺寸样式 //粗斜线 //细斜线 //圆点 //角度箭头 static BOOL g_bAutoLTScale; //是否自动设置线型比例 static double g_nLtPScale; //图纸空间自动线型 static double g_nLtMScale;//模型空间自动线型 static int g_nDimNumGripTip; static BOOL g_bTextDefaultLayer; static BOOL g_bStetchEntity; static BOOL g_bCtrlToggle; static BOOL g_bCtrlToggle1[]; static Adesk::UInt8 g_bCheckDim; static BOOL g_bExplodeSubText; static BOOL g_bOsnapExpl; static int g_nDealOldDimArrowSize; static BOOL g_bDynDim; static int g_nDimAdjust; static BOOL g_bSelfDrawDim; static BOOL g_bDisableQuickMode; static BOOL g_bCoordPrec2; static BOOL g_bDynamicCoord; static BOOL g_bQuickDragMText; static double g_nArrowLen; static double g_nArrowWidth; static BOOL g_bAutoFocus; static int g_nSymbArrowStyle; static BOOL g_bABCoord; static int g_nCoordArrowStyle; static int g_nCoordPrec; static CString g_csPipeDim[35]; static double g_nInsBlkRotate; static double g_nPipeWidth[35]; static double g_nPipeRadius[35]; static CString g_csTwtLineType[35]; static int g_iPackMode; static TCHAR *LZW_EXT; static TCHAR *JPG_EXT; static TCHAR *BMB_TITLE; static TCHAR *JPB_TITLE; static TCHAR *DWB_TITLE; static TCHAR *SLD_EXT; static TCHAR *SLB_TITLE; /*----------------------------------------------------------*/ static XStringList g_lstWinfont; static DList g_lstCharset, g_lstPitch; static CString g_csPipeDnStyle; static CString g_csVPipeStyle; static CString g_csPipeTextStyle; static CString g_csCircleTextStyle; static CString g_csSanTextStyle; static CString g_csDimWellStyle; static CString g_csSheetStyle; static CString g_csTwtDimStyle; static CString g_csEleDimStyle; static CString g_csPipeDnChn; static CString g_csPipeDnEng; static CString g_csVPipeChn; static CString g_csVPipeEng; static CString g_csPipeTextChn; static CString g_csPipeTextEng; static CString g_csCircleTextChn; static CString g_csCircleTextEng; static CString g_csSanTextChn; static CString g_csSanTextEng; static CString g_csDimWellChn; static CString g_csDimWellEng; static CString g_csSheetChn; static CString g_csSheetEng; static CString g_csDimChn; static CString g_csDimEng; static CString g_csEleDimChn; static CString g_csEleDimEng; static double g_nPipeDnHeight; static double g_nPipeDnScale; static double g_nVPipeHeight; static double g_nVPipeScale; static double g_nPipeTextHeight; static double g_nPipeTextScale; static double g_nCircleTextHeight; static double g_nCircleTextScale; static double g_nSanTextHeight; static double g_nSanTextScale; static double g_nDimWellHeight; static double g_nDimWellScale; static double g_nSheetHeight; static double g_nSheetScale; static double g_nTwtDimHeight; static double g_nDimScale; static double g_nEleDimHeight; static double g_nEleDimScale; static int g_nDimPipeGradientType;// 短管坡度标注样式 static int g_nDimShortPipeGradientType;// 管线管径标注样式 static int g_nDimPipeDnType;// 短线管径标注样式 static int g_nDimShortPipeDnType;// 管线管长标注样式 static int g_nDimShortPipeLenType;// 管线标注分隔符样式 static int g_nDimPipeLabelType;// 短线标注分隔符样式 static int g_nDimShortPipeLabelType;// 管线标注排列方式 static int g_nDimPipeDrawType; static double g_nSprinklerRadius , g_nDrainPtRadius , g_nDoubleDist , g_nValveScale , g_nStandPipe2Wall , g_nBreakPipeWidth , g_nPipeTextBreak , g_nDnDimDist2Pipe , g_nWellRadius , g_nDimCirDiam , g_nFeedCircleScale , g_nCurPipeWidth , g_nElbowRate , g_dDbPipeLineWidth; static int g_iDefaultPipeDn , g_iElbowType , g_iVPipeDimStyle , g_iSprinklerDistMod , g_nSinataryDataType; static int g_iDimPipeLinePos;// 管底标注和井底标注位置 0:井中心1:井与管线的交点处 static int g_iDimPipeBaseLineAng;// 管底标注基线角度 0:随支管角度 1:水平角度 static BOOL g_bIsElevDimChangeByPipeElev;// 单注标高是否随管线标高联动 static double g_dVPipeDimDn2Label; static int g_iDimPipeGradientType , g_iDimShortPipeGradientType , g_iDimPipeLen; //室外管线标注样式 static int g_iDimWellNamePos , g_iDimWellNameAngle; //井编号距井上下位置 static double g_dDimWellNameDist; //井编号距离 static int g_iDimWellEleType , g_iDimWellEleLeadAngle;//管底标注样式 static int g_nAlignTypeForVPipeDim4; // 立管标注样式4中管径的对齐方式 cet 2012-4-19 static int g_nAlignTypeForWellDim; // 井标注对齐方式 0:居中 1:端对齐 static double g_dWellDimText2Base; // 井标注(管底标注)文字距线距离 static CString g_csVerticalSectionHead; static CString g_csVerticalSectionHeadFeed; static BOOL g_bDwgBegin; static XPoint g_ptBase; static CString g_csInsBlkName; static BOOL g_bEquipByScale, g_bDimWellOnlyEle; static CString g_csSingleTextStyle; static BOOL g_bShowPipeCanalMinLine; static double g_fZero; static int g_iDrawMode; static BOOL g_bUpdateMViewBlock; static BOOL g_bStandPipeArc; // 传统扣弯 static BOOL g_bIsFeedPoint; // static BOOL g_bPipeWeight; // static int g_iPipeMaterial[35]; static TCHAR g_sDwbPath[256]; }; typedef Singleton g_Option; class SSearchPipeList; namespace GlobalFunc { template static void deleteContainerOfStd(T &ss) { typename T::iterator it(ss.begin()); for (; it != ss.end(); ++it) delete(*it); ss.clear(); } // 删除 arx 容器内的指针 只指对AcArray及派生类 template static void deleteContainerOfArx(T1 &ss) { for (int i = 0; i < ss.length(); ++i) { T2 *p = (T2*)ss[i]; delete p; } ss.removeAll(); } BOOL IsWell(AcDbObjectId id); BOOL IsEquipment(AcDbObjectId id); BOOL IsOfAcadWindows(HWND hwnd); int GetCornerPoint(const ADSGePoint3d &ptCorn1, const TCHAR *pszMsg, ADSGePoint3d &ptCorn2); int GetScreenSize(double *width, double *height); double A2R(double Angle); double PixelToWcs(int nPixel); double Radian2Angle(double Radian); double AngleRangeToPI(double dAngle); int Release(RBGroups *pList); struct resbuf * LinkResbufList(struct resbuf *list1, struct resbuf *list2); int TypeOfCode(int code); void ApplicationError(const TCHAR *msg, ...); PGroups VBuildList(int *parguments); struct resbuf *GetXdataTagItem(struct resbuf * xdata, int tag, struct resbuf **lagptr); void SetXdataTagItem(struct resbuf **xdata, int tag, struct resbuf *tag_xdata, const TCHAR *appname); void PointTransformBy(ads_matrix xform, ads_point pt, ads_point newpt); ADSGePoint3d Wcs2Ucs(ADSGePoint3d ptSrc, BOOL bVector = FALSE); double Wcs2Ucs(double nAng); ADSGePoint3d Ecs2Wcs(ADSGePoint3d ptSrc, TVector3D vtEcs, BOOL bVector = FALSE); ADSGePoint3d Wcs2Ecs(ADSGePoint3d ptSrc, TVector3D vtEcs, BOOL bVector = FALSE); ADSGePoint3d Ucs2Ecs(ADSGePoint3d ptSrc, TVector3D vtEcs, BOOL bVector = FALSE); void UcsWorld(); AcDbObjectId AddToModelSpace(AcDbEntity *pEntity, Adesk::Boolean bDoneClose = Adesk::kTrue, Adesk::Boolean bWorkset = Adesk::kFalse); CString GetSymbolName(AcDbObjectId idSymbolRec); AcDbObjectId MakeBlock(const TCHAR *szBlock, PickEntSet &ss, ADSGePoint3d ptInsert); int AssureLayer(const TCHAR *szLayer, int nFlag); template int TGSetVar(LPCTSTR sym, K val) { RBGroups g(val); return ads_setvar(sym, (resbuf *)&g); } int TGGetVar(const TCHAR *var, int *res); int TGGetVar(const TCHAR *var, double *res); int TGGetVar(const TCHAR *var, TCHAR *res); int TGGetVar(const TCHAR *var, CString *res); int TGGetVar(const TCHAR *var, ADSGePoint3d *res); int TGGetVar(const TCHAR *var, TCString *res); Acad::ErrorStatus GetSafeSelectionEx(PickEntSet &ss, BOOL bCrossing, const ADSGePoint3d &ptLow, const ADSGePoint3d &ptUp, const AcRxClass *pClass); Acad::ErrorStatus GetSafeSelectionEx(PickEntSet &ss, BOOL bCrossing, const ADSGePoint3d &ptLow, const ADSGePoint3d &ptUp, const AcRxClass *pClass, AcDbObjectId idBlock); template inline void Exchange(T& t1, T&t2) { T temp = t1; t1 = t2; t2 = temp; } template class PushMemVar { public: PushMemVar(T &var, const T &val); ~PushMemVar(); protected: T *m_pVarBackup; T m_valBackup; }; template PushMemVar::PushMemVar(T &var, const T &val) { m_pVarBackup = &var; m_valBackup = var; var = val; } template PushMemVar::~PushMemVar() { *m_pVarBackup = m_valBackup; } class PushVarStr { public: PushVarStr(const TCHAR * pszVar, const TCHAR * pszVal = NULL) : var(pszVar), value(80) { TGGetVar(pszVar, &value); if (pszVal) { if (_tcsicmp(pszVar, _T("clayer")) == 0) { AssureLayer(pszVal, 0); // 确保存在 } TGSetVar(pszVar, pszVal); } } ~PushVarStr() { TGSetVar((LPTSTR)var, (LPTSTR)value); } public: TCString var; TCString value; }; template class PushAcadVar { public: PushAcadVar(const TCHAR *pszVar, K kVal) : var(pszVar) { TGGetVar(pszVar, &value); if (bLayer) { if (pszVar) { if (_tcsicmp(pszVar, _T("clayer")) == 0) { //modify by xlc on 111205 确保当前层存在,不是当前层的系统变量 //AssureLayer(pszVar, 0); // 确保存在 AssureLayer((const TCHAR*)kVal, 0); // 确保存在 } TGSetVar(pszVar, kVal); } } else { TGSetVar(pszVar, kVal); } } PushAcadVar(const TCHAR *pszVar) : var(pszVar) { if (!bLayer) { TGGetVar(pszVar, &value); } } virtual ~PushAcadVar() { TGSetVar((const TCHAR *)var, value); } public: CString var; K value; }; bool IsStrAllNum(CString csText); double DocGetPScale(); Entity GetEquipmentByPt(XPoint &pt, int nSnap = 0.2*GlobalFunc::DocGetPScale(), const TCHAR *szLayer = _T("*")); CString PlusString2(const TCHAR *szRes, int step, BOOL bIsPlus);//给MYSPIN用,他不需要对前面递增递减 int EntToScale(ads_name ssname, ads_point bpt, double *res); int EntToRotate(ads_name ssname, ads_point bpt, double *res); int EntToMove(ads_name ssname, ads_point bpt, ads_point res); CView* GetCurDwgView(); int YesNoQuestion(const TCHAR *s, int nDefaultAnswer = Q_YES); int GetInsertMatrix(const EntitySet & e, ads_matrix result); int SetToProductMatrix(ads_matrix mat1, ads_matrix mat2, ads_matrix result); void MatrixMultiply(ads_matrix result, ads_matrix m1, ads_matrix m2, ...); int PointProjectToLine(ads_point src_pt, ads_point cl_pt1, ads_point cl_pt2, ads_point dest_pt); int MakeEntity(int type, ...); void AsAdsMatrix(const AcGeMatrix3d &mat1, ads_matrix mat2); double AngleRangeTo2PI(double dAngle); AcGeMatrix3d & AsAcGeMatrix3d(ads_matrix mat); ADSGePoint3d Max(const ADSGePoint3d &pt1, const ADSGePoint3d &pt2); ADSGePoint3d Min(const ADSGePoint3d &pt1, const ADSGePoint3d &pt2); struct resbuf * GetResbufAtCode(struct resbuf *p, int code); int PlaneNormalBy3Pt(const ads_point pt1, const ads_point pt2, const ads_point pt3, ads_vector result); int GetPlaneEquation(const ads_point pt, const ads_vector vt, struct STPlanePara *plan); int PointProjectToPlane(const ads_point pt, const struct STPlanePara *plan, ads_point qt); int Maximum(int n, int r1, ...); double Maximum(int n, double r1, ...); int Minimum(int n, int r1, ...); double Minimum(int n, double r1, ...); BOOL IsMirrorMatrix(ads_matrix mat); BOOL IsMirrorMatrix(const AcGeMatrix3d &mat); int IsEqual(double prec, int n, double num1, double num2, ...); int IsEqual(int n, int num1, int num2, ...); ads_real operator & (const TVector3D & pt1, const TVector3D & pt2); TVector3D operator * (const TVector3D &pt1, const Vector3D &pt2); void Refresh_DIST_SNAP(); void PolyConvert(const GePoly2D &poly, AcDbPolyline &pline); void PolyConvert(const AcDbPolyline &pline, GePoly2D &poly); void ReleaseEntSet(AcDbVoidPtrArray &entSet); int GetCirDivNum(double r, double h); int MergeCurve(GeCurveSegment &curve, GeCurveSegment &seg, int bMinusCurve, int bMinusSeg); int LimitCycle(int n, int nLen); int GetPointInArcType(ads_point pt, ads_point cenpt, ads_real rad, ads_real ang1, ads_real ang2); char* _StrCpy(char *dest, const char *from, const char *to); wchar_t* _StrCpy(wchar_t *dest, const wchar_t *from, const wchar_t *to); double AsViewAngle(double ang); AcDbObjectId GetTextStyleId(const TCHAR *styleName, AcDbDatabase *pDb = NULL); void ftoa(double f, int nPrec, TCHAR *res); CString Angle2Str(double nAng); AcDbObjectId GetTempEntityId(AcRxClass *pClass, const TCHAR *szBlockName, BOOL *bFirstNew); int IsArxAppLoaded(const TCHAR * AppName); Acad::ErrorStatus ReadString(AcDbDwgFiler *pFiler, TCString &sResult); char* StrNew(const char *src); wchar_t * WStrNew(const wchar_t *src); double ChangeAngleTo1_4(double dAngle); BOOL Equal(double val1, double val2, double nSnap); AcDbObjectId GetDimStyleId(const TCHAR *styleName, AcDbDatabase *pDb = NULL); ADSGePoint3d Ucs2Wcs(ADSGePoint3d ptSrc, BOOL bVector = FALSE); double Ucs2Wcs(double nAng); int SelectEntity1(const TCHAR *szPrompt, EntitySet &entResult, ADSGePoint3d &ptPick, RBList &rbBaseMask); int SelectEntity1(double nPrec, const TCHAR *szPrompt, EntitySet &entResult, ADSGePoint3d &ptPick, RBList &rbBaseMask); int SelectEntity(const TCHAR *szPrompt, EntitySet &entResult, ADSGePoint3d &ptPick, RBList &rbBaseMask); int SelectEntity(const TCHAR *szPrompt, EntitySet &entResult, ADSGePoint3d &ptPick, RBList &rbBaseMask, const TCHAR* szKeyword, TCHAR& cRet); int SelectEntity(const TCHAR *szPrompt, EntitySet &entResult, RBList &rbBaseMask); int SelectEntity(const TCHAR *szPrompt, EntitySet &entResult, RBList &rbBaseMask, const TCHAR* szKeyword, TCHAR& cRet); int SelectEntities(const TCHAR *szPrompt, PickEntSet &ssResult, RBList &rbBaseMask); int SelectEntities(const TCHAR *szPrompt, PickEntSet &ssResult, RBList &rbBaseMask, const TCHAR* szKeyword, TCHAR& cRet); void ExplodeEx(AcDbEntity* pEntity, AcDbVoidPtrArray &res); TCHAR* GetStringAtIndex(const TCHAR *string, int i, TCHAR *item); int FindFile(const TCHAR *szFile, TCHAR * szPath); int FindFile(const TCHAR *sDbfPath); AcDbObjectId AddTextStyle(AcDbTextStyleTableRecord *pRec, BOOL bDoneClosed, AcDbDatabase *pDb = NULL); AcDbObjectId AddDimStyle(AcDbDimStyleTableRecord *pRec, BOOL bDoneClosed, AcDbDatabase *pDb = NULL); int GetTextStyleColor(AcDbObjectId idStyle); AcDbObjectId InitLineType(const TCHAR *szLineType, AcDbDatabase *pDb = NULL); AcDbObjectId GetLayerIdFromString(const TCHAR* pStr, AcDbDatabase *pDb = NULL); AcDbObjectId MakeLayer(const TCHAR *LayName, BOOL bApplyChange); AcDbObjectId MakeLayer(const TCHAR *LayName, AcDbDatabase *pDb); BOOL DocSetLayerStd(const TCHAR* sFile); int UCmpLabel(const wchar_t* sLabel1, const wchar_t* sLabel2); int ACmpLabel(const char* sLabel1, const char* sLabel2); wchar_t * WStrchrNew(const wchar_t *string, int c, bool bToFile = true); char * StrchrNew(const char *string, int c, bool bToFile); int GetIniFileToIniBufer(const TCHAR *ini_file, const TCHAR *topic, struct STIniStruct **res); TCHAR * GetIniBuferValueByKey(const struct STIniStruct *buf, const TCHAR *desc_handle); int FreeIniBuffer(struct STIniStruct *res); COLORREF GetAcadBackColor(); TCString GetFullCmdName(const TCHAR *szName); double DocGetText2BaseRatio(); BOOL DocSetText2BaseRatio(double nDist); double DocGetEleTriangleSize(); BOOL DocSetEleTriangleSize(double nValue); double DocGetMultiLeaderDistRatio(); BOOL DocSetMultiLeaderDistRatio(double nValue); double DocGetEleDoteSize(); BOOL DocSetEleDoteSize(double nValue); double DocGetEleCrossSize(); BOOL DocSetEleCrossSize(double nValue); int DocGetDrawingIndexStyle(); BOOL DocSetDrawingIndexStyle(int nStyle); int DocGetArcLenDimType(); BOOL DocSetArcLenDimType(int nType); BOOL DocSetPScale(double nScale); BOOL DocGetMeterUnitDraw(); void DocSetMeterUnitDraw(BOOL bV); BOOL DocGetMeterUnitDim(); void DocSetMeterUnitDim(BOOL bV); BOOL DocGetCurMeterUnitDraw(); void DocSetCurMeterUnitDraw(BOOL bMeters); double DocGetHighBold(); template AcDbObjectId AddToSpace(Adesk::Boolean bClosed, T *pEntSymb) { AcDbObjectId InitLayer(const TCHAR *, BOOL); const TCHAR *pszLayer = pEntSymb->GetDefaultLayer(); // 设置在默认图层 if (pszLayer && g_Option::instance().g_bTextDefaultLayer) { AcDbObjectId idLayer = InitLayer(pszLayer, TRUE); if (idLayer.isValid()) { pEntSymb->setLayer(pszLayer); } } return AddToModelSpace(pEntSymb, bClosed, Adesk::kTrue); } template BOOL CopyObject(const K &src, K &dest) { AcDbDeepCloneFiler filer; BOOL bRet = FALSE; if (src.dwgOutFields(&filer) == Acad::eOk) { filer.seek(0L, 0); bRet = (dest.dwgInFields(&filer) == Acad::eOk); } return bRet; } TCString Dist2Str(double nDist); double GetApertureWcs(); wchar_t * StrCpy(wchar_t *dest, const wchar_t *from, const wchar_t *to); char * StrCpy(char *dest, const char *from, const char *to); AcDbObjectId DimStyleTch2Acad(AcDbObjectId idTch, double nScale, BOOL bAngular, AcDbDatabase *pDb, double dTxtHeight); BOOL DocGetCheckDim(); AcGiDraw::TextAlignment GetTextAlignment(const AcDb::TextHorzMode &nHMode , const AcDb::TextVertMode &nVMode); void GetTextAlignment(const AcGiDraw::TextAlignment &align , AcDb::TextHorzMode &nHMode , AcDb::TextVertMode &nVMode); int GetLayerColor(AcDbObjectId idLay); int DocGetDealOldDimArrowSize(); AcDbObjectId DimStyleAcad2Tch(AcDbObjectId idAcad, double &nScale); BOOL GreatThan(double val1, double val2, double nSnap = g_Option::instance()._DIST_SNAP); BOOL LessThan(double val1, double val2, double nSnap = g_Option::instance()._DIST_SNAP); BOOL LessEqual(double val1, double val2, double nSnap = g_Option::instance()._DIST_SNAP); BOOL GreatEqual(double val1, double val2, double nSnap = g_Option::instance()._DIST_SNAP); int GetPickPoint(const ads_point ref, const TCHAR *prompt, ads_point res); int GetFullOsMode(int nFlagsAdd); int GetPtOnWhichPort(ADSGePoint3d pt, double &dScale, BOOL &bOnEnt, PickEntSet entSet); void InitGetBegin(int nFlag, const TCHAR *szKeyTable); void InitLocalMsg(BOOL bTrue); BOOL GetWcsCursor(ADSGePoint3d &ptLoc); CString getSystemTemporaryFolder(); CString GetRootDir(); CString GetArxDir(); CString GetSysDir(); void DelSuffixZero(TCHAR *sText); double DocGetDITextRatio(); BOOL DocSetDITextRatio(double nValue); Acad::ErrorStatus ReadPoly2D(AcDbDwgFiler *pFiler, GePoly2D &poly); Acad::ErrorStatus WritePoly2D(AcDbDwgFiler *pFiler, const GePoly2D &poly); Acad::ErrorStatus MoveGripPointsAt(GePoly2D &poly, const AcDbIntArray& indices, const AcGeVector3d& offset); template int Intersect(R &ln, GePoly2D &poly, PointList &pts) { int num = poly.TotalSegments(); GeCurveSegment seg1; for (int i = 0; i < num; i++) { if (poly.Nth(i, seg1) != RTNORM) { return -1; } seg1.SetLineFlag(LS_FINITE); ADSGePoint3d intPt[2]; int ptNum = seg1.Intersection(ln, intPt[0], intPt[1]); for (int n = 0; n < ptNum; n++) { pts.Insert(intPt[n]); } } return pts.Length() - 2; } int PolyClip(const PtrList &ss, const GePoly2D &poly1, PtrList &ss1, PtrList &ss2, PtrList &ssOnEdge); void ExplodePoly2D(const GePoly2D &poly, PtrList &lstSegs); int BoolOper(AcDb::BoolOperType nOperType, LPVOID pPoly1, LPVOID pPoly2, LPVOID pPtrListPoly2d); void WCS2UCS(AcGePoint3d& pt, BOOL bVer = 0); int GetDist(const TCHAR *szPrmpt, ads_real &r, int nBitFlag = 0); SubText* HitTestOnText(PickEntSet& ss, ADSGePoint3d pt); void PostCommand(const TCHAR *pszCmd, bool bEcho = false); bool FindRT_MANIFEST(); BOOL IsKeyPressed(int vk); int SelectEnts(LPCTSTR szPrompt, LPCTSTR szNextPrompt, RBList &rbBaseMask, PickSet &ssResult, LPCTSTR szKeyword, TCHAR& cRet); int IsWCS(); Acad::ErrorStatus GetEntFromBlockByDxf(PtrList &lstObjects, const TCHAR *pDxfWizard, int nCmpMethod = 0, const TCHAR *pszBlk = ACDB_MODEL_SPACE); AcDbObjectId AddToPaperSpace(AcDbEntity *pEntity, Adesk::Boolean bDoneClose, Adesk::Boolean bWorkset = Adesk::kFalse); AcDbObjectId AddToCurrentSpace(AcDbEntity *pEntity, Adesk::Boolean bDoneClose, Adesk::Boolean bWorkset = Adesk::kFalse); int DePeriod(int nPeriod, int nIndex); int GetBlockRefSizeInfo(const AcDbBlockReference *pBlkRef , ADSGePoint3d &ptBase , double *nRot , ADSGePoint3d &ptCen , double *nSizeX , double *nSizeY , double *nSizeZ); Acad::ErrorStatus GetSafeSelectionEx(PickEntSet &ss , BOOL bCrossing , const ADSGePoint3d &ptLow , const ADSGePoint3d &ptUp , const AcRxClass *pClass); TCString Point2d2Str(const ADSGePoint3d &pt); AcDbObjectId GetBlockIdFromString(const TCHAR *pszBlock, AcDbDatabase *pDb = NULL); BOOL GetBlcCtrlPoint(AcDbObjectId id, ADSGePoint3d &ptMax); void GetPointList(XCurveSegment seg, double dDist, XPointList &lstPt); void GetPointList(XCurveSegment seg, int iNum, XPointList &lstPt, int mode); BOOL WriteXdata(Entity ent, const TCHAR*szName, const TCHAR*szValue); CString PlusString(const TCHAR *szRes, int step, BOOL bIsPlus, bool bHasChineseNum); CString PlusString(const TCHAR* szRes, int step, BOOL bIsPlus); AcDbCurve* GetOffsetCurve(AcDbCurve *pCurve, double dOffsetDist, XPoint ptPick); AcDbPolyline* GetNextPloyLine(Entity ent, Entity ent2, XPoint ptPick, XPoint ptPick2); void SplitBlkStr(const TCHAR *szInput, CString &csTK, CString &csRecord); void GetPointPickSet(XPoint pt, PickSet &ss, RBList &rbMask, int len = 1); Acad::ErrorStatus AssureInCurrentView_New(const XPoint &ptLow, const XPoint &ptUp); BOOL IsLayerOn(const TCHAR*szLayerName); CString getDwbPath(); CString getTkPath(); AcGeVector3d GetUcsZvt(); Acad::ErrorStatus WriteAcDbSoftPointerIds(AcDbDwgFiler* pFiler, const DList &lstId); Acad::ErrorStatus ReadAcDbSoftPointerIds(AcDbDwgFiler* pFiler, DList &lstId); Acad::ErrorStatus FilerRead(AcDbDwgFiler *pFiler, BOOL& bResult); Acad::ErrorStatus FilerWrite(AcDbDwgFiler *pFiler, const BOOL& bResult); CString getCurrentCmdNames(); BOOL IsTransformCmd(); int CompareObjectId(const AcDbObjectId *id1, const void *id2); int CompareObjectId(const AcDbSoftPointerId *id1, const void *id2); void ScaleTransform(const AcGeMatrix3d& xform, double &dVar); void AngleTransform(const AcGeMatrix3d& xform, double &dAngle); CString DoubleToString(double dValue, int nPreci, bool bTrim = false); BOOL GetBlkNameById(AcDbObjectId id, CString &sBlkName, CString &sDesName); double EqualPointTol(); PickEntSet & DocGetPickFirst(); int get_line_angle(ads_real& line_angle); AcDbObjectId GetLinetypeIdFromString(const TCHAR *pStr, AcDbDatabase *pDb); AcDbObjectId GetLinetypeIdFromString2(const TCHAR* pStr); int SplitSlbName(const TCHAR *totalName, TCHAR *slbFile, TCHAR *sldFile); CString ReadXdata(Entity ent, const TCHAR*szName); AcDbObjectId GetLayerRecordId(CString layerName); Acad::ErrorStatus ArxZoomTo(const ADSGePoint3d &ptCen, double nWidth, double nHeight); AcDbObjectId InitTwtTextStyle(const TCHAR *szTextStyle); BOOL DocGetIsDwgBegin(); void DocSetIsDwgBegin(BOOL bTrue); int GetPipeLayerIdxByName(const TCHAR* szLayer); BOOL GetPipeMaterialList(XStringList &lstMat); AcGeMatrix3d BlockTransform(const AcDbBlockReference *pInsert); void HideDialog(CWnd *pWnd, BOOL Flag); CString GetDimWellDeep(double dDeep); CString GetPipeMaterialByIdx(int idx); CString GetDnByMat(const TCHAR* szMat); CString GetDimPipeLen(double dLen); double GetPipeOutDByDn(const TCHAR* szMat, int iDnIn); CString GetBlkNameById(AcDbObjectId id); void UpdateGraphic(PickEntSet &ss); void DoDimPipeDn(Entity ent, int iRadius, const TCHAR* szType, double nHeight, BOOL bIsDown, BOOL bModifyPos); int DragMovePickSet(PickEntSet &ss, const TCHAR *pszPrompt, const ADSGePoint3d &ptBase, ADSGePoint3d &ptFinal); void DrawSlide(const TCHAR*szPath, CWnd* pWnd); #if ARX > 22 bool WatchKeyboardMouse(MSG* pMsg); #else BOOL WatchKeyboardMouse(MSG* pMsg); #endif void AnyKeyReturn(const CString &sTip); AcDbObjectId InitGridLayer(const TCHAR* szLay); BOOL AddLineType(const TCHAR*szLineType); void UpdateMultDim(); double GetValBetween2(double n1, double n2, double nRange1, double nRange2, double nFactor); void GetAllPipeAndNodeByNode(AcDbObjectId nodeId, AcDbObjectId idFront, PickSet &ss); void GetAllPipeAndNodeByPipe(AcDbObjectId pipeId, AcDbObjectId idFront, PickSet &ss); double GetPipeGradient(Entity ent); BOOL IsSprinkler(AcDbObjectId idNode); BOOL IsSprinkler(Entity ent); BOOL SearchSprinkPipeSys(Entity ent, AcDbObjectId idFront, SSearchPipeList *pListAll, PickSet &ssAll); Acad::ErrorStatus AssureInCurrentView(const ADSGePoint3d &ptLow, const ADSGePoint3d &ptUp); double GetPipeDjByDn(const TCHAR* szMat, int iDnIn); double GetPipeOutDByDn(int nMaterial, double dDn); void GetPipePoint(Entity ent, XPoint &pt1, XPoint& pt2, XPoint &ptMid); void GetPipePoint(Entity ent, XPoint &pt1, XPoint& pt2); CString GetPipeWireLayLineType(const TCHAR* szLayer); int LoadDwbBlock(const TCHAR *sDwbFile, const TCHAR *sDwgName, TCHAR *sBlockName); AcDbObjectId InitPipeLayer(const TCHAR* szLay); CString GetLayerLineType(const TCHAR* szLayer); Acad::ErrorStatus PostToDb(AcDbEntity* ent, BOOL bClose = FALSE); BOOL InsertBlock(const TCHAR*szBlkName, XPoint pt, double nScale, double Rotation, const TCHAR* szLayer); AcDbObjectId InsertBlock(const TCHAR*szBlkName, AcGePoint3d pt, double XScale, double YScale, double Rotation, const TCHAR* szLayer); BOOL IsExternalBlock(Entity entBlk); void ConstructMatrix(const ADSGePoint3d &ptBase , const ADSGePoint3d &ptInsert , double sx , double sy , double sz , double rot , ads_matrix result); void Get2DCurveFromBlock(AcDbBlockTableRecord &blockRec , ads_matrix matForInsert , PtrList &lstResult); CString GetPipeLayerByIdx(int iLayer); TPipeSys::SysType GetPipeSysByLayer(const TCHAR* szLayer); CString GetPipeNameBySys(TPipeSys::SysType sys); CString GetDimLayBySys(TPipeSys::SysType sys); BOOL StringAnalysis(const TCHAR *src, XString &sPrefix, int *num, int *numWidth); CString GetWellName(AcDbObjectId id); CString GetWellName(Entity ent); XCurveSegment GetSegByPt(XPoly2D poly, XPoint pt, double &dAngle); double GetInsRotate(XPoint ptIns, XCurveSegment seg); BOOL GetBlkRecordWidth(const TCHAR* szBlkName, double nScaleX, double nScaleY, double &nWidth, double &nHeight); void GetWire2Point(Entity ent, XPoint &ptStart, XPoint &ptEnd); XCurveSegment GetExternalBlockSeg(Entity entBlk, XPoint &ptPick); Entity GetPipeByPt(XPoint pt, double &nElevation, int &iPipeSys); AcDbObjectId GetBlkIdByName(const TCHAR* szBlkName); Acad::ErrorStatus GetEntByDxf(PickEntSet &lstObjects, const TCHAR *pDxfWizard, int nCmpMethod = 0); double GetFullByPercentQ(double nPercentQ); BOOL IsHydrant(AcDbObjectId idNode); BOOL IsWell(AcDbObjectId id); int GetNodeType(Entity ent); BOOL CalcLstPipeLength(SSearchPipeList *pListAll, SSearchPipeList *pListFront, PickSet &ss); SSearchPipeList *GetNextDimNode2(SSearchPipeList *pListAll, SSearchPipeList *pDisadvantage); SSearchPipeList *GetPipeNodeByName(SSearchPipeList *pListAll, CString csName, SSearchPipeList *pNode); int GetFirstAncestorSerial(SSearchPipeList *pListLast); int GetAncestorSerial(SSearchPipeList *pListLast); void GetPipeSpecList(DList &lstSpec, const TCHAR* szMat); CString GetPipeLayer(Entity entPipe); BOOL GetInsertExtend(const AcDbObjectId &id, double &dWidth, double &dHeight); BOOL GetInsertExtend(const AcDbObjectId &id, double &x, double &y, double &z); DIMJson::WValue* GetOptionJsonValue(DIMJson::WDocument &doc, LPCTSTR pszKey); CString getOptionString(); bool setOptionString(LPCTSTR pszJson); bool setOptionString(DIMJson::WCValue &v); void setDimConfigReloadFlag(const BOOL &bLoad); bool getDimConfigReloadFlag(); void LoadConfig(); void _LoadConfig(); template bool GetOptionValue(LPCTSTR pszKey, T &t) { using namespace DIMJson; if (!pszKey) return false; CString strOption = getOptionString(); if (strOption.IsEmpty()) return false; WDocument doc; doc.Parse(strOption); if (doc.HasParseError()) return false; WCValue *pV = GetOptionJsonValue(doc, pszKey); if (!pV) return false; t = pV->Get(); return true; } template bool setOptionValue(LPCTSTR pszPath, const T &t) { using namespace DIMJson; if (!pszPath) return false; CString strOption = getOptionString(); if (strOption.IsEmpty()) return false; WDocument doc; doc.Parse(strOption); if (doc.HasParseError()) return false; WValue *pV = GetOptionJsonValue(doc, pszPath); if (!pV) return false; if (pV->Is()) { pV->Set(t); } return setOptionString(doc); } AcDbHatch *NewHatchFromPoly2D(const GePoly2D &poly, const TCHAR *pszPattern0, double nScl); CString GetBlkDesName(const TCHAR *szRecord, const TCHAR *szTKName); } class SplitpathOperator { public: SplitpathOperator(const TCHAR *pszPath) : m_sDrive(_MAX_DRIVE) , m_sDir(_MAX_DIR) , m_sFileName(_MAX_FNAME) , m_sExt(_MAX_EXT) , m_sFullPath(pszPath) { #ifdef _UNICODE _wsplitpath(pszPath, m_sDrive, m_sDir, m_sFileName, m_sExt); #else _splitpath(pszPath, m_sDrive, m_sDir, m_sFileName, m_sExt); #endif } virtual ~SplitpathOperator(){} public: TCString m_sFullPath; TCString m_sDrive, m_sDir, m_sFileName, m_sExt; }; class SSearchPipeList { public: SSearchPipeList() { m_ID = NULL; m_iDn = 0; m_nDang = 0; m_nI = 0; m_nV = 0; m_csName = _T(""), m_iType = 0; m_iNum = 0; m_bNeedCale = FALSE; m_nLength = 0; m_pPrevious = NULL; m_nStartPress = 0; m_nLost = 0; m_nPipeQ = 0; m_nSpare = 0; }; AcDbObjectId m_ID; int m_iNum; int m_iType; //0:管 1:节点 2:喷头 3:井 4:化粪池 int m_iDn; //管径 int m_iSpare; //保留 BOOL m_bNeedCale; CString m_csName; //0:管段名称 1/2:节点名称 double m_nLength; //管长 double m_nPipeQ; //管段流量 double m_nDang; //当量长度 double m_nStartPress; //起点压力 double m_nI; //水力坡降 mH2O/m double m_nV; //流速 m/s double m_nLost; //沿程损失 double m_nSpare; //保留 EntityFields fd; //扩展数据 SSearchPipeList *m_pPrevious; DList m_lstNode; }; class CHookMsg { public: CHookMsg(); ~CHookMsg(); int GetValue(); //0:左键,1、右键,2:空格、回车,3:ESC键 protected: #if ARX > 22 static bool ListenMsg(MSG *pMsg); #else static BOOL ListenMsg(MSG *pMsg); #endif private: static int s_iValue; }; #define RevDrtAngle(drt) (GlobalFunc::AngleRangeTo2PI((drt) + PI)) #define IsExactSameDrt(drt1,drt2,prec) ((fabs(GlobalFunc::AngleRangeTo2PI((drt1) - (drt2))) < prec || fabs(GlobalFunc::AngleRangeTo2PI((drt2) - (drt1))) < prec) ? 1:0)