libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
pappso::IntegrationScopeRhomb Class Reference

#include <integrationscoperhomb.h>

Inheritance diagram for pappso::IntegrationScopeRhomb:
pappso::IntegrationScopeBase

Public Member Functions

 IntegrationScopeRhomb ()
 IntegrationScopeRhomb (const std::vector< QPointF > &points)
 IntegrationScopeRhomb (const std::vector< QPointF > &points, Enums::DataKind data_kind_x, Enums::DataKind data_kind_y)
 IntegrationScopeRhomb (const IntegrationScopeRhomb &other)
virtual ~IntegrationScopeRhomb () override
virtual IntegrationScopeRhombclone () const
virtual IntegrationScopeRhomboperator= (const IntegrationScopeRhomb &other)
virtual std::size_t addPoint (QPointF point)
virtual bool getPoint (QPointF &point) const override
virtual bool getPoints (std::vector< QPointF > &points) const override
virtual IntegrationScopeFeatures getTopMostPoint (QPointF &point) const override
virtual IntegrationScopeFeatures getTopMostPoints (std::vector< QPointF > &points) const override
virtual IntegrationScopeFeatures getBottomMostPoint (QPointF &point) const override
virtual IntegrationScopeFeatures getBottomMostPoints (std::vector< QPointF > &points) const override
virtual IntegrationScopeFeatures getLeftMostPoint (QPointF &point) const override
virtual IntegrationScopeFeatures getLeftMostPoints (std::vector< QPointF > &points) const override
virtual IntegrationScopeFeatures getLeftMostTopPoint (QPointF &point) const override
virtual IntegrationScopeFeatures getLeftMostBottomPoint (QPointF &point) const override
virtual IntegrationScopeFeatures getRightMostPoint (QPointF &point) const override
virtual IntegrationScopeFeatures getRightMostPoints (std::vector< QPointF > &points) const override
virtual IntegrationScopeFeatures getRightMostTopPoint (QPointF &point) const override
virtual IntegrationScopeFeatures getRightMostBottomPoint (QPointF &point) const override
virtual IntegrationScopeFeatures getWidth (double &width) const override
virtual IntegrationScopeFeatures getHeight (double &height) const override
virtual IntegrationScopeFeatures getRhombHorizontalSize (double &size) const override
virtual IntegrationScopeFeatures getRhombVerticalSize (double &size) const override
virtual bool range (Enums::Axis axis, double &start, double &end) const override
virtual void setDataKindX (Enums::DataKind data_kind) override
virtual bool getDataKindX (Enums::DataKind &data_kind) override
virtual void setDataKindY (Enums::DataKind data_kind) override
virtual bool getDataKindY (Enums::DataKind &data_kind) override
bool is1D () const override
bool is2D () const override
virtual bool isRectangle () const override
virtual bool isRhomboid () const override
virtual bool transpose () override
virtual bool contains (const QPointF &point) const override
virtual QString toString () const override
virtual void reset () override
virtual IntegrationScopeBaseoperator= (const IntegrationScopeBase &other)
Public Member Functions inherited from pappso::IntegrationScopeBase
 IntegrationScopeBase ()
 IntegrationScopeBase (const IntegrationScopeBase &other)
virtual ~IntegrationScopeBase ()

Protected Attributes

std::vector< QPointF > m_points
Enums::DataKind m_dataKindX = Enums::DataKind::unset
Enums::DataKind m_dataKindY = Enums::DataKind::unset

Detailed Description

Definition at line 76 of file integrationscoperhomb.h.

Constructor & Destructor Documentation

◆ IntegrationScopeRhomb() [1/4]

pappso::IntegrationScopeRhomb::IntegrationScopeRhomb ( )

Definition at line 21 of file integrationscoperhomb.cpp.

22{
23 // qDebug() << "Constructing" << this;
24}

References pappso::IntegrationScopeBase::IntegrationScopeBase().

Referenced by IntegrationScopeRhomb(), clone(), and operator=().

◆ IntegrationScopeRhomb() [2/4]

pappso::IntegrationScopeRhomb::IntegrationScopeRhomb ( const std::vector< QPointF > & points)
explicit

Definition at line 26 of file integrationscoperhomb.cpp.

26 : m_points(points)
27{
28 // qDebug() << "Constructing" << this << "with" << m_points.size() << "points.";
29}

References m_points.

◆ IntegrationScopeRhomb() [3/4]

pappso::IntegrationScopeRhomb::IntegrationScopeRhomb ( const std::vector< QPointF > & points,
Enums::DataKind data_kind_x,
Enums::DataKind data_kind_y )
explicit

Definition at line 31 of file integrationscoperhomb.cpp.

34 : IntegrationScopeBase(), m_points(points), m_dataKindX(data_kind_x), m_dataKindY(data_kind_y)
35{
36 // qDebug() << "Constructing" << this << "with" << m_points.size() << "points."
37 // << "data_kind_x:" << static_cast<int>(data_kind_x)
38 // << "data_kind_y:" << static_cast<int>(data_kind_y);
39}

References pappso::IntegrationScopeBase::IntegrationScopeBase(), m_dataKindX, m_dataKindY, and m_points.

◆ IntegrationScopeRhomb() [4/4]

pappso::IntegrationScopeRhomb::IntegrationScopeRhomb ( const IntegrationScopeRhomb & other)

Definition at line 40 of file integrationscoperhomb.cpp.

42 m_points(other.m_points),
43 m_dataKindX(other.m_dataKindX),
44 m_dataKindY(other.m_dataKindY)
45{
46}

References pappso::IntegrationScopeBase::IntegrationScopeBase(), IntegrationScopeRhomb(), m_dataKindX, m_dataKindY, and m_points.

◆ ~IntegrationScopeRhomb()

pappso::IntegrationScopeRhomb::~IntegrationScopeRhomb ( )
overridevirtual

Definition at line 48 of file integrationscoperhomb.cpp.

49{
50 // qDebug() << "Destructing" << this;
51}

Member Function Documentation

◆ addPoint()

std::size_t pappso::IntegrationScopeRhomb::addPoint ( QPointF point)
virtual

Definition at line 74 of file integrationscoperhomb.cpp.

75{
76 m_points.push_back(point);
77 return m_points.size();
78}

References m_points.

◆ clone()

IntegrationScopeRhomb * pappso::IntegrationScopeRhomb::clone ( ) const
virtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 54 of file integrationscoperhomb.cpp.

References IntegrationScopeRhomb().

◆ contains()

bool pappso::IntegrationScopeRhomb::contains ( const QPointF & point) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 1009 of file integrationscoperhomb.cpp.

1010{
1011 // We have to make the real check using the point-in-polygon algorithm.
1012
1013 // This code is inspired by the work described here:
1014 // https://wrf.ecse.rpi.edu/Research/Short_Notes/pnpoly.html
1015
1016 // int pnpoly(int vertex_count, float *vertx, float *verty, float testx,
1017 // float testy)
1018
1019 int i = 0;
1020 int j = 0;
1021 bool is_inside = false;
1022
1023 int vertex_count = m_points.size();
1024
1025 for(i = 0, j = vertex_count - 1; i < vertex_count; j = i++)
1026 {
1027 if(((m_points.at(i).y() > point.y()) != (m_points.at(j).y() > point.y())) &&
1028 (point.x() < (m_points.at(j).x() - m_points.at(i).x()) * (point.y() - m_points.at(i).y()) /
1029 (m_points.at(j).y() - m_points.at(i).y()) +
1030 m_points.at(i).x()))
1031 is_inside = !is_inside;
1032 }
1033
1034 // if(is_inside)
1035 // qDebug() << "Testing point:" << point
1036 // << "against rhomboid polygon - turns out be in.";
1037 // else
1038 // qDebug() << "Testing point:" << point
1039 // << "against rhomboid polygon - turns out be out.";
1040
1041 return is_inside;
1042}

References m_points.

◆ getBottomMostPoint()

IntegrationScopeFeatures pappso::IntegrationScopeRhomb::getBottomMostPoint ( QPointF & point) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 168 of file integrationscoperhomb.cpp.

169{
170 if(m_points.size() < 4)
171 qFatal("The rhomboid has not four points.");
172
173 double bottom_most_y_value = std::numeric_limits<double>::max();
174
175 for(auto &the_point : m_points)
176 {
177 if(the_point.y() < bottom_most_y_value)
178 {
179 bottom_most_y_value = the_point.y();
180 point = the_point;
181 }
182 }
183
185}

References m_points, and pappso::SUCCESS.

Referenced by getBottomMostPoints(), getHeight(), and range().

◆ getBottomMostPoints()

IntegrationScopeFeatures pappso::IntegrationScopeRhomb::getBottomMostPoints ( std::vector< QPointF > & points) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 188 of file integrationscoperhomb.cpp.

189{
190 if(m_points.size() < 4)
191 qFatal("The rhomboid has not four points.");
192
193 // Depending of the horiz or vert quality of the scope we are going to return
194 // 1 or 2 points, respectively.
195
196 points.clear();
197
198 QPointF point;
199
201 qFatal("Failed to get the bottom most point.");
202
203 // Store that point immediately.
204 points.push_back(point);
205
206 // Now that we know at least one of the bottom most points, check if there are
207 // other points having same y and different x. Note that one specific case
208 // is when the rhomboid is flat on the x axis, in which case all the points
209 // have the same y value. We will thus return 4 points. In all the other
210 // cases, we return 2 points if the rhomboid is horizontal and 1 point if the
211 // rhomboid is vertical.
212
213 for(auto &the_point : m_points)
214 {
215 if(the_point == point)
216 continue;
217
218 if(the_point.y() == point.y())
219 {
220 // We are handling a vertical rhomboid.
221 points.push_back(the_point);
222 }
223 }
224
225 uint temp = 0;
226
227 if(points.size() == 1)
228 temp |= static_cast<int>(IntegrationScopeFeatures::RHOMBOID_VERTICAL);
229 else if(points.size() == 2)
230 temp |= static_cast<int>(IntegrationScopeFeatures::RHOMBOID_HORIZONTAL);
231 else if(points.size() > 2)
232 temp |= static_cast<int>(IntegrationScopeFeatures::FLAT_ON_X_AXIS);
233
234 temp |= static_cast<int>(IntegrationScopeFeatures::SUCCESS);
235
236 return static_cast<IntegrationScopeFeatures>(temp);
237}
virtual IntegrationScopeFeatures getBottomMostPoint(QPointF &point) const override
unsigned int uint
Definition types.h:67

References pappso::FAILURE, pappso::FLAT_ON_X_AXIS, getBottomMostPoint(), m_points, pappso::RHOMBOID_HORIZONTAL, pappso::RHOMBOID_VERTICAL, and pappso::SUCCESS.

Referenced by getLeftMostBottomPoint(), and getRightMostBottomPoint().

◆ getDataKindX()

bool pappso::IntegrationScopeRhomb::getDataKindX ( Enums::DataKind & data_kind)
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 952 of file integrationscoperhomb.cpp.

953{
954 data_kind = m_dataKindX;
955 return true;
956}

References m_dataKindX.

◆ getDataKindY()

bool pappso::IntegrationScopeRhomb::getDataKindY ( Enums::DataKind & data_kind)
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 959 of file integrationscoperhomb.cpp.

960{
961 data_kind = m_dataKindY;
962 return true;
963}

References m_dataKindY.

◆ getHeight()

IntegrationScopeFeatures pappso::IntegrationScopeRhomb::getHeight ( double & height) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 734 of file integrationscoperhomb.cpp.

735{
736 // See getWidth() for explanations.
737
738 if(m_points.size() < 4)
739 qFatal("The IntegrationScopeRhomb has less than four points.");
740
741 // The height of the rhomboid is the entire span that it has on the y axis.
742
743 QPointF top_most_point;
744 QPointF bottom_most_point;
745
746 if(!getTopMostPoint(top_most_point))
747 qFatal("Failed to get the top most point.");
748
749 if(!getBottomMostPoint(bottom_most_point))
750 qFatal("Failed to get the bottom most point.");
751
752 height = fabs(top_most_point.y() - bottom_most_point.y());
753
755}
virtual IntegrationScopeFeatures getTopMostPoint(QPointF &point) const override

References getBottomMostPoint(), getTopMostPoint(), m_points, and pappso::SUCCESS.

◆ getLeftMostBottomPoint()

IntegrationScopeFeatures pappso::IntegrationScopeRhomb::getLeftMostBottomPoint ( QPointF & point) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 456 of file integrationscoperhomb.cpp.

457{
458 if(m_points.size() < 4)
459 qFatal("The rhomboid has not four points.");
460
461 std::vector<QPointF> points;
462
463 // Try the bottom most points, which will tell us if the rhomboid is
464 // horizontal or not.
465
466 IntegrationScopeFeatures scope_features = getBottomMostPoints(points);
467
468 if(scope_features == IntegrationScopeFeatures::FAILURE)
469 qFatal("Failed to get the bottom most points.");
470
472 {
473 // We should have gotten 2 points.
474
475 if(points.size() != 2)
476 qFatal("We should have gotten two points.");
477
478 if(points.at(0).x() < points.at(1).x())
479 point = points.at(0);
480 else
481 point = points.at(1);
482 }
483 else if(scope_features & IntegrationScopeFeatures::RHOMBOID_VERTICAL)
484 {
485 // In this case, we need to ask for the left most points. We'll have to
486 // check the results again!
487
488 scope_features = getLeftMostPoints(points);
489
490 if(!(scope_features & IntegrationScopeFeatures::SUCCESS))
491 qFatal("Failed to get the left most points.");
492
494 {
495 // We should have gotten 2 points.
496
497 if(points.size() != 2)
498 qFatal("We should have gotten two points.");
499
500 if(points.at(0).y() < points.at(1).y())
501 point = points.at(0);
502 else
503 point = points.at(1);
504 }
505 else if(scope_features & IntegrationScopeFeatures::FLAT_ON_Y_AXIS)
506 {
507 // It is possible that the user has rotated the vertical rhomboid
508 // such that all the points are aligned on the y axis (all have the
509 // same x axis value). This is not an error condition. All we do is
510 // return scope_features so the caller understands the situations.
511 }
512 else
513 qFatal("This point should never be reached.");
514 }
515 else if(scope_features & IntegrationScopeFeatures::FLAT_ON_X_AXIS)
516 {
517 // This is not an error condition. All we do is return scope_features
518 // so the caller understands the situations.
519 }
520 else
521 qFatal("This point should never be reached.");
522
523 return scope_features;
524}
virtual IntegrationScopeFeatures getBottomMostPoints(std::vector< QPointF > &points) const override
virtual IntegrationScopeFeatures getLeftMostPoints(std::vector< QPointF > &points) const override

References pappso::FAILURE, pappso::FLAT_ON_X_AXIS, pappso::FLAT_ON_Y_AXIS, getBottomMostPoints(), getLeftMostPoints(), m_points, pappso::RHOMBOID_HORIZONTAL, pappso::RHOMBOID_VERTICAL, and pappso::SUCCESS.

Referenced by toString().

◆ getLeftMostPoint()

IntegrationScopeFeatures pappso::IntegrationScopeRhomb::getLeftMostPoint ( QPointF & point) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 240 of file integrationscoperhomb.cpp.

241{
242 if(m_points.size() < 4)
243 qFatal("The rhomboid has not four points.");
244
245 double left_most_x = std::numeric_limits<double>::max();
246
247 for(auto &the_point : m_points)
248 {
249 if(the_point.x() < left_most_x)
250 {
251 left_most_x = the_point.x();
252 point = the_point;
253 }
254 }
255
257}

References m_points, and pappso::SUCCESS.

Referenced by getLeftMostPoints(), getWidth(), and range().

◆ getLeftMostPoints()

IntegrationScopeFeatures pappso::IntegrationScopeRhomb::getLeftMostPoints ( std::vector< QPointF > & points) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 260 of file integrationscoperhomb.cpp.

261{
262 if(m_points.size() < 4)
263 qFatal("The rhomboid has not four points.");
264
265 // Depending of the horiz or vert quality of the scope we are going to return
266 // 1 or 2 points, respectively.
267
268 points.clear();
269
270 QPointF point;
271
273 qFatal("Failed to get at least one left most point.");
274
275 // Store that point immediately.
276 points.push_back(point);
277
278 // Now that we know at least one of the left most points, check if there are
279 // other points having same x and different y. Note that one specific case
280 // is when the rhomboid is flat on the y axis, in which case all the points
281 // have the same x value. We will thus return 4 points. In all the other
282 // cases, we return 1 point if the rhomboid is horizontal and 2 points if the
283 // rhomboid is vertical.
284
285 for(auto &the_point : m_points)
286 {
287 if(the_point == point)
288 continue;
289
290 if(the_point.x() == point.x())
291 {
292 // We are handling a vertical rhomboid.
293 points.push_back(the_point);
294 }
295 }
296
297 uint temp = 0;
298
299 if(points.size() == 1)
300 temp |= static_cast<int>(IntegrationScopeFeatures::RHOMBOID_HORIZONTAL);
301 else if(points.size() == 2)
302 temp |= static_cast<int>(IntegrationScopeFeatures::RHOMBOID_VERTICAL);
303 else if(points.size() > 2)
304 temp |= static_cast<int>(IntegrationScopeFeatures::FLAT_ON_Y_AXIS);
305
306 temp |= static_cast<int>(IntegrationScopeFeatures::SUCCESS);
307
308 return static_cast<IntegrationScopeFeatures>(temp);
309}
virtual IntegrationScopeFeatures getLeftMostPoint(QPointF &point) const override

References pappso::FAILURE, pappso::FLAT_ON_Y_AXIS, getLeftMostPoint(), m_points, pappso::RHOMBOID_HORIZONTAL, pappso::RHOMBOID_VERTICAL, and pappso::SUCCESS.

Referenced by getLeftMostBottomPoint(), getLeftMostTopPoint(), and getRhombVerticalSize().

◆ getLeftMostTopPoint()

IntegrationScopeFeatures pappso::IntegrationScopeRhomb::getLeftMostTopPoint ( QPointF & point) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 384 of file integrationscoperhomb.cpp.

385{
386 if(m_points.size() < 4)
387 qFatal("The rhomboid has not four points.");
388
389 std::vector<QPointF> points;
390
391 // Try the top most points, which will tell us if the rhomboid is horizontal
392 // or not.
393
394 IntegrationScopeFeatures scope_features = getTopMostPoints(points);
395
396 if(scope_features == IntegrationScopeFeatures::FAILURE)
397 qFatal("Failed to get the top most points.");
398
400 {
401 // We should have gotten 2 points.
402
403 if(points.size() != 2)
404 qFatal("We should have gotten two points.");
405
406 if(points.at(0).x() < points.at(1).x())
407 point = points.at(0);
408 else
409 point = points.at(1);
410 }
411 else if(scope_features & IntegrationScopeFeatures::RHOMBOID_VERTICAL)
412 {
413 // In this case, we need to ask for the left most points. We'll have to
414 // check the
415 // results again!
416
417 scope_features = getLeftMostPoints(points);
418
419 if(scope_features == IntegrationScopeFeatures::FAILURE)
420 qFatal("Failed to get the left most points.");
421
423 {
424 // We should have gotten 2 points.
425
426 if(points.size() != 2)
427 qFatal("We should have gotten two points.");
428
429 if(points.at(0).y() > points.at(1).y())
430 point = points.at(0);
431 else
432 point = points.at(1);
433 }
434 else if(scope_features & IntegrationScopeFeatures::FLAT_ON_Y_AXIS)
435 {
436 // It is possible that the user has rotated the vertical rhomboid
437 // such that all the points are aligned on the y axis (all have the
438 // same x axis value). This is not an error condition. All we do is
439 // return scope_features so the caller understands the situations.
440 }
441 else
442 qFatal("This point should never be reached.");
443 }
444 else if(scope_features & IntegrationScopeFeatures::FLAT_ON_X_AXIS)
445 {
446 // This is not an error condition. All we do is return scope_features
447 // so the caller understands the situations.
448 }
449 else
450 qFatal("This point should never be reached.");
451
452 return scope_features;
453}
virtual IntegrationScopeFeatures getTopMostPoints(std::vector< QPointF > &points) const override

References pappso::FAILURE, pappso::FLAT_ON_X_AXIS, pappso::FLAT_ON_Y_AXIS, getLeftMostPoints(), getTopMostPoints(), m_points, pappso::RHOMBOID_HORIZONTAL, and pappso::RHOMBOID_VERTICAL.

Referenced by toString().

◆ getPoint()

bool pappso::IntegrationScopeRhomb::getPoint ( QPointF & point) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 81 of file integrationscoperhomb.cpp.

82{
83 return false;
84}

◆ getPoints()

bool pappso::IntegrationScopeRhomb::getPoints ( std::vector< QPointF > & points) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 87 of file integrationscoperhomb.cpp.

88{
89 points.clear();
90 points.assign(m_points.begin(), m_points.end());
91 return true;
92}

References m_points.

◆ getRhombHorizontalSize()

IntegrationScopeFeatures pappso::IntegrationScopeRhomb::getRhombHorizontalSize ( double & size) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 758 of file integrationscoperhomb.cpp.

759{
760 if(m_points.size() < 4)
761 qFatal("The IntegrationScopeRhomb has less than four points.");
762
763 // There are two kinds of rhomboid integration scopes:
764
765 /*
766 * 4 +-----------+3
767 * | |
768 * | |
769 * | |
770 * | |
771 * | |
772 * | |
773 * | |
774 * 1+----------+2
775 * ----width---
776 */
777
778 // As visible here, the fixed size of the rhomboid (using the S key in the
779 // plot widget) is the *horizontal* side (this is the plot context's
780 // m_integrationScopeRhombWidth). In this case the height of the scope is 0.
781
782 // and
783
784
785 /*
786 * +3
787 * . |
788 * . |
789 * . |
790 * . +2
791 * . .
792 * . .
793 * . .
794 * 4+ .
795 * | | .
796 * height | | .
797 * | | .
798 * 1+
799 *
800 */
801
802 // As visible here, the fixed size of the rhomboid (using the S key in the
803 // plot widget) is the *vertical* side (this is the plot context's
804 // m_integrationScopeRhombHeight). In this case the width of the scope is 0.
805
806 // In this function we need to establish what kind of rhomboid (horizontal or
807 // vertical) we are dealing with.
808
809 // If the scope is horizontal, then two points of same y value (either top or
810 // bottom) have different x values. That is, leftmost top point has the same y
811 // value as the rightmost top point. Similarly, the leftmost bottom point has
812 // the same y value as the rightmost bottom point.
813
814 // If the scope is vertical, then there is only one single point that has the
815 // greatest y value. Likewise, there is only one single point having the
816 // smallest y value. Conversely, there are going to be two points of differing
817 // y values having the same x value (2 leftmost points and two rightmost
818 // points).
819
820 std::vector<QPointF> points;
821
822 // First get the top most point, we'll use the y value to check if there is
823 // only one point sharing that value or not.
824
825 // qDebug() << "The rhomboid integration scope:" << toString();
826
827 IntegrationScopeFeatures scope_features = getTopMostPoints(points);
828
829 if(scope_features == IntegrationScopeFeatures::FAILURE)
830 qFatal("Failed to get top most points.");
831
832 // qDebug() << "getTopMostPoints() got" << points.size() << "points.";
833
835 {
836 // Do not change anything to the width passed as parameter.
837 }
838 else if(scope_features & IntegrationScopeFeatures::RHOMBOID_HORIZONTAL)
839 {
840 // We are dealing with a horizontal rhomboid. Thus we *must* have
841 // gotten 2 points.
842 size = fabs(points.at(0).x() - points.at(1).x());
843 }
844 else if(scope_features & IntegrationScopeFeatures::RHOMBOID_VERTICAL)
845 {
846 // We are dealing with a vertical rhomboid.
847 size = 0;
848 }
849
850 return scope_features;
851}

References pappso::FAILURE, pappso::FLAT_ON_X_AXIS, getTopMostPoints(), m_points, pappso::RHOMBOID_HORIZONTAL, and pappso::RHOMBOID_VERTICAL.

◆ getRhombVerticalSize()

IntegrationScopeFeatures pappso::IntegrationScopeRhomb::getRhombVerticalSize ( double & size) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 854 of file integrationscoperhomb.cpp.

855{
856 // See getRhombHorizontalSize() for explanations.
857
858 // If the scope is horizontal, then two points of same y value (either top or
859 // bottom) have different x values. That is, leftmost top point has the same y
860 // value as the rightmost top point. Similarly, the leftmost bottom point has
861 // the same y value as the rightmost bottom point.
862
863 // If the scope is vertical, then there is only one single point that has the
864 // greatest y value. Likewise, there is only one single point having the
865 // smallest y value. Conversely, there are going to be two points of differing
866 // y values having the same x value (2 leftmost points and two rightmost
867 // points).
868
869 std::vector<QPointF> points;
870
871 // Get the leftmost points (there are going to be 1 or 2 points in the
872 // vector depending on the kind of rhomboid.
873
874 // qDebug() << "The rhomboid integration scope:" << toString();
875
876 IntegrationScopeFeatures scope_features = getLeftMostPoints(points);
877
878 if(scope_features == IntegrationScopeFeatures::FAILURE)
879 qFatal("Failed to get left most points.");
880
881 // qDebug() << "getLeftMostPoints() got" << points.size() << "points.";
882
884 {
885 // Do not change anything to the width passed as parameter.
886 }
887 else if(scope_features & IntegrationScopeFeatures::RHOMBOID_HORIZONTAL)
888 {
889 // We are dealing with a horizontal rhomboid.
890 size = 0;
891 }
892 else if(scope_features & IntegrationScopeFeatures::RHOMBOID_VERTICAL)
893 {
894 // We are dealing with a vertical rhomboid. Thus we *must* have
895 // gotten 2 points.
896 size = fabs(points.at(0).y() - points.at(1).y());
897 }
898
899 return scope_features;
900}

References pappso::FAILURE, pappso::FLAT_ON_Y_AXIS, getLeftMostPoints(), pappso::RHOMBOID_HORIZONTAL, and pappso::RHOMBOID_VERTICAL.

◆ getRightMostBottomPoint()

IntegrationScopeFeatures pappso::IntegrationScopeRhomb::getRightMostBottomPoint ( QPointF & point) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 598 of file integrationscoperhomb.cpp.

599{
600 if(m_points.size() < 4)
601 qFatal("The rhomboid has not four points.");
602
603 std::vector<QPointF> points;
604
605 // Try the bottom most points, which will tell us if the rhomboid is
606 // horizontal or not.
607
608 IntegrationScopeFeatures scope_features = getBottomMostPoints(points);
609
610 if(scope_features == IntegrationScopeFeatures::FAILURE)
611 qFatal("Failed to get the bottom most points.");
612
614 {
615 // We should have gotten 2 points.
616
617 if(points.size() != 2)
618 qFatal("We should have gotten two points.");
619
620 if(points.at(0).x() > points.at(1).x())
621 point = points.at(0);
622 else
623 point = points.at(1);
624 }
625 else if(scope_features & IntegrationScopeFeatures::RHOMBOID_VERTICAL)
626 {
627 // In this case, we need to ask for the left most points. We'll have to
628 // check the results again!
629
630 scope_features = getRightMostPoints(points);
631
632 if(!(scope_features & IntegrationScopeFeatures::SUCCESS))
633 qFatal("Failed to get the right most points.");
634
636 {
637 // We should have gotten 2 points.
638
639 if(points.size() != 2)
640 qFatal("We should have gotten two points.");
641
642 if(points.at(0).y() < points.at(1).y())
643 point = points.at(0);
644 else
645 point = points.at(1);
646 }
647 else if(scope_features & IntegrationScopeFeatures::FLAT_ON_Y_AXIS)
648 {
649 // It is possible that the user has rotated the vertical rhomboid
650 // such that all the points are aligned on the y axis (all have the
651 // same x axis value). This is not an error condition. All we do is
652 // return scope_features so the caller understands the situations.
653 }
654 else
655 qFatal("This point should never be reached.");
656 }
657 else if(scope_features & IntegrationScopeFeatures::FLAT_ON_ANY_AXIS)
658 {
659 // This is not an error condition. All we do is return scope_features
660 // so the caller understands the situations.
661 }
662 else
663 qFatal("This point should never be reached.");
664
665 return scope_features;
666}
virtual IntegrationScopeFeatures getRightMostPoints(std::vector< QPointF > &points) const override

References pappso::FAILURE, pappso::FLAT_ON_ANY_AXIS, pappso::FLAT_ON_Y_AXIS, getBottomMostPoints(), getRightMostPoints(), m_points, pappso::RHOMBOID_HORIZONTAL, pappso::RHOMBOID_VERTICAL, and pappso::SUCCESS.

Referenced by toString().

◆ getRightMostPoint()

IntegrationScopeFeatures pappso::IntegrationScopeRhomb::getRightMostPoint ( QPointF & point) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 312 of file integrationscoperhomb.cpp.

313{
314 if(m_points.size() < 4)
315 qFatal("The rhomboid has not four points.");
316
317 double greatest_x = std::numeric_limits<double>::min();
318
319 for(auto &the_point : m_points)
320 {
321 if(the_point.x() > greatest_x)
322 {
323 greatest_x = the_point.x();
324 point = the_point;
325 }
326 }
327
329}

References m_points, and pappso::SUCCESS.

Referenced by getRightMostPoints(), getWidth(), and range().

◆ getRightMostPoints()

IntegrationScopeFeatures pappso::IntegrationScopeRhomb::getRightMostPoints ( std::vector< QPointF > & points) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 332 of file integrationscoperhomb.cpp.

333{
334 if(m_points.size() < 4)
335 qFatal("The rhomboid has not four points.");
336
337 // Depending of the horiz or vert quality of the scope we are going to return
338 // 1 or 2 points, respectively.
339
340 points.clear();
341
342 QPointF point;
343
345 qFatal("Failed to get at least one left most point.");
346
347 // Store that point immediately.
348 points.push_back(point);
349
350 // Now that we know at least one of the right most points, check if there are
351 // other points having same x and different y. Note that one specific case
352 // is when the rhomboid is flat on the y axis, in which case all the points
353 // have the same x value. We will thus return 4 points. In all the other
354 // cases, we return 1 point if the rhomboid is horizontal and 2 points if the
355 // rhomboid is vertical.
356
357 for(auto &the_point : m_points)
358 {
359 if(the_point == point)
360 continue;
361
362 if(the_point.x() == point.x())
363 {
364 // We are handling a vertical rhomboid.
365 points.push_back(the_point);
366 }
367 }
368
369 uint temp = 0;
370
371 if(points.size() == 1)
372 temp |= static_cast<int>(IntegrationScopeFeatures::RHOMBOID_HORIZONTAL);
373 else if(points.size() == 2)
374 temp |= static_cast<int>(IntegrationScopeFeatures::RHOMBOID_VERTICAL);
375 else if(points.size() > 2)
376 temp |= static_cast<int>(IntegrationScopeFeatures::FLAT_ON_Y_AXIS);
377
378 temp |= static_cast<int>(IntegrationScopeFeatures::SUCCESS);
379
380 return static_cast<IntegrationScopeFeatures>(temp);
381}
virtual IntegrationScopeFeatures getRightMostPoint(QPointF &point) const override

References pappso::FAILURE, pappso::FLAT_ON_Y_AXIS, getRightMostPoint(), m_points, pappso::RHOMBOID_HORIZONTAL, pappso::RHOMBOID_VERTICAL, and pappso::SUCCESS.

Referenced by getRightMostBottomPoint(), and getRightMostTopPoint().

◆ getRightMostTopPoint()

IntegrationScopeFeatures pappso::IntegrationScopeRhomb::getRightMostTopPoint ( QPointF & point) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 527 of file integrationscoperhomb.cpp.

528{
529 if(m_points.size() < 4)
530 qFatal("The rhomboid has not four points.");
531
532 std::vector<QPointF> points;
533
534 // Try the top most points, which will tell us if the rhomboid is horizontal
535 // or not.
536
537 IntegrationScopeFeatures scope_features = getTopMostPoints(points);
538
539 if(scope_features == IntegrationScopeFeatures::FAILURE)
540 qFatal("Failed to get the top most points.");
541
543 {
544 // We should have gotten 2 points.
545
546 if(points.size() != 2)
547 qFatal("We should have gotten two points.");
548
549 if(points.at(0).x() > points.at(1).x())
550 point = points.at(0);
551 else
552 point = points.at(1);
553 }
554 else if(scope_features & IntegrationScopeFeatures::RHOMBOID_VERTICAL)
555 {
556 // In this case, we need to ask for the left most points. We'll have to
557 // check the results again!
558
559 scope_features = getRightMostPoints(points);
560
561 if(scope_features == IntegrationScopeFeatures::FAILURE)
562 qFatal("Failed to get the right most points.");
563
565 {
566 // We should have gotten 2 points.
567
568 if(points.size() != 2)
569 qFatal("We should have gotten two points.");
570
571 if(points.at(0).y() > points.at(1).y())
572 point = points.at(0);
573 else
574 point = points.at(1);
575 }
576 else if(scope_features & IntegrationScopeFeatures::FLAT_ON_Y_AXIS)
577 {
578 // It is possible that the user has rotated the vertical rhomboid
579 // such that all the points are aligned on the y axis (all have the
580 // same x axis value). This is not an error condition. All we do is
581 // return scope_features so the caller understands the situations.
582 }
583 else
584 qFatal("This point should never be reached.");
585 }
586 else if(scope_features & IntegrationScopeFeatures::FLAT_ON_X_AXIS)
587 {
588 // This is not an error condition. All we do is return scope_features
589 // so the caller understands the situations.
590 }
591 else
592 qFatal("This point should never be reached.");
593
594 return scope_features;
595}

References pappso::FAILURE, pappso::FLAT_ON_X_AXIS, pappso::FLAT_ON_Y_AXIS, getRightMostPoints(), getTopMostPoints(), m_points, pappso::RHOMBOID_HORIZONTAL, and pappso::RHOMBOID_VERTICAL.

Referenced by toString().

◆ getTopMostPoint()

IntegrationScopeFeatures pappso::IntegrationScopeRhomb::getTopMostPoint ( QPointF & point) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 95 of file integrationscoperhomb.cpp.

96{
97 if(m_points.size() < 4)
98 qFatal("The rhomboid has not four points.");
99
100 double top_most_y_value = std::numeric_limits<double>::min();
101
102 for(auto &the_point : m_points)
103 {
104 if(the_point.y() > top_most_y_value)
105 {
106 top_most_y_value = the_point.y();
107 point = the_point;
108 }
109 }
110
111 // Necessarily, whe have a top most point (greatest y of all).
113}

References m_points, and pappso::SUCCESS.

Referenced by getHeight(), getTopMostPoints(), and range().

◆ getTopMostPoints()

IntegrationScopeFeatures pappso::IntegrationScopeRhomb::getTopMostPoints ( std::vector< QPointF > & points) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 116 of file integrationscoperhomb.cpp.

117{
118 if(m_points.size() < 4)
119 qFatal("The rhomboid has not four points.");
120
121 // Depending on the horiz or vert quality of the scope we are going to return
122 // 2 or 1 point, respectively.
123
124 points.clear();
125
126 QPointF point;
127
129 qFatal("Failed to get the top most point.");
130
131 // Store that point immediately.
132 points.push_back(point);
133
134 // Now that we know at least one of the top most points, check if there are
135 // other points having same y and different x. Note that one specific case
136 // is when the rhomboid is flat on the x axis, in which case all the points
137 // have the same y value. We will thus return 4 points. In all the other
138 // cases, we return 2 points if the rhomboid is horizontal and 1 point if the
139 // rhomboid is vertical.
140
141 for(auto &the_point : m_points)
142 {
143 if(the_point == point)
144 continue;
145
146 if(the_point.y() == point.y())
147 {
148 // We are handling a horizontal rhomboid.
149 points.push_back(the_point);
150 }
151 }
152
153 uint temp = 0;
154
155 if(points.size() == 1)
157 else if(points.size() == 2)
159 else if(points.size() > 2)
161
163
164 return static_cast<IntegrationScopeFeatures>(temp);
165}

References pappso::FLAT_ON_X_AXIS, getTopMostPoint(), m_points, pappso::RHOMBOID_HORIZONTAL, pappso::RHOMBOID_VERTICAL, and pappso::SUCCESS.

Referenced by getLeftMostTopPoint(), getRhombHorizontalSize(), and getRightMostTopPoint().

◆ getWidth()

IntegrationScopeFeatures pappso::IntegrationScopeRhomb::getWidth ( double & width) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 669 of file integrationscoperhomb.cpp.

670{
671 if(m_points.size() < 4)
672 qFatal("The IntegrationScopeRhomb has less than four points.");
673
674 // There are two kinds of rhomboid integration scopes:
675
676 /*
677 4 +-----------+3
678 | |
679 | |
680 | |
681 | |
682 | |
683 | |
684 | |
685 1+----------+2
686 ----width---
687 */
688
689 // As visible here, the fixed size of the rhomboid (using the S key in the
690 // plot widget) is the *horizontal* side (this is the plot context's
691 // m_integrationScopeRhombWidth). In this case the height of the scope is 0.
692
693 // and
694
695
696 /*
697 * +3
698 * . |
699 * . |
700 * . |
701 * . +2
702 * . .
703 * . .
704 * . .
705 * 4+ .
706 * | | .
707 * height | | .
708 * | | .
709 * 1+
710 *
711 */
712
713 // As visible here, the fixed size of the rhomboid (using the S key in the
714 // plot widget) is the *vertical* side (this is the plot context's
715 // m_integrationScopeRhombHeight). In this case the width of the scope is 0.
716
717 // The width of the rhomboid is the entire span that it has on the x axis.
718
719 QPointF left_most_point;
720 QPointF right_most_point;
721
722 if(!getLeftMostPoint(left_most_point))
723 qFatal("Failed to get the left most point.");
724
725 if(!getRightMostPoint(right_most_point))
726 qFatal("Failed to get the right most point.");
727
728 width = fabs(right_most_point.x() - left_most_point.x());
729
731}

References getLeftMostPoint(), getRightMostPoint(), m_points, and pappso::SUCCESS.

◆ is1D()

bool pappso::IntegrationScopeRhomb::is1D ( ) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 966 of file integrationscoperhomb.cpp.

967{
968 return false;
969}

Referenced by is2D().

◆ is2D()

bool pappso::IntegrationScopeRhomb::is2D ( ) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 972 of file integrationscoperhomb.cpp.

973{
974 return !is1D();
975}

References is1D().

◆ isRectangle()

bool pappso::IntegrationScopeRhomb::isRectangle ( ) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 978 of file integrationscoperhomb.cpp.

979{
980 return false;
981}

◆ isRhomboid()

bool pappso::IntegrationScopeRhomb::isRhomboid ( ) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 984 of file integrationscoperhomb.cpp.

985{
986 return true;
987}

◆ operator=() [1/2]

IntegrationScopeBase & pappso::IntegrationScopeBase::operator= ( const IntegrationScopeBase & other)
virtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 70 of file integrationscopebase.cpp.

46{
47 Q_UNUSED(other);
48 if(&other == this)
49 return *this;
50
51 return *this;
52}

◆ operator=() [2/2]

IntegrationScopeRhomb & pappso::IntegrationScopeRhomb::operator= ( const IntegrationScopeRhomb & other)
virtual

Definition at line 60 of file integrationscoperhomb.cpp.

61{
62 if(this == &other)
63 return *this;
64
65 m_points.assign(other.m_points.begin(), other.m_points.end());
66
67 m_dataKindX = other.m_dataKindX;
68 m_dataKindY = other.m_dataKindY;
69
70 return *this;
71}

References IntegrationScopeRhomb(), m_dataKindX, m_dataKindY, and m_points.

◆ range()

bool pappso::IntegrationScopeRhomb::range ( Enums::Axis axis,
double & start,
double & end ) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 903 of file integrationscoperhomb.cpp.

904{
905 if(axis == Enums::Axis::x)
906 {
907 QPointF left_most_point;
909 qFatal("Failed to get left-most point.");
910
911 QPointF right_most_point;
913 qFatal("Failed to get right-most point.");
914
915 start = left_most_point.x();
916 end = right_most_point.x();
917
918 return true;
919 }
920 else if(axis == Enums::Axis::y)
921 {
922 QPointF bottom_most_point;
924 qFatal("Failed to get bottom-most point.");
925
926 QPointF top_most_point;
928 qFatal("Failed to get top-most point.");
929
930 start = bottom_most_point.y();
931 end = top_most_point.y();
932
933 return true;
934 }
935
936 return false;
937}

References pappso::FAILURE, getBottomMostPoint(), getLeftMostPoint(), getRightMostPoint(), getTopMostPoint(), pappso::Enums::x, and pappso::Enums::y.

◆ reset()

void pappso::IntegrationScopeRhomb::reset ( )
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 1081 of file integrationscoperhomb.cpp.

1082{
1084 m_points.clear();
1085}

References m_points, and pappso::IntegrationScopeBase::reset().

◆ setDataKindX()

void pappso::IntegrationScopeRhomb::setDataKindX ( Enums::DataKind data_kind)
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 940 of file integrationscoperhomb.cpp.

941{
942 m_dataKindX = data_kind;
943}

References m_dataKindX.

◆ setDataKindY()

void pappso::IntegrationScopeRhomb::setDataKindY ( Enums::DataKind data_kind)
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 946 of file integrationscoperhomb.cpp.

947{
948 m_dataKindY = data_kind;
949}

References m_dataKindY.

◆ toString()

QString pappso::IntegrationScopeRhomb::toString ( ) const
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 1045 of file integrationscoperhomb.cpp.

1046{
1047 QString text = "[";
1048
1049#if 0
1050
1051 // This version is bad because it has reentrancy problems: it might be
1052 // called by functions that are actually called in turn here.
1053
1054 // First the bottom points pair
1056 text.append(QString("(%1, %2)").arg(point.x()).arg(point.y()));
1057
1059 text.append(QString("(%1, %2)").arg(point.x()).arg(point.y()));
1060
1061 // Second the top points pair
1062 getLeftMostTopPoint(point);
1063 text.append(QString("(%1, %2)").arg(point.x()).arg(point.y()));
1064
1065 getRightMostTopPoint(point);
1066 text.append(QString("(%1, %2)").arg(point.x()).arg(point.y()));
1067
1068#endif
1069
1070 for(auto &point : m_points)
1071 text.append(QString("(%1, %2)").arg(point.x()).arg(point.y()));
1072
1073 text.append("]");
1074
1075 // qDebug() << "Returning toString():" << text;
1076
1077 return text;
1078}
virtual IntegrationScopeFeatures getRightMostTopPoint(QPointF &point) const override
virtual IntegrationScopeFeatures getLeftMostTopPoint(QPointF &point) const override
virtual IntegrationScopeFeatures getLeftMostBottomPoint(QPointF &point) const override
virtual IntegrationScopeFeatures getRightMostBottomPoint(QPointF &point) const override

References getLeftMostBottomPoint(), getLeftMostTopPoint(), getRightMostBottomPoint(), getRightMostTopPoint(), and m_points.

◆ transpose()

bool pappso::IntegrationScopeRhomb::transpose ( )
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 990 of file integrationscoperhomb.cpp.

991{
992 Enums::DataKind was_data_kind_y = m_dataKindY;
994 m_dataKindX = was_data_kind_y;
995
996 // Transpose each point in a new vector.
997 std::vector<QPointF> transposed_points;
998
999 for(QPointF &point : m_points)
1000 transposed_points.push_back(QPointF(point.y(), point.x()));
1001
1002 // And now set them back to the member datum.
1003 m_points.assign(transposed_points.begin(), transposed_points.end());
1004
1005 return true;
1006}

References m_dataKindX, m_dataKindY, and m_points.

Member Data Documentation

◆ m_dataKindX

Enums::DataKind pappso::IntegrationScopeRhomb::m_dataKindX = Enums::DataKind::unset
protected

◆ m_dataKindY

Enums::DataKind pappso::IntegrationScopeRhomb::m_dataKindY = Enums::DataKind::unset
protected

◆ m_points


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