From 7de742b436548ba7d22346bc035a8a8d625bb910 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 7 Jul 2013 21:19:19 +0200 Subject: [PATCH] 0000735: Feature request for better Fillet/Chamfer --- src/Mod/Part/Gui/DlgFilletEdges.cpp | 80 +++++++++++++++++++++++++++++ src/Mod/Part/Gui/DlgFilletEdges.h | 1 + 2 files changed, 81 insertions(+) diff --git a/src/Mod/Part/Gui/DlgFilletEdges.cpp b/src/Mod/Part/Gui/DlgFilletEdges.cpp index f241f656bd..f53fc7445a 100644 --- a/src/Mod/Part/Gui/DlgFilletEdges.cpp +++ b/src/Mod/Part/Gui/DlgFilletEdges.cpp @@ -43,10 +43,13 @@ # include # include # include +# include +# include #endif #include "DlgFilletEdges.h" #include "ui_DlgFilletEdges.h" +#include "SoBrepShape.h" #include "../App/PartFeature.h" #include "../App/FeatureFillet.h" @@ -60,7 +63,9 @@ #include #include #include +#include #include +#include using namespace PartGui; @@ -250,6 +255,81 @@ void DlgFilletEdges::onSelectionChanged(const Gui::SelectionChanges& msg) } } } + + if (msg.Type != Gui::SelectionChanges::SetPreselect && + msg.Type != Gui::SelectionChanges::RmvPreselect) + QTimer::singleShot(20, this, SLOT(onHighlightEdges())); +} + +void DlgFilletEdges::onHighlightEdges() +{ + Gui::ViewProvider* view = Gui::Application::Instance->getViewProvider(d->object); + if (view) { + // deselect all faces + { + SoSearchAction searchAction; + searchAction.setType(PartGui::SoBrepFaceSet::getClassTypeId()); + searchAction.setInterest(SoSearchAction::FIRST); + searchAction.apply(view->getRoot()); + SoPath* selectionPath = searchAction.getPath(); + if (selectionPath) { + Gui::SoSelectionElementAction action(Gui::SoSelectionElementAction::None); + action.apply(selectionPath); + } + } + // deselect all points + { + SoSearchAction searchAction; + searchAction.setType(PartGui::SoBrepPointSet::getClassTypeId()); + searchAction.setInterest(SoSearchAction::FIRST); + searchAction.apply(view->getRoot()); + SoPath* selectionPath = searchAction.getPath(); + if (selectionPath) { + Gui::SoSelectionElementAction action(Gui::SoSelectionElementAction::None); + action.apply(selectionPath); + } + } + // select the edges + { + SoSearchAction searchAction; + searchAction.setType(PartGui::SoBrepEdgeSet::getClassTypeId()); + searchAction.setInterest(SoSearchAction::FIRST); + searchAction.apply(view->getRoot()); + SoPath* selectionPath = searchAction.getPath(); + if (selectionPath) { + ParameterGrp::handle hGrp = Gui::WindowParameter::getDefaultParameter()->GetGroup("View"); + SbColor selectionColor(0.1f, 0.8f, 0.1f); + unsigned long selection = (unsigned long)(selectionColor.getPackedValue()); + selection = hGrp->GetUnsigned("SelectionColor", selection); + float transparency; + selectionColor.setPackedValue((uint32_t)selection, transparency); + + // clear the selection first + Gui::SoSelectionElementAction clear(Gui::SoSelectionElementAction::None); + clear.apply(selectionPath); + + Gui::SoSelectionElementAction action(Gui::SoSelectionElementAction::Append); + action.setColor(selectionColor); + action.apply(selectionPath); + + QAbstractItemModel* model = ui->treeView->model(); + SoLineDetail detail; + action.setElement(&detail); + for (int i=0; irowCount(); ++i) { + QVariant value = model->index(i,0).data(Qt::CheckStateRole); + Qt::CheckState checkState = static_cast(value.toInt()); + + // is item checked + if (checkState & Qt::Checked) { + // the index value of the edge + int id = model->index(i,0).data(Qt::UserRole).toInt(); + detail.setLineIndex(id-1); + action.apply(selectionPath); + } + } + } + } + } } void DlgFilletEdges::onSelectEdge(const QString& subelement, int type) diff --git a/src/Mod/Part/Gui/DlgFilletEdges.h b/src/Mod/Part/Gui/DlgFilletEdges.h index 46df513669..0fab0dbeb0 100644 --- a/src/Mod/Part/Gui/DlgFilletEdges.h +++ b/src/Mod/Part/Gui/DlgFilletEdges.h @@ -103,6 +103,7 @@ private Q_SLOTS: void on_filletStartRadius_valueChanged(double); void on_filletEndRadius_valueChanged(double); void toggleCheckState(const QModelIndex&); + void onHighlightEdges(); private: std::auto_ptr ui;