443 lines
13 KiB
C++
443 lines
13 KiB
C++
#if !defined(AFX_AXISGRIDSHEET_H__1CD6AF60_C38E_436B_990C_FD40C10B0678__INCLUDED_)
|
|
#define AFX_AXISGRIDSHEET_H__1CD6AF60_C38E_436B_990C_FD40C10B0678__INCLUDED_
|
|
|
|
#if _MSC_VER > 1000
|
|
#pragma once
|
|
#endif // _MSC_VER > 1000
|
|
// AxisGridSheet.h : header file
|
|
#include "resource.h"
|
|
#include "GsPreviewCtrl.h"
|
|
#include "afxwin.h"
|
|
#include "WDGrid.h"
|
|
#include "afxcmn.h"
|
|
#include <vector>
|
|
#include <algorithm>
|
|
//using namespace std;
|
|
|
|
#define WM_GRID_MESSAGE (WM_USER+100)
|
|
#define WM_EDIT_MESSAGE (WM_USER+101)
|
|
#define ID_NEW_ROW 1
|
|
#define ID_INS_ROW 2
|
|
#define ID_DEL_ROW 3
|
|
#define ID_ADD_ROW 4
|
|
#define ID_SELECT_ALL 5
|
|
#define ID_COPY_ROW 6
|
|
#define ID_CUT_ROW 7
|
|
#define ID_PASTE_ROW 8
|
|
#define AXIS_PEC 1E-6
|
|
|
|
///////////////////////////////
|
|
///////////////////////////////
|
|
// TAxisGrid
|
|
class TAxisGrid : public WDGrid
|
|
{
|
|
protected:
|
|
virtual void OnCellComboString(WDGridCell &cell, CComboBox &combo);
|
|
virtual bool OnModified(WDGridCell &cell, CString &text);
|
|
virtual bool OnBeforePaste(long i);
|
|
virtual void OnDataChanged();
|
|
virtual void OnInsertRow(WDGridRow&row);
|
|
|
|
DECLARE_MESSAGE_MAP()
|
|
};
|
|
|
|
//////////////////////////////////
|
|
//////////////////////////////////
|
|
// 尺寸*个数
|
|
class TCountAndSize
|
|
{
|
|
public:
|
|
double m_dSize;
|
|
int m_nCount;
|
|
int m_nPosition;
|
|
public:
|
|
TCountAndSize & operator = (const TCountAndSize &src)
|
|
{
|
|
m_dSize = src.m_dSize;
|
|
m_nCount = src.m_nCount;
|
|
m_nPosition = src.m_nPosition;
|
|
return *this;
|
|
}
|
|
|
|
TCountAndSize(double s, int c, int nPosition = 0)
|
|
: m_dSize(s), m_nCount(c), m_nPosition(nPosition)
|
|
{
|
|
}
|
|
TCountAndSize(const TCountAndSize &src)
|
|
{
|
|
*this = src;
|
|
}
|
|
|
|
bool operator <(const TCountAndSize&d){return FALSE;}
|
|
bool operator >(const TCountAndSize&d){return FALSE;}
|
|
|
|
};
|
|
|
|
///////////////////////////////
|
|
///////////////////////////////
|
|
// 轴线长度和类别
|
|
class TAxisDistAndKind
|
|
{
|
|
public:
|
|
double nDist;
|
|
int nKind; // 1, 2, 3
|
|
public:
|
|
TAxisDistAndKind(double nD, int nK): nDist(nD), nKind(nK) {}
|
|
static int CompareReal(const TAxisDistAndKind *, const void *);
|
|
static int CompareForSort(const TAxisDistAndKind *p1, const TAxisDistAndKind *p2);
|
|
};
|
|
|
|
////////////////////////////////////
|
|
////////////////////////////////////
|
|
// CEditEx
|
|
class CEditEx : public CEdit
|
|
{
|
|
public:
|
|
virtual BOOL PreTranslateMessage(MSG* pMsg)
|
|
{
|
|
if(pMsg->message == WM_KEYDOWN)
|
|
{
|
|
int nVK = (int)pMsg->wParam;
|
|
if(nVK == VK_RETURN || nVK == VK_SPACE || nVK == 0xBC)
|
|
{
|
|
// [2010-3-23 wubo] 允许用户在控件中插入这三个字符
|
|
CPoint ptCur = GetCaretPos();
|
|
int idx = CharFromPos(ptCur);
|
|
CString csItem1;
|
|
GetWindowText(csItem1);
|
|
csItem1.Insert(idx, ' ');
|
|
SetWindowText(csItem1);
|
|
|
|
GetParent()->SendMessage(WM_COMMAND,
|
|
MAKELPARAM(GetDlgCtrlID(), WM_EDIT_MESSAGE),
|
|
(LPARAM)GetSafeHwnd());
|
|
|
|
// int nEndChar = LineLength();
|
|
// SetSel(nEndChar, nEndChar);
|
|
// [2010-3-23 wubo] 设置caret到下一个字符。如果插入字符没有被过滤掉,则此行为与CEdit的默认行为一致,
|
|
// 如果被过滤掉,说明下一字符为空格,将caret越过空格。
|
|
SetSel(idx + 1, idx + 1);
|
|
|
|
return TRUE;
|
|
}
|
|
}
|
|
return CEdit::PreTranslateMessage(pMsg);
|
|
}
|
|
};
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CAxisBasePage dialog
|
|
|
|
class CAxisBasePage : public CAcUiTabChildDialog
|
|
{
|
|
DECLARE_DYNAMIC(CAxisBasePage)
|
|
public:
|
|
enum EDimType {kRect = 0, kArc};
|
|
|
|
// Construction
|
|
public:
|
|
CAxisBasePage();
|
|
|
|
// Dialog Data
|
|
//{{AFX_DATA(CAxisBasePage)
|
|
TAxisGrid m_grid;
|
|
CGsPreviewCtrl m_PreviewCtrl;
|
|
AcDbDatabase m_PreviewDb;
|
|
BOOL m_bPreview;
|
|
CListBox m_list;
|
|
CEditEx m_editInput;
|
|
CEditEx m_editAngle;
|
|
CSpinButtonCtrl m_spinAngle;
|
|
double m_dDisX;
|
|
double m_dDisY;
|
|
double m_dAngle;
|
|
//}}AFX_DATA
|
|
XPoint m_ptIns;
|
|
// [2010-4-2 wubo] 函数变虚,CArcAxisPage类重载此函数,以使总夹角显示3位小数。
|
|
// void UpdateEditDis();
|
|
virtual void UpdateEditDis();
|
|
// [2010-4-2 wubo] 函数变虚,CArcAxisPage类重载此函数,以使表格中的轴夹角可为小数。
|
|
// void UpdateGrid();
|
|
virtual void UpdateGrid();
|
|
// [2010-4-2 wubo] 函数变虚,CArcAxisPage类重载此函数,以便在键入轴夹角时可输入和显示小数。
|
|
// void UpdateEditInput();
|
|
virtual void UpdateEditInput();
|
|
virtual int InsertToCSpace() = 0;
|
|
|
|
// Overrides
|
|
// ClassWizard generate virtual function overrides
|
|
//{{AFX_VIRTUAL(CAxisBasePage)
|
|
protected:
|
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
|
virtual BOOL OnInitDialog();
|
|
//}}AFX_VIRTUAL
|
|
|
|
// Implementation
|
|
protected:
|
|
BOOL m_bEditInput;
|
|
virtual void InitList() = 0;
|
|
virtual void UpdateEditAngle() = 0;
|
|
virtual void GetEditDisValue() = 0;
|
|
virtual BOOL AddToCList(double m_dSize, int m_nCount) = 0;
|
|
virtual PDList<TCountAndSize> & GetSizeDesc(int n) = 0;
|
|
virtual PDList<TCountAndSize> & GetSizeDesc() = 0;
|
|
virtual BOOL DrawEntity(AcDbBlockTableRecord *&pBlockTableRecord) = 0;
|
|
virtual void ImportFromFile() = 0;
|
|
virtual void ExportToFile() = 0;
|
|
|
|
BOOL InitPreview();
|
|
// [2010-4-2 wubo] 函数变虚,CArcAxisPage类重载此函数,使轴夹角列的默认宽度为7位数字宽。
|
|
// void InitGrid();
|
|
virtual void InitGrid();
|
|
void UpdatePreview();
|
|
virtual void UpdateVisible(){}
|
|
|
|
// add by zyc [2012/04/20] 将拾取的标注数据添加到键入编辑框
|
|
void AddDataToInputEdit(CArray<double, double&>& arData);
|
|
|
|
void DrawBasePoint(const double dLength, AcDbBlockTableRecord *&pBlockTabRecord);
|
|
void GetRecordExtents(AcDbBlockTableRecord *pBlockTabRecord, AcDbExtents &extents);
|
|
void CopyPDList(PDList<TCountAndSize> &source, PDList<TCountAndSize> &dest);
|
|
double TotalDistance(PDList<TCountAndSize> &lstDesc);
|
|
|
|
// Generated message map functions
|
|
//{{AFX_MSG(CAxisBasePage)
|
|
afx_msg void OnLbnSelchangeList();
|
|
afx_msg void OnBnClickedButtonClear();
|
|
afx_msg void OnEnKillfocusEditInput();
|
|
afx_msg void OnMessageEditInput();
|
|
afx_msg LRESULT OnGridMessage(WPARAM wParam, LPARAM lParam);
|
|
afx_msg void OnDestroy();
|
|
//}}AFX_MSG
|
|
DECLARE_MESSAGE_MAP()
|
|
};
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CRectAxisPage dialog
|
|
|
|
class CRectAxisPage : public CAxisBasePage
|
|
{
|
|
DECLARE_DYNCREATE(CRectAxisPage)
|
|
|
|
// Construction
|
|
public:
|
|
CRectAxisPage();
|
|
|
|
// Dialog Data
|
|
//{{AFX_DATA(CRectAxisPage)
|
|
enum { IDD = IDD_RECTAXIS_PAGE };
|
|
int m_nRadio;
|
|
double m_dOffset;
|
|
CEdit m_editOffset;
|
|
CButton m_buttonBack;
|
|
CButton m_buttonForward;
|
|
//}}AFX_DATA
|
|
static const TCHAR *s_szFileTitle; //数据文件标题
|
|
void ComeBack();
|
|
virtual int InsertToCSpace();
|
|
|
|
// Overrides
|
|
// ClassWizard generate virtual function overrides
|
|
//{{AFX_VIRTUAL(CRectAxisPage)
|
|
protected:
|
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
|
virtual BOOL OnInitDialog();
|
|
//}}AFX_VIRTUAL
|
|
|
|
// Implementation
|
|
protected:
|
|
PDList<TCountAndSize> m_lstUp, m_lstDown, m_lstLeft, m_lstRight;
|
|
|
|
virtual void InitList();
|
|
virtual void UpdateEditAngle();
|
|
virtual void GetEditDisValue();
|
|
virtual BOOL AddToCList(double m_dSize, int m_nCount);
|
|
virtual PDList<TCountAndSize> & GetSizeDesc(int n);
|
|
virtual PDList<TCountAndSize> & GetSizeDesc();
|
|
virtual BOOL DrawEntity(AcDbBlockTableRecord *&pBlockTableRecord);
|
|
virtual void ImportFromFile();
|
|
virtual void ExportToFile();
|
|
|
|
void UpdateEditOffset();
|
|
virtual void UpdateVisible();
|
|
void GetOffset(PDList<TCountAndSize> &lstSize, int &nPos, double &dOffset);
|
|
void ReplaceOffset(PDList<TCountAndSize> &lstSize);
|
|
PDList<TCountAndSize> &GetCorreDesc();
|
|
PDList<TCountAndSize> &GetCurrentDesc();
|
|
|
|
double GetAxisLenX();
|
|
double GetAxisLenY();
|
|
BOOL DrawAxis(AcDbBlockTableRecord *&pBlockTableRecord, int nDir);
|
|
// Generated message map functions
|
|
//{{AFX_MSG(CRectAxisPage)
|
|
// afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
|
|
afx_msg void OnBnClickedRadio();
|
|
afx_msg void OnBnClickedButtonBack();
|
|
afx_msg void OnBnClickedButtonForward();
|
|
afx_msg void OnEnChangeEditOffset();
|
|
afx_msg void OnBnClickedButtonClear();
|
|
afx_msg void OnEnKillfocusEditAngle();
|
|
afx_msg void OnMessageEditAngle();
|
|
afx_msg void OnEnChangeEditAngle();
|
|
afx_msg void OnBnClickedButtonPick();
|
|
//}}AFX_MSG
|
|
DECLARE_MESSAGE_MAP()
|
|
};
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CArcAxisPage dialog
|
|
|
|
class CArcAxisPage : public CAxisBasePage
|
|
{
|
|
DECLARE_DYNCREATE(CArcAxisPage)
|
|
|
|
// Construction
|
|
public:
|
|
CArcAxisPage();
|
|
|
|
// Dialog Data
|
|
//{{AFX_DATA(CArcAxisPage)
|
|
enum { IDD = IDD_ARCAXIS_PAGE };
|
|
int m_nCenter;
|
|
int m_nClockWise;
|
|
CEdit m_editRadius;
|
|
double m_dInRadius;
|
|
//}}AFX_DATA
|
|
int m_nPtInsert;
|
|
static const TCHAR *s_szFileTitle; //数据文件标题
|
|
PDList<TCountAndSize> m_lstArc, m_lstRadius;
|
|
void ComeBack();
|
|
void CopyPropertiesFrom(CArcAxisPage *pSource);
|
|
virtual BOOL DrawEntity(AcDbBlockTableRecord *&pBlockTableRecord);
|
|
virtual int InsertToCSpace();
|
|
// [2010-4-2 wubo] 重载虚函数,使轴夹角可为小数
|
|
virtual void UpdateGrid();
|
|
// [2010-4-2 wubo] 重载虚函数,使总长度显示3位小数
|
|
virtual void UpdateEditDis();
|
|
// [2010-4-2 wubo] 重载虚函数,使轴夹角可以键入和显示小数,整数+小数点+小数一共为7
|
|
virtual void UpdateEditInput();
|
|
|
|
// Overrides
|
|
// ClassWizard generated virtual function overrides
|
|
//{{AFX_VIRTUAL(CArcAxisPage)
|
|
protected:
|
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
|
virtual BOOL OnInitDialog();
|
|
//}}AFX_VIRTUAL
|
|
|
|
// Implementation
|
|
protected:
|
|
BOOL m_bComAxis;
|
|
XPoint m_ptCenter;
|
|
|
|
virtual void InitList();
|
|
virtual void UpdateEditAngle();
|
|
virtual void GetEditDisValue();
|
|
virtual BOOL AddToCList(double m_dSize, int m_nCount);
|
|
virtual PDList<TCountAndSize> & GetSizeDesc(int n);
|
|
virtual PDList<TCountAndSize> & GetSizeDesc();
|
|
virtual void ImportFromFile();
|
|
virtual void ExportToFile();
|
|
// [2010-4-2 wubo] 重载虚函数,使表格中的轴夹角列默认为7个数的宽度
|
|
virtual void InitGrid();
|
|
|
|
void UpdateList();
|
|
void UpdateInRadius();
|
|
void UpdateClockWise();
|
|
void UpdateComonAxis( BOOL bComAxis = FALSE);
|
|
XPoint GetCenterPoint();
|
|
BOOL DrawAxisArc(AcDbBlockTableRecord *&pBlockTabRecord);
|
|
BOOL DrawAxisLine(AcDbBlockTableRecord *&pBlockTabRecord);
|
|
BOOL DrawCircleCenter(AcDbBlockTableRecord *&pBlockTabRecord);
|
|
// Generated message map functions
|
|
//{{AFX_MSG(CArcAxisPage)
|
|
afx_msg void OnBnClickedRadioCenterangle();
|
|
afx_msg void OnBnClickedRadioClockwise();
|
|
afx_msg void OnEnKillfocusEditAngle();
|
|
afx_msg void OnMessageEditAngle();
|
|
afx_msg void OnEnChangeEditAngle();
|
|
afx_msg void OnEnChangeEditRadius();
|
|
afx_msg void OnEnKFEditRadius();
|
|
afx_msg void OnBnClickedButtonInsert();
|
|
afx_msg void OnBnClickedButtonRadius();
|
|
afx_msg void OnBnClickedButtonCommon();
|
|
afx_msg void OnBnClickedButtonPick();
|
|
//}}AFX_MSG
|
|
DECLARE_MESSAGE_MAP()
|
|
};
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CAxisGridSheet
|
|
|
|
class CAxisGridSheet : public CAcUiTabMainDialog
|
|
{
|
|
DECLARE_DYNAMIC(CAxisGridSheet)
|
|
|
|
// Construction
|
|
public:
|
|
CAxisGridSheet(CWnd* parent = NULL);
|
|
|
|
// Dialog Data
|
|
//{{AFX_DATA(CArcAxisPage)
|
|
enum { IDD = IDD_AXIS_GRID };
|
|
CAcUiTab m_tab;
|
|
CStatic m_staticX;
|
|
CStatic m_staticY;
|
|
//}}AFX_DATA
|
|
|
|
public:
|
|
// Overrides
|
|
// ClassWizard generated virtual function overrides
|
|
//{{AFX_VIRTUAL(CAxisGridSheet)
|
|
virtual BOOL OnInitDialog();
|
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
|
|
virtual void OnOK();
|
|
//}}AFX_VIRTUAL
|
|
BOOL GetInRadius(const CString &szInRadius, double &dRadius);
|
|
BOOL GetComAxisLine();
|
|
void UpdateSize(CString szDisX, CString szDisY);
|
|
|
|
// add by zyc 20120420 拾取标注对象并获得标注数据
|
|
int PickDimensions(CRectAxisPage::EDimType eType, CArray<double, double&>& arData);
|
|
|
|
// add by zyc 20120420 用于list::sort的排序函数,对拾取的标注对象排序
|
|
static bool SortDimArc(const AcDbObjectId& element1, const AcDbObjectId& element2);
|
|
static bool SortDimRect(const AcDbObjectId& element1, const AcDbObjectId& element2);
|
|
|
|
protected:
|
|
CRectAxisPage m_pageRectAxis;
|
|
CArcAxisPage m_pageArcAxis;
|
|
static int s_nPage;
|
|
int m_nQuadrant;
|
|
|
|
// add by zyc
|
|
// 过滤标注对象,第一个参数表示需要保留的标注类型
|
|
BOOL FilterDimensions(CArcAxisPage::EDimType eType, std::vector<AcDbObjectId>& lstObjId);
|
|
// 检查标注对象是否共线
|
|
BOOL IsCollinear(CArcAxisPage::EDimType eType, std::vector<AcDbObjectId>& vtObjId);
|
|
// 根据标注对象所在的位置进行排序,并提取标注对象的数据
|
|
BOOL SortDimensions(CArcAxisPage::EDimType eType, std::vector<AcDbObjectId>& vtObjId, CArray<double, double&>& arData);
|
|
|
|
BOOL SelectAxisGrid();
|
|
int GetVectorPos( AcGeVector2d vec );
|
|
BOOL GetQuadrant(const XPoint &point, const XLine &line, const XPoint &ptMid, double dRotate, CArcAxisPage *pArc);
|
|
XPointList m_lstPoint;
|
|
//{{AFX_MSG(CAxisGridSheet)
|
|
afx_msg void OnDestroy();
|
|
afx_msg void OnBnClickedButtonComeback();
|
|
afx_msg void OnTcnSelchangeTab(NMHDR *pNMHDR, LRESULT *pResult);
|
|
//}}AFX_MSG
|
|
DECLARE_MESSAGE_MAP()
|
|
};
|
|
|
|
//{{AFX_INSERT_LOCATION}}
|
|
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
|
|
|
#endif // !defined(AFX_AXISGRIDSHEET_H__1CD6AF60_C38E_436B_990C_FD40C10B0678__INCLUDED_)
|
|
|
|
|