This repository has been archived by the owner on Dec 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from Astroua/develop
release 0.4.1 merging form develop into master
- Loading branch information
Showing
111 changed files
with
3,170 additions
and
3,741 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
#include "AxisDisplayInfo.h" | ||
|
||
#include "CartaLib/CartaLib.h" | ||
#include <QDebug> | ||
|
||
namespace Carta { | ||
|
||
namespace Lib { | ||
|
||
using Carta::Lib::AxisInfo; | ||
|
||
bool AxisDisplayInfo::isCelestialPlane( const std::vector<AxisDisplayInfo>& displayInfos ){ | ||
bool celestialPlane = false; | ||
int infoCount = displayInfos.size(); | ||
int planeCount = 0; | ||
for ( int i = 0; i < infoCount; i++ ){ | ||
AxisInfo::KnownType type = displayInfos[i].getAxisType(); | ||
if ( type == AxisInfo::KnownType::DIRECTION_LON || type == AxisInfo::KnownType::DIRECTION_LAT ){ | ||
int frame = displayInfos[i].getFrame(); | ||
if ( frame < 0 ){ | ||
planeCount++; | ||
} | ||
} | ||
} | ||
if ( planeCount == 2 ){ | ||
celestialPlane = true; | ||
} | ||
return celestialPlane; | ||
} | ||
|
||
bool AxisDisplayInfo::isPermuted( const std::vector<AxisDisplayInfo>& displayInfos){ | ||
int axesCount = displayInfos.size(); | ||
bool actualPerm = false; | ||
//Decide if we really need to do a permutation based on whether | ||
//any of the axes have changed from their nominal position. | ||
for ( int i = 0; i < axesCount; i++ ){ | ||
if ( displayInfos[i].getPermuteIndex() != i ){ | ||
actualPerm = true; | ||
break; | ||
} | ||
} | ||
return actualPerm; | ||
} | ||
|
||
AxisDisplayInfo::AxisDisplayInfo(){ | ||
m_type = AxisInfo::KnownType::OTHER; | ||
m_frameCount = 0; | ||
m_frame = 0; | ||
m_permuteIndex = -1; | ||
} | ||
|
||
AxisDisplayInfo::AxisDisplayInfo( const AxisDisplayInfo& other){ | ||
m_type = other.getAxisType(); | ||
m_frameCount = other.getFrameCount(); | ||
m_frame = other.getFrame(); | ||
m_permuteIndex = other.getPermuteIndex(); | ||
} | ||
|
||
|
||
|
||
AxisDisplayInfo& AxisDisplayInfo::operator=( const AxisDisplayInfo& other ){ | ||
if ( this != &other ){ | ||
m_type = other.getAxisType(); | ||
m_frameCount = other.getFrameCount(); | ||
m_frame = other.getFrame(); | ||
m_permuteIndex = other.getPermuteIndex(); | ||
} | ||
return *this; | ||
} | ||
|
||
bool AxisDisplayInfo::operator==( const AxisDisplayInfo& other ) const{ | ||
bool equalInfo = false; | ||
if ( m_type == other.getAxisType() ){ | ||
if ( m_frameCount == other.getFrameCount() ){ | ||
if ( m_frame == other.getFrame() ){ | ||
if ( m_permuteIndex == other.getPermuteIndex() ){ | ||
equalInfo = true; | ||
} | ||
} | ||
} | ||
} | ||
return equalInfo; | ||
} | ||
|
||
bool AxisDisplayInfo::operator!=( const AxisDisplayInfo& other ) const { | ||
return !( *this == other ); | ||
} | ||
|
||
AxisInfo::KnownType AxisDisplayInfo::getAxisType() const { | ||
return m_type; | ||
} | ||
|
||
int AxisDisplayInfo::getFrameCount() const { | ||
return m_frameCount; | ||
} | ||
|
||
int AxisDisplayInfo::getFrame() const { | ||
return m_frame; | ||
} | ||
|
||
int AxisDisplayInfo::getPermuteIndex() const { | ||
return m_permuteIndex; | ||
} | ||
|
||
void AxisDisplayInfo::setAxisType( const Carta::Lib::AxisInfo::KnownType type ) { | ||
m_type = type; | ||
} | ||
|
||
void AxisDisplayInfo::setFrameCount( int count ){ | ||
CARTA_ASSERT( count >= 0 ); | ||
m_frameCount = count; | ||
} | ||
|
||
void AxisDisplayInfo::setFrame( int frame ){ | ||
CARTA_ASSERT( frame >= -1 && frame < m_frameCount ); | ||
m_frame = frame; | ||
} | ||
|
||
|
||
void AxisDisplayInfo::setPermuteIndex( int index ){ | ||
CARTA_ASSERT( index >= 0 ); | ||
m_permuteIndex = index; | ||
} | ||
|
||
QString AxisDisplayInfo::toString() const { | ||
QString result ("Frame: "+QString::number( m_frame ) + "\n"); | ||
result = result + "Frame Count:" + QString::number( m_frameCount ) + "\n"; | ||
result = result + "Type:" + QString::number( static_cast<int>(m_type) )+ "\n"; | ||
result = result + "Permute:"+ QString::number( m_permuteIndex ) + "\n"; | ||
return result; | ||
} | ||
|
||
AxisDisplayInfo::~AxisDisplayInfo(){ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/*** | ||
* Information about how an axis should be displayed. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <vector> | ||
#include "CartaLib/AxisInfo.h" | ||
|
||
namespace Carta { | ||
|
||
namespace Lib { | ||
|
||
class AxisDisplayInfo { | ||
|
||
public: | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
AxisDisplayInfo( ); | ||
|
||
/** | ||
* Copy constructor. | ||
*/ | ||
AxisDisplayInfo( const AxisDisplayInfo& other); | ||
|
||
/** | ||
* Assignment operator. | ||
*/ | ||
AxisDisplayInfo& operator=( const AxisDisplayInfo& other ); | ||
|
||
/** | ||
* Equality operator. | ||
* @param other an AxisDisplayInfo to compare this one to. | ||
* @return true if the AxisDisplayInfos are the same; false otherwise. | ||
*/ | ||
bool operator==( const AxisDisplayInfo& other ) const; | ||
|
||
/** | ||
* Inequality operator. | ||
* @param other an AxisDisplayInfo to compare this one to. | ||
* @return true if the AxisDisplayInfos are NOT the same; false otherwise. | ||
*/ | ||
bool operator!=( const AxisDisplayInfo& other ) const; | ||
|
||
/** | ||
* Return the axis type. | ||
* @return - the axis type. | ||
*/ | ||
Carta::Lib::AxisInfo::KnownType getAxisType() const; | ||
|
||
/** | ||
* Return the current axis frame. | ||
* @return - the current axis frame. | ||
*/ | ||
int getFrame() const; | ||
|
||
/** | ||
* Return the total number of frames in the axis. | ||
* @return - the total number of frames for the axis. | ||
*/ | ||
int getFrameCount() const; | ||
|
||
/** | ||
* Return the index of the axis in display order. | ||
* @return - the display index of the axis. | ||
*/ | ||
//For example, the spectral axis might have index 3 in the image, but | ||
//we would permute it to being axis 0 if we wanted to plot Channel vs Something. | ||
//The axes are permuted so the horizontal and vertical display axes come first. | ||
int getPermuteIndex() const; | ||
|
||
/** | ||
* Set the type of the axis. | ||
* @param type - the axis type. | ||
*/ | ||
void setAxisType( const Carta::Lib::AxisInfo::KnownType type ); | ||
|
||
/** | ||
* Set the total number of frames in the axis. | ||
* @param count - the total number of frames in the axis. | ||
*/ | ||
void setFrameCount( int count ); | ||
|
||
/** | ||
* Set the current axis frame. | ||
* @param frame - the current axis frame. | ||
*/ | ||
void setFrame( int frame ); | ||
|
||
/** | ||
* Set the index of the axis in display order (the horizontal and vertical | ||
* display axes should be the first axes in display order). | ||
* @param - index of the axis in display order. | ||
*/ | ||
//Note: 0-based index. | ||
void setPermuteIndex( int index ); | ||
|
||
/** | ||
* Return a string representation of the axis display information. | ||
* @return - a string representation of the axis display information. | ||
*/ | ||
QString toString() const; | ||
|
||
/** | ||
* Return true if the display axes are in the celestial plane; false if they | ||
* include an axis outside of the celestial plane such as a spectral axis. | ||
* @return - true if both display axes are in the celestial plane; false, otherwise. | ||
*/ | ||
static bool isCelestialPlane( const std::vector<AxisDisplayInfo>& displayInfos ); | ||
|
||
/** | ||
* Return true if the display axes have been permuted from their original ordering in the | ||
* image; false otherwise. | ||
* @return - true if the display axes have been permuted; false, otherwise. | ||
*/ | ||
static bool isPermuted( const std::vector<AxisDisplayInfo>& displayInfos); | ||
|
||
/** | ||
* Destructor. | ||
*/ | ||
virtual ~AxisDisplayInfo(); | ||
|
||
private: | ||
|
||
Carta::Lib::AxisInfo::KnownType m_type; | ||
int m_frameCount; | ||
int m_frame; | ||
int m_permuteIndex; | ||
|
||
}; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.