class ModuleBase_ShapeInPlaneFilter: public SelectMgr_Filter
{
public:
- Standard_EXPORT ModuleBase_ShapeInPlaneFilter(const gp_Pln& thePane):
- SelectMgr_Filter(), myPlane(thePane) {}
+ Standard_EXPORT ModuleBase_ShapeInPlaneFilter(): SelectMgr_Filter() {}
+
+ void setPlane(const gp_Pln& thePane) { myPlane = thePane; }
+ gp_Pln plane() const { return myPlane; }
Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
aDisplayer->erase((*aIt), false);
}
aDisplayer->erase(myCurrentSketch);
+
+
+ if (myPlaneFilter.IsNull())
+ myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
+ myWorkshop->viewer()->addSelectionFilter(myPlaneFilter);
+ if (theOperation->isEditOperation()) {
+ // If it is editing of sketch then it means that plane is already defined
+ std::shared_ptr<GeomAPI_Pln> aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
+ myPlaneFilter->setPlane(aPln->impl<gp_Pln>());
+ }
}
}
aDisplayer->display(myCurrentSketch);
myCurrentSketch = CompositeFeaturePtr();
+ myWorkshop->viewer()->removeSelectionFilter(myPlaneFilter);
}
}
+void PartSet_Module::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
+{
+ myPlaneFilter->setPlane(thePln->impl<gp_Pln>());
+}
void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
if (theType == "sketch-start-label") {
PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId);
aWgt->setWorkshop(aWorkshop);
+ connect(aWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)),
+ this, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
theModelWidgets.append(aWgt);
return aWgt->getControl();
private slots:
void onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape);
+ void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
+
private:
/// Converts mouse position to 2d coordinates.
/// Member myCurrentSketch has to be correctly defined
double myCurX, myCurY;
CompositeFeaturePtr myCurrentSketch;
QList<FeaturePtr> myEditingFeatures;
+
+ Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
};
#endif
XGUI_Displayer* aDisp = myWorkshop->displayer();
aDisp->removeSelectionFilter(myPlaneFilter);
aDisp->closeLocalContexts();
+ emit planeSelected(plane());
setSketchingMode();
+
+ // Update sketcher actions
XGUI_ActionsMgr* anActMgr = myWorkshop->actionsMgr();
anActMgr->update();
}
std::shared_ptr<GeomAPI_Pln> plane() const;
+signals:
+ void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
+
private slots:
void onPlaneSelected();
//for (aContext->InitCurrent(); aContext->MoreCurrent(); aContext->NextCurrent())
// aAisList.Append(aContext->Current());
+ SelectMgr_ListOfFilter aFilters;
+ aFilters.Assign(aContext->Filters());
+
aContext->ClearCurrents();
aContext->OpenLocalContext();
aContext->NotUseDisplayedObjects();
myUseExternalObjects = false;
myActiveSelectionModes.clear();
+ SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
+ for (;aIt.More(); aIt.Next()) {
+ aContext->AddFilter(aIt.Value());
+ }
// Restore selection
//AIS_ListIteratorOfListOfInteractive aIt(aAisList);
//for(; aIt.More(); aIt.Next()) {