Work on reference selection for Datum features

This commit is contained in:
jrheinlaender
2013-04-13 15:55:13 +04:30
committed by Stefan Tröger
parent 571d5d2b7d
commit a1359fc9e9
8 changed files with 250 additions and 162 deletions

View File

@@ -30,9 +30,13 @@
# include <BRepAdaptor_Surface.hxx>
#endif
#include <App/Plane.h>
#include <Mod/Part/App/TopoShape.h>
#include <Mod/Part/App/PartFeature.h>
#include <Mod/PartDesign/App/Body.h>
#include <Mod/PartDesign/App/DatumFeature.h>
#include "ReferenceSelection.h"
#include "Workbench.h"
using namespace PartDesignGui;
using namespace Gui;
@@ -41,6 +45,31 @@ using namespace Gui;
bool ReferenceSelection::allow(App::Document* pDoc, App::DocumentObject* pObj, const char* sSubName)
{
if (plane && (pObj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())))
// Note: It is assumed that a Part has exactly 3 App::Plane objects at the root of the feature tree
return true;
if (pObj->getTypeId().isDerivedFrom(PartDesign::Datum::getClassTypeId())) {
// Allow selecting PartDesign::Datum features
if (!ActivePartObject->hasFeature(pObj))
return false;
if (plane && (pObj->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())))
return true;
if (edge && (pObj->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId())))
return true;
if (point && (pObj->getTypeId().isDerivedFrom(PartDesign::Point::getClassTypeId())))
return true;
return false;
}
// Handle selection of geometry elements
if (support == NULL)
return false;
// Don't allow selection in other document
if (pDoc != support->getDocument())
return false;
if (!sSubName || sSubName[0] == '\0')
return false;
if (pObj != support)