PD: add SelectionFilterGate to filter dependents, fix mirror taskview
This commit is contained in:
parent
cdf437445c
commit
be249f902d
|
@ -175,12 +175,18 @@ bool ReferenceSelection::allow(App::Document* pDoc, App::DocumentObject* pObj, c
|
|||
|
||||
bool NoDependentsSelection::allow(App::Document* pDoc, App::DocumentObject* pObj, const char* sSubName)
|
||||
{
|
||||
if (support && !support->testIfLinkDAGCompatible(pObj)) {
|
||||
if (support && support->testIfLinkDAGCompatible(pObj)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
this->notAllowedReason = QT_TR_NOOP("Selecting this will cause circular dependency.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return refSelection.allow(pDoc, pObj, sSubName);
|
||||
bool CombineSelectionFilterGates::allow(App::Document* pDoc, App::DocumentObject* pObj, const char* sSubName)
|
||||
{
|
||||
return filter1->allow(pDoc, pObj, sSubName) && filter2->allow(pDoc, pObj, sSubName);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -56,21 +56,31 @@ public:
|
|||
|
||||
class NoDependentsSelection : public Gui::SelectionFilterGate
|
||||
{
|
||||
ReferenceSelection refSelection;
|
||||
const App::DocumentObject* support;
|
||||
|
||||
public:
|
||||
NoDependentsSelection(const App::DocumentObject* support_,
|
||||
const bool edge_, const bool plane_, const bool planar_, const bool point_ = false)
|
||||
: Gui::SelectionFilterGate((Gui::SelectionFilter*)0), refSelection(support_, edge_, plane_, planar_, point_), support(support_)
|
||||
NoDependentsSelection(const App::DocumentObject* support_)
|
||||
: Gui::SelectionFilterGate((Gui::SelectionFilter*)0), support(support_)
|
||||
{
|
||||
}
|
||||
/**
|
||||
* Allow the user to pick only objects wich are not in objs getDependencyList
|
||||
*/
|
||||
bool allow(App::Document* pDoc, App::DocumentObject* pObj, const char* sSubName);
|
||||
bool allow(App::Document* pDoc, App::DocumentObject* pObj, const char* sSubName) override;
|
||||
};
|
||||
|
||||
class CombineSelectionFilterGates: public Gui::SelectionFilterGate
|
||||
{
|
||||
std::unique_ptr<Gui::SelectionFilterGate> filter1;
|
||||
std::unique_ptr<Gui::SelectionFilterGate> filter2;
|
||||
|
||||
public:
|
||||
CombineSelectionFilterGates(std::unique_ptr<Gui::SelectionFilterGate> &filter1_, std::unique_ptr<Gui::SelectionFilterGate> &filter2_)
|
||||
: Gui::SelectionFilterGate((Gui::SelectionFilter*)0), filter1(std::move(filter1_)), filter2(std::move(filter2_))
|
||||
{
|
||||
}
|
||||
bool allow(App::Document* pDoc, App::DocumentObject* pObj, const char* sSubName) override;
|
||||
};
|
||||
// Convenience methods
|
||||
/// Extract reference from Selection
|
||||
void getReferencedSelection(const App::DocumentObject* thisObj, const Gui::SelectionChanges& msg,
|
||||
|
|
|
@ -223,7 +223,7 @@ TaskDatumParameters::TaskDatumParameters(ViewProviderDatum *DatumView,QWidget *p
|
|||
|
||||
DatumView->setPickable(false);
|
||||
|
||||
Gui::Selection().addSelectionGate(new NoDependentsSelection(DatumView->getObject(), true, true, true, true));
|
||||
Gui::Selection().addSelectionGate(new NoDependentsSelection(DatumView->getObject()));
|
||||
|
||||
// connect object deletion with slot
|
||||
auto bnd = boost::bind(&TaskDatumParameters::objectDeleted, this, _1);
|
||||
|
|
|
@ -184,23 +184,18 @@ void TaskMirroredParameters::onSelectionChanged(const Gui::SelectionChanges& msg
|
|||
removeItemFromListWidget(ui->listWidgetFeatures, msg.pObjectName);
|
||||
exitSelectionMode();
|
||||
} else {
|
||||
// TODO checkme (2015-09-01, Fat-Zer)
|
||||
exitSelectionMode();
|
||||
std::vector<std::string> mirrorPlanes;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
getReferencedSelection(pcMirrored, msg, selObj, mirrorPlanes);
|
||||
if(!selObj)
|
||||
return;
|
||||
// Note: ReferenceSelection has already checked the selection for validity
|
||||
if ( selectionMode == reference ||
|
||||
selObj->isDerivedFrom ( App::Plane::getClassTypeId () ) ||
|
||||
selObj->isDerivedFrom(PartDesign::Plane::getClassTypeId())) {
|
||||
if ( selectionMode == reference) {
|
||||
std::vector<std::string> mirrorPlanes;
|
||||
App::DocumentObject* selObj;
|
||||
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
|
||||
getReferencedSelection(pcMirrored, msg, selObj, mirrorPlanes);
|
||||
if (!selObj)
|
||||
return;
|
||||
pcMirrored->MirrorPlane.setValue(selObj, mirrorPlanes);
|
||||
|
||||
recomputeFeature();
|
||||
updateUI();
|
||||
}
|
||||
exitSelectionMode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -338,7 +338,9 @@ void TaskTransformedParameters::exitSelectionMode()
|
|||
|
||||
void TaskTransformedParameters::addReferenceSelectionGate(bool edge, bool face)
|
||||
{
|
||||
Gui::Selection().addSelectionGate(new ReferenceSelection(getBaseObject(), edge, face, /*point =*/ true));
|
||||
std::unique_ptr<Gui::SelectionFilterGate> gateRefPtr = std::make_unique<ReferenceSelection>(getBaseObject(), edge, face, /*point =*/ true);
|
||||
std::unique_ptr<Gui::SelectionFilterGate> gateDepPtr = std::make_unique<NoDependentsSelection>(getTopTransformedObject());
|
||||
Gui::Selection().addSelectionGate(new CombineSelectionFilterGates(gateRefPtr, gateDepPtr));
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
|
|
Loading…
Reference in New Issue
Block a user