void TaskPadParameters::onFaceName(const QString& text)
{
    // We must expect that "text" is the translation of "Face" followed by an ID.
    QString name;
    QTextStream str(&name);
    str << "^" << tr("Face") << "(\\d+)$";
    QRegExp rx(name);
    if (text.indexOf(rx) < 0) {
        ui->lineFaceName->setProperty("FaceName", QByteArray());
        return;
    }

    int faceId = rx.cap(1).toInt();
    std::stringstream ss;
    ss << "Face" << faceId;
    ui->lineFaceName->setProperty("FaceName", QByteArray(ss.str().c_str()));

    PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
    Part::Feature* support = pcPad->getSupport();
    if (support == NULL) {
        // There is no support, so we can't select from it...
        return;
    }
    std::vector<std::string> upToFaces(1,ss.str());
    pcPad->UpToFace.setValue(support, upToFaces);
    if (updateView())
        pcPad->getDocument()->recomputeFeature(pcPad);
}
void TaskPadParameters::onUpdateView(bool on)
{
    if (on) {
        PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
        pcPad->getDocument()->recomputeFeature(pcPad);
    }
}
void TaskPadParameters::onLength2Changed(double len)
{
    PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
    pcPad->Length2.setValue(len);
    if (updateView())
        pcPad->getDocument()->recomputeFeature(pcPad);
}
void TaskPadParameters::onReversed(bool on)
{
    PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
    pcPad->Reversed.setValue(on);
    if (updateView())
        pcPad->getDocument()->recomputeFeature(pcPad);
}
void TaskPadParameters::onMidplane(bool on)
{
    PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
    pcPad->Midplane.setValue(on);
    ui->checkBoxReversed->setEnabled(!on);
    if (updateView())
        pcPad->getDocument()->recomputeFeature(pcPad);
}
Beispiel #6
0
void TaskPadParameters::onFaceName(const QString& text)
{
    if (text.left(4) != tr("Face"))
      return;

    PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
    pcPad->FaceName.setValue(text.toUtf8());
    pcPad->getDocument()->recomputeFeature(pcPad);
}
Beispiel #7
0
void TaskPadParameters::onModeChanged(int index)
{
    PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());

    switch (index) {
        case 0: pcPad->Type.setValue("Length"); break;
        case 1: pcPad->Type.setValue("UpToLast"); break;
        case 2: pcPad->Type.setValue("UpToFirst"); break;
        case 3: pcPad->Type.setValue("UpToFace"); break;
        default: pcPad->Type.setValue("TwoLengths");
    }

    updateUI(index);

    pcPad->getDocument()->recomputeFeature(pcPad);
}
Beispiel #8
0
void TaskPadParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
{
    PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
    if (pcPad->Type.getValue() != 3) // ignore user selections if mode is not upToFace
        return;

    if (!msg.pSubName || msg.pSubName[0] == '\0')
        return;
    std::string element(msg.pSubName);
    if (element.substr(0,4) != "Face")
      return;

    if (msg.Type == Gui::SelectionChanges::AddSelection) {
        pcPad->FaceName.setValue(element);
        pcPad->getDocument()->recomputeFeature(pcPad);
        ui->lineFaceName->setText(tr(element.c_str()));
    }
}
void TaskPadParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
{
    if (msg.Type == Gui::SelectionChanges::AddSelection) {
        // Don't allow selection in other document
        if (strcmp(msg.pDocName, PadView->getObject()->getDocument()->getName()) != 0)
            return;

        if (!msg.pSubName || msg.pSubName[0] == '\0')
            return;
        std::string subName(msg.pSubName);
        if (subName.substr(0,4) != "Face")
            return;
        int faceId = std::atoi(&subName[4]);

        // Don't allow selection outside support
        PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
        Part::Feature* support = pcPad->getSupport();
        if (support == NULL) {
            // There is no support, so we can't select from it...
            // Turn off reference selection mode
            onButtonFace(false);
            return;
        }
        if (strcmp(msg.pObjectName, support->getNameInDocument()) != 0)
            return;

        std::vector<std::string> upToFaces(1,subName);
        pcPad->UpToFace.setValue(support, upToFaces);
        if (updateView())
            pcPad->getDocument()->recomputeFeature(pcPad);
        ui->lineFaceName->blockSignals(true);
        ui->lineFaceName->setText(tr("Face") + QString::number(faceId));
        ui->lineFaceName->setProperty("FaceName", QByteArray(subName.c_str()));
        ui->lineFaceName->blockSignals(false);
        // Turn off reference selection mode
        onButtonFace(false);
    }
    else if (msg.Type == Gui::SelectionChanges::ClrSelection) {
        ui->lineFaceName->blockSignals(true);
        ui->lineFaceName->setText(tr("No face selected"));
        ui->lineFaceName->setProperty("FaceName", QByteArray());
        ui->lineFaceName->blockSignals(false);
    }
}
void TaskPadParameters::onModeChanged(int index)
{
    PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());

    switch (index) {
        case 0:
            pcPad->Type.setValue("Length");
            // Avoid error message
            if (ui->lengthEdit->getQuantity() < Precision::Confusion())
                ui->lengthEdit->setValue(5.0);
            break;
        case 1: pcPad->Type.setValue("UpToLast"); break;
        case 2: pcPad->Type.setValue("UpToFirst"); break;
        case 3: pcPad->Type.setValue("UpToFace"); break;
        default: pcPad->Type.setValue("TwoLengths");
    }

    updateUI(index);

    if (updateView())
        pcPad->getDocument()->recomputeFeature(pcPad);
}
Beispiel #11
0
void TaskPadParameters::onMidplane(bool on)
{
    PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(PadView->getObject());
    pcPad->Midplane.setValue(on);
    pcPad->getDocument()->recomputeFeature(pcPad);
}