Part: add datum objects and commands to create them.

This commit is contained in:
PaddleStroke
2024-09-20 10:46:01 +02:00
parent 655ae579ed
commit 19ef989300
21 changed files with 626 additions and 64 deletions

View File

@@ -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>()
);
}

View File

@@ -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)) {

View File

@@ -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/>. *
* *
***************************************************************************/

View File

@@ -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/>. *
* *
***************************************************************************/