Skip to content
This repository has been archived by the owner on Dec 12, 2019. It is now read-only.

Commit

Permalink
Merge pull request #102 from Astroua/develop
Browse files Browse the repository at this point in the history
release 0.4.1 merging form develop into master
  • Loading branch information
alexstrilets committed Oct 29, 2015
2 parents 682337a + ee93491 commit 1efe006
Show file tree
Hide file tree
Showing 111 changed files with 3,170 additions and 3,741 deletions.
137 changes: 137 additions & 0 deletions carta/cpp/CartaLib/AxisDisplayInfo.cpp
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(){

}
}
}
135 changes: 135 additions & 0 deletions carta/cpp/CartaLib/AxisDisplayInfo.h
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;

};

}
}
7 changes: 7 additions & 0 deletions carta/cpp/CartaLib/AxisLabelInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ bool AxisLabelInfo::operator!=( const AxisLabelInfo& other ) const {
return !( *this == other );
}

QString AxisLabelInfo::toString() const {
QString str( "Location="+QString::number(static_cast<int>(m_location))+"\n");
str = str + "Format="+QString::number(static_cast<int>(m_format))+"\n";
str = str + "Precision="+ QString::number(m_precision) + "\n";
return str;
}

AxisLabelInfo::~AxisLabelInfo(){
}

Expand Down
6 changes: 6 additions & 0 deletions carta/cpp/CartaLib/AxisLabelInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class AxisLabelInfo
DEG_MIN_SEC,
DECIMAL_DEG,
HR_MIN_SEC,
DECIMAL,
OTHER
};

Expand Down Expand Up @@ -90,6 +91,11 @@ class AxisLabelInfo
*/
bool operator!=( const AxisLabelInfo& other ) const;

/**
* Return a string representation of the axis label information (for debugging).
* @return - a string representation of the axis label information.
*/
QString toString() const;

private:
Formats m_format;
Expand Down
2 changes: 2 additions & 0 deletions carta/cpp/CartaLib/CartaLib.pro
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ SOURCES += \
Slice.cpp \
AxisInfo.cpp \
AxisLabelInfo.cpp \
AxisDisplayInfo.cpp \
ICoordinateFormatter.cpp \
IPlotLabelGenerator.cpp \
Hooks/LoadAstroImage.cpp \
Expand Down Expand Up @@ -49,6 +50,7 @@ HEADERS += \
Slice.h \
AxisInfo.h \
AxisLabelInfo.h \
AxisDisplayInfo.h \
ICoordinateFormatter.h \
IPlotLabelGenerator.h \
Hooks/LoadAstroImage.h \
Expand Down
3 changes: 0 additions & 3 deletions carta/cpp/CartaLib/ICoordinateFormatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ class CoordinateFormatterInterface {
/// enable printing of an axis
virtual Me & enableAxis(int ind) = 0;

/// Set the axes the user will see (3 axis: x,y axes plus a hidden axis).
virtual void setDisplayAxes( std::vector<Carta::Lib::AxisInfo::KnownType> displayAxes ) = 0;

/// get the sky coordinate system used right now
virtual KnownSkyCS skyCS() = 0;

Expand Down
10 changes: 10 additions & 0 deletions carta/cpp/CartaLib/IImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,16 @@ class ImageInterface
virtual const Unit &
getPixelUnit() const = 0;

/// Return the image with the axes permuted in the order given by indices.
/// Passing in [1,2,0] for an image with 3 axes would result in the axis map
/// 0 -> 1
/// 1 -> 2
/// 2 -> 0
/// That is, the second axis in this image would become the first axis in the
/// returned image.
virtual std::shared_ptr<Image::ImageInterface>
getPermuted(const std::vector<int> & indices) = 0;

/// return dimensions of the image
virtual const VI &
dims() const = 0;
Expand Down
6 changes: 3 additions & 3 deletions carta/cpp/CartaLib/IWcsGridRenderService.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "CartaLib/IImage.h"
#include "CartaLib/AxisLabelInfo.h"
#include "CartaLib/VectorGraphics/VGList.h"
#include "CartaLib/AxisDisplayInfo.h"
#include <memory>

namespace Carta
Expand Down Expand Up @@ -49,10 +50,9 @@ class IWcsGridRenderService : public QObject
};

/// set the new ordering for the axes in cases where the display axes are not
/// the first two axes in the image. The perm list should match the dimensions
/// in the image and containing unique integers ranging from 1 to perms.size().
/// the first two axes in the image.
virtual void
setAxisPermutations( std::vector<int> perms ) = 0;
setAxisDisplayInfo( std::vector<AxisDisplayInfo> displayInfos ) = 0;

/// set the input data, shold have at least 2 dimensions
/// \note the data is not imporant, only meta data attached to this is important
Expand Down
Loading

0 comments on commit 1efe006

Please sign in to comment.