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.
kev/Drawer/Module/GeoSigmaDraw/ActionChangeLayerItem.cpp

155 lines
3.2 KiB
C++

#include "StdAfx.h"
#include ".\actionchangelayeritem.h"
#include "SigmaDoc.h"
#include "SigmaView.h"
#include "DrawModel/SplitStr.h"
#include "Visitor.h"
NAction::CActionChangeLayerItem::CActionChangeLayerItem()
: CActionItem(nullptr, 0)
{
}
CActionChangeLayerItem::CActionChangeLayerItem(CSigmaDoc * ppDoc, UINT actionType,
CPositionList& list, CString strOldLayer, CString strNewLayer)
: CActionItem(ppDoc, actionType)
, m_strOldLayer(strOldLayer)
, m_strNewLayer(strNewLayer)
{
POSITION pos=list.GetHeadPosition();
POSITION pt;
while(pos)
{
pt=list.GetNext(pos);
m_eleList.AddTail(pt);
}
}
CActionChangeLayerItem::~CActionChangeLayerItem(void)
{
}
void CActionChangeLayerItem::Undo()
{
CActionItem::Undo();
CSplitStr spliter;
spliter.SetSplitFlag(";");
spliter.SetSequenceAsOne(FALSE);
spliter.SetData(m_strOldLayer);
CStringArray layers;
spliter.GetSplitStrArray(layers);
int nCount = layers.GetCount();
if (nCount == 1)
{
POSITION pt;
POSITION pos = m_eleList.GetHeadPosition();
while (pos)
{
pt = m_eleList.GetNext(pos);
GetDoc()->GetDraw()->SetElementLayer(pt, m_strOldLayer);
}
}
else {
int nIndex = 0;
POSITION pt;
POSITION pos = m_eleList.GetHeadPosition();
while (pos)
{
pt = m_eleList.GetNext(pos);
CString strLayerName("");
if (nIndex > nCount - 1) {
strLayerName = layers[nCount - 1];
}
else {
strLayerName = layers[nIndex];
}
GetDoc()->GetDraw()->SetElementLayer(pt, strLayerName);
nIndex++;
}
}
//GetDoc()->InvalidateSelection(m_eleList);
}
void CActionChangeLayerItem::Redo()
{
CActionItem::Redo();
POSITION pt;
POSITION pos=m_eleList.GetHeadPosition();
while(pos)
{
pt=m_eleList.GetNext(pos);
GetDoc()->GetDraw()->SetElementLayer(pt, m_strNewLayer);
}
GetDoc()->InvalidateSelection(m_eleList);
}
void NAction::CActionChangeLayerItem::accept(CActionVisitor& visitor)
{
visitor.visit(*this);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
NAction::CActionCurveReversalItem::CActionCurveReversalItem()
: CActionItem(nullptr, 0)
{
}
CActionCurveReversalItem::CActionCurveReversalItem(CSigmaDoc * ppDoc, UINT actionType, CPositionList& list)
: CActionItem(ppDoc, actionType)
{
POSITION pos=list.GetHeadPosition();
POSITION pt;
while(pos)
{
pt=list.GetNext(pos);
m_eleList.AddTail(pt);
}
}
CActionCurveReversalItem::~CActionCurveReversalItem(void)
{
}
void CActionCurveReversalItem::Undo()
{
CActionItem::Undo();
Reversal();
GetDoc()->InvalidateSelection(m_eleList);
}
void CActionCurveReversalItem::Redo()
{
CActionItem::Redo();
Reversal();
GetDoc()->InvalidateSelection(m_eleList);
}
void NAction::CActionCurveReversalItem::accept(CActionVisitor& visitor)
{
visitor.visit(*this);
}
void NAction::CActionCurveReversalItem::Reversal(void)
{
COne* pOne;
CCurveEx* pCurve;
POSITION pt;
POSITION pos=m_eleList.GetHeadPosition();
while(pos)
{
pt=m_eleList.GetNext(pos);
pOne=GetDoc()->GetDraw()->GetAt(pt);
if(pOne->GetType()!=DOUBLEFOX_CURVE) continue;
pCurve=(CCurveEx*)pOne->GetValue();
pCurve->Reversal();
if(pCurve->bAutoLocation)
pCurve->GetLocation();
}
}