Permalink
Browse files

Better CMake policy setting code. Fixing some MSVC compiler warnings (#…

…836)

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
  • Loading branch information...
imikejackson committed Nov 6, 2018
1 parent bb34251 commit 2f324e35484aca8a75174071604e8c08b5596fcb
View
@@ -1,11 +1,15 @@
if(${CMAKE_MAJOR_VERSION} STREQUAL "3")
# CMake 3.1 introduces if() policies on dereferencing variables in quotes
cmake_policy(SET CMP0054 NEW)
if(${CMAKE_MAJOR_VERSION} VERSION_GREATER_EQUAL "3.1.0")
cmake_policy(SET CMP0002 NEW)
cmake_policy(SET CMP0054 NEW)
endif()
cmake_policy(SET CMP0002 NEW)
if(${CMAKE_MAJOR_VERSION} VERSION_GREATER_EQUAL "3.12.0")
cmake_policy(SET CMP0074 NEW)
endif()
# cmake_policy(SET CMP0074 NEW)
if(${CMAKE_MAJOR_VERSION} VERSION_GREATER_EQUAL "3.13.0")
cmake_policy(SET CMP0079 NEW)
endif()
cmake_minimum_required(VERSION 3.10.0)
@@ -262,7 +262,7 @@ void FindMisorientations::execute()
QuaternionMathF::Copy(avgQuats[nname], q2);
xtalType2 = m_CrystalStructures[m_FeaturePhases[nname]];
tempMisoList = neighborlist[i].size();
if(xtalType1 == xtalType2 && xtalType1 < m_OrientationOps.size())
if(xtalType1 == xtalType2 && static_cast<int64_t>(xtalType1) < static_cast<int64_t>(m_OrientationOps.size()))
{
w = m_OrientationOps[xtalType1]->getMisoQuat(q1, q2, n1, n2, n3);
misorientationlists[i][j] = w * SIMPLib::Constants::k_180OverPi;
@@ -506,7 +506,7 @@ void drawScalarBar(HPDF_Page page, const PoleFigureConfiguration_t &config,
HPDF_Page_SetGrayStroke (page, 0.00f);
HPDF_Page_BeginText (page);
HPDF_Page_SetFontAndSize (page, font, fontPtSize);
HPDF_Page_MoveTextPos (page, position.first + margins + rect.first + margins, position.second + margins + fontPtSize + rect.second*numColors/1.5);
HPDF_Page_MoveTextPos(page, position.first + margins + rect.first + margins, position.second + margins + fontPtSize + rect.second * numColors / 1.5f);
HPDF_Page_ShowText (page, label.toLatin1());
HPDF_Page_EndText (page);
@@ -515,7 +515,7 @@ void drawScalarBar(HPDF_Page page, const PoleFigureConfiguration_t &config,
HPDF_Page_SetGrayStroke (page, 0.00f);
HPDF_Page_BeginText (page);
HPDF_Page_SetFontAndSize (page, font, fontPtSize);
HPDF_Page_MoveTextPos (page, position.first + margins + rect.first + margins, position.second + margins + fontPtSize + rect.second*numColors/1.5 - (fontPtSize*1.10f) );
HPDF_Page_MoveTextPos(page, position.first + margins + rect.first + margins, position.second + margins + fontPtSize + rect.second * numColors / 1.5f - (fontPtSize * 1.10f));
HPDF_Page_ShowText (page, label.toLatin1());
HPDF_Page_EndText (page);
@@ -524,7 +524,7 @@ void drawScalarBar(HPDF_Page page, const PoleFigureConfiguration_t &config,
HPDF_Page_SetGrayStroke (page, 0.00f);
HPDF_Page_BeginText (page);
HPDF_Page_SetFontAndSize (page, font, fontPtSize);
HPDF_Page_MoveTextPos (page, position.first + margins + rect.first + margins, position.second + margins + fontPtSize + rect.second*numColors/1.5- (fontPtSize*2.20f) );
HPDF_Page_MoveTextPos(page, position.first + margins + rect.first + margins, position.second + margins + fontPtSize + rect.second * numColors / 1.5f - (fontPtSize * 2.20f));
HPDF_Page_ShowText (page, label.toLatin1());
HPDF_Page_EndText (page);
@@ -533,7 +533,7 @@ void drawScalarBar(HPDF_Page page, const PoleFigureConfiguration_t &config,
HPDF_Page_SetGrayStroke (page, 0.00f);
HPDF_Page_BeginText (page);
HPDF_Page_SetFontAndSize (page, font, fontPtSize);
HPDF_Page_MoveTextPos (page, position.first + margins + rect.first + margins, position.second + margins + fontPtSize + rect.second*numColors/1.5 - (fontPtSize*3.30f) );
HPDF_Page_MoveTextPos(page, position.first + margins + rect.first + margins, position.second + margins + fontPtSize + rect.second * numColors / 1.5f - (fontPtSize * 3.30f));
HPDF_Page_ShowText (page, label.toLatin1());
HPDF_Page_EndText (page);
@@ -542,7 +542,7 @@ void drawScalarBar(HPDF_Page page, const PoleFigureConfiguration_t &config,
HPDF_Page_SetGrayStroke (page, 0.00f);
HPDF_Page_BeginText (page);
HPDF_Page_SetFontAndSize (page, font, fontPtSize);
HPDF_Page_MoveTextPos (page, position.first + margins + rect.first + margins, position.second + margins + fontPtSize + rect.second*numColors/1.5 - (fontPtSize*4.40f) );
HPDF_Page_MoveTextPos(page, position.first + margins + rect.first + margins, position.second + margins + fontPtSize + rect.second * numColors / 1.5f - (fontPtSize * 4.40f));
HPDF_Page_ShowText (page, label.toLatin1());
HPDF_Page_EndText (page);
@@ -551,7 +551,7 @@ void drawScalarBar(HPDF_Page page, const PoleFigureConfiguration_t &config,
HPDF_Page_SetGrayStroke (page, 0.00f);
HPDF_Page_BeginText (page);
HPDF_Page_SetFontAndSize (page, font, fontPtSize);
HPDF_Page_MoveTextPos (page, position.first + margins + rect.first + margins, position.second + margins + fontPtSize + rect.second*numColors/1.5 - (fontPtSize*5.50f) );
HPDF_Page_MoveTextPos(page, position.first + margins + rect.first + margins, position.second + margins + fontPtSize + rect.second * numColors / 1.5f - (fontPtSize * 5.50f));
HPDF_Page_ShowText (page, label.toLatin1());
HPDF_Page_EndText (page);
@@ -845,28 +845,28 @@ void WritePoleFigure::execute()
{
pageWidth = subCanvasWidth * 4;
pageHeight = subCanvasHeight;
imagePositions[0] = std::make_pair(0, 0);
imagePositions[1] = std::make_pair(subCanvasWidth, 0);
imagePositions[2] = std::make_pair(subCanvasWidth * 2, 0);
imagePositions[3] = std::make_pair(subCanvasWidth * 3, 0);
imagePositions[0] = std::make_pair(0.0f, 0.0f);
imagePositions[1] = std::make_pair(subCanvasWidth, 0.0f);
imagePositions[2] = std::make_pair(subCanvasWidth * 2.0f, 0.0f);
imagePositions[3] = std::make_pair(subCanvasWidth * 3.0f, 0.0f);
}
else if(m_ImageLayout == SIMPL::Layout::Vertical)
{
pageWidth = subCanvasWidth;
pageHeight = subCanvasHeight * 4.0f;
imagePositions[0] = std::make_pair(0, subCanvasHeight * 3);
imagePositions[1] = std::make_pair(0, subCanvasHeight * 2);
imagePositions[2] = std::make_pair(0, subCanvasHeight * 1);
imagePositions[3] = std::make_pair(0, 0);
imagePositions[0] = std::make_pair(0.0f, subCanvasHeight * 3.0f);
imagePositions[1] = std::make_pair(0.0f, subCanvasHeight * 2.0f);
imagePositions[2] = std::make_pair(0.0f, subCanvasHeight * 1.0f);
imagePositions[3] = std::make_pair(0.0f, 0.0f);
}
else if(m_ImageLayout == SIMPL::Layout::Square)
{
pageWidth =subCanvasWidth * 2;
pageHeight = subCanvasHeight * 2;
imagePositions[0] = std::make_pair(0, subCanvasHeight); // Upper Left
pageWidth = subCanvasWidth * 2.0f;
pageHeight = subCanvasHeight * 2.0f;
imagePositions[0] = std::make_pair(0.0f, subCanvasHeight); // Upper Left
imagePositions[1] = std::make_pair(subCanvasWidth, subCanvasHeight); // Upper Right
imagePositions[2] = std::make_pair(0, 0); // Lower Left
imagePositions[3] = std::make_pair(subCanvasWidth, 0); // Lower Right
imagePositions[2] = std::make_pair(0.0f, 0.0f); // Lower Left
imagePositions[3] = std::make_pair(subCanvasWidth, 0.0f); // Lower Right
}
pageHeight = pageHeight + margins + fontPtSize;
@@ -912,29 +912,29 @@ void WritePoleFigure::execute()
{
if(text.at(k) == '-')
{
HPDF_TextWidth tw = HPDF_Font_TextWidth(font, buffer.data(), buffer.size());
int32_t scaledOffset = (tw.width * fontPtSize / 1000);
buffer.push_back(static_cast<uint8_t>(text.at(k+1).toLatin1()));
tw = HPDF_Font_TextWidth(font, buffer.data(), buffer.size());
int32_t scaledOffset2 = (tw.width * fontPtSize / 1000);
buffer.pop_back();
int32_t diff = (scaledOffset2 - scaledOffset);
buf[0] = '-';
tw = HPDF_Font_TextWidth(font, buf, 1);
int32_t charWidth = (tw.width * fontPtSize / 1000);
scaledOffset = scaledOffset + (diff - charWidth)/2;
// Draw the bar at the correct location...
std::string underScore("-");
HPDF_Page_BeginText (page);
HPDF_Page_SetFontAndSize (page, font, fontPtSize);
HPDF_Page_MoveTextPos (page, x + margins + scaledOffset, y+margins+fontPtSize+imageHeight+fontPtSize*1.60+ margins);
HPDF_Page_ShowText (page, underScore.c_str());
HPDF_Page_EndText (page);
k++;
HPDF_TextWidth tw = HPDF_Font_TextWidth(font, buffer.data(), static_cast<HPDF_UINT>(buffer.size()));
int32_t scaledOffset = static_cast<int32_t>(tw.width * fontPtSize / 1000);
buffer.push_back(static_cast<uint8_t>(text.at(k + 1).toLatin1()));
tw = HPDF_Font_TextWidth(font, buffer.data(), static_cast<HPDF_UINT>(buffer.size()));
int32_t scaledOffset2 = static_cast<int32_t>(tw.width * fontPtSize / 1000);
buffer.pop_back();
int32_t diff = (scaledOffset2 - scaledOffset);
buf[0] = '-';
tw = HPDF_Font_TextWidth(font, buf, 1);
int32_t charWidth = static_cast<int32_t>(tw.width * fontPtSize / 1000.0f);
scaledOffset = scaledOffset + (diff - charWidth) / 2;
// Draw the bar at the correct location...
std::string underScore("-");
HPDF_Page_BeginText(page);
HPDF_Page_SetFontAndSize(page, font, fontPtSize);
HPDF_Page_MoveTextPos(page, x + margins + scaledOffset, y + margins + fontPtSize + imageHeight + fontPtSize * 1.60f + margins);
HPDF_Page_ShowText(page, underScore.c_str());
HPDF_Page_EndText(page);
k++;
}
// Keep building up the string to finally print.
if(text.at(k) != '-')
@@ -1001,11 +1001,11 @@ void WritePoleFigure::execute()
// Now draw the Color Scalar Bar if needed.
if(config.discrete)
{
drawDiscreteInfoArea(page, config, imagePositions[3], margins, imageHeight / 20.0f, font, phase, laueNames[laueIndex], materialName);
drawDiscreteInfoArea(page, config, imagePositions[3], margins, imageHeight / 20.0f, font, static_cast<int32_t>(phase), laueNames[laueIndex], materialName);
}
else
{
drawScalarBar(page, config, imagePositions[3], margins, imageHeight / 20.0f, font, phase, laueNames[laueIndex], materialName);
drawScalarBar(page, config, imagePositions[3], margins, imageHeight / 20.0f, font, static_cast<int32_t>(phase), laueNames[laueIndex], materialName);
}
/* save the document to a file */
@@ -1020,20 +1020,6 @@ void WritePoleFigure::execute()
notifyStatusMessage(getHumanLabel(), "Complete");
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
AbstractFilter::Pointer WritePoleFigure::newFilterInstance(bool copyFilterParameters) const
{
WritePoleFigure::Pointer filter = WritePoleFigure::New();
if(copyFilterParameters)
{
copyFilterParameterInstanceVariables(filter.get());
}
return filter;
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
@@ -156,11 +156,6 @@ class OrientationAnalysis_EXPORT WritePoleFigure : public AbstractFilter
*/
const QString getFilterVersion() const override;
/**
* @brief newFilterInstance Reimplemented from @see AbstractFilter class
*/
AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override;
/**
* @brief getGroupName Reimplemented from @see AbstractFilter class
*/
@@ -105,7 +105,7 @@ class SampleSurfaceMeshImplByPoints
GeometryMath::FindDistanceBetweenPoints(ll, ur, radius);
int64_t pointsVisited = 0;
// check points in vertex array to see if they are in the bounding box of the feature
for(int64_t i = start; i < end; i++)
for(int64_t i = static_cast<int64_t>(start); i < static_cast<int64_t>(end); i++)
{
// Check for the filter being cancelled.
if(m_Filter->getCancel())
@@ -462,8 +462,8 @@ void SampleSurfaceMesh::execute()
#endif
// C++11 RIGHT HERE....
unsigned int nthreads = std::thread::hardware_concurrency();
// If the number of featurs is larger than the number of cores to do the work then parallelize over the number of features
int32_t nthreads = static_cast<int32_t>(std::thread::hardware_concurrency()); // Returns ZERO if not defined on this platform
// If the number of features is larger than the number of cores to do the work then parallelize over the number of features
// otherwise parallelize over the number of triangle points.
if(numFeatures > nthreads)
{

0 comments on commit 2f324e3

Please sign in to comment.