Fem: Apply clang-format

This commit is contained in:
wmayer
2023-09-25 12:54:22 +02:00
committed by wwmayer
parent 59c7653584
commit b8b94c249e
148 changed files with 6507 additions and 4651 deletions

75
src/Mod/Fem/Gui/AppFemGuiPy.cpp Executable file → Normal file
View File

@@ -22,7 +22,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QFileInfo>
#include <QFileInfo>
#endif
#include <App/DocumentObjectPy.h>
@@ -37,25 +37,27 @@
#include "ActiveAnalysisObserver.h"
namespace FemGui {
class Module : public Py::ExtensionModule<Module>
namespace FemGui
{
class Module: public Py::ExtensionModule<Module>
{
public:
Module() : Py::ExtensionModule<Module>("FemGui")
Module()
: Py::ExtensionModule<Module>("FemGui")
{
add_varargs_method("setActiveAnalysis", &Module::setActiveAnalysis,
"setActiveAnalysis(AnalysisObject) -- Set the Analysis object in work."
);
add_varargs_method("getActiveAnalysis", &Module::getActiveAnalysis,
"getActiveAnalysis() -- Returns the Analysis object in work."
);
add_varargs_method("open", &Module::open,
"open(string) -- Opens an Abaqus file in a text editor."
);
add_varargs_method("insert", &Module::open,
"insert(string,string) -- Opens an Abaqus file in a text editor."
);
initialize("This module is the FemGui module."); // register with Python
add_varargs_method("setActiveAnalysis",
&Module::setActiveAnalysis,
"setActiveAnalysis(AnalysisObject) -- Set the Analysis object in work.");
add_varargs_method("getActiveAnalysis",
&Module::getActiveAnalysis,
"getActiveAnalysis() -- Returns the Analysis object in work.");
add_varargs_method("open",
&Module::open,
"open(string) -- Opens an Abaqus file in a text editor.");
add_varargs_method("insert",
&Module::open,
"insert(string,string) -- Opens an Abaqus file in a text editor.");
initialize("This module is the FemGui module."); // register with Python
}
private:
@@ -74,30 +76,40 @@ private:
Py::Object setActiveAnalysis(const Py::Tuple& args)
{
if (FemGui::ActiveAnalysisObserver::instance()->hasActiveObject()) {
FemGui::ActiveAnalysisObserver::instance()->highlightActiveObject(Gui::HighlightMode::Blue, false);
FemGui::ActiveAnalysisObserver::instance()->highlightActiveObject(
Gui::HighlightMode::Blue,
false);
FemGui::ActiveAnalysisObserver::instance()->setActiveObject(nullptr);
}
PyObject* object = nullptr;
if (PyArg_ParseTuple(args.ptr(), "|O!", &(App::DocumentObjectPy::Type), &object) && object) {
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(object)->getDocumentObjectPtr();
if (PyArg_ParseTuple(args.ptr(), "|O!", &(App::DocumentObjectPy::Type), &object)
&& object) {
App::DocumentObject* obj =
static_cast<App::DocumentObjectPy*>(object)->getDocumentObjectPtr();
if (!obj || !obj->getTypeId().isDerivedFrom(Fem::FemAnalysis::getClassTypeId())) {
throw Py::Exception(Base::PyExc_FC_GeneralError, "Active Analysis object have to be of type Fem::FemAnalysis!");
throw Py::Exception(Base::PyExc_FC_GeneralError,
"Active Analysis object have to be of type Fem::FemAnalysis!");
}
// get the gui document of the Analysis Item
FemGui::ActiveAnalysisObserver::instance()->setActiveObject(static_cast<Fem::FemAnalysis*>(obj));
FemGui::ActiveAnalysisObserver::instance()->highlightActiveObject(Gui::HighlightMode::Blue, true);
FemGui::ActiveAnalysisObserver::instance()->setActiveObject(
static_cast<Fem::FemAnalysis*>(obj));
FemGui::ActiveAnalysisObserver::instance()->highlightActiveObject(
Gui::HighlightMode::Blue,
true);
}
return Py::None();
}
Py::Object getActiveAnalysis(const Py::Tuple& args)
{
if (!PyArg_ParseTuple(args.ptr(), ""))
if (!PyArg_ParseTuple(args.ptr(), "")) {
throw Py::Exception();
}
if (FemGui::ActiveAnalysisObserver::instance()->hasActiveObject()) {
return Py::asObject(FemGui::ActiveAnalysisObserver::instance()->getActiveObject()->getPyObject());
return Py::asObject(
FemGui::ActiveAnalysisObserver::instance()->getActiveObject()->getPyObject());
}
return Py::None();
}
@@ -105,8 +117,9 @@ private:
{
char* Name;
const char* DocName;
if (!PyArg_ParseTuple(args.ptr(), "et|s", "utf-8", &Name, &DocName))
if (!PyArg_ParseTuple(args.ptr(), "et|s", "utf-8", &Name, &DocName)) {
throw Py::Exception();
}
std::string EncodedName = std::string(Name);
PyMem_Free(Name);
@@ -123,14 +136,14 @@ private:
}
}
if ( (ext == QLatin1String("inp"))
|| (ext == QLatin1String("sif"))
|| (ext == QLatin1String("txt")) ) {
if ((ext == QLatin1String("inp")) || (ext == QLatin1String("sif"))
|| (ext == QLatin1String("txt"))) {
Gui::TextEditor* editor = new Gui::TextEditor();
editor->setWindowIcon(Gui::BitmapFactory().pixmap(":/icons/fem-solver-inp-editor.svg"));
Gui::EditorView* edit = new Gui::EditorView(editor, Gui::getMainWindow());
if (ext == QLatin1String("inp"))
if (ext == QLatin1String("inp")) {
editor->setSyntaxHighlighter(new FemGui::AbaqusHighlighter(editor));
}
edit->setDisplayName(Gui::EditorView::FileName);
edit->open(fileName);
edit->resize(400, 300);
@@ -150,4 +163,4 @@ PyObject* initModule()
return Base::Interpreter().addModule(new Module);
}
} // namespace FemGui
} // namespace FemGui