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

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()
This diff is collapsed.
cmake_minimum_required( VERSION 3.0 )
get_filename_component( CURRENT_TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME )
message( STATUS " - " ${CURRENT_TARGET} )
project( ${CURRENT_TARGET} LANGUAGES CXX )
#include_directories( ${Qt5Widgets_INCLUDE_DIRS} )
include_directories( ${ASTEX_INCLUDE_DIRS} )
set( CMAKE_AUTOMOC ON )
file( GLOB LIB_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.h )
file( GLOB LIB_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp )
add_library( ${PROJECT_NAME} ${LIB_HEADERS} ${LIB_SOURCES} )
target_link_libraries( ${PROJECT_NAME} ${ASTEX_LIBRARIES} )
if( ENABLE_SOLUTION_FOLDERS )
set_target_properties( ${PROJECT_NAME} PROPERTIES FOLDER "Core" )
endif()
This diff is collapsed.
This diff is collapsed.
/*
* (c) LSIIT, UMR CNRS/UdS
* Authors: O. Gnevaux, F. Larue.
*
* See licence.txt for additional information.
*/
#include "GLViewer.h"
#include "Panel.h"
#include "InfoBar.h"
#include "InfoBarManager.h"
InfoBar::InfoBar( const unsigned int thickness, const bool visible ) :
QObject(),
m_Parent(NULL),
m_Thickness(thickness),
m_FitToContent(thickness==0),
m_AlphaTime( visible? 1.0f : 0.0f ),
m_Alpha( visible? 1.0f : 0.0f ),
m_AlphaFadeOffset(m_ShowingSpeed),
m_ShowingSpeed(0.075f),
m_HidingSpeed(0.075f)
{
m_Timer = new QTimer( this );
connect( m_Timer, SIGNAL(timeout()), this, SLOT(updateTransparency()) );
}
InfoBar::~InfoBar()
{
for( std::list<Panel*>::iterator p=m_Panels.begin(); p!=m_Panels.end(); ++p )
delete *p;
}
void InfoBar::display()
{
glPushAttrib( GL_LINE_BIT | GL_HINT_BIT | GL_CURRENT_BIT );
glEnable( GL_LINE_SMOOTH );
glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
switch( m_Orientation )
{
case LEFT:
{
glBegin( GL_QUAD_STRIP );
glColor4f( 0.5f, 0.5f, 0.5f, 0.4f*m_Alpha );
glVertex2i( m_Rect.left(), m_Rect.bottom() );
glVertex2i( m_Rect.left(), m_Rect.top() );
glVertex2i( m_Rect.right()-10, m_Rect.bottom() );
glVertex2i( m_Rect.right()-10, m_Rect.top() );
glColor4f( 0.5f, 0.5f, 0.5f, 0.6f*m_Alpha );
glVertex2i( m_Rect.right(), m_Rect.bottom() );
glVertex2i( m_Rect.right(), m_Rect.top() );
glEnd();
glBegin( GL_LINES );
glColor4f( 0.5f, 0.5f, 0.5f, m_Alpha );
glVertex2i( m_Rect.right(), m_Rect.bottom() );
glVertex2i( m_Rect.right(), m_Rect.top() );
glEnd();
unsigned int py = m_Rect.top();
for( std::list<Panel*>::iterator p=m_Panels.begin(); p!=m_Panels.end(); ++p )
{
py -= (*p)->height() + BORDER;
(*p)->displayAt( m_Rect.left()+BORDER, py, viewer(), m_Alpha );
}
break;
}
case RIGHT:
{
glBegin( GL_QUAD_STRIP );
glColor4f( 0.5f, 0.5f, 0.5f, 0.4f*m_Alpha );
glVertex2i( m_Rect.right(), m_Rect.bottom() );
glVertex2i( m_Rect.right(), m_Rect.top() );
glVertex2i( m_Rect.left()+10, m_Rect.bottom() );
glVertex2i( m_Rect.left()+10, m_Rect.top() );
glColor4f( 0.5f, 0.5f, 0.5f, 0.6f*m_Alpha );
glVertex2i( m_Rect.left(), m_Rect.bottom() );
glVertex2i( m_Rect.left(), m_Rect.top() );
glEnd();
glBegin( GL_LINES );
glColor4f( 0.5f, 0.5f, 0.5f, m_Alpha );
glVertex2i( m_Rect.left(), m_Rect.bottom() );
glVertex2i( m_Rect.left(), m_Rect.top() );
glEnd();
unsigned int py = m_Rect.top();
for( std::list<Panel*>::iterator p=m_Panels.begin(); p!=m_Panels.end(); ++p )
{
py -= (*p)->height() + BORDER;
(*p)->displayAt( m_Rect.left()+4+BORDER, py, viewer(), m_Alpha );
}
break;
}
case TOP:
{
glBegin( GL_QUAD_STRIP );
glColor4f( 0.5f, 0.5f, 0.5f, 0.4f*m_Alpha );
glVertex2i( m_Rect.left(), m_Rect.top() );
glVertex2i( m_Rect.right(), m_Rect.top() );
glVertex2i( m_Rect.left(), m_Rect.bottom()+10 );
glVertex2i( m_Rect.right(), m_Rect.bottom()+10 );
glColor4f( 0.5f, 0.5f, 0.5f, 0.6f*m_Alpha );
glVertex2i( m_Rect.left(), m_Rect.bottom() );
glVertex2i( m_Rect.right(), m_Rect.bottom() );
glEnd();
glBegin( GL_LINES );
glColor4f( 0.5f, 0.5f, 0.5f, m_Alpha );
glVertex2i( m_Rect.left(), m_Rect.bottom() );
glVertex2i( m_Rect.right(), m_Rect.bottom() );
glEnd();
unsigned int px = BORDER;
for( std::list<Panel*>::iterator p=m_Panels.begin(); p!=m_Panels.end(); px+=(*p)->width()+BORDER, ++p )
(*p)->displayAt( px, m_Rect.bottom()+BORDER+4, viewer(), m_Alpha );
break;
}
case BOTTOM:
{
glBegin( GL_QUAD_STRIP );
glColor4f( 0.5f, 0.5f, 0.5f, 0.4f*m_Alpha );
glVertex2i( m_Rect.left(), m_Rect.bottom() );
glVertex2i( m_Rect.right(), m_Rect.bottom() );
glVertex2i( m_Rect.left(), m_Rect.top()-10 );
glVertex2i( m_Rect.right(), m_Rect.top()-10 );
glColor4f( 0.5f, 0.5f, 0.5f, 0.6f*m_Alpha );
glVertex2i( m_Rect.left(), m_Rect.top() );
glVertex2i( m_Rect.right(), m_Rect.top() );
glEnd();
glBegin( GL_LINES );
glColor4f( 0.5f, 0.5f, 0.5f, m_Alpha );
glVertex2i( m_Rect.left(), m_Rect.top() );
glVertex2i( m_Rect.right(), m_Rect.top() );
glEnd();
unsigned int px = BORDER;
for( std::list<Panel*>::iterator p=m_Panels.begin(); p!=m_Panels.end(); px+=(*p)->width()+BORDER, ++p )
(*p)->displayAt( px, m_Rect.bottom()+BORDER, viewer(), m_Alpha );
break;
}
}
glPopAttrib();
}
GLViewer* InfoBar::viewer() const
{
return parent()->parent();
}
void InfoBar::setThickness( const unsigned int thickness )
{
m_Thickness = thickness;
m_FitToContent = (thickness == 0);
if( m_Parent )
m_Parent->repackInfoBars();
}
void InfoBar::show()
{
m_AlphaFadeOffset = m_ShowingSpeed;
m_Timer->start( 10 );
}
void InfoBar::hide()
{
m_AlphaFadeOffset = -m_HidingSpeed;
m_Timer->start( 10 );
}
void InfoBar::updateTransparency()
{
m_AlphaTime += m_AlphaFadeOffset;
if( m_AlphaTime >= 1.0f )
{
m_AlphaTime = 1.0f;
m_Timer->stop();
}
else if( m_AlphaTime <= 0.0f )
{
m_AlphaTime = 0.0f;
m_Timer->stop();
}
m_Alpha = 0.5 - 0.5*std::cos( m_AlphaTime*3.1415926535897932384626433832795 );
viewer()->update();
}
void InfoBar::repack()
{
if( m_Panels.empty() || !viewer() )
return;
unsigned int totalStretching = 0;
unsigned int maxThickness = 0;
int remainingLength;
if( m_Orientation==BOTTOM || m_Orientation==TOP )
{
remainingLength = m_Rect.width() - BORDER;
for( std::list<Panel*>::iterator p=m_Panels.begin(); p!=m_Panels.end(); ++p )
{
totalStretching += (*p)->stretching();
remainingLength -= (int)(*p)->preferedWidth() + BORDER;
if( maxThickness < (*p)->preferedHeight() )
maxThickness = (*p)->preferedHeight();
}
if( remainingLength < 0 )
remainingLength = 0;
float stretchingUnit = 0.0f;
if( totalStretching )
stretchingUnit = (float) remainingLength / totalStretching;
if( m_FitToContent )
m_Thickness = maxThickness + 2*BORDER + 4;
for( std::list<Panel*>::iterator p=m_Panels.begin(); p!=m_Panels.end(); ++p )
(*p)->setDimensions( (*p)->preferedWidth() + (*p)->stretching()*stretchingUnit, thickness()-(2*BORDER+4) );
}
else
{
remainingLength = -m_Rect.height() - BORDER;
for( std::list<Panel*>::iterator p=m_Panels.begin(); p!=m_Panels.end(); ++p )
{
totalStretching += (*p)->stretching();
remainingLength -= (*p)->preferedHeight() + BORDER;
if( maxThickness < (*p)->preferedWidth() )
maxThickness = (*p)->preferedWidth();
}
if( remainingLength < 0 )
remainingLength = 0;
float stretchingUnit = 0.0f;
if( totalStretching )
stretchingUnit = (float) remainingLength / totalStretching;
if( m_FitToContent )
m_Thickness = maxThickness + 2*BORDER + 4;
for( std::list<Panel*>::iterator p=m_Panels.begin(); p!=m_Panels.end(); ++p )
(*p)->setDimensions( thickness()-(2*BORDER+4), (*p)->preferedHeight() + (*p)->stretching()*stretchingUnit );
}
}
/*
* (c) LSIIT, UMR CNRS/UdS
* Authors: O. Gnevaux, F. Larue.
*
* See licence.txt for additional information.
*/
#ifndef INFOBAR_H
#define INFOBAR_H
#include <QObject>
#include <QRect>
#include <QTimer>
#include <list>
class InfoBarManager;
class Panel;
class GLViewer;
class InfoBar : public QObject
{
Q_OBJECT
friend class InfoBarManager;
/******************\
| Internal type(s) |
\******************/
public:
enum Orientation
{
LEFT ,
RIGHT ,
TOP ,
BOTTOM ,
};
/********************\
| Member variable(s) |
\********************/
private:
static const int BORDER = 4;
InfoBarManager *m_Parent;
unsigned int m_Thickness;
QRect m_Rect;
Orientation m_Orientation;
bool m_FitToContent;
QTimer *m_Timer;
float m_AlphaTime;
float m_Alpha;
float m_AlphaFadeOffset;
float m_ShowingSpeed;
float m_HidingSpeed;
std::list<Panel*> m_Panels;
/*****************************\
| Constructor(s) / destructor |
\*****************************/
public:
InfoBar( const unsigned int thickness = 0, const bool visible = true );
~InfoBar();
/********************\
| Member function(s) |
\********************/
private:
inline void attach( InfoBarManager *parent,
Orientation orient )
{
m_Parent = parent;
m_Orientation = orient;
}
inline void setRect( int xMin, int xMax, int yMin, int yMax )
{
m_Rect.setLeft( xMin );
m_Rect.setRight( xMax );
m_Rect.setTop( yMax );
m_Rect.setBottom( yMin );
repack();
}
void display();
public:
inline InfoBarManager* parent() const { return m_Parent; }
GLViewer* viewer() const;
void setThickness( const unsigned int thickness );
inline unsigned int thickness() const { return m_Thickness; }
void show();
void hide();
inline bool isHidden() const { return m_AlphaTime == 0.0f; }
inline bool isVisible() const { return m_AlphaTime != 0.0f; }
inline void setShowingSpeed( float s ) { m_ShowingSpeed = s; }
inline float showingSpeed() const { return m_ShowingSpeed; }
inline void setHidingSpeed( float s ) { m_HidingSpeed = s; }
inline float hidingSpeed() const { return m_HidingSpeed; }
inline void append( Panel *p ) { m_Panels.push_back(p); repack(); }
void repack();
inline std::list<Panel*> panels() { return m_Panels; }
inline const std::list<Panel*> panels() const { return m_Panels; }
/************\
| QT slot(s) |
\************/
private slots:
void updateTransparency();
};
#endif //INFOBAR_H
/*
* (c) LSIIT, UMR CNRS/UdS
* Authors: O. Gnevaux, F. Larue.
*
* See licence.txt for additional information.
*/
#include "GLViewer.h"
#include "InfoBarManager.h"
#include "InfoBar.h"
InfoBarManager::InfoBarManager( GLViewer *parent ) : m_ParentViewer(parent)
{
m_InfoBar[InfoBar::TOP ] = NULL;
m_InfoBar[InfoBar::BOTTOM] = NULL;
m_InfoBar[InfoBar::LEFT ] = NULL;
m_InfoBar[InfoBar::RIGHT ] = NULL;
}
InfoBarManager::~InfoBarManager()
{
delete m_InfoBar[InfoBar::TOP ];
delete m_InfoBar[InfoBar::BOTTOM];
delete m_InfoBar[InfoBar::LEFT ];
delete m_InfoBar[InfoBar::RIGHT ];
}
void InfoBarManager::setup()
{
repackInfoBars();
}
void InfoBarManager::setInfoBar( InfoBar *bar,
InfoBar::Orientation screenSide )
{
bar->attach( this, screenSide );
delete m_InfoBar[screenSide];
m_InfoBar[screenSide] = bar;
repackInfoBars();
}
void InfoBarManager::repackInfoBars()
{
if( !parent() )
return;
unsigned int minBound, maxBound;
if( m_InfoBar[InfoBar::BOTTOM] )
{
minBound = m_InfoBar[InfoBar::BOTTOM]->thickness();
m_InfoBar[InfoBar::BOTTOM]->setRect( 0, parent()->width(), 0, minBound );
}
else
minBound = 0;
if( m_InfoBar[InfoBar::TOP] )
{
maxBound = parent()->height() - m_InfoBar[InfoBar::TOP]->thickness();
m_InfoBar[InfoBar::TOP]->setRect( 0, parent()->width(), maxBound, parent()->height() );
}
else
maxBound = parent()->height();
if( m_InfoBar[InfoBar::LEFT] )
m_InfoBar[InfoBar::LEFT]->setRect( 0, m_InfoBar[InfoBar::LEFT]->thickness(), minBound, maxBound );
if( m_InfoBar[InfoBar::RIGHT] )
m_InfoBar[InfoBar::RIGHT]->setRect( parent()->width()-m_InfoBar[InfoBar::RIGHT]->thickness(), parent()->width(), minBound, maxBound );
}
void InfoBarManager::display()
{
glPushAttrib( GL_ENABLE_BIT |
GL_TRANSFORM_BIT |
GL_CURRENT_BIT |
GL_COLOR_BUFFER_BIT );
glDisable( GL_DEPTH_TEST );