Skip to content

Commit 28e7706

Browse files
authored
Fix warnings and update points (#240)
* Update number of points to uint64 * Use reference dataset * Add some const * Rename lambda capture variable to not shadow function paramters * More uint64 * Set MSVC warning level to W3 * We only want one dataset
1 parent e1bac5f commit 28e7706

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ set(CMAKE_AUTORCC ON)
2121
set(CMAKE_AUTOMOC ON)
2222

2323
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
24-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DWIN32 /EHsc /MP /permissive- /Zc:__cplusplus")
24+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DWIN32 /EHsc /W3 /MP /permissive- /Zc:__cplusplus")
2525
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
2626
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD")
2727
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")

src/MappingUtils.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <utility>
1515
#include <vector>
1616

17-
std::pair<const mv::LinkedData*, unsigned int> getSelectionMapping(const mv::Dataset<Points>& source, const mv::Dataset<Points>& target, LinkedDataCondition checkMapping) {
17+
std::pair<const mv::LinkedData*, std::uint64_t> getSelectionMapping(const mv::Dataset<Points>& source, const mv::Dataset<Points>& target, LinkedDataCondition checkMapping) {
1818
const std::vector<mv::LinkedData>& linkedDatas = source->getLinkedData();
1919

2020
if (linkedDatas.empty())
@@ -34,18 +34,18 @@ std::pair<const mv::LinkedData*, unsigned int> getSelectionMapping(const mv::Dat
3434
return { nullptr, 0 };
3535
}
3636

37-
std::pair<const mv::LinkedData*, unsigned int> getSelectionMappingColorsToPositions(const mv::Dataset<Points>& colors, const mv::Dataset<Points>& positions) {
38-
auto testTargetAndParent = [](const mv::LinkedData& linkedData, const mv::Dataset<Points>& positions) -> bool {
37+
std::pair<const mv::LinkedData*, std::uint64_t> getSelectionMappingColorsToPositions(const mv::Dataset<Points>& colors, const mv::Dataset<Points>& positions) {
38+
auto testTargetAndParent = [](const mv::LinkedData& linkedData, const mv::Dataset<Points>& positions_) -> bool {
3939
const mv::Dataset<mv::DatasetImpl> mapTargetData = linkedData.getTargetDataset();
40-
return mapTargetData == positions || parentHasSameNumPoints(mapTargetData, positions);
40+
return mapTargetData == positions_ || parentHasSameNumPoints(mapTargetData, positions_);
4141
};
4242

4343
return getSelectionMapping(colors, positions, testTargetAndParent);
4444
}
4545

46-
std::pair<const mv::LinkedData*, unsigned int> getSelectionMappingPositionsToColors(const mv::Dataset<Points>& positions, const mv::Dataset<Points>& colors) {
47-
auto testTarget = [](const mv::LinkedData& linkedData, const mv::Dataset<Points>& colors) -> bool {
48-
return linkedData.getTargetDataset() == colors;
46+
std::pair<const mv::LinkedData*, std::uint64_t> getSelectionMappingPositionsToColors(const mv::Dataset<Points>& positions, const mv::Dataset<Points>& colors) {
47+
auto testTarget = [](const mv::LinkedData& linkedData, const mv::Dataset<Points>& colors_) -> bool {
48+
return linkedData.getTargetDataset() == colors_;
4949
};
5050

5151
auto [mapping, numTargetPoints] = getSelectionMapping(positions, colors, testTarget);
@@ -58,7 +58,7 @@ std::pair<const mv::LinkedData*, unsigned int> getSelectionMappingPositionsToCol
5858
return { mapping, numTargetPoints };
5959
}
6060

61-
std::pair<const mv::LinkedData*, unsigned int> getSelectionMappingPositionSourceToColors(const mv::Dataset<Points>& positions, const mv::Dataset<Points>& colors) {
61+
std::pair<const mv::LinkedData*, std::uint64_t> getSelectionMappingPositionSourceToColors(const mv::Dataset<Points>& positions, const mv::Dataset<Points>& colors) {
6262
if (!positions->isDerivedData())
6363
return { nullptr, 0 };
6464

@@ -77,7 +77,7 @@ bool checkSurjectiveMapping(const mv::LinkedData& linkedData, const std::uint32_
7777
std::uint32_t count = 0;
7878

7979
for (const auto& [key, vec] : linkedMap) {
80-
for (std::uint32_t val : vec) {
80+
for (const std::uint32_t val : vec) {
8181
if (val >= numPointsInTarget) continue; // Skip values that are too large
8282

8383
if (!found[val]) {

src/MappingUtils.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ using LinkedDataCondition = std::function<bool(const mv::LinkedData& linkedData,
3939
};
4040
This function will return the first match of the condition
4141
*/
42-
std::pair<const mv::LinkedData*, unsigned int> getSelectionMapping(const mv::Dataset<Points>& source, const mv::Dataset<Points>& target, LinkedDataCondition checkMapping);
42+
std::pair<const mv::LinkedData*, std::uint64_t> getSelectionMapping(const mv::Dataset<Points>& source, const mv::Dataset<Points>& target, LinkedDataCondition checkMapping);
4343

4444
// Returns a mapping (linked data) from colors whose target is positions or whose target's parent has the same number of points as positions
45-
std::pair<const mv::LinkedData*, unsigned int> getSelectionMappingColorsToPositions(const mv::Dataset<Points>& colors, const mv::Dataset<Points>& positions);
45+
std::pair<const mv::LinkedData*, std::uint64_t> getSelectionMappingColorsToPositions(const mv::Dataset<Points>& colors, const mv::Dataset<Points>& positions);
4646

4747
// Returns a mapping (linked data) from positions whose target is colors or
4848
// a mapping from positions' parent whose target is colors if the number of data points match
49-
std::pair<const mv::LinkedData*, unsigned int> getSelectionMappingPositionsToColors(const mv::Dataset<Points>& positions, const mv::Dataset<Points>& colors);
49+
std::pair<const mv::LinkedData*, std::uint64_t> getSelectionMappingPositionsToColors(const mv::Dataset<Points>& positions, const mv::Dataset<Points>& colors);
5050

5151
// Returns a mapping (linked data) from positions' source data whose target is colors
52-
std::pair<const mv::LinkedData*, unsigned int> getSelectionMappingPositionSourceToColors(const mv::Dataset<Points>& positions, const mv::Dataset<Points>& colors);
52+
std::pair<const mv::LinkedData*, std::uint64_t> getSelectionMappingPositionSourceToColors(const mv::Dataset<Points>& positions, const mv::Dataset<Points>& colors);
5353

5454
// Check if the mapping is surjective, i.e. hits all elements in the target
5555
bool checkSurjectiveMapping(const mv::LinkedData& linkedData, const std::uint32_t numPointsInTarget);

src/ScatterplotPlugin.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ ScatterplotPlugin::ScatterplotPlugin(const PluginFactory* factory) :
138138
if (datasetsMimeData == nullptr)
139139
return dropRegions;
140140

141-
if (datasetsMimeData->getDatasets().count() > 1)
141+
if (datasetsMimeData->getDatasetsCount() != 1)
142142
return dropRegions;
143143

144-
const auto dataset = datasetsMimeData->getDatasets().first();
144+
const auto& dataset = datasetsMimeData->getDatasetsRef().first();
145145
const auto datasetGuiName = dataset->text();
146146
const auto datasetId = dataset->getId();
147147
const auto dataType = dataset->getDataType();
@@ -244,13 +244,13 @@ ScatterplotPlugin::ScatterplotPlugin(const PluginFactory* factory) :
244244
{
245245
// Check to set whether the number of data points comprised throughout all clusters is the same number
246246
// as the number of data points in the dataset we are trying to color
247-
int totalNumIndices = 0;
247+
std::uint64_t totalNumIndices = 0;
248248
for (const Cluster& cluster : candidateDataset->getClusters())
249249
{
250250
totalNumIndices += cluster.getIndices().size();
251251
}
252252

253-
int totalNumPoints = 0;
253+
std::uint64_t totalNumPoints = 0;
254254
if (_positionDataset->isDerivedData())
255255
totalNumPoints = _positionSourceDataset->getFullDataset<Points>()->getNumPoints();
256256
else
@@ -755,7 +755,7 @@ void ScatterplotPlugin::loadColors(const Dataset<Points>& pointsColor, const std
755755
const mv::SelectionMap::Map& mapColorsToPositions = selectionMapping->getMapping().getMap();
756756

757757
for (const auto& [fromColorID, vecOfPositionIDs] : mapColorsToPositions) {
758-
for (std::uint32_t toPositionID : vecOfPositionIDs) {
758+
for (const std::uint32_t toPositionID : vecOfPositionIDs) {
759759
mappedColorScalars[toPositionID] = colorScalars[fromColorID];
760760
}
761761
}
@@ -775,7 +775,7 @@ void ScatterplotPlugin::loadColors(const Dataset<Points>& pointsColor, const std
775775
for (const auto& [fromPositionID, vecOfColorIDs] : mapPositionsToColors) {
776776
if (mappedColorScalars[fromPositionID] != std::numeric_limits<float>::lowest())
777777
continue;
778-
for (std::uint32_t toColorID : vecOfColorIDs) {
778+
for (const std::uint32_t toColorID : vecOfColorIDs) {
779779
mappedColorScalars[fromPositionID] = colorScalars[toColorID];
780780
}
781781
}
@@ -846,7 +846,7 @@ void ScatterplotPlugin::loadColors(const Dataset<Clusters>& clusters)
846846
return;
847847

848848
// Get global indices from the position dataset
849-
int totalNumPoints = 0;
849+
std::uint64_t totalNumPoints = 0;
850850
if (_positionDataset->isDerivedData())
851851
totalNumPoints = _positionSourceDataset->getFullDataset<Points>()->getNumPoints();
852852
else

src/ScatterplotPlugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class ScatterplotPlugin : public ViewPlugin
119119
Dataset<Points> _positionDataset; /** Smart pointer to points dataset for point position */
120120
Dataset<Points> _positionSourceDataset; /** Smart pointer to source of the points dataset for point position (if any) */
121121
std::vector<mv::Vector2f> _positions; /** Point positions */
122-
unsigned int _numPoints; /** Number of point positions */
122+
std::uint64_t _numPoints; /** Number of point positions */
123123
QPointer<SettingsAction> _settingsAction; /** Group action for all settings */
124124
QPointer<HorizontalToolbarAction> _primaryToolbarAction; /** Horizontal toolbar for primary content */
125125
QRectF _selectionBoundaries; /** Boundaries of the selection */

0 commit comments

Comments
 (0)