15#include "Displacement.h"
17#include "IException.h"
45 startX + width, startY + height, startZ + depth);
64 setArea(startX, startY, startZ, endX, endY, endZ);
76 if(areaToCopy.m_startX) {
80 if(areaToCopy.m_startY) {
84 if(areaToCopy.m_startZ) {
88 if(areaToCopy.m_endX) {
92 if(areaToCopy.m_endY) {
96 if(areaToCopy.m_endZ) {
466 if (
isValid() && otherArea.isValid()) {
475 if (startX <= endX && startY <= endY && startZ <= endZ)
476 result =
Area3D(startX, startY, startZ, endX, endY, endZ);
518 return getStartX() == otherArea.getStartX() &&
521 getEndX() == otherArea.getEndX() &&
522 getEndY() == otherArea.getEndY() &&
523 getEndZ() == otherArea.getEndZ();
536 return !(*
this == otherArea);
549 if(areaToCopy.m_startX) {
553 if(areaToCopy.m_startY) {
557 if(areaToCopy.m_startZ) {
561 if(areaToCopy.m_endX) {
565 if(areaToCopy.m_endY) {
569 if(areaToCopy.m_endZ) {
597 bool startXValid = startX.isValid();
598 bool endXValid = endX.isValid();
599 bool startYValid = startY.isValid();
600 bool endYValid = endY.isValid();
601 bool startZValid = startZ.isValid();
602 bool endZValid = endZ.isValid();
607 if(startXValid && startYValid && startZValid && endXValid && endYValid &&
608 endZValid && startX <= endX && startY <= endY && startZ <= endZ) {
617 if(startXValid && endXValid && startX > endX) {
618 QString msg = QObject::tr(
"Cannot have a 3D area with inverted X coordinates of "
619 "[%1 meters] to [%2 meters]")
620 .arg(startX.meters()).arg(endX.meters());
624 if(startYValid && endYValid && startY > endY) {
625 QString msg = QObject::tr(
"Cannot have a 3D area with inverted Y coordinates of "
626 "[%1 meters] to [%2 meters]")
627 .arg(startY.meters()).arg(endY.meters());
631 if(startZValid && endZValid && startZ > endZ) {
632 QString msg = QObject::tr(
"Cannot have a 3D area with inverted Z coordinates of "
633 "[%1 meters] to [%2 meters]")
634 .arg(startZ.meters()).arg(endZ.meters());
Represents a 3D area (a 3D "cube")
Displacement getStartY() const
Returns the topmost Y position of the 3D area.
bool isValid() const
Returns true if all of the positions of the 3D area are valid (i.e.
Area3D & operator=(const Area3D &areaToCopy)
Assigns areaToCopy to this.
Displacement * m_endX
The rightmost X position. Either NULL or a valid displacement.
void setHeight(const Distance &height)
Changes the height of the 3D area.
void setStartY(const Displacement &startY)
Sets the topmost Y position.
void setZDimension(const Displacement &startZ, const Distance &depth)
Sets the Z dimension of the 3D area.
void setEndY(const Displacement &endY)
Sets the bottommost Y position.
Displacement getEndX() const
Returns the rightmost X position of the 3D area.
void setEndZ(const Displacement &endZ)
Sets the backmost Z position.
void setWidth(const Distance &width)
Changes the width of the 3D area.
Distance getWidth() const
Returns the width (in the X dimension) of the 3D area.
Displacement * m_startX
The leftmost X position. Either NULL or a valid displacement.
virtual ~Area3D()
The destructor frees allocated memory.
void setYDimension(const Displacement &startY, const Distance &height)
Sets the Y dimension of the 3D area.
Displacement * m_startY
The topmost Y position. Either NULL or a valid displacement.
Displacement * m_startZ
The frontmost Z position. Either NULL or a valid displacement.
bool operator!=(const Area3D &otherArea) const
Compares two areas with the != operator.
Area3D intersect(const Area3D &otherArea) const
Returns the intersection of this 3D area with another 3D area.
void moveEndY(const Displacement &endY)
Moves the bottommost Y position of the 3D area.
virtual void setArea(const Displacement &startX, const Displacement &startY, const Displacement &startZ, const Displacement &endX, const Displacement &endY, const Displacement &endZ)
Sets the area.
Distance getDepth() const
Returns the depth (in the Z dimension) of the 3D area.
void moveStartX(const Displacement &startX)
Moves the leftmost X position of the 3D area.
void setDepth(const Distance &depth)
Changes the depth of the 3D area.
void moveStartZ(const Displacement &startZ)
Moves the frontmost Z position of the 3D area.
void moveEndZ(const Displacement &endZ)
Moves the backmost Z position of the 3D area.
void moveEndX(const Displacement &endX)
Moves the rightmost X position of the 3D area.
Displacement * m_endZ
The backmost Z position. Either NULL or a valid displacement.
Displacement getStartZ() const
Returns the frontmost Z position of the 3D area.
void moveStartY(const Displacement &startY)
Moves the topmost Y position of the 3D area.
bool operator==(const Area3D &otherArea) const
Compares two areas with the == operator.
void setStartX(const Displacement &startX)
Sets the leftmost X position.
Distance getHeight() const
Returns the height (in the Y dimension) of the 3D area.
void setXDimension(const Displacement &startX, const Distance &width)
Sets the X dimension of the 3D area.
void setStartZ(const Displacement &startZ)
Sets the frontmost Z position.
Displacement getEndZ() const
Returns the backmost Z position of the 3D area.
void deleteTheData()
Frees all allocated memory used by this 3D area.
Displacement getEndY() const
Returns the bottommost Y position of the 3D area.
void nullTheData()
Nulls all of the members used by this 3D area.
Displacement getStartX() const
Returns the leftmost X position of the 3D area.
void setEndX(const Displacement &endX)
Sets the rightmost X position.
Displacement * m_endY
The bottommost Y position. Either NULL or a valid displacement.
Area3D()
The empty constructor creates an invalid 3D area.
Displacement is a signed length, usually in meters.
Distance measurement, usually in meters.
@ Meters
The distance is being specified in meters.
@ Programmer
This error is for when a programmer made an API call that was illegal.
This is free and unencumbered software released into the public domain.