Skip to content

Commit

Permalink
Merge pull request #126 from arrayfire/devel
Browse files Browse the repository at this point in the history
Release 0.9.2
  • Loading branch information
9prady9 committed Dec 19, 2016
2 parents c6bea12 + 175a6b2 commit 4c8a291
Show file tree
Hide file tree
Showing 19 changed files with 2,416 additions and 1,059 deletions.
20 changes: 14 additions & 6 deletions CMakeModules/FindFontConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

if ( FONTCONFIG_INCLUDE_DIR AND FONTCONFIG_LIBRARY )
IF ( FONTCONFIG_INCLUDE_DIR AND FONTCONFIG_LIBRARY )
# in cache already
SET(Fontconfig_FIND_QUIETLY TRUE)
endif ( FONTCONFIG_INCLUDE_DIR AND FONTCONFIG_LIBRARY )
ENDIF ( FONTCONFIG_INCLUDE_DIR AND FONTCONFIG_LIBRARY )

# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
if(NOT WIN32)
find_package(PkgConfig)
IF (NOT WIN32)
FIND_PACKAGE(PkgConfig)

pkg_check_modules(FONTCONFIG_PKG QUIET fontconfig)
endif(NOT WIN32)
ENDIF (NOT WIN32)

FIND_PATH(FONTCONFIG_INCLUDE_DIR NAMES fontconfig/fontconfig.h
PATHS
Expand All @@ -32,6 +32,10 @@ FIND_PATH(FONTCONFIG_INCLUDE_DIR NAMES fontconfig/fontconfig.h
${FONTCONFIG_PKG_INCLUDE_DIRS} # Generated by pkg-config
)

IF (DEFINED FONTCONFIG_INCLUDE_DIR-NOTFOUND)
MESSAGE(FATAL_ERROR "FontConfig header files not found")
ENDIF (DEFINED FONTCONFIG_INCLUDE_DIR-NOTFOUND)

FIND_LIBRARY(FONTCONFIG_LIBRARY NAMES fontconfig ${FONTCONFIG_PKG_LIBRARY}
PATHS
/usr/local
Expand All @@ -44,7 +48,11 @@ FIND_LIBRARY(FONTCONFIG_LIBRARY NAMES fontconfig ${FONTCONFIG_PKG_LIBRARY}
lib
)

include(FindPackageHandleStandardArgs)
IF (DEFINED FONTCONFIG_LIBRARY-NOTFOUND)
MESSAGE(FATAL_ERROR "FontConfig library files not found")
ENDIF (DEFINED FONTCONFIG_LIBRARY-NOTFOUND)

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Fontconfig DEFAULT_MSG FONTCONFIG_LIBRARY FONTCONFIG_INCLUDE_DIR)

# show the FONTCONFIG_INCLUDE_DIR and FONTCONFIG_LIBRARY variables only in the advanced view
Expand Down
2 changes: 1 addition & 1 deletion CMakeModules/Version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ENDIF()

SET(FG_VERSION_MAJOR "0")
SET(FG_VERSION_MINOR "9")
SET(FG_VERSION_PATCH "0")
SET(FG_VERSION_PATCH "2")

SET(FG_VERSION "${FG_VERSION_MAJOR}.${FG_VERSION_MINOR}.${FG_VERSION_PATCH}")
SET(FG_API_VERSION_CURRENT ${FG_VERSION_MAJOR}${FG_VERSION_MINOR})
Expand Down
Binary file removed docs/images/gfx_palette.png
Binary file not shown.
8 changes: 6 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ OPTION(BUILD_EXAMPLES_CUDA "Turn off/on building cuda examples" ON)
OPTION(BUILD_EXAMPLES_OPENCL "Turn off/on building opencl examples" ON)
OPTION(USE_SYSTEM_CL2HPP "Use cl2.hpp header installed on the system" OFF)

INCLUDE(build_cl2hpp)
IF(NOT USE_SYSTEM_CL2HPP)
INCLUDE(build_cl2hpp)
ENDIF()

MACRO(BUILD_EXAMPLE EX_NAME EX_SRC COMPUTE_NAME FG_LIBS COMPUTE_LIBS)
IF(${COMPUTE_NAME} STREQUAL "cuda")
Expand All @@ -22,7 +24,9 @@ MACRO(BUILD_EXAMPLE EX_NAME EX_SRC COMPUTE_NAME FG_LIBS COMPUTE_LIBS)
RUNTIME_OUTPUT_DIRECTORY ${DIR_NAME}
FOLDER "Examples/${COMPUTE_NAME}")
IF(${COMPUTE_NAME} STREQUAL "opencl")
ADD_DEPENDENCIES(example_${EX_NAME}_${COMPUTE_NAME} cl2hpp)
IF(NOT USE_SYSTEM_CL2HPP)
ADD_DEPENDENCIES(example_${EX_NAME}_${COMPUTE_NAME} cl2hpp)
ENDIF()
ENDIF()
ENDMACRO()

Expand Down
16 changes: 8 additions & 8 deletions examples/cpu/surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@

using namespace std;

static const float XMIN = -8.0f;
static const float XMAX = 8.f;
static const float YMIN = -8.0f;
static const float YMAX = 8.f;
static const float XMIN = -32.0f;
static const float XMAX = 32.0f;
static const float YMIN = -32.0f;
static const float YMAX = 32.0f;

const float DX = 0.5;
const float DX = 0.25;
const size_t XSIZE = (XMAX-XMIN)/DX;
const size_t YSIZE = (YMAX-YMIN)/DX;

void genSurface(float dx, std::vector<float> &vec )
{
vec.clear();
for(float x=XMIN; x < XMAX; x+=dx){
for(float y=YMIN; y < YMAX; y+=dx){
for(float x=XMIN; x < XMAX; x+=dx) {
for(float y=YMIN; y < YMAX; y+=dx) {
vec.push_back(x);
vec.push_back(y);
float z = sqrt(x*x+y*y) + 2.2204e-16;
Expand All @@ -50,7 +50,7 @@ int main(void)
wnd.makeCurrent();

forge::Chart chart(FG_CHART_3D);
chart.setAxesLimits(-10.f, 10.f, -10.f, 10.f, -0.5f, 1.f);
chart.setAxesLimits(XMIN-2.0f, XMAX+2.0f, YMIN-2.0f, YMAX+2.0f, -0.5f, 1.f);
chart.setAxesTitles("x-axis", "y-axis", "z-axis");

forge::Surface surf = chart.surface(XSIZE, YSIZE, forge::f32);
Expand Down
33 changes: 32 additions & 1 deletion include/fg/chart.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,23 @@ FGAPI fg_err fg_set_chart_axes_limits(fg_chart pHandle,
const float pYmin, const float pYmax,
const float pZmin, const float pZmax);

/**
Get axes data ranges
\param[out] pXmin is x-axis minimum data value
\param[out] pXmax is x-axis maximum data value
\param[out] pYmin is y-axis minimum data value
\param[out] pYmax is y-axis maximum data value
\param[out] pZmin is z-axis minimum data value
\param[out] pZmax is z-axis maximum data value
\param[in] pHandle is chart handle
\ingroup chart_functions
*/
FGAPI fg_err fg_get_chart_axes_limits(float* pXmin, float* pXmax,
float* pYmin, float* pYmax,
float* pZmin, float* pZmax,
const fg_chart pHandle);
/**
Set legend position for Chart
Expand Down Expand Up @@ -268,7 +285,21 @@ class Chart {
*/
FGAPI void setAxesLimits(const float pXmin, const float pXmax,
const float pYmin, const float pYmax,
const float pZmin=-1, const float pZmax=1);
const float pZmin=0, const float pZmax=0);

/**
Get axes data ranges
\param[out] pXmin is x-axis minimum data value
\param[out] pXmax is x-axis maximum data value
\param[out] pYmin is y-axis minimum data value
\param[out] pYmax is y-axis maximum data value
\param[out] pZmin is z-axis minimum data value
\param[out] pZmax is z-axis maximum data value
*/
FGAPI void getAxesLimits(float* pXmin, float* pXmax,
float* pYmin, float* pYmax,
float* pZmin = NULL, float* pZmax = NULL);

/**
Set legend position for Chart
Expand Down
20 changes: 11 additions & 9 deletions include/fg/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,19 @@ typedef enum {

/**
Color maps
\image html gfx_palette.png
*/
typedef enum {
FG_COLOR_MAP_DEFAULT = 0, ///< Default [0-255] grayscale colormap
FG_COLOR_MAP_SPECTRUM = 1, ///< Spectrum color
FG_COLOR_MAP_COLORS = 2, ///< Pure Colors
FG_COLOR_MAP_RED = 3, ///< Red color map
FG_COLOR_MAP_MOOD = 4, ///< Mood color map
FG_COLOR_MAP_HEAT = 5, ///< Heat color map
FG_COLOR_MAP_BLUE = 6 ///< Blue color map
FG_COLOR_MAP_DEFAULT = 0, ///< Default [0-255] grayscale colormap
FG_COLOR_MAP_SPECTRUM = 1, ///< Visual spectrum (390nm-830nm) in sRGB colorspace
FG_COLOR_MAP_RAINBOW = 2, ///< Rainbow color map
FG_COLOR_MAP_RED = 3, ///< Red color map
FG_COLOR_MAP_MOOD = 4, ///< Mood color map
FG_COLOR_MAP_HEAT = 5, ///< Heat color map
FG_COLOR_MAP_BLUE = 6, ///< Blue color map
FG_COLOR_MAP_INFERNO = 7, ///< perceptually uniform shades of black-red-yellow
FG_COLOR_MAP_MAGMA = 8, ///< perceptually uniform shades of black-red-white
FG_COLOR_MAP_PLASMA = 9, ///< perceptually uniform shades of blue-red-yellow
FG_COLOR_MAP_VIRIDIS = 10, ///< perceptually uniform shades of blue-green-yellow
} fg_color_map;

typedef enum {
Expand Down
22 changes: 22 additions & 0 deletions src/api/c/chart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,28 @@ fg_err fg_set_chart_axes_limits(fg_chart pHandle,
return FG_ERR_NONE;
}

fg_err fg_get_chart_axes_limits(float* pXmin, float* pXmax,
float* pYmin, float* pYmax,
float* pZmin, float* pZmax,
const fg_chart pHandle)
{
try {
float xmin, xmax, ymin, ymax, zmin, zmax;
getChart(pHandle)->getAxesLimits(&xmin, &xmax, &ymin, &ymax, &zmin, &zmax);

// Check for NULLs and assign
if(pXmin) *pXmin = xmin;
if(pXmax) *pXmax = xmax;
if(pYmin) *pYmin = ymin;
if(pYmax) *pYmax = ymax;
if(pZmin) *pZmin = zmin;
if(pZmax) *pZmax = zmax;
}
CATCHALL

return FG_ERR_NONE;
}

fg_err fg_set_chart_legend_position(fg_chart pHandle, const float pX, const float pY)
{
try {
Expand Down
18 changes: 18 additions & 0 deletions src/api/cpp/chart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,24 @@ void Chart::setAxesLimits(const float pXmin, const float pXmax,
} CATCH_INTERNAL_TO_EXTERNAL
}

void Chart::getAxesLimits(float* pXmin, float* pXmax,
float* pYmin, float* pYmax,
float* pZmin, float* pZmax)
{
try {
float xmin, xmax, ymin, ymax, zmin, zmax;
getChart(mValue)->getAxesLimits(&xmin, &xmax, &ymin, &ymax, &zmin, &zmax);

// Check for NULLs and assign
if(pXmin) *pXmin = xmin;
if(pXmax) *pXmax = xmax;
if(pYmin) *pYmin = ymin;
if(pYmax) *pYmax = ymax;
if(pZmin) *pZmin = zmin;
if(pZmax) *pZmax = zmax;
} CATCH_INTERNAL_TO_EXTERNAL
}

void Chart::setLegendPosition(const float pX, const float pY)
{
try {
Expand Down
6 changes: 6 additions & 0 deletions src/backend/chart.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ class Chart {
mChart->setAxesLimits(pXmin, pXmax, pYmin, pYmax, pZmin, pZmax);
}

inline void getAxesLimits(float* pXmin, float* pXmax,
float* pYmin, float* pYmax,
float* pZmin, float* pZmax) {
mChart->getAxesLimits(pXmin, pXmax, pYmin, pYmax, pZmin, pZmax);
}

inline void setLegendPosition(const unsigned pX, const unsigned pY) {
mChart->setLegendPosition(pX, pY);
}
Expand Down
Loading

0 comments on commit 4c8a291

Please sign in to comment.