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
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()
108 * Draws / deletes the current preview.
110 void RS_PreviewActionInterface::xorPreview()
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...
136 if (!preview->isEmpty())
138 graphicView->SetPreviewMode();
139 graphicView->SetPreviewEntity(preview);
140 graphicView->SetPreviewOffset(offset);
141 graphicView->redraw();