diff --git a/CreoPluging9.0.vcxproj b/CreoPluging9.0.vcxproj index e8e383a..7d9b02b 100644 --- a/CreoPluging9.0.vcxproj +++ b/CreoPluging9.0.vcxproj @@ -156,6 +156,7 @@ + @@ -171,6 +172,9 @@ CompileAsCpp + + CompileAsCpp + CompileAsCpp diff --git a/CreoPluging9.0.vcxproj.filters b/CreoPluging9.0.vcxproj.filters index 2689155..cb8f649 100644 --- a/CreoPluging9.0.vcxproj.filters +++ b/CreoPluging9.0.vcxproj.filters @@ -21,11 +21,17 @@ 头文件 + + 头文件 + 源文件 + + 源文件 + 源文件 diff --git a/CreoPluging9.0/x64/Debug/Creo90Manager.obj b/CreoPluging9.0/x64/Debug/Creo90Manager.obj index 739c454..c2d511e 100644 Binary files a/CreoPluging9.0/x64/Debug/Creo90Manager.obj and b/CreoPluging9.0/x64/Debug/Creo90Manager.obj differ diff --git a/CreoPluging9.0/x64/Debug/CreoPluging9.0.pch b/CreoPluging9.0/x64/Debug/CreoPluging9.0.pch index 7390690..f6b181a 100644 Binary files a/CreoPluging9.0/x64/Debug/CreoPluging9.0.pch and b/CreoPluging9.0/x64/Debug/CreoPluging9.0.pch differ diff --git a/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/CL.command.1.tlog b/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/CL.command.1.tlog index 2ecab5a..616b606 100644 Binary files a/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/CL.command.1.tlog and b/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/CL.command.1.tlog differ diff --git a/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/CL.read.1.tlog b/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/CL.read.1.tlog index c8c6564..1f0b152 100644 Binary files a/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/CL.read.1.tlog and b/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/CL.read.1.tlog differ diff --git a/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/CL.write.1.tlog b/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/CL.write.1.tlog index 979f2f1..fe7de2a 100644 Binary files a/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/CL.write.1.tlog and b/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/CL.write.1.tlog differ diff --git a/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/Cl.items.tlog b/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/Cl.items.tlog index 8fe845d..62dfa01 100644 --- a/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/Cl.items.tlog +++ b/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/Cl.items.tlog @@ -2,4 +2,5 @@ D:\App\C++\CreoPluging9.0\dllmain.cpp;D:\App\C++\CreoPluging9.0\CreoPluging9.0\x D:\App\C++\CreoPluging9.0\Creo90Manager.cpp;D:\App\C++\CreoPluging9.0\CreoPluging9.0\x64\Debug\Creo90Manager.obj D:\App\C++\CreoPluging9.0\ShrinkwrapCommand.cpp;D:\App\C++\CreoPluging9.0\CreoPluging9.0\x64\Debug\ShrinkwrapCommand.obj D:\App\C++\CreoPluging9.0\Shrinkwrap90Manager.cpp;D:\App\C++\CreoPluging9.0\CreoPluging9.0\x64\Debug\Shrinkwrap90Manager.obj +D:\App\C++\CreoPluging9.0\ShrinkwrapDialog.cpp;D:\App\C++\CreoPluging9.0\CreoPluging9.0\x64\Debug\ShrinkwrapDialog.obj D:\App\C++\CreoPluging9.0\pch.cpp;D:\App\C++\CreoPluging9.0\CreoPluging9.0\x64\Debug\pch.obj diff --git a/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/link.command.1.tlog b/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/link.command.1.tlog index f098df7..b534a23 100644 Binary files a/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/link.command.1.tlog and b/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/link.command.1.tlog differ diff --git a/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/link.read.1.tlog b/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/link.read.1.tlog index a8ec755..1b2ef22 100644 Binary files a/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/link.read.1.tlog and b/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/link.read.1.tlog differ diff --git a/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/link.secondary.1.tlog b/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/link.secondary.1.tlog index ec5b9f6..c14e8ea 100644 --- a/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/link.secondary.1.tlog +++ b/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/link.secondary.1.tlog @@ -1,4 +1,4 @@ -^D:\APP\C++\CREOPLUGING9.0\CREOPLUGING9.0\X64\DEBUG\CREO90MANAGER.OBJ|D:\APP\C++\CREOPLUGING9.0\CREOPLUGING9.0\X64\DEBUG\DLLMAIN.OBJ|D:\APP\C++\CREOPLUGING9.0\CREOPLUGING9.0\X64\DEBUG\PCH.OBJ|D:\APP\C++\CREOPLUGING9.0\CREOPLUGING9.0\X64\DEBUG\SHRINKWRAP90MANAGER.OBJ|D:\APP\C++\CREOPLUGING9.0\CREOPLUGING9.0\X64\DEBUG\SHRINKWRAPCOMMAND.OBJ +^D:\APP\C++\CREOPLUGING9.0\CREOPLUGING9.0\X64\DEBUG\CREO90MANAGER.OBJ|D:\APP\C++\CREOPLUGING9.0\CREOPLUGING9.0\X64\DEBUG\DLLMAIN.OBJ|D:\APP\C++\CREOPLUGING9.0\CREOPLUGING9.0\X64\DEBUG\PCH.OBJ|D:\APP\C++\CREOPLUGING9.0\CREOPLUGING9.0\X64\DEBUG\SHRINKWRAP90MANAGER.OBJ|D:\APP\C++\CREOPLUGING9.0\CREOPLUGING9.0\X64\DEBUG\SHRINKWRAPCOMMAND.OBJ|D:\APP\C++\CREOPLUGING9.0\CREOPLUGING9.0\X64\DEBUG\SHRINKWRAPDIALOG.OBJ D:\App\C++\CreoPluging9.0\x64\Debug\CreoPluging9.0.lib D:\App\C++\CreoPluging9.0\x64\Debug\CreoPluging9.0.EXP D:\App\C++\CreoPluging9.0\x64\Debug\CreoPluging9.0.ILK diff --git a/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/link.write.1.tlog b/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/link.write.1.tlog index 71a1533..d09c0d5 100644 Binary files a/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/link.write.1.tlog and b/CreoPluging9.0/x64/Debug/CreoPluging9.0.tlog/link.write.1.tlog differ diff --git a/CreoPluging9.0/x64/Debug/Shrinkwrap90Manager.obj b/CreoPluging9.0/x64/Debug/Shrinkwrap90Manager.obj index 1f1c8f0..23ee9ee 100644 Binary files a/CreoPluging9.0/x64/Debug/Shrinkwrap90Manager.obj and b/CreoPluging9.0/x64/Debug/Shrinkwrap90Manager.obj differ diff --git a/CreoPluging9.0/x64/Debug/ShrinkwrapCommand.obj b/CreoPluging9.0/x64/Debug/ShrinkwrapCommand.obj index 9a534a1..a5e79a3 100644 Binary files a/CreoPluging9.0/x64/Debug/ShrinkwrapCommand.obj and b/CreoPluging9.0/x64/Debug/ShrinkwrapCommand.obj differ diff --git a/CreoPluging9.0/x64/Debug/ShrinkwrapDialog.obj b/CreoPluging9.0/x64/Debug/ShrinkwrapDialog.obj new file mode 100644 index 0000000..65e3127 Binary files /dev/null and b/CreoPluging9.0/x64/Debug/ShrinkwrapDialog.obj differ diff --git a/CreoPluging9.0/x64/Debug/dllmain.obj b/CreoPluging9.0/x64/Debug/dllmain.obj index 4754e97..77ac534 100644 Binary files a/CreoPluging9.0/x64/Debug/dllmain.obj and b/CreoPluging9.0/x64/Debug/dllmain.obj differ diff --git a/CreoPluging9.0/x64/Debug/pch.obj b/CreoPluging9.0/x64/Debug/pch.obj index 954bf4e..0c9cd0d 100644 Binary files a/CreoPluging9.0/x64/Debug/pch.obj and b/CreoPluging9.0/x64/Debug/pch.obj differ diff --git a/CreoPluging9.0/x64/Debug/vc143.pdb b/CreoPluging9.0/x64/Debug/vc143.pdb index 0b5bc7f..39b1cbd 100644 Binary files a/CreoPluging9.0/x64/Debug/vc143.pdb and b/CreoPluging9.0/x64/Debug/vc143.pdb differ diff --git a/Shrinkwrap90Manager.cpp b/Shrinkwrap90Manager.cpp index 2909785..fbb3645 100644 --- a/Shrinkwrap90Manager.cpp +++ b/Shrinkwrap90Manager.cpp @@ -9,6 +9,8 @@ #include #include #include +#include +#include namespace { @@ -52,17 +54,47 @@ ShrinkwrapShellResult Shrinkwrap90Manager::ExportShell(const ShrinkwrapShellRequ pfcPart_ptr outputPart = session->CreatePart(modelName.c_str()); pfcModel_ptr outputModel = pfcModel::cast(outputPart); - pfcShrinkwrapMergedSolidInstructions_ptr instr = pfcShrinkwrapMergedSolidInstructions::Create(outputModel); + + pfcShrinkwrapModelExportInstructions_ptr modelInstr; - instr->SetQuality(req.quality); - instr->SetAutoHoleFilling(req.fill_holes ? xtrue : xfalse); - instr->SetIgnoreSmallSurfaces(req.ignore_small_surfaces ? xtrue : xfalse); - instr->SetSmallSurfPercentage(req.small_surface_percentage); - instr->SetIgnoreQuilts(req.ignore_quilts ? xtrue : xfalse); - instr->SetIgnoreSkeleton(req.ignore_skeleton ? xtrue : xfalse); - instr->SetAssignMassProperties(req.assign_mass_properties ? xtrue : xfalse); + if (req.method == 1) { + // Faceted Solid + // Note: Faceted Solid export is handled via pfcShrinkwrapFacetedPartInstructions + // But user wants "Faceted Solid" creation which usually creates a new model (like Merged Solid). + // However, OTK distinguishes between "Export to file" (STL/VRML/FacetedPart) and "Create feature/model". + // pfcShrinkwrapMergedSolidInstructions creates a new model. + // pfcShrinkwrapSurfaceSubsetInstructions creates a new model. + // pfcShrinkwrapFacetedPartInstructions exports to a file directly OR creates a model? + // Let's check pfcShrinkwrapFacetedPartInstructions::Create signature. + // Create(pfcModel_ptr OutputModel, xbool Lightweight) + // So it exports to 'OutputModel'. + + pfcShrinkwrapFacetedPartInstructions_ptr fInstr = pfcShrinkwrapFacetedPartInstructions::Create(outputModel, xfalse); + modelInstr = pfcShrinkwrapModelExportInstructions::cast(fInstr); - pfcShrinkwrapExportInstructions_ptr exportInstr = pfcShrinkwrapExportInstructions::cast(instr); + } else if (req.method == 2) { + // Merged Solid + pfcShrinkwrapMergedSolidInstructions_ptr mInstr = pfcShrinkwrapMergedSolidInstructions::Create(outputModel); + modelInstr = pfcShrinkwrapModelExportInstructions::cast(mInstr); + + } else { + // Surface Subset (Default = 0) + pfcShrinkwrapSurfaceSubsetInstructions_ptr sInstr = pfcShrinkwrapSurfaceSubsetInstructions::Create(outputModel); + modelInstr = pfcShrinkwrapModelExportInstructions::cast(sInstr); + } + + // Common options + modelInstr->SetQuality(req.quality); + modelInstr->SetAutoHoleFilling(req.fill_holes ? xtrue : xfalse); + modelInstr->SetIgnoreSmallSurfaces(req.ignore_small_surfaces ? xtrue : xfalse); + if (req.ignore_small_surfaces) { + modelInstr->SetSmallSurfPercentage(req.small_surface_percentage); + } + modelInstr->SetIgnoreQuilts(req.ignore_quilts ? xtrue : xfalse); + modelInstr->SetIgnoreSkeleton(req.ignore_skeleton ? xtrue : xfalse); + modelInstr->SetAssignMassProperties(req.assign_mass_properties ? xtrue : xfalse); + + pfcShrinkwrapExportInstructions_ptr exportInstr = pfcShrinkwrapExportInstructions::cast(modelInstr); source->ExportShrinkwrap(exportInstr); std::string dir = outPath.parent_path().string(); @@ -71,10 +103,21 @@ ShrinkwrapShellResult Shrinkwrap90Manager::ExportShell(const ShrinkwrapShellRequ outputPart->Backup(descr); std::filesystem::path actualOutPath = outPath.parent_path() / (modelName + ".prt"); + + // Ensure file is written + std::this_thread::sleep_for(std::chrono::milliseconds(200)); + ShrinkwrapShellResult res; res.output_path = actualOutPath.string(); std::error_code ec; uintmax_t bytes = std::filesystem::file_size(actualOutPath, ec); + + if (ec || bytes == 0) { + // Retry + std::this_thread::sleep_for(std::chrono::milliseconds(500)); + bytes = std::filesystem::file_size(actualOutPath, ec); + } + if (ec) bytes = 0; res.file_size = FormatFileSize(bytes); res.execution_time = ""; // 由上层填充 diff --git a/ShrinkwrapCommand.cpp b/ShrinkwrapCommand.cpp index 354415b..72e2487 100644 --- a/ShrinkwrapCommand.cpp +++ b/ShrinkwrapCommand.cpp @@ -3,6 +3,7 @@ #include "ShrinkwrapCommand.h" #include "Creo90Manager.h" #include "Shrinkwrap90Manager.h" +#include "ShrinkwrapDialog.h" #include "CreoOtk.h" @@ -66,18 +67,36 @@ void ShrinkwrapActionListener::OnCommand() { return; } - std::string outPath = PromptForOutputPath(session); - if (outPath.empty()) { - return; - } - ShrinkwrapShellRequest req; - req.output_file_path = outPath; req.quality = 5; req.ignore_quilts = true; req.ignore_skeleton = true; req.assign_mass_properties = false; + // Show configuration dialog first + if (!ShrinkwrapDialog::Show(req)) { + return; // User cancelled + } + + std::ostringstream debugOss; + const char* methodNames[] = { "Surface Subset", "Faceted Solid", "Merged Solid" }; + int mIdx = (req.method >= 0 && req.method <= 2) ? req.method : 0; + + debugOss << "Parameters Applied:\n" + << "Method: " << methodNames[mIdx] << "\n" + << "Quality: " << req.quality << "\n" + << "Fill Holes: " << (req.fill_holes ? "Yes" : "No") << "\n" + << "Ignore Quilts: " << (req.ignore_quilts ? "Yes" : "No") << "\n" + << "Ignore Skeleton: " << (req.ignore_skeleton ? "Yes" : "No") << "\n" + << "Ignore Small: " << (req.ignore_small_surfaces ? "Yes" : "No"); + ShowMessage(session, debugOss.str()); + + std::string outPath = PromptForOutputPath(session); + if (outPath.empty()) { + return; + } + req.output_file_path = outPath; + auto start = std::chrono::steady_clock::now(); Shrinkwrap90Manager mgr; ShrinkwrapShellResult result = mgr.ExportShell(req); diff --git a/ShrinkwrapDialog.cpp b/ShrinkwrapDialog.cpp new file mode 100644 index 0000000..5e88ec9 --- /dev/null +++ b/ShrinkwrapDialog.cpp @@ -0,0 +1,232 @@ +#include "pch.h" +#include "ShrinkwrapDialog.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +xstring ShrinkwrapDialog::DIALOG_NAME = "shrinkwrap_params"; + +class ShrinkwrapDialog::DialogListener : public uifcDefaultDialogListener { +public: + // This listener handles generic dialog events if needed. + // For now we just implement it to satisfy the requirements if attached. +}; + +class ShrinkwrapDialog::SliderListener : public uifcDefaultSliderListener { +public: + void OnChange(uifcSlider_ptr handle) override { + OnDragMove(handle); // Re-use logic + } + + void OnDragMove(uifcSlider_ptr handle) override { + try { + int val = handle->GetIntegerValue(); // uifcSlider inherits GetIntegerValue + uifcLabel_ptr lbl = uifcLabelFind(ShrinkwrapDialog::DIALOG_NAME, "quality_val_lbl"); + if (lbl) { + std::stringstream ss; + ss << val; + lbl->SetText(ss.str().c_str()); + } + } catch (...) {} + } +}; + +class ShrinkwrapDialog::CheckButtonListener : public uifcDefaultCheckButtonListener { +public: + void OnActivate(uifcCheckButton_ptr handle) override { + try { + uifcCheckState state = handle->GetCheckedState(); + bool checked = (state == uifcCHECK_STATE_SET); + uifcInputPanel_ptr ip = uifcInputPanelFind(ShrinkwrapDialog::DIALOG_NAME, "small_surf_pct_ip"); + if (ip) { + // uifcInputPanel inherits uifcComponent which has SetEnabled + // Let's check uifcComponent methods or if it's SetEnabled vs SetEnable + // uifcSlider.h shows SetEnabled(xbool). Let's assume InputPanel has it too via Component. + // The error "SetEnable is not a member" suggests it's likely SetEnabled. + ip->SetEnabled(checked); + } + } catch (...) {} + } +}; + +// ... ButtonListener removed as we use specific listeners below ... + +class OKButtonListener : public uifcDefaultPushButtonListener { +public: + OKButtonListener(bool& res) : result(res) {} + void OnActivate(uifcPushButton_ptr handle) override { + result = true; + uifcExitDialog(handle->GetDialog(), 0); + } +private: + bool& result; +}; + +class CancelButtonListener : public uifcDefaultPushButtonListener { +public: + void OnActivate(uifcPushButton_ptr handle) override { + uifcExitDialog(handle->GetDialog(), 0); + } +}; + +class QualitySliderListener : public uifcDefaultSliderListener { +public: + void OnDragMove(uifcSlider_ptr handle) override { + UpdateLabel(handle); + } + void OnChange(uifcSlider_ptr handle) override { + UpdateLabel(handle); + } + +private: + void UpdateLabel(uifcSlider_ptr handle) { + try { + int val = handle->GetIntegerValue(); // Use GetIntegerValue + uifcLabel_ptr lbl = uifcLabelFind(handle->GetDialog(), "quality_val_lbl"); + if (lbl) { + std::stringstream ss; + ss << val; + lbl->SetText(ss.str().c_str()); + } + } catch (...) {} + } +}; + +class SmallSurfCheckListener : public uifcDefaultCheckButtonListener { +public: + void OnActivate(uifcCheckButton_ptr handle) override { + try { + uifcCheckState state = handle->GetCheckedState(); + bool checked = (state == uifcCHECK_STATE_SET); + uifcInputPanel_ptr ip = uifcInputPanelFind(handle->GetDialog(), "small_surf_pct_ip"); + if (ip) ip->SetEnabled(checked); // Use SetEnabled + } catch (...) {} + } +}; + +void ShrinkwrapDialog::InitValues(const ShrinkwrapShellRequest& request) { + try { + uifcRadioGroup_ptr methodRg = uifcRadioGroupFind(DIALOG_NAME, "method_rg"); + if (methodRg) { + xstringsequence_ptr sel = xstringsequence::create(); + std::stringstream ss; + ss << request.method; + sel->append(ss.str().c_str()); + methodRg->SetSelectedItemNameArray(sel); // SetSelectedItemNameArray + } + + uifcCheckButtonFind(DIALOG_NAME, "fill_holes_cb")->SetCheckedState(request.fill_holes ? uifcCHECK_STATE_SET : uifcCHECK_STATE_UNSET); + uifcCheckButtonFind(DIALOG_NAME, "ignore_quilts_cb")->SetCheckedState(request.ignore_quilts ? uifcCHECK_STATE_SET : uifcCHECK_STATE_UNSET); + uifcCheckButtonFind(DIALOG_NAME, "ignore_skeleton_cb")->SetCheckedState(request.ignore_skeleton ? uifcCHECK_STATE_SET : uifcCHECK_STATE_UNSET); + uifcCheckButtonFind(DIALOG_NAME, "assign_mass_cb")->SetCheckedState(request.assign_mass_properties ? uifcCHECK_STATE_SET : uifcCHECK_STATE_UNSET); + + uifcCheckButton_ptr smallCb = uifcCheckButtonFind(DIALOG_NAME, "ignore_small_cb"); + smallCb->SetCheckedState(request.ignore_small_surfaces ? uifcCHECK_STATE_SET : uifcCHECK_STATE_UNSET); + + uifcInputPanel_ptr smallIp = uifcInputPanelFind(DIALOG_NAME, "small_surf_pct_ip"); + smallIp->SetDoubleValue(request.small_surface_percentage); + smallIp->SetEnabled(request.ignore_small_surfaces); + + uifcSlider_ptr slider = uifcSliderFind(DIALOG_NAME, "quality_slider"); + slider->SetMinimumIntegerValue(1); + slider->SetMaximumIntegerValue(10); + slider->SetIntegerValue(request.quality); // SetIntegerValue + + uifcLabel_ptr qLbl = uifcLabelFind(DIALOG_NAME, "quality_val_lbl"); + std::stringstream ss; + ss << request.quality; + qLbl->SetText(ss.str().c_str()); + + } catch (...) {} +} + +void ShrinkwrapDialog::UpdateRequest(ShrinkwrapShellRequest& request) { + try { + uifcRadioGroup_ptr methodRg = uifcRadioGroupFind(DIALOG_NAME, "method_rg"); + if (methodRg) { + xstringsequence_ptr sel = methodRg->GetSelectedItemNameArray(); // GetSelectedItemNameArray + if (sel && sel->getarraysize() > 0) { + std::string s = (const char*)sel->get(0); + try { + request.method = std::stoi(s); + } catch (...) {} + } + } + + request.fill_holes = (uifcCheckButtonFind(DIALOG_NAME, "fill_holes_cb")->GetCheckedState() == uifcCHECK_STATE_SET); + request.ignore_quilts = (uifcCheckButtonFind(DIALOG_NAME, "ignore_quilts_cb")->GetCheckedState() == uifcCHECK_STATE_SET); + request.ignore_skeleton = (uifcCheckButtonFind(DIALOG_NAME, "ignore_skeleton_cb")->GetCheckedState() == uifcCHECK_STATE_SET); + request.assign_mass_properties = (uifcCheckButtonFind(DIALOG_NAME, "assign_mass_cb")->GetCheckedState() == uifcCHECK_STATE_SET); + + request.ignore_small_surfaces = (uifcCheckButtonFind(DIALOG_NAME, "ignore_small_cb")->GetCheckedState() == uifcCHECK_STATE_SET); + if (request.ignore_small_surfaces) { + request.small_surface_percentage = uifcInputPanelFind(DIALOG_NAME, "small_surf_pct_ip")->GetDoubleValue(); + } + + request.quality = uifcSliderFind(DIALOG_NAME, "quality_slider")->GetIntegerValue(); + } catch (...) {} +} + + +bool ShrinkwrapDialog::Show(ShrinkwrapShellRequest& request) { + bool isOk = false; + + // Debug point 1: Confirm entry + /* + pfcSession_ptr session = pfcGetProESession(); + if (session) session->UIShowMessageDialog("Entering ShrinkwrapDialog::Show", NULL); + */ + + try { + int status = uifcCreateDialog(DIALOG_NAME, DIALOG_NAME); + if (status != 0) { + // Debug point 2: Creation failed (if status implies failure, though uifc usually throws) + } + + InitValues(request); + + uifcPushButtonFind(DIALOG_NAME, "ok_pb")->AddActionListener(new OKButtonListener(isOk)); + uifcPushButtonFind(DIALOG_NAME, "cancel_pb")->AddActionListener(new CancelButtonListener()); + uifcSliderFind(DIALOG_NAME, "quality_slider")->AddActionListener(new QualitySliderListener()); + uifcCheckButtonFind(DIALOG_NAME, "ignore_small_cb")->AddActionListener(new SmallSurfCheckListener()); + + uifcActivateDialog(DIALOG_NAME); + + if (isOk) { + UpdateRequest(request); + } + + uifcDestroyDialog(DIALOG_NAME); + } catch (pfcXToolkitError& e) { + // Log OTK errors or show a message + pfcSession_ptr session = pfcGetProESession(); + if (session) { + xstring msg = e.GetMessage(); + std::stringstream ss; + ss << "OTK Error: " << msg; + session->UIShowMessageDialog(ss.str().c_str(), NULL); + } + try { + uifcDestroyDialog(DIALOG_NAME); + } catch (...) {} + return false; + } catch (...) { + pfcSession_ptr session = pfcGetProESession(); + if (session) { + session->UIShowMessageDialog("Unknown exception in dialog creation", NULL); + } + try { + uifcDestroyDialog(DIALOG_NAME); + } catch (...) {} + return false; + } + return isOk; +} diff --git a/ShrinkwrapDialog.h b/ShrinkwrapDialog.h new file mode 100644 index 0000000..a94fac0 --- /dev/null +++ b/ShrinkwrapDialog.h @@ -0,0 +1,20 @@ +#pragma once + +#include "ShrinkwrapTypes.h" +#include "CreoOtk.h" +#include + +class ShrinkwrapDialog { +public: + static xstring DIALOG_NAME; + static bool Show(ShrinkwrapShellRequest& request); + +private: + class DialogListener; + class SliderListener; + class ButtonListener; + class CheckButtonListener; + + static void InitValues(const ShrinkwrapShellRequest& request); + static void UpdateRequest(ShrinkwrapShellRequest& request); +}; diff --git a/ShrinkwrapTypes.h b/ShrinkwrapTypes.h index 82e71d9..593b94e 100644 --- a/ShrinkwrapTypes.h +++ b/ShrinkwrapTypes.h @@ -4,6 +4,7 @@ struct ShrinkwrapShellRequest { std::string software_type = "creo"; + int method = 0; // 0=Surface Subset, 1=Faceted Solid, 2=Merged Solid int quality = 5; // 1-10 double chord_height = 0.1; // 当前版本不映射到 OTK Shrinkwrap bool fill_holes = false; diff --git a/text/chinese_cn/resource/shrinkwrap_params.res b/text/chinese_cn/resource/shrinkwrap_params.res new file mode 100644 index 0000000..4ce6c4e --- /dev/null +++ b/text/chinese_cn/resource/shrinkwrap_params.res @@ -0,0 +1,153 @@ +(Dialog shrinkwrap_params + (Components + (SubLayout method_lay) + (SubLayout options_lay) + (SubLayout quality_lay) + (SubLayout control_lay) + (Separator separator) + ) + + (Resources + (.Label "Light Export Parameters") + (.Resizeable False) + (.DefaultButton "ok_pb") + (.Layout + (Grid (Rows 1 1 0 1 0) (Cols 1) + method_lay + options_lay + quality_lay + separator + control_lay + ) + ) + ) +) + +(Layout method_lay + (Components + (RadioGroup method_rg) + ) + + (Resources + (method_rg.Names "0" + "1" + "2") + (method_rg.Labels "Surface Subset" + "Faceted Solid" + "Merged Solid") + (method_rg.Orientation 1) ! Vertical + (.Label "Creation Method") + (.Decorated True) + (.AttachLeft True) + (.AttachRight True) + (.Layout + (Grid (Rows 1) (Cols 1) + method_rg + ) + ) + ) +) + +(Layout options_lay + (Components + (CheckButton fill_holes_cb) + (CheckButton ignore_quilts_cb) + (CheckButton ignore_skeleton_cb) + (CheckButton assign_mass_cb) + (CheckButton ignore_small_cb) + (InputPanel small_surf_pct_ip) + (Label small_surf_pct_lbl) + ) + + (Resources + (fill_holes_cb.Label "Fill holes") + (fill_holes_cb.AttachLeft True) + (ignore_quilts_cb.Label "Ignore quilts") + (ignore_quilts_cb.AttachLeft True) + (ignore_skeleton_cb.Label "Ignore skeleton") + (ignore_skeleton_cb.AttachLeft True) + (assign_mass_cb.Label "Assign mass properties") + (assign_mass_cb.AttachLeft True) + (ignore_small_cb.Label "Ignore small surfaces") + (ignore_small_cb.AttachLeft True) + (small_surf_pct_lbl.Label "% of model size") + (small_surf_pct_lbl.AttachLeft True) + (small_surf_pct_ip.Columns 5) + (small_surf_pct_ip.InputType 4) ! Real number + (small_surf_pct_ip.MinVal 0.0) + (small_surf_pct_ip.MaxVal 100.0) + + (.Label "Options") + (.Decorated True) + (.AttachLeft True) + (.AttachRight True) + (.Layout + (Grid (Rows 1 1 1 1 1) (Cols 1 1) + fill_holes_cb + ignore_quilts_cb + ignore_skeleton_cb + assign_mass_cb + ignore_small_cb + (Grid (Rows 1) (Cols 1 1) + small_surf_pct_ip + small_surf_pct_lbl + ) + ) + ) + ) +) + +(Layout quality_lay + (Components + (Label quality_lbl) + (Slider quality_slider) + (Label quality_val_lbl) + ) + + (Resources + (quality_lbl.Label "Quality Level:") + (quality_lbl.AttachLeft True) + (quality_slider.MinVal 1) + (quality_slider.MaxVal 10) + (quality_slider.Columns 15) + (quality_val_lbl.Label "5") + (quality_val_lbl.Columns 2) + + (.Label "Output Quality") + (.Decorated True) + (.AttachLeft True) + (.AttachRight True) + (.Layout + (Grid (Rows 1) (Cols 1 1 1) + quality_lbl + quality_slider + quality_val_lbl + ) + ) + ) +) + +(Layout control_lay + (Components + (PushButton ok_pb) + (PushButton cancel_pb) + ) + + (Resources + (ok_pb.Label "OK") + (ok_pb.Columns 6) + (cancel_pb.Label "Cancel") + (cancel_pb.Columns 6) + + (.AttachRight True) + (.TopOffset 5) + (.BottomOffset 5) + (.RightOffset 5) + (.Layout + (Grid (Rows 1) (Cols 1 1) + ok_pb + cancel_pb + ) + ) + ) +) diff --git a/text/chinese_cn/shrinkwrap_msg.txt b/text/chinese_cn/shrinkwrap_msg.txt new file mode 100644 index 0000000..07f7b4a --- /dev/null +++ b/text/chinese_cn/shrinkwrap_msg.txt @@ -0,0 +1,12 @@ +LightExport +LightExport +# +# +LightExport Help +LightExport Help +# +# +LightExport Description +LightExport Description +# +# diff --git a/text/usascii/resource/shrinkwrap_params.res b/text/usascii/resource/shrinkwrap_params.res new file mode 100644 index 0000000..4ce6c4e --- /dev/null +++ b/text/usascii/resource/shrinkwrap_params.res @@ -0,0 +1,153 @@ +(Dialog shrinkwrap_params + (Components + (SubLayout method_lay) + (SubLayout options_lay) + (SubLayout quality_lay) + (SubLayout control_lay) + (Separator separator) + ) + + (Resources + (.Label "Light Export Parameters") + (.Resizeable False) + (.DefaultButton "ok_pb") + (.Layout + (Grid (Rows 1 1 0 1 0) (Cols 1) + method_lay + options_lay + quality_lay + separator + control_lay + ) + ) + ) +) + +(Layout method_lay + (Components + (RadioGroup method_rg) + ) + + (Resources + (method_rg.Names "0" + "1" + "2") + (method_rg.Labels "Surface Subset" + "Faceted Solid" + "Merged Solid") + (method_rg.Orientation 1) ! Vertical + (.Label "Creation Method") + (.Decorated True) + (.AttachLeft True) + (.AttachRight True) + (.Layout + (Grid (Rows 1) (Cols 1) + method_rg + ) + ) + ) +) + +(Layout options_lay + (Components + (CheckButton fill_holes_cb) + (CheckButton ignore_quilts_cb) + (CheckButton ignore_skeleton_cb) + (CheckButton assign_mass_cb) + (CheckButton ignore_small_cb) + (InputPanel small_surf_pct_ip) + (Label small_surf_pct_lbl) + ) + + (Resources + (fill_holes_cb.Label "Fill holes") + (fill_holes_cb.AttachLeft True) + (ignore_quilts_cb.Label "Ignore quilts") + (ignore_quilts_cb.AttachLeft True) + (ignore_skeleton_cb.Label "Ignore skeleton") + (ignore_skeleton_cb.AttachLeft True) + (assign_mass_cb.Label "Assign mass properties") + (assign_mass_cb.AttachLeft True) + (ignore_small_cb.Label "Ignore small surfaces") + (ignore_small_cb.AttachLeft True) + (small_surf_pct_lbl.Label "% of model size") + (small_surf_pct_lbl.AttachLeft True) + (small_surf_pct_ip.Columns 5) + (small_surf_pct_ip.InputType 4) ! Real number + (small_surf_pct_ip.MinVal 0.0) + (small_surf_pct_ip.MaxVal 100.0) + + (.Label "Options") + (.Decorated True) + (.AttachLeft True) + (.AttachRight True) + (.Layout + (Grid (Rows 1 1 1 1 1) (Cols 1 1) + fill_holes_cb + ignore_quilts_cb + ignore_skeleton_cb + assign_mass_cb + ignore_small_cb + (Grid (Rows 1) (Cols 1 1) + small_surf_pct_ip + small_surf_pct_lbl + ) + ) + ) + ) +) + +(Layout quality_lay + (Components + (Label quality_lbl) + (Slider quality_slider) + (Label quality_val_lbl) + ) + + (Resources + (quality_lbl.Label "Quality Level:") + (quality_lbl.AttachLeft True) + (quality_slider.MinVal 1) + (quality_slider.MaxVal 10) + (quality_slider.Columns 15) + (quality_val_lbl.Label "5") + (quality_val_lbl.Columns 2) + + (.Label "Output Quality") + (.Decorated True) + (.AttachLeft True) + (.AttachRight True) + (.Layout + (Grid (Rows 1) (Cols 1 1 1) + quality_lbl + quality_slider + quality_val_lbl + ) + ) + ) +) + +(Layout control_lay + (Components + (PushButton ok_pb) + (PushButton cancel_pb) + ) + + (Resources + (ok_pb.Label "OK") + (ok_pb.Columns 6) + (cancel_pb.Label "Cancel") + (cancel_pb.Columns 6) + + (.AttachRight True) + (.TopOffset 5) + (.BottomOffset 5) + (.RightOffset 5) + (.Layout + (Grid (Rows 1) (Cols 1 1) + ok_pb + cancel_pb + ) + ) + ) +) diff --git a/x64/Debug/CreoPluging9.0.dll b/x64/Debug/CreoPluging9.0.dll index 6c84d94..4a34520 100644 Binary files a/x64/Debug/CreoPluging9.0.dll and b/x64/Debug/CreoPluging9.0.dll differ diff --git a/x64/Debug/CreoPluging9.0.lib b/x64/Debug/CreoPluging9.0.lib index bb0a325..d9e5b5e 100644 Binary files a/x64/Debug/CreoPluging9.0.lib and b/x64/Debug/CreoPluging9.0.lib differ diff --git a/x64/Debug/CreoPluging9.0.pdb b/x64/Debug/CreoPluging9.0.pdb index 77b2060..f8848d1 100644 Binary files a/x64/Debug/CreoPluging9.0.pdb and b/x64/Debug/CreoPluging9.0.pdb differ