683 lines
16 KiB
C++
683 lines
16 KiB
C++
// SelectGJKLocation.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "SelectGJKLocation.h"
|
|
#include "GJKWorkspace.h"
|
|
#include "gjkWorkspace.h"
|
|
#include "TkwFile.h"
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
extern CString GetFileNameByAllName(const TCHAR* szAllFileName);
|
|
extern CString GetPathNameByAllName(const TCHAR* szAllFileName);
|
|
//extern void MakeVisible(PickSet &ss, bool bTrue);
|
|
extern BOOL GetFullGjkFile(const TCHAR* szShortFile, CString &csTkwFileName);
|
|
//GEOAPI BOOL arxWBlock(PickSet &ss, const TCHAR* szFileName, XPoint ptIns);
|
|
extern BOOL GetGjkwFileByMenu(const TCHAR* szMenuName, CString &csTkwFileName);
|
|
//extern TARCH_IMPEXP TCHAR g_sDwbPath[];
|
|
extern int GetNextDrawing(const TCHAR *tkName, TCHAR *dwg);
|
|
//extern GEOAPI int GetPickSetByGroup(const TCHAR *szGroup, PickSet &ss);
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSelectGJKLocation dialog
|
|
//add by cwk
|
|
void Iterator(Array<CString> &arr)
|
|
{
|
|
XString xsTchtkwFile;
|
|
if(!FindFile(_T("shsgjk.idx"), xsTchtkwFile))
|
|
{
|
|
AfxMessageBox(_T("SYS目录下没有发现shsgjk.idx文件!"));
|
|
return ;
|
|
}
|
|
CString csTmp, csBuf, csTkwType, csTkwTmp;
|
|
CString csDwbPath, csDdblPath, csLib3dPath;
|
|
csDwbPath = g_sDwbPath;
|
|
csDdblPath = csDwbPath.Left(csDwbPath.GetLength() - 5) + _T("\\ddbl\\");
|
|
csLib3dPath = csDwbPath.Left(csDwbPath.GetLength() - 5) + _T("\\Lib3d\\");
|
|
|
|
FILE *fp=_tfopen(xsTchtkwFile, _T("r"));
|
|
if(!fp)
|
|
return ;
|
|
|
|
while(!feof(fp))
|
|
{
|
|
TCHAR sBuf[256]=_T("");
|
|
_fgetts(sBuf, 255, fp);
|
|
csBuf = sBuf;
|
|
csBuf.TrimLeft();
|
|
csBuf.TrimRight();
|
|
if(csBuf == _T("") )
|
|
continue;
|
|
if(csBuf.Find(_T(':')) < 0 || csBuf.Find(_T('*')) < 0)
|
|
continue;
|
|
csTmp = csBuf.Mid(csBuf.Find(_T(':')) + 1,
|
|
csBuf.Find(_T('*')) - csBuf.Find(_T(':')) - 1);
|
|
csTkwType = csBuf.Left(csBuf.Find(_T(':')));
|
|
csTkwTmp = csBuf.Right(csBuf.GetLength() -csBuf.Find(_T('*')) - 1);
|
|
arr.AddTail(csTkwTmp);
|
|
}
|
|
fclose(fp);
|
|
}
|
|
//add by cwk
|
|
BOOL IsSameName(CString tkName,CString tksKind,CString tkNewname)
|
|
{
|
|
CodeBase db;
|
|
XDbfTable *pTable = db.Open(tkName);
|
|
if(!pTable)
|
|
{
|
|
AfxMessageBox(_T("TK文件只读或损坏!"));
|
|
return RTERROR;
|
|
}
|
|
pTable->MoveFirst();
|
|
CString xsKind,xsItem;
|
|
while(!pTable->IsEOF())
|
|
{
|
|
GET_FIELD(pTable, _T("kind"), xsKind);
|
|
GET_FIELD(pTable, _T("item"), xsItem);
|
|
CString sKind = xsKind,sItem = xsItem;
|
|
if(sKind == tksKind && sItem == tkNewname)
|
|
{
|
|
return TRUE;
|
|
}
|
|
pTable->MoveNext();
|
|
}
|
|
pTable->Close();
|
|
return FALSE;
|
|
}
|
|
|
|
//add by cwk
|
|
int InsGJK()
|
|
{
|
|
CString sName;
|
|
PickSet ss(SS_FREE);
|
|
if (SelectEntities(_T("请选择对象:"),ss,RBList(RTDXF0, _T("*"), NULL)) != RTNORM)
|
|
return RTERROR;
|
|
int nRetCode = RTERROR;
|
|
int rc;
|
|
XPoint center, basePt;
|
|
ads_real sx, sy, sz;
|
|
ss.GetExtend(center, &sx, &sy, &sz);
|
|
center.z -= sz/2.0; //基点在下方
|
|
adsout << _T("\n图块基点<") << center << _T(">:");
|
|
rc = ads_getpoint(Wcs2Ucs(center), _T(""), basePt);
|
|
if(rc==RTNONE)
|
|
{
|
|
basePt=Wcs2Ucs(center);
|
|
rc=RTNORM;
|
|
}
|
|
XString xsFullSld, xsFullDwg;
|
|
BOOL bHide = FALSE;
|
|
PickSet ssAll(SS_FREE);
|
|
if(rc==RTNORM)
|
|
{
|
|
ssAll.Get(_T("X"));
|
|
ssAll -= ss;
|
|
|
|
//add by xlc on 080812 解决对局部隐藏对象的影响
|
|
PickSet ssHide(SS_FREE);
|
|
GetPickSetByGroup(_T("_TCH_HIDE_GROUP"), ssHide);
|
|
ssAll -= ssHide;
|
|
|
|
MakeVisible(ssAll, false);
|
|
while(1)
|
|
{
|
|
const TCHAR *szPrompt = _T("\n制作幻灯片(请用zoom调整合适)或 [消隐(H)/不制作返回(X)]<制作>:");
|
|
XString sKeyword;
|
|
int nRet = 0;
|
|
INITGET_BEG(0, _T("H X"));
|
|
nRet = ads_getkword(szPrompt, sKeyword);
|
|
INITGET_END();
|
|
if(nRet == RTNONE)
|
|
break;
|
|
if(sKeyword[0]==_T('H'))
|
|
{
|
|
bHide = TRUE;
|
|
}
|
|
else
|
|
{
|
|
MakeVisible(ssAll, true);
|
|
return RTERROR;
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
return RTERROR;
|
|
}
|
|
CSelectGJKLocation dlg;
|
|
dlg.m_cGJKTree.m_bFlag = TRUE;
|
|
BOOL bFlag = FALSE;
|
|
if (ss.Length() == 1)
|
|
{
|
|
Entity ent = ss[0L];
|
|
Array<CString> arr;
|
|
Iterator(arr);
|
|
int i = 0;
|
|
while (i < arr.GetLength())
|
|
{
|
|
CString str = arr[i];
|
|
GetFullGjkFile(str,dlg.m_tkwname);
|
|
CTkwFile tkwfile(dlg.m_tkwname);
|
|
if (!tkwfile.m_csDxfCode.IsEmpty() && tkwfile.m_csDxfCode.Find(_T(',')) > -1)
|
|
{
|
|
TCHAR cType[256];
|
|
int i = 0,j = 0;
|
|
while (i < tkwfile.m_csDxfCode.GetLength())
|
|
{
|
|
if (tkwfile.m_csDxfCode[i] != _T(','))
|
|
{
|
|
cType[j] = tkwfile.m_csDxfCode[i];
|
|
}
|
|
else
|
|
{
|
|
cType[j] = _T('\0');
|
|
if (ent.Is(cType))
|
|
{
|
|
bFlag = TRUE;
|
|
break;
|
|
}
|
|
j = -1;
|
|
}
|
|
i++;
|
|
j++;
|
|
}
|
|
if (!bFlag)
|
|
{
|
|
cType[j] = _T('\0');
|
|
if (ent.Is(cType))
|
|
{
|
|
bFlag = TRUE;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (ent.Is(tkwfile.m_csDxfCode))
|
|
bFlag = TRUE;
|
|
}
|
|
if (bFlag)
|
|
break;
|
|
i++;
|
|
}
|
|
if (bFlag)
|
|
{
|
|
INT_PTR n = dlg.DoModal();
|
|
if (n == IDCANCEL )
|
|
{
|
|
MakeVisible(ssAll, true);
|
|
return RTERROR;
|
|
}
|
|
|
|
//modify by xlc on 080812 退出制作幻灯状态
|
|
//if (!dlg.m_bSelect)
|
|
//{
|
|
// AfxMessageBox(_T("请选择目标位置!!"));
|
|
// n = dlg.DoModal();
|
|
//}
|
|
//if (dlg.m_sNewGJKname.IsEmpty())
|
|
//{
|
|
// AfxMessageBox(_T("请输入新构件名字!!"));
|
|
// n = dlg.DoModal();
|
|
//}
|
|
for(i=0;;i++)
|
|
{
|
|
if (!dlg.m_bSelect)
|
|
{
|
|
AfxMessageBox(_T("请选择目标位置!!"));
|
|
n = dlg.DoModal();
|
|
if (n == IDCANCEL )
|
|
{
|
|
MakeVisible(ssAll, true);
|
|
return RTERROR;
|
|
}
|
|
}
|
|
else
|
|
break;
|
|
}
|
|
for(i=0;;i++)
|
|
{
|
|
if (dlg.m_sNewGJKname.IsEmpty())
|
|
{
|
|
AfxMessageBox(_T("请输入新构件名字!!"));
|
|
n = dlg.DoModal();
|
|
if (n == IDCANCEL )
|
|
{
|
|
MakeVisible(ssAll, true);
|
|
return RTERROR;
|
|
}
|
|
}
|
|
else
|
|
break;
|
|
}
|
|
|
|
while (n == IDOK && IsSameName(dlg.m_tkname,dlg.m_type,dlg.m_sNewGJKname))
|
|
{
|
|
AfxMessageBox(_T("出现重名,请重新输入名字"));
|
|
n = dlg.DoModal();
|
|
}
|
|
if (n == IDOK)
|
|
{
|
|
if(dlg.m_tkname == _T(""))
|
|
{
|
|
return RTERROR;
|
|
}
|
|
sName = dlg.m_sNewGJKname;
|
|
XString xsRet, xsDwbPath;
|
|
xsDwbPath << GetPathNameByAllName(dlg.m_tkname)
|
|
<< GetFileNameByAllName(dlg.m_tkname) << _T(".DWB");
|
|
|
|
if(GetNextDrawing(dlg.m_tkname, xsRet)!=RTNORM)
|
|
{
|
|
return RTERROR;
|
|
}
|
|
//入库
|
|
{
|
|
TCHAR dwgPrefix[256]=_T("");
|
|
GetTempPath(255, dwgPrefix);
|
|
if(dwgPrefix[_tcslen(dwgPrefix)-1]!=_T('\\'))
|
|
_tcscat(dwgPrefix, _T("\\"));
|
|
_tcscat(dwgPrefix, _T("SRTEMP\\"));
|
|
MakeDir(dwgPrefix);
|
|
xsFullSld << dwgPrefix << CString((const TCHAR*)xsRet) << _T(".sld");
|
|
xsFullDwg << dwgPrefix << CString((const TCHAR*)xsRet) << _T(".dwg");
|
|
if(bHide)
|
|
{
|
|
XPushVar<int> splframe(_T("SPLFRAME"), 0);
|
|
SHads_command(RTSTR, _T("HIDE"), RTNONE);
|
|
SHads_command(RTSTR, _T("MSLIDE"), RTSTR, (TCHAR *)xsFullSld, RTNONE);
|
|
SHads_command(RTSTR, _T("REGEN"), RTNONE);
|
|
}
|
|
else
|
|
{
|
|
SHads_command(RTSTR, _T("MSLIDE"), RTSTR, (TCHAR *)xsFullSld, RTNONE);
|
|
}
|
|
XString xsSlbFile(256);
|
|
xsSlbFile << GetPathNameByAllName(dlg.m_tkname) << GetFileNameByAllName(dlg.m_tkname)<< _T(".SLB");
|
|
XSlideLib slbMan(xsSlbFile);
|
|
if(!slbMan)
|
|
{
|
|
MakeVisible(ssAll, true);
|
|
return RTERROR;
|
|
}
|
|
slbMan.Append(xsFullSld);
|
|
_tremove(xsFullSld);
|
|
|
|
if(!ss)
|
|
{
|
|
MakeVisible(ssAll, true);
|
|
return RTERROR;
|
|
}
|
|
if(arxWBlock(ss, xsFullDwg, Ucs2Wcs(basePt)))
|
|
{
|
|
XString xsDwbFile(256);
|
|
xsDwbFile << GetPathNameByAllName(dlg.m_tkname) << GetFileNameByAllName(dlg.m_tkname) << _T(".DWB");
|
|
XDrawingLib dwbMan(xsDwbFile);
|
|
if(!dwbMan)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
dwbMan.Append(xsFullDwg);
|
|
nRetCode=RTNORM;
|
|
}
|
|
_tremove(xsFullDwg);
|
|
}
|
|
MakeVisible(ssAll, true);
|
|
{
|
|
CodeBase db;
|
|
XDbfTable *pTable = db.Open(dlg.m_tkname);
|
|
if(!pTable)
|
|
{
|
|
AfxMessageBox(_T("TK文件只读或损坏!"));
|
|
return RTERROR;
|
|
}
|
|
pTable->AppendBegin();
|
|
SET_FIELD(pTable, _T("kind"), LPCTSTR(dlg.m_type));
|
|
SET_FIELD(pTable, _T("Item"), LPCTSTR(sName));
|
|
SET_FIELD(pTable, _T("Drawing"), xsRet);
|
|
pTable->AppendEnd();
|
|
}
|
|
if (n == IDOK && !dlg.m_bFlag)
|
|
{
|
|
CGJKWorkspace dlg0(dlg.m_tkwname,dlg.m_tkname,xsRet,2);
|
|
dlg0.DoModal();
|
|
}
|
|
}
|
|
}
|
|
|
|
//add by xlc on 080812 退出制作幻灯状态
|
|
else
|
|
{
|
|
MakeVisible(ssAll, true);
|
|
return RTERROR;
|
|
}
|
|
}
|
|
}
|
|
if (!bFlag || ss.Length() > 1)
|
|
{
|
|
GetFullGjkFile(_T("Other"),dlg.m_tkwname);
|
|
INT_PTR n = dlg.DoModal();
|
|
if (n == IDCANCEL )
|
|
{
|
|
MakeVisible(ssAll, true);
|
|
return RTERROR;
|
|
}
|
|
|
|
//modify by xlc on 080812 退出制作幻灯状态
|
|
/*if (!dlg.m_bSelect)
|
|
{
|
|
AfxMessageBox(_T("请选择目标位置!!"));
|
|
n = dlg.DoModal();
|
|
}
|
|
if (dlg.m_sNewGJKname.IsEmpty())
|
|
{
|
|
AfxMessageBox(_T("请输入新构件名字!!"));
|
|
n = dlg.DoModal();
|
|
}*/
|
|
for(int i=0;;i++)
|
|
{
|
|
if (!dlg.m_bSelect)
|
|
{
|
|
AfxMessageBox(_T("请选择目标位置!!"));
|
|
n = dlg.DoModal();
|
|
if (n == IDCANCEL )
|
|
{
|
|
MakeVisible(ssAll, true);
|
|
return RTERROR;
|
|
}
|
|
}
|
|
else
|
|
break;
|
|
}
|
|
for(i=0;;i++)
|
|
{
|
|
if (dlg.m_sNewGJKname.IsEmpty())
|
|
{
|
|
AfxMessageBox(_T("请输入新构件名字!!"));
|
|
n = dlg.DoModal();
|
|
if (n == IDCANCEL )
|
|
{
|
|
MakeVisible(ssAll, true);
|
|
return RTERROR;
|
|
}
|
|
}
|
|
else
|
|
break;
|
|
}
|
|
|
|
while (n == IDOK && IsSameName(dlg.m_tkname,dlg.m_type,dlg.m_sNewGJKname))
|
|
{
|
|
AfxMessageBox(_T("出现重名,请重新输入名字"));
|
|
n = dlg.DoModal();
|
|
}
|
|
if (n == IDOK)
|
|
{
|
|
if(dlg.m_tkname == _T(""))
|
|
{
|
|
MakeVisible(ssAll, true);
|
|
return RTERROR;
|
|
}
|
|
sName = dlg.m_sNewGJKname;
|
|
XString xsRet, xsDwbPath;
|
|
xsDwbPath << GetPathNameByAllName(dlg.m_tkname)
|
|
<< GetFileNameByAllName(dlg.m_tkname) << _T(".DWB");
|
|
|
|
if(GetNextDrawing(dlg.m_tkname, xsRet)!=RTNORM)
|
|
{
|
|
MakeVisible(ssAll, true);
|
|
return RTERROR;
|
|
}
|
|
//入库
|
|
{
|
|
TCHAR dwgPrefix[256]=_T("");
|
|
GetTempPath(255, dwgPrefix);
|
|
if(dwgPrefix[_tcslen(dwgPrefix)-1]!=_T('\\'))
|
|
_tcscat(dwgPrefix, _T("\\"));
|
|
_tcscat(dwgPrefix, _T("SRTEMP\\"));
|
|
MakeDir(dwgPrefix);
|
|
xsFullSld << dwgPrefix << CString((const TCHAR*)xsRet) << _T(".sld");
|
|
xsFullDwg << dwgPrefix << CString((const TCHAR*)xsRet) << _T(".dwg");
|
|
if(bHide)
|
|
{
|
|
XPushVar<int> splframe(_T("SPLFRAME"), 0);
|
|
SHads_command(RTSTR, _T("HIDE"), RTNONE);
|
|
SHads_command(RTSTR, _T("MSLIDE"), RTSTR, (TCHAR *)xsFullSld, RTNONE);
|
|
SHads_command(RTSTR, _T("REGEN"), RTNONE);
|
|
}
|
|
else
|
|
{
|
|
SHads_command(RTSTR, _T("MSLIDE"), RTSTR, (TCHAR *)xsFullSld, RTNONE);
|
|
}
|
|
|
|
XString xsSlbFile(256);
|
|
xsSlbFile << GetPathNameByAllName(dlg.m_tkname) << GetFileNameByAllName(dlg.m_tkname)<< _T(".SLB");
|
|
XSlideLib slbMan(xsSlbFile);
|
|
if(!slbMan)
|
|
{
|
|
MakeVisible(ssAll, true);
|
|
return RTERROR;
|
|
}
|
|
slbMan.Append(xsFullSld);
|
|
_tremove(xsFullSld);
|
|
|
|
if(!ss)
|
|
{
|
|
MakeVisible(ssAll, true);
|
|
return RTERROR;
|
|
}
|
|
|
|
if(arxWBlock(ss, xsFullDwg, Ucs2Wcs(basePt)))
|
|
{
|
|
XString xsDwbFile(256);
|
|
xsDwbFile << GetPathNameByAllName(dlg.m_tkname) << GetFileNameByAllName(dlg.m_tkname) << _T(".DWB");
|
|
XDrawingLib dwbMan(xsDwbFile);
|
|
if(!dwbMan)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
dwbMan.Append(xsFullDwg);
|
|
nRetCode=RTNORM;
|
|
}
|
|
_tremove(xsFullDwg);
|
|
}
|
|
MakeVisible(ssAll, true);
|
|
CodeBase db;
|
|
XDbfTable *pTable = db.Open(dlg.m_tkname);
|
|
if(!pTable)
|
|
{
|
|
AfxMessageBox(_T("TK文件只读或损坏!"));
|
|
return RTERROR;
|
|
}
|
|
pTable->AppendBegin();
|
|
SET_FIELD(pTable, _T("kind"), LPCTSTR(dlg.m_type));
|
|
SET_FIELD(pTable, _T("Item"), LPCTSTR(sName));
|
|
SET_FIELD(pTable, _T("Drawing"), xsRet);
|
|
pTable->AppendEnd();
|
|
}
|
|
if (n == IDOK && !dlg.m_bFlag)
|
|
{
|
|
CTemporaryResourceOverride vTmp;
|
|
CGJKWorkspace dlg0(dlg.m_tkwname,dlg.m_tkname,xsRet,2);
|
|
dlg0.DoModal();
|
|
}
|
|
}
|
|
|
|
//add by xlc on 080812 退出制作幻灯状态
|
|
else
|
|
{
|
|
MakeVisible(ssAll, true);
|
|
return RTERROR;
|
|
}
|
|
}
|
|
return RTNORM;
|
|
}
|
|
|
|
CSelectGJKLocation::CSelectGJKLocation(CWnd* pParent /*=NULL*/)
|
|
: CModelessDialog(CSelectGJKLocation::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CSelectGJKLocation)
|
|
m_sGJKlocation = _T("");
|
|
m_sNewGJKname = _T("");
|
|
//}}AFX_DATA_INIT
|
|
m_bFlag = FALSE;
|
|
m_bEditLabel = FALSE;
|
|
m_bSelect = FALSE;
|
|
}
|
|
|
|
void CSelectGJKLocation::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CSelectGJKLocation)
|
|
DDX_Control(pDX, IDC_TREE_GJK, m_cGJKTree);
|
|
DDX_Text(pDX, IDC_EDIT_LOCATION, m_sGJKlocation);
|
|
DDX_Text(pDX, IDC_EDIT_NAME, m_sNewGJKname);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CSelectGJKLocation, CModelessDialog)
|
|
//{{AFX_MSG_MAP(CSelectGJKLocation)
|
|
ON_NOTIFY(TVN_SELCHANGED, IDC_TREE_GJK, OnSelchangedGJKTree)
|
|
ON_BN_CLICKED(IDC_BUTTON_OK, OnButtonOkExit)
|
|
ON_COMMAND(ID_TK_POPUP_RENAMEKIND, OnTkPopupRenamekind)
|
|
ON_COMMAND(ID_TK_POPUP_NEW, OnTkPopupNew)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSelectGJKLocation message handlers
|
|
BOOL CSelectGJKLocation::PreTranslateMessage(MSG* pMsg)
|
|
{
|
|
if (pMsg ->message == WM_KEYDOWN)
|
|
{
|
|
if (m_bEditLabel && (pMsg ->wParam == VK_RETURN || pMsg ->wParam == VK_DELETE
|
|
|| pMsg ->wParam == VK_ESCAPE || GetKeyState(VK_CONTROL)))
|
|
{
|
|
::TranslateMessage(pMsg);
|
|
::DispatchMessage(pMsg);
|
|
return TRUE;
|
|
}
|
|
}
|
|
return CDialog::PreTranslateMessage(pMsg);
|
|
}
|
|
BOOL CSelectGJKLocation::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
m_bSelect = FALSE;
|
|
CTemporaryResourceOverride vTmp;
|
|
m_imageTree.Create( IDB_TREE1, 14, 1, RGB(255,255,255) );
|
|
m_cGJKTree.SetImageList( &m_imageTree, TVSIL_NORMAL );
|
|
m_cGJKTree.SetDataSource(m_tkwname);
|
|
m_sGJKlocation = m_cGJKTree.GetItemText(m_cGJKTree.GetRootItem());
|
|
UpdateData(FALSE);
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
void CSelectGJKLocation::OnSelchangedGJKTree(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
UpdateData();
|
|
HTREEITEM SelItem = m_cGJKTree.GetSelectedItem();
|
|
m_sGJKlocation = m_cGJKTree.GetItemText(SelItem);
|
|
UpdateData(FALSE);
|
|
HTREEITEM rootItem = m_cGJKTree.GetRootItem();
|
|
if (rootItem == SelItem)
|
|
{
|
|
m_bSelect = FALSE;
|
|
}
|
|
else
|
|
{
|
|
m_bSelect = TRUE;
|
|
}
|
|
CString str = m_cGJKTree.GetItemText(rootItem);
|
|
GetFullGjkFile(str,m_tkwname);
|
|
if (SelItem == rootItem)
|
|
{
|
|
return;
|
|
}
|
|
HTREEITEM parentItem = NULL;
|
|
HTREEITEM temp = SelItem;
|
|
do
|
|
{
|
|
parentItem = m_cGJKTree.GetParentItem(SelItem);
|
|
if (parentItem == rootItem)
|
|
{
|
|
m_tkname = m_cGJKTree.GetItemText(SelItem);
|
|
m_tkname = GetPathNameByAllName(m_tkwname) + m_tkname + _T(".TK");
|
|
break;
|
|
}
|
|
SelItem = parentItem;
|
|
} while(1);
|
|
|
|
SelItem = temp;
|
|
m_type = _T("");
|
|
while (m_cGJKTree.GetParentItem(SelItem) != rootItem)
|
|
{
|
|
if (m_type.IsEmpty())
|
|
{
|
|
m_type = m_cGJKTree.GetItemText(SelItem);
|
|
}
|
|
else
|
|
{
|
|
m_type = m_cGJKTree.GetItemText(SelItem) + _T('\\') + m_type;
|
|
}
|
|
SelItem = m_cGJKTree.GetParentItem(SelItem);
|
|
}
|
|
}
|
|
|
|
void CSelectGJKLocation::OnButtonOkExit()
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
m_bFlag = TRUE;
|
|
OnOK();
|
|
}
|
|
void CSelectGJKLocation::OnTkPopupRenamekind() //类别重命名
|
|
{
|
|
HTREEITEM hTreeItem = NULL;
|
|
hTreeItem = m_cGJKTree.GetSelectedItem();
|
|
m_cGJKTree.SetFocus();
|
|
if(hTreeItem && hTreeItem != m_cGJKTree.GetRootItem());
|
|
{
|
|
m_bEditLabel = TRUE;
|
|
m_bSelect = FALSE;
|
|
m_cGJKTree.EditLabel(hTreeItem);
|
|
}
|
|
}
|
|
|
|
void CSelectGJKLocation::OnTkPopupNew() //新建类别
|
|
{
|
|
HTREEITEM hItem = NULL;
|
|
hItem = m_cGJKTree.GetSelectedItem();
|
|
HTREEITEM hSubItem = NULL;
|
|
if(hItem == NULL)
|
|
return;
|
|
|
|
CString csCurTKName, csCurType;
|
|
m_cGJKTree.GetNodeAllPath(hItem, csCurTKName, csCurType);
|
|
|
|
CodeBase db;
|
|
XDbfTable *pTable = db.Open(csCurTKName);
|
|
if(!pTable)
|
|
{
|
|
AfxMessageBox(_T("TK文件只读或损坏!"));
|
|
return;
|
|
}
|
|
hSubItem = m_cGJKTree.InsertItem(_T("新类别"), 1, 2, hItem );
|
|
m_cGJKTree.SelectItem(hSubItem);
|
|
if(csCurType == _T(""))
|
|
csCurType = _T("新类别");
|
|
else
|
|
csCurType = csCurType + _T("\\新类别");
|
|
pTable->AppendBegin();
|
|
SET_FIELD(pTable, _T("kind"), (const TCHAR*)csCurType);
|
|
pTable->AppendEnd();
|
|
m_cGJKTree.SetFocus();
|
|
m_bEditLabel = TRUE;
|
|
m_bSelect = FALSE;
|
|
m_cGJKTree.EditLabel(hSubItem);
|
|
}
|