Simplify the feature pick dialog

less options are easier to grasp for the user
This commit is contained in:
Stefan Tröger 2015-11-08 19:32:09 +01:00
parent 005c3db946
commit e675c43ddf
2 changed files with 83 additions and 131 deletions

View File

@ -84,15 +84,10 @@ TaskFeaturePick::TaskFeaturePick(std::vector<App::DocumentObject*>& objects,
connect(ui->checkUsed, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool)));
connect(ui->checkOtherBody, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool)));
connect(ui->bodyRadioIndependent, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool)));
connect(ui->bodyRadioXRef, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool)));
connect(ui->checkOtherPart, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool)));
connect(ui->partRadioIndependent, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool)));
connect(ui->partRadioDependent, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool)));
connect(ui->partRadioXRef, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool)));
connect(ui->checkNoBody, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool)));
connect(ui->nobodyRadioIndependent, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool)));
connect(ui->nobodyRadioXRef, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool)));
connect(ui->radioIndependent, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool)));
connect(ui->radioDependent, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool)));
connect(ui->radioXRef, SIGNAL(toggled(bool)), this, SLOT(onUpdate(bool)));
enum { axisBit=0, planeBit = 1};
@ -153,9 +148,6 @@ void TaskFeaturePick::updateList()
{
int index = 0;
//get all origins in temporary mode
for (std::vector<featureStatus>::const_iterator st = statuses.begin(); st != statuses.end(); st++) {
QListWidgetItem* item = ui->listWidget->item(index);
@ -166,7 +158,7 @@ void TaskFeaturePick::updateList()
case noWire: item->setHidden(true); break;
case otherBody: item->setHidden(!ui->checkOtherBody->isChecked()); break;
case otherPart: item->setHidden(!ui->checkOtherPart->isChecked()); break;
case notInBody: item->setHidden(!ui->checkNoBody->isChecked()); break;
case notInBody: item->setHidden(!ui->checkOtherPart->isChecked()); break;
case basePlane: item->setHidden(false); break;
case afterTip: item->setHidden(true); break;
}
@ -177,24 +169,32 @@ void TaskFeaturePick::updateList()
void TaskFeaturePick::onUpdate(bool)
{
bool enable = false;
if(ui->checkOtherBody->isChecked() || ui->checkOtherPart->isChecked())
enable = true;
ui->radioDependent->setEnabled(enable);
ui->radioIndependent->setEnabled(enable);
ui->radioXRef->setEnabled(enable);
updateList();
}
std::vector<App::DocumentObject*> TaskFeaturePick::getFeatures() {
features.clear();
QListIterator<QListWidgetItem*> i(ui->listWidget->selectedItems());
while (i.hasNext()) {
auto item = i.next();
if(item->isHidden())
continue;
QString t = item->text();
t = t.left(t.indexOf(QString::fromAscii("(")) - 1);
features.push_back(t);
}
std::vector<App::DocumentObject*> result;
for (std::vector<QString>::const_iterator s = features.begin(); s != features.end(); s++)
@ -219,40 +219,30 @@ std::vector<App::DocumentObject*> TaskFeaturePick::buildFeatures() {
t = t.left(t.indexOf(QString::fromAscii("(")) - 1);
auto obj = App::GetApplication().getActiveDocument()->getObject(t.toAscii().data());
//build the dependend copy if wanted by the user
if(*st == otherBody) {
//build the dependend copy or reference if wanted by the user
if(*st == otherBody ||
*st == otherPart ||
*st == notInBody ) {
if(ui->bodyRadioIndependent->isChecked()) {
auto copy = makeCopy(obj, "", true);
activeBody->addFeature(copy);
result.push_back(copy);
} else {
result.push_back(obj);
}
}
else if(*st == otherPart) {
if(!ui->radioXRef->isChecked()) {
auto copy = makeCopy(obj, "", ui->radioIndependent->isChecked());
if(!ui->partRadioXRef->isChecked()) {
auto copy = makeCopy(obj, "", ui->partRadioIndependent->isChecked());
auto oBody = PartDesignGui::getBodyFor(obj, false);
if(oBody)
if(*st == otherBody)
activeBody->addFeature(copy);
else
activePart->addObject(copy);
result.push_back(copy);
}
else
result.push_back(obj);
} else if(*st == notInBody) {
if(ui->bodyRadioIndependent->isChecked()) {
auto copy = makeCopy(obj, "", true);
activeBody->addFeature(copy);
// doesn't supposed to get here anything but sketch but to be on the safe side better to check
if (copy->getTypeId().isDerivedFrom(Sketcher::SketchObject::getClassTypeId())) {
Sketcher::SketchObject *sketch = static_cast<Sketcher::SketchObject*>(copy);
PartDesignGui::fixSketchSupport(sketch);
else if(*st == otherPart) {
auto oBody = PartDesignGui::getBodyFor(obj, false);
if(!oBody)
activePart->addObject(copy);
else
activeBody->addFeature(copy);
}
else if(*st == notInBody) {
activeBody->addFeature(copy);
// doesn't supposed to get here anything but sketch but to be on the safe side better to check
if (copy->getTypeId().isDerivedFrom(Sketcher::SketchObject::getClassTypeId())) {
Sketcher::SketchObject *sketch = static_cast<Sketcher::SketchObject*>(copy);
PartDesignGui::fixSketchSupport(sketch);
}
}
result.push_back(copy);
}
@ -400,12 +390,12 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::st
void TaskFeaturePick::onSelectionChanged(const Gui::SelectionChanges& msg)
{
{
ui->listWidget->clearSelection();
for(Gui::SelectionSingleton::SelObj obj : Gui::Selection().getSelection()) {
for(int row = 0; row < ui->listWidget->count(); row++) {
QListWidgetItem *item = ui->listWidget->item(row);
QString t = item->text();
t = t.left(t.indexOf(QString::fromAscii("(")) - 1);
@ -420,7 +410,6 @@ void TaskFeaturePick::showExternal(bool val) {
ui->checkOtherBody->setChecked(val);
ui->checkOtherPart->setChecked(val);
ui->checkNoBody->setChecked(val);
updateList();
}
@ -430,7 +419,7 @@ void TaskFeaturePick::showExternal(bool val) {
// TaskDialog
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TaskDlgFeaturePick::TaskDlgFeaturePick(std::vector<App::DocumentObject*> &objects,
TaskDlgFeaturePick::TaskDlgFeaturePick(std::vector<App::DocumentObject*> &objects,
const std::vector<TaskFeaturePick::featureStatus> &status,
boost::function<bool (std::vector<App::DocumentObject*>)> afunc,
boost::function<void (std::vector<App::DocumentObject*>)> wfunc)
@ -438,15 +427,15 @@ TaskDlgFeaturePick::TaskDlgFeaturePick(std::vector<App::DocumentObject*> &object
{
pick = new TaskFeaturePick(objects, status);
Content.push_back(pick);
acceptFunction = afunc;
workFunction = wfunc;
}
TaskDlgFeaturePick::~TaskDlgFeaturePick()
{
//do the work now as before in accept() the dialog is still open, hence the work
//function could not open annother dialog
//do the work now as before in accept() the dialog is still open, hence the work
//function could not open annother dialog
if(accepted)
workFunction(pick->buildFeatures());
}
@ -456,18 +445,18 @@ TaskDlgFeaturePick::~TaskDlgFeaturePick()
void TaskDlgFeaturePick::open()
{
}
void TaskDlgFeaturePick::clicked(int)
{
}
bool TaskDlgFeaturePick::accept()
{
accepted = acceptFunction(pick->getFeatures());
return accepted;
}

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>388</width>
<height>493</height>
<width>364</width>
<height>487</height>
</rect>
</property>
<property name="windowTitle">
@ -25,54 +25,43 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="checkOtherBody">
<widget class="QGroupBox" name="checkExternal">
<property name="title">
<string>Allow features from other bodies</string>
</property>
<property name="flat">
<bool>false</bool>
<string>Allow external features</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="bodyRadioIndependent">
<property name="text">
<string>Make independent copy (recommended)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="bodyRadioXRef">
<property name="text">
<string>Create cross-reference</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="checkOtherPart">
<property name="title">
<string>Allow features from other parts</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="partRadioIndependent">
<widget class="QCheckBox" name="checkOtherBody">
<property name="text">
<string>From other bodies of the same part</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkOtherPart">
<property name="text">
<string>From different parts or free features</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioIndependent">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Make independent copy (recommended)</string>
</property>
@ -82,46 +71,20 @@
</widget>
</item>
<item>
<widget class="QRadioButton" name="partRadioDependent">
<widget class="QRadioButton" name="radioDependent">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Make dependent copy</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="partRadioXRef">
<property name="text">
<string>Create cross-reference</string>
<widget class="QRadioButton" name="radioXRef">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="checkNoBody">
<property name="title">
<string>Allow features not belong to any body</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QRadioButton" name="nobodyRadioIndependent">
<property name="text">
<string>Make independent copy (recommended)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="nobodyRadioXRef">
<property name="text">
<string>Create cross-reference</string>
</property>