Path: blob/devel/ElmerGUI/Application/vtkpost/axes.cpp
3203 views
/*****************************************************************************1* *2* Elmer, A Finite Element Software for Multiphysical Problems *3* *4* Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland *5* *6* This program is free software; you can redistribute it and/or *7* modify it under the terms of the GNU General Public License *8* as published by the Free Software Foundation; either version 2 *9* of the License, or (at your option) any later version. *10* *11* This program is distributed in the hope that it will be useful, *12* but WITHOUT ANY WARRANTY; without even the implied warranty of *13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *14* GNU General Public License for more details. *15* *16* You should have received a copy of the GNU General Public License *17* along with this program (in file fem/GPL-2); if not, write to the *18* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, *19* Boston, MA 02110-1301, USA. *20* *21*****************************************************************************/2223/*****************************************************************************24* *25* ElmerGUI axes *26* *27*****************************************************************************28* *29* Authors: Mikko Lyly, Juha Ruokolainen and Peter R�back *30* Email: [email protected] *31* Web: http://www.csc.fi/elmer *32* Address: CSC - IT Center for Science Ltd. *33* Keilaranta 14 *34* 02101 Espoo, Finland *35* *36* Original Date: 15 Mar 2008 *37* *38*****************************************************************************/3940#include <QtGui>41#include <iostream>42#include "vtkpost.h"43#include "axes.h"4445#include <vtkAxes.h>46#include <vtkTubeFilter.h>47#include <vtkPolyDataMapper.h>48#include <vtkActor.h>49#include <vtkFollower.h>50#include <vtkVectorText.h>51#include <vtkProperty.h>5253using namespace std;5455Axes::Axes(QWidget *parent)56: QDialog(parent)57{58ui.setupUi(this);5960setWindowTitle("Coordinate axes");61setWindowIcon(QIcon(":/icons/Mesh3D.png"));62}6364Axes::~Axes()65{66}6768void Axes::draw(VtkPost* vtkPost)69{70double scl = vtkPost->GetLength() / 8.0;7172vtkAxes* axes = vtkAxes::New();73axes->SetOrigin(0, 0, 0);74axes->SetScaleFactor(scl);7576vtkTubeFilter* axesTubes = vtkTubeFilter::New();77axesTubes->SetInputConnection(axes->GetOutputPort());78axesTubes->SetRadius(axes->GetScaleFactor() / 33.0);79axesTubes->SetNumberOfSides(20);8081vtkPolyDataMapper* axesMapper = vtkPolyDataMapper::New();82axesMapper->SetInputConnection(axesTubes->GetOutputPort());8384vtkPost->GetAxesActor()->SetMapper(axesMapper);8586vtkVectorText* XText = vtkVectorText::New();87vtkVectorText* YText = vtkVectorText::New();88vtkVectorText* ZText = vtkVectorText::New();8990XText->SetText("X");91YText->SetText("Y");92ZText->SetText("Z");9394vtkPolyDataMapper* XTextPolyDataMapper = vtkPolyDataMapper::New();95vtkPolyDataMapper* YTextPolyDataMapper = vtkPolyDataMapper::New();96vtkPolyDataMapper* ZTextPolyDataMapper = vtkPolyDataMapper::New();9798XTextPolyDataMapper->SetInputConnection(XText->GetOutputPort());99YTextPolyDataMapper->SetInputConnection(YText->GetOutputPort());100ZTextPolyDataMapper->SetInputConnection(ZText->GetOutputPort());101102vtkPost->GetAxesXTextActor()->SetMapper(XTextPolyDataMapper);103vtkPost->GetAxesYTextActor()->SetMapper(YTextPolyDataMapper);104vtkPost->GetAxesZTextActor()->SetMapper(ZTextPolyDataMapper);105106scl = axes->GetScaleFactor() / 5.0;107108vtkPost->GetAxesXTextActor()->SetScale(scl, scl, scl);109vtkPost->GetAxesYTextActor()->SetScale(scl, scl, scl);110vtkPost->GetAxesZTextActor()->SetScale(scl, scl, scl);111112scl = axes->GetScaleFactor();113114vtkPost->GetAxesXTextActor()->SetPosition(scl, 0.0, 0.0);115vtkPost->GetAxesYTextActor()->SetPosition(0.0, scl, 0.0);116vtkPost->GetAxesZTextActor()->SetPosition(0.0, 0.0, scl);117118vtkPost->GetAxesXTextActor()->GetProperty()->SetColor(0, 0, 0);119vtkPost->GetAxesYTextActor()->GetProperty()->SetColor(0, 0, 0);120vtkPost->GetAxesZTextActor()->GetProperty()->SetColor(0, 0, 0);121122// Clean up:123//----------124XTextPolyDataMapper->Delete();125YTextPolyDataMapper->Delete();126ZTextPolyDataMapper->Delete();127XText->Delete();128YText->Delete();129ZText->Delete();130axesTubes->Delete();131axesMapper->Delete();132axes->Delete();133}134135136