Skip to content
Permalink
Browse files

Merge master - adapt to QgsAbstractMaterialSettings implementation

  • Loading branch information
NEDJIMAbelgacem committed Jul 25, 2020
2 parents 1a73f1d + 8b5dedf commit 4488739215b5702511655973c0b3c5d2075dc1e2
Showing 363 changed files with 6,410 additions and 2,040 deletions.
@@ -571,7 +571,7 @@ IF (PEDANTIC)
# ADD_DEFINITIONS( -fstrict-aliasing -Wstrict-aliasing=1 -Wredundant-decls )

IF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type-c-linkage -Wno-overloaded-virtual -Wimplicit-fallthrough")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-return-type-c-linkage -Wno-overloaded-virtual -Wimplicit-fallthrough")
ENDIF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")

# add any extra CXXFLAGS flags set by user. can be -D CXX_EXTRA_FLAGS or environment variable
@@ -49,7 +49,7 @@ ELSE(EXISTS PYQT5_VERSION)
IF(PYQT5_FOUND)
IF(NOT PyQt5_FIND_QUIETLY)
MESSAGE(STATUS "Found PyQt5 version: ${PYQT5_VERSION_STR}")
ENDIF(NOT PYQT5_FIND_QUIETLY)
ENDIF(NOT PyQt5_FIND_QUIETLY)
ELSE(PYQT5_FOUND)
IF(PyQt5_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find PyQt5")
@@ -30,14 +30,13 @@
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

try:
import PyQt5.pyqtconfig
import os.path
import PyQt5.QtCore

pyqtcfg = PyQt5.pyqtconfig.Configuration()
try:
__import__('sipbuild')
except ImportError:
import PyQt5.QtCore
import sipconfig # won't work for SIP v5
import os.path
import sys

cfg = sipconfig.Configuration()
@@ -55,35 +54,40 @@
else:
sys.exit(1)
cfg = {
'pyqt_version': PyQt5.QtCore.PYQT_VERSION,
'pyqt_version_str': PyQt5.QtCore.PYQT_VERSION_STR,
'pyqt_sip_flags': PyQt5.QtCore.PYQT_CONFIGURATION['sip_flags'],
'pyqt_mod_dir': os.path.join(cfg.default_mod_dir, "PyQt5"),
'pyqt_sip_dir': sip_dir,
'pyqt_bin_dir': cfg.default_bin_dir,
}
pyqtcfg = sipconfig.Configuration([cfg])
else: # Code for SIP v5
from distutils.sysconfig import get_python_lib
import shutil
cfg = {
'pyqt_mod_dir': os.path.dirname(PyQt5.__file__),
'pyqt_sip_dir': os.path.join(get_python_lib(plat_specific=1), "PyQt5", "bindings"),
'pyqt_bin_dir': os.path.dirname(shutil.which("pyuic5")),
}

print("pyqt_version:%06.0x" % pyqtcfg.pyqt_version)
print("pyqt_version_num:%d" % pyqtcfg.pyqt_version)
print("pyqt_version_str:%s" % pyqtcfg.pyqt_version_str)
print("pyqt_version:%06.0x" % PyQt5.QtCore.PYQT_VERSION)
print("pyqt_version_num:%d" % PyQt5.QtCore.PYQT_VERSION)
print("pyqt_version_str:%s" % PyQt5.QtCore.PYQT_VERSION_STR)

pyqt_version_tag = ""
in_t = False
for item in pyqtcfg.pyqt_sip_flags.split(' '):
pyqt_config_list = PyQt5.QtCore.PYQT_CONFIGURATION["sip_flags"].split(' ')
for item in pyqt_config_list:
if item == "-t":
in_t = True
elif in_t:
if item.startswith("Qt_4"):
if item.startswith("Qt_5"):
pyqt_version_tag = item
else:
in_t = False
print("pyqt_version_tag:%s" % pyqt_version_tag)

print("pyqt_mod_dir:%s" % pyqtcfg.pyqt_mod_dir)
print("pyqt_sip_dir:%s" % pyqtcfg.pyqt_sip_dir)
print("pyqt_sip_flags:%s" % pyqtcfg.pyqt_sip_flags)
print("pyqt_bin_dir:%s" % pyqtcfg.pyqt_bin_dir)
print("pyqt_mod_dir:%s" % cfg['pyqt_mod_dir'])
print("pyqt_sip_dir:%s" % cfg['pyqt_sip_dir'])
print("pyqt_sip_flags:%s" % PyQt5.QtCore.PYQT_CONFIGURATION['sip_flags'])
print("pyqt_bin_dir:%s" % cfg['pyqt_bin_dir'])

try:
import PyQt5.sip
@@ -40,8 +40,12 @@ ELSE(SIP_VERSION)
STRING(REGEX REPLACE ".*\nsip_version_str:([^\n]+).*$" "\\1" SIP_VERSION_STR ${sip_config})
STRING(REGEX REPLACE ".*\nsip_bin:([^\n]+).*$" "\\1" SIP_BINARY_PATH ${sip_config})
STRING(REGEX REPLACE ".*\ndefault_sip_dir:([^\n]+).*$" "\\1" SIP_DEFAULT_SIP_DIR ${sip_config})
STRING(REGEX REPLACE ".*\nsip_inc_dir:([^\n]+).*$" "\\1" SIP_INCLUDE_DIR ${sip_config})
STRING(REGEX REPLACE ".*\nsip_module_dir:([^\n]+).*$" "\\1" SIP_MODULE_DIR ${sip_config})
IF(${SIP_VERSION_STR} VERSION_LESS 5)
STRING(REGEX REPLACE ".*\nsip_inc_dir:([^\n]+).*$" "\\1" SIP_INCLUDE_DIR ${sip_config})
STRING(REGEX REPLACE ".*\nsip_module_dir:([^\n]+).*$" "\\1" SIP_MODULE_DIR ${sip_config})
ELSE(${SIP_VERSION_STR} VERSION_LESS 5)
FIND_PROGRAM(SIP_MODULE_EXECUTABLE sip-module)
ENDIF(${SIP_VERSION_STR} VERSION_LESS 5)
SET(SIP_FOUND TRUE)
ENDIF(sip_config)

@@ -30,17 +30,31 @@
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

import sipconfig
try:
import sipbuild
except ImportError: # Code for SIP v4
import sipconfig

sipcfg = sipconfig.Configuration()
print("sip_version:%06.0x" % sipcfg.sip_version)
print("sip_version_num:%d" % sipcfg.sip_version)
print("sip_version_str:%s" % sipcfg.sip_version_str)
print("sip_bin:%s" % sipcfg.sip_bin)
print("default_sip_dir:%s" % sipcfg.default_sip_dir)
print("sip_inc_dir:%s" % sipcfg.sip_inc_dir)
# SIP 4.19.10+ has new sipcfg.sip_module_dir
if hasattr(sipcfg, "sip_module_dir"):
print("sip_module_dir:%s" % sipcfg.sip_module_dir)
else:
print("sip_module_dir:%s" % sipcfg.sip_mod_dir)
sipcfg = sipconfig.Configuration()
print("sip_version:%06.0x" % sipcfg.sip_version)
print("sip_version_num:%d" % sipcfg.sip_version)
print("sip_version_str:%s" % sipcfg.sip_version_str)
print("sip_bin:%s" % sipcfg.sip_bin)
print("default_sip_dir:%s" % sipcfg.default_sip_dir)
print("sip_inc_dir:%s" % sipcfg.sip_inc_dir)
# SIP 4.19.10+ has new sipcfg.sip_module_dir
if hasattr(sipcfg, "sip_module_dir"):
print("sip_module_dir:%s" % sipcfg.sip_module_dir)
else:
print("sip_module_dir:%s" % sipcfg.sip_mod_dir)
else: # Code for SIP v5
print("sip_version:%06.0x" % sipbuild.version.SIP_VERSION)
print("sip_version_num:%d" % sipbuild.version.SIP_VERSION)
print("sip_version_str:%s" % sipbuild.version.SIP_VERSION_STR)

import shutil
print("sip_bin:%s" % shutil.which("sip5"))

from distutils.sysconfig import get_python_lib
python_modules_dir = get_python_lib(plat_specific=1)
print("default_sip_dir:%s" % python_modules_dir)
@@ -121,6 +121,12 @@ MACRO(GENERATE_SIP_PYTHON_MODULE_CODE MODULE_NAME MODULE_SIP SIP_FILES CPP_FILES
DEPENDS ${SIP_EXTRA_FILES_DEPEND}
VERBATIM
)
IF (SIP_MODULE_EXECUTABLE)
ADD_CUSTOM_COMMAND(
OUTPUT ${_sip_output_files} APPEND
COMMAND ${SIP_MODULE_EXECUTABLE} --target-dir ${CMAKE_CURRENT_BINARY_DIR}/${_module_path} --sip-h ${PYQT5_SIP_IMPORT}
)
ENDIF (SIP_MODULE_EXECUTABLE)

ADD_CUSTOM_TARGET(generate_sip_${MODULE_NAME}_cpp_files DEPENDS ${_sip_output_files})

@@ -533,6 +533,11 @@ MDAL_EXPORT void MDAL_G_closeEditMode( MDAL_DatasetGroupH group );
*/
MDAL_EXPORT const char *MDAL_G_referenceTime( MDAL_DatasetGroupH group );

/**
* Sets reference time for dataset group expressed in date with ISO8601 format
*/
MDAL_EXPORT void MDAL_G_setReferenceTime( MDAL_DatasetGroupH group, const char *referenceTimeISO8601 );

/**
* Returns whether the dataset group is temporal, i.e. has time-related datasets
*
@@ -49,7 +49,22 @@ void MDAL::SelafinFile::initialize()
mFileSize = mIn.tellg();
mIn.seekg( 0, mIn.beg );

mIsNativeLittleEndian = MDAL::isNativeLittleEndian();
mChangeEndianness = MDAL::isNativeLittleEndian();

//Check if need to change the endianness
// read first size_t that has to be 80
size_t firstInt = readSizeT();
mIn.seekg( 0, mIn.beg );
if ( firstInt != 80 )
{
mChangeEndianness = !mChangeEndianness;
//Retry
firstInt = readSizeT();
if ( firstInt != 80 )
throw MDAL::Error( MDAL_Status::Err_UnknownFormat, "File " + mFileName + " could not be open" );
mIn.seekg( 0, mIn.beg );
}

mParsed = false;
}

@@ -282,7 +297,7 @@ std::vector<double> MDAL::SelafinFile::datasetValues( size_t timeStepIndex, size
{
if ( !mParsed )
parseFile();
if ( variableIndex < mVariableStreamPosition.size() && timeStepIndex < mVariableStreamPosition[timeStepIndex].size() )
if ( variableIndex < mVariableStreamPosition.size() && timeStepIndex < mVariableStreamPosition[variableIndex].size() )
return readDoubleArr( mVariableStreamPosition[variableIndex][timeStepIndex], offset, count );
else
return std::vector<double>();
@@ -403,7 +418,7 @@ void MDAL::SelafinFile::populateDataset( MDAL::Mesh *mesh, std::shared_ptr<MDAL:

std::string MDAL::SelafinFile::readString( size_t len )
{
size_t length = readSizet();
size_t length = readSizeT();
if ( length != len ) throw MDAL::Error( MDAL_Status::Err_UnknownFormat, "Unable to read string" );
std::string ret = readStringWithoutLength( len );
ignoreArrayLength();
@@ -412,7 +427,7 @@ std::string MDAL::SelafinFile::readString( size_t len )

std::vector<double> MDAL::SelafinFile::readDoubleArr( size_t len )
{
size_t length = readSizet();
size_t length = readSizeT();
if ( mStreamInFloatPrecision )
{
if ( length != len * 4 )
@@ -450,7 +465,7 @@ std::vector<double> MDAL::SelafinFile::readDoubleArr( const std::streampos &posi

std::vector<int> MDAL::SelafinFile::readIntArr( size_t len )
{
size_t length = readSizet();
size_t length = readSizeT();
if ( length != len * 4 ) throw MDAL::Error( MDAL_Status::Err_UnknownFormat, "File format problem while reading int array" );
std::vector<int> ret( len );
for ( size_t i = 0; i < len; ++i )
@@ -500,13 +515,13 @@ double MDAL::SelafinFile::readDouble( )
if ( mStreamInFloatPrecision )
{
float ret_f;
if ( !readValue( ret_f, mIn, mIsNativeLittleEndian ) )
if ( !readValue( ret_f, mIn, mChangeEndianness ) )
throw MDAL::Error( MDAL_Status::Err_UnknownFormat, "Reading double failed" );
ret = static_cast<double>( ret_f );
}
else
{
if ( !readValue( ret, mIn, mIsNativeLittleEndian ) )
if ( !readValue( ret, mIn, mChangeEndianness ) )
throw MDAL::Error( MDAL_Status::Err_UnknownFormat, "Reading double failed" );
}
return ret;
@@ -520,7 +535,7 @@ int MDAL::SelafinFile::readInt( )
if ( mIn.read( reinterpret_cast< char * >( &data ), 4 ) )
if ( !mIn )
throw MDAL::Error( MDAL_Status::Err_UnknownFormat, "Unable to open stream for reading int" );
if ( mIsNativeLittleEndian )
if ( mChangeEndianness )
{
std::reverse( reinterpret_cast< char * >( &data ), reinterpret_cast< char * >( &data ) + 4 );
}
@@ -531,26 +546,26 @@ int MDAL::SelafinFile::readInt( )
return var;
}

size_t MDAL::SelafinFile::readSizet()
size_t MDAL::SelafinFile::readSizeT()
{
int var = readInt( );
return static_cast<size_t>( var );
}

bool MDAL::SelafinFile::checkIntArraySize( size_t len )
{
return ( len * 4 == readSizet() );
return ( len * 4 == readSizeT() );
}

bool MDAL::SelafinFile::checkDoubleArraySize( size_t len )
{
if ( mStreamInFloatPrecision )
{
return ( len * 4 ) == readSizet();
return ( len * 4 ) == readSizeT();
}
else
{
return ( len * 8 ) == readSizet();
return ( len * 8 ) == readSizeT();
}
}

@@ -780,7 +795,7 @@ void MDAL::MeshSelafin::calculateExtent() const
}
index += count;
}
while ( count == 0 );
while ( count != 0 );

mExtent = MDAL::computeExtent( vertices );
mIsExtentUpToDate = true;
@@ -127,7 +127,7 @@ namespace MDAL

double readDouble( );
int readInt( );
size_t readSizet( );
size_t readSizeT( );

void ignoreArrayLength( );
std::string readStringWithoutLength( size_t len );
@@ -157,7 +157,7 @@ namespace MDAL

std::string mFileName;
bool mStreamInFloatPrecision = true;
bool mIsNativeLittleEndian = true;
bool mChangeEndianness = true;
long long mFileSize = -1;

std::ifstream mIn;
@@ -21,7 +21,7 @@ static const char *EMPTY_STR = "";

const char *MDAL_Version()
{
return "0.6.90";
return "0.6.91";
}

MDAL_Status MDAL_LastStatus()
@@ -874,6 +874,18 @@ const char *MDAL_G_referenceTime( MDAL_DatasetGroupH group )
return _return_str( g->referenceTime().toStandardCalendarISO8601() );
}

void MDAL_G_setReferenceTime( MDAL_DatasetGroupH group, const char *referenceTimeISO8601 )
{
if ( !group )
{
MDAL::Log::error( MDAL_Status::Err_IncompatibleDataset, "Dataset Group is not valid (null)" );
return;
}
MDAL::DatasetGroup *g = static_cast< MDAL::DatasetGroup * >( group );
const std::string datetime( referenceTimeISO8601 );
g->setReferenceTime( MDAL::DateTime( datetime ) );
}

void MDAL_G_setMetadata( MDAL_DatasetGroupH group, const char *key, const char *val )
{
if ( !group )
@@ -49,6 +49,37 @@ MDAL::DateTime::DateTime( double value, Epoch epoch ): mValid( true )
}
}

MDAL::DateTime::DateTime( const std::string &fromISO8601 )
{
std::vector<std::string> splitedDateTime = split( fromISO8601, 'T' );

if ( splitedDateTime.size() != 2 )
return;
//parse date
std::vector<std::string> splitedDate = split( splitedDateTime.at( 0 ), '-' );
if ( splitedDate.size() != 3 )
return;

//parse time
splitedDateTime[1] = replace( splitedDateTime.at( 1 ), "Z", "", ContainsBehaviour::CaseInsensitive );
std::vector<std::string> splitedTime = split( splitedDateTime.at( 1 ), ':' );
if ( splitedTime.size() < 2 || splitedTime.size() > 3 )
return;

DateTimeValues dateTimeValues;
dateTimeValues.year = toInt( splitedDate[0] );
dateTimeValues.month = toInt( splitedDate[1] );
dateTimeValues.day = toInt( splitedDate[2] );
dateTimeValues.hours = toInt( splitedTime[0] );
dateTimeValues.minutes = toInt( splitedTime[1] );
if ( splitedTime.size() == 3 )
dateTimeValues.seconds = toDouble( splitedTime[2] );
else
dateTimeValues.seconds = 0.0;

setWithGregorianCalendarDate( dateTimeValues );
}

std::string MDAL::DateTime::toStandardCalendarISO8601() const
{
if ( mValid )
@@ -67,6 +67,9 @@ namespace MDAL
//! Constructor with Julian day or Unix Epoch
DateTime( double value, Epoch epoch );

//! Constructor with ISO 8601 string
DateTime( const std::string &fromISO8601 );

//! Returns a string with the date/time expressed in Greogrian proleptic calendar with ISO8601 format (local time zone)
//! Do not support negative year
std::string toStandardCalendarISO8601() const;

0 comments on commit 4488739

Please sign in to comment.
You can’t perform that action at this time.