void TaskDraftParameters::onAngleChanged(double angle) { clearButtons(none); PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DressUpView->getObject()); pcDraft->Angle.setValue(angle); pcDraft->getDocument()->recomputeFeature(pcDraft); }
void TaskDraftParameters::onFaceDeleted(void) { PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DraftView->getObject()); App::DocumentObject* base = pcDraft->Base.getValue(); std::vector<std::string> faces = pcDraft->Base.getSubValues(); faces.erase(faces.begin() + ui->listWidgetFaces->currentRow()); pcDraft->Base.setValue(base, faces); ui->listWidgetFaces->model()->removeRow(ui->listWidgetFaces->currentRow()); pcDraft->getDocument()->recomputeFeature(pcDraft); }
void TaskDraftParameters::onSelectionChanged(const Gui::SelectionChanges& msg) { if (selectionMode == none) return; if (msg.Type == Gui::SelectionChanges::AddSelection) { if (referenceSelected(msg)) { if (selectionMode == refAdd) ui->listWidgetReferences->addItem(QString::fromStdString(msg.pSubName)); else removeItemFromListWidget(ui->listWidgetReferences, msg.pSubName); clearButtons(none); exitSelectionMode(); } else if (selectionMode == plane) { PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DressUpView->getObject()); std::vector<std::string> planes; App::DocumentObject* selObj; getReferencedSelection(pcDraft, msg, selObj, planes); if(!selObj) return; pcDraft->NeutralPlane.setValue(selObj, planes); ui->linePlane->setText(getRefStr(selObj, planes)); pcDraft->getDocument()->recomputeFeature(pcDraft); clearButtons(none); exitSelectionMode(); } else if (selectionMode == line) { PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DressUpView->getObject()); std::vector<std::string> edges; App::DocumentObject* selObj; getReferencedSelection(pcDraft, msg, selObj, edges); if(!selObj) return; pcDraft->PullDirection.setValue(selObj, edges); ui->lineLine->setText(getRefStr(selObj, edges)); pcDraft->getDocument()->recomputeFeature(pcDraft); clearButtons(none); exitSelectionMode(); } } }
void TaskDraftParameters::onReversedChanged(const bool on) { PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DraftView->getObject()); pcDraft->Reversed.setValue(on); pcDraft->getDocument()->recomputeFeature(pcDraft); }
void TaskDraftParameters::onAngleChanged(double angle) { PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DraftView->getObject()); pcDraft->Angle.setValue((float)angle); pcDraft->getDocument()->recomputeFeature(pcDraft); }
void TaskDraftParameters::onSelectionChanged(const Gui::SelectionChanges& msg) { if (selectionMode == none) return; if (msg.Type == Gui::SelectionChanges::AddSelection) { if (strcmp(msg.pDocName, DraftView->getObject()->getDocument()->getName()) != 0) return; PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DraftView->getObject()); App::DocumentObject* base = this->getBase(); // TODO: Must we make a copy here instead of assigning to const char* ? const char* fname = base->getNameInDocument(); std::string subName(msg.pSubName); if ((selectionMode == faceAdd) && (subName.size() > 4 && subName.substr(0,4) == "Face")) { if (strcmp(msg.pObjectName, fname) != 0) return; std::vector<std::string> faces = pcDraft->Base.getSubValues(); if (std::find(faces.begin(), faces.end(), subName) == faces.end()) { faces.push_back(subName); pcDraft->Base.setValue(base, faces); ui->listWidgetFaces->insertItem(0, QString::fromStdString(subName)); pcDraft->getDocument()->recomputeFeature(pcDraft); ui->buttonFaceAdd->setChecked(false); exitSelectionMode(); } } else if ((selectionMode == faceRemove) && (subName.size() > 4 && subName.substr(0,4) == "Face")) { if (strcmp(msg.pObjectName, fname) != 0) return; std::vector<std::string> faces = pcDraft->Base.getSubValues(); std::vector<std::string>::iterator f = std::find(faces.begin(), faces.end(), subName); if (f != faces.end()) { faces.erase(f); pcDraft->Base.setValue(base, faces); QList<QListWidgetItem*> items = ui->listWidgetFaces->findItems(QString::fromStdString(subName), Qt::MatchExactly); if (!items.empty()) { for (QList<QListWidgetItem*>::const_iterator i = items.begin(); i != items.end(); i++) { QListWidgetItem* it = ui->listWidgetFaces->takeItem(ui->listWidgetFaces->row(*i)); delete it; } } pcDraft->getDocument()->recomputeFeature(pcDraft); ui->buttonFaceRemove->setChecked(false); exitSelectionMode(); } } else if ((selectionMode == plane) && (subName.size() > 4) && ((subName.substr(0,4) == "Face") || (subName.substr(0,4) == "Edge"))) { if (strcmp(msg.pObjectName, fname) != 0) return; std::vector<std::string> planes(1,subName); pcDraft->NeutralPlane.setValue(base, planes); ui->linePlane->setText(QString::fromStdString(subName)); pcDraft->getDocument()->recomputeFeature(pcDraft); ui->buttonPlane->setChecked(false); exitSelectionMode(); } else if ((selectionMode == line) && (subName.size() > 4 && subName.substr(0,4) == "Edge")) { if (strcmp(msg.pObjectName, fname) != 0) return; std::vector<std::string> edges(1,subName); pcDraft->PullDirection.setValue(base, edges); ui->lineLine->setText(QString::fromStdString(subName)); pcDraft->getDocument()->recomputeFeature(pcDraft); ui->buttonLine->setChecked(false); exitSelectionMode(); } } }