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"
20 * Sets the entity container on which the action class inherited
21 * from this interface operates.
23 RS_PreviewActionInterface::RS_PreviewActionInterface(const char * name,
24 RS_EntityContainer & container, RS_GraphicView & graphicView):
25 RS_ActionInterface(name, container, graphicView)
27 RS_DEBUG->print("RS_PreviewActionInterface::RS_PreviewActionInterface: Setting up action with preview: \"%s\"", name);
29 // preview is linked to the container for getting access to
30 // document settings / dictionary variables
31 preview = new RS_Preview(&container);
34 RS_DEBUG->print("RS_PreviewActionInterface::RS_PreviewActionInterface: Setting up action with preview: \"%s\": OK", name);
38 RS_PreviewActionInterface::~RS_PreviewActionInterface()
43 void RS_PreviewActionInterface::init(int status)
45 RS_ActionInterface::init(status);
50 void RS_PreviewActionInterface::finish()
52 RS_ActionInterface::finish();
57 void RS_PreviewActionInterface::suspend()
59 RS_ActionInterface::suspend();
64 void RS_PreviewActionInterface::resume()
66 RS_ActionInterface::resume();
70 void RS_PreviewActionInterface::trigger()
72 RS_ActionInterface::trigger();
78 * Clears the preview by removing all entities in it.
80 void RS_PreviewActionInterface::clearPreview()
86 * Draws the preview on the screen.
88 void RS_PreviewActionInterface::drawPreview()
95 * Deletes the preview from the screen.
97 void RS_PreviewActionInterface::deletePreview()
103 //#include "qg_graphicview.h"
105 * Draws / deletes the current preview.
107 void RS_PreviewActionInterface::xorPreview()
109 #warning "!!! xorPreview() not working AT ALL !!!"
111 if (!preview->isEmpty())
113 RS_Painter * painter = graphicView->createDirectPainter();
114 painter->setPreviewMode();
115 painter->setOffset(offset);
116 graphicView->drawEntity(preview, false);
117 graphicView->destroyPainter();
122 // OK, we need a new approach here--direct painting is NOT acceptable anymore!
123 // So, something like this:
125 In graphicView->drawEntity(preview, false); we set the pointer to an entity
126 in the GV. We set a flag telling paintEvent that this is a preview, and then
127 call update() in the view. *That* should do it...
129 //This doesn't work, causes the thing to crash...
130 //Now it works, just need to upgrade the rendering paths so that they aren't all
131 //fucked up like QCad was...
133 if (!preview->isEmpty())
135 graphicView->SetPreviewMode();
136 graphicView->SetPreviewEntity(preview);
137 graphicView->SetPreviewOffset(offset);
138 graphicView->redraw();