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

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

#include <CentipedePairCartesian.h>

Collaboration diagram for CentipedePairCartesian:
Collaboration graph

Public Member Functions

 CentipedePairCartesian (GraphicsScene &scene, const Transformation &transformation, const DocumentModelGuideline &modelGuideline, const DocumentModelCoords &modelCoords, const QPointF &posScreen)
 Constructor with individual coordinates.
virtual ~CentipedePairCartesian ()
bool done (const QPointF &posScreen)
 True if cursor has moved far enough that the CentipedePairCartesian 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 cartesian 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 cartesian 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 CentipedePairCartesian.h.

Constructor & Destructor Documentation

◆ CentipedePairCartesian()

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

Constructor with individual coordinates.

Definition at line 19 of file CentipedePairCartesian.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 m_centipedeXT = new CentipedeSegmentConstantXLine (scene,
32 modelGuideline,
33 transformation,
34 posScreen);
35 m_centipedeYR = new CentipedeSegmentConstantYLine (scene,
36 modelGuideline,
37 transformation,
38 posScreen);
39
40 // Save starting graph position
41 transformation.transformScreenToRawGraph(posScreen,
42 m_posGraphStart);
43}
void transformScreenToRawGraph(const QPointF &coordScreen, QPointF &coordGraph) const
Transform from cartesian pixel screen coordinates to cartesian/polar graph coordinates.

◆ ~CentipedePairCartesian()

CentipedePairCartesian::~CentipedePairCartesian ( )
virtual

Definition at line 45 of file CentipedePairCartesian.cpp.

46{
47 delete m_centipedeXT;
48 delete m_centipedeYR;
49}

Member Function Documentation

◆ done()

bool CentipedePairCartesian::done ( const QPointF & posScreen)

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

Definition at line 51 of file CentipedePairCartesian.cpp.

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

◆ move()

void CentipedePairCartesian::move ( const QPointF & posScreen)

Follow cursor move.

Definition at line 59 of file CentipedePairCartesian.cpp.

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

◆ selectedXTFinal()

bool CentipedePairCartesian::selectedXTFinal ( ) const

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

Definition at line 73 of file CentipedePairCartesian.cpp.

74{
75 return m_selectedXTFinal;
76}

◆ valueFinal()

double CentipedePairCartesian::valueFinal ( ) const

Final XT or YT (depending on selectedXTFinal) value.

Definition at line 95 of file CentipedePairCartesian.cpp.

96{
97 return m_valueFinal;
98}

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