Merge branch 'master' of git://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad
This commit is contained in:
@@ -668,7 +668,7 @@ void Document::RestoreDocFile(Base::Reader &reader)
|
||||
if (!xmlReader.getFilenames().empty())
|
||||
xmlReader.readFiles(static_cast<zipios::ZipInputStream&>(reader));
|
||||
|
||||
// reset modifeid flag
|
||||
// reset modified flag
|
||||
setModified(false);
|
||||
}
|
||||
|
||||
@@ -697,6 +697,9 @@ void Document::slotFinishRestoreDocument(const App::Document& doc)
|
||||
for (it = d->_ViewProviderMap.begin(); it != d->_ViewProviderMap.end(); ++it) {
|
||||
it->second->finishRestoring();
|
||||
}
|
||||
|
||||
// reset modified flag
|
||||
setModified(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,6 +64,7 @@ Pad::Pad()
|
||||
short Pad::mustExecute() const
|
||||
{
|
||||
if (Placement.isTouched() ||
|
||||
Type.isTouched() ||
|
||||
Length.isTouched() ||
|
||||
Length2.isTouched() ||
|
||||
UpToFace.isTouched())
|
||||
@@ -112,18 +113,21 @@ App::DocumentObjectExecReturn *Pad::execute(void)
|
||||
|
||||
gp_Dir dir(SketchVector.x,SketchVector.y,SketchVector.z);
|
||||
dir.Transform(invObjLoc.Transformation());
|
||||
|
||||
|
||||
TopoDS_Shape sketchshape = makeFace(wires);
|
||||
if (sketchshape.IsNull())
|
||||
return new App::DocumentObjectExecReturn("Pad: Creating a face from sketch failed");
|
||||
sketchshape.Move(invObjLoc);
|
||||
|
||||
|
||||
TopoDS_Shape prism;
|
||||
std::string method(Type.getValueAsString());
|
||||
if (method == "UpToFirst" || method == "UpToLast" || method == "UpToFace") {
|
||||
TopoDS_Face supportface = getSupportFace();
|
||||
supportface.Move(invObjLoc);
|
||||
|
||||
if (Reversed.getValue())
|
||||
dir.Reverse();
|
||||
|
||||
// Find a valid face to extrude up to
|
||||
TopoDS_Face upToFace;
|
||||
if (method == "UpToFace") {
|
||||
@@ -154,7 +158,7 @@ App::DocumentObjectExecReturn *Pad::execute(void)
|
||||
|
||||
// set the additive shape property for later usage in e.g. pattern
|
||||
this->AddShape.setValue(prism);
|
||||
|
||||
|
||||
// if the sketch has a support fuse them to get one result object
|
||||
if (!support.IsNull()) {
|
||||
// Let's call algorithm computing a fuse operation:
|
||||
@@ -178,7 +182,7 @@ App::DocumentObjectExecReturn *Pad::execute(void)
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
if (std::string(e->GetMessageString()) == "TopoDS::Face")
|
||||
return new App::DocumentObjectExecReturn("Could not create face from sketch.\n"
|
||||
return new App::DocumentObjectExecReturn("Could not create face from sketch.\n"
|
||||
"Intersecting sketch entities or multiple faces in a sketch are not allowed.");
|
||||
else
|
||||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
|
||||
@@ -66,6 +66,7 @@ Pocket::Pocket()
|
||||
short Pocket::mustExecute() const
|
||||
{
|
||||
if (Placement.isTouched() ||
|
||||
Type.isTouched() ||
|
||||
Length.isTouched() ||
|
||||
UpToFace.isTouched())
|
||||
return 1;
|
||||
|
||||
@@ -140,7 +140,7 @@ std::vector<TopoDS_Wire> SketchBased::getSketchWires() const {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// TODO: This code is taken from and duplicates code in Part2DObject::positionBySupport()
|
||||
// Note: We cannot return a reference, because it will become Null.
|
||||
// Not clear where, because we check for IsNull() here, but as soon as it is passed out of
|
||||
@@ -172,14 +172,14 @@ const TopoDS_Face SketchBased::getSupportFace() const {
|
||||
|
||||
return face;
|
||||
}
|
||||
|
||||
|
||||
Part::Feature* SketchBased::getSupport() const {
|
||||
// get the support of the Sketch if any
|
||||
App::DocumentObject* SupportLink = static_cast<Part::Part2DObject*>(Sketch.getValue())->Support.getValue();
|
||||
Part::Feature* SupportObject = NULL;
|
||||
if (SupportLink && SupportLink->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
|
||||
SupportObject = static_cast<Part::Feature*>(SupportLink);
|
||||
|
||||
|
||||
return SupportObject;
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ const TopoDS_Shape& SketchBased::getSupportShape() const {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int SketchBased::getSketchAxisCount(void) const
|
||||
{
|
||||
Part::Part2DObject *sketch = static_cast<Part::Part2DObject*>(Sketch.getValue());
|
||||
@@ -444,15 +444,17 @@ void SketchBased::getUpToFace(TopoDS_Face& upToFace,
|
||||
|
||||
if (remove_limits) {
|
||||
// Note: Using an unlimited face every time gives unnecessary failures for concave faces
|
||||
TopLoc_Location loc = upToFace.Location();
|
||||
BRepAdaptor_Surface adapt(upToFace, Standard_False);
|
||||
BRepBuilderAPI_MakeFace mkFace(adapt.Surface().Surface());
|
||||
if (!mkFace.IsDone())
|
||||
throw Base::Exception("SketchBased: Up To Face: Failed to create unlimited face");
|
||||
upToFace = TopoDS::Face(mkFace.Shape());
|
||||
upToFace.Location(loc);
|
||||
}
|
||||
|
||||
// Check that the upToFace does not intersect the sketch face and
|
||||
// is not parallel to the extrusion direction
|
||||
// is not parallel to the extrusion direction (for simplicity, supportface is used instead of sketchshape)
|
||||
BRepAdaptor_Surface adapt1(TopoDS::Face(supportface));
|
||||
BRepAdaptor_Surface adapt2(TopoDS::Face(upToFace));
|
||||
|
||||
@@ -461,7 +463,8 @@ void SketchBased::getUpToFace(TopoDS_Face& upToFace,
|
||||
throw Base::Exception("SketchBased: Up to face: Must not be parallel to extrusion direction!");
|
||||
}
|
||||
|
||||
BRepExtrema_DistShapeShape distSS(supportface, upToFace);
|
||||
// We must measure from sketchshape, not supportface, here
|
||||
BRepExtrema_DistShapeShape distSS(sketchshape, upToFace);
|
||||
if (distSS.Value() < Precision::Confusion())
|
||||
throw Base::Exception("SketchBased: Up to face: Must not intersect sketch!");
|
||||
|
||||
@@ -484,12 +487,13 @@ void SketchBased::generatePrism(TopoDS_Shape& prism,
|
||||
// Note: 1E6 created problems once...
|
||||
Ltotal = 1E4;
|
||||
|
||||
if (midplane)
|
||||
Loffset = -Ltotal/2;
|
||||
else if (method == "TwoLengths") {
|
||||
|
||||
if (method == "TwoLengths") {
|
||||
// midplane makes no sense here
|
||||
Loffset = -L2;
|
||||
Ltotal += L2;
|
||||
}
|
||||
} else if (midplane)
|
||||
Loffset = -Ltotal/2;
|
||||
|
||||
TopoDS_Shape from = sketchshape;
|
||||
if (method == "TwoLengths" || midplane) {
|
||||
|
||||
@@ -97,10 +97,10 @@ TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,QWidget *parent)
|
||||
double l2 = pcPad->Length2.getValue();
|
||||
int index = pcPad->Type.getValue(); // must extract value here, clear() kills it!
|
||||
std::vector<std::string> subStrings = pcPad->UpToFace.getSubValues();
|
||||
std::string upToFace;
|
||||
std::string upToFace;
|
||||
int faceId = -1;
|
||||
if (!subStrings.empty()) {
|
||||
upToFace = subStrings.front();
|
||||
if (!subStrings.empty()) {
|
||||
upToFace = subStrings.front();
|
||||
if (upToFace.substr(0,4) == "Face")
|
||||
faceId = std::atoi(&upToFace[4]);
|
||||
}
|
||||
@@ -116,8 +116,8 @@ TaskPadParameters::TaskPadParameters(ViewProviderPad *PadView,QWidget *parent)
|
||||
// According to bug #0000521 the reversed option
|
||||
// shouldn't be de-activated if the pad has a support face
|
||||
ui->checkBoxReversed->setChecked(reversed);
|
||||
ui->lineFaceName->setText(faceId >= 0 ?
|
||||
tr("Face") + QString::number(faceId) :
|
||||
ui->lineFaceName->setText(faceId >= 0 ?
|
||||
tr("Face") + QString::number(faceId) :
|
||||
tr("No face selected"));
|
||||
ui->lineFaceName->setProperty("FaceName", QByteArray(upToFace.c_str()));
|
||||
ui->changeMode->clear();
|
||||
@@ -158,7 +158,7 @@ void TaskPadParameters::updateUI(int index)
|
||||
} else if (index == 1 || index == 2) { // up to first/last
|
||||
ui->doubleSpinBox->setEnabled(false);
|
||||
ui->checkBoxMidplane->setEnabled(false);
|
||||
ui->checkBoxReversed->setEnabled(false);
|
||||
ui->checkBoxReversed->setEnabled(true);
|
||||
ui->doubleSpinBox2->setEnabled(false);
|
||||
ui->buttonFace->setEnabled(false);
|
||||
ui->lineFaceName->setEnabled(false);
|
||||
@@ -212,7 +212,7 @@ void TaskPadParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
}
|
||||
if (strcmp(msg.pObjectName, support->getNameInDocument()) != 0)
|
||||
return;
|
||||
|
||||
|
||||
std::vector<std::string> upToFaces(1,subName);
|
||||
pcPad->UpToFace.setValue(support, upToFaces);
|
||||
if (updateView())
|
||||
@@ -228,7 +228,7 @@ void TaskPadParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
ui->lineFaceName->blockSignals(true);
|
||||
ui->lineFaceName->setText(tr("No face selected"));
|
||||
ui->lineFaceName->setProperty("FaceName", QByteArray());
|
||||
ui->lineFaceName->blockSignals(false);
|
||||
ui->lineFaceName->blockSignals(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ void TaskPadParameters::onButtonFace(const bool pressed) {
|
||||
doc->setShow(support->getNameInDocument());
|
||||
}
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelectionGate
|
||||
Gui::Selection().addSelectionGate
|
||||
(new ReferenceSelection(support, false, true, false));
|
||||
} else {
|
||||
Gui::Selection().rmvSelectionGate();
|
||||
@@ -351,7 +351,7 @@ void TaskPadParameters::onUpdateView(bool on)
|
||||
{
|
||||
if (on) {
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
|
||||
pcPad->getDocument()->recomputeFeature(pcPad);
|
||||
pcPad->getDocument()->recomputeFeature(pcPad);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -472,14 +472,14 @@ bool TaskDlgPadParameters::accept()
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Midplane = %i",name.c_str(),parameter->getMidplane()?1:0);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Length2 = %f",name.c_str(),parameter->getLength2());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Type = %u",name.c_str(),parameter->getMode());
|
||||
QByteArray facename = parameter->getFaceName();
|
||||
std::string facename = parameter->getFaceName().data();
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
|
||||
Part::Feature* support = pcPad->getSupport();
|
||||
|
||||
if (support != NULL && !facename.isEmpty()) {
|
||||
if (support != NULL && !facename.empty()) {
|
||||
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
|
||||
buf = buf.arg(QString::fromUtf8(support->getNameInDocument()));
|
||||
buf = buf.arg(QString::fromUtf8(facename.data()));
|
||||
buf = buf.arg(QString::fromStdString(facename));
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = %s", name.c_str(), buf.toStdString().c_str());
|
||||
} else
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = None", name.c_str());
|
||||
|
||||
@@ -89,10 +89,10 @@ TaskPocketParameters::TaskPocketParameters(ViewProviderPocket *PocketView,QWidge
|
||||
bool midplane = pcPocket->Midplane.getValue();
|
||||
int index = pcPocket->Type.getValue(); // must extract value here, clear() kills it!
|
||||
std::vector<std::string> subStrings = pcPocket->UpToFace.getSubValues();
|
||||
std::string upToFace;
|
||||
std::string upToFace;
|
||||
int faceId = -1;
|
||||
if (!subStrings.empty()) {
|
||||
upToFace = subStrings.front();
|
||||
if (!subStrings.empty()) {
|
||||
upToFace = subStrings.front();
|
||||
if (upToFace.substr(0,4) == "Face")
|
||||
faceId = std::atoi(&upToFace[4]);
|
||||
}
|
||||
@@ -102,8 +102,8 @@ TaskPocketParameters::TaskPocketParameters(ViewProviderPocket *PocketView,QWidge
|
||||
ui->doubleSpinBox->setMaximum(INT_MAX);
|
||||
ui->doubleSpinBox->setValue(l);
|
||||
ui->checkBoxMidplane->setChecked(midplane);
|
||||
ui->lineFaceName->setText(faceId >= 0 ?
|
||||
tr("Face") + QString::number(faceId) :
|
||||
ui->lineFaceName->setText(faceId >= 0 ?
|
||||
tr("Face") + QString::number(faceId) :
|
||||
tr("No face selected"));
|
||||
ui->lineFaceName->setProperty("FaceName", QByteArray(upToFace.c_str()));
|
||||
ui->changeMode->clear();
|
||||
@@ -192,7 +192,7 @@ void TaskPocketParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
}
|
||||
if (strcmp(msg.pObjectName, support->getNameInDocument()) != 0)
|
||||
return;
|
||||
|
||||
|
||||
std::vector<std::string> upToFaces(1,subName);
|
||||
pcPocket->UpToFace.setValue(support, upToFaces);
|
||||
if (updateView())
|
||||
@@ -241,13 +241,13 @@ void TaskPocketParameters::onModeChanged(int index)
|
||||
pcPocket->Length.setValue(oldLength);
|
||||
ui->doubleSpinBox->setValue(oldLength);
|
||||
break;
|
||||
case 1:
|
||||
oldLength = pcPocket->Length.getValue();
|
||||
pcPocket->Type.setValue("ThroughAll");
|
||||
case 1:
|
||||
oldLength = pcPocket->Length.getValue();
|
||||
pcPocket->Type.setValue("ThroughAll");
|
||||
break;
|
||||
case 2:
|
||||
oldLength = pcPocket->Length.getValue();
|
||||
pcPocket->Type.setValue("UpToFirst");
|
||||
case 2:
|
||||
oldLength = pcPocket->Length.getValue();
|
||||
pcPocket->Type.setValue("UpToFirst");
|
||||
break;
|
||||
case 3:
|
||||
// Because of the code at the begining of Pocket::execute() which is used to detect
|
||||
@@ -257,7 +257,7 @@ void TaskPocketParameters::onModeChanged(int index)
|
||||
pcPocket->Length.setValue(0.0);
|
||||
ui->doubleSpinBox->setValue(0.0);
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
pcPocket->Type.setValue("Length");
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ void TaskPocketParameters::onButtonFace(const bool pressed) {
|
||||
doc->setShow(support->getNameInDocument());
|
||||
}
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelectionGate
|
||||
Gui::Selection().addSelectionGate
|
||||
(new ReferenceSelection(support, false, true, false));
|
||||
} else {
|
||||
Gui::Selection().rmvSelectionGate();
|
||||
@@ -430,13 +430,13 @@ bool TaskDlgPocketParameters::accept()
|
||||
//Gui::Command::openCommand("Pocket changed");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Length = %f",name.c_str(),parameter->getLength());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Type = %u",name.c_str(),parameter->getMode());
|
||||
QByteArray facename = parameter->getFaceName();
|
||||
std::string facename = parameter->getFaceName().data();
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(PocketView->getObject());
|
||||
Part::Feature* support = pcPocket->getSupport();
|
||||
if (support != NULL && !facename.isEmpty()) {
|
||||
if (support != NULL && !facename.empty()) {
|
||||
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
|
||||
buf = buf.arg(QString::fromUtf8(support->getNameInDocument()));
|
||||
buf = buf.arg(QString::fromUtf8(facename.data()));
|
||||
buf = buf.arg(QString::fromStdString(facename));
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = %s", name.c_str(), buf.toStdString().c_str());
|
||||
} else
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = None", name.c_str());
|
||||
|
||||
Reference in New Issue
Block a user