]> Shamusworld >> Repos - architektonas/blobdiff - src/base/rs_preview.cpp
Fixed preview rendering for ActionDrawLine...
[architektonas] / src / base / rs_preview.cpp
index 6bbbb661978588081b1cf4a2e7ac5d7bb45d1e32..1de0166b68947bdec3f5587888f86787e3e002c6 100644 (file)
 #include "rs_entitycontainer.h"
 #include "graphicview.h"
 #include "rs_information.h"
+#include "paintintf.h"
 #include "settings.h"
 
 /**
  * Constructor.
  */
-RS_Preview::RS_Preview(RS_EntityContainer * parent): RS_EntityContainer(parent)
+RS_Preview::RS_Preview(RS_EntityContainer * parent): RS_EntityContainer(parent),
+       visible(false)
 {
        settings.beginGroup("Appearance");
        maxEntities = settings.value("MaxPreview", 100).toInt();
@@ -93,11 +95,11 @@ void RS_Preview::addEntity(RS_Entity * entity)
 }
 
 /**
-* Clones the given entity and adds the clone to the preview.
-*/
-void RS_Preview::addCloneOf(RS_Entity* entity)
+ * Clones the given entity and adds the clone to the preview.
+ */
+void RS_Preview::addCloneOf(RS_Entity * entity)
 {
-       if (entity == NULL)
+       if (!entity)
                return;
 
        RS_Entity * clone = entity->clone();
@@ -105,8 +107,8 @@ void RS_Preview::addCloneOf(RS_Entity* entity)
 }
 
 /**
-* Adds all entities from 'container' to the preview (unselected).
-*/
+ * Adds all entities from 'container' to the preview (unselected).
+ */
 void RS_Preview::addAllFrom(RS_EntityContainer & container)
 {
        int c = 0;
@@ -127,8 +129,8 @@ void RS_Preview::addAllFrom(RS_EntityContainer & container)
 }
 
 /**
-* Adds all selected entities from 'container' to the preview (unselected).
-*/
+ * Adds all selected entities from 'container' to the preview (unselected).
+ */
 void RS_Preview::addSelectionFrom(RS_EntityContainer & container)
 {
        int c = 0;
@@ -149,9 +151,9 @@ void RS_Preview::addSelectionFrom(RS_EntityContainer & container)
 }
 
 /**
-* Adds all entities in the given range and those which have endpoints
-* in the given range to the preview.
-*/
+ * Adds all entities in the given range and those which have endpoints in the
+ * given range to the preview.
+ */
 void RS_Preview::addStretchablesFrom(RS_EntityContainer & container, const Vector & v1,
        const Vector & v2)
 {
@@ -172,3 +174,34 @@ void RS_Preview::addStretchablesFrom(RS_EntityContainer & container, const Vecto
                }
        }
 }
+
+void RS_Preview::SetOffset(Vector v)
+{
+       offset = v;
+}
+
+Vector RS_Preview::Offset(void)
+{
+       return offset;
+}
+
+void RS_Preview::SetVisible(bool visibility/*= true*/)
+{
+       visible = visibility;
+}
+
+bool RS_Preview::Visible(void)
+{
+       return visible;
+}
+
+void RS_Preview::Draw(GraphicView * view, PaintInterface * painter)
+{
+       if (isEmpty())
+               return;
+
+//     painter->setPreviewMode();
+       painter->setOffset(offset);
+       view->drawEntity(this, false);
+       painter->setOffset(Vector(0, 0));
+}