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.
187 lines
4.5 KiB
C++
187 lines
4.5 KiB
C++
#include "stdafx.h"
|
|
#include "SigmaView.h"
|
|
#include "SigmaProjectionParameter.h"
|
|
#include "ProjectionParameterAssistant.h"
|
|
#include "ActionProjectionItem.h"
|
|
|
|
extern "C" __declspec(dllexport)
|
|
int Projection_GetParameter(CSigmaView* pView, SigmaProjectionParameter * parameter)
|
|
{
|
|
if (pView == 0 || parameter == 0)
|
|
return -1;
|
|
|
|
if (pView->m_pDoc == 0)
|
|
return -1;
|
|
|
|
CString projStr = pView->m_pDoc->GetDraw()->GetProjection();
|
|
ProjectionParameterAssistant * assistant = ProjectionParameterAssistant::GetInstance();
|
|
|
|
assistant->SetParameter(parameter);
|
|
if (assistant->ParseParameterFromString(projStr) == 0)
|
|
return -1;
|
|
|
|
return 1;
|
|
}
|
|
|
|
extern "C" __declspec(dllexport)
|
|
int Projection_GetDefaultParameter(CSigmaView* pView, SigmaProjectionParameter * parameter)
|
|
{
|
|
if (pView == 0 || parameter == 0)
|
|
return -1;
|
|
|
|
if (pView->m_pDoc == 0)
|
|
return -1;
|
|
|
|
CString projStr = pView->m_pDoc->GetDraw()->GetProjection();
|
|
ProjectionParameterAssistant * assistant = ProjectionParameterAssistant::GetInstance();
|
|
|
|
assistant->SetParameter(parameter);
|
|
assistant->InitParameter();
|
|
|
|
return 1;
|
|
}
|
|
|
|
extern "C" __declspec(dllexport)
|
|
int Projection_SetParameter(CSigmaView* pView, SigmaProjectionParameter parameter)
|
|
{
|
|
if (pView == 0)
|
|
return -1;
|
|
|
|
if (pView->m_pDoc == 0)
|
|
return -1;
|
|
|
|
//TODO:检查要设置的参数和现有参数是否相同 相同的画 直接返回
|
|
ProjectionParameterAssistant * assistant = ProjectionParameterAssistant::GetInstance();
|
|
assistant->SetParameter(¶meter);
|
|
|
|
std::string projectStr;
|
|
int ret = assistant->GetProjectStr(projectStr);
|
|
if (ret == -1) {
|
|
return -1;
|
|
}
|
|
|
|
CString oldProjection = pView->m_pDoc->GetDraw()->GetProjection();
|
|
CString newProjection = projectStr.c_str();
|
|
|
|
pView->m_pDoc->GetDraw()->SetProjection(newProjection);
|
|
|
|
pView->m_pDoc->SetActionItem(new CActionProjectionItem(pView->m_pDoc, 0, oldProjection, newProjection));
|
|
|
|
return 1;
|
|
}
|
|
|
|
extern "C" __declspec(dllexport)
|
|
int Projection_Change(CSigmaView* pView, SigmaProjectionParameter * parameter)
|
|
{
|
|
if (pView == 0 || parameter == 0)
|
|
return -1;
|
|
|
|
if (pView->m_pDoc == 0)
|
|
return -1;
|
|
|
|
ProjectionParameterAssistant * assistant = ProjectionParameterAssistant::GetInstance();
|
|
assistant->SetParameter(parameter);
|
|
|
|
std::string projectStr;
|
|
int ret = assistant->GetProjectStr(projectStr);
|
|
if (ret == -1)
|
|
return -1;
|
|
|
|
CString oldProjection = pView->m_pDoc->GetDraw()->GetProjection();
|
|
CString newProjection = projectStr.c_str();
|
|
|
|
pView->m_pDoc->GetDraw()->ChangeToProjection(newProjection);
|
|
|
|
pView->m_pDoc->SetActionItem(new CActionProjectionItem(pView->m_pDoc, 0, oldProjection, newProjection));
|
|
|
|
return 1;
|
|
}
|
|
|
|
extern "C" __declspec(dllexport)
|
|
//约定other字节数组的长度为512
|
|
int Projection_GetOtherStr(CSigmaView* pView, SigmaProjectionParameter * parameter, BYTE* other)
|
|
{
|
|
if (pView == 0 || parameter == 0)
|
|
return -1;
|
|
|
|
if (pView->m_pDoc == 0)
|
|
return -1;
|
|
|
|
ProjectionParameterAssistant * assistant = ProjectionParameterAssistant::GetInstance();
|
|
assistant->SetParameter(parameter);
|
|
|
|
std::string otherStr;
|
|
if (assistant->GenerateOtherString(otherStr) == false)
|
|
{
|
|
other[0] = '\0';
|
|
return -1;
|
|
}
|
|
|
|
size_t count = otherStr.size();
|
|
if (count >= 512)
|
|
count = 511;
|
|
memcpy(other, otherStr.data(), count);
|
|
other[count] = '\0';
|
|
|
|
return 1;
|
|
}
|
|
|
|
extern "C" __declspec(dllexport)
|
|
//约定other字节数组的长度为512
|
|
int Projection_GetProjectString(CSigmaView* pView, SigmaProjectionParameter * parameter, BYTE* projByts)
|
|
{
|
|
if (pView == 0 || parameter == 0)
|
|
return -1;
|
|
|
|
if (pView->m_pDoc == 0)
|
|
return -1;
|
|
|
|
ProjectionParameterAssistant * assistant = ProjectionParameterAssistant::GetInstance();
|
|
assistant->SetParameter(parameter);
|
|
|
|
std::string projStr;
|
|
if (assistant->GetProjectStr(projStr) == false)
|
|
{
|
|
projByts[0] = '\0';
|
|
return -1;
|
|
}
|
|
|
|
size_t count = projStr.size();
|
|
if (count >= 512)
|
|
count = 511;
|
|
memcpy(projByts, projStr.data(), count);
|
|
projByts[count] = '\0';
|
|
|
|
return 1;
|
|
}
|
|
|
|
extern "C" __declspec(dllexport)
|
|
int Projection_FillOtherParameter(CSigmaView* pView, SigmaProjectionParameter * parameter, LPCTSTR otherStr)
|
|
{
|
|
if (pView == 0 || parameter == 0)
|
|
return -1;
|
|
|
|
if (pView->m_pDoc == 0)
|
|
return -1;
|
|
|
|
std::string str(otherStr);
|
|
ProjectionParameterAssistant * assistant = ProjectionParameterAssistant::GetInstance();
|
|
assistant->SetParameter(parameter);
|
|
if (assistant->FillOtherParameter(str))
|
|
return 1;
|
|
|
|
return -1;
|
|
}
|
|
|
|
extern "C" __declspec(dllexport)
|
|
int Projection_IsEmpty(CSigmaView* pView)
|
|
{
|
|
if (pView == NULL)
|
|
{
|
|
return 1; //投影参数为空
|
|
}
|
|
|
|
bool bEmpty = pView->m_pDoc->GetDraw()->GetProjection().IsEmpty();
|
|
|
|
return bEmpty ? 1 : 0;
|
|
} |