Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/path-invalid-base-geometry-robustness
Browse files Browse the repository at this point in the history
  • Loading branch information
mlampert committed Feb 15, 2021
2 parents f7a467c + 62ed39e commit cc62aff
Show file tree
Hide file tree
Showing 22 changed files with 239 additions and 162 deletions.
3 changes: 0 additions & 3 deletions src/Mod/AddonManager/AddonManager.py
Expand Up @@ -26,14 +26,11 @@
from __future__ import print_function

import os
import re
import shutil
import stat
import sys
import tempfile

from PySide import QtGui, QtCore
import AddonManager_rc
import FreeCADGui

from addonmanager_utilities import translate # this needs to be as is for pylupdate
Expand Down
1 change: 0 additions & 1 deletion src/Mod/AddonManager/InitGui.py
Expand Up @@ -4,7 +4,6 @@
# License LGPL

import AddonManager
import AddonManager_rc

FreeCADGui.addLanguagePath(":/translations")
FreeCADGui.addCommand('Std_AddonMgr', AddonManager.CommandAddonManager())
2 changes: 0 additions & 2 deletions src/Mod/AddonManager/addonmanager_workers.py
Expand Up @@ -24,9 +24,7 @@
import os
import re
import shutil
import stat
import sys
import tempfile

from PySide import QtCore, QtGui

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/Gui/TaskFemConstraintContact.cpp
Expand Up @@ -404,7 +404,7 @@ TaskDlgFemConstraintContact::TaskDlgFemConstraintContact(ViewProviderFemConstrai
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
this->parameter = new TaskFemConstraintContact(ConstraintView);;
this->parameter = new TaskFemConstraintContact(ConstraintView);

Content.push_back(parameter);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp
Expand Up @@ -571,7 +571,7 @@ TaskDlgFemConstraintDisplacement::TaskDlgFemConstraintDisplacement(ViewProviderF
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
this->parameter = new TaskFemConstraintDisplacement(ConstraintView);;
this->parameter = new TaskFemConstraintDisplacement(ConstraintView);

Content.push_back(parameter);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/Gui/TaskFemConstraintFixed.cpp
Expand Up @@ -252,7 +252,7 @@ TaskDlgFemConstraintFixed::TaskDlgFemConstraintFixed(ViewProviderFemConstraintFi
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
this->parameter = new TaskFemConstraintFixed(ConstraintView);;
this->parameter = new TaskFemConstraintFixed(ConstraintView);

Content.push_back(parameter);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp
Expand Up @@ -872,7 +872,7 @@ TaskDlgFemConstraintFluidBoundary::TaskDlgFemConstraintFluidBoundary(ViewProvide
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
this->parameter = new TaskFemConstraintFluidBoundary(ConstraintView);;
this->parameter = new TaskFemConstraintFluidBoundary(ConstraintView);

Content.push_back(parameter);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/Gui/TaskFemConstraintForce.cpp
Expand Up @@ -394,7 +394,7 @@ TaskDlgFemConstraintForce::TaskDlgFemConstraintForce(ViewProviderFemConstraintFo
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
this->parameter = new TaskFemConstraintForce(ConstraintView);;
this->parameter = new TaskFemConstraintForce(ConstraintView);

Content.push_back(parameter);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/Gui/TaskFemConstraintHeatflux.cpp
Expand Up @@ -383,7 +383,7 @@ TaskDlgFemConstraintHeatflux::TaskDlgFemConstraintHeatflux(ViewProviderFemConstr
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
this->parameter = new TaskFemConstraintHeatflux(ConstraintView);;
this->parameter = new TaskFemConstraintHeatflux(ConstraintView);

Content.push_back(parameter);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/Gui/TaskFemConstraintInitialTemperature.cpp
Expand Up @@ -106,7 +106,7 @@ TaskDlgFemConstraintInitialTemperature::TaskDlgFemConstraintInitialTemperature(V
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
this->parameter = new TaskFemConstraintInitialTemperature(ConstraintView);;
this->parameter = new TaskFemConstraintInitialTemperature(ConstraintView);

Content.push_back(parameter);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/Gui/TaskFemConstraintPlaneRotation.cpp
Expand Up @@ -273,7 +273,7 @@ TaskDlgFemConstraintPlaneRotation::TaskDlgFemConstraintPlaneRotation(ViewProvide
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
this->parameter = new TaskFemConstraintPlaneRotation(ConstraintView);;
this->parameter = new TaskFemConstraintPlaneRotation(ConstraintView);

Content.push_back(parameter);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/Gui/TaskFemConstraintPressure.cpp
Expand Up @@ -269,7 +269,7 @@ TaskDlgFemConstraintPressure::TaskDlgFemConstraintPressure(ViewProviderFemConstr
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
this->parameter = new TaskFemConstraintPressure(ConstraintView);;
this->parameter = new TaskFemConstraintPressure(ConstraintView);

Content.push_back(parameter);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/Gui/TaskFemConstraintPulley.cpp
Expand Up @@ -182,7 +182,7 @@ TaskDlgFemConstraintPulley::TaskDlgFemConstraintPulley(ViewProviderFemConstraint
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
this->parameter = new TaskFemConstraintPulley(ConstraintView);;
this->parameter = new TaskFemConstraintPulley(ConstraintView);

Content.push_back(parameter);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/Gui/TaskFemConstraintTemperature.cpp
Expand Up @@ -324,7 +324,7 @@ TaskDlgFemConstraintTemperature::TaskDlgFemConstraintTemperature(ViewProviderFem
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
this->parameter = new TaskFemConstraintTemperature(ConstraintView);;
this->parameter = new TaskFemConstraintTemperature(ConstraintView);

Content.push_back(parameter);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/Gui/TaskFemConstraintTransform.cpp
Expand Up @@ -486,7 +486,7 @@ TaskDlgFemConstraintTransform::TaskDlgFemConstraintTransform(ViewProviderFemCons
{
this->ConstraintView = ConstraintView;
assert(ConstraintView);
this->parameter = new TaskFemConstraintTransform(ConstraintView);;
this->parameter = new TaskFemConstraintTransform(ConstraintView);

Content.push_back(parameter);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/Fem/femsolver/z88/writer.py
Expand Up @@ -73,7 +73,7 @@ def write_z88_input(self):
self.element_count = len(self.femelement_table)
self.set_z88_elparam()
self.write_z88_mesh()
self.write_z88_contraints()
self.write_z88_constraints()
self.write_z88_face_loads()
self.write_z88_materials()
self.write_z88_elements_properties()
Expand Down Expand Up @@ -120,7 +120,7 @@ def write_z88_mesh(self):
)
f.close()

def write_z88_contraints(self):
def write_z88_constraints(self):
constraints_data = [] # will be a list of tuple for better sorting

# fixed constraints
Expand Down Expand Up @@ -155,8 +155,8 @@ def write_z88_contraints(self):
constraints_data.append((n, str(n) + " 3 1 " + str(v3) + "\n"))

# write constraints_data to file
contraints_file_path = self.file_name + "i2.txt"
f = open(contraints_file_path, "w")
constraints_file_path = self.file_name + "i2.txt"
f = open(constraints_file_path, "w")
f.write(str(len(constraints_data)) + "\n")
for c in sorted(constraints_data):
f.write(c[1])
Expand Down
191 changes: 108 additions & 83 deletions src/Mod/PartDesign/Gui/TaskPipeParameters.cpp
Expand Up @@ -436,6 +436,113 @@ void TaskPipeParameters::exitSelectionMode() {
Gui::Selection().clearSelection();
}

bool TaskPipeParameters::accept()
{
//see what to do with external references
//check the prerequisites for the selected objects
//the user has to decide which option we should take if external references are used
PartDesign::Pipe* pcPipe = static_cast<PartDesign::Pipe*>(getPipeView()->getObject());
auto pcActiveBody = PartDesignGui::getBodyFor(pcPipe, false);
if (!pcActiveBody) {
QMessageBox::warning(this, tr("Input error"), tr("No active body"));
return false;
}
//auto pcActivePart = PartDesignGui::getPartFor(pcActiveBody, false);
std::vector<App::DocumentObject*> copies;

bool extReference = false;
App::DocumentObject* spine = pcPipe->Spine.getValue();
App::DocumentObject* auxSpine = pcPipe->AuxillerySpine.getValue();

// If a spine isn't set but user entered a label then search for the appropriate document object
QString label = ui->spineBaseEdit->text();
if (!spine && !label.isEmpty()) {
QByteArray ba = label.toUtf8();
std::vector<App::DocumentObject*> objs = pcPipe->getDocument()->findObjects(App::DocumentObject::getClassTypeId(), nullptr, ba.constData());
if (!objs.empty()) {
pcPipe->Spine.setValue(objs.front());
spine = objs.front();
}
}

if (spine && !pcActiveBody->hasObject(spine) && !pcActiveBody->getOrigin()->hasObject(spine)) {
extReference = true;
}
else if (auxSpine && !pcActiveBody->hasObject(auxSpine) && !pcActiveBody->getOrigin()->hasObject(auxSpine)) {
extReference = true;
}
else {
for(App::DocumentObject* obj : pcPipe->Sections.getValues()) {
if (!pcActiveBody->hasObject(obj) && !pcActiveBody->getOrigin()->hasObject(obj)) {
extReference = true;
break;
}
}
}

if (extReference) {
QDialog dia(Gui::getMainWindow());
Ui_DlgReference dlg;
dlg.setupUi(&dia);
dia.setModal(true);
int result = dia.exec();
if (result == QDialog::DialogCode::Rejected)
return false;

if (!dlg.radioXRef->isChecked()) {

if (!pcActiveBody->hasObject(spine) && !pcActiveBody->getOrigin()->hasObject(spine)) {
pcPipe->Spine.setValue(PartDesignGui::TaskFeaturePick::makeCopy(spine, "",
dlg.radioIndependent->isChecked()),
pcPipe->Spine.getSubValues());
copies.push_back(pcPipe->Spine.getValue());
}
else if (!pcActiveBody->hasObject(auxSpine) && !pcActiveBody->getOrigin()->hasObject(auxSpine)){
pcPipe->AuxillerySpine.setValue(PartDesignGui::TaskFeaturePick::makeCopy(auxSpine, "",
dlg.radioIndependent->isChecked()),
pcPipe->AuxillerySpine.getSubValues());
copies.push_back(pcPipe->AuxillerySpine.getValue());
}

std::vector<App::DocumentObject*> objs;
int index = 0;
for(App::DocumentObject* obj : pcPipe->Sections.getValues()) {

if(!pcActiveBody->hasObject(obj) && !pcActiveBody->getOrigin()->hasObject(obj)) {
objs.push_back(PartDesignGui::TaskFeaturePick::makeCopy(obj, "", dlg.radioIndependent->isChecked()));
copies.push_back(objs.back());
}
else {
objs.push_back(obj);
}

index++;
}

pcPipe->Sections.setValues(objs);
}
}

try {
Gui::cmdAppDocument(pcPipe, "recompute()");
if (!vp->getObject()->isValid())
throw Base::RuntimeError(vp->getObject()->getStatusString());
Gui::cmdGuiDocument(pcPipe, "resetEdit()");
Gui::Command::commitCommand();

//we need to add the copied features to the body after the command action, as otherwise FreeCAD crashes unexplainably
for (auto obj : copies) {
pcActiveBody->addObject(obj);
}
}
catch (const Base::Exception& e) {
QMessageBox::warning(this, tr("Input error"), QString::fromUtf8(e.what()));
return false;
}

return true;
}


//**************************************************************************
//**************************************************************************
Expand Down Expand Up @@ -1014,89 +1121,7 @@ TaskDlgPipeParameters::~TaskDlgPipeParameters()

bool TaskDlgPipeParameters::accept()
{
//see what to do with external references
//check the prerequisites for the selected objects
//the user has to decide which option we should take if external references are used
PartDesign::Pipe* pcPipe = static_cast<PartDesign::Pipe*>(getPipeView()->getObject());
auto pcActiveBody = PartDesignGui::getBodyFor(pcPipe, false);
//auto pcActivePart = PartDesignGui::getPartFor(pcActiveBody, false);
std::vector<App::DocumentObject*> copies;

bool extReference = false;
if(!pcActiveBody->hasObject(pcPipe->Spine.getValue()) && !pcActiveBody->getOrigin()->hasObject(pcPipe->Spine.getValue()))
extReference = true;
else if(pcPipe->AuxillerySpine.getValue() && !pcActiveBody->hasObject(pcPipe->AuxillerySpine.getValue()) &&
!pcActiveBody->getOrigin()->hasObject(pcPipe->AuxillerySpine.getValue()))
extReference = true;
else {
for(App::DocumentObject* obj : pcPipe->Sections.getValues()) {
if(!pcActiveBody->hasObject(obj) && !pcActiveBody->getOrigin()->hasObject(obj))
extReference = true;
}
}

if (extReference) {
QDialog dia(Gui::getMainWindow());
Ui_DlgReference dlg;
dlg.setupUi(&dia);
dia.setModal(true);
int result = dia.exec();
if (result == QDialog::DialogCode::Rejected)
return false;

if(!dlg.radioXRef->isChecked()) {

if(!pcActiveBody->hasObject(pcPipe->Spine.getValue()) && !pcActiveBody->getOrigin()->hasObject(pcPipe->Spine.getValue())) {
pcPipe->Spine.setValue(PartDesignGui::TaskFeaturePick::makeCopy(pcPipe->Spine.getValue(), "", dlg.radioIndependent->isChecked()),
pcPipe->Spine.getSubValues());
copies.push_back(pcPipe->Spine.getValue());
}
else if(!pcActiveBody->hasObject(pcPipe->AuxillerySpine.getValue()) && !pcActiveBody->getOrigin()->hasObject(pcPipe->AuxillerySpine.getValue())){
pcPipe->AuxillerySpine.setValue(PartDesignGui::TaskFeaturePick::makeCopy(pcPipe->AuxillerySpine.getValue(), "", dlg.radioIndependent->isChecked()),
pcPipe->AuxillerySpine.getSubValues());
copies.push_back(pcPipe->AuxillerySpine.getValue());
}

std::vector<App::DocumentObject*> objs;
int index = 0;
for(App::DocumentObject* obj : pcPipe->Sections.getValues()) {

if(!pcActiveBody->hasObject(obj) && !pcActiveBody->getOrigin()->hasObject(obj)) {
objs.push_back(PartDesignGui::TaskFeaturePick::makeCopy(obj, "", dlg.radioIndependent->isChecked()));
copies.push_back(objs.back());
}
else
objs.push_back(obj);

index++;
}

pcPipe->Sections.setValues(objs);
}
}

try {
Gui::cmdAppDocument(pcPipe, "recompute()");
if (!vp->getObject()->isValid())
throw Base::RuntimeError(vp->getObject()->getStatusString());
Gui::cmdGuiDocument(pcPipe, "resetEdit()");
Gui::Command::commitCommand();

//we need to add the copied features to the body after the command action, as otherwise FreeCAD crashes unexplainably
for(auto obj : copies) {
//Dead code: pcActiveBody was previously used without checking for null, so it won't be null here either.
//if(pcActiveBody)
pcActiveBody->addObject(obj);
//else if (pcActivePart)
// pcActivePart->addObject(obj);
}
}
catch (const Base::Exception& e) {
QMessageBox::warning(parameter, tr("Input error"), QString::fromUtf8(e.what()));
return false;
}

return true;
return parameter->accept();
}


Expand Down

0 comments on commit cc62aff

Please sign in to comment.