Surface: automatically start "Add edge" mode when starting the fill surface tool. Moving the order of edges is supported now.

This commit is contained in:
wmayer
2020-10-13 17:32:20 +02:00
parent 255ef44c93
commit 72bcdf8c89
3 changed files with 53 additions and 1 deletions

View File

@@ -275,6 +275,9 @@ FillingPanel::FillingPanel(ViewProviderFilling* vp, Surface::Filling* obj)
ui->listBoundary->addAction(action);
connect(action, SIGNAL(triggered()), this, SLOT(onDeleteEdge()));
ui->listBoundary->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(ui->listBoundary->model(),
SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)), this, SLOT(onIndexesMoved()));
}
/*
@@ -379,6 +382,11 @@ void FillingPanel::open()
this->vp->highlightReferences(ViewProviderFilling::Face, links, true);
Gui::Selection().clearSelection();
// if the surface is not yet created then automatically start "AppendEdge" mode
if (editedObject->Shape.getShape().isNull()) {
on_buttonEdgeAdd_clicked();
}
}
void FillingPanel::clearSelection()
@@ -744,6 +752,42 @@ void FillingPanel::onDeleteEdge()
}
}
void FillingPanel::onIndexesMoved()
{
QAbstractItemModel* model = qobject_cast<QAbstractItemModel*>(sender());
if (!model)
return;
std::vector<App::DocumentObject*> objects;
std::vector<std::string> element;
std::vector<std::string> faces;
std::vector<long> order;
int rows = model->rowCount();
for (int i = 0; i < rows; i++) {
QModelIndex index = model->index(i, 0);
QList<QVariant> data;
data = index.data(Qt::UserRole).toList();
App::Document* doc = App::GetApplication().getDocument(data[0].toByteArray());
App::DocumentObject* obj = doc ? doc->getObject(data[1].toByteArray()) : nullptr;
std::string sub = data[2].toByteArray().constData();
std::string face = data[3].toByteArray().constData();
long cont = data[4].toInt();
objects.push_back(obj);
element.push_back(sub);
faces.push_back(face);
order.push_back(cont);
}
editedObject->BoundaryEdges.setValues(objects, element);
editedObject->BoundaryFaces.setValues(faces);
editedObject->BoundaryOrder.setValues(order);
editedObject->recomputeFeature();
}
void FillingPanel::on_buttonAccept_clicked()
{
QListWidgetItem* item = ui->listBoundary->currentItem();

View File

@@ -101,6 +101,7 @@ private Q_SLOTS:
void on_buttonAccept_clicked();
void on_buttonIgnore_clicked();
void onDeleteEdge(void);
void onIndexesMoved();
void clearSelection();
};

View File

@@ -48,7 +48,14 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="3">
<widget class="QListWidget" name="listBoundary"/>
<widget class="QListWidget" name="listBoundary">
<property name="toolTip">
<string>List can be reordered by dragging</string>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">