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 "!!! RS_PreviewActionInterface::xorPreview() is DEPRECATED !!!"
114 //#warning "!!! xorPreview() not working AT ALL !!!"
116 if (!preview->isEmpty())
118 RS_Painter * painter = graphicView->createDirectPainter();
119 painter->setPreviewMode();
120 painter->setOffset(offset);
121 graphicView->drawEntity(preview, false);
122 graphicView->destroyPainter();
127 // OK, we need a new approach here--direct painting is NOT acceptable anymore!
128 // So, something like this:
130 In graphicView->drawEntity(preview, false); we set the pointer to an entity
131 in the GV. We set a flag telling paintEvent that this is a preview, and then
132 call update() in the view. *That* should do it...
134 //This doesn't work, causes the thing to crash...
135 //Now it works, just need to upgrade the rendering paths so that they aren't all
136 //fucked up like QCad was...
137 if (!preview->isEmpty())
139 graphicView->SetPreviewMode();
140 graphicView->SetPreviewEntity(preview);
141 graphicView->SetPreviewOffset(offset);
142 graphicView->redraw();