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.
239 lines
5.0 KiB
C++
239 lines
5.0 KiB
C++
#include "FITKAbsGeoSketch2D.h"
|
|
|
|
namespace Interface
|
|
{
|
|
FITKAbsGeoSketch2D::FITKAbsGeoSketch2D()
|
|
{
|
|
// 初始化重做列表。
|
|
m_redoList = new FITKGeoCommandManager;
|
|
}
|
|
|
|
FITKAbsGeoSketch2D::~FITKAbsGeoSketch2D()
|
|
{
|
|
// 析构重做列表。
|
|
if (m_redoList)
|
|
{
|
|
delete m_redoList;
|
|
m_redoList = nullptr;
|
|
}
|
|
}
|
|
|
|
// 获取数据类型。
|
|
FITKGeoEnum::FITKGeometryComType FITKAbsGeoSketch2D::getGeometryCommandType()
|
|
{
|
|
return FITKGeoEnum::FITKGeometryComType::FGTSketch2D;
|
|
}
|
|
|
|
// 更新子数据。
|
|
bool FITKAbsGeoSketch2D::update()
|
|
{
|
|
bool flag = true;
|
|
for (int i = 0; i < getDataCount(); i++)
|
|
{
|
|
// 获取子数据并尝试进行更新。
|
|
Interface::FITKAbsGeoCommand* subCmd = getDataByIndex(i);
|
|
if (subCmd)
|
|
{
|
|
flag &= subCmd->update();
|
|
}
|
|
else
|
|
{
|
|
flag = false;
|
|
}
|
|
}
|
|
|
|
// 返回是否存在子数据更新失败。
|
|
return flag;
|
|
}
|
|
|
|
void FITKAbsGeoSketch2D::setPlane(double* pos, double* normal, double* up)
|
|
{
|
|
// 设置全部信息。
|
|
if (!pos || !normal || !up)
|
|
{
|
|
return;
|
|
}
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
m_pos[i] = pos[i];
|
|
m_nor[i] = normal[i];
|
|
m_up[i] = up[i];
|
|
}
|
|
}
|
|
|
|
void FITKAbsGeoSketch2D::getPlane(double* pos, double* normal, double* up)
|
|
{
|
|
// 获取全部信息。
|
|
if (!pos || !normal || !up)
|
|
{
|
|
return;
|
|
}
|
|
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
pos[i] = m_pos[i];
|
|
normal[i] = m_nor[i];
|
|
up[i] = m_up[i];
|
|
}
|
|
}
|
|
|
|
void FITKAbsGeoSketch2D::setPosition(double* pos)
|
|
{
|
|
// 保存位置。
|
|
if (pos)
|
|
{
|
|
m_pos[0] = pos[0];
|
|
m_pos[1] = pos[1];
|
|
m_pos[2] = pos[2];
|
|
}
|
|
}
|
|
|
|
void FITKAbsGeoSketch2D::getPosition(double* pos)
|
|
{
|
|
if (pos)
|
|
{
|
|
pos[0] = m_pos[0];
|
|
pos[1] = m_pos[1];
|
|
pos[2] = m_pos[2];
|
|
}
|
|
}
|
|
|
|
void FITKAbsGeoSketch2D::setNormal(double* nor)
|
|
{
|
|
// 保存方向。
|
|
if (nor)
|
|
{
|
|
m_nor[0] = nor[0];
|
|
m_nor[1] = nor[1];
|
|
m_nor[2] = nor[2];
|
|
}
|
|
}
|
|
|
|
void FITKAbsGeoSketch2D::getNormal(double* nor)
|
|
{
|
|
if (nor)
|
|
{
|
|
nor[0] = m_nor[0];
|
|
nor[1] = m_nor[1];
|
|
nor[2] = m_nor[2];
|
|
}
|
|
}
|
|
|
|
void FITKAbsGeoSketch2D::setUp(double* up)
|
|
{
|
|
// 保存方向。
|
|
if (up)
|
|
{
|
|
m_up[0] = up[0];
|
|
m_up[1] = up[1];
|
|
m_up[2] = up[2];
|
|
}
|
|
}
|
|
|
|
void FITKAbsGeoSketch2D::getUp(double* up)
|
|
{
|
|
if (up)
|
|
{
|
|
up[0] = m_up[0];
|
|
up[1] = m_up[1];
|
|
up[2] = m_up[2];
|
|
}
|
|
}
|
|
|
|
bool FITKAbsGeoSketch2D::undoInternal()
|
|
{
|
|
int nSubCnmd = this->getDataCount();
|
|
if (nSubCnmd == 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// 移动命令。
|
|
FITKAbsGeoCommand* subCmd = this->getDataByIndex(nSubCnmd - 1);
|
|
if (!subCmd)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
this->removeDataObjWithoutRelease(subCmd);
|
|
m_redoList->appendDataObj(subCmd);
|
|
this->update();
|
|
return true;
|
|
}
|
|
|
|
bool FITKAbsGeoSketch2D::redoInternal()
|
|
{
|
|
if (!m_redoList)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
int nSubCnmd = m_redoList->getDataCount();
|
|
if (nSubCnmd == 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
// 移动命令。
|
|
FITKAbsGeoCommand* subCmd = m_redoList->getDataByIndex(nSubCnmd - 1);
|
|
if (!subCmd)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
m_redoList->removeDataObjWithoutRelease(subCmd);
|
|
|
|
// 需要跳过清空Redo列表逻辑进行添加。
|
|
FITKGeoCommandManager::appendDataObj(subCmd);
|
|
|
|
this->update();
|
|
|
|
return true;
|
|
}
|
|
|
|
void FITKAbsGeoSketch2D::appendDataObj(Core::FITKAbstractDataObject* obj)
|
|
{
|
|
// 清空重做列表。
|
|
if (m_redoList)
|
|
{
|
|
m_redoList->clear();
|
|
}
|
|
|
|
// 执行插入数据。
|
|
FITKGeoCommandManager::appendDataObj(obj);
|
|
}
|
|
|
|
bool FITKAbsGeoSketch2D::canUndo()
|
|
{
|
|
FITKGeoCommandManager* list = this->getUndoList();
|
|
if (!list)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return list->getDataCount() != 0;
|
|
}
|
|
|
|
bool FITKAbsGeoSketch2D::canRedo()
|
|
{
|
|
FITKGeoCommandManager* list = this->getRedoList();
|
|
if (!list)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return list->getDataCount() != 0;
|
|
}
|
|
|
|
FITKGeoCommandManager* FITKAbsGeoSketch2D::getUndoList()
|
|
{
|
|
// 当前命令列表即为撤销列表。
|
|
return this;
|
|
}
|
|
|
|
FITKGeoCommandManager* FITKAbsGeoSketch2D::getRedoList()
|
|
{
|
|
return m_redoList;
|
|
}
|
|
} |