-std::list<int> PartSet_OperationSketch::getSelectionModes(FeaturePtr theFeature) const
-{
- std::list<int> aModes;
- if (!hasSketchPlane())
- aModes.push_back(TopAbs_FACE);
- else
- aModes = PartSet_OperationSketchBase::getSelectionModes(theFeature);
-
- return aModes;
-}
-
-
-/// Initializes the operation with previously created feature. It is used in sequental operations
-void PartSet_OperationSketch::initFeature(FeaturePtr theFeature)
-{
- if (theFeature)
- setEditingFeature(theFeature);
-}
-
-FeaturePtr PartSet_OperationSketch::sketch() const
-{
- return feature();
-}
-
-void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted)
-{
- if (!hasSketchPlane()) {
- if (!theHighlighted.empty()) {
- XGUI_ViewerPrs aPrs = theHighlighted.front();
- const TopoDS_Shape& aShape = aPrs.shape();
- if (!aShape.IsNull())
- setSketchPlane(aShape);
- }
- }
- else {
- // if shift button is pressed and there are some already selected objects, the operation should
- // not be started. We just want to combine some selected objects.
- bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
- if (aHasShift && theSelected.size() > 0)
- return;
-
- if (theHighlighted.size() == 1) {
- FeaturePtr aFeature = theHighlighted.front().feature();
- if (aFeature) {
- std::string anOperationType = PartSet_OperationFeatureEdit::Type();
- if (theSelected.size() > 1)
- anOperationType = PartSet_OperationFeatureEditMulti::Type();
- restartOperation(anOperationType, aFeature);
- }
- }
- else
- myFeatures = theHighlighted;
-
- }
-}
-
-void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
- const std::list<XGUI_ViewerPrs>& theSelected,
- const std::list<XGUI_ViewerPrs>& theHighlighted)
-{
- if (!hasSketchPlane()) {
- }
- else {
- /// TODO: OCC bug: 25034 - the highlighted list should be filled not only for AIS_Shape
- /// but for other IO, for example constraint dimensions.
- /// It is empty and we have to use the process mouse release to start edition operation
- /// for these objects
- if (theSelected.size() == 1) {
- FeaturePtr aFeature = theSelected.front().feature();
- if (aFeature)
- restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature);
- }
- }
-}
-
-void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
-{
- if (!hasSketchPlane() || !(theEvent->buttons() & Qt::LeftButton) || myFeatures.empty())
- return;
-
- if (myFeatures.size() != 1) {
- FeaturePtr aFeature = PartSet_Tools::nearestFeature(theEvent->pos(), theView, feature(),
- myFeatures);
- if (aFeature)
- restartOperation(PartSet_OperationFeatureEditMulti::Type(), aFeature);
- }
-}
-
-std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> >
- PartSet_OperationSketch::subPreview() const
-{
- std::map<FeaturePtr, boost::shared_ptr<GeomAPI_Shape> > aPreviewMap;
-
- boost::shared_ptr<SketchPlugin_Feature> aFeature;
-
- boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
- if (!aData->isValid())
- return aPreviewMap;
- boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
- boost::dynamic_pointer_cast<ModelAPI_AttributeRefList>(aData->attribute(SKETCH_ATTR_FEATURES));
-
- std::list<FeaturePtr > aFeatures = aRefList->list();
- std::list<FeaturePtr >::const_iterator anIt = aFeatures.begin(),
- aLast = aFeatures.end();
- for (; anIt != aLast; anIt++) {
- aFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(*anIt);
- boost::shared_ptr<GeomAPI_Shape> aPreview = aFeature->preview();
- if (aPreview)
- aPreviewMap[aFeature] = aPreview;
- }
- return aPreviewMap;
-}
-
-void PartSet_OperationSketch::stopOperation()
-{
- PartSet_OperationSketchBase::stopOperation();
- emit featureConstructed(feature(), FM_Hide);
- emit closeLocalContext();
-}
-