From: Shamus Hammons Date: Wed, 16 Jun 2010 04:30:19 +0000 (+0000) Subject: Scrubbed all references to CreatePainter(), CreateDirectPainter() and X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=47beade308343557117edbae58009bf0e02833ef;p=architektonas Scrubbed all references to CreatePainter(), CreateDirectPainter() and DestroyPainter(). Still need to clean up rendering path...--This line, and those below, will be ignored-- M src/actions/rs_actionzoompan.cpp M src/mainapp/qc_graphicview.cpp M src/widgets/qg_graphicview.cpp M src/widgets/qg_graphicview.h M src/base/rs_graphicview.h M src/base/rs_graphicview.cpp --- diff --git a/src/actions/rs_actionzoompan.cpp b/src/actions/rs_actionzoompan.cpp index 7e788de..ac46efb 100644 --- a/src/actions/rs_actionzoompan.cpp +++ b/src/actions/rs_actionzoompan.cpp @@ -30,17 +30,11 @@ void RS_ActionZoomPan::init(int status) RS_ActionInterface::init(status); snapMode = RS2::SnapFree; snapRes = RS2::RestrictNothing; - //v1 = v2 = Vector(false); x1 = y1 = x2 = y2 = -1; - //graphicView->saveView(); } void RS_ActionZoomPan::trigger() { - /*if (v1.valid && v2.valid) { - graphicView->zoomPan(v2-v1); - v1 = v2; - }*/ if (x1 >= 0) { graphicView->zoomPan(x2 - x1, y2 - y1); @@ -51,21 +45,18 @@ void RS_ActionZoomPan::trigger() void RS_ActionZoomPan::mouseMoveEvent(QMouseEvent * e) { - //v2 = snapPoint(e); x2 = e->x(); y2 = e->y(); - //if (getStatus()==1 && graphicView->toGuiDX((v2-v1).magnitude())>10) { +//This is where we see if the delta was big enough to warrant a redraw... if (getStatus() == 1 && (abs(x2 - x1) > 7 || abs(y2 - y1) > 7)) trigger(); } void RS_ActionZoomPan::mousePressEvent(QMouseEvent * e) { - if (e->button() == Qt::MidButton - || e->button() == Qt::LeftButton) + if (e->button() == Qt::MidButton || e->button() == Qt::LeftButton) { - //v1 = snapPoint(e); x1 = e->x(); y1 = e->y(); setStatus(1); @@ -90,5 +81,3 @@ void RS_ActionZoomPan::updateMouseCursor() graphicView->setMouseCursor(RS2::SizeAllCursor); #endif } - -// EOF diff --git a/src/base/rs_graphicview.cpp b/src/base/rs_graphicview.cpp index 73500e2..a2dcb73 100644 --- a/src/base/rs_graphicview.cpp +++ b/src/base/rs_graphicview.cpp @@ -70,15 +70,6 @@ RS_GraphicView::RS_GraphicView(): background(), foreground(), previewMode(false) defaultSnapMode = RS2::SnapFree; defaultSnapRes = RS2::RestrictNothing; - /* - background = RS_Color(0,0,0); - foreground = RS_Color(255,255,255); - gridColor = RS_Color("gray"); - metaGridColor = RS_Color("#404040"); - selectedColor = RS_Color("#a54747"); - highlightedColor = RS_Color("#739373"); - */ - settings.beginGroup("Appearance"); setBackground(QColor(settings.value("BackgroundColor", "#000000").toString())); setGridColor(QColor(settings.value("GridColor", "#7F7F7F").toString())); @@ -511,7 +502,7 @@ void RS_GraphicView::setCurrentAction(RS_ActionInterface * action) */ void RS_GraphicView::killSelectActions() { - if (eventHandler != NULL) + if (eventHandler) eventHandler->killSelectActions(); } @@ -520,7 +511,7 @@ void RS_GraphicView::killSelectActions() */ void RS_GraphicView::killAllActions() { - if (eventHandler != NULL) + if (eventHandler) eventHandler->killAllActions(); } @@ -529,11 +520,10 @@ void RS_GraphicView::killAllActions() */ void RS_GraphicView::back() { - if (eventHandler != NULL && eventHandler->hasAction()) + if (eventHandler && eventHandler->hasAction()) eventHandler->back(); - else - if (RS_DIALOGFACTORY != NULL) - RS_DIALOGFACTORY->requestPreviousMenu(); + else if (RS_DIALOGFACTORY) + RS_DIALOGFACTORY->requestPreviousMenu(); } /** @@ -541,7 +531,7 @@ void RS_GraphicView::back() */ void RS_GraphicView::enter() { - if (eventHandler != NULL && eventHandler->hasAction()) + if (eventHandler && eventHandler->hasAction()) eventHandler->enter(); } @@ -551,7 +541,7 @@ void RS_GraphicView::enter() */ void RS_GraphicView::mousePressEvent(QMouseEvent * e) { - if (eventHandler != NULL) + if (eventHandler) eventHandler->mousePressEvent(e); } @@ -563,18 +553,18 @@ void RS_GraphicView::mouseReleaseEvent(QMouseEvent * e) { RS_DEBUG->print("RS_GraphicView::mouseReleaseEvent"); - if (eventHandler != NULL) + if (!eventHandler) + return; + + if (e->button() != Qt::RightButton || eventHandler->hasAction()) { - if (e->button() != Qt::RightButton || eventHandler->hasAction()) - { - eventHandler->mouseReleaseEvent(e); - //e->accept(); - } - else - { - back(); - e->accept(); - } + eventHandler->mouseReleaseEvent(e); + //e->accept(); + } + else + { + back(); + e->accept(); } RS_DEBUG->print("RS_GraphicView::mouseReleaseEvent: OK"); @@ -595,7 +585,7 @@ void RS_GraphicView::mouseMoveEvent(QMouseEvent * e) RS_DEBUG->print("RS_GraphicView::mouseMoveEvent 001"); - if (e != NULL) + if (e) { mx = e->x(); my = e->y(); @@ -603,17 +593,17 @@ void RS_GraphicView::mouseMoveEvent(QMouseEvent * e) RS_DEBUG->print("RS_GraphicView::mouseMoveEvent 002"); - if (eventHandler != NULL) + if (eventHandler) eventHandler->mouseMoveEvent(e); RS_DEBUG->print("RS_GraphicView::mouseMoveEvent 003"); - if (eventHandler == NULL || !eventHandler->hasAction() && graphic != NULL) + if (!eventHandler || !eventHandler->hasAction() && graphic) { Vector mouse = toGraph(Vector(mx, my)); Vector relMouse = mouse - getRelativeZero(); - if (RS_DIALOGFACTORY != NULL) + if (RS_DIALOGFACTORY) RS_DIALOGFACTORY->updateCoordinateWidget(mouse, relMouse); } @@ -626,7 +616,7 @@ void RS_GraphicView::mouseMoveEvent(QMouseEvent * e) */ void RS_GraphicView::mouseLeaveEvent() { - if (eventHandler != NULL) + if (eventHandler) eventHandler->mouseLeaveEvent(); } @@ -636,7 +626,7 @@ void RS_GraphicView::mouseLeaveEvent() */ void RS_GraphicView::mouseEnterEvent() { - if (eventHandler != NULL) + if (eventHandler) eventHandler->mouseEnterEvent(); } @@ -646,7 +636,7 @@ void RS_GraphicView::mouseEnterEvent() */ void RS_GraphicView::keyPressEvent(QKeyEvent * e) { - if (eventHandler != NULL) + if (eventHandler) eventHandler->keyPressEvent(e); } @@ -656,7 +646,7 @@ void RS_GraphicView::keyPressEvent(QKeyEvent * e) */ void RS_GraphicView::keyReleaseEvent(QKeyEvent * e) { - if (eventHandler != NULL) + if (eventHandler) eventHandler->keyReleaseEvent(e); } @@ -665,7 +655,7 @@ void RS_GraphicView::keyReleaseEvent(QKeyEvent * e) */ void RS_GraphicView::commandEvent(RS_CommandEvent * e) { - if (eventHandler != NULL) + if (eventHandler) eventHandler->commandEvent(e); } @@ -674,7 +664,7 @@ void RS_GraphicView::commandEvent(RS_CommandEvent * e) */ void RS_GraphicView::enableCoordinateInput() { - if (eventHandler != NULL) + if (eventHandler) eventHandler->enableCoordinateInput(); } @@ -683,7 +673,7 @@ void RS_GraphicView::enableCoordinateInput() */ void RS_GraphicView::disableCoordinateInput() { - if (eventHandler != NULL) + if (eventHandler) eventHandler->disableCoordinateInput(); } @@ -1205,10 +1195,10 @@ void RS_GraphicView::drawWindow(Vector v1, Vector v2) if (simulationRunning) return; - if (container != NULL) + if (container) { - for (RS_Entity * se=container->firstEntity(RS2::ResolveNone); - se!=NULL; se = container->nextEntity(RS2::ResolveNone)) + for(RS_Entity * se=container->firstEntity(RS2::ResolveNone); se!=NULL; + se=container->nextEntity(RS2::ResolveNone)) { if (se->isInWindow(v1, v2)) drawEntity(se); @@ -1236,25 +1226,17 @@ void RS_GraphicView::drawIt() return; //} -// bool painterCreated = false; - settings.beginGroup("Appearance"); draftMode = settings.value("DraftMode", false).toBool(); settings.endGroup(); - //RS_DEBUG->print("RS_GraphicView::drawIt() begin"); - //RS_DEBUG->print(" factors: %f/%f", factor.x, factor.y); - //RS_DEBUG->timestamp(); - - if (painter == NULL) - { -printf("RS_GraphicView::drawIt(): painter == NULL!\n"); + if (!painter) +// { +//printf("RS_GraphicView::drawIt(): painter == NULL!\n"); return; -// createPainter(); -// painterCreated = true; - } - else - painter->erase(); +// } + + painter->erase(); // drawing paper border: if (isPrintPreview()) @@ -1263,17 +1245,10 @@ printf("RS_GraphicView::drawIt(): painter == NULL!\n"); else drawMetaGrid(); - //if (draftMode) { - // painter->setPen(RS_Pen(foreground, RS2::Width00, RS2::SolidLine)); - //} - // drawing entities: //#warning "!!! This looks like a bug, no match for 'drawEntity(RS_Entity *, bool) !!!" // and indeed it *is* a bug... true is converted to 1.0 here. Dumb, dumb, dumb. - drawEntity(container, true); - - //RS_DEBUG->timestamp(); - //RS_DEBUG->print(" draw zero.."); + drawEntity(container);//, true); // drawing zero points: if (!isPrintPreview()) @@ -1282,17 +1257,9 @@ printf("RS_GraphicView::drawIt(): painter == NULL!\n"); drawRelativeZero(); } - //RS_DEBUG->timestamp(); - //RS_DEBUG->print(" draw grid.."); - // drawing grid: if (!isPrintPreview()) drawGrid(); - - //RS_DEBUG->timestamp(); - //RS_DEBUG->print("RS_GraphicView::drawIt() end"); -// if (painterCreated == true) -// destroyPainter(); } /** @@ -1516,9 +1483,8 @@ void RS_GraphicView::simulateIt() simulationRunning = true; simulationLast = Vector(0.0, 0.0); - destroyPainter(); +//jlh destroyPainter(); - createDirectPainter(); painter->erase(); // drawing paper border: @@ -1558,7 +1524,7 @@ void RS_GraphicView::simulateIt() //RS_DEBUG->timestamp(); //RS_DEBUG->print("RS_GraphicView::drawIt() end"); //if (painterCreated==true) { - destroyPainter(); +//jlh destroyPainter(); //} simulationRunning = false; } @@ -1589,7 +1555,7 @@ void RS_GraphicView::simulateEntity(RS_Entity * e, const RS_Pen & pen) if (sp.distanceTo(simulationLast) > 1.0e-4) { - createDirectPainter(); +//jlh createDirectPainter(); RS_Pen rpen(RS_Color(0, 0, 255), RS2::Width00, RS2::SolidLine); //painter->setPen(pen); RS_Line rapidLine(NULL, RS_LineData(simulationLast, sp)); @@ -1649,7 +1615,7 @@ void RS_GraphicView::simulateEntity(RS_Entity * e, const RS_Pen & pen) } else { - createDirectPainter(); +//jlh createDirectPainter(); //RS_Pen pen(foreground, RS2::Width00, RS2::SolidLine); painter->setPen(pen); drawEntityPlain(e); @@ -1766,7 +1732,7 @@ void RS_GraphicView::drawLineSmooth(const Vector & p1, const Vector & p2, const if (lx >= 0.0 && lx <= (double)getWidth() && ly >= 0.0 && ly <= (double)getHeight()) { //if (painter==NULL) { - createDirectPainter(); +//jlh createDirectPainter(); //} painter->setPen(pen); painter->drawGridPoint(Vector(lx, ly)); @@ -1791,7 +1757,7 @@ void RS_GraphicView::drawArcSmooth(const Vector & center, double radius, double if (radius <= 1.4) { - createDirectPainter(); +//jlh createDirectPainter(); painter->setPen(pen); painter->drawGridPoint(center); } @@ -1836,7 +1802,7 @@ void RS_GraphicView::drawArcSmooth(const Vector & center, double radius, double k2y = RS_Math::round(center.y-sin(a)*radius); //if(graphic->isPointOnScreen(k2x, k2y) || // graphic->isPointOnScreen(k1x, k1y) ) { - createDirectPainter(); +//jlh createDirectPainter(); painter->setPen(pen); if ((k2x >= 0 && k2x <= painter->getWidth() && k2y >= 0 && k2y <= painter->getHeight()) @@ -1856,7 +1822,7 @@ void RS_GraphicView::drawArcSmooth(const Vector & center, double radius, double k1y = k2y; } - createDirectPainter(); +//jlh createDirectPainter(); painter->setPen(pen); painter->drawLine(Vector(k2x, k2y), Vector(ix2, iy2)); //painter->lineTo(ix2, iy2); @@ -1877,7 +1843,7 @@ void RS_GraphicView::drawArcSmooth(const Vector & center, double radius, double k2y = RS_Math::round(center.y - sin(a) * radius); //if(graphic->isPointOnScreen(k2x, k2y) || // graphic->isPointOnScreen(k1x, k1y) ) { - createDirectPainter(); +//jlh createDirectPainter(); painter->setPen(pen); if ((k2x >=0 && k2x <= painter->getWidth() && k2y >= 0 && k2y <= painter->getHeight()) @@ -1895,7 +1861,7 @@ void RS_GraphicView::drawArcSmooth(const Vector & center, double radius, double k1y = k2y; } - createDirectPainter(); +//jlh createDirectPainter(); painter->setPen(pen); //painter->lineTo(ix2, iy2); painter->drawLine(Vector(k2x, k2y), Vector(ix2, iy2)); @@ -1993,21 +1959,16 @@ RS_LineTypePattern * RS_GraphicView::getPattern(RS2::LineType t) * zero. It's called from within drawIt(). The default implemetation * draws a simple red round zero point. * + * Actually, we have to rework the rendering code because the way that QCad did + * it was wrong on so many levels... Part of that is making sure the rendering + * path is 100% clear! + * * @see drawIt() */ void RS_GraphicView::drawAbsoluteZero() { -//RS_DEBUG->print(RS_Debug::D_CRITICAL, "RS_GraphicView::drawAbsoluteZero (painter=%08X)", painter); -// bool painterCreated = false; - - // create a temporary painter device - if (painter == NULL) - { + if (!painter) return; -//Hrm. createDirectPainter(); -// createPainter(); -// painterCreated = true; - } int zr = 20; @@ -2017,18 +1978,13 @@ void RS_GraphicView::drawAbsoluteZero() //Using Qt::red doesn't seem to work here... //It's because Qt colors and RS_Color are not 100% compatible... RS_Pen p(RS_Color(255, 0, 0), RS2::Width00, RS2::SolidLine); -// p.setScreenWidth(0); painter->setPen(p); - //painter->setBrush(Qt::NoBrush); painter->drawLine(Vector(toGuiX(0.0) - zr, toGuiY(0.0)), Vector(toGuiX(0.0) + zr, toGuiY(0.0))); painter->drawLine(Vector(toGuiX(0.0), toGuiY(0.0) - zr), Vector(toGuiX(0.0), toGuiY(0.0) + zr)); - -// if (painterCreated) -// destroyPainter(); } /** @@ -2040,21 +1996,8 @@ void RS_GraphicView::drawAbsoluteZero() */ void RS_GraphicView::drawRelativeZero() { -//#warning "!!! drawRelativeZero() not working AT ALL !!!" -#if 1 -// bool painterCreated = false; - - if (relativeZero.valid == false) - return; - - // create a temporary painter device - if (painter == NULL) - { + if (!relativeZero.valid || !painter) return; -//hrm. createDirectPainter(); -// createPainter(); -// painterCreated = true; - } // RS_Pen p(Qt::red, RS2::Width00, RS2::SolidLine); // p.setScreenWidth(0); @@ -2072,12 +2015,7 @@ void RS_GraphicView::drawRelativeZero() Vector(toGuiX(relativeZero.x), toGuiY(relativeZero.y) + zr)); painter->drawCircle(toGui(relativeZero), zr); - painter->setNormalMode(); - -// if (painterCreated) -// destroyPainter(); -#endif } /** @@ -2087,8 +2025,6 @@ void RS_GraphicView::drawRelativeZero() */ void RS_GraphicView::drawPaper() { - bool painterCreated = false; - if (container == NULL) return; @@ -2100,12 +2036,8 @@ void RS_GraphicView::drawPaper() if (graphic->getPaperScale() < 1.0e-6) return; - // create a temporary painter device if (painter == NULL) - { - createDirectPainter(); - painterCreated = true; - } + return; // draw paper: painter->setPen(RS_Pen(Qt::gray)); @@ -2134,9 +2066,6 @@ void RS_GraphicView::drawPaper() painter->fillRect((int)(v1.x) + 1, (int)(v1.y) - 1, (int)((v2.x - v1.x)) - 2, (int)((v2.y - v1.y)) + 2, RS_Color(255, 255, 255)); - - if (painterCreated) - destroyPainter(); } /** @@ -2188,38 +2117,27 @@ void RS_GraphicView::drawMetaGrid() if (grid == NULL || isGridOn() == false /*|| grid->getMetaSpacing()<0.0*/) return; - bool painterCreated = false; - - // create a temporary painter device if (painter == NULL) - { -//hrm createDirectPainter(); - createPainter(); - painterCreated = true; - } + return; RS_Pen pen(metaGridColor, RS2::Width00, RS2::DotLine); painter->setPen(pen); // draw meta grid: double * mx = grid->getMetaX(); + double * my = grid->getMetaY(); - if (mx != NULL) + if (mx) { for(int i=0; icountMetaX(); ++i) painter->drawLine(Vector(toGuiX(mx[i]), 0), Vector(toGuiX(mx[i]), getHeight())); } - double * my = grid->getMetaY(); - - if (my != NULL) + if (my) { for(int i=0; icountMetaY(); ++i) painter->drawLine(Vector(0, toGuiY(my[i])), Vector(getWidth(), toGuiY(my[i]))); } - - if (painterCreated) - destroyPainter(); } /** @@ -2415,25 +2333,14 @@ void RS_GraphicView::setRelativeZero(const Vector & pos) */ void RS_GraphicView::moveRelativeZero(const Vector & pos) { -// bool painterCreated = false; - - if (painter == NULL) - { +#warning "!!! RS_GraphicView::moveRelativeZero(): Bad render path !!!" + if (!painter) return; -//hrm painter = createDirectPainter(); -// painter = createPainter(); -// painterCreated = true; - } //painter->setXORMode(); drawRelativeZero(); - setRelativeZero(pos); - drawRelativeZero(); - -// if (painterCreated) -// destroyPainter(); } RS_EventHandler * RS_GraphicView::getEventHandler() diff --git a/src/base/rs_graphicview.h b/src/base/rs_graphicview.h index 9ba6a1e..dafc78e 100644 --- a/src/base/rs_graphicview.h +++ b/src/base/rs_graphicview.h @@ -57,24 +57,25 @@ class RS_GraphicView * Sets an external painter device. */ virtual void setPainter(PaintInterface * p); - // virtual void setPainter(RS_Painter * p); + +// We're removing this crap... +#if 0 /** This virtual method must be overwritten and must return the painter device for the buffer of this widget */ - virtual PaintInterface * createPainter() = 0; - // virtual RS_Painter * createPainter() = 0; +// virtual PaintInterface * createPainter() = 0; /** * This virtual method must be overwritten and must return * the direct painter device for this widget */ - virtual PaintInterface * createDirectPainter() = 0; - // virtual RS_Painter * createDirectPainter() = 0; +// virtual PaintInterface * createDirectPainter() = 0; /** * This virtual method must be overwritten and must destroy * the painter device and point 'painter' to NULL. If the painter * is static during the whole life of the application, it might * just do nothing. */ - virtual void destroyPainter() = 0; +// virtual void destroyPainter() = 0; +#endif virtual void setBackground(const RS_Color & bg); RS_Color getBackground(); diff --git a/src/mainapp/qc_graphicview.cpp b/src/mainapp/qc_graphicview.cpp index 7d184ee..799d4ad 100644 --- a/src/mainapp/qc_graphicview.cpp +++ b/src/mainapp/qc_graphicview.cpp @@ -15,8 +15,6 @@ #include "qc_graphicview.h" #include "rs_actiondefault.h" -#include "settings.h" -#include "qc_applicationwindow.h" QC_GraphicView::QC_GraphicView(RS_Document * doc, QWidget * parent): QG_GraphicView(parent, "graphicview") diff --git a/src/widgets/qg_graphicview.cpp b/src/widgets/qg_graphicview.cpp index 0ecf480..96cdebf 100644 --- a/src/widgets/qg_graphicview.cpp +++ b/src/widgets/qg_graphicview.cpp @@ -42,20 +42,9 @@ QG_GraphicView::QG_GraphicView(QWidget * parent, const char */*name*/, Qt::Windo buffer = NULL; lastWidth = 0; lastHeight = 0; - //coordinateWidget = NULL; - //mouseWidget = NULL; - //optionWidget = NULL; - //cadToolBar = NULL; - //commandWidget = NULL; //hrm. painter = NULL; -// layout = new Q3GridLayout(this, 3, 2); -// layout->setColStretch(0, 1); -// layout->setColStretch(1, 0); -// layout->setColStretch(2, 0); -// layout->setRowStretch(0, 1); -// layout->setRowStretch(1, 0); layout = new QGridLayout(this); layout->setColumnStretch(0, 1); layout->setColumnStretch(1, 0); @@ -92,36 +81,26 @@ A non-zero alignment indicates that the widget should not grow to fill the avail #ifndef __APPLE__ // Mouse Cursors: QBitmap bmp; -// QPixmap cur1(cur_cad_bmp_xpm); -// bmp = QPixmap(cur_cad_mask_xpm); QPixmap cur1(":/res/cur_cad_bmp.xpm"); bmp = QPixmap(":/res/cur_cad_mask.xpm"); cur1.setMask(bmp); curCad = new QCursor(cur1, 15, 15); -// QPixmap cur2(cur_glass_bmp_xpm); -// bmp = QPixmap(cur_glass_mask_xpm); QPixmap cur2(":/res/cur_glass_bmp.xpm"); bmp = QPixmap(":/res/cur_glass_mask.xpm"); cur2.setMask(bmp); curMagnifier = new QCursor(cur2, 12, 12); -// QPixmap cur3(cur_del_bmp_xpm); -// bmp = QPixmap(cur_del_mask_xpm); QPixmap cur3(":/res/cur_del_bmp.xpm"); bmp = QPixmap(":/res/cur_del_mask.xpm"); cur3.setMask(bmp); curDel = new QCursor(cur3, 15, 15); -// QPixmap cur4(cur_select_bmp_xpm); -// bmp = QPixmap(cur_select_mask_xpm); QPixmap cur4(":/res/cur_select_bmp.xpm"); bmp = QPixmap(":/res/cur_select_mask.xpm"); cur4.setMask(bmp); curSelect = new QCursor(cur4, 15, 15); -// QPixmap cur5(cur_hand_bmp_xpm); -// bmp = QPixmap(cur_hand_mask_xpm); QPixmap cur5(":/res/cur_hand_bmp.xpm"); bmp = QPixmap(":/res/cur_hand_mask.xpm"); cur5.setMask(bmp); @@ -194,104 +173,6 @@ int QG_GraphicView::getHeight() return height() - hScrollBar->sizeHint().height(); } -/** - * Creates a new painter for the buffer of this widget and returns a - * pointer to it. The class variable 'painter' also - * points to that object. - */ -//'painter' is NOT a class variable! -//RS_Painter * QG_GraphicView::createPainter() -PaintInterface * QG_GraphicView::createPainter() -{ -#if 1 - return NULL; -#else -//RS_DEBUG->print(RS_Debug::D_CRITICAL, "QG_GraphicView::createPainter called..."); - RS_DEBUG->print("QG_GraphicView::createPainter begin"); - - if (lastWidth != getWidth() || lastHeight != getHeight()) - { - destroyPainter(); - - if (buffer != NULL) - { - delete buffer; - buffer = NULL; - } - - lastWidth = getWidth(); - lastHeight = getHeight(); - } - - if (buffer == NULL) - { - //RS_DEBUG->timestamp(); - RS_DEBUG->print("creating buffer: %d,%d", getWidth(), getHeight()); - buffer = new QPixmap(getWidth(), getHeight()); - RS_DEBUG->print("ok"); - } - - if (painter == NULL) - { - painter = new RS_PainterQt(buffer); - painter->setDrawingMode(drawingMode); - ((RS_PainterQt *)painter)->setBackgroundMode(Qt::OpaqueMode); - ((RS_PainterQt *)painter)->setBackgroundColor(background); - ((RS_PainterQt *)painter)->eraseRect(0, 0, getWidth(), getHeight()); - - //RS_DEBUG->timestamp(); - } - - RS_DEBUG->print("QG_GraphicView::createPainter end"); - - return painter; -#endif -} - -/** - * Creates a new painter for this widget and returns a - * pointer to it. The class variable 'painter' also - * automatically points to that object. - */ -//RS_Painter * QG_GraphicView::createDirectPainter() -PaintInterface * QG_GraphicView::createDirectPainter() -{ -#if 1 - return NULL; -#else -//RS_DEBUG->print(RS_Debug::D_CRITICAL, "QG_GraphicView::createDirectPainter called..."); - RS_DEBUG->print("QG_GraphicView::createDirectPainter begin"); - - destroyPainter(); - painter = new RS_PainterQt(this); - painter->setDrawingMode(drawingMode); - - RS_DEBUG->print("QG_GraphicView::createDirectPainter end"); - - return painter; -#endif -} - -/** - * Deletes the painter. - */ -void QG_GraphicView::destroyPainter() -{ -#if 1 - return; -#else - RS_DEBUG->print("QG_GraphicView::destroyPainter begin"); - - if (painter != NULL) - { - delete painter; - painter = NULL; - } - - RS_DEBUG->print("QG_GraphicView::destroyPainter end"); -#endif -} - /** * Changes the current background color of this view. */ @@ -858,6 +739,11 @@ void QG_GraphicView::slotVScrolled(int value) * Handles paint events by redrawing the graphic in this view. * usually that's very fast since we only paint the buffer we * have from the last call.. + * + * This is not true anymore--even if it was true in the first place, which + * seems doubtful to me. Everything is redrawn every time; we need to see if + * relying on Qt do to the clipping is wise or not... Also, we need to clarify + * all rendering paths since they are not all logical or consistent. */ void QG_GraphicView::paintEvent(QPaintEvent *) { diff --git a/src/widgets/qg_graphicview.h b/src/widgets/qg_graphicview.h index b509421..09a4333 100644 --- a/src/widgets/qg_graphicview.h +++ b/src/widgets/qg_graphicview.h @@ -34,9 +34,9 @@ class QG_GraphicView: public QWidget, public RS_GraphicView, //public Q3FilePrev // virtual RS_Painter * createPainter(); // virtual RS_Painter * createDirectPainter(); #warning "!!! Need to scrub out all instances of createPainter and createDirectPainter !!!" - virtual PaintInterface * createPainter(); - virtual PaintInterface * createDirectPainter(); - virtual void destroyPainter(); +// virtual PaintInterface * createPainter(); +// virtual PaintInterface * createDirectPainter(); +// virtual void destroyPainter(); virtual void setBackground(const RS_Color & bg); virtual void setMouseCursor(RS2::CursorType c); virtual void updateGridStatusWidget(const QString & text);