Part: add datum objects and commands to create them.
This commit is contained in:
@@ -3,22 +3,21 @@
|
||||
* Copyright (c) 2015 Alexander Golubev (Fat-Zer) <fatzer2@gmail.com> *
|
||||
* Copyright (c) 2024 Ondsel (PL Boyer) <development@ondsel.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* FreeCAD is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
@@ -3,22 +3,21 @@
|
||||
* Copyright (c) 2015 Alexander Golubev (Fat-Zer) <fatzer2@gmail.com> *
|
||||
* Copyright (c) 2024 Ondsel (PL Boyer) <development@ondsel.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* FreeCAD is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
@@ -156,9 +156,9 @@ void StdCmdVarSet::activated(int iMsg)
|
||||
|
||||
// add the varset to a group if it is selected
|
||||
auto sels = Selection().getSelectionEx(nullptr, App::DocumentObject::getClassTypeId(),
|
||||
ResolveMode::OldStyleElement, true);
|
||||
ResolveMode::OldStyleElement, true);
|
||||
if (sels.size() == 1) {
|
||||
App::DocumentObject *obj = sels[0].getObject();
|
||||
App::DocumentObject* obj = sels[0].getObject();
|
||||
auto group = obj->getExtension<App::GroupExtension>();
|
||||
if (group) {
|
||||
Gui::Document* docGui = Application::Instance->activeDocument();
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
#include "ConicPy.h"
|
||||
#include "CustomFeature.h"
|
||||
#include "CylinderPy.h"
|
||||
#include "Datums.h"
|
||||
#include "DatumFeature.h"
|
||||
#include "EllipsePy.h"
|
||||
#include "FaceMaker.h"
|
||||
@@ -534,6 +535,10 @@ PyMOD_INIT_FUNC(Part)
|
||||
Part::GeomSurfaceOfRevolution ::init();
|
||||
Part::GeomSurfaceOfExtrusion ::init();
|
||||
Part::Datum ::init();
|
||||
Part::DatumPlane ::init();
|
||||
Part::DatumLine ::init();
|
||||
Part::DatumPoint ::init();
|
||||
Part::LocalCoordinateSystem ::init();
|
||||
|
||||
// Geometry2d types
|
||||
Part::Geometry2d ::init();
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <Base/Placement.h>
|
||||
|
||||
#include "Attacher.h"
|
||||
#include "PartFeature.h"
|
||||
|
||||
|
||||
namespace Part
|
||||
|
||||
@@ -213,6 +213,8 @@ SET(Features_SRCS
|
||||
CustomFeature.h
|
||||
BodyBase.h
|
||||
BodyBase.cpp
|
||||
Datums.cpp
|
||||
Datums.h
|
||||
DatumFeature.cpp
|
||||
DatumFeature.h
|
||||
AttachExtension.h
|
||||
|
||||
63
src/Mod/Part/App/Datums.cpp
Normal file
63
src/Mod/Part/App/Datums.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Ondsel (PL Boyer) <development@ondsel.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include "Datums.h"
|
||||
|
||||
|
||||
using namespace Part;
|
||||
using namespace Attacher;
|
||||
|
||||
PROPERTY_SOURCE_WITH_EXTENSIONS(Part::DatumPlane, App::Plane)
|
||||
|
||||
Part::DatumPlane::DatumPlane()
|
||||
{
|
||||
AttachExtension::initExtension(this);
|
||||
this->setAttacher(new AttachEnginePlane);
|
||||
}
|
||||
|
||||
|
||||
PROPERTY_SOURCE_WITH_EXTENSIONS(Part::DatumLine, App::Line)
|
||||
|
||||
Part::DatumLine::DatumLine()
|
||||
{
|
||||
AttachExtension::initExtension(this);
|
||||
this->setAttacher(new AttachEngineLine);
|
||||
}
|
||||
|
||||
|
||||
PROPERTY_SOURCE_WITH_EXTENSIONS(Part::DatumPoint, App::Point)
|
||||
|
||||
Part::DatumPoint::DatumPoint()
|
||||
{
|
||||
AttachExtension::initExtension(this);
|
||||
this->setAttacher(new AttachEnginePoint);
|
||||
}
|
||||
|
||||
|
||||
PROPERTY_SOURCE_WITH_EXTENSIONS(Part::LocalCoordinateSystem, App::LocalCoordinateSystem)
|
||||
|
||||
Part::LocalCoordinateSystem::LocalCoordinateSystem()
|
||||
{
|
||||
AttachExtension::initExtension(this);
|
||||
}
|
||||
84
src/Mod/Part/App/Datums.h
Normal file
84
src/Mod/Part/App/Datums.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Ondsel (PL Boyer) <development@ondsel.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef PART_DATUMS_H
|
||||
#define PART_DATUMS_H
|
||||
|
||||
#include <App/Datums.h>
|
||||
|
||||
#include "AttachExtension.h"
|
||||
|
||||
namespace Part
|
||||
{
|
||||
|
||||
class PartExport DatumPlane : public App::Plane, public AttachExtension
|
||||
{
|
||||
PROPERTY_HEADER_WITH_EXTENSIONS(Part::DatumPlane);
|
||||
|
||||
public:
|
||||
DatumPlane();
|
||||
~DatumPlane() override = default;
|
||||
const char* getViewProviderName() const override {
|
||||
return "PartGui::ViewProviderPlane";
|
||||
}
|
||||
};
|
||||
|
||||
class PartExport DatumLine : public App::Line, public AttachExtension
|
||||
{
|
||||
PROPERTY_HEADER_WITH_EXTENSIONS(Part::DatumLine);
|
||||
|
||||
public:
|
||||
DatumLine();
|
||||
~DatumLine() override = default;
|
||||
const char* getViewProviderName() const override {
|
||||
return "PartGui::ViewProviderLine";
|
||||
}
|
||||
};
|
||||
|
||||
class PartExport DatumPoint : public App::Point, public AttachExtension
|
||||
{
|
||||
PROPERTY_HEADER_WITH_EXTENSIONS(Part::DatumPoint);
|
||||
|
||||
public:
|
||||
DatumPoint();
|
||||
~DatumPoint() override = default;
|
||||
const char* getViewProviderName() const override {
|
||||
return "PartGui::ViewProviderPoint";
|
||||
}
|
||||
};
|
||||
|
||||
class PartExport LocalCoordinateSystem : public App::LocalCoordinateSystem, public AttachExtension
|
||||
{
|
||||
PROPERTY_HEADER_WITH_EXTENSIONS(Part::LocalCoordinateSystem);
|
||||
|
||||
public:
|
||||
LocalCoordinateSystem();
|
||||
~LocalCoordinateSystem() override = default;
|
||||
const char* getViewProviderName() const override {
|
||||
return "PartGui::ViewProviderLCS";
|
||||
}
|
||||
};
|
||||
|
||||
} //namespace Part
|
||||
|
||||
|
||||
#endif // PART_DATUMS_H
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "ViewProvider.h"
|
||||
#include "ViewProvider2DObject.h"
|
||||
#include "ViewProviderAttachExtension.h"
|
||||
#include "ViewProviderDatum.h"
|
||||
#include "ViewProviderGridExtension.h"
|
||||
#include "ViewProviderBoolean.h"
|
||||
#include "ViewProviderBox.h"
|
||||
@@ -167,6 +168,10 @@ PyMOD_INIT_FUNC(PartGui)
|
||||
PartGui::ViewProviderGridExtensionPython ::init();
|
||||
PartGui::ViewProviderSplineExtension ::init();
|
||||
PartGui::ViewProviderSplineExtensionPython ::init();
|
||||
PartGui::ViewProviderLine ::init();
|
||||
PartGui::ViewProviderPlane ::init();
|
||||
PartGui::ViewProviderPoint ::init();
|
||||
PartGui::ViewProviderLCS ::init();
|
||||
PartGui::ViewProviderPartExt ::init();
|
||||
PartGui::ViewProviderPart ::init();
|
||||
PartGui::ViewProviderPrimitive ::init();
|
||||
|
||||
@@ -164,6 +164,8 @@ SET(PartGui_SRCS
|
||||
ViewProvider.h
|
||||
ViewProviderAttachExtension.h
|
||||
ViewProviderAttachExtension.cpp
|
||||
ViewProviderDatum.cpp
|
||||
ViewProviderDatum.h
|
||||
ViewProviderExt.cpp
|
||||
ViewProviderExt.h
|
||||
ViewProviderReference.cpp
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#endif
|
||||
|
||||
#include <App/Document.h>
|
||||
#include <App/GeoFeature.h>
|
||||
#include <App/DocumentObjectGroup.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
@@ -51,6 +52,8 @@
|
||||
#include <Gui/View3DInventorViewer.h>
|
||||
#include <Gui/WaitCursor.h>
|
||||
|
||||
#include <Mod/Part/App/Datums.h>
|
||||
|
||||
#include "BoxSelection.h"
|
||||
#include "CrossSections.h"
|
||||
#include "DlgBooleanOperation.h"
|
||||
@@ -2211,6 +2214,193 @@ bool CmdPartSectionCut::isActive()
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// Part_CoordinateSystem
|
||||
//===========================================================================
|
||||
|
||||
namespace {
|
||||
QString getAutoGroupCommandStr()
|
||||
// Helper function to get the python code to add the newly created object to the active Part/Body object if present
|
||||
{
|
||||
App::GeoFeature* activeObj = Gui::Application::Instance->activeView()->getActiveObject<App::GeoFeature*>(PDBODYKEY);
|
||||
if (!activeObj) {
|
||||
activeObj = Gui::Application::Instance->activeView()->getActiveObject<App::GeoFeature*>(PARTKEY);
|
||||
}
|
||||
|
||||
if (activeObj) {
|
||||
QString activeName = QString::fromLatin1(activeObj->getNameInDocument());
|
||||
return QString::fromLatin1("App.ActiveDocument.getObject('%1\').addObject(obj)\n").arg(activeName);
|
||||
}
|
||||
|
||||
return QString::fromLatin1("# Object created at document root.");
|
||||
}
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdPartCoordinateSystem)
|
||||
|
||||
CmdPartCoordinateSystem::CmdPartCoordinateSystem()
|
||||
: Command("Part_CoordinateSystem")
|
||||
{
|
||||
sGroup = QT_TR_NOOP("Part");
|
||||
sMenuText = QT_TR_NOOP("Create a coordinate system");
|
||||
sToolTipText = QT_TR_NOOP("A coordinate system object that can be attached to other objects.");
|
||||
sWhatsThis = "Part_CoordinateSystem";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "Std_CoordinateSystem";
|
||||
}
|
||||
|
||||
void CmdPartCoordinateSystem::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Add a coordinate system"));
|
||||
|
||||
std::string name = getUniqueObjectName("LCS");
|
||||
doCommand(Doc, "obj = App.activeDocument().addObject('Part::LocalCoordinateSystem','%s')", name.c_str());
|
||||
doCommand(Doc, getAutoGroupCommandStr().toUtf8());
|
||||
doCommand(Doc, "obj.Visibility = True");
|
||||
doCommand(Doc, "obj.ViewObject.doubleClicked()");
|
||||
}
|
||||
|
||||
bool CmdPartCoordinateSystem::isActive()
|
||||
{
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Part_Plane
|
||||
//===========================================================================
|
||||
DEF_STD_CMD_A(CmdPartPlane)
|
||||
|
||||
CmdPartPlane::CmdPartPlane()
|
||||
: Command("Part_Plane")
|
||||
{
|
||||
sGroup = QT_TR_NOOP("Part");
|
||||
sMenuText = QT_TR_NOOP("Create a datum plane");
|
||||
sToolTipText = QT_TR_NOOP("A plane object that can be attached to other objects.");
|
||||
sWhatsThis = "Part_Plane";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "Std_Plane";
|
||||
}
|
||||
|
||||
void CmdPartPlane::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Add a datum plane"));
|
||||
|
||||
std::string name = getUniqueObjectName("Plane");
|
||||
doCommand(Doc, "obj = App.activeDocument().addObject('Part::DatumPlane','%s')", name.c_str());
|
||||
doCommand(Doc, getAutoGroupCommandStr().toUtf8());
|
||||
doCommand(Doc, "obj.ViewObject.doubleClicked()");
|
||||
}
|
||||
|
||||
bool CmdPartPlane::isActive()
|
||||
{
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Part_Line
|
||||
//===========================================================================
|
||||
DEF_STD_CMD_A(CmdPartLine)
|
||||
|
||||
CmdPartLine::CmdPartLine()
|
||||
: Command("Part_Line")
|
||||
{
|
||||
sGroup = QT_TR_NOOP("Part");
|
||||
sMenuText = QT_TR_NOOP("Create a datum line");
|
||||
sToolTipText = QT_TR_NOOP("A line object that can be attached to other objects.");
|
||||
sWhatsThis = "Part_Line";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "Std_Axis";
|
||||
}
|
||||
|
||||
void CmdPartLine::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Add a datum line"));
|
||||
|
||||
std::string name = getUniqueObjectName("Line");
|
||||
doCommand(Doc, "obj = App.activeDocument().addObject('Part::DatumLine','%s')", name.c_str());
|
||||
doCommand(Doc, getAutoGroupCommandStr().toUtf8());
|
||||
doCommand(Doc, "obj.ViewObject.doubleClicked()");
|
||||
}
|
||||
|
||||
bool CmdPartLine::isActive()
|
||||
{
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Part_Point
|
||||
//===========================================================================
|
||||
DEF_STD_CMD_A(CmdPartPoint)
|
||||
|
||||
CmdPartPoint::CmdPartPoint()
|
||||
: Command("Part_Point")
|
||||
{
|
||||
sGroup = QT_TR_NOOP("Part");
|
||||
sMenuText = QT_TR_NOOP("Create a datum point");
|
||||
sToolTipText = QT_TR_NOOP("A point object that can be attached to other objects.");
|
||||
sWhatsThis = "Part_Point";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "Std_Point";
|
||||
}
|
||||
|
||||
void CmdPartPoint::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Add a datum point"));
|
||||
|
||||
std::string name = getUniqueObjectName("Point");
|
||||
doCommand(Doc, "obj = App.activeDocument().addObject('Part::DatumPoint','%s')", name.c_str());
|
||||
doCommand(Doc, getAutoGroupCommandStr().toUtf8());
|
||||
doCommand(Doc, "obj.ViewObject.doubleClicked()");
|
||||
}
|
||||
|
||||
bool CmdPartPoint::isActive()
|
||||
{
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// Part_Datums
|
||||
//===========================================================================
|
||||
class CmdPartDatums : public Gui::GroupCommand
|
||||
{
|
||||
public:
|
||||
CmdPartDatums()
|
||||
: GroupCommand("Part_Datums")
|
||||
{
|
||||
sGroup = QT_TR_NOOP("Part");
|
||||
sMenuText = QT_TR_NOOP("Create a datum");
|
||||
sToolTipText = QT_TR_NOOP("Create a datum object (LCS, Plane, Line, Point) that can be attached to other objects.");
|
||||
sWhatsThis = "Part_Datums";
|
||||
sStatusTip = sToolTipText;
|
||||
|
||||
setCheckable(false);
|
||||
|
||||
addCommand("Part_CoordinateSystem");
|
||||
addCommand("Part_Plane");
|
||||
addCommand("Part_Line");
|
||||
addCommand("Part_Point");
|
||||
}
|
||||
|
||||
const char* className() const override
|
||||
{
|
||||
return "CmdPartDatums";
|
||||
}
|
||||
|
||||
bool isActive() override
|
||||
{
|
||||
return hasActiveDocument();
|
||||
}
|
||||
};
|
||||
//---------------------------------------------------------------
|
||||
|
||||
void CreatePartCommands()
|
||||
@@ -2256,4 +2446,10 @@ void CreatePartCommands()
|
||||
rcCmdMgr.addCommand(new CmdBoxSelection());
|
||||
rcCmdMgr.addCommand(new CmdPartProjectionOnSurface());
|
||||
rcCmdMgr.addCommand(new CmdPartSectionCut());
|
||||
|
||||
rcCmdMgr.addCommand(new CmdPartCoordinateSystem());
|
||||
rcCmdMgr.addCommand(new CmdPartPlane());
|
||||
rcCmdMgr.addCommand(new CmdPartLine());
|
||||
rcCmdMgr.addCommand(new CmdPartPoint());
|
||||
rcCmdMgr.addCommand(new CmdPartDatums());
|
||||
}
|
||||
|
||||
@@ -113,6 +113,10 @@ void ViewProviderAttachExtension::extensionSetupContextMenu(QMenu* menu, QObject
|
||||
|
||||
void ViewProviderAttachExtension::showAttachmentEditor()
|
||||
{
|
||||
if (Gui::Control().activeDialog()) {
|
||||
Gui::Control().closeDialog();
|
||||
}
|
||||
|
||||
// See PropertyEnumAttacherItem::openTask()
|
||||
Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog();
|
||||
TaskDlgAttacher* task;
|
||||
|
||||
@@ -44,7 +44,6 @@ public:
|
||||
void extensionUpdateData(const App::Property*) override;
|
||||
void extensionSetupContextMenu(QMenu*, QObject*, const char*) override;
|
||||
|
||||
private:
|
||||
void showAttachmentEditor();
|
||||
};
|
||||
|
||||
|
||||
94
src/Mod/Part/Gui/ViewProviderDatum.cpp
Normal file
94
src/Mod/Part/Gui/ViewProviderDatum.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Ondsel (PL Boyer) <development@ondsel.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#endif
|
||||
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObjectGroup.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/View3DInventor.h>
|
||||
#include <Gui/View3DInventorViewer.h>
|
||||
|
||||
#include "ViewProviderDatum.h"
|
||||
|
||||
|
||||
using namespace PartGui;
|
||||
|
||||
PROPERTY_SOURCE_WITH_EXTENSIONS(PartGui::ViewProviderLine, Gui::ViewProviderLine)
|
||||
|
||||
ViewProviderLine::ViewProviderLine()
|
||||
{
|
||||
PartGui::ViewProviderAttachExtension::initExtension(this);
|
||||
}
|
||||
|
||||
bool ViewProviderLine::doubleClicked()
|
||||
{
|
||||
showAttachmentEditor();
|
||||
return true;
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE_WITH_EXTENSIONS(PartGui::ViewProviderPlane, Gui::ViewProviderPlane)
|
||||
|
||||
ViewProviderPlane::ViewProviderPlane()
|
||||
{
|
||||
PartGui::ViewProviderAttachExtension::initExtension(this);
|
||||
}
|
||||
|
||||
bool ViewProviderPlane::doubleClicked()
|
||||
{
|
||||
showAttachmentEditor();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
PROPERTY_SOURCE_WITH_EXTENSIONS(PartGui::ViewProviderPoint, Gui::ViewProviderPoint)
|
||||
|
||||
ViewProviderPoint::ViewProviderPoint()
|
||||
{
|
||||
PartGui::ViewProviderAttachExtension::initExtension(this);
|
||||
}
|
||||
|
||||
bool ViewProviderPoint::doubleClicked()
|
||||
{
|
||||
showAttachmentEditor();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
PROPERTY_SOURCE_WITH_EXTENSIONS(PartGui::ViewProviderLCS, Gui::ViewProviderCoordinateSystem)
|
||||
|
||||
ViewProviderLCS::ViewProviderLCS()
|
||||
{
|
||||
PartGui::ViewProviderAttachExtension::initExtension(this);
|
||||
}
|
||||
|
||||
bool ViewProviderLCS::doubleClicked()
|
||||
{
|
||||
showAttachmentEditor();
|
||||
return true;
|
||||
}
|
||||
84
src/Mod/Part/Gui/ViewProviderDatum.h
Normal file
84
src/Mod/Part/Gui/ViewProviderDatum.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Ondsel (PL Boyer) <development@ondsel.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef PARTGUI_ViewProviderDatum_H
|
||||
#define PARTGUI_ViewProviderDatum_H
|
||||
|
||||
#include <Gui/ViewProviderLine.h>
|
||||
#include <Gui/ViewProviderPlane.h>
|
||||
#include <Gui/ViewProviderPoint.h>
|
||||
#include <Gui/ViewProviderCoordinateSystem.h>
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include <Mod/Part/Gui/ViewProviderAttachExtension.h>
|
||||
|
||||
namespace PartGui {
|
||||
|
||||
class PartGuiExport ViewProviderLine : public Gui::ViewProviderLine, PartGui::ViewProviderAttachExtension
|
||||
{
|
||||
PROPERTY_HEADER_WITH_EXTENSIONS(PartGui::ViewProviderLine);
|
||||
|
||||
public:
|
||||
ViewProviderLine();
|
||||
~ViewProviderLine() override = default;
|
||||
|
||||
bool doubleClicked() override;
|
||||
};
|
||||
|
||||
class PartGuiExport ViewProviderPlane : public Gui::ViewProviderPlane, PartGui::ViewProviderAttachExtension
|
||||
{
|
||||
PROPERTY_HEADER_WITH_EXTENSIONS(PartGui::ViewProviderPlane);
|
||||
|
||||
public:
|
||||
ViewProviderPlane();
|
||||
~ViewProviderPlane() override = default;
|
||||
|
||||
bool doubleClicked() override;
|
||||
};
|
||||
|
||||
class PartGuiExport ViewProviderPoint : public Gui::ViewProviderPoint, PartGui::ViewProviderAttachExtension
|
||||
{
|
||||
PROPERTY_HEADER_WITH_EXTENSIONS(PartGui::ViewProviderPoint);
|
||||
|
||||
public:
|
||||
ViewProviderPoint();
|
||||
~ViewProviderPoint() override = default;
|
||||
|
||||
bool doubleClicked() override;
|
||||
};
|
||||
|
||||
class PartGuiExport ViewProviderLCS : public Gui::ViewProviderCoordinateSystem, PartGui::ViewProviderAttachExtension
|
||||
{
|
||||
PROPERTY_HEADER_WITH_EXTENSIONS(PartGui::ViewProviderLCS);
|
||||
|
||||
public:
|
||||
ViewProviderLCS();
|
||||
~ViewProviderLCS() override = default;
|
||||
|
||||
bool doubleClicked() override;
|
||||
};
|
||||
|
||||
} // namespace PartGui
|
||||
|
||||
|
||||
#endif // PARTGUI_ViewProviderDatum_H
|
||||
@@ -37,6 +37,7 @@ void WorkbenchManipulator::modifyMenuBar([[maybe_unused]] Gui::MenuItem* menuBar
|
||||
void WorkbenchManipulator::modifyToolBars(Gui::ToolBarItem* toolBar)
|
||||
{
|
||||
addSelectionFilter(toolBar);
|
||||
addDatums(toolBar);
|
||||
}
|
||||
|
||||
void WorkbenchManipulator::modifyDockWindows([[maybe_unused]] Gui::DockWindowItems* dockWindow)
|
||||
@@ -71,3 +72,18 @@ void WorkbenchManipulator::addSelectionFilter(Gui::ToolBarItem* toolBar)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WorkbenchManipulator::addDatums(Gui::ToolBarItem* toolBar)
|
||||
{
|
||||
if (auto view = toolBar->findItem("Structure")) {
|
||||
auto add = new Gui::ToolBarItem(); // NOLINT
|
||||
add->setCommand("Part_Datums");
|
||||
auto item = view->findItem("Std_Group");
|
||||
if (item) {
|
||||
view->insertItem(item, add);
|
||||
}
|
||||
else {
|
||||
view->appendItem(add);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ protected:
|
||||
private:
|
||||
static void addSectionCut(Gui::MenuItem* menuBar);
|
||||
static void addSelectionFilter(Gui::ToolBarItem* toolBar);
|
||||
static void addDatums(Gui::ToolBarItem* toolBar);
|
||||
};
|
||||
|
||||
} // namespace PartGui
|
||||
|
||||
@@ -219,7 +219,9 @@ bool Body::isAllowed(const App::DocumentObject *obj)
|
||||
//obj->isDerivedFrom<Part::FeaturePython>() // trouble with this line on Windows!? Linker fails to find getClassTypeId() of the Part::FeaturePython...
|
||||
//obj->isDerivedFrom<Part::Feature>()
|
||||
// allow VarSets for parameterization
|
||||
obj->isDerivedFrom<App::VarSet>()
|
||||
obj->isDerivedFrom<App::VarSet>() ||
|
||||
obj->isDerivedFrom<App::DatumElement>() ||
|
||||
obj->isDerivedFrom<App::LocalCoordinateSystem>()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -342,11 +342,11 @@ bool ViewProviderBody::canDropObjects() const
|
||||
{
|
||||
// if the BaseFeature property is marked as hidden or read-only then
|
||||
// it's not allowed to modify it.
|
||||
PartDesign::Body* body = getObject<PartDesign::Body>();
|
||||
if (body->BaseFeature.testStatus(App::Property::Status::Hidden))
|
||||
return false;
|
||||
if (body->BaseFeature.testStatus(App::Property::Status::ReadOnly))
|
||||
auto* body = getObject<PartDesign::Body>();
|
||||
if (body->BaseFeature.testStatus(App::Property::Status::Hidden)
|
||||
|| body->BaseFeature.testStatus(App::Property::Status::ReadOnly)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -355,7 +355,15 @@ bool ViewProviderBody::canDropObject(App::DocumentObject* obj) const
|
||||
if (obj->isDerivedFrom<App::VarSet>()) {
|
||||
return true;
|
||||
}
|
||||
if (!obj->isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
else if (obj->isDerivedFrom(App::DatumElement::getClassTypeId())) {
|
||||
// accept only datums that are not part of a LCS.
|
||||
auto* lcs = static_cast<App::DatumElement*>(obj)->getLCS();
|
||||
return !lcs;
|
||||
}
|
||||
else if (obj->isDerivedFrom(App::LocalCoordinateSystem::getClassTypeId())) {
|
||||
return !obj->isDerivedFrom(App::Origin::getClassTypeId());
|
||||
}
|
||||
else if (!obj->isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
return false;
|
||||
}
|
||||
else if (PartDesign::Body::findBodyOf(obj)) {
|
||||
@@ -375,8 +383,10 @@ bool ViewProviderBody::canDropObject(App::DocumentObject* obj) const
|
||||
|
||||
void ViewProviderBody::dropObject(App::DocumentObject* obj)
|
||||
{
|
||||
PartDesign::Body* body = getObject<PartDesign::Body>();
|
||||
if (obj->isDerivedFrom<Part::Part2DObject>()) {
|
||||
auto* body = getObject<PartDesign::Body>();
|
||||
if (obj->isDerivedFrom<Part::Part2DObject>()
|
||||
|| obj->isDerivedFrom<App::DatumElement>()
|
||||
|| obj->isDerivedFrom<App::LocalCoordinateSystem>()) {
|
||||
body->addObject(obj);
|
||||
}
|
||||
else if (PartDesign::Body::isAllowed(obj) && PartDesignGui::isFeatureMovable(obj)) {
|
||||
|
||||
@@ -2,22 +2,21 @@
|
||||
* Copyright (c) 2013 Jan Rheinlaender *
|
||||
* <jrheinlaender@users.sourceforge.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* FreeCAD is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
@@ -2,22 +2,21 @@
|
||||
* Copyright (c) 2013 Jan Rheinlaender *
|
||||
* <jrheinlaender@users.sourceforge.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* FreeCAD is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user