Engauge Digitizer 2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
DigitizeStateColorPicker Class Reference

Digitizing state for selecting a color for DigitizeStateSegment. More...

#include <DigitizeStateColorPicker.h>

Inheritance diagram for DigitizeStateColorPicker:
Inheritance graph
Collaboration diagram for DigitizeStateColorPicker:
Collaboration graph

Public Member Functions

 DigitizeStateColorPicker (DigitizeStateContext &context)
 Single constructor.
 
virtual ~DigitizeStateColorPicker ()
 
virtual QString activeCurve () const
 Name of the active Curve. This can include AXIS_CURVE_NAME.
 
virtual void begin (CmdMediator *cmdMediator, DigitizeState previousState)
 Method that is called at the exact moment a state is entered.
 
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 current state.
 
virtual QCursor cursor (CmdMediator *cmdMediator) const
 Returns the state-specific cursor shape.
 
virtual void end ()
 Method that is called at the exact moment a state is exited. Typically called just before begin for the next state.
 
virtual void handleContextMenuEventAxis (CmdMediator *cmdMediator, const QString &pointIdentifier)
 Handle a right click, on an axis point, that was intercepted earlier.
 
virtual void handleContextMenuEventGraph (CmdMediator *cmdMediator, const QStringList &pointIdentifiers)
 Handle a right click, on a graph point, that was intercepted earlier.
 
virtual void handleCurveChange (CmdMediator *cmdMediator)
 Handle the selection of a new curve. At a minimum, DigitizeStateSegment will generate a new set of Segments.
 
virtual void handleKeyPress (CmdMediator *cmdMediator, Qt::Key key, bool atLeastOneSelectedItem)
 Handle a key press that was intercepted earlier.
 
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 mode is worthwhile.
 
virtual void handleMousePress (CmdMediator *cmdMediator, QPointF posScreen)
 Handle a mouse press that was intercepted earlier.
 
virtual void handleMouseRelease (CmdMediator *cmdMediator, QPointF posScreen)
 Handle a mouse release that was intercepted earlier.
 
virtual QString state () const
 State name for debugging.
 
virtual void updateAfterPointAddition ()
 Update graphics attributes after possible new points. This is useful for highlight opacity.
 
virtual void updateModelDigitizeCurve (CmdMediator *cmdMediator, const DocumentModelDigitizeCurve &modelDigitizeCurve)
 Update the digitize curve settings.
 
virtual void updateModelSegments (const DocumentModelSegments &modelSegments)
 Update the segments given the new settings.
 
- Public Member Functions inherited from DigitizeStateAbstractBase
 DigitizeStateAbstractBase (DigitizeStateContext &context)
 Single constructor.
 
virtual ~DigitizeStateAbstractBase ()
 
DigitizeStateContextcontext ()
 Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses, without const.
 
const DigitizeStateContextcontext () const
 Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses, without const.
 
void setCursor (CmdMediator *cmdMediator)
 Update the cursor according to the current state.
 

Additional Inherited Members

- Protected Member Functions inherited from DigitizeStateAbstractBase
bool canPasteProtected (const Transformation &transformation, const QSize &viewSize) const
 Protected version of canPaste method. Some, but not all, leaf classes use this method.
 

Detailed Description

Digitizing state for selecting a color for DigitizeStateSegment.

The basic strategy is that this class acts like a special case of DlgSettingsFilter. Specifically, the pixel just selected by a mouse click is used to change the segment filter for the currently specified curve

Definition at line 21 of file DigitizeStateColorPicker.h.

Constructor & Destructor Documentation

◆ DigitizeStateColorPicker()

DigitizeStateColorPicker::DigitizeStateColorPicker ( DigitizeStateContext & context)

Single constructor.

Definition at line 24 of file DigitizeStateColorPicker.cpp.

24 :
26{
27}
Base class for all digitizing states. This serves as an interface to DigitizeStateContext.
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses,...

◆ ~DigitizeStateColorPicker()

DigitizeStateColorPicker::~DigitizeStateColorPicker ( )
virtual

Definition at line 29 of file DigitizeStateColorPicker.cpp.

30{
31}

Member Function Documentation

◆ activeCurve()

QString DigitizeStateColorPicker::activeCurve ( ) const
virtual

Name of the active Curve. This can include AXIS_CURVE_NAME.

Implements DigitizeStateAbstractBase.

Definition at line 33 of file DigitizeStateColorPicker.cpp.

34{
36}
MainWindow & mainWindow()
Reference to the MainWindow, without const.
QString selectedGraphCurve() const
Curve name that is currently selected in m_cmbCurve.

◆ begin()

void DigitizeStateColorPicker::begin ( CmdMediator * cmdMediator,
DigitizeState previousState )
virtual

Method that is called at the exact moment a state is entered.

Typically called just after end for the previous state. The previousState value is used by DigitizeStateColorPicker to return to the previous state

Implements DigitizeStateAbstractBase.

Definition at line 38 of file DigitizeStateColorPicker.cpp.

40{
41 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateColorPicker::begin";
42
43 setCursor(cmdMediator);
44 context().setDragMode(QGraphicsView::NoDrag);
45
46 // Save current state stuff so it can be restored afterwards
47 m_previousDigitizeState = previousState;
48 m_previousBackground = context().mainWindow().selectOriginal(BACKGROUND_IMAGE_ORIGINAL); // Only makes sense to have original image with all its colors
49
51}
@ BACKGROUND_IMAGE_ORIGINAL
const int INNER_RADIUS_MIN
log4cpp::Category * mainCat
Definition Logger.cpp:14
void setCursor(CmdMediator *cmdMediator)
Update the cursor according to the current state.
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.
void setDragMode(QGraphicsView::DragMode dragMode)
Set QGraphicsView drag mode (in m_view). Called from DigitizeStateAbstractBase subclasses.
BackgroundImage selectOriginal(BackgroundImage backgroundImage)
Make original background visible, for DigitizeStateColorPicker.
void updateViewsOfSettings(const QString &activeCurve)
Update curve-specific view of settings. Private version gets active curve name from DigitizeStateCont...
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ canPaste()

bool DigitizeStateColorPicker::canPaste ( const Transformation & transformation,
const QSize & viewSize ) const
virtual

Return true if there is good data in the clipboard for pasting, and that is compatible with the current state.

Implements DigitizeStateAbstractBase.

Definition at line 53 of file DigitizeStateColorPicker.cpp.

55{
56 return false;
57}

◆ cursor()

QCursor DigitizeStateColorPicker::cursor ( CmdMediator * cmdMediator) const
virtual

Returns the state-specific cursor shape.

Implements DigitizeStateAbstractBase.

Definition at line 160 of file DigitizeStateColorPicker.cpp.

161{
162 // Hot point is at the point of the eye dropper
163 const int HOT_X_IN_BITMAP = 8;
164 const int HOT_Y_IN_BITMAP = 24;
165 LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateColorPicker::cursor";
166
167 QBitmap bitmap (":/engauge/img/cursor_eyedropper.xpm");
168 QBitmap bitmapMask (":/engauge/img/cursor_eyedropper_mask.xpm");
169 return QCursor (bitmap,
173}
#define LOG4CPP_DEBUG_S(logger)
Definition convenience.h:20

◆ end()

void DigitizeStateColorPicker::end ( )
virtual

Method that is called at the exact moment a state is exited. Typically called just before begin for the next state.

Implements DigitizeStateAbstractBase.

Definition at line 175 of file DigitizeStateColorPicker.cpp.

176{
177 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateColorPicker::end";
178
179 // Restore original background. The state transition was triggered earlier by either the user selecting
180 // a valid point, or by user clicking on another digitize state button
181 context().mainWindow().selectOriginal(m_previousBackground);
182}

◆ handleContextMenuEventAxis()

void DigitizeStateColorPicker::handleContextMenuEventAxis ( CmdMediator * cmdMediator,
const QString & pointIdentifier )
virtual

Handle a right click, on an axis point, that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 230 of file DigitizeStateColorPicker.cpp.

232{
233 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateColorPicker::handleContextMenuEventAxis "
234 << " point=" << pointIdentifier.toLatin1 ().data ();
235}

◆ handleContextMenuEventGraph()

void DigitizeStateColorPicker::handleContextMenuEventGraph ( CmdMediator * cmdMediator,
const QStringList & pointIdentifiers )
virtual

Handle a right click, on a graph point, that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 237 of file DigitizeStateColorPicker.cpp.

239{
240 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateColorPicker ::handleContextMenuEventGraph "
241 << "points=" << pointIdentifiers.join(",").toLatin1 ().data ();
242}

◆ handleCurveChange()

void DigitizeStateColorPicker::handleCurveChange ( CmdMediator * cmdMediator)
virtual

Handle the selection of a new curve. At a minimum, DigitizeStateSegment will generate a new set of Segments.

Implements DigitizeStateAbstractBase.

Definition at line 244 of file DigitizeStateColorPicker.cpp.

245{
246 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateColorPicker::handleCurveChange";
247}

◆ handleKeyPress()

void DigitizeStateColorPicker::handleKeyPress ( CmdMediator * cmdMediator,
Qt::Key key,
bool atLeastOneSelectedItem )
virtual

Handle a key press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 249 of file DigitizeStateColorPicker.cpp.

252{
253 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateColorPicker::handleKeyPress"
254 << " key=" << QKeySequence (key).toString ().toLatin1 ().data ();
255}

◆ handleMouseMove()

void DigitizeStateColorPicker::handleMouseMove ( CmdMediator * cmdMediator,
QPointF posScreen )
virtual

Handle a mouse move. This is part of an experiment to see if augmenting the cursor in Point Match mode is worthwhile.

Implements DigitizeStateAbstractBase.

Definition at line 257 of file DigitizeStateColorPicker.cpp.

259{
260// LOG4CPP_DEBUG_S ((*mainCat)) << "DigitizeStateColorPicker::handleMouseMove";
261}

◆ handleMousePress()

void DigitizeStateColorPicker::handleMousePress ( CmdMediator * cmdMediator,
QPointF pos )
virtual

Handle a mouse press that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 263 of file DigitizeStateColorPicker.cpp.

265{
266 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateColorPicker::handleMousePress";
267}

◆ handleMouseRelease()

void DigitizeStateColorPicker::handleMouseRelease ( CmdMediator * cmdMediator,
QPointF pos )
virtual

Handle a mouse release that was intercepted earlier.

Implements DigitizeStateAbstractBase.

Definition at line 269 of file DigitizeStateColorPicker.cpp.

271{
272 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateColorPicker::handleMouseRelease";
273
276 if (computeFilterFromPixel (cmdMediator,
277 posScreen,
278 context().mainWindow().selectedGraphCurve(),
280
281 // Trigger a state transition. The background restoration will be handled by the end method
282 context().requestDelayedStateTransition(m_previousDigitizeState);
283
284 // Create command to change segment filter
285 QUndoCommand *cmd = new CmdSettingsColorFilter (context ().mainWindow(),
286 cmdMediator->document (),
289 context().appendNewCmd(cmdMediator,
290 cmd);
291 }
292}
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
Command for DlgSettingsColorFilter.
void appendNewCmd(CmdMediator *cmdMediator, QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
void requestDelayedStateTransition(DigitizeState digitizeState)
Initiate state transition to be performed later, when DigitizeState is off the stack.
Model for DlgSettingsColorFilter and CmdSettingsColorFilter.
DocumentModelColorFilter modelColorFilter() const
Get method for DocumentModelColorFilter.
Definition Document.cpp:688

◆ state()

QString DigitizeStateColorPicker::state ( ) const
virtual

State name for debugging.

Implements DigitizeStateAbstractBase.

Definition at line 343 of file DigitizeStateColorPicker.cpp.

344{
345 return "DigitizeStateColorPicker";
346}

◆ updateAfterPointAddition()

void DigitizeStateColorPicker::updateAfterPointAddition ( )
virtual

Update graphics attributes after possible new points. This is useful for highlight opacity.

Implements DigitizeStateAbstractBase.

Definition at line 348 of file DigitizeStateColorPicker.cpp.

349{
350 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateColorPicker::updateAfterPointAddition";
351}

◆ updateModelDigitizeCurve()

void DigitizeStateColorPicker::updateModelDigitizeCurve ( CmdMediator * cmdMediator,
const DocumentModelDigitizeCurve & modelDigitizeCurve )
virtual

Update the digitize curve settings.

Implements DigitizeStateAbstractBase.

Definition at line 353 of file DigitizeStateColorPicker.cpp.

355{
356 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateColorPicker::updateModelDigitizeCurve";
357}

◆ updateModelSegments()

void DigitizeStateColorPicker::updateModelSegments ( const DocumentModelSegments & modelSegments)
virtual

Update the segments given the new settings.

Implements DigitizeStateAbstractBase.

Definition at line 359 of file DigitizeStateColorPicker.cpp.

360{
361 LOG4CPP_INFO_S ((*mainCat)) << "DigitizeStateColorPicker::updateModelSegments";
362}

The documentation for this class was generated from the following files: