[FEM] task dialogs: remove unused includes

- also some code style fixes from MSVC
This commit is contained in:
Uwe
2022-03-17 23:31:17 +01:00
parent b7e1dd9ee9
commit 7ccfe10af4
12 changed files with 414 additions and 600 deletions

View File

@@ -24,36 +24,18 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <BRepAdaptor_Curve.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <Geom_Line.hxx>
# include <Geom_Plane.hxx>
# include <Precision.hxx>
# include <QAction>
# include <QKeyEvent>
# include <QMessageBox>
# include <QRegExp>
# include <QTextStream>
# include <TopoDS.hxx>
# include <gp_Ax1.hxx>
# include <gp_Lin.hxx>
# include <gp_Pln.hxx>
# include <sstream>
#endif
#include "Mod/Fem/App/FemConstraintFixed.h"
#include <App/Document.h>
#include <Gui/Command.h>
#include <Gui/SelectionObject.h>
#include <Mod/Fem/App/FemConstraintFixed.h>
#include "TaskFemConstraintFixed.h"
#include "ui_TaskFemConstraintFixed.h"
#include <App/Application.h>
#include <App/Document.h>
#include <Base/Tools.h>
#include <Gui/Command.h>
#include <Gui/Selection.h>
#include <Gui/SelectionFilter.h>
#include <Gui/SelectionObject.h>
#include <Mod/Part/App/PartFeature.h>
using namespace FemGui;
@@ -61,8 +43,8 @@ using namespace Gui;
/* TRANSLATOR FemGui::TaskFemConstraintFixed */
TaskFemConstraintFixed::TaskFemConstraintFixed(ViewProviderFemConstraintFixed *ConstraintView,QWidget *parent)
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintFixed")
TaskFemConstraintFixed::TaskFemConstraintFixed(ViewProviderFemConstraintFixed* ConstraintView, QWidget* parent)
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintFixed")
{ //Note change "Fixed" in line above to new constraint name
proxy = new QWidget(this);
ui = new Ui_TaskFemConstraintFixed();
@@ -73,14 +55,14 @@ TaskFemConstraintFixed::TaskFemConstraintFixed(ViewProviderFemConstraintFixed *C
createDeleteAction(ui->lw_references);
deleteAction->connect(deleteAction, SIGNAL(triggered()), this, SLOT(onReferenceDeleted()));
connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
connect(ui->lw_references, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
connect(ui->lw_references, SIGNAL(itemClicked(QListWidgetItem*)),
this, SLOT(setSelection(QListWidgetItem*)));
this->groupLayout()->addWidget(proxy);
/* Note: */
/* Note: */
// Get the feature data
Fem::ConstraintFixed* pcConstraint = static_cast<Fem::ConstraintFixed*>(ConstraintView->getObject());
@@ -123,7 +105,7 @@ void TaskFemConstraintFixed::updateUI()
void TaskFemConstraintFixed::addToSelection()
{
std::vector<Gui::SelectionObject> selection = Gui::Selection().getSelectionEx(); //gets vector of selected objects of active document
if (selection.size() == 0){
if (selection.size() == 0) {
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
@@ -131,40 +113,40 @@ void TaskFemConstraintFixed::addToSelection()
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it) {//for every selected object
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
return;
}
std::vector<std::string> subNames=it->getSubNames();
std::vector<std::string> subNames = it->getSubNames();
App::DocumentObject* obj = ConstraintView->getObject()->getDocument()->getObject(it->getFeatName());
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt){// for every selected sub element
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt) {// for every selected sub element
bool addMe = true;
for (std::vector<std::string>::iterator itr = std::find(SubElements.begin(), SubElements.end(), subNames[subIt]);
itr != SubElements.end();
itr = std::find(++itr, SubElements.end(), subNames[subIt]))
itr != SubElements.end();
itr = std::find(++itr, SubElements.end(), subNames[subIt]))
{// for every sub element in selection that matches one in old list
if (obj == Objects[std::distance(SubElements.begin(), itr)]){//if selected sub element's object equals the one in old list then it was added before so don't add
if (obj == Objects[std::distance(SubElements.begin(), itr)]) {//if selected sub element's object equals the one in old list then it was added before so don't add
addMe = false;
}
}
// limit constraint such that only vertexes or faces or edges can be used depending on what was selected first
std::string searchStr;
if (subNames[subIt].find("Vertex") != std::string::npos)
searchStr="Vertex";
searchStr = "Vertex";
else if (subNames[subIt].find("Edge") != std::string::npos)
searchStr = "Edge";
else
searchStr = "Face";
for (size_t iStr = 0; iStr < (SubElements.size()); ++iStr){
if (SubElements[iStr].find(searchStr) == std::string::npos){
for (size_t iStr = 0; iStr < (SubElements.size()); ++iStr) {
if (SubElements[iStr].find(searchStr) == std::string::npos) {
QString msg = tr("Only one type of selection (vertex,face or edge) per constraint allowed!");
QMessageBox::warning(this, tr("Selection error"), msg);
addMe = false;
break;
}
}
if (addMe){
if (addMe) {
QSignalBlocker block(ui->lw_references);
Objects.push_back(obj);
SubElements.push_back(subNames[subIt]);
@@ -180,7 +162,7 @@ void TaskFemConstraintFixed::addToSelection()
void TaskFemConstraintFixed::removeFromSelection()
{
std::vector<Gui::SelectionObject> selection = Gui::Selection().getSelectionEx(); //gets vector of selected objects of active document
if (selection.size() == 0){
if (selection.size() == 0) {
QMessageBox::warning(this, tr("Selection error"), tr("Nothing selected!"));
return;
}
@@ -188,27 +170,27 @@ void TaskFemConstraintFixed::removeFromSelection()
std::vector<App::DocumentObject*> Objects = pcConstraint->References.getValues();
std::vector<std::string> SubElements = pcConstraint->References.getSubValues();
std::vector<size_t> itemsToDel;
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it){//for every selected object
if(!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
for (std::vector<Gui::SelectionObject>::iterator it = selection.begin(); it != selection.end(); ++it) {//for every selected object
if (!it->isObjectTypeOf(Part::Feature::getClassTypeId())) {
QMessageBox::warning(this, tr("Selection error"), tr("Selected object is not a part!"));
return;
}
const std::vector<std::string>& subNames = it->getSubNames();
App::DocumentObject* obj = it->getObject();
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt){// for every selected sub element
for (size_t subIt = 0; subIt < (subNames.size()); ++subIt) {// for every selected sub element
for (std::vector<std::string>::iterator itr = std::find(SubElements.begin(), SubElements.end(), subNames[subIt]);
itr != SubElements.end();
itr = std::find(++itr, SubElements.end(), subNames[subIt]))
{// for every sub element in selection that matches one in old list
if (obj == Objects[std::distance(SubElements.begin(), itr)]){//if selected sub element's object equals the one in old list then it was added before so mark for deletion
if (obj == Objects[std::distance(SubElements.begin(), itr)]) {//if selected sub element's object equals the one in old list then it was added before so mark for deletion
itemsToDel.push_back(std::distance(SubElements.begin(), itr));
}
}
}
}
std::sort(itemsToDel.begin(), itemsToDel.end());
while (itemsToDel.size() > 0){
while (itemsToDel.size() > 0) {
Objects.erase(Objects.begin() + itemsToDel.back());
SubElements.erase(SubElements.begin() + itemsToDel.back());
itemsToDel.pop_back();
@@ -239,12 +221,12 @@ const std::string TaskFemConstraintFixed::getReferences() const
return TaskFemConstraint::getReferences(items);
}
bool TaskFemConstraintFixed::event(QEvent *e)
bool TaskFemConstraintFixed::event(QEvent* e)
{
return TaskFemConstraint::KeyEvent(e);
}
void TaskFemConstraintFixed::changeEvent(QEvent *)
void TaskFemConstraintFixed::changeEvent(QEvent*)
{
}
@@ -260,7 +242,7 @@ void TaskFemConstraintFixed::clearButtons(const SelectionChangeModes notThis)
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgFemConstraintFixed::TaskDlgFemConstraintFixed(ViewProviderFemConstraintFixed *ConstraintView)
TaskDlgFemConstraintFixed::TaskDlgFemConstraintFixed(ViewProviderFemConstraintFixed* ConstraintView)
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
@@ -278,7 +260,7 @@ void TaskDlgFemConstraintFixed::open()
QString msg = QObject::tr("Constraint fixed");
Gui::Command::openCommand((const char*)msg.toUtf8());
ConstraintView->setVisible(true);
Gui::Command::doCommand(Gui::Command::Doc,ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
Gui::Command::doCommand(Gui::Command::Doc, ViewProviderFemConstraint::gethideMeshShowPartStr((static_cast<Fem::Constraint*>(ConstraintView->getObject()))->getNameInDocument()).c_str()); //OvG: Hide meshes and show parts
}
}
@@ -287,14 +269,14 @@ bool TaskDlgFemConstraintFixed::accept()
std::string name = ConstraintView->getObject()->getNameInDocument();
const TaskFemConstraintFixed* parameters = static_cast<const TaskFemConstraintFixed*>(parameter);
std::string scale = parameters->getScale(); //OvG: determine modified scale
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Scale = %s", name.c_str(), scale.c_str()); //OvG: implement modified scale
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Scale = %s", name.c_str(), scale.c_str()); //OvG: implement modified scale
return TaskDlgFemConstraint::accept();
}
bool TaskDlgFemConstraintFixed::reject()
{
Gui::Command::abortCommand();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()");
Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeDocument().resetEdit()");
Gui::Command::updateActive();
return true;