211 lines
7.6 KiB
C++
211 lines
7.6 KiB
C++
#pragma once
|
|
|
|
#include <sstream>
|
|
#include "LayerMgr.h"
|
|
#include "AecDbEwPipe.h"
|
|
#include "AecDbEwCable.h"
|
|
#include "gspreviewctrlex.h"
|
|
#include "define_class_xdata_key.h"
|
|
|
|
/*
|
|
保存一个或多个EWFnctNode结构体为文本文件
|
|
*/
|
|
struct EWFnctNode;
|
|
|
|
class UIDataCache
|
|
{
|
|
public:
|
|
UIDataCache(){}
|
|
~UIDataCache(){}
|
|
|
|
public:
|
|
static bool FindNode(LPCTSTR pszSection, EWFnctNode *pNode);
|
|
static bool WriteNode(LPCTSTR pszSection, EWFnctNode *pNode);
|
|
|
|
static bool Write(LPCTSTR pszSection, LPCTSTR pszKye, LPCTSTR pszValue);
|
|
static bool Write(LPCTSTR pszSection, LPCTSTR pszKye, const double &dValue);
|
|
static bool Write(LPCTSTR pszSection, LPCTSTR pszKye, const float &fValue);
|
|
static bool Write(LPCTSTR pszSection, LPCTSTR pszKye, const int &iValue);
|
|
static bool Write(LPCTSTR pszSection, LPCTSTR pszKye, const AcGePoint3d &pt);
|
|
static bool Write(LPCTSTR pszSection, LPCTSTR pszKye, const CStringArray &ar);
|
|
|
|
// psz 为通配符字符串,只用来解释可变参数的类型(例:"%s%d%f%i%p%a")
|
|
// %f-float %d-double %i-int %s-字符串 %p-AcGePoint3d %a-CStringArray
|
|
// psz 中的 %x 个数与 可变参数 相同
|
|
static bool Write(LPCTSTR psz, LPCTSTR pszSection, ...);
|
|
|
|
static bool Read(LPCTSTR pszSection, LPCTSTR pszKye, CString &sValue);
|
|
static bool Read(LPCTSTR pszSection, LPCTSTR pszKye, double &dValue);
|
|
static bool Read(LPCTSTR pszSection, LPCTSTR pszKye, float &fValue);
|
|
static bool Read(LPCTSTR pszSection, LPCTSTR pszKye, int &iValue);
|
|
static bool Read(LPCTSTR pszSection, LPCTSTR pszKye, AcGePoint3d &pt);
|
|
static bool Read(LPCTSTR pszSection, LPCTSTR pszKye, CStringArray &ar);
|
|
|
|
// psz 为通配符字符串,只用来解释可变参数的类型(例:"%s%d%f%i%p%a")
|
|
// %f-float %d-double %i-int %s-字符串 %p-AcGePoint3d %a-CStringArray
|
|
// psz 中的 %x 个数与 可变参数 相同
|
|
static bool Read(LPCTSTR psz, LPCTSTR pszSection, ...);
|
|
|
|
private:
|
|
static void GetAllSections(std::vector<CString> §ions, LPCTSTR path);
|
|
static bool Read(LPCTSTR pszSection, LPCTSTR pszKye, std::wstring &sValue);
|
|
};
|
|
|
|
|
|
#include "KTCadUtilityEx.h"
|
|
|
|
namespace GLTools
|
|
{
|
|
struct compare_double
|
|
{
|
|
bool operator () (const double &a, const double &b) const
|
|
{
|
|
// a < b
|
|
return DOWN_ZERO(a - b);
|
|
}
|
|
};
|
|
}
|
|
|
|
namespace GLTools
|
|
{
|
|
const LPCTSTR gLayer_Stake = _T("LAY_EW_STAKE");
|
|
const LPCTSTR gLayer_EW = _T("LAY_EW_EARTHWORM");
|
|
const LPCTSTR gLayer_ELEV = _T("LAY_EW_ELEVATION");
|
|
const LPCTSTR gLayer_FAMI = _T("LAY_EW_FAMILY");
|
|
const LPCTSTR gLayer_ZD_OUTPUT = _T("LAY_EW_ZD_OUTPUT");
|
|
const LPCTSTR gLayer_ZD_GRID_LINE = _T("LAY_EW_ZD_GRID_LINE");
|
|
const LPCTSTR gLayer_ZD_TABLE_LINE = _T("LAY_EW_ZD_TABLE_LINE");
|
|
const LPCTSTR gLayer_ZD_TEXT_DATA = _T("LAY_EW_ZD_TEXT_DATA");
|
|
const LPCTSTR gLayer_ZD_TEXT_HEAD = _T("LAY_EW_ZD_TEXT_HEAD");
|
|
const LPCTSTR gLayer_ZD_TEXT_RULE = _T("LAY_EW_ZD_TEXT_RULE");
|
|
const LPCTSTR gLayer_ZD_TEXT_SCALE = _T("LAY_EW_ZD_TEXT_SCALE");
|
|
const LPCTSTR gLayer_ZD_DIM = _T("LAY_EW_ZD_DIM");
|
|
const LPCTSTR gLayer_ZD_RULE = _T("LAY_EW_ZD_RULE");
|
|
const LPCTSTR gLayer_ZD_SCALE = _T("LAY_EW_ZD_SCALE");
|
|
const LPCTSTR gLayer_PIPE_SINGLE = _T("LAY_EW_PIPE_SINGLE");
|
|
const LPCTSTR gLayer_PIPE_DOUBLE = _T("LAY_EW_PIPE_DOUBLE");
|
|
const LPCTSTR gLayer_CABLE_SINGLE = _T("LAY_EW_CABLE_SINGLE");
|
|
const LPCTSTR gLayer_CABLE_DOUBLE = _T("LAY_EW_CABLE_DOUBLE");
|
|
const LPCTSTR gLayer_CABLE = _T("LAY_EW_CABLE");
|
|
const LPCTSTR gLayer_PIPE = _T("LAY_EW_PIPE");
|
|
const LPCTSTR gLayer_DS = _T("LAY_EW_DS"); // 地形
|
|
}
|
|
namespace GLTools
|
|
{
|
|
template<typename T>
|
|
bool isThisClass(AcDbObjectId &id)
|
|
{
|
|
OPENOBJ_BEGIN(id, AcDb::kForRead, T, p)
|
|
if (p) return true;
|
|
OPENOBJ_END()
|
|
return false;
|
|
}
|
|
|
|
void loadToolbar();
|
|
|
|
// 中心点,管廊方向
|
|
void drawCoordinate(const AcGePoint3d &ptOrig, const AcGeVector3d &vtEw, const int &MinX, const int &MinY, const int &MinZ);
|
|
|
|
// 根据文字样式名称,得到文字样式id
|
|
AcDbObjectId getTextStyle(LPCTSTR style);
|
|
|
|
// 调用 PipelineCmd 工程的 getEqu 函数
|
|
// 用户选择一个设备,并将此设备内容保存到一个临时文件中
|
|
// 将此文件路径返回
|
|
bool getPipelineCmdEquipment(CString &path);
|
|
|
|
// 根据数据库ID,将设备内容保存到临时文件中
|
|
bool getPipelineCmdEquipment(const int & idx, CString & path);
|
|
|
|
// 得到用户选择的设备的数据库索引
|
|
bool getPipelineCmdEquipment(int &idx);
|
|
|
|
// 得到节点的插入时的偏移量
|
|
double getNodeOffset(const EWFnctNode &node);
|
|
|
|
// 点选两段管廊,得到他们及中间的管廊集合
|
|
bool getConnectWorms(AcDbObjectIdArray &ids, AcDbObjectIdArray *pNextIDs = NULL, AcDbObjectIdArray *pPrevIDs = NULL);
|
|
|
|
// 鼠标选中一个管廊节点,返回节点所在管廊id及节点guid
|
|
void pickEwNode(AcDbObjectId &idPort, AcDbObjectId &idEw, std::string &md5, CString &guid);
|
|
}
|
|
|
|
namespace StakeTools
|
|
{
|
|
// 解析桩号文字
|
|
bool analyStakeString(LPCTSTR psz, double &dist, CString *pPrefix = NULL, bool *pThousands = NULL);
|
|
|
|
// 是否是桩号字符串
|
|
bool IsStakeString(LPCTSTR pszStake);
|
|
|
|
// 是否是浮点数
|
|
bool IsDoubleString(LPCTSTR pszDouble);
|
|
|
|
// 根据一个浮点数,得到其各位上的数字
|
|
// 如果 d > 0,返回1,否则为-1,如果返回0,则失败
|
|
// first 为小数点的前半部分,由低位到高位排列
|
|
// second 为小数点的后半部分,由高到低排列
|
|
// prec 精度
|
|
// 例:d = 123.456 , prec = 5
|
|
// 则 first = <3.2.1> second = <4,5,6,0,0>
|
|
int getBitsForFloat(const double &d, std::vector<int> &first, std::vector<int> &second, const int &prec = 5);
|
|
|
|
// 根据桩号距离,生成桩号文字
|
|
CString generateStakeString(const double &dist, LPCTSTR psz = _T("K"));
|
|
|
|
// 选取上华桩号并分析
|
|
bool getSHSStake(LPCTSTR pszPrompt
|
|
, AcDbObjectId &idTxt
|
|
, double &dist
|
|
, CString &prefix
|
|
, bool &bStart2End
|
|
, bool &bThousands
|
|
, AcGePoint3d *ptIns = NULL
|
|
, CString *orignString = NULL);
|
|
|
|
// 判断是否是上华桩号
|
|
bool isSHSStake(AcDbObjectId id);
|
|
|
|
// 判断是否是上华桩线
|
|
bool isSHSStakeLine(AcDbObjectId id);
|
|
|
|
// 写入桩号扩展标志
|
|
bool writeSHSStakeFlag(AcDbObjectId id, const AcGePoint3d &ptIns, const bool &bS2E, LPCTSTR pszStake, const double &stakeDist, const double &ptDist);
|
|
bool writeSHSStakeFlag(AcDbEntity *pEnt, const AcGePoint3d &ptIns, const bool &bS2E, LPCTSTR pszStake, const double &stakeDist, const double &ptDist);
|
|
|
|
// 读取桩号扩展标志
|
|
bool readSHSStake(AcDbEntity *pEnt, AcGePoint3d &ptIns, bool &bS2E, CString &sStake, double &stakeDist, double &pointDist);
|
|
bool readSHSStake(AcDbObjectId id, AcGePoint3d &ptIns, bool &bS2E, CString &sStake, double &stakeDist, double &pointDist);
|
|
|
|
// 获得模型空间中所有上华桩号
|
|
bool getSHSStakeOfAll(std::vector<AcDbObjectId> &ids, bool bSortByStakeDist = true);
|
|
|
|
// 根据中心线上的点pt,得到其桩号文字距离
|
|
bool getDistByPointForCenterLine(const std::vector<AcDbObjectId> &ids, const AcDbObjectId &polyID, const AcGePoint3d &pt, double &stakeDist);
|
|
}
|
|
|
|
namespace INITools
|
|
{
|
|
bool getSections(LPCTSTR szPath, std::vector<CString> §ions);
|
|
bool getSectionContent(LPCTSTR szPath, LPCTSTR szSection, std::map<CString, CString> &mapV);
|
|
bool setSectionContent(LPCTSTR szPath, LPCTSTR szSection, const std::map<CString, CString> &mapV);
|
|
}
|
|
|
|
namespace PipeTools
|
|
{
|
|
AecDbEwPipe* createPipeFromLineSeg(const LineSeg &seg);
|
|
AecDbEwCable* createCableFromLineSeg(const LineSeg &seg);
|
|
}
|
|
|
|
namespace EquTools
|
|
{
|
|
// 子类化,并根据数据库索引显示图形
|
|
bool subClassGsViewAndShow(CGsPreviewCtrlEx *pCtrl, CDialog *pDlg, const UINT &ID, const int &id3D);
|
|
|
|
// 选择一个3D设备,并显示
|
|
bool selectEquAndShow(CGsPreviewCtrlEx *pCtrl, int &idx);
|
|
}
|
|
|
|
#define ParaAParaB(A,B) (A)=(B)
|
|
#define ParaBParaA(A,B) (B)=(A)
|