[VTK] MFC์์ VTK ScalrBar ์ฌ์ฉํ๊ธฐ
์ด๋ฒ ํฌ์คํ ์์๋ VTK Window์ ScalarBar๋ฅผ ๋์ฐ๋ ์์ ๋ฅผ ์๊ฐํ๊ณ ์ ํฉ๋๋ค.
์๋ ๋งํฌ๋ VTK์์ ์ ๊ณตํ๋ ๊ณต์ ์์ ์ฌ์ดํธ์ ๋๋ค.
๋งํฌ: https://lorensen.github.io/VTKExamples/site/Cxx
๋์์ ์๋์ ๊ฐ์ต๋๋ค.
<MFC ScalarBar ์์ >
๋จผ์ ์์ ๋ ์๋ ๋งํฌ์์ ํ์ธํ ์ ์์ต๋๋ค.
๋งํฌ: https://lorensen.github.io/VTKExamples/site/Cxx/Visualization/ScalarBarActorColorSeries/
ScalarBar๋ Point Cloud Data์ Z์ถ ๋์ด ๋ฒ์์ ๋ฐ๋ผ ์์์ ์ ํ ๋, ๋์ด์ ๋ฒ์๋ฅผ ๋ณด์ฌ์ฃผ๊ธฐ ์ํด ์ฌ์ฉ๋ฉ๋๋ค.
์, ๋ณธ๊ฒฉ์ ์ผ๋ก ์์ ๋ง๋ค๊ธฐ๋ฅผ ์ค์ตํด ๋ณด๊ฒ ์ต๋๋ค.
(ํต์ฌ ๋ถ๋ถ๋ง ์ค๋ช
ํฉ๋๋ค. ์์ธํ ๋ด์ฉ์ ๋ณธ๋ฌธ ํ๋จ์ ์์ ์ฝ๋๋ฅผ ์ฐธ๊ณ ํด์ฃผ์ธ์.)
๋จผ์ Dialog ๊ธฐ๋ฐ์ผ๋ก ํ๋ก์ ํธ๋ฅผ ์์ฑํฉ๋๋ค.
๊ทธ๋ฆฌ๊ณ MFC์์ VTK ์ฌ์ฉ์ ์ํด ์๋ ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ์ฌ ์ค์ ํฉ๋๋ค.
1. VTK ์ด๊ธฐํ
Main Dialog header ํ์ผ์ ์๋์ ์ด๊ธฐํ ์ฝ๋๋ฅผ ์ถ๊ฐํฉ๋๋ค.
#pragma once
#include <vtkAutoInit.h>
#define vtkRenderingCore_AUTOINIT 3(vtkRenderingOpenGL2,vtkInteractionStyle, vtkRenderingFreeType)
#define vtkRenderingContext2D_AUTOINIT 1(vtkRenderingContextOpenGL2)
#include <vtkActor.h>
#include <vtkFloatArray.h>
#include <vtkLookupTable.h>
#include <vtkPointData.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkScalarBarActor.h>
#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>
#include <vtkColorSeries.h>
#include <vtkNamedColors.h>
2. Picture Control์ ๊ทธ๋ ค์ง vtkRenderWindow๋ฅผ ์ด๊ธฐํํฉ๋๋ค.
<Header File>
public :
vtkNew<vtkRenderWindow> m_vtkRenderWindow;
void InitializeVTKWindow(void* hWnd);
void ResizeVTKWindow();
<Source File>
void CExampleBarChartDlg::InitializeVTKWindow(void* hWnd)
{
vtkNewGetClientRect(rc);
m_vtkRenderWindow->SetSize(rc.Width(), rc.Height());
}
3. Button Event์ ScalarBar data๋ฅผ ๋ถ๋ฌ์ค๋ ์ฝ๋๋ฅผ ์ ์ํฉ๋๋ค.
void CExampleScalarBarDlg::OnBnClickedBtnInitScalar()
{
vtkNew<vtkNamedColors> colors;
// Create a sphere fora some geometry
vtkNew<vtkSphereSource> sphere;
sphere->SetCenter(0, 0, 0);
sphere->SetRadius(1);
sphere->SetPhiResolution(30);
sphere->SetThetaResolution(60);
sphere->Update();
// Create scalar data to associate with the vertices of the sphere
int numPts = sphere->GetOutput()->GetPoints()->GetNumberOfPoints();
vtkNew<vtkFloatArray> scalars;
scalars->SetNumberOfValues(numPts);
for (int i = 0; i < numPts; ++i)
{
scalars->SetValue(i, static_cast<float>(i) / numPts);
}
vtkNew<vtkPolyData> poly;
poly->DeepCopy(sphere->GetOutput());
poly->GetPointData()->SetScalars(scalars);
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputData(poly);
mapper->ScalarVisibilityOn();
mapper->SetScalarModeToUsePointData();
mapper->SetColorModeToMapScalars();
vtkNew<vtkActor> actor;
actor->SetMapper(mapper);
actor->GetProperty()->SetInterpolationToFlat();
vtkNew<vtkScalarBarActor> scalarBar;
scalarBar->SetLookupTable(mapper->GetLookupTable());
scalarBar->SetTitle("Beachball");
scalarBar->SetNumberOfLabels(4);
// Create a lookup table to share between the mapper and the scalarbar
vtkNew<vtkLookupTable> seriesLut;
vtkNew<vtkColorSeries> series;
int seriesEnum = series->BREWER_QUALITATIVE_SET3;
series->SetColorScheme(seriesEnum);
series->BuildLookupTable(seriesLut, series->ORDINAL);
mapper->SetLookupTable(seriesLut);
scalarBar->SetLookupTable(seriesLut);
// Create an interactor
vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
renderWindowInteractor->SetRenderWindow(m_vtkRenderWindow);
vtkNew<vtkRenderer> renderer;
renderer->AddActor(actor);
renderer->AddActor2D(scalarBar);
renderer->GradientBackgroundOn();
renderer->SetBackground(.1, .2, .3);
renderer->ResetCamera();
m_vtkRenderWindow->AddRenderer(renderer);
m_vtkRenderWindow->Render();
renderer->ResetCamera();
m_vtkRenderWindow->Render();
}
๊ธฐ๋ณธ C++ ์์ ์ฝ๋๋ฅผ MFC Dialog ํ๋ก์ ํธ๋ก ๋ณ๊ฒฝํ ๊ฒ ๋ฐ์ ์์ผ๋ ๊ฐ๋จํ์ฃ ?
์์ธํ ๋ด์ฉ์ ์ฒจ๋ถ๋ ์ฝ๋๋ฅผ ์ฐธ๊ณ ํด์ฃผ์ธ์.
'Programming > VTK' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[VTK] MFC์์ VTK ๋ง์ฐ์ค ์ผ์ชฝ ํด๋ฆญ ์ด๋ฒคํธ ๋ฐ ์ขํ ์ ๋ณด ์ป๊ธฐ (0) | 2019.07.01 |
---|---|
[VTK] MFC์์ VTK 3D ๋ชจ๋ธ ํ์ผ ๋ถ๋ฌ์ Renderingํ๊ธฐ (3) | 2019.06.08 |
[VTK] MFC์์ VTK 2D Line Plot ์ฌ์ฉํ๊ธฐ (5) | 2019.05.30 |
[VTK] MFC์์ VTK 2D Bar ์ฐจํธ ์ฌ์ฉํ๊ธฐ (0) | 2019.05.28 |
[VTK] Visual Studio 2015 MFC์์ VTK ์ฌ์ฉ ์ค๋นํ๊ธฐ (9) | 2019.05.26 |
[VTK] VTK 8.2 ๋ฐ Visual Studio 2015 ํ๊ฒฝ ๊ตฌ์ฑ (22) | 2019.05.15 |
[VTK] VTK SDK ์๊ฐ (2) | 2019.05.13 |
๋๊ธ
์ด ๊ธ ๊ณต์ ํ๊ธฐ
-
๊ตฌ๋
ํ๊ธฐ
๊ตฌ๋ ํ๊ธฐ
-
์นด์นด์คํก
์นด์นด์คํก
-
๋ผ์ธ
๋ผ์ธ
-
ํธ์ํฐ
ํธ์ํฐ
-
Facebook
Facebook
-
์นด์นด์ค์คํ ๋ฆฌ
์นด์นด์ค์คํ ๋ฆฌ
-
๋ฐด๋
๋ฐด๋
-
๋ค์ด๋ฒ ๋ธ๋ก๊ทธ
๋ค์ด๋ฒ ๋ธ๋ก๊ทธ
-
Pocket
Pocket
-
Evernote
Evernote
๋ค๋ฅธ ๊ธ
-
[VTK] MFC์์ VTK ๋ง์ฐ์ค ์ผ์ชฝ ํด๋ฆญ ์ด๋ฒคํธ ๋ฐ ์ขํ ์ ๋ณด ์ป๊ธฐ
[VTK] MFC์์ VTK ๋ง์ฐ์ค ์ผ์ชฝ ํด๋ฆญ ์ด๋ฒคํธ ๋ฐ ์ขํ ์ ๋ณด ์ป๊ธฐ
2019.07.01 -
[VTK] MFC์์ VTK 3D ๋ชจ๋ธ ํ์ผ ๋ถ๋ฌ์ Renderingํ๊ธฐ
[VTK] MFC์์ VTK 3D ๋ชจ๋ธ ํ์ผ ๋ถ๋ฌ์ Renderingํ๊ธฐ
2019.06.08 -
[VTK] MFC์์ VTK 2D Line Plot ์ฌ์ฉํ๊ธฐ
[VTK] MFC์์ VTK 2D Line Plot ์ฌ์ฉํ๊ธฐ
2019.05.30 -
[VTK] MFC์์ VTK 2D Bar ์ฐจํธ ์ฌ์ฉํ๊ธฐ
[VTK] MFC์์ VTK 2D Bar ์ฐจํธ ์ฌ์ฉํ๊ธฐ
2019.05.28