Extend task panel for filling function
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
#include <QTimer>
|
||||
#include <TopExp.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Gui/Application.h>
|
||||
@@ -171,7 +173,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
bool allowFace(App::DocumentObject* pObj, const char* sSubName)
|
||||
bool allowFace(App::DocumentObject*, const char* sSubName)
|
||||
{
|
||||
std::string element(sSubName);
|
||||
if (element.substr(0,4) != "Face")
|
||||
@@ -216,9 +218,9 @@ FillingPanel::FillingPanel(ViewProviderFilling* vp, Surface::Filling* obj)
|
||||
// Create context menu
|
||||
QAction* action = new QAction(tr("Remove"), this);
|
||||
action->setShortcut(QString::fromLatin1("Del"));
|
||||
ui->listWidget->addAction(action);
|
||||
ui->listBoundary->addAction(action);
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(onDeleteEdge()));
|
||||
ui->listWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
ui->listBoundary->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -251,8 +253,8 @@ void FillingPanel::setEditedObject(Surface::Filling* obj)
|
||||
|
||||
App::Document* doc = editedObject->getDocument();
|
||||
for (; it != objects.end() && jt != element.end(); ++it, ++jt) {
|
||||
QListWidgetItem* item = new QListWidgetItem(ui->listWidget);
|
||||
ui->listWidget->addItem(item);
|
||||
QListWidgetItem* item = new QListWidgetItem(ui->listBoundary);
|
||||
ui->listBoundary->addItem(item);
|
||||
|
||||
QString text = QString::fromLatin1("%1.%2")
|
||||
.arg(QString::fromUtf8((*it)->Label.getValue()))
|
||||
@@ -370,6 +372,56 @@ void FillingPanel::on_buttonEdgeRemove_clicked()
|
||||
Gui::Selection().addSelectionGate(new ShapeSelection(selectionMode, editedObject));
|
||||
}
|
||||
|
||||
void FillingPanel::on_listBoundary_itemDoubleClicked(QListWidgetItem* item)
|
||||
{
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().rmvSelectionGate();
|
||||
selectionMode = None;
|
||||
ui->comboBoxFaces->clear();
|
||||
ui->comboBoxCont->clear();
|
||||
|
||||
if (item) {
|
||||
modifyBorder(true);
|
||||
|
||||
QList<QVariant> data;
|
||||
data = item->data(Qt::UserRole).toList();
|
||||
|
||||
try {
|
||||
App::Document* doc = App::GetApplication().getDocument(data[0].toByteArray());
|
||||
App::DocumentObject* obj = doc ? doc->getObject(data[1].toByteArray()) : nullptr;
|
||||
if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
const Part::TopoShape& shape = static_cast<Part::Feature*>(obj)->Shape.getShape();
|
||||
TopoDS_Shape edge = shape.getSubShape(data[2].toByteArray());
|
||||
|
||||
// build up map edge->face
|
||||
TopTools_IndexedMapOfShape faces;
|
||||
TopExp::MapShapes(shape.getShape(), TopAbs_FACE, faces);
|
||||
TopTools_IndexedDataMapOfShapeListOfShape edge2Face;
|
||||
TopExp::MapShapesAndAncestors(shape.getShape(), TopAbs_EDGE, TopAbs_FACE, edge2Face);
|
||||
const TopTools_ListOfShape& adj_faces = edge2Face.FindFromKey(edge);
|
||||
if (adj_faces.Extent() > 0) {
|
||||
ui->comboBoxFaces->addItem(tr("None"));
|
||||
ui->comboBoxCont->addItem(QString::fromLatin1("C0"));
|
||||
ui->comboBoxCont->addItem(QString::fromLatin1("G1"));
|
||||
ui->comboBoxCont->addItem(QString::fromLatin1("G2"));
|
||||
TopTools_ListIteratorOfListOfShape it(adj_faces);
|
||||
for (; it.More(); it.Next()) {
|
||||
const TopoDS_Shape& F = it.Value();
|
||||
int index = faces.FindIndex(F);
|
||||
ui->comboBoxFaces->addItem(QString::fromLatin1("Face%1").arg(index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Gui::Selection().addSelection(data[0].toByteArray(),
|
||||
data[1].toByteArray(),
|
||||
data[2].toByteArray());
|
||||
}
|
||||
catch (...) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
if (selectionMode == None)
|
||||
@@ -393,8 +445,8 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
selectionMode = None;
|
||||
}
|
||||
else if (selectionMode == AppendEdge) {
|
||||
QListWidgetItem* item = new QListWidgetItem(ui->listWidget);
|
||||
ui->listWidget->addItem(item);
|
||||
QListWidgetItem* item = new QListWidgetItem(ui->listBoundary);
|
||||
ui->listBoundary->addItem(item);
|
||||
|
||||
Gui::SelectionObject sel(msg);
|
||||
QString text = QString::fromLatin1("%1.%2")
|
||||
@@ -421,10 +473,10 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
data << QByteArray(msg.pDocName);
|
||||
data << QByteArray(msg.pObjectName);
|
||||
data << QByteArray(msg.pSubName);
|
||||
for (int i=0; i<ui->listWidget->count(); i++) {
|
||||
QListWidgetItem* item = ui->listWidget->item(i);
|
||||
for (int i=0; i<ui->listBoundary->count(); i++) {
|
||||
QListWidgetItem* item = ui->listBoundary->item(i);
|
||||
if (item && item->data(Qt::UserRole) == data) {
|
||||
ui->listWidget->takeItem(i);
|
||||
ui->listBoundary->takeItem(i);
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
@@ -454,13 +506,13 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
|
||||
void FillingPanel::onDeleteEdge()
|
||||
{
|
||||
int row = ui->listWidget->currentRow();
|
||||
QListWidgetItem* item = ui->listWidget->item(row);
|
||||
int row = ui->listBoundary->currentRow();
|
||||
QListWidgetItem* item = ui->listBoundary->item(row);
|
||||
if (item) {
|
||||
checkOpenCommand();
|
||||
QList<QVariant> data;
|
||||
data = item->data(Qt::UserRole).toList();
|
||||
ui->listWidget->takeItem(row);
|
||||
ui->listBoundary->takeItem(row);
|
||||
delete item;
|
||||
|
||||
App::Document* doc = App::GetApplication().getDocument(data[0].toByteArray());
|
||||
@@ -483,6 +535,30 @@ void FillingPanel::onDeleteEdge()
|
||||
}
|
||||
}
|
||||
|
||||
void FillingPanel::on_buttonAccept_clicked()
|
||||
{
|
||||
modifyBorder(false);
|
||||
}
|
||||
|
||||
void FillingPanel::on_buttonIgnore_clicked()
|
||||
{
|
||||
modifyBorder(false);
|
||||
}
|
||||
|
||||
void FillingPanel::modifyBorder(bool on)
|
||||
{
|
||||
ui->buttonInitFace->setDisabled(on);
|
||||
ui->lineInitFaceName->setDisabled(on);
|
||||
ui->buttonEdgeAdd->setDisabled(on);
|
||||
ui->buttonEdgeRemove->setDisabled(on);
|
||||
ui->listBoundary->setDisabled(on);
|
||||
|
||||
ui->comboBoxFaces->setEnabled(on);
|
||||
ui->comboBoxCont->setEnabled(on);
|
||||
ui->buttonAccept->setEnabled(on);
|
||||
ui->buttonIgnore->setEnabled(on);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
TaskFilling::TaskFilling(ViewProviderFilling* vp, Surface::Filling* obj)
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#include <Mod/Part/Gui/ViewProviderSpline.h>
|
||||
#include <Mod/Surface/App/FeatureFilling.h>
|
||||
|
||||
class QListWidgetItem;
|
||||
|
||||
namespace SurfaceGui
|
||||
{
|
||||
|
||||
@@ -81,12 +83,16 @@ protected:
|
||||
virtual void slotUndoDocument(const Gui::Document& Doc);
|
||||
/** Notifies on redo */
|
||||
virtual void slotRedoDocument(const Gui::Document& Doc);
|
||||
void modifyBorder(bool);
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_buttonInitFace_clicked();
|
||||
void on_buttonEdgeAdd_clicked();
|
||||
void on_buttonEdgeRemove_clicked();
|
||||
void on_lineInitFaceName_textChanged(const QString&);
|
||||
void on_listBoundary_itemDoubleClicked(QListWidgetItem*);
|
||||
void on_buttonAccept_clicked();
|
||||
void on_buttonIgnore_clicked();
|
||||
void onDeleteEdge(void);
|
||||
void clearSelection();
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<property name="windowTitle">
|
||||
<string>Filling</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
@@ -39,43 +39,113 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonEdgeAdd">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add Edge</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonEdgeRemove">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove Edge</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QListWidget" name="listWidget"/>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Boundary</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="QListWidget" name="listBoundary"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Faces:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="comboBoxFaces">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Continuity:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="comboBoxCont">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>74</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="buttonAccept">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Accept</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QPushButton" name="buttonIgnore">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ignore</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonEdgeAdd">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add Edge</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonEdgeRemove">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove Edge</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
Reference in New Issue
Block a user