Engauge Digitizer 2
Loading...
Searching...
No Matches
CentipedePairPolar Class Reference

Show two polar Centipede graphics items that the user interacts with by moving the cursor. More...

#include <CentipedePairPolar.h>

Collaboration diagram for CentipedePairPolar:
Collaboration graph

Public Member Functions

 CentipedePairPolar (GraphicsScene &scene, const Transformation &transformation, const DocumentModelGuideline &modelGuideline, const DocumentModelCoords &modelCoords, const QPointF &posScreen)
 Constructor with individual coordinates.
virtual ~CentipedePairPolar ()
bool done (const QPointF &posScreen)
 True if cursor has moved far enough that the CentipedePairPolar has finished and should be removed.
void move (const QPointF &posScreen)
 Follow cursor move.
bool selectedXTFinal () const
 True if XT is final selection, otherwise false if YR is final selection.
double valueFinal () const
 Final XT or YT (depending on selectedXTFinal) value.

Detailed Description

Show two polar Centipede graphics items that the user interacts with by moving the cursor.

This unique approach was chosen over conventional approaches for the following reasons:

  • Does not require a hard-to-find button to toggle between X/T and Y/R guideline options
  • Does not require two system states, with one state for creating X/T guidelines and another state for creating Y/R guidelines
  • Keeps focus on the screen region where the user clicked
  • Does not require user to click on one of the two guideline options, which the user may not know to do, or the user may accidentally miss the desired guideline when clicking which cause confusion. In some cases trying to click on the narrow desired guideline may even be difficult
  • This solution is conceptually simple "just move the cursor in the direction you want"
  • This solution is fun

Two Centipedes are always shown. Initially they are in the form of two orthogonal line segments (straight for polar and constant-theta polar cases, and curved for constant-radius polar case). Shown below are the notional explanation in the first column (with the Centipede objects keeping constant lengths) and the implemented solution in the second column (with the Centipede objects changing lengths). The implemented solution uses two GraphicsItem subclasses, which is less complicateed than implementing the notional explanation with four graphics items (one for each quadrant).

  Notional Explanation          Implemented Solution
           1                            1
           1                            1
           1                            1
      2 2 2 1 1 1                  2 2 2 2 2 2
           2                            1
           2                            1
           2                            1

As the cursor is moved, the Centipedes crawl the same amount correspondingly. As an example, if the cursor is moved from the center to the right (within -45 to +45 degrees so the +x axis is closest to the cursor) then the Guidelines move as

  Notional Explanation          Implemented Solution
           1                            1
           1                            1
    2 2 2 2 1 1 1 1              2 2 2 2 2 2 2 2
           2                            1
           2                            1

When the Centipede tails disappear the user's direction preference is noted and Centipede dragging ends.

  Notional Explanation          Implemented Solution
2 2 2 2 2 2 1 1 1 1 1 1      2 2 2 2 2 2 2 2 2 2 2 2

[At least one blank comment line is required after the final indented section so it is recognized as a code snippet like the code snippets before it]

Definition at line 64 of file CentipedePairPolar.h.

Constructor & Destructor Documentation

◆ CentipedePairPolar()

CentipedePairPolar::CentipedePairPolar ( GraphicsScene & scene,
const Transformation & transformation,
const DocumentModelGuideline & modelGuideline,
const DocumentModelCoords & modelCoords,
const QPointF & posScreen )

Constructor with individual coordinates.

Definition at line 19 of file CentipedePairPolar.cpp.

23 :
24 m_modelGuideline (modelGuideline),
25 m_centipedeXT (nullptr),
26 m_centipedeYR (nullptr),
27 m_posScreenStart (posScreen),
28 m_selectedXTFinal (true),
29 m_valueFinal (0)
30{
31 // Create visible Centipede items
32 m_centipedeXT = new CentipedeSegmentConstantTRadial (scene,
33 modelCoords,
34 modelGuideline,
35 transformation,
36 posScreen);
37 m_centipedeYR = new CentipedeSegmentConstantREllipse (scene,
38 modelCoords,
39 modelGuideline,
40 transformation,
41 posScreen);
42
43 // Save starting graph position
44 transformation.transformScreenToRawGraph(posScreen,
45 m_posGraphStart);
46}
void transformScreenToRawGraph(const QPointF &coordScreen, QPointF &coordGraph) const
Transform from cartesian pixel screen coordinates to cartesian/polar graph coordinates.

◆ ~CentipedePairPolar()

CentipedePairPolar::~CentipedePairPolar ( )
virtual

Definition at line 48 of file CentipedePairPolar.cpp.

49{
50 delete m_centipedeXT;
51 delete m_centipedeYR;
52}

Member Function Documentation

◆ done()

bool CentipedePairPolar::done ( const QPointF & posScreen)

True if cursor has moved far enough that the CentipedePairPolar has finished and should be removed.

Definition at line 54 of file CentipedePairPolar.cpp.

55{
56 QPointF delta = posScreen - m_posScreenStart;
57 double distanceFromCenter = magnitude (delta);
58
59 return (distanceFromCenter > m_modelGuideline.creationCircleRadius ());
60}
double magnitude(const QPointF &vec)
Norm of vector.
Definition mmsubs.cpp:193

◆ move()

void CentipedePairPolar::move ( const QPointF & posScreen)

Follow cursor move.

Definition at line 62 of file CentipedePairPolar.cpp.

63{
64 QPointF delta = posScreen - m_posScreenStart;
65 double distanceFromCenter = magnitude (delta);
66
67 if (updateFinalValues (posScreen)) {
68 m_centipedeXT->updateRadius (m_modelGuideline.creationCircleRadius () + distanceFromCenter);
69 m_centipedeYR->updateRadius (m_modelGuideline.creationCircleRadius () - distanceFromCenter);
70 } else {
71 m_centipedeXT->updateRadius (m_modelGuideline.creationCircleRadius () - distanceFromCenter);
72 m_centipedeYR->updateRadius (m_modelGuideline.creationCircleRadius () + distanceFromCenter);
73 }
74}

◆ selectedXTFinal()

bool CentipedePairPolar::selectedXTFinal ( ) const

True if XT is final selection, otherwise false if YR is final selection.

Definition at line 76 of file CentipedePairPolar.cpp.

77{
78 return m_selectedXTFinal;
79}

◆ valueFinal()

double CentipedePairPolar::valueFinal ( ) const

Final XT or YT (depending on selectedXTFinal) value.

Definition at line 98 of file CentipedePairPolar.cpp.

99{
100 return m_valueFinal;
101}

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