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 "rs_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, RS_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
34 // document 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);
54 void RS_PreviewActionInterface::finish()
56 RS_ActionInterface::finish();
61 void RS_PreviewActionInterface::suspend()
63 RS_ActionInterface::suspend();
68 void RS_PreviewActionInterface::resume()
70 RS_ActionInterface::resume();
74 void RS_PreviewActionInterface::trigger()
76 RS_ActionInterface::trigger();
82 * Clears the preview by removing all entities in it.
84 void RS_PreviewActionInterface::clearPreview()
90 * Draws the preview on the screen.
92 void RS_PreviewActionInterface::drawPreview()
99 * Deletes the preview from the screen.
101 void RS_PreviewActionInterface::deletePreview()
107 //#include "qg_graphicview.h"
109 * Draws / deletes the current preview.
111 void RS_PreviewActionInterface::xorPreview()
113 #warning "!!! xorPreview() not working AT ALL !!!"
115 if (!preview->isEmpty())
117 RS_Painter * painter = graphicView->createDirectPainter();
118 painter->setPreviewMode();
119 painter->setOffset(offset);
120 graphicView->drawEntity(preview, false);
121 graphicView->destroyPainter();
126 // OK, we need a new approach here--direct painting is NOT acceptable anymore!
127 // So, something like this:
129 In graphicView->drawEntity(preview, false); we set the pointer to an entity
130 in the GV. We set a flag telling paintEvent that this is a preview, and then
131 call update() in the view. *That* should do it...
133 //This doesn't work, causes the thing to crash...
134 //Now it works, just need to upgrade the rendering paths so that they aren't all
135 //fucked up like QCad was...
137 if (!preview->isEmpty())
139 graphicView->SetPreviewMode();
140 graphicView->SetPreviewEntity(preview);
141 graphicView->SetPreviewOffset(offset);
142 graphicView->redraw();