+ Improve performance when selecting all edges of an edited fillet feature
This commit is contained in:
parent
573c1abb29
commit
db72aa2a98
|
@ -627,7 +627,7 @@ bool SelectionSingleton::addSelection(const char* pDocName, const char* pObjectN
|
|||
if (isSelected(pDocName, pObjectName, pSubName))
|
||||
return true;
|
||||
|
||||
_SelObj temp;
|
||||
_SelObj temp;
|
||||
|
||||
temp.pDoc = getDocument(pDocName);
|
||||
|
||||
|
@ -681,8 +681,62 @@ bool SelectionSingleton::addSelection(const char* pDocName, const char* pObjectN
|
|||
// allow selection
|
||||
return true;
|
||||
}
|
||||
else { // neither an existing nor active document available
|
||||
//assert(0);
|
||||
else {
|
||||
// neither an existing nor active document available
|
||||
// this can often happen when importing .iv files
|
||||
Base::Console().Error("Cannot add to selection: no document '%s' found.\n", pDocName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool SelectionSingleton::addSelection(const char* pDocName, const char* pObjectName, const std::vector<std::string>& pSubNames)
|
||||
{
|
||||
// already in ?
|
||||
//if (isSelected(pDocName, pObjectName, pSubName))
|
||||
// return true;
|
||||
|
||||
_SelObj temp;
|
||||
|
||||
temp.pDoc = getDocument(pDocName);
|
||||
|
||||
if (temp.pDoc) {
|
||||
if(pObjectName)
|
||||
temp.pObject = temp.pDoc->getObject(pObjectName);
|
||||
else
|
||||
temp.pObject = 0;
|
||||
|
||||
if (temp.pObject)
|
||||
temp.TypeName = temp.pObject->getTypeId().getName();
|
||||
|
||||
temp.DocName = pDocName;
|
||||
temp.FeatName = pObjectName ? pObjectName : "";
|
||||
for (std::vector<std::string>::const_iterator it = pSubNames.begin(); it != pSubNames.end(); ++it) {
|
||||
temp.SubName = it->c_str();
|
||||
temp.x = 0;
|
||||
temp.y = 0;
|
||||
temp.z = 0;
|
||||
|
||||
_SelList.push_back(temp);
|
||||
}
|
||||
|
||||
SelectionChanges Chng;
|
||||
|
||||
Chng.pDocName = pDocName;
|
||||
Chng.pObjectName = pObjectName ? pObjectName : "";
|
||||
Chng.pSubName = "";
|
||||
Chng.x = 0;
|
||||
Chng.y = 0;
|
||||
Chng.z = 0;
|
||||
Chng.Type = SelectionChanges::AddSelection;
|
||||
|
||||
Notify(Chng);
|
||||
signalSelectionChanged(Chng);
|
||||
|
||||
// allow selection
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
// neither an existing nor active document available
|
||||
// this can often happen when importing .iv files
|
||||
Base::Console().Error("Cannot add to selection: no document '%s' found.\n", pDocName);
|
||||
return false;
|
||||
|
|
|
@ -200,6 +200,8 @@ class GuiExport SelectionSingleton : public Base::Subject<const SelectionChanges
|
|||
public:
|
||||
/// Add to selection
|
||||
bool addSelection(const char* pDocName, const char* pObjectName=0, const char* pSubName=0, float x=0, float y=0, float z=0);
|
||||
/// Add to selection with several sub-elements
|
||||
bool addSelection(const char* pDocName, const char* pObjectName, const std::vector<std::string>& pSubNames);
|
||||
/// Remove from selection (for internal use)
|
||||
void rmvSelection(const char* pDocName, const char* pObjectName=0, const char* pSubName=0);
|
||||
/// Set the selection for a document
|
||||
|
|
|
@ -540,7 +540,10 @@ void DlgFilletEdges::setupFillet(const std::vector<App::DocumentObject*>& objs)
|
|||
ui->shapeObject->setCurrentIndex(current_index);
|
||||
on_shapeObject_activated(current_index);
|
||||
ui->shapeObject->setEnabled(false);
|
||||
|
||||
std::vector<std::string> subElements;
|
||||
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(ui->treeView->model());
|
||||
bool block = model->blockSignals(true); // do not call toggleCheckState
|
||||
for (std::vector<Part::FilletElement>::const_iterator et = e.begin(); et != e.end(); ++et) {
|
||||
std::vector<int>::iterator it = std::find(d->edge_ids.begin(), d->edge_ids.end(), et->edgeid);
|
||||
if (it != d->edge_ids.end()) {
|
||||
|
@ -548,8 +551,19 @@ void DlgFilletEdges::setupFillet(const std::vector<App::DocumentObject*>& objs)
|
|||
model->setData(model->index(index, 0), Qt::Checked, Qt::CheckStateRole);
|
||||
model->setData(model->index(index, 1), QVariant(QLocale::system().toString(et->radius1,'f',Base::UnitsApi::getDecimals())));
|
||||
model->setData(model->index(index, 2), QVariant(QLocale::system().toString(et->radius2,'f',Base::UnitsApi::getDecimals())));
|
||||
|
||||
int id = model->index(index, 0).data(Qt::UserRole).toInt();
|
||||
std::stringstream str;
|
||||
str << "Edge" << id;
|
||||
subElements.push_back(str.str());
|
||||
}
|
||||
}
|
||||
model->blockSignals(block);
|
||||
|
||||
App::Document* doc = d->object->getDocument();
|
||||
Gui::Selection().addSelection(doc->getName(),
|
||||
d->object->getNameInDocument(),
|
||||
subElements);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -667,12 +681,32 @@ void DlgFilletEdges::on_selectFaces_toggled(bool on)
|
|||
|
||||
void DlgFilletEdges::on_selectAllButton_clicked()
|
||||
{
|
||||
std::vector<std::string> subElements;
|
||||
QAbstractItemModel* model = ui->treeView->model();
|
||||
bool block = model->blockSignals(true); // do not call toggleCheckState
|
||||
for (int i=0; i<model->rowCount(); ++i) {
|
||||
QModelIndex index = model->index(i,0);
|
||||
|
||||
// is not yet checked?
|
||||
QVariant check = index.data(Qt::CheckStateRole);
|
||||
Qt::CheckState state = static_cast<Qt::CheckState>(check.toInt());
|
||||
if (state == Qt::Unchecked) {
|
||||
int id = index.data(Qt::UserRole).toInt();
|
||||
std::stringstream str;
|
||||
str << "Edge" << id;
|
||||
subElements.push_back(str.str());
|
||||
}
|
||||
|
||||
Qt::CheckState checkState = Qt::Checked;
|
||||
QVariant value(static_cast<int>(checkState));
|
||||
model->setData(model->index(i,0), value, Qt::CheckStateRole);
|
||||
model->setData(index, value, Qt::CheckStateRole);
|
||||
}
|
||||
model->blockSignals(block);
|
||||
|
||||
App::Document* doc = d->object->getDocument();
|
||||
Gui::Selection().addSelection(doc->getName(),
|
||||
d->object->getNameInDocument(),
|
||||
subElements);
|
||||
}
|
||||
|
||||
void DlgFilletEdges::on_selectNoneButton_clicked()
|
||||
|
|
Loading…
Reference in New Issue
Block a user