Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/ElmerGUI/Application/vtkpost/axes.cpp
3203 views
1
/*****************************************************************************
2
* *
3
* Elmer, A Finite Element Software for Multiphysical Problems *
4
* *
5
* Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland *
6
* *
7
* This program is free software; you can redistribute it and/or *
8
* modify it under the terms of the GNU General Public License *
9
* as published by the Free Software Foundation; either version 2 *
10
* of the License, or (at your option) any later version. *
11
* *
12
* This program is distributed in the hope that it will be useful, *
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
* GNU General Public License for more details. *
16
* *
17
* You should have received a copy of the GNU General Public License *
18
* along with this program (in file fem/GPL-2); if not, write to the *
19
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *
20
* Boston, MA 02110-1301, USA. *
21
* *
22
*****************************************************************************/
23
24
/*****************************************************************************
25
* *
26
* ElmerGUI axes *
27
* *
28
*****************************************************************************
29
* *
30
* Authors: Mikko Lyly, Juha Ruokolainen and Peter R�back *
31
* Email: [email protected] *
32
* Web: http://www.csc.fi/elmer *
33
* Address: CSC - IT Center for Science Ltd. *
34
* Keilaranta 14 *
35
* 02101 Espoo, Finland *
36
* *
37
* Original Date: 15 Mar 2008 *
38
* *
39
*****************************************************************************/
40
41
#include <QtGui>
42
#include <iostream>
43
#include "vtkpost.h"
44
#include "axes.h"
45
46
#include <vtkAxes.h>
47
#include <vtkTubeFilter.h>
48
#include <vtkPolyDataMapper.h>
49
#include <vtkActor.h>
50
#include <vtkFollower.h>
51
#include <vtkVectorText.h>
52
#include <vtkProperty.h>
53
54
using namespace std;
55
56
Axes::Axes(QWidget *parent)
57
: QDialog(parent)
58
{
59
ui.setupUi(this);
60
61
setWindowTitle("Coordinate axes");
62
setWindowIcon(QIcon(":/icons/Mesh3D.png"));
63
}
64
65
Axes::~Axes()
66
{
67
}
68
69
void Axes::draw(VtkPost* vtkPost)
70
{
71
double scl = vtkPost->GetLength() / 8.0;
72
73
vtkAxes* axes = vtkAxes::New();
74
axes->SetOrigin(0, 0, 0);
75
axes->SetScaleFactor(scl);
76
77
vtkTubeFilter* axesTubes = vtkTubeFilter::New();
78
axesTubes->SetInputConnection(axes->GetOutputPort());
79
axesTubes->SetRadius(axes->GetScaleFactor() / 33.0);
80
axesTubes->SetNumberOfSides(20);
81
82
vtkPolyDataMapper* axesMapper = vtkPolyDataMapper::New();
83
axesMapper->SetInputConnection(axesTubes->GetOutputPort());
84
85
vtkPost->GetAxesActor()->SetMapper(axesMapper);
86
87
vtkVectorText* XText = vtkVectorText::New();
88
vtkVectorText* YText = vtkVectorText::New();
89
vtkVectorText* ZText = vtkVectorText::New();
90
91
XText->SetText("X");
92
YText->SetText("Y");
93
ZText->SetText("Z");
94
95
vtkPolyDataMapper* XTextPolyDataMapper = vtkPolyDataMapper::New();
96
vtkPolyDataMapper* YTextPolyDataMapper = vtkPolyDataMapper::New();
97
vtkPolyDataMapper* ZTextPolyDataMapper = vtkPolyDataMapper::New();
98
99
XTextPolyDataMapper->SetInputConnection(XText->GetOutputPort());
100
YTextPolyDataMapper->SetInputConnection(YText->GetOutputPort());
101
ZTextPolyDataMapper->SetInputConnection(ZText->GetOutputPort());
102
103
vtkPost->GetAxesXTextActor()->SetMapper(XTextPolyDataMapper);
104
vtkPost->GetAxesYTextActor()->SetMapper(YTextPolyDataMapper);
105
vtkPost->GetAxesZTextActor()->SetMapper(ZTextPolyDataMapper);
106
107
scl = axes->GetScaleFactor() / 5.0;
108
109
vtkPost->GetAxesXTextActor()->SetScale(scl, scl, scl);
110
vtkPost->GetAxesYTextActor()->SetScale(scl, scl, scl);
111
vtkPost->GetAxesZTextActor()->SetScale(scl, scl, scl);
112
113
scl = axes->GetScaleFactor();
114
115
vtkPost->GetAxesXTextActor()->SetPosition(scl, 0.0, 0.0);
116
vtkPost->GetAxesYTextActor()->SetPosition(0.0, scl, 0.0);
117
vtkPost->GetAxesZTextActor()->SetPosition(0.0, 0.0, scl);
118
119
vtkPost->GetAxesXTextActor()->GetProperty()->SetColor(0, 0, 0);
120
vtkPost->GetAxesYTextActor()->GetProperty()->SetColor(0, 0, 0);
121
vtkPost->GetAxesZTextActor()->GetProperty()->SetColor(0, 0, 0);
122
123
// Clean up:
124
//----------
125
XTextPolyDataMapper->Delete();
126
YTextPolyDataMapper->Delete();
127
ZTextPolyDataMapper->Delete();
128
XText->Delete();
129
YText->Delete();
130
ZText->Delete();
131
axesTubes->Delete();
132
axesMapper->Delete();
133
axes->Delete();
134
}
135
136