1#ifndef QEPREFOCALSTATION_HPP
2#define QEPREFOCALSTATION_HPP
7#include <QtUiPlugin/QDesignerExportWidget>
13#include <QtSvg/QSvgRenderer>
15#include <QXmlStreamReader>
16#include <elt/cut/widgets/widgets/QeRadialItemPlot.hpp>
18#define _USE_MATH_DEFINES
158 enum ElementName { A, B, C };
167 Q_ENUM(Configuration);
174 Q_ENUM(PositionCheck);
185 explicit QePreFocalStation(QWidget *parent = Q_NULLPTR);
186 virtual ~QePreFocalStation();
469 if (m_currentConfiguration ==
static_cast<Configuration
>(configuration))
472 m_currentConfiguration =
static_cast<Configuration
>(configuration);
474 this->m_warningZoneRadius = this->warningRadiuses[m_currentConfiguration];
479 void setPrioritySBInt(
int priority_index){
480 switch(priority_index){
482 this->m_prioritySB = ElementName::A;
485 this->m_prioritySB = ElementName::B;
488 this->m_prioritySB = ElementName::C;
495 emit prioritySBChanged(this->m_prioritySB);
504 void setA1B1ScienceFieldRadius (
double newValue);
510 void setBetaWarningAngle (
double newValue);
516 void setPfsRadius(
double newValue);
522 void setPrioritySB(ElementName newValue);
529 this->m_reverse = doReverse;
530 this->m_backgroundUpdateNeeded =
true;
542 void setCurrentSAAzA (
double newValue);
548 void setCurrentSARadialA (
double newValue);
554 void setTargetSAAzA(
double newValue);
560 void setTargetSARadialA(
double newValue);
570 void setCurrentSAAzB (
double newValue);
576 void setCurrentSARadialB (
double newValue);
582 void setTargetSAAzB(
double newValue);
588 void setTargetSARadialB(
double newValue);
598 void setCurrentSAAzC (
double newValue);
604 void setCurrentSARadialC (
double newValue);
610 void setTargetSAAzC(
double newValue);
616 void setTargetSARadialC(
double newValue);
625 void paintEvent(QPaintEvent *event)
override;
643 void paintSA(QPainter *painter, QPointF *positionPoint,
double azimuth,
double radial, Role roleName, ElementName sbName);
654 void updateSBColorAndText(Role roleName, QColor elementColor, QPen ¤tPen, QString &sbName);
661 QColor calculateColor(QColor baseColor, Role roleName);
671 PositionCheck checkForCollisions(ElementName elementName);
678 void drawM6ArmShadow(QPainter *painter, Configuration config);
683 QString elementLabel;
684 QColor elementCurrentColor;
687 QColor m_basicColor_A = QColor(
"#009DFF");
688 QColor m_basicColor_B = QColor(
"#45fddc");
689 QColor m_basicColor_C = QColor(
"#6A5ACD");
690 QColor m_warningColor = QColor(
"magenta");
691 QColor m_shadowColor = QColor(104, 101, 101, 50);
692 QColor m_technicalFieldColor = QColor(219, 217, 209, 50);
693 QColor m_scienceFieldColor = QColor(255, 187, 0, 100);
694 QColor m_tooCloseColor = QColor(
"orange");
695 QColor m_collisionColor = QColor(
"red");
696 QString m_sbTextCurrent =
"black";
697 QString m_sbTextTarget =
"#515151";
699 QMap<ElementName, ElementInfo> elements = {
700 {ElementName::A, {
"A", m_basicColor_A}},
701 {ElementName::B, {
"B", m_basicColor_B}},
702 {ElementName::C, {
"C", m_basicColor_C}},
706 double m_currentSAAz_A = 0.0;
707 double m_currentSARadial_A = 0.0;
708 double m_targetSAAz_A = 0.0;
709 double m_targetSARadial_A = 0.0;
712 double m_currentSAAz_B = 0.0;
713 double m_currentSARadial_B = 0.0;
714 double m_targetSAAz_B = 0.0;
715 double m_targetSARadial_B = 0.0;
718 double m_currentSAAz_C = 0.0;
719 double m_currentSARadial_C = 0.0;
720 double m_targetSAAz_C = 0.0;
721 double m_targetSARadial_C = 0.0;
723 bool m_backgroundUpdateNeeded =
true;
728 double m_arm_scale = 0.0;
732 QPointF m_currentBoxPos_A = QPointF(0.0, 0.0);
733 QPointF m_currentBoxPos_B = QPointF(0.0, 0.0);
734 QPointF m_currentBoxPos_C = QPointF(0.0, 0.0);
736 QPointF m_targetBoxPos_A = QPointF(0.0, 0.0);
737 QPointF m_targetBoxPos_B = QPointF(0.0, 0.0);
738 QPointF m_targetBoxPos_C = QPointF(0.0, 0.0);
741 const QString c_sensorBoxImagePath =
":/sensor_box.svg";
742 QString m_originalXml;
743 QString m_modifiedXml;
746 double m_pfsRadius = 995.0;
747 double m_scienceFieldRadius = 397.0;
748 double m_technicalFieldRadius;
751 double m_a1b1ScienceFieldRadius = 497.0;
753 double m_m6cMirrorShadeRadius = 487;
755 double m_m6nMirrorShadeRadius = 746;
759 double m_warningZoneRadius = m_scienceFieldRadius;
765 Configuration m_currentConfiguration = Configuration::None;
770 QMap<Configuration, double> warningRadiuses = {
771 {Configuration::None, m_scienceFieldRadius},
772 {Configuration::A1B1, m_a1b1ScienceFieldRadius},
773 {Configuration::Coude, m_m6cMirrorShadeRadius},
774 {Configuration::A3B3, m_m6nMirrorShadeRadius},
780 double m_collisionAngle = 50.0 * (M_PI/180);
781 double m_betaWarningAngle = 10.0 * (M_PI/180);
783 ElementName m_prioritySB;
785 bool m_reverse =
true;
void a1b1ScienceFieldRadiusChanged(double newValue)
Indicates that A1/B1 Science Field Radius has changed.
double getA1B1ScienceFieldRadius()
Gets the A1/B1 Science Field Radius.
Definition QePreFocalStation.hpp:198
void currentSARadialChangedC(double newValue)
Indicates that the current radial value has changed.
void targetSARadialChangedA(double newValue)
Indicates that the target radial value has changed.
void currentSARadialChangedA(double newValue)
Indicates that the current radial value has changed.
void setCurrentConfiguration(Configuration newConfiguration)
Sets the value of the current configuration property.
Definition QePreFocalStation.cpp:45
void setTargetSARadialA(double newValue)
Sets the value of the target radial coordinate of SA A.
Definition QePreFocalStation.cpp:105
void currentSAAzChangedC(double newValue)
Indicates that the current azimuth value has changed.
QPointF getTargetBoxPosA()
Gets target position of the Sensor Box A (for testing purposes)
Definition QePreFocalStation.hpp:256
double a1b1ScienceFieldRadius
Science field radius in A1/B1 configuration.
Definition QePreFocalStation.hpp:47
double getCurrentSAAzB()
Gets the value of the current azimuth the SA B has.
Definition QePreFocalStation.hpp:266
double betaWarningAngle
Beta angle which creates a warning zone to signalize 2 SAs are too close each other.
Definition QePreFocalStation.hpp:54
void setA1B1ScienceFieldRadius(double newValue)
Sets the value of the A1/B1 Science Field Radius property.
Definition QePreFocalStation.cpp:53
double pfsRadius
Radius of the PFS plane.
Definition QePreFocalStation.hpp:60
double targetSARadial_B
Y coordinate of Sensor Arm B target position.
Definition QePreFocalStation.hpp:120
void setPfsRadius(double newValue)
Sets the value of PFS radius.
Definition QePreFocalStation.cpp:70
double getPfsRadius()
Gets the of PFS plane.
Definition QePreFocalStation.hpp:210
double currentSARadial_A
Radial coordinate of the current position in radians.
Definition QePreFocalStation.hpp:81
void currentConfigurationChanged(Configuration newConfiguration)
Indicates that the current configuration has changed.
void targetSARadialChangedC(double newValue)
Indicates that the target radial value has changed.
double getTargetSARadialB()
Gets the value of the target radial coordinate the SA B has.
Definition QePreFocalStation.hpp:284
double getTargetSARadialC()
Gets the value of the target radial coordinate the SA C has.
Definition QePreFocalStation.hpp:324
Configuration currentConfiguration
Current configuration of the PFS.
Definition QePreFocalStation.hpp:42
double getCurrentSARadialA()
Gets the value of the current radial coordinate the SA A has.
Definition QePreFocalStation.hpp:232
Configuration getCurrentConfiguration()
Gets the current configuration of the Pre FocalStation.
Definition QePreFocalStation.hpp:192
double getCurrentSAAzA()
Gets the value of the current azimuth coordinate the SA A has.
Definition QePreFocalStation.hpp:226
double getCurrentSARadialC()
Gets the value of the current radial coordinate the SA C has.
Definition QePreFocalStation.hpp:312
void setTargetSARadialB(double newValue)
Sets the value of the target radial coordinate of SA B.
Definition QePreFocalStation.cpp:129
double currentSAAz_C
Azimuth coordinate of the current position in radians.
Definition QePreFocalStation.hpp:129
double targetSAAz_A
Azimuth coordinate of the target position in radians.
Definition QePreFocalStation.hpp:87
double getCurrentSARadialB()
Gets the value of the current radial coordinate the SA B has.
Definition QePreFocalStation.hpp:272
void setTargetSAAzC(double newValue)
Sets the value of the target azimuth property.
Definition QePreFocalStation.cpp:147
void pfsRadiusChanged(double newValue)
Indicates that PFS radius has changed.
void targetSARadialChangedB(double newValue)
Indicates that the target radial value has changed.
void setBetaWarningAngle(double newValue)
Sets the value of the beta warning angle property.
Definition QePreFocalStation.cpp:61
QPointF getCurrentBoxPosC()
Gets the position of the Sensor Box C (for testing purposes)
Definition QePreFocalStation.hpp:330
void setCurrentSARadialB(double newValue)
Sets the value of the current radial coordinate of SA B.
Definition QePreFocalStation.cpp:117
QPointF getTargetBoxPosC()
Gets target position of the Sensor Box C (for testing purposes)
Definition QePreFocalStation.hpp:336
double getTargetSARadialA()
Gets the value of the target radial coordinate the SA A has.
Definition QePreFocalStation.hpp:244
double currentSARadial_C
Azimuth coordinate of the current position in radians.
Definition QePreFocalStation.hpp:135
void betaWarningAngleChanged(double newValue)
Indicates that warning angle has changed.
double targetSAAz_C
X coordinate of Sensor Arm C target position.
Definition QePreFocalStation.hpp:141
ElementName getPrioritySB()
Gets the priority SB name.
Definition QePreFocalStation.hpp:216
double getTargetSAAzA()
Gets the value of the target azimuth the SA A has.
Definition QePreFocalStation.hpp:238
void changePFSSide(bool doReverse)
Helper method to change the PFS widget view to PFS A or PFS B.
Definition QePreFocalStation.hpp:528
double targetSARadial_C
Y coordinate of Sensor Arm C target position.
Definition QePreFocalStation.hpp:147
void setCurrentSAAzB(double newValue)
Sets the value of the current azimuth property.
Definition QePreFocalStation.cpp:111
double currentSARadial_B
Azimuth coordinate of the current position in radians.
Definition QePreFocalStation.hpp:108
void targetSAAzChangedA(double newValue)
Indicates that the target azimuth value has changed.
void setCurrentSAAzA(double newValue)
Sets the value of the current azimuth property.
Definition QePreFocalStation.cpp:87
void prioritySBChanged(ElementName newValue)
Indicates that priority SB has changed.
void currentSARadialChangedB(double newValue)
Indicates that the current radial value has changed.
void setCurrentSAAzC(double newValue)
Sets the value of the current azimuth property.
Definition QePreFocalStation.cpp:135
double getCurrentSAAzC()
Gets the value of the current azimuth the SA C has.
Definition QePreFocalStation.hpp:306
void setCurrentSARadialA(double newValue)
Sets the value of the current radial coordinate of SA A.
Definition QePreFocalStation.cpp:93
void setTargetSAAzA(double newValue)
Sets the value of the target azimuth property.
Definition QePreFocalStation.cpp:99
void currentSAAzChangedA(double newValue)
Indicates that the current azimuth value has changed.
double currentSAAz_B
Azimuth coordinate of the current position in radians.
Definition QePreFocalStation.hpp:102
QePreFocalStation(QWidget *parent=Q_NULLPTR)
Constructor that is used to set a parent relationship with.
Definition QePreFocalStation.cpp:14
double targetSARadial_A
Radial coordinate of the target position in radians.
Definition QePreFocalStation.hpp:93
void currentSAAzChangedB(double newValue)
Indicates that the current azimuth value has changed.
void targetSAAzChangedC(double newValue)
Indicates that the target azimuth value has changed.
double getTargetSAAzC()
Gets the value of the target azimuth the SA C has.
Definition QePreFocalStation.hpp:318
double getTargetSAAzB()
Gets the value of the target azimuth the SA B has.
Definition QePreFocalStation.hpp:278
void setTargetSAAzB(double newValue)
Sets the value of the target azimuth property.
Definition QePreFocalStation.cpp:123
QPointF getCurrentBoxPosA()
Gets the position of the Sensor Box A (for testing purposes)
Definition QePreFocalStation.hpp:250
void setCurrentConfigurationInt(int configuration)
Convinience method to allow setting PFS configuration using its integer representation.
Definition QePreFocalStation.hpp:468
double currentSAAz_A
Azimuth coordinate of the current position in radians.
Definition QePreFocalStation.hpp:75
void setPrioritySB(ElementName newValue)
Sets the priority Sensor Box.
Definition QePreFocalStation.cpp:81
double getBetaWarningAngle()
Gets the beta angle used to define warning zone.
Definition QePreFocalStation.hpp:204
QPointF getCurrentBoxPosB()
Gets the position of the Sensor Box B (for testing purposes)
Definition QePreFocalStation.hpp:290
void setCurrentSARadialC(double newValue)
Sets the value of the current radial coordinate of SA C.
Definition QePreFocalStation.cpp:141
QPointF getTargetBoxPosB()
Gets target position of the Sensor Box B (for testing purposes)
Definition QePreFocalStation.hpp:296
double targetSAAz_B
X coordinate of Sensor Arm B target position.
Definition QePreFocalStation.hpp:114
void targetSAAzChangedB(double newValue)
Indicates that the target azimuth value has changed.
void setTargetSARadialC(double newValue)
Sets the value of the current radial coordinate of SA C.
Definition QePreFocalStation.cpp:153
ElementName prioritySB
The Sensor Box that has a priority over other SBs.
Definition QePreFocalStation.hpp:66
virtual void paintDartBoard(QPainter *painter)
Uses a QPainter to draw the dartboard (mostly static) background.
Definition QeRadialItemPlot.hpp:67
void updateBackground()
Updates the m_backgroundUpdateNeeded internal flag to signal a significant change was detect,...
Definition QeRadialItemPlot.cpp:171
QeRadialItemPlot(QWidget *parent=Q_NULLPTR)
Constructor that is used to set a parent relationship with.
Definition QeRadialItemPlot.cpp:13