cut 3.3.0
Loading...
Searching...
No Matches
QePreFocalStation.hpp
1#ifndef QEPREFOCALSTATION_HPP
2#define QEPREFOCALSTATION_HPP
3
4#include <QObject>
5#include <QString>
6#include <QWidget>
7#include <QtUiPlugin/QDesignerExportWidget>
8
9#include <qpalette.h>
10#include <qcolor.h>
11#include <qpainter.h>
12#include <QtSvg/QtSvg>
13#include <QtSvg/QSvgRenderer>
14#include <QColor>
15#include <QXmlStreamReader>
16#include <elt/cut/widgets/widgets/QeRadialItemPlot.hpp>
17
18#define _USE_MATH_DEFINES
19#include <cmath>
20#include <iostream>
21#include <QColor>
22#include <map>
23
35class QDESIGNER_WIDGET_EXPORT QePreFocalStation : public QeRadialItemPlot {
36 Q_OBJECT
37
48
55
60 Q_PROPERTY(double pfsRadius READ getPfsRadius WRITE setPfsRadius NOTIFY pfsRadiusChanged)
61
66 Q_PROPERTY(ElementName prioritySB READ getPrioritySB WRITE setPrioritySB NOTIFY prioritySBChanged)
67
68 /**************************************|
69 | SENSOR ARM A |
70 |**************************************/
76
82
87 Q_PROPERTY(double targetSAAz_A READ getTargetSAAzA WRITE setTargetSAAzA NOTIFY targetSAAzChangedA )
88
94
95 /**************************************|
96 | SENSOR ARM B |
97 |**************************************/
103
109
114 Q_PROPERTY(double targetSAAz_B READ getTargetSAAzB WRITE setTargetSAAzB NOTIFY targetSAAzChangedB )
115
121
122 /**************************************|
123 | SENSOR ARM C |
124 |**************************************/
130
136
141 Q_PROPERTY(double targetSAAz_C READ getTargetSAAzC WRITE setTargetSAAzC NOTIFY targetSAAzChangedC )
142
148
149
150public:
151
152 enum Role {
153 CURRENT,
154 TARGET
155 };
156 Q_ENUM(Role);
157
158 enum ElementName { A, B, C };
159 Q_ENUM(ElementName);
160
161 enum Configuration {
162 None,
163 A1B1,
164 Coude,
165 A3B3
166 };
167 Q_ENUM(Configuration);
168
169 enum PositionCheck {
170 OK,
171 TOOCLOSE,
172 COLLSION
173 };
174 Q_ENUM(PositionCheck);
175
176 enum PFSSetup {
177 PFS_A,
178 PFS_B
179 };
180
185 explicit QePreFocalStation(QWidget *parent = Q_NULLPTR);
186 virtual ~QePreFocalStation();
187
192 Configuration getCurrentConfiguration(){ return m_currentConfiguration; }
193
198 double getA1B1ScienceFieldRadius(){ return m_a1b1ScienceFieldRadius; }
199
204 double getBetaWarningAngle(){ return m_betaWarningAngle; }
205
210 double getPfsRadius() { return m_pfsRadius; }
211
216 ElementName getPrioritySB() { return m_prioritySB; }
217
218 /**************************************|
219 | SENSOR ARM A |
220 |**************************************/
221
226 double getCurrentSAAzA(){ return m_currentSAAz_A; }
227
232 double getCurrentSARadialA(){ return m_currentSARadial_A; }
233
238 double getTargetSAAzA(){ return m_targetSAAz_A; }
239
244 double getTargetSARadialA(){ return m_targetSARadial_A; }
245
250 QPointF getCurrentBoxPosA(){ return m_currentBoxPos_A; }
251
256 QPointF getTargetBoxPosA(){ return m_targetBoxPos_A; }
257
258 /**************************************|
259 | SENSOR ARM B |
260 |**************************************/
261
266 double getCurrentSAAzB(){ return m_currentSAAz_B; }
267
272 double getCurrentSARadialB(){ return m_currentSARadial_B; }
273
278 double getTargetSAAzB(){ return m_targetSAAz_B; }
279
284 double getTargetSARadialB(){ return m_targetSARadial_B; }
285
290 QPointF getCurrentBoxPosB(){ return m_currentBoxPos_B; }
291
296 QPointF getTargetBoxPosB(){ return m_targetBoxPos_B; }
297
298 /**************************************|
299 | SENSOR ARM C |
300 |**************************************/
301
306 double getCurrentSAAzC(){ return m_currentSAAz_C; }
307
312 double getCurrentSARadialC(){ return m_currentSARadial_C; }
313
318 double getTargetSAAzC(){ return m_targetSAAz_C; }
319
324 double getTargetSARadialC(){ return m_targetSARadial_C; }
325
330 QPointF getCurrentBoxPosC(){ return m_currentBoxPos_C; }
331
336 QPointF getTargetBoxPosC(){ return m_targetBoxPos_C; }
337
338
339signals:
340
345 void currentConfigurationChanged(Configuration newConfiguration);
346
351 void a1b1ScienceFieldRadiusChanged(double newValue);
352
357 void betaWarningAngleChanged(double newValue);
358
363 void pfsRadiusChanged(double newValue);
364
369 void prioritySBChanged(ElementName newValue);
370
371 /**************************************|
372 | SENSOR ARM A |
373 |**************************************/
374
379 void currentSAAzChangedA(double newValue);
380
385 void currentSARadialChangedA(double newValue);
386
391 void targetSAAzChangedA(double newValue);
392
397 void targetSARadialChangedA(double newValue);
398
399 /**************************************|
400 | SENSOR ARM B |
401 |**************************************/
402
407 void currentSAAzChangedB(double newValue);
408
413 void currentSARadialChangedB(double newValue);
414
419 void targetSAAzChangedB(double newValue);
420
425 void targetSARadialChangedB(double newValue);
426
427 /**************************************|
428 | SENSOR ARM C |
429 |**************************************/
430
435 void currentSAAzChangedC(double newValue);
436
441 void currentSARadialChangedC(double newValue);
442
447 void targetSAAzChangedC(double newValue);
448
453 void targetSARadialChangedC(double newValue);
454
455
456public slots:
457
462 void setCurrentConfiguration (Configuration newConfiguration);
463
468 void setCurrentConfigurationInt(int configuration){
469 if (m_currentConfiguration == static_cast<Configuration>(configuration))
470 return;
471
472 m_currentConfiguration = static_cast<Configuration>(configuration);
473 emit currentConfigurationChanged(m_currentConfiguration);
474 this->m_warningZoneRadius = this->warningRadiuses[m_currentConfiguration];
475 this->updateBackground();
476 this->update();
477 }
478
479 void setPrioritySBInt(int priority_index){
480 switch(priority_index){
481 case 0:
482 this->m_prioritySB = ElementName::A;
483 break;
484 case 1:
485 this->m_prioritySB = ElementName::B;
486 break;
487 case 2:
488 this->m_prioritySB = ElementName::C;
489 break;
490 default:
491 return;
492 }
493
494
495 emit prioritySBChanged(this->m_prioritySB);
496 this->update();
497
498 }
499
504 void setA1B1ScienceFieldRadius (double newValue);
505
510 void setBetaWarningAngle (double newValue);
511
516 void setPfsRadius(double newValue);
517
522 void setPrioritySB(ElementName newValue);
523
528 void changePFSSide(bool doReverse){
529 this->m_reverse = doReverse;
530 this->m_backgroundUpdateNeeded = true;
531 this->update();
532 }
533
534 /**************************************|
535 | SENSOR ARM A |
536 |**************************************/
537
542 void setCurrentSAAzA (double newValue);
543
548 void setCurrentSARadialA (double newValue);
549
554 void setTargetSAAzA(double newValue);
555
560 void setTargetSARadialA(double newValue);
561
562 /**************************************|
563 | SENSOR ARM B |
564 |**************************************/
565
570 void setCurrentSAAzB (double newValue);
571
576 void setCurrentSARadialB (double newValue);
577
582 void setTargetSAAzB(double newValue);
583
588 void setTargetSARadialB(double newValue);
589
590 /**************************************|
591 | SENSOR ARM C |
592 |**************************************/
593
598 void setCurrentSAAzC (double newValue);
599
604 void setCurrentSARadialC (double newValue);
605
610 void setTargetSAAzC(double newValue);
611
616 void setTargetSARadialC(double newValue);
617
618
619protected:
625 void paintEvent(QPaintEvent *event) override;
626
631 void paintDartBoard(QPainter *painter) override;
632
643 void paintSA(QPainter *painter, QPointF *positionPoint, double azimuth, double radial, Role roleName, ElementName sbName);
644
654 void updateSBColorAndText(Role roleName, QColor elementColor, QPen &currentPen, QString &sbName);
655
661 QColor calculateColor(QColor baseColor, Role roleName);
662
671 PositionCheck checkForCollisions(ElementName elementName);
672
678 void drawM6ArmShadow(QPainter *painter, Configuration config);
679
680
681private:
682 struct ElementInfo {
683 QString elementLabel;
684 QColor elementCurrentColor;
685 };
686
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";
698
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}},
703 };
704
705 // Sensor Arm A
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;
710
711 // Sensor Arm B
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;
716
717 // Sensor Arm C
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;
722
723 bool m_backgroundUpdateNeeded = true;
724
725
726 // The factor used to normalize arms length with respect to
727 // generated focal plane radius (50.0)
728 double m_arm_scale = 0.0;
729
730 // Current and target positions of sensor arms
731 // used for testing purposes
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);
735
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);
739
740
741 const QString c_sensorBoxImagePath = ":/sensor_box.svg";
742 QString m_originalXml;
743 QString m_modifiedXml;
744 QSvgRenderer m_svg;
745
746 double m_pfsRadius = 995.0;
747 double m_scienceFieldRadius = 397.0;
748 double m_technicalFieldRadius;
749 // In A1/B1 Configuration, science field radius if defined by configurable x
750 // which: 5 >= x >= 2.5 arc mins (0.497 m)
751 double m_a1b1ScienceFieldRadius = 497.0;
752 // Shadow casted by M6C Mirror on technical field in coude configuration
753 double m_m6cMirrorShadeRadius = 487;
754 // Shadow casted by M6N Mirror on technical field in A3/B3 configuration
755 double m_m6nMirrorShadeRadius = 746;
756 // When SA length is beyond this radius, a warning is triggered
757 // Because the current configuration is None by default,
758 // SAs lengths are restricted by science field radius
759 double m_warningZoneRadius = m_scienceFieldRadius;
760 // Distance from the outermost circle to technical field.
761 // If radial coordinate of SA is 0, SA is drawn with legth equal to the m_margin
762 // representing completely retracted SA
763 double m_margin = 0;
764
765 Configuration m_currentConfiguration = Configuration::None;
766
767 // Associate configuration modes with science field boundaries
768 // (or mirror shadows overcating the technical field)
769 // to easly retrieve radiuses that restrict warning zone
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},
775 };
776
777 // Angle values to determine whether 2 SAs are either too close each other
778 // or they collide.
779 // Converted to radians
780 double m_collisionAngle = 50.0 * (M_PI/180);
781 double m_betaWarningAngle = 10.0 * (M_PI/180);
782
783 ElementName m_prioritySB;
784 // False for PFS A, true for PFS B
785 bool m_reverse = true;
786
787};
788
789
790#endif // QEPREFOCALSTATION_HPP
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