25#include <QApplication>
27#include <QGraphicsEllipseItem>
28#include <QGraphicsItem>
29#include <QGraphicsScene>
60 lockNonGuidelinesAndUnlockGuidelines (
true);
77 context().mainWindow().cmdMediator()->document(),
81 context().mainWindow().cmdMediator()->document(),
93 return QCursor (Qt::ArrowCursor);
100 lockNonGuidelinesAndUnlockGuidelines (
false);
109 const QString &pointIdentifier)
112 <<
" point=" << pointIdentifier.toLatin1 ().data ();
116 const QStringList &pointIdentifiers)
119 <<
"points=" << pointIdentifiers.join(
",").toLatin1 ().data ();
128 bool atLeastOneSelectedItem)
130 m_context->handleKeyPress (key,
131 atLeastOneSelectedItem);
137 m_context->handleMouseMove (posScreen);
143 m_context->handleMousePress (&
context().mainWindow ().scene (),
144 context().mainWindow ().transformation (),
148 hitTestForGraphics (posScreen));
154 m_context->handleMouseRelease (posScreen);
157bool DigitizeStateGuideline::hitTestForGraphics (
const QPointF &posScreen)
160 QGraphicsItem *itemClick =
new QGraphicsRectItem (QRectF (posScreen - QPointF (2, 2),
161 posScreen + QPointF (2, 2)));
168 QList<QGraphicsItem*>::iterator itr;
172 for (itr = items.begin (); itr != items.end (); itr++) {
174 QGraphicsItem *item = *itr;
178 bool isVisible = item->isVisible();
179 bool isCollision = item->collidesWithItem (itemClick);
180 if (isGuideline && isVisible && isCollision) {
193void DigitizeStateGuideline::lockNonGuidelinesAndUnlockGuidelines (
bool lockdown)
198 QList<QGraphicsItem*>::iterator itr;
199 for (itr = items.begin (); itr != items.end (); itr++) {
201 QGraphicsItem *item = *itr;
208 item->setFlag (QGraphicsItem::ItemIsSelectable, !lockdown);
209 item->setFlag (QGraphicsItem::ItemIsMovable, !lockdown);
210 item->setFlag (QGraphicsItem::ItemIsFocusable, !lockdown);
214 item->setFlag (QGraphicsItem::ItemIsSelectable, lockdown);
215 item->setFlag (QGraphicsItem::ItemIsMovable, lockdown);
216 item->setFlag (QGraphicsItem::ItemIsFocusable, lockdown);
217 item->setAcceptHoverEvents (lockdown);
218 item->setVisible (
true);
226 return "DigitizeStateGuideline";
@ DATA_KEY_GRAPHICS_ITEM_TYPE
DigitizeState
Set of possible states of Digitize toolbar.
GraphicsItemType
Runtime type identification (RTTI) for QGraphicsItem objects.
@ GRAPHICS_ITEM_TYPE_GUIDELINE
@ GRAPHICS_ITEM_TYPE_SCALE_BAR
@ GRAPHICS_ITEM_TYPE_SEGMENT
@ GRAPHICS_ITEM_TYPE_LINE
@ GRAPHICS_ITEM_TYPE_POINT
log4cpp::Category * mainCat
State context class for tracking the steps involved in creating centipedes in preparation for creatin...
Wrapper around QUndoCommand. This simplifies the more complicated feature set of QUndoCommand.
Command for adding one X/T Guideline value.
Command for adding one Y/R Guideline value.
DigitizeStateAbstractBase(DigitizeStateContext &context)
Single constructor.
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses,...
void setCursor(CmdMediator *cmdMediator)
Update the cursor according to the current state.
Container for all DigitizeStateAbstractBase subclasses. This functions as the context class in a stan...
void setDragMode(QGraphicsView::DragMode dragMode)
Set QGraphicsView drag mode (in m_view). Called from DigitizeStateAbstractBase subclasses.
void appendNewCmd(CmdMediator *cmdMediator, QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
MainWindow & mainWindow()
Reference to the MainWindow, without const.
virtual void handleMousePress(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse press that was intercepted earlier.
virtual bool canPaste(const Transformation &transformation, const QSize &viewSize) const
Return true if there is good data in the clipboard for pasting, and that is compatible with the curre...
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.
virtual void end()
Method that is called at the exact moment a state is exited. Typically called just before begin for t...
virtual void begin(CmdMediator *cmdMediator, DigitizeState previousState)
Method that is called at the exact moment a state is entered.
virtual QString state() const
State name for debugging.
virtual void handleContextMenuEventAxis(CmdMediator *cmdMediator, const QString &pointIdentifier)
Handle a right click, on an axis point, that was intercepted earlier.
virtual void updateAfterPointAddition()
Update graphics attributes after possible new points. This is useful for highlight opacity.
virtual ~DigitizeStateGuideline()
virtual void updateModelSegments(const DocumentModelSegments &modelSegments)
Update the segments given the new settings.
virtual bool guidelinesAreSelectable() const
Enable/disable guidelines according to state.
virtual void handleMouseRelease(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse release that was intercepted earlier.
void createGuidelineCommand(bool selectedXT, double valueSelected)
Create command to add Guideline for CentipedeStateContext.
virtual QCursor cursor(CmdMediator *cmdMediator) const
Returns the state-specific cursor shape.
virtual void handleMouseMove(CmdMediator *cmdMediator, QPointF posScreen)
Handle a mouse move. This is part of an experiment to see if augmenting the cursor in Point Match mod...
virtual void handleCurveChange(CmdMediator *cmdMediator)
Handle the selection of a new curve. At a minimum, DigitizeStateSegment will generate a new set of Se...
virtual void handleKeyPress(CmdMediator *cmdMediator, Qt::Key key, bool atLeastOneSelectedItem)
Handle a key press that was intercepted earlier.
virtual void handleContextMenuEventGraph(CmdMediator *cmdMediator, const QStringList &pointIdentifiers)
Handle a right click, on a graph point, that was intercepted earlier.
DigitizeStateGuideline(DigitizeStateContext &context)
Single constructor.
virtual void updateModelDigitizeCurve(CmdMediator *cmdMediator, const DocumentModelDigitizeCurve &curve)
Update the digitize curve settings.
Model for DlgSettingsDigitizeCurve and CmdSettingsDigitizeCurve.
Model for DlgSettingsSegments and CmdSettingsSegments.
DocumentModelGuideline modelGuideline() const
Get method for DocumentModelGuideline.
DocumentModelCoords modelCoords() const
Get method for DocumentModelCoords.
QString selectedGraphCurve() const
Curve name that is currently selected in m_cmbCurve.
GraphicsScene & scene()
Scene container for the QImage and QGraphicsItems.
#define LOG4CPP_INFO_S(logger)
#define LOG4CPP_DEBUG_S(logger)