diff --git a/src/Algorithms/AlgorithmCiftiCreateDenseScalar.cxx b/src/Algorithms/AlgorithmCiftiCreateDenseScalar.cxx index e7edbae9f..da037df2c 100644 --- a/src/Algorithms/AlgorithmCiftiCreateDenseScalar.cxx +++ b/src/Algorithms/AlgorithmCiftiCreateDenseScalar.cxx @@ -28,7 +28,6 @@ #include "CaretAssert.h" #include "GiftiLabelTable.h" #include "MetricFile.h" -#include "PaletteColorMapping.h" #include "StructureEnum.h" #include "VolumeFile.h" @@ -168,7 +167,6 @@ AlgorithmCiftiCreateDenseScalar::AlgorithmCiftiCreateDenseScalar(ProgressObject* myXML.setNumberOfDimensions(2); myXML.setMap(CiftiXML::ALONG_COLUMN, denseMap); int numMaps = -1; - //Always choose a dominant input, to try to copy palette settings from, even if we have a name list const CaretMappableDataFile* nameFile = NULL; if (leftData != NULL) { @@ -244,11 +242,6 @@ AlgorithmCiftiCreateDenseScalar::AlgorithmCiftiCreateDenseScalar(ProgressObject* } else { scalarMap.setMapName(i, nameFile->getMapName(i));//copy map names } - const PaletteColorMapping* thisPalette = nameFile->getMapPaletteColorMapping(i); - if (thisPalette != NULL) - { - *(scalarMap.getMapPalette(i)) = *thisPalette; - } } myXML.setMap(CiftiXML::ALONG_ROW, scalarMap); myCiftiOut->setCiftiXML(myXML); diff --git a/src/Algorithms/AlgorithmCiftiCreateDenseTimeseries.cxx b/src/Algorithms/AlgorithmCiftiCreateDenseTimeseries.cxx index b0a36e70e..eec8f946b 100644 --- a/src/Algorithms/AlgorithmCiftiCreateDenseTimeseries.cxx +++ b/src/Algorithms/AlgorithmCiftiCreateDenseTimeseries.cxx @@ -26,7 +26,6 @@ #include "CiftiFile.h" #include "GiftiLabelTable.h" #include "MetricFile.h" -#include "PaletteColorMapping.h" #include "StructureEnum.h" #include "VolumeFile.h" @@ -182,18 +181,15 @@ AlgorithmCiftiCreateDenseTimeseries::AlgorithmCiftiCreateDenseTimeseries(Progres myXML.setNumberOfDimensions(2); myXML.setMap(CiftiXML::ALONG_COLUMN, denseMap); int numMaps = -1; - const PaletteColorMapping* myPalette = NULL; if (leftData != NULL) { numMaps = leftData->getNumberOfMaps(); - myPalette = leftData->getMapPaletteColorMapping(0); } if (rightData != NULL) { if (numMaps == -1) { numMaps = rightData->getNumberOfMaps(); - myPalette = rightData->getMapPaletteColorMapping(0); } else { if (numMaps != rightData->getNumberOfMaps()) { @@ -206,7 +202,6 @@ AlgorithmCiftiCreateDenseTimeseries::AlgorithmCiftiCreateDenseTimeseries(Progres if (numMaps == -1) { numMaps = cerebData->getNumberOfMaps(); - myPalette = cerebData->getMapPaletteColorMapping(0); } else { if (numMaps != cerebData->getNumberOfMaps()) { @@ -219,7 +214,6 @@ AlgorithmCiftiCreateDenseTimeseries::AlgorithmCiftiCreateDenseTimeseries(Progres if (numMaps == -1) { numMaps = myVol->getNumberOfMaps(); - myPalette = myVol->getMapPaletteColorMapping(0); } else { if (numMaps != myVol->getNumberOfMaps()) { @@ -237,10 +231,6 @@ AlgorithmCiftiCreateDenseTimeseries::AlgorithmCiftiCreateDenseTimeseries(Progres seriesMap.setStep(timestep); seriesMap.setLength(numMaps); myXML.setMap(CiftiXML::ALONG_ROW, seriesMap); - if (myPalette != NULL) - { - *(myXML.getFilePalette()) = *myPalette; - } myCiftiOut->setCiftiXML(myXML); CaretArray temprow(numMaps); const CiftiBrainModelsMap& myDenseMap = myXML.getBrainModelsMap(CiftiXML::ALONG_COLUMN); diff --git a/src/Algorithms/AlgorithmCiftiSeparate.cxx b/src/Algorithms/AlgorithmCiftiSeparate.cxx index f49c04e73..9a64a262e 100644 --- a/src/Algorithms/AlgorithmCiftiSeparate.cxx +++ b/src/Algorithms/AlgorithmCiftiSeparate.cxx @@ -654,7 +654,7 @@ void AlgorithmCiftiSeparate::getCroppedVolSpace(const CiftiFile* ciftiIn, const int64_t numVoxels = (int64_t)myMap.size(); if (numVoxels > 0) {//make a voxel bounding box to minimize memory usage - int64_t extrema[6] = { myMap[0].m_ijk[0], + int extrema[6] = { myMap[0].m_ijk[0], myMap[0].m_ijk[0], myMap[0].m_ijk[1], myMap[0].m_ijk[1], @@ -699,7 +699,7 @@ void AlgorithmCiftiSeparate::getCroppedVolSpaceAll(const CiftiFile* ciftiIn, con int64_t numVoxels = (int64_t)myMap.size(); if (numVoxels > 0) {//make a voxel bounding box to minimize memory usage - int64_t extrema[6] = { myMap[0].m_ijk[0], + int extrema[6] = { myMap[0].m_ijk[0], myMap[0].m_ijk[0], myMap[0].m_ijk[1], myMap[0].m_ijk[1], diff --git a/src/Algorithms/AlgorithmVolumeResample.cxx b/src/Algorithms/AlgorithmVolumeResample.cxx index c5c92ffce..accd67e84 100644 --- a/src/Algorithms/AlgorithmVolumeResample.cxx +++ b/src/Algorithms/AlgorithmVolumeResample.cxx @@ -53,9 +53,6 @@ OperationParameters* AlgorithmVolumeResample::getParameters() ret->addVolumeOutputParameter(4, "volume-out", "the output volume"); - OptionalParameter* backgroundOpt = ret->createOptionalParameter(8, "-background", "use a specified value for locations outside the FoV of the input image or warpfield(s)"); - backgroundOpt->addDoubleParameter(1, "value", "the value to use (default 0)"); - ParameterComponent* affineOpt = ret->createRepeatableParameter(5, "-affine", "add an affine transform"); affineOpt->addStringParameter(1, "affine", "the affine file to use"); OptionalParameter* flirtOpt = affineOpt->createOptionalParameter(2, "-flirt", "MUST be used if affine is a flirt affine"); @@ -94,12 +91,6 @@ void AlgorithmVolumeResample::useParameters(OperationParameters* myParams, Progr auto& affInstances = myParams->getRepeatableParameterInstances(5); auto& affSeriesInstances = myParams->getRepeatableParameterInstances(6); auto& warpInstances = myParams->getRepeatableParameterInstances(7); - float backgroundVal = 0.0f;//the help info says zero, don't use the VolumeFile constant - OptionalParameter* backgroundOpt = myParams->getOptionalParameter(8); - if (backgroundOpt->m_present) - { - backgroundVal = backgroundOpt->getDouble(1); - } VolumeSpace refSpace; { NiftiIO myIO; @@ -115,7 +106,7 @@ void AlgorithmVolumeResample::useParameters(OperationParameters* myParams, Progr } else if (methodStr == "ENCLOSING_VOXEL") { myMethod = VolumeFile::ENCLOSING_VOXEL; } else { - throw AlgorithmException("unrecognized interpolation method '" + methodStr + "'"); + throw AlgorithmException("unrecognized interpolation method"); } XfmStack myStack; auto xfmOrder = myParams->getRepeatableOrder();//helper for some ugly code to resolve relative order of repeatable options @@ -172,11 +163,11 @@ void AlgorithmVolumeResample::useParameters(OperationParameters* myParams, Progr throw AlgorithmException("internal error, tell the developers what you just tried to do"); } } - AlgorithmVolumeResample(myProgObj, inVol, myStack, refSpace, myMethod, outVol, backgroundVal); + AlgorithmVolumeResample(myProgObj, inVol, myStack, refSpace, myMethod, outVol); } AlgorithmVolumeResample::AlgorithmVolumeResample(ProgressObject* myProgObj, const VolumeFile* inVol, const XfmStack& myStack, const VolumeSpace refSpace, - const VolumeFile::InterpType& myMethod, VolumeFile* outVol, const float backgroundVal) : AbstractAlgorithm(myProgObj) + const VolumeFile::InterpType& myMethod, VolumeFile* outVol) : AbstractAlgorithm(myProgObj) { LevelProgress myProgress(myProgObj); vector outDims = inVol->getOriginalDimensions(); @@ -224,9 +215,10 @@ AlgorithmVolumeResample::AlgorithmVolumeResample(ProgressObject* myProgObj, cons Vector3D inCoord = myStack.xfmPoint(outCoord, b, &validCoord);//put it through the inverse transforms that are in reverse order if (validCoord) { - scratchFrame[outVol->getIndex(i, j, k)] = inVol->interpolateValue(inCoord, myMethod, NULL, b, c, backgroundVal); + float interpVal = inVol->interpolateValue(inCoord, myMethod, NULL, b, c); + scratchFrame[outVol->getIndex(i, j, k)] = interpVal; } else { - scratchFrame[outVol->getIndex(i, j, k)] = backgroundVal; + scratchFrame[outVol->getIndex(i, j, k)] = VolumeFile::INVALID_INTERP_VALUE; } } } diff --git a/src/Algorithms/AlgorithmVolumeResample.h b/src/Algorithms/AlgorithmVolumeResample.h index 812fd75cd..540b86e01 100644 --- a/src/Algorithms/AlgorithmVolumeResample.h +++ b/src/Algorithms/AlgorithmVolumeResample.h @@ -39,7 +39,7 @@ namespace caret { static float getAlgorithmInternalWeight(); public: AlgorithmVolumeResample(ProgressObject* myProgObj, const VolumeFile* inVol, const XfmStack& myStack, const VolumeSpace refSpace, - const VolumeFile::InterpType& myMethod, VolumeFile* outVol, float backgroundVal = 0.0f); + const VolumeFile::InterpType& myMethod, VolumeFile* outVol); static OperationParameters* getParameters(); static void useParameters(OperationParameters* myParams, ProgressObject* myProgObj); static AString getCommandSwitch(); diff --git a/src/Algorithms/AlgorithmVolumeWarpfieldAffineRegression.cxx b/src/Algorithms/AlgorithmVolumeWarpfieldAffineRegression.cxx index 8724719c3..4bd4d5dc7 100644 --- a/src/Algorithms/AlgorithmVolumeWarpfieldAffineRegression.cxx +++ b/src/Algorithms/AlgorithmVolumeWarpfieldAffineRegression.cxx @@ -62,7 +62,7 @@ OperationParameters* AlgorithmVolumeWarpfieldAffineRegression::getParameters() AString("For all voxels in the warpfield, do a regression that predicts the post-warp coordinate from the source coordinate. ") + "When -roi is specified, only consider voxels with a value greater than 0 in .\n\n" + "The default is to expect the warpfield to be in relative world coordinates (mm space), and to write the output as a world affine (mm space to mm space). " + - "If you are using FSL-created files and utilities, specify -fnirt and -flirt-out as needed, as their coordinate conventions are different." + "If you are using FSL-created files and utilities, specify -fnirt and -flirt as needed, as their coordinate conventions are different." ); return ret; } diff --git a/src/Annotations/Annotation.cxx b/src/Annotations/Annotation.cxx index a4516baff..5490aca37 100644 --- a/src/Annotations/Annotation.cxx +++ b/src/Annotations/Annotation.cxx @@ -730,9 +730,6 @@ Annotation::initializeAnnotationMembers() &m_colorLine); m_sceneAssistant->addArray("m_customColorLine", m_customColorLine, 4, 0.0); - m_sceneAssistant->add("m_lineWidthPercentage", - &m_lineWidthPercentage); - m_sceneAssistant->add("m_stackingOrder", &m_stackingOrder); } diff --git a/src/Brain/BrainOpenGLAnnotationDrawingFixedPipeline.cxx b/src/Brain/BrainOpenGLAnnotationDrawingFixedPipeline.cxx index 78db6f85a..0cb9bc47e 100644 --- a/src/Brain/BrainOpenGLAnnotationDrawingFixedPipeline.cxx +++ b/src/Brain/BrainOpenGLAnnotationDrawingFixedPipeline.cxx @@ -1283,7 +1283,6 @@ BrainOpenGLAnnotationDrawingFixedPipeline::drawAnnotationsInternal(const Drawing /* * Annotation being drawn by the user. */ - Annotation* temporaryBoxAnnotation(NULL); m_brainOpenGLFixedPipeline->checkForOpenGLError(NULL, "Start of annotation drawn by user model space."); if (m_annotationBeingDrawn != NULL) { @@ -1296,7 +1295,6 @@ BrainOpenGLAnnotationDrawingFixedPipeline::drawAnnotationsInternal(const Drawing AnnotationBox box(AnnotationAttributesDefaultTypeEnum::NORMAL); box.applyCoordinatesSizeAndRotationFromOther(textAnn); box.applyColoringFromOther(textAnn); - temporaryBoxAnnotation = &box; drawAnnotation(m_dummyAnnotationFile, &box, @@ -1397,20 +1395,6 @@ BrainOpenGLAnnotationDrawingFixedPipeline::drawAnnotationsInternal(const Drawing selectFlag = false; } } - - /* - * When drawing a new text annotation by dragging the mouse to - * select a region, a box annotation is drawn (above) to show - * the region for the text. We DO NOT want to allow selection - * of this box because it will block selection of the text - * annotation and, since the box annotation is drawn on the - * stack (above), selection of the box will cause a crash. - */ - if (temporaryBoxAnnotation != NULL) { - if (selectionInfo.m_annotation == temporaryBoxAnnotation) { - selectFlag = false; - } - } if (selectFlag) { annotationID->setAnnotation(selectionInfo.m_annotationFile, selectionInfo.m_annotation, diff --git a/src/Brain/BrainOpenGLFixedPipeline.cxx b/src/Brain/BrainOpenGLFixedPipeline.cxx index 6bbfaa3ac..93f0d6c35 100644 --- a/src/Brain/BrainOpenGLFixedPipeline.cxx +++ b/src/Brain/BrainOpenGLFixedPipeline.cxx @@ -169,7 +169,6 @@ #include "SurfaceProjectionBarycentric.h" #include "SurfaceProjectionVanEssen.h" #include "SurfaceSelectionModel.h" -#include "TabDrawingInfo.h" #include "TopologyHelper.h" #include "VolumeFile.h" #include "VolumeMappableInterface.h" @@ -1611,10 +1610,10 @@ BrainOpenGLFixedPipeline::drawTabAnnotations(const BrainOpenGLViewportContent* t case ModelTypeEnum::MODEL_TYPE_CHART: case ModelTypeEnum::MODEL_TYPE_CHART_TWO: case ModelTypeEnum::MODEL_TYPE_INVALID: + case ModelTypeEnum::MODEL_TYPE_HISTOLOGY: case ModelTypeEnum::MODEL_TYPE_MULTI_MEDIA: drawScaleBarsFlag = false; break; - case ModelTypeEnum::MODEL_TYPE_HISTOLOGY: case ModelTypeEnum::MODEL_TYPE_SURFACE: case ModelTypeEnum::MODEL_TYPE_SURFACE_MONTAGE: case ModelTypeEnum::MODEL_TYPE_VOLUME_SLICES: @@ -4585,7 +4584,6 @@ BrainOpenGLFixedPipeline::setupVolumeDrawInfo(BrowserTabContent* browserTabConte { volumeDrawInfoOut.clear(); - const int32_t tabIndex(browserTabContent->getTabNumber()); OverlaySet* overlaySet = browserTabContent->getOverlaySet(); const int32_t numberOfOverlays = overlaySet->getNumberOfDisplayedOverlays(); for (int32_t iOver = (numberOfOverlays - 1); iOver >= 0; iOver--) { @@ -4646,7 +4644,6 @@ BrainOpenGLFixedPipeline::setupVolumeDrawInfo(BrowserTabContent* browserTabConte statistics, wholeBrainVoxelDrawingMode, mapIndex, - tabIndex, opacity); volumeDrawInfoOut.push_back(vdi); } @@ -4665,7 +4662,6 @@ BrainOpenGLFixedPipeline::setupVolumeDrawInfo(BrowserTabContent* browserTabConte NULL, wholeBrainVoxelDrawingMode, mapIndex, - tabIndex, opacity); volumeDrawInfoOut.push_back(vdi); } @@ -4873,7 +4869,6 @@ BrainOpenGLFixedPipeline::drawVolumeVoxelsAsCubesWholeBrain(std::vectorgetDisplayPropertiesLabels(); const DisplayGroupEnum::Enum displayGroup = dsl->getDisplayGroupForTab(this->windowTabIndex); - const LabelViewModeEnum::Enum labelViewMode(dsl->getLabelViewModeForTab(this->windowTabIndex)); /* * For identification, five items per voxel @@ -4944,12 +4939,6 @@ BrainOpenGLFixedPipeline::drawVolumeVoxelsAsCubesWholeBrain(std::vectorwindowTabIndex); - uint8_t rgba[4]; for (int64_t iVoxel = 0; iVoxel < dimI; iVoxel++) { for (int64_t jVoxel = 0; jVoxel < dimJ; jVoxel++) { @@ -4960,7 +4949,8 @@ BrainOpenGLFixedPipeline::drawVolumeVoxelsAsCubesWholeBrain(std::vectorwindowTabIndex, rgba); } else { @@ -4968,7 +4958,8 @@ BrainOpenGLFixedPipeline::drawVolumeVoxelsAsCubesWholeBrain(std::vectorwindowTabIndex, rgba); } if (rgba[3] > 0) { @@ -5181,7 +5172,7 @@ BrainOpenGLFixedPipeline::drawVolumeVoxelsAsCubesWholeBrainOutsideFaces(std::vec const DisplayPropertiesLabels* dsl = m_brain->getDisplayPropertiesLabels(); const DisplayGroupEnum::Enum displayGroup = dsl->getDisplayGroupForTab(this->windowTabIndex); - const LabelViewModeEnum::Enum labelViewMode(dsl->getLabelViewModeForTab(this->windowTabIndex)); + /* * For identification, five items per voxel * 1) volume index @@ -5325,12 +5316,6 @@ BrainOpenGLFixedPipeline::drawVolumeVoxelsAsCubesWholeBrainOutsideFaces(std::vec std::vector axialSliceRGBA(numAxialSizeRGBA); std::vector volumeRGBA(numRGBA, 0); - const TabDrawingInfo tabDrawingInfo(volInfo.mapFile, - volInfo.mapIndex, - displayGroup, - labelViewMode, - this->windowTabIndex); - /* * Get coloring for all voxels in volume */ @@ -5341,7 +5326,8 @@ BrainOpenGLFixedPipeline::drawVolumeVoxelsAsCubesWholeBrainOutsideFaces(std::vec volumeFile->getVoxelColorsForSliceInMap(volInfo.mapIndex, VolumeSliceViewPlaneEnum::AXIAL, kVoxel, - tabDrawingInfo, + displayGroup, + this->windowTabIndex, axialSliceRGBA.data()); /* * Apply layer opacity @@ -9487,8 +9473,7 @@ BrainOpenGLFixedPipeline::VolumeDrawInfo::VolumeDrawInfo(CaretMappableDataFile* const FastStatistics* statistics, const WholeBrainVoxelDrawingMode::Enum wholeBrainVoxelDrawingMode, const int32_t mapIndex, - const int32_t tabIndex, - const float opacity) + const float opacity) : statistics(statistics) { this->mapFile = mapFile; this->volumeFile = volumeFile; @@ -9496,7 +9481,6 @@ BrainOpenGLFixedPipeline::VolumeDrawInfo::VolumeDrawInfo(CaretMappableDataFile* this->paletteColorMapping = paletteColorMapping; this->wholeBrainVoxelDrawingMode = wholeBrainVoxelDrawingMode; this->mapIndex = mapIndex; - this->tabIndex = tabIndex; this->opacity = opacity; this->volumeType = SubvolumeAttributes::UNKNOWN; if (this->volumeFile != NULL) { diff --git a/src/Brain/BrainOpenGLFixedPipeline.h b/src/Brain/BrainOpenGLFixedPipeline.h index 02f4be422..f3cb807e1 100644 --- a/src/Brain/BrainOpenGLFixedPipeline.h +++ b/src/Brain/BrainOpenGLFixedPipeline.h @@ -171,7 +171,6 @@ namespace caret { const FastStatistics* statistics, const WholeBrainVoxelDrawingMode::Enum wholeBrainVoxelDrawingMode, const int32_t mapIndex, - const int32_t tabIndex, const float opacity); Brain* brain; CaretMappableDataFile* mapFile; @@ -181,7 +180,6 @@ namespace caret { WholeBrainVoxelDrawingMode::Enum wholeBrainVoxelDrawingMode; const FastStatistics* statistics; int32_t mapIndex; - int32_t tabIndex; float opacity; }; diff --git a/src/Brain/BrainOpenGLHistologySliceDrawing.cxx b/src/Brain/BrainOpenGLHistologySliceDrawing.cxx index 0fc4f7014..cf291a293 100644 --- a/src/Brain/BrainOpenGLHistologySliceDrawing.cxx +++ b/src/Brain/BrainOpenGLHistologySliceDrawing.cxx @@ -66,7 +66,6 @@ #include "SelectionItemVoxel.h" #include "SelectionManager.h" #include "SessionManager.h" -#include "TabDrawingInfo.h" #include "VolumeFile.h" #include "VolumeMappableInterface.h" @@ -315,8 +314,6 @@ BrainOpenGLHistologySliceDrawing::draw(BrainOpenGLFixedPipeline* fixedPipelineDr return; } - setupScaleBars(orthographicProjection); - if (s_debugFlag) { std::cout << orthographicProjection.toString() << std::endl; } @@ -985,7 +982,6 @@ BrainOpenGLHistologySliceDrawing::drawVolumeOverlaysOnCziImageFile(std::vectorm_brain->getDisplayPropertiesLabels(); const int32_t tabIndex(m_browserTabContent->getTabNumber()); const DisplayGroupEnum::Enum displayGroup = dsl->getDisplayGroupForTab(tabIndex); - const LabelViewModeEnum::Enum labelViewMode(dsl->getLabelViewModeForTab(tabIndex)); glPushAttrib(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); @@ -1006,13 +1002,9 @@ BrainOpenGLHistologySliceDrawing::drawVolumeOverlaysOnCziImageFile(std::vector= 0); AString errorMessage; - const TabDrawingInfo tabDrawingInfo(dynamic_cast(vmi), - mapIndex, - displayGroup, - labelViewMode, - tabIndex); std::vector primitives(vmi->getHistologySliceIntersectionPrimitive(mapIndex, - tabDrawingInfo, + displayGroup, + tabIndex, histologySlice, overlay->getVolumeToImageMappingMode(), overlay->getVolumeToImageMappingThickness(), @@ -1076,35 +1068,3 @@ BrainOpenGLHistologySliceDrawing::drawVolumeOverlaysOnCziImageFile(std::vectorplaneXyzToStereotaxicXyz(pLeft, xyzLeft) - && slice->planeXyzToStereotaxicXyz(pRight, xyzRight)) { - /* - * Needed for scale bar drawing - */ - m_fixedPipelineDrawing->setupScaleBarDrawingInformation(m_browserTabContent, - xyzLeft[0], - xyzRight[0]); - return; - } - } - } -} diff --git a/src/Brain/BrainOpenGLHistologySliceDrawing.h b/src/Brain/BrainOpenGLHistologySliceDrawing.h index e05699703..1d0a8e1e0 100644 --- a/src/Brain/BrainOpenGLHistologySliceDrawing.h +++ b/src/Brain/BrainOpenGLHistologySliceDrawing.h @@ -103,8 +103,6 @@ namespace caret { void drawVolumeOverlaysOnCziImageFile(std::vector& volumeDrawingInfo); - void setupScaleBars(const GraphicsOrthographicProjection& orthographicProjection); - BrainOpenGLFixedPipeline* m_fixedPipelineDrawing = NULL; BrowserTabContent* m_browserTabContent = NULL; diff --git a/src/Brain/BrainOpenGLVolumeMprThreeDrawing.cxx b/src/Brain/BrainOpenGLVolumeMprThreeDrawing.cxx index c1ab7781a..55ba1c557 100644 --- a/src/Brain/BrainOpenGLVolumeMprThreeDrawing.cxx +++ b/src/Brain/BrainOpenGLVolumeMprThreeDrawing.cxx @@ -70,7 +70,6 @@ #include "SelectionItemVoxelEditing.h" #include "SelectionManager.h" #include "SessionManager.h" -#include "TabDrawingInfo.h" #include "VolumeVerticesEdgesFaces.h" #include "VolumeFile.h" #include "VolumeMprViewportSlice.h" @@ -148,8 +147,8 @@ BrainOpenGLVolumeMprThreeDrawing::draw(BrainOpenGLFixedPipeline* fixedPipelineDr const DisplayPropertiesLabels* dsl = m_brain->getDisplayPropertiesLabels(); m_displayGroup = dsl->getDisplayGroupForTab(m_fixedPipelineDrawing->windowTabIndex); + m_tabIndex = m_browserTabContent->getTabNumber(); - m_labelViewMode = dsl->getLabelViewModeForTab(m_tabIndex); m_mprViewMode = browserTabContent->getVolumeMprViewMode(); m_orientationMode = browserTabContent->getVolumeMprOrientationMode(); @@ -2808,8 +2807,7 @@ BrainOpenGLVolumeMprThreeDrawing::drawSliceIntensityProjection2D(const VolumeMpr CaretAssertToDoFatal(); /* should be using normal slice ID */ performIntensityIdentification(mprSliceView, sliceViewPlane, - volumeFile, - mapIndex); + volumeFile); return; } @@ -3132,12 +3130,6 @@ BrainOpenGLVolumeMprThreeDrawing::drawSliceWithPrimitive(const VolumeMprVirtualS setupMprBlending(BlendingMode::MPR_UNDERLAY_SLICE, s_INVALID_ALPHA_VALUE, s_INVALID_NUMBER_OF_SLICES); - /* - * May fix labels on/off when only one layer - * setupMprBlending(BlendingMode::MPR_OVERLAY_SLICE, //JWH 27aug2024 - * 1.0, - * s_INVALID_NUMBER_OF_SLICES); - */ firstFlag = false; } else { @@ -3158,13 +3150,9 @@ BrainOpenGLVolumeMprThreeDrawing::drawSliceWithPrimitive(const VolumeMprVirtualS glPolygonOffset(-2.0, 2.0); } } - const TabDrawingInfo tabDrawingInfo(vdi.mapFile, - vdi.mapIndex, - m_displayGroup, - m_labelViewMode, - m_tabIndex); GraphicsPrimitiveV3fT3f* primitive(volumeInterface->getVolumeDrawingTrianglesPrimitive(vdi.mapIndex, - tabDrawingInfo)); + m_displayGroup, + m_tabIndex)); if (primitive != NULL) { const Vector3D sliceOffset(0.0, 0.0, 0.0); @@ -4117,8 +4105,7 @@ BrainOpenGLVolumeMprThreeDrawing::drawSliceIntensityProjection3D(const VolumeSli if (idModeFlag) { performIntensityIdentification(mprSliceView, sliceViewPlane, - volumeFile, - mapIndex); + volumeFile); return; } @@ -4187,13 +4174,9 @@ BrainOpenGLVolumeMprThreeDrawing::drawSliceIntensityProjection3D(const VolumeSli } for (int32_t iStep = 0; iStep < numSteps; iStep++) { - const TabDrawingInfo tabDrawingInfo(dynamic_cast(volumeFile), - mapIndex, - m_displayGroup, - m_labelViewMode, - m_tabIndex); GraphicsPrimitiveV3fT3f* primitive(volumeFile->getVolumeDrawingTrianglesPrimitive(mapIndex, - tabDrawingInfo)); + m_displayGroup, + m_tabIndex)); if (primitive != NULL) { setPrimitiveCoordinates(mprSliceView, @@ -4279,14 +4262,11 @@ BrainOpenGLVolumeMprThreeDrawing::getVoxelSize(const VolumeMappableInterface* vo * Slice view plane being drawn * @param volume * Volume being drawn - * @param mapIndex - * Map file index */ void BrainOpenGLVolumeMprThreeDrawing::performIntensityIdentification(const VolumeMprVirtualSliceView& mprSliceView, const VolumeSliceViewPlaneEnum::Enum sliceViewPlane, - VolumeMappableInterface* volume, - const int32_t mapIndex) + VolumeMappableInterface* volume) { CaretAssertToDoFatal(); /* should be using normal slice ID for identification */ @@ -4380,11 +4360,6 @@ BrainOpenGLVolumeMprThreeDrawing::performIntensityIdentification(const VolumeMpr } } - const TabDrawingInfo tabDrawingInfo(dynamic_cast(volume), - mapIndex, - m_displayGroup, - m_labelViewMode, - m_tabIndex); int64_t minMaxIJK[3] { -1, -1, -1 }; const Vector3D p1toP2Vector((p2 - p1).normal()); const float stepDistance(voxelSize); @@ -4398,7 +4373,7 @@ BrainOpenGLVolumeMprThreeDrawing::performIntensityIdentification(const VolumeMpr const int32_t brickIndex(0); uint8_t rgba[4]; volume->getVoxelColorInMap(voxelI, voxelJ, voxelK, brickIndex, - tabDrawingInfo, rgba); + m_displayGroup, m_tabIndex, rgba); if (rgba[3] > 0) { const float intensity((rgba[0] * 0.30) + (rgba[1] * 0.59) diff --git a/src/Brain/BrainOpenGLVolumeMprThreeDrawing.h b/src/Brain/BrainOpenGLVolumeMprThreeDrawing.h index 5ca3737ac..c7413256d 100644 --- a/src/Brain/BrainOpenGLVolumeMprThreeDrawing.h +++ b/src/Brain/BrainOpenGLVolumeMprThreeDrawing.h @@ -29,7 +29,6 @@ #include "CaretObject.h" #include "VolumeMprVirtualSliceView.h" #include "GraphicsViewport.h" -#include "LabelViewModeEnum.h" #include "Plane.h" #include "SelectionItemVolumeMprCrosshair.h" #include "Vector3D.h" @@ -258,8 +257,7 @@ namespace caret { void performIntensityIdentification(const VolumeMprVirtualSliceView& mprSliceView, const VolumeSliceViewPlaneEnum::Enum sliceViewPlane, - VolumeMappableInterface* volume, - const int32_t mapIndex); + VolumeMappableInterface* volume); float getVoxelSize(const VolumeMappableInterface* volume) const; @@ -296,8 +294,6 @@ namespace caret { DisplayGroupEnum::Enum m_displayGroup; - LabelViewModeEnum::Enum m_labelViewMode; - int32_t m_tabIndex = -1; VolumeMprViewModeEnum::Enum m_mprViewMode = VolumeMprViewModeEnum::MULTI_PLANAR_RECONSTRUCTION; diff --git a/src/Brain/BrainOpenGLVolumeMprTwoDrawing.cxx b/src/Brain/BrainOpenGLVolumeMprTwoDrawing.cxx index 6ed0804bd..0751309bf 100644 --- a/src/Brain/BrainOpenGLVolumeMprTwoDrawing.cxx +++ b/src/Brain/BrainOpenGLVolumeMprTwoDrawing.cxx @@ -70,7 +70,6 @@ #include "SelectionItemVoxelEditing.h" #include "SelectionManager.h" #include "SessionManager.h" -#include "TabDrawingInfo.h" #include "VolumeFile.h" #include "VolumeTextureCoordinateMapper.h" @@ -153,7 +152,7 @@ BrainOpenGLVolumeMprTwoDrawing::draw(BrainOpenGLFixedPipeline* fixedPipelineDraw const DisplayPropertiesLabels* dsl = m_brain->getDisplayPropertiesLabels(); m_displayGroup = dsl->getDisplayGroupForTab(m_fixedPipelineDrawing->windowTabIndex); - m_labelViewMode = dsl->getLabelViewModeForTab(m_fixedPipelineDrawing->windowTabIndex); + m_tabIndex = m_browserTabContent->getTabNumber(); /* @@ -2392,8 +2391,7 @@ BrainOpenGLVolumeMprTwoDrawing::drawSliceIntensityProjection2D(const SliceInfo& CaretAssert(volumeFile); if (idModeFlag) { performIntensityIdentification(sliceInfo, - volumeFile, - volumeFileAndMapIndex.second); + volumeFile); continue; } @@ -2708,13 +2706,9 @@ BrainOpenGLVolumeMprTwoDrawing::drawSliceWithPrimitive(const SliceInfo& sliceInf } } - const TabDrawingInfo tabDrawingInfo(vdi.mapFile, - vdi.mapIndex, - m_displayGroup, - m_labelViewMode, - m_tabIndex); GraphicsPrimitiveV3fT3f* primitive(volumeInterface->getVolumeDrawingTriangleStripPrimitive(vdi.mapIndex, - tabDrawingInfo)); + m_displayGroup, + m_tabIndex)); VolumeTextureCoordinateMapper mapper(volumeInterface); @@ -3475,8 +3469,7 @@ BrainOpenGLVolumeMprTwoDrawing::drawSliceIntensityProjection3D(const VolumeSlice const SliceInfo sliceInfo(createSliceInfo3D()); if (idModeFlag) { performIntensityIdentification(sliceInfo, - volumeFile, - mapIndex); + volumeFile); continue; } std::vector allIntersections(getVolumeRayIntersections(volumeFile, @@ -3528,13 +3521,9 @@ BrainOpenGLVolumeMprTwoDrawing::drawSliceIntensityProjection3D(const VolumeSlice const Vector3D sliceCoords(p1 + stepVector * iStep); const Vector3D sliceOffset(sliceCoords - sliceInfo.m_centerXYZ); - const TabDrawingInfo tabDrawingInfo(dynamic_cast(volumeFile), - mapIndex, - m_displayGroup, - m_labelViewMode, - m_tabIndex); GraphicsPrimitiveV3fT3f* primitive(volumeFile->getVolumeDrawingTriangleStripPrimitive(mapIndex, - tabDrawingInfo)); + m_displayGroup, + m_tabIndex)); if (primitive != NULL) { const Vector3D textureBottomLeft(mapper.mapXyzToStr(sliceInfo.m_bottomLeftXYZ + sliceOffset)); @@ -3646,13 +3635,10 @@ BrainOpenGLVolumeMprTwoDrawing::getVoxelSize(const VolumeMappableInterface* volu * Info for drawing slices * @param volume * Volume being drawn - * @param mapIndex - * Index of the map */ void BrainOpenGLVolumeMprTwoDrawing::performIntensityIdentification(const SliceInfo& sliceInfo, - VolumeMappableInterface* volume, - const int32_t mapIndex) + VolumeMappableInterface* volume) { GraphicsViewport viewport(GraphicsViewport::newInstanceCurrentViewport()); const int32_t mouseVpX(m_fixedPipelineDrawing->mouseX - viewport.getX()); @@ -3710,11 +3696,6 @@ BrainOpenGLVolumeMprTwoDrawing::performIntensityIdentification(const SliceInfo& if (distance > 1.0) { float minMaxIntensity(idMaxIntensityFlag ? 0.0 : 256.0); - const TabDrawingInfo tabDrawingInfo(dynamic_cast(volume), - mapIndex, - m_displayGroup, - m_labelViewMode, - m_tabIndex); int64_t minMaxIJK[3] { -1, -1, -1 }; const Vector3D p1toP2Vector((p2 - p1).normal()); const float stepDistance(voxelSize); @@ -3728,7 +3709,7 @@ BrainOpenGLVolumeMprTwoDrawing::performIntensityIdentification(const SliceInfo& const int32_t brickIndex(0); uint8_t rgba[4]; volume->getVoxelColorInMap(voxelI, voxelJ, voxelK, brickIndex, - tabDrawingInfo, rgba); + m_displayGroup, m_tabIndex, rgba); if (rgba[3] > 0) { const float intensity((rgba[0] * 0.30) + (rgba[1] * 0.59) diff --git a/src/Brain/BrainOpenGLVolumeMprTwoDrawing.h b/src/Brain/BrainOpenGLVolumeMprTwoDrawing.h index 1f5142816..e4ad9750c 100644 --- a/src/Brain/BrainOpenGLVolumeMprTwoDrawing.h +++ b/src/Brain/BrainOpenGLVolumeMprTwoDrawing.h @@ -27,7 +27,6 @@ #include "BrainOpenGLFixedPipeline.h" #include "CaretObject.h" -#include "LabelViewModeEnum.h" #include "Plane.h" #include "SelectionItemVolumeMprCrosshair.h" #include "Vector3D.h" @@ -256,8 +255,7 @@ namespace caret { std::vector> getIntensityVolumeFilesAndMapIndices() const; void performIntensityIdentification(const SliceInfo& sliceInfo, - VolumeMappableInterface* volume, - const int32_t mapIndex); + VolumeMappableInterface* volume); float getVoxelSize(const VolumeMappableInterface* volume) const; @@ -279,8 +277,6 @@ namespace caret { DisplayGroupEnum::Enum m_displayGroup; - LabelViewModeEnum::Enum m_labelViewMode; - int32_t m_tabIndex = -1; VolumeMprViewModeEnum::Enum m_mprViewMode = VolumeMprViewModeEnum::MULTI_PLANAR_RECONSTRUCTION; diff --git a/src/Brain/BrainOpenGLVolumeObliqueSliceDrawing.cxx b/src/Brain/BrainOpenGLVolumeObliqueSliceDrawing.cxx index 6669f31d9..0f2712a91 100644 --- a/src/Brain/BrainOpenGLVolumeObliqueSliceDrawing.cxx +++ b/src/Brain/BrainOpenGLVolumeObliqueSliceDrawing.cxx @@ -43,7 +43,6 @@ #include "CaretPreferenceDataValue.h" #include "CaretPreferences.h" #include "CiftiMappableDataFile.h" -#include "DataFileColorModulateSelector.h" #include "DeveloperFlagsEnum.h" #include "DisplayPropertiesLabels.h" #include "ElapsedTimer.h" @@ -74,7 +73,6 @@ #include "SpacerTabIndex.h" #include "Surface.h" #include "SurfacePlaneIntersectionToContour.h" -#include "TabDrawingInfo.h" #include "VolumeFile.h" #include "VolumeSurfaceOutlineColorOrTabModel.h" #include "VolumeSurfaceOutlineModel.h" @@ -198,7 +196,6 @@ BrainOpenGLVolumeObliqueSliceDrawing::draw(BrainOpenGLFixedPipeline* fixedPipeli const DisplayPropertiesLabels* dsl = m_brain->getDisplayPropertiesLabels(); m_displayGroup = dsl->getDisplayGroupForTab(m_fixedPipelineDrawing->windowTabIndex); - m_labelViewMode = dsl->getLabelViewModeForTab(m_fixedPipelineDrawing->windowTabIndex); m_tabIndex = m_browserTabContent->getTabNumber(); @@ -2666,7 +2663,7 @@ BrainOpenGLVolumeObliqueSliceDrawing::drawObliqueSliceWithOutlines(const VolumeS const int32_t browserTabIndex = m_browserTabContent->getTabNumber(); const DisplayPropertiesLabels* displayPropertiesLabels = m_brain->getDisplayPropertiesLabels(); -// const DisplayGroupEnum::Enum displayGroup = displayPropertiesLabels->getDisplayGroupForTab(browserTabIndex); + const DisplayGroupEnum::Enum displayGroup = displayPropertiesLabels->getDisplayGroupForTab(browserTabIndex); bool haveAlphaBlendingFlag(false); std::vector slices; @@ -2690,8 +2687,7 @@ BrainOpenGLVolumeObliqueSliceDrawing::drawObliqueSliceWithOutlines(const VolumeS numberOfColumns, browserTabIndex, displayPropertiesLabels, - m_displayGroup, - m_labelViewMode, + displayGroup, bottomLeft, leftToRightStepXYZ, bottomToTopStepXYZ, @@ -2798,7 +2794,6 @@ BrainOpenGLVolumeObliqueSliceDrawing::ObliqueSlice::ObliqueSlice(BrainOpenGLFixe const int32_t browserTabIndex, const DisplayPropertiesLabels* displayPropertiesLabels, const DisplayGroupEnum::Enum displayGroup, - const LabelViewModeEnum::Enum labelViewMode, const float originXYZ[3], const float leftToRightStepXYZ[3], const float bottomToTopStepXYZ[3], @@ -2817,7 +2812,6 @@ m_numberOfColumns(numberOfColumns), m_browserTabIndex(browserTabIndex), m_displayPropertiesLabels(displayPropertiesLabels), m_displayGroup(displayGroup), -m_labelViewMode(labelViewMode), m_identificationX(fixedPipelineDrawing->mouseX), m_identificationY(fixedPipelineDrawing->mouseY), m_identificationModeFlag(identificationModeFlag), @@ -2849,31 +2843,8 @@ m_bottomLayerFlag(bottomLayerFlag) const CiftiMappableDataFile* ciftiMappableFileConst = dynamic_cast(volumeInterface); m_ciftiMappableFile = const_cast(ciftiMappableFileConst); - if (m_volumeFile != NULL) { - const DataFileColorModulateSelector* modSel(m_volumeFile->getMapColorModulateFileSelector(m_mapIndex)); - CaretAssert(modSel); - if (modSel->isEnabled()) { - m_modulationVolumeFile = modSel->getSelectedVolumeFile(); - m_modulationMapIndex = modSel->getSelectedMapIndex(); - } - } - - /* - * Special case for detecting "Special-RGB-Volume" for - * displaying a 3 map volume file as RGB values - */ - bool volumeSpecialRgbFlag(false); - if (m_volumeFile != NULL) { - if (m_volumeFile->getType() == SubvolumeAttributes::RGB_WORKBENCH) { - volumeSpecialRgbFlag = true; - } - } m_dataValueType = DataValueType::INVALID; - - if (volumeSpecialRgbFlag) { - m_dataValueType = DataValueType::VOLUME_RGB_WORKBENCH; - } - else if (m_mapFile->isMappedWithPalette()) { + if (m_mapFile->isMappedWithPalette()) { if (m_volumeFile != NULL) { m_dataValueType = DataValueType::VOLUME_PALETTE; } @@ -3131,18 +3102,14 @@ BrainOpenGLVolumeObliqueSliceDrawing::ObliqueSlice::assignRgba(const bool volume case DataValueType::CIFTI_LABEL: { CaretAssert(m_ciftiMappableFile); - const TabDrawingInfo tabDrawingInfo(m_ciftiMappableFile, - m_mapIndex, - m_displayGroup, - m_labelViewMode, - m_browserTabIndex); const GiftiLabelTable* labelTable = m_ciftiMappableFile->getMapLabelTable(m_mapIndex); CaretAssert(labelTable); - NodeAndVoxelColoring::colorIndicesWithLabelTableForObliqueVolume(labelTable, - &m_data[0], - m_data.size(), - tabDrawingInfo, - &m_rgba[0]); + NodeAndVoxelColoring::colorIndicesWithLabelTableForDisplayGroupTab(labelTable, + &m_data[0], + m_data.size(), + m_displayGroup, + m_browserTabIndex, + &m_rgba[0]); } break; case DataValueType::CIFTI_PALETTE: @@ -3171,16 +3138,12 @@ BrainOpenGLVolumeObliqueSliceDrawing::ObliqueSlice::assignRgba(const bool volume CaretAssert(m_volumeFile); const GiftiLabelTable* labelTable = m_volumeFile->getMapLabelTable(m_mapIndex); CaretAssert(labelTable); - const TabDrawingInfo tabDrawingInfo(m_volumeFile, - m_mapIndex, - m_displayGroup, - m_labelViewMode, - m_browserTabIndex); - NodeAndVoxelColoring::colorIndicesWithLabelTableForObliqueVolume(labelTable, - &m_data[0], - m_data.size(), - tabDrawingInfo, - &m_rgba[0]); + NodeAndVoxelColoring::colorIndicesWithLabelTableForDisplayGroupTab(labelTable, + &m_data[0], + m_data.size(), + m_displayGroup, + m_browserTabIndex, + &m_rgba[0]); } break; case DataValueType::VOLUME_PALETTE: @@ -3244,46 +3207,29 @@ BrainOpenGLVolumeObliqueSliceDrawing::ObliqueSlice::assignRgba(const bool volume break; case DataValueType::VOLUME_RGB_WORKBENCH: { + const bool range255Flag(true); CaretAssert(m_data.size() == m_rgba.size()); - const int64_t numVoxels = static_cast(m_data.size() / 4); - std::vector red(numVoxels); - std::vector green(numVoxels); - std::vector blue(numVoxels); - std::vector alpha(numVoxels); - for (int64_t i = 0; i < numVoxels; i++) { - const int64_t i4(i * 4); - red[i] = m_data[i4]; - green[i] = m_data[i4+1]; - blue[i] = m_data[i4+2]; - alpha[i] = m_data[i4+3]; + const int32_t numVoxels = static_cast(m_data.size() / 4); + if (range255Flag) { + for (int32_t i = 0; i < numVoxels; i++) { + const int32_t i4 = i * 4; + m_rgba[i4] = static_cast(m_data[i4]); + m_rgba[i4+1] = static_cast(m_data[i4+1]); + m_rgba[i4+2] = static_cast(m_data[i4+2]); + m_rgba[i4+3] = static_cast(m_data[i4+3]); + } } - - uint8_t rgbThreshold[3] { 0, 0, 0}; - NodeAndVoxelColoring::colorScalarsWithRGBA(&red[0], - &green[0], - &blue[0], - &alpha[0], - numVoxels, - rgbThreshold, - &m_rgba[0]); - } - break; - } - - if (m_modulationVolumeFile != NULL) { - CaretAssert((m_modulationData.size() * 4) == m_rgba.size()); - const int64_t numData(m_modulationData.size()); - for (int64_t i = 0; i < numData; i++) { - float modValue(m_modulationData[i]); - if (modValue > 1.0) modValue = 1.0; - if (modValue < 0.0) modValue = 0.0; - - const int64_t i4(i * 4); - for (int64_t j = 0; j < 3; j++) { - const float v(static_cast(m_rgba[i4 + j]) * modValue); - m_rgba[i4 + j] = static_cast(v); + else { + for (int32_t i = 0; i < numVoxels; i++) { + const int32_t i4 = i * 4; + m_rgba[i4] = static_cast(m_data[i4] * 255.0); + m_rgba[i4+1] = static_cast(m_data[i4+1] * 255.0); + m_rgba[i4+2] = static_cast(m_data[i4+2] * 255.0); + m_rgba[i4+3] = static_cast(m_data[i4+3] * 255.0); + } } } + break; } } @@ -3623,52 +3569,43 @@ BrainOpenGLVolumeObliqueSliceDrawing::ObliqueSlice::loadData(const VolumeSliceIn break; } - /* - * IJK is needed by identification and volume modulation - */ - int64_t ijk[3] = { -1, -1, -1 }; - if (valueValidFlag) { - if (m_volumeFile != NULL) { - m_volumeFile->enclosingVoxel(voxelCenter, ijk); - if ( ! m_volumeFile->indexValid(ijk)) { - ijk[0] = -1; - ijk[1] = -1; - ijk[2] = -1; - valueValidFlag = false; - } - } - else if (m_ciftiMappableFile != NULL) { - int64_t i(-1), j(-1), k(-1); - m_ciftiMappableFile->enclosingVoxel(voxelCenter[0], voxelCenter[1], voxelCenter[2], - i, j, k); - if (m_ciftiMappableFile->indexValid(i, j, k)) { - ijk[0] = i; - ijk[1] = j; - ijk[2] = k; + if (m_identificationModeFlag) { + /* + * When identifying, need an IJK triplet + * for each voxel + */ + int64_t ijk[3] = { -1, -1, -1 }; + if (valueValidFlag) { + if (m_volumeFile != NULL) { + m_volumeFile->enclosingVoxel(voxelCenter, ijk); + if ( ! m_volumeFile->indexValid(ijk)) { + ijk[0] = -1; + ijk[1] = -1; + ijk[2] = -1; + valueValidFlag = false; + } } - else { - valueValidFlag = false; + else if (m_ciftiMappableFile != NULL) { + int64_t i(-1), j(-1), k(-1); + m_ciftiMappableFile->enclosingVoxel(voxelCenter[0], voxelCenter[1], voxelCenter[2], + i, j, k); + if (m_ciftiMappableFile->indexValid(i, j, k)) { + ijk[0] = i; + ijk[1] = j; + ijk[2] = k; + } + else { + valueValidFlag = false; + } } } - } - - if (m_identificationModeFlag) { m_identificationIJK.insert(m_identificationIJK.end(), ijk, ijk + 3); } if (valueValidFlag) { - if (m_modulationVolumeFile != NULL) { - m_modulationData.push_back(m_modulationVolumeFile->getValue(ijk[0], ijk[1], ijk[2], m_modulationMapIndex)); - } - m_validVoxelCount++; } - else { - if (m_modulationVolumeFile != NULL) { - m_modulationData.push_back(1.0); - } - } } } @@ -3676,10 +3613,6 @@ BrainOpenGLVolumeObliqueSliceDrawing::ObliqueSlice::loadData(const VolumeSliceIn if (m_thresholdMapIndex >= 0) { CaretAssert(m_data.size() == m_thresholdData.size()); } - if ( ! m_modulationData.empty()) { - CaretAssert((m_data.size() == m_modulationData.size()) - || (m_data.size() == (m_modulationData.size() * 4))); - } } /** diff --git a/src/Brain/BrainOpenGLVolumeObliqueSliceDrawing.h b/src/Brain/BrainOpenGLVolumeObliqueSliceDrawing.h index 1bf4b1dff..fc3091691 100644 --- a/src/Brain/BrainOpenGLVolumeObliqueSliceDrawing.h +++ b/src/Brain/BrainOpenGLVolumeObliqueSliceDrawing.h @@ -27,7 +27,6 @@ #include "BrainOpenGLVolumeSliceDrawing.h" #include "CaretObject.h" #include "DisplayGroupEnum.h" -#include "LabelViewModeEnum.h" #include "ModelTypeEnum.h" #include "Plane.h" #include "VolumeSliceInterpolationEdgeEffectsMaskingEnum.h" @@ -104,7 +103,6 @@ namespace caret { const int32_t browserTabIndex, const DisplayPropertiesLabels* displayPropertiesLabels, const DisplayGroupEnum::Enum displayGroup, - const LabelViewModeEnum::Enum labelViewMode, const float originXYZ[3], const float leftToRightStepXYZ[3], const float bottomToTopStepXYZ[3], @@ -151,8 +149,6 @@ namespace caret { const DisplayGroupEnum::Enum m_displayGroup; - const LabelViewModeEnum::Enum m_labelViewMode; - const int32_t m_identificationX; const int32_t m_identificationY; @@ -165,10 +161,6 @@ namespace caret { VolumeFile* m_volumeFile = NULL; - const VolumeFile* m_modulationVolumeFile = NULL; - - int32_t m_modulationMapIndex = -1; - uint8_t m_opacityByte = 255; CiftiMappableDataFile* m_thresholdCiftiMappableFile = NULL; @@ -193,8 +185,6 @@ namespace caret { std::vector m_rgba; - std::vector m_modulationData; - std::vector m_identificationIJK; int32_t m_validVoxelCount = 0; @@ -346,8 +336,6 @@ namespace caret { DisplayGroupEnum::Enum m_displayGroup; - LabelViewModeEnum::Enum m_labelViewMode; - int32_t m_tabIndex; double m_lookAtCenter[3]; diff --git a/src/Brain/BrainOpenGLVolumeSliceDrawing.cxx b/src/Brain/BrainOpenGLVolumeSliceDrawing.cxx index 550cea7d2..503106c00 100644 --- a/src/Brain/BrainOpenGLVolumeSliceDrawing.cxx +++ b/src/Brain/BrainOpenGLVolumeSliceDrawing.cxx @@ -72,7 +72,6 @@ #include "SessionManager.h" #include "SpacerTabIndex.h" #include "Surface.h" -#include "TabDrawingInfo.h" #include "VolumeFile.h" using namespace caret; @@ -1462,18 +1461,14 @@ BrainOpenGLVolumeSliceDrawing::drawOrthogonalSlice(const VolumeSliceViewPlaneEnu /* * Get colors for all voxels in the slice. */ - TabDrawingInfo tabDrawingInfo(volInfo.mapFile, - volInfo.mapIndex, - displayGroup, - displayPropertiesLabels->getLabelViewModeForTab(browserTabIndex), - browserTabIndex); const int64_t validVoxelCount = volumeFile->getVoxelColorsForSliceInMap(volInfo.mapIndex, firstVoxelIJK, rowStepIJK, columnStepIJK, drawBottomToTopInfo.numberOfVoxels, drawLeftToRightInfo.numberOfVoxels, - tabDrawingInfo, + displayGroup, + browserTabIndex, sliceVoxelsRGBA); /* @@ -1994,11 +1989,6 @@ BrainOpenGLVolumeSliceDrawing::drawOrthogonalSliceWithCulling(const VolumeSliceV numVoxelsZ };//only used to multiply them all together to get an element count for the presumed array size, so just provide them as XYZ - const TabDrawingInfo tabDrawingInfo(volInfo.mapFile, - volInfo.mapIndex, - displayGroup, - displayPropertiesLabels->getLabelViewModeForTab(browserTabIndex), - browserTabIndex); const int64_t validVoxelCount = volumeFile->getVoxelColorsForSubSliceInMap(mapIndex, sliceViewPlane, @@ -2006,7 +1996,8 @@ BrainOpenGLVolumeSliceDrawing::drawOrthogonalSliceWithCulling(const VolumeSliceV culledFirstVoxelIJK, culledLastVoxelIJK, voxelCountXYZ, - tabDrawingInfo, + displayGroup, + browserTabIndex, sliceVoxelsRGBA); /* @@ -4939,18 +4930,14 @@ BrainOpenGLVolumeSliceDrawing::drawOrthogonalSliceAllView(const VolumeSliceViewP << " rowstep IJK: " << AString::fromNumbers(rowStepIJK, 3, ",") << " colstep IJK: " << AString::fromNumbers(columnStepIJK, 3, ",") << std::endl; } - const TabDrawingInfo tabDrawingInfo(volInfo.mapFile, - volInfo.mapIndex, - displayGroup, - displayPropertiesLabels->getLabelViewModeForTab(browserTabIndex), - browserTabIndex); const int64_t validVoxelCount = volumeInterface->getVoxelColorsForSliceInMap(volInfo.mapIndex, firstVoxelIJK, rowStepIJK, columnStepIJK, drawBottomToTopInfo.numberOfVoxels, drawLeftToRightInfo.numberOfVoxels, - tabDrawingInfo, + displayGroup, + browserTabIndex, sliceVoxelsRGBA); /* diff --git a/src/Brain/BrowserTabContent.cxx b/src/Brain/BrowserTabContent.cxx index 1c8cc3dff..9ad4e3c17 100644 --- a/src/Brain/BrowserTabContent.cxx +++ b/src/Brain/BrowserTabContent.cxx @@ -110,7 +110,6 @@ #include "SurfaceMontageConfigurationCerebellar.h" #include "SurfaceMontageConfigurationCerebral.h" #include "SurfaceMontageConfigurationFlatMaps.h" -#include "SurfaceMontageConfigurationHippocampus.h" #include "SurfaceSelectionModel.h" #include "StructureEnum.h" #include "TileTabsBrowserTabGeometry.h" @@ -1893,11 +1892,24 @@ BrowserTabContent::receiveEvent(Event* event) Vector3D volumeSliceXYZ(idLocationEvent->getStereotaxicXYZ()); /* - * If montage viewing, do not alter the slice + * If othogonal/montage viewing, do not alter the slice * coordinate in the axis being viewed */ if (getDisplayedVolumeModel() != NULL) { bool keepSliceCoordinateForSelectedAxis = false; + switch (m_volumeSliceSettings->getSliceProjectionType()) { + case VolumeSliceProjectionTypeEnum::VOLUME_SLICE_PROJECTION_ORTHOGONAL: + if (getVolumeSliceViewPlane() != VolumeSliceViewPlaneEnum::ALL) { + keepSliceCoordinateForSelectedAxis = true; + } + break; + case VolumeSliceProjectionTypeEnum::VOLUME_SLICE_PROJECTION_OBLIQUE: + break; + case VolumeSliceProjectionTypeEnum::VOLUME_SLICE_PROJECTION_MPR: + break; + case VolumeSliceProjectionTypeEnum::VOLUME_SLICE_PROJECTION_MPR_THREE: + break; + } switch (m_volumeSliceSettings->getSliceDrawingType()) { case VolumeSliceDrawingTypeEnum::VOLUME_SLICE_DRAW_MONTAGE: keepSliceCoordinateForSelectedAxis = true; @@ -2665,27 +2677,6 @@ BrowserTabContent::getFilesDisplayedInTab(std::vector& displayed } } break; - case SurfaceMontageConfigurationTypeEnum::HIPPOCAMPUS_CONFIGURATION: - { - SurfaceMontageConfigurationHippocampus* smhc = msm->getHippocampusConfiguration(tabIndex); - if (smhc->isFirstSurfaceEnabled()) { - if (smhc->isLeftEnabled()) { - displayedDataFiles.insert(smhc->getLeftFirstSurfaceSelectionModel()->getSurface()); - } - if (smhc->isRightEnabled()) { - displayedDataFiles.insert(smhc->getRightFirstSurfaceSelectionModel()->getSurface()); - } - } - if (smhc->isSecondSurfaceEnabled()) { - if (smhc->isLeftEnabled()) { - displayedDataFiles.insert(smhc->getLeftSecondSurfaceSelectionModel()->getSurface()); - } - if (smhc->isRightEnabled()) { - displayedDataFiles.insert(smhc->getRightSecondSurfaceSelectionModel()->getSurface()); - } - } - } - break; } } break; @@ -6162,11 +6153,6 @@ BrowserTabContent::restoreFromScene(const SceneAttributes* sceneAttributes, m_sceneClassAssistant->restoreMembers(sceneAttributes, sceneClass); - /* - * Tab number may change when 'm_sceneClassAssistant->restoreMembers' restores the tab number - * so need to update the tab number in the scroll bar - */ - m_scaleBar->setTabIndex(m_tabNumber); /* * Need to recreate clipping plane group since tab is passed diff --git a/src/Brain/CMakeLists.txt b/src/Brain/CMakeLists.txt index 10fd8baca..cd29b8b8e 100644 --- a/src/Brain/CMakeLists.txt +++ b/src/Brain/CMakeLists.txt @@ -229,9 +229,8 @@ SurfaceDrawingTypeEnum.h SurfaceMontageConfigurationAbstract.h SurfaceMontageConfigurationCerebellar.h SurfaceMontageConfigurationCerebral.h -SurfaceMontageConfigurationFlatMaps.h -SurfaceMontageConfigurationHippocampus.h SurfaceMontageConfigurationTypeEnum.h +SurfaceMontageConfigurationFlatMaps.h SurfaceMontageLayoutOrientationEnum.h SurfaceMontageViewport.h SurfaceNodeColoring.h @@ -462,9 +461,8 @@ SurfaceDrawingTypeEnum.cxx SurfaceMontageConfigurationAbstract.cxx SurfaceMontageConfigurationCerebellar.cxx SurfaceMontageConfigurationCerebral.cxx -SurfaceMontageConfigurationFlatMaps.cxx -SurfaceMontageConfigurationHippocampus.cxx SurfaceMontageConfigurationTypeEnum.cxx +SurfaceMontageConfigurationFlatMaps.cxx SurfaceMontageLayoutOrientationEnum.cxx SurfaceMontageViewport.cxx SurfaceNodeColoring.cxx diff --git a/src/Brain/DisplayPropertiesLabels.cxx b/src/Brain/DisplayPropertiesLabels.cxx index cbbc55745..f08d61424 100644 --- a/src/Brain/DisplayPropertiesLabels.cxx +++ b/src/Brain/DisplayPropertiesLabels.cxx @@ -41,14 +41,12 @@ using namespace caret; DisplayPropertiesLabels::DisplayPropertiesLabels() : DisplayProperties() { - m_displayGroup.fill(DisplayGroupEnum::getDefaultValue()); - m_labelViewMode.fill(LabelViewModeEnum::LIST); - - m_sceneAssistant->addTabIndexedEnumeratedTypeArray("m_displayGroup", - m_displayGroup.data()); - m_sceneAssistant->addTabIndexedEnumeratedTypeArray("m_labelViewMode", - m_labelViewMode.data()); + for (int32_t i = 0; i < BrainConstants::MAXIMUM_NUMBER_OF_BROWSER_TABS; i++) { + m_displayGroup[i] = DisplayGroupEnum::getDefaultValue(); + } + m_sceneAssistant->addTabIndexedEnumeratedTypeArray("m_displayGroup", + m_displayGroup); } /** @@ -72,8 +70,6 @@ DisplayPropertiesLabels::copyDisplayProperties(const int32_t sourceTabIndex, { const DisplayGroupEnum::Enum displayGroup = this->getDisplayGroupForTab(sourceTabIndex); this->setDisplayGroupForTab(targetTabIndex, displayGroup); - this->setLabelViewModeForTab(targetTabIndex, - this->getLabelViewModeForTab(sourceTabIndex)); } /** @@ -83,8 +79,6 @@ DisplayPropertiesLabels::copyDisplayProperties(const int32_t sourceTabIndex, void DisplayPropertiesLabels::reset() { - m_displayGroup.fill(DisplayGroupEnum::getDefaultValue()); - m_labelViewMode.fill(LabelViewModeEnum::LIST); } /** @@ -127,33 +121,6 @@ DisplayPropertiesLabels::setDisplayGroupForTab(const int32_t browserTabIndex, m_displayGroup[browserTabIndex] = displayGroup; } -/** - * @return The label view mode for the given tab - * @param browserTabIndex - * Index of browser tab. - */ -LabelViewModeEnum::Enum -DisplayPropertiesLabels::getLabelViewModeForTab(const int32_t browserTabIndex) const -{ - CaretAssertVectorIndex(m_labelViewMode, browserTabIndex); - return m_labelViewMode[browserTabIndex]; -} - -/** - * Set the label view mode for the given tab - * @param browserTabIndex - * Index of browser tab. - * @param labelViewMode - * New label view mode - */ -void -DisplayPropertiesLabels::setLabelViewModeForTab(const int32_t browserTabIndex, - const LabelViewModeEnum::Enum labelViewMode) -{ - CaretAssertVectorIndex(m_labelViewMode, browserTabIndex); - m_labelViewMode[browserTabIndex] = labelViewMode; -} - /** * Create a scene for an instance of a class. * diff --git a/src/Brain/DisplayPropertiesLabels.h b/src/Brain/DisplayPropertiesLabels.h index 0b317e2e8..633f4e341 100644 --- a/src/Brain/DisplayPropertiesLabels.h +++ b/src/Brain/DisplayPropertiesLabels.h @@ -21,12 +21,10 @@ */ /*LICENSE_END*/ -#include #include "BrainConstants.h" #include "DisplayGroupEnum.h" #include "DisplayProperties.h" -#include "LabelViewModeEnum.h" namespace caret { @@ -55,11 +53,6 @@ namespace caret { void setDisplayGroupForTab(const int32_t browserTabIndex, const DisplayGroupEnum::Enum displayGroup); - LabelViewModeEnum::Enum getLabelViewModeForTab(const int32_t browserTabIndex) const; - - void setLabelViewModeForTab(const int32_t browserTabIndex, - const LabelViewModeEnum::Enum labelViewMode); - private: DisplayPropertiesLabels(const DisplayPropertiesLabels&); @@ -73,10 +66,8 @@ namespace caret { // ADD_NEW_MEMBERS_HERE - std::array m_displayGroup; + DisplayGroupEnum::Enum m_displayGroup[BrainConstants::MAXIMUM_NUMBER_OF_BROWSER_TABS]; - std::array m_labelViewMode; - }; #ifdef __DISPLAY_PROPERTIES_LABELS_DECLARE__ diff --git a/src/Brain/DisplayPropertiesSamples.cxx b/src/Brain/DisplayPropertiesSamples.cxx index be4a03c4e..2c3c26aaa 100644 --- a/src/Brain/DisplayPropertiesSamples.cxx +++ b/src/Brain/DisplayPropertiesSamples.cxx @@ -77,8 +77,10 @@ DisplayPropertiesSamples::~DisplayPropertiesSamples() * The new/updated sample. */ void -DisplayPropertiesSamples::updateForNewSample(const Annotation* /*sample*/) +DisplayPropertiesSamples::updateForNewSample(const Annotation* sample) { + CaretAssert(sample); + setDisplaySamples(true); } diff --git a/src/Brain/EventNodeIdentificationColorsGetFromCharts.h b/src/Brain/EventNodeIdentificationColorsGetFromCharts.h index 6934d01ee..326b8d04c 100644 --- a/src/Brain/EventNodeIdentificationColorsGetFromCharts.h +++ b/src/Brain/EventNodeIdentificationColorsGetFromCharts.h @@ -38,11 +38,11 @@ namespace caret { virtual ~EventNodeIdentificationColorsGetFromCharts(); void addNode(const int32_t nodeIndex, - const float rgba[3]); + const float rgba[4]); void applyChartColorToNode(const int32_t nodeIndex, - uint8_t rgb[3]); + uint8_t rgba[4]); AString getStructureName() const; diff --git a/src/Brain/ModelSurfaceMontage.cxx b/src/Brain/ModelSurfaceMontage.cxx index 618d9a622..570f648f3 100644 --- a/src/Brain/ModelSurfaceMontage.cxx +++ b/src/Brain/ModelSurfaceMontage.cxx @@ -40,7 +40,6 @@ #include "SurfaceMontageConfigurationCerebellar.h" #include "SurfaceMontageConfigurationCerebral.h" #include "SurfaceMontageConfigurationFlatMaps.h" -#include "SurfaceMontageConfigurationHippocampus.h" #include "SurfaceSelectionModel.h" using namespace caret; @@ -66,7 +65,6 @@ ModelSurfaceMontage::ModelSurfaceMontage(Brain* brain) m_cerebellarConfiguration[i] = new SurfaceMontageConfigurationCerebellar(i); m_cerebralConfiguration[i] = new SurfaceMontageConfigurationCerebral(i); m_flatMapsConfiguration[i] = new SurfaceMontageConfigurationFlatMaps(i); - m_hippocampusConfiguration[i] = new SurfaceMontageConfigurationHippocampus(i); } std::vector overlaySurfaceStructures; @@ -85,7 +83,6 @@ ModelSurfaceMontage::~ModelSurfaceMontage() delete m_cerebellarConfiguration[i]; delete m_cerebralConfiguration[i]; delete m_flatMapsConfiguration[i]; - delete m_hippocampusConfiguration[i]; } } @@ -110,7 +107,6 @@ ModelSurfaceMontage::initializeSelectedSurfaces() m_cerebellarConfiguration[i]->initializeSelectedSurfaces(); m_cerebralConfiguration[i]->initializeSelectedSurfaces(); m_flatMapsConfiguration[i]->initializeSelectedSurfaces(); - m_hippocampusConfiguration[i]->initializeSelectedSurfaces(); } } @@ -178,7 +174,6 @@ ModelSurfaceMontage::initializeOverlays() m_cerebellarConfiguration[i]->getOverlaySet()->initializeOverlays(); m_cerebralConfiguration[i]->getOverlaySet()->initializeOverlays(); m_flatMapsConfiguration[i]->getOverlaySet()->initializeOverlays(); - m_hippocampusConfiguration[i]->getOverlaySet()->initializeOverlays(); } } @@ -246,23 +241,6 @@ ModelSurfaceMontage::getSelectedSurface(const StructureEnum::Enum structure, } } break; - case SurfaceMontageConfigurationTypeEnum::HIPPOCAMPUS_CONFIGURATION: - { - SurfaceMontageConfigurationHippocampus* smcc = getHippocampusConfiguration(windowTabNumber); - switch (structure) { - case StructureEnum::CORTEX_LEFT: - selectionModels.push_back(smcc->getLeftFirstSurfaceSelectionModel()); - selectionModels.push_back(smcc->getLeftSecondSurfaceSelectionModel()); - break; - case StructureEnum::CORTEX_RIGHT: - selectionModels.push_back(smcc->getRightFirstSurfaceSelectionModel()); - selectionModels.push_back(smcc->getRightSecondSurfaceSelectionModel()); - break; - default: - break; - } - } - break; } Surface* surfaceOut = NULL; @@ -308,12 +286,6 @@ ModelSurfaceMontage::getSelectedConfiguration(const int32_t tabIndex) tabIndex); return m_flatMapsConfiguration[tabIndex]; break; - case SurfaceMontageConfigurationTypeEnum::HIPPOCAMPUS_CONFIGURATION: - CaretAssertArrayIndex(m_hippocampusConfiguration, - BrainConstants::MAXIMUM_NUMBER_OF_BROWSER_TABS, - tabIndex); - return m_hippocampusConfiguration[tabIndex]; - break; } return NULL; @@ -355,9 +327,6 @@ ModelSurfaceMontage::getSelectedConfigurationType(const int32_t tabIndex) const if (m_flatMapsConfiguration[tabIndex]->isValid()) { validTypes.push_back(SurfaceMontageConfigurationTypeEnum::FLAT_CONFIGURATION); } - if (m_hippocampusConfiguration[tabIndex]->isValid()) { - validTypes.push_back(SurfaceMontageConfigurationTypeEnum::HIPPOCAMPUS_CONFIGURATION); - } /* * Verify selected type is valid @@ -388,14 +357,6 @@ ModelSurfaceMontage::getSelectedConfigurationType(const int32_t tabIndex) const validTypeSelected = true; } break; - case SurfaceMontageConfigurationTypeEnum::HIPPOCAMPUS_CONFIGURATION: - CaretAssertArrayIndex(m_hippocampusConfiguration, - BrainConstants::MAXIMUM_NUMBER_OF_BROWSER_TABS, - tabIndex); - if (m_hippocampusConfiguration[tabIndex]->isValid()) { - validTypeSelected = true; - } - break; } /* @@ -528,39 +489,6 @@ ModelSurfaceMontage::getFlatMapsConfiguration(const int32_t tabIndex) const return m_flatMapsConfiguration[tabIndex]; } -/** - * Get the hippocampus configuration in the given tab. - * - * @param tabIndex - * Index of tab. - * @return - * hippocampus configuration. - */ -SurfaceMontageConfigurationHippocampus* -ModelSurfaceMontage::getHippocampusConfiguration(const int32_t tabIndex) -{ - CaretAssertArrayIndex(m_hippocampusConfiguration, - BrainConstants::MAXIMUM_NUMBER_OF_BROWSER_TABS, - tabIndex); - return m_hippocampusConfiguration[tabIndex]; -} - -/** - * Get the hippocampus configuration in the given tab. - * - * @param tabIndex - * Index of tab. - * @return - * hippocampus configuration. - */ -const SurfaceMontageConfigurationHippocampus* -ModelSurfaceMontage::getHippocampusConfiguration(const int32_t tabIndex) const -{ - CaretAssertArrayIndex(m_hippocampusConfiguration, - BrainConstants::MAXIMUM_NUMBER_OF_BROWSER_TABS, - tabIndex); - return m_hippocampusConfiguration[tabIndex]; -} /** * Save information specific to this type of model to the scene. @@ -585,9 +513,7 @@ ModelSurfaceMontage::saveModelSpecificInformationToScene(const SceneAttributes* SceneObjectDataTypeEnum::SCENE_CLASS); SceneObjectMapIntegerKey* flatConfigurationMap = new SceneObjectMapIntegerKey("m_flatMapsConfiguration", SceneObjectDataTypeEnum::SCENE_CLASS); - SceneObjectMapIntegerKey* hippoConfigurationMap = new SceneObjectMapIntegerKey("m_hippocampusConfiguration", - SceneObjectDataTypeEnum::SCENE_CLASS); - + /* * Get indices of tabs that are to be saved to scene. @@ -613,15 +539,11 @@ ModelSurfaceMontage::saveModelSpecificInformationToScene(const SceneAttributes* flatConfigurationMap->addClass(tabIndex, m_flatMapsConfiguration[tabIndex]->saveToScene(sceneAttributes, "m_flatMapsConfiguration" + tabString)); - hippoConfigurationMap->addClass(tabIndex, - m_hippocampusConfiguration[tabIndex]->saveToScene(sceneAttributes, - "m_hippocampusConfiguration" + tabString)); } sceneClass->addChild(cerebellarConfigurationMap); sceneClass->addChild(cerebralConfigurationMap); sceneClass->addChild(flatConfigurationMap); - sceneClass->addChild(hippoConfigurationMap); // /* @@ -726,7 +648,7 @@ ModelSurfaceMontage::restoreModelSpecificInformationFromScene(const SceneAttribu } /* - * Restore Cortex + * Restore Cortext */ const SceneObjectMapIntegerKey* cerebralMap = sceneClass->getMapIntegerKey("m_cerebralConfiguration"); if (cerebellumMap != NULL) { @@ -768,27 +690,6 @@ ModelSurfaceMontage::restoreModelSpecificInformationFromScene(const SceneAttribu } } - /* - * Restore Hippocampus - */ - const SceneObjectMapIntegerKey* hippoMap = sceneClass->getMapIntegerKey("m_hippocampusConfiguration"); - if (hippoMap != NULL) { - const std::map& structureMap = hippoMap->getMap(); - for (std::map::const_iterator iter = structureMap.begin(); - iter != structureMap.end(); - iter++) { - const int32_t key = iter->first; - const SceneClass* hippoSceneClass = dynamic_cast(iter->second); - hippoSceneClass->setRestored(true);// prevents "failed to restore" - CaretAssertArrayIndex(m_hippocampusConfiguration, - BrainConstants::MAXIMUM_NUMBER_OF_BROWSER_TABS, - key); - - m_hippocampusConfiguration[key]->restoreFromScene(sceneAttributes, - hippoSceneClass); - } - } - sceneClass->getEnumerateTypeArrayForTabIndices("m_selectedConfigurationType", m_selectedConfigurationType); } @@ -1151,7 +1052,6 @@ ModelSurfaceMontage::copyTabContent(const int32_t sourceTabIndex, m_cerebellarConfiguration[destinationTabIndex]->copyConfiguration(m_cerebellarConfiguration[sourceTabIndex]); m_cerebralConfiguration[destinationTabIndex]->copyConfiguration(m_cerebralConfiguration[sourceTabIndex]); m_flatMapsConfiguration[destinationTabIndex]->copyConfiguration(m_flatMapsConfiguration[sourceTabIndex]); - m_hippocampusConfiguration[destinationTabIndex]->copyConfiguration(m_hippocampusConfiguration[sourceTabIndex]); m_selectedConfigurationType[destinationTabIndex] = m_selectedConfigurationType[sourceTabIndex]; } diff --git a/src/Brain/ModelSurfaceMontage.h b/src/Brain/ModelSurfaceMontage.h index ab76f27ef..23c35769b 100644 --- a/src/Brain/ModelSurfaceMontage.h +++ b/src/Brain/ModelSurfaceMontage.h @@ -34,7 +34,6 @@ namespace caret { class SurfaceMontageConfigurationCerebellar; class SurfaceMontageConfigurationCerebral; class SurfaceMontageConfigurationFlatMaps; - class SurfaceMontageConfigurationHippocampus; /// Controls the display of a surface montage class ModelSurfaceMontage : public Model, public EventListenerInterface { @@ -92,10 +91,6 @@ namespace caret { const SurfaceMontageConfigurationFlatMaps* getFlatMapsConfiguration(const int32_t tabIndex) const; - SurfaceMontageConfigurationHippocampus* getHippocampusConfiguration(const int32_t tabIndex); - - const SurfaceMontageConfigurationHippocampus* getHippocampusConfiguration(const int32_t tabIndex) const; - virtual AString toString() const; virtual void getDescriptionOfContent(const int32_t tabIndex, @@ -125,8 +120,6 @@ namespace caret { SurfaceMontageConfigurationFlatMaps* m_flatMapsConfiguration[BrainConstants::MAXIMUM_NUMBER_OF_BROWSER_TABS]; - SurfaceMontageConfigurationHippocampus* m_hippocampusConfiguration[BrainConstants::MAXIMUM_NUMBER_OF_BROWSER_TABS]; - mutable SurfaceMontageConfigurationTypeEnum::Enum m_selectedConfigurationType[BrainConstants::MAXIMUM_NUMBER_OF_BROWSER_TABS]; }; diff --git a/src/Brain/ModelSurfaceSelector.cxx b/src/Brain/ModelSurfaceSelector.cxx index 134713c37..43db5ec3a 100644 --- a/src/Brain/ModelSurfaceSelector.cxx +++ b/src/Brain/ModelSurfaceSelector.cxx @@ -173,13 +173,10 @@ ModelSurfaceSelector::updateSelector() bool haveCortexLeft = false; bool haveCortexRight = false; bool haveCerebellum = false; - bool haveHippcampusLeft = false; - bool haveHippocampusRight = false; /* * Find the ALL surface models and structures */ - std::set otherStructures; for (std::vector::const_iterator iter = m_allSurfaceModels.begin(); iter != m_allSurfaceModels.end(); iter++) { @@ -197,14 +194,7 @@ ModelSurfaceSelector::updateSelector() case StructureEnum::CORTEX_RIGHT: haveCortexRight = true; break; - case StructureEnum::HIPPOCAMPUS_LEFT: - haveHippcampusLeft = true; - break; - case StructureEnum::HIPPOCAMPUS_RIGHT: - haveHippocampusRight = true; - break; default: - otherStructures.insert(structure); break; } } @@ -214,25 +204,15 @@ ModelSurfaceSelector::updateSelector() */ m_availableStructures.clear(); m_availableStructures.push_back(StructureEnum::ALL); + if (haveCerebellum) { + m_availableStructures.push_back(StructureEnum::CEREBELLUM); + } if (haveCortexLeft) { m_availableStructures.push_back(StructureEnum::CORTEX_LEFT); } if (haveCortexRight) { m_availableStructures.push_back(StructureEnum::CORTEX_RIGHT); } - if (haveCerebellum) { - m_availableStructures.push_back(StructureEnum::CEREBELLUM); - } - if (haveHippcampusLeft) { - m_availableStructures.push_back(StructureEnum::HIPPOCAMPUS_LEFT); - } - if (haveHippocampusRight) { - m_availableStructures.push_back(StructureEnum::HIPPOCAMPUS_RIGHT); - } - - m_availableStructures.insert(m_availableStructures.end(), - otherStructures.begin(), - otherStructures.end()); /* * Update the structure selection. diff --git a/src/Brain/SurfaceMontageConfigurationHippocampus.cxx b/src/Brain/SurfaceMontageConfigurationHippocampus.cxx deleted file mode 100644 index b6c9280c7..000000000 --- a/src/Brain/SurfaceMontageConfigurationHippocampus.cxx +++ /dev/null @@ -1,856 +0,0 @@ - -/*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 __SURFACE_MONTAGE_CONFIGURATION_HIPPOCAMPUS_DECLARE__ -#include "SurfaceMontageConfigurationHippocampus.h" -#undef __SURFACE_MONTAGE_CONFIGURATION_HIPPOCAMPUS_DECLARE__ - -#include "BrainStructure.h" -#include "CaretAssert.h" -#include "EventBrainStructureGetAll.h" -#include "EventManager.h" -#include "PlainTextStringBuilder.h" -#include "SceneClass.h" -#include "SceneClassAssistant.h" -#include "Surface.h" -#include "SurfaceSelectionModel.h" - -using namespace caret; - - - -/** - * \class caret::SurfaceMontageConfigurationHippocampus - * \brief Surface montage cerebral cortext configuration. - * \ingroup Brain - */ - -/** - * Constructor. - */ -SurfaceMontageConfigurationHippocampus::SurfaceMontageConfigurationHippocampus(const int32_t tabIndex) -: SurfaceMontageConfigurationAbstract(SurfaceMontageConfigurationTypeEnum::HIPPOCAMPUS_CONFIGURATION, - SUPPORTS_LAYOUT_ORIENTATION_YES) -{ - std::vector validSurfaceTypes; - SurfaceTypeEnum::getAllEnumsExceptFlat(validSurfaceTypes); - - m_leftFirstSurfaceSelectionModel = new SurfaceSelectionModel(StructureEnum::HIPPOCAMPUS_LEFT, - validSurfaceTypes); - m_leftSecondSurfaceSelectionModel = new SurfaceSelectionModel(StructureEnum::HIPPOCAMPUS_LEFT, - validSurfaceTypes); - m_rightFirstSurfaceSelectionModel = new SurfaceSelectionModel(StructureEnum::HIPPOCAMPUS_RIGHT, - validSurfaceTypes); - m_rightSecondSurfaceSelectionModel = new SurfaceSelectionModel(StructureEnum::HIPPOCAMPUS_RIGHT, - validSurfaceTypes); - m_leftEnabled = true; - m_rightEnabled = true; - m_firstSurfaceEnabled = true; - m_secondSurfaceEnabled = false; - m_lateralEnabled = true; - m_medialEnabled = true; - - m_sceneAssistant = new SceneClassAssistant(); - - m_sceneAssistant->add("m_leftFirstSurfaceSelectionModel", - "SurfaceSelectionModel", - m_leftFirstSurfaceSelectionModel); - m_sceneAssistant->add("m_leftSecondSurfaceSelectionModel", - "SurfaceSelectionModel", - m_leftSecondSurfaceSelectionModel); - m_sceneAssistant->add("m_rightFirstSurfaceSelectionModel", - "SurfaceSelectionModel", - m_rightFirstSurfaceSelectionModel); - m_sceneAssistant->add("m_rightSecondSurfaceSelectionModel", - "SurfaceSelectionModel", - m_rightSecondSurfaceSelectionModel); - - m_sceneAssistant->add("m_leftEnabled", - &m_leftEnabled); - m_sceneAssistant->add("m_rightEnabled", - &m_rightEnabled); - m_sceneAssistant->add("m_firstSurfaceEnabled", - &m_firstSurfaceEnabled); - m_sceneAssistant->add("m_secondSurfaceEnabled", - &m_secondSurfaceEnabled); - m_sceneAssistant->add("m_lateralEnabled", - &m_lateralEnabled); - m_sceneAssistant->add("m_medialEnabled", - &m_medialEnabled); - - std::vector supportedStructures; - supportedStructures.push_back(StructureEnum::HIPPOCAMPUS_LEFT); - supportedStructures.push_back(StructureEnum::HIPPOCAMPUS_RIGHT); - setupOverlaySet("Cerebral Montage", - tabIndex, - supportedStructures); -} - -/** - * Destructor. - */ -SurfaceMontageConfigurationHippocampus::~SurfaceMontageConfigurationHippocampus() -{ - delete m_leftFirstSurfaceSelectionModel; - delete m_leftSecondSurfaceSelectionModel; - delete m_rightFirstSurfaceSelectionModel; - delete m_rightSecondSurfaceSelectionModel; - - delete m_sceneAssistant; -} - -/** - * Initialize the selected surfaces. - */ -void -SurfaceMontageConfigurationHippocampus::initializeSelectedSurfaces() -{ - EventBrainStructureGetAll brainStructureEvent; - EventManager::get()->sendEvent(brainStructureEvent.getPointer()); - - Surface* leftAnatSurface = NULL; - BrainStructure* leftBrainStructure = brainStructureEvent.getBrainStructureByStructure(StructureEnum::CORTEX_LEFT); - if (leftBrainStructure != NULL) { - leftAnatSurface = leftBrainStructure->getPrimaryAnatomicalSurface(); - } - - Surface* rightAnatSurface = NULL; - BrainStructure* rightBrainStructure = brainStructureEvent.getBrainStructureByStructure(StructureEnum::CORTEX_RIGHT); - if (rightBrainStructure != NULL) { - rightAnatSurface = rightBrainStructure->getPrimaryAnatomicalSurface(); - } - - m_leftFirstSurfaceSelectionModel->setSurfaceToType(SurfaceTypeEnum::ANATOMICAL); - if (leftAnatSurface != NULL) { - m_leftFirstSurfaceSelectionModel->setSurface(leftAnatSurface); - } - - - m_leftSecondSurfaceSelectionModel->setSurfaceToType(SurfaceTypeEnum::INFLATED, - SurfaceTypeEnum::VERY_INFLATED); - - m_rightFirstSurfaceSelectionModel->setSurfaceToType(SurfaceTypeEnum::ANATOMICAL); - if (rightAnatSurface != NULL) { - m_rightFirstSurfaceSelectionModel->setSurface(rightAnatSurface); - } - - m_rightSecondSurfaceSelectionModel->setSurfaceToType(SurfaceTypeEnum::INFLATED, - SurfaceTypeEnum::VERY_INFLATED); -} - -/** - * @return Is this configuration valid? - */ -bool -SurfaceMontageConfigurationHippocampus::isValid() -{ - const bool valid = ((getLeftFirstSurfaceSelectionModel()->getSurface() != NULL) - || (getRightFirstSurfaceSelectionModel()->getSurface() != NULL)); - return valid; -} - -/** - * Update the montage viewports using the current selected surfaces and settings. - * - * @param surfaceMontageViewports - * Will be loaded with the montage viewports. - */ -void -SurfaceMontageConfigurationHippocampus::updateSurfaceMontageViewports(std::vector& surfaceMontageViewports) -{ - surfaceMontageViewports.clear(); - - std::vector leftLateralViewports; - std::vector leftMedialViewports; - std::vector rightLateralViewports; - std::vector rightMedialViewports; - - if (m_leftEnabled) { - if (m_firstSurfaceEnabled) { - Surface* leftSurface = m_leftFirstSurfaceSelectionModel->getSurface(); - if (leftSurface != NULL) { - if (m_lateralEnabled) { - SurfaceMontageViewport smv(leftSurface, - ProjectionViewTypeEnum::PROJECTION_VIEW_LEFT_LATERAL); - leftLateralViewports.push_back(smv); - } - if (m_medialEnabled) { - SurfaceMontageViewport smv(leftSurface, - ProjectionViewTypeEnum::PROJECTION_VIEW_LEFT_MEDIAL); - leftMedialViewports.push_back(smv); - } - } - } - if (m_secondSurfaceEnabled) { - Surface* leftSurface = m_leftSecondSurfaceSelectionModel->getSurface(); - if (leftSurface != NULL) { - if (m_lateralEnabled) { - SurfaceMontageViewport smv(leftSurface, - ProjectionViewTypeEnum::PROJECTION_VIEW_LEFT_LATERAL); - leftLateralViewports.push_back(smv); - } - if (m_medialEnabled) { - SurfaceMontageViewport smv(leftSurface, - ProjectionViewTypeEnum::PROJECTION_VIEW_LEFT_MEDIAL); - leftMedialViewports.push_back(smv); - } - } - } - } - - if (m_rightEnabled) { - if (m_firstSurfaceEnabled) { - Surface* rightSurface = m_rightFirstSurfaceSelectionModel->getSurface(); - if (rightSurface != NULL) { - if (m_lateralEnabled) { - SurfaceMontageViewport smv(rightSurface, - ProjectionViewTypeEnum::PROJECTION_VIEW_RIGHT_LATERAL); - rightLateralViewports.push_back(smv); - } - if (m_medialEnabled) { - SurfaceMontageViewport smv(rightSurface, - ProjectionViewTypeEnum::PROJECTION_VIEW_RIGHT_MEDIAL); - rightMedialViewports.push_back(smv); - } - } - } - } - if (m_rightEnabled) { - if (m_secondSurfaceEnabled) { - Surface* rightSurface = m_rightSecondSurfaceSelectionModel->getSurface(); - if (rightSurface != NULL) { - if (m_lateralEnabled) { - SurfaceMontageViewport smv(rightSurface, - ProjectionViewTypeEnum::PROJECTION_VIEW_RIGHT_LATERAL); - rightLateralViewports.push_back(smv); - } - if (m_medialEnabled) { - SurfaceMontageViewport smv(rightSurface, - ProjectionViewTypeEnum::PROJECTION_VIEW_RIGHT_MEDIAL); - rightMedialViewports.push_back(smv); - } - } - } - } - - std::vector leftViewports; - leftViewports.insert(leftViewports.end(), - leftLateralViewports.begin(), - leftLateralViewports.end()); - leftViewports.insert(leftViewports.end(), - leftMedialViewports.begin(), - leftMedialViewports.end()); - - std::vector rightViewports; - rightViewports.insert(rightViewports.end(), - rightLateralViewports.begin(), - rightLateralViewports.end()); - rightViewports.insert(rightViewports.end(), - rightMedialViewports.begin(), - rightMedialViewports.end()); - - const int32_t numLeft = static_cast(leftViewports.size()); - const int32_t numRight = static_cast(rightViewports.size()); - const int32_t totalNum = numLeft + numRight; - - if (totalNum == 1) { - surfaceMontageViewports.insert(surfaceMontageViewports.end(), - leftViewports.begin(), - leftViewports.end()); - surfaceMontageViewports.insert(surfaceMontageViewports.end(), - rightViewports.begin(), - rightViewports.end()); - CaretAssert(surfaceMontageViewports.size() == 1); - - surfaceMontageViewports[0].setRowAndColumn(0, 0); - - } - else if (totalNum == 2) { - surfaceMontageViewports.insert(surfaceMontageViewports.end(), - leftViewports.begin(), - leftViewports.end()); - surfaceMontageViewports.insert(surfaceMontageViewports.end(), - rightViewports.begin(), - rightViewports.end()); - - CaretAssert(surfaceMontageViewports.size() == 2); - - switch (getLayoutOrientation()) { - case SurfaceMontageLayoutOrientationEnum::COLUMN_LAYOUT_ORIENTATION: - surfaceMontageViewports[0].setRowAndColumn(0, 0); - surfaceMontageViewports[1].setRowAndColumn(1, 0); - break; - case SurfaceMontageLayoutOrientationEnum::LANDSCAPE_LAYOUT_ORIENTATION: - surfaceMontageViewports[0].setRowAndColumn(0, 0); - surfaceMontageViewports[1].setRowAndColumn(0, 1); - break; - case SurfaceMontageLayoutOrientationEnum::PORTRAIT_LAYOUT_ORIENTATION: - surfaceMontageViewports[0].setRowAndColumn(0, 0); - surfaceMontageViewports[1].setRowAndColumn(1, 0); - break; - case SurfaceMontageLayoutOrientationEnum::ROW_LAYOUT_ORIENTATION: - surfaceMontageViewports[0].setRowAndColumn(0, 0); - surfaceMontageViewports[1].setRowAndColumn(0, 1); - break; - } - - } - else if (totalNum == 4) { - if (numLeft == 4) { - surfaceMontageViewports.insert(surfaceMontageViewports.end(), - leftLateralViewports.begin(), - leftLateralViewports.end()); - surfaceMontageViewports.insert(surfaceMontageViewports.end(), - leftMedialViewports.begin(), - leftMedialViewports.end()); - CaretAssert(surfaceMontageViewports.size() == 4); - surfaceMontageViewports[0].setRowAndColumn(0, 0); - surfaceMontageViewports[1].setRowAndColumn(1, 0); - surfaceMontageViewports[2].setRowAndColumn(0, 1); - surfaceMontageViewports[3].setRowAndColumn(1, 1); - } - else if (numRight == 4) { - surfaceMontageViewports.insert(surfaceMontageViewports.end(), - rightLateralViewports.begin(), - rightLateralViewports.end()); - surfaceMontageViewports.insert(surfaceMontageViewports.end(), - rightMedialViewports.begin(), - rightMedialViewports.end()); - CaretAssert(surfaceMontageViewports.size() == 4); - surfaceMontageViewports[0].setRowAndColumn(0, 0); - surfaceMontageViewports[1].setRowAndColumn(1, 0); - surfaceMontageViewports[2].setRowAndColumn(0, 1); - surfaceMontageViewports[3].setRowAndColumn(1, 1); - } - else if (numLeft == numRight) { - surfaceMontageViewports.insert(surfaceMontageViewports.end(), - leftViewports.begin(), - leftViewports.end()); - surfaceMontageViewports.insert(surfaceMontageViewports.end(), - rightViewports.begin(), - rightViewports.end()); - CaretAssert(surfaceMontageViewports.size() == 4); - - surfaceMontageViewports[0].setRowAndColumn(0, 0); - surfaceMontageViewports[1].setRowAndColumn(1, 0); - surfaceMontageViewports[2].setRowAndColumn(0, 1); - surfaceMontageViewports[3].setRowAndColumn(1, 1); - } - else { - CaretAssert(0); - } - - /* - * Override layout for row/column layout - */ - switch (getLayoutOrientation()) { - case SurfaceMontageLayoutOrientationEnum::COLUMN_LAYOUT_ORIENTATION: - for (int32_t i = 0; i < 4; i++) { - surfaceMontageViewports[i].setRowAndColumn(i, 0); - } - break; - case SurfaceMontageLayoutOrientationEnum::LANDSCAPE_LAYOUT_ORIENTATION: - break; - case SurfaceMontageLayoutOrientationEnum::PORTRAIT_LAYOUT_ORIENTATION: - break; - case SurfaceMontageLayoutOrientationEnum::ROW_LAYOUT_ORIENTATION: - for (int32_t i = 0; i < 4; i++) { - surfaceMontageViewports[i].setRowAndColumn(0, i); - } - break; - } - } - else if (totalNum == 8) { - surfaceMontageViewports.insert(surfaceMontageViewports.end(), - leftLateralViewports.begin(), - leftLateralViewports.end()); - surfaceMontageViewports.insert(surfaceMontageViewports.end(), - leftMedialViewports.begin(), - leftMedialViewports.end()); - surfaceMontageViewports.insert(surfaceMontageViewports.end(), - rightLateralViewports.begin(), - rightLateralViewports.end()); - surfaceMontageViewports.insert(surfaceMontageViewports.end(), - rightMedialViewports.begin(), - rightMedialViewports.end()); - CaretAssert(surfaceMontageViewports.size() == 8); - - switch (getLayoutOrientation()) { - case SurfaceMontageLayoutOrientationEnum::COLUMN_LAYOUT_ORIENTATION: - surfaceMontageViewports[0].setRowAndColumn(0, 0); - surfaceMontageViewports[2].setRowAndColumn(1, 0); - surfaceMontageViewports[1].setRowAndColumn(2, 0); - surfaceMontageViewports[3].setRowAndColumn(3, 0); - surfaceMontageViewports[4].setRowAndColumn(4, 0); - surfaceMontageViewports[6].setRowAndColumn(5, 0); - surfaceMontageViewports[5].setRowAndColumn(6, 0); - surfaceMontageViewports[7].setRowAndColumn(7, 0); - break; - case SurfaceMontageLayoutOrientationEnum::LANDSCAPE_LAYOUT_ORIENTATION: - surfaceMontageViewports[0].setRowAndColumn(0, 0); - surfaceMontageViewports[1].setRowAndColumn(1, 0); - surfaceMontageViewports[2].setRowAndColumn(0, 1); - surfaceMontageViewports[3].setRowAndColumn(1, 1); - surfaceMontageViewports[4].setRowAndColumn(0, 2); - surfaceMontageViewports[5].setRowAndColumn(1, 2); - surfaceMontageViewports[6].setRowAndColumn(0, 3); - surfaceMontageViewports[7].setRowAndColumn(1, 3); - break; - case SurfaceMontageLayoutOrientationEnum::PORTRAIT_LAYOUT_ORIENTATION: - surfaceMontageViewports[0].setRowAndColumn(0, 0); - surfaceMontageViewports[1].setRowAndColumn(1, 0); - surfaceMontageViewports[2].setRowAndColumn(0, 1); - surfaceMontageViewports[3].setRowAndColumn(1, 1); - surfaceMontageViewports[4].setRowAndColumn(2, 0); - surfaceMontageViewports[5].setRowAndColumn(3, 0); - surfaceMontageViewports[6].setRowAndColumn(2, 1); - surfaceMontageViewports[7].setRowAndColumn(3, 1); - break; - case SurfaceMontageLayoutOrientationEnum::ROW_LAYOUT_ORIENTATION: - surfaceMontageViewports[0].setRowAndColumn(0, 0); - surfaceMontageViewports[2].setRowAndColumn(0, 1); - surfaceMontageViewports[1].setRowAndColumn(0, 2); - surfaceMontageViewports[3].setRowAndColumn(0, 3); - surfaceMontageViewports[4].setRowAndColumn(0, 4); - surfaceMontageViewports[6].setRowAndColumn(0, 5); - surfaceMontageViewports[5].setRowAndColumn(0, 6); - surfaceMontageViewports[7].setRowAndColumn(0, 7); - break; - } - } - else if (totalNum > 0) { - CaretAssert(0); - } - - CaretAssert(totalNum == static_cast(surfaceMontageViewports.size())); - -// std::cout << "Orientation: " << SurfaceMontageLayoutOrientationEnum::toName(getLayoutOrientation()) << std::endl; -// for (int32_t i = 0; i < numViewports; i++) { -// const SurfaceMontageViewport& svp = surfaceMontageViewports[i]; -// std::cout << qPrintable("(" -// + AString::number(svp.getRow()) -// + "," -// + AString::number(svp.getColumn()) -// + ") " -// + ProjectionViewTypeEnum::toName(svp.getProjectionViewType())) -// << std::endl; -// } -// std::cout << std::endl; -} - -/** - * Save members to the given scene class. - * - * @param sceneAttributes - * Attributes for the scene. Scenes may be of different types - * (full, generic, etc) and the attributes should be checked when - * saving the scene. - * @param sceneClass - * sceneClass to which information is added. - */ -void -SurfaceMontageConfigurationHippocampus::saveMembersToScene(const SceneAttributes* sceneAttributes, - SceneClass* sceneClass) -{ - m_sceneAssistant->saveMembers(sceneAttributes, - sceneClass); -} - -/** - * Restore information specific to the type of model from the scene. - * - * @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 from which information is restored. - */ -void -SurfaceMontageConfigurationHippocampus::restoreMembersFromScene(const SceneAttributes* sceneAttributes, - const SceneClass* sceneClass) -{ - m_sceneAssistant->restoreMembers(sceneAttributes, - sceneClass); -} - -/** - * @return Is left enabled? - */ -bool -SurfaceMontageConfigurationHippocampus::isLeftEnabled() const -{ - return m_leftEnabled; -} - -/** - * Set left enabled - * @param enabled - * New status - */ -void -SurfaceMontageConfigurationHippocampus::setLeftEnabled(const bool enabled) -{ - m_leftEnabled = enabled; -} - -/** - * @return Is right enabled? - */ -bool -SurfaceMontageConfigurationHippocampus::isRightEnabled() const -{ - return m_rightEnabled; -} - -/** - * Set right enabled - * @param enabled - * New status - */ -void -SurfaceMontageConfigurationHippocampus::setRightEnabled(const bool enabled) -{ - m_rightEnabled = enabled; -} - -/** - * @return Is lateral enabled? - */ -bool -SurfaceMontageConfigurationHippocampus::isLateralEnabled() const -{ - return m_lateralEnabled; -} - -/** - * Set lateral enabled - * @param enabled - * New status - */ -void -SurfaceMontageConfigurationHippocampus::setLateralEnabled(const bool enabled) -{ - m_lateralEnabled = enabled; -} - -/** - * @return Is medial enabled? - */ -bool -SurfaceMontageConfigurationHippocampus::isMedialEnabled() const -{ - return m_medialEnabled; -} - -/** - * Set medial enabled - * @param enabled - * New status - */ -void -SurfaceMontageConfigurationHippocampus::setMedialEnabled(const bool enabled) -{ - m_medialEnabled = enabled; -} - -/** - * @return Is enabled? - */ -bool -SurfaceMontageConfigurationHippocampus::isFirstSurfaceEnabled() const -{ - return m_firstSurfaceEnabled; -} - -/** - * Set first surface enabled - * @param enabled - * New status - */ -void -SurfaceMontageConfigurationHippocampus::setFirstSurfaceEnabled(const bool enabled) -{ - m_firstSurfaceEnabled = enabled; -} - -/** - * @return Is first surfce enabled? - */ -bool -SurfaceMontageConfigurationHippocampus::isSecondSurfaceEnabled() const -{ - return m_secondSurfaceEnabled; -} - -/** - * Set second surface enabled - * @param enabled - * New status - */ -void -SurfaceMontageConfigurationHippocampus::setSecondSurfaceEnabled(const bool enabled) -{ - m_secondSurfaceEnabled = enabled; -} - -/** - * @return the left first surface selection in this configuration. - */ -SurfaceSelectionModel* -SurfaceMontageConfigurationHippocampus::getLeftFirstSurfaceSelectionModel() -{ - return m_leftFirstSurfaceSelectionModel; -} - -/** - * @return the left first surface selection in this configuration. - */ -const SurfaceSelectionModel* -SurfaceMontageConfigurationHippocampus::getLeftFirstSurfaceSelectionModel() const -{ - return m_leftFirstSurfaceSelectionModel; -} - -/** - * @return the left second surface selection in this configuration. - */ -SurfaceSelectionModel* -SurfaceMontageConfigurationHippocampus::getLeftSecondSurfaceSelectionModel() -{ - return m_leftSecondSurfaceSelectionModel; -} - -/** - * @return the left second surface selection in this configuration. - */ -const SurfaceSelectionModel* -SurfaceMontageConfigurationHippocampus::getLeftSecondSurfaceSelectionModel() const -{ - return m_leftSecondSurfaceSelectionModel; -} - -/** - * @return the right first surface selection in this configuration. - */ -SurfaceSelectionModel* -SurfaceMontageConfigurationHippocampus::getRightFirstSurfaceSelectionModel() -{ - return m_rightFirstSurfaceSelectionModel; -} - -/** - * @return the right first surface selection in this configuration. - */ -const SurfaceSelectionModel* -SurfaceMontageConfigurationHippocampus::getRightFirstSurfaceSelectionModel() const -{ - return m_rightFirstSurfaceSelectionModel; -} - -/** - * @return the right second surface selection in this configuration. - */ -SurfaceSelectionModel* -SurfaceMontageConfigurationHippocampus::getRightSecondSurfaceSelectionModel() -{ - return m_rightSecondSurfaceSelectionModel; -} - -/** - * @return the right second surface selection in this configuration. - */ -const SurfaceSelectionModel* -SurfaceMontageConfigurationHippocampus::getRightSecondSurfaceSelectionModel() const -{ - return m_rightSecondSurfaceSelectionModel; -} - -/** - * Get a description of this object's content. - * @return String describing this object's content. - */ -AString -SurfaceMontageConfigurationHippocampus::toString() const -{ - PlainTextStringBuilder tb; - getDescriptionOfContent(tb); - return tb.getText(); -} - -/** - * Get a text description of the instance's content. - * - * @param descriptionOut - * Description of the instance's content. - */ -void -SurfaceMontageConfigurationHippocampus::getDescriptionOfContent(PlainTextStringBuilder& descriptionOut) const -{ - AString msg; - - descriptionOut.addLine("Hippocampus Montage: "); - - descriptionOut.pushIndentation(); - - if (isLeftEnabled()) { - if (isFirstSurfaceEnabled()) { - const Surface* firstLeftSurface = getLeftFirstSurfaceSelectionModel()->getSurface(); - if (firstLeftSurface != NULL) { - descriptionOut.addLine("Left Surface:"); - descriptionOut.pushIndentation(); - firstLeftSurface->getDescriptionOfContent(descriptionOut); - descriptionOut.popIndentation(); - } - } - - if (isSecondSurfaceEnabled()) { - const Surface* secondLeftSurface = getLeftSecondSurfaceSelectionModel()->getSurface(); - if (secondLeftSurface != NULL) { - descriptionOut.addLine("Left Surface:"); - descriptionOut.pushIndentation(); - secondLeftSurface->getDescriptionOfContent(descriptionOut); - descriptionOut.popIndentation(); - } - } - } - - if (isRightEnabled()) { - if (isFirstSurfaceEnabled()) { - const Surface* firstRightSurface = getRightFirstSurfaceSelectionModel()->getSurface(); - if (firstRightSurface != NULL) { - descriptionOut.addLine("Right Surface:"); - descriptionOut.pushIndentation(); - firstRightSurface->getDescriptionOfContent(descriptionOut); - descriptionOut.popIndentation(); - } - } - if (isSecondSurfaceEnabled()) { - const Surface* secondRightSurface = getRightSecondSurfaceSelectionModel()->getSurface(); - if (secondRightSurface != NULL) { - descriptionOut.addLine("Right Surface:"); - descriptionOut.pushIndentation(); - secondRightSurface->getDescriptionOfContent(descriptionOut); - descriptionOut.popIndentation(); - } - } - } - - AString viewsMsg = "Selected Views: "; - - if (isLateralEnabled()) { - viewsMsg += " Lateral"; - } - if (isMedialEnabled()) { - viewsMsg += " Medial"; - } - - descriptionOut.addLine(viewsMsg); - - descriptionOut.popIndentation(); -} - -/** - * Get all surfaces displayed in this configuration. - * - * @param surfaceOut - * Will contain all displayed surfaces upon exit. - */ -void -SurfaceMontageConfigurationHippocampus::getDisplayedSurfaces(std::vector& surfacesOut) const -{ - surfacesOut.clear(); - - if (isLeftEnabled()) { - Surface* firstLeftSurface = NULL;; - if (isFirstSurfaceEnabled()) { - firstLeftSurface = const_cast(getLeftFirstSurfaceSelectionModel()->getSurface()); - if (firstLeftSurface != NULL) { - surfacesOut.push_back(const_cast(firstLeftSurface)); - } - } - - if (isSecondSurfaceEnabled()) { - const Surface* secondLeftSurface = getLeftSecondSurfaceSelectionModel()->getSurface(); - if (secondLeftSurface != NULL) { - if (secondLeftSurface != firstLeftSurface) { - surfacesOut.push_back(const_cast(secondLeftSurface)); - } - } - } - } - - if (isRightEnabled()) { - Surface* firstRightSurface = NULL; - if (isFirstSurfaceEnabled()) { - firstRightSurface = const_cast(getRightFirstSurfaceSelectionModel()->getSurface()); - if (firstRightSurface != NULL) { - surfacesOut.push_back(const_cast(firstRightSurface)); - } - } - if (isSecondSurfaceEnabled()) { - const Surface* secondRightSurface = getRightSecondSurfaceSelectionModel()->getSurface(); - if (secondRightSurface != NULL) { - if (secondRightSurface != firstRightSurface) { - surfacesOut.push_back(const_cast(secondRightSurface)); - } - } - } - } -} - -/** - * Copy the given configuration to this configurtion. - * - * @param configuration. - * Configuration that is copied. - */ -void -SurfaceMontageConfigurationHippocampus::copyConfiguration(SurfaceMontageConfigurationAbstract* configuration) -{ - SurfaceMontageConfigurationAbstract::copyConfiguration(configuration); - - SurfaceMontageConfigurationHippocampus* cerebralConfiguration = dynamic_cast(configuration); - CaretAssert(cerebralConfiguration); - - m_leftFirstSurfaceSelectionModel->setSurface(cerebralConfiguration->m_leftFirstSurfaceSelectionModel->getSurface()); - - m_leftSecondSurfaceSelectionModel->setSurface(cerebralConfiguration->m_leftSecondSurfaceSelectionModel->getSurface()); - - m_rightFirstSurfaceSelectionModel->setSurface(cerebralConfiguration->m_rightFirstSurfaceSelectionModel->getSurface()); - - m_rightSecondSurfaceSelectionModel->setSurface(cerebralConfiguration->m_rightSecondSurfaceSelectionModel->getSurface()); - - m_leftEnabled = cerebralConfiguration->m_leftEnabled; - - m_rightEnabled = cerebralConfiguration->m_rightEnabled; - - m_firstSurfaceEnabled = cerebralConfiguration->m_firstSurfaceEnabled; - - m_secondSurfaceEnabled = cerebralConfiguration->m_secondSurfaceEnabled; - - m_lateralEnabled = cerebralConfiguration->m_lateralEnabled; - - m_medialEnabled = cerebralConfiguration->m_medialEnabled; -} - - diff --git a/src/Brain/SurfaceMontageConfigurationHippocampus.h b/src/Brain/SurfaceMontageConfigurationHippocampus.h deleted file mode 100644 index 882f29e9d..000000000 --- a/src/Brain/SurfaceMontageConfigurationHippocampus.h +++ /dev/null @@ -1,142 +0,0 @@ -#ifndef __SURFACE_MONTAGE_CONFIGURATION_HIPPOCAMPUS_H__ -#define __SURFACE_MONTAGE_CONFIGURATION_HIPPOCAMPUS_H__ - -/*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*/ - - -#include "SurfaceMontageConfigurationAbstract.h" - -namespace caret { - class SceneClassAssistant; - class SurfaceSelectionModel; - - class SurfaceMontageConfigurationHippocampus : public SurfaceMontageConfigurationAbstract { - - public: - SurfaceMontageConfigurationHippocampus(const int32_t tabIndex); - - virtual ~SurfaceMontageConfigurationHippocampus(); - - SurfaceSelectionModel* getLeftFirstSurfaceSelectionModel(); - - const SurfaceSelectionModel* getLeftFirstSurfaceSelectionModel() const; - - SurfaceSelectionModel* getLeftSecondSurfaceSelectionModel(); - - const SurfaceSelectionModel* getLeftSecondSurfaceSelectionModel() const; - - SurfaceSelectionModel* getRightFirstSurfaceSelectionModel(); - - const SurfaceSelectionModel* getRightFirstSurfaceSelectionModel() const; - - SurfaceSelectionModel* getRightSecondSurfaceSelectionModel(); - - const SurfaceSelectionModel* getRightSecondSurfaceSelectionModel() const; - - bool isLeftEnabled() const; - - void setLeftEnabled(const bool enabled); - - bool isRightEnabled() const; - - void setRightEnabled(const bool enabled); - - bool isLateralEnabled() const; - - void setLateralEnabled(const bool enabled); - - bool isMedialEnabled() const; - - void setMedialEnabled(const bool enabled); - - bool isFirstSurfaceEnabled() const; - - void setFirstSurfaceEnabled(const bool enabled); - - bool isSecondSurfaceEnabled() const; - - void setSecondSurfaceEnabled(const bool enabled); - - virtual void initializeSelectedSurfaces(); - - virtual bool isValid(); - - virtual void updateSurfaceMontageViewports(std::vector& surfaceMontageViewports); - - virtual void copyConfiguration(SurfaceMontageConfigurationAbstract* configuration); - - private: - SurfaceMontageConfigurationHippocampus(const SurfaceMontageConfigurationHippocampus&); - - SurfaceMontageConfigurationHippocampus& operator=(const SurfaceMontageConfigurationHippocampus&); - - public: - virtual AString toString() const; - - virtual void getDescriptionOfContent(PlainTextStringBuilder& descriptionOut) const; - - virtual void getDisplayedSurfaces(std::vector& surfacesOut) const; - - - // ADD_NEW_METHODS_HERE - - protected: - virtual void saveMembersToScene(const SceneAttributes* sceneAttributes, - SceneClass* sceneClass); - - virtual void restoreMembersFromScene(const SceneAttributes* sceneAttributes, - const SceneClass* sceneClass); - - private: - SceneClassAssistant* m_sceneAssistant; - - SurfaceSelectionModel* m_leftFirstSurfaceSelectionModel; - - SurfaceSelectionModel* m_leftSecondSurfaceSelectionModel; - - SurfaceSelectionModel* m_rightFirstSurfaceSelectionModel; - - SurfaceSelectionModel* m_rightSecondSurfaceSelectionModel; - - bool m_leftEnabled; - - bool m_rightEnabled; - - bool m_firstSurfaceEnabled; - - bool m_secondSurfaceEnabled; - - bool m_lateralEnabled; - - bool m_medialEnabled; - - // ADD_NEW_MEMBERS_HERE - - friend class ModelSurfaceMontage; - - }; - -#ifdef __SURFACE_MONTAGE_CONFIGURATION_HIPPOCAMPUS_DECLARE__ - // -#endif // __SURFACE_MONTAGE_CONFIGURATION_HIPPOCAMPUS_DECLARE__ - -} // namespace -#endif //__SURFACE_MONTAGE_CONFIGURATION_HIPPOCAMPUS_H__ diff --git a/src/Brain/SurfaceMontageConfigurationTypeEnum.cxx b/src/Brain/SurfaceMontageConfigurationTypeEnum.cxx index 4bb20490a..e14775971 100644 --- a/src/Brain/SurfaceMontageConfigurationTypeEnum.cxx +++ b/src/Brain/SurfaceMontageConfigurationTypeEnum.cxx @@ -31,7 +31,9 @@ using namespace caret; /** * \class caret::SurfaceMontageConfigurationTypeEnum - * \brief Type for montage configuration + * \brief + * + * * * Using this enumerated type in the GUI with an EnumComboBoxTemplate * @@ -118,9 +120,6 @@ SurfaceMontageConfigurationTypeEnum::initialize() "FLAT_CONFIGURATION", "Flat Maps")); - enumData.push_back(SurfaceMontageConfigurationTypeEnum(HIPPOCAMPUS_CONFIGURATION, - "HIPPOCAMPUS_CONFIGURATION", - "Hippocampus")); } /** diff --git a/src/Brain/SurfaceMontageConfigurationTypeEnum.h b/src/Brain/SurfaceMontageConfigurationTypeEnum.h index 8a78c34d5..9b4585c2c 100644 --- a/src/Brain/SurfaceMontageConfigurationTypeEnum.h +++ b/src/Brain/SurfaceMontageConfigurationTypeEnum.h @@ -35,14 +35,12 @@ class SurfaceMontageConfigurationTypeEnum { * Enumerated values. */ enum Enum { - /** L/R Cerebellum */ + /** */ CEREBELLAR_CORTEX_CONFIGURATION, - /** Cortex */ + /** */ CEREBRAL_CORTEX_CONFIGURATION, - /** flat maps */ - FLAT_CONFIGURATION, - /** L/R Hippocampus **/ - HIPPOCAMPUS_CONFIGURATION + /** */ + FLAT_CONFIGURATION }; diff --git a/src/Brain/VolumeMprSettings.cxx b/src/Brain/VolumeMprSettings.cxx index bb8a8d118..f9e0dd755 100644 --- a/src/Brain/VolumeMprSettings.cxx +++ b/src/Brain/VolumeMprSettings.cxx @@ -322,7 +322,7 @@ VolumeMprSettings::restoreFromScene(const SceneAttributes* sceneAttributes, return; } - /*const int32_t sceneVersion(sceneClass->getVersionNumber());*/ + const int32_t sceneVersion(sceneClass->getVersionNumber()); m_sceneAssistant->restoreMembers(sceneAttributes, sceneClass); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7d194b435..3e15d9ff8 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,7 +8,7 @@ CMAKE_MINIMUM_REQUIRED (VERSION 3.0) # PROJECT(Workbench) -SET(WB_VERSION "2.0.0") +SET(WB_VERSION "2.0.1") # # Set to true for verbose output when debugging this file # diff --git a/src/CZIlib/CZI/libCZI.h b/src/CZIlib/CZI/libCZI.h index 6a5c3e047..7799f1aec 100644 --- a/src/CZIlib/CZI/libCZI.h +++ b/src/CZIlib/CZI/libCZI.h @@ -22,7 +22,6 @@ #pragma once -#include #include "ImportExport.h" #include "priv_guiddef.h" diff --git a/src/CZIlib/CZI/libCZI_exceptions.h b/src/CZIlib/CZI/libCZI_exceptions.h index e19e62cf5..6b18cb482 100644 --- a/src/CZIlib/CZI/libCZI_exceptions.h +++ b/src/CZIlib/CZI/libCZI_exceptions.h @@ -24,7 +24,6 @@ #include #include -#include namespace libCZI { diff --git a/src/Cifti/CiftiXML.cxx b/src/Cifti/CiftiXML.cxx index e443bb348..f311df3f1 100644 --- a/src/Cifti/CiftiXML.cxx +++ b/src/Cifti/CiftiXML.cxx @@ -349,7 +349,7 @@ void CiftiXML::readXML(QXmlStreamReader& xml) throw DataFileException("CIFTI element may only be specified once"); } QXmlStreamAttributes attributes = xml.attributes(); - if (attributes.hasAttribute("Version")) + if(attributes.hasAttribute("Version")) { m_parsedVersion = CiftiVersion(attributes.value("Version").toString()); } else { diff --git a/src/Commands/CommandOperationManager.cxx b/src/Commands/CommandOperationManager.cxx index 1f8d27f5a..1344266f8 100644 --- a/src/Commands/CommandOperationManager.cxx +++ b/src/Commands/CommandOperationManager.cxx @@ -214,7 +214,6 @@ #include "OperationSurfaceFlipNormals.h" #include "OperationSurfaceGeodesicDistance.h" #include "OperationSurfaceGeodesicDistanceAllToAll.h" -#include "OperationSurfaceGeodesicDistanceSparseText.h" #include "OperationSurfaceGeodesicROIs.h" #include "OperationSurfaceInformation.h" #include "OperationSurfaceNormals.h" @@ -476,7 +475,6 @@ CommandOperationManager::CommandOperationManager() this->commandOperations.push_back(new CommandParser(new AutoOperationSurfaceFlipNormals())); this->commandOperations.push_back(new CommandParser(new AutoOperationSurfaceGeodesicDistance())); this->commandOperations.push_back(new CommandParser(new AutoOperationSurfaceGeodesicDistanceAllToAll())); - this->commandOperations.push_back(new CommandParser(new AutoOperationSurfaceGeodesicDistanceSparseText())); this->commandOperations.push_back(new CommandParser(new AutoOperationSurfaceGeodesicROIs())); this->commandOperations.push_back(new CommandParser(new AutoOperationSurfaceInformation())); this->commandOperations.push_back(new CommandParser(new AutoOperationSurfaceNormals())); diff --git a/src/Common/BoundingBox.h b/src/Common/BoundingBox.h index 58eb744c1..8d9436061 100644 --- a/src/Common/BoundingBox.h +++ b/src/Common/BoundingBox.h @@ -75,7 +75,7 @@ class BoundingBox : public CaretObject { const float c[3], const float d[4]); - void update(const float xyz[3]); + void update(const float xyz[]); void update(const float x, const float y, @@ -83,7 +83,7 @@ class BoundingBox : public CaretObject { void update(const std::array& xyz); - void updateExcludeNanInf(const float xyz[3]); + void updateExcludeNanInf(const float xyz[]); void updateExcludeNanInf(const float x, const float y, diff --git a/src/Common/CMakeLists.txt b/src/Common/CMakeLists.txt index 347d6b77f..5b358d4cb 100644 --- a/src/Common/CMakeLists.txt +++ b/src/Common/CMakeLists.txt @@ -73,7 +73,6 @@ CaretCompactLookup.h CaretException.h CaretFunctionName.h CaretHeap.h -CaretHierarchy.h CaretHttpManager.h CaretLogger.h CaretMathExpression.h @@ -93,8 +92,6 @@ CaretTemporaryFile.h CaretUndoCommand.h CaretUndoStack.h CaretUnitsTypeEnum.h -Cluster.h -ClusterContainer.h ColorFunctions.h CubicSpline.h DataCompressZLib.h @@ -246,7 +243,6 @@ CaretColor.cxx CaretColorEnum.cxx CaretCommandLine.cxx CaretException.cxx -CaretHierarchy.cxx CaretHttpManager.cxx CaretLogger.cxx CaretMathExpression.cxx @@ -263,8 +259,6 @@ CaretTemporaryFile.cxx CaretUndoCommand.cxx CaretUndoStack.cxx CaretUnitsTypeEnum.cxx -Cluster.cxx -ClusterContainer.cxx ColorFunctions.cxx CubicSpline.cxx DataCompressZLib.cxx diff --git a/src/Common/CaretColorEnum.cxx b/src/Common/CaretColorEnum.cxx index d8414234b..de590353d 100644 --- a/src/Common/CaretColorEnum.cxx +++ b/src/Common/CaretColorEnum.cxx @@ -502,8 +502,8 @@ CaretColorEnum::getColorEnumsNoBlackOrWhite(std::vector& a getColorAndOptionalEnums(allColorEnums, OPTION_NO_OPTIONS); - (void)std::remove(allColorEnums.begin(), allColorEnums.end(), CaretColorEnum::BLACK); - (void)std::remove(allColorEnums.begin(), allColorEnums.end(), CaretColorEnum::WHITE); + std::remove(allColorEnums.begin(), allColorEnums.end(), CaretColorEnum::BLACK); + std::remove(allColorEnums.begin(), allColorEnums.end(), CaretColorEnum::WHITE); } /** diff --git a/src/Common/CaretHierarchy.cxx b/src/Common/CaretHierarchy.cxx deleted file mode 100644 index d38433d35..000000000 --- a/src/Common/CaretHierarchy.cxx +++ /dev/null @@ -1,217 +0,0 @@ -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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*/ - -#include "CaretHierarchy.h" - -#include "CaretAssert.h" -#include "CaretException.h" -#include "CaretPointer.h" - -using namespace caret; -using namespace std; - -CaretHierarchy::CaretHierarchy() -{ - m_usedNames.insert(""); //don't allow adding the empty string, which we implicitly use for the root element -} - -void CaretHierarchy::clear() -{ - m_root = Item(); - m_usedNames.clear(); - m_usedNames.insert(""); //include the implicit root element -} - -//backwards recursive depth-first, for some efficiency when reading from file -bool CaretHierarchy::Item::add(const CaretHierarchy::Item& toAdd, const AString parent) -{ - if (name == parent) - { - children.push_back(toAdd); - return true; - } - for (auto iter = children.rbegin(); iter != children.rend(); ++iter) - { - if (iter->add(toAdd, parent)) return true; - } - return false; -} - -bool CaretHierarchy::addItem(const Item& toAdd, const AString parent) -{ - if (m_usedNames.find(toAdd.name) != m_usedNames.end()) return false; - if (m_usedNames.find(parent) == m_usedNames.end()) return false; //we can predict when it would fail, so return early - if (m_root.add(toAdd, parent)) - { - m_usedNames.insert(toAdd.name); - return true; - } - return false; -} - -void CaretHierarchy::Item::XMLWriteHelper(QXmlStreamWriter& xml) const -{ - if (name == "") - {//don't write the implicit root element, it exists for convenience rather than structure - for (auto iter : children) - { - iter.XMLWriteHelper(xml); - } - } else { - xml.writeStartElement("Item"); //TODO: better name? - xml.writeAttribute("Name", name); - auto kvdata = extraInfo.getAllData(); - if (!kvdata.empty()) - { - xml.writeStartElement("Info"); - for (auto iter : kvdata) - { - xml.writeStartElement("InfoItem"); - xml.writeAttribute("Key", iter.first); - xml.writeAttribute("Value", iter.second); - xml.writeEndElement(); - } - xml.writeEndElement(); - } - for (auto iter : children) - { - iter.XMLWriteHelper(xml); - } - xml.writeEndElement(); - } -} - -void CaretHierarchy::writeXML(QXmlStreamWriter& xml) const -{ - xml.writeStartElement("CaretHierarchy"); - xml.writeAttribute("Version", "1"); - m_root.XMLWriteHelper(xml); - xml.writeEndElement(); -} - -QString CaretHierarchy::writeXMLToString() const -{ - QString ret; - QXmlStreamWriter xml(&ret); - xml.setAutoFormatting(true); - xml.writeStartDocument(); - writeXML(xml); - xml.writeEndDocument(); - return ret; -} - -void CaretHierarchy::readXML(QXmlStreamReader& xml) -{ - clear(); //leaves us with just the root element and "" used - vector parents; //can use add() for sanity checking rather than recursive parsing, just need to track the XML parent name - vector toAdd; - parents.push_back(""); //trick for handling the root case without special code - try - { - bool haveRoot = false; - bool rootEnded = false; - for (; !xml.atEnd(); xml.readNext()) - { - if (xml.isStartElement()) - { - auto name = xml.name(); - if (name == QLatin1String("CaretHierarchy")) - { - if (haveRoot) throw CaretException("found root 'CaretHierarchy' element more than once"); - haveRoot = true; - QXmlStreamAttributes attributes = xml.attributes(); - if (!attributes.hasAttribute("Version")) throw CaretException("no Version attribute in hierarch XML"); - if (attributes.value("Version").toString() != "1") throw CaretException("unknown hierarchy version '" + attributes.value("Version").toString() + "'"); - } else if (name == QLatin1String("Item")) { - if (!haveRoot) throw CaretException("hierarchy XML is missing root element"); - if (rootEnded) throw CaretException("found Item tag after closing root tag in hierarchy XML"); - QXmlStreamAttributes attributes = xml.attributes(); - AString itemName = attributes.value("Name").toString(); - toAdd.push_back(Item(itemName)); - parents.push_back(itemName); - } else if (name == QLatin1String("Info")) { - if (toAdd.empty()) throw CaretException("Info element not allowed at root level"); - toAdd.back().extraInfo.readXML(xml); //leaves xml on end element of Info, which readNext() should eat so the endElement section never sees it - } else { - throw CaretException("unexpected element '" + name.toString() + "' in hierarchy XML"); - } - } else if (xml.isEndElement()) { - auto name = xml.name(); - if (name == QLatin1String("Item")) - { - if (!addItem(toAdd.back(), parents.back())) throw CaretException("failed to add item '" + name.toString() + "' to hierarchy, check for a duplicate, empty, or missing Name attribute"); - toAdd.pop_back(); - parents.pop_back(); - } else { - CaretAssert(name == QLatin1String("CaretHierarchy")); - rootEnded = true; - } //start element case will already have sanity checked the tag names - } - } - } catch (CaretException& e) { - throw CaretException("Hierarchy XML error: " + e.whatString()); //so we can throw on error instead of doing a bunch of dancing with xml.raiseError and xml.hasError - } - if(xml.hasError()) - { - throw CaretException("Hierarchy XML error: " + xml.errorString()); - } -} - -void CaretHierarchy::OrderedKVStore::readXML(QXmlStreamReader& xml) -{ - clear(); //forget prior stuff - for (xml.readNext(); !xml.atEnd(); xml.readNext()) - { - if (xml.isStartElement()) - { - auto name = xml.name(); - if (name != QLatin1String("InfoItem")) throw CaretException("found unexpected element in Info context: " + name.toString()); - QXmlStreamAttributes attributes = xml.attributes(); - set(attributes.value("Key").toString(), attributes.value("Value").toString()); - } else if (xml.isEndElement()) { - if (xml.name() != QLatin1String("InfoItem")) return; - } - } -} - -void CaretHierarchy::readXML(const QString& text) -{ - QXmlStreamReader xml(text); - readXML(xml); -} - -void CaretHierarchy::Item::QSIModelHelper(QStandardItem* qsiOut) const -{ - for (int index = 0; index < int(children.size()); ++index) - { - const Item& child = children[index]; - auto node = new QStandardItem(child.name); - qsiOut->setChild(index, node); - node->setData(QVariant(id)); - child.QSIModelHelper(node); - } -} - -QStandardItemModel* CaretHierarchy::buildQSIModel() const -{ - CaretPointerNonsync ret(new QStandardItemModel()); //not mutex protected, but we only need it for throw guarantees, not multithreaded replacement - m_root.QSIModelHelper(ret->invisibleRootItem()); //QT also has a "root above tree" idea for convenience, rather than an array of top-level items - return ret.releasePointer(); -} diff --git a/src/Common/CaretHierarchy.h b/src/Common/CaretHierarchy.h deleted file mode 100644 index 0a8e23b92..000000000 --- a/src/Common/CaretHierarchy.h +++ /dev/null @@ -1,120 +0,0 @@ -#ifndef __CARET_HIERARCHY_H__ -#define __CARET_HIERARCHY_H__ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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*/ - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "AString.h" - -namespace caret -{ - - class CaretHierarchy - { - public: - struct Item; - - CaretHierarchy(); - bool addItem(const Item& toAdd, const AString parent = ""); //defaults to making the root element the parent - void clear(); - bool isEmpty() const { return (m_root.children.size() == 0); } - std::set getAllNames() const { auto ret = m_usedNames; ret.erase(""); return ret; } //hide the implicit root element - const Item& getInvisibleRoot() const { return m_root; } //when in rome... - - void readXML(const QString& text); - void readXML(QXmlStreamReader& xml); - - QString writeXMLToString() const; - void writeXML(QXmlStreamWriter& xml) const; - - QStandardItemModel* buildQSIModel() const; //NOTE: allocates a new, unowned object - - class OrderedKVStore - { - std::map m_nameLookup; - std::vector > m_store; - public: - const std::vector >& getAllData() const { return m_store; } - AString get(const AString& name) const - { - auto iter = m_nameLookup.find(name); - if (iter == m_nameLookup.end()) return ""; - return m_store[iter->second].second; - } - void set(const AString& name, const AString& value) - { - auto iter = m_nameLookup.find(name); - if (iter == m_nameLookup.end()) - { - m_nameLookup[name] = m_store.size(); - m_store.push_back(std::make_pair(name, value)); - } else { - m_store[iter->second].second = value; - } - } - void erase(const AString& name) - { - auto iter = m_nameLookup.find(name); - if (iter == m_nameLookup.end()) return; - for (size_t i = iter->second + 1; i < m_store.size(); ++i) - { - m_nameLookup[m_store[i].first] -= 1; - } - m_store.erase(m_store.begin() + iter->second); - m_nameLookup.erase(iter);//now iter is invalid, but we are done - } - void clear() { m_nameLookup.clear(); m_store.clear(); } - - void readXML(QXmlStreamReader& xml); - }; - - struct Item - { - bool add(const Item& toAdd, const AString parent); //search for parent and add to its children - reverse depth first for parsing to be somewhat efficient - - AString name; - AString id; //NOTE: defunct - OrderedKVStore extraInfo; - std::vector children; - - Item(const AString nameIn) : name(nameIn) {} - Item() {} - - void XMLWriteHelper(QXmlStreamWriter& xml) const; - void QSIModelHelper(QStandardItem* qsiOut) const; - }; - private: - Item m_root; - std::set m_usedNames; //efficiently prevent duplicate names - }; - -} - -#endif diff --git a/src/Common/CaretPointer.h b/src/Common/CaretPointer.h index e66473229..54338f7e0 100644 --- a/src/Common/CaretPointer.h +++ b/src/Common/CaretPointer.h @@ -29,55 +29,6 @@ namespace caret { - //implement copy semantics with a forward-declared pointer type, as long as copy, destructor, =, etc are implemented in the cxx - //use -> and * for access to members, but =, destruct, copy construct behaves like it was a non-pointer member - template - class CaretForwardHelper - { - mutable T* m_pointer; - public: - //can be done with only forward declaration - CaretForwardHelper() { m_pointer = NULL; } - - //below need to have the real header for the type - CaretForwardHelper(const CaretForwardHelper& rhs) { m_pointer = new T(*rhs); } //rhs template can't replace default copy - //copy from another forward declare of arbitrary type, as long as it is compatible - template - CaretForwardHelper(const CaretForwardHelper& rhs) { m_pointer = new T(*rhs); } - //copy from some arbitrary other type - template - CaretForwardHelper(const R& rhs) { m_pointer = new T(rhs); } - //implement dereference as the way to instantiate m_pointer, useful for implementing the rest of the logic - const T& operator*() const - { - if (m_pointer == NULL) - { - m_pointer = new T(); - } - return *m_pointer; - } - T& operator*() - { - if (m_pointer == NULL) - { - m_pointer = new T(); - } - return *m_pointer; - } - //default assignment implementation isn't what we want, fix it - T& operator=(const CaretForwardHelper& rhs) { return **this = *rhs; } //similar to copy, rhs template can't replace default - template - T& operator=(const CaretForwardHelper& rhs) { return **this = *rhs; } //could check for rhs.m_pointer == NULL, but this is cleaner - template - T& operator=(const R& rhs) { return **this = rhs; } - //arrow, conversion - const T *const& operator->() const { return &**this; } //deref this to get template, deref again to call custom operator, then address-of to get real pointer - T * operator->() { return &**this; } //we do want const on the template to return a pointer to const - operator const T& () const { return **this; } - operator T& () { return **this; } - ~CaretForwardHelper() { if (m_pointer != NULL) delete m_pointer; } - }; - namespace _caret_pointer_impl {//namespace to hide things that shouldn't be used outside the header diff --git a/src/Common/Cluster.cxx b/src/Common/Cluster.cxx deleted file mode 100644 index ca92e9266..000000000 --- a/src/Common/Cluster.cxx +++ /dev/null @@ -1,396 +0,0 @@ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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 __CLUSTER_DECLARE__ -#include "Cluster.h" -#undef __CLUSTER_DECLARE__ - -#include "CaretAssert.h" -#include "CaretLogger.h" -using namespace caret; - -/** - * \class caret::Cluster - * \brief Data for a brainordinate cluster - * \ingroup Common - */ - -/** - * @return string name for the given type - * @param type - * The type - */ -AString -Cluster::locationTypeToName(const LocationType type) -{ - AString name("invalid"); - switch (type) { - case LocationType::UNKNOWN: - name = "Unknown"; - break; - case LocationType::CENTRAL: - name = "Central"; - break; - case LocationType::LEFT: - name = "Left"; - break; - case LocationType::RIGHT: - name = "Right"; - break; - } - return name; -} - -/** - * Default constructor creates an invalid cluster. - */ -Cluster::Cluster() -: CaretObject(), -m_location(LocationType::UNKNOWN), -m_name(""), -m_key(-1) -{ - -} - -/** - * Constructor for a cluster with type NONE - * @param name - * Name of cluster - * @param key - * Index of cluster (such as a label index) - * @param coordinatesXYZ - * Coordinates in the cluster. - */ -Cluster::Cluster(const AString& name, - const int32_t key, - const std::vector& coordinatesXYZ) -: CaretObject(), -m_location(LocationType::UNKNOWN), -m_name(name), -m_key(key), -m_coordinateXYZ(coordinatesXYZ) -{ - -} - -/** - * Destructor. - */ -Cluster::~Cluster() -{ -} - -/** - * Copy constructor. - * @param obj - * Object that is copied. - */ -Cluster::Cluster(const Cluster& obj) -: CaretObject(obj) -{ - this->copyHelperCluster(obj); -} - -/** - * Assignment operator. - * @param obj - * Data copied from obj to this. - * @return - * Reference to this object. - */ -Cluster& -Cluster::operator=(const Cluster& obj) -{ - if (this != &obj) { - CaretObject::operator=(obj); - this->copyHelperCluster(obj); - } - return *this; -} - -/** - * @return True if this instance is valid (valid is one or more brainordinates) - */ -bool -Cluster::isValid() const -{ - return ( ! m_coordinateXYZ.empty()); -} - -/** - * Helps with copying an object of this type. - * @param obj - * Object that is copied. - */ -void -Cluster::copyHelperCluster(const Cluster& obj) -{ - m_location = obj.m_location; - m_name = obj.m_name; - m_key = obj.m_key; - m_coordinateXYZ = obj.m_coordinateXYZ; - m_centerOfGravityXYZ = obj.m_centerOfGravityXYZ; -} - -/** - * @return Name of cluster - */ -AString -Cluster::getName() const -{ - return m_name; -} - -/** - * @return Location of the cluster - */ -Cluster::LocationType -Cluster::getLocationType() const -{ - computeCenterOfGravityAndLocation(); - return m_location; -} - -/** - * @return Name of location type of the cluster - */ -AString -Cluster::getLocationTypeName() const -{ - return Cluster::locationTypeToName(m_location); -} - -/** - * @return Key for cluster - */ -int32_t -Cluster::getKey() const -{ - return m_key; -} - -/** - * @return Center of gravity for cluster - */ -Vector3D -Cluster::getCenterOfGravityXYZ() const -{ - computeCenterOfGravityAndLocation(); - return m_centerOfGravityXYZ; -} - -/** - * @return Number of brainordinates in cluster - */ -int64_t -Cluster::getNumberOfBrainordinates() const -{ - return m_coordinateXYZ.size(); -} - -/** - * Add a coordinate to this cluster. - * @param coordinateXYZ - * Coordinate added to this cluster - */ -void -Cluster::addCoordinate(const Vector3D& coordinateXYZ) -{ - m_coordinateXYZ.push_back(coordinateXYZ); - invalidateCenterOfGravityAndLocation(); -} - -/** - * @return Number of coordinates in this cluster - */ -const Vector3D& -Cluster::getCoordinate(const int32_t index) const -{ - CaretAssertVectorIndex(m_coordinateXYZ, index); - return m_coordinateXYZ[index]; -} - -/** - * Merge the coordinates from the given cluster with this cluster's coordinates - */ -void -Cluster::mergeCoordinates(const Cluster& cluster) -{ - m_coordinateXYZ.insert(m_coordinateXYZ.end(), - cluster.m_coordinateXYZ.begin(), cluster.m_coordinateXYZ.end()); -} - - -/** - * Invalidate center-of-gravity and location of cluster. - */ -void -Cluster::invalidateCenterOfGravityAndLocation() -{ - m_centerOfGravityAndLocationValidFlag = false; -} - -/** - * Compute center-of-gravity and location of cluster. - */ -void -Cluster::computeCenterOfGravityAndLocation() const -{ - if (m_centerOfGravityAndLocationValidFlag) { - return; - } - - m_centerOfGravityXYZ.fill(0.0); - m_location = LocationType::UNKNOWN; - const float numCoords(m_coordinateXYZ.size()); - if (numCoords < 1.0) { - return; - } - - float numLeft(0.0); - float numRight(0.0); - - Vector3D sumXYZ; - for (const Vector3D& xyz : m_coordinateXYZ) { - sumXYZ += xyz; - - /* - * At 0.0 is neither left nor right - */ - if (xyz[0] >= 0.0) { - numRight += 1.0; - } - else { - numLeft += 1.0; - } - } - - CaretAssert(numCoords >= 1.0); - m_centerOfGravityXYZ = (sumXYZ / numCoords); - - /* - * Estimate if cluster is left, right, central - * using percentage of nodes with negative and - * postive X-coordinate - */ - const float numLeftRight(numLeft + numRight); - if (numLeftRight >= 1.0) { - const float leftPercent((numLeft / numLeftRight) * 100.0); - const float rightPercent((numRight / numLeftRight) * 100.0); - - const float centralPercentMinimim(40.0); - const float centralPercentMaximum(60.0); - if ((leftPercent >= centralPercentMinimim) - && (leftPercent <= centralPercentMaximum) - && (rightPercent >= centralPercentMinimim) - && (rightPercent <= centralPercentMaximum)) { - m_location = LocationType::CENTRAL; - } - else if (leftPercent > rightPercent) { - m_location = LocationType::LEFT; - } - else { - m_location = LocationType::RIGHT; - } - - if (m_location == LocationType::UNKNOWN) { - const AString msg("Cluster \"" - + getName() - + "\" " + AString::number(m_coordinateXYZ.size()) + " brainordinates" - " COG: " + m_centerOfGravityXYZ.toString() - + " location is UNKNOWN " - + " Percent Left=" + AString::number(leftPercent) - + " Percent Right=" + AString::number(rightPercent)); - CaretLogWarning(msg); - CaretAssertMessage(0, msg); - } - } - - m_centerOfGravityAndLocationValidFlag = true; -} - -/** - * @return True if this cluster was split into other clusters (typically Central is - * split into left and right). - */ -bool -Cluster::isSplitClusterFlag() const -{ - return m_splitClusterFlag; -} - - -/** - * Split a cluster into new right and left clusters. - * @return Vector containing the new clusters. - */ -std::vector -Cluster::splitClusterIntoRightAndLeft() const -{ - std::vector leftXYZ; - std::vector rightXYZ; - - for (const Vector3D& xyz : m_coordinateXYZ) { - if (xyz[0] < 0.0) { - leftXYZ.push_back(xyz); - } - else if (xyz[0] >= 0.0) { - rightXYZ.push_back(xyz); - } - } - - std::vector clustersOut; - - if ( ! leftXYZ.empty()) { - Cluster* leftCluster(new Cluster(getName(), getKey(), leftXYZ)); - leftCluster->computeCenterOfGravityAndLocation(); - clustersOut.push_back(leftCluster); - } - if ( ! rightXYZ.empty()) { - Cluster* rightCluster(new Cluster(getName(), getKey(), rightXYZ)); - rightCluster->computeCenterOfGravityAndLocation(); - clustersOut.push_back(rightCluster); - } - - m_splitClusterFlag = ( ! clustersOut.empty()); - - return clustersOut; -} - -/** - * Get a description of this object's content. - * @return String describing this object's content. - */ -AString -Cluster::toString() const -{ - computeCenterOfGravityAndLocation(); /* ensure cog and type have been calculated */ - - AString text; - text.append("Name=" + m_name); - text.append(" LocationType=" + getLocationTypeName()); - text.append(" Key=" + AString::number(m_key)); - text.append(" COG=" + m_centerOfGravityXYZ.toString()); - text.append(" Number of Brainordinates=" + AString::number(getNumberOfBrainordinates())); - return text; -} - diff --git a/src/Common/Cluster.h b/src/Common/Cluster.h deleted file mode 100644 index e06eae19f..000000000 --- a/src/Common/Cluster.h +++ /dev/null @@ -1,128 +0,0 @@ -#ifndef __CLUSTER_H__ -#define __CLUSTER_H__ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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*/ - - -#include -#include -#include - -#include "CaretObject.h" -#include "Vector3D.h" - -namespace caret { - - class Cluster : public CaretObject { - - public: - /** - * Location type of the cluster - */ - enum class LocationType { - /** unknown - default */ - UNKNOWN, - /** neither left nor right */ - CENTRAL, - /** left side accumulation */ - LEFT, - /** right side accumulation */ - RIGHT - }; - - static AString locationTypeToName(const LocationType type); - - Cluster(); - - Cluster(const AString& name, - const int32_t key, - const std::vector& coordinatesXYZ); - - virtual ~Cluster(); - - Cluster(const Cluster& obj); - - Cluster& operator=(const Cluster& obj); - - bool isValid() const; - - AString getName() const; - - LocationType getLocationType() const; - - AString getLocationTypeName() const; - - int32_t getKey() const; - - Vector3D getCenterOfGravityXYZ() const; - - int64_t getNumberOfBrainordinates() const; - - void addCoordinate(const Vector3D& coordinateXYZ); - - const Vector3D& getCoordinate(const int32_t index) const; - - void mergeCoordinates(const Cluster& cluster); - - std::vector splitClusterIntoRightAndLeft() const; - - bool isSplitClusterFlag() const; - - // ADD_NEW_METHODS_HERE - - virtual AString toString() const; - - private: - void copyHelperCluster(const Cluster& obj); - - void computeCenterOfGravityAndLocation() const; - - void invalidateCenterOfGravityAndLocation(); - - mutable LocationType m_location = LocationType::UNKNOWN; - - AString m_name = ""; - - int32_t m_key = -1; - - std::vector m_coordinateXYZ; - - mutable Vector3D m_centerOfGravityXYZ; - - mutable bool m_centerOfGravityAndLocationValidFlag = false; - - /** - * True if this cluster was split into other clusters (typically Central is - * split into left and right). - */ - mutable bool m_splitClusterFlag = false; - - // ADD_NEW_MEMBERS_HERE - - friend class ClusterContainer; - }; - -#ifdef __CLUSTER_DECLARE__ - // -#endif // __CLUSTER_DECLARE__ - -} // namespace -#endif //__CLUSTER_H__ diff --git a/src/Common/ClusterContainer.cxx b/src/Common/ClusterContainer.cxx deleted file mode 100644 index 87f6d9803..000000000 --- a/src/Common/ClusterContainer.cxx +++ /dev/null @@ -1,386 +0,0 @@ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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 __CLUSTER_CONTAINER_DECLARE__ -#include "ClusterContainer.h" -#undef __CLUSTER_CONTAINER_DECLARE__ - -#include - -#include "CaretAssert.h" -#include "StringTableModel.h" - -using namespace caret; - - - -/** - * \class caret::ClusterContainer - * \brief Container for clusters - * \ingroup Common - */ - -/** - * Constructor. - */ -ClusterContainer::ClusterContainer() -: CaretObject() -{ - -} - -/** - * Destructor. - */ -ClusterContainer::~ClusterContainer() -{ -} - -/** - * Add a cluster. - * @param cluster - * Cluster to add. Takes ownership of cluster and will eventually delete it. - */ -void -ClusterContainer::addCluster(Cluster* cluster) -{ - m_clusters.emplace_back(cluster); - - clearSortedContainers(); -} - -/** - * Clear the clusters in this container. - */ -void -ClusterContainer::clear() -{ - clearSortedContainers(); - m_clusters.clear(); -} - -/** - * Clear the sorted containers. - */ -void -ClusterContainer::clearSortedContainers() -{ - m_mapWithClustersSortedByKey.clear(); - m_mapWithClustersSortedByName.clear(); - m_vectorClustersSortedByKey.clear(); - m_vectorClustersSortedByName.clear(); - m_keysSorted.clear(); -} - -/** - * @return ALL clusters sorted by key - */ -const std::vector& -ClusterContainer::getClustersSortedByKey() const -{ - createMultimapClustersSortedByKey(); - - if (m_vectorClustersSortedByKey.empty()) { - if ( ! m_mapWithClustersSortedByKey.empty()) { - for (const auto& keyCluster : m_mapWithClustersSortedByKey) { - m_vectorClustersSortedByKey.push_back(keyCluster.second); - } - } - } - return m_vectorClustersSortedByKey; -} - -/** - * Lazily initialize the multimap that sorts clusters by key - */ -void -ClusterContainer::createMultimapClustersSortedByKey() const -{ - if (m_mapWithClustersSortedByKey.empty()) { - if ( ! m_clusters.empty()) { - for (const auto& c : m_clusters) { - m_mapWithClustersSortedByKey.insert(std::make_pair(c->m_key, c.get())); - } - } - } -} - -/** - * @return ALL clusters sorted by name - */ -const std::vector& -ClusterContainer::getClustersSortedByName() const -{ - createMultimapClustersSortedByName(); - - if (m_vectorClustersSortedByName.empty()) { - if ( ! m_mapWithClustersSortedByName.empty()) { - for (const auto& nameCluster : m_mapWithClustersSortedByName) { - m_vectorClustersSortedByName.push_back(nameCluster.second); - } - } - } - return m_vectorClustersSortedByName; -} - -/** - * Lazily initialize the multimap that sorts clusters by name - */ -void -ClusterContainer::createMultimapClustersSortedByName() const -{ - if (m_mapWithClustersSortedByName.empty()) { - if ( ! m_clusters.empty()) { - for (const auto& c : m_clusters) { - m_mapWithClustersSortedByName.insert(std::make_pair(c->m_name, c.get())); - } - } - } -} - -/** - * @return All clusters with the given key - * @param key - * Key for requested clusters - */ -std::vector -ClusterContainer::getClustersWithKey(const int32_t key) const -{ - createMultimapClustersSortedByKey(); - - std::pair matches = m_mapWithClustersSortedByKey.equal_range(key); - std::vector clustersOut; - for (MultimapSortedByKeyIterator iter = matches.first; - iter != matches.second; - iter++) { - clustersOut.push_back(iter->second); - } - return clustersOut; -} - -/** - * @return All clusters with the given name - * @param name - * Name for requested clusters - */ -std::vector -ClusterContainer::getClustersWithName(const AString& name) const -{ - createMultimapClustersSortedByName(); - - std::pair matches = m_mapWithClustersSortedByName.equal_range(name); - std::vector clustersOut; - for (MultimapSortedByNameIterator iter = matches.first; - iter != matches.second; - iter++) { - clustersOut.push_back(iter->second); - } - return clustersOut; -} - -/** - * Add a key that does not map to any cluster - */ -void -ClusterContainer::addKeyThatIsNotInAnyCluster(const int32_t key) -{ - m_keysThatAreNotInAnyClusters.insert(key); -} - -/** - * @return Keys that do not map to any clusters (do not map to brainordinates) - */ -std::set -ClusterContainer::getKeysThatAreNotInAnyClusters() const -{ - return m_keysThatAreNotInAnyClusters; -} - -/** - * @return The clusters in a formatted text string - */ -AString -ClusterContainer::getClustersInFormattedString() const -{ - const std::vector clusters(getClustersSortedByName()); - - const int32_t numClusters(clusters.size()); - if (numClusters <= 0) { - return "No clusters were found."; - } - - const AString numClustersString(" (" - + AString::number(numClusters) - + " total clusters)"); - const int32_t rowCount(numClusters + 1); - const int32_t columnCount(7); - StringTableModel stm(rowCount, columnCount); - stm.setColumnAlignment(0, StringTableModel::ALIGN_RIGHT); - stm.setElement(0, 0, "Key"); - stm.setColumnAlignment(1, StringTableModel::ALIGN_RIGHT); - stm.setElement(0, 1, "Count"); - stm.setColumnAlignment(2, StringTableModel::ALIGN_RIGHT); - stm.setElement(0, 2, "X"); - stm.setColumnAlignment(3, StringTableModel::ALIGN_RIGHT); - stm.setElement(0, 3, "Y"); - stm.setColumnAlignment(4, StringTableModel::ALIGN_RIGHT); - stm.setElement(0, 4, "Z"); - stm.setColumnAlignment(5, StringTableModel::ALIGN_LEFT); - stm.setElement(0, 5, "Location"); - stm.setColumnAlignment(6, StringTableModel::ALIGN_LEFT); - stm.setElement(0, 6, ("Cluster Name" + numClustersString)); - for (int32_t i = 0; i < numClusters; i++) { - const Cluster* c = clusters[i]; - CaretAssert(c); - const int32_t row(i + 1); - stm.setElement(row, 0, c->getKey()); - stm.setElement(row, 1, c->getNumberOfBrainordinates()); - const Vector3D& cog = c->getCenterOfGravityXYZ(); - stm.setElement(row, 2, cog[0]); - stm.setElement(row, 3, cog[1]); - stm.setElement(row, 4, cog[2]); - stm.setElement(row, 5, c->getLocationTypeName()); - stm.setElement(row, 6, c->getName()); - } - - return stm.getInString(); -} - -/** - * Unique keys of all clusters sorted. - */ -std::vector -ClusterContainer::getAllClusterKeys() const -{ - if (m_keysSorted.empty()) { - std::set keys; - for (const auto& c : m_clusters) { - keys.insert(c->getKey()); - } - m_keysSorted.clear(); - m_keysSorted.insert(m_keysSorted.end(), - keys.begin(), keys.end()); - } - return m_keysSorted; -} - -/** - * Merge disjoint clusters with same key based upon sign of x-coordinate from the center-of-gravity. - * @return A container containing the merged clusters. - */ -std::unique_ptr -ClusterContainer::mergeDisjointRightLeftClusters() const -{ - std::unique_ptr clustersOut(new ClusterContainer()); - - const std::vector allKeys(getAllClusterKeys()); - - /* - * Need to split any central clusters into left and right before merging - */ - for (int32_t key : allKeys) { - std::vector keyClusters(getClustersWithKey(key)); - - for (const Cluster* cluster : keyClusters) { - switch (cluster->getLocationType()) { - case Cluster::LocationType::UNKNOWN: - break; - case Cluster::LocationType::CENTRAL: - { - std::vector newClusters(cluster->splitClusterIntoRightAndLeft()); - for (Cluster* c : newClusters) { - clustersOut->addCluster(c); - } - } - break; - case Cluster::LocationType::LEFT: - break; - case Cluster::LocationType::RIGHT: - break; - } - } - } - - /* - * Merge clusters for each key - */ - for (int32_t key : allKeys) { - std::vector keyClusters(getClustersWithKey(key)); - - Cluster* unknownCluster(NULL); - Cluster* centralCluster(NULL); - Cluster* leftCluster(NULL); - Cluster* rightCluster(NULL); - - for (const Cluster* cluster : keyClusters) { - switch (cluster->getLocationType()) { - case Cluster::LocationType::UNKNOWN: - if (unknownCluster != NULL) { - unknownCluster->mergeCoordinates(*cluster); - } - else { - unknownCluster = new Cluster(*cluster); - } - break; - case Cluster::LocationType::CENTRAL: - if (centralCluster != NULL) { - centralCluster->mergeCoordinates(*cluster); - } - else { - centralCluster = new Cluster(*cluster); - } - break; - case Cluster::LocationType::LEFT: - if (leftCluster != NULL) { - leftCluster->mergeCoordinates(*cluster); - } - else { - leftCluster = new Cluster(*cluster); - } - break; - case Cluster::LocationType::RIGHT: - if (rightCluster != NULL) { - rightCluster->mergeCoordinates(*cluster); - } - else { - rightCluster = new Cluster(*cluster); - } - break; - } - } - - if (unknownCluster != NULL) { - clustersOut->addCluster(unknownCluster); - } - if (centralCluster != NULL) { - clustersOut->addCluster(centralCluster); - } - if (leftCluster != NULL) { - clustersOut->addCluster(leftCluster); - } - if (rightCluster != NULL) { - clustersOut->addCluster(rightCluster); - } - } - - return clustersOut; -} - diff --git a/src/Common/ClusterContainer.h b/src/Common/ClusterContainer.h deleted file mode 100644 index 30fd04873..000000000 --- a/src/Common/ClusterContainer.h +++ /dev/null @@ -1,130 +0,0 @@ -#ifndef __CLUSTER_CONTAINER_H__ -#define __CLUSTER_CONTAINER_H__ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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*/ - -#include -#include -#include -#include -#include - -#include "CaretObject.h" -#include "Cluster.h" - - -namespace caret { - - class ClusterContainer : public CaretObject { - - public: - ClusterContainer(); - - virtual ~ClusterContainer(); - - ClusterContainer(const ClusterContainer&) = delete; - - ClusterContainer& operator=(const ClusterContainer&) = delete; - - void addCluster(Cluster* cluster); - - const std::vector& getClustersSortedByKey() const; - - const std::vector& getClustersSortedByName() const; - - std::vector getClustersWithKey(const int32_t key) const; - - std::vector getClustersWithName(const AString& name) const; - - std::vector getAllClusterKeys() const; - - void addKeyThatIsNotInAnyCluster(const int32_t key); - - std::set getKeysThatAreNotInAnyClusters() const; - - void clear(); - - AString getClustersInFormattedString() const; - - std::unique_ptr mergeDisjointRightLeftClusters() const; - - // ADD_NEW_METHODS_HERE - - private: - void clearSortedContainers(); - - void createMultimapClustersSortedByKey() const; - - void createMultimapClustersSortedByName() const; - - /** - * THE container for the clusters. Will delete the clusters at some time. - */ - std::vector> m_clusters; - - /** - * Lazily initialized multimap with pointers to clusters sorted by name. - * Multimap since more than one cluster may have the same name. - * Used to quickly access clusters by name - */ - typedef std::multimap MultimapSortedByName; - typedef MultimapSortedByName::const_iterator MultimapSortedByNameIterator; - mutable MultimapSortedByName m_mapWithClustersSortedByName; - - /* - * Lazily initialized pointers to all clusters sorted by Key - */ - mutable std::vector m_vectorClustersSortedByKey; - - /* - * Lazily initialized pointers to all clusters sorted by name - */ - mutable std::vector m_vectorClustersSortedByName; - - /** - * Lazily initialized multimap with pointers to clusters sorted by key. - * Multimap since more than one cluster may have the same key. - * Used to quickly access clusters by key - */ - typedef std::multimap MultimapSortedByKey; - typedef MultimapSortedByKey::const_iterator MultimapSortedByKeyIterator; - mutable MultimapSortedByKey m_mapWithClustersSortedByKey; - - /** - * Lazily initilaized keys sorted - */ - mutable std::vector m_keysSorted; - - /** - * Keys that do not map to any cluster - */ - std::set m_keysThatAreNotInAnyClusters; - - // ADD_NEW_MEMBERS_HERE - - }; - -#ifdef __CLUSTER_CONTAINER_DECLARE__ - // -#endif // __CLUSTER_CONTAINER_DECLARE__ - -} // namespace -#endif //__CLUSTER_CONTAINER_H__ diff --git a/src/Common/MathFunctions.h b/src/Common/MathFunctions.h index 7ace941b5..0899f4a68 100644 --- a/src/Common/MathFunctions.h +++ b/src/Common/MathFunctions.h @@ -194,9 +194,9 @@ class MathFunctions : public CaretObject { const int32_t offsetCoord3); static float triangleAreaSigned2D( - const float p1[2], - const float p2[2], - const float p3[2]); + const float p1[3], + const float p2[3], + const float p3[3]); static float triangleAreaSigned3D( const float referenceNormal[3], @@ -206,17 +206,17 @@ class MathFunctions : public CaretObject { static void vtkLinearSolve3x3( const float A[3][3], - const float x[3], - float y[3]); + const float x[], + float y[]); static void vtkLUSolve3x3( const float A[3][3], - const int32_t index[3], - float x[3]); + const int32_t index[], + float x[]); static void vtkLUFactor3x3( float A[3][3], - int32_t index[3]); + int32_t index[]); static void vtkInvert3x3(const double A[3][3], double AI[3][3]); @@ -238,20 +238,20 @@ class MathFunctions : public CaretObject { static double vtkDeterminant2x2(double a, double b, double c, double d); static bool lineIntersection2D( - const float p1[2], - const float p2[2], - const float q1[2], - const float q2[2], + const float p1[3], + const float p2[3], + const float q1[3], + const float q2[3], const float tolerance, - float intersectionOut[2]); + float intersectionOut[3]); static bool vectorIntersection2D( - const float p1[2], - const float p2[2], - const float q1[2], - const float q2[2], + const float p1[3], + const float p2[3], + const float q1[3], + const float q2[3], const float tolerance, - float intersectionOut[2]); + float intersectionOut[3]); static bool rayIntersectPlane( const float p1[3], @@ -259,7 +259,7 @@ class MathFunctions : public CaretObject { const float p3[3], const float rayOrigin[3], const float rayVector[3], - float intersectionXYZandDistance[4]); + float intersectionXYZandDistance[3]); static void projectPoint( const float pt[3], diff --git a/src/Common/Vector3D.cxx b/src/Common/Vector3D.cxx index ccaf7fdf5..1e0416cd8 100644 --- a/src/Common/Vector3D.cxx +++ b/src/Common/Vector3D.cxx @@ -222,19 +222,6 @@ Vector3D& Vector3D::operator=(const float* right) return *this; } -bool Vector3D::operator<(const Vector3D& rhs) const -{ - for (int32_t i = 0; i < 3; i++) { - if (m_vec[i] < rhs.m_vec[i]) { - return true; - } - else if (m_vec[i] > rhs.m_vec[i]) { - return false; - } - } - return false; -} - void Vector3D::fill(const float value) { m_vec[0] = value; diff --git a/src/Common/Vector3D.h b/src/Common/Vector3D.h index e13f92645..319b6a606 100644 --- a/src/Common/Vector3D.h +++ b/src/Common/Vector3D.h @@ -55,8 +55,6 @@ namespace caret { float& operator[](const int32_t& index); const float& operator[](const int32_t& index) const; Vector3D& operator=(const float* right); - // comparison operators - bool operator<(const Vector3D& rhs) const; //numerical operators Vector3D& operator+=(const Vector3D& right); Vector3D& operator-=(const Vector3D& right); diff --git a/src/Files/Border.cxx b/src/Files/Border.cxx index 45dace0bc..488133e7a 100644 --- a/src/Files/Border.cxx +++ b/src/Files/Border.cxx @@ -268,7 +268,7 @@ Border::getClassRgba(float rgba[4]) const * Red, green, blue, alpha ranging zero to one. */ void -Border::setClassRgba(const float rgba[4]) +Border::setClassRgba(const float rgba[3]) { m_classRgbaColor[0] = rgba[0]; m_classRgbaColor[1] = rgba[1]; diff --git a/src/Files/CMakeLists.txt b/src/Files/CMakeLists.txt index bde91eb86..07fd0898f 100755 --- a/src/Files/CMakeLists.txt +++ b/src/Files/CMakeLists.txt @@ -17,26 +17,6 @@ if(Qt5_FOUND) include_directories(${Qt5Network_INCLUDE_DIRS}) endif() -# -# With AUTOMOC, do not need to specify files -# that contain Q_OBJECT macro for Qt to process with 'moc' -# (meta-object compiler). -# -IF(WORKBENCH_USE_CMAKE_AUTOMOC) - SET(CMAKE_AUTOMOC ON) -ELSE() - SET(MOC_INPUT_HEADER_FILES - LabelSelectionItemModel.h - ) - - IF(Qt6_FOUND) - QT6_WRAP_CPP(MOC_SOURCE_FILES ${MOC_INPUT_HEADER_FILES}) - ENDIF() - IF(Qt5_FOUND) - QT5_WRAP_CPP(MOC_SOURCE_FILES ${MOC_INPUT_HEADER_FILES}) - ENDIF() -ENDIF() - # # Files Library # @@ -60,8 +40,6 @@ CaretDataFileHelper.h CaretDataFileSelectionModel.h CaretMappableDataFile.h CaretMappableDataFileAndMapSelectionModel.h -CaretMappableDataFileClusterFinder.h -CaretMappableDataFileLabelSelectionDelegate.h CaretSparseFile.h CaretVolumeExtension.h ChartableLineSeriesBrainordinateInterface.h @@ -111,7 +89,6 @@ CziImageResolutionChangeModeEnum.h CziNonLinearTransform.h CziPixelCoordSpaceEnum.h CziUtilities.h -DataFileColorModulateSelector.h DingOntologyTermsFile.h EventCaretDataFilesGet.h EventCaretMappableDataFileMapsViewedInOverlays.h @@ -161,8 +138,6 @@ ImageSpatialUnitsEnum.h LabelDrawingProperties.h LabelDrawingTypeEnum.h LabelFile.h -LabelSelectionItem.h -LabelSelectionItemModel.h MapYokingGroupEnum.h MediaDisplayCoordinateModeEnum.h MediaFile.h @@ -228,8 +203,6 @@ WarpfieldFile.h XmlStreamReaderHelper.h XmlStreamWriterHelper.h -${MOC_SOURCE_FILES} - AffineFile.cxx AffineSeriesFile.cxx AnnotationFile.cxx @@ -248,8 +221,6 @@ CaretDataFileHelper.cxx CaretDataFileSelectionModel.cxx CaretMappableDataFile.cxx CaretMappableDataFileAndMapSelectionModel.cxx -CaretMappableDataFileClusterFinder.cxx -CaretMappableDataFileLabelSelectionDelegate.cxx CaretSparseFile.cxx CaretVolumeExtension.cxx ChartableLineSeriesInterface.cxx @@ -295,7 +266,6 @@ CziImageResolutionChangeModeEnum.cxx CziNonLinearTransform.cxx CziPixelCoordSpaceEnum.cxx CziUtilities.cxx -DataFileColorModulateSelector.cxx DingOntologyTermsFile.cxx EventCaretDataFilesGet.cxx EventCaretMappableDataFileMapsViewedInOverlays.cxx @@ -344,8 +314,6 @@ ImageSpatialUnitsEnum.cxx LabelDrawingProperties.cxx LabelDrawingTypeEnum.cxx LabelFile.cxx -LabelSelectionItem.cxx -LabelSelectionItemModel.cxx MapYokingGroupEnum.cxx MediaDisplayCoordinateModeEnum.cxx MediaFile.cxx diff --git a/src/Files/CaretDataFileSelectionModel.cxx b/src/Files/CaretDataFileSelectionModel.cxx index bb5fa03e8..ed7b23b73 100644 --- a/src/Files/CaretDataFileSelectionModel.cxx +++ b/src/Files/CaretDataFileSelectionModel.cxx @@ -75,9 +75,6 @@ m_structure(structure) case FILE_MODE_MAPS_TO_SAME_BRAINORDINATES: CaretAssert(m_mappableDataFile); break; - case FILE_MODE_MAPS_TO_SAME_BRAINORDINATES_EXCLUDE_SELF: - CaretAssert(m_mappableDataFile); - break; case FILE_MODE_MULTI_STRUCTURE_BORDER_FILES: break; } @@ -112,22 +109,6 @@ CaretDataFileSelectionModel::newInstanceMapsToSameBrainordinates(const CaretMapp return model; } -/** - * Create a new instance of a Caret Data File Selection Model that - * matches a mappable data file's brainordinate mapping. - * - * @param dataFileType - * Type of the data file. - */ -CaretDataFileSelectionModel* -CaretDataFileSelectionModel::newInstanceMapsToSameBrainordinatesExcludeSelf(const CaretMappableDataFile* mappableDataFile) -{ - CaretDataFileSelectionModel* model = new CaretDataFileSelectionModel(mappableDataFile, - StructureEnum::ALL, - FILE_MODE_MAPS_TO_SAME_BRAINORDINATES_EXCLUDE_SELF); - return model; -} - /** * Create a new instance of a Caret Data File Selection Model that @@ -414,9 +395,7 @@ CaretDataFileSelectionModel::getAvailableFiles() const } break; case FILE_MODE_MAPS_TO_SAME_BRAINORDINATES: - case FILE_MODE_MAPS_TO_SAME_BRAINORDINATES_EXCLUDE_SELF: { - const bool excludeSelfFlag(m_fileMode == FILE_MODE_MAPS_TO_SAME_BRAINORDINATES_EXCLUDE_SELF); CaretAssert(m_mappableDataFile); EventCaretMappableDataFilesGet mapFilesGetEvent; EventManager::get()->sendEvent(mapFilesGetEvent.getPointer()); @@ -429,23 +408,15 @@ CaretDataFileSelectionModel::getAvailableFiles() const * in the same file. */ for (auto mf : mapFiles) { - bool doFlag(true); - if (mf == m_mappableDataFile) { - if (excludeSelfFlag) { - doFlag = false; - } - } - if (doFlag) { - switch (m_mappableDataFile->getBrainordinateMappingMatch(mf)) { - case CaretMappableDataFile::BrainordinateMappingMatch::EQUAL: - caretDataFiles.push_back(mf); - break; - case CaretMappableDataFile::BrainordinateMappingMatch::NO: - break; - case CaretMappableDataFile::BrainordinateMappingMatch::SUBSET: - caretDataFiles.push_back(mf); - break; - } + switch (m_mappableDataFile->getBrainordinateMappingMatch(mf)) { + case CaretMappableDataFile::BrainordinateMappingMatch::EQUAL: + caretDataFiles.push_back(mf); + break; + case CaretMappableDataFile::BrainordinateMappingMatch::NO: + break; + case CaretMappableDataFile::BrainordinateMappingMatch::SUBSET: + caretDataFiles.push_back(mf); + break; } } } diff --git a/src/Files/CaretDataFileSelectionModel.h b/src/Files/CaretDataFileSelectionModel.h index 445910a6d..05403a362 100644 --- a/src/Files/CaretDataFileSelectionModel.h +++ b/src/Files/CaretDataFileSelectionModel.h @@ -38,8 +38,6 @@ namespace caret { public: static CaretDataFileSelectionModel* newInstanceMapsToSameBrainordinates(const CaretMappableDataFile* mappableDataFile); - static CaretDataFileSelectionModel* newInstanceMapsToSameBrainordinatesExcludeSelf(const CaretMappableDataFile* mappableDataFile); - static CaretDataFileSelectionModel* newInstanceForCaretDataFileType(const DataFileTypeEnum::Enum dataFileType); static CaretDataFileSelectionModel* newInstanceForCaretDataFileTypes(const std::vector& dataFileTypes); @@ -120,7 +118,6 @@ namespace caret { FILE_MODE_CHARTABLE_MATRIX_PARCEL_INTERFACE, FILE_MODE_DATA_FILE_TYPE_ENUM, FILE_MODE_MAPS_TO_SAME_BRAINORDINATES, - FILE_MODE_MAPS_TO_SAME_BRAINORDINATES_EXCLUDE_SELF, FILE_MODE_MULTI_STRUCTURE_BORDER_FILES }; diff --git a/src/Files/CaretMappableDataFile.cxx b/src/Files/CaretMappableDataFile.cxx index 596e90951..a2aac8120 100644 --- a/src/Files/CaretMappableDataFile.cxx +++ b/src/Files/CaretMappableDataFile.cxx @@ -31,7 +31,6 @@ #include "ChartableTwoFileHistogramChart.h" #include "CiftiMappableConnectivityMatrixDataFile.h" #include "CiftiXML.h" -#include "DataFileColorModulateSelector.h" #include "DataFileContentInformation.h" #include "EventManager.h" #include "FastStatistics.h" @@ -40,8 +39,6 @@ #include "GiftiMetaDataXmlElements.h" #include "Histogram.h" #include "LabelDrawingProperties.h" -#include "LabelSelectionItemModel.h" -#include "CaretMappableDataFileLabelSelectionDelegate.h" #include "NodeAndVoxelColoring.h" #include "PaletteColorMapping.h" #include "SceneClass.h" @@ -124,7 +121,6 @@ CaretMappableDataFile::copyCaretMappableDataFile(const CaretMappableDataFile& cm { *m_labelDrawingProperties = *cmdf.m_labelDrawingProperties; m_mapThresholdFileSelectionModels.clear(); - m_mapColorModulateFileSelectors.clear(); } // note: method is documented in header file @@ -494,37 +490,6 @@ CaretMappableDataFile::saveFileDataToScene(const SceneAttributes* sceneAttribute } } } - - if (isMappedWithLabelTable()) { - SceneObjectMapIntegerKey* lhMap = new SceneObjectMapIntegerKey("LabelHierarchyMap", - SceneObjectDataTypeEnum::SCENE_CLASS); - const int32_t numLH(m_labelHierarchySelectionDelegate.size()); - for (int32_t i = 0; i < numLH; i++) { - if (m_labelHierarchySelectionDelegate[i]) { - const AString lhName("LabelHierarchy_" + AString::number(i)); - lhMap->addClass(i, m_labelHierarchySelectionDelegate[i]->saveToScene(sceneAttributes, - lhName)); - } - } - - if (lhMap->isEmpty()) { - delete lhMap; - lhMap = NULL; - } - else { - sceneClass->addChild(lhMap); - } - } - - if ( ! m_mapColorModulateFileSelectors.empty()) { - SceneObjectMapIntegerKey* sceneModMap = new SceneObjectMapIntegerKey("m_mapColorModulateFileSelectors", - SceneObjectDataTypeEnum::SCENE_CLASS); - for (auto& iter : m_mapColorModulateFileSelectors) { - sceneModMap->addClass(iter.first, - iter.second->saveToScene(sceneAttributes, "modSelElement")); - } - sceneClass->addChild(sceneModMap); - } } /** @@ -853,38 +818,6 @@ CaretMappableDataFile::restoreFileDataFromScene(const SceneAttributes* sceneAttr * no longer being added to the scene. */ } - - if (isMappedWithLabelTable()) { - const SceneObjectMapIntegerKey* lhMap(sceneClass->getMapIntegerKey("LabelHierarchyMap")); - if (lhMap != NULL) { - const std::vector mapIndices(lhMap->getKeys()); - for (int32_t mapIndex : mapIndices) { - if (static_cast(m_labelHierarchySelectionDelegate.size()) < (mapIndex + 1)) { - m_labelHierarchySelectionDelegate.resize(mapIndex + 1); - } - m_labelHierarchySelectionDelegate[mapIndex].reset(new CaretMappableDataFileLabelSelectionDelegate(this, - mapIndex)); - m_labelHierarchySelectionDelegate[mapIndex]->restoreFromScene(sceneAttributes, - lhMap->classValue(mapIndex)); - } - } - } - - { - m_mapColorModulateFileSelectors.clear(); - - const SceneObjectMapIntegerKey* sceneModMap = sceneClass->getMapIntegerKey("m_mapColorModulateFileSelectors"); - if (sceneModMap != NULL) { - const std::vector keys = sceneModMap->getKeys(); - for (auto mapIndex : keys) { - CaretAssert(mapIndex < getNumberOfMaps()); - const SceneClass* modSel = dynamic_cast(sceneModMap->getObject(mapIndex)); - CaretAssert(modSel); - getMapColorModulateFileSelector(mapIndex)->restoreFromScene(sceneAttributes, - modSel); - } - } - } } /** @@ -1119,19 +1052,6 @@ CaretMappableDataFile::addToDataFileContentInformation(DataFileContentInformatio + getMapLabelTable(mapIndex)->toFormattedString(" ") + "\n"); - const int32_t tabZero(0); - const LabelSelectionItemModel* labelModel(getLabelSelectionHierarchyForMapAndTab(mapIndex, - DisplayGroupEnum::DISPLAY_GROUP_TAB, - tabZero)); - if (labelModel != NULL) { - const AString labelModelText(labelModel->toFormattedString(" ")); - if ( ! labelModelText.isEmpty()) { - dataFileInformation.addText(labelTableName - + labelModelText - + "\n"); - } - } - if ( ! haveLabelTableForEachMap) { break; } @@ -1277,10 +1197,8 @@ CaretMappableDataFile::clear() CaretDataFile::clear(); m_chartingDelegate.reset(); - m_labelHierarchySelectionDelegate.clear(); m_mapThresholdFileSelectionModels.clear(); - m_mapColorModulateFileSelectors.clear(); } /** @@ -1531,20 +1449,6 @@ CaretMappableDataFile::getMapThresholdFileSelectionModel(const int32_t mapIndex) return m_mapThresholdFileSelectionModels[mapIndex].get(); } -/** - * @return The modulate file selection model for the given map index. - */ -DataFileColorModulateSelector* -CaretMappableDataFile::getMapColorModulateFileSelector(const int32_t mapIndex) -{ - if (m_mapColorModulateFileSelectors.find(mapIndex) == m_mapColorModulateFileSelectors.end()) { - std::unique_ptr ptr(new DataFileColorModulateSelector(this)); - m_mapColorModulateFileSelectors.insert(std::make_pair(mapIndex, std::move(ptr))); - } - CaretAssert(m_mapColorModulateFileSelectors[mapIndex]); - return m_mapColorModulateFileSelectors[mapIndex].get(); -} - /** * Update the charting delegate after changes (add a row/column, etc.) * are made to the data file. @@ -1559,70 +1463,6 @@ CaretMappableDataFile::updateAfterFileDataChanges() m_applyToAllMapsSelected = isPaletteColorMappingEqualForAllMaps(); } -/** - * @return The clusters for the given map's label table (may be NULL) - * @param mapIndex - * Index of the map - */ -const ClusterContainer* -CaretMappableDataFile::getMapLabelTableClusters(const int32_t /*mapIndex*/) const -{ - return NULL; -} - -/** - * @return Label selection hierarchy for the map in the tab (may be NULL) - * @param mapIndex - * Index of map - * @param displayGroup - * The display group - * @param tabIndex - * Index of the tab if displayGroup is TAB - */ -LabelSelectionItemModel* -CaretMappableDataFile::getLabelSelectionHierarchyForMapAndTab(const int32_t mapIndex, - const DisplayGroupEnum::Enum displayGroup, - const int32_t tabIndex) -{ - if (getDataFileType() == DataFileTypeEnum::VOLUME) { - if (isMappedWithLabelTable()) { - if (static_cast(m_labelHierarchySelectionDelegate.size()) < getNumberOfMaps()) { - m_labelHierarchySelectionDelegate.resize(getNumberOfMaps()); - } - if ( ! m_labelHierarchySelectionDelegate[mapIndex]) { - m_labelHierarchySelectionDelegate[mapIndex].reset(new CaretMappableDataFileLabelSelectionDelegate(this, - mapIndex)); - } - - if (m_labelHierarchySelectionDelegate[mapIndex]) { - return m_labelHierarchySelectionDelegate[mapIndex]->getSelectionModelForMapAndTab(displayGroup, - tabIndex); - } - } - } - return NULL; -} - -/** - * @return Label selection hierarchy for the map in the tab (may be NULL) - * @param mapIndex - * Index of map - * @param displayGroup - * The display group - * @param tabIndex - * Index of the tab if displayGroup is TAB - */ -const LabelSelectionItemModel* -CaretMappableDataFile::getLabelSelectionHierarchyForMapAndTab(const int32_t mapIndex, - const DisplayGroupEnum::Enum displayGroup, - const int32_t tabIndex) const -{ - CaretMappableDataFile* nonConstThis(const_cast(this)); - return nonConstThis->getLabelSelectionHierarchyForMapAndTab(mapIndex, - displayGroup, - tabIndex); -} - /** * @return Is apply palette color mapping to all maps selected. */ diff --git a/src/Files/CaretMappableDataFile.h b/src/Files/CaretMappableDataFile.h index d0d1b7ff6..c0e34f954 100644 --- a/src/Files/CaretMappableDataFile.h +++ b/src/Files/CaretMappableDataFile.h @@ -28,7 +28,6 @@ #include "ChartOneDataTypeEnum.h" #include "CaretPointer.h" #include "CiftiXML.h" -#include "DisplayGroupEnum.h" #include "NiftiEnums.h" #include "PaletteModifiedStatusEnum.h" #include "PaletteNormalizationModeEnum.h" @@ -37,15 +36,11 @@ namespace caret { class ChartDataCartesian; class ChartableTwoFileDelegate; - class ClusterContainer; - class DataFileColorModulateSelector; - class CaretMappableDataFileLabelSelectionDelegate; class FastStatistics; class GiftiMetaData; class GiftiLabelTable; class Histogram; class LabelDrawingProperties; - class LabelSelectionItemModel; class MapFileDataSelector; class PaletteColorMapping; @@ -388,40 +383,7 @@ namespace caret { * not mapped using a label table). */ virtual const GiftiLabelTable* getMapLabelTable(const int32_t mapIndex) const = 0; - - /** - * @return The clusters for the given map's label table (may be NULL) - * @param mapIndex - * Index of the map - */ - virtual const ClusterContainer* getMapLabelTableClusters(const int32_t mapIndex) const; - - /* - * @return Label selection hierarchy for the map in the tab (may be NULL) - * @param mapIndex - * Index of map - * @param displayGroup - * The display group - * @param tabIndex - * Index of the tab if displayGroup is TAB - */ - LabelSelectionItemModel* getLabelSelectionHierarchyForMapAndTab(const int32_t mapIndex, - const DisplayGroupEnum::Enum displayGroup, - const int32_t tabIndex); - /* - * @return Label selection delegate for the map in the tab (may be NULL) - * @param mapIndex - * Index of map - * @param displayGroup - * The display group - * @param tabIndex - * Index of the tab if displayGroup is TAB - */ - const LabelSelectionItemModel* getLabelSelectionHierarchyForMapAndTab(const int32_t mapIndex, - const DisplayGroupEnum::Enum displayGroup, - const int32_t tabIndex) const; - bool isMedialWallLabelInMapLabelTable(const int32_t mapIndex) const; /** @@ -530,10 +492,8 @@ namespace caret { CaretMappableDataFileAndMapSelectionModel* getMapThresholdFileSelectionModel(const int32_t mapIndex); - DataFileColorModulateSelector* getMapColorModulateFileSelector(const int32_t mapIndex); - - /* - * Are all brainordinates in this file also in the given file? + /** + * Are all brainordinates in this file also in the given file? * That is, the brainordinates are equal to or a subset of the brainordinates * in the given file. * @@ -595,12 +555,8 @@ namespace caret { mutable std::unique_ptr m_chartingDelegate; - mutable std::vector> m_labelHierarchySelectionDelegate; - std::vector> m_mapThresholdFileSelectionModels; - std::map> m_mapColorModulateFileSelectors; - /** * Added by WB-781 Apply to All Maps for ColorBar. * This value is saved to scenes but NOT to the data file. diff --git a/src/Files/CaretMappableDataFileAndMapSelectionModel.cxx b/src/Files/CaretMappableDataFileAndMapSelectionModel.cxx index debecdd1c..d48970cb4 100644 --- a/src/Files/CaretMappableDataFileAndMapSelectionModel.cxx +++ b/src/Files/CaretMappableDataFileAndMapSelectionModel.cxx @@ -45,15 +45,10 @@ using namespace caret; * * @param caretMappableDataFile * Mappable data file. - * @param excludeSelfFlag - * If true exclude self from file selection */ -CaretMappableDataFileAndMapSelectionModel::CaretMappableDataFileAndMapSelectionModel(const CaretMappableDataFile* caretMappableDataFile, - const bool excludeSelfFlag) +CaretMappableDataFileAndMapSelectionModel::CaretMappableDataFileAndMapSelectionModel(const CaretMappableDataFile* caretMappableDataFile) : CaretObject(), -m_mode(excludeSelfFlag - ? Mode::MAP_TO_SAME_BRAINORDINATES_EXCLUDE_SELF - : Mode::MAP_TO_SAME_BRAINORDINATES), +m_mode(Mode::MAP_TO_SAME_BRAINORDINATES), m_mappableDataFile(caretMappableDataFile) { std::vector dataFileTypesVector; @@ -267,10 +262,6 @@ CaretMappableDataFileAndMapSelectionModel::performConstruction(const std::vector CaretAssert(m_mappableDataFile); m_caretDataFileSelectionModel = CaretDataFileSelectionModel::newInstanceMapsToSameBrainordinates(m_mappableDataFile); break; - case Mode::MAP_TO_SAME_BRAINORDINATES_EXCLUDE_SELF: - CaretAssert(m_mappableDataFile); - m_caretDataFileSelectionModel = CaretDataFileSelectionModel::newInstanceMapsToSameBrainordinatesExcludeSelf(m_mappableDataFile); - break; case Mode::MATCH_DATA_FILE_TYPES: validateDataFileTypes(); m_caretDataFileSelectionModel = CaretDataFileSelectionModel::newInstanceForCaretDataFileTypes(dataFileTypes, @@ -397,8 +388,6 @@ CaretMappableDataFileAndMapSelectionModel::getAvailableFiles() const switch (m_mode) { case Mode::MAP_TO_SAME_BRAINORDINATES: break; - case Mode::MAP_TO_SAME_BRAINORDINATES_EXCLUDE_SELF: - break; case Mode::MATCH_DATA_FILE_TYPES: break; } @@ -447,8 +436,6 @@ CaretMappableDataFileAndMapSelectionModel::setSelectedFile(CaretMappableDataFile switch (m_mode) { case Mode::MAP_TO_SAME_BRAINORDINATES: break; - case Mode::MAP_TO_SAME_BRAINORDINATES_EXCLUDE_SELF: - break; case Mode::MATCH_DATA_FILE_TYPES: { const DataFileTypeEnum::Enum fileType = selectedFile->getDataFileType(); diff --git a/src/Files/CaretMappableDataFileAndMapSelectionModel.h b/src/Files/CaretMappableDataFileAndMapSelectionModel.h index 588344817..2baf0b0e9 100644 --- a/src/Files/CaretMappableDataFileAndMapSelectionModel.h +++ b/src/Files/CaretMappableDataFileAndMapSelectionModel.h @@ -36,8 +36,7 @@ namespace caret { class CaretMappableDataFileAndMapSelectionModel : public CaretObject, public SceneableInterface { public: - CaretMappableDataFileAndMapSelectionModel(const CaretMappableDataFile* caretMappableDataFile, - const bool excludeSelfFlag = false); + CaretMappableDataFileAndMapSelectionModel(const CaretMappableDataFile* caretMappableDataFile); CaretMappableDataFileAndMapSelectionModel(const DataFileTypeEnum::Enum dataFileType); @@ -110,7 +109,6 @@ namespace caret { private: enum class Mode { MAP_TO_SAME_BRAINORDINATES, - MAP_TO_SAME_BRAINORDINATES_EXCLUDE_SELF, MATCH_DATA_FILE_TYPES }; diff --git a/src/Files/CaretMappableDataFileClusterFinder.cxx b/src/Files/CaretMappableDataFileClusterFinder.cxx deleted file mode 100644 index 4de95684a..000000000 --- a/src/Files/CaretMappableDataFileClusterFinder.cxx +++ /dev/null @@ -1,311 +0,0 @@ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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 __CARET_MAPPABLE_DATA_FILE_CLUSTER_FINDER_DECLARE__ -#include "CaretMappableDataFileClusterFinder.h" -#undef __CARET_MAPPABLE_DATA_FILE_CLUSTER_FINDER_DECLARE__ - -#include "CaretLogger.h" -#include "Cluster.h" -#include "ClusterContainer.h" -#include "GiftiLabel.h" -#include "GiftiLabelTable.h" -#include "CaretAssert.h" -#include "StringTableModel.h" -#include "VolumeFile.h" - -using namespace caret; - - - -/** - * \class caret::CaretMappableDataFileClusterFinder - * \brief Finds cluster in surface (in the future) and volume files for different types of data - * \ingroup Files - */ - -/** - * Constructor. - * @param mapFile - * Map file for searching - * @param findMode - * The find mode - * @param mapIndex - * Index of map that is searched - */ -CaretMappableDataFileClusterFinder::CaretMappableDataFileClusterFinder(const FindMode findMode, - const CaretMappableDataFile* mapFile, - const int32_t mapIndex) -: CaretObject(), -m_findMode(findMode), -m_mapFile(mapFile), -m_mapIndex(mapIndex) -{ - CaretAssert(m_mapFile); - - m_clusterContainer.reset(new ClusterContainer); -} - -/** - * Destructor. - */ -CaretMappableDataFileClusterFinder::~CaretMappableDataFileClusterFinder() -{ -} - -/** - * Run the search for custers - * @return Result of the search. - */ -std::unique_ptr -CaretMappableDataFileClusterFinder::findClusters() -{ - if (m_mapFile == NULL) { - return CaretResult::newInstanceError("Input file is invalid (NULL)."); - } - if ((m_mapIndex < 0) - || (m_mapIndex >= m_mapFile->getNumberOfMaps())) { - return CaretResult::newInstanceError("Map index=" - + AString::number(m_mapIndex) - + " is invalid for " - + m_mapFile->getFileName()); - } - - std::unique_ptr result; - - switch (m_findMode) { - case FindMode::VOLUME_LABEL: - { - const VolumeFile* volumeFile(dynamic_cast(m_mapFile)); - if (volumeFile == NULL) { - return CaretResult::newInstanceError(m_mapFile->getFileName() - + " is not a volume file"); - } - if ( ! volumeFile->isMappedWithLabelTable()) { - return CaretResult::newInstanceError(m_mapFile->getFileName() - + " is not a label volume file"); - } - - result = findLabelVolumeClusters(volumeFile); - } - break; - } - - CaretAssert(result); - return result; -} - -/** - * @return The clusters that were found - */ -const ClusterContainer* -CaretMappableDataFileClusterFinder::getClusterContainer() const -{ - return m_clusterContainer.get(); -} - -/** - * @return A pointer to the cluster contain that the caller takes ownership - * of and is responsible for deleting. After calling this function, calling this - * function again or calling 'getClusterContainer()' will return NULL. - */ -ClusterContainer* -CaretMappableDataFileClusterFinder::takeClusterContainer() -{ - return m_clusterContainer.release(); -} - -/** - * @return The clusters in a formatted text string - */ -AString -CaretMappableDataFileClusterFinder::getClustersInFormattedString() const -{ - if (m_clusterContainer) { - return m_clusterContainer->getClustersInFormattedString(); - } - return AString(""); -} - -/** - * Find clusters in a label volume - * @param volumeFile - * Volume that is searched - * @return The result - */ -std::unique_ptr -CaretMappableDataFileClusterFinder::findLabelVolumeClusters(const VolumeFile* volumeFile) -{ - int64_t dimI, dimJ, dimK, dimComp, dimMaps; - volumeFile->getDimensions(dimI, dimJ, dimK, dimMaps, dimComp); - - const GiftiLabelTable* labelTable(volumeFile->getMapLabelTable(m_mapIndex)); - - const int64_t numVoxels(dimI * dimJ * dimK); - std::vector voxelHasBeenSearchedFlags(numVoxels, 0); - - const float* voxelData(volumeFile->getFrame(m_mapIndex)); - CaretAssert(voxelData); - - /* - * Set unassiged labels as searched - */ - const int32_t unassignedLabelKey(labelTable->getUnassignedLabelKey()); - for (int64_t m = 0; m < numVoxels; m++) { - if (static_cast(voxelData[m]) == unassignedLabelKey) { - CaretAssertVectorIndex(voxelHasBeenSearchedFlags, m); - voxelHasBeenSearchedFlags[m] = 1; - } - } - - const VolumeSpace& volumeSpace(volumeFile->getVolumeSpace()); - - std::set labelKeysWithClusters; - - const int32_t debugKey(-1); - - /* - * Loop through all voxels - */ - for (int64_t i = 0; i < dimI; i++) { - for (int64_t j = 0; j < dimJ; j++) { - for (int64_t k = 0; k < dimK; k++) { - const int64_t voxelOffset(volumeSpace.getIndex(i, j, k)); - CaretAssertVectorIndex(voxelHasBeenSearchedFlags, voxelOffset); - if ( ! voxelHasBeenSearchedFlags[voxelOffset]) { - voxelHasBeenSearchedFlags[voxelOffset] = 1; - - /* - * Search for connected voxels with 'labelKey' - */ - const float labelKey(volumeFile->getValue(i, j, k, m_mapIndex, 0)); - if (labelTable->getLabel(labelKey) == NULL) { - CaretLogInfo("Finding clusters, skipping label key=" - + AString::number(labelKey) - + " that does not have a label"); - continue; - } - - labelKeysWithClusters.insert(labelKey); - - const VoxelIJK voxelIJK(i, j, k); - Vector3D voxelXYZ; - volumeSpace.indexToSpace(voxelIJK, voxelXYZ); - - if (debugKey == labelKey) { - std::cout << "Debug: Starting search for key=" << labelKey - << " Name=" << labelTable->getLabelName(labelKey) - << " Voxel=(" << i << ", " << j << ", " << k << ")" - << " XYZ=" << voxelXYZ.toString() << std::endl; - } - - /* - * Sum is used to compute cluster's center of gravity - */ - std::vector clusterCoordsXYZ; - clusterCoordsXYZ.push_back(voxelXYZ); - - std::vector neighboringVoxelIJKsToSearch; - neighboringVoxelIJKsToSearch.reserve(500); /* avoid reallocations */ - - /* - * Get neighbors of current voxel - */ - volumeFile->getNeigbors26(voxelIJK, - voxelData, - labelKey, - labelKey, - voxelHasBeenSearchedFlags, - neighboringVoxelIJKsToSearch); - - /* - * Loop through neighbors - * 'neighboringVoxelIJKsToSearch' will increase as neighbors of neighbors are added - */ - for (int64_t index = 0; index < static_cast(neighboringVoxelIJKsToSearch.size()); index++) { - CaretAssertVectorIndex(neighboringVoxelIJKsToSearch, index); - const VoxelIJK& vijk(neighboringVoxelIJKsToSearch[index]); - clusterCoordsXYZ.push_back(volumeSpace.indexToSpace(vijk)); - - volumeFile->getNeigbors26(vijk, - voxelData, - labelKey, - labelKey, - voxelHasBeenSearchedFlags, - neighboringVoxelIJKsToSearch); - } - - /* - * Save the cluster - */ - CaretAssert( ! clusterCoordsXYZ.empty()); - Cluster* cluster(new Cluster(labelTable->getLabelName(labelKey), - labelKey, - clusterCoordsXYZ)); - m_clusterContainer->addCluster(cluster); - - if (debugKey == labelKey) { - std::cout << " Cluster: " << cluster->toString() << std::endl << std::flush; - } - } - } - } - } - - const std::set allKeys(labelTable->getKeys()); - std::set labelNames; - for (const int32_t key : allKeys) { - if (labelKeysWithClusters.find(key) == labelKeysWithClusters.end()) { - if (key != unassignedLabelKey) { - m_clusterContainer->addKeyThatIsNotInAnyCluster(key); - labelNames.insert(labelTable->getLabelName(key)); - } - } - } - if ( ! labelNames.empty()) { - AString text("File: " - + volumeFile->getFileNameNoPath() - + " map: " - + volumeFile->getMapName(m_mapIndex) - + " \nLabels are not used by any voxels:"); - for (const AString& name : labelNames) { - text.appendWithNewLine(" " + name); - } - CaretLogInfo(text); - } - - const bool printClustersFlag(false); - if (printClustersFlag) { - const AString txt(m_clusterContainer->getClustersInFormattedString()); - std::cout << txt << std::endl; - auto mergedContainer(m_clusterContainer->mergeDisjointRightLeftClusters()); - std::cout << std::endl << "MERGED" << std::endl; - std::cout << mergedContainer->getClustersInFormattedString() << std::endl; - } - - /* - * Combine left (right) clusters with other left (right) clusters for each key - */ - m_clusterContainer = m_clusterContainer->mergeDisjointRightLeftClusters(); - - return CaretResult::newInstanceSuccess(); -} - diff --git a/src/Files/CaretMappableDataFileClusterFinder.h b/src/Files/CaretMappableDataFileClusterFinder.h deleted file mode 100644 index 0a561049a..000000000 --- a/src/Files/CaretMappableDataFileClusterFinder.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef __CARET_MAPPABLE_DATA_FILE_CLUSTER_FINDER_H__ -#define __CARET_MAPPABLE_DATA_FILE_CLUSTER_FINDER_H__ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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*/ - - -#include -#include -#include - -#include "CaretObject.h" -#include "CaretResult.h" -#include "Vector3D.h" - -namespace caret { - - class CaretMappableDataFile; - class ClusterContainer; - class VolumeFile; - - class CaretMappableDataFileClusterFinder : public CaretObject { - - public: - /** - * Mode for searchinhg - */ - enum class FindMode { - VOLUME_LABEL - }; - - CaretMappableDataFileClusterFinder(const FindMode findMode, - const CaretMappableDataFile* mapFile, - const int32_t mapIndex); - - virtual ~CaretMappableDataFileClusterFinder(); - - CaretMappableDataFileClusterFinder(const CaretMappableDataFileClusterFinder&) = delete; - - CaretMappableDataFileClusterFinder& operator=(const CaretMappableDataFileClusterFinder&) = delete; - - std::unique_ptr findClusters(); - - const ClusterContainer* getClusterContainer() const; - - ClusterContainer* takeClusterContainer(); - - AString getClustersInFormattedString() const; - - // ADD_NEW_METHODS_HERE - - private: - std::unique_ptr findLabelVolumeClusters(const VolumeFile* volumeFile); - - const FindMode m_findMode; - - const CaretMappableDataFile* m_mapFile; - - const int32_t m_mapIndex; - - std::unique_ptr m_clusterContainer; - - // ADD_NEW_MEMBERS_HERE - - }; - -#ifdef __CARET_MAPPABLE_DATA_FILE_CLUSTER_FINDER_DECLARE__ - // -#endif // __CARET_MAPPABLE_DATA_FILE_CLUSTER_FINDER_DECLARE__ - -} // namespace -#endif //__CARET_MAPPABLE_DATA_FILE_CLUSTER_FINDER_H__ diff --git a/src/Files/CaretMappableDataFileLabelSelectionDelegate.cxx b/src/Files/CaretMappableDataFileLabelSelectionDelegate.cxx deleted file mode 100644 index 7bce3bf70..000000000 --- a/src/Files/CaretMappableDataFileLabelSelectionDelegate.cxx +++ /dev/null @@ -1,291 +0,0 @@ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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 __CARET_MAPPABLE_DATA_FILE_LABEL_SELECTION_DELEGATE_DECLARE__ -#include "CaretMappableDataFileLabelSelectionDelegate.h" -#undef __CARET_MAPPABLE_DATA_FILE_LABEL_SELECTION_DELEGATE_DECLARE__ - -#include "BrainConstants.h" -#include "CaretAssert.h" -#include "CaretLogger.h" -#include "CaretMappableDataFile.h" -#include "GiftiLabelTable.h" -#include "LabelSelectionItemModel.h" -#include "SceneClass.h" -#include "SceneClassAssistant.h" -#include "SceneObjectMapIntegerKey.h" - -using namespace caret; - - - -/** - * \class caret::CaretMappableDataFileLabelSelectionDelegate - * \brief Handles label hierarchies for data files - * \ingroup Files - */ - -/** - * Constructor. - * @param mapFile - * The data file - * @param mapIndex - * Index of the map - */ -CaretMappableDataFileLabelSelectionDelegate::CaretMappableDataFileLabelSelectionDelegate(CaretMappableDataFile* mapFile, - const int32_t mapIndex) -: CaretObject(), -m_mapFile(mapFile), -m_mapIndex(mapIndex) -{ - CaretAssert(mapFile); - m_sceneAssistant = std::unique_ptr(new SceneClassAssistant()); - - m_tabSelectionModels.resize(BrainConstants::MAXIMUM_NUMBER_OF_BROWSER_TABS); - m_displayGroupSelectionModels.resize(DisplayGroupEnum::NUMBER_OF_GROUPS); - - if ( ! mapFile->isMappedWithLabelTable()) { - const AString txt ("Attempting to create LabelSelectionModel for non-label file: " - + m_mapFile->getFileName()); - CaretLogSevere(txt); - CaretAssertMessage(0, txt); - } -} - -/** - * Destructor. - */ -CaretMappableDataFileLabelSelectionDelegate::~CaretMappableDataFileLabelSelectionDelegate() -{ -} - -/** - * @return Selection model for the given map and tab, NULL if not valid - * @param displayGroup - * Display group selected in the tab - * @param tabIndex - * Index of the tab - */ -LabelSelectionItemModel* -CaretMappableDataFileLabelSelectionDelegate::getSelectionModelForMapAndTab(const DisplayGroupEnum::Enum displayGroup, - const int32_t tabIndex) -{ - if (displayGroup == DisplayGroupEnum::DISPLAY_GROUP_TAB) { - if ( ! m_tabSelectionModels[tabIndex]) { - m_tabSelectionModels[tabIndex].reset(createModel(displayGroup, - tabIndex)); - } - return m_tabSelectionModels[tabIndex].get(); - } - else { - const int32_t displayGroupIndex(DisplayGroupEnum::toIntegerCode(displayGroup)); - if ( ! m_displayGroupSelectionModels[displayGroupIndex]) { - m_displayGroupSelectionModels[displayGroupIndex].reset(createModel(displayGroup, - tabIndex)); - } - return m_displayGroupSelectionModels[displayGroupIndex].get(); - } - - CaretAssert(0); - return NULL; -} - -/** - * @return A label selection model for the given map, display group, and tab - * @param displayGroup - * Display group selected in the tab - * @param tabIndex - * Index of the tab - */ -LabelSelectionItemModel* -CaretMappableDataFileLabelSelectionDelegate::createModel(const DisplayGroupEnum::Enum displayGroup, - const int32_t tabIndex) -{ - AString mapName(m_mapFile->getMapName(m_mapIndex)); - if (mapName.isEmpty()) { - mapName = AString::number(m_mapIndex + 1); - } - const AString filenameAndMap("File: " - + m_mapFile->getFileNameNoPath() - + " Map: " - + mapName); - GiftiLabelTable* labelTable(m_mapFile->getMapLabelTable(m_mapIndex)); - CaretAssert(labelTable); - - /* - * One LabelSelectionItemModel is created for each tab and display group. - * This prevents logging missing labels more than one time. - */ - const bool logMismatchedLabelsFlag( ! m_modelHasBeenCreatedFlag); - - const ClusterContainer* labelClusterContainer(m_mapFile->getMapLabelTableClusters(m_mapIndex)); - LabelSelectionItemModel* modelOut(new LabelSelectionItemModel(filenameAndMap, - labelTable, - labelClusterContainer, - displayGroup, - tabIndex, - logMismatchedLabelsFlag)); - CaretAssert(modelOut); - m_modelHasBeenCreatedFlag = true; - - return modelOut; -} - -/** - * Get a description of this object's content. - * @return String describing this object's content. - */ -AString -CaretMappableDataFileLabelSelectionDelegate::toString() const -{ - return "CaretMappableDataFileLabelSelectionDelegate"; -} - -/** - * Save information specific to this type of model to the scene. - * - * @param sceneAttributes - * Attributes for the scene. Scenes may be of different types - * (full, generic, etc) and the attributes should be checked when - * saving the scene. - * - * @param instanceName - * Name of instance in the scene. - */ -SceneClass* -CaretMappableDataFileLabelSelectionDelegate::saveToScene(const SceneAttributes* sceneAttributes, - const AString& instanceName) -{ - SceneClass* sceneClass = new SceneClass(instanceName, - "CaretMappableDataFileLabelSelectionDelegate", - 1); - m_sceneAssistant->saveMembers(sceneAttributes, - sceneClass); - const std::vector validTabIndices(sceneAttributes->getIndicesOfTabsForSavingToScene()); - - { - SceneObjectMapIntegerKey* tabSceneMap(new SceneObjectMapIntegerKey("TabModels", - SceneObjectDataTypeEnum::SCENE_CLASS)); - const int32_t numTabs(validTabIndices.size()); - for (int32_t i = 0; i < numTabs; i++) { - CaretAssertVectorIndex(validTabIndices, i); - const int32_t tabIndex(validTabIndices[i]); - if (m_tabSelectionModels[tabIndex]) { - const AString tabName("Tab_" + AString::number(tabIndex)); - tabSceneMap->addClass(tabIndex, - m_tabSelectionModels[tabIndex]->saveToScene(sceneAttributes, - tabName)); - } - } - if (tabSceneMap->isEmpty()) { - delete tabSceneMap; - tabSceneMap = NULL; - } - else { - sceneClass->addChild(tabSceneMap); - } - } - - { - SceneObjectMapIntegerKey* dgSceneMap(new SceneObjectMapIntegerKey("DisplayGroupModels", - SceneObjectDataTypeEnum::SCENE_CLASS)); - for (int32_t i = 0; i < DisplayGroupEnum::NUMBER_OF_GROUPS; i++) { - if (m_displayGroupSelectionModels[i]) { - const AString dgName("DisplayGroup_" + AString::number(i)); - dgSceneMap->addClass(i, - m_displayGroupSelectionModels[i]->saveToScene(sceneAttributes, - dgName)); - } - } - if (dgSceneMap->isEmpty()) { - delete dgSceneMap; - dgSceneMap = NULL; - } - else { - sceneClass->addChild(dgSceneMap); - } - } - - // Uncomment if sub-classes must save to scene - //saveSubClassDataToScene(sceneAttributes, - // sceneClass); - - return sceneClass; -} - -/** - * Restore information specific to the type of model from the scene. - * - * @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 from which model specific information is obtained. - */ -void -CaretMappableDataFileLabelSelectionDelegate::restoreFromScene(const SceneAttributes* sceneAttributes, - const SceneClass* sceneClass) -{ - if (sceneClass == NULL) { - return; - } - - m_sceneAssistant->restoreMembers(sceneAttributes, - sceneClass); - - { - const SceneObjectMapIntegerKey* tabSceneMap(sceneClass->getMapIntegerKey("TabModels")); - if (tabSceneMap != NULL) { - const std::vector tabIndices(tabSceneMap->getKeys()); - for (const int32_t tabIndex : tabIndices) { - LabelSelectionItemModel* model(getSelectionModelForMapAndTab(DisplayGroupEnum::DISPLAY_GROUP_TAB, - tabIndex)); - CaretAssert(model); - model->restoreFromScene(sceneAttributes, - tabSceneMap->classValue(tabIndex)); - } - } - } - - { - const SceneObjectMapIntegerKey* dgSceneMap(sceneClass->getMapIntegerKey("DisplayGroupModels")); - if (dgSceneMap != NULL) { - const std::vector dgIndices(dgSceneMap->getKeys()); - for (const int32_t dgIndex : dgIndices) { - bool validFlag(false); - const DisplayGroupEnum::Enum displayGroup(DisplayGroupEnum::fromIntegerCode(dgIndex, - &validFlag)); - const int32_t invalidTabIndex(-1); - LabelSelectionItemModel* model(getSelectionModelForMapAndTab(displayGroup, - invalidTabIndex)); - CaretAssert(model); - model->restoreFromScene(sceneAttributes, dgSceneMap->classValue(dgIndex)); - } - } - } - //Uncomment if sub-classes must restore from scene - //restoreSubClassDataFromScene(sceneAttributes, - // sceneClass); - -} - diff --git a/src/Files/CaretMappableDataFileLabelSelectionDelegate.h b/src/Files/CaretMappableDataFileLabelSelectionDelegate.h deleted file mode 100644 index 6ead3eafc..000000000 --- a/src/Files/CaretMappableDataFileLabelSelectionDelegate.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef __CARET_MAPPABLE_DATA_FILE_LABEL_SELECTION_DELEGATE_H__ -#define __CARET_MAPPABLE_DATA_FILE_LABEL_SELECTION_DELEGATE_H__ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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*/ - - - -#include - -#include "CaretObject.h" -#include "DisplayGroupEnum.h" -#include "SceneableInterface.h" - - -namespace caret { - class CaretMappableDataFile; - class LabelSelectionItemModel; - class SceneClassAssistant; - - class CaretMappableDataFileLabelSelectionDelegate : public CaretObject, public SceneableInterface { - - public: - CaretMappableDataFileLabelSelectionDelegate(CaretMappableDataFile* mapFile, - const int32_t mapIndex); - - virtual ~CaretMappableDataFileLabelSelectionDelegate(); - - CaretMappableDataFileLabelSelectionDelegate(const CaretMappableDataFileLabelSelectionDelegate&) = delete; - - CaretMappableDataFileLabelSelectionDelegate& operator=(const CaretMappableDataFileLabelSelectionDelegate&) = delete; - - LabelSelectionItemModel* getSelectionModelForMapAndTab(const DisplayGroupEnum::Enum displayGroup, - const int32_t tabIndex); - - // ADD_NEW_METHODS_HERE - - virtual AString toString() const; - - virtual SceneClass* saveToScene(const SceneAttributes* sceneAttributes, - const AString& instanceName); - - virtual void restoreFromScene(const SceneAttributes* sceneAttributes, - const SceneClass* sceneClass); - - - - - - -// If there will be sub-classes of this class that need to save -// and restore data from scenes, these pure virtual methods can -// be uncommented to force their implementation by sub-classes. -// protected: -// virtual void saveSubClassDataToScene(const SceneAttributes* sceneAttributes, -// SceneClass* sceneClass) = 0; -// -// virtual void restoreSubClassDataFromScene(const SceneAttributes* sceneAttributes, -// const SceneClass* sceneClass) = 0; - - private: - LabelSelectionItemModel* createModel(const DisplayGroupEnum::Enum displayGroup, - const int32_t tabIndex); - - CaretMappableDataFile* m_mapFile; - - const int32_t m_mapIndex; - - std::unique_ptr m_sceneAssistant; - - std::vector> m_tabSelectionModels; - - std::vector> m_displayGroupSelectionModels; - - bool m_modelHasBeenCreatedFlag = false; - - // ADD_NEW_MEMBERS_HERE - - }; - -#ifdef __CARET_MAPPABLE_DATA_FILE_LABEL_SELECTION_DELEGATE_DECLARE__ - // -#endif // __CARET_MAPPABLE_DATA_FILE_LABEL_SELECTION_DELEGATE_DECLARE__ - -} // namespace -#endif //__CARET_MAPPABLE_DATA_FILE_LABEL_SELECTION_DELEGATE_H__ diff --git a/src/Files/CaretVolumeExtension.cxx b/src/Files/CaretVolumeExtension.cxx index d6112164c..78649c23c 100644 --- a/src/Files/CaretVolumeExtension.cxx +++ b/src/Files/CaretVolumeExtension.cxx @@ -28,7 +28,6 @@ #include "PaletteColorMappingSaxReader.h" #include "PaletteColorMappingXmlElements.h" #include "PaletteNormalizationModeEnum.h" -#include "CaretHierarchy.h" #include "CaretLogger.h" #include "XmlUnexpectedElementSaxParser.h" #include @@ -116,18 +115,7 @@ void SubvolumeAttributes::writeAsXML(XmlWriter& xmlWriter, int index) xmlWriter.writeStartElement(CARET_VOL_EXT_VOL_INFO, myattrs); if (!m_comment.isEmpty()) xmlWriter.writeElementCData(CARET_VOL_EXT_VI_COMMENT, m_comment); if (!m_guiLabel.isEmpty()) xmlWriter.writeElementCData(CARET_VOL_EXT_VI_GUI_LABEL, m_guiLabel); - GiftiMetaData tempMD = m_metadata; - if (m_labelTable != NULL) - { - const CaretHierarchy& myHier = m_labelTable->getHierarchy(); - if (!myHier.isEmpty()) - { - tempMD.set("CaretHierarchy", myHier.writeXMLToString()); - } else { - tempMD.remove("CaretHierarchy"); - } - m_labelTable->writeAsXML(xmlWriter); //expect the extension to not have stuff it doesn't need, so just write everything it has - } + if (m_labelTable != NULL) m_labelTable->writeAsXML(xmlWriter);//expect the extension to not have stuff it doesn't need, so just write everything it has m_studyMetadata.writeAsXML(xmlWriter); if (m_palette != NULL) m_palette->writeAsXML(xmlWriter); AString typeString; @@ -158,8 +146,8 @@ void SubvolumeAttributes::writeAsXML(XmlWriter& xmlWriter, int index) typeString = "Unknown"; } xmlWriter.writeElementCData(CARET_VOL_EXT_VI_TYPE, typeString); - if ( ! tempMD.isEmpty()) { - tempMD.writeAsXML(xmlWriter); + if ( ! m_metadata.isEmpty()) { + m_metadata.writeAsXML(xmlWriter); } xmlWriter.writeEndElement(); } @@ -272,23 +260,8 @@ void CaretVolumeExtensionXMLReader::endElement(const AString& namespaceURI, cons m_toFill->m_date = elemCharData; break; case VOLUME_INFORMATION: - { - CaretAssertVectorIndex(m_toFill->m_attributes, m_viIndex); - auto thisAttr = m_toFill->m_attributes[m_viIndex]; - try - { - if (thisAttr->m_type == SubvolumeAttributes::LABEL && thisAttr->m_labelTable != NULL && thisAttr->m_metadata.exists("CaretHierarchy")) - { - CaretHierarchy myHier; - myHier.readXML(thisAttr->m_metadata.get("CaretHierarchy")); - thisAttr->m_labelTable->setHierarchy(myHier); - } - } catch (CaretException& e) { - CaretLogWarning("failed to parse hierarchy XML, discarding hierarchy: " + e.whatString()); - } m_viIndex = -1; break; - } case VI_COMMENT: CaretAssertVectorIndex(m_toFill->m_attributes, m_viIndex); m_toFill->m_attributes[m_viIndex]->m_comment = elemCharData; diff --git a/src/Files/CiftiMappableDataFile.cxx b/src/Files/CiftiMappableDataFile.cxx index 6125a1091..bdd6d3e2c 100644 --- a/src/Files/CiftiMappableDataFile.cxx +++ b/src/Files/CiftiMappableDataFile.cxx @@ -3821,8 +3821,10 @@ CiftiMappableDataFile::getNonZeroVoxelCoordinateBoundingBox(const int32_t /*mapI * The slice plane. * @param sliceIndex * Index of the slice. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param rgbaOut * Output containing the rgba values (must have been allocated * by caller to sufficient count of elements in the slice). @@ -3833,7 +3835,8 @@ int64_t CiftiMappableDataFile::getVoxelColorsForSliceInMap(const int32_t mapIndex, const VolumeSliceViewPlaneEnum::Enum slicePlane, const int64_t sliceIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const { CaretAssertVectorIndex(m_mapContent, @@ -3962,7 +3965,7 @@ CiftiMappableDataFile::getVoxelColorsForSliceInMap(const int32_t mapIndex, if (label != NULL) { const GroupAndNameHierarchyItem* item = label->getGroupNameSelectionItem(); CaretAssert(item); - if (item->isSelected(tabDrawingInfo) == false) { + if (item->isSelected(displayGroup, tabIndex) == false) { alpha = 0; } } @@ -4008,7 +4011,7 @@ CiftiMappableDataFile::getVoxelColorsForSliceInMap(const int32_t mapIndex, if (label != NULL) { const GroupAndNameHierarchyItem* item = label->getGroupNameSelectionItem(); CaretAssert(item); - if (item->isSelected(tabDrawingInfo) == false) { + if (item->isSelected(displayGroup, tabIndex) == false) { alpha = 0; } } @@ -4054,7 +4057,7 @@ CiftiMappableDataFile::getVoxelColorsForSliceInMap(const int32_t mapIndex, if (label != NULL) { const GroupAndNameHierarchyItem* item = label->getGroupNameSelectionItem(); CaretAssert(item); - if (item->isSelected(tabDrawingInfo) == false) { + if (item->isSelected(displayGroup, tabIndex) == false) { alpha = 0; } } @@ -4090,8 +4093,10 @@ CiftiMappableDataFile::getVoxelColorsForSliceInMap(const int32_t mapIndex, * Number of rows. * @param numberOfColumns * Number of columns. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param rgbaOut * RGBA color components out. * @return @@ -4104,7 +4109,8 @@ CiftiMappableDataFile::getVoxelColorsForSliceInMap(const int32_t mapIndex, const int64_t columnStepIJK[3], const int64_t numberOfRows, const int64_t numberOfColumns, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const { CaretAssertVectorIndex(m_mapContent, @@ -4180,7 +4186,7 @@ CiftiMappableDataFile::getVoxelColorsForSliceInMap(const int32_t mapIndex, if (label != NULL) { const GroupAndNameHierarchyItem* item = label->getGroupNameSelectionItem(); CaretAssert(item); - if (item->isSelected(tabDrawingInfo) == false) { + if (item->isSelected(displayGroup, tabIndex) == false) { alpha = 0; } } @@ -4241,8 +4247,10 @@ CiftiMappableDataFile::getVoxelColorsForSliceInMap(const int32_t mapIndex, * Indices of voxel for last corner of sub-slice (inclusive). * @param voxelCountIJK * Voxel counts for each axis. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param rgbaOut * Output containing the rgba values (must have been allocated * by caller to sufficient count of elements in the slice). @@ -4256,7 +4264,8 @@ CiftiMappableDataFile::getVoxelColorsForSubSliceInMap(const int32_t mapIndex, const int64_t firstCornerVoxelIndex[3], const int64_t lastCornerVoxelIndex[3], const int64_t voxelCountIJK[3], - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const { CaretAssertVectorIndex(m_mapContent, @@ -4411,7 +4420,7 @@ CiftiMappableDataFile::getVoxelColorsForSubSliceInMap(const int32_t mapIndex, if (label != NULL) { const GroupAndNameHierarchyItem* item = label->getGroupNameSelectionItem(); CaretAssert(item); - if (item->isSelected(tabDrawingInfo) == false) { + if (item->isSelected(displayGroup, tabIndex) == false) { alpha = 0; } } @@ -4483,7 +4492,7 @@ CiftiMappableDataFile::getVoxelColorsForSubSliceInMap(const int32_t mapIndex, if (label != NULL) { const GroupAndNameHierarchyItem* item = label->getGroupNameSelectionItem(); CaretAssert(item); - if (item->isSelected(tabDrawingInfo) == false) { + if (item->isSelected(displayGroup, tabIndex) == false) { alpha = 0; } } @@ -4556,7 +4565,7 @@ CiftiMappableDataFile::getVoxelColorsForSubSliceInMap(const int32_t mapIndex, if (label != NULL) { const GroupAndNameHierarchyItem* item = label->getGroupNameSelectionItem(); CaretAssert(item); - if (item->isSelected(tabDrawingInfo) == false) { + if (item->isSelected(displayGroup, tabIndex) == false) { alpha = 0; } } @@ -4599,18 +4608,25 @@ CiftiMappableDataFile::getVoxelColorsForSubSliceInMap(const int32_t mapIndex, * * @param mapIndex * Index of the map. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. + * @param rgbaOut + * Output containing the rgba values (must have been allocated + * by caller to sufficient count of elements in the slice). * @return * Graphics primitive or NULL if unable to draw */ GraphicsPrimitiveV3fT3f* CiftiMappableDataFile::getVolumeDrawingTriangleStripPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo) const + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex) const { return m_graphicsPrimitiveManager->getVolumeDrawingPrimitiveForMap(VolumeGraphicsPrimitiveManager::PrimitiveShape::TRIANGLE_STRIP, mapIndex, - tabDrawingInfo); + displayGroup, + tabIndex); } /** @@ -4618,18 +4634,25 @@ CiftiMappableDataFile::getVolumeDrawingTriangleStripPrimitive(const int32_t mapI * * @param mapIndex * Index of the map. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. + * @param rgbaOut + * Output containing the rgba values (must have been allocated + * by caller to sufficient count of elements in the slice). * @return * Graphics primitive or NULL if unable to draw */ GraphicsPrimitiveV3fT3f* CiftiMappableDataFile::getVolumeDrawingTriangleFanPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo) const + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex) const { return m_graphicsPrimitiveManager->getVolumeDrawingPrimitiveForMap(VolumeGraphicsPrimitiveManager::PrimitiveShape::TRIANGLE_FAN, mapIndex, - tabDrawingInfo); + displayGroup, + tabIndex); } /** @@ -4637,26 +4660,35 @@ CiftiMappableDataFile::getVolumeDrawingTriangleFanPrimitive(const int32_t mapInd * * @param mapIndex * Index of the map. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. + * @param rgbaOut + * Output containing the rgba values (must have been allocated + * by caller to sufficient count of elements in the slice). * @return * Graphics primitive or NULL if unable to draw */ GraphicsPrimitiveV3fT3f* CiftiMappableDataFile::getVolumeDrawingTrianglesPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo) const + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex) const { return m_graphicsPrimitiveManager->getVolumeDrawingPrimitiveForMap(VolumeGraphicsPrimitiveManager::PrimitiveShape::TRIANGLES, mapIndex, - tabDrawingInfo); + displayGroup, + tabIndex); } /** * Create a graphics primitive for showing part of volume that intersects with an image from histology * @param mapIndex * Index of the map. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param mediaFile * The medial file for drawing histology * @param volumeMappingMode @@ -4670,7 +4702,8 @@ CiftiMappableDataFile::getVolumeDrawingTrianglesPrimitive(const int32_t mapIndex */ GraphicsPrimitive* CiftiMappableDataFile::getHistologyImageIntersectionPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, const MediaFile* mediaFile, const VolumeToImageMappingModeEnum::Enum volumeMappingMode, const float volumeSliceThickness, @@ -4678,7 +4711,8 @@ CiftiMappableDataFile::getHistologyImageIntersectionPrimitive(const int32_t mapI { return m_graphicsPrimitiveManager->getImageIntersectionDrawingPrimitiveForMap(mediaFile, mapIndex, - tabDrawingInfo, + displayGroup, + tabIndex, volumeMappingMode, volumeSliceThickness, errorMessageOut); @@ -4688,8 +4722,10 @@ CiftiMappableDataFile::getHistologyImageIntersectionPrimitive(const int32_t mapI * Create a graphics primitive for showing part of volume that intersects with an image from histology * @param mapIndex * Index of the map. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param histologySlice * The histology slice being drawn * @param volumeMappingMode @@ -4703,7 +4739,8 @@ CiftiMappableDataFile::getHistologyImageIntersectionPrimitive(const int32_t mapI */ std::vector CiftiMappableDataFile::getHistologySliceIntersectionPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, const HistologySlice* histologySlice, const VolumeToImageMappingModeEnum::Enum volumeMappingMode, const float volumeSliceThickness, @@ -4711,7 +4748,8 @@ CiftiMappableDataFile::getHistologySliceIntersectionPrimitive(const int32_t mapI { return m_graphicsPrimitiveManager->getImageIntersectionDrawingPrimitiveForMap(histologySlice, mapIndex, - tabDrawingInfo, + displayGroup, + tabIndex, volumeMappingMode, volumeSliceThickness, errorMessageOut); @@ -4737,6 +4775,10 @@ CiftiMappableDataFile::getHistologySliceIntersectionPrimitive(const int32_t mapI * Third dimension (k). * @param mapIndex * Time/map index. + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param rgbaOut * Output containing RGBA values for voxel at the given indices. */ @@ -4746,14 +4788,16 @@ CiftiMappableDataFile::getVoxelColorInMapForLabelData(const std::vector& const int64_t indexIn2, const int64_t indexIn3, const int64_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t rgbaOut[4]) const { getVoxelColorInMap(indexIn1, indexIn2, indexIn3, mapIndex, - tabDrawingInfo, + displayGroup, + tabIndex, rgbaOut); @@ -4777,7 +4821,7 @@ CiftiMappableDataFile::getVoxelColorInMapForLabelData(const std::vector& if (label != NULL) { const GroupAndNameHierarchyItem* item = label->getGroupNameSelectionItem(); if (item != NULL) { - if (item->isSelected(tabDrawingInfo) == false) { + if (item->isSelected(displayGroup, tabIndex) == false) { rgbaOut[3] = 0; } } @@ -4800,8 +4844,10 @@ CiftiMappableDataFile::getVoxelColorInMapForLabelData(const std::vector& * Third dimension (k). * @param mapIndex * Time/map index. - * @param tabDrawingInfo - * Info about drawing in tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param rgbaOut * Output containing RGBA values for voxel at the given indices. */ @@ -4810,7 +4856,8 @@ CiftiMappableDataFile::getVoxelColorInMap(const int64_t indexIn1, const int64_t indexIn2, const int64_t indexIn3, const int64_t mapIndex, - const TabDrawingInfo& /*tabDrawingInfo*/, + const DisplayGroupEnum::Enum /*displayGroup*/, + const int32_t /*tabIndex*/, uint8_t rgbaOut[4]) const { rgbaOut[0] = 0; diff --git a/src/Files/CiftiMappableDataFile.h b/src/Files/CiftiMappableDataFile.h index 4219b218a..d4ff98e3a 100644 --- a/src/Files/CiftiMappableDataFile.h +++ b/src/Files/CiftiMappableDataFile.h @@ -353,7 +353,8 @@ namespace caret { virtual int64_t getVoxelColorsForSliceInMap(const int32_t mapIndex, const VolumeSliceViewPlaneEnum::Enum slicePlane, const int64_t sliceIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const override; int64_t getVoxelColorsForSliceInMap(const int32_t mapIndex, @@ -362,7 +363,8 @@ namespace caret { const int64_t columnStepIJK[3], const int64_t numberOfRows, const int64_t numberOfColumns, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const override; virtual int64_t getVoxelColorsForSubSliceInMap(const int32_t mapIndex, @@ -371,14 +373,16 @@ namespace caret { const int64_t firstCornerVoxelIndex[3], const int64_t lastCornerVoxelIndex[3], const int64_t voxelCountIJK[3], - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const override; virtual void getVoxelColorInMap(const int64_t indexIn1, const int64_t indexIn2, const int64_t indexIn3, const int64_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t rgbaOut[4]) const override; virtual void getVoxelColorInMap(const int64_t indexIn1, @@ -392,27 +396,33 @@ namespace caret { const int64_t indexIn2, const int64_t indexIn3, const int64_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t rgbaOut[4]) const; virtual GraphicsPrimitiveV3fT3f* getVolumeDrawingTriangleStripPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo) const override; + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex) const override; virtual GraphicsPrimitiveV3fT3f* getVolumeDrawingTriangleFanPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo) const override; + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex) const override; virtual GraphicsPrimitiveV3fT3f* getVolumeDrawingTrianglesPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo) const override; + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex) const override; virtual GraphicsPrimitive* getHistologyImageIntersectionPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, const MediaFile* mediaFile, const VolumeToImageMappingModeEnum::Enum volumeMappingMode, const float volumeSliceThickness, AString& errorMessageOut) const override; virtual std::vector getHistologySliceIntersectionPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, const HistologySlice* histologySlice, const VolumeToImageMappingModeEnum::Enum volumeMappingMode, const float volumeSliceThickness, diff --git a/src/Files/CiftiParcelScalarFile.cxx b/src/Files/CiftiParcelScalarFile.cxx index 9f5737bec..8c7a0cbf0 100644 --- a/src/Files/CiftiParcelScalarFile.cxx +++ b/src/Files/CiftiParcelScalarFile.cxx @@ -27,7 +27,6 @@ #include "ChartDataCartesian.h" #include "ChartMatrixDisplayProperties.h" #include "CiftiConnectivityMatrixParcelDynamicFile.h" -#include "CiftiConnectivityMatrixParcelFile.h" #include "CiftiFile.h" #include "CiftiParcelReordering.h" #include "CiftiParcelReorderingModel.h" @@ -54,10 +53,11 @@ using namespace caret; */ /** - * Create a Cifti Parcel Scalar File using the currently loaded row in a Cifti matrix file + * Create a Cifti Parcel Scalar File using the currently loaded row in a Cifti + * connectivity parcel dynamic file * - * @param sourceCiftiMatrixFile - * The connectivity matrix file. + * @param sourceParcelDynamicFile + * The parcel dynamic file. * @param destinationDirectory * Directory in which file is placed if the input matrix file is not * in a valid local (user's file system) directory. @@ -69,34 +69,22 @@ using namespace caret; */ CiftiParcelScalarFile* -CiftiParcelScalarFile::newInstanceFromRowInCiftiConnectivityMatrixFile(const CiftiMappableConnectivityMatrixDataFile* sourceCiftiMatrixFile, - const AString& destinationDirectory, - AString& errorMessageOut) +CiftiParcelScalarFile::newInstanceFromRowInCiftiParcelDynamicFile(const CiftiConnectivityMatrixParcelDynamicFile* sourceParcelDynamicFile, + const AString& destinationDirectory, + AString& errorMessageOut) { - CaretAssert(sourceCiftiMatrixFile); + CaretAssert(sourceParcelDynamicFile); errorMessageOut.clear(); - const CiftiConnectivityMatrixParcelDynamicFile* parcelDynamicFile = - dynamic_cast(sourceCiftiMatrixFile); - const CiftiConnectivityMatrixParcelFile* parcelMatrixFile = - dynamic_cast(sourceCiftiMatrixFile); - if ((parcelDynamicFile != NULL) - || (parcelMatrixFile != NULL)) { - /* ok, acceptable file type */ - } - else { - errorMessageOut = "Only Cifti Parcel Matrix and Parcel Dynamic Files are supported for conversion to Cifti Scalar Files."; - return NULL; - } - const CiftiFile* sourceCiftiFile = sourceCiftiMatrixFile->m_ciftiFile; + const CiftiFile* sourceCiftiFile = sourceParcelDynamicFile->m_ciftiFile; - if (sourceCiftiMatrixFile->getNumberOfMaps() <= 0) { + if (sourceParcelDynamicFile->getNumberOfMaps() <= 0) { errorMessageOut = "No data appears to be loaded in the Cifti Matrix File (No Maps)."; return NULL; } std::vector data; - sourceCiftiMatrixFile->getMapData(0, data); + sourceParcelDynamicFile->getMapData(0, data); if (data.empty()) { errorMessageOut = "No data appears to be loaded in the Cifti Matrix File (mapData empty)."; return NULL; @@ -120,7 +108,7 @@ CiftiParcelScalarFile::newInstanceFromRowInCiftiConnectivityMatrixFile(const Cif CiftiScalarsMap scalarsMap; scalarsMap.setLength(1); scalarsMap.setMapName(0, - sourceCiftiMatrixFile->getMapName(0)); + sourceParcelDynamicFile->getMapName(0)); ciftiScalarXML.setMap(CiftiXML::ALONG_ROW, scalarsMap); ciftiScalarXML.setMap(CiftiXML::ALONG_COLUMN, @@ -144,7 +132,7 @@ CiftiParcelScalarFile::newInstanceFromRowInCiftiConnectivityMatrixFile(const Cif /* * May need to convert a remote path to a local path */ - FileInformation initialFileNameInfo(sourceCiftiMatrixFile->getFileName()); + FileInformation initialFileNameInfo(sourceParcelDynamicFile->getFileName()); const AString scalarFileName = initialFileNameInfo.getAsLocalAbsoluteFilePath(destinationDirectory, parcelScalarFile->getDataFileType()); @@ -156,7 +144,7 @@ CiftiParcelScalarFile::newInstanceFromRowInCiftiConnectivityMatrixFile(const Cif scalarFileInfo.getFileComponents(thePath, theName, theExtension); - theName.append("_" + sourceCiftiMatrixFile->getRowLoadedText()); + theName.append("_" + sourceParcelDynamicFile->getRowLoadedText()); const AString newFileName = FileInformation::assembleFileComponents(thePath, theName, theExtension); @@ -169,7 +157,7 @@ CiftiParcelScalarFile::newInstanceFromRowInCiftiConnectivityMatrixFile(const Cif */ PaletteColorMapping* scalarPalette = parcelScalarFile->getMapPaletteColorMapping(0); CaretAssert(scalarPalette); - const PaletteColorMapping* densePalette = sourceCiftiMatrixFile->getMapPaletteColorMapping(0); + const PaletteColorMapping* densePalette = sourceParcelDynamicFile->getMapPaletteColorMapping(0); CaretAssert(densePalette); scalarPalette->copy(*densePalette, true); diff --git a/src/Files/CiftiParcelScalarFile.h b/src/Files/CiftiParcelScalarFile.h index 4d153aa1a..af9ddff8a 100644 --- a/src/Files/CiftiParcelScalarFile.h +++ b/src/Files/CiftiParcelScalarFile.h @@ -28,7 +28,7 @@ #include "CiftiMappableDataFile.h" namespace caret { - class CiftiMappableConnectivityMatrixDataFile; + class CiftiConnectivityMatrixParcelDynamicFile; class CiftiParcelReorderingModel; class SceneClassAssistant; @@ -38,9 +38,9 @@ namespace caret { public ChartableMatrixParcelInterface { public: - static CiftiParcelScalarFile* newInstanceFromRowInCiftiConnectivityMatrixFile(const CiftiMappableConnectivityMatrixDataFile* sourceCiftiMatrixFile, - const AString& destinationDirectory, - AString& errorMessageOut); + static CiftiParcelScalarFile* newInstanceFromRowInCiftiParcelDynamicFile(const CiftiConnectivityMatrixParcelDynamicFile* sourceParcelDynamicFile, + const AString& destinationDirectory, + AString& errorMessageOut); CiftiParcelScalarFile(); diff --git a/src/Files/DataFileColorModulateSelector.cxx b/src/Files/DataFileColorModulateSelector.cxx deleted file mode 100644 index 89f5c9eb1..000000000 --- a/src/Files/DataFileColorModulateSelector.cxx +++ /dev/null @@ -1,207 +0,0 @@ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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 __DATA_FILE_COLOR_MODULATE_SELECTOR_DECLARE__ -#include "DataFileColorModulateSelector.h" -#undef __DATA_FILE_COLOR_MODULATE_SELECTOR_DECLARE__ - -#include "CaretAssert.h" -#include "CaretMappableDataFile.h" -#include "CaretMappableDataFileAndMapSelectionModel.h" -#include "SceneClassAssistant.h" -#include "SceneClass.h" -#include "VolumeFile.h" - -using namespace caret; - -/** - * \class caret::DataFileColorModulateSelector - * \brief Items used to modulate a file's coloring with another file - * \ingroup Files - */ - -/** - * Constructor. - * @param mapFile - * File that is modulated - * @param mapIndex - * Index of map - */ -DataFileColorModulateSelector::DataFileColorModulateSelector(CaretMappableDataFile* mapFile) -: CaretObject() -{ - const bool excludeSelfFlag(true); - m_selectionModel.reset(new CaretMappableDataFileAndMapSelectionModel(mapFile, - excludeSelfFlag)); - - m_sceneAssistant.reset(new SceneClassAssistant()); - m_sceneAssistant->add("m_enabledFlag", - &m_enabledFlag); -} - -/** - * Destructor. - */ -DataFileColorModulateSelector::~DataFileColorModulateSelector() -{ -} - -/** - * @return Pointer to selected mappable file selected, else NULL. - */ -const CaretMappableDataFile* -DataFileColorModulateSelector::getSelectedMapFile() const -{ - return m_selectionModel->getSelectedFile(); -} - -/** - * @return Pointer to volume file if a volume file is selected, else NULL. - */ -const VolumeFile* -DataFileColorModulateSelector::getSelectedVolumeFile() const -{ - const VolumeFile* volumeFile(NULL); - - const CaretMappableDataFile* mapFile(getSelectedMapFile()); - if (mapFile != NULL) { - volumeFile = dynamic_cast(mapFile); - } - - return volumeFile; -} - -/** - * @return Index of map in selected file or negative if no file selected - */ -int32_t -DataFileColorModulateSelector::getSelectedMapIndex() const -{ - return m_selectionModel->getSelectedMapIndex(); -} - -/** - * @return The selection model - */ -CaretMappableDataFileAndMapSelectionModel* -DataFileColorModulateSelector::getSelectionModel() -{ - return m_selectionModel.get(); -} - -/** - * @return The selection model - */ -const CaretMappableDataFileAndMapSelectionModel* -DataFileColorModulateSelector::getSelectionModel() const -{ - return m_selectionModel.get(); -} - -/** - * @return True if enabled - */ -bool -DataFileColorModulateSelector::isEnabled() const -{ - return m_enabledFlag; -} - -/** - * Set enabled status - * @param enabled - * New enabled status - */ -void -DataFileColorModulateSelector::setEnabled(const bool enabled) -{ - m_enabledFlag = enabled; -} - -/** - * Create a scene for an instance of a class. - * - * @param sceneAttributes - * Attributes for the scene. Scenes may be of different types - * (full, generic, etc) and the attributes should be checked when - * saving the scene. - * - * @param instanceName - * Name of the class' instance. - * - * @return Pointer to SceneClass object representing the state of - * this object. Under some circumstances a NULL pointer may be - * returned. Caller will take ownership of returned object. - */ -SceneClass* -DataFileColorModulateSelector::saveToScene(const SceneAttributes* sceneAttributes, - const AString& instanceName) -{ - SceneClass* sceneClass = new SceneClass(instanceName, - "DataFileColorModulateSelector", - 1); - - m_sceneAssistant->saveMembers(sceneAttributes, - sceneClass); - - sceneClass->addClass(m_selectionModel->saveToScene(sceneAttributes, - "m_selectionModel")); - - return sceneClass; -} - -/** - * Restore the state of an instance of a class. - * - * @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. May be NULL for some types of scenes. - */ -void -DataFileColorModulateSelector::restoreFromScene(const SceneAttributes* sceneAttributes, - const SceneClass* sceneClass) -{ - if (sceneClass == NULL) { - return; - } - - m_sceneAssistant->restoreMembers(sceneAttributes, - sceneClass); - - m_selectionModel->restoreFromScene(sceneAttributes, - sceneClass->getClass("m_selectionModel")); -} - -/** - * Get a description of this object's content. - * @return String describing this object's content. - */ -AString -DataFileColorModulateSelector::toString() const -{ - return "DataFileColorModulateSelector"; -} - diff --git a/src/Files/DataFileColorModulateSelector.h b/src/Files/DataFileColorModulateSelector.h deleted file mode 100644 index a94d2f7ed..000000000 --- a/src/Files/DataFileColorModulateSelector.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef __DATA_FILE_COLOR_MODULATE_SELECTOR_H__ -#define __DATA_FILE_COLOR_MODULATE_SELECTOR_H__ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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*/ - - - -#include - -#include "CaretObject.h" -#include "SceneableInterface.h" - -namespace caret { - - class CaretMappableDataFile; - class CaretMappableDataFileAndMapSelectionModel; - class SceneClassAssistant; - class VolumeFile; - - class DataFileColorModulateSelector : public CaretObject, SceneableInterface { - - public: - DataFileColorModulateSelector(CaretMappableDataFile* mapFile); - - virtual ~DataFileColorModulateSelector(); - - DataFileColorModulateSelector(const DataFileColorModulateSelector&) = delete; - - DataFileColorModulateSelector& operator=(const DataFileColorModulateSelector&) = delete; - - const CaretMappableDataFile* getSelectedMapFile() const; - - const VolumeFile* getSelectedVolumeFile() const; - - int32_t getSelectedMapIndex() const; - - CaretMappableDataFileAndMapSelectionModel* getSelectionModel(); - - const CaretMappableDataFileAndMapSelectionModel* getSelectionModel() const; - - bool isEnabled() const; - - void setEnabled(const bool enabled); - - virtual SceneClass* saveToScene(const SceneAttributes* sceneAttributes, - const AString& instanceName); - - virtual void restoreFromScene(const SceneAttributes* sceneAttributes, - const SceneClass* sceneClass); - - // ADD_NEW_METHODS_HERE - - virtual AString toString() const; - - private: - std::unique_ptr m_selectionModel = NULL; - - bool m_enabledFlag = false; - - std::unique_ptr m_sceneAssistant; - - // ADD_NEW_MEMBERS_HERE - - }; - -#ifdef __DATA_FILE_COLOR_MODULATE_SELECTOR_DECLARE__ - // -#endif // __DATA_FILE_COLOR_MODULATE_SELECTOR_DECLARE__ - -} // namespace -#endif //__DATA_FILE_COLOR_MODULATE_SELECTOR_H__ diff --git a/src/Files/Focus.cxx b/src/Files/Focus.cxx index 0d9f2834d..101080fb2 100644 --- a/src/Files/Focus.cxx +++ b/src/Files/Focus.cxx @@ -435,7 +435,7 @@ Focus::getClassRgba(float rgba[4]) const * @param rgba * Red, green, blue, alpha ranging zero to one. */ -void Focus::setClassRgba(const float rgba[4]) +void Focus::setClassRgba(const float rgba[3]) { m_classRgbaColor[0] = rgba[0]; m_classRgbaColor[1] = rgba[1]; diff --git a/src/Files/GroupAndNameHierarchyItem.cxx b/src/Files/GroupAndNameHierarchyItem.cxx index 06709b81a..30841b7de 100644 --- a/src/Files/GroupAndNameHierarchyItem.cxx +++ b/src/Files/GroupAndNameHierarchyItem.cxx @@ -32,7 +32,6 @@ #include "SceneClass.h" #include "SceneClassArray.h" #include "SceneClassAssistant.h" -#include "TabDrawingInfo.h" #include @@ -428,18 +427,6 @@ GroupAndNameHierarchyItem::removeChild(GroupAndNameHierarchyItem* child) } } -/** - * @return True if selected - * @param tabDrawingInfo - * Info for drawing tab - */ -bool -GroupAndNameHierarchyItem::isSelected(const TabDrawingInfo& tabDrawingInfo) const -{ - return isSelected(tabDrawingInfo.getDisplayGroup(), - tabDrawingInfo.getTabIndex()); -} - /** * Is this item selected? * @@ -468,23 +455,6 @@ GroupAndNameHierarchyItem::isSelected(const DisplayGroupEnum::Enum displayGroup, return m_selectedInDisplayGroup[displayIndex]; } -/** - * Get the "check state" of an item. - * @param tabDrawingInfo - * Info for drawing tab - * @return - * CHECKED if this item and ALL of its children are selected. - * PARTIALLY_CHECKED if this item is selected and any of its - * children, but not all of its children, are selected. - * UNCHECKED if this item is not selected. - */ -GroupAndNameCheckStateEnum::Enum -GroupAndNameHierarchyItem::getCheckState(const TabDrawingInfo& tabDrawingInfo) const -{ - return getCheckState(tabDrawingInfo.getDisplayGroup(), - tabDrawingInfo.getTabIndex()); -} - /** * Get the "check state" of an item. * @@ -537,24 +507,6 @@ GroupAndNameHierarchyItem::getCheckState(const DisplayGroupEnum::Enum displayGro return GroupAndNameCheckStateEnum::UNCHECKED; } -/** - * Set the selected status of this item only. It does not alter - * the status of ancestors and children. - * - * @param tabDrawingInfo - * Info for drawing tab - * @param status - * True if item is selected, else false. - */ -void -GroupAndNameHierarchyItem::setSelected(const TabDrawingInfo& tabDrawingInfo, - const bool status) -{ - setSelected(tabDrawingInfo.getDisplayGroup(), - tabDrawingInfo.getTabIndex(), - status); -} - /** * Set the selected status of this item only. It does not alter * the status of ancestors and children. @@ -590,23 +542,6 @@ GroupAndNameHierarchyItem::setSelected(const DisplayGroupEnum::Enum displayGroup } } -/** - * Set the selected status for all of this item's descendants. - * - * @param tabDrawingInfo - * Info for drawing tab - * @param status - * True if item is selected, else false. - */ -void -GroupAndNameHierarchyItem::setDescendantsSelected(const TabDrawingInfo& tabDrawingInfo, - const bool status) -{ - setDescendantsSelected(tabDrawingInfo.getDisplayGroup(), - tabDrawingInfo.getTabIndex(), - status); -} - /** * Set the selected status for all of this item's descendants. * @@ -635,24 +570,6 @@ GroupAndNameHierarchyItem::setDescendantsSelected(const DisplayGroupEnum::Enum d } } -/** - * Set the selected status of this item's ancestor's (parent, - * its parent, etc). - * - * @param tabDrawingInfo - * Info for drawing tab - * @param status - * True if item is selected, else false. - */ -void -GroupAndNameHierarchyItem::setAncestorsSelected(const TabDrawingInfo& tabDrawingInfo, - const bool status) -{ - setAncestorsSelected(tabDrawingInfo.getDisplayGroup(), - tabDrawingInfo.getTabIndex(), - status); -} - /** * Set the selected status of this item's ancestor's (parent, * its parent, etc). @@ -679,24 +596,6 @@ GroupAndNameHierarchyItem::setAncestorsSelected(const DisplayGroupEnum::Enum dis } } -/** - * Set the selected status of this item, its ancestors, and all - * of its children. - * - * @param tabDrawingInfo - * Info for drawing tab - * @param status - * True if item is selected, else false. - */ -void -GroupAndNameHierarchyItem::setSelfAncestorsAndDescendantsSelected(const TabDrawingInfo& tabDrawingInfo, - const bool status) -{ - setSelfAncestorsAndDescendantsSelected(tabDrawingInfo.getDisplayGroup(), - tabDrawingInfo.getTabIndex(), - status); -} - /** * Set the selected status of this item, its ancestors, and all * of its children. diff --git a/src/Files/GroupAndNameHierarchyItem.h b/src/Files/GroupAndNameHierarchyItem.h index 8c5f02501..70b8f3244 100644 --- a/src/Files/GroupAndNameHierarchyItem.h +++ b/src/Files/GroupAndNameHierarchyItem.h @@ -32,7 +32,6 @@ namespace caret { class GroupAndNameHierarchyUserInterface; class SceneClassAssistant; - class TabDrawingInfo; class GroupAndNameHierarchyItem : public CaretObject, SceneableInterface { @@ -86,43 +85,27 @@ namespace caret { void removeChild(GroupAndNameHierarchyItem* child); - bool isSelected(const TabDrawingInfo& tabDrawingInfo) const; - bool isSelected(const DisplayGroupEnum::Enum displayGroup, const int32_t tabIndex) const; - GroupAndNameCheckStateEnum::Enum getCheckState(const TabDrawingInfo& tabDrawingInfo) const; - GroupAndNameCheckStateEnum::Enum getCheckState(const DisplayGroupEnum::Enum displayGroup, - const int32_t tabIndex) const; - - void setSelected(const TabDrawingInfo& tabDrawingInfo, - const bool status); + const int32_t tabIndex) const; void setSelected(const DisplayGroupEnum::Enum displayGroup, - const int32_t tabIndex, - const bool status); - - void setDescendantsSelected(const TabDrawingInfo& tabDrawingInf, - const bool status); + const int32_t tabIndex, + const bool status); void setDescendantsSelected(const DisplayGroupEnum::Enum displayGroup, - const int32_t tabIndex, - const bool status); - - void setAncestorsSelected(const TabDrawingInfo& tabDrawingInf, - const bool status); + const int32_t tabIndex, + const bool status); void setAncestorsSelected(const DisplayGroupEnum::Enum displayGroup, - const int32_t tabIndex, - const bool status); - - void setSelfAncestorsAndDescendantsSelected(const TabDrawingInfo& tabDrawingInf, - const bool status); + const int32_t tabIndex, + const bool status); void setSelfAncestorsAndDescendantsSelected(const DisplayGroupEnum::Enum displayGroup, - const int32_t tabIndex, - const bool status); + const int32_t tabIndex, + const bool status); const float* getIconColorRGBA() const; diff --git a/src/Files/LabelSelectionItem.cxx b/src/Files/LabelSelectionItem.cxx deleted file mode 100644 index 1d738899d..000000000 --- a/src/Files/LabelSelectionItem.cxx +++ /dev/null @@ -1,671 +0,0 @@ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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 __LABEL_SELECTION_ITEM_DECLARE__ -#include "LabelSelectionItem.h" -#undef __LABEL_SELECTION_ITEM_DECLARE__ - -#include "ApplicationInformation.h" -#include "CaretAssert.h" -#include "CaretLogger.h" -#include "Cluster.h" -#include "HtmlStringBuilder.h" -#include "SceneClass.h" -#include "SceneClassAssistant.h" - -using namespace caret; - -/** - * \class caret::LabelSelectionItem - * \brief Extends QStandardItem for label hierarchy - * \ingroup Files - */ - -/** - * Constructor for a label - * @param text - * Text displayed in the item - * @param ontologyID - * The ID from the JSON - * @param labelIndex - * Index of the label - * @param labelRGBA - * Color for icon - */ -LabelSelectionItem::LabelSelectionItem(const AString& text, - const AString& ontologyID, - const int32_t labelIndex, - const std::array& labelRGBA) -: QStandardItem(), -m_itemType(ItemType::ITEM_LABEL), -m_ontologyID(ontologyID), -m_labelIndex(labelIndex) -{ - initializeInstance(); - setText(text); - - /* - * Only create pixmap when GUI is available (QApplication / wb_view) otherwise a crash - * will occur without a GUI (QCoreApplication / wb_command). - */ - if (ApplicationInformation::getApplicationType() == ApplicationTypeEnum::APPLICATION_TYPE_GRAPHICAL_USER_INTERFACE) { - QPixmap iconPixmap(24, 24); - iconPixmap.fill(QColor(labelRGBA[0], - labelRGBA[1], - labelRGBA[2], - labelRGBA[3])); - setIcon(iconPixmap); - } -} - -/** - * Constructor for an item in the hierarchy that is above and not a label - * @param text - * Text displayed in the item - * @param ontologyID - * The ID from the JSON - */ -LabelSelectionItem::LabelSelectionItem(const AString& text, - const AString& ontologyID) -: QStandardItem(), -m_itemType(ItemType::ITEM_HIERARCHY), -m_ontologyID(ontologyID), -m_labelIndex(-1) -{ - initializeInstance(); - setText(text); -} - -/** - * Copy constructor - */ -LabelSelectionItem::LabelSelectionItem(const LabelSelectionItem& other) -: QStandardItem(other), -SceneableInterface(other), -m_itemType(other.m_itemType) -{ - initializeInstance(); - copyHelper(other); -} - - -/** - * Destructor. - */ -LabelSelectionItem::~LabelSelectionItem() -{ -} - -/** - * Copy constructor - * @param other - * Item that is copied to 'this' - */ -LabelSelectionItem& -LabelSelectionItem::operator=(const LabelSelectionItem& other) -{ - if (this != &other) { - QStandardItem::operator=(other); - this->copyHelper(other); - } - return *this; -} - -/** - * Helps with copying an instance - * @param other - * Other item that is copied to this - */ -void -LabelSelectionItem::copyHelper(const LabelSelectionItem& other) -{ - setText(other.text()); - m_ontologyID = other.m_ontologyID; - m_labelIndex = other.m_labelIndex; - if (m_labelIndex >= 0) { - setIcon(other.icon()); - } -} - -/** - * Initialize an instance - */ -void -LabelSelectionItem::initializeInstance() -{ - m_sceneAssistant = std::unique_ptr(new SceneClassAssistant()); - setCheckable(true); - appendToToolTip("Right-click for menu to go to label's location"); - if ( ! m_ontologyID.isEmpty()) { - appendToToolTip("Ontology ID=" + m_ontologyID); - } -} - -/** - * @return a copy of this item. - * The item's children are not copied. - * When subclassing QStandardItem, you can reimplement this function to provide - * QStandardItemModel with a factory that it can use to create new items on demand. - */ -QStandardItem* -LabelSelectionItem::clone() const -{ - LabelSelectionItem* item(new LabelSelectionItem(*this)); - - return item; -} - -/** - * @return the type of this item. - * The type is used to distinguish custom items from the base class. - * When subclassing QStandardItem, you should reimplement this function and return a new value - * greater than or equal to UserType. - */ -int -LabelSelectionItem::type() const -{ - return static_cast(m_itemType); -} - -AString -LabelSelectionItem::getOntologyID() const -{ - return m_ontologyID; -} - -/** - * @return Information about label for display in GUI - */ -AString -LabelSelectionItem::getTextForInfoDisplay() const -{ - HtmlStringBuilder html; - html.addBold(text()); - html.addLineBreak(); - html.add("ID: " + getOntologyID()); - return html.toStringWithHtmlBodyForToolTip(); -} - -/** - * @return Index of the label - */ -int32_t -LabelSelectionItem::getLabelIndex() const -{ - return m_labelIndex; -} - -/** - * Set all children to the given checked status - * @param checked - * New checked status - */ -void -LabelSelectionItem::setAllChildrenChecked(const bool checked) -{ - const Qt::CheckState checkState(checked - ? Qt::Checked - : Qt::Unchecked); - setCheckedStatusOfAllChildren(this, - checkState); -} - -/** - * Set the checked status of all children - * @param item - * The item - * @param checkState - * The check state - */ -void -LabelSelectionItem::setCheckedStatusOfAllChildren(QStandardItem* item, - const Qt::CheckState checkState) -{ - CaretAssert(item); - const int32_t numChildren(item->rowCount()); - for (int32_t iRow = 0; iRow < numChildren; iRow++) { - QStandardItem* child(item->child(iRow)); - child->setCheckState(checkState); - setCheckedStatusOfAllChildren(child, - checkState); - } -} - -/** - * Set the check state for this instance based upon its children's check states - * There are three checked status for items WITH CHILDREN - * - Checked: This instance and ALL children are checked - * - Unchecked: This instance and ALL children and unchecked - * - PartiallyChecked: There are children that are both checked and unchecked - * @return - * Check state for this instance - */ -Qt::CheckState -LabelSelectionItem::setCheckStateFromChildren() -{ - const int32_t numChildren(rowCount()); - - /* - * If no children, use this instance's check state - */ - if (numChildren == 0) { - return checkState(); - } - - int32_t numChildrenChecked = 0; - bool partiallyCheckedFlag(false); - - /* - * Examine checked status of children - */ - for (int32_t iRow = 0; iRow < numChildren; iRow++) { - QStandardItem* myChild(child(iRow)); - CaretAssert(myChild); - CaretAssert(myChild != this); /* should never happen and would cause infinite loop */ - - LabelSelectionItem* labelChild(dynamic_cast(myChild)); - CaretAssert(labelChild); - const Qt::CheckState childCheckState(labelChild->setCheckStateFromChildren()); - switch (childCheckState) { - case Qt::Unchecked: - break; - case Qt::Checked: - ++numChildrenChecked; - break; - case Qt::PartiallyChecked: - /* - * If a child is partially checked, then this instance will be partially checked - */ - partiallyCheckedFlag = true; - break; - } - - if (partiallyCheckedFlag) { - break; - } - } - - Qt::CheckState childrenCheckState(Qt::Unchecked); - - if (partiallyCheckedFlag) { - /* - * At least one child is partially checked so this instance is partially checked - */ - childrenCheckState = Qt::PartiallyChecked; - } - else if (numChildrenChecked == numChildren) { - /* - * All children are checked so this instance is checked - */ - childrenCheckState = Qt::Checked; - } - else if (numChildrenChecked == 0) { - /* - * All children and unchecked so this instance is unchecked - */ - childrenCheckState = Qt::Unchecked; - } - else if (numChildrenChecked > 0) { - /* - * Have children that are both checked and unchecked so this - * instance is partially checked - */ - childrenCheckState = Qt::PartiallyChecked;; - } - else { - /* - * Should not get here - */ - CaretAssert(0); - } - - Qt::CheckState checkStateOut(childrenCheckState); - - /* - * If this item corresponds to a label, its status - * is INDEPENDENT of its children. - */ - if (getLabelIndex() >= 0) { - switch (checkState()) { - case Qt::Checked: - checkStateOut = Qt::Checked; - break; - case Qt::Unchecked: - checkStateOut = Qt::Unchecked; - break; - case Qt::PartiallyChecked: - checkStateOut = Qt::Checked; - break; - } - } - - /* - * Set check state of this instance - */ - setCheckState(checkStateOut); - - return checkStateOut; -} - -/** - * Set the all, left, and right clusters that are accumulated - * from my clusters and clusters from all children. - */ -void -LabelSelectionItem::setMyAndChildrenMergedClusters() -{ - m_myAndChildrenCentersOfGravity.reset(new CogSet()); - - /* - * May not have centers of gravity if a parent label - */ - if (m_centersOfGravity) { - m_myAndChildrenCentersOfGravity->merge(m_centersOfGravity.get()); - } - - const int32_t numChildren(rowCount()); - for (int32_t iRow = 0; iRow < numChildren; iRow++) { - QStandardItem* myChild(child(iRow)); - CaretAssert(myChild); - CaretAssert(myChild != this); /* should never happen and would cause infinite loop */ - - LabelSelectionItem* labelChild(dynamic_cast(myChild)); - CaretAssert(labelChild); - - /* - * Set merged clusters in child and all of its children - */ - labelChild->setMyAndChildrenMergedClusters(); - const CogSet* childCOG(labelChild->getMyAndChildrenCentersOfGravity()); - CaretAssert(childCOG); - m_myAndChildrenCentersOfGravity->merge(childCOG); - } -} - -/** - * @return All descendants and this item that are of the given type - * @param itemType - * Type for matching to QStandardItem::type() - * @return - * Vector containing the matching items - */ -std::vector -LabelSelectionItem::getThisAndAllDescendantsOfType(const LabelSelectionItem::ItemType itemType) -{ - std::vector itemsOut; - - if (type() == static_cast(itemType)) { - itemsOut.push_back(this); - } - - if (hasChildren()) { - const int32_t numRows(rowCount()); - for (int32_t iRow = 0; iRow < numRows; iRow++) { - QStandardItem* itemChild(child(iRow)); - LabelSelectionItem* labelChild(dynamic_cast(itemChild)); - CaretAssert(labelChild); - std::vector childItems(labelChild->getThisAndAllDescendantsOfType(itemType)); - itemsOut.insert(itemsOut.end(), - childItems.begin(), childItems.end()); - } - } - - return itemsOut; -} - -/** - * @return This and all descendants - */ -std::vector -LabelSelectionItem::getThisAndAllDescendants() -{ - std::vector itemsOut; - - itemsOut.push_back(this); - - if (hasChildren()) { - const int32_t numRows(rowCount()); - for (int32_t iRow = 0; iRow < numRows; iRow++) { - QStandardItem* itemChild(child(iRow)); - LabelSelectionItem* labelChild(dynamic_cast(itemChild)); - CaretAssert(labelChild); - std::vector childItems(labelChild->getThisAndAllDescendants()); - itemsOut.insert(itemsOut.end(), - childItems.begin(), childItems.end()); - } - } - - return itemsOut; -} - -/** - * @return A formatted string showing the hierarchy - * @param indentation - * Indentation for the string - */ -AString -LabelSelectionItem::toFormattedString(const AString& indentation) const -{ - AString text; - - text.appendWithNewLine(indentation + AString(this->text())); - - if (hasChildren()) { - const AString& childIndentation(indentation + " "); - - const int32_t numRows(rowCount()); - for (int32_t iRow = 0; iRow < numRows; iRow++) { - QStandardItem* itemChild(child(iRow)); - LabelSelectionItem* labelChild(dynamic_cast(itemChild)); - CaretAssert(labelChild); - text.appendWithNewLine(labelChild->toFormattedString(childIndentation)); - } - } - - return text; -} - -/* - * @return Reference to centers of gravity for this item - */ -const LabelSelectionItem::CogSet* -LabelSelectionItem::getCentersOfGravity() const -{ - return m_centersOfGravity.get(); -} - -/* - * @return Reference to centers of gravity for this item and all children - */ -const LabelSelectionItem::CogSet* -LabelSelectionItem::getMyAndChildrenCentersOfGravity() const -{ - return m_myAndChildrenCentersOfGravity.get(); -} - -/** - * Set the clusters (may contain multiple, disjoint clusters) - * @param clusters - * Clusters for this item - */ -void -LabelSelectionItem::setClusters(const std::vector& clusters) -{ - COG* allCOG(NULL); - COG* centralCOG(NULL); - COG* leftCOG(NULL); - COG* rightCOG(NULL); - - bool centralSplitFlag(false); - - const AString moreThanOneMsg("There is more than cluster of the same type (should only be one) type="); - for (const auto& c : clusters) { - - const AString title(c->getLocationTypeName() - + ": " - + AString::number(c->getNumberOfBrainordinates()) - + " Brainordinates; " - + "COG " - + c->getCenterOfGravityXYZ().toString()); - switch (c->getLocationType()) { - case Cluster::LocationType::UNKNOWN: - CaretLogWarning("Cluster is UNKNOWN " - + c->toString()); - break; - case Cluster::LocationType::CENTRAL: - if (centralCOG != NULL) { - const AString msg(moreThanOneMsg + c->getLocationTypeName() - + " name=" + c->getName()); - CaretLogWarning(msg); - CaretAssertMessage(0, msg); - } - else { - centralCOG = new COG(title, - c->getCenterOfGravityXYZ(), - c->getNumberOfBrainordinates()); - centralSplitFlag = c->isSplitClusterFlag(); - } - break; - case Cluster::LocationType::LEFT: - if (leftCOG != NULL) { - const AString msg(moreThanOneMsg + c->getLocationTypeName() - + " name=" + c->getName()); - CaretLogWarning(msg); - CaretAssertMessage(0, msg); - } - else { - leftCOG = new COG(title, - c->getCenterOfGravityXYZ(), - c->getNumberOfBrainordinates()); - } - break; - case Cluster::LocationType::RIGHT: - if (rightCOG != NULL) { - const AString msg(moreThanOneMsg + c->getLocationTypeName() - + " name=" + c->getName()); - CaretLogWarning(msg); - CaretAssertMessage(0, msg); - } - else { - rightCOG = new COG(title, - c->getCenterOfGravityXYZ(), - c->getNumberOfBrainordinates()); - } - break; - } - } - - /* - * Create ALL that is combination of the others - */ - if ((centralCOG != NULL) - || (leftCOG != NULL) - || (rightCOG != NULL)) { - Vector3D zeros; - int64_t numBrainordinates(0); - allCOG = new COG("All", zeros, numBrainordinates); - if (centralCOG != NULL) { - /* - * Central is split into right and left clusters. - * Adding this would add the brainordinates two times. - */ - if ( ! centralSplitFlag) { - allCOG->merge(*allCOG); - } - } - if (leftCOG != NULL) { - allCOG->merge(*leftCOG); - } - if (rightCOG != NULL) { - allCOG->merge(*rightCOG); - } - allCOG->updateTitle("All"); - } - - m_centersOfGravity.reset(new CogSet(allCOG, - centralCOG, - leftCOG, - rightCOG)); -} - -/** - * Append text to the current tooltip separating with a newline. - */ -void -LabelSelectionItem::appendToToolTip(const QString& text) -{ - if (text.isEmpty()) { - return; - } - QString s(this->toolTip().trimmed()); - if ( ! s.isEmpty()) { - s.append("\n"); - } - s.append(text); - setToolTip(s); -} - -/** - * Save information specific to this type of model to the scene. - * - * @param sceneAttributes - * Attributes for the scene. Scenes may be of different types - * (full, generic, etc) and the attributes should be checked when - * saving the scene. - * - * @param instanceName - * Name of instance in the scene. - */ -SceneClass* -LabelSelectionItem::saveToScene(const SceneAttributes* sceneAttributes, - const AString& instanceName) -{ - SceneClass* sceneClass = new SceneClass(instanceName, - "LabelSelectionItem", - 1); - m_sceneAssistant->saveMembers(sceneAttributes, - sceneClass); - return sceneClass; -} - -/** - * Restore information specific to the type of model from the scene. - * - * @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 from which model specific information is obtained. - */ -void -LabelSelectionItem::restoreFromScene(const SceneAttributes* sceneAttributes, - const SceneClass* sceneClass) -{ - if (sceneClass == NULL) { - return; - } - - m_sceneAssistant->restoreMembers(sceneAttributes, - sceneClass); -} - diff --git a/src/Files/LabelSelectionItem.h b/src/Files/LabelSelectionItem.h deleted file mode 100644 index b8ce3612f..000000000 --- a/src/Files/LabelSelectionItem.h +++ /dev/null @@ -1,258 +0,0 @@ -#ifndef __LABEL_SELECTION_ITEM_H__ -#define __LABEL_SELECTION_ITEM_H__ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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*/ - - -#include -#include -#include - -#include - -#include "CaretObject.h" -#include "Cluster.h" -#include "SceneableInterface.h" - - -namespace caret { - class SceneClassAssistant; - - class LabelSelectionItem : public QStandardItem, public SceneableInterface { - - public: - class COG : public CaretObject { - public: - COG(const AString& title, - const Vector3D& xyz, - const int64_t numberOfBrainordinates) - : m_title(title), - m_xyz(xyz), - m_numberOfBrainordinates(numberOfBrainordinates) { } - - ~COG() { } - - AString getTitle() const { return m_title; } - - const Vector3D& getXYZ() const { return m_xyz; } - - int64_t getNumberOfBrainordinates() const { return m_numberOfBrainordinates; } - - void merge(const COG& cog) { - const Vector3D sum((m_xyz * m_numberOfBrainordinates) - + (cog.m_xyz * cog.m_numberOfBrainordinates)); - m_numberOfBrainordinates += cog.m_numberOfBrainordinates; - if (m_numberOfBrainordinates >= 1) { - m_xyz = (sum / static_cast(m_numberOfBrainordinates)); - } - else { - m_xyz.fill(0.0); - } - } - - void updateTitle(const AString& titlePrefix) { - m_title = (titlePrefix - + ": " - + AString::number(m_numberOfBrainordinates) - + " Brainordinates; COG " - + m_xyz.toString()); - } - private: - AString m_title; - - Vector3D m_xyz; - - int64_t m_numberOfBrainordinates; - }; - - class CogSet : public CaretObject { - public: - CogSet() { } - - CogSet(COG* allCOG, - COG* centralCOG, - COG* leftCOG, - COG* rightCOG) - : m_allCOG(allCOG), - m_centralCOG(centralCOG), - m_leftCOG(leftCOG), - m_rightCOG(rightCOG) { } - - std::vector getCOGs() const { - std::vector cogsOut; - if (m_allCOG != NULL) cogsOut.push_back(m_allCOG.get()); - if (m_centralCOG != NULL) cogsOut.push_back(m_centralCOG.get()); - if (m_leftCOG != NULL) cogsOut.push_back(m_leftCOG.get()); - if (m_rightCOG != NULL) cogsOut.push_back(m_rightCOG.get()); - return cogsOut; - } - - void merge(const CogSet* cogSet) { - if (cogSet->m_allCOG != NULL) { - if (m_allCOG != NULL) { - m_allCOG->merge(*cogSet->m_allCOG); - } - else { - m_allCOG.reset(new COG("Sum All", - cogSet->m_allCOG->getXYZ(), - cogSet->m_allCOG->getNumberOfBrainordinates())); - } - m_allCOG->updateTitle("Sum All"); - } - - if (cogSet->m_centralCOG != NULL) { - if (m_centralCOG != NULL) { - m_centralCOG->merge(*cogSet->m_centralCOG); - } - else { - m_centralCOG.reset(new COG("Sum Central", - cogSet->m_centralCOG->getXYZ(), - cogSet->m_centralCOG->getNumberOfBrainordinates())); - } - m_centralCOG->updateTitle("Sum Central"); - } - - if (cogSet->m_leftCOG != NULL) { - if (m_leftCOG != NULL) { - m_leftCOG->merge(*cogSet->m_leftCOG); - } - else { - m_leftCOG.reset(new COG("Sum Left", - cogSet->m_leftCOG->getXYZ(), - cogSet->m_leftCOG->getNumberOfBrainordinates())); - } - m_leftCOG->updateTitle("Sum Left"); - } - - if (cogSet->m_rightCOG != NULL) { - if (m_rightCOG != NULL) { - m_rightCOG->merge(*cogSet->m_rightCOG); - } - else { - m_rightCOG.reset(new COG("Sum Right", - cogSet->m_rightCOG->getXYZ(), - cogSet->m_rightCOG->getNumberOfBrainordinates())); - } - m_rightCOG->updateTitle("Sum Right"); - } - } - private: - std::unique_ptr m_allCOG; - std::unique_ptr m_centralCOG; - std::unique_ptr m_leftCOG; - std::unique_ptr m_rightCOG; - }; - - /* - * Type of item returned by override type() method - */ - enum class ItemType : int { - /** Item is a label that that is turned on/off by user */ - ITEM_LABEL = QStandardItem::UserType + 1, - /** Item is in the hierarchy and IS NOT a label */ - ITEM_HIERARCHY = QStandardItem::UserType + 2 - }; - - LabelSelectionItem(const AString& text, - const AString& ontologyID, - const int32_t labelIndex, - const std::array& labelRGBA); - - LabelSelectionItem(const AString& text, - const AString& ontologyID); - - virtual ~LabelSelectionItem(); - - virtual QStandardItem* clone() const; - - virtual int type() const; - - AString getOntologyID() const; - - AString getTextForInfoDisplay() const; - - int32_t getLabelIndex() const; - - void setAllChildrenChecked(const bool checked); - - Qt::CheckState setCheckStateFromChildren(); - - std::vector getThisAndAllDescendantsOfType(const LabelSelectionItem::ItemType itemType); - - std::vector getThisAndAllDescendants(); - - AString toFormattedString(const AString& indentation) const; - - const CogSet* getCentersOfGravity() const; - - const CogSet* getMyAndChildrenCentersOfGravity() const; - - void setClusters(const std::vector& clusters); - - void appendToToolTip(const QString& text); - - // ADD_NEW_METHODS_HERE - - virtual SceneClass* saveToScene(const SceneAttributes* sceneAttributes, - const AString& instanceName); - - virtual void restoreFromScene(const SceneAttributes* sceneAttributes, - const SceneClass* sceneClass); - - protected: - LabelSelectionItem(const LabelSelectionItem& other); - - LabelSelectionItem& operator=(const LabelSelectionItem& other); - - private: - void copyHelper(const LabelSelectionItem& other); - - void initializeInstance(); - - void setCheckedStatusOfAllChildren(QStandardItem* item, - const Qt::CheckState checkState); - - void setMyAndChildrenMergedClusters(); - - const ItemType m_itemType; - - AString m_ontologyID; - - int32_t m_labelIndex; - - std::unique_ptr m_sceneAssistant; - - std::unique_ptr m_centersOfGravity; - - std::unique_ptr m_myAndChildrenCentersOfGravity; - - friend class LabelSelectionItemModel; - - // ADD_NEW_MEMBERS_HERE - - }; - -#ifdef __LABEL_SELECTION_ITEM_DECLARE__ - // -#endif // __LABEL_SELECTION_ITEM_DECLARE__ - -} // namespace -#endif //__LABEL_SELECTION_ITEM_H__ diff --git a/src/Files/LabelSelectionItemModel.cxx b/src/Files/LabelSelectionItemModel.cxx deleted file mode 100644 index 9bafe6594..000000000 --- a/src/Files/LabelSelectionItemModel.cxx +++ /dev/null @@ -1,642 +0,0 @@ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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 __LABEL_SELECTION_ITEM_MODEL_DECLARE__ -#include "LabelSelectionItemModel.h" -#undef __LABEL_SELECTION_ITEM_MODEL_DECLARE__ - -#include - -#include "CaretAssert.h" -#include "CaretHierarchy.h" -#include "CaretLogger.h" -#include "ClusterContainer.h" -#include "GiftiLabel.h" -#include "GiftiLabelTable.h" -#include "GroupAndNameHierarchyItem.h" -#include "SceneClass.h" -#include "SceneClassAssistant.h" -#include "ScenePrimitiveArray.h" - -using namespace caret; - - - -/** - * \class caret::LabelSelectionItemModel - * \brief Model for label hierarchy - * \ingroup Files - */ - -/** - * Constructor. - * @param fileAndMapName - * Name of file and map containing label table - * @param GiftiLabelTable - * GIFTI label tabel from which this hierarchy is build - * @param clusterContainer - * The cluster container (may be NULL) - * @param displayGroup - * The display group - * @param tabIndex - * Index of the tab if displayGroup is TAB - * @param logMismatchedLabelsFlag - * If true, log a message if any labels are in hierarchy but not in label table - */ -LabelSelectionItemModel::LabelSelectionItemModel(const AString& fileAndMapName, - GiftiLabelTable* giftiLabelTable, - const ClusterContainer* clusterContainer, - const DisplayGroupEnum::Enum displayGroup, - const int32_t tabIndex, - const bool logMismatchedLabelsFlag) -: QStandardItemModel(), -m_fileAndMapName(fileAndMapName), -m_giftiLabelTable(giftiLabelTable), -m_displayGroup(displayGroup), -m_tabIndex(tabIndex), -m_logMismatchedLabelsFlag(logMismatchedLabelsFlag) -{ - CaretAssert(m_giftiLabelTable); - - m_sceneAssistant = std::unique_ptr(new SceneClassAssistant()); - - buildModel(clusterContainer); -} - -/** - * Destructor. - */ -LabelSelectionItemModel::~LabelSelectionItemModel() -{ -} - -/** - * @return True if this model is valid - */ -bool -LabelSelectionItemModel::isValid() const -{ - return m_validFlag; -} - -/** - * Set the checked status of all items - * @param checked - * The checked status - */ -void -LabelSelectionItemModel::setCheckedStatusOfAllItems(const bool checked) -{ - QStandardItem* rootItem(invisibleRootItem()); - const int32_t numChildren(rootItem->rowCount()); - for (int32_t iRow = 0; iRow < numChildren; iRow++) { - QStandardItem* childItem(rootItem->child(iRow)); - LabelSelectionItem* labelItem(dynamic_cast(childItem)); - CaretAssert(labelItem); - labelItem->setCheckState(checked - ? Qt::Checked - : Qt::Unchecked); - labelItem->setAllChildrenChecked(checked); - } -} - -/** - * Update the checked state of all items - */ -void -LabelSelectionItemModel::updateCheckedStateOfAllItems() -{ - QStandardItem* rootItem(invisibleRootItem()); - const int32_t numChildren(rootItem->rowCount()); - for (int32_t iRow = 0; iRow < numChildren; iRow++) { - QStandardItem* childItem(rootItem->child(iRow)); - LabelSelectionItem* labelItem(dynamic_cast(childItem)); - CaretAssert(labelItem); - labelItem->setCheckStateFromChildren(); - } -} - -/** - * @return True if the label with the given key is checked, else false. - * @param labelKey - * The label's key - */ -bool -LabelSelectionItemModel::isLabelChecked(const int32_t labelKey) const -{ - auto iter(m_labelKeyToLabelSelectionItem.find(labelKey)); - if (iter != m_labelKeyToLabelSelectionItem.end()) { - const LabelSelectionItem* item(iter->second); - if (item != NULL) { - return (item->checkState() == Qt::Checked); - } - } - return false; -} - -/** - * Build the tree model from the hierarchy and the label table - * @param clusterContainer - * The cluster container (may be NULL) - */ -void -LabelSelectionItemModel::buildModel(const ClusterContainer* clusterContainer) -{ - CaretAssert(m_giftiLabelTable); - - m_labelKeyToLabelSelectionItem.clear(); - m_buildTreeMissingLabelNames.clear(); - - const CaretHierarchy& caretHierarchy(m_giftiLabelTable->getHierarchy()); - if (caretHierarchy.isEmpty()) { - return; - } - const CaretHierarchy::Item& caretRootItem(caretHierarchy.getInvisibleRoot()); - - std::vector topLevelItems; - const int32_t numChildren(caretRootItem.children.size()); - if (numChildren > 0) { - for (int32_t i = 0; i < numChildren; i++) { - CaretAssertVectorIndex(caretRootItem.children, i); - topLevelItems.push_back(buildTree(&caretRootItem.children[i], - m_giftiLabelTable, - clusterContainer)); - } - } - - AString text; - - /* - * Name in hiearchy has not children and name is not found in label table - */ - if ( ! m_buildTreeMissingLabelNames.empty()) { - text.appendWithNewLine(" No labels in the label table were found for these childless elements in the hierarchy:"); - for (const AString& name : m_buildTreeMissingLabelNames) { - text.appendWithNewLine(" " + name); - } - } - - /* - * Name is in the label table but not found in the hierarchy - * OR label is in hierarchy but has children - * (Except for unassigned label key) - */ - const int32_t unassignedLabelKey(m_giftiLabelTable->getUnassignedLabelKey()); - std::set buildTreeMissingHierarchyNames; - std::set labelIsParentInHierarchyNames; - const std::vector labelKeys(m_giftiLabelTable->getLabelKeysSortedByName()); - for (const int32_t key : labelKeys) { - if (key != unassignedLabelKey) { - if (m_labelKeyToLabelSelectionItem.find(key) == m_labelKeyToLabelSelectionItem.end()) { - const AString labelName(m_giftiLabelTable->getLabelName(key)); - if (m_hierarchyParentNames.find(labelName) != m_hierarchyParentNames.end()) { - labelIsParentInHierarchyNames.insert(labelName); - } - else { - buildTreeMissingHierarchyNames.insert(labelName); - } - } - } - } - - if ( ! buildTreeMissingHierarchyNames.empty()) { - /* - * Add labels from label table that are not in the hierarchy to the hierarchy - */ - const AString emptyOntologyID(""); - LabelSelectionItem* parentItem(new LabelSelectionItem("Label Table Only", - emptyOntologyID)); - for (const AString& name : buildTreeMissingHierarchyNames) { - const GiftiLabel* giftiLabel(m_giftiLabelTable->getLabel(name)); - if (giftiLabel != NULL) { - const int32_t labelKey(giftiLabel->getKey()); - LabelSelectionItem* item(new LabelSelectionItem(name, - emptyOntologyID, - labelKey, - getLabelRGBA(giftiLabel))); - if (clusterContainer != NULL) { - item->setClusters(clusterContainer->getClustersWithKey(labelKey)); - } - parentItem->appendRow(item); - m_labelKeyToLabelSelectionItem[labelKey] = item; - } - } - - topLevelItems.push_back(parentItem); - - text.appendWithNewLine(" These labels not in hierarchy have been added to the group \"" - + parentItem->text() - + "\": "); - for (const AString& name : buildTreeMissingHierarchyNames) { - text.appendWithNewLine(" " + name); - } - } - - if ( ! labelIsParentInHierarchyNames.empty()) { - text.appendWithNewLine(" Label from label table is in the element hierarchy but element contains children:"); - for (const AString& name : labelIsParentInHierarchyNames) { - text.appendWithNewLine(" " + name); - } - } - - if ( ! text.isEmpty()) { - if (m_logMismatchedLabelsFlag) { - text.insert(0, (m_fileAndMapName + "\n")); - CaretLogInfo(text); - } - } - - for (LabelSelectionItem* item : topLevelItems) { - invisibleRootItem()->appendRow(item); - } - - const std::set keysNotInClusters(clusterContainer->getKeysThatAreNotInAnyClusters()); - for (auto& keyItem : m_labelKeyToLabelSelectionItem) { - const int32_t key(keyItem.first); - if (keysNotInClusters.find(key) != keysNotInClusters.end()) { - LabelSelectionItem* labelItem(keyItem.second); - labelItem->appendToToolTip("This label is not used by any brainordinates"); - if ( ! labelItem->hasChildren()) { - /* - * Will not do anything since not used by any brainordinates - * AND it has no children so disable it - */ - labelItem->setEnabled(false); - } - } - } - - setCheckedStatusOfAllItems(true); - - updateCheckedStateOfAllItems(); - - { - std::vector topLevelItems(getTopLevelItems()); - for (auto& item : topLevelItems) { - (void)item->setMyAndChildrenMergedClusters(); - } - } - - m_validFlag = true; -} - -/** - * Build the tree from the items in the hierarchy - * @param hierarchyItem - * Hierarchy item and its children are added - * @param giftiLabelTable - * The GIFTI label table - * @param clusterContainer - * The cluster container (may be NULL) - */ -LabelSelectionItem* -LabelSelectionItemModel::buildTree(const CaretHierarchy::Item* hierarchyItem, - const GiftiLabelTable* giftiLabelTable, - const ClusterContainer* clusterContainer) -{ - LabelSelectionItem* itemOut(NULL); - - std::array rgba { 255, 255, 255, 255 }; - int32_t labelKey(-1); - const GiftiLabel* label(giftiLabelTable->getLabel(hierarchyItem->name)); - if (label != NULL) { - rgba = getLabelRGBA(label); - labelKey = label->getKey(); - } - - CaretAssert(hierarchyItem); - const int32_t numChildren(hierarchyItem->children.size()); - if (numChildren > 0) { - if (label != NULL) { - itemOut = new LabelSelectionItem(hierarchyItem->name, - hierarchyItem->id, - labelKey, - rgba); - if (clusterContainer != NULL) { - itemOut->setClusters(clusterContainer->getClustersWithKey(labelKey)); - } - } - else { - itemOut = new LabelSelectionItem(hierarchyItem->name, - hierarchyItem->id); - } - for (int32_t i = 0; i < numChildren; i++) { - CaretAssertVectorIndex(hierarchyItem->children, i); - itemOut->appendRow(buildTree(&hierarchyItem->children[i], - giftiLabelTable, - clusterContainer)); - } - if (labelKey >= 0) { - m_labelKeyToLabelSelectionItem[labelKey] = itemOut; - } - m_hierarchyParentNames.insert(hierarchyItem->name); - } - else { - AString name(hierarchyItem->name); - itemOut = new LabelSelectionItem(name, - hierarchyItem->id, - labelKey, - rgba); - if (clusterContainer != NULL) { - itemOut->setClusters(clusterContainer->getClustersWithKey(labelKey)); - } - - if (labelKey >= 0) { - m_labelKeyToLabelSelectionItem[labelKey] = itemOut; - } - if (label == NULL) { - m_buildTreeMissingLabelNames.insert(name); - itemOut->appendToToolTip("There is no label in the label table for this name"); - if ( ! itemOut->hasChildren()) { - /* - * Will not do anything since there is no label in the label table - * AND it has no children so disable it - */ - itemOut->setEnabled(false); - } - } - } - - return itemOut; -} - -/** - * @return The RGBA color for the label as four bytes. If the label is NULL, - * white it returned. - * @param label - * The GIFTI label - */ -std::array -LabelSelectionItemModel::getLabelRGBA(const GiftiLabel* label) const -{ - std::array rgba { 255, 255, 255, 255 }; - if (label == NULL) { - return rgba; - } - - const std::array rgbaFloat { - label->getRed(), - label->getGreen(), - label->getBlue(), - label->getAlpha() - }; - - for (int i = 0; i < 4; i++) { - int32_t c(static_cast(rgbaFloat[i] * 255.0)); - if (c > 255) c = 255; - if (c < 0) c = 0; - rgba[i] = c; - } - - return rgba; -} - -/** - * @return All descendants that are of the given type - * @param itemType - * Type for matching to QStandardItem::type() - * @return - * Vector containing the matching items - */ -std::vector -LabelSelectionItemModel::getAllDescendantsOfType(const LabelSelectionItem::ItemType itemType) -{ - std::vector itemsOut; - - QStandardItem* rootItem(invisibleRootItem()); - const int32_t numChildren(rootItem->rowCount()); - for (int32_t iRow = 0; iRow < numChildren; iRow++) { - QStandardItem* childItem(rootItem->child(iRow)); - LabelSelectionItem* labelItem(dynamic_cast(childItem)); - CaretAssert(labelItem); - std::vector items(labelItem->getThisAndAllDescendantsOfType(itemType)); - itemsOut.insert(itemsOut.end(), - items.begin(), items.end()); - } - - return itemsOut; -} - -/** - * @return All items at the top level of the hierarchy - */ -std::vector -LabelSelectionItemModel::getTopLevelItems() -{ - std::vector itemsOut; - - QStandardItem* rootItem(invisibleRootItem()); - const int32_t numChildren(rootItem->rowCount()); - for (int32_t iRow = 0; iRow < numChildren; iRow++) { - QStandardItem* childItem(rootItem->child(iRow)); - LabelSelectionItem* labelItem(dynamic_cast(childItem)); - CaretAssert(labelItem); - itemsOut.push_back(labelItem); - } - - return itemsOut; -} -/** - * @return All descendants - */ -std::vector -LabelSelectionItemModel::getAllDescendants() -{ - std::vector itemsOut; - - QStandardItem* rootItem(invisibleRootItem()); - const int32_t numChildren(rootItem->rowCount()); - for (int32_t iRow = 0; iRow < numChildren; iRow++) { - QStandardItem* childItem(rootItem->child(iRow)); - LabelSelectionItem* labelItem(dynamic_cast(childItem)); - CaretAssert(labelItem); - std::vector items(labelItem->getThisAndAllDescendants()); - itemsOut.insert(itemsOut.end(), - items.begin(), items.end()); - } - - return itemsOut; -} - -/** - * @return A formatted string showing the hierarchy - * @param indentation - * Indentation for the string - */ -AString -LabelSelectionItemModel::toFormattedString(const AString& indentation) const -{ - AString text; - - QStandardItem* rootItem(invisibleRootItem()); - const int32_t numChildren(rootItem->rowCount()); - for (int32_t iRow = 0; iRow < numChildren; iRow++) { - QStandardItem* childItem(rootItem->child(iRow)); - LabelSelectionItem* labelItem(dynamic_cast(childItem)); - CaretAssert(labelItem); - text.appendWithNewLine(labelItem->toFormattedString(indentation + " ")); - } - - return text; -} - -/** - * Synchronize selections between this label hiearchy and the list in the label table - * @param copyToLabelTableFlag - * If true, copy selections from this model to the label table, - * else copy selections from the label table to this model. - */ -void -LabelSelectionItemModel::synchronizeSelectionsWithLabelTable(const bool copyToLabelTableFlag) -{ - for (auto& keyItem : m_labelKeyToLabelSelectionItem) { - const int32_t key(keyItem.first); - CaretAssert(key >= 0); - LabelSelectionItem* labelSelectionItem(keyItem.second); - CaretAssert(labelSelectionItem); - - GiftiLabel* label(m_giftiLabelTable->getLabel(key)); - if (label != NULL) { - GroupAndNameHierarchyItem* gnhn(label->getGroupNameSelectionItem()); - CaretAssert(gnhn); - if (copyToLabelTableFlag) { - const bool selectedFlag(labelSelectionItem->checkState() != Qt::Unchecked); - gnhn->setSelected(m_displayGroup, m_tabIndex, selectedFlag); - } - else { - const Qt::CheckState checkState(gnhn->isSelected(m_displayGroup, m_tabIndex) - ? Qt::Checked - : Qt::Unchecked); - labelSelectionItem->setCheckState(checkState); - } - } - } - - if ( ! copyToLabelTableFlag) { - updateCheckedStateOfAllItems(); - } -} - - -/** - * Save information specific to this type of model to the scene. - * - * @param sceneAttributes - * Attributes for the scene. Scenes may be of different types - * (full, generic, etc) and the attributes should be checked when - * saving the scene. - * - * @param instanceName - * Name of instance in the scene. - */ -SceneClass* -LabelSelectionItemModel::saveToScene(const SceneAttributes* sceneAttributes, - const AString& instanceName) -{ - SceneClass* sceneClass = new SceneClass(instanceName, - "LabelSelectionItemModel", - 1); - m_sceneAssistant->saveMembers(sceneAttributes, - sceneClass); - - /* - * Save only those labels that are checked - */ - std::vector checkedLabelNames; - const std::vector labelItems(getAllDescendantsOfType(LabelSelectionItem::ItemType::ITEM_LABEL)); - for (const LabelSelectionItem* lsi : labelItems) { - if (lsi->checkState() == Qt::Checked) { - checkedLabelNames.push_back(lsi->text()); - } - } - - if ( ! checkedLabelNames.empty()) { - sceneClass->addStringArray("CheckedLabels", - &checkedLabelNames[0], - checkedLabelNames.size()); - } - - // Uncomment if sub-classes must save to scene - //saveSubClassDataToScene(sceneAttributes, - // sceneClass); - - return sceneClass; -} - -/** - * Restore information specific to the type of model from the scene. - * - * @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 from which model specific information is obtained. - */ -void -LabelSelectionItemModel::restoreFromScene(const SceneAttributes* sceneAttributes, - const SceneClass* sceneClass) -{ - if (sceneClass == NULL) { - return; - } - - m_sceneAssistant->restoreMembers(sceneAttributes, - sceneClass); - - /* - * Restore checked status of labels - */ - bool haveCheckedLabelsFlag(false); - const ScenePrimitiveArray* checkedLabelsArray(sceneClass->getPrimitiveArray("CheckedLabels")); - if (checkedLabelsArray != NULL) { - std::set checkedLabelNames; - const int32_t numLabels(checkedLabelsArray->getNumberOfArrayElements()); - for (int32_t i = 0; i < numLabels; i++) { - checkedLabelNames.insert(checkedLabelsArray->stringValue(i)); - } - - if ( ! checkedLabelNames.empty()) { - haveCheckedLabelsFlag = true; - - std::vector labelItems(getAllDescendantsOfType(LabelSelectionItem::ItemType::ITEM_LABEL)); - for (LabelSelectionItem* item : labelItems) { - if (checkedLabelNames.find(item->text()) != checkedLabelNames.end()) { item->setCheckState(Qt::Checked); - } - else { - item->setCheckState(Qt::Unchecked); - } - } - } - } - - if ( ! haveCheckedLabelsFlag) { - setCheckedStatusOfAllItems(true); - } - - updateCheckedStateOfAllItems(); - - //Uncomment if sub-classes must restore from scene - //restoreSubClassDataFromScene(sceneAttributes, - // sceneClass); -} - diff --git a/src/Files/LabelSelectionItemModel.h b/src/Files/LabelSelectionItemModel.h deleted file mode 100644 index 7ab0bcb81..000000000 --- a/src/Files/LabelSelectionItemModel.h +++ /dev/null @@ -1,141 +0,0 @@ -#ifndef __LABEL_SELECTION_ITEM_MODEL_H__ -#define __LABEL_SELECTION_ITEM_MODEL_H__ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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*/ - -#include -#include -#include -#include -#include - -#include - -#include "CaretHierarchy.h" -#include "DisplayGroupEnum.h" -#include "LabelSelectionItem.h" -#include "SceneableInterface.h" - - -namespace caret { - class ClusterContainer; - class GiftiLabel; - class GiftiLabelTable; - class SceneClassAssistant; - - class LabelSelectionItemModel : public QStandardItemModel, public SceneableInterface { - - Q_OBJECT - - public: - LabelSelectionItemModel(const AString& fileAndMapName, - GiftiLabelTable* giftiLabelTable, - const ClusterContainer* clusterContainer, - const DisplayGroupEnum::Enum displayGroup, - const int32_t tabIndex, - const bool logMismatchedLabelsFlag); - - virtual ~LabelSelectionItemModel(); - - bool isValid() const; - - LabelSelectionItemModel(const LabelSelectionItemModel&) = delete; - - LabelSelectionItemModel& operator=(const LabelSelectionItemModel&) = delete; - - bool isLabelChecked(const int32_t labelKey) const; - - void setCheckedStatusOfAllItems(const bool checked); - - void updateCheckedStateOfAllItems(); - - std::vector getAllDescendants(); - - std::vector getAllDescendantsOfType(const LabelSelectionItem::ItemType itemType); - - std::vector getTopLevelItems(); - - AString toFormattedString(const AString& indentation) const; - - void synchronizeSelectionsWithLabelTable(const bool copyToLabelTableFlag); - - // ADD_NEW_METHODS_HERE - - virtual SceneClass* saveToScene(const SceneAttributes* sceneAttributes, - const AString& instanceName); - - virtual void restoreFromScene(const SceneAttributes* sceneAttributes, - const SceneClass* sceneClass); - - - - - - -// If there will be sub-classes of this class that need to save -// and restore data from scenes, these pure virtual methods can -// be uncommented to force their implementation by sub-classes. -// protected: -// virtual void saveSubClassDataToScene(const SceneAttributes* sceneAttributes, -// SceneClass* sceneClass) = 0; -// -// virtual void restoreSubClassDataFromScene(const SceneAttributes* sceneAttributes, -// const SceneClass* sceneClass) = 0; - - private: - void buildModel(const ClusterContainer* clusterContainer); - - LabelSelectionItem* buildTree(const CaretHierarchy::Item* hierarchyItem, - const GiftiLabelTable* giftiLabelTable, - const ClusterContainer* clusterContainer); - - std::array getLabelRGBA(const GiftiLabel* label) const; - - const AString& m_fileAndMapName; - - GiftiLabelTable* m_giftiLabelTable; - - const DisplayGroupEnum::Enum m_displayGroup; - - const int32_t m_tabIndex; - - const bool m_logMismatchedLabelsFlag; - - std::unique_ptr m_sceneAssistant; - - std::map m_labelKeyToLabelSelectionItem; - - std::set m_buildTreeMissingLabelNames; - - std::set m_hierarchyParentNames; - - bool m_validFlag = false; - - // ADD_NEW_MEMBERS_HERE - - }; - -#ifdef __LABEL_SELECTION_ITEM_MODEL_DECLARE__ - // -#endif // __LABEL_SELECTION_ITEM_MODEL_DECLARE__ - -} // namespace -#endif //__LABEL_SELECTION_ITEM_MODEL_H__ diff --git a/src/Files/NodeAndVoxelColoring.cxx b/src/Files/NodeAndVoxelColoring.cxx index cd439ee0b..d669204f8 100644 --- a/src/Files/NodeAndVoxelColoring.cxx +++ b/src/Files/NodeAndVoxelColoring.cxx @@ -32,17 +32,13 @@ #include "CaretAssert.h" #include "CaretLogger.h" -#include "CaretMappableDataFile.h" #include "CaretOMP.h" #include "GiftiLabel.h" #include "GiftiLabelTable.h" #include "GroupAndNameHierarchyItem.h" -#include "LabelSelectionItem.h" -#include "LabelSelectionItemModel.h" #include "Palette.h" #include "PaletteColorMapping.h" #include "MathFunctions.h" -#include "TabDrawingInfo.h" using namespace caret; @@ -543,51 +539,16 @@ NodeAndVoxelColoring::colorScalarsWithRGBAPrivate(const float* redComponents, break; } - /* - * Examine data to see if it ranges [0,1]. - * Otherwise, it is [0, 255]. - */ - bool rangeOneFlag(false); - bool autoRangeDetectFlag(true); - if (autoRangeDetectFlag) { - rangeOneFlag = true; - const float valueOne(1.001); - for (int64_t i = 0; i < numberOfComponents; i++) { - if ((redComponents[i] > valueOne) - || (redComponents[i] < -valueOne) - || (greenComponents[i] > valueOne) - || (greenComponents[i] < -valueOne) - || (blueComponents[i] > valueOne) - || (blueComponents[i] < -valueOne)) { - rangeOneFlag = false; - break; - } - } - } - - const float scaleValue(rangeOneFlag - ? 255.0 - : 1.0); - for (int64_t i = 0; i < numberOfComponents; i++) { - float red = redComponents[i] * scaleValue; - float green = greenComponents[i] * scaleValue; - float blue = blueComponents[i] * scaleValue; + const float red = redComponents[i]; + const float green = greenComponents[i]; + const float blue = blueComponents[i]; float alpha = 0.0; - if (red < 0.0) red = -red; - if (green < 0.0) green = -green; - if (blue < 0.0) blue = -blue; - if (red > 255.0) red = 255.0; - if (green > 255.0) green = 255.0; - if (blue > 255.0) blue = 255.0; - if ((red >= thresholdRed) && (green >= thresholdGreen) && (blue >= thresholdBlue)) { - alpha = ((alphaComponents == NULL) ? 255.0 : (alphaComponents[i] * scaleValue)); - if (alpha < 0.0) alpha = -alpha; - if (alpha > 255.0) alpha = 255.0; + alpha = ((alphaComponents == NULL) ? 255.0 : alphaComponents[i]); } const int64_t i4 = i * 4; @@ -658,83 +619,61 @@ NodeAndVoxelColoring::colorScalarsWithRGBA(const float* redComponents, * The indices are are used to access colors in the label table. * @param numberOfIndices * Number of indices. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param rgbv * Output with assigned colors. Number of elements is (numberOfIndices * 4). */ void -NodeAndVoxelColoring::colorIndicesWithLabelTableForObliqueVolume(const GiftiLabelTable* labelTable, - const float* labelIndices, - const int64_t numberOfIndices, - const TabDrawingInfo& tabDrawingInfo, - uint8_t* rgbaOut) +NodeAndVoxelColoring::colorIndicesWithLabelTableForDisplayGroupTab(const GiftiLabelTable* labelTable, + const float* labelIndices, + const int64_t numberOfIndices, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, + float* rgbv) { - /* - * Invalidate all coloring. - */ - for (int64_t i = 0; i < numberOfIndices; i++) { - rgbaOut[i*4+3] = 0; - } - - const int32_t tabIndex(tabDrawingInfo.getTabIndex()); - const DisplayGroupEnum::Enum displayGroup(tabDrawingInfo.getDisplayGroup()); - const LabelViewModeEnum::Enum labelViewMode(tabDrawingInfo.getLabelViewMode()); - const LabelSelectionItemModel* labelModel(tabDrawingInfo.getMapFile()->getLabelSelectionHierarchyForMapAndTab(tabDrawingInfo.getMapIndex(), - displayGroup, - tabIndex)); - /* - * Assign colors from labels to nodes - */ - float labelRGBA[4]; - for (int64_t i = 0; i < numberOfIndices; i++) { - const int64_t labelKey = static_cast(labelIndices[i]); - const GiftiLabel* gl = labelTable->getLabel(labelKey); - if (gl != NULL) { - bool colorDataFlag = false; - switch (labelViewMode) { - case LabelViewModeEnum::HIERARCHY: - if (labelModel->isLabelChecked(labelKey)) { - colorDataFlag = true; - } - break; - case LabelViewModeEnum::LIST: - { - const GroupAndNameHierarchyItem* item = gl->getGroupNameSelectionItem(); - if (item != NULL) { - if (tabIndex == NodeAndVoxelColoring::INVALID_TAB_INDEX) { - colorDataFlag = true; - } - else if (item->isSelected(tabDrawingInfo)) { - colorDataFlag = true; - } - } - else { - colorDataFlag = true; - } - } - break; - } - - if (colorDataFlag) { - gl->getColor(labelRGBA); - if (labelRGBA[3] > 0.0) { - const int64_t i4 = i * 4; - - CaretAssertArrayIndex(rgbaUnsignedByte, numberOfIndices * 4, i*4+3); - rgbaOut[i4] = labelRGBA[0] * 255.0; - rgbaOut[i4+1] = labelRGBA[1] * 255.0; - rgbaOut[i4+2] = labelRGBA[2] * 255.0; - if (labelRGBA[3] > 0.0) { - rgbaOut[i4+3] = labelRGBA[3] * 255.0; - } - else { - rgbaOut[i4+3] = 0; - } - } - } - } - } + NodeAndVoxelColoring::colorIndicesWithLabelTableForDisplayGroupTabPrivate(labelTable, + labelIndices, + numberOfIndices, + displayGroup, + tabIndex, + COLOR_TYPE_FLOAT, + (void*)rgbv); +} + +/** + * Assign colors to label indices using a GIFTI label table. + * + * @param labelTabl + * Label table used for coloring and indexing with label indices. + * @param labelIndices + * The indices are are used to access colors in the label table. + * @param numberOfIndices + * Number of indices. + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. + * @param rgbv + * Output with assigned colors. Number of elements is (numberOfIndices * 4). + */ +void +NodeAndVoxelColoring::colorIndicesWithLabelTableForDisplayGroupTab(const GiftiLabelTable* labelTable, + const float* labelIndices, + const int64_t numberOfIndices, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, + uint8_t* rgbv) +{ + NodeAndVoxelColoring::colorIndicesWithLabelTableForDisplayGroupTabPrivate(labelTable, + labelIndices, + numberOfIndices, + displayGroup, + tabIndex, + COLOR_TYPE_UNSIGNED_BTYE, + (void*)rgbv); } /** diff --git a/src/Files/NodeAndVoxelColoring.h b/src/Files/NodeAndVoxelColoring.h index dad892201..97246333b 100644 --- a/src/Files/NodeAndVoxelColoring.h +++ b/src/Files/NodeAndVoxelColoring.h @@ -32,7 +32,6 @@ namespace caret { class FastStatistics; class GiftiLabelTable; class PaletteColorMapping; - class TabDrawingInfo; class NodeAndVoxelColoring { @@ -63,12 +62,23 @@ namespace caret { const uint8_t rgbThreshold[3], uint8_t* rgbaOut); - static void colorIndicesWithLabelTableForObliqueVolume(const GiftiLabelTable* labelTable, - const float* labelIndices, - const int64_t numberOfIndices, - const TabDrawingInfo& tabDrawingInfo, - uint8_t* rgbv); - + // JWH 24 April 2015 static const float SMALL_POSITIVE; + // JWH 24 April 2015 static const float SMALL_NEGATIVE; + + static void colorIndicesWithLabelTableForDisplayGroupTab(const GiftiLabelTable* labelTable, + const float* labelIndices, + const int64_t numberOfIndices, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, + float* rgbv); + + static void colorIndicesWithLabelTableForDisplayGroupTab(const GiftiLabelTable* labelTable, + const float* labelIndices, + const int64_t numberOfIndices, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, + uint8_t* rgbv); + static void colorIndicesWithLabelTable(const GiftiLabelTable* labelTable, const float* labelIndices, const int64_t numberOfIndices, diff --git a/src/Files/VolumeDynamicConnectivityFile.cxx b/src/Files/VolumeDynamicConnectivityFile.cxx index 616490d71..bd5debace 100644 --- a/src/Files/VolumeDynamicConnectivityFile.cxx +++ b/src/Files/VolumeDynamicConnectivityFile.cxx @@ -497,13 +497,17 @@ VolumeDynamicConnectivityFile::getConnectivityForVoxelIndex(const int64_t ijk[3] { bool validFlag(false); + const int64_t numVoxelsInSlice(m_dimI * m_dimJ * m_dimK); + const ConnectivityCorrelationTwo* connCorrelationTwo(getConnectivityCorrelationTwo()); if (connCorrelationTwo != NULL) { if (indexValid(ijk)) { const int64_t brainordinateIndex(m_parentVolumeFile->getIndex(ijk)); connCorrelationTwo->computeForDataSetIndex(brainordinateIndex, voxelsOut); - CaretAssert((m_dimI * m_dimJ * m_dimK) == static_cast(voxelsOut.size())); +#ifndef NDEBUG + CaretAssert(numVoxelsInSlice == static_cast(voxelsOut.size())); +#endif validFlag = true; } } diff --git a/src/Files/VolumeFile.cxx b/src/Files/VolumeFile.cxx index 54f94eaf4..8c3acf296 100644 --- a/src/Files/VolumeFile.cxx +++ b/src/Files/VolumeFile.cxx @@ -31,12 +31,9 @@ #include "ApplicationInformation.h" #include "CaretHttpManager.h" #include "CaretLogger.h" -#include "CaretMappableDataFileClusterFinder.h" -#include "CaretResult.h" #include "CaretTemporaryFile.h" #include "ChartDataCartesian.h" #include "ChartDataSource.h" -#include "ClusterContainer.h" #include "DataFileContentInformation.h" #include "ElapsedTimer.h" #include "EventManager.h" @@ -266,7 +263,6 @@ VolumeFile::clear() m_maxScalingVal = 1.0; m_graphicsPrimitiveManager->clear(); - m_mapLabelClusterContainers.clear(); } void VolumeFile::readFile(const AString& filename) @@ -506,8 +502,7 @@ VolumeFile::interpolateValue(const float* coordIn, const VoxelInterpolationTypeEnum::Enum interpType, bool* validOut, const int64_t brickIndex, - const int64_t component, - const float backgroundVal) const + const int64_t component) const { InterpType interp = CUBIC; switch (interpType) { @@ -526,16 +521,15 @@ VolumeFile::interpolateValue(const float* coordIn, interp, validOut, brickIndex, - component, - backgroundVal); + component); } -float VolumeFile::interpolateValue(const float* coordIn, InterpType interp, bool* validOut, const int64_t brickIndex, const int64_t component, const float backgroundVal) const +float VolumeFile::interpolateValue(const float* coordIn, InterpType interp, bool* validOut, const int64_t brickIndex, const int64_t component) const { - return interpolateValue(coordIn[0], coordIn[1], coordIn[2], interp, validOut, brickIndex, component, backgroundVal); + return interpolateValue(coordIn[0], coordIn[1], coordIn[2], interp, validOut, brickIndex, component); } -float VolumeFile::interpolateValue(const float coordIn1, const float coordIn2, const float coordIn3, InterpType interp, bool* validOut, const int64_t brickIndex, const int64_t component, const float backgroundVal) const +float VolumeFile::interpolateValue(const float coordIn1, const float coordIn2, const float coordIn3, InterpType interp, bool* validOut, const int64_t brickIndex, const int64_t component) const { /* * If the volume is a single slice, CUBIC and TRILINEAR will fail they @@ -565,7 +559,7 @@ float VolumeFile::interpolateValue(const float coordIn1, const float coordIn2, c { return getMapLabelTable(brickIndex)->getUnassignedLabelKey(); } else { - return backgroundVal; + return INVALID_INTERP_VALUE; } } int64_t whichFrame = component * dimensions[3] + brickIndex; @@ -591,7 +585,7 @@ float VolumeFile::interpolateValue(const float coordIn1, const float coordIn2, c { return getMapLabelTable(brickIndex)->getUnassignedLabelKey(); } else { - return backgroundVal; + return INVALID_INTERP_VALUE; } } } @@ -635,7 +629,7 @@ float VolumeFile::interpolateValue(const float coordIn1, const float coordIn2, c { return getMapLabelTable(brickIndex)->getUnassignedLabelKey(); } else { - return backgroundVal; + return INVALID_INTERP_VALUE; } } } @@ -646,7 +640,7 @@ float VolumeFile::interpolateValue(const float coordIn1, const float coordIn2, c { return getMapLabelTable(brickIndex)->getUnassignedLabelKey(); } else { - return backgroundVal; + return INVALID_INTERP_VALUE; } } @@ -1539,43 +1533,6 @@ VolumeFile::getMapLabelTable(const int32_t mapIndex) const return m_caretVolExt.m_attributes[mapIndex]->m_labelTable; } -/** - * @return The clusters for the given map's label table (may be NULL) - * @param mapIndex - * Index of the map - */ -const ClusterContainer* -VolumeFile::getMapLabelTableClusters(const int32_t mapIndex) const -{ - if (isMappedWithLabelTable()) { - /* - * If it does not exist, no attempt has been made to create it - */ - if (m_mapLabelClusterContainers.find(mapIndex) == m_mapLabelClusterContainers.end()) { - CaretMappableDataFileClusterFinder finder(CaretMappableDataFileClusterFinder::FindMode::VOLUME_LABEL, - this, - mapIndex); - const auto result(finder.findClusters()); - if (result->isSuccess()) { - m_mapLabelClusterContainers[mapIndex] = std::unique_ptr(finder.takeClusterContainer()); - } - else { - CaretLogWarning(result->getErrorDescription()); - ClusterContainer* nullPointer(NULL); - /* - * Putting a NULL in here, prevents running find clusters again - */ - m_mapLabelClusterContainers[mapIndex] = std::unique_ptr(nullPointer); - CaretAssertToDoFatal(); - } - } - - return m_mapLabelClusterContainers[mapIndex].get(); - } - - return NULL; -} - /** * @return Is the data in the file mapped to colors using * Red, Green, Blue, Alpha values. @@ -1811,8 +1768,10 @@ VolumeFile::updateScalarColoringForMap(const int32_t mapIndex) * Plane for which colors are requested. * @param sliceIndex * Index of the slice. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param rgbaOut * Contains colors upon exit. * @return @@ -1822,7 +1781,8 @@ int64_t VolumeFile::getVoxelColorsForSliceInMap(const int32_t mapIndex, const VolumeSliceViewPlaneEnum::Enum slicePlane, const int64_t sliceIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const { if (s_voxelColoringEnabled == false) { @@ -1834,7 +1794,8 @@ VolumeFile::getVoxelColorsForSliceInMap(const int32_t mapIndex, return m_voxelColorizer->getVoxelColorsForSliceInMap(mapIndex, slicePlane, sliceIndex, - tabDrawingInfo, + displayGroup, + tabIndex, rgbaOut); } @@ -1853,8 +1814,10 @@ VolumeFile::getVoxelColorsForSliceInMap(const int32_t mapIndex, * Number of rows. * @param numberOfColumns * Number of columns. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param rgbaOut * RGBA color components out. * @return @@ -1867,7 +1830,8 @@ VolumeFile::getVoxelColorsForSliceInMap(const int32_t mapIndex, const int64_t columnStepIJK[3], const int64_t numberOfRows, const int64_t numberOfColumns, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const { if (s_voxelColoringEnabled == false) { @@ -1882,7 +1846,8 @@ VolumeFile::getVoxelColorsForSliceInMap(const int32_t mapIndex, columnStepIJK, numberOfRows, numberOfColumns, - tabDrawingInfo, + displayGroup, + tabIndex, rgbaOut); } @@ -1901,8 +1866,10 @@ VolumeFile::getVoxelColorsForSliceInMap(const int32_t mapIndex, * Indices of voxel for last corner of sub-slice (inclusive). * @param voxelCountIJK * Voxel counts for each axis. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param rgbaOut * Output containing the rgba values (must have been allocated * by caller to sufficient count of elements in the slice). @@ -1916,7 +1883,8 @@ VolumeFile::getVoxelColorsForSubSliceInMap(const int32_t mapIndex, const int64_t firstCornerVoxelIndex[3], const int64_t lastCornerVoxelIndex[3], const int64_t voxelCountIJK[3], - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const { if (s_voxelColoringEnabled == false) { @@ -1931,7 +1899,8 @@ VolumeFile::getVoxelColorsForSubSliceInMap(const int32_t mapIndex, firstCornerVoxelIndex, lastCornerVoxelIndex, voxelCountIJK, - tabDrawingInfo, + displayGroup, + tabIndex, rgbaOut); } @@ -1940,18 +1909,25 @@ VolumeFile::getVoxelColorsForSubSliceInMap(const int32_t mapIndex, * * @param mapIndex * Index of the map. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. + * @param rgbaOut + * Output containing the rgba values (must have been allocated + * by caller to sufficient count of elements in the slice). * @return * Graphics primitive or NULL if unable to draw */ GraphicsPrimitiveV3fT3f* VolumeFile::getVolumeDrawingTriangleStripPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo) const + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex) const { return m_graphicsPrimitiveManager->getVolumeDrawingPrimitiveForMap(VolumeGraphicsPrimitiveManager::PrimitiveShape::TRIANGLE_STRIP, mapIndex, - tabDrawingInfo); + displayGroup, + tabIndex); } /** @@ -1959,18 +1935,25 @@ VolumeFile::getVolumeDrawingTriangleStripPrimitive(const int32_t mapIndex, * * @param mapIndex * Index of the map. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. + * @param rgbaOut + * Output containing the rgba values (must have been allocated + * by caller to sufficient count of elements in the slice). * @return * Graphics primitive or NULL if unable to draw */ GraphicsPrimitiveV3fT3f* VolumeFile::getVolumeDrawingTriangleFanPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo) const + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex) const { return m_graphicsPrimitiveManager->getVolumeDrawingPrimitiveForMap(VolumeGraphicsPrimitiveManager::PrimitiveShape::TRIANGLE_FAN, mapIndex, - tabDrawingInfo); + displayGroup, + tabIndex); } /** @@ -1978,26 +1961,35 @@ VolumeFile::getVolumeDrawingTriangleFanPrimitive(const int32_t mapIndex, * * @param mapIndex * Index of the map. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. + * @param rgbaOut + * Output containing the rgba values (must have been allocated + * by caller to sufficient count of elements in the slice). * @return * Graphics primitive or NULL if unable to draw */ GraphicsPrimitiveV3fT3f* VolumeFile::getVolumeDrawingTrianglesPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo) const + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex) const { return m_graphicsPrimitiveManager->getVolumeDrawingPrimitiveForMap(VolumeGraphicsPrimitiveManager::PrimitiveShape::TRIANGLES, mapIndex, - tabDrawingInfo); + displayGroup, + tabIndex); } /** * Create a graphics primitive for showing part of volume that intersects with an image from histology * @param mapIndex * Index of the map. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param mediaFile * The medial file for drawing histology * @param volumeMappingMode @@ -2011,7 +2003,8 @@ VolumeFile::getVolumeDrawingTrianglesPrimitive(const int32_t mapIndex, */ GraphicsPrimitive* VolumeFile::getHistologyImageIntersectionPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, const MediaFile* mediaFile, const VolumeToImageMappingModeEnum::Enum volumeMappingMode, const float volumeSliceThickness, @@ -2019,7 +2012,8 @@ VolumeFile::getHistologyImageIntersectionPrimitive(const int32_t mapIndex, { return m_graphicsPrimitiveManager->getImageIntersectionDrawingPrimitiveForMap(mediaFile, mapIndex, - tabDrawingInfo, + displayGroup, + tabIndex, volumeMappingMode, volumeSliceThickness, errorMessageOut); @@ -2029,8 +2023,10 @@ VolumeFile::getHistologyImageIntersectionPrimitive(const int32_t mapIndex, * Create a graphics primitive for showing part of volume that intersects with an image from histology * @param mapIndex * Index of the map. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param histologySlice * The histology slice being drawn * @param errorMessageOut @@ -2040,7 +2036,8 @@ VolumeFile::getHistologyImageIntersectionPrimitive(const int32_t mapIndex, */ std::vector VolumeFile::getHistologySliceIntersectionPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, const HistologySlice* histologySlice, const VolumeToImageMappingModeEnum::Enum volumeMappingMode, const float volumeSliceThickness, @@ -2048,7 +2045,8 @@ VolumeFile::getHistologySliceIntersectionPrimitive(const int32_t mapIndex, { return m_graphicsPrimitiveManager->getImageIntersectionDrawingPrimitiveForMap(histologySlice, mapIndex, - tabDrawingInfo, + displayGroup, + tabIndex, volumeMappingMode, volumeSliceThickness, errorMessageOut); @@ -2174,8 +2172,10 @@ VolumeFile::getVoxelColorInMap(const int64_t i, * Axial index * @param mapIndex * Index of map. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param rgbaOut * Contains voxel coloring on exit. */ @@ -2184,7 +2184,8 @@ VolumeFile::getVoxelColorInMap(const int64_t i, const int64_t j, const int64_t k, const int64_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t rgbaOut[4]) const { if (s_voxelColoringEnabled == false) { @@ -2197,7 +2198,8 @@ VolumeFile::getVoxelColorInMap(const int64_t i, j, k, mapIndex, - tabDrawingInfo, + displayGroup, + tabIndex, rgbaOut); } @@ -2607,25 +2609,6 @@ VolumeFile::addToDataFileContentInformation(DataFileContentInformation& dataFile dataFileInformation.addNameAndValue("Spacing", AString::fromNumbers(spacing, 3, ", ")); - if (isMappedWithLabelTable()) { - for (int32_t i = 0; i < getNumberOfMaps(); i++) { - CaretMappableDataFileClusterFinder finder(CaretMappableDataFileClusterFinder::FindMode::VOLUME_LABEL, - this, - i); - const auto result(finder.findClusters()); - if (result->isSuccess()) { - const AString mapName(getMapName(i).isEmpty() - ? AString::number(i + 1) - : getMapName(i)); - dataFileInformation.addText("Clusters for map: " + mapName + "\n"); - dataFileInformation.addText(finder.getClustersInFormattedString()); - } - else { - CaretLogWarning("Finding clusters error: " - + result->getErrorDescription()); - } - } - } } /** @@ -3209,66 +3192,3 @@ VolumeFile::setValuesForVoxelEditing(const int32_t mapIndex, } } -/** - * Get the 26 connected neighbors for a voxel.l - * @param voxelIJK - * Indices of voxel - * @param voxelValues - * Pointer to first value in the slice (must contain I * J * K values) also known as 'frame' - * @param minValue - * Minimum data value for neighbor (inclusive) - * @param maxValue - * Maximum data value for neighbor (inclusive) - * @param voxelHasBeenSearchedFlags - * A vector that indicates a voxel has been searched and is not added to the neighbors. - * These flags are updated for any voxel that is added to the neighbors. - * @param neighborIJKs - * Voxels that are neighbors with a value in the range and have not been searched - * are APPENDED to this vector (any values in thie vector on entry remain in the - * vector on exit).. - */ -void -VolumeFile::getNeigbors26(const VoxelIJK& voxelIJK, - const float* voxelValues, - const float minimumValue, - const float maximumValue, - std::vector& voxelHasBeenSearchedFlags, - std::vector& neighborIJKs) const -{ - const VolumeSpace vs(getVolumeSpace()); - CaretUsedInDebugCompileOnly(const int64_t* dims(vs.getDims())); - CaretAssert(static_cast(voxelHasBeenSearchedFlags.size()) - == (dims[0] * dims[1] * dims[2])); - - CaretAssert((voxelIJK.m_ijk[0] >= 0) && (voxelIJK.m_ijk[0] < dims[0])); - CaretAssert((voxelIJK.m_ijk[1] >= 0) && (voxelIJK.m_ijk[1] < dims[1])); - CaretAssert((voxelIJK.m_ijk[2] >= 0) && (voxelIJK.m_ijk[2] < dims[2])); - - for (int64_t i = -1; i <= 1; i++) { - for (int64_t j = -1; j <= 1; j++) { - for (int64_t k = -1; k <= 1; k++) { - if ((i != 0) || (j != 0) || (k != 0)) { /* ignore self */ - const int64_t vi(voxelIJK.m_ijk[0] + i); - const int64_t vj(voxelIJK.m_ijk[1] + j); - const int64_t vk(voxelIJK.m_ijk[2] + k); - if (vs.indexValid(vi, vj, vk)) { - const int64_t offset(vs.getIndex(vi, vj, vk)); - CaretAssertVectorIndex(voxelHasBeenSearchedFlags, offset); - if ( ! voxelHasBeenSearchedFlags[offset]) { - const float v(voxelValues[offset]); - if ((v >= minimumValue) - && (v <= maximumValue)) { - CaretAssert((vi >= 0) && (vi < dims[0])); - CaretAssert((vj >= 0) && (vj < dims[1])); - CaretAssert((vk >= 0) && (vk < dims[2])); - neighborIJKs.emplace_back(vi, vj, vk); - voxelHasBeenSearchedFlags[offset] = 1; - } - } - } - } - } - } - } -} - diff --git a/src/Files/VolumeFile.h b/src/Files/VolumeFile.h index 8c45b03d2..761607f73 100644 --- a/src/Files/VolumeFile.h +++ b/src/Files/VolumeFile.h @@ -22,7 +22,6 @@ */ /*LICENSE_END*/ -#include #include #include "BrainConstants.h" @@ -145,8 +144,6 @@ namespace caret { double m_minScalingVal, m_maxScalingVal; - mutable std::map> m_mapLabelClusterContainers; - protected: VolumeFile(const DataFileTypeEnum::Enum dataFileType); @@ -202,11 +199,11 @@ namespace caret { void freeSpline(const int64_t brickIndex = 0, const int64_t component = 0) const; - float interpolateValue(const float* coordIn, InterpType interp = TRILINEAR, bool* validOut = NULL, const int64_t brickIndex = 0, const int64_t component = 0, const float backgroundVal = INVALID_INTERP_VALUE) const; + float interpolateValue(const float* coordIn, InterpType interp = TRILINEAR, bool* validOut = NULL, const int64_t brickIndex = 0, const int64_t component = 0) const; - float interpolateValue(const float coordIn1, const float coordIn2, const float coordIn3, InterpType interp = TRILINEAR, bool* validOut = NULL, const int64_t brickIndex = 0, const int64_t component = 0, const float backgroundVal = INVALID_INTERP_VALUE) const; + float interpolateValue(const float coordIn1, const float coordIn2, const float coordIn3, InterpType interp = TRILINEAR, bool* validOut = NULL, const int64_t brickIndex = 0, const int64_t component = 0) const; - float interpolateValue(const float* coordIn, const VoxelInterpolationTypeEnum::Enum interpType = VoxelInterpolationTypeEnum::TRILINEAR, bool* validOut = NULL, const int64_t brickIndex = 0, const int64_t component = 0, const float backgroundVal = INVALID_INTERP_VALUE) const; + float interpolateValue(const float* coordIn, const VoxelInterpolationTypeEnum::Enum interpType = VoxelInterpolationTypeEnum::TRILINEAR, bool* validOut = NULL, const int64_t brickIndex = 0, const int64_t component = 0) const; ///returns true if volume space matches in spatial dimensions and sform bool matchesVolumeSpace(const VolumeFile* right) const; @@ -323,8 +320,6 @@ namespace caret { const GiftiLabelTable* getMapLabelTable(const int32_t mapIndex) const; - virtual const ClusterContainer* getMapLabelTableClusters(const int32_t mapIndex) const override; - void getVoxelIndicesWithLabelKey(const int32_t mapIndex, const int32_t labelKey, std::vector& voxelIndicesOut) const; @@ -347,14 +342,16 @@ namespace caret { const int64_t columnStepIJK[3], const int64_t numberOfRows, const int64_t numberOfColumns, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const override; virtual int64_t getVoxelColorsForSliceInMap( const int32_t mapIndex, const VolumeSliceViewPlaneEnum::Enum slicePlane, const int64_t sliceIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const override; virtual int64_t getVoxelColorsForSubSliceInMap( @@ -364,27 +361,33 @@ namespace caret { const int64_t firstCornerVoxelIndex[3], const int64_t lastCornerVoxelIndex[3], const int64_t voxelCountIJK[3], - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const override; virtual GraphicsPrimitiveV3fT3f* getVolumeDrawingTriangleStripPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo) const override; + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex) const override; virtual GraphicsPrimitiveV3fT3f* getVolumeDrawingTriangleFanPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo) const override; + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex) const override; virtual GraphicsPrimitiveV3fT3f* getVolumeDrawingTrianglesPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo) const override; + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex) const override; virtual GraphicsPrimitive* getHistologyImageIntersectionPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, const MediaFile* mediaFile, const VolumeToImageMappingModeEnum::Enum volumeMappingMode, const float volumeSliceThickness, AString& errorMessageOut) const override; virtual std::vector getHistologySliceIntersectionPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, const HistologySlice* histologySlice, const VolumeToImageMappingModeEnum::Enum volumeMappingMode, const float volumeSliceThickness, @@ -405,7 +408,8 @@ namespace caret { const int64_t j, const int64_t k, const int64_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t rgbaOut[4]) const override; void clearVoxelColoringForMap(const int64_t mapIndex); @@ -467,15 +471,6 @@ namespace caret { void setValuesForVoxelEditing(const int32_t mapIndex, const std::vector& voxelsIJK, const float value); - - void getNeigbors26(const VoxelIJK& voxelIJK, - const float* voxelValues, - const float minimumValue, - const float maximumValue, - std::vector& voxelHasBeenSearchedFlags, - std::vector& neighborIJKs) const; - - }; } diff --git a/src/Files/VolumeFileVoxelColorizer.cxx b/src/Files/VolumeFileVoxelColorizer.cxx index 35608056d..a0fb47b18 100644 --- a/src/Files/VolumeFileVoxelColorizer.cxx +++ b/src/Files/VolumeFileVoxelColorizer.cxx @@ -25,14 +25,11 @@ #include "CaretAssert.h" #include "CaretLogger.h" -#include "DataFileColorModulateSelector.h" #include "ElapsedTimer.h" #include "GiftiLabel.h" #include "GroupAndNameHierarchyItem.h" -#include "LabelSelectionItemModel.h" #include "NodeAndVoxelColoring.h" #include "Palette.h" -#include "TabDrawingInfo.h" #include "VolumeFile.h" #include "VoxelColorUpdate.h" @@ -251,7 +248,7 @@ VolumeFileVoxelColorizer::assignVoxelColorsForMap(const int32_t mapIndex) const * Use first 3 maps as RGB components */ const float* alphaComponents(NULL); - const uint8_t thresholdRGB[3] = { 0, 0, 0 }; + const uint8_t thresholdRGB[3] = { 5, 5, 5 }; NodeAndVoxelColoring::colorScalarsWithRGBA(m_volumeFile->getFrame(0), m_volumeFile->getFrame(1), m_volumeFile->getFrame(2), @@ -272,10 +269,6 @@ VolumeFileVoxelColorizer::assignVoxelColorsForMap(const int32_t mapIndex) const break; } - if (m_mapColoringValid[mapIndex]) { - applyColorModulation(mapIndex); - } - CaretLogFine("Time to color map named \"" + m_volumeFile->getMapName(mapIndex) + " in volume file " @@ -285,56 +278,6 @@ VolumeFileVoxelColorizer::assignVoxelColorsForMap(const int32_t mapIndex) const + " milliseconds"); } -/** - * Apply color modulation with another volume file. - * Data in modulation file should range [0, 1] and be a single component map. - * @param mapIndex - * Index of map in file being colorized - */ -void -VolumeFileVoxelColorizer::applyColorModulation(const int32_t mapIndex) const -{ - const DataFileColorModulateSelector* modulateSelector(m_volumeFile->getMapColorModulateFileSelector(mapIndex)); - CaretAssert(modulateSelector); - if (modulateSelector->isEnabled()) { - const VolumeFile* modulateVolumeFile(modulateSelector->getSelectedVolumeFile()); - if (modulateVolumeFile != NULL) { - const int32_t modulateMapIndex(modulateSelector->getSelectedMapIndex()); - if ((modulateMapIndex >= 0) - && (modulateMapIndex < modulateVolumeFile->getNumberOfMaps())) { - int64_t dimI, dimJ, dimK, mapCount, numComps; - modulateVolumeFile->getDimensions(dimI, - dimJ, - dimK, - mapCount, - numComps); - if ((dimI == m_dimI) - && (dimJ == m_dimJ) - && (dimK == m_dimK)) { - const int64_t componentIndex(0); - const float* modData(modulateVolumeFile->getFrame(modulateMapIndex, - componentIndex)); - - CaretAssertVectorIndex(m_mapRGBA, mapIndex); - uint8_t* rgba(m_mapRGBA[mapIndex]); - - for (int64_t i = 0; i < m_voxelCountPerMap; i++) { - float modValue(modData[i]); - if (modValue > 1.0) modValue = 1.0; - if (modValue < 0.0) modValue = 0.0; - - const int64_t i4(i * 4); - for (int64_t j = 0; j < 3; j++) { - const float v(static_cast(rgba[i4 + j]) * modValue); - rgba[i4 + j] = static_cast(v); - } - } - } - } - } - } -} - /** * Invalidate the RGBA coloring for all maps. */ @@ -357,8 +300,10 @@ VolumeFileVoxelColorizer::invalidateColoring() * Plane of the slice. * @param sliceIndex * Index of the slice. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param rgbaOut * RGBA color components out. * @return @@ -368,7 +313,8 @@ int64_t VolumeFileVoxelColorizer::getVoxelColorsForSliceInMap(const int32_t mapIndex, const VolumeSliceViewPlaneEnum::Enum slicePlane, const int64_t sliceIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const { CaretAssertVectorIndex(m_mapRGBA, mapIndex); @@ -416,9 +362,6 @@ VolumeFileVoxelColorizer::getVoxelColorsForSliceInMap(const int32_t mapIndex, CaretAssert(labelTable); } - const LabelSelectionItemModel* labelSelectionItemModel(m_volumeFile->getLabelSelectionHierarchyForMapAndTab(mapIndex, - tabDrawingInfo.getDisplayGroup(), - tabDrawingInfo.getTabIndex())); int64_t validVoxelCount = 0; /* @@ -448,22 +391,11 @@ VolumeFileVoxelColorizer::getVoxelColorsForSliceInMap(const int32_t mapIndex, mapIndex)); const GiftiLabel* label = labelTable->getLabel(dataValue); if (label != NULL) { - switch (tabDrawingInfo.getLabelViewMode()) { - case LabelViewModeEnum::HIERARCHY: - if ( ! labelSelectionItemModel->isLabelChecked(dataValue)) { - alpha = 0; - } - break; - case LabelViewModeEnum::LIST: - { - const GroupAndNameHierarchyItem* item = label->getGroupNameSelectionItem(); - if (item != NULL) { - if ( ! item->isSelected(tabDrawingInfo)) { - alpha = 0; - } - } + const GroupAndNameHierarchyItem* item = label->getGroupNameSelectionItem(); + if (item != NULL) { + if (item->isSelected(displayGroup, tabIndex) == false) { + alpha = 0; } - break; } } } @@ -496,8 +428,10 @@ VolumeFileVoxelColorizer::getVoxelColorsForSliceInMap(const int32_t mapIndex, * Number of rows. * @param numberOfColumns * Number of columns. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param rgbaOut * RGBA color components out. * @return @@ -510,7 +444,8 @@ VolumeFileVoxelColorizer::getVoxelColorsForSliceInMap(const int32_t mapIndex, const int64_t columnStepIJK[3], const int64_t numberOfRows, const int64_t numberOfColumns, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const { CaretAssertVectorIndex(m_mapColoringValid, mapIndex); @@ -530,10 +465,6 @@ VolumeFileVoxelColorizer::getVoxelColorsForSliceInMap(const int32_t mapIndex, CaretAssert(labelTable); } - const LabelSelectionItemModel* labelSelectionItemModel(m_volumeFile->getLabelSelectionHierarchyForMapAndTab(mapIndex, - tabDrawingInfo.getDisplayGroup(), - tabDrawingInfo.getTabIndex())); - int64_t validVoxelCount = 0; int64_t rgbaOutIndex = 0; @@ -561,21 +492,10 @@ VolumeFileVoxelColorizer::getVoxelColorsForSliceInMap(const int32_t mapIndex, mapIndex)); const GiftiLabel* label = labelTable->getLabel(dataValue); if (label != NULL) { - switch (tabDrawingInfo.getLabelViewMode()) { - case LabelViewModeEnum::HIERARCHY: - if ( ! labelSelectionItemModel->isLabelChecked(dataValue)) { - alpha = 0; - } - break; - case LabelViewModeEnum::LIST: - { - const GroupAndNameHierarchyItem* item = label->getGroupNameSelectionItem(); - if (item != NULL) { - if ( ! item->isSelected(tabDrawingInfo.getDisplayGroup(), - tabDrawingInfo.getTabIndex())) { - alpha = 0; - } - } + const GroupAndNameHierarchyItem* item = label->getGroupNameSelectionItem(); + if (item != NULL) { + if (item->isSelected(displayGroup, tabIndex) == false) { + alpha = 0; } } } @@ -585,11 +505,6 @@ VolumeFileVoxelColorizer::getVoxelColorsForSliceInMap(const int32_t mapIndex, if (alpha > 0.0) { ++validVoxelCount; } - if (alpha == 0) { /* Fixes labels on/off in MPR */ - rgbaOut[rgbaOutIndex] = 0; - rgbaOut[rgbaOutIndex+1] = 0; - rgbaOut[rgbaOutIndex+2] = 0; - } rgbaOut[rgbaOutIndex+3] = alpha; rgbaOutIndex += 4; @@ -623,8 +538,10 @@ VolumeFileVoxelColorizer::getVoxelColorsForSliceInMap(const int32_t mapIndex, * Indices of voxel for last corner of sub-slice (inclusive). * @param voxelCountIJK * Voxel counts for each axis. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param rgbaOut * RGBA color components out. * @return @@ -637,7 +554,8 @@ VolumeFileVoxelColorizer::getVoxelColorsForSubSliceInMap(const int32_t mapIndex, const int64_t firstCornerVoxelIndex[3], const int64_t lastCornerVoxelIndex[3], const int64_t* CaretParameterUsedInDebugCompileOnly(voxelCountIJK), - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const { CaretAssertVectorIndex(m_mapRGBA, mapIndex); @@ -649,10 +567,6 @@ VolumeFileVoxelColorizer::getVoxelColorsForSubSliceInMap(const int32_t mapIndex, assignVoxelColorsForMap(mapIndex); } - const LabelSelectionItemModel* labelSelectionItemModel(m_volumeFile->getLabelSelectionHierarchyForMapAndTab(mapIndex, - tabDrawingInfo.getDisplayGroup(), - tabDrawingInfo.getTabIndex())); - VolumeSpace::OrientTypes orient[3]; m_volumeFile->getOrientation(orient); int orient2dim[3]; @@ -754,23 +668,12 @@ VolumeFileVoxelColorizer::getVoxelColorsForSubSliceInMap(const int32_t mapIndex, const GiftiLabel* label = labelTable->getLabel(dataValue); if (label != NULL) { - switch (tabDrawingInfo.getLabelViewMode()) { - case LabelViewModeEnum::HIERARCHY: - if ( ! labelSelectionItemModel->isLabelChecked(dataValue)) { - alpha = 0; - } - break; - case LabelViewModeEnum::LIST: + const GroupAndNameHierarchyItem* item = label->getGroupNameSelectionItem(); + if (item != NULL) + { + if (item->isSelected(displayGroup, tabIndex) == false) { - const GroupAndNameHierarchyItem* item = label->getGroupNameSelectionItem(); - if (item != NULL) - { - if ( ! item->isSelected(tabDrawingInfo.getDisplayGroup(), - tabDrawingInfo.getTabIndex())) - { - alpha = 0; - } - } + alpha = 0; } } } @@ -839,8 +742,10 @@ VolumeFileVoxelColorizer::getVoxelColorInMap(const int64_t i, * Axial index * @param mapIndex * Index of map. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param rgbaOut * Contains voxel coloring on exit. */ @@ -849,7 +754,8 @@ VolumeFileVoxelColorizer::getVoxelColorInMap(const int64_t i, const int64_t j, const int64_t k, const int64_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t rgbaOut[4]) const { // CaretAssertVectorIndex(m_mapColoringValid, mapIndex); @@ -869,9 +775,6 @@ VolumeFileVoxelColorizer::getVoxelColorInMap(const int64_t i, // rgbaOut[2] = mapRGBA[rgbaOffset+2]; // uint8_t alpha = mapRGBA[rgbaOffset+3]; - const LabelSelectionItemModel* labelSelectionItemModel(m_volumeFile->getLabelSelectionHierarchyForMapAndTab(mapIndex, - tabDrawingInfo.getDisplayGroup(), - tabDrawingInfo.getTabIndex())); getVoxelColorInMap(i, j, k, mapIndex, rgbaOut); @@ -892,21 +795,10 @@ VolumeFileVoxelColorizer::getVoxelColorInMap(const int64_t i, mapIndex)); const GiftiLabel* label = labelTable->getLabel(dataValue); if (label != NULL) { - switch (tabDrawingInfo.getLabelViewMode()) { - case LabelViewModeEnum::HIERARCHY: - if ( ! labelSelectionItemModel->isLabelChecked(dataValue)) { - alpha = 0; - } - break; - case LabelViewModeEnum::LIST: - { - const GroupAndNameHierarchyItem* item = label->getGroupNameSelectionItem(); - if (item != NULL) { - if ( ! item->isSelected(tabDrawingInfo.getDisplayGroup(), - tabDrawingInfo.getTabIndex())) { - alpha = 0; - } - } + const GroupAndNameHierarchyItem* item = label->getGroupNameSelectionItem(); + if (item != NULL) { + if (item->isSelected(displayGroup, tabIndex) == false) { + alpha = 0; } } } diff --git a/src/Files/VolumeFileVoxelColorizer.h b/src/Files/VolumeFileVoxelColorizer.h index c56fb31e5..0e57d3d97 100644 --- a/src/Files/VolumeFileVoxelColorizer.h +++ b/src/Files/VolumeFileVoxelColorizer.h @@ -23,12 +23,12 @@ #include "CaretObject.h" +#include "DisplayGroupEnum.h" #include "VolumeSliceViewPlaneEnum.h" #include "VoxelIJK.h" namespace caret { - class TabDrawingInfo; class VolumeFile; class VoxelColorUpdate; @@ -47,13 +47,15 @@ namespace caret { const int64_t columnStepIJK[3], const int64_t numberOfRows, const int64_t numberOfColumns, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const; int64_t getVoxelColorsForSliceInMap(const int32_t mapIndex, const VolumeSliceViewPlaneEnum::Enum slicePlane, const int64_t sliceIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const; int64_t getVoxelColorsForSubSliceInMap(const int32_t mapIndex, @@ -62,7 +64,8 @@ namespace caret { const int64_t firstCornerVoxelIndex[3], const int64_t lastCornerVoxelIndex[3], const int64_t* voxelCountIJK, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const; void getVoxelColorInMap(const int64_t i, @@ -75,7 +78,8 @@ namespace caret { const int64_t j, const int64_t k, const int64_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t rgbaOut[4]) const; void updateVoxelColorsInMap(const VoxelColorUpdate& voxelColorUpdate); @@ -109,8 +113,6 @@ namespace caret { + ((ijk[2] * m_dimI * m_dimJ)))); } - void applyColorModulation(const int32_t mapIndex) const; - // ADD_NEW_MEMBERS_HERE VolumeFile* m_volumeFile; diff --git a/src/Files/VolumeGraphicsPrimitiveManager.cxx b/src/Files/VolumeGraphicsPrimitiveManager.cxx index 61592fdf5..140e19174 100644 --- a/src/Files/VolumeGraphicsPrimitiveManager.cxx +++ b/src/Files/VolumeGraphicsPrimitiveManager.cxx @@ -31,7 +31,6 @@ #include "GraphicsUtilitiesOpenGL.h" #include "HistologySlice.h" #include "ImageFile.h" -#include "TabDrawingInfo.h" #include "VolumeMappableInterface.h" #include "VolumeToImageMapping.h" @@ -106,18 +105,15 @@ VolumeGraphicsPrimitiveManager::clearIntersectionImagePrimitives() void VolumeGraphicsPrimitiveManager::invalidateAllColoring() { - m_mapGraphicsTrianglesPrimitives.clear(); - m_mapGraphicsTriangleFanPrimitives.clear(); - m_mapGraphicsTriangleStripPrimitives.clear(); -// for (auto& p : m_mapGraphicsTriangleFanPrimitives) { -// p.reset(); -// } -// for (auto& p : m_mapGraphicsTriangleStripPrimitives) { -// p.reset(); -// } -// for (auto& p : m_mapGraphicsTrianglesPrimitives) { -// p.reset(); -// } + for (auto& p : m_mapGraphicsTriangleFanPrimitives) { + p.reset(); + } + for (auto& p : m_mapGraphicsTriangleStripPrimitives) { + p.reset(); + } + for (auto& p : m_mapGraphicsTrianglesPrimitives) { + p.reset(); + } clearIntersectionImagePrimitives(); } @@ -129,39 +125,19 @@ VolumeGraphicsPrimitiveManager::invalidateAllColoring() void VolumeGraphicsPrimitiveManager::invalidateColoringForMap(const int32_t mapIndex) { - { - std::vector removeKeys; - for (auto& m : m_mapGraphicsTriangleFanPrimitives) { - if (m.first.m_mapIndex == mapIndex) - removeKeys.push_back(m.first); - } - for (auto key : removeKeys) { - m_mapGraphicsTriangleFanPrimitives.erase(key); - } + if ((mapIndex >= 0) + && (mapIndex < static_cast(m_mapGraphicsTriangleFanPrimitives.size()))) { + m_mapGraphicsTriangleFanPrimitives[mapIndex].reset(); } - - { - std::vector removeKeys; - for (auto& m : m_mapGraphicsTriangleStripPrimitives) { - if (m.first.m_mapIndex == mapIndex) - removeKeys.push_back(m.first); - } - for (auto key : removeKeys) { - m_mapGraphicsTriangleStripPrimitives.erase(key); - } + if ((mapIndex >= 0) + && (mapIndex < static_cast(m_mapGraphicsTriangleStripPrimitives.size()))) { + m_mapGraphicsTriangleStripPrimitives[mapIndex].reset(); } - - { - std::vector removeKeys; - for (auto& m : m_mapGraphicsTrianglesPrimitives) { - if (m.first.m_mapIndex == mapIndex) - removeKeys.push_back(m.first); - } - for (auto key : removeKeys) { - m_mapGraphicsTrianglesPrimitives.erase(key); - } + if ((mapIndex >= 0) + && (mapIndex < static_cast(m_mapGraphicsTrianglesPrimitives.size()))) { + m_mapGraphicsTrianglesPrimitives[mapIndex].reset(); } - + /* * Remove any items with key that contains map index * (1) Get the key while avoiding invalidating the iterator @@ -190,57 +166,42 @@ VolumeGraphicsPrimitiveManager::invalidateColoringForMap(const int32_t mapIndex) * Shape for primitive drawing * @param mapIndex * Index of the map. - * @param tabDrawingInfo - * Info for drawing tab. + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @return * Graphics primitive or NULL if unable to draw */ GraphicsPrimitiveV3fT3f* VolumeGraphicsPrimitiveManager::getVolumeDrawingPrimitiveForMap(const PrimitiveShape primitiveShape, const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo) const + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex) const { - /* - * Each map in a volume requires its own primitive since each map is - * colored differently. - * - * For label volume types: Display of particular labels is performed in each tab - * and may be unique for each tab. Therefore if this is a label volume, - * we must also have a unique primitive for each tab. - * - * For all other volume types: Coloring is the same in all tabs so use - * 'tabZeroIndex' for this volume types. - */ - const bool labelVolumeFlag(tabDrawingInfo.getMapFile()->isMappedWithLabelTable()); - const int32_t tabZeroIndex(0); - PrimitiveKey key(tabDrawingInfo.getMapIndex(), - (labelVolumeFlag ? tabDrawingInfo.getTabIndex() : tabZeroIndex)); - + if (m_mapDataFile->getNumberOfMaps() != static_cast(m_mapGraphicsTriangleFanPrimitives.size())) { + m_mapGraphicsTriangleFanPrimitives.resize(mapIndex + 1); + } + if (m_mapDataFile->getNumberOfMaps() != static_cast(m_mapGraphicsTriangleStripPrimitives.size())) { + m_mapGraphicsTriangleStripPrimitives.resize(mapIndex + 1); + } + if (m_mapDataFile->getNumberOfMaps() != static_cast(m_mapGraphicsTrianglesPrimitives.size())) { + m_mapGraphicsTrianglesPrimitives.resize(mapIndex + 1); + } + GraphicsPrimitiveV3fT3f* primitiveOut(NULL); switch (primitiveShape) { case PrimitiveShape::TRIANGLE_FAN: - { - auto iter(m_mapGraphicsTriangleFanPrimitives.find(key)); - if (iter != m_mapGraphicsTriangleFanPrimitives.end()) { - primitiveOut = iter->second.get(); - } - } + CaretAssertVectorIndex(m_mapGraphicsTriangleFanPrimitives, mapIndex); + primitiveOut = m_mapGraphicsTriangleFanPrimitives[mapIndex].get(); break; case PrimitiveShape::TRIANGLE_STRIP: - { - auto iter(m_mapGraphicsTriangleStripPrimitives.find(key)); - if (iter != m_mapGraphicsTriangleStripPrimitives.end()) { - primitiveOut = iter->second.get(); - } - } + CaretAssertVectorIndex(m_mapGraphicsTriangleStripPrimitives, mapIndex); + primitiveOut = m_mapGraphicsTriangleStripPrimitives[mapIndex].get(); break; case PrimitiveShape::TRIANGLES: - { - auto iter(m_mapGraphicsTrianglesPrimitives.find(key)); - if (iter != m_mapGraphicsTrianglesPrimitives.end()) { - primitiveOut = iter->second.get(); - } - } + CaretAssertVectorIndex(m_mapGraphicsTrianglesPrimitives, mapIndex); + primitiveOut = m_mapGraphicsTrianglesPrimitives[mapIndex].get(); break; } @@ -266,22 +227,22 @@ VolumeGraphicsPrimitiveManager::getVolumeDrawingPrimitiveForMap(const PrimitiveS AString errorMessage; primitiveOut = VolumeGraphicsPrimitiveManager::createPrimitive(primitiveShape, mapIndex, - tabDrawingInfo, + displayGroup, + tabIndex, errorMessage); if (primitiveOut != NULL) { - std::unique_ptr ptr(primitiveOut); switch (primitiveShape) { case PrimitiveShape::TRIANGLE_FAN: - m_mapGraphicsTriangleFanPrimitives.insert(std::make_pair(key, - std::move(ptr))); + CaretAssertVectorIndex(m_mapGraphicsTriangleFanPrimitives, mapIndex); + m_mapGraphicsTriangleFanPrimitives[mapIndex].reset(primitiveOut); break; case PrimitiveShape::TRIANGLE_STRIP: - m_mapGraphicsTriangleStripPrimitives.insert(std::make_pair(key, - std::move(ptr))); + CaretAssertVectorIndex(m_mapGraphicsTriangleStripPrimitives, mapIndex); + m_mapGraphicsTriangleStripPrimitives[mapIndex].reset(primitiveOut); break; case PrimitiveShape::TRIANGLES: - m_mapGraphicsTrianglesPrimitives.insert(std::make_pair(key, - std::move(ptr))); + CaretAssertVectorIndex(m_mapGraphicsTrianglesPrimitives, mapIndex); + m_mapGraphicsTrianglesPrimitives[mapIndex].reset(primitiveOut); break; } } @@ -310,8 +271,10 @@ VolumeGraphicsPrimitiveManager::toString() const * Shape for primitive drawing * @param mapIndex * Map index for creating the primitive - * @param tabDrawingInfo - * Info for drawing tab. + * @param displayGroup + * Display gtroup selected + * @param tabIndex + * Index of tab * @param errorMessageOut * Contains information if error occurs * @return @@ -320,7 +283,8 @@ VolumeGraphicsPrimitiveManager::toString() const GraphicsPrimitiveV3fT3f* VolumeGraphicsPrimitiveManager::createPrimitive(const PrimitiveShape primitiveShape, const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, AString& errorMessageOut) const { CaretAssert(m_volumeInterface); @@ -382,7 +346,8 @@ VolumeGraphicsPrimitiveManager::createPrimitive(const PrimitiveShape primitiveSh columnStepIJK, numberOfRows, numberOfColumns, - tabDrawingInfo, + displayGroup, + tabIndex, &rgbaSlice[0]); for (int64_t j = 0; j < numberOfRows; j++) { @@ -476,8 +441,10 @@ VolumeGraphicsPrimitiveManager::createPrimitive(const PrimitiveShape primitiveSh * Media file for intersection * @param mapIndex * Map index for creating the primitive - * @param tabDrawingInfo - * Info for drawing tab. + * @param displayGroup + * Display gtroup selected + * @param tabIndex + * Index of tab * @param volumeMappingMode * Mode for volume mapping * @param volumeSliceThickness @@ -490,7 +457,8 @@ VolumeGraphicsPrimitiveManager::createPrimitive(const PrimitiveShape primitiveSh GraphicsPrimitiveV3fT2f* VolumeGraphicsPrimitiveManager::getImageIntersectionDrawingPrimitiveForMap(const MediaFile* mediaFile, const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, const VolumeToImageMappingModeEnum::Enum volumeMappingMode, const float volumeSliceThickness, AString& errorMessageOut) const @@ -504,7 +472,7 @@ VolumeGraphicsPrimitiveManager::getImageIntersectionDrawingPrimitiveForMap(const ImageIntersectionKey key((void*)mediaFile, mapIndex, - tabDrawingInfo.getTabIndex(), + tabIndex, volumeMappingMode, volumeSliceThickness); std::cout << "Slice thickness1: " << volumeSliceThickness << std::endl; @@ -524,8 +492,8 @@ VolumeGraphicsPrimitiveManager::getImageIntersectionDrawingPrimitiveForMap(const mapIndex, volumeMappingMode, volumeSliceThickness, - tabDrawingInfo.getDisplayGroup(), - tabDrawingInfo.getTabIndex(), + displayGroup, + tabIndex, mediaFile); if (mapper.runMapping(errorMessageOut)) { const int32_t numImageFiles(mapper.getNumberOfOutputImageFiles()); @@ -542,7 +510,7 @@ VolumeGraphicsPrimitiveManager::getImageIntersectionDrawingPrimitiveForMap(const if ( ! allImageFiles.empty()) { for (auto& imageFile : allImageFiles) { int32_t invalidOverlayIndex(-1); - primitiveOut = imageFile->getGraphicsPrimitiveForPlaneXyzDrawing(tabDrawingInfo.getTabIndex(), + primitiveOut = imageFile->getGraphicsPrimitiveForPlaneXyzDrawing(tabIndex, invalidOverlayIndex); } } @@ -557,8 +525,10 @@ VolumeGraphicsPrimitiveManager::getImageIntersectionDrawingPrimitiveForMap(const * Histology slice for intersection * @param mapIndex * Map index for creating the primitive - * @param tabDrawingInfo - * Info for drawing tab. + * @param displayGroup + * Display gtroup selected + * @param tabIndex + * Index of tab * @param volumeMappingMode * Mode for volume mapping * @param volumeSliceThickness @@ -571,7 +541,8 @@ VolumeGraphicsPrimitiveManager::getImageIntersectionDrawingPrimitiveForMap(const std::vector VolumeGraphicsPrimitiveManager::getImageIntersectionDrawingPrimitiveForMap(const HistologySlice* histologySlice, const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, const VolumeToImageMappingModeEnum::Enum volumeMappingMode, const float volumeSliceThickness, AString& errorMessageOut) const @@ -582,7 +553,7 @@ VolumeGraphicsPrimitiveManager::getImageIntersectionDrawingPrimitiveForMap(const ImageIntersectionKey key((void*)histologySlice, mapIndex, - tabDrawingInfo.getTabIndex(), + tabIndex, volumeMappingMode, volumeSliceThickness); @@ -601,8 +572,8 @@ VolumeGraphicsPrimitiveManager::getImageIntersectionDrawingPrimitiveForMap(const mapIndex, volumeMappingMode, volumeSliceThickness, - tabDrawingInfo.getDisplayGroup(), - tabDrawingInfo.getTabIndex(), + displayGroup, + tabIndex, histologySlice); if (mapper.runMapping(errorMessageOut)) { const int32_t numImageFiles(mapper.getNumberOfOutputImageFiles()); @@ -619,7 +590,7 @@ VolumeGraphicsPrimitiveManager::getImageIntersectionDrawingPrimitiveForMap(const if ( ! allImageFiles.empty()) { for (auto& imageFile : allImageFiles) { int32_t invalidOverlayIndex(-1); - GraphicsPrimitiveV3fT2f* primitive = imageFile->getGraphicsPrimitiveForPlaneXyzDrawing(tabDrawingInfo.getTabIndex(), + GraphicsPrimitiveV3fT2f* primitive = imageFile->getGraphicsPrimitiveForPlaneXyzDrawing(tabIndex, invalidOverlayIndex); if (primitive != NULL) { primitivesOut.push_back(primitive); diff --git a/src/Files/VolumeGraphicsPrimitiveManager.h b/src/Files/VolumeGraphicsPrimitiveManager.h index be07f5eb7..e28a9c587 100644 --- a/src/Files/VolumeGraphicsPrimitiveManager.h +++ b/src/Files/VolumeGraphicsPrimitiveManager.h @@ -26,7 +26,6 @@ #include "CaretObject.h" #include "DisplayGroupEnum.h" -#include "LabelViewModeEnum.h" #include "VolumeToImageMappingModeEnum.h" #include "VoxelColorUpdate.h" #include "VoxelIJK.h" @@ -40,7 +39,6 @@ namespace caret { class HistologySlice; class ImageFile; class MediaFile; - class TabDrawingInfo; class VolumeMappableInterface; class VolumeGraphicsPrimitiveManager : public CaretObject { @@ -70,19 +68,22 @@ namespace caret { GraphicsPrimitiveV3fT3f* getVolumeDrawingPrimitiveForMap(const PrimitiveShape drawingType, const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo) const; + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex) const; GraphicsPrimitiveV3fT2f* getImageIntersectionDrawingPrimitiveForMap(const MediaFile* mediaFile, const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, const VolumeToImageMappingModeEnum::Enum volumeMappingMode, const float volumeSliceThickness, AString& errorMessageOut) const; std::vector getImageIntersectionDrawingPrimitiveForMap(const HistologySlice* histologySlice, const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, const VolumeToImageMappingModeEnum::Enum volumeMappingMode, const float volumeSliceThickness, AString& errorMessageOut) const; @@ -98,24 +99,6 @@ namespace caret { virtual AString toString() const; private: - class PrimitiveKey { - public: - PrimitiveKey(const int32_t mapIndex, - const int32_t tabIndex) - : m_mapIndex(mapIndex), - m_tabIndex(tabIndex) - { } - - bool operator<(const PrimitiveKey& rhs) const { - if (m_mapIndex == rhs.m_mapIndex) { - return (m_tabIndex < rhs.m_tabIndex); - } - return (m_mapIndex < rhs.m_mapIndex); - } - int32_t m_mapIndex; - int32_t m_tabIndex; - }; - class ImageIntersectionKey { public: ImageIntersectionKey(void* dataPtr, @@ -163,7 +146,8 @@ namespace caret { GraphicsPrimitiveV3fT3f* createPrimitive(const PrimitiveShape drawingType, const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, AString& errorMessageOut) const; void updateNumberOfVoxelColorUpdates(const int32_t mapIndex) const; @@ -174,11 +158,11 @@ namespace caret { VolumeMappableInterface* m_volumeInterface; - mutable std::map> m_mapGraphicsTriangleFanPrimitives; + mutable std::vector> m_mapGraphicsTriangleFanPrimitives; - mutable std::map> m_mapGraphicsTriangleStripPrimitives; + mutable std::vector> m_mapGraphicsTriangleStripPrimitives; - mutable std::map> m_mapGraphicsTrianglesPrimitives; + mutable std::vector> m_mapGraphicsTrianglesPrimitives; mutable std::vector m_voxelColorUpdates; diff --git a/src/FilesBase/CMakeLists.txt b/src/FilesBase/CMakeLists.txt index 46de7cf73..b63c6b129 100644 --- a/src/FilesBase/CMakeLists.txt +++ b/src/FilesBase/CMakeLists.txt @@ -13,12 +13,10 @@ SET(QT_DONT_USE_QTGUI) # if(Qt6_FOUND) include_directories(${Qt6Core_INCLUDE_DIRS}) - include_directories(${Qt6Gui_INCLUDE_DIRS}) include_directories(${Qt6Core5Compat_INCLUDE_DIRS}) endif() if(Qt5_FOUND) include_directories(${Qt5Core_INCLUDE_DIRS}) - include_directories(${Qt5Gui_INCLUDE_DIRS}) endif() # @@ -27,11 +25,9 @@ endif() ADD_LIBRARY(FilesBase GiftiLabel.h GiftiLabelTable.h -LabelViewModeEnum.h nifti1.h nifti2.h NiftiEnums.h -TabDrawingInfo.h VolumeBase.h VolumeMappableInterface.h VolumeSliceViewPlaneEnum.h @@ -41,9 +37,7 @@ VolumeToImageMappingModeEnum.h GiftiLabel.cxx GiftiLabelTable.cxx -LabelViewModeEnum.cxx NiftiEnums.cxx -TabDrawingInfo.cxx VolumeBase.cxx VolumeMappableInterface.cxx VolumeSliceViewPlaneEnum.cxx diff --git a/src/FilesBase/GiftiLabel.cxx b/src/FilesBase/GiftiLabel.cxx index 15492ce25..0959339df 100644 --- a/src/FilesBase/GiftiLabel.cxx +++ b/src/FilesBase/GiftiLabel.cxx @@ -286,6 +286,7 @@ GiftiLabel::copyHelper(const GiftiLabel& gl) this->initializeMembersGiftiLabel(); setNamePrivate(gl.name); this->key = gl.key; + this->selected = gl.selected; this->red = gl.red; this->green = gl.green; this->blue = gl.blue; @@ -307,6 +308,7 @@ GiftiLabel::initializeMembersGiftiLabel() this->medialWallNameFlag = false; this->name = ""; this->key = s_invalidLabelKey; + this->selected = true; this->red = 1.0; this->green = 1.0; this->blue = 1.0; @@ -435,6 +437,30 @@ GiftiLabel::getNameAndKeyForLabelEditor() const return keyAndNameText; } +/** + * Is this label selected (for display)? + * + * @return true if label selected for display, else false. + * + */ +bool +GiftiLabel::isSelected() const +{ + return this->selected; +} + +/** + * Set the label selected (for display). + * + * @param selected - new selection status. + * + */ +void +GiftiLabel::setSelected(const bool selected) +{ + this->selected = selected; +} + /** * Get the color components. * @param rgbaOut four dimensional array into which are loaded, diff --git a/src/FilesBase/GiftiLabel.h b/src/FilesBase/GiftiLabel.h index 83d3053b5..5fe0b7d43 100644 --- a/src/FilesBase/GiftiLabel.h +++ b/src/FilesBase/GiftiLabel.h @@ -128,6 +128,10 @@ namespace caret { AString getNameAndKeyForLabelEditor() const; + bool isSelected() const; + + void setSelected(const bool selected); + void getColor(float rgbaOut[4]) const; void setColor(const float rgba[4]); @@ -201,6 +205,8 @@ namespace caret { int32_t key; + bool selected; + bool medialWallNameFlag; float red; diff --git a/src/FilesBase/GiftiLabelTable.cxx b/src/FilesBase/GiftiLabelTable.cxx index 29cabb6f9..6d2d5727a 100644 --- a/src/FilesBase/GiftiLabelTable.cxx +++ b/src/FilesBase/GiftiLabelTable.cxx @@ -26,7 +26,6 @@ #include "AStringNaturalComparison.h" #include "CaretAssert.h" #include "CaretLogger.h" -#include "CaretHierarchy.h" #include "GiftiLabel.h" #include "GiftiLabelTable.h" #include "GiftiXmlElements.h" @@ -102,7 +101,6 @@ GiftiLabelTable::copyHelper(const GiftiLabelTable& glt) addLabel(iter->second); } } - m_hierarchy = glt.m_hierarchy; } void @@ -125,7 +123,6 @@ GiftiLabelTable::initializeMembersGiftiLabelTable() void GiftiLabelTable::clear() { - m_hierarchy->clear(); for (LABELS_MAP_CONST_ITERATOR iter = this->labelsMap.begin(); iter != labelsMap.end(); iter++) { @@ -793,6 +790,56 @@ GiftiLabelTable::setLabel(const int32_t key, } } +/** + * Get the selection status of the label at the specified key. If there + * is no label at the key, false is returned. + * @param key - key of label + * @return selection status of label. + * + */ +bool +GiftiLabelTable::isLabelSelected(const int32_t key) const +{ + LABELS_MAP_CONST_ITERATOR iter = this->labelsMap.find(key); + if (iter != this->labelsMap.end()) { + return iter->second->isSelected(); + } + return false; +} + +/** + * Set the selection status of a label. + * @param key - key of label. + * @param sel - new selection status. + * + */ +void +GiftiLabelTable::setLabelSelected( + const int32_t key, + const bool sel) +{ + LABELS_MAP_ITERATOR iter = this->labelsMap.find(key); + if (iter != this->labelsMap.end()) { + iter->second->setSelected(sel); + } +} + +/** + * Set the selection status for all labels. + * @param newStatus New selection status. + * + */ +void +GiftiLabelTable::setSelectionStatusForAllLabels(const bool newStatus) +{ + for (LABELS_MAP_ITERATOR iter = this->labelsMap.begin(); + iter != this->labelsMap.end(); + iter++) { + GiftiLabel* gl = iter->second; + gl->setSelected(newStatus); + } +} + /** * Get the alpha color component for a label. If the key is not a * valid label, an alpha of zero is returned. @@ -834,7 +881,7 @@ GiftiLabelTable::getLabelColor(const int32_t key, float rgbaOut[4]) const void GiftiLabelTable::setLabelColor( const int32_t key, - const float color[4]) + const float color[]) { if (key == 0) { @@ -1669,20 +1716,4 @@ GiftiLabelTable::exportToCaret5ColorFile(const AString& filename) const file.close(); } -//could special case NULL and use =, but this is simpler and performance is probably about the same (vector has to call the destructors anyway) -void GiftiLabelTable::setHierarchy(const CaretHierarchy& hierarchy) -{ - m_hierarchy = hierarchy; //for =, it pretends to be a non-pointer member - setModified(); -} - -void GiftiLabelTable::clearHierarchy() -{ - m_hierarchy->clear(); //can't overload . operator in forward-declare helper, need -> for member access - setModified(); -} -const CaretHierarchy& GiftiLabelTable::getHierarchy() const -{ - return m_hierarchy; //converts to template type -} diff --git a/src/FilesBase/GiftiLabelTable.h b/src/FilesBase/GiftiLabelTable.h index 8995b1253..8f5e225d6 100644 --- a/src/FilesBase/GiftiLabelTable.h +++ b/src/FilesBase/GiftiLabelTable.h @@ -25,7 +25,6 @@ #include "CaretObject.h" #include "TracksModificationInterface.h" -#include "CaretPointer.h" #include "GiftiException.h" #include @@ -38,7 +37,6 @@ namespace caret { -class CaretHierarchy; class GiftiLabel; class XmlWriter; @@ -137,6 +135,14 @@ class GiftiLabelTable : public CaretObject, TracksModificationInterface { const float y, const float z); + bool isLabelSelected(const int32_t key) const; + + void setLabelSelected( + const int32_t key, + const bool sel); + + void setSelectionStatusForAllLabels(const bool newStatus); + float getLabelAlpha(const int32_t key) const; void getLabelColor(const int32_t key, float rgbaOut[4]) const; @@ -192,10 +198,6 @@ class GiftiLabelTable : public CaretObject, TracksModificationInterface { const int32_t newKey); void exportToCaret5ColorFile(const AString& filename) const; - - void setHierarchy(const CaretHierarchy& hierarchy); - void clearHierarchy(); - const CaretHierarchy& getHierarchy() const; private: void issueLabelKeyZeroWarning(const AString& name) const; @@ -220,7 +222,6 @@ class GiftiLabelTable : public CaretObject, TracksModificationInterface { int32_t m_tableModelColumnIndexBlue; int32_t m_tableModelColumnCount; - CaretForwardHelper m_hierarchy; //helper for implementing forward-declared members with reduced per-class code }; } // namespace diff --git a/src/FilesBase/LabelViewModeEnum.cxx b/src/FilesBase/LabelViewModeEnum.cxx deleted file mode 100644 index 67456b380..000000000 --- a/src/FilesBase/LabelViewModeEnum.cxx +++ /dev/null @@ -1,383 +0,0 @@ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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*/ - -#include -#define __LABEL_VIEW_MODE_ENUM_DECLARE__ -#include "LabelViewModeEnum.h" -#undef __LABEL_VIEW_MODE_ENUM_DECLARE__ - -#include "CaretAssert.h" - -using namespace caret; - - -/** - * \class caret::LabelViewModeEnum - * \brief Mode for label selection in Features ToolBox - * - * - * Using this enumerated type in the GUI with an EnumComboBoxTemplate - * - * Header File (.h) - * Forward declare the data type: - * class EnumComboBoxTemplate; - * - * Declare the member: - * EnumComboBoxTemplate* m_labelViewModeEnumComboBox; - * - * Declare a slot that is called when user changes selection - * private slots: - * void labelViewModeEnumComboBoxItemActivated(); - * - * Implementation File (.cxx) - * Include the header files - * #include "EnumComboBoxTemplate.h" - * #include "LabelViewModeEnum.h" - * - * Instatiate: - * m_labelViewModeEnumComboBox = new EnumComboBoxTemplate(this); - * m_labelViewModeEnumComboBox->setup(); - * - * Get notified when the user changes the selection: - * QObject::connect(m_labelViewModeEnumComboBox, SIGNAL(itemActivated()), - * this, SLOT(labelViewModeEnumComboBoxItemActivated())); - * - * Update the selection: - * m_labelViewModeEnumComboBox->setSelectedItem(NEW_VALUE); - * - * Read the selection: - * const LabelViewModeEnum::Enum VARIABLE = m_labelViewModeEnumComboBox->getSelectedItem(); - * - */ - -/* -switch (value) { - case LabelViewModeEnum::HIERARCHY: - break; - case LabelViewModeEnum::LIST: - break; -} -*/ - -/** - * Constructor. - * - * @param enumValue - * An enumerated value. - * @param name - * Name of enumerated value. - * - * @param guiName - * User-friendly name for use in user-interface. - */ -LabelViewModeEnum::LabelViewModeEnum(const Enum enumValue, - const AString& name, - const AString& guiName) -{ - this->enumValue = enumValue; - this->integerCode = integerCodeCounter++; - this->name = name; - this->guiName = guiName; -} - -/** - * Destructor. - */ -LabelViewModeEnum::~LabelViewModeEnum() -{ -} - -/** - * Initialize the enumerated metadata. - */ -void -LabelViewModeEnum::initialize() -{ - if (initializedFlag) { - return; - } - initializedFlag = true; - - enumData.push_back(LabelViewModeEnum(HIERARCHY, - "HIERARCHY", - "Hierarchy")); - - enumData.push_back(LabelViewModeEnum(LIST, - "LIST", - "List")); - -} - -/** - * Find the data for and enumerated value. - * @param enumValue - * The enumerated value. - * @return Pointer to data for this enumerated type - * or NULL if no data for type or if type is invalid. - */ -const LabelViewModeEnum* -LabelViewModeEnum::findData(const Enum enumValue) -{ - if (initializedFlag == false) initialize(); - - size_t num = enumData.size(); - for (size_t i = 0; i < num; i++) { - const LabelViewModeEnum* d = &enumData[i]; - if (d->enumValue == enumValue) { - return d; - } - } - - return NULL; -} - -/** - * Get a string representation of the enumerated type. - * @param enumValue - * Enumerated value. - * @return - * String representing enumerated value. - */ -AString -LabelViewModeEnum::toName(Enum enumValue) { - if (initializedFlag == false) initialize(); - - const LabelViewModeEnum* enumInstance = findData(enumValue); - return enumInstance->name; -} - -/** - * Get an enumerated value corresponding to its name. - * @param name - * Name of enumerated value. - * @param isValidOut - * If not NULL, it is set indicating that a - * enum value exists for the input name. - * @return - * Enumerated value. - */ -LabelViewModeEnum::Enum -LabelViewModeEnum::fromName(const AString& name, bool* isValidOut) -{ - if (initializedFlag == false) initialize(); - - bool validFlag = false; - Enum enumValue = LabelViewModeEnum::enumData[0].enumValue; - - for (std::vector::iterator iter = enumData.begin(); - iter != enumData.end(); - iter++) { - const LabelViewModeEnum& d = *iter; - if (d.name == name) { - enumValue = d.enumValue; - validFlag = true; - break; - } - } - - if (isValidOut != 0) { - *isValidOut = validFlag; - } - else if (validFlag == false) { - CaretAssertMessage(0, AString("Name " + name + " failed to match enumerated value for type LabelViewModeEnum")); - } - return enumValue; -} - -/** - * Get a GUI string representation of the enumerated type. - * @param enumValue - * Enumerated value. - * @return - * String representing enumerated value. - */ -AString -LabelViewModeEnum::toGuiName(Enum enumValue) { - if (initializedFlag == false) initialize(); - - const LabelViewModeEnum* enumInstance = findData(enumValue); - return enumInstance->guiName; -} - -/** - * Get an enumerated value corresponding to its GUI name. - * @param s - * Name of enumerated value. - * @param isValidOut - * If not NULL, it is set indicating that a - * enum value exists for the input name. - * @return - * Enumerated value. - */ -LabelViewModeEnum::Enum -LabelViewModeEnum::fromGuiName(const AString& guiName, bool* isValidOut) -{ - if (initializedFlag == false) initialize(); - - bool validFlag = false; - Enum enumValue = LabelViewModeEnum::enumData[0].enumValue; - - for (std::vector::iterator iter = enumData.begin(); - iter != enumData.end(); - iter++) { - const LabelViewModeEnum& d = *iter; - if (d.guiName == guiName) { - enumValue = d.enumValue; - validFlag = true; - break; - } - } - - if (isValidOut != 0) { - *isValidOut = validFlag; - } - else if (validFlag == false) { - CaretAssertMessage(0, AString("guiName " + guiName + " failed to match enumerated value for type LabelViewModeEnum")); - } - return enumValue; -} - -/** - * Get the integer code for a data type. - * - * @return - * Integer code for data type. - */ -int32_t -LabelViewModeEnum::toIntegerCode(Enum enumValue) -{ - if (initializedFlag == false) initialize(); - const LabelViewModeEnum* enumInstance = findData(enumValue); - return enumInstance->integerCode; -} - -/** - * Find the data type corresponding to an integer code. - * - * @param integerCode - * Integer code for enum. - * @param isValidOut - * If not NULL, on exit isValidOut will indicate if - * integer code is valid. - * @return - * Enum for integer code. - */ -LabelViewModeEnum::Enum -LabelViewModeEnum::fromIntegerCode(const int32_t integerCode, bool* isValidOut) -{ - if (initializedFlag == false) initialize(); - - bool validFlag = false; - Enum enumValue = LabelViewModeEnum::enumData[0].enumValue; - - for (std::vector::iterator iter = enumData.begin(); - iter != enumData.end(); - iter++) { - const LabelViewModeEnum& enumInstance = *iter; - if (enumInstance.integerCode == integerCode) { - enumValue = enumInstance.enumValue; - validFlag = true; - break; - } - } - - if (isValidOut != 0) { - *isValidOut = validFlag; - } - else if (validFlag == false) { - CaretAssertMessage(0, AString("Integer code " + AString::number(integerCode) + " failed to match enumerated value for type LabelViewModeEnum")); - } - return enumValue; -} - -/** - * Get all of the enumerated type values. The values can be used - * as parameters to toXXX() methods to get associated metadata. - * - * @param allEnums - * A vector that is OUTPUT containing all of the enumerated values. - */ -void -LabelViewModeEnum::getAllEnums(std::vector& allEnums) -{ - if (initializedFlag == false) initialize(); - - allEnums.clear(); - - for (std::vector::iterator iter = enumData.begin(); - iter != enumData.end(); - iter++) { - allEnums.push_back(iter->enumValue); - } -} - -/** - * Get all of the names of the enumerated type values. - * - * @param allNames - * A vector that is OUTPUT containing all of the names of the enumerated values. - * @param isSorted - * If true, the names are sorted in alphabetical order. - */ -void -LabelViewModeEnum::getAllNames(std::vector& allNames, const bool isSorted) -{ - if (initializedFlag == false) initialize(); - - allNames.clear(); - - for (std::vector::iterator iter = enumData.begin(); - iter != enumData.end(); - iter++) { - allNames.push_back(LabelViewModeEnum::toName(iter->enumValue)); - } - - if (isSorted) { - std::sort(allNames.begin(), allNames.end()); - } -} - -/** - * Get all of the GUI names of the enumerated type values. - * - * @param allNames - * A vector that is OUTPUT containing all of the GUI names of the enumerated values. - * @param isSorted - * If true, the names are sorted in alphabetical order. - */ -void -LabelViewModeEnum::getAllGuiNames(std::vector& allGuiNames, const bool isSorted) -{ - if (initializedFlag == false) initialize(); - - allGuiNames.clear(); - - for (std::vector::iterator iter = enumData.begin(); - iter != enumData.end(); - iter++) { - allGuiNames.push_back(LabelViewModeEnum::toGuiName(iter->enumValue)); - } - - if (isSorted) { - std::sort(allGuiNames.begin(), allGuiNames.end()); - } -} - diff --git a/src/FilesBase/LabelViewModeEnum.h b/src/FilesBase/LabelViewModeEnum.h deleted file mode 100644 index b112ee97d..000000000 --- a/src/FilesBase/LabelViewModeEnum.h +++ /dev/null @@ -1,104 +0,0 @@ -#ifndef __LABEL_VIEW_MODE_ENUM_H__ -#define __LABEL_VIEW_MODE_ENUM_H__ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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*/ - - -#include -#include -#include "AString.h" - -namespace caret { - -class LabelViewModeEnum { - -public: - /** - * Enumerated values. - */ - enum Enum { - /** Hierarchy */ - HIERARCHY, - /** List */ - LIST - }; - - - ~LabelViewModeEnum(); - - static AString toName(Enum enumValue); - - static Enum fromName(const AString& name, bool* isValidOut); - - static AString toGuiName(Enum enumValue); - - static Enum fromGuiName(const AString& guiName, bool* isValidOut); - - static int32_t toIntegerCode(Enum enumValue); - - static Enum fromIntegerCode(const int32_t integerCode, bool* isValidOut); - - static void getAllEnums(std::vector& allEnums); - - static void getAllNames(std::vector& allNames, const bool isSorted); - - static void getAllGuiNames(std::vector& allGuiNames, const bool isSorted); - -private: - LabelViewModeEnum(const Enum enumValue, - const AString& name, - const AString& guiName); - - static const LabelViewModeEnum* findData(const Enum enumValue); - - /** Holds all instance of enum values and associated metadata */ - static std::vector enumData; - - /** Initialize instances that contain the enum values and metadata */ - static void initialize(); - - /** Indicates instance of enum values and metadata have been initialized */ - static bool initializedFlag; - - /** Auto generated integer codes */ - static int32_t integerCodeCounter; - - /** The enumerated type value for an instance */ - Enum enumValue; - - /** The integer code associated with an enumerated value */ - int32_t integerCode; - - /** The name, a text string that is identical to the enumerated value */ - AString name; - - /** A user-friendly name that is displayed in the GUI */ - AString guiName; -}; - -#ifdef __LABEL_VIEW_MODE_ENUM_DECLARE__ -std::vector LabelViewModeEnum::enumData; -bool LabelViewModeEnum::initializedFlag = false; -int32_t LabelViewModeEnum::integerCodeCounter = 0; -#endif // __LABEL_VIEW_MODE_ENUM_DECLARE__ - -} // namespace -#endif //__LABEL_VIEW_MODE_ENUM_H__ diff --git a/src/FilesBase/TabDrawingInfo.cxx b/src/FilesBase/TabDrawingInfo.cxx deleted file mode 100644 index 7cbaf37a3..000000000 --- a/src/FilesBase/TabDrawingInfo.cxx +++ /dev/null @@ -1,175 +0,0 @@ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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 __TAB_DRAWING_INFO_DECLARE__ -#include "TabDrawingInfo.h" -#undef __TAB_DRAWING_INFO_DECLARE__ - -#include "BrainConstants.h" -#include "CaretAssert.h" -using namespace caret; - - - -/** - * \class caret::TabDrawingInfo - * \brief Info for drawing a tab - * \ingroup FilesBase - * - * By placing this info in a an object, items can be added without having to modify many function parameters - */ - -/** - * Constructor. - * @param mapFile - * The map file being drawn - * @parm mapIndex - * Map in file that is being drawn - * @param displayGroup - * The display group selected - * @param labelViewMode - * The label viewing mode - * @param tabIndex - * Index of tab being drawn - */ -TabDrawingInfo::TabDrawingInfo(CaretMappableDataFile* mapFile, - const int32_t mapIndex, - const DisplayGroupEnum::Enum displayGroup, - const LabelViewModeEnum::Enum labelViewMode, - const int32_t tabIndex) -: CaretObject(), -m_mapFile(mapFile), -m_mapIndex(mapIndex), -m_displayGroup(displayGroup), -m_labelViewMode(labelViewMode), -m_tabIndex(tabIndex) -{ - CaretAssert(mapFile); - CaretAssert(mapIndex >= 0); - CaretAssert((tabIndex >= 0) - && (tabIndex < BrainConstants::MAXIMUM_NUMBER_OF_BROWSER_TABS)); -} - -/** - * Destructor. - */ -TabDrawingInfo::~TabDrawingInfo() -{ -} - -/** - * Copy constructor. - * @param obj - * Object that is copied. - */ -TabDrawingInfo::TabDrawingInfo(const TabDrawingInfo& obj) -: CaretObject(obj) -{ - this->copyHelperTabDrawingInfo(obj); -} - -/** - * Assignment operator. - * @param obj - * Data copied from obj to this. - * @return - * Reference to this object. - */ -TabDrawingInfo& -TabDrawingInfo::operator=(const TabDrawingInfo& obj) -{ - if (this != &obj) { - CaretObject::operator=(obj); - this->copyHelperTabDrawingInfo(obj); - } - return *this; -} - -/** - * Helps with copying an object of this type. - * @param obj - * Object that is copied. - */ -void -TabDrawingInfo::copyHelperTabDrawingInfo(const TabDrawingInfo& obj) -{ - m_mapFile = obj.m_mapFile; - m_mapIndex = obj.m_mapIndex; - m_displayGroup = obj.m_displayGroup; - m_labelViewMode = obj.m_labelViewMode; - m_tabIndex = obj.m_tabIndex; -} - -/** - * @return Map file being drawn - */ -CaretMappableDataFile* -TabDrawingInfo::getMapFile() const -{ - return m_mapFile; -} - -/** - * @return Map index being drawn - */ -int32_t -TabDrawingInfo::getMapIndex() const -{ - return m_mapIndex; -} - -/** - * @return The display group - */ -DisplayGroupEnum::Enum -TabDrawingInfo::getDisplayGroup() const -{ - return m_displayGroup; -} - -/** - * @return The label view mode - */ -LabelViewModeEnum::Enum -TabDrawingInfo::getLabelViewMode() const -{ - return m_labelViewMode; -} - -/** - * @return The tab index - */ -int32_t -TabDrawingInfo::getTabIndex() const -{ - return m_tabIndex; -} - -/** - * Get a description of this object's content. - * @return String describing this object's content. - */ -AString -TabDrawingInfo::toString() const -{ - return "TabDrawingInfo"; -} - diff --git a/src/FilesBase/TabDrawingInfo.h b/src/FilesBase/TabDrawingInfo.h deleted file mode 100644 index ad763d1e4..000000000 --- a/src/FilesBase/TabDrawingInfo.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef __TAB_DRAWING_INFO_H__ -#define __TAB_DRAWING_INFO_H__ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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*/ - - - -#include - -#include "CaretObject.h" -#include "DisplayGroupEnum.h" -#include "LabelViewModeEnum.h" - - -namespace caret { - - class CaretMappableDataFile; - - class TabDrawingInfo : public CaretObject { - - public: - TabDrawingInfo(CaretMappableDataFile* mapFile, - const int32_t mapIndex, - const DisplayGroupEnum::Enum displayGroup, - const LabelViewModeEnum::Enum labelViewMode, - const int32_t tabIndex); - - virtual ~TabDrawingInfo(); - - TabDrawingInfo(const TabDrawingInfo& obj); - - TabDrawingInfo& operator=(const TabDrawingInfo& obj); - - CaretMappableDataFile* getMapFile() const; - - int32_t getMapIndex() const; - - DisplayGroupEnum::Enum getDisplayGroup() const; - - LabelViewModeEnum::Enum getLabelViewMode() const; - - int32_t getTabIndex() const; - - // ADD_NEW_METHODS_HERE - - virtual AString toString() const; - - private: - void copyHelperTabDrawingInfo(const TabDrawingInfo& obj); - - CaretMappableDataFile* m_mapFile; - - int32_t m_mapIndex; - - DisplayGroupEnum::Enum m_displayGroup; - - LabelViewModeEnum::Enum m_labelViewMode; - - int32_t m_tabIndex; - - // ADD_NEW_MEMBERS_HERE - - }; - -#ifdef __TAB_DRAWING_INFO_DECLARE__ - // -#endif // __TAB_DRAWING_INFO_DECLARE__ - -} // namespace -#endif //__TAB_DRAWING_INFO_H__ diff --git a/src/FilesBase/VolumeMappableInterface.h b/src/FilesBase/VolumeMappableInterface.h index 2b9ef882b..61509a02c 100644 --- a/src/FilesBase/VolumeMappableInterface.h +++ b/src/FilesBase/VolumeMappableInterface.h @@ -21,6 +21,7 @@ */ /*LICENSE_END*/ +#include "DisplayGroupEnum.h" #include "Vector3D.h" #include "VolumeSliceViewPlaneEnum.h" #include "VolumeSpace.h" @@ -34,7 +35,6 @@ namespace caret { class MediaFile; class GraphicsPrimitive; class GraphicsPrimitiveV3fT3f; - class TabDrawingInfo; /** * \class caret::VolumeMappableInterface @@ -354,8 +354,10 @@ namespace caret { * The slice plane. * @param sliceIndex * Index of the slice. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param rgbaOut * Output containing the rgba values (must have been allocated * by caller to sufficient count of elements in the slice). @@ -365,7 +367,8 @@ namespace caret { virtual int64_t getVoxelColorsForSliceInMap(const int32_t mapIndex, const VolumeSliceViewPlaneEnum::Enum slicePlane, const int64_t sliceIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const = 0; /** @@ -383,8 +386,10 @@ namespace caret { * Number of rows. * @param numberOfColumns * Number of columns. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param rgbaOut * RGBA color components out. * @return @@ -396,7 +401,8 @@ namespace caret { const int64_t columnStepIJK[3], const int64_t numberOfRows, const int64_t numberOfColumns, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const = 0; /** @@ -414,8 +420,10 @@ namespace caret { * Indices of voxel for last corner of sub-slice (inclusive). * @param voxelCountIJK * Voxel counts for each axis. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param rgbaOut * Output containing the rgba values (must have been allocated * by caller to sufficient count of elements in the slice). @@ -428,7 +436,8 @@ namespace caret { const int64_t firstCornerVoxelIndex[3], const int64_t lastCornerVoxelIndex[3], const int64_t voxelCountIJK[3], - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t* rgbaOut) const = 0; /** @@ -442,8 +451,10 @@ namespace caret { * Third dimension (k). * @param brickIndex * Time/map index. - * @param tabDrawingInfo - * Info for drawing the tab + * @param displayGroup + * The selected display group. + * @param tabIndex + * Index of selected tab. * @param rgbaOut * Output containing RGBA values for voxel at the given indices. */ @@ -451,7 +462,8 @@ namespace caret { const int64_t indexIn2, const int64_t indexIn3, const int64_t brickIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, uint8_t rgbaOut[4]) const = 0; /** @@ -475,23 +487,28 @@ namespace caret { uint8_t rgbaOut[4]) const = 0; virtual GraphicsPrimitiveV3fT3f* getVolumeDrawingTriangleStripPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo) const = 0; + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex) const = 0; virtual GraphicsPrimitiveV3fT3f* getVolumeDrawingTriangleFanPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo) const = 0; + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex) const = 0; virtual GraphicsPrimitiveV3fT3f* getVolumeDrawingTrianglesPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo) const = 0; + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex) const = 0; virtual GraphicsPrimitive* getHistologyImageIntersectionPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, const MediaFile* mediaFile, const VolumeToImageMappingModeEnum::Enum volumeMappingMode, const float volumeSliceThickness, AString& errorMessageOut) const = 0; virtual std::vector getHistologySliceIntersectionPrimitive(const int32_t mapIndex, - const TabDrawingInfo& tabDrawingInfo, + const DisplayGroupEnum::Enum displayGroup, + const int32_t tabIndex, const HistologySlice* histologySlice, const VolumeToImageMappingModeEnum::Enum volumeMappingMode, const float volumeSliceThickness, diff --git a/src/Gifti/GiftiDataArray.cxx b/src/Gifti/GiftiDataArray.cxx index 53e104c7e..9f75f5b62 100644 --- a/src/Gifti/GiftiDataArray.cxx +++ b/src/Gifti/GiftiDataArray.cxx @@ -267,7 +267,7 @@ GiftiDataArray::deleteRows(const std::vector& rowsToDeleteIn) // std::vector rowsToDelete = rowsToDeleteIn; std::sort(rowsToDelete.begin(), rowsToDelete.end()); - (void)std::unique(rowsToDelete.begin(), rowsToDelete.end()); + std::unique(rowsToDelete.begin(), rowsToDelete.end()); std::reverse(rowsToDelete.begin(), rowsToDelete.end()); // diff --git a/src/Graphics/GraphicsPrimitiveV3fT3f.cxx b/src/Graphics/GraphicsPrimitiveV3fT3f.cxx index bcb6a31fd..ad706fa5c 100644 --- a/src/Graphics/GraphicsPrimitiveV3fT3f.cxx +++ b/src/Graphics/GraphicsPrimitiveV3fT3f.cxx @@ -92,7 +92,7 @@ GraphicsPrimitiveV3fT3f::copyHelperGraphicsPrimitiveV3fT3f(const GraphicsPrimiti */ void GraphicsPrimitiveV3fT3f::addVertex(const float xyz[3], - const float str[3]) + const float str[2]) { addVertexProtected(xyz, NULL, diff --git a/src/GuiQt/BalsaDatabaseManager.cxx b/src/GuiQt/BalsaDatabaseManager.cxx index 743adc58c..267d1ef4f 100644 --- a/src/GuiQt/BalsaDatabaseManager.cxx +++ b/src/GuiQt/BalsaDatabaseManager.cxx @@ -127,7 +127,6 @@ BalsaDatabaseManager::login(const AString& databaseURL, std::cout << "Response Code: " << loginResponse.m_responseCode << std::endl; } - AString setCookieErrorMessage = "Did not find 'set-cookie' in response headers."; for (std::map::iterator mapIter = loginResponse.m_headers.begin(); mapIter != loginResponse.m_headers.end(); mapIter++) { @@ -143,11 +142,6 @@ BalsaDatabaseManager::login(const AString& databaseURL, m_jSessionIdCookie = value.mid(offset, length); } - else { - setCookieErrorMessage = ("set-cookie invalid. Value='" - + value - + "'."); - } } if (m_debugFlag) { std::cout << " Response Header: " << qPrintable(mapIter->first) @@ -161,8 +155,7 @@ BalsaDatabaseManager::login(const AString& databaseURL, if (loginResponse.m_responseCode == 200) { if (m_jSessionIdCookie.isEmpty()) { - errorMessageOut = ("Login was successful but BALSA failed to provide a Session ID.\n" - + setCookieErrorMessage); + errorMessageOut = ("Login was successful but BALSA failed to provide a Session ID."); logout(); return false; } diff --git a/src/GuiQt/BrainBrowserWindowOrientedToolBox.cxx b/src/GuiQt/BrainBrowserWindowOrientedToolBox.cxx index 05bc5c50a..2d0caeb76 100644 --- a/src/GuiQt/BrainBrowserWindowOrientedToolBox.cxx +++ b/src/GuiQt/BrainBrowserWindowOrientedToolBox.cxx @@ -56,7 +56,7 @@ #include "HistologyOverlaySetViewController.h" #include "IdentificationDisplayWidget.h" #include "ImageSelectionViewController.h" -#include "LabelSelectionViewWidget.h" +#include "LabelSelectionViewController.h" #include "MediaOverlaySetViewController.h" #include "OverlaySetViewController.h" #include "SamplesSelectionViewController.h" @@ -155,7 +155,7 @@ BrainBrowserWindowOrientedToolBox::BrainBrowserWindowOrientedToolBox(const int32 m_fociSelectionViewController = NULL; m_histologyOverlaySetViewController = NULL; m_imageSelectionViewController = NULL; - m_labelSelectionWidget = NULL; + m_labelSelectionViewController = NULL; m_mediaSelectionViewController = NULL; m_overlaySetViewController = NULL; m_samplesSelectionViewController = NULL; @@ -204,7 +204,7 @@ BrainBrowserWindowOrientedToolBox::BrainBrowserWindowOrientedToolBox(const int32 browserWindowIndex, objectNamePrefix, this); - m_overlayTabIndex = addToScrolledAreaInTabWidget(m_overlaySetViewController, + m_overlayTabIndex = addToTabWidget(m_overlaySetViewController, "Layers"); } if (isOverlayToolBox) { @@ -212,7 +212,7 @@ BrainBrowserWindowOrientedToolBox::BrainBrowserWindowOrientedToolBox(const int32 browserWindowIndex, objectNamePrefix, this); - m_chartOverlayTabIndex = addToScrolledAreaInTabWidget(m_chartOverlaySetViewController, + m_chartOverlayTabIndex = addToTabWidget(m_chartOverlaySetViewController, "Chart Layers"); } if (isOverlayToolBox) { @@ -220,13 +220,13 @@ BrainBrowserWindowOrientedToolBox::BrainBrowserWindowOrientedToolBox(const int32 browserWindowIndex, objectNamePrefix, this); - m_chartTabIndex = addToScrolledAreaInTabWidget(m_chartToolBoxViewController, + m_chartTabIndex = addToTabWidget(m_chartToolBoxViewController, "Charting"); } if (isOverlayToolBox) { m_connectivityMatrixViewController = new CiftiConnectivityMatrixViewController(objectNamePrefix, this); - m_connectivityTabIndex = addToScrolledAreaInTabWidget(m_connectivityMatrixViewController, + m_connectivityTabIndex = addToTabWidget(m_connectivityMatrixViewController, "Connectivity"); } if (isFeaturesToolBox) { @@ -246,7 +246,7 @@ BrainBrowserWindowOrientedToolBox::BrainBrowserWindowOrientedToolBox(const int32 "Features ToolBox Annotation Tab", ""); - m_annotationTabIndex = addToScrolledAreaInTabWidget(m_annotationTabWidget, + m_annotationTabIndex = addToTabWidget(m_annotationTabWidget, "Annot"); m_annotationTabWidget->setCurrentIndex(0); } @@ -254,14 +254,14 @@ BrainBrowserWindowOrientedToolBox::BrainBrowserWindowOrientedToolBox(const int32 m_borderSelectionViewController = new BorderSelectionViewController(browserWindowIndex, objectNamePrefix, this); - m_borderTabIndex = addToScrolledAreaInTabWidget(m_borderSelectionViewController, + m_borderTabIndex = addToTabWidget(m_borderSelectionViewController, "Borders"); } if (isFeaturesToolBox) { m_fiberOrientationViewController = new FiberOrientationSelectionViewController(browserWindowIndex, this); - m_fiberOrientationTabIndex = addToScrolledAreaInTabWidget(m_fiberOrientationViewController, + m_fiberOrientationTabIndex = addToTabWidget(m_fiberOrientationViewController, "Fibers"); } @@ -269,7 +269,7 @@ BrainBrowserWindowOrientedToolBox::BrainBrowserWindowOrientedToolBox(const int32 m_fociSelectionViewController = new FociSelectionViewController(browserWindowIndex, objectNamePrefix, this); - m_fociTabIndex = addToScrolledAreaInTabWidget(m_fociSelectionViewController, + m_fociTabIndex = addToTabWidget(m_fociSelectionViewController, "Foci"); } @@ -278,7 +278,7 @@ BrainBrowserWindowOrientedToolBox::BrainBrowserWindowOrientedToolBox(const int32 browserWindowIndex, objectNamePrefix, this); - m_histologyTabIndex = addToScrolledAreaInTabWidget(m_histologyOverlaySetViewController, + m_histologyTabIndex = addToTabWidget(m_histologyOverlaySetViewController, "Histology"); } @@ -286,16 +286,16 @@ BrainBrowserWindowOrientedToolBox::BrainBrowserWindowOrientedToolBox(const int32 m_imageSelectionViewController = new ImageSelectionViewController(browserWindowIndex, objectNamePrefix, this); - m_imageTabIndex = addToScrolledAreaInTabWidget(m_imageSelectionViewController, + m_imageTabIndex = addToTabWidget(m_imageSelectionViewController, "Images"); } if (isFeaturesToolBox) { - m_labelSelectionWidget = new LabelSelectionViewWidget(browserWindowIndex, - objectNamePrefix, - this); - m_labelTabIndex = addToTabWidget(m_labelSelectionWidget, - "Labels"); + m_labelSelectionViewController = new LabelSelectionViewController(browserWindowIndex, + objectNamePrefix, + this); + m_labelTabIndex = addToTabWidget(m_labelSelectionViewController, + "Labels"); } if (isOverlayToolBox) { @@ -303,7 +303,7 @@ BrainBrowserWindowOrientedToolBox::BrainBrowserWindowOrientedToolBox(const int32 browserWindowIndex, objectNamePrefix, this); - m_mediaTabIndex = addToScrolledAreaInTabWidget(m_mediaSelectionViewController, + m_mediaTabIndex = addToTabWidget(m_mediaSelectionViewController, "Media"); } @@ -311,7 +311,7 @@ BrainBrowserWindowOrientedToolBox::BrainBrowserWindowOrientedToolBox(const int32 m_samplesSelectionViewController = new SamplesSelectionViewController(browserWindowIndex, objectNamePrefix, this); - m_samplesTabIndex = addToScrolledAreaInTabWidget(m_samplesSelectionViewController, + m_samplesTabIndex = addToTabWidget(m_samplesSelectionViewController, "Samples"); } @@ -320,14 +320,14 @@ BrainBrowserWindowOrientedToolBox::BrainBrowserWindowOrientedToolBox(const int32 m_browserWindowIndex, objectNamePrefix, "toolbox"); - m_volumeSurfaceOutlineTabIndex = addToScrolledAreaInTabWidget(m_volumeSurfaceOutlineSetViewController, + m_volumeSurfaceOutlineTabIndex = addToTabWidget(m_volumeSurfaceOutlineSetViewController, "Vol/Surf Outline"); } if (isOverlayToolBox) { #ifdef __SHOW_DYNCONN_PROTOTYPE__ DynConnViewController* dynConn = new DynConnViewController(); - addToScrolledAreaInTabWidget(dynConn, "DynConn"); + addToTabWidget(dynConn, "DynConn"); #endif // __SHOW_DYNCONN_PROTOTYPE__ } @@ -434,7 +434,7 @@ BrainBrowserWindowOrientedToolBox::createSplitterAndIdentificationWidget(const Q * Name corresponding to widget's tab. */ int -BrainBrowserWindowOrientedToolBox::addToScrolledAreaInTabWidget(QWidget* page, +BrainBrowserWindowOrientedToolBox::addToTabWidget(QWidget* page, const QString& label) { QScrollArea* scrollArea = new QScrollArea(); @@ -447,21 +447,6 @@ BrainBrowserWindowOrientedToolBox::addToScrolledAreaInTabWidget(QWidget* page, return indx; } -/** - * Place widget into the tab widget. - * @param page - * Widget that is added. - * @param label - * Name corresponding to widget's tab. - */ -int -BrainBrowserWindowOrientedToolBox::addToTabWidget(QWidget* page, - const QString& label) -{ - int indx = m_tabWidget->addTab(page, - label); - return indx; -} /** * Called when floating status changes. @@ -611,9 +596,9 @@ BrainBrowserWindowOrientedToolBox::saveToScene(const SceneAttributes* sceneAttri sceneClass->addClass(m_imageSelectionViewController->saveToScene(sceneAttributes, "m_imageSelectionViewController")); } - if (m_labelSelectionWidget != NULL) { - sceneClass->addClass(m_labelSelectionWidget->saveToScene(sceneAttributes, - "m_labelSelectionWidget")); + if (m_labelSelectionViewController != NULL) { + sceneClass->addClass(m_labelSelectionViewController->saveToScene(sceneAttributes, + "m_labelSelectionViewController")); } if (m_samplesSelectionViewController != NULL) { sceneClass->addClass(m_samplesSelectionViewController->saveToScene(sceneAttributes, @@ -724,26 +709,14 @@ BrainBrowserWindowOrientedToolBox::restoreFromScene(const SceneAttributes* scene m_imageSelectionViewController->restoreFromScene(sceneAttributes, sceneClass->getClass("m_imageSelectionViewController")); } - if (m_labelSelectionWidget != NULL) { - m_labelSelectionWidget->restoreFromScene(sceneAttributes, - sceneClass->getClass("m_labelSelectionWidget")); + if (m_labelSelectionViewController != NULL) { + m_labelSelectionViewController->restoreFromScene(sceneAttributes, + sceneClass->getClass("m_labelSelectionViewController")); } if (m_samplesSelectionViewController != NULL) { m_samplesSelectionViewController->restoreFromScene(sceneAttributes, sceneClass->getClass("m_samplesSelectionViewController")); } - - /* - * Restore older scene when m_labelSelectionViewController was a child of this widget. - * It is now a child of m_labelSelectionWidget - */ - const SceneClass* labelControllerScene(sceneClass->getClass("m_labelSelectionViewController")); - if (labelControllerScene) { - if (m_labelSelectionWidget != NULL) { - m_labelSelectionWidget->restoreFromScene(sceneAttributes, - labelControllerScene); - } - } /* * Restore current widget size */ diff --git a/src/GuiQt/BrainBrowserWindowOrientedToolBox.h b/src/GuiQt/BrainBrowserWindowOrientedToolBox.h index 4ae6b1a36..7914d3201 100644 --- a/src/GuiQt/BrainBrowserWindowOrientedToolBox.h +++ b/src/GuiQt/BrainBrowserWindowOrientedToolBox.h @@ -43,7 +43,7 @@ namespace caret { class HistologyOverlaySetViewController; class IdentificationDisplayWidget; class ImageSelectionViewController; - class LabelSelectionViewWidget; + class LabelSelectionViewController; class MediaOverlaySetViewController; class OverlaySetViewController; class SamplesSelectionViewController; @@ -91,9 +91,6 @@ namespace caret { BrainBrowserWindowOrientedToolBox(const BrainBrowserWindowOrientedToolBox&); BrainBrowserWindowOrientedToolBox& operator=(const BrainBrowserWindowOrientedToolBox&); - int addToScrolledAreaInTabWidget(QWidget* page, - const QString& label); - int addToTabWidget(QWidget* page, const QString& label); @@ -121,7 +118,7 @@ namespace caret { ImageSelectionViewController* m_imageSelectionViewController; - LabelSelectionViewWidget* m_labelSelectionWidget; + LabelSelectionViewController* m_labelSelectionViewController; MediaOverlaySetViewController* m_mediaSelectionViewController; diff --git a/src/GuiQt/BrainBrowserWindowToolBar.cxx b/src/GuiQt/BrainBrowserWindowToolBar.cxx index 20cb57020..892f57281 100644 --- a/src/GuiQt/BrainBrowserWindowToolBar.cxx +++ b/src/GuiQt/BrainBrowserWindowToolBar.cxx @@ -238,7 +238,7 @@ m_parentBrainBrowserWindow(parentBrainBrowserWindow) this->tabBar->setShape(QTabBar::RoundedNorth); this->tabBar->setMovable(true); -#ifdef Q_OS_MACOS +#ifdef Q_OS_MACX /* * Adding a parent to the style will result in it * being destroyed when this instance is destroyed. @@ -256,7 +256,7 @@ m_parentBrainBrowserWindow(parentBrainBrowserWindow) fusionStyle->setParent(this); this->tabBar->setStyle(fusionStyle); } -#endif // Q_OS_MACOS +#endif // Q_OS_MACX QObject::connect(this->tabBar, SIGNAL(currentChanged(int)), this, SLOT(selectedTabChanged(int))); QObject::connect(this->tabBar, SIGNAL(tabCloseRequested(int)), diff --git a/src/GuiQt/BrainBrowserWindowToolBarOrientation.cxx b/src/GuiQt/BrainBrowserWindowToolBarOrientation.cxx index 1ae096761..68ef874eb 100644 --- a/src/GuiQt/BrainBrowserWindowToolBarOrientation.cxx +++ b/src/GuiQt/BrainBrowserWindowToolBarOrientation.cxx @@ -510,9 +510,6 @@ BrainBrowserWindowToolBarOrientation::updateContent(BrowserTabContent* browserTa break; case SurfaceMontageConfigurationTypeEnum::FLAT_CONFIGURATION: break; - case SurfaceMontageConfigurationTypeEnum::HIPPOCAMPUS_CONFIGURATION: - enableDualViewOrientationButtons = true; - break; } this->orientationLateralMedialToolButtonAction->setText(latMedLeftRightText); diff --git a/src/GuiQt/BrainBrowserWindowToolBarSurfaceMontage.cxx b/src/GuiQt/BrainBrowserWindowToolBarSurfaceMontage.cxx index 6a458e9e6..03537f217 100644 --- a/src/GuiQt/BrainBrowserWindowToolBarSurfaceMontage.cxx +++ b/src/GuiQt/BrainBrowserWindowToolBarSurfaceMontage.cxx @@ -37,7 +37,6 @@ #include "SurfaceMontageConfigurationCerebellar.h" #include "SurfaceMontageConfigurationCerebral.h" #include "SurfaceMontageConfigurationFlatMaps.h" -#include "SurfaceMontageConfigurationHippocampus.h" #include "SurfaceMontageLayoutOrientationEnum.h" #include "SurfaceSelectionModel.h" #include "SurfaceSelectionViewController.h" @@ -106,9 +105,6 @@ m_parentToolBar(parentToolBar) m_flatMapsComponent = new SurfaceMontageFlatMapsComponent(this, objectNamePrefix); - m_hippocampusComponent = new SurfaceMontageHippocampusComponent(this, - objectNamePrefix); - QHBoxLayout* configOrientationLayout = new QHBoxLayout(); WuQtUtilities::setLayoutSpacingAndMargins(configOrientationLayout, 2, 0); configOrientationLayout->addStretch(); @@ -122,7 +118,6 @@ m_parentToolBar(parentToolBar) m_stackedWidget->addWidget(m_cerebellarComponent); m_stackedWidget->addWidget(m_cerebralComponent); m_stackedWidget->addWidget(m_flatMapsComponent); - m_stackedWidget->addWidget(m_hippocampusComponent); QVBoxLayout* layout = new QVBoxLayout(this); WuQtUtilities::setLayoutSpacingAndMargins(layout, 2, 0); @@ -201,9 +196,6 @@ BrainBrowserWindowToolBarSurfaceMontage::updateContent(BrowserTabContent* browse if (msm->getFlatMapsConfiguration(tabIndex)->isValid()) { validConfigs.push_back(SurfaceMontageConfigurationTypeEnum::FLAT_CONFIGURATION); } - if (msm->getHippocampusConfiguration(tabIndex)->isValid()) { - validConfigs.push_back(SurfaceMontageConfigurationTypeEnum::HIPPOCAMPUS_CONFIGURATION); - } m_surfaceMontageConfigurationTypeEnumComboBox->setupWithItems(validConfigs); SurfaceMontageConfigurationAbstract* selectedConfiguration = msm->getSelectedConfiguration(tabIndex); @@ -224,308 +216,9 @@ BrainBrowserWindowToolBarSurfaceMontage::updateContent(BrowserTabContent* browse m_flatMapsComponent->updateContent(browserTabContent); m_stackedWidget->setCurrentWidget(m_flatMapsComponent); break; - case SurfaceMontageConfigurationTypeEnum::HIPPOCAMPUS_CONFIGURATION: - m_hippocampusComponent->updateContent(browserTabContent); - m_stackedWidget->setCurrentWidget(m_hippocampusComponent); - break; - } -} - -/* - ******************************************************************************************** - */ - -/** - * \class caret::SurfaceMontageHippocampusComponent - * \brief Hippocampus Surface Montage Component of Brain Browser Window ToolBar - * \ingroup GuiQt - */ - -/** - * Constructor. - * - * @param parentToolBar - * parent toolbar. - * @param objectNamePrefix - * Prefix name for naming objects - */ -SurfaceMontageHippocampusComponent::SurfaceMontageHippocampusComponent(BrainBrowserWindowToolBarSurfaceMontage* parentToolBarMontage, - const QString& parentObjectNamePrefix) -: QWidget(parentToolBarMontage) -{ - const QString objectNamePrefix(parentObjectNamePrefix - + ":SurfaceHippocampusMontage"); - - m_parentToolBarMontage = parentToolBarMontage; - - WuQMacroManager* macroManager = WuQMacroManager::instance(); - - m_leftCheckBox = new QCheckBox("Left"); - QObject::connect(m_leftCheckBox, SIGNAL(toggled(bool)), - this, SLOT(checkBoxSelected(bool))); - m_leftCheckBox->setObjectName(objectNamePrefix - + ":EnableLeft"); - m_leftCheckBox->setToolTip("Enable Left Surfaces"); - macroManager->addMacroSupportToObject(m_leftCheckBox, - "Enable left surface in hippocampus montage"); - - m_rightCheckBox = new QCheckBox("Right"); - QObject::connect(m_rightCheckBox, SIGNAL(toggled(bool)), - this, SLOT(checkBoxSelected(bool))); - m_rightCheckBox->setObjectName(objectNamePrefix - + ":EnableRight"); - m_rightCheckBox->setToolTip("Enable Right Surface"); - macroManager->addMacroSupportToObject(m_rightCheckBox, - "Enable right surface in hippocampus montage"); - - m_lateralCheckBox = new QCheckBox("Lateral"); - QObject::connect(m_lateralCheckBox, SIGNAL(toggled(bool)), - this, SLOT(checkBoxSelected(bool))); - m_lateralCheckBox->setObjectName(objectNamePrefix - + ":EnableLateralView"); - m_lateralCheckBox->setToolTip("Enable Lateral View"); - macroManager->addMacroSupportToObject(m_lateralCheckBox, - "Enable lateral view in hippocampus montage"); - - m_medialCheckBox = new QCheckBox("Medial"); - QObject::connect(m_medialCheckBox, SIGNAL(toggled(bool)), - this, SLOT(checkBoxSelected(bool))); - m_medialCheckBox->setObjectName(objectNamePrefix - + ":EnableMedialView"); - m_medialCheckBox->setToolTip("Enable Medial View"); - macroManager->addMacroSupportToObject(m_medialCheckBox, - "Enable medial view in hippocampus montage"); - - m_surfaceMontageFirstSurfaceCheckBox = new QCheckBox(" "); - QObject::connect(m_surfaceMontageFirstSurfaceCheckBox, SIGNAL(toggled(bool)), - this, SLOT(checkBoxSelected(bool))); - m_surfaceMontageFirstSurfaceCheckBox->setObjectName(objectNamePrefix - + ":EnableFirstRowSurfaces"); - m_surfaceMontageFirstSurfaceCheckBox->setToolTip("Enable First Surfaces"); - macroManager->addMacroSupportToObject(m_surfaceMontageFirstSurfaceCheckBox, - "Enable first surface row in hippocampus montage"); - - m_surfaceMontageSecondSurfaceCheckBox = new QCheckBox(" "); - QObject::connect(m_surfaceMontageSecondSurfaceCheckBox, SIGNAL(toggled(bool)), - this, SLOT(checkBoxSelected(bool))); - m_surfaceMontageSecondSurfaceCheckBox->setObjectName(objectNamePrefix - + ":EnableSecondRowSurfaces"); - m_surfaceMontageSecondSurfaceCheckBox->setToolTip("Enable Second Surfaces"); - macroManager->addMacroSupportToObject(m_surfaceMontageSecondSurfaceCheckBox, - "Enable second row in hippocampus montage"); - - m_leftSurfaceViewController = new SurfaceSelectionViewController(this, - objectNamePrefix - + ":SurfaceLeftTop", - "hippocampus montage left top"); - QObject::connect(m_leftSurfaceViewController, SIGNAL(surfaceSelected(Surface*)), - this, SLOT(leftSurfaceSelected(Surface*))); - - m_leftSecondSurfaceViewController = new SurfaceSelectionViewController(this, - objectNamePrefix - + ":SurfaceLeftBottom", - "hippocampus montage left bottom"); - QObject::connect(m_leftSecondSurfaceViewController, SIGNAL(surfaceSelected(Surface*)), - this, SLOT(leftSecondSurfaceSelected(Surface*))); - - m_rightSurfaceViewController = new SurfaceSelectionViewController(this, - objectNamePrefix - + ":SurfaceRightTop", - "hippocampus montage right top"); - QObject::connect(m_rightSurfaceViewController, SIGNAL(surfaceSelected(Surface*)), - this, SLOT(rightSurfaceSelected(Surface*))); - - m_rightSecondSurfaceViewController = new SurfaceSelectionViewController(this, - objectNamePrefix - + ":SurfaceRightBottom", - "hippocampus montage right bottom"); - QObject::connect(m_rightSecondSurfaceViewController, SIGNAL(surfaceSelected(Surface*)), - this, SLOT(rightSecondSurfaceSelected(Surface*))); - - QHBoxLayout* checkBoxLayout = new QHBoxLayout(); - WuQtUtilities::setLayoutSpacingAndMargins(checkBoxLayout, 2, 0); - checkBoxLayout->addWidget(m_leftCheckBox); - checkBoxLayout->addSpacing(10); - checkBoxLayout->addStretch(); - checkBoxLayout->addWidget(m_lateralCheckBox); - checkBoxLayout->addSpacing(10); - checkBoxLayout->addStretch(); - checkBoxLayout->addWidget(m_medialCheckBox); - checkBoxLayout->addSpacing(10); - checkBoxLayout->addStretch(); - checkBoxLayout->addWidget(m_rightCheckBox); - - int32_t columnIndex = 0; - const int32_t COLUMN_ONE_TWO = columnIndex++; - const int32_t COLUMN_INDEX_LEFT = columnIndex++; - const int32_t COLUMN_INDEX_RIGHT = columnIndex++; - - QGridLayout* layout = new QGridLayout(this); - layout->setColumnStretch(0, 0); - layout->setColumnStretch(1, 100); - layout->setColumnStretch(2, 100); - WuQtUtilities::setLayoutSpacingAndMargins(layout, 4, 0); - int row = layout->rowCount(); - layout->addWidget(m_surfaceMontageFirstSurfaceCheckBox, row, COLUMN_ONE_TWO); - layout->addWidget(m_leftSurfaceViewController->getWidget(), row, COLUMN_INDEX_LEFT); - layout->addWidget(m_rightSurfaceViewController->getWidget(), row, COLUMN_INDEX_RIGHT); - row = layout->rowCount(); - layout->addWidget(m_surfaceMontageSecondSurfaceCheckBox, row, COLUMN_ONE_TWO); - layout->addWidget(m_leftSecondSurfaceViewController->getWidget(), row, COLUMN_INDEX_LEFT); - layout->addWidget(m_rightSecondSurfaceViewController->getWidget(), row, COLUMN_INDEX_RIGHT); - row = layout->rowCount(); - layout->addLayout(checkBoxLayout, - row, COLUMN_INDEX_LEFT, - 1, 2); - row = layout->rowCount(); - - m_widgetGroup = new WuQWidgetObjectGroup(this); - m_widgetGroup->add(m_leftSurfaceViewController->getWidget()); - m_widgetGroup->add(m_leftSecondSurfaceViewController->getWidget()); - m_widgetGroup->add(m_rightSurfaceViewController->getWidget()); - m_widgetGroup->add(m_rightSecondSurfaceViewController->getWidget()); - m_widgetGroup->add(m_leftCheckBox); - m_widgetGroup->add(m_rightCheckBox); - m_widgetGroup->add(m_surfaceMontageFirstSurfaceCheckBox); - m_widgetGroup->add(m_surfaceMontageSecondSurfaceCheckBox); - m_widgetGroup->add(m_medialCheckBox); - m_widgetGroup->add(m_lateralCheckBox); - - setFixedHeight(sizeHint().height()); -} - -/** - * Destructor. - */ -SurfaceMontageHippocampusComponent::~SurfaceMontageHippocampusComponent() -{ - -} - -/** - * Update the hippocampus montage options widget. - * - * @param browserTabContent - * The active model display controller (may be NULL). - */ -void -SurfaceMontageHippocampusComponent::updateContent(BrowserTabContent* browserTabContent) -{ - m_widgetGroup->blockAllSignals(true); - - const int32_t tabIndex = browserTabContent->getTabNumber(); - ModelSurfaceMontage* msm = browserTabContent->getDisplayedSurfaceMontageModel(); - SurfaceMontageConfigurationHippocampus* smcc = msm->getHippocampusConfiguration(tabIndex); - - m_leftCheckBox->setChecked(smcc->isLeftEnabled()); - m_rightCheckBox->setChecked(smcc->isRightEnabled()); - m_surfaceMontageFirstSurfaceCheckBox->setChecked(smcc->isFirstSurfaceEnabled()); - m_surfaceMontageSecondSurfaceCheckBox->setChecked(smcc->isSecondSurfaceEnabled()); - m_lateralCheckBox->setChecked(smcc->isLateralEnabled()); - m_medialCheckBox->setChecked(smcc->isMedialEnabled()); - - m_leftSurfaceViewController->updateControl(smcc->getLeftFirstSurfaceSelectionModel()); - m_leftSecondSurfaceViewController->updateControl(smcc->getLeftSecondSurfaceSelectionModel()); - m_rightSurfaceViewController->updateControl(smcc->getRightFirstSurfaceSelectionModel()); - m_rightSecondSurfaceViewController->updateControl(smcc->getRightSecondSurfaceSelectionModel()); - - m_widgetGroup->blockAllSignals(false); -} - -/** - * Called when montage left first surface is selected. - * @param surface - * Surface that was selected. - */ -void -SurfaceMontageHippocampusComponent::leftSurfaceSelected(Surface* surface) -{ - if (surface != NULL) { - BrowserTabContent* btc = m_parentToolBarMontage->getTabContentFromSelectedTab(); - const int32_t tabIndex = btc->getTabNumber(); - ModelSurfaceMontage* msm = btc->getDisplayedSurfaceMontageModel(); - SurfaceMontageConfigurationHippocampus* smcc = msm->getHippocampusConfiguration(tabIndex); - smcc->getLeftFirstSurfaceSelectionModel()->setSurface(surface); - m_parentToolBarMontage->invalidateColoringAndUpdateGraphicsWindow(); - } -} - -/** - * Called when montage left second surface is selected. - * @param surface - * Surface that was selected. - */ -void -SurfaceMontageHippocampusComponent::leftSecondSurfaceSelected(Surface* surface) -{ - if (surface != NULL) { - BrowserTabContent* btc = m_parentToolBarMontage->getTabContentFromSelectedTab(); - const int32_t tabIndex = btc->getTabNumber(); - ModelSurfaceMontage* msm = btc->getDisplayedSurfaceMontageModel(); - SurfaceMontageConfigurationHippocampus* smcc = msm->getHippocampusConfiguration(tabIndex); - smcc->getLeftSecondSurfaceSelectionModel()->setSurface(surface); - m_parentToolBarMontage->invalidateColoringAndUpdateGraphicsWindow(); - } -} - -/** - * Called when montage right surface is selected. - * @param surface - * Surface that was selected. - */ -void -SurfaceMontageHippocampusComponent::rightSurfaceSelected(Surface* surface) -{ - if (surface != NULL) { - BrowserTabContent* btc = m_parentToolBarMontage->getTabContentFromSelectedTab(); - const int32_t tabIndex = btc->getTabNumber(); - ModelSurfaceMontage* msm = btc->getDisplayedSurfaceMontageModel(); - SurfaceMontageConfigurationHippocampus* smcc = msm->getHippocampusConfiguration(tabIndex); - smcc->getRightFirstSurfaceSelectionModel()->setSurface(surface); - m_parentToolBarMontage->invalidateColoringAndUpdateGraphicsWindow(); - } -} - -/** - * Called when montage right second surface is selected. - * @param surface - * Surface that was selected. - */ -void -SurfaceMontageHippocampusComponent::rightSecondSurfaceSelected(Surface* surface) -{ - if (surface != NULL) { - BrowserTabContent* btc = m_parentToolBarMontage->getTabContentFromSelectedTab(); - const int32_t tabIndex = btc->getTabNumber(); - ModelSurfaceMontage* msm = btc->getDisplayedSurfaceMontageModel(); - SurfaceMontageConfigurationHippocampus* smcc = msm->getHippocampusConfiguration(tabIndex); - smcc->getRightSecondSurfaceSelectionModel()->setSurface(surface); - m_parentToolBarMontage->invalidateColoringAndUpdateGraphicsWindow(); } } -/** - * Called when surface montage checkbox is toggled. - * @param status - * New status of check box. - */ -void -SurfaceMontageHippocampusComponent::checkBoxSelected(bool /*status*/) -{ - BrowserTabContent* btc = m_parentToolBarMontage->getTabContentFromSelectedTab(); - const int32_t tabIndex = btc->getTabNumber(); - ModelSurfaceMontage* msm = btc->getDisplayedSurfaceMontageModel(); - SurfaceMontageConfigurationHippocampus* smcc = msm->getHippocampusConfiguration(tabIndex); - smcc->setLeftEnabled(m_leftCheckBox->isChecked()); - smcc->setRightEnabled(m_rightCheckBox->isChecked()); - smcc->setFirstSurfaceEnabled(m_surfaceMontageFirstSurfaceCheckBox->isChecked()); - smcc->setSecondSurfaceEnabled(m_surfaceMontageSecondSurfaceCheckBox->isChecked()); - smcc->setLateralEnabled(m_lateralCheckBox->isChecked()); - smcc->setMedialEnabled(m_medialCheckBox->isChecked()); - - m_parentToolBarMontage->updateUserInterface(); - m_parentToolBarMontage->invalidateColoringAndUpdateGraphicsWindow(); -} /* ******************************************************************************************** diff --git a/src/GuiQt/BrainBrowserWindowToolBarSurfaceMontage.h b/src/GuiQt/BrainBrowserWindowToolBarSurfaceMontage.h index 6d1b0c1ff..59e28f2eb 100644 --- a/src/GuiQt/BrainBrowserWindowToolBarSurfaceMontage.h +++ b/src/GuiQt/BrainBrowserWindowToolBarSurfaceMontage.h @@ -34,7 +34,6 @@ namespace caret { class SurfaceMontageCerebellarComponent; class SurfaceMontageCerebralComponent; class SurfaceMontageFlatMapsComponent; - class SurfaceMontageHippocampusComponent; class SurfaceSelectionViewController; class BrainBrowserWindowToolBarSurfaceMontage : public BrainBrowserWindowToolBarComponent { @@ -67,8 +66,6 @@ namespace caret { SurfaceMontageFlatMapsComponent* m_flatMapsComponent; - SurfaceMontageHippocampusComponent* m_hippocampusComponent; - QStackedWidget* m_stackedWidget; EnumComboBoxTemplate* m_surfaceMontageConfigurationTypeEnumComboBox; @@ -186,45 +183,6 @@ namespace caret { WuQWidgetObjectGroup* m_widgetGroup; }; - /* ===========================================================================*/ - - class SurfaceMontageHippocampusComponent : public QWidget { - - Q_OBJECT - - public: - SurfaceMontageHippocampusComponent(BrainBrowserWindowToolBarSurfaceMontage* parentToolBarMontage, - const QString& parentObjectNamePrefix); - - ~SurfaceMontageHippocampusComponent(); - - void updateContent(BrowserTabContent* browserTabContent); - - private slots: - void leftSurfaceSelected(Surface*); - void leftSecondSurfaceSelected(Surface*); - void rightSurfaceSelected(Surface*); - void rightSecondSurfaceSelected(Surface*); - void checkBoxSelected(bool); - - private: - BrainBrowserWindowToolBarSurfaceMontage* m_parentToolBarMontage; - - SurfaceSelectionViewController* m_leftSurfaceViewController; - SurfaceSelectionViewController* m_leftSecondSurfaceViewController; - SurfaceSelectionViewController* m_rightSurfaceViewController; - SurfaceSelectionViewController* m_rightSecondSurfaceViewController; - QCheckBox* m_leftCheckBox; - QCheckBox* m_rightCheckBox; - QCheckBox* m_surfaceMontageFirstSurfaceCheckBox; - QCheckBox* m_surfaceMontageSecondSurfaceCheckBox; - QCheckBox* m_lateralCheckBox; - QCheckBox* m_medialCheckBox; - - WuQWidgetObjectGroup* m_widgetGroup; - }; - - #ifdef __BRAIN_BROWSER_WINDOW_TOOL_BAR_SURFACE_MONTAGE_DECLARE__ // #endif // __BRAIN_BROWSER_WINDOW_TOOL_BAR_SURFACE_MONTAGE_DECLARE__ diff --git a/src/GuiQt/CMakeLists.txt b/src/GuiQt/CMakeLists.txt index 1a29e5947..cc66b9e5a 100644 --- a/src/GuiQt/CMakeLists.txt +++ b/src/GuiQt/CMakeLists.txt @@ -171,8 +171,6 @@ ELSE() LabelSelectionDialog.h LabelSelectionWidget.h LabelSelectionViewController.h - LabelSelectionViewHierarchyController.h - LabelSelectionViewWidget.h LockAspectWarningDialog.h MacApplication.h MacDockMenu.h @@ -182,7 +180,6 @@ ELSE() MapSettingsFiberTrajectoryWidget.h MapSettingsLabelsWidget.h MapSettingsLayerWidget.h - MapSettingsModulateWidget.h MapSettingsPaletteColorMappingWidget.h MapSettingsParcelsWidget.h MapYokingGroupComboBox.h @@ -498,8 +495,6 @@ KeyEvent.h LabelSelectionDialog.h LabelSelectionWidget.h LabelSelectionViewController.h -LabelSelectionViewHierarchyController.h -LabelSelectionViewWidget.h LockAspectWarningDialog.h MacApplication.h MacDockMenu.h @@ -509,7 +504,6 @@ MapSettingsColorBarWidget.h MapSettingsFiberTrajectoryWidget.h MapSettingsLabelsWidget.h MapSettingsLayerWidget.h -MapSettingsModulateWidget.h MapSettingsPaletteColorMappingWidget.h MapSettingsParcelsWidget.h MapYokingGroupComboBox.h @@ -847,8 +841,6 @@ KeyEvent.cxx LabelSelectionDialog.cxx LabelSelectionWidget.cxx LabelSelectionViewController.cxx -LabelSelectionViewHierarchyController.cxx -LabelSelectionViewWidget.cxx LockAspectWarningDialog.cxx MacApplication.cxx MacDockMenu.cxx @@ -858,7 +850,6 @@ MapSettingsColorBarWidget.cxx MapSettingsFiberTrajectoryWidget.cxx MapSettingsLabelsWidget.cxx MapSettingsLayerWidget.cxx -MapSettingsModulateWidget.cxx MapSettingsPaletteColorMappingWidget.cxx MapSettingsParcelsWidget.cxx MapYokingGroupComboBox.cxx diff --git a/src/GuiQt/CaretFileDialog.cxx b/src/GuiQt/CaretFileDialog.cxx index cdf9d2e4f..dc8d0361f 100644 --- a/src/GuiQt/CaretFileDialog.cxx +++ b/src/GuiQt/CaretFileDialog.cxx @@ -203,7 +203,7 @@ CaretFileDialog::initializeCaretFileDialog() m_filterFilesProxyModel = new FilterFilesProxyModel(); this->setProxyModel(m_filterFilesProxyModel); -#ifdef Q_OS_MACOS +#ifdef Q_OS_MACX /* * On Macs, add /Volumes to the sidebar URLs * so that mounted disks can be accessed. @@ -211,7 +211,7 @@ CaretFileDialog::initializeCaretFileDialog() QList urls = this->sidebarUrls(); urls.append(QUrl::fromLocalFile("/Volumes")); this->setSidebarUrls(urls); -#endif // Q_OS_MACOS +#endif // Q_OS_MACX QObject::connect(this, SIGNAL(filterSelected(const QString&)), this, SLOT(fileFilterWasChanged(const QString&))); diff --git a/src/GuiQt/CiftiConnectivityMatrixViewController.cxx b/src/GuiQt/CiftiConnectivityMatrixViewController.cxx index 7a0cced41..c5bcebcf5 100644 --- a/src/GuiQt/CiftiConnectivityMatrixViewController.cxx +++ b/src/GuiQt/CiftiConnectivityMatrixViewController.cxx @@ -43,7 +43,6 @@ #include "CiftiFiberTrajectoryFile.h" #include "CiftiMappableConnectivityMatrixDataFile.h" #include "CiftiConnectivityMatrixParcelDynamicFile.h" -#include "CiftiConnectivityMatrixParcelFile.h" #include "CiftiParcelScalarFile.h" #include "CiftiConnectivityMatrixParcelDynamicFile.h" #include "ConnectivityCorrelationSettingsMenu.h" @@ -723,17 +722,15 @@ CiftiConnectivityMatrixViewController::copyToolButtonClicked(int indx) metricDynConnFile, volDynConnFile); - CiftiConnectivityMatrixParcelFile* parcelMatrixFile = dynamic_cast(matrixFile); bool errorFlag = false; AString errorMessage; const AString directoryName = GuiManager::get()->getBrain()->getCurrentDirectory(); - if ((ciftiParcelDynConnFile != NULL) - || (parcelMatrixFile != NULL)) { - CiftiParcelScalarFile* parcelScalarFile(CiftiParcelScalarFile::newInstanceFromRowInCiftiConnectivityMatrixFile(matrixFile, - directoryName, - errorMessage)); + if (ciftiParcelDynConnFile != NULL) { + CiftiParcelScalarFile* parcelScalarFile(CiftiParcelScalarFile::newInstanceFromRowInCiftiParcelDynamicFile(ciftiParcelDynConnFile, + directoryName, + errorMessage)); if (parcelScalarFile != NULL) { EventDataFileAdd dataFileAdd(parcelScalarFile); EventManager::get()->sendEvent(dataFileAdd.getPointer()); diff --git a/src/GuiQt/EventUserInterfaceUpdate.cxx b/src/GuiQt/EventUserInterfaceUpdate.cxx index a998a9e24..080ed8291 100644 --- a/src/GuiQt/EventUserInterfaceUpdate.cxx +++ b/src/GuiQt/EventUserInterfaceUpdate.cxx @@ -44,7 +44,6 @@ EventUserInterfaceUpdate::EventUserInterfaceUpdate() : Event(EventTypeEnum::EVENT_USER_INTERFACE_UPDATE) { m_windowIndex = -1; - m_isFirstUpdateType = true; this->setAll(true); } diff --git a/src/GuiQt/LabelSelectionViewController.cxx b/src/GuiQt/LabelSelectionViewController.cxx index 7b9a4f378..0cdc55633 100644 --- a/src/GuiQt/LabelSelectionViewController.cxx +++ b/src/GuiQt/LabelSelectionViewController.cxx @@ -19,20 +19,27 @@ */ /*LICENSE_END*/ +#include +#include +#include +#include #include #include #include -#include +//#include +#include #define __LABEL_SELECTION_VIEW_CONTROLLER_DECLARE__ #include "LabelSelectionViewController.h" #undef __LABEL_SELECTION_VIEW_CONTROLLER_DECLARE__ #include "Brain.h" +#include "BrainOpenGL.h" #include "BrainStructure.h" #include "BrowserTabContent.h" #include "CaretAssert.h" #include "GroupAndNameHierarchyViewController.h" +#include "DisplayGroupEnumComboBox.h" #include "DisplayPropertiesLabels.h" #include "EventGraphicsPaintSoonAllWindows.h" #include "EventManager.h" @@ -41,7 +48,10 @@ #include "GuiManager.h" #include "SceneClass.h" #include "VolumeFile.h" +#include "WuQDataEntryDialog.h" #include "WuQMacroManager.h" +#include "WuQTabWidget.h" +#include "WuQtUtilities.h" using namespace caret; @@ -75,11 +85,27 @@ m_objectNamePrefix(parentObjectName { m_browserWindowIndex = browserWindowIndex; + QLabel* groupLabel = new QLabel("Group"); + m_labelsDisplayGroupComboBox = new DisplayGroupEnumComboBox(this, + (m_objectNamePrefix + + ":DisplayGroup"), + "labels"); + QObject::connect(m_labelsDisplayGroupComboBox, SIGNAL(displayGroupSelected(const DisplayGroupEnum::Enum)), + this, SLOT(labelDisplayGroupSelected(const DisplayGroupEnum::Enum))); + + QHBoxLayout* groupLayout = new QHBoxLayout(); + groupLayout->addWidget(groupLabel); + groupLayout->addWidget(m_labelsDisplayGroupComboBox->getWidget()); + groupLayout->addStretch(); + QWidget* selectionWidget = this->createSelectionWidget(); QVBoxLayout* layout = new QVBoxLayout(this); - layout->setContentsMargins(0, 0, 0, 0); - layout->addWidget(selectionWidget); + layout->addLayout(groupLayout); + layout->addWidget(selectionWidget, 0, Qt::AlignLeft); + layout->addStretch(); + + EventManager::get()->addEventListener(this, EventTypeEnum::EVENT_USER_INTERFACE_UPDATE); LabelSelectionViewController::allLabelSelectionViewControllers.insert(this); } @@ -89,6 +115,8 @@ m_objectNamePrefix(parentObjectName */ LabelSelectionViewController::~LabelSelectionViewController() { + EventManager::get()->removeAllEventsFromListener(this); + LabelSelectionViewController::allLabelSelectionViewControllers.erase(this); } @@ -102,12 +130,39 @@ LabelSelectionViewController::createSelectionWidget() "labels", this); - QScrollArea* scrollArea = new QScrollArea(); - scrollArea->setWidget(m_labelClassNameHierarchyViewController); - scrollArea->setWidgetResizable(true); - scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); + return m_labelClassNameHierarchyViewController; +} + +/** + * Called when the label display group combo box is changed. + */ +void +LabelSelectionViewController::labelDisplayGroupSelected(const DisplayGroupEnum::Enum displayGroup) +{ + /* + * Update selected display group in model. + */ + BrowserTabContent* browserTabContent = + GuiManager::get()->getBrowserTabContentForBrowserWindow(m_browserWindowIndex, false); + if (browserTabContent == NULL) { + return; + } - return scrollArea; + const int32_t browserTabIndex = browserTabContent->getTabNumber(); + Brain* brain = GuiManager::get()->getBrain(); + DisplayPropertiesLabels* dsb = brain->getDisplayPropertiesLabels(); + dsb->setDisplayGroupForTab(browserTabIndex, + displayGroup); + + /* + * Since display group has changed, need to update controls + */ + updateLabelViewController(); + + /* + * Apply the changes. + */ + processLabelSelectionChanges(); } /** @@ -129,6 +184,8 @@ LabelSelectionViewController::updateLabelViewController() DisplayPropertiesLabels* dpb = brain->getDisplayPropertiesLabels(); const DisplayGroupEnum::Enum displayGroup = dpb->getDisplayGroupForTab(browserTabIndex); + m_labelsDisplayGroupComboBox->setSelectedDisplayGroup(dpb->getDisplayGroupForTab(browserTabIndex)); + /* * Get all of label files. */ @@ -194,6 +251,16 @@ LabelSelectionViewController::updateOtherLabelViewControllers() void LabelSelectionViewController::processLabelSelectionChanges() { + BrowserTabContent* browserTabContent = + GuiManager::get()->getBrowserTabContentForBrowserWindow(m_browserWindowIndex, false); + CaretAssert(browserTabContent); + const int32_t browserTabIndex = browserTabContent->getTabNumber(); + Brain* brain = GuiManager::get()->getBrain(); + DisplayPropertiesLabels* dsb = brain->getDisplayPropertiesLabels(); + dsb->setDisplayGroupForTab(browserTabIndex, + m_labelsDisplayGroupComboBox->getSelectedDisplayGroup()); + + processSelectionChanges(); } @@ -208,6 +275,34 @@ LabelSelectionViewController::processSelectionChanges() EventManager::get()->sendEvent(EventGraphicsPaintSoonAllWindows().getPointer()); } +/** + * Receive events from the event manager. + * + * @param event + * Event sent by event manager. + */ +void +LabelSelectionViewController::receiveEvent(Event* event) +{ + bool doUpdate = false; + + if (event->getEventType() == EventTypeEnum::EVENT_USER_INTERFACE_UPDATE) { + EventUserInterfaceUpdate* uiEvent = dynamic_cast(event); + CaretAssert(uiEvent); + + if (uiEvent->isUpdateForWindow(m_browserWindowIndex)) { + if (uiEvent->isToolBoxUpdate()) { + doUpdate = true; + uiEvent->setEventProcessed(); + } + } + } + + if (doUpdate) { + updateLabelViewController(); + } +} + /** * Create a scene for an instance of a class. * diff --git a/src/GuiQt/LabelSelectionViewController.h b/src/GuiQt/LabelSelectionViewController.h index c576022a2..59141d8b3 100644 --- a/src/GuiQt/LabelSelectionViewController.h +++ b/src/GuiQt/LabelSelectionViewController.h @@ -21,11 +21,13 @@ */ /*LICENSE_END*/ -#include +#include #include #include +#include "DisplayGroupEnum.h" +#include "EventListenerInterface.h" #include "SceneableInterface.h" class QCheckBox; @@ -33,8 +35,9 @@ class QCheckBox; namespace caret { class GroupAndNameHierarchyViewController; + class DisplayGroupEnumComboBox; - class LabelSelectionViewController : public QWidget, public SceneableInterface { + class LabelSelectionViewController : public QWidget, public EventListenerInterface, public SceneableInterface { Q_OBJECT @@ -45,24 +48,28 @@ namespace caret { virtual ~LabelSelectionViewController(); + void receiveEvent(Event* event); + virtual SceneClass* saveToScene(const SceneAttributes* sceneAttributes, const AString& instanceName); virtual void restoreFromScene(const SceneAttributes* sceneAttributes, const SceneClass* sceneClass); - void updateLabelViewController(); - private slots: void processLabelSelectionChanges(); void processSelectionChanges(); + void labelDisplayGroupSelected(const DisplayGroupEnum::Enum); + private: LabelSelectionViewController(const LabelSelectionViewController&); LabelSelectionViewController& operator=(const LabelSelectionViewController&); + void updateLabelViewController(); + void updateOtherLabelViewControllers(); QWidget* createSelectionWidget(); @@ -77,6 +84,8 @@ namespace caret { QCheckBox* m_labelsContralateralCheckBox; + DisplayGroupEnumComboBox* m_labelsDisplayGroupComboBox; + static std::set allLabelSelectionViewControllers; }; diff --git a/src/GuiQt/LabelSelectionViewHierarchyController.cxx b/src/GuiQt/LabelSelectionViewHierarchyController.cxx deleted file mode 100644 index 9c14f7a21..000000000 --- a/src/GuiQt/LabelSelectionViewHierarchyController.cxx +++ /dev/null @@ -1,782 +0,0 @@ - -/*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*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define __LABEL_SELECTION_VIEW_HIERARCHY_CONTROLLER_DECLARE__ -#include "LabelSelectionViewHierarchyController.h" -#undef __LABEL_SELECTION_VIEW_HIERARCHY_CONTROLLER_DECLARE__ - -#include "Brain.h" -#include "BrainStructure.h" -#include "BrowserTabContent.h" -#include "CaretAssert.h" -#include "CaretHierarchy.h" -#include "CaretLogger.h" -#include "CaretMappableDataFileAndMapSelectorObject.h" -#include "Cluster.h" -#include "DisplayPropertiesLabels.h" -#include "EventGraphicsPaintSoonAllWindows.h" -#include "EventIdentificationHighlightLocation.h" -#include "EventManager.h" -#include "EventSurfaceColoringInvalidate.h" -#include "EventUserInterfaceUpdate.h" -#include "GuiManager.h" -#include "LabelSelectionItem.h" -#include "LabelSelectionItemModel.h" -#include "SceneClass.h" -#include "SceneStringArray.h" -#include "WuQMacroManager.h" -#include "WuQMessageBoxTwo.h" - -using namespace caret; - - - -/** - * \class caret::LabelSelectionViewHierarchyController - * \brief Widget for controlling display of labels - * \ingroup GuiQt - * - * Widget for controlling the display of labels including - * different display groups. - */ - -/** - * Constructor. - * - * @param browserWindowIndex - * Index of browser window - * @param parentObjectName - * Name of parent object - * @param parent - * The parent object - */ -LabelSelectionViewHierarchyController::LabelSelectionViewHierarchyController(const int32_t browserWindowIndex, - const QString& parentObjectName, - QWidget* parent) -: QWidget(parent), -m_objectNamePrefix(parentObjectName - + ":LabelHierarchy") -{ - m_browserWindowIndex = browserWindowIndex; - - std::vector dataFileTypes { DataFileTypeEnum::VOLUME }; - std::vector volumeTypes { SubvolumeAttributes::LABEL }; - std::vector structures; - - QLabel* fileLabel(new QLabel("File")); - QLabel* mapLabel(new QLabel("Map")); - m_labelFileAndMapSelector = new CaretMappableDataFileAndMapSelectorObject(dataFileTypes, - volumeTypes, - CaretMappableDataFileAndMapSelectorObject::OPTION_SHOW_MAP_INDEX_SPIN_BOX, - this); - QObject::connect(m_labelFileAndMapSelector, &CaretMappableDataFileAndMapSelectorObject::selectionWasPerformed, - this, &LabelSelectionViewHierarchyController::processFileSelectionChanged); - QWidget* mapFileComboBox(NULL); - QWidget* mapIndexSpinBox(NULL); - QWidget* mapNameComboBox(NULL); - m_labelFileAndMapSelector->getWidgetsForAddingToLayout(mapFileComboBox, - mapIndexSpinBox, - mapNameComboBox); - - m_collapseAllAction = new QAction("Collpase"); - m_collapseAllAction->setToolTip("Collapse all items"); - QObject::connect(m_collapseAllAction, &QAction::triggered, - this, &LabelSelectionViewHierarchyController::collapseAllActionTriggered); - QToolButton* collapseAllToolButton(new QToolButton()); - collapseAllToolButton->setDefaultAction(m_collapseAllAction); - - m_expandAllAction = new QAction("Expand"); - m_expandAllAction->setToolTip("Expand all items"); - QObject::connect(m_expandAllAction, &QAction::triggered, - this, &LabelSelectionViewHierarchyController::expandAllActionTriggered); - QToolButton* expandAllToolButton(new QToolButton()); - expandAllToolButton->setDefaultAction(m_expandAllAction); - - m_allOnAction = new QAction("On"); - m_allOnAction->setToolTip("Turn all items on (check all)"); - QObject::connect(m_allOnAction, &QAction::triggered, - this, &LabelSelectionViewHierarchyController::allOnActionTriggered); - QToolButton* allOnToolButton(new QToolButton()); - allOnToolButton->setDefaultAction(m_allOnAction); - - m_allOffAction = new QAction("Off"); - m_allOffAction->setToolTip("Turn all items off (uncheck all)"); - QObject::connect(m_allOffAction, &QAction::triggered, - this, &LabelSelectionViewHierarchyController::allOffActionTriggered); - QToolButton* allOffToolButton(new QToolButton()); - allOffToolButton->setDefaultAction(m_allOffAction); - - m_infoAction = new QAction("Info"); - m_infoAction->setToolTip("Show information about selected label"); - m_infoAction->setEnabled(false); - QObject::connect(m_infoAction, &QAction::triggered, - this, &LabelSelectionViewHierarchyController::infoActionTriggered); - m_infoToolButton = new QToolButton; - m_infoToolButton->setDefaultAction(m_infoAction); - - m_findAction = new QAction("Find"); - m_findAction->setToolTip("Find the first item containing the text"); - m_findAction->setEnabled(false); - QObject::connect(m_findAction, &QAction::triggered, - this, &LabelSelectionViewHierarchyController::findActionTriggered); - QToolButton* findToolButton(new QToolButton); - findToolButton->setDefaultAction(m_findAction); - - m_nextAction = new QAction("Next"); - m_nextAction->setToolTip("Move to the next item containing the text (will wrap)"); - m_nextAction->setEnabled(false); - QObject::connect(m_nextAction, &QAction::triggered, - this, &LabelSelectionViewHierarchyController::nextActionTriggered); - QToolButton* nextToolButton(new QToolButton); - nextToolButton->setDefaultAction(m_nextAction); - - m_findTextLineEdit = new QLineEdit(); - m_findTextLineEdit->setToolTip("Enter find text here"); - QObject::connect(m_findTextLineEdit, &QLineEdit::returnPressed, - this, &LabelSelectionViewHierarchyController::findActionTriggered); - QObject::connect(m_findTextLineEdit, &QLineEdit::textChanged, - this, &LabelSelectionViewHierarchyController::findTextLineEditTextChanged); - - QHBoxLayout* buttonsLayout(new QHBoxLayout()); - buttonsLayout->setSpacing(buttonsLayout->spacing() / 2); - buttonsLayout->setContentsMargins(2, 2, 2, 2); - buttonsLayout->addWidget(allOnToolButton); - buttonsLayout->addWidget(allOffToolButton); - buttonsLayout->addWidget(collapseAllToolButton); - buttonsLayout->addWidget(expandAllToolButton); - buttonsLayout->addSpacing(4); - buttonsLayout->addWidget(m_infoToolButton); - buttonsLayout->addSpacing(4); - buttonsLayout->addWidget(findToolButton); - buttonsLayout->addWidget(nextToolButton); - buttonsLayout->addWidget(m_findTextLineEdit, - 100); /* stretch factor */ - - m_treeView = new QTreeView(); - m_treeView->setEditTriggers(QTreeView::NoEditTriggers); /* prevent editing text if double-clicked */ - m_treeView->setExpandsOnDoubleClick(false); /* do not collapse/expand if double-clicked */ - m_treeView->setHeaderHidden(true); - m_treeView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - m_treeView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - m_treeView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); - m_treeView->setContextMenuPolicy(Qt::CustomContextMenu); - QObject::connect(m_treeView, &QTreeView::clicked, - this, &LabelSelectionViewHierarchyController::treeItemClicked); - QObject::connect(m_treeView, &QTreeView::doubleClicked, - this, &LabelSelectionViewHierarchyController::treeItemDoubleClicked); - QObject::connect(m_treeView, &QTreeView::customContextMenuRequested, - this, &LabelSelectionViewHierarchyController::showTreeViewContextMenu); - - QGridLayout* layout(new QGridLayout(this)); - layout->setVerticalSpacing(layout->verticalSpacing() / 2); - layout->setColumnStretch(2, 100); - layout->setContentsMargins(0, 0, 0, 0); - int row(0); - layout->addWidget(fileLabel, row, 0); - layout->addWidget(mapFileComboBox, row, 1, 1, 2); - ++row; - layout->addWidget(mapLabel, row, 0); - layout->addWidget(mapIndexSpinBox, row, 1); - layout->addWidget(mapNameComboBox, row, 2); - ++row; - layout->addLayout(buttonsLayout, row, 0, 1, 3); - ++row; - layout->addWidget(m_treeView, row, 0, 1, 3); - layout->setRowStretch(row, 100); -} - -/** - * Destructor. - */ -LabelSelectionViewHierarchyController::~LabelSelectionViewHierarchyController() -{ -} - -/** - * Called when tree item is - * @param modelIndex - * Model index that is - */ -void -LabelSelectionViewHierarchyController::treeItemDoubleClicked(const QModelIndex& /*modelIndex*/) -{ -} - -/** - * @return The LabelSelectionItem at the model index or NULL if not available. - * @param modelIndex - * The model index. - */ -LabelSelectionItem* -LabelSelectionViewHierarchyController::getLabelSelectionItemAtModelIndex(const QModelIndex& modelIndex) -{ - if (modelIndex.isValid()) { - auto model(modelIndex.model()); - if (model != NULL) { - const QAbstractItemModel* model(modelIndex.model()); - if (model != NULL) { - if (model == m_labelHierarchyModel) { - QStandardItem* standardItem(m_labelHierarchyModel->itemFromIndex(modelIndex)); - if (standardItem != NULL) { - LabelSelectionItem* labelItem(dynamic_cast(standardItem)); - return labelItem; - } - } - } - } - } - return NULL; -} - -/** - * Called when tree item is - * @param modelIndex - * Model index that is - */ -void -LabelSelectionViewHierarchyController::treeItemClicked(const QModelIndex& modelIndex) -{ - LabelSelectionItem* labelItem(getLabelSelectionItemAtModelIndex(modelIndex)); - if (labelItem != NULL) { - const auto checkState(labelItem->checkState()); - labelItem->setAllChildrenChecked(checkState == Qt::Checked); - - m_infoAction->setEnabled(true); - } - - processSelectionChanges(); -} - -/** - * Show a context menu for the tree view - * @param pos - * Position in the tree view - */ -void -LabelSelectionViewHierarchyController::showTreeViewContextMenu(const QPoint& pos) -{ - const QModelIndex modelIndex(m_treeView->indexAt(pos)); - LabelSelectionItem* labelItem(getLabelSelectionItemAtModelIndex(modelIndex)); - if (labelItem != NULL) { - const bool infoButtonFlag(false); - showSelectedItemMenu(labelItem, - m_treeView->mapToGlobal(pos), - infoButtonFlag); - } -} - -/** - * Show a menu for the selected label - * @param labelItem - * The label item that is selected - * @param pos - * Position for the menu - * @param infoButtonFlag - * If true, menu is for the Info button, else right-click menu on label - */ -void -LabelSelectionViewHierarchyController::showSelectedItemMenu(const LabelSelectionItem* labelItem, - const QPoint& pos, - const bool infoButtonFlag) -{ - CaretAssert(labelItem); - const QString name(labelItem->text()); - - QMenu menu(this); - - QAction* infoAction(NULL); - if (infoButtonFlag) { - infoAction = menu.addAction("Info..."); - menu.addSeparator(); - } - - /* - * My clusters - */ - std::vector clusterActions; - std::vector clusterXYZs; - const LabelSelectionItem::CogSet* allCogSet(labelItem->getMyAndChildrenCentersOfGravity()); - if (allCogSet != NULL) { - const std::vector cogs(allCogSet->getCOGs()); - for (const LabelSelectionItem::COG* c : cogs) { - QAction* a(menu.addAction(c->getTitle())); - clusterActions.push_back(a); - clusterXYZs.push_back(c->getXYZ()); - } - CaretAssert(clusterActions.size() == clusterXYZs.size()); - } - const LabelSelectionItem::CogSet* cogSet(labelItem->getCentersOfGravity()); - if (cogSet != NULL) { - if ( ! clusterActions.empty()) { - menu.addSeparator(); - } - const std::vector cogs(cogSet->getCOGs()); - for (const LabelSelectionItem::COG* c : cogs) { - QAction* a(menu.addAction(c->getTitle())); - clusterActions.push_back(a); - clusterXYZs.push_back(c->getXYZ()); - } - CaretAssert(clusterActions.size() == clusterXYZs.size()); - } - - if ( ! menu.actions().isEmpty()) { - QAction* selectedAction(menu.exec(pos)); - if (selectedAction != NULL) { - if (selectedAction == infoAction) { - WuQMessageBoxTwo::information(this, - "Info", - labelItem->getTextForInfoDisplay()); - } - else { - for (int32_t i = 0; i < static_cast(clusterActions.size()); i++) { - if (selectedAction == clusterActions[i]) { - CaretAssertVectorIndex(clusterXYZs, i); - const Vector3D cogXYZ(clusterXYZs[i]); - EventIdentificationHighlightLocation highlightLocation(m_browserTabIndex, - cogXYZ, - cogXYZ, - EventIdentificationHighlightLocation::LOAD_FIBER_ORIENTATION_SAMPLES_MODE_NO); - EventManager::get()->sendEvent(highlightLocation.getPointer()); - break; - } - } - } - - EventManager::get()->sendEvent(EventGraphicsPaintSoonAllWindows().getPointer()); - EventManager::get()->sendEvent(EventUserInterfaceUpdate().getPointer()); - } - } -} - -/** - * Set the checked status of all children - * @param item - * The item - * @param checkState - * The check state - */ -void -LabelSelectionViewHierarchyController::setCheckedStatusOfAllChildren(QStandardItem* item, - const Qt::CheckState checkState) -{ - CaretAssert(item); - const int32_t numChildren(item->rowCount()); - for (int32_t iRow = 0; iRow < numChildren; iRow++) { - QStandardItem* child(item->child(iRow)); - child->setCheckState(checkState); - setCheckedStatusOfAllChildren(child, - checkState); - } -} - -/** - * Called when the file selection is changed - */ -void -LabelSelectionViewHierarchyController::processFileSelectionChanged() -{ - /* - * Since display group has changed, need to update controls - */ - updateLabelViewController(); - - /* - * Apply the changes. - */ - processSelectionChanges(); -} - -/** - * Update the label selection widget. - */ -void -LabelSelectionViewHierarchyController::updateLabelViewController() -{ - bool enableTreeViewFlag(false); - bool enableWidgetFlag(false); - - BrowserTabContent* browserTabContent = - GuiManager::get()->getBrowserTabContentForBrowserWindow(m_browserWindowIndex, true); - m_browserTabIndex = -1; - if (browserTabContent != NULL) { - m_browserTabIndex = browserTabContent->getTabNumber(); - - std::pair fileAndMapIndex(getSelectedFileAndMapIndex()); - CaretMappableDataFile* mapFile(fileAndMapIndex.first); - - if (mapFile != NULL) { - if (mapFile->isMappedWithLabelTable()) { - const int32_t mapIndex(fileAndMapIndex.second); - if ((mapIndex >= 0) - && (mapIndex < mapFile->getNumberOfMaps())) { - enableWidgetFlag = true; - - const DisplayPropertiesLabels* dsl(GuiManager::get()->getBrain()->getDisplayPropertiesLabels()); - CaretAssert(dsl); - LabelSelectionItemModel* selectionModel(mapFile->getLabelSelectionHierarchyForMapAndTab(mapIndex, - dsl->getDisplayGroupForTab(m_browserTabIndex), - m_browserTabIndex)); - if (selectionModel != NULL) { - if (selectionModel->isValid()) { - const LabelSelectionItemModel* oldHierarchyModel(m_labelHierarchyModel); - m_labelHierarchyModel = selectionModel; - m_treeView->setModel(m_labelHierarchyModel); - m_treeView->setEnabled(true); - if (m_labelHierarchyModel != oldHierarchyModel) { - /* - * If model has changed and NO top level items are expanded, - * expand all items - */ - bool topLevelItemExpandedFlag(false); - const std::vector topLevelItems(m_labelHierarchyModel->getTopLevelItems()); - for (const LabelSelectionItem* item : topLevelItems) { - if (m_treeView->isExpanded(item->index())) { - topLevelItemExpandedFlag = true; - break; - } - } - if ( ! topLevelItemExpandedFlag) { - m_treeView->expandAll(); - } - } - m_treeView->adjustSize(); - - m_findItems.clear(); - m_findItemsCurrentIndex = 0; - findTextLineEditTextChanged(m_findTextLineEdit->text()); - - enableTreeViewFlag = true; - } - } - } - } - } - } - - if (enableTreeViewFlag) { - m_treeView->setEnabled(true); - } - else { - m_labelHierarchyModel = NULL; - m_treeView->setModel(NULL); - m_treeView->setEnabled(false); - - m_findItems.clear(); - m_findItemsCurrentIndex = 0; - findTextLineEditTextChanged(m_findTextLineEdit->text()); - } - - m_treeView->adjustSize(); - - m_allOnAction->setEnabled(enableTreeViewFlag); - m_allOffAction->setEnabled(enableTreeViewFlag); - m_collapseAllAction->setEnabled(enableTreeViewFlag); - m_expandAllAction->setEnabled(enableTreeViewFlag); - - setEnabled(enableWidgetFlag); -} - -/** - * Issue update events after selections are changed. - */ -void -LabelSelectionViewHierarchyController::processSelectionChanges() -{ - if (m_labelHierarchyModel != NULL) { - m_labelHierarchyModel->updateCheckedStateOfAllItems(); - - std::pair fileAndMapIndex(getSelectedFileAndMapIndex()); - CaretMappableDataFile* mapFile(fileAndMapIndex.first); - const int32_t mapIndex(fileAndMapIndex.second); - - if (mapFile != NULL) { - mapFile->updateScalarColoringForMap(mapIndex); - if (mapFile->isSurfaceMappable()) { - EventManager::get()->sendEvent(EventSurfaceColoringInvalidate().getPointer()); - } - } - - const bool copyToLabelTableFlag(true); - m_labelHierarchyModel->synchronizeSelectionsWithLabelTable(copyToLabelTableFlag); - } - - EventManager::get()->sendEvent(EventGraphicsPaintSoonAllWindows().getPointer()); -} - -/** - * Called when collapse all action is triggered - */ -void -LabelSelectionViewHierarchyController::collapseAllActionTriggered() -{ - m_treeView->collapseAll(); -} - -/** - * Called when expand all action is triggered - */ -void -LabelSelectionViewHierarchyController::expandAllActionTriggered() -{ - m_treeView->expandAll(); -} - -/** - * Called when expand all action is triggered - */ -void -LabelSelectionViewHierarchyController::allOnActionTriggered() -{ - if (m_labelHierarchyModel != NULL) { - m_labelHierarchyModel->setCheckedStatusOfAllItems(true); - processSelectionChanges(); - } -} - -/** - * Called when expand all action is triggered - */ -void -LabelSelectionViewHierarchyController::allOffActionTriggered() -{ - if (m_labelHierarchyModel != NULL) { - m_labelHierarchyModel->setCheckedStatusOfAllItems(false); - processSelectionChanges(); - } -} - -/** - * Called when Info button is clicked - */ -void -LabelSelectionViewHierarchyController::infoActionTriggered() -{ - const QModelIndex selectedIndex(m_treeView->currentIndex()); - if (selectedIndex.isValid()) { - if (m_labelHierarchyModel != NULL) { - QStandardItem* item(m_labelHierarchyModel->itemFromIndex(selectedIndex)); - if (item != NULL) { - const LabelSelectionItem* labelItem(dynamic_cast(item)); - if (labelItem != NULL) { - const bool infoButtonFlag(true); - showSelectedItemMenu(labelItem, - mapToGlobal(m_infoToolButton->pos()), - infoButtonFlag); - } - } - } - } -} - -/** - * Called when find button is clicked or return is pressed in the find line edit - */ -void -LabelSelectionViewHierarchyController::findActionTriggered() -{ - m_findItems.clear(); - m_findItemsCurrentIndex = 0; - - if (m_labelHierarchyModel != NULL) { - const QString findText(m_findTextLineEdit->text().trimmed()); - - const int modelColumn(0); - m_findItems = m_labelHierarchyModel->findItems(findText, - (Qt::MatchContains - | Qt::MatchRecursive), - modelColumn); - if (m_findItems.isEmpty()) { - GuiManager::get()->beep(); - } - scrollTreeViewToFindItem(); - } -} - -/** - * Called when next button is clicked - */ -void -LabelSelectionViewHierarchyController::nextActionTriggered() -{ - scrollTreeViewToFindItem(); -} - -/** - * Scroll the tree view to the next find item - */ -void -LabelSelectionViewHierarchyController::scrollTreeViewToFindItem() -{ - const int32_t numFindItems(m_findItems.size()); - if (numFindItems > 0) { - if ((m_findItemsCurrentIndex < 0) - || (m_findItemsCurrentIndex >= numFindItems)) { - m_findItemsCurrentIndex = 0; - } - CaretAssertVectorIndex(m_findItems, m_findItemsCurrentIndex); - const QStandardItem* item(m_findItems[m_findItemsCurrentIndex]); - const QModelIndex modelIndex(m_labelHierarchyModel->indexFromItem(item)); - if (modelIndex.isValid()) { - m_treeView->setCurrentIndex(modelIndex); - m_treeView->scrollTo(modelIndex, - QTreeView::PositionAtCenter); - } - - /* - * For 'next' - */ - ++m_findItemsCurrentIndex; - } - - m_nextAction->setEnabled(numFindItems > 1); -} - - -/** - * Called when next button is clicked - * @param text - * Text in the line edit - */ -void -LabelSelectionViewHierarchyController::findTextLineEditTextChanged(const QString& text) -{ - m_findAction->setEnabled( ! text.trimmed().isEmpty()); - m_nextAction->setEnabled(false); - m_findItems.clear(); - m_findItemsCurrentIndex = 0; -} - - -/** - * @return A pair containing the selected file and map index - */ -std::pair -LabelSelectionViewHierarchyController::getSelectedFileAndMapIndex() -{ - CaretAssert(m_labelFileAndMapSelector); - CaretMappableDataFileAndMapSelectionModel* model = m_labelFileAndMapSelector->getModel(); - CaretAssert(model); - m_labelFileAndMapSelector->updateFileAndMapSelector(model); - - CaretMappableDataFile* mapFile = model->getSelectedFile(); - const int32_t mapIndex = model->getSelectedMapIndex(); - - return std::make_pair(mapFile, mapIndex); -} - -/** - * Create a scene for an instance of a class. - * - * @param sceneAttributes - * Attributes for the scene. Scenes may be of different types - * (full, generic, etc) and the attributes should be checked when - * saving the scene. - * - * @return Pointer to SceneClass object representing the state of - * this object. Under some circumstances a NULL pointer may be - * returned. Caller will take ownership of returned object. - */ -SceneClass* -LabelSelectionViewHierarchyController::saveToScene(const SceneAttributes* /*sceneAttributes*/, - const AString& instanceName) -{ - /* - * Make sure current model (m_labelHierarchyModel) is valid - */ - updateLabelViewController(); - - SceneClass* sceneClass = new SceneClass(instanceName, - "LabelSelectionViewHierarchyController", - 1); - - if (m_labelHierarchyModel != NULL) { - std::vector items(m_labelHierarchyModel->getAllDescendants()); - std::vector expandedNames; - for (const LabelSelectionItem* lsi : items) { - if (m_treeView->isExpanded(lsi->index())) { - expandedNames.push_back(lsi->text()); - } - } - - if ( ! expandedNames.empty()) { - sceneClass->addStringArray("expandedNames", &expandedNames[0], expandedNames.size()); - } - } - return sceneClass; -} - -/** - * Restore the state of an instance of a class. - * - * @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 containing the state that was previously - * saved and should be restored. - */ -void -LabelSelectionViewHierarchyController::restoreFromScene(const SceneAttributes* /*sceneAttributes*/, - const SceneClass* sceneClass) -{ - updateLabelViewController(); - m_treeView->expandAll(); - - if ((sceneClass == NULL) - || (m_labelHierarchyModel == NULL)) { - return; - } - - const ScenePrimitiveArray* expandedNamesArray(sceneClass->getPrimitiveArray("expandedNames")); - if (expandedNamesArray != NULL) { - std::set expandedNames; - const int32_t numNames(expandedNamesArray->getNumberOfArrayElements()); - for (int32_t i = 0; i < numNames; i++) { - expandedNames.insert(expandedNamesArray->stringValue(i)); - } - - if ( ! expandedNames.empty()) { - m_treeView->collapseAll(); - - const std::vector items(m_labelHierarchyModel->getAllDescendants()); - for (LabelSelectionItem* lsi : items) { - if (expandedNames.find(lsi->text()) != expandedNames.end()) { - m_treeView->expand(lsi->index()); - } - } - } - } -} - - - diff --git a/src/GuiQt/LabelSelectionViewHierarchyController.h b/src/GuiQt/LabelSelectionViewHierarchyController.h deleted file mode 100644 index 87cac8d0b..000000000 --- a/src/GuiQt/LabelSelectionViewHierarchyController.h +++ /dev/null @@ -1,149 +0,0 @@ -#ifndef __LABEL_SELECTION_VIEW_HIERARCHY_CONTROLLER__H_ -#define __LABEL_SELECTION_VIEW_HIERARCHY_CONTROLLER__H_ - -/*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*/ - -#include -#include -#include - -#include - -#include "SceneableInterface.h" - -class QLineEdit; -class QModelIndex; -class QStandardItem; -class QStandardItemModel; -class QTreeView; -class QToolButton; - -namespace caret { - - class CaretMappableDataFile; - class CaretMappableDataFileAndMapSelectorObject; - class LabelSelectionItem; - class LabelSelectionItemModel; - - class LabelSelectionViewHierarchyController : public QWidget, public SceneableInterface { - - Q_OBJECT - - public: - LabelSelectionViewHierarchyController(const int32_t browserWindowIndex, - const QString& parentObjectName, - QWidget* parent = 0); - - virtual ~LabelSelectionViewHierarchyController(); - - virtual SceneClass* saveToScene(const SceneAttributes* sceneAttributes, - const AString& instanceName); - - virtual void restoreFromScene(const SceneAttributes* sceneAttributes, - const SceneClass* sceneClass); - - void updateLabelViewController(); - - private slots: - LabelSelectionItem* getLabelSelectionItemAtModelIndex(const QModelIndex& modelIndex); - - void showTreeViewContextMenu(const QPoint& pos); - - void processFileSelectionChanged(); - - void processSelectionChanges(); - - void treeItemClicked(const QModelIndex& modelIndex); - - void treeItemDoubleClicked(const QModelIndex& modelIndex); - - void collapseAllActionTriggered(); - - void expandAllActionTriggered(); - - void allOnActionTriggered(); - - void allOffActionTriggered(); - - void infoActionTriggered(); - - void findActionTriggered(); - - void nextActionTriggered(); - - void findTextLineEditTextChanged(const QString& text); - - private: - LabelSelectionViewHierarchyController(const LabelSelectionViewHierarchyController&); - - LabelSelectionViewHierarchyController& operator=(const LabelSelectionViewHierarchyController&); - - void setCheckedStatusOfAllChildren(QStandardItem* item, - const Qt::CheckState checkState); - - std::pair getSelectedFileAndMapIndex(); - - void scrollTreeViewToFindItem(); - - void showSelectedItemMenu(const LabelSelectionItem* labelItem, - const QPoint& pos, - const bool infoButtonFlag); - - const QString m_objectNamePrefix; - - int32_t m_browserWindowIndex = -1; - - int32_t m_browserTabIndex = -1; - - QTreeView* m_treeView; - - QAction* m_collapseAllAction; - - QAction* m_expandAllAction; - - QAction* m_allOnAction; - - QAction* m_allOffAction; - - QToolButton* m_infoToolButton; - - QAction* m_infoAction; - - QAction* m_findAction; - - QAction* m_nextAction; - - QLineEdit* m_findTextLineEdit; - - LabelSelectionItemModel* m_labelHierarchyModel = NULL; - - CaretMappableDataFileAndMapSelectorObject* m_labelFileAndMapSelector; - - QList m_findItems; - - int32_t m_findItemsCurrentIndex = 0; - }; - -#ifdef __LABEL_SELECTION_VIEW_HIERARCHY_CONTROLLER_DECLARE__ -#endif // __LABEL_SELECTION_VIEW_HIERARCHY_CONTROLLER_DECLARE__ - -} // namespace -#endif //__LABEL_SELECTION_VIEW_HIERARCHY_CONTROLLER__H_ diff --git a/src/GuiQt/LabelSelectionViewWidget.cxx b/src/GuiQt/LabelSelectionViewWidget.cxx deleted file mode 100644 index 93a2333b7..000000000 --- a/src/GuiQt/LabelSelectionViewWidget.cxx +++ /dev/null @@ -1,316 +0,0 @@ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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 __LABEL_SELECTION_VIEW_WIDGET_DECLARE__ -#include "LabelSelectionViewWidget.h" -#undef __LABEL_SELECTION_VIEW_WIDGET_DECLARE__ - -#include -#include -#include -#include - -#include "Brain.h" -#include "BrowserTabContent.h" -#include "CaretAssert.h" -#include "CaretLogger.h" -#include "DisplayGroupEnumComboBox.h" -#include "DisplayPropertiesLabels.h" -#include "EnumComboBoxTemplate.h" -#include "EventManager.h" -#include "EventGraphicsPaintSoonAllWindows.h" -#include "EventSurfaceColoringInvalidate.h" -#include "EventUserInterfaceUpdate.h" -#include "GuiManager.h" -#include "LabelSelectionViewController.h" -#include "LabelSelectionViewHierarchyController.h" -#include "LabelViewModeEnum.h" -#include "GuiManager.h" -#include "SceneClass.h" - -using namespace caret; - - - -/** - * \class caret::LabelSelectionViewWidget - * \brief Widget for Label tab of toolbox - * \ingroup GuiQt - */ - -/** - * Constructor. - * @param browserWindowIndex - * Index of browser window - * @param parentObjectName - * Name of parent object - * @param parent - * The parent object - */ -LabelSelectionViewWidget::LabelSelectionViewWidget(const int32_t browserWindowIndex, - const QString& parentObjectName, - QWidget* parent) -: QWidget(parent), -m_browserWindowIndex(browserWindowIndex) -{ - QLabel* labelViewLabel(new QLabel("View")); - m_labelViewModeEnumComboBox = new EnumComboBoxTemplate(this); - m_labelViewModeEnumComboBox->setup(); - QObject::connect(m_labelViewModeEnumComboBox, SIGNAL(itemActivated()), - this, SLOT(labelViewModeEnumComboBoxItemActivated())); - - QLabel* groupLabel = new QLabel("Group"); - m_labelsDisplayGroupComboBox = new DisplayGroupEnumComboBox(this, - (parentObjectName - + ":DisplayGroup"), - "labels"); - QObject::connect(m_labelsDisplayGroupComboBox, SIGNAL(displayGroupSelected(const DisplayGroupEnum::Enum)), - this, SLOT(labelDisplayGroupSelected(const DisplayGroupEnum::Enum))); - - - m_labelViewController = new LabelSelectionViewController(browserWindowIndex, - parentObjectName, - parent); - - m_labelViewHierarchyController = new LabelSelectionViewHierarchyController(browserWindowIndex, - parentObjectName, - parent); - - m_stackedWidget = new QStackedWidget(); - m_labelViewControllerTabIndex = m_stackedWidget->addWidget(m_labelViewController); - m_labelViewHierarchyControllerTabIndex = m_stackedWidget->addWidget(m_labelViewHierarchyController); - - QGridLayout* gridLayout(new QGridLayout(this)); - gridLayout->setContentsMargins(2, 2, 2, 2); - gridLayout->setVerticalSpacing(gridLayout->verticalSpacing() / 2); - gridLayout->setColumnStretch(0, 0); - gridLayout->setColumnStretch(1, 0); - gridLayout->setColumnStretch(2, 0); - gridLayout->setColumnStretch(3, 0); - gridLayout->setColumnStretch(4, 100); - int row(0); - gridLayout->addWidget(labelViewLabel, row, 0); - gridLayout->addWidget(m_labelViewModeEnumComboBox->getWidget(), row, 1); - gridLayout->addWidget(groupLabel, row, 2); - gridLayout->addWidget(m_labelsDisplayGroupComboBox->getWidget(), row, 3, Qt::AlignLeft); - ++row; - gridLayout->addWidget(m_stackedWidget, row, 0, 1, 5); - gridLayout->setRowStretch(row, 100); - - EventManager::get()->addEventListener(this, EventTypeEnum::EVENT_USER_INTERFACE_UPDATE); -} - -/** - * Destructor. - */ -LabelSelectionViewWidget::~LabelSelectionViewWidget() -{ - EventManager::get()->removeAllEventsFromListener(this); -} - -/** - * Called when the label display group combo box is changed. - */ -void -LabelSelectionViewWidget::labelDisplayGroupSelected(const DisplayGroupEnum::Enum displayGroup) -{ - /* - * Update selected display group in model. - */ - BrowserTabContent* browserTabContent = - GuiManager::get()->getBrowserTabContentForBrowserWindow(m_browserWindowIndex, false); - if (browserTabContent == NULL) { - return; - } - - const int32_t browserTabIndex = browserTabContent->getTabNumber(); - Brain* brain = GuiManager::get()->getBrain(); - DisplayPropertiesLabels* dsb = brain->getDisplayPropertiesLabels(); - dsb->setDisplayGroupForTab(browserTabIndex, - displayGroup); - - labelViewModeEnumComboBoxItemActivated(); -} - -/** - * Called when label view mode combo box is changed - */ -void -LabelSelectionViewWidget::labelViewModeEnumComboBoxItemActivated() -{ - BrowserTabContent* browserTabContent = - GuiManager::get()->getBrowserTabContentForBrowserWindow(m_browserWindowIndex, true); - if (browserTabContent == NULL) { - return; - } - const int32_t browserTabIndex(browserTabContent->getTabNumber()); - - Brain* brain(GuiManager::get()->getBrain()); - DisplayPropertiesLabels* dsl(brain->getDisplayPropertiesLabels()); - const LabelViewModeEnum::Enum labelMode = m_labelViewModeEnumComboBox->getSelectedItem(); - dsl->setLabelViewModeForTab(browserTabIndex, - labelMode); - - switch (labelMode) { - case LabelViewModeEnum::HIERARCHY: - m_labelViewHierarchyController->updateLabelViewController(); - m_stackedWidget->setCurrentWidget(m_labelViewHierarchyController); - break; - case LabelViewModeEnum::LIST: - m_labelViewController->updateLabelViewController(); - m_stackedWidget->setCurrentWidget(m_labelViewController); - break; - } - - updateAfterSelectionChanges(); -} -/** - * Receive events from the event manager. - * - * @param event - * Event sent by event manager. - */ -void -LabelSelectionViewWidget::receiveEvent(Event* event) -{ - - bool doUpdate = false; - - if (event->getEventType() == EventTypeEnum::EVENT_USER_INTERFACE_UPDATE) { - EventUserInterfaceUpdate* uiEvent = dynamic_cast(event); - CaretAssert(uiEvent); - - if (uiEvent->isUpdateForWindow(m_browserWindowIndex)) { - if (uiEvent->isToolBoxUpdate()) { - doUpdate = true; - uiEvent->setEventProcessed(); - } - } - } - - if (doUpdate) { - BrowserTabContent* browserTabContent = - GuiManager::get()->getBrowserTabContentForBrowserWindow(m_browserWindowIndex, true); - if (browserTabContent == NULL) { - return; - } - const int32_t browserTabIndex(browserTabContent->getTabNumber()); - - Brain* brain(GuiManager::get()->getBrain()); - const DisplayPropertiesLabels* dpl(brain->getDisplayPropertiesLabels()); - - m_labelViewModeEnumComboBox->setSelectedItem(dpl->getLabelViewModeForTab(browserTabIndex)); - - const DisplayGroupEnum::Enum displayGroup = dpl->getDisplayGroupForTab(browserTabIndex); - - m_labelsDisplayGroupComboBox->setSelectedDisplayGroup(displayGroup); - - switch (dpl->getLabelViewModeForTab(browserTabIndex)) { - case LabelViewModeEnum::HIERARCHY: - m_labelViewHierarchyController->updateLabelViewController(); - m_stackedWidget->setCurrentWidget(m_labelViewHierarchyController); - break; - case LabelViewModeEnum::LIST: - m_labelViewController->updateLabelViewController(); - m_stackedWidget->setCurrentWidget(m_labelViewController); - break; - } - } -} - -/** - * Update after selection changes are made - */ -void -LabelSelectionViewWidget::updateAfterSelectionChanges() -{ - m_labelViewController->updateLabelViewController(); - m_labelViewHierarchyController->updateLabelViewController(); - - EventManager::get()->sendEvent(EventSurfaceColoringInvalidate().getPointer()); - EventManager::get()->sendEvent(EventGraphicsPaintSoonAllWindows().getPointer()); -} - - -/** - * Create a scene for an instance of a class. - * - * @param sceneAttributes - * Attributes for the scene. Scenes may be of different types - * (full, generic, etc) and the attributes should be checked when - * saving the scene. - * - * @return Pointer to SceneClass object representing the state of - * this object. Under some circumstances a NULL pointer may be - * returned. Caller will take ownership of returned object. - */ -SceneClass* -LabelSelectionViewWidget::saveToScene(const SceneAttributes* sceneAttributes, - const AString& instanceName) -{ - SceneClass* sceneClass = new SceneClass(instanceName, - "LabelSelectionViewHierarchyController", - 1); - - sceneClass->addClass(m_labelViewController->saveToScene(sceneAttributes, - "m_labelViewController")); - sceneClass->addClass(m_labelViewHierarchyController->saveToScene(sceneAttributes, - "m_labelViewHierarchyController")); - - return sceneClass; -} - -/** - * Restore the state of an instance of a class. - * - * @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 containing the state that was previously - * saved and should be restored. - */ -void -LabelSelectionViewWidget::restoreFromScene(const SceneAttributes* sceneAttributes, - const SceneClass* sceneClass) -{ - if (sceneClass == NULL) { - return; - } - - const AString className(sceneClass->getName()); - if (className == "m_labelSelectionWidget") { - m_labelViewController->restoreFromScene(sceneAttributes, - sceneClass->getClass("m_labelViewController")); - m_labelViewHierarchyController->restoreFromScene(sceneAttributes, - sceneClass->getClass("m_labelViewHierarchyController")); - } - else if (className == "m_labelSelectionViewController") { - m_labelViewController->restoreFromScene(sceneAttributes, - sceneClass); - } - else { - CaretLogWarning("Restoring LabelSelectionViewWidget with invalid scene class named: " - + className); - } -} diff --git a/src/GuiQt/LabelSelectionViewWidget.h b/src/GuiQt/LabelSelectionViewWidget.h deleted file mode 100644 index f55018b2d..000000000 --- a/src/GuiQt/LabelSelectionViewWidget.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef __LABEL_SELECTION_VIEW_WIDGET_H__ -#define __LABEL_SELECTION_VIEW_WIDGET_H__ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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*/ - - - -#include - -#include - -#include "DisplayGroupEnum.h" -#include "EventListenerInterface.h" -#include "SceneableInterface.h" - -class QStackedWidget; - -namespace caret { - - class DisplayGroupEnumComboBox; - class EnumComboBoxTemplate; - class LabelSelectionViewController; - class LabelSelectionViewHierarchyController; - - class LabelSelectionViewWidget : public QWidget, public EventListenerInterface, public SceneableInterface { - - Q_OBJECT - - public: - LabelSelectionViewWidget(const int32_t browserWindowIndex, - const QString& parentObjectName, - QWidget* parent); - - virtual ~LabelSelectionViewWidget(); - - LabelSelectionViewWidget(const LabelSelectionViewWidget&) = delete; - - LabelSelectionViewWidget& operator=(const LabelSelectionViewWidget&) = delete; - - void receiveEvent(Event* event); - - virtual SceneClass* saveToScene(const SceneAttributes* sceneAttributes, - const AString& instanceName); - - virtual void restoreFromScene(const SceneAttributes* sceneAttributes, - const SceneClass* sceneClass); - - // ADD_NEW_METHODS_HERE - - private slots: - void labelViewModeEnumComboBoxItemActivated(); - - void labelDisplayGroupSelected(const DisplayGroupEnum::Enum); - - private: - void updateAfterSelectionChanges(); - - const int32_t m_browserWindowIndex; - - EnumComboBoxTemplate* m_labelViewModeEnumComboBox; - - QStackedWidget* m_stackedWidget; - - LabelSelectionViewController* m_labelViewController; - - LabelSelectionViewHierarchyController* m_labelViewHierarchyController; - - int32_t m_labelViewControllerTabIndex = -1; - - int32_t m_labelViewHierarchyControllerTabIndex = -1; - - DisplayGroupEnumComboBox* m_labelsDisplayGroupComboBox; - - // ADD_NEW_MEMBERS_HERE - - }; - -#ifdef __LABEL_SELECTION_VIEW_WIDGET_DECLARE__ - // -#endif // __LABEL_SELECTION_VIEW_WIDGET_DECLARE__ - -} // namespace -#endif //__LABEL_SELECTION_VIEW_WIDGET_H__ diff --git a/src/GuiQt/MapSettingsModulateWidget.cxx b/src/GuiQt/MapSettingsModulateWidget.cxx deleted file mode 100644 index e2ca17442..000000000 --- a/src/GuiQt/MapSettingsModulateWidget.cxx +++ /dev/null @@ -1,184 +0,0 @@ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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 __MAP_SETTINGS_MODULATE_WIDGET_DECLARE__ -#include "MapSettingsModulateWidget.h" -#undef __MAP_SETTINGS_MODULATE_WIDGET_DECLARE__ - -#include -#include -#include - -#include "CaretAssert.h" -#include "CaretMappableDataFile.h" -#include "CaretMappableDataFileAndMapSelectorObject.h" -#include "DataFileColorModulateSelector.h" -#include "EventGraphicsPaintSoonAllWindows.h" -#include "EventManager.h" -#include "EventSurfaceColoringInvalidate.h" -#include "WuQtUtilities.h" -using namespace caret; - - - -/** - * \class caret::MapSettingsModulateWidget - * \brief Widget for selection of modulate color file in map settings dialog - * \ingroup GuiQt - */ - -/** - * Constructor. - * @param parent - * The parent widget - */ -MapSettingsModulateWidget::MapSettingsModulateWidget(QWidget* parent) -: QWidget(parent) -{ - m_enabledCheckBox = new QCheckBox("Enable Color Modulation"); - QObject::connect(m_enabledCheckBox, &QCheckBox::clicked, - this, &MapSettingsModulateWidget::modulateEnabledCheckBoxClicked); - - m_modulateMapFileIndexSelector = new CaretMappableDataFileAndMapSelectorObject(CaretMappableDataFileAndMapSelectorObject::OPTION_SHOW_MAP_INDEX_SPIN_BOX, - this); - QObject::connect(m_modulateMapFileIndexSelector, &CaretMappableDataFileAndMapSelectorObject::selectionWasPerformed, - this, &MapSettingsModulateWidget::modulateMapFileIndexSelectorChanged); - QWidget* modulateFileComboBox(0); - QWidget* modulateMapIndexSpinBox(0); - QWidget* modulateMapNameComboBox(0); - m_modulateMapFileIndexSelector->getWidgetsForAddingToLayout(modulateFileComboBox, - modulateMapIndexSpinBox, - modulateMapNameComboBox); - - const AString ttText(" for modulation. This modulation file is used to 'modulate' the coloring. " - "Values in the modulation file should range [0.0, 1.0] and the modulation files " - "available for selection are the same dimensions as the file to which " - "modulation is applied. The RGB values of the file being displayed are " - "multiplied by the corresponding (same dimension index) value from the " - "modulation file."); - WuQtUtilities::setWordWrappedToolTip(modulateFileComboBox, - "Select file" + ttText); - WuQtUtilities::setWordWrappedToolTip(modulateMapIndexSpinBox, - "Select map" + ttText); - WuQtUtilities::setWordWrappedToolTip(modulateMapNameComboBox, - "Select map" + ttText); - - QGridLayout* modulateFileLayout = new QGridLayout(this); - QLabel* modulateFileLabel = new QLabel("File"); - QLabel* modulateMapLabel = new QLabel("Map"); - modulateFileLayout->setColumnStretch(0, 0); - modulateFileLayout->setColumnStretch(1, 0); - modulateFileLayout->setColumnStretch(2, 100); - int32_t rowIndex(0); - modulateFileLayout->addWidget(m_enabledCheckBox, rowIndex, 0, 1, 3, Qt::AlignLeft); - ++rowIndex; - modulateFileLayout->addWidget(modulateFileLabel, rowIndex, 0); - modulateFileLayout->addWidget(modulateFileComboBox, rowIndex, 1, 1, 2); - ++rowIndex; - modulateFileLayout->addWidget(modulateMapLabel, rowIndex, 0); - modulateFileLayout->addWidget(modulateMapIndexSpinBox, rowIndex, 1); - modulateFileLayout->addWidget(modulateMapNameComboBox, rowIndex, 2); - ++rowIndex; - - modulateFileLayout->setRowStretch(100, 100); - modulateFileLayout->setColumnStretch(100, 100); - - setSizePolicy(sizePolicy().horizontalPolicy(), - QSizePolicy::Fixed); -} - -/** - * Destructor. - */ -MapSettingsModulateWidget::~MapSettingsModulateWidget() -{ -} - -/** - * Update the widgets - * @param caretMappableDataFile - * File that is in editor - * @param mapIndex - * Index of map selected in file - */ -void -MapSettingsModulateWidget::updateEditor(CaretMappableDataFile* caretMappableDataFile, - const int32_t mapIndex) -{ - m_caretMappableDataFile = caretMappableDataFile; - m_mapIndex = mapIndex; - - DataFileColorModulateSelector* selector(getSelector()); - if (selector != NULL) { - m_modulateMapFileIndexSelector->updateFileAndMapSelector(selector->getSelectionModel()); - m_enabledCheckBox->setChecked(selector->isEnabled()); - setEnabled(true); - } - else { - setEnabled(false); - } -} - -/** - * Gets called when the threshold map file/index is changed. - */ -void -MapSettingsModulateWidget::modulateMapFileIndexSelectorChanged() -{ - DataFileColorModulateSelector* selector(getSelector()); - if (selector != NULL) { - m_caretMappableDataFile->updateScalarColoringForMap(m_mapIndex); - EventManager::get()->sendEvent(EventSurfaceColoringInvalidate().getPointer()); - EventManager::get()->sendEvent(EventGraphicsPaintSoonAllWindows().getPointer()); - } -} - -/** - * Gets called when modulate checkbox is checked/unchecked - * @param checked - * New checked status - */ -void -MapSettingsModulateWidget::modulateEnabledCheckBoxClicked(bool checked) -{ - DataFileColorModulateSelector* selector(getSelector()); - if (selector != NULL) { - selector->setEnabled(checked); - } - modulateMapFileIndexSelectorChanged(); -} - -/** - * @return The active color modulate selector or NULL if not available - */ -DataFileColorModulateSelector* -MapSettingsModulateWidget::getSelector() -{ - if (m_caretMappableDataFile != NULL) { - if ((m_mapIndex >= 0) - && m_mapIndex < m_caretMappableDataFile->getNumberOfMaps()) { - DataFileColorModulateSelector* selector(m_caretMappableDataFile->getMapColorModulateFileSelector(m_mapIndex)); - return selector; - } - } - return NULL; -} - diff --git a/src/GuiQt/MapSettingsModulateWidget.h b/src/GuiQt/MapSettingsModulateWidget.h deleted file mode 100644 index 849da505e..000000000 --- a/src/GuiQt/MapSettingsModulateWidget.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef __MAP_SETTINGS_MODULATE_WIDGET_H__ -#define __MAP_SETTINGS_MODULATE_WIDGET_H__ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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*/ - - -#include - -#include - -class QCheckBox; - -namespace caret { - - class CaretMappableDataFile; - class CaretMappableDataFileAndMapSelectorObject; - class DataFileColorModulateSelector; - - class MapSettingsModulateWidget : public QWidget { - Q_OBJECT - - public: - MapSettingsModulateWidget(QWidget* parent = NULL); - - virtual ~MapSettingsModulateWidget(); - - MapSettingsModulateWidget(const MapSettingsModulateWidget&) = delete; - - MapSettingsModulateWidget& operator=(const MapSettingsModulateWidget&) = delete; - - void updateEditor(CaretMappableDataFile* caretMappableDataFile, - const int32_t mapIndex); - - // ADD_NEW_METHODS_HERE - - private slots: - void modulateEnabledCheckBoxClicked(bool status); - - void modulateMapFileIndexSelectorChanged(); - - private: - DataFileColorModulateSelector* getSelector(); - - QCheckBox* m_enabledCheckBox; - - CaretMappableDataFileAndMapSelectorObject* m_modulateMapFileIndexSelector; - - CaretMappableDataFile* m_caretMappableDataFile = NULL; - - int32_t m_mapIndex = -1; - - // ADD_NEW_MEMBERS_HERE - - }; - -#ifdef __MAP_SETTINGS_MODULATE_WIDGET_DECLARE__ - // -#endif // __MAP_SETTINGS_MODULATE_WIDGET_DECLARE__ - -} // namespace -#endif //__MAP_SETTINGS_MODULATE_WIDGET_H__ diff --git a/src/GuiQt/OverlaySettingsEditorDialog.cxx b/src/GuiQt/OverlaySettingsEditorDialog.cxx index 6f18f22b7..f0f61dd0a 100644 --- a/src/GuiQt/OverlaySettingsEditorDialog.cxx +++ b/src/GuiQt/OverlaySettingsEditorDialog.cxx @@ -47,7 +47,6 @@ #include "MapSettingsFiberTrajectoryWidget.h" #include "MapSettingsLabelsWidget.h" #include "MapSettingsLayerWidget.h" -#include "MapSettingsModulateWidget.h" #include "MapSettingsPaletteColorMappingWidget.h" #include "MapSettingsParcelsWidget.h" #include "Overlay.h" @@ -108,8 +107,6 @@ OverlaySettingsEditorDialog::OverlaySettingsEditorDialog(QWidget* parent) m_lineHistoryWidget = new MapSettingsChartTwoLineHistoryWidget(); - m_modulateWidget = new MapSettingsModulateWidget(); - m_tabWidget = new QTabWidget(); m_colorBarWidgetTabIndex = m_tabWidget->addTab(m_colorBarWidget, @@ -121,8 +118,7 @@ OverlaySettingsEditorDialog::OverlaySettingsEditorDialog(QWidget* parent) m_layersWidgetTabIndex = m_tabWidget->addTab(m_layerWidget, "Layer"); - m_modulateWidgetTabIndex = m_tabWidget->addTab(m_modulateWidget, - "Modulate"); + m_lineHistoryWidgetTabIndex = m_tabWidget->addTab(m_lineHistoryWidget, "Dyn-Lines"); m_metadataWidgetTabIndex = m_tabWidget->addTab(new QWidget(), @@ -375,9 +371,6 @@ OverlaySettingsEditorDialog::updateDialogContentPrivate(Overlay* brainordinateOv } } - m_modulateWidget->updateEditor(m_caretMappableDataFile, - m_selectedMapFileIndex); - CiftiFiberTrajectoryFile* trajFile = dynamic_cast(m_caretMappableDataFile); if (trajFile != NULL) { /* @@ -546,8 +539,6 @@ OverlaySettingsEditorDialog::updateDialogContentPrivate(Overlay* brainordinateOv isFiberTrajectoryValid); m_tabWidget->setTabEnabled(m_lineHistoryWidgetTabIndex, isLineHistoryValid); - m_tabWidget->setTabEnabled(m_modulateWidgetTabIndex, - isVolumeLayer); /* * When the selected tab is invalid, we want to select the @@ -559,7 +550,6 @@ OverlaySettingsEditorDialog::updateDialogContentPrivate(Overlay* brainordinateOv priorityTabIndices.push_back(m_lineHistoryWidgetTabIndex); priorityTabIndices.push_back(m_colorBarWidgetTabIndex); priorityTabIndices.push_back(m_labelsWidgetTabIndex); - priorityTabIndices.push_back(m_modulateWidgetTabIndex); priorityTabIndices.push_back(m_parcelsWidgetTabIndex); priorityTabIndices.push_back(m_trajectoryWidgetTabIndex); priorityTabIndices.push_back(m_layersWidgetTabIndex); diff --git a/src/GuiQt/OverlaySettingsEditorDialog.h b/src/GuiQt/OverlaySettingsEditorDialog.h index 465f302cc..955f74b9a 100644 --- a/src/GuiQt/OverlaySettingsEditorDialog.h +++ b/src/GuiQt/OverlaySettingsEditorDialog.h @@ -41,7 +41,6 @@ namespace caret { class MapSettingsFiberTrajectoryWidget; class MapSettingsLabelsWidget; class MapSettingsLayerWidget; - class MapSettingsModulateWidget; class MapSettingsPaletteColorMappingWidget; class MapSettingsParcelsWidget; class Overlay; @@ -125,8 +124,6 @@ namespace caret { MapSettingsChartTwoLineHistoryWidget* m_lineHistoryWidget; - MapSettingsModulateWidget* m_modulateWidget; - QPushButton* m_editLabelTablePushButton; QLabel* m_selectedMapFileNameLabel; @@ -149,7 +146,6 @@ namespace caret { int32_t m_lineHistoryWidgetTabIndex; - int32_t m_modulateWidgetTabIndex; }; #ifdef __OVERLAY_SETTINGS_EDITOR_DIALOG_DECLARE__ diff --git a/src/GuiQt/UserInputModeVolumeEditWidget.cxx b/src/GuiQt/UserInputModeVolumeEditWidget.cxx index 84e0500f8..e9c41cb69 100644 --- a/src/GuiQt/UserInputModeVolumeEditWidget.cxx +++ b/src/GuiQt/UserInputModeVolumeEditWidget.cxx @@ -36,14 +36,12 @@ #include "Brain.h" #include "BrainBrowserWindowToolBar.h" -#include "BrowserTabContent.h" #include "CaretAssert.h" #include "CaretLogger.h" #include "EventDataFileAdd.h" #include "EventManager.h" #include "EventUpdateVolumeEditingToolBar.h" #include "EventUserInterfaceUpdate.h" -#include "EventBrowserWindowDrawingContent.h" #include "GiftiLabel.h" #include "GiftiLabelTableEditor.h" #include "GuiManager.h" @@ -56,7 +54,6 @@ #include "WuQFactory.h" #include "WuQHyperlinkToolTip.h" #include "WuQMessageBox.h" -#include "WuQMessageBoxTwo.h" #include "WuQSpinBoxOddValue.h" #include "WuQtUtilities.h" @@ -856,13 +853,6 @@ UserInputModeVolumeEditWidget::labelValueActionTriggered() if (lte.exec() == GiftiLabelTableEditor::Accepted) { const AString selectedName = lte.getLastSelectedLabelName(); m_voxelLabelValueAction->setText(selectedName); - - const AString msg("If a new label was added, the Hierarchy view in " - "Label's tab of the Features Toolbox will NOT update " - "(The List view will update). After editing, saving and reloading " - "the volume label file will update the Hierarchy view. " - "If you are NOT using the Hierarchy view, no action is needed."); - WuQMessageBoxTwo::information(this, "Information", msg); } } } diff --git a/src/Nifti/Matrix4x4.cxx b/src/Nifti/Matrix4x4.cxx index 3d4046072..bed226bcc 100644 --- a/src/Nifti/Matrix4x4.cxx +++ b/src/Nifti/Matrix4x4.cxx @@ -878,7 +878,7 @@ Matrix4x4::rotateZ(const double degrees) void Matrix4x4::rotate( const double angle, - const double vector[3]) + const double vector[4]) { this->rotate(angle, vector[0], vector[1], vector[2]); this->setModified(); diff --git a/src/Nifti/Matrix4x4.h b/src/Nifti/Matrix4x4.h index 511a56772..74c76c318 100644 --- a/src/Nifti/Matrix4x4.h +++ b/src/Nifti/Matrix4x4.h @@ -64,7 +64,7 @@ class Matrix4x4 : public Matrix4x4Interface, public CaretObject { void getTranslation(float translatationOut[3]) const; - void setTranslation(const float t[3]); + void setTranslation(const float t[]); void setTranslation( const double tx, @@ -97,7 +97,7 @@ class Matrix4x4 : public Matrix4x4Interface, public CaretObject { void rotate( const double angle, - const double vector[3]); + const double vector[]); void rotate( const double angle, diff --git a/src/Operations/CMakeLists.txt b/src/Operations/CMakeLists.txt index a8b42c836..8e6ea662b 100644 --- a/src/Operations/CMakeLists.txt +++ b/src/Operations/CMakeLists.txt @@ -93,7 +93,6 @@ OperationSurfaceCutResample.h OperationSurfaceFlipNormals.h OperationSurfaceGeodesicDistance.h OperationSurfaceGeodesicDistanceAllToAll.h -OperationSurfaceGeodesicDistanceSparseText.h OperationSurfaceGeodesicROIs.h OperationSurfaceInformation.h OperationSurfaceNormals.h @@ -190,7 +189,6 @@ OperationSurfaceCutResample.cxx OperationSurfaceFlipNormals.cxx OperationSurfaceGeodesicDistance.cxx OperationSurfaceGeodesicDistanceAllToAll.cxx -OperationSurfaceGeodesicDistanceSparseText.cxx OperationSurfaceGeodesicROIs.cxx OperationSurfaceInformation.cxx OperationSurfaceNormals.cxx diff --git a/src/Operations/OperationCiftiCreateDenseFromTemplate.cxx b/src/Operations/OperationCiftiCreateDenseFromTemplate.cxx index 27ce63a02..42293407a 100644 --- a/src/Operations/OperationCiftiCreateDenseFromTemplate.cxx +++ b/src/Operations/OperationCiftiCreateDenseFromTemplate.cxx @@ -28,7 +28,6 @@ #include "GiftiLabelTable.h" #include "LabelFile.h" #include "MetricFile.h" -#include "PaletteColorMapping.h" #include "VolumeFile.h" #include @@ -177,7 +176,7 @@ void OperationCiftiCreateDenseFromTemplate::useParameters(OperationParameters* m outXML.setMap(CiftiXML::ALONG_COLUMN, *(templateXML.getMap(CiftiXML::ALONG_COLUMN))); int labelMode = -1;//-1 not set, 0 set to false, 1 set to true int64_t numMaps = -1; - const CaretMappableDataFile* nameFile = NULL;//this is also used for palette + const CaretMappableDataFile* nameFile = NULL; const CiftiFile* ciftiNameFile = NULL;//cifti doesn't inherit from CaretMappableDataFile, it is too different const CiftiBrainModelsMap& templateMap = templateXML.getBrainModelsMap(CiftiXML::ALONG_COLUMN); vector surfStructures = templateMap.getSurfaceStructureList(), volStructures = templateMap.getVolumeStructureList(); @@ -498,27 +497,6 @@ void OperationCiftiCreateDenseFromTemplate::useParameters(OperationParameters* m if (!ok) throw OperationException("unrecognized unit string '" + unitString + "'"); outMap.setUnit(myUnit); } - if (ciftiNameFile != NULL) - {//approximate logic for file versus map palette - switch (ciftiNameFile->getCiftiXML().getMappingType(CiftiXML::ALONG_ROW)) - { - case CiftiMappingType::BRAIN_MODELS: - case CiftiMappingType::SERIES: - case CiftiMappingType::PARCELS: - *(outXML.getFilePalette()) = *(ciftiNameFile->getCiftiXML().getFilePalette()); - break; - case CiftiMappingType::SCALARS: - *(outXML.getFilePalette()) = *(ciftiNameFile->getCiftiXML().getScalarsMap(CiftiXML::ALONG_ROW).getMapPalette(0)); - break; - default: - break; - } - } else { - if (nameFile != NULL && nameFile->getMapPaletteColorMapping(0) != NULL) - { - *(outXML.getFilePalette()) = *(nameFile->getMapPaletteColorMapping(0)); - } - } outXML.setMap(CiftiXML::ALONG_ROW, outMap); } else { if (labelMode == 1) @@ -551,19 +529,6 @@ void OperationCiftiCreateDenseFromTemplate::useParameters(OperationParameters* m for (int64_t i = 0; i < numMaps; ++i) { outMap.setMapName(i, nameMap.getIndexName(i)); - switch (ciftiNameFile->getCiftiXML().getMappingType(CiftiXML::ALONG_ROW)) - { - case CiftiMappingType::BRAIN_MODELS: - case CiftiMappingType::SERIES: - case CiftiMappingType::PARCELS: - *(outMap.getMapPalette(i)) = *(ciftiNameFile->getCiftiXML().getFilePalette()); - break; - case CiftiMappingType::SCALARS: - *(outMap.getMapPalette(i)) = *(ciftiNameFile->getCiftiXML().getScalarsMap(CiftiXML::ALONG_ROW).getMapPalette(i)); - break; - default: - break; - } } } else { if (nameFile != NULL) @@ -571,10 +536,6 @@ void OperationCiftiCreateDenseFromTemplate::useParameters(OperationParameters* m for (int64_t i = 0; i < numMaps; ++i) { outMap.setMapName(i, nameFile->getMapName(i)); - if (nameFile->getMapPaletteColorMapping(i) != NULL) - { - *(outMap.getMapPalette(i)) = *(nameFile->getMapPaletteColorMapping(i)); - } } } } diff --git a/src/Operations/OperationCiftiPalette.cxx b/src/Operations/OperationCiftiPalette.cxx index 5df575788..3a3b11605 100644 --- a/src/Operations/OperationCiftiPalette.cxx +++ b/src/Operations/OperationCiftiPalette.cxx @@ -21,12 +21,10 @@ #include "OperationCiftiPalette.h" #include "CiftiFile.h" -#include "GiftiMetaDataXmlElements.h" #include "OperationException.h" #include "Palette.h" #include "PaletteColorMapping.h" #include "PaletteFile.h" -#include "PaletteNormalizationModeEnum.h" #include @@ -92,9 +90,6 @@ OperationParameters* OperationCiftiPalette::getParameters() OptionalParameter* inversionOpt = ret->createOptionalParameter(15, "-inversion", "specify palette inversion"); inversionOpt->addStringParameter(1, "type", "the type of inversion"); - OptionalParameter* normModeOpt = ret->createOptionalParameter(16, "-normalization", "specify normalization mode (NOTE: this is always a file-wide setting, NOT per-map)"); - normModeOpt->addStringParameter(1, "type", "the normalization mode"); - AString myText = AString("NOTE: The output file must be a different file than the input file.\n\n") + "For scalar maps, by default the palette is changed for every map, specify -column to change only one map. Palette settings not specified will be taken from the first column " + "for scalar maps, and from the existing file palette for other mapping types. " + @@ -133,13 +128,6 @@ OperationParameters* OperationCiftiPalette::getParameters() { myText += PaletteInvertModeEnum::toName(myEnums4[i]) + "\n"; } - myText += "\nThe argument to -normalization must be one of the following:\n\n"; - vector myEnums5; - PaletteNormalizationModeEnum::getAllEnums(myEnums5); - for (int i = 0; i < (int)myEnums5.size(); ++i) - { - myText += PaletteNormalizationModeEnum::toName(myEnums5[i]) + "\n"; - } ret->setHelpText(myText); return ret; } @@ -276,15 +264,6 @@ void OperationCiftiPalette::useParameters(OperationParameters* myParams, Progres myMapping.setInvertedMode(inversionType); } ciftiOut->setCiftiXML(myOutXML); //use mutability of palette to get both provenance and file palette correct - //NOTE: need to modify metadata after setting xml, because the provenance-keeping code discards the new file metadata entirely - OptionalParameter* normModeOpt = myParams->getOptionalParameter(16); - if (normModeOpt->m_present) - { - bool ok = false; - PaletteNormalizationModeEnum::fromName(normModeOpt->getString(1), &ok); //don't actually need the enum, just sanity check the string - if (!ok) throw OperationException("unrecognized palette normalization mode: " + normModeOpt->getString(1)); - ciftiOut->getCiftiXML().getFileMetaData()->set(GiftiMetaDataXmlElements::METADATA_PALETTE_NORMALIZATION_MODE, normModeOpt->getString(1)); //not actually part of the palette settings - } if (myOutXML.getMappingType(CiftiXML::ALONG_ROW) == CiftiMappingType::SCALARS) { if (myColumn == -1) diff --git a/src/Operations/OperationMetadataStringReplace.cxx b/src/Operations/OperationMetadataStringReplace.cxx index fcd75e891..10f502c71 100644 --- a/src/Operations/OperationMetadataStringReplace.cxx +++ b/src/Operations/OperationMetadataStringReplace.cxx @@ -25,7 +25,6 @@ #include "DataFileTypeEnum.h" #include "LabelFile.h" #include "MetricFile.h" -#include "SurfaceFile.h" #include "VolumeFile.h" #include "FileInformation.h" @@ -90,7 +89,7 @@ void OperationMetadataStringReplace::useParameters(OperationParameters* myParams for (int32_t map = 0; map < numMaps; ++map) { replaceInMetaData(myMetric.getMapMetaData(map), findString, replString, myCS); - AString mapName = myMetric.getMapName(map); //because QString.replace modifies *this rather than constructing a new string, so it can't be called on const& + AString mapName = myMetric.getMapName(map); myMetric.setMapName(map, mapName.replace(findString, replString, myCS)); } myMetric.writeFile(outFileName); @@ -111,14 +110,6 @@ void OperationMetadataStringReplace::useParameters(OperationParameters* myParams myLabel.writeFile(outFileName); break; } - case DataFileTypeEnum::SURFACE: - { - SurfaceFile mySurf; - mySurf.readFile(inFileName); - replaceInMetaData(mySurf.getFileMetaData(), findString, replString, myCS); - mySurf.writeFile(outFileName); - break; - } case DataFileTypeEnum::VOLUME: { VolumeFile myVol; @@ -140,11 +131,7 @@ void OperationMetadataStringReplace::useParameters(OperationParameters* myParams case DataFileTypeEnum::CONNECTIVITY_DENSE_SCALAR: case DataFileTypeEnum::CONNECTIVITY_DENSE_TIME_SERIES: case DataFileTypeEnum::CONNECTIVITY_PARCEL: - case DataFileTypeEnum::CONNECTIVITY_PARCEL_LABEL: case DataFileTypeEnum::CONNECTIVITY_PARCEL_DENSE: - case DataFileTypeEnum::CONNECTIVITY_PARCEL_SCALAR: - case DataFileTypeEnum::CONNECTIVITY_PARCEL_SERIES: - case DataFileTypeEnum::CONNECTIVITY_SCALAR_DATA_SERIES: { CiftiFile myCifti; FileInformation myInfo1(inFileName), myInfo2(outFileName); @@ -153,47 +140,35 @@ void OperationMetadataStringReplace::useParameters(OperationParameters* myParams { myCifti.convertToInMemory(); } - CiftiXML myXML = myCifti.getCiftiXML(); + CiftiXMLOld myXML = myCifti.getCiftiXMLOld(); CiftiFile myOutCifti; myOutCifti.setWritingFile(outFileName); + int numRows = myXML.getNumberOfRows(), rowSize = myXML.getNumberOfColumns(); replaceInMetaData(myXML.getFileMetaData(), findString, replString, myCS); - for (int i = 0; i < myXML.getNumberOfDimensions(); ++i) + if (myXML.getMappingType(CiftiXMLOld::ALONG_ROW) == CIFTI_INDEX_TYPE_SCALARS || myXML.getMappingType(CiftiXMLOld::ALONG_ROW) == CIFTI_INDEX_TYPE_LABELS) + { + for (int row = 0; row < numRows; ++row) + { + AString mapName = myXML.getMapName(CiftiXMLOld::ALONG_ROW, row); + myXML.setMapNameForIndex(CiftiXMLOld::ALONG_ROW, row, mapName.replace(findString, replString, myCS)); + replaceInMetaData(myXML.getMapMetadata(CiftiXMLOld::ALONG_ROW, row), findString, replString, myCS); + } + } + if (myXML.getMappingType(CiftiXMLOld::ALONG_COLUMN) == CIFTI_INDEX_TYPE_SCALARS || myXML.getMappingType(CiftiXMLOld::ALONG_COLUMN) == CIFTI_INDEX_TYPE_LABELS) { - switch (myXML.getMappingType(i)) + for (int col = 0; col < rowSize; ++col) { - case CiftiMappingType::SCALARS: - { - CiftiScalarsMap& myMapping = myXML.getScalarsMap(i); - for (int64_t map = 0; map < myMapping.getLength(); ++map) - { - AString mapName = myMapping.getMapName(map); - myMapping.setMapName(map, mapName.replace(findString, replString, myCS)); - replaceInMetaData(myMapping.getMapMetadata(map), findString, replString, myCS); - } - break; - } - case CiftiMappingType::LABELS: - { - CiftiLabelsMap& myMapping = myXML.getLabelsMap(i); - for (int64_t map = 0; map < myMapping.getLength(); ++map) - { - AString mapName = myMapping.getMapName(map); - myMapping.setMapName(map, mapName.replace(findString, replString, myCS)); - replaceInMetaData(myMapping.getMapMetadata(map), findString, replString, myCS); - } - break; - } - default: - break;//no map-level metadata or names for other types (assume parcel names are sacred) + AString mapName = myXML.getMapName(CiftiXMLOld::ALONG_COLUMN, col); + myXML.setMapNameForIndex(CiftiXMLOld::ALONG_COLUMN, col, mapName.replace(findString, replString, myCS)); + replaceInMetaData(myXML.getMapMetadata(CiftiXMLOld::ALONG_COLUMN, col), findString, replString, myCS); } } - vector dims = myCifti.getDimensions(); myOutCifti.setCiftiXML(myXML, false); - vector scratchRow(dims[0]); - for (MultiDimIterator iter = myCifti.getIteratorOverRows(); !iter.atEnd(); ++iter) + vector scratchRow(rowSize); + for (int i = 0; i < numRows; ++i) { - myCifti.getRow(scratchRow.data(), *iter); - myOutCifti.setRow(scratchRow.data(), *iter); + myCifti.getRow(scratchRow.data(), i); + myOutCifti.setRow(scratchRow.data(), i); } myOutCifti.writeFile(outFileName); break; diff --git a/src/Operations/OperationMetricPalette.cxx b/src/Operations/OperationMetricPalette.cxx index a8e89b3d8..633f48606 100644 --- a/src/Operations/OperationMetricPalette.cxx +++ b/src/Operations/OperationMetricPalette.cxx @@ -19,14 +19,11 @@ /*LICENSE_END*/ #include "OperationMetricPalette.h" - -#include "GiftiMetaDataXmlElements.h" #include "OperationException.h" #include "MetricFile.h" #include "Palette.h" #include "PaletteColorMapping.h" #include "PaletteFile.h" -#include "PaletteNormalizationModeEnum.h" #include using namespace caret; @@ -90,9 +87,6 @@ OperationParameters* OperationMetricPalette::getParameters() OptionalParameter* inversionOpt = ret->createOptionalParameter(15, "-inversion", "specify palette inversion"); inversionOpt->addStringParameter(1, "type", "the type of inversion"); - OptionalParameter* normModeOpt = ret->createOptionalParameter(16, "-normalization", "specify normalization mode (NOTE: this is always a file-wide setting, NOT per-map)"); - normModeOpt->addStringParameter(1, "type", "the normalization mode"); - AString myText = AString("The original metric file is overwritten with the modified version. By default, all columns of the metric file are adjusted ") + "to the new settings, use the -column option to change only one column. Mapping settings not specified in options will be taken from the first column. " + "The argument must be one of the following:\n\n"; @@ -130,13 +124,6 @@ OperationParameters* OperationMetricPalette::getParameters() { myText += PaletteInvertModeEnum::toName(myEnums4[i]) + "\n"; } - myText += "\nThe argument to -normalization must be one of the following:\n\n"; - vector myEnums5; - PaletteNormalizationModeEnum::getAllEnums(myEnums5); - for (int i = 0; i < (int)myEnums5.size(); ++i) - { - myText += PaletteNormalizationModeEnum::toName(myEnums5[i]) + "\n"; - } ret->setHelpText(myText); return ret; } @@ -236,14 +223,6 @@ void OperationMetricPalette::useParameters(OperationParameters* myParams, Progre if (!ok) throw OperationException("unrecognized palette inversion type: " + inversionOpt->getString(1)); myMapping.setInvertedMode(inversionType); } - OptionalParameter* normModeOpt = myParams->getOptionalParameter(16); - if (normModeOpt->m_present) - { - bool ok = false; - PaletteNormalizationModeEnum::fromName(normModeOpt->getString(1), &ok); //don't actually need the enum, just sanity check the string - if (!ok) throw OperationException("unrecognized palette normalization mode: " + normModeOpt->getString(1)); - myMetric.getFileMetaData()->set(GiftiMetaDataXmlElements::METADATA_PALETTE_NORMALIZATION_MODE, normModeOpt->getString(1)); //not actually part of the palette settings - } if (myColumn == -1) { for (int i = 0; i < myMetric.getNumberOfMaps(); ++i) diff --git a/src/Operations/OperationSurfaceGeodesicDistanceAllToAll.cxx b/src/Operations/OperationSurfaceGeodesicDistanceAllToAll.cxx index e643ed997..919b8c114 100644 --- a/src/Operations/OperationSurfaceGeodesicDistanceAllToAll.cxx +++ b/src/Operations/OperationSurfaceGeodesicDistanceAllToAll.cxx @@ -54,7 +54,7 @@ OperationParameters* OperationSurfaceGeodesicDistanceAllToAll::getParameters() OptionalParameter* limitOpt = ret->createOptionalParameter(4, "-limit", "stop at a specified distance"); limitOpt->addDoubleParameter(1, "limit-mm", "distance in mm to stop at"); - OptionalParameter* corrAreaOpt = ret->createOptionalParameter(5, "-corrected-areas", "vertex areas to use to correct the distances on a group-average surface"); + OptionalParameter* corrAreaOpt = ret->createOptionalParameter(5, "-corrected-areas", "vertex areas to use instead of computing them from the surface"); corrAreaOpt->addMetricParameter(1, "area-metric", "the corrected vertex areas, as a metric"); ret->createOptionalParameter(6, "-naive", "use only neighbors, don't crawl triangles (not recommended)"); @@ -92,6 +92,7 @@ void OperationSurfaceGeodesicDistanceAllToAll::useParameters(OperationParameters distLimit = limitOpt->getDouble(1); if (!(distLimit > 0.0f)) throw OperationException(" must be positive"); } + CaretPointer myHelp; CaretPointer myBase; OptionalParameter* corrAreaOpt = myParams->getOptionalParameter(5); if (corrAreaOpt->m_present) @@ -99,6 +100,9 @@ void OperationSurfaceGeodesicDistanceAllToAll::useParameters(OperationParameters MetricFile* corrAreas = corrAreaOpt->getMetric(1); if (corrAreas->getNumberOfNodes() != mySurf->getNumberOfNodes()) throw OperationException("corrected vertex areas metric does not match surface number of vertices"); myBase.grabNew(new GeodesicHelperBase(mySurf, corrAreas->getValuePointerForColumn(0))); + myHelp.grabNew(new GeodesicHelper(myBase)); + } else { + myHelp = mySurf->getGeodesicHelper(); } bool naive = myParams->getOptionalParameter(6)->m_present; CiftiBrainModelsMap myMap; diff --git a/src/Operations/OperationSurfaceGeodesicDistanceSparseText.cxx b/src/Operations/OperationSurfaceGeodesicDistanceSparseText.cxx deleted file mode 100644 index af34a6a8e..000000000 --- a/src/Operations/OperationSurfaceGeodesicDistanceSparseText.cxx +++ /dev/null @@ -1,106 +0,0 @@ -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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*/ - -#include "OperationSurfaceGeodesicDistanceSparseText.h" -#include "OperationException.h" - -#include "GeodesicHelper.h" -#include "MathFunctions.h" -#include "MetricFile.h" -#include "SurfaceFile.h" - -#include - -using namespace caret; -using namespace std; - -AString OperationSurfaceGeodesicDistanceSparseText::getCommandSwitch() -{ - return "-surface-geodesic-distance-sparse-text"; -} - -AString OperationSurfaceGeodesicDistanceSparseText::getShortDescription() -{ - return "OUTPUT GEODESIC DISTANCES AS TEXT"; -} - -OperationParameters* OperationSurfaceGeodesicDistanceSparseText::getParameters() -{ - OperationParameters* ret = new OperationParameters(); - - ret->addSurfaceParameter(1, "surface", "the surface to compute on"); - - ret->addDoubleParameter(2, "limit", "the geodesic distance limit in mm"); - - ret->addStringParameter(3, "text-out", "output - the output text file"); //fake the output parameter formatting - - OptionalParameter* corrAreaOpt = ret->createOptionalParameter(4, "-corrected-areas", "vertex areas to use to correct the distances on a group-average surface"); - corrAreaOpt->addMetricParameter(1, "area-metric", "the corrected vertex areas, as a metric"); - - ret->createOptionalParameter(5, "-naive", "use only neighbors, don't crawl triangles (not recommended)"); - - ret->setHelpText( - AString("Similar to -geodesic-distance-all-to-all, but outputs in a text format that only lists the in-range vertices. ") + - "Each line in the output text file is a list of pairs, like ',,,,...' in csv format.\n\n" + - "The -corrected-areas option should be used when the input is a group average surface - group average surfaces have " + - "significantly less surface area than individual surfaces do, and therefore distances measured on them would be smaller than measuring them on individual surfaces. " + - "In this case, the input to this option should be a group average of the output of -surface-vertex-areas for each subject.\n\n" + - "If -naive is not specified, the algorithm uses not just immediate neighbors, but also neighbors derived from crawling across pairs of triangles that share an edge." - ); - return ret; -} - -void OperationSurfaceGeodesicDistanceSparseText::useParameters(OperationParameters* myParams, ProgressObject* myProgObj) -{ - LevelProgress myProgress(myProgObj); - SurfaceFile* mySurf = myParams->getSurface(1); - float limit = myParams->getDouble(2); - AString textOutName = myParams->getString(3); - CaretPointer myGeoHelp; - CaretPointer myBase; - OptionalParameter* corrAreaOpt = myParams->getOptionalParameter(4); - if (corrAreaOpt->m_present) - { - MetricFile* corrAreas = corrAreaOpt->getMetric(1); - if (corrAreas->getNumberOfNodes() != mySurf->getNumberOfNodes()) throw OperationException("corrected vertex areas metric does not match surface number of vertices"); - myBase.grabNew(new GeodesicHelperBase(mySurf, corrAreas->getValuePointerForColumn(0))); - myGeoHelp.grabNew(new GeodesicHelper(myBase)); - } else { - myGeoHelp = mySurf->getGeodesicHelper(); - } - bool naive = myParams->getOptionalParameter(5)->m_present; - if (limit < 0.0f || !MathFunctions::isNumeric(limit)) throw OperationException("geodesic distance limit must be numeric and non-negative"); //accept zero, I guess... - fstream textOut(textOutName.toLatin1().data(), ios_base::out); - int32_t numNodes = mySurf->getNumberOfNodes(); - vector nodes; - vector dists; - for (int32_t i = 0; i < numNodes; ++i) - { - myGeoHelp->getNodesToGeoDist(i, limit, nodes, dists, !naive); - bool first = true; - for (int neigh = 0; neigh < int(nodes.size()); ++neigh) - { - if (!first) textOut << ","; - first = false; - textOut << nodes[neigh] << "," << dists[neigh]; - } - textOut << endl; - } -} diff --git a/src/Operations/OperationSurfaceGeodesicDistanceSparseText.h b/src/Operations/OperationSurfaceGeodesicDistanceSparseText.h deleted file mode 100644 index 4ffc37e51..000000000 --- a/src/Operations/OperationSurfaceGeodesicDistanceSparseText.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef __OPERATION_SURFACE_GEODESIC_DISTANCE_SPARSE_TEXT_H__ -#define __OPERATION_SURFACE_GEODESIC_DISTANCE_SPARSE_TEXT_H__ - -/*LICENSE_START*/ -/* - * Copyright (C) 2024 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*/ - -#include "AbstractOperation.h" - -namespace caret { - - class OperationSurfaceGeodesicDistanceSparseText : public AbstractOperation - { - public: - static OperationParameters* getParameters(); - static void useParameters(OperationParameters* myParams, ProgressObject* myProgObj); - static AString getCommandSwitch(); - static AString getShortDescription(); - }; - - typedef TemplateAutoOperation AutoOperationSurfaceGeodesicDistanceSparseText; - -} - -#endif //__OPERATION_SURFACE_GEODESIC_DISTANCE_SPARSE_TEXT_H__ diff --git a/src/Operations/OperationVolumeLabelImport.cxx b/src/Operations/OperationVolumeLabelImport.cxx index 3b8a50841..23c3fb064 100644 --- a/src/Operations/OperationVolumeLabelImport.cxx +++ b/src/Operations/OperationVolumeLabelImport.cxx @@ -21,18 +21,11 @@ #include "OperationVolumeLabelImport.h" #include "OperationException.h" -#include "CaretHierarchy.h" #include "CaretLogger.h" #include "FileInformation.h" #include "GiftiLabel.h" #include "VolumeFile.h" -#include -#include -#include -#include -#include - #include #include #include @@ -73,10 +66,6 @@ OperationParameters* OperationVolumeLabelImport::getParameters() ret->createOptionalParameter(7, "-drop-unused-labels", "remove any unused label values from the label table"); - OptionalParameter* hierOpt = ret->createOptionalParameter(8, "-hierarchy", "read label name hierarchy from a json file"); - hierOpt->addStringParameter(1, "file", "the input json file"); - hierOpt->createOptionalParameter(2, "-add-abbreviation-to-name", "put the abbreviation specified in the json onto the front of each label/group name as ' - '"); - ret->setHelpText( AString("Creates a label volume from an integer-valued volume file. ") + "The label name and color information is stored in the volume header in a nifti extension, with a similar format as in caret5, see -volume-help. " + @@ -95,57 +84,6 @@ OperationParameters* OperationVolumeLabelImport::getParameters() return ret; } -namespace -{ - void recurseJson(CaretHierarchy& hierarchyOut, const QJsonArray& elements, const bool addAbbrev, const AString parent = "") - { - for (auto iter = elements.constBegin(); iter != elements.constEnd(); ++iter) - { - QJsonObject thisobj = iter->toObject(); - CaretHierarchy::Item toAdd; - AString name = thisobj.value("name").toString(); - if (addAbbrev) - { - AString abbrev = thisobj.value("acronym").toString(); - toAdd.extraInfo.set("BareName", name); //currently, may be overridden by a literal BareName key - name = abbrev + " - " + name; - } - toAdd.name = name; - auto keys = thisobj.keys(); - for (auto iter = keys.begin(); iter != keys.end(); ++iter) - { - AString key = *iter; - if (key == "name") continue; //don't put name into extraInfo, it is already handled - auto valueobj = thisobj.value(key); - AString value; - switch (valueobj.type()) - { - case QJsonValue::Bool: - if (valueobj.toBool()) { value = "True"; } else { value = "False"; } - break; - case QJsonValue::Double: - value = AString::number(valueobj.toDouble(), 'g', 16); //handle stupidly large integers with g16, since json numbers are always implicitly double - break; - case QJsonValue::String: - value = valueobj.toString(); - break; - default: - break; - } - if (value != "") - { - toAdd.extraInfo.set(key, value); - } - } - hierarchyOut.addItem(toAdd, parent); - if (thisobj.contains("children")) - { - recurseJson(hierarchyOut, thisobj.value("children").toArray(), addAbbrev, toAdd.name); - } - } - } -} - void OperationVolumeLabelImport::useParameters(OperationParameters* myParams, ProgressObject* myProgObj) { AString temp; @@ -176,7 +114,6 @@ void OperationVolumeLabelImport::useParameters(OperationParameters* myParams, Pr } } bool dropUnused = myParams->getOptionalParameter(7)->m_present; - OptionalParameter* hierOpt = myParams->getOptionalParameter(8); GiftiLabelTable myTable; map translate; if (listfileName != "") @@ -275,34 +212,12 @@ void OperationVolumeLabelImport::useParameters(OperationParameters* myParams, Pr translate[value] = newValue; } } - int32_t tableUnlabeledKey = myTable.getUnassignedLabelKey(); - if (hierOpt->m_present) - { - AString hierfileName = hierOpt->getString(1); - bool addAbbrev = hierOpt->getOptionalParameter(2)->m_present; - QFile jsonfile(hierfileName); - jsonfile.open(QIODevice::ReadOnly | QIODevice::Text); - QJsonDocument myjson = QJsonDocument::fromJson(jsonfile.readAll()); - QJsonArray myarray = myjson.array(); - CaretHierarchy myHier; - recurseJson(myHier, myarray, addAbbrev); - auto hierNames = myHier.getAllNames(); - map tableMap; //not needed, but API requires it - myTable.getKeysAndNames(tableMap); - for (auto iter : tableMap) - { - if (iter.first != tableUnlabeledKey && hierNames.find(iter.second) == hierNames.end()) - { - CaretLogWarning("label name '" + iter.second + "' not found in specified hierarchy"); - } - } - myTable.setHierarchy(myHier); - } vector myDims; myVol->getDimensions(myDims); const int64_t FRAMESIZE = myDims[0] * myDims[1] * myDims[2]; CaretArray frameOut(FRAMESIZE); - translate[unlabeledValue] = tableUnlabeledKey; + int32_t unusedLabel = myTable.getUnassignedLabelKey(); + translate[unlabeledValue] = unusedLabel; if (subvol == -1) { outVol->reinitialize(myVol->getOriginalDimensions(), myVol->getSform(), myDims[4], SubvolumeAttributes::LABEL); @@ -324,7 +239,7 @@ void OperationVolumeLabelImport::useParameters(OperationParameters* myParams, Pr { if (discardOthers) { - frameOut[i] = tableUnlabeledKey; + frameOut[i] = unusedLabel; } else {//use a random color, but fully opaque for the label GiftiLabel myLabel(labelval, AString("LABEL_") + AString::number(labelval), rand() & 255, rand() & 255, rand() & 255, 255); if (myTable.getLabelKeyFromName(myLabel.getName()) != GiftiLabel::getInvalidLabelKey()) @@ -387,7 +302,7 @@ void OperationVolumeLabelImport::useParameters(OperationParameters* myParams, Pr { if (discardOthers) { - frameOut[i] = tableUnlabeledKey; + frameOut[i] = unusedLabel; } else {//use a random color, but fully opaque for the label GiftiLabel myLabel(labelval, AString("LABEL_") + AString::number(labelval), rand() & 255, rand() & 255, rand() & 255, 255); if (myTable.getLabelKeyFromName(myLabel.getName()) != GiftiLabel::getInvalidLabelKey()) diff --git a/src/Operations/OperationVolumePalette.cxx b/src/Operations/OperationVolumePalette.cxx index ec6fd108f..9f1abb49d 100644 --- a/src/Operations/OperationVolumePalette.cxx +++ b/src/Operations/OperationVolumePalette.cxx @@ -22,11 +22,9 @@ #include "OperationException.h" #include "CaretLogger.h" -#include "GiftiMetaDataXmlElements.h" #include "Palette.h" #include "PaletteColorMapping.h" #include "PaletteFile.h" -#include "PaletteNormalizationModeEnum.h" #include "VolumeFile.h" using namespace caret; @@ -90,9 +88,6 @@ OperationParameters* OperationVolumePalette::getParameters() OptionalParameter* inversionOpt = ret->createOptionalParameter(15, "-inversion", "specify palette inversion"); inversionOpt->addStringParameter(1, "type", "the type of inversion"); - OptionalParameter* normModeOpt = ret->createOptionalParameter(16, "-normalization", "specify normalization mode (NOTE: this is always a file-wide setting, NOT per-map)"); - normModeOpt->addStringParameter(1, "type", "the normalization mode"); - AString myText = AString("The original volume file is overwritten with the modified version. By default, all columns of the volume file are adjusted ") + "to the new settings, use the -subvolume option to change only one subvolume. Mapping settings not specified in options will be taken from the first subvolume. " + "The argument must be one of the following:\n\n"; @@ -130,13 +125,6 @@ OperationParameters* OperationVolumePalette::getParameters() { myText += PaletteInvertModeEnum::toName(myEnums4[i]) + "\n"; } - myText += "\nThe argument to -normalization must be one of the following:\n\n"; - vector myEnums5; - PaletteNormalizationModeEnum::getAllEnums(myEnums5); - for (int i = 0; i < (int)myEnums5.size(); ++i) - { - myText += PaletteNormalizationModeEnum::toName(myEnums5[i]) + "\n"; - } ret->setHelpText(myText); return ret; } @@ -243,14 +231,6 @@ void OperationVolumePalette::useParameters(OperationParameters* myParams, Progre if (!ok) throw OperationException("unrecognized palette inversion type: " + inversionOpt->getString(1)); myMapping.setInvertedMode(inversionType); } - OptionalParameter* normModeOpt = myParams->getOptionalParameter(16); - if (normModeOpt->m_present) - { - bool ok = false; - PaletteNormalizationModeEnum::fromName(normModeOpt->getString(1), &ok); //don't actually need the enum, just sanity check the string - if (!ok) throw OperationException("unrecognized palette normalization mode: " + normModeOpt->getString(1)); - myVolume.getFileMetaData()->set(GiftiMetaDataXmlElements::METADATA_PALETTE_NORMALIZATION_MODE, normModeOpt->getString(1)); //not actually part of the palette settings - } if (mySubvolume == -1) { for (int i = 0; i < myVolume.getNumberOfMaps(); ++i)