0000735: Feature request for better Fillet/Chamfer

This commit is contained in:
wmayer 2013-07-07 21:19:19 +02:00
parent 56295c5d76
commit 7de742b436
2 changed files with 81 additions and 0 deletions

View File

@ -43,10 +43,13 @@
# include <QItemSelectionModel>
# include <boost/signal.hpp>
# include <boost/bind.hpp>
# include <Inventor/actions/SoSearchAction.h>
# include <Inventor/details/SoLineDetail.h>
#endif
#include "DlgFilletEdges.h"
#include "ui_DlgFilletEdges.h"
#include "SoBrepShape.h"
#include "../App/PartFeature.h"
#include "../App/FeatureFillet.h"
@ -60,7 +63,9 @@
#include <Gui/WaitCursor.h>
#include <Gui/Selection.h>
#include <Gui/SelectionFilter.h>
#include <Gui/SoFCUnifiedSelection.h>
#include <Gui/ViewProvider.h>
#include <Gui/Window.h>
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; i<model->rowCount(); ++i) {
QVariant value = model->index(i,0).data(Qt::CheckStateRole);
Qt::CheckState checkState = static_cast<Qt::CheckState>(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)

View File

@ -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_DlgFilletEdges> ui;