Volume Rendering Measure UI and interact logic.
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
#include "Rendering/Widget/ClickableOrientationMarkerWidget.h"
|
||||
#include "Rendering/Core/SmartFixedPointVolumeRayCastMapper.h"
|
||||
#include "IO/DICOM/ExtendMedicalImageProperties.h"
|
||||
#include "Rendering/Measure/ArrowAnnotationActor.h"
|
||||
#include "Rendering/Measure/VolRulerAnnotationActor.h"
|
||||
#include "Rendering/Measure/VolArrowAnnotationActor.h"
|
||||
|
||||
namespace {
|
||||
@@ -619,10 +619,10 @@ void VolumeRenderingViewer::pressedOrientationMarker(vtkObject* sender, unsigned
|
||||
}
|
||||
}
|
||||
|
||||
void VolumeRenderingViewer::ActiveArrow() {
|
||||
void VolumeRenderingViewer::ActiveMeasure(int type) {
|
||||
auto style = VolumeInteractorStyle::SafeDownCast(this->InteractorStyle);
|
||||
if (style){
|
||||
style->ActiveMeasure(VolArrowAnnotationActor::New());
|
||||
style->ActiveMeasure((type==0?(Measure*)VolRulerAnnotationActor::New():VolArrowAnnotationActor::New()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
|
||||
void ResetZoomFitWindow();
|
||||
|
||||
void ActiveArrow();
|
||||
void ActiveMeasure(int type);
|
||||
|
||||
void UnActiveMeasure();
|
||||
|
||||
|
||||
@@ -8,10 +8,21 @@
|
||||
#include <QButtonGroup>
|
||||
#include <QActionGroup>
|
||||
#include <QMenu>
|
||||
#include <tuple>
|
||||
|
||||
#include "Common/QGlobals.h"
|
||||
#include "Rendering/Core/RenderingDefines.h"
|
||||
|
||||
VolumeRenderingToolBar::VolumeRenderingToolBar(QWidget *parent) : QToolBar(parent) {
|
||||
|
||||
typedef std::tuple<const char *, const char *, int> ActionProperty;
|
||||
namespace {
|
||||
const ActionProperty MEASURE_ACTIIONS[2] = {
|
||||
{"Length", ":/InfiniteViewer/Icon/distance.png", 0},
|
||||
{"Arrow", ":/InfiniteViewer/Icon/arrow.png", 1},
|
||||
};}
|
||||
|
||||
VolumeRenderingToolBar::VolumeRenderingToolBar(QWidget *parent) : QToolBar(parent)
|
||||
, mBtnMeasure(new QToolButton(this)){
|
||||
auto btnReset = new QToolButton(this);
|
||||
addButton(btnReset, "reset");
|
||||
connect(btnReset,&QToolButton::clicked,[=](){
|
||||
@@ -78,11 +89,32 @@ VolumeRenderingToolBar::VolumeRenderingToolBar(QWidget *parent) : QToolBar(paren
|
||||
connect(group, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked),this,&VolumeRenderingToolBar::modeButtonClicked);
|
||||
|
||||
addSeparator();
|
||||
auto btnMeasure = new QToolButton(this);
|
||||
addButton(btnMeasure, "measure");
|
||||
connect(btnMeasure,&QToolButton::clicked,[=](){
|
||||
emit activeArrow();
|
||||
|
||||
addButton(mBtnMeasure, "measure");
|
||||
mBtnMeasure->setCheckable(true);
|
||||
QMenu *m;
|
||||
m = new QMenu(this);
|
||||
m->addAction(tr("Ruler"), this, [=] {
|
||||
mBtnMeasure->setChecked(true);
|
||||
QPixmap map(std::get<1>(MEASURE_ACTIIONS[0]));
|
||||
mBtnMeasure->setIcon(QIcon(map));
|
||||
mMeasureType = 0;
|
||||
emit activeMeasure(mMeasureType);
|
||||
});
|
||||
m->addAction(tr("Arrow"), this, [=] {
|
||||
mBtnMeasure->setChecked(true);
|
||||
QPixmap map(std::get<1>(MEASURE_ACTIIONS[1]));
|
||||
mBtnMeasure->setIcon(QIcon(map));
|
||||
mMeasureType = 1;
|
||||
emit activeMeasure(mMeasureType);
|
||||
});
|
||||
connect(mBtnMeasure, &QToolButton::clicked, [=](){
|
||||
emit activeMeasure(mMeasureType);
|
||||
});
|
||||
mBtnMeasure->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
mBtnMeasure->setToolTip(QString("Measurements"));
|
||||
mBtnMeasure->setPopupMode(QToolButton::MenuButtonPopup);
|
||||
mBtnMeasure->setMenu(m);
|
||||
addSeparator();
|
||||
auto btnPreset = new QToolButton(this);
|
||||
addButton(btnPreset, "preset");
|
||||
@@ -118,4 +150,8 @@ QAction* VolumeRenderingToolBar::addButton(QToolButton* button, const char* obje
|
||||
button->setObjectName(objectName);
|
||||
button->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
||||
return addWidget(button);
|
||||
}
|
||||
}
|
||||
|
||||
void VolumeRenderingToolBar::unActiveMeasure() {
|
||||
if (mBtnMeasure)mBtnMeasure->setChecked(false);
|
||||
}
|
||||
|
||||
@@ -15,15 +15,19 @@ public:
|
||||
explicit VolumeRenderingToolBar(QWidget *parent = nullptr);
|
||||
|
||||
~VolumeRenderingToolBar() override;
|
||||
void unActiveMeasure();
|
||||
signals:
|
||||
void modeButtonClicked(int id);
|
||||
void viewDirectionChanged(int id);
|
||||
void resetView();
|
||||
void fitWindow();
|
||||
void activeArrow();
|
||||
void activeMeasure(int type);
|
||||
|
||||
private:
|
||||
QAction* addButton(QToolButton* button, const char* objectName);
|
||||
|
||||
QToolButton* mBtnMeasure = nullptr;
|
||||
int mMeasureType = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ VolumeRenderingWindow::VolumeRenderingWindow(QWidget *parent , Qt::WindowFlags f
|
||||
mViewer->ResetView();
|
||||
mViewer->Render();
|
||||
});
|
||||
connect(toolBar, &VolumeRenderingToolBar::activeArrow,[=](){
|
||||
mViewer->ActiveArrow();
|
||||
connect(toolBar, &VolumeRenderingToolBar::activeMeasure,[=](int type){
|
||||
mViewer->ActiveMeasure(type);
|
||||
mViewer->Render();
|
||||
});
|
||||
connect(toolBar, &VolumeRenderingToolBar::fitWindow,[=](){
|
||||
@@ -50,7 +50,9 @@ VolumeRenderingWindow::VolumeRenderingWindow(QWidget *parent , Qt::WindowFlags f
|
||||
});
|
||||
connect(toolBar, &VolumeRenderingToolBar::modeButtonClicked,[=](int mode){
|
||||
mViewer->SetInteractorStyleMode(mode);
|
||||
toolBar->unActiveMeasure();
|
||||
mViewer->UnActiveMeasure();
|
||||
|
||||
});
|
||||
|
||||
connect(toolBar, &VolumeRenderingToolBar::viewDirectionChanged, [=](int direction){
|
||||
|
||||
Reference in New Issue
Block a user