Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages

RS_EntityContainer Class Reference

Class representing a tree of entities. More...

#include <rs_entitycontainer.h>

Inheritance diagram for RS_EntityContainer:

RS_Entity RS_Undoable RS_Flags RS_Dimension RS_Document RS_Hatch RS_Insert RS_Leader RS_Pattern RS_Polyline RS_Preview RS_Spline RS_Text List of all members.

Public Member Functions

 RS_EntityContainer (RS_EntityContainer *parent=NULL, bool owner=true)
 Default constructor.
virtual ~RS_EntityContainer ()
 Destructor.
virtual RS_Entityclone ()
virtual void detach ()
 Detaches shallow copies and creates deep copies of all subentities.
virtual RS2::EntityType rtti () const
void reparent (RS_EntityContainer *parent)
virtual bool isContainer () const
virtual bool isAtomic () const
virtual double getLength ()
virtual void undoStateChanged (bool undone)
 Called when the undo state changed.
virtual void setVisible (bool v)
virtual void setProcessed (bool on)
 Resets all processed flags of all entities.
virtual bool setSelected (bool select=true)
 Selects this entity.
virtual bool toggleSelected ()
 Toggles select on this entity.
virtual void selectWindow (const RS_Vector &v1, const RS_Vector &v2, bool select=true, bool cross=false)
 Selects all entities within the given area.
virtual void addEntity (RS_Entity *entity)
 Adds a entity to this container and updates the borders of this entity-container if autoUpdateBorders is true.
virtual void insertEntity (int index, RS_Entity *entity)
 Inserts a entity to this container at the given position and updates the borders of this entity-container if autoUpdateBorders is true.
virtual void replaceEntity (int index, RS_Entity *entity)
 Replaces the entity at the given index with the given entity and updates the borders of this entity-container if autoUpdateBorders is true.
virtual bool removeEntity (RS_Entity *entity)
 Removes an entity from this container and updates the borders of this entity-container if autoUpdateBorders is true.
virtual void moveEntityToBack (RS_Entity *entity, bool toBack=true)
 Moves the given entity in the background (at the end of the entity list).
virtual void moveEntityToFront (RS_Entity *entity)
 Moves the given entity in the foreground (at the end of the entity list).
virtual RS_EntityfirstEntity (RS2::ResolveLevel level=RS2::ResolveNone)
 Returns the first entity or NULL if this graphic is empty.
virtual RS_EntitylastEntity (RS2::ResolveLevel level=RS2::ResolveNone)
 Returns the last entity or NULL if this graphic is empty.
virtual RS_EntitynextEntity (RS2::ResolveLevel level=RS2::ResolveNone)
 Returns the next entity or container or NULL if the last entity returned by next() was the last entity in the container.
virtual RS_EntityprevEntity (RS2::ResolveLevel level=RS2::ResolveNone)
 Returns the prev entity or container or NULL if the last entity returned by prev() was the first entity in the container.
virtual RS_EntityentityAt (int index)
virtual RS_EntitycurrentEntity ()
virtual int entityAt ()
virtual int findEntity (RS_Entity *entity)
 Finds the given entity and makes it the current entity if found.
virtual void clear ()
 Erases all entities in this container and resets the borders.
RS_MutableListIterator< RS_Entity * > createIterator ()
 Returns the copy to a new iterator for traversing the entities.
virtual bool isEmpty ()
virtual int count ()
 Counts all entities (branches of the tree).
virtual int countDeep ()
 Counts all entities (leaves of the tree).
virtual int countSelected ()
 Counts the selected entities in this container.
virtual void setAutoUpdateBorders (bool enable)
 Enables / disables automatic update of borders on entity removals and additions.
virtual void adjustBorders (RS_Entity *entity)
 Adjusts the borders of this graphic (max/min values).
virtual void calculateBorders ()
 Recalculates the borders of this entity container.
virtual void forcedCalculateBorders ()
 Recalculates the borders of this entity container including invisible entities.
virtual int updateDimensions (bool autoText=true, bool onlySelected=false)
 Updates all Dimension entities in this container and reposition their labels if autoText is true.
virtual void updateInserts ()
 Updates all Insert entities in this container.
virtual void updateSplines ()
 Updates all Spline entities in this container.
virtual void update ()
 Updates the sub entities of this container.
virtual void renameInserts (const RS_String &oldName, const RS_String &newName)
 Renames all inserts with name 'oldName' to 'newName'.
virtual RS_Vector getNearestEndpoint (const RS_Vector &coord, double *dist=NULL)
RS_EntitygetNearestEntity (const RS_Vector &point, double *dist=NULL, RS2::ResolveLevel level=RS2::ResolveAll)
virtual RS_Vector getNearestPointOnEntity (const RS_Vector &coord, bool onEntity=true, double *dist=NULL, RS_Entity **entity=NULL)
 Must be overwritten to get the closest coordinate to the given coordinate which is on this entity.
virtual RS_Vector getNearestCenter (const RS_Vector &coord, double *dist=NULL)
 Must be overwritten to get the (nearest) center point to the given coordinate for this entity.
virtual RS_Vector getNearestMiddle (const RS_Vector &coord, double *dist=NULL)
 Must be overwritten to get the (nearest) middle point to the given coordinate for this entity.
virtual RS_Vector getNearestDist (double distance, const RS_Vector &coord, double *dist=NULL)
 Must be overwritten to get the nearest point with a given distance to the endpoint to the given coordinate for this entity.
virtual RS_Vector getNearestIntersection (const RS_Vector &coord, double *dist=NULL)
virtual RS_Vector getNearestRef (const RS_Vector &coord, double *dist=NULL)
 Must be overwritten to get the nearest reference point for this entity.
virtual RS_Vector getNearestSelectedRef (const RS_Vector &coord, double *dist=NULL)
 Gets the nearest reference point of this entity if it is selected.
virtual double getDistanceToPoint (const RS_Vector &coord, RS_Entity **entity, RS2::ResolveLevel level=RS2::ResolveNone, double solidDist=RS_MAXDOUBLE)
 Must be overwritten to get the shortest distance between this entity and a coordinate.
virtual RS2::Side getSideOfPoint (const RS_Vector &)
 Implementations must return RS2::RightHand if coord is on the right hand side of this entity, RS2::LeftHand if it is on the left hand side and RS2::NoSide otherwise (on entity, entity has no side, .
virtual bool optimizeContours ()
 Rearranges the atomic entities in this container in a way that connected entities are stored in the right order and direction.
virtual bool hasEndpointsWithinWindow (const RS_Vector &v1, const RS_Vector &v2)
virtual void move (const RS_Vector &offset)
 Implementations must move the entity by the given vector.
virtual void rotate (const RS_Vector &center, double angle)
 Implementations must rotate the entity by the given angle around the given center.
virtual void scale (const RS_Vector &center, const RS_Vector &factor)
 Implementations must scale the entity by the given factors.
virtual void mirror (const RS_Vector &axisPoint1, const RS_Vector &axisPoint2)
 Implementations must mirror the entity by the given axis.
virtual void stretch (const RS_Vector &firstCorner, const RS_Vector &secondCorner, const RS_Vector &offset)
 Implementations must stretch the given range of the entity by the given offset.
virtual void moveRef (const RS_Vector &ref, const RS_Vector &offset)
 Implementations must drag the reference point(s) of all (sub-)entities that are very close to ref by offset.
virtual void moveSelectedRef (const RS_Vector &ref, const RS_Vector &offset)
 Implementations must drag the reference point(s) of selected (sub-)entities that are very close to ref by offset.
virtual void draw (RS_Painter *painter, RS_GraphicView *view, double patternOffset=0.0)
 Implementations must draw the entity on the given device.

Protected Attributes

RS_PtrList< RS_Entityentities
 entities in the container
RS_EntityContainersubContainer
 sub container used only temporarly for iteration.

Static Protected Attributes

static bool autoUpdateBorders = true
 Automatically update the borders of the container when entities are added or removed.

Detailed Description

Class representing a tree of entities.

Typical entity containers are graphics, polylines, groups, texts, ...)

Author:
Andrew Mustun


Constructor & Destructor Documentation

RS_EntityContainer::RS_EntityContainer RS_EntityContainer parent = NULL,
bool  owner = true
 

Default constructor.

Parameters:
owner True if we own and also delete the entities.


Member Function Documentation

void RS_EntityContainer::clear  )  [virtual]
 

Erases all entities in this container and resets the borders.

RS_Entity * RS_EntityContainer::currentEntity  )  [virtual]
 

Returns:
The current entity.

void RS_EntityContainer::detach  )  [virtual]
 

Detaches shallow copies and creates deep copies of all subentities.

This is called after cloning entity containers.

int RS_EntityContainer::entityAt  )  [virtual]
 

Returns:
Current index.

RS_Entity * RS_EntityContainer::entityAt int  index  )  [virtual]
 

Returns:
Entity at the given index or NULL if the index is out of range.

RS_Entity * RS_EntityContainer::firstEntity RS2::ResolveLevel  level = RS2::ResolveNone  )  [virtual]
 

Returns the first entity or NULL if this graphic is empty.

Parameters:
level 

double RS_EntityContainer::getDistanceToPoint const RS_Vector coord,
RS_Entity **  entity,
RS2::ResolveLevel  level = RS2::ResolveNone,
double  solidDist = RS_MAXDOUBLE
[virtual]
 

Must be overwritten to get the shortest distance between this entity and a coordinate.

Parameters:
coord Coordinate (typically a mouse coordinate)
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.
level The resolve level.
See also:
RS2::ResolveLevel
Returns:
The measured distance between coord and the entity.

Implements RS_Entity.

Reimplemented in RS_Hatch.

double RS_EntityContainer::getLength  )  [virtual]
 

Returns:
Total length of all entities in this container.

Reimplemented from RS_Entity.

Reimplemented in RS_Dimension, RS_Hatch, RS_Leader, and RS_Text.

RS_Vector RS_EntityContainer::getNearestCenter const RS_Vector coord,
double *  dist = NULL
[virtual]
 

Must be overwritten to get the (nearest) center point to the given coordinate for this entity.

Parameters:
coord Coordinate (typically a mouse coordinate)
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.
Returns:
The closest center point.

Implements RS_Entity.

Reimplemented in RS_Spline.

RS_Vector RS_EntityContainer::getNearestDist double  distance,
const RS_Vector coord,
double *  dist = NULL
[virtual]
 

Must be overwritten to get the nearest point with a given distance to the endpoint to the given coordinate for this entity.

Parameters:
distance Distance to endpoint.
coord Coordinate (typically a mouse coordinate)
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.
Returns:
The closest point with the given distance to the endpoint.

Implements RS_Entity.

Reimplemented in RS_Spline.

RS_Vector RS_EntityContainer::getNearestEndpoint const RS_Vector coord,
double *  dist = NULL
[virtual]
 

Returns:
The point which is closest to 'coord' (one of the vertexes)

Implements RS_Entity.

Reimplemented in RS_Spline.

RS_Vector RS_EntityContainer::getNearestIntersection const RS_Vector coord,
double *  dist = NULL
[virtual]
 

Returns:
The intersection which is closest to 'coord'

RS_Vector RS_EntityContainer::getNearestMiddle const RS_Vector coord,
double *  dist = NULL
[virtual]
 

Must be overwritten to get the (nearest) middle point to the given coordinate for this entity.

Parameters:
coord Coordinate (typically a mouse coordinate)
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.
Returns:
The closest middle point.

Implements RS_Entity.

Reimplemented in RS_Spline.

RS_Vector RS_EntityContainer::getNearestPointOnEntity const RS_Vector coord,
bool  onEntity = true,
double *  dist = NULL,
RS_Entity **  entity = NULL
[virtual]
 

Must be overwritten to get the closest coordinate to the given coordinate which is on this entity.

Parameters:
coord Coordinate (typically a mouse coordinate)
dist Pointer to a value which will contain the measured distance between coord and the point. The passed pointer can also be NULL in which case the distance will be lost.
Returns:
The closest coordinate.

Implements RS_Entity.

RS_Vector RS_EntityContainer::getNearestRef const RS_Vector coord,
double *  dist = NULL
[virtual]
 

Must be overwritten to get the nearest reference point for this entity.

Parameters:
coord Coordinate (typically a mouse coordinate)
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.
Returns:
The closest point with the given distance to the endpoint.

Reimplemented from RS_Entity.

Reimplemented in RS_Dimension, RS_Insert, RS_Leader, RS_Polyline, RS_Spline, and RS_Text.

RS_Vector RS_EntityContainer::getNearestSelectedRef const RS_Vector coord,
double *  dist = NULL
[virtual]
 

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.

Parameters:
coord Coordinate (typically a mouse coordinate)
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.
Returns:
The closest point with the given distance to the endpoint.

Reimplemented from RS_Entity.

Reimplemented in RS_Dimension, RS_Leader, RS_Polyline, and RS_Spline.

virtual RS2::Side RS_EntityContainer::getSideOfPoint const RS_Vector  )  [inline, virtual]
 

Implementations must return RS2::RightHand if coord is on the right hand side of this entity, RS2::LeftHand if it is on the left hand side and RS2::NoSide otherwise (on entity, entity has no side, .

.).

Implements RS_Entity.

virtual bool RS_EntityContainer::isAtomic  )  const [inline, virtual]
 

Returns:
false: because entities made from this class and subclasses are containers for other entities.

Implements RS_Entity.

virtual bool RS_EntityContainer::isContainer  )  const [inline, virtual]
 

Returns:
true: because entities made from this class and subclasses are containers for other entities.

Implements RS_Entity.

Reimplemented in RS_Hatch.

RS_Entity * RS_EntityContainer::lastEntity RS2::ResolveLevel  level = RS2::ResolveNone  )  [virtual]
 

Returns the last entity or NULL if this graphic is empty.

Parameters:
level\li 0 Groups are not resolved
  • 1 (default) only Groups are resolved
  • 2 all Entity Containers are resolved

bool RS_EntityContainer::optimizeContours  )  [virtual]
 

Rearranges the atomic entities in this container in a way that connected entities are stored in the right order and direction.

Non-recoursive. Only affects atomic entities in this container.

Return values:
true all contours were closed
false at least one contour is not closed

Reimplemented in RS_Polyline.

void RS_EntityContainer::renameInserts const RS_String &  oldName,
const RS_String &  newName
[virtual]
 

Renames all inserts with name 'oldName' to 'newName'.

This is called after a block was rename to update the inserts.

virtual RS2::EntityType RS_EntityContainer::rtti  )  const [inline, virtual]
 

Returns:
RS2::EntityContainer

Reimplemented from RS_Entity.

Reimplemented in RS_Block, RS_DimAligned, RS_DimAngular, RS_DimDiametric, RS_DimLinear, RS_DimRadial, RS_FontChar, RS_Graphic, RS_Hatch, RS_Insert, RS_Leader, RS_Polyline, RS_Spline, and RS_Text.

void RS_EntityContainer::selectWindow const RS_Vector v1,
const RS_Vector v2,
bool  select = true,
bool  cross = false
[virtual]
 

Selects all entities within the given area.

Parameters:
select True to select, False to deselect the entities.

virtual void RS_EntityContainer::setAutoUpdateBorders bool  enable  )  [inline, virtual]
 

Enables / disables automatic update of borders on entity removals and additions.

By default this is turned on.

void RS_EntityContainer::stretch const RS_Vector firstCorner,
const RS_Vector secondCorner,
const RS_Vector offset
[virtual]
 

Implementations must stretch the given range of the entity by the given offset.

This default implementation moves the whole entity if it is completely inside the given range.

Reimplemented from RS_Entity.

Reimplemented in RS_DimAligned, RS_DimLinear, RS_Hatch, RS_Leader, RS_Polyline, and RS_Text.

void RS_EntityContainer::undoStateChanged bool  undone  )  [virtual]
 

Called when the undo state changed.

Forwards the event to all sub-entities.

Parameters:
undone true: entity has become invisible. false: entity has become visible.

Reimplemented from RS_Entity.

int RS_EntityContainer::updateDimensions bool  autoText = true,
bool  onlySelected = false
[virtual]
 

Updates all Dimension entities in this container and reposition their labels if autoText is true.

If onlySelected is true, only selected dimensions will be modified, or all if nothing is selected.

Returns:
Number of entities that were updated.


The documentation for this class was generated from the following files:
Generated on Sat Jan 6 13:48:23 2007 for qcadlib by  doxygen 1.4.4