Qt&Vtk-030-Theme

简介: Qt&Vtk-030-Theme

image.png摘要

1 官方示例展示


接着搬运,搬运到后面真的不是不想在手撸了,开启Ctrl+C Ctrl+V的节奏,官方示例演示如下image.png

#ifndef THEME_H
#define THEME_H
#include <QWidget>
#include "vtkGraphLayoutView.h"
#include "vtkRandomGraphSource.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkViewTheme.h"
namespace Ui {
class Theme;
}
class Theme : public QWidget
{
    Q_OBJECT
public:
    explicit Theme(QWidget *parent = 0);
    ~Theme();
private:
    Ui::Theme *ui;
    vtkRandomGraphSource* source = nullptr;
    vtkGraphLayoutView* view = nullptr;
    vtkViewTheme* theme = nullptr;
};
#endif // THEME_H

2.2 theme.cpp


#include "theme.h"
#include "ui_theme.h"
Theme::Theme(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Theme)
{
    ui->setupUi(this);
    source = vtkRandomGraphSource::New();
    view = vtkGraphLayoutView::New();
    view->SetRepresentationFromInputConnection(source->GetOutputPort());
    theme = vtkViewTheme::CreateMellowTheme();
    view->ApplyViewTheme(theme);
    theme->Delete();
    view->SetRenderWindow(ui->widget->GetRenderWindow());
    view->SetVertexColorArrayName("VertexDegree");
    view->SetColorVertices(true);
    view->SetVertexLabelArrayName("VertexDegree");
    view->SetVertexLabelVisibility(true);
    view->ResetCamera();
    view->Render();
}
Theme::~Theme()
{
    delete ui;
}

image.pngimage.png

目录
相关文章
Qt&Vtk-017-EasyView
Qt&Vtk-017-EasyView
197 0
Qt&Vtk-017-EasyView
Qt&Vtk-015-Cylinder
Qt&Vtk-015-Cylinder
138 0
Qt&Vtk-015-Cylinder
Qt&Vtk-019-GPURenderDemo
Qt&Vtk-019-GPURenderDemo
159 0
Qt&Vtk-019-GPURenderDemo
Qt&Vtk-004-AmbientSpheres
Qt&Vtk-004-AmbientSpheres
213 0
Qt&Vtk-004-AmbientSpheres
Qt&Vtk-010-Cone5
Qt&Vtk-010-Cone5
169 0
Qt&Vtk-010-Cone5
Qt&Vtk-006-one
Qt&Vtk-006-one
120 0
Qt&Vtk-006-one
Qt&Vtk-027-RGrid
Qt&Vtk-027-RGrid
153 0
Qt&Vtk-027-RGrid
Qt&Vtk-020-GraphItem
Qt&Vtk-020-GraphItem
180 0
Qt&Vtk-020-GraphItem
Qt&Vtk-012-CreateTree
Qt&Vtk-012-CreateTree
154 0
Qt&Vtk-012-CreateTree
Qt&Vtk-009-Cone4
Qt&Vtk-009-Cone4
121 0
Qt&Vtk-009-Cone4