You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

149 lines
7.7 KiB
C++

#pragma once
#include "ObjComponent.h"
#include "Module.h"
#include "LabVecRang.h"
#include "MarkAreaMgr.h"
//元件管理
class CObjComponentMgr :public CModule
{
friend class CDlgObjComponent;
friend class CDlgObjComponentArr;
public:
CObjComponentMgr(void);
~CObjComponentMgr(void);
virtual void Draw(CDC* pDC);//在pDC 绘制一些内容
virtual MODULE GetModuleType(){return _OBJ_COMPONENT_PROP;};
virtual void WriteWorkFileExt(vector<CLab> &LabVec);
virtual void ReadWorkFile(CLabVecRang &LabVecRang);
bool IsInArea(Dbxy pt,DbSize Size);
void SetDrawBase(bool b){m_bDrawBase = b;};
void AddBaseComponent();
void AddBaseComponent(Dbxy pt,DbSize size);
void AddComponent(CObjComponent Component);
void InsertList(CListCtrl &List);
void DelSel(int &idx);
void DelAll();
void OpArea(int idx,CObjComponent &Area,bool bRead);
void SetCurSelIdx(int idx){m_CurSelIdx = idx;};
void Array();
bool SelObjectInRect(DbRect rect);
void SelAllObj();
void NotSelAllObj();
void RevSelAllObj();
vector<Dbxy> &GetCatchPtVec(){return m_CatchPtVec;};
void SetDrawAllObj(bool b){m_bDrawAllObj = b;};//设置是否绘制原件对象
void DelAllBaseObj(){m_BaseComponentVec.clear();};
bool HasBase(){return !m_BaseComponentVec.empty();};//是否有基准对象
DbSize GetBaseSize(int idx);
bool IsBaseCircle(int idx);
void CollectWorkData(DbRect &rect,vector<vector<Dbxy>> &vec,bool bNeedSel);
void ResetObjCollectState(bool NeedSel);
void DrawArea(CDC* pDC,Dbxy Offset);
void SetAreaRadius(double r){m_AreaRadius = r;};
double GetAreaRadius(){return m_AreaRadius;};
COLORREF GetNoSelColor(){return m_NoSelColor;};
COLORREF GetSelColor(){return m_SelColor;};
COLORREF GetViewColor(){return m_ViewObjColor;};
COLORREF GetViewedObjColor(){return m_ViewedObjColor;};
bool IsDrawFillColor(){return m_bDrawFillColor;};
void SetDefaultAng(double ang){m_DefaultAng = ang;};
double GetDefaultAng(){return m_DefaultAng;};
Dbxy FindNearestPt(Dbxy pt);
bool IsAutoArray(){return m_bAutoArray;};
bool HasObj(){return !m_ComponentVec.empty();};
void CreatAreaByObj(CMarkAreaMgr &AreaMgr);
int GetObjCnt(){return m_ComponentVec.size();}
void GetSelObjIdx(vector<bool> &SelObjIdxVec);
void SetSelectedByIdx(int idx,bool b);
vector<CObjComponent>&GetComponentVec(){return m_ComponentVec;};
void CreatObjByLayerObj();
void AnalyseMarkPt(double R);
void SetAreaBasePt(Dbxy pt){m_AreaBasePt = pt;};
IntXY GetFristSelectedObjIdx();
void MoveFristSelObjToPt(Dbxy TargetPt);
void MoveObjToCameraByDir(DIRECTION dir,Dbxy TargetPt);
IntXY GetCurViewObjIdx(){return m_CurSelObjIdx;};
void MoveTrackS(Dbxy TargetPt,IntXY Gap,bool bDir);
void ResetMoveTrackSDir(){m_bMoveTrackSDir = true;};//重置方向
bool IsbShowRealObj(){return m_bShowRealObj;};
void SetCurSelObjIdx(IntXY Idx);
bool MoveObjToPtByIdx(IntXY IdxXY,Dbxy TargetPt);
int GetCurViewedObj();
bool SetMarkObj();
bool SwithObjToCcdMode();
DbRect SetMarkedStateRect(DbRect rect,bool bSel);
void ResetAllMarkedState();
void SetShapeLockState(bool b);
Dbxy GetAllObjCenterPt(){return m_AllObjCenterPt;};
void CalAllObjCenterPt();
void ResetAllMarkObj();
private:
bool IdxValid(int idx);
void ArrayExt();
void Arrayij(int i,int j,IntXY idx,Dbxy Offset,Dbxy RealOffset);
void AutoArray();
void SetBaseObjOffset(Dbxy Offset);
bool AutoArrayExt(Dbxy BasePt,DbSize Size,double OffsetX,double OffsetY,bool bIsCircle);
void SaveBaseObj(vector<CLab> &LabVec);
void ReadBaseObj(CLabVecRang &LabVecRang);
bool IsCircle();
void SetIsCircle(bool b);
void OnObjSelStateChange();
int ConvertIdx(IntXY Idx);
void SetCurViewObjIdx(IntXY Idx);
void DivideBySpacingDis(double dis,bool bDivideX);
CObjComponent CopyObj(CObjComponent &Obj,int sign,double dis,bool bDivideX);
int GetMarkObjCnt();
void SetSelObjMark(int CurMarkCnt);
int GetSelObjCnt();
Dbxy GetFristSelObjCenter();
private:
vector<CObjComponent> m_BaseComponentVec;//基准元件的容器
vector<CObjComponent> m_ComponentVec;//元件容器
bool m_bDrawAllObj;//是否绘制所有的原件对象
bool m_bDrawBase;//是否只绘制基准元件
int m_CurSelIdx;//当前选择的基准元件 索引值
vector<Dbxy> m_CatchPtVec;//保存切割道的交点,用于指定抓取
bool m_bObjToCcdMode;//true 的时候选择obj 会移动到CCD 观察
//需要保存的参数-----------------------------------------------
COLORREF m_NoSelColor;//没有选中的颜色
COLORREF m_SelColor;//选中的颜色
COLORREF m_ViewObjColor;//正在观察的obj 颜色
COLORREF m_ViewedObjColor;//观察过的obj 颜色
bool m_bDrawBindingObj;//是否绘制绑定的layer obj
bool m_bDrawFillColor;//是否绘制填充
bool m_bAutoArray;//是否自动排列
double m_AutoArrayGap;//自动排布间隔(mm)
double m_DefaultAng;//默认角度
//元件阵列信息---------------------------------------------------------------
int m_ArrayXcntZ;//X 正方向阵列数量
int m_ArrayXcntF;//X 负方向阵列数量
int m_ArrayYcntZ;//Y 正方向阵列数量
int m_ArrayYcntF;//Y 负方向阵列数量
double m_OffsetX;//X 方向间隔
double m_OffsetY;//Y 方向间隔
//限定元件的范围-------------------------------------------------------------
bool m_bUseArea;//是否使用限定范围
bool m_bRectArea;//true 为矩形范围,false 为圆形范围
Dbxy m_AreaBasePt;//范围的基准点
DbSize m_AreaSize;//矩形范围的尺寸
double m_AreaRadius;//圆形范围的直径
bool m_bNeedAllIn;//元件是否需要全部在范围内
Dbxy m_AllObjCenterPt;//所有原件中心坐标,不计算不加工的obj
//LPS - ISP3000------------------------------------------------------------------
IntXY m_CurSelObjIdx;//当前选择的obj 索引值
double m_RealOffsetX;//实际的X 方向间隔mm
double m_RealOffsetY;//实际的Y 方向间隔mm
bool m_bMoveTrackSDir;//S形轨迹移动的方向标志
bool m_bShowRealObj;//显示obj 的实际位置
};
extern CObjComponentMgr *gObjComponentMgr;