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, DataKind data_kind_x, DataKind data_kind_y)
 
 IntegrationScopeRhomb (const IntegrationScopeRhomb &other)
 
virtual ~IntegrationScopeRhomb ()
 
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 (Axis axis, double &start, double &end) const override
 
virtual void setDataKindX (DataKind data_kind) override
 
virtual bool getDataKindX (DataKind &data_kind) override
 
virtual void setDataKindY (DataKind data_kind) override
 
virtual bool getDataKindY (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
 
- Public Member Functions inherited from pappso::IntegrationScopeBase
 IntegrationScopeBase ()
 
 IntegrationScopeBase (const IntegrationScopeBase &other)
 
virtual ~IntegrationScopeBase ()
 

Protected Attributes

std::vector< QPointF > m_points
 
DataKind m_dataKindX = DataKind::unset
 
DataKind m_dataKindY = 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}

◆ IntegrationScopeRhomb() [2/4]

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

Definition at line 26 of file integrationscoperhomb.cpp.

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

References m_points.

◆ IntegrationScopeRhomb() [3/4]

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

Definition at line 32 of file integrationscoperhomb.cpp.

36 m_points(points),
37 m_dataKindX(data_kind_x),
38 m_dataKindY(data_kind_y)
39{
40 qDebug() << "Constructing" << this << "with" << m_points.size() << "points."
41 << "data_kind_x:" << static_cast<int>(data_kind_x)
42 << "data_kind_y:" << static_cast<int>(data_kind_y);
43}

References m_points.

◆ IntegrationScopeRhomb() [4/4]

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

Definition at line 44 of file integrationscoperhomb.cpp.

46 m_points(other.m_points),
47 m_dataKindX(other.m_dataKindX),
48 m_dataKindY(other.m_dataKindY)
49{
50}

◆ ~IntegrationScopeRhomb()

pappso::IntegrationScopeRhomb::~IntegrationScopeRhomb ( )
virtual

Definition at line 52 of file integrationscoperhomb.cpp.

53{
54 qDebug() << "Destructing" << this;
55}

Member Function Documentation

◆ addPoint()

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

Definition at line 72 of file integrationscoperhomb.cpp.

73{
74 m_points.push_back(point);
75 return m_points.size();
76}

References m_points.

◆ contains()

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

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 1010 of file integrationscoperhomb.cpp.

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

References m_points.

◆ getBottomMostPoint()

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

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 166 of file integrationscoperhomb.cpp.

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

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 186 of file integrationscoperhomb.cpp.

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

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 ( DataKind data_kind)
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 953 of file integrationscoperhomb.cpp.

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

References m_dataKindX.

◆ getDataKindY()

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

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 960 of file integrationscoperhomb.cpp.

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

References m_dataKindY.

◆ getHeight()

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

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 732 of file integrationscoperhomb.cpp.

733{
734 // See getWidth() for explanations.
735
736 if(m_points.size() < 4)
737 qFatal("The IntegrationScopeRhomb has less than four points.");
738
739 // The height of the rhomboid is the entire span that it has on the y axis.
740
741 QPointF top_most_point;
742 QPointF bottom_most_point;
743
744 if(!getTopMostPoint(top_most_point))
745 qFatal("Failed to get the top most point.");
746
747 if(!getBottomMostPoint(bottom_most_point))
748 qFatal("Failed to get the bottom most point.");
749
750 height = fabs(top_most_point.y() - bottom_most_point.y());
751
753}
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 454 of file integrationscoperhomb.cpp.

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

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

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 258 of file integrationscoperhomb.cpp.

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

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

80{
81 return false;
82}

◆ getPoints()

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

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 85 of file integrationscoperhomb.cpp.

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

References m_points.

◆ getRhombHorizontalSize()

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

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 756 of file integrationscoperhomb.cpp.

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

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

◆ getRhombVerticalSize()

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

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 853 of file integrationscoperhomb.cpp.

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

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

◆ getRightMostBottomPoint()

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

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 596 of file integrationscoperhomb.cpp.

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

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

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 330 of file integrationscoperhomb.cpp.

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

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

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 93 of file integrationscoperhomb.cpp.

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

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 114 of file integrationscoperhomb.cpp.

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

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 667 of file integrationscoperhomb.cpp.

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

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

◆ is1D()

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

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 967 of file integrationscoperhomb.cpp.

968{
969 return false;
970}

Referenced by is2D().

◆ is2D()

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

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 973 of file integrationscoperhomb.cpp.

974{
975 return !is1D();
976}

References is1D().

◆ isRectangle()

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

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 979 of file integrationscoperhomb.cpp.

980{
981 return false;
982}

◆ isRhomboid()

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

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 985 of file integrationscoperhomb.cpp.

986{
987 return true;
988}

◆ operator=()

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

Definition at line 58 of file integrationscoperhomb.cpp.

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

References m_dataKindX, m_dataKindY, and m_points.

◆ range()

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

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 902 of file integrationscoperhomb.cpp.

903{
904 if(axis == Axis::x)
905 {
906 QPointF left_most_point;
908 qFatal("Failed to get left-most point.");
909
910 QPointF right_most_point;
911 if(getRightMostPoint(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 == Axis::y)
921 {
922 QPointF bottom_most_point;
923 if(getBottomMostPoint(bottom_most_point) ==
925 qFatal("Failed to get bottom-most point.");
926
927 QPointF top_most_point;
929 qFatal("Failed to get top-most point.");
930
931 start = bottom_most_point.y();
932 end = top_most_point.y();
933
934 return true;
935 }
936
937 return false;
938}

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

◆ reset()

void pappso::IntegrationScopeRhomb::reset ( )
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 1084 of file integrationscoperhomb.cpp.

1085{
1087 m_points.clear();
1088}

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

◆ setDataKindX()

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

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 941 of file integrationscoperhomb.cpp.

942{
943 m_dataKindX = data_kind;
944}

References m_dataKindX.

◆ setDataKindY()

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

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 947 of file integrationscoperhomb.cpp.

948{
949 m_dataKindY = data_kind;
950}

References m_dataKindY.

◆ toString()

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

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 1048 of file integrationscoperhomb.cpp.

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

Referenced by getRhombHorizontalSize(), and getRhombVerticalSize().

◆ transpose()

bool pappso::IntegrationScopeRhomb::transpose ( )
overridevirtual

Reimplemented from pappso::IntegrationScopeBase.

Definition at line 991 of file integrationscoperhomb.cpp.

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

References m_dataKindX, m_dataKindY, and m_points.

Member Data Documentation

◆ m_dataKindX

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

Definition at line 143 of file integrationscoperhomb.h.

Referenced by getDataKindX(), operator=(), setDataKindX(), and transpose().

◆ m_dataKindY

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

Definition at line 144 of file integrationscoperhomb.h.

Referenced by getDataKindY(), operator=(), setDataKindY(), and transpose().

◆ m_points


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