VR mode button and VR mode style support.
This commit is contained in:
@@ -99,6 +99,12 @@ QToolButton#fusion{qproperty-icon:url(":/InfiniteViewer/Icon/fusion.png")}
|
||||
QToolButton#MPR{qproperty-icon:url(":/InfiniteViewer/Icon/MPR.png")}
|
||||
QToolButton#VR{qproperty-icon:url(":/InfiniteViewer/Icon/VR.png")}
|
||||
|
||||
QToolButton#reset{qproperty-icon:url(":/InfiniteViewer/Icon/Reset.png")}
|
||||
QToolButton#planeRotate{qproperty-icon:url(":/InfiniteViewer/Icon/rotate.png")}
|
||||
QToolButton#freeRotate{qproperty-icon:url(":/InfiniteViewer/Icon/rotate-3d.png")}
|
||||
QToolButton#setting{qproperty-icon:url(":/InfiniteViewer/Icon/Settings.png")}
|
||||
QToolButton#preset{qproperty-icon:url(":/InfiniteViewer/Icon/preset.png")}
|
||||
|
||||
QToolButton#minimize{
|
||||
min-height: 25px;
|
||||
max-height: 25px;
|
||||
|
||||
BIN
src/Icon/Reset.png
Normal file
BIN
src/Icon/Reset.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
BIN
src/Icon/Settings.png
Normal file
BIN
src/Icon/Settings.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
src/Icon/preset.png
Normal file
BIN
src/Icon/preset.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
BIN
src/Icon/rotate-3d.png
Normal file
BIN
src/Icon/rotate-3d.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
src/Icon/rotate.png
Normal file
BIN
src/Icon/rotate.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
@@ -52,6 +52,11 @@
|
||||
<file>Icon/unfusionable.png</file>
|
||||
<file>Icon/unMPR.png</file>
|
||||
<file>Icon/VR.png</file>
|
||||
<file>Icon/rotate.png</file>
|
||||
<file>Icon/rotate-3d.png</file>
|
||||
<file>Icon/Reset.png</file>
|
||||
<file>Icon/Settings.png</file>
|
||||
<file>Icon/preset.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/pqWidgets">
|
||||
<file>Icon/pq/pqBold24.png</file>
|
||||
|
||||
52
src/src/Interaction/VolumeInteractorStyle.cpp
Normal file
52
src/src/Interaction/VolumeInteractorStyle.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// Created by Krad on 2022/8/24.
|
||||
//
|
||||
|
||||
#include "VolumeInteractorStyle.h"
|
||||
|
||||
#include <vtkObjectFactory.h>
|
||||
#include <vtkCommand.h>
|
||||
#include <vtkCallbackCommand.h>
|
||||
#include <vtkRenderWindow.h>
|
||||
#include <vtkRenderWindowInteractor.h>
|
||||
#include <vtkRenderer.h>
|
||||
|
||||
vtkStandardNewMacro(VolumeInteractorStyle)
|
||||
|
||||
VolumeInteractorStyle::VolumeInteractorStyle() {
|
||||
|
||||
}
|
||||
|
||||
VolumeInteractorStyle::~VolumeInteractorStyle() {
|
||||
|
||||
}
|
||||
|
||||
void VolumeInteractorStyle::OnLeftButtonDown() {
|
||||
this->FindPokedRenderer(this->Interactor->GetEventPosition()[0],
|
||||
this->Interactor->GetEventPosition()[1]);
|
||||
if (this->CurrentRenderer == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this->GrabFocus(this->EventCallbackCommand);
|
||||
switch(this->InteractionMode) {
|
||||
case VOLUME_ROTATE3D: {
|
||||
this->StartRotate();
|
||||
break;
|
||||
}
|
||||
case VOLUME_PAN: {
|
||||
this->StartPan();
|
||||
break;
|
||||
}
|
||||
case VOLUME_ROTATE2D: {
|
||||
this->StartSpin();
|
||||
break;
|
||||
}
|
||||
case VOLUME_ZOOM: {
|
||||
this->StartDolly();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
47
src/src/Interaction/VolumeInteractorStyle.h
Normal file
47
src/src/Interaction/VolumeInteractorStyle.h
Normal file
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// Created by Krad on 2022/8/24.
|
||||
//
|
||||
|
||||
#ifndef OMEGAV_VOLUMEINTERACTORSTYLE_H
|
||||
#define OMEGAV_VOLUMEINTERACTORSTYLE_H
|
||||
|
||||
#include <vtkInteractorStyleTrackballCamera.h>
|
||||
|
||||
#define VOLUME_ROTATE3D 0
|
||||
#define VOLUME_ROTATE2D 1
|
||||
#define VOLUME_ZOOM 2
|
||||
#define VOLUME_PAN 3
|
||||
|
||||
class VolumeInteractorStyle:public vtkInteractorStyleTrackballCamera {
|
||||
public:
|
||||
static VolumeInteractorStyle *New();
|
||||
|
||||
vtkTypeMacro(VolumeInteractorStyle, vtkInteractorStyleTrackballCamera);
|
||||
|
||||
vtkSetClampMacro(InteractionMode, int, VOLUME_ROTATE3D, VOLUME_PAN);
|
||||
vtkGetMacro(InteractionMode, int);
|
||||
|
||||
void OnLeftButtonDown() override;
|
||||
// void OnLeftButtonUp() override;
|
||||
// void OnRightButtonDown() override;
|
||||
// void OnRightButtonUp() override;
|
||||
// void OnMouseMove() override;
|
||||
|
||||
void OnMouseWheelForward() override{};
|
||||
void OnMouseWheelBackward() override{};
|
||||
|
||||
protected:
|
||||
VolumeInteractorStyle();
|
||||
|
||||
~VolumeInteractorStyle() override;
|
||||
|
||||
private:
|
||||
VolumeInteractorStyle(const VolumeInteractorStyle &) = delete;
|
||||
|
||||
void operator=(const VolumeInteractorStyle &) = delete;
|
||||
|
||||
int InteractionMode;
|
||||
};
|
||||
|
||||
|
||||
#endif //OMEGAV_VOLUMEINTERACTORSTYLE_H
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <vtkRenderer.h>
|
||||
#include <vtkRenderWindow.h>
|
||||
#include <vtkRenderWindowInteractor.h>
|
||||
#include <vtkInteractorStyleTrackballCamera.h>
|
||||
#include <vtkCamera.h>
|
||||
#include <vtkImageData.h>
|
||||
#include <vtkVolume.h>
|
||||
@@ -19,6 +18,8 @@
|
||||
#include <vtkColorTransferFunction.h>
|
||||
#include <vtkCornerAnnotation.h>
|
||||
|
||||
#include "Interaction/VolumeInteractorStyle.h"
|
||||
|
||||
vtkStandardNewMacro(VolumeRenderingViewer);
|
||||
|
||||
VolumeRenderingViewer::VolumeRenderingViewer()
|
||||
@@ -112,7 +113,9 @@ void VolumeRenderingViewer::InstallPipeline() {
|
||||
|
||||
if (this->Interactor) {
|
||||
if (!this->InteractorStyle) {
|
||||
this->InteractorStyle = vtkInteractorStyleTrackballCamera::New();
|
||||
auto style = VolumeInteractorStyle::New();
|
||||
style->SetInteractionMode(0);
|
||||
this->InteractorStyle = style;
|
||||
}
|
||||
|
||||
this->Interactor->SetInteractorStyle(this->InteractorStyle);
|
||||
@@ -241,3 +244,10 @@ void VolumeRenderingViewer::printFrameRate() {
|
||||
sprintf(buff,"FPS:%3.0f", fps);
|
||||
annotation->SetText(0,buff );
|
||||
}
|
||||
|
||||
void VolumeRenderingViewer::SetInteractorStyleMode(int mode) {
|
||||
auto style = VolumeInteractorStyle::SafeDownCast(InteractorStyle);
|
||||
if (style){
|
||||
style->SetInteractionMode(mode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,8 @@ public:
|
||||
*/
|
||||
virtual void SetupInteractor(vtkRenderWindowInteractor *);
|
||||
|
||||
void SetInteractorStyleMode(int mode);
|
||||
|
||||
protected:
|
||||
VolumeRenderingViewer();
|
||||
|
||||
|
||||
@@ -4,10 +4,80 @@
|
||||
|
||||
#include "VolumeRenderingToolBar.h"
|
||||
|
||||
#include <QToolButton>
|
||||
#include <QButtonGroup>
|
||||
|
||||
VolumeRenderingToolBar::VolumeRenderingToolBar(QWidget *parent) : QToolBar(parent) {
|
||||
auto btnReset = new QToolButton(this);
|
||||
addButton(btnReset, "reset");
|
||||
|
||||
auto mBtnAnonymize = new QToolButton(this);
|
||||
addButton(mBtnAnonymize, "anonymize");
|
||||
addSeparator();
|
||||
auto group = new QButtonGroup(this);
|
||||
|
||||
|
||||
auto btnFreeRotate = new QToolButton(this);
|
||||
addButton(btnFreeRotate, "freeRotate");
|
||||
btnFreeRotate->setCheckable(true);
|
||||
btnFreeRotate->setChecked(true);
|
||||
auto btnRotate = new QToolButton(this);
|
||||
addButton(btnRotate, "planeRotate");
|
||||
btnRotate->setCheckable(true);
|
||||
auto btnPan = new QToolButton(this);
|
||||
addButton(btnPan, "pan");
|
||||
btnPan->setCheckable(true);
|
||||
auto btnZoom = new QToolButton(this);
|
||||
addButton(btnZoom, "zoom");
|
||||
btnZoom->setCheckable(true);
|
||||
auto btnWindow = new QToolButton(this);
|
||||
addButton(btnWindow, "window");
|
||||
btnWindow->setCheckable(true);
|
||||
|
||||
group->addButton(btnFreeRotate,0);
|
||||
group->addButton(btnRotate,1);
|
||||
group->addButton(btnZoom,2);
|
||||
group->addButton(btnPan,3);
|
||||
group->setExclusive(true);
|
||||
|
||||
connect(group, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked),this,&VolumeRenderingToolBar::modeButtonClicked);
|
||||
|
||||
addSeparator();
|
||||
auto btnMeasure = new QToolButton(this);
|
||||
addButton(btnMeasure, "measure");
|
||||
addSeparator();
|
||||
auto btnPreset = new QToolButton(this);
|
||||
addButton(btnPreset, "preset");
|
||||
addSeparator();
|
||||
auto btnSetting = new QToolButton(this);
|
||||
addButton(btnSetting, "setting");
|
||||
|
||||
|
||||
QWidget *spacer = new QWidget(this);
|
||||
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
addWidget(spacer);
|
||||
|
||||
auto mBtnMinimize = new QToolButton(this);
|
||||
auto mBtnMaximize = new QToolButton(this);
|
||||
auto mBtnClose = new QToolButton(this);
|
||||
auto mBtnFullScreen = new QToolButton(this);
|
||||
auto mActionMinimize = addButton(mBtnMinimize, "minimize");
|
||||
auto mActionMaximize = addButton(mBtnMaximize, "maximize");
|
||||
auto mActionClose = addButton(mBtnClose, "close");
|
||||
auto mActionFullScreen = addButton(mBtnFullScreen, "fullscreen");
|
||||
|
||||
mActionMinimize->setVisible(false);
|
||||
mActionMaximize->setVisible(false);
|
||||
mActionClose->setVisible(false);
|
||||
|
||||
}
|
||||
|
||||
VolumeRenderingToolBar::~VolumeRenderingToolBar() {
|
||||
|
||||
}
|
||||
|
||||
QAction* VolumeRenderingToolBar::addButton(QToolButton* button, const char* objectName) {
|
||||
button->setObjectName(objectName);
|
||||
button->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
||||
return addWidget(button);
|
||||
}
|
||||
@@ -7,12 +7,19 @@
|
||||
|
||||
#include <QToolBar>
|
||||
|
||||
class QAction;
|
||||
|
||||
class VolumeRenderingToolBar : public QToolBar {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VolumeRenderingToolBar(QWidget *parent = nullptr);
|
||||
|
||||
~VolumeRenderingToolBar();
|
||||
~VolumeRenderingToolBar() override;
|
||||
signals:
|
||||
void modeButtonClicked(int id);
|
||||
|
||||
private:
|
||||
QAction* addButton(QToolButton* button, const char* objectName);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,11 @@ VolumeRenderingWindow::VolumeRenderingWindow(QWidget *parent , Qt::WindowFlags f
|
||||
widget->SetRenderWindow(mRenderWin);
|
||||
layout->addWidget(widget);
|
||||
setMinimumSize(680,500);
|
||||
|
||||
connect(toolBar, &VolumeRenderingToolBar::modeButtonClicked,[=](int mode){
|
||||
printf("mode:%d \r\n", mode);
|
||||
mViewer->SetInteractorStyleMode(mode);
|
||||
});
|
||||
}
|
||||
|
||||
VolumeRenderingWindow::~VolumeRenderingWindow() {
|
||||
|
||||
Reference in New Issue
Block a user