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

View File

@@ -23,12 +23,12 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QAction>
# include <QApplication>
# include <QMenu>
# include <QMessageBox>
# include <QTextStream>
# include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoSeparator.h>
#include <QAction>
#include <QApplication>
#include <QMenu>
#include <QMessageBox>
#include <QTextStream>
#endif
#include <App/Document.h>
@@ -50,11 +50,11 @@
#include <Mod/Fem/App/FemSetObject.h>
#include <Mod/Fem/App/FemSolverObject.h>
#ifdef FC_USE_VTK
# include <Mod/Fem/App/FemPostObject.h>
#include <Mod/Fem/App/FemPostObject.h>
#endif
#include "ViewProviderAnalysis.h"
#include "TaskDlgAnalysis.h"
#include "ViewProviderAnalysis.h"
using namespace FemGui;
@@ -70,13 +70,13 @@ ViewProviderFemHighlighter::~ViewProviderFemHighlighter()
annotate->unref();
}
void ViewProviderFemHighlighter::attach(ViewProviderFemAnalysis *view)
void ViewProviderFemHighlighter::attach(ViewProviderFemAnalysis* view)
{
SoGroup *root = view->getRoot();
SoGroup* root = view->getRoot();
root->addChild(annotate);
}
void ViewProviderFemHighlighter::highlightView(Gui::ViewProviderDocumentObject *view)
void ViewProviderFemHighlighter::highlightView(Gui::ViewProviderDocumentObject* view)
{
annotate->removeAllChildren();
@@ -99,18 +99,18 @@ ViewProviderFemAnalysis::ViewProviderFemAnalysis()
ViewProviderFemAnalysis::~ViewProviderFemAnalysis() = default;
void ViewProviderFemAnalysis::attach(App::DocumentObject *obj)
void ViewProviderFemAnalysis::attach(App::DocumentObject* obj)
{
Gui::ViewProviderDocumentObjectGroup::attach(obj);
extension.attach(this);
// activate analysis if currently active workbench is FEM
auto *workbench = Gui::WorkbenchManager::instance()->active();
auto* workbench = Gui::WorkbenchManager::instance()->active();
if (workbench->name() == "FemWorkbench") {
doubleClicked();
}
}
void ViewProviderFemAnalysis::highlightView(Gui::ViewProviderDocumentObject *view)
void ViewProviderFemAnalysis::highlightView(Gui::ViewProviderDocumentObject* view)
{
extension.highlightView(view);
}
@@ -130,12 +130,12 @@ bool ViewProviderFemAnalysis::doubleClicked()
// necessary for the workflow with new files to add a solver as next object
std::vector<App::DocumentObject*> selVector {};
selVector.push_back(this->getObject());
auto *docName = this->getObject()->getDocument()->getName();
auto* docName = this->getObject()->getDocument()->getName();
Gui::Selection().setSelection(docName, selVector);
return true;
}
std::vector<App::DocumentObject *> ViewProviderFemAnalysis::claimChildren() const
std::vector<App::DocumentObject*> ViewProviderFemAnalysis::claimChildren() const
{
return Gui::ViewProviderDocumentObjectGroup::claimChildren();
}
@@ -155,46 +155,46 @@ void ViewProviderFemAnalysis::show()
Gui::ViewProviderDocumentObjectGroup::show();
}
void ViewProviderFemAnalysis::setupContextMenu(QMenu *menu, QObject *, const char *)
void ViewProviderFemAnalysis::setupContextMenu(QMenu* menu, QObject*, const char*)
{
Gui::ActionFunction *func = new Gui::ActionFunction(menu);
QAction *act = menu->addAction(tr("Activate analysis"));
func->trigger(act, [this](){
Gui::ActionFunction* func = new Gui::ActionFunction(menu);
QAction* act = menu->addAction(tr("Activate analysis"));
func->trigger(act, [this]() {
this->doubleClicked();
});
}
bool ViewProviderFemAnalysis::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Default ) {
if (ModNum == ViewProvider::Default) {
// When double-clicking on the item for this pad the object
// unsets and sets its edit mode without closing the task panel
//Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
//TaskDlgAnalysis *anaDlg = qobject_cast<TaskDlgAnalysis *>(dlg);
//if (padDlg && anaDlg->getPadView() != this)
// padDlg = 0; // another pad left open its task panel
//if (dlg && !padDlg) {
// QMessageBox msgBox;
// msgBox.setText(QObject::tr("A dialog is already open in the task panel"));
// msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?"));
// msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
// msgBox.setDefaultButton(QMessageBox::Yes);
// int ret = msgBox.exec();
// if (ret == QMessageBox::Yes)
// Gui::Control().closeDialog();
// else
// return false;
//}
// Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
// TaskDlgAnalysis *anaDlg = qobject_cast<TaskDlgAnalysis *>(dlg);
// if (padDlg && anaDlg->getPadView() != this)
// padDlg = 0; // another pad left open its task panel
// if (dlg && !padDlg) {
// QMessageBox msgBox;
// msgBox.setText(QObject::tr("A dialog is already open in the task panel"));
// msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?"));
// msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
// msgBox.setDefaultButton(QMessageBox::Yes);
// int ret = msgBox.exec();
// if (ret == QMessageBox::Yes)
// Gui::Control().closeDialog();
// else
// return false;
// }
// start the edit dialog
// if (padDlg)
// Gui::Control().showDialog(padDlg);
// else
// if (padDlg)
// Gui::Control().showDialog(padDlg);
// else
//Fem::FemAnalysis* pcAna = static_cast<Fem::FemAnalysis*>(this->getObject());
//Gui::Control().showDialog(new TaskDlgAnalysis(pcAna));
//return true;
// Fem::FemAnalysis* pcAna = static_cast<Fem::FemAnalysis*>(this->getObject());
// Gui::Control().showDialog(new TaskDlgAnalysis(pcAna));
// return true;
return false;
}
else {
@@ -218,35 +218,46 @@ bool ViewProviderFemAnalysis::canDragObjects() const
return true;
}
bool ViewProviderFemAnalysis::canDragObject(App::DocumentObject *obj) const
bool ViewProviderFemAnalysis::canDragObject(App::DocumentObject* obj) const
{
if (!obj)
if (!obj) {
return false;
if (obj->getTypeId().isDerivedFrom(Fem::FemMeshObject::getClassTypeId()))
}
if (obj->getTypeId().isDerivedFrom(Fem::FemMeshObject::getClassTypeId())) {
return true;
else if (obj->getTypeId().isDerivedFrom(Fem::FemSolverObject::getClassTypeId()))
}
else if (obj->getTypeId().isDerivedFrom(Fem::FemSolverObject::getClassTypeId())) {
return true;
else if (obj->getTypeId().isDerivedFrom(Fem::FemResultObject::getClassTypeId()))
}
else if (obj->getTypeId().isDerivedFrom(Fem::FemResultObject::getClassTypeId())) {
return true;
else if (obj->getTypeId().isDerivedFrom(Fem::Constraint::getClassTypeId()))
}
else if (obj->getTypeId().isDerivedFrom(Fem::Constraint::getClassTypeId())) {
return true;
else if (obj->getTypeId().isDerivedFrom(Fem::FemSetObject::getClassTypeId()))
}
else if (obj->getTypeId().isDerivedFrom(Fem::FemSetObject::getClassTypeId())) {
return true;
else if (obj->getTypeId().isDerivedFrom(Base::Type::fromName("Fem::FeaturePython")))
}
else if (obj->getTypeId().isDerivedFrom(Base::Type::fromName("Fem::FeaturePython"))) {
return true;
else if (obj->getTypeId().isDerivedFrom(App::MaterialObject::getClassTypeId()))
}
else if (obj->getTypeId().isDerivedFrom(App::MaterialObject::getClassTypeId())) {
return true;
else if (obj->getTypeId().isDerivedFrom(App::TextDocument::getClassTypeId()))
}
else if (obj->getTypeId().isDerivedFrom(App::TextDocument::getClassTypeId())) {
return true;
}
#ifdef FC_USE_VTK
else if (obj->getTypeId().isDerivedFrom(Fem::FemPostObject::getClassTypeId()))
else if (obj->getTypeId().isDerivedFrom(Fem::FemPostObject::getClassTypeId())) {
return true;
}
#endif
else
else {
return false;
}
}
void ViewProviderFemAnalysis::dragObject(App::DocumentObject *obj)
void ViewProviderFemAnalysis::dragObject(App::DocumentObject* obj)
{
ViewProviderDocumentObjectGroup::dragObject(obj);
}
@@ -256,17 +267,17 @@ bool ViewProviderFemAnalysis::canDropObjects() const
return true;
}
bool ViewProviderFemAnalysis::canDropObject(App::DocumentObject *obj) const
bool ViewProviderFemAnalysis::canDropObject(App::DocumentObject* obj) const
{
return canDragObject(obj);
}
void ViewProviderFemAnalysis::dropObject(App::DocumentObject *obj)
void ViewProviderFemAnalysis::dropObject(App::DocumentObject* obj)
{
ViewProviderDocumentObjectGroup::dropObject(obj);
}
bool ViewProviderFemAnalysis::onDelete(const std::vector<std::string> &)
bool ViewProviderFemAnalysis::onDelete(const std::vector<std::string>&)
{
// warn the user if the object has unselected children
auto objs = claimChildren();
@@ -274,7 +285,8 @@ bool ViewProviderFemAnalysis::onDelete(const std::vector<std::string> &)
}
bool ViewProviderFemAnalysis::checkSelectedChildren(const std::vector<App::DocumentObject*> objs,
Gui::Document* docGui, std::string objectName)
Gui::Document* docGui,
std::string objectName)
{
// warn the user if the object has unselected children
if (!objs.empty()) {
@@ -290,37 +302,47 @@ bool ViewProviderFemAnalysis::checkSelectedChildren(const std::vector<App::Docum
break;
}
}
if (!found)
if (!found) {
break;
}
}
if (found)// all children are selected too
if (found) { // all children are selected too
return true;
}
// generate dialog
QString bodyMessage;
QTextStream bodyMessageStream(&bodyMessage);
bodyMessageStream << qApp->translate("Std_Delete",
("The " + objectName + " is not empty, therefore the\nfollowing "
"referencing objects might be lost:").c_str());
("The " + objectName
+ " is not empty, therefore the\nfollowing "
"referencing objects might be lost:")
.c_str());
bodyMessageStream << '\n';
for (auto ObjIterator : objs)
for (auto ObjIterator : objs) {
bodyMessageStream << '\n' << QString::fromUtf8(ObjIterator->Label.getValue());
}
bodyMessageStream << "\n\n" << QObject::tr("Are you sure you want to continue?");
// show and evaluate the dialog
int DialogResult = QMessageBox::warning(Gui::getMainWindow(),
qApp->translate("Std_Delete", "Object dependencies"), bodyMessage,
QMessageBox::Yes, QMessageBox::No);
if (DialogResult == QMessageBox::Yes)
int DialogResult =
QMessageBox::warning(Gui::getMainWindow(),
qApp->translate("Std_Delete", "Object dependencies"),
bodyMessage,
QMessageBox::Yes,
QMessageBox::No);
if (DialogResult == QMessageBox::Yes) {
return true;
else
}
else {
return false;
}
}
else {
return true;
}
}
bool ViewProviderFemAnalysis::canDelete(App::DocumentObject *obj) const
bool ViewProviderFemAnalysis::canDelete(App::DocumentObject* obj) const
{
// deletions of objects from a FemAnalysis don't necessarily destroy anything
// thus we can pass this action
@@ -339,4 +361,4 @@ PROPERTY_SOURCE_TEMPLATE(FemGui::ViewProviderFemAnalysisPython, FemGui::ViewProv
// explicit template instantiation
template class FemGuiExport ViewProviderPythonFeatureT<ViewProviderFemAnalysis>;
} // namespace Gui
} // namespace Gui