]> Shamusworld >> Repos - architektonas/blobdiff - src/base/preview.cpp
Major refactor of Architektonas: Jettisoning old cruft.
[architektonas] / src / base / preview.cpp
diff --git a/src/base/preview.cpp b/src/base/preview.cpp
deleted file mode 100644 (file)
index c108600..0000000
+++ /dev/null
@@ -1,209 +0,0 @@
-// preview.cpp
-//
-// Part of the Architektonas Project
-// Originally part of QCad Community Edition by Andrew Mustun
-// Extensively rewritten and refactored by James L. Hammons
-// Portions copyright (C) 2001-2003 RibbonSoft
-// Copyright (C) 2010 Underground Software
-// See the README and GPLv2 files for licensing and warranty information
-//
-// JLH = James L. Hammons <jlhamm@acm.org>
-//
-// Who  When        What
-// ---  ----------  -----------------------------------------------------------
-// JLH  05/21/2010  Added this text. :-)
-//
-
-#include "preview.h"
-
-#include "entitycontainer.h"
-#include "graphicview.h"
-#include "information.h"
-#include "paintinterface.h"
-#include "settings.h"
-
-/**
- * Constructor.
- */
-Preview::Preview(EntityContainer * parent): EntityContainer(parent),
-       visible(false)
-{
-       settings.beginGroup("Appearance");
-       maxEntities = settings.value("MaxPreview", 100).toInt();
-       settings.endGroup();
-}
-
-/**
- * Destructor.
- */
-Preview::~Preview()
-{
-}
-
-/**
- * Adds an entity to this preview and removes any attributes / layer
- * connectsions before that.
- */
-void Preview::addEntity(Entity * entity)
-{
-       if (entity == NULL || entity->isUndone())
-               return;
-
-       // Only border preview for complex entities:
-       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)
-       {
-               Vector min = entity->getMin();
-               Vector max = entity->getMax();
-
-               Line * l1 = new Line(this, LineData(Vector(min.x, min.y), Vector(max.x, min.y)));
-               Line * l2 = new Line(this, LineData(Vector(max.x, min.y), Vector(max.x, max.y)));
-               Line * l3 = new Line(this, LineData(Vector(max.x, max.y), Vector(min.x, max.y)));
-               Line * l4 = new Line(this, LineData(Vector(min.x, max.y), Vector(min.x, min.y)));
-
-               EntityContainer::addEntity(l1);
-               EntityContainer::addEntity(l2);
-               EntityContainer::addEntity(l3);
-               EntityContainer::addEntity(l4);
-
-               delete entity;
-               entity = NULL;
-       }
-       else
-       {
-               entity->setLayer(NULL);
-               entity->setSelected(false);
-               entity->reparent(this);
-               entity->setPen(Pen(Color(255, 255, 255), RS2::Width00, RS2::SolidLine));
-               EntityContainer::addEntity(entity);
-       }
-}
-
-/**
- * Clones the given entity and adds the clone to the preview.
- */
-void Preview::addCloneOf(Entity * entity)
-{
-       if (!entity)
-               return;
-
-       Entity * clone = entity->clone();
-       addEntity(clone);
-}
-
-/**
- * Adds all entities from 'container' to the preview (unselected).
- */
-void Preview::addAllFrom(EntityContainer & container)
-{
-       int c = 0;
-
-       for(Entity * e=container.firstEntity(); e!=NULL; e=container.nextEntity())
-       {
-               if (c < maxEntities)
-               {
-                       Entity * clone = e->clone();
-                       clone->setSelected(false);
-                       clone->reparent(this);
-
-                       c += clone->countDeep();
-                       addEntity(clone);
-                       // clone might be NULL after this point
-               }
-       }
-}
-
-/**
- * Adds all selected entities from 'container' to the preview (unselected).
- */
-void Preview::addSelectionFrom(EntityContainer & container)
-{
-       int c = 0;
-
-       for(Entity * e=container.firstEntity(); e!=NULL; e=container.nextEntity())
-       {
-               if (e->isSelected() && c < maxEntities)
-               {
-                       Entity * clone = e->clone();
-                       clone->setSelected(false);
-                       clone->reparent(this);
-
-                       c += clone->countDeep();
-                       addEntity(clone);
-                       // clone might be NULL after this point
-               }
-       }
-}
-
-/**
- * Adds all entities in the given range and those which have endpoints in the
- * given range to the preview.
- */
-void Preview::addStretchablesFrom(EntityContainer & container, const Vector & v1,
-       const Vector & v2)
-{
-       int c = 0;
-
-       for(Entity * e=container.firstEntity(); e!=NULL; e=container.nextEntity())
-       {
-               if (e->isVisible() && e->rtti() != RS2::EntityHatch && (e->isInWindow(v1, v2)
-                       || e->hasEndpointsWithinWindow(v1, v2)) && c < maxEntities)
-               {
-                       Entity * clone = e->clone();
-                       //clone->setSelected(false);
-                       clone->reparent(this);
-
-                       c += clone->countDeep();
-                       addEntity(clone);
-                       // clone might be NULL after this point
-               }
-       }
-}
-
-void Preview::SetOffset(Vector v)
-{
-       offset = v;
-}
-
-Vector Preview::Offset(void)
-{
-       return offset;
-}
-
-void Preview::SetVisible(bool visibility/*= true*/)
-{
-       visible = visibility;
-}
-
-bool Preview::Visible(void)
-{
-       return visible;
-}
-
-void Preview::Draw(GraphicView * view, PaintInterface * painter)
-{
-       if (isEmpty())
-               return;
-
-       painter->setPen(Pen(Color(60, 255, 80), RS2::Width00, RS2::SolidLine));
-       painter->setOffset(offset);
-
-       // We have to traverse the container ourselves, because RS_Container::draw()
-       // uses drawEntity() instead of drawEntityPlain()...
-       for(Entity * e=firstEntity(RS2::ResolveNone); e!=NULL; e=nextEntity(RS2::ResolveNone))
-               view->drawEntityPlain(e);
-
-       painter->setOffset(Vector(0, 0));
-}