+++ /dev/null
-#ifndef __INSERT_H__
-#define __INSERT_H__
-
-#include "entitycontainer.h"
-#include "block.h"
-#include "drawing.h"
-
-/**
- * Holds the data that defines an insert.
- */
-class InsertData
-{
- public:
- /**
- * Default constructor.
- */
- InsertData() {}
-
- /**
- * @param name The name of the block used as an identifier.
- * @param insertionPoint Insertion point of the block.
- * @param scaleFactor Scale factor in x / y.
- * @param angle Rotation angle.
- * @param cols Number of cols if we insert a whole array.
- * @param rows Number of rows if we insert a whole array.
- * @param spacing Spacing between rows and cols.
- * @param blockSource Source for the block to insert if other than parent.
- * Normally blocks are requested from the entity's parent but the
- * block can also come from another resource. Text uses that
- * to share the blocks (letters) from a font.
- * @param updateMode RS2::Update will update the insert entity instantly
- * RS2::NoUpdate will not update the insert. You can update
- * it later manually using the update() method. This is
- * often the case since you might want to adjust attributes
- * after creating an insert entity.
- */
- InsertData(const QString & name, Vector insertionPoint, Vector scaleFactor,
- double angle, int cols, int rows, Vector spacing, BlockList * blockSource = NULL,
- RS2::UpdateMode updateMode = RS2::Update)
- {
- this->name = name;
- this->insertionPoint = insertionPoint;
- this->scaleFactor = scaleFactor;
- this->angle = angle;
- this->cols = cols;
- this->rows = rows;
- this->spacing = spacing;
- this->blockSource = blockSource;
- this->updateMode = updateMode;
- }
-
- friend class Insert;
-
- friend std::ostream & operator<<(std::ostream & os, const InsertData & d)
- {
- os << "(" << d.name.toLatin1().data() << ")";
- return os;
- }
-
- QString name;
- Vector insertionPoint;
- Vector scaleFactor;
- double angle;
- int cols, rows;
- Vector spacing;
- BlockList * blockSource;
- RS2::UpdateMode updateMode;
-};
-
-/**
- * An insert inserts a block into the drawing at a certain location
- * with certain attributes (angle, scale, ...).
- * Inserts don't really contain other entities internally. They just
- * refer to a block. However, to the outside world they act exactly
- * like EntityContainer.
- *
- * @author Andrew Mustun
- */
-class Insert: public EntityContainer
-{
- public:
- Insert(EntityContainer * parent, const InsertData & d);
- virtual ~Insert();
-
- virtual Entity * clone();
- virtual RS2::EntityType rtti() const;
- InsertData getData() const;
- virtual void reparent(EntityContainer * parent);
-
- Block * getBlockForInsert();
- virtual void update();
-
- QString getName() const;
- void setName(const QString & newName);
- Vector getInsertionPoint() const;
- void setInsertionPoint(const Vector & i);
- Vector getScale() const;
- void setScale(const Vector & s);
- double getAngle() const;
- void setAngle(double a);
- int getCols() const;
- void setCols(int c);
- int getRows() const;
- void setRows(int r);
- Vector getSpacing() const;
- void setSpacing(const Vector & s);
- virtual bool isVisible();
-
- virtual VectorSolutions getRefPoints();
- virtual Vector getNearestRef(const Vector & coord, double * dist = NULL);
-
- virtual void move(Vector offset);
- virtual void rotate(Vector center, double angle);
- virtual void scale(Vector center, Vector factor);
- virtual void mirror(Vector axisPoint1, Vector axisPoint2);
-
- friend std::ostream & operator<<(std::ostream & os, const Insert & i);
-
- protected:
- InsertData data;
- Block * block;
-};
-
-#endif