- /// \param thePoint the 3D point in the viewer
- static void ConvertTo3D(const double theX, const double theY,
- boost::shared_ptr<ModelAPI_Feature> theSketch,
- gp_Pnt& thePoint);
-
- /// Returns the point of intersection of the two lines, the first is (v0, v1), the second is (v2, v3),
- /// where vi - {xi,yi}. If the v0 is on the second line, the result is a projection of the v1 to this line
- /// \param theX0 the horizontal coordinate of 0 point
- /// \param theY0 the vertical coordinate of 0 point
- /// \param theX1 the horizontal coordinate of 1 point
- /// \param theY1 the vertical coordinate of 1 point
- /// \param theX2 the horizontal coordinate of 2 point
- /// \param theY2 the vertical coordinate of 2 point
- /// \param theX3 the horizontal coordinate of 3 point
- /// \param theY3 the vertical coordinate of 3 point
- /// \param theX the output horizontal coordinate of the intersection point
- /// \param theY the outpup vertical coordinate of the intersection point
- static void IntersectLines(double theX0, double theY0, double theX1, double theY1,
- double theX2, double theY2, double theX3, double theY3,
- double& theX, double& theY);
-
- /// Returns the coordinates of projection of the point to the line
- /// \param thePointX the projected point horizontal coordinate
- /// \param thePointY the projected point vertictal coordinate
- /// \param theX1 the horizontal coordinate of the first line point
- /// \param theY1 the vertical coordinate of the first line point
- /// \param theX2 the horizontal coordinate of the second line point
- /// \param theY2 the vertical coordinate of the second line point
- static void ProjectPointOnLine(double theX1, double theY1, double theX2, double theY2,
- double thePointX, double thePointY, double& theX, double& theY);
-
- /// Returns a feature that is under the mouse point
- /// \param thePoint a screen point
- /// \param theView a 3D view
- /// \param theSketch the sketch feature
- /// \param theFeatures the list of selected presentations
- static boost::shared_ptr<ModelAPI_Feature> NearestFeature(QPoint thePoint, Handle_V3d_View theView,
- boost::shared_ptr<ModelAPI_Feature> theSketch,
- const std::list<XGUI_ViewerPrs>& theFeatures);
-private:
- /// Return the distance between the feature and the point
- /// \param theFeature feature object
- /// \param theX the horizontal coordinate of the point
- /// \param theX the vertical coordinate of the point
- static double DistanceToPoint(boost::shared_ptr<ModelAPI_Feature> theFeature,
- double theX, double theY);
+ static std::shared_ptr<GeomAPI_Pnt> convertTo3D(const double theX, const double theY,
+ FeaturePtr theSketch);
+
+ /// Returns pointer to the root document.
+ static std::shared_ptr<ModelAPI_Document> document();
+
+ /// \brief Save the double to the feature. If the attribute is double, it is filled.
+ /// \param theFeature the feature
+ /// \param theX the horizontal coordinate
+ /// \param theAttribute the feature attribute
+ static void setFeatureValue(FeaturePtr theFeature, double theX, const std::string& theAttribute);
+
+ /// \brief Returns the feature double value if it is.
+ /// \param theFeature the feature
+ /// \param theAttribute the feature attribute
+ /// \param isValid an output parameter whether the value is valid
+ /// \returns the feature value
+ static double featureValue(FeaturePtr theFeature, const std::string& theAttribute, bool& isValid);
+
+ /// Find a feature in the attribute of the given feature. If the kind is not empty,
+ /// the return feature should be this type. Otherwise it is null
+ /// \param theFeature a source feature
+ /// \param theAttribute a name of the requried attribute attribute
+ /// \param theKind an output feature kind
+ /// \return the feature
+ static FeaturePtr feature(FeaturePtr theFeature, const std::string& theAttribute,
+ const std::string& theKind);
+
+ /// Creates a constraint on two points
+ /// \param theSketch a sketch feature
+ /// \param thePoint1 the first point
+ /// \param thePoint2 the second point
+ static void createConstraint(CompositeFeaturePtr theSketch,
+ std::shared_ptr<GeomDataAPI_Point2D> thePoint1,
+ std::shared_ptr<GeomDataAPI_Point2D> thePoint2);
+
+ /// Create a sketch plane instance
+ /// \param theSketch a sketch feature
+ /// \return API object of geom plane
+ static std::shared_ptr<GeomAPI_Pln> sketchPlane(CompositeFeaturePtr theSketch);
+
+ /// Create a sketch plane instance
+ /// \param theSketch a sketch feature
+ /// \return API object of geom plane
+ static void nullifySketchPlane(CompositeFeaturePtr theSketch);
+
+ /// Create a point 3D on a basis of point 2D and sketch feature
+ /// \param thePoint2D a point on a sketch
+ /// \param theSketch a sketch feature
+ /// \return API object of point 3D
+ static std::shared_ptr<GeomAPI_Pnt> point3D(std::shared_ptr<GeomAPI_Pnt2d> thePoint2D,
+ CompositeFeaturePtr theSketch);
+
+ /// Finds a line (arc or circle) by given edge
+ /// \param theShape an edge
+ /// \param theObject a selected result object
+ /// \param theSketch a sketch feature
+ /// \return result of found feature or NULL
+ static std::shared_ptr<ModelAPI_Result> findFixedObjectByExternal(
+ const TopoDS_Shape& theShape,
+ const ObjectPtr& theObject,
+ CompositeFeaturePtr theSketch);
+
+ /// Creates a line (arc or circle) by given edge
+ /// Created line will have fixed constraint
+ /// \param theShape an edge
+ /// \param theObject a selected result object
+ /// \param theSketch a sketch feature
+ /// \param theTemporary the created external object is temporary, execute is not performed for it
+ /// \param theCreatedFeature a new projection feature
+ /// \return result of created feature
+ static std::shared_ptr<ModelAPI_Result> createFixedObjectByExternal(
+ const std::shared_ptr<GeomAPI_Shape>& theShape,
+ const ObjectPtr& theObject,
+ CompositeFeaturePtr theSketch,
+ const bool theTemporary,
+ FeaturePtr& theCreatedFeature);
+
+ /// Checks whether the list of selected presentations contains the given one
+ /// \param theSelected a list of presentations
+ /// \param thePrs a presentation to be found
+ /// \return - result of check, true if the list contains the prs
+ static bool isContainPresentation(const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theSelected,
+ const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
+
+ /**
+ * Find attribute of object which corresponds to the given shape
+ * \param theObj - an object
+ * \param theShape - a Shape
+ * \param theSketch - a Sketch to get a plane of converting to 2d
+ */
+ static AttributePtr findAttributeBy2dPoint(ObjectPtr theObj, const TopoDS_Shape theShape,
+ FeaturePtr theSketch);
+
+ /**
+ * Finds an attribute value in attribute reference attribute value
+ * \param theAttribute - an attribure reference filled with an attribute
+ * \param theWorkshop a reference to workshop
+ * \return a geometry shape
+ */
+ static std::shared_ptr<GeomAPI_Shape> findShapeBy2DPoint(const AttributePtr& theAttribute,
+ ModuleBase_IWorkshop* theWorkshop);
+
+ /**
+ * Returns point of coincidence feature
+ * \param theFeature the coincidence feature
+ * \param theAttribute the attribute name
+ */
+ static std::shared_ptr<GeomAPI_Pnt2d> getPoint(std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::string& theAttribute);
+
+ /**
+ * Convertes parameters into a geom point
+ * \theEvent a Qt event to find mouse position
+ * \param theWindow view window to define eye of view
+ * \param theSketch to convert 3D point coordinates into coorditates of the sketch plane
+ */
+ static std::shared_ptr<GeomAPI_Pnt2d> getPnt2d(QMouseEvent* theEvent,
+ ModuleBase_IViewWindow* theWindow,
+ const FeaturePtr& theSketch);
+
+ /**
+ * Gets all references to the feature, take coincidence constraint features, get point 2d attributes
+ * and compare the point value to be equal with the given. Returns the first feature, which has
+ * equal points.
+ * \param theFeature the coincidence feature
+ * \param thePoint a 2d point
+ * \return the coincidence feature or null
+ */
+ static FeaturePtr findFirstCoincidence(const FeaturePtr& theFeature,
+ std::shared_ptr<GeomAPI_Pnt2d> thePoint);
+
+ /**
+ * Returns list of features connected in a councedence feature point
+ * \param theStartCoin the coincidence feature
+ * \param theList a list which collects lines features
+ * \param theCoincidencies a list of coincidence features
+ * \param theAttr the attribute name
+ */
+ static void findCoincidences(FeaturePtr theStartCoin, QList<FeaturePtr>& theList,
+ QList<FeaturePtr>& theCoincidencies,
+ std::string theAttr, QList<bool>& theIsAttributes);
+
+ /*
+ * Finds and returns feature reerenced to the paramenter feature with the given name if found
+ * \param theFeature a source feature where refsToMe is obtained
+ * \param theFeatureId an indentifier of the searched feature
+ */
+ static FeaturePtr findRefsToMeFeature(FeaturePtr theFeature, const std::string& theFeatureId)
+ {
+ if (!theFeature.get())
+ return FeaturePtr();
+
+ // find first projected feature and edit it
+ const std::set<AttributePtr>& aRefsList = theFeature->data()->refsToMe();
+ std::set<AttributePtr>::const_iterator anIt;
+ for (anIt = aRefsList.cbegin(); anIt != aRefsList.cend(); ++anIt) {
+ FeaturePtr aRefFeature = std::dynamic_pointer_cast<ModelAPI_Feature>((*anIt)->owner());
+ if (aRefFeature && aRefFeature->getKind() == theFeatureId)
+ return aRefFeature;
+ }
+ return FeaturePtr();
+ }
+
+ /**
+ * Returns point of a coincedence
+ * \param theStartCoin the coincedence feature
+ */
+ static std::shared_ptr<GeomAPI_Pnt2d> getCoincedencePoint(FeaturePtr theStartCoin);
+
+ /// Sends redisplay event for all sub-features of the composite. Flush it.
+ static void sendSubFeaturesEvent(const CompositeFeaturePtr& theComposite,
+ const Events_ID theId);
+
+ /**
+ * Returns true if the object is a sketch entity, where auxiliary attribute has true value
+ * \param theObject a result or feature
+ * \return boolean result
+ */
+ static bool isAuxiliarySketchEntity(const ObjectPtr& theObject);
+
+ /**
+ * Returns true if the object is a sketch entity produced by projection or intersection feature
+ * and if it should not be included into the sketch result
+ */
+ static bool isIncludeIntoSketchResult(const ObjectPtr& theObject);
+
+ static ResultPtr createFixedByExternalCenter(const ObjectPtr& theObject,
+ const std::shared_ptr<GeomAPI_Edge>& theEdge,
+ ModelAPI_AttributeSelection::CenterType theType,
+ const CompositeFeaturePtr& theSketch,
+ bool theTemporary,
+ FeaturePtr& theCreatedFeature);
+
+
+ static void getFirstAndLastIndexInFolder(const ObjectPtr& theFolder,
+ int& theFirst, int& theLast);
+
+
+ /**
+ * Returns default color value for the given object
+ */
+ static void getDefaultColor(ObjectPtr theObject, const bool isEmptyColorValid,
+ std::vector<int>& theColor);
+
+ /**
+ * Returns default deflection value for the given object
+ */
+ static double getDefaultDeflection(const ObjectPtr& theObject);
+
+
+ /**
+ * Returns default transparency value
+ */
+ static double getDefaultTransparency();
+
+ /**
+ * Returns cursor according to (SKETCH_TAB_NAME, "operation_cursor") property value
+ */
+ static QCursor getOperationCursor();