1 // rs_previewactioninterface.cpp
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 06/02/2010 Added this text. :-)
15 #include "rs_previewactioninterface.h"
18 #include "graphicview.h"
19 #include "rs_preview.h"
24 * Sets the entity container on which the action class inherited
25 * from this interface operates.
27 RS_PreviewActionInterface::RS_PreviewActionInterface(const char * name,
28 RS_EntityContainer & container, GraphicView & graphicView):
29 RS_ActionInterface(name, container, graphicView)
31 RS_DEBUG->print("RS_PreviewActionInterface::RS_PreviewActionInterface: Setting up action with preview: \"%s\"", name);
33 // Preview is linked to the container for getting access to document
34 // settings / dictionary variables
35 preview = new RS_Preview(&container);
38 RS_DEBUG->print("RS_PreviewActionInterface::RS_PreviewActionInterface: Setting up action with preview: \"%s\": OK", name);
42 RS_PreviewActionInterface::~RS_PreviewActionInterface()
47 void RS_PreviewActionInterface::init(int status)
49 RS_ActionInterface::init(status);
53 void RS_PreviewActionInterface::finish()
55 RS_ActionInterface::finish();
60 void RS_PreviewActionInterface::suspend()
62 RS_ActionInterface::suspend();
66 void RS_PreviewActionInterface::resume()
68 RS_ActionInterface::resume();
72 void RS_PreviewActionInterface::trigger()
74 RS_ActionInterface::trigger();
80 * Clears the preview by removing all entities in it.
82 void RS_PreviewActionInterface::clearPreview()
88 * Draws the preview on the screen.
90 void RS_PreviewActionInterface::drawPreview()
97 * Deletes the preview from the screen.
99 void RS_PreviewActionInterface::deletePreview()
106 * Draws / deletes the current preview.
108 void RS_PreviewActionInterface::xorPreview()
110 #warning "!!! RS_PreviewActionInterface::xorPreview() is DEPRECATED !!!"
112 //#warning "!!! xorPreview() not working AT ALL !!!"
114 if (!preview->isEmpty())
116 RS_Painter * painter = graphicView->createDirectPainter();
117 painter->setPreviewMode();
118 painter->setOffset(offset);
119 graphicView->drawEntity(preview, false);
120 graphicView->destroyPainter();
125 // OK, we need a new approach here--direct painting is NOT acceptable anymore!
126 // So, something like this:
128 In graphicView->drawEntity(preview, false); we set the pointer to an entity
129 in the GV. We set a flag telling paintEvent that this is a preview, and then
130 call update() in the view. *That* should do it...
132 //This doesn't work, causes the thing to crash...
133 //Now it works, just need to upgrade the rendering paths so that they aren't all
134 //fucked up like QCad was...
135 if (!preview->isEmpty())
137 graphicView->SetPreviewMode();
138 graphicView->SetPreviewEntity(preview);
139 graphicView->SetPreviewOffset(offset);
140 graphicView->redraw();