If we can make the UI more like Inkscape we'll be in good shape. Plus elements
of VectorWorks & etc. as well...
-
--------------------------------------------------------------------------------
-
-What's needed:
-
-- Draw the entities
-- Draw the preview (if any)
-- Draw the snapper (if any)
-
*/
// Qt4 handles double buffering of screen writes now, so this needs
// a rewrite.
#warning "!!! Need to pass a valid QPainter to drawIt() !!!"
-#if 0
- drawIt();
-
-//#warning "!!! Double buffering is out... !!!"
-// Seems most rendering is going through this path... Hrm.
- if (buffer != NULL)
- {
- QPainter wPainter;
- wPainter.begin(this);
- wPainter.drawPixmap(0, 0, *buffer);
- wPainter.end();
- }
-#else
-// refCount++;
-//if (refCount > 1)
-//{
-//// RS_DEBUG->print(RS_Debug::D_CRITICAL, "paintEvent seems to be called recursively: refCount=%u", refCount);
-// printf("paintEvent seems to be called recursively: refCount=%u\n", refCount);
-//}
QPainter pntr(this);
pntr.setBackgroundMode(Qt::OpaqueMode);
-// pntr.setBackgroundColor(background);
pntr.setBackground(QBrush(background));
painter = new PaintInterface(&pntr);
-#if 0
- if (!painter)
- {
- painter = new RS_PainterQt(this);
-
- //Nope, this didn't fix the problem...
- //The problem is, unless we specifically tell Qt NOT to
- //clear the window every time, it will...
- //So...
-// if (!previewMode)
- {
- painter->setDrawingMode(drawingMode);
- ((RS_PainterQt *)painter)->setBackgroundMode(Qt::OpaqueMode);
- ((RS_PainterQt *)painter)->setBackgroundColor(background);
-// ((RS_PainterQt *)painter)->eraseRect(0, 0, getWidth(), getHeight());
- }
- }
- else
- {
- printf("QG_GraphicView::paintEvent: painter is NOT NULL!\n");
- }
-#endif
-
//Note that we do drawIt() regardless here because paintEvent() clears the background
//*unless* we create the window with a specific style. Depending on our draw code, we
//just may go that way...
drawIt();
-//Need some logic here to do drawing in preview mode, since it'll be calling
-//update now instead of trying to do a direct draw...
-#if 0
- if (previewMode)
- {
-//hrm. painter->setCompositionMode(QPainter::CompositionMode_Xor);
-//needed anymore? painter->setXORMode();
- painter->setOffset(previewOffset);
- drawEntity(previewEntity);//meh -> , 1.0, false);
- painter->setOffset(Vector(0, 0));
- // We'll set previewMode to false here, just because we can
- previewMode = false;
- }
-#else
+
+ // Draw the snapper first, we want to be able to see the preview on top of
+ // this...
+ if (snapper.Visible())
+ snapper.Draw(this, painter);
+
if (preview.Visible())
{
- RS_Pen oldPen = painter->getPen();
- //ick. doesn't work...
-// pntr.setCompositionMode(QPainter::CompositionMode_Xor);
- // One of these has GOT to work... (but NEITHER do...!)
- // It's because this is the pen for the container, not the entities INSIDE...
- // How do we fix that??? [by drawing the container ourselves, that's how. :-/]
painter->setPen(RS_Pen(RS_Color(60, 255, 80), RS2::Width00, RS2::SolidLine));
-// preview.setPen(RS_Pen(RS_Color(60, 255, 60), RS2::Width00, RS2::SolidLine));
painter->setOffset(preview.Offset());
-//This is green, but in the upper left hand corner...
-//painter->drawLine(Vector(15, 15), Vector(15, -15));
-//painter->drawLine(Vector(15, -15), Vector(-15, -15));
-//painter->drawLine(Vector(-15, -15), Vector(-15, 15));
-//painter->drawLine(Vector(-15, 15), Vector(15, 15));
-// drawEntityPlain(&preview);
+
+ // We have to traverse the container ourselves, because RS_Container::draw()
+ // uses drawEntity() instead of drawEntityPlain()...
for(RS_Entity * e=preview.firstEntity(RS2::ResolveNone); e!=NULL;
e = preview.nextEntity(RS2::ResolveNone))
{
-// e->setPen(RS_Pen(RS_Color(60, 255, 80), RS2::Width00, RS2::SolidLine));
drawEntityPlain(e);
}
- //ick
-// pntr.setCompositionMode(QPainter::CompositionMode_Source);
+
painter->setOffset(Vector(0, 0));
- painter->setPen(oldPen);
}
-#endif
-
- if (snapper.Visible())
- snapper.Draw(this, painter);
delete painter;
painter = NULL;
-// refCount--;
-#endif
-
RS_DEBUG->print("QG_GraphicView::paintEvent end");
}
-
-#if 0 //JLH
-/**
- * Previews the given url for the file open dialog.
- */
-void QG_GraphicView::previewUrl(const Q3Url & u)
-{
- //static Drawing* gr = new Drawing();
-
- RS_DEBUG->print("QG_GraphicView::previewUrl");
-
- if (container != NULL && container->rtti() == RS2::EntityGraphic)
- {
- ((Drawing *)container)->open(u.path(), RS2::FormatUnknown);
- zoomAuto();
- }
- //setContainer(gr);
-
- RS_DEBUG->print("QG_GraphicView::previewUrl: OK");
-}
-#endif