Commit e38d3668 authored by Frédéric Larue's avatar Frédéric Larue
Browse files

Initial commit from a clean version of ASTexGUI.

parents
get_filename_component( CURRENT_TARGET ${CMAKE_SOURCE_DIR} NAME )
message( STATUS "Creating solution " ${CURRENT_TARGET} )
project( ${CURRENT_TARGET} )
# Look for required packages.
if( WIN32 )
set( CMAKE_PREFIX_PATH
D:/Programs/Qt5.6.0/5.6/msvc2015_64
)
set( GLEW_LIBRARIES glew32.lib )
set( GL_LIBRARIES opengl32.lib )
endif()
if( UNIX )
set( CMAKE_PREFIX_PATH
/opt/Qt/5.6/gcc_64/lib/cmake
)
set( GL_LIBRARIES GL )
find_package( GLEW REQUIRED )
endif()
find_package( Qt5 COMPONENTS Widgets REQUIRED )
# OS dependent definitions.
if( WIN32 )
add_definitions( -D_USE_MATH_DEFINES -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -DUNICODE )
# Detect platform.
if( CMAKE_SHARED_LINKER_FLAGS MATCHES ".+x64" )
set( PLATFORM "x64" )
else()
set( PLATFORM "Win32" )
endif()
message( STATUS "Detected platform: " ${PLATFORM} )
# Set output directories.
#set( CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/install/${PLATFORM} )
endif()
if( UNIX )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++11" )
endif()
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release )
set( PLUGINS_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG}/plugins )
set( PLUGINS_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE}/plugins )
message( STATUS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} )
set( ENABLE_SOLUTION_FOLDERS (MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode) )
if( ENABLE_SOLUTION_FOLDERS )
set_property( GLOBAL PROPERTY USE_FOLDERS ON )
endif()
# Set default include directories.
include_directories(
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/GLViewer
${CMAKE_SOURCE_DIR}/GPU
${CMAKE_SOURCE_DIR}/GUI_main
${CMAKE_SOURCE_DIR}/Interfaces
${CMAKE_SOURCE_DIR}/UIData
${CMAKE_SOURCE_DIR}/UIParam
${CMAKE_SOURCE_DIR}/NodeEditor
${Qt5Widgets_INCLUDE_DIRS}
${GLEW_DIR}/include
)
# Add projects required for the ASTexGUI's minimal application.
set( UI_CORE_COMPONENTS
GLViewer
GPU
Interfaces
NodeEditor
UIData
UIParam
)
set( UI_ALL_COMPONENTS ${UI_CORE_COMPONENTS} ${UI_ADDITIONAL_COMPONENTS} )
message( STATUS "Adding core components:" )
add_subdirectory( GUI_main )
foreach( a IN ITEMS ${UI_ALL_COMPONENTS} )
add_subdirectory( ${a} )
endforeach()
# Add additional plug-in projects.
message( STATUS "Looking for plugins:" )
file( GLOB PLUGINS_DIR LIST_DIRECTORIES true ${CMAKE_SOURCE_DIR}/plugins/* )
foreach( PLUGIN_PATH IN ITEMS ${PLUGINS_DIR} )
if( IS_DIRECTORY ${PLUGIN_PATH} AND EXISTS ${PLUGIN_PATH}/CMakeLists.txt )
get_filename_component( PLUGIN_NAME ${PLUGIN_PATH} NAME )
message( STATUS " - " ${PLUGIN_NAME} )
add_subdirectory( ${PLUGIN_PATH} )
endif()
endforeach( PLUGIN_PATH )
# Install required external dependencies.
message( STATUS ${ASTEX_ROOT_DIR} )
if( WIN32 )
# TODO: install QT image format DLLs.
install( FILES "${GLEW_DIR}/bin/Release/x64/glew32.dll" DESTINATION ./Release CONFIGURATIONS Release )
install( FILES "${GLEW_DIR}/bin/Release/x64/glew32.dll" DESTINATION ./Debug CONFIGURATIONS Debug )
install( FILES "${_qt5Core_install_prefix}/bin/Qt5Cored.dll" DESTINATION ./Debug CONFIGURATIONS Debug )
install( FILES "${_qt5Core_install_prefix}/bin/Qt5Guid.dll" DESTINATION ./Debug CONFIGURATIONS Debug )
install( FILES "${_qt5Core_install_prefix}/bin/Qt5Widgetsd.dll" DESTINATION ./Debug CONFIGURATIONS Debug )
install( FILES "${_qt5Core_install_prefix}/plugins/platforms/qwindowsd.dll" DESTINATION ./Debug/platforms CONFIGURATIONS Debug )
install( FILES "${_qt5Core_install_prefix}/bin/Qt5Core.dll" DESTINATION ./Release CONFIGURATIONS Release )
install( FILES "${_qt5Core_install_prefix}/bin/Qt5Gui.dll" DESTINATION ./Release CONFIGURATIONS Release )
install( FILES "${_qt5Core_install_prefix}/bin/Qt5Widgets.dll" DESTINATION ./Release CONFIGURATIONS Release )
install( FILES "${_qt5Core_install_prefix}/plugins/platforms/qwindows.dll" DESTINATION ./Release/platforms CONFIGURATIONS Release )
file( GLOB QT_IMG_FORMAT_PLUGINS ${_qt5Core_install_prefix}/plugins/imageformats/*.dll )
foreach( PLUGIN_PATH IN ITEMS ${QT_IMG_FORMAT_PLUGINS} )
if( PLUGIN_PATH MATCHES ".+d\\.dll" )
install( FILES ${PLUGIN_PATH} DESTINATION ./Debug/imageformats CONFIGURATIONS Debug )
else()
install( FILES ${PLUGIN_PATH} DESTINATION ./Release/imageformats CONFIGURATIONS Release )
endif()
endforeach( PLUGIN_PATH )
endif()
/*
* (c) LSIIT, UMR CNRS/UdS
* Authors: O. Génevaux, F. Larue.
*
* See licence.txt for additional information.
*/
#ifndef __BOX_H__
#define __BOX_H__
#include <QVector2D>
#include <QVector3D>
/*
*
* CLASSES DECLARATIONS.
*
*/
/** Axis-aligned bounding box in 2D.
* \ingroup Acquisition
*/
class Box2f
{
/******************\
| Internal type(s) |
\******************/
public:
/** Set of 2D coordinates representing the corners of a bounding box.
*
* Provided by the BoundingBox::GetCorners function.
*/
class CornerSet
{
public:
typedef QVector2D *iterator;
typedef const QVector2D *const_iterator;
QVector2D xy; /**< Corner on ( X_min, Y_min ). */
QVector2D Xy; /**< Corner on ( X_max, Y_min ). */
QVector2D xY; /**< Corner on ( X_min, Y_max ). */
QVector2D XY; /**< Corner on ( X_max, Y_max ). */
/** Indexed access to the box corners. */
inline QVector2D& operator[]( const unsigned int i ) { return (&xy)[i]; }
/** Indexed access to the box corners (read-only version). */
inline const QVector2D& operator[]( const unsigned int i ) const { return (&xy)[i]; }
inline iterator begin() { return &xy; }
inline const_iterator begin() const { return &xy; }
inline iterator end() { return (&XY)+1; }
inline const_iterator end() const { return (&XY)+1; }
};
/********************\
| Member variable(s) |
\********************/
private:
#ifdef _WIN32
#pragma warning(disable: 4251)
#endif
QVector2D m_Min, m_Max;
/*****************************\
| Constructor(s) / destructor |
\*****************************/
public:
inline Box2f() { SetNull(); }
inline ~Box2f() { }
/********************\
| Member function(s) |
\********************/
public:
/** Initialization to an "unbounding box". */
inline void SetNull();
/** Check if the bounding box has been initialized. */
inline bool IsNull() const { return m_Min.x() > m_Max.x(); }
/** Box boundaries extension so as to bound the specified 3D point.
*
* \param[in] v Coordinates of the 2D point to bound.
*/
inline void Add( const QVector2D& v );
/** Box boundaries extension so as to bound the specified 3D point.
*
* \param[in] v Pointer to the coordinates of the 2D point to bound.
*/
inline void Add( const QVector2D* v );
/** Box boundaries extension so as to bound the specified box.
*
* \param[in] b Bounding box to bound.
*/
inline void Add( const Box2f& b );
/** Box boundaries extension so as to bound the specified box.
*
* \param[in] b Pointer to the bounding box to bound.
*/
inline void Add( const Box2f* b );
/** Check if a point is included in the box.
*
* \param[in] v Coordinates of the 2D point to check.
* \return True if the point is included in the box, false otherwise.
*/
inline bool Contains( const QVector2D& v ) const;
/** Check if a box is included in the box.
*
* \param[in] b Bounding box to check.
* \return True if the query box is included in the current one, false otherwise.
*/
inline bool Contains( const Box2f& b ) const;
/** Check if a box intersects the box.
*
* \param[in] b Bounding box to check.
* \return True if the query box intersects the current one, false otherwise.
*/
inline bool Intersects( const Box2f& b ) const;
/** Access to the lower boundaries of the box.
*
* \return Box lower boundaries.
*/
inline QVector2D& Min() { return m_Min; }
/** Access to the lower boundaries of the box (read only version).
*
* \return Box lower boundaries.
*/
inline const QVector2D& Min() const { return m_Min; }
/** Access to the upper boundaries of the box.
*
* \return Box upper boundaries.
*/
inline QVector2D& Max() { return m_Max; }
/** Access to the upper boundaries of the box (read only version).
*
* \return Box upper boundaries.
*/
inline const QVector2D& Max() const { return m_Max; }
/** Recovery of the dimensions of the box.
*
* \return Box dimensions.
*/
inline QVector2D Dimensions() const { return m_Max - m_Min; }
/** Recovery of diagonal length of the box.
*
* \return Diagonal length.
*/
inline float Diagonal() const { return Dimensions().length(); }
/** Recovery of the center point of the box.
*
* \return Box center.
*/
inline QVector2D Center() const { return 0.5f*( m_Min + m_Max ); }
/** Recovery of the height points representing the corners of the box.
*
* \return Set of corner points.
*/
inline void Corners( CornerSet &corners ) const;
/** Explicit specification of the box boundaries.
*
* \param[in] min Lower boundary.
* \param[in] max Upper boundary.
*/
inline void SetBoundaries( const QVector2D& min, const QVector2D& max );
/** Explicit specification of the box boundaries.
*
* \param[in] xMin Lower boundary along axis X.
* \param[in] xMax Upper boundary along axis X.
* \param[in] yMin Lower boundary along axis Y.
* \param[in] yMax Upper boundary along axis Y.
*/
inline void SetBoundaries( const float xMin, const float xMax,
const float yMin, const float yMax );
/** Recovery of the area of the box.
*
* \return Box area.
*/
inline float Area() const;
};
/*
*
* INLINE MEMBER FUNCTIONS DEFINITIONS.
*
*/
inline void Box2f::SetNull()
{
m_Min.setX( std::numeric_limits<float>::max() );
m_Min.setY( std::numeric_limits<float>::max() );
m_Max.setX( -std::numeric_limits<float>::max() );
m_Max.setY( -std::numeric_limits<float>::max() );
}
inline void Box2f::Add( const QVector2D& v )
{
if( v.x() < m_Min.x() )
m_Min.setX( v.x() );
if( v.x() > m_Max.x() )
m_Max.setX( v.x() );
if( v.y() < m_Min.y() )
m_Min.setY( v.y() );
if( v.y() > m_Max.y() )
m_Max.setY( v.y() );
}
inline void Box2f::Add( const QVector2D* v )
{
Add( *v );
}
inline void Box2f::Add( const Box2f& b )
{
if( b.m_Min.x() < m_Min.x() )
m_Min.setX( b.m_Min.x() );
if( b.m_Max.x() > m_Max.x() )
m_Max.setX( b.m_Max.x() );
if( b.m_Min.y() < m_Min.y() )
m_Min.setY( b.m_Min.y() );
if( b.m_Max.y() > m_Max.y() )
m_Max.setY( b.m_Max.y() );
}
inline void Box2f::Add( const Box2f* b )
{
Add( *b );
}
inline bool Box2f::Contains( const QVector2D& v ) const
{
return v.x() >= m_Min.x() && v.x() <= m_Max.x() &&
v.y() >= m_Min.y() && v.y() <= m_Max.y();
}
inline bool Box2f::Contains( const Box2f& b ) const
{
return b.m_Min.x() >= m_Min.x() && b.m_Max.x() <= m_Max.x() &&
b.m_Min.y() >= m_Min.y() && b.m_Max.y() <= m_Max.y();
}
inline bool Box2f::Intersects( const Box2f& b ) const
{
return b.m_Min.x() < m_Max.x() && b.m_Max.x() > m_Min.x() &&
b.m_Min.y() < m_Max.y() && b.m_Max.y() > m_Min.y();
}
inline void Box2f::SetBoundaries( const QVector2D& min, const QVector2D& max )
{
m_Min = min;
m_Max = max;
}
inline void Box2f::SetBoundaries( const float xMin, const float xMax,
const float yMin, const float yMax )
{
m_Min = QVector2D( xMin, yMin );
m_Max = QVector2D( xMax, yMax );
}
inline void Box2f::Corners( CornerSet &corners ) const
{
corners.xy = m_Min;
corners.Xy = QVector2D( m_Max.x(), m_Min.y() );
corners.xY = QVector2D( m_Min.x(), m_Max.y() );
corners.XY = m_Max;
}
inline float Box2f::Area() const
{
return IsNull()? 0.0f : (m_Max.x()-m_Min.x()) * (m_Max.y()-m_Min.y());
}
/*
*
* CLASSES DECLARATIONS.
*
*/
/** Axis-aligned bounding box in 3D.
* \ingroup Acquisition
*/
class Box3f
{
/******************\
| Internal type(s) |
\******************/
public:
/** Set of 3D coordinates representing the corners of a bounding box.
*
* Provided by the BoundingBox::GetCorners function.
*/
class CornerSet
{
public:
typedef QVector3D *iterator;
typedef const QVector3D *const_iterator;
QVector3D xyz; /**< Corner on ( X_min, Y_min, Z_min ). */
QVector3D xyZ; /**< Corner on ( X_min, Y_min, Z_max ). */
QVector3D xYz; /**< Corner on ( X_min, Y_max, Z_min ). */
QVector3D xYZ; /**< Corner on ( X_min, Y_max, Z_max ). */
QVector3D Xyz; /**< Corner on ( X_max, Y_min, Z_min ). */
QVector3D XyZ; /**< Corner on ( X_max, Y_min, Z_max ). */
QVector3D XYz; /**< Corner on ( X_max, Y_max, Z_min ). */
QVector3D XYZ; /**< Corner on ( X_max, Y_max, Z_max ). */
/** Indexed access to the box corners. */
inline QVector3D& operator[]( const unsigned int i ) { return (&xyz)[i]; }
/** Indexed access to the box corners (read-only version). */
inline const QVector3D& operator[]( const unsigned int i ) const { return (&xyz)[i]; }
inline iterator begin() { return &xyz; }
inline const_iterator begin() const { return &xyz; }
inline iterator end() { return (&XYZ)+1; }
inline const_iterator end() const { return (&XYZ)+1; }
};
/********************\
| Member variable(s) |
\********************/
private:
#ifdef _WIN32
#pragma warning(disable: 4251)
#endif
QVector3D m_Min, m_Max;
/*****************************\
| Constructor(s) / destructor |
\*****************************/
public:
inline Box3f() { SetNull(); }
inline ~Box3f() { }
/********************\
| Member function(s) |
\********************/
public:
/** Initialization to an "unbounding box". */
inline void SetNull();
/** Check if the bounding box has been initialized. */
inline bool IsNull() const { return m_Min.x() > m_Max.x(); }
/** Box boundaries extension so as to bound the specified 3D point.
*
* \param[in] v Coordinates of the 3D point to bound.
*/
inline void Add( const QVector3D& v );
/** Box boundaries extension so as to bound the specified 3D point.
*
* \param[in] v Pointer to the coordinates of the 3D point to bound.
*/
inline void Add( const QVector3D* v );
/** Box boundaries extension so as to bound the specified box.
*
* \param[in] b Bounding box to bound.
*/
inline void Add( const Box3f& b );
/** Box boundaries extension so as to bound the specified box.
*
* \param[in] b Pointer to the bounding box to bound.
*/
inline void Add( const Box3f* b );
/** Check if a point is included in the box.
*
* \param[in] v Coordinates of the 3D point to check.
* \return True if the point is included in the box, false otherwise.
*/
inline bool Contains( const QVector3D& v ) const;
/** Check if a box is included in the box.
*
* \param[in] b Bounding box to check.
* \return True if the query box is included in the current one, false otherwise.
*/
inline bool Contains( const Box3f& b ) const;
/** Check if a box intersects the box.
*
* \param[in] b Bounding box to check.
* \return True if the query box intersects the current one, false otherwise.
*/
inline bool Intersects( const Box3f& b ) const;
/** Access to the lower boundaries of the box.
*
* \return Box lower boundaries.
*/
inline QVector3D& Min() { return m_Min; }
/** Access to the lower boundaries of the box (read only version).
*
* \return Box lower boundaries.
*/
inline const QVector3D& Min() const { return m_Min; }
/** Access to the upper boundaries of the box.
*
* \return Box upper boundaries.
*/
inline QVector3D& Max() { return m_Max; }
/** Access to the upper boundaries of the box (read only version).
*
* \return Box upper boundaries.
*/
inline const QVector3D& Max() const { return m_Max; }
/** Recovery of the dimensions of the box.
*
* \return Box dimensions.
*/
inline QVector3D Dimensions() const { return m_Max - m_Min; }
/** Recovery of diagonal length of the box.
*
* \return Diagonal length.
*/
inline float Diagonal() const { return Dimensions().length(); }
/** Recovery of the center point of the box.
*
* \return Box center.
*/
inline QVector3D Center() const { return 0.5f*( m_Min + m_Max ); }
/** Recovery of the height points representing the corners of the box.
*
* \return Set of corner points.
*/
inline void Corners( CornerSet &corners ) const;
/** Explicit specification of the box boundaries.
*
* \param[in] min Lower boundary.