Ejemplo n.º 1
0
/**
 * Adds an entity to this preview and removes any attributes / layer
 * connectsions before that.
 */
void RS_Preview::addEntity(RS_Entity* entity) {
    if (entity==NULL || entity->isUndone()) {
        return;
    }

    // only border preview for complex entities:
    //if ((entity->count() > maxEntities-count()) &&

    bool addBorder = false;

    if (entity->rtti()==RS2::EntityImage || entity->rtti()==RS2::EntityHatch || 
		entity->rtti()==RS2::EntityInsert) {

        addBorder = true;
    } else {
        if (entity->isContainer() && entity->rtti()!=RS2::EntitySpline) {
            if (entity->countDeep() > maxEntities-countDeep()) {
                addBorder = true;
            }
        }
    }

    if (addBorder) {
        RS_Vector min = entity->getMin();
        RS_Vector max = entity->getMax();

        RS_Line* l1 =
            new RS_Line(this,
                        RS_LineData(RS_Vector(min.x, min.y),
                                    RS_Vector(max.x, min.y)));
        RS_Line* l2 =
            new RS_Line(this,
                        RS_LineData(RS_Vector(max.x, min.y),
                                    RS_Vector(max.x, max.y)));
        RS_Line* l3 =
            new RS_Line(this,
                        RS_LineData(RS_Vector(max.x, max.y),
                                    RS_Vector(min.x, max.y)));
        RS_Line* l4 =
            new RS_Line(this,
                        RS_LineData(RS_Vector(min.x, max.y),
                                    RS_Vector(min.x, min.y)));

        RS_EntityContainer::addEntity(l1);
        RS_EntityContainer::addEntity(l2);
        RS_EntityContainer::addEntity(l3);
        RS_EntityContainer::addEntity(l4);

        delete entity;
        entity = NULL;
    } else {
        entity->setLayer(NULL);
        entity->setSelected(false);
        entity->reparent(this);
        entity->setPen(RS_Pen(RS_Color(255,255,255),
                              RS2::Width00,
                              RS2::SolidLine));
        RS_EntityContainer::addEntity(entity);
    }
}
Ejemplo n.º 2
0
/**
 * Adds an entity to this preview and removes any attributes / layer
 * connectsions before that.
 */
void RS_Preview::addEntity(RS_Entity* entity) {
    if (entity==nullptr || entity->isUndone()) {
        return;
    }

    // only border preview for complex entities:
    //if ((entity->count() > maxEntities-count()) &&

    bool addBorder = false;

    if (entity->rtti()==RS2::EntityImage || entity->rtti()==RS2::EntityHatch ||
                entity->rtti()==RS2::EntityInsert) {

        addBorder = true;
    } else {
        if (entity->isContainer() && entity->rtti()!=RS2::EntitySpline) {
            if (entity->countDeep() > maxEntities-countDeep()) {
                addBorder = true;
            }
        }
    }

    if (addBorder) {
        RS_Vector min = entity->getMin();
        RS_Vector max = entity->getMax();

        RS_Line* l1 =
            new RS_Line(this,
                        RS_LineData(RS_Vector(min.x, min.y),
                                    RS_Vector(max.x, min.y)));
        RS_Line* l2 =
            new RS_Line(this,
                        RS_LineData(RS_Vector(max.x, min.y),
                                    RS_Vector(max.x, max.y)));
        RS_Line* l3 =
            new RS_Line(this,
                        RS_LineData(RS_Vector(max.x, max.y),
                                    RS_Vector(min.x, max.y)));
        RS_Line* l4 =
            new RS_Line(this,
                        RS_LineData(RS_Vector(min.x, max.y),
                                    RS_Vector(min.x, min.y)));

        RS_EntityContainer::addEntity(l1);
        RS_EntityContainer::addEntity(l2);
        RS_EntityContainer::addEntity(l3);
        RS_EntityContainer::addEntity(l4);

        delete entity;
        entity = nullptr;
    } else {
        entity->setLayer(nullptr);
        entity->setSelected(false);
        entity->reparent(this);
                // Don't set this pen, let drawing routines decide entity->setPenToActive();
        RS_EntityContainer::addEntity(entity);
    }
}