#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2)
VTK_MODULE_INIT(vtkInteractionStyle)
#include <vtkSmartPointer.h>
class vtkRenderer;
class vtkImageViewer2;
class vtkObject;
class vtkCallbackCommand;
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
public:
void updateMousePosInfo(const QString& mousePosInfo);
private slots:
void openFileSlot();
private:
// 注意必须为静态函数
static void updateCoords(vtkObject* obj, unsigned long eventId, void * clientData, void * callbackData);
private:
vtkSmartPointer<vtkRenderer> pRenderer;
vtkSmartPointer<vtkImageViewer2> pImageViewer;
vtkSmartPointer<vtkCallbackCommand> pMouseCallback;
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QVTKWidget.h>
#include <vtkImageViewer2.h>
#include <vtkJPEGReader.h>
#include <vtkPNGReader.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkImageActor.h>
#include <vtkCallbackCommand.h>
#include <QFileDialog>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
pImageViewer = vtkS