+ std::list<int> aModes;
+ if (!myIsEditMode)
+ aModes.push_back(TopAbs_FACE);
+ else {
+ aModes.push_back(TopAbs_VERTEX);
+ aModes.push_back(TopAbs_EDGE);
+ }
+ return aModes;
+}
+
+void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
+ const std::list<XGUI_ViewerPrs>& theSelected)
+{
+ if (theSelected.empty())
+ return;
+
+ if (!myIsEditMode) {
+ XGUI_ViewerPrs aPrs = theSelected.front();
+ const TopoDS_Shape& aShape = aPrs.shape();
+ if (!aShape.IsNull()) {
+ setSketchPlane(aShape);
+ myIsEditMode = true;
+ }
+ }
+}
+
+void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView,
+ const std::list<XGUI_ViewerPrs>& theSelected)
+{
+ if (!myIsEditMode || !(theEvent->buttons() & Qt::LeftButton) || theSelected.empty())
+ return;
+
+ boost::shared_ptr<ModelAPI_Feature> aFeature = PartSet_Tools::NearestFeature(theEvent->pos(),
+ theView, feature(), theSelected);
+ if (aFeature)
+ emit launchOperation(PartSet_OperationEditLine::Type(), aFeature);
+}
+
+void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape)
+{
+ if (theShape.IsNull())
+ return;
+
+ // get selected shape
+ boost::shared_ptr<GeomAPI_Shape> aGShape(new GeomAPI_Shape);
+ aGShape->setImpl(new TopoDS_Shape(theShape));
+
+ // get plane parameters
+ boost::shared_ptr<GeomAPI_Pln> aPlane = GeomAlgoAPI_FaceBuilder::plane(aGShape);
+
+ // set plane parameters to feature
+ boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+ double anA, aB, aC, aD;
+ aPlane->coefficients(anA, aB, aC, aD);
+
+ boost::shared_ptr<ModelAPI_AttributeDouble> anAttr;
+ /*
+ aData->real(SKETCH_ATTR_PLANE_A)->setValue(anA);
+ aData->real(SKETCH_ATTR_PLANE_B)->setValue(aB);
+ aData->real(SKETCH_ATTR_PLANE_C)->setValue(aC);
+ aData->real(SKETCH_ATTR_PLANE_D)->setValue(aD);
+ */
+ // temporary solution for main planes only
+ boost::shared_ptr<GeomDataAPI_Point> anOrigin =
+ boost::dynamic_pointer_cast<GeomDataAPI_Point>(aData->attribute(SKETCH_ATTR_ORIGIN));
+ anOrigin->setValue(0, 0, 0);
+ boost::shared_ptr<GeomDataAPI_Dir> aNormal =
+ boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_NORM));
+ aNormal->setValue(anA, aB, aC);
+ boost::shared_ptr<GeomDataAPI_Dir> aDirX =
+ boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRX));
+ aDirX->setValue(aB, aC, anA);
+ boost::shared_ptr<GeomDataAPI_Dir> aDirY =
+ boost::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SKETCH_ATTR_DIRY));
+ aDirY->setValue(aC, anA, aB);
+ boost::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
+ emit planeSelected(aDir->x(), aDir->y(), aDir->z());