| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | #include <QApplication>
|
| | #include <QMessageBox>
|
| | #include <sstream>
|
| |
|
| | #include <BRepAdaptor_Curve.hxx>
|
| | #include <GeomAPI_ProjectPointOnCurve.hxx>
|
| | #include <TopoDS_Edge.hxx>
|
| | #include <TopoDS_Shape.hxx>
|
| |
|
| | #include "Mod/Part/App/PartFeature.h"
|
| | #include <App/Document.h>
|
| | #include <Gui/Application.h>
|
| | #include <Gui/Command.h>
|
| | #include <Gui/Control.h>
|
| | #include <Gui/MainWindow.h>
|
| | #include <Gui/Selection/SelectionFilter.h>
|
| | #include <Gui/Selection/SelectionObject.h>
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | DEF_STD_CMD(CmdSurfaceCut)
|
| |
|
| | CmdSurfaceCut::CmdSurfaceCut()
|
| | : Command("Surface_Cut")
|
| | {
|
| | sAppModule = "Surface";
|
| | sGroup = QT_TR_NOOP("Surface");
|
| | sMenuText = QT_TR_NOOP("Surface Cut");
|
| | sToolTipText = QT_TR_NOOP("Cuts one shape using another");
|
| | sWhatsThis = "Surface_Cut";
|
| | sStatusTip = sToolTipText;
|
| | sPixmap = "Surface_Cut";
|
| |
|
| | }
|
| |
|
| | void CmdSurfaceCut::activated(int iMsg)
|
| | {
|
| | Q_UNUSED(iMsg);
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | }
|
| |
|
| |
|
| | DEF_STD_CMD_A(CmdSurfaceFilling)
|
| |
|
| | CmdSurfaceFilling::CmdSurfaceFilling()
|
| | : Command("Surface_Filling")
|
| | {
|
| | sAppModule = "Surface";
|
| | sGroup = QT_TR_NOOP("Surface");
|
| | sMenuText = QT_TR_NOOP("Filling");
|
| | sToolTipText = QT_TR_NOOP(
|
| | "Creates a surface from a series of selected boundary edges.\n"
|
| | "Additionally, the surface may be constrained by edges and\n"
|
| | "vertices that are not on the boundary."
|
| | );
|
| | sStatusTip = sToolTipText;
|
| | sWhatsThis = "Surface_Filling";
|
| | sPixmap = "Surface_Filling";
|
| | }
|
| |
|
| | void CmdSurfaceFilling::activated(int iMsg)
|
| | {
|
| | Q_UNUSED(iMsg);
|
| | std::string FeatName = getUniqueObjectName("Surface");
|
| |
|
| | openCommand(QT_TRANSLATE_NOOP("Command", "Create surface"));
|
| | doCommand(Doc, "App.ActiveDocument.addObject(\"Surface::Filling\",\"%s\")", FeatName.c_str());
|
| | doCommand(Doc, "Gui.ActiveDocument.setEdit('%s',0)", FeatName.c_str());
|
| | }
|
| |
|
| | bool CmdSurfaceFilling::isActive()
|
| | {
|
| | return hasActiveDocument();
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| | DEF_STD_CMD_A(CmdSurfaceGeomFillSurface)
|
| |
|
| | CmdSurfaceGeomFillSurface::CmdSurfaceGeomFillSurface()
|
| | : Command("Surface_GeomFillSurface")
|
| | {
|
| | sAppModule = "Surface";
|
| | sGroup = QT_TR_NOOP("Surface");
|
| | sMenuText = QT_TR_NOOP("Fill Boundary Curves");
|
| | sToolTipText = QT_TR_NOOP("Creates a surface from 2, 3, or 4 boundary edges");
|
| | sWhatsThis = "Surface_GeomFillSurface";
|
| | sStatusTip = sToolTipText;
|
| | sPixmap = "Surface_GeomFillSurface";
|
| | }
|
| |
|
| | bool CmdSurfaceGeomFillSurface::isActive()
|
| | {
|
| | return hasActiveDocument();
|
| | }
|
| |
|
| | void CmdSurfaceGeomFillSurface::activated(int iMsg)
|
| | {
|
| | Q_UNUSED(iMsg);
|
| | std::string FeatName = getUniqueObjectName("Surface");
|
| |
|
| | openCommand(QT_TRANSLATE_NOOP("Command", "Create surface"));
|
| | doCommand(Doc, "App.ActiveDocument.addObject(\"Surface::GeomFillSurface\",\"%s\")", FeatName.c_str());
|
| | doCommand(Doc, "Gui.ActiveDocument.setEdit('%s',0)", FeatName.c_str());
|
| | }
|
| |
|
| |
|
| | DEF_STD_CMD_A(CmdSurfaceCurveOnMesh)
|
| |
|
| | CmdSurfaceCurveOnMesh::CmdSurfaceCurveOnMesh()
|
| | : Command("Surface_CurveOnMesh")
|
| | {
|
| | sAppModule = "MeshPart";
|
| | sGroup = QT_TR_NOOP("Surface");
|
| | sMenuText = QT_TR_NOOP("Curve on Mesh");
|
| | sToolTipText = QT_TR_NOOP(
|
| | "Creates an approximated curve on top of a mesh.\n"
|
| | "This command only works with a mesh object."
|
| | );
|
| | sWhatsThis = "Surface_CurveOnMesh";
|
| | sStatusTip = sToolTipText;
|
| | sPixmap = "Surface_CurveOnMesh";
|
| | }
|
| |
|
| |
|
| | void CmdSurfaceCurveOnMesh::activated(int)
|
| | {
|
| | doCommand(
|
| | Doc,
|
| | "import MeshPartGui, FreeCADGui\n"
|
| | "FreeCADGui.runCommand('MeshPart_CurveOnMesh')\n"
|
| | );
|
| | }
|
| |
|
| | bool CmdSurfaceCurveOnMesh::isActive()
|
| | {
|
| | if (Gui::Control().activeDialog()) {
|
| | return false;
|
| | }
|
| |
|
| |
|
| | App::Document* doc = App::GetApplication().getActiveDocument();
|
| |
|
| | return doc && doc->countObjectsOfType("Mesh::Feature") > 0;
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| | DEF_STD_CMD_A(CmdBlendCurve)
|
| |
|
| | CmdBlendCurve::CmdBlendCurve()
|
| | : Command("Surface_BlendCurve")
|
| | {
|
| | sAppModule = "Surface";
|
| | sGroup = QT_TR_NOOP("Surface");
|
| | sMenuText = QT_TR_NOOP("Blend Curve");
|
| | sToolTipText = QT_TR_NOOP("Joins 2 edges with continuity");
|
| | sStatusTip = sToolTipText;
|
| | sWhatsThis = "BlendCurve";
|
| | sPixmap = "Surface_BlendCurve";
|
| | }
|
| |
|
| | void CmdBlendCurve::activated(int)
|
| | {
|
| | std::string docName = App::GetApplication().getActiveDocument()->getName();
|
| | std::string objName[2];
|
| | std::string edge[2];
|
| | std::string featName = getUniqueObjectName("BlendCurve");
|
| | std::vector<Gui::SelectionObject> sel
|
| | = getSelection().getSelectionEx(nullptr, Part::Feature::getClassTypeId());
|
| |
|
| | objName[0] = sel[0].getFeatName();
|
| | edge[0] = sel[0].getSubNames()[0];
|
| |
|
| | if (sel.size() == 1) {
|
| | objName[1] = sel[0].getFeatName();
|
| | edge[1] = sel[0].getSubNames()[1];
|
| | }
|
| | else {
|
| | objName[1] = sel[1].getFeatName();
|
| | edge[1] = sel[1].getSubNames()[0];
|
| | }
|
| | openCommand(QT_TRANSLATE_NOOP("Command", "Blend Curve"));
|
| | doCommand(
|
| | Doc,
|
| | "App.ActiveDocument.addObject(\"Surface::FeatureBlendCurve\",\"%s\")",
|
| | featName.c_str()
|
| | );
|
| | doCommand(
|
| | Doc,
|
| | "App.ActiveDocument.%s.StartEdge = (App.getDocument('%s').getObject('%s'),['%s'])",
|
| | featName.c_str(),
|
| | docName.c_str(),
|
| | objName[0].c_str(),
|
| | edge[0].c_str()
|
| | );
|
| | doCommand(
|
| | Doc,
|
| | "App.ActiveDocument.%s.EndEdge = (App.getDocument('%s').getObject('%s'),['%s'])",
|
| | featName.c_str(),
|
| | docName.c_str(),
|
| | objName[1].c_str(),
|
| | edge[1].c_str()
|
| | );
|
| | updateActive();
|
| | commitCommand();
|
| | }
|
| |
|
| | bool CmdBlendCurve::isActive()
|
| | {
|
| | Gui::SelectionFilter edgeFilter("SELECT Part::Feature SUBELEMENT Edge COUNT 2");
|
| | return edgeFilter.match();
|
| | }
|
| |
|
| | DEF_STD_CMD_A(CmdSurfaceExtendFace)
|
| |
|
| | CmdSurfaceExtendFace::CmdSurfaceExtendFace()
|
| | : Command("Surface_ExtendFace")
|
| | {
|
| | sAppModule = "Surface";
|
| | sGroup = QT_TR_NOOP("Surface");
|
| | sMenuText = QT_TR_NOOP("Extend Face");
|
| | sToolTipText = QT_TR_NOOP(
|
| | "Extrapolates the selected face or surface at its boundaries with "
|
| | "its local U and V parameters"
|
| | );
|
| | sWhatsThis = "Surface_ExtendFace";
|
| | sStatusTip = sToolTipText;
|
| | sPixmap = "Surface_ExtendFace";
|
| | }
|
| |
|
| | void CmdSurfaceExtendFace::activated(int)
|
| | {
|
| | Gui::SelectionFilter faceFilter("SELECT Part::Feature SUBELEMENT Face COUNT 1");
|
| | if (faceFilter.match()) {
|
| | const std::vector<std::string>& sub = faceFilter.Result[0][0].getSubNames();
|
| | if (sub.size() == 1) {
|
| | openCommand(QT_TRANSLATE_NOOP("Command", "Extend surface"));
|
| | std::string FeatName = getUniqueObjectName("Surface");
|
| | std::string supportString = faceFilter.Result[0][0].getAsPropertyLinkSubString();
|
| | doCommand(Doc, "App.ActiveDocument.addObject(\"Surface::Extend\",\"%s\")", FeatName.c_str());
|
| | doCommand(Doc, "App.ActiveDocument.%s.Face = %s", FeatName.c_str(), supportString.c_str());
|
| | updateActive();
|
| | commitCommand();
|
| | }
|
| | }
|
| | else {
|
| | QMessageBox::warning(
|
| | Gui::getMainWindow(),
|
| | qApp->translate("Surface_ExtendFace", "Wrong selection"),
|
| | qApp->translate("Surface_ExtendFace", "Select a single face")
|
| | );
|
| | }
|
| | }
|
| |
|
| | bool CmdSurfaceExtendFace::isActive()
|
| | {
|
| | return Gui::Selection().countObjectsOfType<Part::Feature>() == 1;
|
| | }
|
| |
|
| | DEF_STD_CMD_A(CmdSurfaceSections)
|
| |
|
| | CmdSurfaceSections::CmdSurfaceSections()
|
| | : Command("Surface_Sections")
|
| | {
|
| | sAppModule = "Surface";
|
| | sGroup = QT_TR_NOOP("Surface");
|
| | sMenuText = QT_TR_NOOP("Sections");
|
| | sToolTipText = QT_TR_NOOP("Creates a surface from a series of sectional edges");
|
| | sStatusTip = sToolTipText;
|
| | sWhatsThis = "Surface_Sections";
|
| | sPixmap = "Surface_Sections";
|
| | }
|
| |
|
| | void CmdSurfaceSections::activated(int iMsg)
|
| | {
|
| | Q_UNUSED(iMsg);
|
| | std::string FeatName = getUniqueObjectName("Surface");
|
| |
|
| | openCommand(QT_TRANSLATE_NOOP("Command", "Create surface"));
|
| | doCommand(Doc, "App.ActiveDocument.addObject(\"Surface::Sections\",\"%s\")", FeatName.c_str());
|
| | doCommand(Doc, "Gui.ActiveDocument.setEdit('%s',0)", FeatName.c_str());
|
| | }
|
| |
|
| | bool CmdSurfaceSections::isActive()
|
| | {
|
| | return hasActiveDocument();
|
| | }
|
| |
|
| | void CreateSurfaceCommands()
|
| | {
|
| | Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();
|
| | |
| | |
| |
|
| | rcCmdMgr.addCommand(new CmdSurfaceFilling());
|
| | rcCmdMgr.addCommand(new CmdSurfaceGeomFillSurface());
|
| | rcCmdMgr.addCommand(new CmdSurfaceSections());
|
| | rcCmdMgr.addCommand(new CmdSurfaceExtendFace());
|
| | rcCmdMgr.addCommand(new CmdSurfaceCurveOnMesh());
|
| | rcCmdMgr.addCommand(new CmdBlendCurve());
|
| | }
|
| |
|