0000596: Edge chain selection
This commit is contained in:
parent
efd0274d47
commit
d4d4c8dc62
|
@ -30,6 +30,7 @@
|
||||||
# include <TopoDS_Edge.hxx>
|
# include <TopoDS_Edge.hxx>
|
||||||
# include <TopoDS_Shape.hxx>
|
# include <TopoDS_Shape.hxx>
|
||||||
# include <TopExp.hxx>
|
# include <TopExp.hxx>
|
||||||
|
# include <TopExp_Explorer.hxx>
|
||||||
# include <TopTools_ListOfShape.hxx>
|
# include <TopTools_ListOfShape.hxx>
|
||||||
# include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
# include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
|
||||||
# include <TopTools_IndexedMapOfShape.hxx>
|
# include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
@ -133,14 +134,23 @@ bool FilletRadiusModel::setData (const QModelIndex & index, const QVariant & val
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
|
|
||||||
namespace PartGui {
|
namespace PartGui {
|
||||||
class EdgeSelection : public Gui::SelectionFilterGate
|
class EdgeFaceSelection : public Gui::SelectionFilterGate
|
||||||
{
|
{
|
||||||
|
bool allowEdge;
|
||||||
App::DocumentObject*& object;
|
App::DocumentObject*& object;
|
||||||
public:
|
public:
|
||||||
EdgeSelection(App::DocumentObject*& obj)
|
EdgeFaceSelection(App::DocumentObject*& obj)
|
||||||
: Gui::SelectionFilterGate((Gui::SelectionFilter*)0), object(obj)
|
: Gui::SelectionFilterGate((Gui::SelectionFilter*)0), allowEdge(true), object(obj)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
void selectEdges()
|
||||||
|
{
|
||||||
|
allowEdge = true;
|
||||||
|
}
|
||||||
|
void selectFaces()
|
||||||
|
{
|
||||||
|
allowEdge = false;
|
||||||
|
}
|
||||||
bool allow(App::Document*pDoc, App::DocumentObject*pObj, const char*sSubName)
|
bool allow(App::Document*pDoc, App::DocumentObject*pObj, const char*sSubName)
|
||||||
{
|
{
|
||||||
if (pObj != this->object)
|
if (pObj != this->object)
|
||||||
|
@ -148,16 +158,21 @@ namespace PartGui {
|
||||||
if (!sSubName || sSubName[0] == '\0')
|
if (!sSubName || sSubName[0] == '\0')
|
||||||
return false;
|
return false;
|
||||||
std::string element(sSubName);
|
std::string element(sSubName);
|
||||||
|
if (allowEdge)
|
||||||
return element.substr(0,4) == "Edge";
|
return element.substr(0,4) == "Edge";
|
||||||
|
else
|
||||||
|
return element.substr(0,4) == "Face";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
class DlgFilletEdgesP
|
class DlgFilletEdgesP
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
App::DocumentObject* object;
|
App::DocumentObject* object;
|
||||||
EdgeSelection* selection;
|
EdgeFaceSelection* selection;
|
||||||
Part::FilletBase* fillet;
|
Part::FilletBase* fillet;
|
||||||
std::vector<int> edge_ids;
|
std::vector<int> edge_ids;
|
||||||
|
TopTools_IndexedMapOfShape all_edges;
|
||||||
|
TopTools_IndexedMapOfShape all_faces;
|
||||||
typedef boost::signals::connection Connection;
|
typedef boost::signals::connection Connection;
|
||||||
Connection connectApplicationDeletedObject;
|
Connection connectApplicationDeletedObject;
|
||||||
Connection connectApplicationDeletedDocument;
|
Connection connectApplicationDeletedDocument;
|
||||||
|
@ -172,7 +187,7 @@ DlgFilletEdges::DlgFilletEdges(Part::FilletBase* fillet, QWidget* parent, Qt::WF
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
d->object = 0;
|
d->object = 0;
|
||||||
d->selection = new EdgeSelection(d->object);
|
d->selection = new EdgeFaceSelection(d->object);
|
||||||
Gui::Selection().addSelectionGate(d->selection);
|
Gui::Selection().addSelectionGate(d->selection);
|
||||||
|
|
||||||
d->fillet = fillet;
|
d->fillet = fillet;
|
||||||
|
@ -225,6 +240,21 @@ void DlgFilletEdges::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||||
std::string objname = d->object->getNameInDocument();
|
std::string objname = d->object->getNameInDocument();
|
||||||
if (docname==msg.pDocName && objname==msg.pObjectName) {
|
if (docname==msg.pDocName && objname==msg.pObjectName) {
|
||||||
QString subelement = QString::fromAscii(msg.pSubName);
|
QString subelement = QString::fromAscii(msg.pSubName);
|
||||||
|
if (subelement.startsWith(QLatin1String("Edge"))) {
|
||||||
|
onSelectEdge(subelement, msg.Type);
|
||||||
|
}
|
||||||
|
else if (subelement.startsWith(QLatin1String("Face"))) {
|
||||||
|
d->selection->selectEdges();
|
||||||
|
onSelectEdgesOfFace(subelement, msg.Type);
|
||||||
|
d->selection->selectFaces();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DlgFilletEdges::onSelectEdge(const QString& subelement, int type)
|
||||||
|
{
|
||||||
|
Gui::SelectionChanges::MsgType msgType = Gui::SelectionChanges::MsgType(type);
|
||||||
QAbstractItemModel* model = ui->treeView->model();
|
QAbstractItemModel* model = ui->treeView->model();
|
||||||
for (int i=0; i<model->rowCount(); ++i) {
|
for (int i=0; i<model->rowCount(); ++i) {
|
||||||
int id = model->data(model->index(i,0), Qt::UserRole).toInt();
|
int id = model->data(model->index(i,0), Qt::UserRole).toInt();
|
||||||
|
@ -232,7 +262,7 @@ void DlgFilletEdges::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||||
if (name == subelement) {
|
if (name == subelement) {
|
||||||
// ok, check the selected sub-element
|
// ok, check the selected sub-element
|
||||||
Qt::CheckState checkState =
|
Qt::CheckState checkState =
|
||||||
(msg.Type == Gui::SelectionChanges::AddSelection
|
(msgType == Gui::SelectionChanges::AddSelection
|
||||||
? Qt::Checked : Qt::Unchecked);
|
? Qt::Checked : Qt::Unchecked);
|
||||||
QVariant value(static_cast<int>(checkState));
|
QVariant value(static_cast<int>(checkState));
|
||||||
QModelIndex index = model->index(i,0);
|
QModelIndex index = model->index(i,0);
|
||||||
|
@ -245,6 +275,31 @@ void DlgFilletEdges::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DlgFilletEdges::onSelectEdgesOfFace(const QString& subelement, int type)
|
||||||
|
{
|
||||||
|
bool ok;
|
||||||
|
int index = subelement.mid(4).toInt(&ok);
|
||||||
|
if (ok) {
|
||||||
|
try {
|
||||||
|
const TopoDS_Shape& face = d->all_faces.FindKey(index);
|
||||||
|
TopTools_IndexedMapOfShape mapOfEdges;
|
||||||
|
TopExp::MapShapes(face, TopAbs_EDGE, mapOfEdges);
|
||||||
|
|
||||||
|
for(int j = 1; j <= mapOfEdges.Extent(); ++j) {
|
||||||
|
TopoDS_Edge edge = TopoDS::Edge(mapOfEdges.FindKey(j));
|
||||||
|
int id = d->all_edges.FindIndex(edge);
|
||||||
|
QString name = QString::fromAscii("Edge%1").arg(id);
|
||||||
|
onSelectEdge(name, type);
|
||||||
|
Gui::SelectionChanges::MsgType msgType = Gui::SelectionChanges::MsgType(type);
|
||||||
|
if (msgType == Gui::SelectionChanges::AddSelection) {
|
||||||
|
Gui::Selection().addSelection(d->object->getDocument()->getName(),
|
||||||
|
d->object->getNameInDocument(), (const char*)name.toAscii());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Standard_Failure) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -435,6 +490,13 @@ void DlgFilletEdges::on_shapeObject_activated(int index)
|
||||||
if (part && part->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
if (part && part->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||||
d->object = part;
|
d->object = part;
|
||||||
TopoDS_Shape myShape = static_cast<Part::Feature*>(part)->Shape.getValue();
|
TopoDS_Shape myShape = static_cast<Part::Feature*>(part)->Shape.getValue();
|
||||||
|
|
||||||
|
d->all_edges.Clear();
|
||||||
|
TopExp::MapShapes(myShape, TopAbs_EDGE, d->all_edges);
|
||||||
|
|
||||||
|
d->all_faces.Clear();
|
||||||
|
TopExp::MapShapes(myShape, TopAbs_FACE, d->all_faces);
|
||||||
|
|
||||||
// build up map edge->face
|
// build up map edge->face
|
||||||
TopTools_IndexedDataMapOfShapeListOfShape edge2Face;
|
TopTools_IndexedDataMapOfShapeListOfShape edge2Face;
|
||||||
TopExp::MapShapesAndAncestors(myShape, TopAbs_EDGE, TopAbs_FACE, edge2Face);
|
TopExp::MapShapesAndAncestors(myShape, TopAbs_EDGE, TopAbs_FACE, edge2Face);
|
||||||
|
@ -481,6 +543,16 @@ void DlgFilletEdges::on_shapeObject_activated(int index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DlgFilletEdges::on_selectEdges_toggled(bool on)
|
||||||
|
{
|
||||||
|
if (on) d->selection->selectEdges();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DlgFilletEdges::on_selectFaces_toggled(bool on)
|
||||||
|
{
|
||||||
|
if (on) d->selection->selectFaces();
|
||||||
|
}
|
||||||
|
|
||||||
void DlgFilletEdges::on_selectAllButton_clicked()
|
void DlgFilletEdges::on_selectAllButton_clicked()
|
||||||
{
|
{
|
||||||
QAbstractItemModel* model = ui->treeView->model();
|
QAbstractItemModel* model = ui->treeView->model();
|
||||||
|
|
|
@ -90,9 +90,13 @@ private:
|
||||||
void onSelectionChanged(const Gui::SelectionChanges& msg);
|
void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||||
void onDeleteObject(const App::DocumentObject&);
|
void onDeleteObject(const App::DocumentObject&);
|
||||||
void onDeleteDocument(const App::Document&);
|
void onDeleteDocument(const App::Document&);
|
||||||
|
void onSelectEdge(const QString& subelement, int type);
|
||||||
|
void onSelectEdgesOfFace(const QString& subelement, int type);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void on_shapeObject_activated(int);
|
void on_shapeObject_activated(int);
|
||||||
|
void on_selectEdges_toggled(bool);
|
||||||
|
void on_selectFaces_toggled(bool);
|
||||||
void on_selectAllButton_clicked();
|
void on_selectAllButton_clicked();
|
||||||
void on_selectNoneButton_clicked();
|
void on_selectNoneButton_clicked();
|
||||||
void on_filletType_activated(int);
|
void on_filletType_activated(int);
|
||||||
|
|
|
@ -51,27 +51,7 @@
|
||||||
<string>Fillet Parameter</string>
|
<string>Fillet Parameter</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="5">
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>221</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QPushButton" name="selectAllButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>All</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
|
||||||
<widget class="QPushButton" name="selectNoneButton">
|
<widget class="QPushButton" name="selectNoneButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>None</string>
|
<string>None</string>
|
||||||
|
@ -85,7 +65,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" colspan="2">
|
<item row="1" column="4" colspan="2">
|
||||||
<widget class="QComboBox" name="filletType">
|
<widget class="QComboBox" name="filletType">
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -99,10 +79,10 @@
|
||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="3">
|
<item row="2" column="0" colspan="6">
|
||||||
<widget class="QTreeView" name="treeView"/>
|
<widget class="QTreeView" name="treeView"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" colspan="3">
|
<item row="3" column="0" colspan="6">
|
||||||
<layout class="QHBoxLayout">
|
<layout class="QHBoxLayout">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
|
@ -155,6 +135,43 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="4">
|
||||||
|
<widget class="QPushButton" name="selectAllButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>All</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QRadioButton" name="selectFaces">
|
||||||
|
<property name="text">
|
||||||
|
<string>Select faces</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>221</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QRadioButton" name="selectEdges">
|
||||||
|
<property name="text">
|
||||||
|
<string>Select edges</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user