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

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. More...
 

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 ( 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.
DigitizeStateColorPicker::~DigitizeStateColorPicker ( )
virtual

Definition at line 29 of file DigitizeStateColorPicker.cpp.

30 {
31 }

Member Function Documentation

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 }
QString selectedGraphCurve() const
Curve name that is currently selected in m_cmbCurve.
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses...
MainWindow & mainWindow()
Reference to the MainWindow, without const.
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 }
void setDragMode(QGraphicsView::DragMode dragMode)
Set QGraphicsView drag mode (in m_view). Called from DigitizeStateAbstractBase subclasses.
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
virtual QString activeCurve() const
Name of the active Curve. This can include AXIS_CURVE_NAME.
BackgroundImage selectOriginal(BackgroundImage backgroundImage)
Make original background visible, for DigitizeStateColorPicker.
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses...
MainWindow & mainWindow()
Reference to the MainWindow, without const.
void setCursor(CmdMediator *cmdMediator)
Update the cursor according to the current state.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
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 }
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,
170  bitmapMask,
171  HOT_X_IN_BITMAP,
172  HOT_Y_IN_BITMAP);
173 }
log4cpp::Category * mainCat
Definition: Logger.cpp:14
#define LOG4CPP_DEBUG_S(logger)
Definition: convenience.h:20
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 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
BackgroundImage selectOriginal(BackgroundImage backgroundImage)
Make original background visible, for DigitizeStateColorPicker.
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses...
MainWindow & mainWindow()
Reference to the MainWindow, without const.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
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 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14
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 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14
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 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14
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 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14
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 }
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 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14
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 
274  DocumentModelColorFilter modelColorFilterBefore = cmdMediator->document().modelColorFilter();
275  DocumentModelColorFilter modelColorFilterAfter = cmdMediator->document().modelColorFilter();
276  if (computeFilterFromPixel (cmdMediator,
277  posScreen,
278  context().mainWindow().selectedGraphCurve(),
279  modelColorFilterAfter)) {
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 (),
287  modelColorFilterBefore,
288  modelColorFilterAfter);
289  context().appendNewCmd(cmdMediator,
290  cmd);
291  }
292 }
void requestDelayedStateTransition(DigitizeState digitizeState)
Initiate state transition to be performed later, when DigitizeState is off the stack.
DocumentModelColorFilter modelColorFilter() const
Get method for DocumentModelColorFilter.
Definition: Document.cpp:688
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
Document & document()
Provide the Document to commands, primarily for undo/redo processing.
Definition: CmdMediator.cpp:72
DigitizeStateContext & context()
Reference to the DigitizeStateContext that contains all the DigitizeStateAbstractBase subclasses...
Model for DlgSettingsColorFilter and CmdSettingsColorFilter.
void appendNewCmd(CmdMediator *cmdMediator, QUndoCommand *cmd)
Append just-created QUndoCommand to command stack. This is called from DigitizeStateAbstractBase subc...
Command for DlgSettingsColorFilter.
log4cpp::Category * mainCat
Definition: Logger.cpp:14
QString DigitizeStateColorPicker::state ( ) const
virtual

State name for debugging.

Implements DigitizeStateAbstractBase.

Definition at line 343 of file DigitizeStateColorPicker.cpp.

344 {
345  return "DigitizeStateColorPicker";
346 }
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 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14
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 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14
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 }
#define LOG4CPP_INFO_S(logger)
Definition: convenience.h:18
log4cpp::Category * mainCat
Definition: Logger.cpp:14

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