/**
* Constructor.
*/
-RS_Hatch::RS_Hatch(RS_EntityContainer * parent, const RS_HatchData & d):
- RS_EntityContainer(parent), data(d)
+Hatch::Hatch(EntityContainer * parent, const HatchData & d):
+ EntityContainer(parent), data(d)
{
hatch = NULL;
updateRunning = false;
needOptimization = true;
}
-/*virtual*/ RS_Hatch::~RS_Hatch()
+/*virtual*/ Hatch::~Hatch()
{
}
-RS_Entity * RS_Hatch::clone()
+Entity * Hatch::clone()
{
- RS_Hatch * t = new RS_Hatch(*this);
+ Hatch * t = new Hatch(*this);
#warning "!!! Need to deal with setAutoDelete() Qt3->Qt4 !!!"
// t->entities.setAutoDelete(entities.autoDelete());
t->initId();
}
/** @return RS2::EntityHatch */
-/*virtual*/ RS2::EntityType RS_Hatch::rtti() const
+/*virtual*/ RS2::EntityType Hatch::rtti() const
{
return RS2::EntityHatch;
}
* @return true: if this is a hatch with lines (hatch pattern),
* false: if this is filled with a solid color.
*/
-/*virtual*/ bool RS_Hatch::isContainer() const
+/*virtual*/ bool Hatch::isContainer() const
{
if (isSolid())
return false;
}
/** @return Copy of data that defines the hatch. */
-RS_HatchData RS_Hatch::getData() const
+HatchData Hatch::getData() const
{
return data;
}
/**
* Validates the hatch.
*/
-bool RS_Hatch::validate()
+bool Hatch::validate()
{
bool ret = true;
// loops:
- for(RS_Entity * l=firstEntity(RS2::ResolveNone); l!=NULL; l=nextEntity(RS2::ResolveNone))
+ for(Entity * l=firstEntity(RS2::ResolveNone); l!=NULL; l=nextEntity(RS2::ResolveNone))
{
if (l->rtti() == RS2::EntityContainer)
{
- RS_EntityContainer * loop = (RS_EntityContainer *)l;
+ EntityContainer * loop = (EntityContainer *)l;
ret = loop->optimizeContours() && ret;
}
}
/**
* @return Number of loops.
*/
-int RS_Hatch::countLoops()
+int Hatch::countLoops()
{
if (data.solid)
return count();
}
/** @return true if this is a solid fill. false if it is a pattern hatch. */
-bool RS_Hatch::isSolid() const
+bool Hatch::isSolid() const
{
return data.solid;
}
-void RS_Hatch::setSolid(bool solid)
+void Hatch::setSolid(bool solid)
{
data.solid = solid;
}
-QString RS_Hatch::getPattern()
+QString Hatch::getPattern()
{
return data.pattern;
}
-void RS_Hatch::setPattern(const QString & pattern)
+void Hatch::setPattern(const QString & pattern)
{
data.pattern = pattern;
}
-double RS_Hatch::getScale()
+double Hatch::getScale()
{
return data.scale;
}
-void RS_Hatch::setScale(double scale)
+void Hatch::setScale(double scale)
{
data.scale = scale;
}
-double RS_Hatch::getAngle()
+double Hatch::getAngle()
{
return data.angle;
}
-void RS_Hatch::setAngle(double angle)
+void Hatch::setAngle(double angle)
{
data.angle = angle;
}
/**
* Recalculates the borders of this hatch.
*/
-void RS_Hatch::calculateBorders()
+void Hatch::calculateBorders()
{
- RS_DEBUG->print("RS_Hatch::calculateBorders");
+ DEBUG->print("Hatch::calculateBorders");
activateContour(true);
- RS_EntityContainer::calculateBorders();
+ EntityContainer::calculateBorders();
- RS_DEBUG->print("RS_Hatch::calculateBorders: size: %f,%f", getSize().x, getSize().y);
+ DEBUG->print("Hatch::calculateBorders: size: %f,%f", getSize().x, getSize().y);
activateContour(false);
}
* Updates the Hatch. Called when the
* hatch or it's data, position, alignment, .. changes.
*/
-void RS_Hatch::update()
+void Hatch::update()
{
- RS_DEBUG->print("RS_Hatch::update");
- RS_DEBUG->print("RS_Hatch::update: contour has %d loops", count());
+ DEBUG->print("Hatch::update");
+ DEBUG->print("Hatch::update: contour has %d loops", count());
if (updateRunning)
return;
if (data.solid == true)
return;
- RS_DEBUG->print("RS_Hatch::update");
+ DEBUG->print("Hatch::update");
updateRunning = true;
// delete old hatch:
if (!validate())
{
- RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Hatch::update: invalid contour in hatch found");
+ DEBUG->print(Debug::D_WARNING, "Hatch::update: invalid contour in hatch found");
updateRunning = false;
return;
}
// search pattern:
- RS_DEBUG->print("RS_Hatch::update: requesting pattern");
- RS_Pattern * pat = RS_PATTERNLIST->requestPattern(data.pattern);
+ DEBUG->print("Hatch::update: requesting pattern");
+ Pattern * pat = PATTERNLIST->requestPattern(data.pattern);
if (pat == NULL)
{
updateRunning = false;
- RS_DEBUG->print("RS_Hatch::update: requesting pattern: not found");
+ DEBUG->print("Hatch::update: requesting pattern: not found");
return;
}
- RS_DEBUG->print("RS_Hatch::update: requesting pattern: OK");
+ DEBUG->print("Hatch::update: requesting pattern: OK");
- RS_DEBUG->print("RS_Hatch::update: cloning pattern");
- pat = (RS_Pattern*)pat->clone();
- RS_DEBUG->print("RS_Hatch::update: cloning pattern: OK");
+ DEBUG->print("Hatch::update: cloning pattern");
+ pat = (Pattern*)pat->clone();
+ DEBUG->print("Hatch::update: cloning pattern: OK");
// scale pattern
- RS_DEBUG->print("RS_Hatch::update: scaling pattern");
+ DEBUG->print("Hatch::update: scaling pattern");
pat->scale(Vector(0.0,0.0), Vector(data.scale, data.scale));
pat->calculateBorders();
forcedCalculateBorders();
- RS_DEBUG->print("RS_Hatch::update: scaling pattern: OK");
+ DEBUG->print("Hatch::update: scaling pattern: OK");
// find out how many pattern-instances we need in x/y:
int px1, py1, px2, py2;
double f;
- RS_Hatch * copy = (RS_Hatch *)this->clone();
+ Hatch * copy = (Hatch *)this->clone();
copy->rotate(Vector(0.0, 0.0), -data.angle);
copy->forcedCalculateBorders();
Vector cPos = getMin();
Vector cSize = getSize();
- RS_DEBUG->print("RS_Hatch::update: pattern size: %f/%f", pSize.x, pSize.y);
- RS_DEBUG->print("RS_Hatch::update: contour size: %f/%f", cSize.x, cSize.y);
+ DEBUG->print("Hatch::update: pattern size: %f/%f", pSize.x, pSize.y);
+ DEBUG->print("Hatch::update: contour size: %f/%f", cSize.x, cSize.y);
if (cSize.x < 1.0e-6 || cSize.y < 1.0e-6 || pSize.x < 1.0e-6 || pSize.y < 1.0e-6
|| cSize.x > RS_MAXDOUBLE - 1 || cSize.y > RS_MAXDOUBLE - 1
delete pat;
delete copy;
updateRunning = false;
- RS_DEBUG->print("RS_Hatch::update: contour size or pattern size too small");
+ DEBUG->print("Hatch::update: contour size or pattern size too small");
return;
}
// avoid huge memory consumption:
else if (cSize.x / pSize.x > 100 || cSize.y / pSize.y > 100)
{
- RS_DEBUG->print("RS_Hatch::update: contour size too large or pattern size too small");
+ DEBUG->print("Hatch::update: contour size too large or pattern size too small");
return;
}
f = copy->getMax().y/pat->getSize().y;
py2 = (int)ceil(f) - 1;
- RS_EntityContainer tmp; // container for untrimmed lines
+ EntityContainer tmp; // container for untrimmed lines
// adding array of patterns to tmp:
- RS_DEBUG->print("RS_Hatch::update: creating pattern carpet");
+ DEBUG->print("Hatch::update: creating pattern carpet");
for(int px=px1; px<=px2; px++)
{
for(int py=py1; py<=py2; py++)
{
- for(RS_Entity * e=pat->firstEntity(); e!=NULL; e=pat->nextEntity())
+ for(Entity * e=pat->firstEntity(); e!=NULL; e=pat->nextEntity())
{
- RS_Entity * te = e->clone();
+ Entity * te = e->clone();
te->rotate(Vector(0.0, 0.0), data.angle);
Vector v1, v2;
v1.setPolar(px * pSize.x, data.angle);
delete pat;
pat = NULL;
- RS_DEBUG->print("RS_Hatch::update: creating pattern carpet: OK");
+ DEBUG->print("Hatch::update: creating pattern carpet: OK");
- RS_DEBUG->print("RS_Hatch::update: cutting pattern carpet");
+ DEBUG->print("Hatch::update: cutting pattern carpet");
// cut pattern to contour shape:
- RS_EntityContainer tmp2; // container for small cut lines
- RS_Line * line = NULL;
- RS_Arc * arc = NULL;
- RS_Circle * circle = NULL;
+ EntityContainer tmp2; // container for small cut lines
+ Line * line = NULL;
+ Arc * arc = NULL;
+ Circle * circle = NULL;
- for(RS_Entity * e=tmp.firstEntity(); e!=NULL; e=tmp.nextEntity())
+ for(Entity * e=tmp.firstEntity(); e!=NULL; e=tmp.nextEntity())
{
Vector startPoint;
Vector endPoint;
if (e->rtti() == RS2::EntityLine)
{
- line = (RS_Line *)e;
+ line = (Line *)e;
arc = NULL;
circle = NULL;
startPoint = line->getStartpoint();
}
else if (e->rtti() == RS2::EntityArc)
{
- arc = (RS_Arc *)e;
+ arc = (Arc *)e;
line = NULL;
circle = NULL;
startPoint = arc->getStartpoint();
}
else if (e->rtti() == RS2::EntityCircle)
{
- circle = (RS_Circle *)e;
+ circle = (Circle *)e;
line = NULL;
arc = NULL;
startPoint = circle->getCenter() + Vector(circle->getRadius(), 0.0);
// is.setAutoDelete(true);
is.append(new Vector(startPoint));
- for(RS_Entity * loop=firstEntity(); loop!=NULL; loop=nextEntity())
+ for(Entity * loop=firstEntity(); loop!=NULL; loop=nextEntity())
{
if (loop->isContainer())
{
- for(RS_Entity * p=((RS_EntityContainer *)loop)->firstEntity(); p!=NULL; p=((RS_EntityContainer*)loop)->nextEntity())
+ for(Entity * p=((EntityContainer *)loop)->firstEntity(); p!=NULL; p=((EntityContainer*)loop)->nextEntity())
{
- VectorSolutions sol = RS_Information::getIntersection(e, p, true);
+ VectorSolutions sol = Information::getIntersection(e, p, true);
for(int i=0; i<=1; ++i)
{
if (sol.get(i).valid)
{
is.append(new Vector(sol.get(i)));
- RS_DEBUG->print(" pattern line intersection: %f/%f", sol.get(i).x, sol.get(i).y);
+ DEBUG->print(" pattern line intersection: %f/%f", sol.get(i).x, sol.get(i).y);
}
}
}
{
if (line != NULL)
{
- tmp2.addEntity(new RS_Line(&tmp2, RS_LineData(*v1, *v2)));
+ tmp2.addEntity(new Line(&tmp2, LineData(*v1, *v2)));
}
else if (arc != NULL || circle != NULL)
{
- tmp2.addEntity(new RS_Arc(&tmp2, RS_ArcData(center, center.distanceTo(*v1),
+ tmp2.addEntity(new Arc(&tmp2, ArcData(center, center.distanceTo(*v1),
center.angleTo(*v1), center.angleTo(*v2), reversed)));
}
}
}
// updating hatch / adding entities that are inside
- RS_DEBUG->print("RS_Hatch::update: cutting pattern carpet: OK");
+ DEBUG->print("Hatch::update: cutting pattern carpet: OK");
// the hatch pattern entities:
- hatch = new RS_EntityContainer(this);
- hatch->setPen(RS_Pen(RS2::FlagInvalid));
+ hatch = new EntityContainer(this);
+ hatch->setPen(Pen(RS2::FlagInvalid));
hatch->setLayer(NULL);
hatch->setFlag(RS2::FlagTemp);
//calculateBorders();
- for(RS_Entity * e=tmp2.firstEntity(); e!=NULL; e=tmp2.nextEntity())
+ for(Entity * e=tmp2.firstEntity(); e!=NULL; e=tmp2.nextEntity())
{
Vector middlePoint;
Vector middlePoint2;
if (e->rtti() == RS2::EntityLine)
{
- RS_Line * line = (RS_Line *)e;
+ Line * line = (Line *)e;
middlePoint = line->getMiddlepoint();
middlePoint2 = line->getNearestDist(line->getLength() / 2.1, line->getStartpoint());
}
else if (e->rtti() == RS2::EntityArc)
{
- RS_Arc * arc = (RS_Arc *)e;
+ Arc * arc = (Arc *)e;
middlePoint = arc->getMiddlepoint();
middlePoint2 = arc->getNearestDist(arc->getLength() / 2.1, arc->getStartpoint());
}
{
bool onContour = false;
- if (RS_Information::isPointInsideContour(middlePoint, this, &onContour)
- || RS_Information::isPointInsideContour(middlePoint2, this))
+ if (Information::isPointInsideContour(middlePoint, this, &onContour)
+ || Information::isPointInsideContour(middlePoint2, this))
{
- RS_Entity * te = e->clone();
- te->setPen(RS_Pen(RS2::FlagInvalid));
+ Entity * te = e->clone();
+ te->setPen(Pen(RS2::FlagInvalid));
te->setLayer(NULL);
te->reparent(hatch);
hatch->addEntity(te);
updateRunning = false;
- RS_DEBUG->print("RS_Hatch::update: OK");
+ DEBUG->print("Hatch::update: OK");
}
/**
* Activates of deactivates the hatch boundary.
*/
-void RS_Hatch::activateContour(bool on)
+void Hatch::activateContour(bool on)
{
- RS_DEBUG->print("RS_Hatch::activateContour: %d", (int)on);
+ DEBUG->print("Hatch::activateContour: %d", (int)on);
- for(RS_Entity * e=firstEntity(); e!=NULL; e=nextEntity())
+ for(Entity * e=firstEntity(); e!=NULL; e=nextEntity())
{
if (!e->isUndone())
{
if (!e->getFlag(RS2::FlagTemp))
{
- RS_DEBUG->print("RS_Hatch::activateContour: set visible");
+ DEBUG->print("Hatch::activateContour: set visible");
e->setVisible(on);
}
else
{
- RS_DEBUG->print("RS_Hatch::activateContour: entity temp");
+ DEBUG->print("Hatch::activateContour: entity temp");
}
}
else
{
- RS_DEBUG->print("RS_Hatch::activateContour: entity undone");
+ DEBUG->print("Hatch::activateContour: entity undone");
}
}
- RS_DEBUG->print("RS_Hatch::activateContour: OK");
+ DEBUG->print("Hatch::activateContour: OK");
}
/**
* Overrides drawing of subentities. This is only ever called for solid fills.
*/
-void RS_Hatch::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
+void Hatch::draw(PaintInterface * painter, GraphicView * view, double /*patternOffset*/)
{
if (!data.solid)
{
- for(RS_Entity * se=firstEntity(); se!=NULL; se = nextEntity())
+ for(Entity * se=firstEntity(); se!=NULL; se = nextEntity())
view->drawEntity(se);
return;
// loops:
if (needOptimization == true)
{
- for(RS_Entity * l=firstEntity(RS2::ResolveNone); l!=NULL; l=nextEntity(RS2::ResolveNone))
+ for(Entity * l=firstEntity(RS2::ResolveNone); l!=NULL; l=nextEntity(RS2::ResolveNone))
{
if (l->rtti() == RS2::EntityContainer)
{
- RS_EntityContainer * loop = (RS_EntityContainer *)l;
+ EntityContainer * loop = (EntityContainer *)l;
loop->optimizeContours();
}
}
}
// loops:
- for(RS_Entity * l=firstEntity(RS2::ResolveNone); l!=NULL; l=nextEntity(RS2::ResolveNone))
+ for(Entity * l=firstEntity(RS2::ResolveNone); l!=NULL; l=nextEntity(RS2::ResolveNone))
{
l->setLayer(getLayer());
if (l->rtti() == RS2::EntityContainer)
{
- RS_EntityContainer * loop = (RS_EntityContainer *)l;
+ EntityContainer * loop = (EntityContainer *)l;
// edges:
- for(RS_Entity * e=loop->firstEntity(RS2::ResolveNone); e!=NULL; e=loop->nextEntity(RS2::ResolveNone))
+ for(Entity * e=loop->firstEntity(RS2::ResolveNone); e!=NULL; e=loop->nextEntity(RS2::ResolveNone))
{
e->setLayer(getLayer());
{
case RS2::EntityLine:
{
- RS_Line * line = (RS_Line *)e;
+ Line * line = (Line *)e;
- int x1 = RS_Math::round(view->toGuiX(line->getStartpoint().x));
- int y1 = RS_Math::round(view->toGuiY(line->getStartpoint().y));
- int x2 = RS_Math::round(view->toGuiX(line->getEndpoint().x));
- int y2 = RS_Math::round(view->toGuiY(line->getEndpoint().y));
+ int x1 = Math::round(view->toGuiX(line->getStartpoint().x));
+ int y1 = Math::round(view->toGuiY(line->getStartpoint().y));
+ int x2 = Math::round(view->toGuiX(line->getEndpoint().x));
+ int y2 = Math::round(view->toGuiY(line->getEndpoint().y));
if (lastValid && (lastX != x1 || lastY != y1))
{
case RS2::EntityArc:
{
- RS_Arc * arc = (RS_Arc *)e;
+ Arc * arc = (Arc *)e;
- int x1 = RS_Math::round(view->toGuiX(arc->getStartpoint().x));
- int y1 = RS_Math::round(view->toGuiY(arc->getStartpoint().y));
- int x2 = RS_Math::round(view->toGuiX(arc->getEndpoint().x));
- int y2 = RS_Math::round(view->toGuiY(arc->getEndpoint().y));
+ int x1 = Math::round(view->toGuiX(arc->getStartpoint().x));
+ int y1 = Math::round(view->toGuiY(arc->getStartpoint().y));
+ int x2 = Math::round(view->toGuiX(arc->getEndpoint().x));
+ int y2 = Math::round(view->toGuiY(arc->getEndpoint().y));
if (lastValid && (lastX != x1 || lastY != y1))
{
case RS2::EntityCircle:
{
- RS_Circle * circle = (RS_Circle *)e;
+ Circle * circle = (Circle *)e;
- int x1 = RS_Math::round(view->toGuiX(circle->getCenter().x + circle->getRadius()));
- int y1 = RS_Math::round(view->toGuiY(circle->getCenter().y));
+ int x1 = Math::round(view->toGuiX(circle->getCenter().x + circle->getRadius()));
+ int y1 = Math::round(view->toGuiY(circle->getCenter().y));
int x2 = x1;
int y2 = y1;
painter->drawPolygon(pa);
}
-/*virtual*/ double RS_Hatch::getLength()
+/*virtual*/ double Hatch::getLength()
{
return -1.0;
}
-double RS_Hatch::getDistanceToPoint(const Vector & coord, RS_Entity ** entity,
+double Hatch::getDistanceToPoint(const Vector & coord, Entity ** entity,
RS2::ResolveLevel level, double solidDist)
{
if (data.solid == true)
bool onContour;
- if (RS_Information::isPointInsideContour(coord, this, &onContour))
+ if (Information::isPointInsideContour(coord, this, &onContour))
// distance is the snap range:
return solidDist;
}
else
{
- return RS_EntityContainer::getDistanceToPoint(coord, entity, level, solidDist);
+ return EntityContainer::getDistanceToPoint(coord, entity, level, solidDist);
}
}
-void RS_Hatch::move(Vector offset)
+void Hatch::move(Vector offset)
{
- RS_EntityContainer::move(offset);
+ EntityContainer::move(offset);
update();
}
-void RS_Hatch::rotate(Vector center, double angle)
+void Hatch::rotate(Vector center, double angle)
{
- RS_EntityContainer::rotate(center, angle);
- data.angle = RS_Math::correctAngle(data.angle + angle);
+ EntityContainer::rotate(center, angle);
+ data.angle = Math::correctAngle(data.angle + angle);
update();
}
-void RS_Hatch::scale(Vector center, Vector factor)
+void Hatch::scale(Vector center, Vector factor)
{
- RS_EntityContainer::scale(center, factor);
+ EntityContainer::scale(center, factor);
data.scale *= factor.x;
update();
}
-void RS_Hatch::mirror(Vector axisPoint1, Vector axisPoint2)
+void Hatch::mirror(Vector axisPoint1, Vector axisPoint2)
{
- RS_EntityContainer::mirror(axisPoint1, axisPoint2);
+ EntityContainer::mirror(axisPoint1, axisPoint2);
double ang = axisPoint1.angleTo(axisPoint2);
- data.angle = RS_Math::correctAngle(data.angle + ang*2.0);
+ data.angle = Math::correctAngle(data.angle + ang*2.0);
update();
}
-void RS_Hatch::stretch(Vector firstCorner, Vector secondCorner, Vector offset)
+void Hatch::stretch(Vector firstCorner, Vector secondCorner, Vector offset)
{
- RS_EntityContainer::stretch(firstCorner, secondCorner, offset);
+ EntityContainer::stretch(firstCorner, secondCorner, offset);
update();
}
/**
* Dumps the point's data to stdout.
*/
-std::ostream & operator<<(std::ostream & os, const RS_Hatch & p)
+std::ostream & operator<<(std::ostream & os, const Hatch & p)
{
os << " Hatch: " << p.getData() << "\n";
return os;