Skip to content

Commit

Permalink
Merge pull request #1 from SciVis/brainvis
Browse files Browse the repository at this point in the history
Atlas label selection
  • Loading branch information
ResearchDaniel committed Oct 5, 2021
2 parents 8e02eb0 + 3ffc92b commit 2972cd5
Show file tree
Hide file tree
Showing 4 changed files with 309 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class IVW_MODULE_VISUALNEURO_API VolumeAtlas {
std::optional<glm::vec4> color;
bool operator==(std::string label) { return name == label; }
};

using const_iterator = std::map<int, Label>::const_iterator;

VolumeAtlas(std::shared_ptr<const Volume> atlas, std::shared_ptr<const DataFrame> labels);

int getLabelId(const ivec3 indexPos) const;
Expand All @@ -68,6 +71,8 @@ class IVW_MODULE_VISUALNEURO_API VolumeAtlas {

bool hasColors() const;

const_iterator begin() const;
const_iterator end() const;
private:
std::shared_ptr<const Volume> atlas_;
std::map<int, Label> labels_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <inviwo/core/properties/stringproperty.h>
#include <inviwo/core/ports/volumeport.h>
#include <inviwo/core/ports/datainport.h>
#include <inviwo/core/interaction/pickingmapper.h>

#include <inviwo/dataframe/datastructures/dataframe.h>
#include <modules/brushingandlinking/ports/brushingandlinkingports.h>
Expand Down Expand Up @@ -94,31 +95,48 @@ class IVW_MODULE_VISUALNEURO_API VolumeAtlasProcessor : public Processor {
void updateTransferFunction();
void updateBrushing();
void updateSelectableRegionProperties();
void handlePicking(PickingEvent*);
int pickingToLabelId(int pickingID) const;

dvec3 getLabelCenterPoint(int labelId) const;

int labelIdToRow(int labelID) const;

VolumeInport atlasVolume_;
DataInport<DataFrame> atlasLabels_;
DataInport<DataFrame> atlasRegionCenterpoints_;
BrushingAndLinkingInport brushingAndLinking_;
VolumeOutport outport_;
DataOutport<TransferFunction> atlasTFOutport_;
DataOutport<TransferFunction> pickingTFOutport_;

ButtonProperty selectAllRegions_;
ButtonProperty deselectAllRegions_;
CompositeProperty selectedVolumeRegions_;
std::unordered_set<int> selectedRegions_;

StringProperty lookedUpName_;
StringProperty selectedName_;
StringProperty hoverName_;
StringProperty coordinatesString_;
BoolProperty visualizeAtlas_;
FloatVec4Property hoverColor_;
FloatVec4Property selectedColor_;
FloatProperty hoverMix_;
FloatVec3Property selectedColor_;
FloatProperty selectedOpacity_;
FloatVec3Property notSelectedColor_;
FloatProperty notSelectedMix_;
FloatProperty notSelectedOpacity_;
IsoTFProperty isotfComposite_;
FloatVec3Property worldPosition_;

BoolProperty enablePicking_;

PickingMapper atlasPicking_;

std::unique_ptr<VolumeAtlas> atlas_;
std::vector<int> pickingToLabelId_;
std::shared_ptr<TransferFunction> pickingTF_ = std::make_shared<TransferFunction>();

int hoverAtlasId_;
double delta_;
int hoverAtlasId_ = -1;

bool brushingDirty_ = true;
};
Expand Down
10 changes: 8 additions & 2 deletions modules/visualneuro/src/datastructures/volumeatlas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ inline VolumeAtlas::VolumeAtlas(std::shared_ptr<const Volume> atlas,
std::shared_ptr<const Column> labelCol;
std::shared_ptr<const Column> colorCol;
for (auto col : *labels) {
if (iCaseCmp(col->getHeader(), "Index")) {
if (iCaseCmp(col->getHeader(), "Index") || iCaseCmp(col->getHeader(), "Label ID")) {
idCol = col;
} else if (iCaseCmp(col->getHeader(), "Region")) {
} else if (iCaseCmp(col->getHeader(), "Region") ||
iCaseCmp(col->getHeader(), "Label Name")) {
labelCol = col;
} else if (iCaseCmp(col->getHeader(), "Color")) {
colorCol = col;
Expand Down Expand Up @@ -133,4 +134,9 @@ inline bool VolumeAtlas::hasColors() const {
return std::any_of(labels_.cbegin(), labels_.cend(),
[](const auto l) { return l.second.color != std::nullopt; });
}

VolumeAtlas::const_iterator VolumeAtlas::begin() const { return labels_.begin(); }

VolumeAtlas::const_iterator VolumeAtlas::end() const { return labels_.end(); }

} // namespace inviwo
Loading

0 comments on commit 2972cd5

Please sign in to comment.