Skip to content

Commit

Permalink
Merge pull request #162 from Astroua/develop
Browse files Browse the repository at this point in the history
Release 0.6.1
  • Loading branch information
alexstrilets committed May 10, 2016
2 parents 4661a7f + dbd0bea commit 65fd57e
Show file tree
Hide file tree
Showing 184 changed files with 12,224 additions and 3,990 deletions.
4 changes: 4 additions & 0 deletions carta/cpp/CartaLib/CartaLib.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ SOURCES += \
Hooks/ConversionSpectralHook.cpp \
Hooks/Histogram.cpp \
Hooks/HistogramResult.cpp \
Hooks/ProfileHook.cpp \
Hooks/ImageStatisticsHook.cpp \
Hooks/LoadRegion.cpp \
Hooks/Plot2DResult.cpp \
Expand All @@ -31,6 +32,7 @@ SOURCES += \
IPlotLabelGenerator.cpp \
Hooks/LoadAstroImage.cpp \
PixelPipeline/CustomizablePixelPipeline.cpp \
ProfileInfo.cpp \
PWLinear.cpp \
StatInfo.cpp \
VectorGraphics/VGList.cpp \
Expand All @@ -53,6 +55,7 @@ HEADERS += \
Hooks/ConversionSpectralHook.h \
Hooks/Histogram.h \
Hooks/HistogramResult.h \
Hooks/ProfileHook.h \
Hooks/HookIDs.h \
Hooks/ImageStatisticsHook.h \
Hooks/LoadRegion.h \
Expand All @@ -71,6 +74,7 @@ HEADERS += \
TPixelPipeline/IScalar2Scalar.h \
PixelPipeline/IPixelPipeline.h \
PixelPipeline/CustomizablePixelPipeline.h \
ProfileInfo.h \
PWLinear.h \
StatInfo.h \
VectorGraphics/VGList.h \
Expand Down
38 changes: 37 additions & 1 deletion carta/cpp/CartaLib/Hooks/HistogramResult.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include <CartaLib/Hooks/HistogramResult.h>
#include <QDebug>

namespace Carta {
namespace Lib {
namespace Hooks {
Expand All @@ -12,19 +14,53 @@ HistogramResult::HistogramResult( const QString histogramName,
}



double HistogramResult::getFrequencyMin() const {
return m_frequencyMin;
}


double HistogramResult::getFrequencyMax() const {
return m_frequencyMax;
}


void HistogramResult::setFrequencyBounds( double minFreq, double maxFreq ){
m_frequencyMin = minFreq;
m_frequencyMax = maxFreq;
}


QDataStream &operator<<(QDataStream& out, const HistogramResult& result ){
out << result.getName()<< result.getUnitsX() << result.getUnitsY();
std::vector<std::pair<double,double>> data = result.getData();
int dataCount = data.size();
out << dataCount;
for ( int i = 0; i < dataCount; i++ ){
out << data[i].first << data[i].second;
}
return out;
}


QDataStream &operator>>(QDataStream& in, HistogramResult& result ){
QString name;
QString unitsX;
QString unitsY;
int dataCount;
in >> name >> unitsX >> unitsY;
in >> dataCount;
std::vector<std::pair<double,double> > data( dataCount );
for ( int i = 0; i < dataCount; i++ ){
double firstEle;
double secondEle;
in >> firstEle >> secondEle;
data[i] = std::pair<double,double>( firstEle, secondEle );
}
result = HistogramResult( name, unitsX, unitsY, data );
return in;
}


}
}

Expand Down
9 changes: 9 additions & 0 deletions carta/cpp/CartaLib/Hooks/HistogramResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <vector>
#include "Plot2DResult.h"

#include <QDataStream>

namespace Carta{
namespace Lib{

Expand Down Expand Up @@ -41,10 +43,17 @@ class HistogramResult : public Plot2DResult {

virtual ~HistogramResult(){}



private:
double m_frequencyMin;
double m_frequencyMax;
};

//Serialization so that the histogram result can be generated in a separate process.
QDataStream &operator<<(QDataStream& out, const Carta::Lib::Hooks::HistogramResult& result );
QDataStream &operator>>(QDataStream& in, Carta::Lib::Hooks::HistogramResult& result );

}
}
}
2 changes: 2 additions & 0 deletions carta/cpp/CartaLib/Hooks/HookIDs.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ enum class UniqueHookIDs {
GetWcsGridRendererHook_ID,
GetInitialFileList_ID,
GetImageRenderService_ID,
ProfileHook_ID,
ImageStatisticsHook_ID,


/// experimental, soon to be removed:
PreRender_ID,
LoadImage_ID
Expand Down
4 changes: 3 additions & 1 deletion carta/cpp/CartaLib/Hooks/Plot2DResult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ QString Plot2DResult::getUnitsY() const {
return m_unitsY;
}


void Plot2DResult::setName( const QString& name ){
m_name = name;
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions carta/cpp/CartaLib/Hooks/Plot2DResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ class Plot2DResult {
*/
QString getUnitsY() const;

/**
* Set the title of the plot data.
* @param name - a title for the plot data.
*/
void setName( const QString& name );

virtual ~Plot2DResult(){}

protected:
Expand Down
7 changes: 7 additions & 0 deletions carta/cpp/CartaLib/Hooks/ProfileHook.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
*
**/


#include "ProfileHook.h"

64 changes: 64 additions & 0 deletions carta/cpp/CartaLib/Hooks/ProfileHook.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Hook for generating profile data.
*
**/

#pragma once

#include "CartaLib/CartaLib.h"
#include "CartaLib/IPlugin.h"
#include "CartaLib/RegionInfo.h"
#include "CartaLib/ProfileInfo.h"

namespace Carta
{
namespace Lib
{
namespace Image {
class ImageInterface;
}
namespace Hooks
{
class ProfileHook : public BaseHook
{
CARTA_HOOK_BOILER1( ProfileHook );

public:
//The intensity counts
typedef std::vector<double> ResultType;

/**
* @brief Params
*/
struct Params {

Params( std::shared_ptr<Image::ImageInterface> dataSource,
Carta::Lib::RegionInfo regionInfo,
Carta::Lib::ProfileInfo profileInfo ){
m_dataSource = dataSource;
m_regionInfo = regionInfo;
m_profileInfo = profileInfo;
}

std::shared_ptr<Image::ImageInterface> m_dataSource;
Carta::Lib::RegionInfo m_regionInfo;
Carta::Lib::ProfileInfo m_profileInfo;
};

/**
* @brief PreRender
* @param pptr
*
* @todo make hook constructors protected, so that only hook helper can create them
*/
ProfileHook( Params * pptr ) : BaseHook( staticId ), paramsPtr( pptr )
{
CARTA_ASSERT( is < Me > () );
}

ResultType result;
Params * paramsPtr;
};
}
}
}
3 changes: 1 addition & 2 deletions carta/cpp/CartaLib/IRemoteVGView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ LayeredRemoteVGView::p_timerCB()
}

QImage buff( size, QImage::Format_ARGB32_Premultiplied );
buff.fill( QColor( 0, 0, 0, 255 ) );
buff.fill( QColor( 0, 0, 0, 0 ) );

// now go through the layers and paint them on top of the last result
for ( auto & layer : m_rasterLayers ) {
Expand All @@ -145,7 +145,6 @@ LayeredRemoteVGView::p_timerCB()
}
combiner->combine( buff, layer.qimg );
}

m_vgView-> setRaster( buff );

// concatenate all VG lists into one
Expand Down
33 changes: 33 additions & 0 deletions carta/cpp/CartaLib/ProfileInfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include "ProfileInfo.h"

namespace Carta {
namespace Lib {

ProfileInfo::ProfileInfo(){
m_restFrequency = 0;
m_restUnit = "GHz";
}

ProfileInfo::AggregateType ProfileInfo::getAggregateType() const {
return m_aggregateType;
}

double ProfileInfo::getRestFrequency() const {
return m_restFrequency;
}

QString ProfileInfo::getRestUnit() const {
return m_restUnit;
}


ProfileInfo & ProfileInfo::setAggregateType( const ProfileInfo::AggregateType & knownType ){
m_aggregateType = knownType;
return * this;
}

ProfileInfo::~ProfileInfo(){

}
} // namespace Lib
} // namespace Carta
64 changes: 64 additions & 0 deletions carta/cpp/CartaLib/ProfileInfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#pragma once

#include <QString>

namespace Carta
{
namespace Lib
{
class ProfileInfo
{
public:
/// Methods of summarizing profiles
enum class AggregateType
{
MEAN,
MEDIAN,
RMS,
SUM,
FLUX_DENSITY,
VARIANCE,
MIN,
MAX,
OTHER
};

/**
* Constructor.
*/
ProfileInfo();

/**
* Return the method to be used for aggregating data.
* @return - the method used for aggregating data.
*/
AggregateType getAggregateType() const;

/**
* Return the rest frequency used in generating the profile.
* @return - the rest frequency used in generating the profile.
*/
double getRestFrequency() const;

/**
* Return the rest frequency unit.
* @return - the rest frequency unit.
*/
QString getRestUnit() const;

/**
* Set the method used for aggregating data.
* @param aggType - the method used for aggregating data.
*/
ProfileInfo & setAggregateType( const AggregateType & aggType );

virtual ~ProfileInfo();

protected:
AggregateType m_aggregateType = AggregateType::OTHER;
double m_restFrequency;
QString m_restUnit;
};

} // namespace Lib
} // namespace Carta
7 changes: 6 additions & 1 deletion carta/cpp/core/Data/Animator/Animator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ Controller* Animator::_getControllerSelected() const {
else {
//Find the first controller that has an image.
int linkCount = m_linkImpl->getLinkCount();
Controller* alt = nullptr;
for ( int i = 0; i < linkCount; i++ ){
Controller* control = dynamic_cast<Controller*>( m_linkImpl->getLink(i) );
if ( control != nullptr ){
Expand All @@ -249,10 +250,14 @@ Controller* Animator::_getControllerSelected() const {
controller = control;
break;
}
alt = control;
}
}
//Otherwise, just choose one.
if ( controller == nullptr ){
controller = alt;
}
}

return controller;
}

Expand Down
4 changes: 2 additions & 2 deletions carta/cpp/core/Data/Animator/AnimatorType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ QString AnimatorType::_makeSelection(){
objManager->destroyObject( m_select->getId());
}
m_select = objManager->createObject<Selection>();
connect( m_select, SIGNAL(indexChanged(bool)), this, SLOT(_selectionChanged(bool)));
connect( m_select, SIGNAL(indexChanged()), this, SLOT(_selectionChanged()));
QString path = m_select->getPath();
return path;
}
Expand All @@ -232,7 +232,7 @@ void AnimatorType::resetStateData( const QString& state ){
}
}

void AnimatorType::_selectionChanged( bool /*forceReload*/ ){
void AnimatorType::_selectionChanged(){
emit indexChanged( m_select->getIndex(), m_type );
}

Expand Down
2 changes: 1 addition & 1 deletion carta/cpp/core/Data/Animator/AnimatorType.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class AnimatorType : public QObject, public Carta::State::CartaObject {
void indexChanged(int,const QString&);

private slots:
void _selectionChanged( bool );
void _selectionChanged();

private:
void _setType( const QString& type );
Expand Down
Loading

0 comments on commit 65fd57e

Please sign in to comment.