Fem: Expose Constraint view provider symbol node to Python
This commit is contained in:
committed by
Chris Hennes
parent
c49c52716c
commit
ea840bc3a3
@@ -35,10 +35,13 @@ set(FemGui_LIBS
|
||||
PartGui
|
||||
)
|
||||
|
||||
generate_from_xml(ViewProviderFemConstraintPy)
|
||||
generate_from_xml(ViewProviderFemMeshPy)
|
||||
generate_from_xml(ViewProviderFemPostPipelinePy)
|
||||
|
||||
SET(Python_SRCS
|
||||
ViewProviderFemConstraintPy.xml
|
||||
ViewProviderFemConstraintPyImp.cpp
|
||||
ViewProviderFemMeshPy.xml
|
||||
ViewProviderFemMeshPyImp.cpp
|
||||
ViewProviderFemPostPipelinePy.xml
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
|
||||
#include "TaskFemConstraint.h"
|
||||
#include "ViewProviderFemConstraint.h"
|
||||
#include "ViewProviderFemConstraintPy.h"
|
||||
|
||||
|
||||
using namespace FemGui;
|
||||
@@ -215,6 +216,15 @@ void ViewProviderFemConstraint::unsetEdit(int ModNum)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* ViewProviderFemConstraint::getPyObject()
|
||||
{
|
||||
if (!pyViewObject) {
|
||||
pyViewObject = new ViewProviderFemConstraintPy(this);
|
||||
}
|
||||
pyViewObject->IncRef();
|
||||
return pyViewObject;
|
||||
}
|
||||
/*
|
||||
// Create a local coordinate system with the z-axis given in dir
|
||||
void getLocalCoordinateSystem(const SbVec3f& z, SbVec3f& y, SbVec3f& x)
|
||||
|
||||
@@ -72,10 +72,17 @@ public:
|
||||
std::vector<App::DocumentObject*> claimChildren() const override;
|
||||
void setupContextMenu(QMenu*, QObject*, const char*) override;
|
||||
|
||||
PyObject* getPyObject() override;
|
||||
|
||||
/// Highlight the references that have been selected
|
||||
virtual void highlightReferences(const bool /* on */)
|
||||
{}
|
||||
|
||||
SoSeparator* getSymbolSeparator() const
|
||||
{
|
||||
return pShapeSep;
|
||||
}
|
||||
|
||||
static std::string gethideMeshShowPartStr();
|
||||
static std::string gethideMeshShowPartStr(const std::string showConstr);
|
||||
|
||||
|
||||
23
src/Mod/Fem/Gui/ViewProviderFemConstraintPy.xml
Normal file
23
src/Mod/Fem/Gui/ViewProviderFemConstraintPy.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="ViewProviderDocumentObjectPy"
|
||||
Name="ViewProviderFemConstraintPy"
|
||||
Twin="ViewProviderFemConstraint"
|
||||
TwinPointer="ViewProviderFemConstraint"
|
||||
Include="Mod/Fem/Gui/ViewProviderFemConstraint.h"
|
||||
Namespace="FemGui"
|
||||
FatherInclude="Gui/ViewProviderDocumentObjectPy.h"
|
||||
FatherNamespace="Gui">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="Mario Passaglia" EMail="mpassaglia@cbc.ub.ar" />
|
||||
<UserDocu>This is the ViewProviderFemConstraint class</UserDocu>
|
||||
</Documentation>
|
||||
<Attribute Name="SymbolNode" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>A pivy SoSeparator with the nodes of the constraint symbols</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="SymbolNode" Type="Object" />
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
71
src/Mod/Fem/Gui/ViewProviderFemConstraintPyImp.cpp
Normal file
71
src/Mod/Fem/Gui/ViewProviderFemConstraintPyImp.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2024 Mario Passaglia <mpassaglia[at]cbc.uba.ar> *
|
||||
* *
|
||||
* 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 <Inventor/nodes/SoSeparator.h>
|
||||
#endif
|
||||
|
||||
#include <Base/Interpreter.h>
|
||||
|
||||
#include "ViewProviderFemConstraintPy.h"
|
||||
#include "ViewProviderFemConstraintPy.cpp"
|
||||
|
||||
|
||||
using namespace FemGui;
|
||||
|
||||
// returns a string which represent the object e.g. when printed in python
|
||||
std::string ViewProviderFemConstraintPy::representation() const
|
||||
{
|
||||
std::stringstream str;
|
||||
str << "<View provider FemConstraint object at " << getViewProviderFemConstraintPtr() << ">";
|
||||
|
||||
return str.str();
|
||||
}
|
||||
|
||||
|
||||
Py::Object ViewProviderFemConstraintPy::getSymbolNode() const
|
||||
{
|
||||
try {
|
||||
SoSeparator* sep = getViewProviderFemConstraintPtr()->getSymbolSeparator();
|
||||
PyObject* Ptr =
|
||||
Base::Interpreter().createSWIGPointerObj("pivy.coin", "_p_SoSeparator", sep, 1);
|
||||
|
||||
sep->ref();
|
||||
|
||||
return Py::Object(Ptr, true);
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
PyObject* ViewProviderFemConstraintPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int ViewProviderFemConstraintPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user