src/widgets/qg_patternbox.h \
src/widgets/qg_pentoolbar.h \
src/widgets/recentfiles.h \
- src/widgets/qg_scrollbar.h \
src/widgets/qg_widthbox.h
SOURCES += \
src/widgets/qg_patternbox.cpp \
src/widgets/qg_pentoolbar.cpp \
src/widgets/recentfiles.cpp \
- src/widgets/qg_scrollbar.cpp \
src/widgets/qg_widthbox.cpp
FORMS = \
{
RS_DEBUG->print("RS_ActionDrawLine::RS_ActionDrawLine");
reset();
-//[DONE]#warning "!!! Need to port setAutoDelete() behaviour from Qt3 to Qt4 !!!"
-// history.setAutoDelete(true);
RS_DEBUG->print("RS_ActionDrawLine::RS_ActionDrawLine: OK");
}
RS_DEBUG->print("RS_ActionDrawLine::reset");
data = RS_LineData(Vector(false), Vector(false));
start = Vector(false);
-// history.clear();
ClearHistory();
RS_DEBUG->print("RS_ActionDrawLine::reset: OK");
}
{
RS_DEBUG->print("RS_ActionDrawLine::init");
RS_PreviewActionInterface::init(status);
-
reset();
RS_DEBUG->print("RS_ActionDrawLine::init: OK");
}
void RS_ActionDrawLine::trigger()
{
- RS_PreviewActionInterface::trigger();
+ RS_PreviewActionInterface::trigger(); // XOR off screen, delete entities in container
RS_Line * line = new RS_Line(container, data);
line->setLayerToActive();
//std::cout << *container;
// Update undo list:
- if (document != NULL)
+ if (document)
{
document->startUndoCycle();
document->addUndoable(line);
document->endUndoCycle();
}
- deleteSnapper();
+ deleteSnapper(); // XOR off of screen
graphicView->moveRelativeZero(Vector(0.0, 0.0));
//This is unnecessary, because we added this to the container...
//#warning "!!! Here's the trouble... Trying to draw direct !!!"
// graphicView->drawEntity(line);
graphicView->moveRelativeZero(line->getEndpoint());
- drawSnapper();
+ drawSnapper(); // XOR on screen
RS_DEBUG->print("RS_ActionDrawLine::trigger(): line added: %d", line->getId());
}
if (getStatus() == SetEndpoint && data.startpoint.valid)
{
RS_DEBUG->print("RS_ActionDrawLine::mouseMoveEvent: update preview");
- deletePreview();
- clearPreview();
+//not needed, but without this, it doesn't draw... strange...
+//obviously we haven't gotten our rendering path correct...
+// deletePreview(); // XOR off of screen
+ clearPreview(); // Remove entities from the container
preview->addEntity(new RS_Line(preview, RS_LineData(data.startpoint, mouse)));
RS_DEBUG->print("RS_ActionDrawLine::mouseMoveEvent: draw preview");
- drawPreview();
+// drawPreview(); // XOR on screen
+ xorPreview(); // XOR on screen
}
RS_DEBUG->print("RS_ActionDrawLine::mouseMoveEvent end");
}
else if (e->button() == Qt::RightButton)
{
- deletePreview();
- clearPreview();
- deleteSnapper();
+ deletePreview(); // XOR off of screen
+ clearPreview(); // Remove entities from the container
+ deleteSnapper(); // XOR off of screen
init(getStatus() - 1);
}
}
{
RS_DEBUG->print("RS_ActionDrawLine::coordinateEvent");
- if (e == NULL)
+ if (!e)
{
RS_DEBUG->print("RS_ActionDrawLine::coordinateEvent: event was NULL");
return;
{
case SetStartpoint:
data.startpoint = mouse;
-// history.clear();
ClearHistory();
history.append(new Vector(mouse));
start = data.startpoint;
{
RS_DEBUG->print("RS_ActionDrawLine::showOptions");
RS_ActionInterface::showOptions();
-
RS_DIALOGFACTORY->requestOptions(this, true);
RS_DEBUG->print("RS_ActionDrawLine::showOptions: OK");
}
void RS_ActionDrawLine::hideOptions()
{
RS_ActionInterface::hideOptions();
-
RS_DIALOGFACTORY->requestOptions(this, false);
}
void RS_ActionDrawLine::close()
{
+//NOTE: We should grey out the "close" button until the conditions for its use are satisfied.
+// Though I can see how this would be called via cmd line... So I guess it's OK
if (history.count() > 2 && start.valid)
{
data.endpoint = start;
void RS_ActionDrawLine::undo()
{
+//NOTE: We should grey out the "undo" button until the conditions for its use are satisfied.
if (history.count() > 1)
{
history.removeLast();
- deletePreview();
- clearPreview();
+ deletePreview(); // XOR off of screen
+ clearPreview(); // Delete entities in container
graphicView->setCurrentAction(new RS_ActionEditUndo(true, *container, *graphicView));
data.startpoint = *history.last();
graphicView->moveRelativeZero(data.startpoint);
while (!history.isEmpty())
delete history.takeFirst();
}
-
}
/**
- * Called to initiate an action. This funtcion is often
+ * Called to initiate an action. This function is often
* overwritten by the implementing action.
*
* @param status The status on which to initiate this action.
* default is 0 to begin the action.
*/
-void RS_ActionInterface::init(int status)
+void RS_ActionInterface::init(int status/*= 0*/)
{
RS_Snapper::init();
setStatus(status);
graphicView->setMouseCursor(RS2::ArrowCursor);
//graphicView->requestToolBar(RS2::ToolBarMain);
updateToolBar();
+//Maybe change this to SnapperOff()?
//jlh: deleteSnapper();
hideOptions();
finished = true;
- RS_Snapper::finish();
+ RS_Snapper::finish(); // Sets RS_Snapper::finished = true
+ // I think this is where we want to update the screen...
+// graphicView->update();
+ graphicView->redraw();
RS_DEBUG->print("RS_ActionInterface::finish: OK");
}
//huh? no slots/signals here... Q_OBJECT
//WHY derive from QObject???
//for the TR macro???
-//mebbe...
+//mebbe... Well, that's what he says above. Though it would be just as easy to
+//prefix a QObject::tr in front of translated strings...
public:
RS_ActionInterface(const char * name, RS_EntityContainer & container,
GraphicView & graphicView);
*/
void RS_PreviewActionInterface::xorPreview()
{
-#warning "!!! xorPreview() not working AT ALL !!!"
+//not true anymore..
+//#warning "!!! xorPreview() not working AT ALL !!!"
#if 0
if (!preview->isEmpty())
{
//This doesn't work, causes the thing to crash...
//Now it works, just need to upgrade the rendering paths so that they aren't all
//fucked up like QCad was...
-#if 1
if (!preview->isEmpty())
{
graphicView->SetPreviewMode();
visible = !visible;
#endif
-#endif
}
void drawPreview();
void deletePreview();
- private:
+// private:
+ protected:
void xorPreview();
protected:
#warning "!!! THIS IS WHERE THE SNAPPER IS BEING DRAWN... !!!"
drawSnapper();
- if (RS_DIALOGFACTORY != NULL)
+ if (RS_DIALOGFACTORY)
RS_DIALOGFACTORY->updateCoordinateWidget(snapCoord, snapCoord - graphicView->getRelativeZero());
RS_DEBUG->print("RS_Snapper::snapPoint: OK");
int idx = -1;
- if (entity != NULL && entity->getParent() != NULL)
+ if (entity && entity->getParent())
idx = entity->getParent()->findEntity(entity);
- if (entity != NULL && dist <= graphicView->toGraphDX(snapRange))
+ if (entity && dist <= graphicView->toGraphDX(snapRange))
{
// highlight:
RS_DEBUG->print("RS_Snapper::catchEntity: found: %d", idx);
}
RS_DEBUG->print("RS_Snapper::catchEntity: OK");
- }
+}
/**
* Catches an entity which is close to the mouse cursor.
*/
void RS_Snapper::hideOptions()
{
- if (snapMode == RS2::SnapDist)
- if (RS_DIALOGFACTORY != NULL)
- RS_DIALOGFACTORY->requestSnapDistOptions(distance, false);
+ if (snapMode == RS2::SnapDist && RS_DIALOGFACTORY)
+ RS_DIALOGFACTORY->requestSnapDistOptions(distance, false);
}
/**
*/
void RS_Snapper::showOptions()
{
- if (snapMode == RS2::SnapDist)
- if (RS_DIALOGFACTORY != NULL)
- RS_DIALOGFACTORY->requestSnapDistOptions(distance, true);
+ if (snapMode == RS2::SnapDist && RS_DIALOGFACTORY)
+ RS_DIALOGFACTORY->requestSnapDistOptions(distance, true);
}
/**
*/
void RS_Snapper::drawSnapper()
{
+printf("RS_Snapper::drawSnapper(): Using DEPRECATED function!!!\n");
if (!visible)
xorSnapper();
}
*/
void RS_Snapper::deleteSnapper()
{
+printf("RS_Snapper::deleteSnapper(): Using DEPRECATED function!!!\n");
if (visible)
{
xorSnapper();
visible = !visible;
#endif
}
+
+void RS_Snapper::SetSnapperVisible(bool visibility/*= true*/)
+{
+ graphicView->SetSnapperDraw(visibility);
+}
+
+//Hmm, not sure this is necessary...
+#warning "!!! Not sure this is necessary... !!!"
+void RS_Snapper::SetSnapperCoords(Vector snapCoord, Vector snapSpot)
+{
+ graphicView->SetSnapperVars(snapSpot, snapCoord, showCrosshairs);
+}
Vector restrictHorizontal(Vector coord);
Vector restrictVertical(Vector coord);
- //RS_Entity* catchLeafEntity(const Vector& pos);
- //RS_Entity* catchLeafEntity(QMouseEvent* e);
RS_Entity * catchEntity(const Vector & pos, RS2::ResolveLevel level = RS2::ResolveNone);
RS_Entity * catchEntity(QMouseEvent * e, RS2::ResolveLevel level = RS2::ResolveNone);
void drawSnapper();
void deleteSnapper();
+/*
+How should we handle this? All rendering goes through the GraphicView (QG_GraphicView to be
+precise, soon to be merged in) as it should. So shouldn't we control the snapper through
+that class as well? Unfortunately, all actions derive from this class...
+
+Should they?
+
+Not 100% sure. It does seem to make more sense to have them be a part of the GraphicView,
+since snapping is a function of the grid and the entities contained in the view. (This would
+also hold for the preview as well.)
+
+On to the interface:
+
+For allowing the crosshairs to be drawn, we'd have
+void ShowSnapper(void)
+
+and
+void HideSnapper(void)
+
+to hide it. Maybe
+void SetSnapperCoords(Vector, Vector)
+
+for setting the coordinates?
+*/
+ protected:
+// void ShowSnapper(void);
+// void HideSnapper(void);
+ void SetSnapperVisible(bool visibility = true);
+ void SetSnapperCoords(Vector, Vector);
+
private:
void xorSnapper();
// JLH 06/15/2010 Moved implementation (however trivial) from header to here.
//
+/*
+To me, this is yet another useless class. It seems to me that this could be
+easily replaced by putting a bitmap creation method in GraphicView. But that's
+just me. >:-)
+*/
+
#include "rs_staticgraphicview.h"
/**
*/
void GraphicView::drawRelativeZero()
{
+// PROBLEM: relativeZero IS NOT VALID!!!
if (!relativeZero.valid || !painter)
+#if 1
return;
+#else
+ {
+ if (!relativeZero.valid)
+ printf("GraphicView::drawRelativeZero(): relativeZero is NOT valid!!!\n");
+
+ if (!painter)
+ printf("GraphicView::drawRelativeZero(): painter is NOT valid!!!\n");
+
+ return;
+ }
+#endif
// RS_Pen p(Qt::red, RS2::Width00, RS2::SolidLine);
// p.setScreenWidth(0);
*/
void GraphicView::moveRelativeZero(const Vector & pos)
{
-#warning "!!! GraphicView::moveRelativeZero(): Bad render path !!!"
- if (!painter)
- return;
+//this is crap. we're taking this shit out.
+//#warning "!!! GraphicView::moveRelativeZero(): Bad render path !!!"
+// if (!painter)
+// return;
//painter->setXORMode();
- drawRelativeZero();
+// drawRelativeZero();
setRelativeZero(pos);
- drawRelativeZero();
+// drawRelativeZero();
}
RS_EventHandler * GraphicView::getEventHandler()
ApplicationWindow * appWindow = ApplicationWindow::getAppWindow();
MDIWindow * parent = appWindow->getMDIWindow();
- if (parent != NULL)
+ if (parent && blockList)
{
- //RS_BlockList* blist = blockWidget->getBlockList();
- if (blockList != NULL)
- {
- RS_Block * blk = blockList->getActive();
+ RS_Block * block = blockList->getActive();
- if (blk != NULL)
- {
- MDIWindow * w = appWindow->slotFileNew(blk);
- // the parent needs a pointer to the block window and
- // vice versa
- parent->addChildWindow(w);
- w->getGraphicView()->zoomAuto(false);
- }
+ if (block)
+ {
+ MDIWindow * w = appWindow->slotFileNew(block);
+ // the parent needs a pointer to the block window and vice versa
+ parent->addChildWindow(w);
+ w->getGraphicView()->zoomAuto(false);
}
}
}
ApplicationWindow * appWindow = ApplicationWindow::getAppWindow();
QMdiArea * workspace = appWindow->getWorkspace();
- if (workspace != NULL)
+ if (workspace)
{
RS_DEBUG->print("QC_DialogFactory::closeEditBlockWindow: workspace found");
QList<QMdiSubWindow *> windows = workspace->subWindowList();
- for(int i=0; i<int(windows.count()); ++i)
+ for(int i=0; i<windows.count(); i++)
{
RS_DEBUG->print("QC_DialogFactory::closeEditBlockWindow: window: %d", i);
MDIWindow * m = (MDIWindow *)windows.at(i);
- if (m != NULL)
+ if (m)
{
RS_DEBUG->print("QC_DialogFactory::closeEditBlockWindow: got mdi");
void setActionRestrictVertical(QAction * a);
void setActionLockRelativeZero(QAction * a);
-// void setCadToolBarSnap(QG_CadToolBarSnap * tb);
void setCadToolBarSnap(CadToolBarSnap * tb);
private:
*/
void QG_BlockWidget::contextMenuEvent(QContextMenuEvent * e)
{
-#warning "Figure out how to port this crap (popup menu) to Qt4... !!! FIX !!!"
#if 0
//QListBoxItem* item = listBox->selectedItem();
Q3PopupMenu * contextMenu = new Q3PopupMenu(this);
contextMenu->insertItem(tr("&Create New Block"), actionHandler, SLOT(slotBlocksCreate()), 0);
contextMenu->exec(QCursor::pos());
delete contextMenu;
+#else
+#warning "Figure out how to port this crap (popup menu) to Qt4... !!! FIX !!!"
#endif
e->accept();
A non-zero alignment indicates that the widget should not grow to fill the available space but should be sized according to sizeHint().
*/
RS_DEBUG->print("--> Creating hScrollBar...");
- hScrollBar = new QG_ScrollBar(Qt::Horizontal, this);
+// hScrollBar = new QG_ScrollBar(Qt::Horizontal, this);
+ hScrollBar = new QScrollBar(Qt::Horizontal, this);
// hScrollBar->setLineStep(50);
hScrollBar->setSingleStep(50);
// layout->addMultiCellWidget(hScrollBar, 1, 1, 0, 0);
layout->addItem(new QSpacerItem(0, hScrollBar->sizeHint().height()), 1, 0);
RS_DEBUG->print("--> Creating vScrollBar...");
- vScrollBar = new QG_ScrollBar(Qt::Vertical, this);
+// vScrollBar = new QG_ScrollBar(Qt::Vertical, this);
+ vScrollBar = new QScrollBar(Qt::Vertical, this);
// vScrollBar->setLineStep(50);
vScrollBar->setSingleStep(50);
// layout->addMultiCellWidget(vScrollBar, 0, 0, 2, 2);
/*
This is retarded. There is absolutely no reason to have this shit in here.
This could be easily called from whoever calls this crap.
+
+And so... We remove it.
*/
+#if 0
// Next three methods from RS_LayerListListener Interface:
void QG_GraphicView::layerEdited(RS_Layer *)
{
{
redraw();
}
+#endif
void QG_GraphicView::emulateMouseMoveEvent()
{
* Instances of this class can be linked to layer lists using
* addLayerListListener().
*/
-class QG_GraphicView: public QWidget, public GraphicView, //public Q3FilePreview,
- public RS_LayerListListener, public RS_BlockListListener
+class QG_GraphicView: public QWidget, public GraphicView//, //public Q3FilePreview,
+// public RS_LayerListListener, public RS_BlockListListener
{
Q_OBJECT
virtual void setMouseCursor(RS2::CursorType c);
virtual void updateGridStatusWidget(const QString & text);
+// This is just crap. Why have a klunky listener interface when we have slots/signals???
+// That's what I thought!!!
// Methods from RS_LayerListListener Interface:
- virtual void layerEdited(RS_Layer *);
- virtual void layerRemoved(RS_Layer *);
- virtual void layerToggled(RS_Layer *);
+// virtual void layerEdited(RS_Layer *);
+// virtual void layerRemoved(RS_Layer *);
+// virtual void layerToggled(RS_Layer *);
protected:
virtual void emulateMouseMoveEvent();
int lastWidth;
int lastHeight;
//! Horizontal scrollbar.
- QG_ScrollBar * hScrollBar;
+// QG_ScrollBar * hScrollBar;
+ QScrollBar * hScrollBar;
//! Vertical scrollbar.
- QG_ScrollBar * vScrollBar;
+// QG_ScrollBar * vScrollBar;
+ QScrollBar * vScrollBar;
//! Layout used to fit in the view and the scrollbars.
QGridLayout * layout;
//! Label for grid spacing.
+++ /dev/null
-// qg_scrollbar.cpp
-//
-// Originally part of QCad Community Edition by Andrew Mustun
-// Extensively rewritten and refactored by James L. Hammons
-// (C) 2010 Underground Software
-//
-// JLH = James L. Hammons <jlhamm@acm.org>
-//
-// Who When What
-// --- ---------- -----------------------------------------------------------
-// JLH 05/08/2010 Moved implementation from header to this file. :-)
-//
-
-// This class seems worse than useless to me; probably will end up removing it
-// at some point. :-P
-
-#include "qg_scrollbar.h"
-
-QG_ScrollBar::QG_ScrollBar(QWidget * parent/*= 0*/, const char */*name = 0*/):
-// QScrollBar(parent, name)
- QScrollBar(parent)
-{
-}
-
-QG_ScrollBar::QG_ScrollBar(Qt::Orientation orientation, QWidget * parent/*= 0*/, const char */*name = 0*/):
-// QScrollBar(orientation, parent, name)
- QScrollBar(orientation, parent)
-{
-}
-
-void QG_ScrollBar::slotWheelEvent(QWheelEvent * e)
-{
- wheelEvent(e);
-}
+++ /dev/null
-#ifndef QG_SCROLLBAR_H
-#define QG_SCROLLBAR_H
-
-#include <QtGui>
-
-/**
- * A small wrapper for the Qt scrollbar. This class offers a slot
- * for scroll events.
- */
-class QG_ScrollBar: public QScrollBar
-{
- Q_OBJECT
-
- public:
- QG_ScrollBar(QWidget * parent = 0, const char * name = 0);
- QG_ScrollBar(Qt::Orientation orientation, QWidget * parent = 0, const char * name = 0);
-
- public slots:
- void slotWheelEvent(QWheelEvent * e);
-};
-
-#endif