Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sketcher] Fixing some issues with "Convert to NURBS" #6403

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 24 additions & 18 deletions src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp
Expand Up @@ -407,23 +407,23 @@ bool CmdSketcherCompBSplineShowHideGeometryInformation::isActive(void)
}

// Convert to NURBS
DEF_STD_CMD_A(CmdSketcherConvertToNURB)
DEF_STD_CMD_A(CmdSketcherConvertToNURBS)

CmdSketcherConvertToNURB::CmdSketcherConvertToNURB()
: Command("Sketcher_BSplineConvertToNURB")
CmdSketcherConvertToNURBS::CmdSketcherConvertToNURBS()
: Command("Sketcher_BSplineConvertToNURBS")
{
sAppModule = "Sketcher";
sGroup = "Sketcher";
sMenuText = QT_TR_NOOP("Convert geometry to B-spline");
sToolTipText = QT_TR_NOOP("Converts the selected geometry to a B-spline");
sWhatsThis = "Sketcher_BSplineConvertToNURB";
sWhatsThis = "Sketcher_BSplineConvertToNURBS";
sStatusTip = sToolTipText;
sPixmap = "Sketcher_BSplineApproximate";
sAccel = "";
eType = ForEdit;
}

void CmdSketcherConvertToNURB::activated(int iMsg)
void CmdSketcherConvertToNURBS::activated(int iMsg)
{
Q_UNUSED(iMsg);

Expand All @@ -444,20 +444,26 @@ void CmdSketcherConvertToNURB::activated(int iMsg)

openCommand(QT_TRANSLATE_NOOP("Command", "Convert to NURBS"));

for (size_t i=0; i < SubNames.size(); i++) {
std::vector<int> GeoIdList;

for (auto subName : SubNames) {
AjinkyaDahale marked this conversation as resolved.
Show resolved Hide resolved
// only handle edges
if (SubNames[i].size() > 4 && SubNames[i].substr(0,4) == "Edge") {
int GeoId = std::atoi(SubNames[i].substr(4,4000).c_str()) - 1;
Gui::cmdAppObjectArgs(selection[0].getObject(), "convertToNURBS(%d) ", GeoId);
nurbsized = true;
}
else if (SubNames[i].size() > 12 && SubNames[i].substr(0,12) == "ExternalEdge") {
int GeoId = - (std::atoi(SubNames[i].substr(12,4000).c_str()) + 2);
Gui::cmdAppObjectArgs(selection[0].getObject(), "convertToNURBS(%d) ", GeoId);
nurbsized = true;
}
int GeoId;
if (subName.size() > 4 && subName.substr(0,4) == "Edge")
GeoId = std::atoi(subName.substr(4,4000).c_str()) - 1;
else if (subName.size() > 12 && subName.substr(0,12) == "ExternalEdge")
GeoId = - (std::atoi(subName.substr(12,4000).c_str()) + 2);
else
continue;
Gui::cmdAppObjectArgs(selection[0].getObject(), "convertToNURBS(%d) ", GeoId);
GeoIdList.push_back(GeoId);
nurbsized = true;
}

// for creating the poles and knots
for (const auto& GeoId : GeoIdList)
Gui::cmdAppObjectArgs(selection[0].getObject(), "exposeInternalGeometry(%d)", GeoId);

if (!nurbsized) {
abortCommand();
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
Expand All @@ -469,7 +475,7 @@ void CmdSketcherConvertToNURB::activated(int iMsg)
tryAutoRecomputeIfNotSolve(Obj);
}

bool CmdSketcherConvertToNURB::isActive(void)
bool CmdSketcherConvertToNURBS::isActive(void)
{
return isSketcherBSplineActive(getActiveGuiDocument(), true);
}
Expand Down Expand Up @@ -1220,7 +1226,7 @@ void CreateSketcherCommandsBSpline(void)
rcCmdMgr.addCommand(new CmdSketcherBSplineKnotMultiplicity());
rcCmdMgr.addCommand(new CmdSketcherBSplinePoleWeight());
rcCmdMgr.addCommand(new CmdSketcherCompBSplineShowHideGeometryInformation());
rcCmdMgr.addCommand(new CmdSketcherConvertToNURB());
rcCmdMgr.addCommand(new CmdSketcherConvertToNURBS());
rcCmdMgr.addCommand(new CmdSketcherIncreaseDegree());
rcCmdMgr.addCommand(new CmdSketcherDecreaseDegree());
rcCmdMgr.addCommand(new CmdSketcherIncreaseKnotMultiplicity());
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Sketcher/Gui/Resources/translations/Sketcher.ts
Expand Up @@ -688,7 +688,7 @@ with respect to a line or a third point</source>
</message>
</context>
<context>
<name>CmdSketcherConvertToNURB</name>
<name>CmdSketcherConvertToNURBS</name>
<message>
<location filename="../../CommandSketcherBSpline.cpp" line="385"/>
<source>Convert geometry to B-spline</source>
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Sketcher/Gui/Workbench.cpp
Expand Up @@ -408,7 +408,7 @@ inline void SketcherAddWorkbenchBSplines<Gui::MenuItem>(Gui::MenuItem& bspline)
<< "Sketcher_BSplineComb"
<< "Sketcher_BSplineKnotMultiplicity"
<< "Sketcher_BSplinePoleWeight"
<< "Sketcher_BSplineConvertToNURB"
<< "Sketcher_BSplineConvertToNURBS"
<< "Sketcher_BSplineIncreaseDegree"
<< "Sketcher_BSplineDecreaseDegree"
<< "Sketcher_BSplineIncreaseKnotMultiplicity"
Expand All @@ -420,7 +420,7 @@ template <>
inline void SketcherAddWorkbenchBSplines<Gui::ToolBarItem>(Gui::ToolBarItem& bspline)
{
bspline << "Sketcher_CompBSplineShowHideGeometryInformation"
<< "Sketcher_BSplineConvertToNURB"
<< "Sketcher_BSplineConvertToNURBS"
<< "Sketcher_BSplineIncreaseDegree"
<< "Sketcher_BSplineDecreaseDegree"
<< "Sketcher_CompModifyKnotMultiplicity"
Expand Down