Pad/Pocket: Allow extrude up to a datum plane

This commit is contained in:
jrheinlaender
2013-05-14 15:44:24 +04:30
committed by Stefan Tröger
parent b815656649
commit f954a51430
12 changed files with 161 additions and 153 deletions

View File

@@ -96,6 +96,7 @@ TaskPocketParameters::TaskPocketParameters(ViewProviderPocket *PocketView,QWidge
bool midplane = pcPocket->Midplane.getValue();
bool reversed = pcPocket->Reversed.getValue();
int index = pcPocket->Type.getValue(); // must extract value here, clear() kills it!
App::DocumentObject* obj = pcPocket->UpToFace.getValue();
std::vector<std::string> subStrings = pcPocket->UpToFace.getSubValues();
std::string upToFace;
int faceId = -1;
@@ -111,9 +112,13 @@ TaskPocketParameters::TaskPocketParameters(ViewProviderPocket *PocketView,QWidge
ui->pocketLength->setValue(l);
ui->checkBoxMidplane->setChecked(midplane);
ui->checkBoxReversed->setChecked(reversed);
ui->lineFaceName->setText(faceId >= 0 ?
tr("Face") + QString::number(faceId) :
tr("No face selected"));
if (PartDesign::Feature::isDatum(obj))
ui->lineFaceName->setText(QString::fromAscii(obj->getNameInDocument()));
else if (faceId >= 0)
ui->lineFaceName->setText(QString::fromAscii(obj->getNameInDocument()) + tr("Face") +
QString::number(faceId));
else
ui->lineFaceName->setText(tr("No face selected"));
ui->lineFaceName->setProperty("FaceName", QByteArray(upToFace.c_str()));
ui->changeMode->clear();
ui->changeMode->insertItem(0, tr("Dimension"));
@@ -185,7 +190,7 @@ void TaskPocketParameters::updateUI(int index)
ui->lineFaceName->setEnabled(true);
QMetaObject::invokeMethod(ui->lineFaceName, "setFocus", Qt::QueuedConnection);
// Go into reference selection mode if no face has been selected yet
if (ui->lineFaceName->text().isEmpty())
if (ui->lineFaceName->text().isEmpty() || (ui->lineFaceName->text() == tr("No face selected")))
onButtonFace(true);
}
}
@@ -309,7 +314,10 @@ int TaskPocketParameters::getMode(void) const
QByteArray TaskPocketParameters::getFaceName(void) const
{
return ui->lineFaceName->property("FaceName").toByteArray();
if ((getMode() >= 1) || (getMode() <= 3))
return getFaceReference(ui->lineFaceName->text(), ui->lineFaceName->property("FaceName").toString()).toLatin1();
else
return "";
}
const bool TaskPocketParameters::updateView() const
@@ -338,14 +346,15 @@ void TaskPocketParameters::changeEvent(QEvent *e)
ui->changeMode->addItem(tr("Up to face"));
ui->changeMode->setCurrentIndex(index);
QByteArray upToFace = this->getFaceName();
QStringList parts = ui->lineFaceName->text().split(QChar::fromAscii(':'));
QByteArray upToFace = ui->lineFaceName->property("FaceName").toByteArray();
int faceId = -1;
bool ok = false;
if (upToFace.indexOf("Face") == 0) {
faceId = upToFace.remove(0,4).toInt(&ok);
}
ui->lineFaceName->setText(ok ?
tr("Face") + QString::number(faceId) :
parts[0] + tr(":Face") + QString::number(faceId) :
tr("No face selected"));
ui->pocketLength->blockSignals(false);
ui->lineFaceName->blockSignals(false);
@@ -361,13 +370,9 @@ void TaskPocketParameters::apply()
ui->pocketLength->apply();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Type = %u",name.c_str(),getMode());
std::string facename = getFaceName().data();
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(vp->getObject());
Part::Feature* support = pcPocket->getSupport();
if (support != NULL && !facename.empty()) {
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
buf = buf.arg(QString::fromUtf8(support->getNameInDocument()));
buf = buf.arg(QString::fromStdString(facename));
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = %s", name.c_str(), buf.toStdString().c_str());
if (!facename.empty()) {
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = %s", name.c_str(), facename.c_str());
} else
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.UpToFace = None", name.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %i", name.c_str(), getReversed()?1:0);