代码同步
This commit is contained in:
parent
5956959e08
commit
2682ba768a
|
@ -210,6 +210,9 @@ extern "C"
|
|||
return m_vCurrentOperationId;
|
||||
}
|
||||
|
||||
void insertCmdLog(vector<string>& commandLines_tmp);
|
||||
void SaveTmpCmd();
|
||||
QString readTmpCmd(QString tmpFile);
|
||||
// 导入型值表
|
||||
// 横向横剖线 命令集
|
||||
std::vector<std::string> &getTransverseProfile_commad();
|
||||
|
@ -391,7 +394,14 @@ extern "C"
|
|||
|
||||
std::vector<std::string> extract_ids_from_file(const QString &filePath, const std::string &rootName);
|
||||
|
||||
|
||||
void setCurentUsingFilePath(QString filePath)
|
||||
{
|
||||
m_strCurentUsingFilePath = filePath;
|
||||
}
|
||||
QString getCurentUsingFilePath()
|
||||
{
|
||||
return m_strCurentUsingFilePath;
|
||||
}
|
||||
|
||||
private:
|
||||
DataManager();
|
||||
|
@ -425,6 +435,8 @@ extern "C"
|
|||
|
||||
std::string m_cmdStr; // CMD命令
|
||||
|
||||
QString m_strCurentUsingFilePath = "";
|
||||
|
||||
std::vector<int> m_vCurrentOperationId;
|
||||
|
||||
XLSXDataManager m_xlsmDataManager;
|
||||
|
|
|
@ -263,6 +263,10 @@ extern "C"
|
|||
void setCurentUsingFilePath(QString filePath)
|
||||
{
|
||||
m_strCurentUsingFilePath = filePath;
|
||||
if(m_pDataManager)
|
||||
{
|
||||
m_pDataManager->setCurentUsingFilePath(m_strCurentUsingFilePath);
|
||||
}
|
||||
}
|
||||
QString getCurentUsingFilePath()
|
||||
{
|
||||
|
|
|
@ -42,6 +42,8 @@ public:
|
|||
|
||||
static QString getLogEndLine();
|
||||
|
||||
static void deleteFile(const QString &filePath);
|
||||
|
||||
private:
|
||||
PathUtil();
|
||||
Q_DISABLE_COPY(PathUtil)
|
||||
|
|
|
@ -342,20 +342,56 @@ void DataManager::saveFile(QString &savefilePath)
|
|||
return;
|
||||
}
|
||||
|
||||
// 写入内容
|
||||
QTextStream out(&file);
|
||||
if (!m_cmdStr.empty())
|
||||
if(m_strCurentUsingFilePath == savefilePath)
|
||||
{
|
||||
out << QString::fromStdString(m_cmdStr);
|
||||
m_cmdStr.clear();
|
||||
QString tmpFile = PathUtil::bin_dir() + "cmdTmp.lst";
|
||||
QString conten = readTmpCmd(tmpFile);
|
||||
QTextStream out(&file);
|
||||
out << conten;
|
||||
file.close();
|
||||
PathUtil::deleteFile(tmpFile);
|
||||
}
|
||||
file.close();
|
||||
else
|
||||
{
|
||||
|
||||
QString cmdCurentUsingFilePath = GetCmdFileName(m_strCurentUsingFilePath);
|
||||
QString conten_old = readTmpCmd(cmdCurentUsingFilePath);
|
||||
|
||||
QTextStream out(&file);
|
||||
QString tmpFile = PathUtil::bin_dir() + "cmdTmp.lst";
|
||||
|
||||
out << conten_old;
|
||||
QString conten_new = readTmpCmd(tmpFile);
|
||||
out << conten_new;
|
||||
file.close();
|
||||
PathUtil::deleteFile(tmpFile);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
pugi::xml_document doc;
|
||||
|
||||
pugi::xml_node root = doc.append_child("Data");
|
||||
|
||||
|
||||
pugi::xml_node data_version_x = root.append_child("DataVersion");
|
||||
m_VersionData.toXml(data_version_x);
|
||||
|
||||
pugi::xml_node model_x = root.append_child("Model");
|
||||
m_ModelData.toXml(model_x);
|
||||
|
||||
// XML: OCIDX
|
||||
// root.append_copy(occIndexData);
|
||||
|
||||
pugi::xml_node model_stab_cal = root.append_child("StabilityCal");
|
||||
m_StabCalData.toXml(model_stab_cal);
|
||||
|
||||
pugi::xml_node model_certify_cal = root.append_child("CertifyCal");
|
||||
m_CertifyCal->toXml(model_certify_cal);
|
||||
|
||||
|
||||
// OCM
|
||||
{
|
||||
QString occ_filename = GetOcmFileName(savefilePath);
|
||||
|
@ -374,8 +410,8 @@ void DataManager::saveFile(QString &savefilePath)
|
|||
char *persistentPtr1 = new char[utf8Data.size() + 1];
|
||||
memset(persistentPtr1, 0, utf8Data.size() + 1);
|
||||
strcpy(persistentPtr1, utf8Data.constData());
|
||||
|
||||
OCCModeling::SaveTopoToStep(persistentPtr1, ids);
|
||||
delete[] persistentPtr1;
|
||||
|
||||
// OCIDX
|
||||
pugi::xml_node occIndexData = root.append_child("OCIDX");
|
||||
|
@ -393,21 +429,9 @@ void DataManager::saveFile(QString &savefilePath)
|
|||
}
|
||||
}
|
||||
|
||||
pugi::xml_node data_version_x = root.append_child("DataVersion");
|
||||
m_VersionData.toXml(data_version_x);
|
||||
|
||||
pugi::xml_node model_x = root.append_child("Model");
|
||||
m_ModelData.toXml(model_x);
|
||||
|
||||
// XML: OCIDX
|
||||
// root.append_copy(occIndexData);
|
||||
|
||||
pugi::xml_node model_stab_cal = root.append_child("StabilityCal");
|
||||
|
||||
m_StabCalData.toXml(model_stab_cal);
|
||||
|
||||
pugi::xml_node model_certify_cal = root.append_child("CertifyCal");
|
||||
m_CertifyCal->toXml(model_certify_cal);
|
||||
|
||||
doc.save_file(
|
||||
savefilePath.toStdWString().c_str(),
|
||||
|
@ -502,6 +526,8 @@ int DataManager::create_point(vector<string> &commandLines, QString &strLog)
|
|||
vector<Surface> vSur;
|
||||
vector<Solid> vSol;
|
||||
|
||||
vector<string> commandLines_tmp = commandLines;
|
||||
|
||||
create_point(commandLines, points, vPoint3d, order);
|
||||
|
||||
bool res = OCCModeling::AddObj(m_executingCmdID, order, vPoint3d, vCur, vSur, vSol);
|
||||
|
@ -524,7 +550,6 @@ int DataManager::create_point(vector<string> &commandLines, QString &strLog)
|
|||
else
|
||||
{
|
||||
std::vector<int> ids;
|
||||
|
||||
for (auto &point : points)
|
||||
{
|
||||
m_ModelData.insertPoint3D(point);
|
||||
|
@ -542,12 +567,9 @@ int DataManager::create_point(vector<string> &commandLines, QString &strLog)
|
|||
}
|
||||
m_undoRedoMg.pushCommand(m_executingCmdID, vUndoRedoData);
|
||||
|
||||
std::string logstr;
|
||||
for (auto str : commandLines)
|
||||
{
|
||||
logstr += str + "\r\n";
|
||||
}
|
||||
m_cmdStr.append(logstr);
|
||||
|
||||
insertCmdLog(commandLines_tmp);
|
||||
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
|
@ -558,6 +580,69 @@ int DataManager::create_point(vector<string> &commandLines, QString &strLog)
|
|||
return errorCode;
|
||||
}
|
||||
|
||||
|
||||
void DataManager::insertCmdLog(vector<string>& commandLines_tmp)
|
||||
{
|
||||
std::string logstr;
|
||||
for (auto str : commandLines_tmp)
|
||||
{
|
||||
logstr += str + PathUtil::getEndMark().toStdString();
|
||||
}
|
||||
m_cmdStr.append(logstr);
|
||||
SaveTmpCmd();
|
||||
|
||||
}
|
||||
|
||||
void DataManager::SaveTmpCmd() // 20180101 modified by czb
|
||||
{
|
||||
// 如果 cmdFilename 为空
|
||||
|
||||
QString tmpFile = PathUtil::bin_dir() + "cmdTmp.lst";
|
||||
QString cmdFilePath = GetCmdFileName(tmpFile);
|
||||
|
||||
QFile file(cmdFilePath); // 打开目标文件
|
||||
|
||||
if (file.open(QIODevice::Append | QIODevice::Text | QIODevice::WriteOnly))
|
||||
{
|
||||
QTextStream out(&file);
|
||||
if (!m_cmdStr.empty()) // 如果 m_cmdStr 不为空
|
||||
{
|
||||
out << QString::fromStdString(m_cmdStr); // 将 m_cmdStr 写入文件
|
||||
m_cmdStr.clear(); // 清空 m_cmdStr
|
||||
}
|
||||
file.close(); // 关闭文件
|
||||
}
|
||||
else
|
||||
{
|
||||
//qDebug() << "文件打开失败!";
|
||||
}
|
||||
}
|
||||
|
||||
QString DataManager::readTmpCmd(QString tmpFile)
|
||||
{
|
||||
QString cmdFilePath = GetCmdFileName(tmpFile);
|
||||
|
||||
QFile file(cmdFilePath); // 创建一个 QFile 对象
|
||||
QString fileContent = ""; // 用于保存文件内容
|
||||
|
||||
if (!file.exists())
|
||||
{
|
||||
|
||||
return fileContent; // 返回空的 QString
|
||||
}
|
||||
|
||||
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
fileContent = file.readAll(); // 读取整个文件,包括换行符
|
||||
file.close();
|
||||
}
|
||||
|
||||
return fileContent; // 返回保存文件内容的 QString
|
||||
}
|
||||
|
||||
|
||||
|
||||
int DataManager::create_line(vector<string> &commandLines, Curve_M &curve, std::vector<Point3D_M> &points, vector<Point3D> &vPoint3d, vector<Curve> &vCur, vector<int> &order)
|
||||
{
|
||||
CurveInterpreter curveInterpreter;
|
||||
|
@ -590,6 +675,7 @@ int DataManager::create_line(vector<string> &commandLines, QString &strLog)
|
|||
vector<Surface> vSur;
|
||||
vector<Solid> vSol;
|
||||
|
||||
vector<string> commandLines_tmp = commandLines;
|
||||
create_line(commandLines, curve, points, vPoint3d, vCur, order);
|
||||
|
||||
bool res = OCCModeling::AddObj(m_executingCmdID, order, vPoint3d, vCur, vSur, vSol);
|
||||
|
@ -628,12 +714,7 @@ int DataManager::create_line(vector<string> &commandLines, QString &strLog)
|
|||
strLog += "生成图元" + curve.m_Name + PathUtil::getEndMark();
|
||||
|
||||
setCurrentOperationId(curve.m_ID);
|
||||
std::string logstr;
|
||||
for (auto str : commandLines)
|
||||
{
|
||||
logstr += str + "\r\n";
|
||||
}
|
||||
m_cmdStr.append(logstr);
|
||||
insertCmdLog(commandLines_tmp);
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
|
@ -670,7 +751,7 @@ int DataManager::create_surface(vector<string> &commandLines, QString &strLog)
|
|||
vector<Curve> vCur;
|
||||
vector<Surface> vSur;
|
||||
vector<Solid> vSol;
|
||||
|
||||
vector<string> commandLines_tmp = commandLines;
|
||||
create_surface(commandLines, surface, vSur, order);
|
||||
|
||||
bool res = OCCModeling::AddObj(m_executingCmdID, order, vPoint3d, vCur, vSur, vSol);
|
||||
|
@ -707,12 +788,7 @@ int DataManager::create_surface(vector<string> &commandLines, QString &strLog)
|
|||
|
||||
// addShowWindowsLog("命令执行成功\n 生成图元" + surface.m_Name);
|
||||
setCurrentOperationId(surface.m_ID);
|
||||
std::string logstr;
|
||||
for (auto str : commandLines)
|
||||
{
|
||||
logstr += str + "\r\n";
|
||||
}
|
||||
m_cmdStr.append(logstr);
|
||||
insertCmdLog(commandLines_tmp);
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
|
@ -748,7 +824,7 @@ int DataManager::create_solid(vector<string> &commandLines, QString &strLog)
|
|||
vector<Surface> vSur;
|
||||
vector<Solid> vSol;
|
||||
vector<int> order;
|
||||
|
||||
vector<string> commandLines_tmp = commandLines;
|
||||
create_solid(commandLines, solid, vSol, order);
|
||||
bool res = OCCModeling::AddObj(m_executingCmdID, order, vPoint3d, vCur, vSur, vSol);
|
||||
if (!res)
|
||||
|
@ -781,12 +857,7 @@ int DataManager::create_solid(vector<string> &commandLines, QString &strLog)
|
|||
m_undoRedoMg.pushCommand(m_executingCmdID, (IModel *)&solid);
|
||||
|
||||
setCurrentOperationId(solid.m_ID);
|
||||
std::string logstr;
|
||||
for (auto str : commandLines)
|
||||
{
|
||||
logstr += str + "\r\n";
|
||||
}
|
||||
m_cmdStr.append(logstr);
|
||||
insertCmdLog(commandLines_tmp);
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
|
@ -818,7 +889,7 @@ int DataManager::create_Hull(vector<string> &commandLines, QString &strLog)
|
|||
Hull_M hull;
|
||||
vector<int> order;
|
||||
vector<Hull> vHull;
|
||||
|
||||
vector<string> commandLines_tmp = commandLines;
|
||||
create_Hull(commandLines, hull, vHull, order);
|
||||
bool res = OCCModeling::AddObjHull(m_executingCmdID, order, vHull);
|
||||
if (!res)
|
||||
|
@ -854,12 +925,7 @@ int DataManager::create_Hull(vector<string> &commandLines, QString &strLog)
|
|||
|
||||
setCurrentOperationId(hull.m_ID);
|
||||
|
||||
std::string logstr;
|
||||
for (auto str : commandLines)
|
||||
{
|
||||
logstr += str + "\r\n";
|
||||
}
|
||||
m_cmdStr.append(logstr);
|
||||
insertCmdLog(commandLines_tmp);
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
|
@ -895,7 +961,7 @@ int DataManager::create_unit_and_space(vector<string> &commandLines, QString &st
|
|||
Space_M space;
|
||||
vector<int> order;
|
||||
vector<Space> vSpace;
|
||||
|
||||
vector<string> commandLines_tmp = commandLines;
|
||||
create_unit_and_space(commandLines, space, vSpace, order);
|
||||
bool result = OCCModeling::AddObjSpace(m_executingCmdID, order, vSpace);
|
||||
if (!result)
|
||||
|
@ -928,12 +994,7 @@ int DataManager::create_unit_and_space(vector<string> &commandLines, QString &st
|
|||
strLog += "命令执行成功" + PathUtil::getEndMark();
|
||||
strLog += "生成图元" + space.m_Name + PathUtil::getEndMark();
|
||||
setCurrentOperationId(space.m_ID);
|
||||
std::string logstr;
|
||||
for (auto str : commandLines)
|
||||
{
|
||||
logstr += str + "\r\n";
|
||||
}
|
||||
m_cmdStr.append(logstr);
|
||||
insertCmdLog(commandLines_tmp);
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
|
@ -967,7 +1028,7 @@ int DataManager::create_Appendage(vector<string> &commandLines, QString &strLog)
|
|||
Appendage_M appendage;
|
||||
vector<int> order;
|
||||
vector<Appendage> vappendage;
|
||||
|
||||
vector<string> commandLines_tmp = commandLines;
|
||||
create_Appendage(commandLines, appendage, vappendage, order);
|
||||
bool result = OCCModeling::AddObjAppendage(m_executingCmdID, order, vappendage);
|
||||
if (!result)
|
||||
|
@ -1001,12 +1062,7 @@ int DataManager::create_Appendage(vector<string> &commandLines, QString &strLog)
|
|||
strLog += "生成图元" + appendage.m_Name + PathUtil::getEndMark();
|
||||
|
||||
setCurrentOperationId(appendage.m_ID);
|
||||
std::string logstr;
|
||||
for (auto str : commandLines)
|
||||
{
|
||||
logstr += str + "\r\n";
|
||||
}
|
||||
m_cmdStr.append(logstr);
|
||||
insertCmdLog(commandLines_tmp);
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
|
@ -1022,6 +1078,7 @@ int DataManager::setObjVisible(vector<string> &commandLines)
|
|||
std::vector<int> ids;
|
||||
int iValue = 0;
|
||||
PropertyInterpreter Interpreter;
|
||||
vector<string> commandLines_tmp = commandLines;
|
||||
Interpreter.ExecuteCommand(commandLines, ids, iValue);
|
||||
|
||||
bool bRet = false;
|
||||
|
@ -1051,6 +1108,7 @@ int DataManager::setObjVisible(vector<string> &commandLines)
|
|||
{
|
||||
bRet = true;
|
||||
setCurrentOperationId(useids);
|
||||
insertCmdLog(commandLines_tmp);
|
||||
}
|
||||
|
||||
return bRet;
|
||||
|
@ -2741,15 +2799,11 @@ int DataManager::cmd_copy(std::string &singlecmdstring, QString &strLog)
|
|||
vector<string> commandLines = CommandStreamProcessing::SplitCommand(singlecmdstring);
|
||||
CopyInterpreter copyInterpreter;
|
||||
IModel *model = nullptr;
|
||||
vector<string> commandLines_tmp = commandLines;
|
||||
copyInterpreter.ExecuteCommand(commandLines, model);
|
||||
errorCode = cmd_add_obj(model, strLog);
|
||||
|
||||
std::string logstr;
|
||||
for (auto str : commandLines)
|
||||
{
|
||||
logstr += str + "\r\n";
|
||||
}
|
||||
m_cmdStr.append(logstr);
|
||||
insertCmdLog(commandLines_tmp);
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
|
@ -2770,16 +2824,12 @@ int DataManager::cmd_trim(std::string &singlecmdstring, QString &strLog)
|
|||
|
||||
TrimInterpreter trimInterpreter;
|
||||
IModel *model = nullptr;
|
||||
vector<string> commandLines_tmp = commandLines;
|
||||
trimInterpreter.ExecuteCommand(commandLines, model);
|
||||
|
||||
errorCode = cmd_add_obj(model, strLog);
|
||||
|
||||
std::string logstr;
|
||||
for (auto str : commandLines)
|
||||
{
|
||||
logstr += str + "\r\n";
|
||||
}
|
||||
m_cmdStr.append(logstr);
|
||||
insertCmdLog(commandLines_tmp);
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
|
@ -2798,16 +2848,12 @@ int DataManager::cmd_mirror(std::string &singlecmdstring, QString &strLog)
|
|||
vector<string> commandLines = CommandStreamProcessing::SplitCommand(singlecmdstring);
|
||||
MirrorGeomInterpreter mirrorGeomInterpreter;
|
||||
IModel *model = nullptr;
|
||||
vector<string> commandLines_tmp = commandLines;
|
||||
mirrorGeomInterpreter.ExecuteCommand(commandLines, model, this);
|
||||
|
||||
errorCode = cmd_add_obj(model, strLog);
|
||||
|
||||
std::string logstr;
|
||||
for (auto str : commandLines)
|
||||
{
|
||||
logstr += str + "\r\n";
|
||||
}
|
||||
m_cmdStr.append(logstr);
|
||||
insertCmdLog(commandLines_tmp);
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
|
@ -2826,6 +2872,7 @@ int DataManager::cmd_intersection(std::string &singlecmdstring, QString &strLog)
|
|||
|
||||
IntersectInterpreter intersectInterpreter;
|
||||
Curve_M curve;
|
||||
vector<string> commandLines_tmp = commandLines;
|
||||
intersectInterpreter.ExecuteCommand(commandLines, curve);
|
||||
vector<int> order;
|
||||
order.emplace_back(curve.m_ID);
|
||||
|
@ -2863,12 +2910,7 @@ int DataManager::cmd_intersection(std::string &singlecmdstring, QString &strLog)
|
|||
|
||||
m_undoRedoMg.pushCommand(m_executingCmdID, (IModel *)&curve);
|
||||
|
||||
std::string logstr;
|
||||
for (auto str : commandLines)
|
||||
{
|
||||
logstr += str + "\r\n";
|
||||
}
|
||||
m_cmdStr.append(logstr);
|
||||
insertCmdLog(commandLines_tmp);
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
|
@ -2890,6 +2932,7 @@ int DataManager::cmd_join(std::string &singlecmdstring, QString &strLog)
|
|||
IModel *model = nullptr;
|
||||
std::vector<int> toDel;
|
||||
std::vector<std::string> names;
|
||||
vector<string> commandLines_tmp = commandLines;
|
||||
joinInterpreter.ExecuteCommand(commandLines, model, toDel, names);
|
||||
|
||||
vector<int> order;
|
||||
|
@ -3038,13 +3081,7 @@ int DataManager::cmd_join(std::string &singlecmdstring, QString &strLog)
|
|||
// strLog += "命令执行成功" + PathUtil::getEndMark();
|
||||
// strLog += "删除图元" +str+ PathUtil::getEndMark();
|
||||
// }
|
||||
|
||||
std::string logstr;
|
||||
for (auto str : commandLines)
|
||||
{
|
||||
logstr += str + "\r\n";
|
||||
}
|
||||
m_cmdStr.append(logstr);
|
||||
insertCmdLog(commandLines_tmp);
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
|
@ -3075,10 +3112,10 @@ int DataManager::cmd_delete(std::string &singlecmdstring, QString &strLog, std::
|
|||
try
|
||||
{
|
||||
vector<string> commandLines = CommandStreamProcessing::SplitCommand(singlecmdstring);
|
||||
vector<string> commandLines_tmp = commandLines;
|
||||
std::vector<Empty> lst;
|
||||
std::vector<std::string> names;
|
||||
DelInterpreter delinterpreter;
|
||||
vector<string> commandLines_tmp = commandLines;
|
||||
delinterpreter.ExecuteCommand(commandLines, lst, names);
|
||||
vector<int> lstID;
|
||||
vector<int> order;
|
||||
|
@ -3119,12 +3156,7 @@ int DataManager::cmd_delete(std::string &singlecmdstring, QString &strLog, std::
|
|||
strLog += "命令执行成功" + PathUtil::getEndMark();
|
||||
strLog += "删除图元 " + str + PathUtil::getEndMark();
|
||||
|
||||
std::string logstr;
|
||||
for (auto str : commandLines)
|
||||
{
|
||||
logstr += str + "\r\n";
|
||||
}
|
||||
m_cmdStr.append(logstr);
|
||||
insertCmdLog(commandLines_tmp);
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
|
|
|
@ -166,3 +166,17 @@ double PathUtil::jsonContainsKeyToDouble(const json &j ,string strkey)
|
|||
return -1.0;
|
||||
}
|
||||
}
|
||||
|
||||
void PathUtil::deleteFile(const QString &filePath)
|
||||
{
|
||||
QFile file(filePath); // 创建一个 QFile 对象
|
||||
if (file.exists()) {
|
||||
if (file.remove()) {
|
||||
//qDebug() << "文件删除成功";
|
||||
} else {
|
||||
/// qDebug() << "文件删除失败";
|
||||
}
|
||||
} else {
|
||||
//qDebug() << "文件不存在";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue