📄 rs_entity.h
字号:
RS_String getGraphicVariableString(const RS_String& key, const RS_String& def); RS2::Unit getGraphicUnit(); /** * Must be overwritten to get all reference points of the entity. */ virtual RS_VectorSolutions getRefPoints() { RS_VectorSolutions ret; return ret; } /** * Must be overwritten to get the closest endpoint to the * given coordinate for this entity. * * @param coord Coordinate (typically a mouse coordinate) * @param dist Pointer to a value which will contain the measured * distance between 'coord' and the closest endpoint. The passed * pointer can also be NULL in which case the distance will be * lost. * * @return The closest endpoint. */ virtual RS_Vector getNearestEndpoint(const RS_Vector& coord, double* dist = NULL) = 0; /** * Must be overwritten to get the closest coordinate to the * given coordinate which is on this entity. * * @param coord Coordinate (typically a mouse coordinate) * @param dist Pointer to a value which will contain the measured * distance between \p coord and the point. The passed pointer can * also be \p NULL in which case the distance will be lost. * * @return The closest coordinate. */ virtual RS_Vector getNearestPointOnEntity(const RS_Vector& /*coord*/, bool onEntity = true, double* dist = NULL, RS_Entity** entity = NULL) = 0; /** * Must be overwritten to get the (nearest) center point to the * given coordinate for this entity. * * @param coord Coordinate (typically a mouse coordinate) * @param dist Pointer to a value which will contain the measured * distance between 'coord' and the closest center point. The passed * pointer can also be NULL in which case the distance will be * lost. * * @return The closest center point. */ virtual RS_Vector getNearestCenter(const RS_Vector& coord, double* dist = NULL) = 0; /** * Must be overwritten to get the (nearest) middle point to the * given coordinate for this entity. * * @param coord Coordinate (typically a mouse coordinate) * @param dist Pointer to a value which will contain the measured * distance between 'coord' and the closest middle point. The passed * pointer can also be NULL in which case the distance will be * lost. * * @return The closest middle point. */ virtual RS_Vector getNearestMiddle(const RS_Vector& coord, double* dist = NULL) = 0; /** * Must be overwritten to get the nearest point with a given * distance to the endpoint to the given coordinate for this entity. * * @param distance Distance to endpoint. * @param coord Coordinate (typically a mouse coordinate) * @param dist Pointer to a value which will contain the measured * distance between 'coord' and the closest point. The passed * pointer can also be NULL in which case the distance will be * lost. * * @return The closest point with the given distance to the endpoint. */ virtual RS_Vector getNearestDist(double distance, const RS_Vector& coord, double* dist = NULL) = 0; /** * Must be overwritten to get the point with a given * distance to the start- or endpoint to the given coordinate for this entity. * * @param distance Distance to endpoint. * @param startp true = measured from Startpoint, false = measured from Endpoint * * @return The point with the given distance to the start- or endpoint. */ virtual RS_Vector getNearestDist(double /*distance*/, bool /*startp*/) { return RS_Vector(false); } /** * Must be overwritten to get the nearest reference point for this entity. * * @param coord Coordinate (typically a mouse coordinate) * @param dist Pointer to a value which will contain the measured * distance between 'coord' and the closest point. The passed * pointer can also be NULL in which case the distance will be * lost. * * @return The closest point with the given distance to the endpoint. */ virtual RS_Vector getNearestRef(const RS_Vector& coord, double* dist = NULL) { RS_VectorSolutions s = getRefPoints(); return s.getClosest(coord, dist); } /** * Gets the nearest reference point of this entity if it is selected. * Containers re-implement this method to return the nearest reference * point of a selected sub entity. * * @param coord Coordinate (typically a mouse coordinate) * @param dist Pointer to a value which will contain the measured * distance between 'coord' and the closest point. The passed * pointer can also be NULL in which case the distance will be * lost. * * @return The closest point with the given distance to the endpoint. */ virtual RS_Vector getNearestSelectedRef(const RS_Vector& coord, double* dist = NULL) { if (isSelected()) { return getNearestRef(coord, dist); } else { return RS_Vector(false); } } /** * Must be overwritten to get the shortest distance between this * entity and a coordinate. * * @param coord Coordinate (typically a mouse coordinate) * @param entity Pointer which will contain the (sub-)entity which is * closest to the given point or NULL if the caller is not * interested in this information. * @param level The resolve level. * * @sa RS2::ResolveLevel * * @return The measured distance between \p coord and the entity. */ virtual double getDistanceToPoint(const RS_Vector& coord, RS_Entity** entity = NULL, RS2::ResolveLevel level = RS2::ResolveNone, double solidDist = RS_MAXDOUBLE) = 0; virtual bool isPointOnEntity(const RS_Vector& coord, double tolerance=RS_TOLERANCE); /** * Implementations must move the entity by the given vector. */ virtual void move(RS_Vector offset) = 0; /** * Implementations must rotate the entity by the given angle around * the given center. */ virtual void rotate(RS_Vector center, double angle) = 0; /** * Implementations must scale the entity by the given factors. */ virtual void scale(RS_Vector center, RS_Vector factor) = 0; /** * Acts like scale(RS_Vector) but with equal factors. * Equal to scale(center, RS_Vector(factor, factor)). */ virtual void scale(RS_Vector center, double factor) { scale(center, RS_Vector(factor, factor)); } /** * Implementations must mirror the entity by the given axis. */ virtual void mirror(RS_Vector axisPoint1, RS_Vector axisPoint2) = 0; virtual void stretch(RS_Vector firstCorner, RS_Vector secondCorner, RS_Vector offset); /** * Implementations must drag the reference point(s) of all * (sub-)entities that are very close to ref by offset. */ virtual void moveRef(const RS_Vector& /*ref*/, const RS_Vector& /*offset*/) { return; } /** * Implementations must drag the reference point(s) of selected * (sub-)entities that are very close to ref by offset. */ virtual void moveSelectedRef(const RS_Vector& /*ref*/, const RS_Vector& /*offset*/) { return; } /** * Implementations must draw the entity on the given device. */ virtual void draw(RS_Painter* painter, RS_GraphicView* view, double patternOffset = 0.0) = 0; double getStyleFactor(RS_GraphicView* view); RS_String* getUserDefVar(RS_String key); RS_StringList getAllKeys(); void setUserDefVar(RS_String key, RS_String val); void delUserDefVar(RS_String key); friend std::ostream& operator << (std::ostream& os, RS_Entity& e); /** Recalculates the borders of this entity. */ virtual void calculateBorders() = 0;protected: //! Entity's parent entity or NULL is this entity has no parent. RS_EntityContainer* parent; //! minimum coordinates RS_Vector minV; //! maximum coordinates RS_Vector maxV; //! Pointer to layer RS_Layer* layer; //! Entity id unsigned long int id; //! pen (attributes) for this entity RS_Pen pen; //! auto updating enabled? bool updateEnabled;private: RS_Dict<RS_String> varList;};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -