Skip to content

Commit

Permalink
Toggling cartesian/polar coordinates remove deployed guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
markummitchell-tu committed Oct 6, 2019
1 parent 946031b commit 181a3e4
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 8 deletions.
11 changes: 11 additions & 0 deletions src/Guideline/GuidelineStateDeployedAbstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "GuidelineStateDeployedAbstract.h"
#include "Logger.h"
#include <QPen>
#include "Transformation.h"
#include "ZValues.h"

GuidelineStateDeployedAbstract::GuidelineStateDeployedAbstract (GuidelineStateContext &context) :
Expand Down Expand Up @@ -52,3 +53,13 @@ void GuidelineStateDeployedAbstract::handleMouseRelease (const QPointF & /* posS
{
// Noop
}

CoordsType GuidelineStateDeployedAbstract::lastCoordsType () const
{
return m_lastCoordsType;
}

void GuidelineStateDeployedAbstract::saveLastCoordsType ()
{
m_lastCoordsType = context().transformation().modelCoords().coordsType();
}
12 changes: 12 additions & 0 deletions src/Guideline/GuidelineStateDeployedAbstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#ifndef GUIDELINE_STATE_DEPLOYED_ABSTRACT_H
#define GUIDELINE_STATE_DEPLOYED_ABSTRACT_H

#include "CoordsType.h"
#include "GuidelineFormat.h"
#include "GuidelineStateAbstractBase.h"
#include <QPointF>
Expand All @@ -22,11 +23,22 @@ class GuidelineStateDeployedAbstract : public GuidelineStateAbstractBase
virtual void end ();
virtual void handleMouseRelease (const QPointF &posScene);

/// Coordinates type associated with the last time Transformation matrix was used
CoordsType lastCoordsType () const;

/// Save coordinates type associated with the current Transformation matrix
void saveLastCoordsType ();

protected:

/// Initialization common to all states
void beginCommon (GuidelineFormat::HoverOption hoverOption);

private:

/// Track coordinates type (cartesian or polar) used with last Transformation. If there
/// is a transition than we need to throw all deployed Guidelines
CoordsType m_lastCoordsType;
};

#endif // GUIDELINE_STATE_DEPLOYED_ABSTRACT_H
10 changes: 8 additions & 2 deletions src/Guideline/GuidelineStateDeployedConstantRAbstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
GuidelineStateDeployedConstantRAbstract::GuidelineStateDeployedConstantRAbstract (GuidelineStateContext &context) :
GuidelineStateDeployedAbstract (context)
{
saveLastCoordsType ();
}

GuidelineStateDeployedConstantRAbstract::~GuidelineStateDeployedConstantRAbstract ()
Expand All @@ -41,8 +42,10 @@ void GuidelineStateDeployedConstantRAbstract::updateWithLatestTransformation ()
{
LOG4CPP_INFO_S ((*mainCat)) << "GuidelineStateDeployedConstantRAbstract::updateWithLatestTransformation";

if (!context().transformation().transformIsDefined()) {
// Discard this Guideline immediately if the transformation transitions to undefined
if (!context().transformation().transformIsDefined() ||
context().transformation().modelCoords().coordsType() != lastCoordsType ()) {
// Discard this Guideline immediately since the transformation just transitioned to undefined,
// or cartesian/polar mode has just toggled
context().requestStateTransition(GUIDELINE_STATE_DISCARDED);
} else {

Expand All @@ -52,5 +55,8 @@ void GuidelineStateDeployedConstantRAbstract::updateWithLatestTransformation ()

GuidelineEllipse *ellipse = dynamic_cast<GuidelineEllipse*> (&context().guideline());
ellipse->updateGeometry (posScreen);

}

saveLastCoordsType ();
}
9 changes: 7 additions & 2 deletions src/Guideline/GuidelineStateDeployedConstantTAbstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
GuidelineStateDeployedConstantTAbstract::GuidelineStateDeployedConstantTAbstract (GuidelineStateContext &context) :
GuidelineStateDeployedAbstract (context)
{
saveLastCoordsType ();
}

GuidelineStateDeployedConstantTAbstract::~GuidelineStateDeployedConstantTAbstract ()
Expand All @@ -41,8 +42,10 @@ void GuidelineStateDeployedConstantTAbstract::updateWithLatestTransformation ()
{
LOG4CPP_INFO_S ((*mainCat)) << "GuidelineStateDeployedConstantTAbstract::updateWithLatestTransformation";

if (!context().transformation().transformIsDefined()) {
// Discard this Guideline immediately if the transformation transitions to undefined
if (!context().transformation().transformIsDefined() ||
context().transformation().modelCoords().coordsType() != lastCoordsType ()) {
// Discard this Guideline immediately since the transformation just transitioned to undefined,
// or cartesian/polar mode has just toggled
context().requestStateTransition(GUIDELINE_STATE_DISCARDED);
} else {

Expand All @@ -53,4 +56,6 @@ void GuidelineStateDeployedConstantTAbstract::updateWithLatestTransformation ()
sceneRect (),
context().posCursorGraph().x ()));
}

saveLastCoordsType ();
}
9 changes: 7 additions & 2 deletions src/Guideline/GuidelineStateDeployedConstantXAbstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
GuidelineStateDeployedConstantXAbstract::GuidelineStateDeployedConstantXAbstract (GuidelineStateContext &context) :
GuidelineStateDeployedAbstract (context)
{
saveLastCoordsType ();
}

GuidelineStateDeployedConstantXAbstract::~GuidelineStateDeployedConstantXAbstract ()
Expand All @@ -40,8 +41,10 @@ void GuidelineStateDeployedConstantXAbstract::updateWithLatestTransformation ()
{
LOG4CPP_INFO_S ((*mainCat)) << "GuidelineStateDeployedConstantXAbstract::updateWithLatestTransformation";

if (!context().transformation().transformIsDefined()) {
// Discard this Guideline immediately if the transformation transitions to undefined
if (!context().transformation().transformIsDefined() ||
context().transformation().modelCoords().coordsType() != lastCoordsType ()) {
// Discard this Guideline immediately since the transformation just transitioned to undefined,
// or cartesian/polar mode has just toggled
context().requestStateTransition(GUIDELINE_STATE_DISCARDED);
} else {

Expand All @@ -52,4 +55,6 @@ void GuidelineStateDeployedConstantXAbstract::updateWithLatestTransformation ()
sceneRect (),
context().posCursorGraph ().x()));
}

saveLastCoordsType ();
}
9 changes: 7 additions & 2 deletions src/Guideline/GuidelineStateDeployedConstantYAbstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
GuidelineStateDeployedConstantYAbstract::GuidelineStateDeployedConstantYAbstract (GuidelineStateContext &context) :
GuidelineStateDeployedAbstract (context)
{
saveLastCoordsType ();
}

GuidelineStateDeployedConstantYAbstract::~GuidelineStateDeployedConstantYAbstract ()
Expand All @@ -40,8 +41,10 @@ void GuidelineStateDeployedConstantYAbstract::updateWithLatestTransformation ()
{
LOG4CPP_INFO_S ((*mainCat)) << "GuidelineStateDeployedConstantYAbstract::updateWithLatestTransformation";

if (!context().transformation().transformIsDefined()) {
// Discard this Guideline immediately if the transformation transitions to undefined
if (!context().transformation().transformIsDefined() ||
context().transformation().modelCoords().coordsType() != lastCoordsType ()) {
// Discard this Guideline immediately since the transformation just transitioned to undefined,
// or cartesian/polar mode has just toggled
context().requestStateTransition(GUIDELINE_STATE_DISCARDED);
} else {

Expand All @@ -52,4 +55,6 @@ void GuidelineStateDeployedConstantYAbstract::updateWithLatestTransformation ()
sceneRect (),
context().posCursorGraph ().y()));
}

saveLastCoordsType ();
}

0 comments on commit 181a3e4

Please sign in to comment.