Skip to content

Commit

Permalink
Assembly: Implementation of BOM
Browse files Browse the repository at this point in the history
  • Loading branch information
PaddleStroke committed May 21, 2024
1 parent ef512ad commit 5702eec
Show file tree
Hide file tree
Showing 21 changed files with 1,010 additions and 40 deletions.
4 changes: 4 additions & 0 deletions src/Mod/Assembly/App/AppAssembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <Base/PyObjectBase.h>

#include "AssemblyObject.h"
#include "BomObject.h"
#include "BomGroup.h"
#include "JointGroup.h"
#include "ViewGroup.h"

Expand Down Expand Up @@ -58,6 +60,8 @@ PyMOD_INIT_FUNC(AssemblyApp)
// This function is responsible for adding inherited slots from a type's base class.

Assembly::AssemblyObject ::init();
Assembly::BomObject ::init();
Assembly::BomGroup ::init();
Assembly::JointGroup ::init();
Assembly::ViewGroup ::init();

Expand Down
55 changes: 55 additions & 0 deletions src/Mod/Assembly/App/BomGroup.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/****************************************************************************
* *
* Copyright (c) 2023 Ondsel <development@ondsel.com> *
* *
* This file is part of FreeCAD. *
* *
* 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. *
* *
* 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 Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/

#include "PreCompiled.h"
#ifndef _PreComp_
#endif

#include <App/Application.h>
#include <App/Document.h>
#include <App/FeaturePythonPyImp.h>
#include <App/PropertyPythonObject.h>
#include <Base/Console.h>
#include <Base/Tools.h>

#include "BomGroup.h"
#include "BomGroupPy.h"

using namespace Assembly;


PROPERTY_SOURCE(Assembly::BomGroup, App::DocumentObjectGroup)

BomGroup::BomGroup()
{}

BomGroup::~BomGroup() = default;

PyObject* BomGroup::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new BomGroupPy(this), true);
}
return Py::new_reference_to(PythonObject);
}
58 changes: 58 additions & 0 deletions src/Mod/Assembly/App/BomGroup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/****************************************************************************
* *
* Copyright (c) 2023 Ondsel <development@ondsel.com> *
* *
* This file is part of FreeCAD. *
* *
* 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. *
* *
* 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 Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/


#ifndef ASSEMBLY_BomGroup_H
#define ASSEMBLY_BomGroup_H

#include <Mod/Assembly/AssemblyGlobal.h>

#include <App/DocumentObjectGroup.h>
#include <App/PropertyLinks.h>


namespace Assembly
{

class AssemblyExport BomGroup: public App::DocumentObjectGroup
{
PROPERTY_HEADER_WITH_OVERRIDE(Assembly::BomGroup);

public:
BomGroup();
~BomGroup() override;

PyObject* getPyObject() override;

/// returns the type name of the ViewProvider
const char* getViewProviderName() const override
{
return "AssemblyGui::ViewProviderBomGroup";
}
};


} // namespace Assembly


#endif // ASSEMBLY_BomGroup_H
19 changes: 19 additions & 0 deletions src/Mod/Assembly/App/BomGroupPy.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="DocumentObjectGroupPy"
Name="BomGroupPy"
Twin="BomGroup"
TwinPointer="BomGroup"
Include="Mod/Assembly/App/BomGroup.h"
Namespace="Assembly"
FatherInclude="App/DocumentObjectGroupPy.h"
FatherNamespace="App">
<Documentation>
<Author Licence="LGPL" Name="Ondsel" EMail="development@ondsel.com" />
<UserDocu>This class is a group subclass for boms.</UserDocu>
</Documentation>

<CustomAttributes />
</PythonExport>
</GenerateModel>
46 changes: 46 additions & 0 deletions src/Mod/Assembly/App/BomGroupPyImp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/***************************************************************************
* Copyright (c) 2014 Jürgen Riegel <juergen.riegel@web.de> *
* *
* 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"

// inclusion of the generated files (generated out of BomGroup.xml)
#include "BomGroupPy.h"
#include "BomGroupPy.cpp"

using namespace Assembly;

// returns a string which represents the object e.g. when printed in python
std::string BomGroupPy::representation() const
{
return {"<Bom Group>"};
}

PyObject* BomGroupPy::getCustomAttributes(const char* /*attr*/) const
{
return nullptr;
}

int BomGroupPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
}
76 changes: 76 additions & 0 deletions src/Mod/Assembly/App/BomObject.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/****************************************************************************
* *
* Copyright (c) 2023 Ondsel <development@ondsel.com> *
* *
* This file is part of FreeCAD. *
* *
* 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. *
* *
* 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 Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/

#include "PreCompiled.h"
#ifndef _PreComp_
#include <cmath>
#include <vector>
#endif

#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObjectGroup.h>
#include <App/FeaturePythonPyImp.h>
#include <App/Link.h>
#include <App/PropertyPythonObject.h>
#include <Base/Console.h>
#include <Base/Placement.h>
#include <Base/Rotation.h>
#include <Base/Tools.h>
#include <Base/Interpreter.h>

#include <Mod/Part/App/PartFeature.h>
#include <Mod/Part/App/TopoShape.h>
#include <Mod/PartDesign/App/Body.h>


#include "BomObject.h"
#include "BomObjectPy.h"


using namespace Assembly;

// ================================ Assembly Object ============================

PROPERTY_SOURCE(Assembly::BomObject, Spreadsheet::Sheet)

BomObject::BomObject()
: Spreadsheet::Sheet()
{}
BomObject::~BomObject() = default;

PyObject* BomObject::getPyObject()
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new BomObjectPy(this), true);
}
return Py::new_reference_to(PythonObject);
}

App::DocumentObjectExecReturn* BomObject::execute()
{
// generateBOM();

return Spreadsheet::Sheet::execute();
}
63 changes: 63 additions & 0 deletions src/Mod/Assembly/App/BomObject.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
/****************************************************************************
* *
* Copyright (c) 2023 Ondsel <development@ondsel.com> *
* *
* This file is part of FreeCAD. *
* *
* 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. *
* *
* 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 Lesser General Public *
* License along with FreeCAD. If not, see *
* <https://www.gnu.org/licenses/>. *
* *
***************************************************************************/


#ifndef ASSEMBLY_BomObject_H
#define ASSEMBLY_BomObject_H


#include <Mod/Assembly/AssemblyGlobal.h>

#include <App/PropertyLinks.h>
#include <Mod/Spreadsheet/App/Sheet.h>


namespace Assembly
{

class JointGroup;

class AssemblyExport BomObject: public Spreadsheet::Sheet
{
PROPERTY_HEADER_WITH_OVERRIDE(Assembly::BomObject);

public:
BomObject();
~BomObject() override;

PyObject* getPyObject() override;

const char* getViewProviderName() const override
{
return "AssemblyGui::ViewProviderBom";
}

App::DocumentObjectExecReturn* execute() override;
};

// using BomObjectPython = App::FeaturePythonT<BomObject>;

} // namespace Assembly


#endif // ASSEMBLY_BomObject_H
19 changes: 19 additions & 0 deletions src/Mod/Assembly/App/BomObjectPy.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="SheetPy"
Name="BomObjectPy"
Twin="BomObject"
TwinPointer="BomObject"
Include="Mod/Assembly/App/BomObject.h"
Namespace="Assembly"
FatherInclude="Mod/Spreadsheet/App/SheetPy.h"
FatherNamespace="Spreadsheet">
<Documentation>
<Author Licence="LGPL" Name="Ondsel" EMail="development@ondsel.com" />
<UserDocu>This class is the BOM object of assemblies, it derives from Spreadsheet Sheet.</UserDocu>
</Documentation>

<CustomAttributes />
</PythonExport>
</GenerateModel>
Loading

0 comments on commit 5702eec

Please sign in to comment.