File: TestMathTextActor3D.cxx

package info (click to toggle)
paraview 4.0.1-1~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 526,572 kB
  • sloc: cpp: 2,284,430; ansic: 816,374; python: 239,936; xml: 70,162; tcl: 48,295; fortran: 39,116; yacc: 5,466; java: 3,518; perl: 3,107; lex: 1,620; sh: 1,555; makefile: 932; asm: 471; pascal: 228
file content (92 lines) | stat: -rw-r--r-- 3,289 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    TestStringToPath.cxx

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/

#include "vtkTextActor3D.h"

#include "vtkCamera.h"
#include "vtkNew.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkTestingInteractor.h"
#include "vtkTextProperty.h"

//----------------------------------------------------------------------------
int TestMathTextActor3D(int, char *[])
{

  vtkNew<vtkTextActor3D> actor1;
  actor1->SetInput("$\\int\\frac{1}{\\left(x+a\\right)^2}dx = -\\frac{1}{x+a}$");
  actor1->GetTextProperty()->SetFontSize(36);
  actor1->GetTextProperty()->SetColor(0.8, 0.8, 0.6);
  actor1->SetPosition(-100, -25, 0);
  actor1->RotateWXYZ(70, 0, 1, 0);

  vtkNew<vtkTextActor3D> actor2;
  actor2->SetInput("$\\langle\\psi_i\\mid\\psi_j\\rangle = \\delta_{ij}$");
  actor2->GetTextProperty()->SetFontSize(40);
  actor2->SetPosition(20, 0, -200);
  actor2->RotateWXYZ(-70, 0, 1, 0);
  actor2->GetTextProperty()->SetColor(0.7, 0.3, 0.2);

  vtkNew<vtkTextActor3D> actor3;
  actor3->SetInput("$\\frac{d}{dx}\\left(\\frac{u(x)}{v(x)}\\right) = "
                   "\\frac{v\\frac{du}{dx} + u\\frac{dv}{dx}}{v^2}$");
  actor3->GetTextProperty()->SetFontSize(36);
  actor3->SetPosition(-125, 75, -100);
  actor3->RotateWXYZ(50, 1, .5, -.2);
  actor3->GetTextProperty()->SetColor(0.6, 0.5, 0.8);

  vtkNew<vtkTextActor3D> actor4;
  actor4->SetInput("$\\hat{H}\\psi = \\left(-\\frac{\\hbar}{2m}\\nabla^2"
                   " + V(r)\\right) \\psi = \\psi\\cdot E $");
  actor4->GetTextProperty()->SetFontSize(22);
  actor4->SetPosition(-75, -100, 25);
  actor4->RotateWXYZ(40, -.2, 1, .3);
  actor4->GetTextProperty()->SetColor(0.2, 0.6, 0.4);

  vtkNew<vtkTextActor3D> actor5;
  actor5->SetInput("$\\frac{d}{dx}\\left(f(x_0)\\right) = \\lim_{h \\to 0}"
                   "\\frac{f(x_0 + h) - f(x_0)}{h}$");
  actor5->GetTextProperty()->SetFontSize(40);
  actor5->GetTextProperty()->SetColor(1, 1, 1);
  actor5->SetPosition(-240, -110, -500);
  actor5->RotateWXYZ(-25, 1, 0, 1);

  vtkNew<vtkRenderer> ren;
  vtkNew<vtkRenderWindow> win;
  win->AddRenderer(ren.GetPointer());
  vtkNew<vtkRenderWindowInteractor> iren;
  iren->SetRenderWindow(win.GetPointer());

  ren->AddActor(actor1.GetPointer());
  ren->AddActor(actor2.GetPointer());
  ren->AddActor(actor3.GetPointer());
  ren->AddActor(actor4.GetPointer());
  ren->AddActor(actor5.GetPointer());

  ren->SetBackground(0.0, 0.0, 0.0);
  win->SetSize(600, 600);
  ren->GetActiveCamera()->SetPosition(0, 0, 400);
  ren->GetActiveCamera()->SetFocalPoint(0, 0, 0);
  ren->GetActiveCamera()->SetViewUp(0, 1, 0);
  ren->ResetCameraClippingRange();

  win->SetMultiSamples(0);
  win->GetInteractor()->Initialize();
  win->GetInteractor()->Start();

  return EXIT_SUCCESS;
}