|
|
#include "stdafx.h"
|
|
|
#include "SigmaView.h"
|
|
|
#include "SectionDoc.h"
|
|
|
#include "ItemProportion.h"
|
|
|
#include "ActionListItem.h"
|
|
|
|
|
|
static CItemProportion * getItemProportion(CSigmaView * pView)
|
|
|
{
|
|
|
CItem * pItem = pView->GetItem();
|
|
|
if (pItem == NULL)
|
|
|
return NULL;
|
|
|
|
|
|
CItemProportion * proportionItem = dynamic_cast<CItemProportion *>(pItem);
|
|
|
|
|
|
return proportionItem;
|
|
|
}
|
|
|
|
|
|
extern "C" __declspec(dllexport)
|
|
|
int CreateProportion(CSigmaView * pView)
|
|
|
{
|
|
|
CItemProportion * pItem = getItemProportion(pView);
|
|
|
if (pItem == NULL)
|
|
|
return -1;
|
|
|
|
|
|
pItem->InsertProportion();
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
extern "C" __declspec(dllexport)
|
|
|
int Proportion_ChangeScale(CSigmaView * pView, double length)
|
|
|
{
|
|
|
CItemProportion * pItem = getItemProportion(pView);
|
|
|
if (pItem == NULL)
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
return pItem->ChangeScale(length);
|
|
|
}
|
|
|
|
|
|
extern "C" __declspec(dllexport)
|
|
|
int Proportion_ChangeScaleHeight(CSigmaView * pView, double height)
|
|
|
{
|
|
|
CItemProportion * pItem = getItemProportion(pView);
|
|
|
if (pItem == NULL)
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
return pItem->ChangeScaleHeight(height);
|
|
|
}
|
|
|
|
|
|
extern "C" __declspec(dllexport)
|
|
|
int Proportion_ChangeNumber(CSigmaView * pView, int number)
|
|
|
{
|
|
|
CItemProportion * pItem = getItemProportion(pView);
|
|
|
if (pItem == NULL)
|
|
|
return -1;
|
|
|
|
|
|
return pItem->ChangeNumber(number);
|
|
|
}
|
|
|
|
|
|
extern "C" __declspec(dllexport)
|
|
|
int Proportion_ChangeShowMode(CSigmaView * pView, int mode)
|
|
|
{
|
|
|
CItemProportion * pItem = getItemProportion(pView);
|
|
|
if (pItem == NULL)
|
|
|
return -1;
|
|
|
|
|
|
return pItem->ChangeShowMode(mode);
|
|
|
}
|
|
|
|
|
|
extern "C" __declspec(dllexport)
|
|
|
int Proportion_ChangeUnit(CSigmaView * pView, int unit)
|
|
|
{
|
|
|
CItemProportion * pItem = getItemProportion(pView);
|
|
|
if (pItem == NULL)
|
|
|
return -1;
|
|
|
|
|
|
return pItem->ChangeUnit(unit);
|
|
|
}
|
|
|
|
|
|
extern "C" __declspec(dllexport)
|
|
|
int Proportion_ChangeColor(CSigmaView * pView, int r, int g, int b)
|
|
|
{
|
|
|
CItemProportion * pItem = getItemProportion(pView);
|
|
|
if (pItem == NULL)
|
|
|
return -1;
|
|
|
|
|
|
return pItem->ChangeColor(r, g, b);
|
|
|
}
|
|
|
|
|
|
extern "C" __declspec(dllexport)
|
|
|
int Proportion_ChangeTextScale(CSigmaView * pView, double scale)
|
|
|
{
|
|
|
CItemProportion * pItem = getItemProportion(pView);
|
|
|
if (pItem == NULL)
|
|
|
return -1;
|
|
|
|
|
|
return pItem->ChangeTextScale(scale);
|
|
|
}
|
|
|
|
|
|
extern "C" __declspec(dllexport)
|
|
|
int Proportion_ChangeAlign(CSigmaView * pView, int align)
|
|
|
{
|
|
|
CItemProportion * pItem = getItemProportion(pView);
|
|
|
if (pItem == NULL)
|
|
|
return -1;
|
|
|
|
|
|
return pItem->ChangeAlign(align);
|
|
|
}
|
|
|
|
|
|
extern "C" __declspec(dllexport)
|
|
|
int Proportion_ChangeTextHeight(CSigmaView * pView, int height)
|
|
|
{
|
|
|
CItemProportion * pItem = getItemProportion(pView);
|
|
|
if (pItem == NULL)
|
|
|
return -1;
|
|
|
|
|
|
return pItem->ChangeTextHeight(height);
|
|
|
}
|
|
|
|
|
|
extern "C" __declspec(dllexport)
|
|
|
int Proportion_ChangeTextWidth(CSigmaView * pView, int width)
|
|
|
{
|
|
|
CItemProportion * pItem = getItemProportion(pView);
|
|
|
if (pItem == NULL)
|
|
|
return -1;
|
|
|
|
|
|
return pItem->ChangeTextWidth(width);
|
|
|
}
|
|
|
|
|
|
extern "C" __declspec(dllexport)
|
|
|
int Proportion_ChangeTextHeightAlone(CSigmaView * pView, int alone)
|
|
|
{
|
|
|
CItemProportion * pItem = getItemProportion(pView);
|
|
|
if (pItem == NULL)
|
|
|
return -1;
|
|
|
|
|
|
return pItem->ChangeTextHeightAlone(alone);
|
|
|
}
|
|
|
|
|
|
extern "C" __declspec(dllexport)
|
|
|
int Proportion_ChangeCoordinate(CSigmaView * pView, double x, double y)
|
|
|
{
|
|
|
CItemProportion * pItem = getItemProportion(pView);
|
|
|
if (pItem == NULL)
|
|
|
return -1;
|
|
|
|
|
|
return pItem->ChangeCoordinate(x, y);
|
|
|
}
|
|
|
|
|
|
extern "C" __declspec(dllexport)
|
|
|
int Proportion_Create(CSigmaView * pView)
|
|
|
{
|
|
|
CItemProportion * pItem = getItemProportion(pView);
|
|
|
if (pItem == NULL)
|
|
|
return -1;
|
|
|
|
|
|
return pItem->Add();
|
|
|
}
|
|
|
|
|
|
extern "C" __declspec(dllexport)
|
|
|
int Proportion_GetScale(CSigmaView * pView)
|
|
|
{
|
|
|
CItemProportion * pItem = getItemProportion(pView);
|
|
|
if (pItem == NULL)
|
|
|
return -1;
|
|
|
|
|
|
return pItem->GetScale();
|
|
|
}
|
|
|
extern "C" __declspec(dllexport)
|
|
|
void Proportion_SetParameter(CSigmaView * pView, struct ProportionData * data) {
|
|
|
CItemProportion * pItem = getItemProportion(pView);
|
|
|
if (pItem == nullptr) {
|
|
|
return;
|
|
|
}
|
|
|
pItem->SetParameter(data);
|
|
|
}
|
|
|
extern "C" __declspec(dllexport)
|
|
|
int Proportion_GetData(CSigmaView * pView, struct ProportionData * data)
|
|
|
{
|
|
|
CItemProportion * pItem = getItemProportion(pView);
|
|
|
if (pItem == NULL)
|
|
|
{
|
|
|
//data->ScaleFactor = pView->m_pDoc->GetDraw()->m_dScaleFactor;
|
|
|
CUnit cu;
|
|
|
double h = cu.Millimetres(pView->m_pDoc->GetDraw()->m_unit.cx); //<2F><><EFBFBD><EFBFBD>1<EFBFBD><31>ʵ<EFBFBD>ʵ<EFBFBD>λ<EFBFBD>ĺ<EFBFBD><C4BA>׳<EFBFBD><D7B3><EFBFBD>
|
|
|
//1<><31><EFBFBD>״<EFBFBD><D7B4><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ʳ<EFBFBD><CAB3><EFBFBD>
|
|
|
double m_dScaleLength = pView->m_pDoc->GetDraw()->m_dScaleFactor / h;
|
|
|
//ת<><D7AA>Ϊ1<CEAA><31><EFBFBD>״<EFBFBD><D7B4><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ʳ<EFBFBD><CAB3><EFBFBD>
|
|
|
m_dScaleLength *= 10;
|
|
|
m_dScaleLength = 2000;
|
|
|
data->ScaleLength = m_dScaleLength;
|
|
|
data->ColorR = 0;
|
|
|
data->ColorG = 0;
|
|
|
data->ColorB = 0;
|
|
|
data->Unit = 2;
|
|
|
|
|
|
data->TextSpace = 1;
|
|
|
data->TextAlign = 1;
|
|
|
data->TextScale = 1;
|
|
|
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
pItem->GetData(data);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* \brief <20><>ͼ<EFBFBD><CDBC><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߶<EFBFBD><DFB6><EFBFBD><EFBFBD><EFBFBD>
|
|
|
* <20>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ԭ<EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>á<EFBFBD><C3A1>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>㡢<EFBFBD><E3A1A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD>ע<EFBFBD>᳷<EFBFBD><E1B3B7><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>Undo<64><6F><EFBFBD><EFBFBD>
|
|
|
* <20><><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD>ˮƽ<CBAE><C6BD><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD> X <20><>Χ<EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> yMax <20><> offset ȷ<><C8B7><EFBFBD><EFBFBD>ֱλ<D6B1>á<EFBFBD>
|
|
|
* \param pView ָ<><D6B8><EFBFBD><EFBFBD>ǰ Sigma <20><>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>룬<EFBFBD><EBA3AC><EFBFBD><EFBFBD>Ϊ nullptr<74><72>
|
|
|
* \param layerName Ŀ<><C4BF>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD><C6A1><EFBFBD>ͼ<EFBFBD>㲻<EFBFBD><E3B2BB><EFBFBD>ڣ<EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>㡣
|
|
|
* \param xMin <20><><EFBFBD>ֲο<D6B2><CEBF><EFBFBD><EFBFBD>ε<EFBFBD><CEB5><EFBFBD><EFBFBD><EFBFBD> X <20><><EFBFBD>ꡣ
|
|
|
* \param yMin <20><><EFBFBD>ֲο<D6B2><CEBF><EFBFBD><EFBFBD>εĵײ<C4B5> Y <20><><EFBFBD>꣨<EFBFBD><EAA3A8><EFBFBD>ڼ<EFBFBD><DABC>βο<CEB2><CEBF><EFBFBD><EFBFBD><EFBFBD>
|
|
|
* \param xMax <20><><EFBFBD>ֲο<D6B2><CEBF><EFBFBD><EFBFBD>ε<EFBFBD><CEB5>Ҳ<EFBFBD> X <20><><EFBFBD>ꡣ
|
|
|
* \param yMax <20><><EFBFBD>ֲο<D6B2><CEBF><EFBFBD><EFBFBD>εĶ<CEB5><C4B6><EFBFBD> Y <20><><EFBFBD>꣨<EFBFBD><EAA3A8>Ϊƫ<CEAA>ƻ<EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD>
|
|
|
* \param scaleValue <20><><EFBFBD><EFBFBD><EFBFBD>߷ֶδ<D6B6><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>ʵ<EFBFBD>ʳ<EFBFBD><CAB3>ȣ<EFBFBD><C8A3>ڲ<EFBFBD><DAB2><EFBFBD> /100.0 <20><><EFBFBD>㵥λ<E3B5A5><CEBB><EFBFBD>ȣ<EFBFBD><C8A3><EFBFBD>
|
|
|
* \param count <20><><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><DFB5>ֶܷ<DCB7><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> >= 1<><31><EFBFBD><EFBFBD>
|
|
|
* \param offset <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> yMax <20><><EFBFBD><EFBFBD><EFBFBD>ϵĴ<CFB5>ֱƫ<D6B1>ƾ<EFBFBD><C6BE>롣
|
|
|
* \return true <20><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>С<EFBFBD>
|
|
|
* \return false <20><><EFBFBD><EFBFBD><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD> pView Ϊ<>գ<EFBFBD><D5A3><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܡ<EFBFBD>
|
|
|
*/
|
|
|
extern "C" __declspec(dllexport)
|
|
|
bool CreateProportionFull(
|
|
|
CSigmaView* pView,
|
|
|
LPCSTR layerName,
|
|
|
double xMin,
|
|
|
double yMin,
|
|
|
double xMax,
|
|
|
double yMax,
|
|
|
int scaleValue,
|
|
|
int count,
|
|
|
int offset)
|
|
|
{
|
|
|
if (pView == nullptr || pView->m_pDoc == nullptr || pView->m_pDoc->m_pXy == nullptr)
|
|
|
{
|
|
|
TRACE("%s: <20>Ƿ<EFBFBD> view <20><><EFBFBD><EFBFBD> document ָ<><D6B8>\n", __FUNCTION__);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
auto pAction = std::make_unique<CActionListItem>(pView->m_pDoc, IDS_STRING_ACTION_DELETE);
|
|
|
|
|
|
CXy* pXy = pView->m_pDoc->m_pXy;
|
|
|
|
|
|
CLayer* pLayer = pXy->FindLayer(layerName);
|
|
|
if (pLayer == nullptr)
|
|
|
{
|
|
|
const CString currentLayer = pXy->GetCurrentLayer()->GetPathName();
|
|
|
pLayer = pXy->FindAddLayer(layerName);
|
|
|
pAction->AddLayerAddItem(pLayer, currentLayer);
|
|
|
}
|
|
|
|
|
|
auto pProportion = std::make_unique<CProportion>();
|
|
|
double unitLen = scaleValue / 100.0;
|
|
|
double totalLen = unitLen * count;
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>㷨<EFBFBD><E3B7A8>ˮƽ<CBAE><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> [xMin, xMax]<5D><><EFBFBD><EFBFBD>ֱƫ<D6B1><C6AB> yMax
|
|
|
pProportion->x0 = xMin + (std::fabs(xMax - xMin) - totalLen) / 2.0;
|
|
|
pProportion->y0 = yMax + offset;
|
|
|
|
|
|
pProportion->m_dScaleLength = scaleValue / 100.0;
|
|
|
pProportion->num = count;
|
|
|
|
|
|
auto pOne = std::make_unique<COne>();
|
|
|
pOne->SetValueSafe(pProportion.release());
|
|
|
pOne->SetLayer(pLayer);
|
|
|
|
|
|
POSITION pos = pXy->AddTailOne(pOne.release());
|
|
|
|
|
|
CPositionList items;
|
|
|
items.AddTail(pos);
|
|
|
pAction->AddAddItem(items);
|
|
|
|
|
|
pView->m_pDoc->SetActionItem(pAction.release());
|
|
|
}
|