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/InterfaceSection.cpp

150 lines
3.8 KiB
C++

#include "stdafx.h"
#include "SigmaView.h"
#include "ActionDeleteItem.h"
#include "Util.h"
extern "C" __declspec(dllexport)
int SectionSetProperty(CSigmaView* pView, BYTE* buffElement, int buffLen, POSITION elementPtr)
{
BOOL bEdited = FALSE;
POSITION pos = (POSITION)elementPtr;
COne* pOne = (COne*)(pView->m_pDoc->GetDraw()->GetAt(pos));
if (pOne->GetType() == DOUBLEFOX_SECTION) {
((CSection*)(pOne->value))->ReadProperty(buffElement, -1, buffLen);
bEdited = true;
}
return bEdited;
}
extern "C" __declspec(dllexport)
int SectionSetTraceData(CSigmaView* pView, float* buffElement, int buffLen, POSITION elementPtr)
{
BOOL bEdited = FALSE;
POSITION pos = (POSITION)elementPtr;
COne* pOne = (COne*)(pView->m_pDoc->GetDraw()->GetAt(pos));
if (pOne->GetType() == DOUBLEFOX_SECTION) {
((CSection*)(pOne->value))->SetTraceData(buffElement, buffLen);
bEdited = true;
}
return bEdited;
}
extern "C" __declspec(dllexport)
POSITION SectionAddNew(CSigmaView * pView, BYTE* buffElement, int buffLen, float* buffValues, int valuesLen, LPCTSTR layerName)
{
// ´´½¨Í¼Ôª
CXy * pXy = pView->m_pDoc->m_pXy;
CLayer * pLayer = pXy->FindAddLayer(layerName);
CSection* pSection = new CSection;
COne *pOne = pXy->CreateOne(pSection, DOUBLEFOX_SECTION);
pOne->SetLayer(pLayer);
pSection->solidMode = 1;
pOne->SetViewState(LAYER_ViewEdit);
POSITION pos = pView->m_pDoc->m_pXy->AddHeadOne(pOne);
// ÉèÖÃÊôÐÔ
SectionSetProperty(pView, buffElement, buffLen, pos);
SectionSetTraceData(pView, buffValues, valuesLen, pos);
return pos;
}
extern "C" __declspec(dllexport)
bool SectionDeleteAll(CSigmaView* pView, LPCTSTR layerName)
{
CXy * pXy = pView->m_pDoc->m_pXy;
pXy->RemoveLayer(layerName);
return true;
}
extern "C" __declspec(dllexport)
bool SectionDelete(CSigmaView* pView, POSITION pos)
{
CXy * pXy = pView->m_pDoc->m_pXy;
if (pXy == NULL) return false;
pXy->RemoveAt(pos);
return true;
}
extern "C" __declspec(dllexport)
int SigmaDeleteElementByPosition(CSigmaView * pView, POSITION positions[], int count)
{
CXy * pXy = pView->m_pDoc->m_pXy;
if (pXy == NULL)
{
return 0;
}
CList<POSITION, POSITION> items;
std::vector<POSITION> validPositions = GetValidPositions(pView->m_pDoc->m_pXy, positions, count);
for (POSITION pos : validPositions)
{
items.AddTail(pos);
}
CActionDeleteItem* deleteItem = new CActionDeleteItem(pView->m_pDoc, IDS_STRING_ACTION_DELETE, items);
pView->m_pDoc->SetActionItem(deleteItem);
return 1;
}
extern "C" __declspec(dllexport)
int SigmaDeleteElement(CSigmaView* pView, LPCTSTR layerName, LPCTSTR eleName)
{
CXy * pXy = pView->m_pDoc->m_pXy;
if (pXy == NULL) return 0;
CPtrList* pl = pXy->GetValueList();
POSITION posCurrent = pl->GetHeadPosition();
COne* pOne;
int nCount = 0;
//pl->GetNext(posCurrent);
while (posCurrent)
{
pOne = pXy->GetAt(posCurrent);
if (pOne->GetLayer()!=nullptr && pOne->GetLayer()->GetName() == layerName
&& pOne->GetName() == eleName)
{
POSITION posTmp = posCurrent;
pl->GetNext(posCurrent);
pXy->RemoveAt(posTmp);
nCount++;
continue;
}
pl->GetNext(posCurrent);
}
return nCount;
}
extern "C" __declspec(dllexport)
int SigmaDeletePoint(CSigmaView* pView, LPCTSTR layerName, LPCTSTR eleName)
{
CXy * pXy = pView->m_pDoc->m_pXy;
if (pXy == NULL) return 0;
CString strlayerName(layerName);
CPtrList* pl = pXy->GetValueList();
POSITION posCurrent = pl->GetHeadPosition();
COne* pOne;
int nCount = 0;
while (posCurrent)
{
pOne = pXy->GetAt(posCurrent);
if (pOne->GetLayer() != nullptr && pOne->GetType() == DOUBLEFOX_POINT
&& (strlayerName.IsEmpty() || pOne->GetLayer()->GetName() == strlayerName)
&& pOne->GetName() == eleName)
{
POSITION posTmp = posCurrent;
pl->GetNext(posCurrent);
pXy->RemoveAt(posTmp);
nCount++;
continue;
}
pl->GetNext(posCurrent);
}
return nCount;
}