1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
|
/*LICENSE_START*/
/*
* Copyright (C) 2014 Washington University School of Medicine
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*LICENSE_END*/
#define __CIFTI_BRAINORDINATE_DATA_SERIES_FILE_DECLARE__
#include "CiftiBrainordinateDataSeriesFile.h"
#undef __CIFTI_BRAINORDINATE_DATA_SERIES_FILE_DECLARE__
#include "CaretLogger.h"
#include "ChartDataCartesian.h"
#include "SceneClass.h"
using namespace caret;
/**
* \class caret::CiftiBrainordinateDataSeriesFile
* \brief CIFTI Brainordinate by Data-Series File.
* \ingroup Files
*/
/**
* Constructor.
*/
CiftiBrainordinateDataSeriesFile::CiftiBrainordinateDataSeriesFile()
: CiftiMappableDataFile(DataFileTypeEnum::CONNECTIVITY_DENSE_TIME_SERIES)
{
for (int32_t i = 0; i < BrainConstants::MAXIMUM_NUMBER_OF_BROWSER_TABS; i++) {
m_chartingEnabledForTab[i] = false;
}
}
/**
* Destructor.
*/
CiftiBrainordinateDataSeriesFile::~CiftiBrainordinateDataSeriesFile()
{
}
/**
* Update coloring for all maps.
*
* Note: Overridden since Data-Series files have one palette that is
* applied to ALL maps. For data-series, just invalidate the coloring
* for all maps (data points).
*
* @param paletteFile
* Palette file containing palettes.
*/
void
CiftiBrainordinateDataSeriesFile::updateScalarColoringForAllMaps(const PaletteFile* /*paletteFile*/)
{
/*
* Just need to invalidate coloring.
* Updating coloring for all maps would take time.
* Coloring update is triggered by code that colors nodes/voxels
* when drawing.
*/
invalidateColoringInAllMaps();
}
/**
* @return Is charting enabled for this file?
*/
bool
CiftiBrainordinateDataSeriesFile::isBrainordinateChartingEnabled(const int32_t tabIndex) const
{
CaretAssertArrayIndex(m_chartingEnabledForTab,
BrainConstants::MAXIMUM_NUMBER_OF_BROWSER_TABS,
tabIndex);
return m_chartingEnabledForTab[tabIndex];
}
/**
* @return Return true if the file's current state supports
* charting data, else false. Typically a brainordinate file
* is chartable if it contains more than one map.
*/
bool
CiftiBrainordinateDataSeriesFile::isBrainordinateChartingSupported() const
{
if (getNumberOfMaps() > 1) {
return true;
}
return false;
}
/**
* Set charting enabled for this file.
*
* @param enabled
* New status for charting enabled.
*/
void
CiftiBrainordinateDataSeriesFile::setBrainordinateChartingEnabled(const int32_t tabIndex,
const bool enabled)
{
CaretAssertArrayIndex(m_chartingEnabledForTab,
BrainConstants::MAXIMUM_NUMBER_OF_BROWSER_TABS,
tabIndex);
m_chartingEnabledForTab[tabIndex] = enabled;
}
/**
* Load charting data for the surface with the given structure and node index.
*
* @param structure
* The surface's structure.
* @param nodeIndex
* Index of the node.
* @return
* Pointer to the chart data. If the data FAILED to load,
* the returned pointer will return true. Caller takes ownership
* of the pointer and must delete it when no longer needed.
*/
ChartDataCartesian*
CiftiBrainordinateDataSeriesFile::loadBrainordinateChartDataForSurfaceNode(const StructureEnum::Enum structure,
const int32_t nodeIndex) throw (DataFileException)
{
ChartDataCartesian* chartData = helpLoadChartDataForSurfaceNode(structure,
nodeIndex);
return chartData;
// ChartDataCartesian* chartData = NULL;
//
// try {
// std::vector<float> data;
// if (getSeriesDataForSurfaceNode(structure,
// nodeIndex,
// data)) {
// const int64_t numData = static_cast<int64_t>(data.size());
//
// bool timeSeriesFlag = false;
// bool dataSeriesFlag = false;
// float convertTimeToSeconds = 1.0;
// switch (getMapIntervalUnits()) {
// case NiftiTimeUnitsEnum::NIFTI_UNITS_HZ:
// break;
// case NiftiTimeUnitsEnum::NIFTI_UNITS_MSEC:
// timeSeriesFlag = true;
// convertTimeToSeconds = 1000.0;
// break;
// case NiftiTimeUnitsEnum::NIFTI_UNITS_PPM:
// break;
// case NiftiTimeUnitsEnum::NIFTI_UNITS_SEC:
// convertTimeToSeconds = 1.0;
// timeSeriesFlag = true;
// break;
// case NiftiTimeUnitsEnum::NIFTI_UNITS_UNKNOWN:
// dataSeriesFlag = true;
// break;
// case NiftiTimeUnitsEnum::NIFTI_UNITS_USEC:
// convertTimeToSeconds = 1000000.0;
// timeSeriesFlag = true;
// break;
// }
//
// if (dataSeriesFlag) {
// chartData = new ChartDataCartesian(ChartDataTypeEnum::CHART_DATA_TYPE_DATA_SERIES,
// ChartAxisUnitsEnum::CHART_AXIS_UNITS_NONE,
// ChartAxisUnitsEnum::CHART_AXIS_UNITS_NONE);
// }
// else if (timeSeriesFlag) {
// chartData = new ChartDataCartesian(ChartDataTypeEnum::CHART_DATA_TYPE_TIME_SERIES,
// ChartAxisUnitsEnum::CHART_AXIS_UNITS_TIME_SECONDS,
// ChartAxisUnitsEnum::CHART_AXIS_UNITS_NONE);
// }
//
// if (chartData != NULL) {
// float timeStart = 0.0;
// float timeStep = 1.0;
// if (timeSeriesFlag) {
// getMapIntervalStartAndStep(timeStart,
// timeStep);
// timeStart *= convertTimeToSeconds;
// timeStep *= convertTimeToSeconds;
// chartData->setTimeStartInSecondsAxisX(timeStart);
// chartData->setTimeStepInSecondsAxisX(timeStep);
// }
//
// for (int64_t i = 0; i < numData; i++) {
// float xValue = i;
//
// if (timeSeriesFlag) {
// xValue = timeStart + (i * timeStep);
// }
//
// chartData->addPoint(xValue,
// data[i]);
// }
//
// const AString description = (getFileNameNoPath()
// + " node "
// + AString::number(nodeIndex));
// chartData->setDescription(description);
// }
// else {
// const AString msg = "New type of units for data series flag, needs updating for charting";
// CaretAssertMessage(0, msg);
// throw DataFileException(msg);
// }
// }
// }
// catch (const DataFileException& dfe) {
// if (chartData != NULL) {
// delete chartData;
// chartData = NULL;
// }
//
// throw dfe;
// }
//
// return chartData;
}
/**
* Load average charting data for the surface with the given structure and node indices.
*
* @param structure
* The surface's structure.
* @param nodeIndices
* Indices of the node.
* @return
* Pointer to the chart data. If the data FAILED to load,
* the returned pointer will be NULL. Caller takes ownership
* of the pointer and must delete it when no longer needed.
*/
ChartDataCartesian*
CiftiBrainordinateDataSeriesFile::loadAverageBrainordinateChartDataForSurfaceNodes(const StructureEnum::Enum structure,
const std::vector<int32_t>& nodeIndices) throw (DataFileException)
{
ChartDataCartesian* chartData = helpLoadChartDataForSurfaceNodeAverage(structure,
nodeIndices);
return chartData;
}
/**
* Load charting data for the voxel enclosing the given coordinate.
*
* @param xyz
* Coordinate of voxel.
* @return
* Pointer to the chart data. If the data FAILED to load,
* the returned pointer will be NULL. Caller takes ownership
* of the pointer and must delete it when no longer needed.
*/
ChartDataCartesian*
CiftiBrainordinateDataSeriesFile::loadBrainordinateChartDataForVoxelAtCoordinate(const float xyz[3]) throw (DataFileException)
{
ChartDataCartesian* chartData = helpLoadChartDataForVoxelAtCoordinate(xyz);
return chartData;
}
/**
* Get chart data types supported by the file.
*
* @param chartDataTypesOut
* Chart types supported by this file.
*/
void
CiftiBrainordinateDataSeriesFile::getSupportedBrainordinateChartDataTypes(std::vector<ChartDataTypeEnum::Enum>& chartDataTypesOut) const
{
helpGetSupportedBrainordinateChartDataTypes(chartDataTypesOut);
}
/**
* Save file data from the scene. For subclasses that need to
* save to a scene, this method should be overriden. sceneClass
* will be valid and any scene data should be added to it.
*
* @param sceneAttributes
* Attributes for the scene. Scenes may be of different types
* (full, generic, etc) and the attributes should be checked when
* restoring the scene.
*
* @param sceneClass
* sceneClass to which data members should be added.
*/
void
CiftiBrainordinateDataSeriesFile::saveFileDataToScene(const SceneAttributes* sceneAttributes,
SceneClass* sceneClass)
{
CiftiMappableDataFile::saveFileDataToScene(sceneAttributes,
sceneClass);
sceneClass->addBooleanArray("m_chartingEnabledForTab",
m_chartingEnabledForTab,
BrainConstants::MAXIMUM_NUMBER_OF_BROWSER_TABS);
}
/**
* Restore file data from the scene. For subclasses that need to
* restore from a scene, this method should be overridden. The scene class
* will be valid and any scene data may be obtained from it.
*
* @param sceneAttributes
* Attributes for the scene. Scenes may be of different types
* (full, generic, etc) and the attributes should be checked when
* restoring the scene.
*
* @param sceneClass
* sceneClass for the instance of a class that implements
* this interface. Will NEVER be NULL.
*/
void
CiftiBrainordinateDataSeriesFile::restoreFileDataFromScene(const SceneAttributes* sceneAttributes,
const SceneClass* sceneClass)
{
CiftiMappableDataFile::restoreFileDataFromScene(sceneAttributes,
sceneClass);
const ScenePrimitiveArray* tabArray = sceneClass->getPrimitiveArray("m_chartingEnabledForTab");
if (tabArray != NULL) {
sceneClass->getBooleanArrayValue("m_chartingEnabledForTab",
m_chartingEnabledForTab,
BrainConstants::MAXIMUM_NUMBER_OF_BROWSER_TABS);
}
else {
/*
* Obsolete value when charting was not 'per tab'
*/
const bool chartingEnabled = sceneClass->getBooleanValue("m_chartingEnabled",
false);
for (int32_t i = 0; i < BrainConstants::MAXIMUM_NUMBER_OF_BROWSER_TABS; i++) {
m_chartingEnabledForTab[i] = chartingEnabled;
}
}
}
|