Commit ef240480 authored by Hans-Christian Ebke's avatar Hans-Christian Ebke
Browse files

Merge remote-tracking branch 'remotes/origin/master'

parents 8fc676a5 35ec798f
...@@ -17,3 +17,31 @@ cppcheck: ...@@ -17,3 +17,31 @@ cppcheck:
artifacts: artifacts:
paths: paths:
- cppcheck.log - cppcheck.log
VS2015-Qt-5.6.0-x64:
script: "CI\\VS2015-Qt-5.6.0-x64.bat"
tags:
- VS2015
- Qt56
artifacts:
paths:
- rel/*.exe
VS2015-Qt-5.6.0-x32:
script: "CI\\VS2015-Qt-5.6.0-x32.bat"
tags:
- VS2015
- Qt56
artifacts:
paths:
- rel/*.exe
VS2013-Qt-5.5.1-x64:
script: "CI\\VS2013-Qt-5.5.1-x64.bat"
tags:
- VS2013
- Qt551
artifacts:
paths:
- rel/*.exe
...@@ -8,21 +8,10 @@ if ( ${PROJECT_NAME} MATCHES "OpenFlipper") ...@@ -8,21 +8,10 @@ if ( ${PROJECT_NAME} MATCHES "OpenFlipper")
endif() endif()
acg_qt5 ()
if (NOT FORCE_QT4)
# try to use QT5 if possible otherwise stick to QT4
acg_qt5 ()
else()
set (QT_MAX_VERSION 4.9.9)
set (QT5_FOUND false)
endif()
if (NOT QT5_FOUND) if (NOT QT5_FOUND)
message(STATUS "Using QT4 for ACG") message(FATAL ERROR "Qt5 not found")
acg_qt4 (REQUIRED 4.5)
else ()
message(STATUS "Using QT5 for ACG")
endif () endif ()
acg_openmp () acg_openmp ()
...@@ -66,7 +55,7 @@ if (QJSON_FOUND) ...@@ -66,7 +55,7 @@ if (QJSON_FOUND)
endif () endif ()
# use Qwt6 for QT5 # use Qwt6 for QT5
if (NOT FORCE_QT4 AND QT5_FOUND) if (QT5_FOUND)
find_package(Qwt6) find_package(Qwt6)
if (QWT6_FOUND) if (QWT6_FOUND)
...@@ -74,14 +63,7 @@ if (NOT FORCE_QT4 AND QT5_FOUND) ...@@ -74,14 +63,7 @@ if (NOT FORCE_QT4 AND QT5_FOUND)
set(ADDITIONAL_LINK_LIBRARIES ${ADDITIONAL_LINK_LIBRARIES} ${QWT6_LIBRARIES}) set(ADDITIONAL_LINK_LIBRARIES ${ADDITIONAL_LINK_LIBRARIES} ${QWT6_LIBRARIES})
set(ADDITIONAL_BUILD_DIRS "QwtWidgets" ) set(ADDITIONAL_BUILD_DIRS "QwtWidgets" )
endif() endif()
else()
find_package(Qwt5)
if(Qwt5_Qt4_FOUND)
set(INCLUDE_DIRS ${INCLUDE_DIRS} ${Qwt5_INCLUDE_DIR} )
set(ADDITIONAL_LINK_LIBRARIES ${ADDITIONAL_LINK_LIBRARIES} ${Qwt5_Qt4_LIBRARY})
set(ADDITIONAL_BUILD_DIRS "QwtWidgets" )
endif()
endif() endif()
include_directories ( include_directories (
...@@ -135,18 +117,13 @@ if (QT5_FOUND) ...@@ -135,18 +117,13 @@ if (QT5_FOUND)
acg_qt5_autouic (uic_targets ${ui}) acg_qt5_autouic (uic_targets ${ui})
acg_qt5_automoc (moc_targets ${headers}) acg_qt5_automoc (moc_targets ${headers})
acg_qt5_autoqrc (qrc_targets ${qrc}) acg_qt5_autoqrc (qrc_targets ${qrc})
elseif (QT4_FOUND)
acg_qt4_autouic (uic_targets ${ui})
acg_qt4_automoc (moc_targets ${headers})
acg_qt4_autoqrc (qrc_targets ${qrc})
endif() endif()
if (QT5_FOUND) if (QT5_FOUND)
acg_add_library (ACG SHARED ${uic_targets} ${sources} ${headers} ${moc_targets} ${qrc_targets}) acg_add_library (ACG SHARED ${uic_targets} ${sources} ${headers} ${moc_targets} ${qrc_targets})
elseif (QT4_FOUND)
acg_add_library (ACG SHARED ${uic_targets} ${sources} ${headers} ${moc_targets} ${qrc_targets})
endif() endif()
if ( NOT WIN32 ) if ( NOT WIN32 )
set_target_properties (ACG PROPERTIES VERSION ${ACG_VERSION_MAJOR}.${ACG_VERSION_MINOR} set_target_properties (ACG PROPERTIES VERSION ${ACG_VERSION_MAJOR}.${ACG_VERSION_MINOR}
SOVERSION ${ACG_VERSION_MAJOR}.${ACG_VERSION_MINOR}) SOVERSION ${ACG_VERSION_MAJOR}.${ACG_VERSION_MINOR})
......
...@@ -103,7 +103,7 @@ void ColorStack::initialize () ...@@ -103,7 +103,7 @@ void ColorStack::initialize ()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool ColorStack::setMaximumIndex (unsigned int _idx) bool ColorStack::setMaximumIndex (size_t _idx)
{ {
if (initialized_) if (initialized_)
{ {
...@@ -117,7 +117,7 @@ bool ColorStack::setMaximumIndex (unsigned int _idx) ...@@ -117,7 +117,7 @@ bool ColorStack::setMaximumIndex (unsigned int _idx)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void ColorStack::setIndex (unsigned int _idx) void ColorStack::setIndex (size_t _idx)
{ {
if (initialized_) if (initialized_)
{ {
...@@ -128,7 +128,7 @@ void ColorStack::setIndex (unsigned int _idx) ...@@ -128,7 +128,7 @@ void ColorStack::setIndex (unsigned int _idx)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
Vec4uc ColorStack::getIndexColor (unsigned int _idx) Vec4uc ColorStack::getIndexColor (size_t _idx)
{ {
if (initialized_) if (initialized_)
{ {
...@@ -144,7 +144,7 @@ Vec4uc ColorStack::getIndexColor (unsigned int _idx) ...@@ -144,7 +144,7 @@ Vec4uc ColorStack::getIndexColor (unsigned int _idx)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void ColorStack::pushIndex (unsigned int _idx) void ColorStack::pushIndex (size_t _idx)
{ {
if (initialized_) if (initialized_)
currentNode_ = currentNode_->pushIndex (_idx); currentNode_ = currentNode_->pushIndex (_idx);
...@@ -160,12 +160,12 @@ void ColorStack::popIndex () ...@@ -160,12 +160,12 @@ void ColorStack::popIndex ()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::vector<unsigned int> ColorStack::colorToStack (Vec4uc _rgba) const std::vector<size_t> ColorStack::colorToStack (Vec4uc _rgba) const
{ {
std::vector<unsigned int> rv(0); std::vector<size_t> rv(0);
if (initialized_ && !error_) if (initialized_ && !error_)
{ {
unsigned int idx = translator_.color2index (_rgba); const size_t idx = translator_.color2index (_rgba);
if (idx >= root_->startIndex () && idx < root_->endIndex ()) if (idx >= root_->startIndex () && idx < root_->endIndex ())
root_->colorToStack (rv, idx); root_->colorToStack (rv, idx);
} }
...@@ -174,7 +174,7 @@ std::vector<unsigned int> ColorStack::colorToStack (Vec4uc _rgba) const ...@@ -174,7 +174,7 @@ std::vector<unsigned int> ColorStack::colorToStack (Vec4uc _rgba) const
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
unsigned int ColorStack::freeIndicies() const size_t ColorStack::freeIndicies() const
{ {
if (initialized_) if (initialized_)
{ {
...@@ -186,7 +186,7 @@ unsigned int ColorStack::freeIndicies() const ...@@ -186,7 +186,7 @@ unsigned int ColorStack::freeIndicies() const
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
unsigned int ColorStack::currentIndex () const size_t ColorStack::currentIndex () const
{ {
if (initialized_) if (initialized_)
{ {
...@@ -198,7 +198,7 @@ unsigned int ColorStack::currentIndex () const ...@@ -198,7 +198,7 @@ unsigned int ColorStack::currentIndex () const
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
ColorStack::Node::Node (unsigned int _idx, Node *_parent, ColorTranslator *_ct) : ColorStack::Node::Node (size_t _idx, Node *_parent, ColorTranslator *_ct) :
parent_(_parent), parent_(_parent),
index_(_idx), index_(_idx),
translator_(_ct), translator_(_ct),
...@@ -221,7 +221,7 @@ ColorStack::Node::~Node () ...@@ -221,7 +221,7 @@ ColorStack::Node::~Node ()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool ColorStack::Node::setMaximumIndex (unsigned int _idx) bool ColorStack::Node::setMaximumIndex (size_t _idx)
{ {
if (_idx == 0) if (_idx == 0)
_idx = 1; _idx = 1;
...@@ -237,7 +237,7 @@ bool ColorStack::Node::setMaximumIndex (unsigned int _idx) ...@@ -237,7 +237,7 @@ bool ColorStack::Node::setMaximumIndex (unsigned int _idx)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool ColorStack::Node::setIndex (unsigned int _idx) const bool ColorStack::Node::setIndex (size_t _idx) const
{ {
if (colorStartIdx_ && colorStartIdx_ + _idx < colorEndIdx_) if (colorStartIdx_ && colorStartIdx_ + _idx < colorEndIdx_)
{ {
...@@ -249,7 +249,7 @@ bool ColorStack::Node::setIndex (unsigned int _idx) const ...@@ -249,7 +249,7 @@ bool ColorStack::Node::setIndex (unsigned int _idx) const
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool ColorStack::Node::getIndexColor (unsigned int _idx, Vec4uc &_rgba) const bool ColorStack::Node::getIndexColor (size_t _idx, Vec4uc &_rgba) const
{ {
if (colorStartIdx_ && colorStartIdx_ + _idx < colorEndIdx_) if (colorStartIdx_ && colorStartIdx_ + _idx < colorEndIdx_)
{ {
...@@ -261,7 +261,7 @@ bool ColorStack::Node::getIndexColor (unsigned int _idx, Vec4uc &_rgba) const ...@@ -261,7 +261,7 @@ bool ColorStack::Node::getIndexColor (unsigned int _idx, Vec4uc &_rgba) const
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
ColorStack::Node * ColorStack::Node::pushIndex (unsigned int _idx) ColorStack::Node * ColorStack::Node::pushIndex (size_t _idx)
{ {
ColorStack::Node *n = new ColorStack::Node (_idx, this, translator_); ColorStack::Node *n = new ColorStack::Node (_idx, this, translator_);
nodes_.push_back (n); nodes_.push_back (n);
...@@ -278,7 +278,7 @@ ColorStack::Node * ColorStack::Node::popIndex () ...@@ -278,7 +278,7 @@ ColorStack::Node * ColorStack::Node::popIndex ()
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void ColorStack::Node::colorToStack (std::vector<unsigned int> &_stack, unsigned int _index) void ColorStack::Node::colorToStack (std::vector<size_t> &_stack, size_t _index)
{ {
if (_index >= colorStartIdx_ && _index < colorEndIdx_) if (_index >= colorStartIdx_ && _index < colorEndIdx_)
{ {
......
...@@ -95,31 +95,31 @@ public: ...@@ -95,31 +95,31 @@ public:
bool initialized() const { return initialized_; } bool initialized() const { return initialized_; }
/// sets the maximum index number used in current node /// sets the maximum index number used in current node
bool setMaximumIndex (unsigned int _idx); bool setMaximumIndex (size_t _idx);
/// sets the current color the given index (like glLoadName) /// sets the current color the given index (like glLoadName)
void setIndex (unsigned int _idx); void setIndex (size_t _idx);
/// gets the color instead of setting it directly /// gets the color instead of setting it directly
Vec4uc getIndexColor (unsigned int _idx); Vec4uc getIndexColor (size_t _idx);
/// creates a new node the stack (like glPushName) /// creates a new node the stack (like glPushName)
void pushIndex (unsigned int _idx); void pushIndex (size_t _idx);
/// pops the current node from the stack (like glPopName) /// pops the current node from the stack (like glPopName)
void popIndex (); void popIndex ();
/// converts the given color to index values on the stack /// converts the given color to index values on the stack
std::vector<unsigned int> colorToStack (Vec4uc _rgba) const; std::vector<size_t> colorToStack (Vec4uc _rgba) const;
/// returns maximal available index count /// returns maximal available index count
unsigned int freeIndicies () const; size_t freeIndicies () const;
/// Did an error occur during picking /// Did an error occur during picking
bool error () const { return error_ && initialized_; }; bool error () const { return error_ && initialized_; };
/// returns the current color index /// returns the current color index
unsigned int currentIndex () const; size_t currentIndex () const;
private: private:
...@@ -127,40 +127,40 @@ private: ...@@ -127,40 +127,40 @@ private:
class Node { class Node {
public: public:
Node (unsigned int _idx, Node *_parent, ColorTranslator *_ct); Node (size_t _idx, Node *_parent, ColorTranslator *_ct);
~Node (); ~Node ();
/// sets the maximum index number used in current node /// sets the maximum index number used in current node
bool setMaximumIndex (unsigned int _idx); bool setMaximumIndex (size_t _idx);
/// sets the current color the given index (like glLoadName) /// sets the current color the given index (like glLoadName)
bool setIndex (unsigned int _idx) const; bool setIndex (size_t _idx) const;
/// gets the color instead of setting it directly /// gets the color instead of setting it directly
bool getIndexColor (unsigned int _idx, Vec4uc &_rgba) const; bool getIndexColor (size_t _idx, Vec4uc &_rgba) const;
/// creates a new node the stack (like glPushName) /// creates a new node the stack (like glPushName)
Node * pushIndex (unsigned int _idx); Node * pushIndex (size_t _idx);
/// pops the current node from the stack (like glPopName) /// pops the current node from the stack (like glPopName)
Node * popIndex (); Node * popIndex ();
void colorToStack (std::vector<unsigned int> &_stack, unsigned int _index); void colorToStack (std::vector<size_t> &_stack, size_t size_t);
unsigned int startIndex () { return startIdx_; }; size_t startIndex () const { return startIdx_; };
unsigned int endIndex () { return endIdx_; }; size_t endIndex () const { return endIdx_; };
unsigned int colorIndex () { return colorStartIdx_; }; size_t colorIndex () const { return colorStartIdx_; };
private: private:
Node *parent_; Node *parent_;
unsigned int index_; size_t index_;
ColorTranslator *translator_; ColorTranslator *translator_;
std::vector<Node *> nodes_; std::vector<Node *> nodes_;
unsigned int startIdx_; size_t startIdx_;
unsigned int endIdx_; size_t endIdx_;
unsigned int colorStartIdx_; size_t colorStartIdx_;
unsigned int colorEndIdx_; size_t colorEndIdx_;
}; };
......
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
#include "ColorTranslator.hh" #include "ColorTranslator.hh"
#include <iostream> #include <iostream>
#include <limits>
//== NAMESPACES =============================================================== //== NAMESPACES ===============================================================
...@@ -81,21 +82,25 @@ initialize() ...@@ -81,21 +82,25 @@ initialize()
glGetIntegerv( GL_BLUE_BITS, &blue_bits_ ); glGetIntegerv( GL_BLUE_BITS, &blue_bits_ );
glGetIntegerv( GL_ALPHA_BITS, &alpha_bits_ ); glGetIntegerv( GL_ALPHA_BITS, &alpha_bits_ );
// We currently only support up to 8 bits per channel (
if (red_bits_ > 8) red_bits_ = 8; if (red_bits_ > 8) red_bits_ = 8;
if (green_bits_ > 8) green_bits_ = 8; if (green_bits_ > 8) green_bits_ = 8;
if (blue_bits_ > 8) blue_bits_ = 8; if (blue_bits_ > 8) blue_bits_ = 8;
if (alpha_bits_ > 8) alpha_bits_ = 8; if (alpha_bits_ > 8) alpha_bits_ = 8;
// Compute the mask to extract the component
red_mask_ = ((1 << red_bits_) - 1); red_mask_ = ((1 << red_bits_) - 1);
green_mask_ = ((1 << green_bits_) - 1); green_mask_ = ((1 << green_bits_) - 1);
blue_mask_ = ((1 << blue_bits_) - 1); blue_mask_ = ((1 << blue_bits_) - 1);
alpha_mask_ = ((1 << alpha_bits_) - 1); alpha_mask_ = ((1 << alpha_bits_) - 1);
// Shift required to move the component to the lowest bits
red_shift_ = 8 - red_bits_; red_shift_ = 8 - red_bits_;
green_shift_ = 8 - green_bits_; green_shift_ = 8 - green_bits_;
blue_shift_ = 8 - blue_bits_; blue_shift_ = 8 - blue_bits_;
alpha_shift_ = 8 - alpha_bits_; alpha_shift_ = 8 - alpha_bits_;
red_round_ = 1 << (red_shift_ - 1); red_round_ = 1 << (red_shift_ - 1);
green_round_ = 1 << (green_shift_ - 1); green_round_ = 1 << (green_shift_ - 1);
blue_round_ = 1 << (blue_shift_ - 1); blue_round_ = 1 << (blue_shift_ - 1);
...@@ -110,12 +115,19 @@ initialize() ...@@ -110,12 +115,19 @@ initialize()
Vec4uc Vec4uc
ColorTranslator:: ColorTranslator::
index2color(unsigned int _idx) const index2color(const size_t _idx) const
{ {
assert(initialized()); assert(initialized());
unsigned char r, g, b, a; unsigned char r, g, b, a;
unsigned int idx(_idx+1);
// Make sure that the number fits
if ( _idx > std::numeric_limits<unsigned int>::max() ) {
std::cerr << "Can't convert index " << _idx << " to RGBA. Number too large for unsigned int \n";
return Vec4uc(0, 0, 0, 0);
}
unsigned int idx = ( static_cast<unsigned int>(_idx) + 1);
b = ((idx & blue_mask_) << blue_shift_) | blue_round_; b = ((idx & blue_mask_) << blue_shift_) | blue_round_;
idx >>= blue_bits_; idx >>= blue_bits_;
g = ((idx & green_mask_) << green_shift_) | green_round_; g = ((idx & green_mask_) << green_shift_) | green_round_;
...@@ -139,13 +151,18 @@ index2color(unsigned int _idx) const ...@@ -139,13 +151,18 @@ index2color(unsigned int _idx) const
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
int size_t
ColorTranslator:: ColorTranslator::
color2index(Vec4uc _rgba) const color2index(const Vec4uc _rgba) const
{ {
assert(initialized()); assert(initialized());
// Work internally with#include <iostream> unsigned int for now
unsigned int result; unsigned int result;
// Combine the single unsigned chars according to masks
result = _rgba[3] >> alpha_shift_; result = _rgba[3] >> alpha_shift_;
result <<= red_bits_; result <<= red_bits_;
result = _rgba[0] >> red_shift_; result = _rgba[0] >> red_shift_;
...@@ -154,14 +171,15 @@ color2index(Vec4uc _rgba) const ...@@ -154,14 +171,15 @@ color2index(Vec4uc _rgba) const
result <<= blue_bits_; result <<= blue_bits_;
result |= _rgba[2] >> blue_shift_; result |= _rgba[2] >> blue_shift_;
return (result-1); // Return size_t Here
return ( static_cast<size_t>(result-1) );
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
unsigned int size_t
ColorTranslator::max_index() const ColorTranslator::max_index() const
{ {
assert(initialized()); assert(initialized());
......