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/InterfaceStyleLibraryManage...

199 lines
4.7 KiB
C++

1 month ago
#include "stdafx.h"
#include "SigmaView.h"
#include "DrawOperator\StyleLibraryManager.h"
#include "Util.h"
#include "ActionListItem.h"
#include <ActionEmbellishItem.h>
/*
* <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>
*/
extern "C" __declspec(dllexport)
bool StyleLibraryInit(const LPCSTR strNewPath, bool bNotJudgeSamePath)
{
return AfxGetStyleLibMgr().InitLib(strNewPath, bNotJudgeSamePath);
}
/**
* <EFBFBD>г<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* \return <EFBFBD>ɶ<EFBFBD><EFBFBD><EFBFBD>(,)<EFBFBD>ָ<EFBFBD><EFBFBD>ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
*/
extern "C" __declspec(dllexport)
BSTR StyleLibraryListGroup()
{
return JoinStrings(AfxGetStyleLibMgr().ListGroup(), ",").AllocSysString();
}
/**
* <EFBFBD>г<EFBFBD><EFBFBD>÷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
*
* \return <EFBFBD>ɶ<EFBFBD><EFBFBD><EFBFBD>(,)<EFBFBD>ָ<EFBFBD><EFBFBD>ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
*/
extern "C" __declspec(dllexport)
BSTR StyleLibraryListStyle(LPCSTR group)
{
std::shared_ptr<StyleManager::CStyleLibraryItem> pItem = AfxGetStyleLibMgr().Find(group);
if (pItem != nullptr)
{
return JoinStrings(pItem->ListStyle(), ",").AllocSysString();
}
return CString().AllocSysString();
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µķ<EFBFBD><EFBFBD><EFBFBD>
*
* \param strNewFile <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
extern "C" __declspec(dllexport)
void StyleLibraryAddNewGroup(const LPCSTR strNewFile)
{
AfxGetStyleLibMgr().AddNewGroup(strNewFile);
}
/**
* <EFBFBD>Ƴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><EFBFBD><EFBFBD>
*/
extern "C" __declspec(dllexport)
void StyleLibraryRemoveAll(void)
{
AfxGetStyleLibMgr().RemoveAll();
}
/**
* <EFBFBD>Ƴ<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* \param strNewFile
*/
extern "C" __declspec(dllexport)
void StyleLibraryRemoveGroup(const LPCSTR strNewFile)
{
AfxGetStyleLibMgr().RemoveGroup(strNewFile);
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* \param oldFile <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* \param newFile <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* \return
*/
extern "C" __declspec(dllexport)
bool StyleLibraryRenameGroup(const LPCSTR oldFile, const LPCSTR newFile)
{
return AfxGetStyleLibMgr().RenameGroup(oldFile, newFile);
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
*
* \return
*/
extern "C" __declspec(dllexport)
bool StyleLibrarySaveAll()
{
return AfxGetStyleLibMgr().SaveAll();
}
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>Ŀ<EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD>
*
* \param pView pView
* \param group <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* \param style <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* \param targetLayer Ŀ<EFBFBD><EFBFBD>ͼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* \return
*/
extern "C" __declspec(dllexport)
bool StyleLibraryApplyStyleTo(CSigmaView * pView, LPCSTR group, LPCSTR style, LPCSTR targetLayer)
{
assert(pView != nullptr);
CXy *pXy = pView->m_pDoc->m_pXy;
CLayer* pLayer = pXy->FindLayer(targetLayer);
if (pLayer == nullptr)
{
return false;
}
std::unique_ptr<CActionEmbellishItem> pActionItem = std::make_unique<CActionEmbellishItem>(pView->m_pDoc, ActionTypeLayerEmbellishCurveAdd, pLayer);
pActionItem->SetOldHowToView(pLayer); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool result = AfxGetStyleLibMgr().ApplyStyleTo(group, style, pXy, targetLayer);
if (result)
{
pActionItem->SetNewHowToView(pLayer);
pView->m_pDoc->SetActionItem(pActionItem.release());
}
return result;
}
extern "C" __declspec(dllexport)
bool StyleLibraryApplyStyleToElement(CSigmaView * pView, LPCSTR group, LPCSTR style, POSITION posElement)
{
int styleType =AfxGetStyleLibMgr().GetStyleType(group, style);
//Ϊ<><CEAA><EFBFBD><EFBFBD><EFBFBD>ε<EFBFBD>Redo/Undo
CXy *pXy = pView->m_pDoc->m_pXy;
COne* pOne = pXy->GetAt(posElement);
bool bSuccess = false;
//CActionEmbellishItem* pActionItem = new CActionEmbellishItem(pView->m_pDoc, 0, pOne);
std::unique_ptr<CActionEmbellishItem> pActionItem = std::make_unique<CActionEmbellishItem>(pView->m_pDoc, 0, pOne);
pActionItem->SetOldHowToView(pOne); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (pOne->GetType() == DOUBLEFOX_POINT || pOne->GetType() == DOUBLEFOX_XYZ || pOne->GetType() == DOUBLEFOX_XPOINT)
{
if (styleType == 2 || styleType == 3) {
if (pOne->HowToViewPoint)
delete pOne->HowToViewPoint;
pOne->HowToViewPoint = new CHowToViewPoint();
CHowToViewPoint* pHtp = (AfxGetStyleLibMgr().GetHowToViewPoint(group, style));
if (pHtp != nullptr)
{
*pOne->HowToViewPoint = *pHtp;
pActionItem->SetNewHowToView(pOne); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bSuccess = true;
}
}
}
else if (pOne->GetType() == DOUBLEFOX_CURVE)
{
if (styleType == 1 || styleType == 3)
{
if (pOne->HowToViewCurve)
delete pOne->HowToViewCurve;
pOne->HowToViewCurve = new CHowToViewCurve();
CHowToViewCurve* pHtc = (AfxGetStyleLibMgr().GetHowToViewCurve(group, style));
if (pHtc != nullptr)
{
*pOne->HowToViewCurve = *pHtc;
pActionItem->SetNewHowToView(pOne); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bSuccess = true;
}
}
}
if (bSuccess == false) {
//delete pActionItem;
return false;
}
pView->m_pDoc->SetActionItem(pActionItem.release());
return bSuccess;
}
/**
* <EFBFBD><EFBFBD>Ⱦ<EFBFBD><EFBFBD>ʽ
*
* \param group <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* \param style <EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* \param hdc HDC
* \param width <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* \param height <EFBFBD>߶<EFBFBD>
* \return <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܣ<EFBFBD>ʧ<EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
extern "C" __declspec(dllexport)
bool StyleLibraryRenderStyle(LPCSTR group, LPCTSTR style, HDC hdc, int width, int height)
{
return AfxGetStyleLibMgr().RenderStyle(group, style, hdc, width, height);
}