Skip to content

Commit

Permalink
Add 2D dot annotation size control
Browse files Browse the repository at this point in the history
  • Loading branch information
davidborland committed Apr 6, 2023
1 parent a03a9a5 commit d936a39
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 27 deletions.
7 changes: 7 additions & 0 deletions qt/SettingsDialog.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ void SettingsDialog::initializeSettings() {

// Neighbor radius
neighborRadiusSpinBox->setValue(visualizationContainer->GetNeighborRadius());

// Dot size
dotSizeSpinBox->setValue(sliceView->GetDotSize());
}

void SettingsDialog::on_windowSpinBox_valueChanged(double value) {
Expand Down Expand Up @@ -132,6 +135,10 @@ void SettingsDialog::on_enableDotAnnotationCheckBox_stateChanged(int state) {
emit enableDotAnnotationChanged(state != 0);
}

void SettingsDialog::on_dotSizeSpinBox_valueChanged(double value) {
visualizationContainer->GetSliceView()->SetDotSize(value);
}

void SettingsDialog::on_flipAxisButton(int axis) {
visualizationContainer->FlipAxis(axis);
}
1 change: 1 addition & 0 deletions qt/SettingsDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public slots:
virtual void on_autoAdjustSamplingCheckBox_stateChanged(int state);

virtual void on_enableDotAnnotationCheckBox_stateChanged(int state);
virtual void on_dotSizeSpinBox_valueChanged(double value);

virtual void on_flipAxisButton(int axis);

Expand Down
51 changes: 39 additions & 12 deletions qt/SettingsDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>314</width>
<height>548</height>
<width>359</width>
<height>576</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -393,6 +393,33 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>2D dot size</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDoubleSpinBox" name="dotSizeSpinBox"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -426,6 +453,16 @@
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
Expand All @@ -439,16 +476,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
Expand Down
6 changes: 3 additions & 3 deletions region/Region.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ void Region::SetComment(const std::string& commentString) {
text->SetInput(LabelString().c_str());
}

void Region::ApplyDot() {
void Region::ApplyDot(double dotSize) {
double* c = GetCenter();
int x = (int)c[0];
int y = (int)c[1];
Expand All @@ -652,12 +652,12 @@ void Region::ApplyDot() {

data->Modified();

int ext[6] = { x, x, y, y, z, z, };
int ext[6] = { x, x, y, y, z, z };
SetExtent(ext);
voi->Update();

center3D->Update();
center2D->Update(center2D->GetActor()->GetPosition()[2]);
center2D->Update(center2D->GetActor()->GetPosition()[2], dotSize);
}

void Region::ClearLabels() {
Expand Down
2 changes: 1 addition & 1 deletion region/Region.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Region {
const std::string& GetComment();
void SetComment(const std::string& commentString);

void ApplyDot();
void ApplyDot(double dotSize);

protected:
unsigned short label;
Expand Down
8 changes: 3 additions & 5 deletions region/RegionCenter2D.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ RegionCenter2D::RegionCenter2D(Region* inputRegion, double color[3]) {
actor->PickableOff();
actor->VisibilityOff();

Update(region->GetCenter()[2]);
Update(region->GetCenter()[2], 1.25);
}

RegionCenter2D::~RegionCenter2D() {
Expand All @@ -49,9 +49,7 @@ vtkSmartPointer<vtkActor> RegionCenter2D::GetActor() {
return actor;
}

void RegionCenter2D::Update(double z) {
double r = 1.25;

void RegionCenter2D::Update(double z, double size) {
double numSlices = 4.0;

double* c = region->GetCenter();
Expand All @@ -62,7 +60,7 @@ void RegionCenter2D::Update(double z) {
if (s < 0) s = 0;

actor->SetPosition(c[0], c[1], z);
actor->SetScale(r * s);
actor->SetScale(size * s);

double epsilon = 0.9;
if (d < epsilon) {
Expand Down
2 changes: 1 addition & 1 deletion region/RegionCenter2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class RegionCenter2D {

vtkSmartPointer<vtkActor> GetActor();

void Update(double z);
void Update(double z, double size);

protected:
Region* region;
Expand Down
16 changes: 14 additions & 2 deletions visualization/SliceView.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ SliceView::SliceView(vtkRenderWindowInteractor* interactor, vtkLookupTable* lut)
showRegionOutlines = true;
rescaleMode = Full;
autoRescale = true;
dotSize = 1.25;

data = nullptr;
labels = nullptr;
Expand Down Expand Up @@ -202,7 +203,7 @@ void SliceView::AddRegionActors(Region* region) {
regionOutlinesRenderer->AddActor(region->GetText());

regionOutlinesRenderer->AddActor(region->GetCenter2D()->GetActor());
region->GetCenter2D()->Update(plane->GetOrigin()[2]);
region->GetCenter2D()->Update(plane->GetOrigin()[2], dotSize);

#ifdef SHOW_REGION_BOX
//regionOutlinesRenderer->AddActor(region->GetBox());
Expand Down Expand Up @@ -425,7 +426,7 @@ void SliceView::UpdatePlane() {
if (regions) {
for (RegionCollection::Iterator it = regions->Begin(); it != regions->End(); it++) {
Region* region = regions->Get(it);
region->GetCenter2D()->Update(z);
region->GetCenter2D()->Update(z, dotSize);
}
}
}
Expand All @@ -435,6 +436,17 @@ void SliceView::SetBrushRadius(int radius) {
brush->GetActor()->SetVisibility(radius > 1);
}

double SliceView::GetDotSize() {
return dotSize;
}

void SliceView::SetDotSize(double size) {
dotSize = size;
UpdatePlane();

Render();
}

void SliceView::Render() {
renderer->GetRenderWindow()->Render();
}
Expand Down
4 changes: 4 additions & 0 deletions visualization/SliceView.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class SliceView {

void SetBrushRadius(int radius);

double GetDotSize();
void SetDotSize(double size);

void SetOrientationX();
void SetOrientationY();
void SetOrientationZ();
Expand All @@ -85,6 +88,7 @@ class SliceView {
protected:
FilterMode filterMode;
bool showRegionOutlines;
double dotSize;

enum RescaleMode {
Full,
Expand Down
6 changes: 3 additions & 3 deletions visualization/VisualizationContainer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2037,7 +2037,7 @@ bool VisualizationContainer::CheckDots() {
void VisualizationContainer::ApplyDotAnnotation() {
for (RegionCollection::Iterator it = regions->Begin(); it != regions->End(); it++) {
Region* region = regions->Get(it);
region->ApplyDot();
region->ApplyDot(sliceView->GetDotSize());
}

labels->Modified();
Expand Down Expand Up @@ -2515,7 +2515,7 @@ void VisualizationContainer::ExtractRegions(vtkIntArray* extents) {
}

if (interactionMode == DotMode) {
region->ApplyDot();
region->ApplyDot(sliceView->GetDotSize());
region->ShowCenter(true);
}

Expand Down Expand Up @@ -2567,7 +2567,7 @@ void VisualizationContainer::ExtractRegions(const std::vector<RegionInfo>& metad
}

if (interactionMode == DotMode) {
region->ApplyDot();
region->ApplyDot(sliceView->GetDotSize());
region->ShowCenter(true);
}
}
Expand Down

0 comments on commit d936a39

Please sign in to comment.