#include "PartSet_WidgetSketchCreator.h"
#include "PartSet_Module.h"
+#include "PartSet_WidgetSketchLabel.h"
#include <Config_Keywords.h>
QList<ModuleBase_ViewerPrs> aSelected = getFilteredSelected();
if (aSelected.size() == 1) { // plane or planar face of not sketch object
- startSketchOperation();
+ startSketchOperation(aSelected.front());
}
else if (aSelected.size() > 1) {
QList<ModuleBase_ViewerPrs>::const_iterator anIt = aSelected.begin(), aLast = aSelected.end();
setVisibleSelectionControl(true);
}
-void PartSet_WidgetSketchCreator::startSketchOperation()
+void PartSet_WidgetSketchCreator::startSketchOperation(const ModuleBase_ViewerPrs& theValue)
{
// Check that model already has bodies
/*XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myModule->workshop());
DocumentPtr aDoc = aMgr->activeDocument();
FeaturePtr aPreviousCurrentFeature = aDoc->currentFeature(false);
FeaturePtr aSketch = aCompFeature->addFeature("Sketch");
+
+ PartSet_WidgetSketchLabel::fillSketchPlaneBySelection(aSketch, theValue);
+
aDoc->setCurrentFeature(aPreviousCurrentFeature, false);
// start edit operation for the sketch
private:
/// Append new Sketch, set the selected plane for the sketch and start Edit operation.
- void startSketchOperation();
+ /// \param theValue a selected object to obtain a plane for sketch
+ void startSketchOperation(const ModuleBase_ViewerPrs& theValue);
private:
std::string myAttributeListID;
}
bool PartSet_WidgetSketchLabel::setSelectionCustom(const ModuleBase_ViewerPrs& thePrs)
+{
+ return fillSketchPlaneBySelection(feature(), thePrs);
+}
+
+bool PartSet_WidgetSketchLabel::fillSketchPlaneBySelection(const FeaturePtr& theFeature,
+ const ModuleBase_ViewerPrs& thePrs)
{
bool isOwnerSet = false;
const TopoDS_Shape& aShape = thePrs.shape();
std::shared_ptr<GeomAPI_Dir> aDir;
- if (thePrs.object() && (feature() != thePrs.object())) {
- DataPtr aData = feature()->data();
+ if (thePrs.object() && (theFeature != thePrs.object())) {
+ DataPtr aData = theFeature->data();
AttributeSelectionPtr aSelAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
(aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
}
}
else if (!aShape.IsNull()) {
- aDir = setSketchPlane(aShape);
+ aDir = setSketchPlane(theFeature, aShape);
isOwnerSet = aDir.get();
}
return isOwnerSet;
}
-std::shared_ptr<GeomAPI_Dir> PartSet_WidgetSketchLabel::setSketchPlane(const TopoDS_Shape& theShape)
+std::shared_ptr<GeomAPI_Dir> PartSet_WidgetSketchLabel::setSketchPlane(const FeaturePtr& theFeature,
+ const TopoDS_Shape& theShape)
{
if (theShape.IsNull())
return std::shared_ptr<GeomAPI_Dir>();
return std::shared_ptr<GeomAPI_Dir>();
// set plane parameters to feature
- std::shared_ptr<ModelAPI_Data> aData = feature()->data();
+ std::shared_ptr<ModelAPI_Data> aData = theFeature->data();
double anA, aB, aC, aD;
aPlane->coefficients(anA, aB, aC, aD);
virtual void setHighlighted(bool) { /*do nothing*/ };
virtual void enableFocusProcessing();
+ static bool fillSketchPlaneBySelection(const FeaturePtr& theFeature,
+ const ModuleBase_ViewerPrs& thePrs);
+
signals:
/// Signal on plane selection
void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
/// Set sketch plane by shape
/// \param theShape a planar face
- std::shared_ptr<GeomAPI_Dir> setSketchPlane(const TopoDS_Shape& theShape);
+ static std::shared_ptr<GeomAPI_Dir> setSketchPlane(const FeaturePtr& theFeature,
+ const TopoDS_Shape& theShape);
/// Erase preview planes
void erasePreviewPlanes();