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.
126 lines
2.9 KiB
C++
126 lines
2.9 KiB
C++
#include "stdafx.h"
|
|
#include "SigmaView.h"
|
|
#include "SectionDoc.h"
|
|
#include "ItemSelect.h"
|
|
#include "ActionMoveItem.h"
|
|
#include "ActionMirrorItem.h"
|
|
|
|
static int Mirror(CSigmaView * pView, bool bHorizontal);
|
|
static void OffsetSelected(CPositionList & selectionSet, CSigmaDoc * pDoc, double dx, double dy);
|
|
|
|
extern "C" __declspec(dllexport)
|
|
int HorizontalMirror(CSigmaView * pView)
|
|
{
|
|
return Mirror(pView, true);
|
|
}
|
|
|
|
extern "C" __declspec(dllexport)
|
|
int VerticalMirror(CSigmaView * pView)
|
|
{
|
|
return Mirror(pView, false);
|
|
}
|
|
|
|
static int Mirror(CSigmaView * pView, bool bHorizontal)
|
|
{
|
|
if (pView == NULL)
|
|
return -1;
|
|
|
|
CSigmaDoc * pDoc = pView->m_pDoc;
|
|
if (pDoc == NULL)
|
|
return -1;
|
|
|
|
if (pDoc->IsEmptySelectionSet())
|
|
return -1;
|
|
|
|
//X轴镜像
|
|
float mt[6];
|
|
memset(mt, 0, sizeof(float) * 6);
|
|
|
|
if (bHorizontal)
|
|
{
|
|
mt[0] = -1.0f;
|
|
mt[3] = 1.0f;
|
|
}
|
|
else
|
|
{
|
|
mt[0] = 1.0f;
|
|
mt[3] = -1.0f;
|
|
}
|
|
|
|
CRect8 rbt = pDoc->GetRectOfSelectedSet();
|
|
COne* pOne;
|
|
POSITION pt, pk;
|
|
CPositionList plist;
|
|
pDoc->GetSelectionSet(plist);
|
|
pt = plist.GetHeadPosition();
|
|
while (pt)
|
|
{
|
|
pk = plist.GetNext(pt);
|
|
pOne = pDoc->GetDraw()->GetAt(pk);
|
|
pOne->Transform(&pDoc->GetDC(), mt);
|
|
}
|
|
CRect8 ret = pDoc->GetRectOfSelectedSet();
|
|
CPoint2D point = rbt.CenterPoint();
|
|
point -= ret.CenterPoint();
|
|
OffsetSelected(plist, pDoc, point.x0, point.y0);
|
|
|
|
//for redo/undo
|
|
//mt[4] = (float)point.x0;
|
|
//mt[5] = -(float)point.y0;
|
|
CActionMirrorItem * pAction = new CActionMirrorItem(pDoc, ID_ORDER_HORIZONTAL_MIRROR, plist, mt, point.x0, point.y0);
|
|
//pAction->SetDC(&(pDoc->m_zoom));
|
|
pDoc->SetActionItem(pAction);
|
|
pDoc->Modified();
|
|
|
|
return 1;
|
|
}
|
|
|
|
static void OffsetSelected(CPositionList & selectionSet, CSigmaDoc * pDoc, double dx, double dy)
|
|
{
|
|
if (selectionSet.IsEmpty())
|
|
return;
|
|
|
|
BOOL bIsPointText = FALSE;
|
|
/*
|
|
if (selectionSet.GetCount() == 1)
|
|
{
|
|
//为了能直接移动点的文本项
|
|
POSITION pos = selectionSet.GetHead();
|
|
COne* pOne = (COne*)pDoc->GetDraw()->GetAt(pos);
|
|
if (pOne->GetType() == DOUBLEFOX_POINT && m_bPointTextSelected == TRUE)
|
|
{
|
|
bIsPointText = TRUE;
|
|
//GetDoc()->SetActionItem(new CActionBackupItem(GetDoc(),IDS_STRING_ACTION_MOVE,m_selection));
|
|
|
|
if (pOne->HowToViewPoint == NULL)
|
|
{
|
|
pOne->HowToViewPoint = new CHowToViewPoint;
|
|
if (pOne->GetLayer()->HowToViewPoint) //层修饰
|
|
*(pOne->HowToViewPoint) = *(pOne->GetLayer()->HowToViewPoint);
|
|
}
|
|
pOne->HowToViewPoint->m_delt.cx += dx;
|
|
pOne->HowToViewPoint->m_delt.cy += dy;
|
|
}
|
|
}
|
|
*/
|
|
|
|
//if (!bIsPointText)
|
|
{
|
|
COne* pOne;
|
|
POSITION pos, pt;
|
|
pos = selectionSet.GetHeadPosition();
|
|
while (pos != NULL)
|
|
{
|
|
pt = selectionSet.GetNext(pos);
|
|
pOne = (COne*)pDoc->GetDraw()->GetAt(pt);
|
|
pOne->Offset(dx, dy);
|
|
}
|
|
|
|
//for redo/undo
|
|
CPoint2D point(dx, dy);
|
|
//CActionOffsetItem *pAction=new CActionOffsetItem(GetDoc(), IDS_STRING_ACTION_MOVE, m_selection, point);
|
|
//GetDoc()->SetActionItem(pAction);
|
|
}
|
|
|
|
//ReloadTrackerPath();
|
|
} |