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.
80 lines
2.0 KiB
C++
80 lines
2.0 KiB
C++
#include "stdafx.h"
|
|
#include "SigmaView.h"
|
|
#include "SectionDoc.h"
|
|
#include "ActionSortItem.h"
|
|
#include "ItemSelect.h"
|
|
|
|
// 获取需要强制保持在顶部的对象列表 (Mask + AboveMask)
|
|
void GetMaskAndTopObjects(CSigmaDoc* pDoc, CPositionList& listOut)
|
|
{
|
|
if (!pDoc || !pDoc->m_pXy) return;
|
|
|
|
CPositionList listMask;
|
|
CPositionList listTop;
|
|
|
|
auto pDraw = pDoc->GetDraw(); // 获取绘图容器
|
|
CPtrList* values = pDraw->GetValueList();
|
|
POSITION pos = values->GetHeadPosition();
|
|
while (pos)
|
|
{
|
|
POSITION curr = pos;
|
|
COne* pOne = (COne*)(values->GetNext(pos));
|
|
if (pOne && pOne->m_pLayer)
|
|
{
|
|
auto role = pOne->m_pLayer->GetMaskRole();
|
|
if (role == CLayer::ELayerMaskRole::Mask)
|
|
{
|
|
listMask.AddTail(curr);
|
|
}
|
|
else if (role == CLayer::ELayerMaskRole::AboveMask)
|
|
{
|
|
listTop.AddTail(curr);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!listMask.IsEmpty()) listOut.AddTail(&listMask);
|
|
if (!listTop.IsEmpty()) listOut.AddTail(&listTop);
|
|
}
|
|
|
|
//order:0=最上显示 1=最下显示 2=上移一层 3=下移一层
|
|
extern "C" __declspec(dllexport)
|
|
int DisplayOrder_Set(CSigmaView * pView, int order)
|
|
{
|
|
if (order < 0 || order > 3) return -1;
|
|
if (pView == NULL || pView->m_pDoc == NULL) return -1;
|
|
|
|
CPositionList seletionSet;
|
|
pView->m_pDoc->GetSelectionSet(seletionSet);
|
|
|
|
CString strLayer = pView->m_pDoc->GetSelectedElementLayer(seletionSet);
|
|
if (strLayer == "Layer:\\遮罩图层")
|
|
return -1;
|
|
|
|
// 执行用户的操作 (让用户随便移)
|
|
CActionSortItem* pUserAction = new CActionSortItem(pView->m_pDoc, ID_OBJECT_MOVETOFRONT, seletionSet, order);
|
|
if (pUserAction)
|
|
{
|
|
pView->m_pDoc->SetActionItem(pUserAction);
|
|
}
|
|
|
|
// 进行“分区管制”修正
|
|
CLayer* pMaskLayer = pView->m_pDoc->m_pXy->FindLayer("遮罩图层");
|
|
if (pMaskLayer == nullptr)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
CPositionList listFix;
|
|
GetMaskAndTopObjects(pView->m_pDoc, listFix);
|
|
if (!listFix.IsEmpty())
|
|
{
|
|
CActionSortItem* pFixAction = new CActionSortItem(pView->m_pDoc, ID_OBJECT_MOVETOFRONT, listFix, 0);
|
|
if (pFixAction)
|
|
{
|
|
pView->m_pDoc->SetActionItem(pFixAction);
|
|
}
|
|
}
|
|
|
|
return 1;
|
|
} |