| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #include <limits> |
| |
|
| | #include <QPushButton> |
| |
|
| |
|
| | #include <Gui/Application.h> |
| | #include <Gui/Document.h> |
| | #include <Gui/Selection/Selection.h> |
| |
|
| | #include "RemoveComponents.h" |
| | #include "ui_RemoveComponents.h" |
| |
|
| |
|
| | using namespace MeshGui; |
| |
|
| | RemoveComponents::RemoveComponents(QWidget* parent, Qt::WindowFlags fl) |
| | : QWidget(parent, fl) |
| | , ui(new Ui_RemoveComponents) |
| | { |
| | ui->setupUi(this); |
| | setupConnections(); |
| | ui->spSelectComp->setRange(1, std::numeric_limits<int>::max()); |
| | ui->spSelectComp->setValue(10); |
| | ui->spDeselectComp->setRange(1, std::numeric_limits<int>::max()); |
| | ui->spDeselectComp->setValue(10); |
| |
|
| | Gui::Selection().clearSelection(); |
| | meshSel.setCheckOnlyVisibleTriangles(ui->visibleTriangles->isChecked()); |
| | meshSel.setCheckOnlyPointToUserTriangles(ui->screenTriangles->isChecked()); |
| | meshSel.setEnabledViewerSelection(false); |
| | } |
| |
|
| | RemoveComponents::~RemoveComponents() |
| | { |
| | |
| | delete ui; |
| | } |
| |
|
| | void RemoveComponents::setupConnections() |
| | { |
| | |
| | connect(ui->selectRegion, &QPushButton::clicked, |
| | this, &RemoveComponents::onSelectRegionClicked); |
| | connect(ui->selectAll, &QPushButton::clicked, |
| | this, &RemoveComponents::onSelectAllClicked); |
| | connect(ui->selectComponents, &QPushButton::clicked, |
| | this, &RemoveComponents::onSelectComponentsClicked); |
| | connect(ui->selectTriangle, &QPushButton::clicked, |
| | this, &RemoveComponents::onSelectTriangleClicked); |
| | connect(ui->deselectRegion, &QPushButton::clicked, |
| | this, &RemoveComponents::onDeselectRegionClicked); |
| | connect(ui->deselectAll, &QPushButton::clicked, |
| | this, &RemoveComponents::onDeselectAllClicked); |
| | connect(ui->deselectComponents, &QPushButton::clicked, |
| | this, &RemoveComponents::onDeselectComponentsClicked); |
| | connect(ui->deselectTriangle, &QPushButton::clicked, |
| | this, &RemoveComponents::onDeselectTriangleClicked); |
| | connect(ui->visibleTriangles, &QCheckBox::toggled, |
| | this, &RemoveComponents::onVisibleTrianglesToggled); |
| | connect(ui->screenTriangles, &QCheckBox::toggled, |
| | this, &RemoveComponents::onScreenTrianglesToggled); |
| | connect(ui->cbSelectComp, &QCheckBox::toggled, |
| | this, &RemoveComponents::onSelectCompToggled); |
| | connect(ui->cbDeselectComp, &QCheckBox::toggled, |
| | this, &RemoveComponents::onDeselectCompToggled); |
| | |
| | } |
| |
|
| | void RemoveComponents::changeEvent(QEvent* e) |
| | { |
| | if (e->type() == QEvent::LanguageChange) { |
| | ui->retranslateUi(this); |
| | } |
| | QWidget::changeEvent(e); |
| | } |
| |
|
| | void RemoveComponents::onSelectRegionClicked() |
| | { |
| | meshSel.startSelection(); |
| | } |
| |
|
| | void RemoveComponents::onDeselectRegionClicked() |
| | { |
| | meshSel.startDeselection(); |
| | } |
| |
|
| | void RemoveComponents::onSelectAllClicked() |
| | { |
| | |
| | meshSel.fullSelection(); |
| | } |
| |
|
| | void RemoveComponents::onDeselectAllClicked() |
| | { |
| | |
| | meshSel.clearSelection(); |
| | } |
| |
|
| | void RemoveComponents::onSelectComponentsClicked() |
| | { |
| | |
| | int size = ui->spSelectComp->value(); |
| | meshSel.selectComponent(size); |
| | } |
| |
|
| | void RemoveComponents::onDeselectComponentsClicked() |
| | { |
| | |
| | int size = ui->spDeselectComp->value(); |
| | meshSel.deselectComponent(size); |
| | } |
| |
|
| | void RemoveComponents::onVisibleTrianglesToggled(bool on) |
| | { |
| | meshSel.setCheckOnlyVisibleTriangles(on); |
| | } |
| |
|
| | void RemoveComponents::onScreenTrianglesToggled(bool on) |
| | { |
| | meshSel.setCheckOnlyPointToUserTriangles(on); |
| | } |
| |
|
| | void RemoveComponents::onSelectCompToggled(bool on) |
| | { |
| | meshSel.setAddComponentOnClick(on); |
| | } |
| |
|
| | void RemoveComponents::onDeselectCompToggled(bool on) |
| | { |
| | meshSel.setRemoveComponentOnClick(on); |
| | } |
| |
|
| | void RemoveComponents::deleteSelection() |
| | { |
| | Gui::Document* doc = Gui::Application::Instance->activeDocument(); |
| | if (!doc) { |
| | return; |
| | } |
| | |
| | doc->openCommand(QT_TRANSLATE_NOOP("Command", "Delete selection")); |
| | bool ok = meshSel.deleteSelection(); |
| | if (!ok) { |
| | doc->abortCommand(); |
| | } |
| | else { |
| | doc->commitCommand(); |
| | } |
| | } |
| |
|
| | void RemoveComponents::invertSelection() |
| | { |
| | meshSel.invertSelection(); |
| | } |
| |
|
| | void RemoveComponents::onSelectTriangleClicked() |
| | { |
| | meshSel.selectTriangle(); |
| | meshSel.setAddComponentOnClick(ui->cbSelectComp->isChecked()); |
| | } |
| |
|
| | void RemoveComponents::onDeselectTriangleClicked() |
| | { |
| | meshSel.deselectTriangle(); |
| | meshSel.setRemoveComponentOnClick(ui->cbDeselectComp->isChecked()); |
| | } |
| |
|
| | void RemoveComponents::reject() |
| | { |
| | |
| | meshSel.clearSelection(); |
| | meshSel.setEnabledViewerSelection(true); |
| | } |
| |
|
| | |
| |
|
| | RemoveComponentsDialog::RemoveComponentsDialog(QWidget* parent, Qt::WindowFlags fl) |
| | : QDialog(parent, fl) |
| | { |
| | widget = new RemoveComponents(this); |
| | this->setWindowTitle(widget->windowTitle()); |
| |
|
| | QVBoxLayout* hboxLayout = new QVBoxLayout(this); |
| | QDialogButtonBox* buttonBox = new QDialogButtonBox(this); |
| | buttonBox->setStandardButtons(QDialogButtonBox::Close | QDialogButtonBox::Ok); |
| | QPushButton* okButton = buttonBox->button(QDialogButtonBox::Ok); |
| | okButton->setText(MeshGui::TaskRemoveComponents::tr("Delete")); |
| | buttonBox->addButton(MeshGui::TaskRemoveComponents::tr("Invert"), QDialogButtonBox::ActionRole); |
| |
|
| | connect(buttonBox, &QDialogButtonBox::clicked, this, &RemoveComponentsDialog::clicked); |
| |
|
| | hboxLayout->addWidget(widget); |
| | hboxLayout->addWidget(buttonBox); |
| | } |
| |
|
| | RemoveComponentsDialog::~RemoveComponentsDialog() = default; |
| |
|
| | void RemoveComponentsDialog::reject() |
| | { |
| | widget->reject(); |
| | QDialog::reject(); |
| | } |
| |
|
| | void RemoveComponentsDialog::clicked(QAbstractButton* btn) |
| | { |
| | QDialogButtonBox* buttonBox = qobject_cast<QDialogButtonBox*>(sender()); |
| | QDialogButtonBox::StandardButton id = buttonBox->standardButton(btn); |
| | if (id == QDialogButtonBox::Ok) { |
| | widget->deleteSelection(); |
| | } |
| | else if (id == QDialogButtonBox::Close) { |
| | this->reject(); |
| | } |
| | else if (id == QDialogButtonBox::NoButton) { |
| | widget->invertSelection(); |
| | } |
| | } |
| |
|
| | |
| |
|
| | |
| |
|
| | TaskRemoveComponents::TaskRemoveComponents() |
| | { |
| | widget = new RemoveComponents(); |
| | addTaskBox(widget, false); |
| | } |
| |
|
| | void TaskRemoveComponents::modifyStandardButtons(QDialogButtonBox* box) |
| | { |
| | QPushButton* btn = box->button(QDialogButtonBox::Ok); |
| | btn->setText(tr("Delete")); |
| | box->addButton(tr("Invert"), QDialogButtonBox::ActionRole); |
| | } |
| |
|
| | bool TaskRemoveComponents::accept() |
| | { |
| | return false; |
| | } |
| |
|
| | void TaskRemoveComponents::clicked(int id) |
| | { |
| | if (id == QDialogButtonBox::Ok) { |
| | widget->deleteSelection(); |
| | } |
| | else if (id == QDialogButtonBox::Close) { |
| | widget->reject(); |
| | } |
| | else if (id == QDialogButtonBox::NoButton) { |
| | widget->invertSelection(); |
| | } |
| | } |
| |
|
| | #include "moc_RemoveComponents.cpp" |
| |
|